00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __PYTHONTYPES_H__
00030 #define __PYTHONTYPES_H__
00031
00032
00033 #include "Exception.h"
00034 #include "X3DTypes.h"
00035 #include "X3DFieldConversion.h"
00036 #include "Node.h"
00037 #include "H3DApi.h"
00038 #include "PyTypeWrapper.h"
00039
00040 #ifdef HAVE_PYTHON
00041
00042 #if defined(_MSC_VER)
00043
00044
00045
00046 #ifdef _DEBUG
00047 #define _DEBUG_UNDEFED
00048 #undef _DEBUG
00049 #endif
00050 #endif
00051 #if defined(__APPLE__) && defined(__MACH__)
00052 #include <Python/Python.h>
00053 #else
00054 #include <Python.h>
00055 #endif
00056 #if defined(_MSC_VER)
00057
00058 #ifdef _DEBUG_UNDEFED
00059 #define _DEBUG
00060 #endif
00061 #endif
00062
00063 namespace H3D {
00064
00065 class PyNodePtr {
00066 protected:
00067 Node *ptr;
00068 };
00069
00071
00073
00074 extern H3DAPI_API PyTypeObject PyNode_Type;
00077 inline string PyNode_Name() { return "Node"; }
00078
00080 PyObject *PyNode_FromNode( Node *v );
00081
00083 Node *PyNode_AsNode( PyObject *o );
00084
00086 inline bool PyNode_Check( PyObject *o) {
00087 return PyObject_TypeCheck(o,&PyNode_Type ) || o == Py_None;
00088 }
00089
00092 struct PyNode : public PyType, PyNodePtr {
00093
00095 inline void setNodePtr( Node *_ptr ) {
00096 if( ptr ) ptr->unref();
00097 ptr = _ptr;
00098 if( ptr ) ptr->ref();
00099 }
00100
00102 inline Node *nodePtr() {
00103 return ptr;
00104 }
00105
00106 static void installType( PyObject* H3D_module );
00107
00111 static PyObject* create();
00112
00114 static void dealloc( PyNode *self );
00115
00118 static int init(PyNode *self, PyObject *args, PyObject *kwds);
00119
00121 static PyObject* repr( PyNode *myself, PyObject *args);
00122
00125 static int compare( PyObject *veca, PyObject *vecb );
00126
00128 static PyObject* getField( PyObject *myself, char* arg );
00129
00131 static PyObject* getFieldList( PyObject *myself );
00132
00134 static PyObject* getName( PyObject *myself );
00135
00137 static PyObject* getTypeName( PyObject *myself );
00138
00140 static PyObject* setName( PyObject *self, PyObject *args );
00141
00143 static PyObject* getSingleField( PyObject *self, PyObject *args );
00144
00146 static PyObject* addField( PyObject *self, PyObject *args,
00147 PyObject *field_type, PyObject *access_type );
00148 };
00149
00151
00153
00154 extern H3DAPI_API PyTypeObject PyVec2f_Type;
00157 inline string PyVec2f_Name() { return "Vec2f"; }
00158
00160 PyObject *PyVec2f_FromVec2f( const Vec2f &v);
00161
00163 Vec2f PyVec2f_AsVec2f( PyObject *o );
00164
00166 inline bool PyVec2f_Check( PyObject *o) {
00167 return PyObject_TypeCheck(o,&PyVec2f_Type);
00168 }
00169
00172 struct PyVec2f :
00173 public PyVecTypeWrapper< Vec2f,
00174 &PyVec2f_Type,
00175 PyVec2f_Name,
00176 PyVec2f_Check,
00177 PyVec2f_AsVec2f,
00178 PyVec2f_FromVec2f >{
00179
00182 static int init(PyVec2f *self, PyObject *args, PyObject *kwds);
00183
00185 static PyObject* length( PyObject *self, PyObject *args );
00186
00188 static PyObject* lengthSqr( PyObject *self, PyObject *args );
00189
00191 static PyObject* normalize( PyObject *self, PyObject *args );
00192
00195 static PyObject* normalizeSafe( PyObject *self, PyObject *args );
00196
00198 static PyObject* dotProduct( PyObject *self, PyObject *args );
00199
00200 };
00201
00203
00205
00206 extern H3DAPI_API PyTypeObject PyVec2d_Type;
00209 inline string PyVec2d_Name() { return "Vec2d"; }
00210
00212 PyObject *PyVec2d_FromVec2d( const Vec2d &v);
00213
00215 Vec2d PyVec2d_AsVec2d( PyObject *o );
00216
00218 inline bool PyVec2d_Check( PyObject *o) {
00219 return PyObject_TypeCheck(o,&PyVec2d_Type);
00220 }
00221
00222 namespace PythonInternals {
00224 inline bool PyVec2d2f_Check( PyObject *o) {
00225 return PyObject_TypeCheck(o,&PyVec2d_Type) ||
00226 PyObject_TypeCheck( o, &PyVec2f_Type );
00227 }
00228
00230 Vec2d PyVec2d2f_AsVec2d( PyObject *o );
00231 }
00232
00235
00236
00237
00238 struct PyVec2d :
00239 public PyVecTypeWrapper< Vec2d,
00240 &PyVec2d_Type,
00241 PyVec2d_Name,
00242 PythonInternals::PyVec2d2f_Check,
00243 PythonInternals::PyVec2d2f_AsVec2d,
00244 PyVec2d_FromVec2d >{
00245
00248 static int init(PyVec2d *self, PyObject *args, PyObject *kwds);
00249
00251 static PyObject* length( PyObject *self, PyObject *args );
00252
00254 static PyObject* lengthSqr( PyObject *self, PyObject *args );
00255
00257 static PyObject* normalize( PyObject *self, PyObject *args );
00258
00261 static PyObject* normalizeSafe( PyObject *self, PyObject *args );
00262
00264 static PyObject* dotProduct( PyObject *self, PyObject *args );
00265 };
00266
00268
00270
00271 extern H3DAPI_API PyTypeObject PyVec3f_Type;
00272
00275 inline string PyVec3f_Name() { return "Vec3f"; }
00276
00278 PyObject *PyVec3f_FromVec3f( const Vec3f &v);
00279
00281 Vec3f PyVec3f_AsVec3f( PyObject *o );
00282
00284 inline bool PyVec3f_Check( PyObject *o) {
00285 return PyObject_TypeCheck(o,&PyVec3f_Type);
00286 }
00287
00290 struct PyVec3f :
00291 public PyVecTypeWrapper< Vec3f,
00292 &PyVec3f_Type,
00293 PyVec3f_Name,
00294 PyVec3f_Check,
00295 PyVec3f_AsVec3f,
00296 PyVec3f_FromVec3f > {
00297
00300 static int init(PyVec3f *self, PyObject *args, PyObject *kwds);
00301
00303 static PyObject* mod( PyObject *veca, PyObject *vecb );
00304
00306 static PyObject* length( PyObject *self, PyObject *args );
00307
00309 static PyObject* lengthSqr( PyObject *self, PyObject *args );
00310
00312 static PyObject* normalize( PyObject *self, PyObject *args );
00313
00316 static PyObject* normalizeSafe( PyObject *self, PyObject *args );
00317
00319 static PyObject* dotProduct( PyObject *self, PyObject *args );
00320
00322 static PyObject* crossProduct( PyObject *self, PyObject *args );
00323
00324 };
00325
00327
00329
00330 extern H3DAPI_API PyTypeObject PyVec3d_Type;
00331
00334 inline string PyVec3d_Name() { return "Vec3d"; }
00335
00337 PyObject *PyVec3d_FromVec3d( const Vec3d &v);
00338
00340 Vec3d PyVec3d_AsVec3d( PyObject *o );
00341
00343 inline bool PyVec3d_Check( PyObject *o) {
00344 return PyObject_TypeCheck(o,&PyVec3d_Type);
00345 }
00346
00347 namespace PythonInternals {
00349 inline bool PyVec3d3f_Check( PyObject *o) {
00350 return PyObject_TypeCheck(o,&PyVec3d_Type) ||
00351 PyObject_TypeCheck( o, &PyVec3f_Type );
00352 }
00353
00355 Vec3d PyVec3d3f_AsVec3d( PyObject *o );
00356 }
00357
00360
00361
00362
00363 struct PyVec3d : public PyVecTypeWrapper< Vec3d,
00364 &PyVec3d_Type,
00365 PyVec3d_Name,
00366 PythonInternals::PyVec3d3f_Check,
00367 PythonInternals::PyVec3d3f_AsVec3d,
00368 PyVec3d_FromVec3d > {
00371 static int init(PyVec3d *self, PyObject *args, PyObject *kwds);
00372 static PyObject* mod( PyObject *veca, PyObject *vecb );
00374 static PyObject* length( PyObject *self, PyObject *args );
00376 static PyObject* lengthSqr( PyObject *self, PyObject *args );
00378 static PyObject* normalize( PyObject *self, PyObject *args );
00381 static PyObject* normalizeSafe( PyObject *self, PyObject *args );
00383 static PyObject* dotProduct( PyObject *self, PyObject *args );
00384
00386 static PyObject* crossProduct( PyObject *self, PyObject *args );
00387 };
00388
00390
00392
00393 extern H3DAPI_API PyTypeObject PyVec4f_Type;
00394
00397 inline string PyVec4f_Name() { return "Vec4f"; }
00398
00400 PyObject *PyVec4f_FromVec4f( const Vec4f &v);
00401
00403 Vec4f PyVec4f_AsVec4f( PyObject *o );
00404
00406 inline bool PyVec4f_Check( PyObject *o) {
00407 return PyObject_TypeCheck(o,&PyVec4f_Type);
00408 }
00409
00412 struct PyVec4f : public PyVecTypeWrapper< Vec4f,
00413 &PyVec4f_Type,
00414 PyVec4f_Name,
00415 PyVec4f_Check,
00416 PyVec4f_AsVec4f,
00417 PyVec4f_FromVec4f > {
00418
00421 static int init(PyVec4f *self, PyObject *args, PyObject *kwds);
00422 };
00423
00424
00426
00428
00429 extern H3DAPI_API PyTypeObject PyVec4d_Type;
00430
00433 inline string PyVec4d_Name() { return "Vec4d"; }
00434
00436 PyObject *PyVec4d_FromVec4d( const Vec4d &v);
00437
00439 Vec4d PyVec4d_AsVec4d( PyObject *o );
00440
00442 inline bool PyVec4d_Check( PyObject *o) {
00443 return PyObject_TypeCheck(o,&PyVec4d_Type);
00444 }
00445
00446 namespace PythonInternals {
00448 inline bool PyVec4d4f_Check( PyObject *o) {
00449 return PyObject_TypeCheck(o,&PyVec4d_Type) ||
00450 PyObject_TypeCheck( o, &PyVec4f_Type );
00451 }
00452
00454 Vec4d PyVec4d4f_AsVec4d( PyObject *o );
00455 }
00456
00459 struct PyVec4d : public PyVecTypeWrapper< Vec4d,
00460 &PyVec4d_Type,
00461 PyVec4d_Name,
00462 PythonInternals::PyVec4d4f_Check,
00463 PythonInternals::PyVec4d4f_AsVec4d,
00464 PyVec4d_FromVec4d > {
00465
00468 static int init(PyVec4d *self, PyObject *args, PyObject *kwds);
00469 };
00470
00472
00474
00475 extern H3DAPI_API PyTypeObject PyRotation_Type;
00476
00479 inline string PyRotation_Name() { return "Rotation"; }
00480
00482 PyObject *PyRotation_FromRotation( const Rotation &v);
00483
00485 Rotation PyRotation_AsRotation( PyObject *o );
00486
00488 inline bool PyRotation_Check( PyObject *o) {
00489 return PyObject_TypeCheck(o,&PyRotation_Type);
00490 }
00491
00494 struct PyRotation : public PyNumberTypeWrapper< Rotation,
00495 &PyRotation_Type,
00496 PyRotation_Name,
00497 PyRotation_Check,
00498 PyRotation_AsRotation,
00499 PyRotation_FromRotation > {
00500
00503 static int init(PyRotation *self, PyObject *args, PyObject *kwds);
00504
00507 static PyObject *toEulerAngles( PyObject *self, PyObject *args );
00508
00510 static PyObject *slerp( PyObject *self, PyObject *args );
00511
00513 static PyObject* mul( PyObject *rota, PyObject *rotb );
00514 };
00515
00517
00519
00520 extern H3DAPI_API PyTypeObject PyQuaternion_Type;
00521
00524 inline string PyQuaternion_Name() { return "Quaternion"; }
00525
00527 PyObject *PyQuaternion_FromQuaternion( const Quaternion &v);
00528
00530 Quaternion PyQuaternion_AsQuaternion( PyObject *o );
00531
00533 inline bool PyQuaternion_Check( PyObject *o) {
00534 return PyObject_TypeCheck(o,&PyQuaternion_Type);
00535 }
00536
00539 struct PyQuaternion : public PyNumberTypeWrapper< Quaternion,
00540 &PyQuaternion_Type,
00541 PyQuaternion_Name,
00542 PyQuaternion_Check,
00543 PyQuaternion_AsQuaternion,
00544 PyQuaternion_FromQuaternion > {
00545
00548 static int init(PyQuaternion *self, PyObject *args, PyObject *kwds);
00549
00551 static PyObject* mul( PyObject *rota, PyObject *rotb );
00552
00555 static PyObject *toEulerAngles( PyObject *self, PyObject *args );
00556
00558 static PyObject *norm( PyObject *self, PyObject *args );
00559
00562 static PyObject* normalize( PyObject *self, PyObject *args );
00563
00565 static PyObject* conjugate( PyObject *self, PyObject *args );
00566
00568 static PyObject* inverse( PyObject *self, PyObject *args );
00569
00571 static PyObject* slerp( PyObject *self, PyObject *args );
00572
00574 static PyObject* dotProduct( PyObject *self, PyObject *args );
00575 };
00576
00578
00580
00581 extern H3DAPI_API PyTypeObject PyMatrix3f_Type;
00582
00585 inline string PyMatrix3f_Name() { return "Matrix3f"; }
00586
00588 PyObject *PyMatrix3f_FromMatrix3f( const Matrix3f &v);
00589
00591 Matrix3f PyMatrix3f_AsMatrix3f( PyObject *o );
00592
00594 inline bool PyMatrix3f_Check( PyObject *o) {
00595 return PyObject_TypeCheck(o,&PyMatrix3f_Type);
00596 }
00599 struct PyMatrix3f : public PyNumberTypeWrapper< Matrix3f,
00600 &PyMatrix3f_Type,
00601 PyMatrix3f_Name,
00602 PyMatrix3f_Check,
00603 PyMatrix3f_AsMatrix3f,
00604 PyMatrix3f_FromMatrix3f > {
00605
00608 static int init(PyMatrix3f *self, PyObject *args, PyObject *kwds);
00609
00611 static PyObject* mul( PyObject *rota, PyObject *rotb );
00612
00614 static PyObject* setToIdentity( PyObject *self, PyObject *args );
00615
00617 static PyObject* inverse( PyObject *self, PyObject *args );
00618
00620 static PyObject* transpose( PyObject *self, PyObject *args );
00621
00624 static PyObject* toEulerAngles( PyObject *self, PyObject *args );
00625
00627 static PyObject* getScalePart( PyObject *self, PyObject *args );
00628
00630 static PyObject* getRow( PyObject *self, PyObject *args );
00631
00633 static PyObject* getColumn( PyObject *self, PyObject *args );
00634
00636 static PyObject* getElement( PyObject *self, PyObject *args );
00637
00639 static PyObject* setElement( PyObject *self, PyObject *args );
00640 };
00641
00643
00645
00646 extern H3DAPI_API PyTypeObject PyMatrix4f_Type;
00647
00650 inline string PyMatrix4f_Name() { return "Matrix4f"; }
00651
00653 PyObject *PyMatrix4f_FromMatrix4f( const Matrix4f &v);
00654
00656 Matrix4f PyMatrix4f_AsMatrix4f( PyObject *o );
00657
00659 inline bool PyMatrix4f_Check( PyObject *o) {
00660 return PyObject_TypeCheck(o,&PyMatrix4f_Type);
00661 }
00664 struct PyMatrix4f : public PyNumberTypeWrapper< Matrix4f,
00665 &PyMatrix4f_Type,
00666 PyMatrix4f_Name,
00667 PyMatrix4f_Check,
00668 PyMatrix4f_AsMatrix4f,
00669 PyMatrix4f_FromMatrix4f > {
00670
00671
00674 static int init(PyMatrix4f *self, PyObject *args, PyObject *kwds);
00675
00677 static PyObject* mul( PyObject *rota, PyObject *rotb );
00678
00680 static PyObject* setToIdentity( PyObject *self, PyObject *args );
00681
00690 static PyObject* transformInverse( PyObject *self, PyObject *args );
00691
00693 static PyObject* inverse( PyObject *self, PyObject *args );
00694
00696 static PyObject* transpose( PyObject *self, PyObject *args );
00697
00699 static PyObject* getRow( PyObject *self, PyObject *args );
00700
00702 static PyObject* getColumn( PyObject *self, PyObject *args );
00703
00705 static PyObject* getScaleRotationPart( PyObject *self, PyObject *args );
00706
00708 static PyObject* getRotationPart( PyObject *self, PyObject *args );
00709
00711 static PyObject* getScalePart( PyObject *self, PyObject *args );
00712
00714 static PyObject* getElement( PyObject *self, PyObject *args );
00715
00717 static PyObject* setElement( PyObject *self, PyObject *args );
00718 };
00719
00720
00722
00724
00725 extern H3DAPI_API PyTypeObject PyMatrix3d_Type;
00726
00729 inline string PyMatrix3d_Name() { return "Matrix3d"; }
00730
00732 PyObject *PyMatrix3d_FromMatrix3d( const Matrix3d &v);
00733
00735 Matrix3d PyMatrix3d_AsMatrix3d( PyObject *o );
00736
00738 inline bool PyMatrix3d_Check( PyObject *o) {
00739 return PyObject_TypeCheck(o,&PyMatrix3d_Type);
00740 }
00741
00742 namespace PythonInternals {
00744 inline bool PyMatrix3d3f_Check( PyObject *o) {
00745 return PyObject_TypeCheck(o,&PyMatrix3d_Type) ||
00746 PyObject_TypeCheck( o, &PyMatrix3f_Type );
00747 }
00748
00750 Matrix3d PyMatrix3d3f_AsMatrix3d( PyObject *o );
00751 }
00752
00755 struct PyMatrix3d : public PyNumberTypeWrapper< Matrix3d,
00756 &PyMatrix3d_Type,
00757 PyMatrix3d_Name,
00758 PythonInternals::PyMatrix3d3f_Check,
00759 PythonInternals::PyMatrix3d3f_AsMatrix3d,
00760 PyMatrix3d_FromMatrix3d > {
00761
00764 static int init(PyMatrix3d *self, PyObject *args, PyObject *kwds);
00765
00767 static PyObject* mul( PyObject *rota, PyObject *rotb );
00768
00770 static PyObject* setToIdentity( PyObject *self, PyObject *args );
00771
00773 static PyObject* inverse( PyObject *self, PyObject *args );
00774
00776 static PyObject* transpose( PyObject *self, PyObject *args );
00777
00780 static PyObject* toEulerAngles( PyObject *self, PyObject *args );
00781
00783 static PyObject* getScalePart( PyObject *self, PyObject *args );
00784
00786 static PyObject* getRow( PyObject *self, PyObject *args );
00787
00789 static PyObject* getColumn( PyObject *self, PyObject *args );
00790
00792 static PyObject* getElement( PyObject *self, PyObject *args );
00793
00795 static PyObject* setElement( PyObject *self, PyObject *args );
00796 };
00797
00799
00801
00802 extern H3DAPI_API PyTypeObject PyMatrix4d_Type;
00803
00806 inline string PyMatrix4d_Name() { return "Matrix4d"; }
00807
00809 PyObject *PyMatrix4d_FromMatrix4d( const Matrix4d &v);
00810
00812 Matrix4d PyMatrix4d_AsMatrix4d( PyObject *o );
00813
00815 inline bool PyMatrix4d_Check( PyObject *o) {
00816 return PyObject_TypeCheck(o,&PyMatrix4d_Type);
00817 }
00818
00819 namespace PythonInternals {
00821 inline bool PyMatrix4d4f_Check( PyObject *o) {
00822 return PyObject_TypeCheck(o,&PyMatrix4d_Type) ||
00823 PyObject_TypeCheck( o, &PyMatrix4f_Type );
00824 }
00825
00827 Matrix4d PyMatrix4d4f_AsMatrix4d( PyObject *o );
00828 }
00829
00832 struct PyMatrix4d : public PyNumberTypeWrapper< Matrix4d,
00833 &PyMatrix4d_Type,
00834 PyMatrix4d_Name,
00835 PythonInternals::PyMatrix4d4f_Check,
00836 PythonInternals::PyMatrix4d4f_AsMatrix4d,
00837 PyMatrix4d_FromMatrix4d > {
00838
00839
00842 static int init(PyMatrix4d *self, PyObject *args, PyObject *kwds);
00843
00845 static PyObject* mul( PyObject *rota, PyObject *rotb );
00846
00848 static PyObject* setToIdentity( PyObject *self, PyObject *args );
00849
00858 static PyObject* transformInverse( PyObject *self, PyObject *args );
00859
00861 static PyObject* inverse( PyObject *self, PyObject *args );
00862
00864 static PyObject* transpose( PyObject *self, PyObject *args );
00865
00867 static PyObject* getRow( PyObject *self, PyObject *args );
00868
00870 static PyObject* getColumn( PyObject *self, PyObject *args );
00871
00873 static PyObject* getScaleRotationPart( PyObject *self, PyObject *args );
00874
00876 static PyObject* getRotationPart( PyObject *self, PyObject *args );
00877
00879 static PyObject* getScalePart( PyObject *self, PyObject *args );
00880
00882 static PyObject* getElement( PyObject *self, PyObject *args );
00883
00885 static PyObject* setElement( PyObject *self, PyObject *args );
00886 };
00887
00889
00891
00892 extern H3DAPI_API PyTypeObject PyRGB_Type;
00893
00896 inline string PyRGB_Name() { return "RGB"; }
00897
00899 PyObject *PyRGB_FromRGB( const RGB &v);
00900
00902 RGB PyRGB_AsRGB( PyObject *o );
00903
00905 inline bool PyRGB_Check( PyObject *o) {
00906 return PyObject_TypeCheck(o,&PyRGB_Type);
00907 }
00908
00911 struct PyRGB : public PyTypeWrapper< RGB,
00912 &PyRGB_Type,
00913 PyRGB_Name,
00914 PyRGB_Check,
00915 PyRGB_AsRGB,
00916 PyRGB_FromRGB > {
00917
00920 static int init(PyRGB *self, PyObject *args, PyObject *kwds);
00921 };
00922
00924
00926
00927 extern H3DAPI_API PyTypeObject PyRGBA_Type;
00928
00931 inline string PyRGBA_Name() { return "RGBA"; }
00932
00934 PyObject *PyRGBA_FromRGBA( const RGBA &v);
00935
00937 RGBA PyRGBA_AsRGBA( PyObject *o );
00938
00940 inline bool PyRGBA_Check( PyObject *o) {
00941 return PyObject_TypeCheck(o,&PyRGBA_Type);
00942 }
00943
00946 struct PyRGBA : public PyTypeWrapper< RGBA,
00947 &PyRGBA_Type,
00948 PyRGBA_Name,
00949 PyRGBA_Check,
00950 PyRGBA_AsRGBA,
00951 PyRGBA_FromRGBA > {
00952
00955 static int init(PyRGBA *self, PyObject *args, PyObject *kwds);
00956 };
00957
00958 }
00959
00960 #endif
00961 #endif