00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H
00045 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H
00046
00047 #include "../util/pyobject_plus.h"
00048 #include "../util/py_tuple.h"
00049
00050 #endif
00051
00052 namespace lass
00053 {
00054 namespace python
00055 {
00056
00057
00058
00059 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_POINT
00060 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_POINT
00061
00062
00063
00064
00065 template <typename ObjectType, typename ExportTraits>
00066 struct PyExportTraitsVectorPoint
00067 {
00068 enum { dimension = ObjectType::dimension };
00069 static PyObject* build(const ObjectType& iV)
00070 {
00071 PyObject* const tuple = PyTuple_New(dimension);
00072 for (int i = 0; i < dimension; ++i)
00073 {
00074 PyTuple_SetItem(tuple, i, pyBuildSimpleObject(iV[i]));
00075 }
00076 return tuple;
00077 }
00078
00079 static int get(PyObject* iValue, ObjectType& oV)
00080 {
00081 const TPyObjPtr tuple = impl::checkedFastSequence(iValue, dimension);
00082 if (!tuple)
00083 {
00084 impl::addMessageHeader(ExportTraits::className());
00085 return 1;
00086 }
00087 PyObject** objects = PySequence_Fast_ITEMS(tuple.get());
00088 ObjectType result;
00089 for (int k = 0; k < dimension; ++k)
00090 {
00091 if (!impl::decodeObject(objects[k], result[k], k + 1))
00092 {
00093 impl::addMessageHeader(ExportTraits::className());
00094 return 1;
00095 }
00096 }
00097 oV = result;
00098 return 0;
00099 }
00100 };
00101
00102 #endif
00103
00104
00105 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_VECTOR_2D)
00106 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_2D
00107 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_2D
00108
00109
00110
00111
00112 template <typename T>
00113 struct PyExportTraits< prim::Vector2D<T> >:
00114 public PyExportTraitsVectorPoint< prim::Vector2D<T>, PyExportTraits< prim::Vector2D<T> > >
00115 {
00116 static const char* className() { return "Vector2D"; }
00117 };
00118
00119 # endif
00120 #endif
00121
00122
00123
00124 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_VECTOR_3D)
00125 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_3D
00126 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_3D
00127
00128
00129
00130
00131 template <typename T>
00132 struct PyExportTraits< prim::Vector3D<T> >:
00133 public PyExportTraitsVectorPoint< prim::Vector3D<T>, PyExportTraits< prim::Vector3D<T> > >
00134 {
00135 static const char* className() { return "Vector3D"; }
00136 };
00137
00138 # endif
00139 #endif
00140
00141
00142 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_VECTOR_4D)
00143 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_4D
00144 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_VECTOR_4D
00145
00146
00147
00148
00149 template <typename T>
00150 struct PyExportTraits< prim::Vector4D<T> >:
00151 public PyExportTraitsVectorPoint< prim::Vector4D<T>, PyExportTraits< prim::Vector4D<T> > >
00152 {
00153 static const char* className() { return "Vector4D"; }
00154 };
00155
00156 # endif
00157 #endif
00158
00159
00160
00161
00162
00163 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_POINT_2D)
00164 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_POINT_2D
00165 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_POINT_2D
00166
00167
00168
00169
00170 template <typename T>
00171 struct PyExportTraits< prim::Point2D<T> >:
00172 public PyExportTraitsVectorPoint< prim::Point2D<T>, PyExportTraits< prim::Point2D<T> > >
00173 {
00174 static const char* className() { return "Point2D"; }
00175 };
00176
00177 # endif
00178 #endif
00179
00180
00181
00182 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_POINT_3D)
00183 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_POINT_3D
00184 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_POINT_3D
00185
00186
00187
00188
00189 template <typename T>
00190 struct PyExportTraits< prim::Point3D<T> >:
00191 public PyExportTraitsVectorPoint< prim::Point3D<T>, PyExportTraits< prim::Point3D<T> > >
00192 {
00193 static const char* className() { return "Point3D"; }
00194 };
00195
00196 # endif
00197 #endif
00198
00199
00200
00201
00202
00203 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB
00204 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB
00205
00206
00207
00208
00209 template < typename AabbType, typename ExportTraits >
00210 struct PyExportTraitsPrimAabb
00211 {
00212 typedef AabbType TAabb;
00213 static PyObject* build(const TAabb& iV)
00214 {
00215 return fromSharedPtrToNakedCast(makeTuple(iV.min(), iV.max()));
00216 }
00217 static int get(PyObject* iValue, TAabb& oV)
00218 {
00219 typename TAabb::TPoint min, max;
00220 if (decodeTuple(iValue, min, max) != 0)
00221 {
00222 impl::addMessageHeader(ExportTraits::className());
00223 return 1;
00224 }
00225 try
00226 {
00227 oV = TAabb(min, max);
00228 }
00229 catch (util::Exception& error)
00230 {
00231 std::ostringstream buffer;
00232 buffer << ExportTraits::className() << ": " << error.message();
00233 PyErr_SetString(PyExc_ValueError, buffer.str().c_str());
00234 return 1;
00235 }
00236 return 0;
00237 }
00238 };
00239
00240 #endif
00241
00242 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_AABB_2D)
00243 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB_2D
00244 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB_2D
00245
00246
00247
00248
00249 template <typename T, typename MMP>
00250 struct PyExportTraits< prim::Aabb2D<T, MMP> >:
00251 public PyExportTraitsPrimAabb< prim::Aabb2D<T, MMP>, PyExportTraits< prim::Aabb2D<T, MMP> > >
00252 {
00253 static const char* className() { return "Aabb2D"; }
00254 };
00255
00256 # endif
00257 #endif
00258
00259 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_AABB_3D)
00260 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB_3D
00261 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AABB_3D
00262
00263
00264
00265
00266 template <typename T, typename MMP>
00267 struct PyExportTraits< prim::Aabb3D<T, MMP> >:
00268 public PyExportTraitsPrimAabb< prim::Aabb3D<T, MMP>, PyExportTraits< prim::Aabb3D<T, MMP> > >
00269 {
00270 static const char* className() { return "Aabb3D"; }
00271 };
00272
00273 # endif
00274 #endif
00275
00276
00277
00278
00279
00280 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT
00281 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT
00282
00283
00284
00285
00286 template < typename LineSegmentType, typename ExportTraits >
00287 struct PyExportTraitsPrimLineSegment
00288 {
00289 typedef LineSegmentType TLineSegment;
00290 static PyObject* build(const TLineSegment& iV)
00291 {
00292 return fromSharedPtrToNakedCast(makeTuple(iV.tail(), iV.head()));
00293 }
00294 static int get(PyObject* iValue, TLineSegment& oV)
00295 {
00296 typename TLineSegment::TPoint tail, head;
00297 if (decodeTuple(iValue, tail, head) != 0)
00298 {
00299 impl::addMessageHeader(ExportTraits::className());
00300 return 1;
00301 }
00302 oV = TLineSegment(tail, head);
00303 return 0;
00304 }
00305 };
00306
00307 #endif
00308
00309 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_LINE_SEGMENT_2D)
00310 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT_2D
00311 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT_2D
00312
00313
00314
00315
00316 template <typename T, typename PP>
00317 struct PyExportTraits< prim::LineSegment2D<T, PP> >:
00318 public PyExportTraitsPrimLineSegment< prim::LineSegment2D<T, PP>, PyExportTraits< prim::LineSegment2D<T, PP> > >
00319 {
00320 static const char* className() { return "LineSegment2D"; }
00321 };
00322
00323 # endif
00324 #endif
00325
00326 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_LINE_SEGMENT_3D)
00327 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT_3D
00328 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_LINE_SEGMENT_3D
00329
00330
00331
00332
00333 template <typename T, typename PP>
00334 struct PyExportTraits< prim::LineSegment3D<T, PP> >:
00335 public PyExportTraitsPrimLineSegment< prim::LineSegment3D<T, PP>, PyExportTraits< prim::LineSegment3D<T, PP> > >
00336 {
00337 static const char* className() { return "LineSegment3D"; }
00338 };
00339
00340 # endif
00341 #endif
00342
00343
00344
00345 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION
00346 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION
00347
00348
00349
00350
00351 template <typename TransformationType, typename ExporTraits>
00352 struct PyExportTraitsPrimTransformation
00353 {
00354 typedef TransformationType TTransformation;
00355 typedef typename TransformationType::TValue TValue;
00356 enum { size = TransformationType::dimension + 1 };
00357
00358 static PyObject* build(const TTransformation& iV)
00359 {
00360 const TValue* const v = iV.matrix();
00361 PyObject* const matrix = PyTuple_New(size);
00362 for (int i = 0; i < size; ++i)
00363 {
00364 PyObject* const row = PyTuple_New(size);
00365 for (int j = 0; j < size; ++j)
00366 {
00367 PyTuple_SetItem(row, j, pyBuildSimpleObject(v[i * size + j]));
00368 }
00369 PyTuple_SetItem(matrix, i, row);
00370 }
00371 return matrix;
00372 }
00373
00374 static int get(PyObject* iValue, TTransformation& oV)
00375 {
00376 TPyObjPtr tuple = impl::checkedFastSequence(iValue, size);
00377 if (!tuple)
00378 {
00379 impl::addMessageHeader(ExporTraits::className());
00380 return 1;
00381 }
00382 PyObject** rows = PySequence_Fast_ITEMS(tuple.get());
00383 TValue values[size * size];
00384 for (int i = 0; i < size; ++i)
00385 {
00386 TPyObjPtr row = impl::checkedFastSequence(rows[i], size);
00387 if (!row)
00388 {
00389 std::ostringstream buffer;
00390 buffer << ExporTraits::className() << ": row " << i;
00391 impl::addMessageHeader(buffer.str());
00392 return 1;
00393 }
00394 PyObject** objects = PySequence_Fast_ITEMS(row.get());
00395 for (int j = 0; j < size; ++j)
00396 {
00397 if (pyGetSimpleObject(objects[j], values[size * i + j]) != 0)
00398 {
00399 std::ostringstream buffer;
00400 buffer << ExporTraits::className() << ": row " << i << ", column " << j;
00401 impl::addMessageHeader(buffer.str());
00402 return 1;
00403 }
00404 }
00405 }
00406 oV = TTransformation(values, values + size * size);
00407 return 0;
00408 }
00409 };
00410
00411 #endif
00412
00413 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_TRANSFORMATION_2D)
00414 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION_2D
00415 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION_2D
00416
00417
00418
00419
00420 template <typename T>
00421 struct PyExportTraits< prim::Transformation2D<T> >:
00422 public PyExportTraitsPrimTransformation< prim::Transformation2D<T>, PyExportTraits< prim::Transformation2D<T> > >
00423 {
00424 static const char* className() { return "Transformation2D"; }
00425 };
00426
00427 # endif
00428 #endif
00429
00430 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_TRANSFORMATION_3D)
00431 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION_3D
00432 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_TRANSFORMATION_3D
00433
00434
00435
00436
00437 template <typename T>
00438 struct PyExportTraits< prim::Transformation3D<T> >:
00439 public PyExportTraitsPrimTransformation< prim::Transformation3D<T>, PyExportTraits< prim::Transformation3D<T> > >
00440 {
00441 static const char* className() { return "Transformation3D"; }
00442 };
00443
00444 # endif
00445 #endif
00446
00447
00448
00449
00450 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON
00451 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON
00452
00453
00454
00455
00456 template <typename PolygonType, typename ExportTraits>
00457 struct PyExportTraitsPrimSimplePolygon
00458 {
00459 typedef PolygonType TPolygon;
00460 typedef typename PolygonType::TPoint TPoint;
00461 static PyObject* build(const TPolygon& iV)
00462 {
00463 std::vector<TPoint> points;
00464 for (unsigned i = 0; i < iV.size(); ++i)
00465 points.push_back(iV[i]);
00466 return pyBuildSimpleObject( points );
00467 }
00468 static int get(PyObject* iValue, TPolygon& oV)
00469 {
00470 std::vector<TPoint> points;
00471 int rv = pyGetSimpleObject(iValue, points);
00472 if (rv)
00473 {
00474 impl::addMessageHeader(ExportTraits::className());
00475 return 1;
00476 }
00477 oV = TPolygon(points.begin(), points.end());
00478 return 0;
00479 }
00480 };
00481
00482 #endif
00483
00484 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_SIMPLE_POLYGON_2D)
00485 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON_2D
00486 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON_2D
00487
00488
00489
00490
00491 template <typename T, typename DP>
00492 struct PyExportTraits< prim::SimplePolygon2D<T, DP> >:
00493 public PyExportTraitsPrimSimplePolygon< prim::SimplePolygon2D<T, DP>, PyExportTraits< prim::SimplePolygon2D<T, DP> > >
00494 {
00495 static const char* className() { return "SimplePolygon2D"; }
00496 };
00497
00498 # endif
00499 #endif
00500
00501
00502 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_SIMPLE_POLYGON_3D)
00503 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON_3D
00504 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_SIMPLE_POLYGON_3D
00505
00506
00507
00508
00509 template <typename T, typename DP>
00510 struct PyExportTraits< prim::SimplePolygon3D<T, DP> >:
00511 public PyExportTraitsPrimSimplePolygon< prim::SimplePolygon3D<T, DP>, PyExportTraits< prim::SimplePolygon3D<T, DP> > >
00512 {
00513 static const char* className() { return "SimplePolygon3D"; }
00514 };
00515
00516 # endif
00517 #endif
00518
00519
00520
00521 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AXIS
00522 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_AXIS
00523
00524
00525
00526
00527 template <typename AxisType, typename ExportTraits>
00528 struct PyExportTraitsPrimAxis
00529 {
00530 typedef AxisType TAxis;
00531 static PyObject* build(const TAxis& iV)
00532 {
00533 return pyBuildSimpleObject(std::string(1, iV.axis()));
00534 }
00535 static int get(PyObject* iValue, TAxis& oV)
00536 {
00537 std::string axis;
00538 if (pyGetSimpleObject(iValue, axis) != 0)
00539 {
00540 impl::addMessageHeader(ExportTraits::className());
00541 }
00542
00543 try
00544 {
00545 oV = TAxis(axis);
00546 }
00547 catch (util::Exception& error)
00548 {
00549 std::ostringstream buffer;
00550 buffer << ExportTraits::className() << ": " << error.message();
00551 PyErr_SetString(PyExc_ValueError, buffer.str().c_str());
00552 return 1;
00553 }
00554 return 0;
00555 }
00556 };
00557
00558 #endif
00559
00560 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_XY)
00561 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XY
00562 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XY
00563
00564
00565
00566
00567 template <>
00568 struct PyExportTraits<prim::XY>:
00569 public PyExportTraitsPrimAxis<prim::XY, PyExportTraits<prim::XY> >
00570 {
00571 static const char* className() { return "XY"; }
00572 };
00573
00574 # endif
00575 #endif
00576
00577 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_XYZ)
00578 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XYZ
00579 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XYZ
00580
00581
00582
00583
00584 template <>
00585 struct PyExportTraits<prim::XYZ>:
00586 public PyExportTraitsPrimAxis<prim::XYZ, PyExportTraits<prim::XYZ> >
00587 {
00588 static const char* className() { return "XYZ"; }
00589 };
00590
00591 # endif
00592 #endif
00593
00594 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_XYZW)
00595 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XYZW
00596 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_XYZW
00597
00598
00599
00600
00601 template <>
00602 struct PyExportTraits<prim::XYZW>:
00603 public PyExportTraitsPrimAxis<prim::XYZW, PyExportTraits<prim::XYZW> >
00604 {
00605 static const char* className() { return "XYWZ"; }
00606 };
00607
00608 # endif
00609 #endif
00610
00611
00612
00613 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_COLOR_RGBA)
00614 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_COLOR_RGBA
00615 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_COLOR_RGBA
00616
00617
00618
00619
00620 template <>
00621 struct PyExportTraits<prim::ColorRGBA>
00622 {
00623 static PyObject* build(const prim::ColorRGBA& iV)
00624 {
00625 return pyBuildSimpleObject(iV.vector());
00626 }
00627 static int get(PyObject* iValue, prim::ColorRGBA& oV)
00628 {
00629 TPyObjPtr tuple(PySequence_Fast(iValue, "ColorRGBA: expected a sequence (tuple, list, ...)"));
00630 if (!tuple)
00631 {
00632 return 1;
00633 }
00634 const Py_ssize_t size = PySequence_Fast_GET_SIZE(tuple.get());
00635 if (size != 3 && size != 4)
00636 {
00637 std::ostringstream buffer;
00638 buffer << "ColorRGBA: expected a sequence of size 3 or 4 (size is " << size << ")";
00639 PyErr_SetString(PyExc_TypeError, buffer.str().c_str());
00640 return 1;
00641 }
00642 PyObject** objects = PySequence_Fast_ITEMS(tuple.get());
00643 prim::ColorRGBA result;
00644 for (int k = 0; k < static_cast<int>(size); ++k)
00645 {
00646 if (!impl::decodeObject(objects[k], result[k], k + 1))
00647 {
00648 impl::addMessageHeader("ColorRGBA");
00649 return 1;
00650 }
00651 }
00652 oV = result;
00653 return 0;
00654 }
00655 };
00656
00657 # endif
00658 #endif
00659
00660
00661
00662 #if defined(LASS_PRIM_HAVE_PY_EXPORT_TRAITS_TRIANGLE_MESH_3D)
00663 # ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_INDEX_TRIANGLE
00664 # define LASS_GUARDIAN_OF_INCLUSION_PRIM_PYOBJECT_UTIL_H_INDEX_TRIANGLE
00665
00666 namespace impl
00667 {
00668 LASS_DLL PyObject* LASS_CALL buildIndexVertex(size_t iVertex, size_t iNormal, size_t iUv);
00669 LASS_DLL int LASS_CALL getIndexVertex(PyObject* iIndices, size_t& oVertex, size_t& oNormal, size_t& oUv);
00670 }
00671
00672
00673
00674
00675 template <>
00676 struct PyExportTraits<prim::IndexTriangle>
00677 {
00678 static PyObject* build(const prim::IndexTriangle& iTriangle)
00679 {
00680 TPyObjPtr triangle(PyTuple_New(3));
00681 if (!triangle) return 0;
00682 for (int k = 0; k < 3; ++k)
00683 {
00684 PyObject* vertex = impl::buildIndexVertex(
00685 iTriangle.vertices[k], iTriangle.normals[k], iTriangle.uvs[k]);
00686 if (!vertex) return 0;
00687 if (PyTuple_SetItem(triangle.get(), k, vertex) != 0) return 0;
00688 }
00689 return fromSharedPtrToNakedCast(triangle);
00690 }
00691 static int get(PyObject* iValue, prim::IndexTriangle& oTriangle)
00692 {
00693 const TPyObjPtr tuple(impl::checkedFastSequence(iValue, 3));
00694 if (!tuple)
00695 {
00696 impl::addMessageHeader("IndexTriangle");
00697 return 1;
00698 }
00699 PyObject** objects = PySequence_Fast_ITEMS(tuple.get());
00700 prim::IndexTriangle result = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
00701 for (int k = 0; k < 3; ++k)
00702 {
00703 if (impl::getIndexVertex(objects[k], result.vertices[k], result.normals[k], result.uvs[k]) != 0)
00704 {
00705 std::ostringstream buffer;
00706 buffer << "IndexTriangle: " << (k + 1) << "th vertex";
00707 impl::addMessageHeader(buffer.str());
00708 return 1;
00709 }
00710 }
00711 oTriangle = result;
00712 return 0;
00713 }
00714 };
00715
00716 # endif
00717 #endif
00718
00719 }
00720
00721 }
00722
00723