[f2d6445] | 1 | // -*- C++ -*- |
---|
| 2 | // |
---|
| 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 4 | // |
---|
| 5 | // Michael A.G. Aivazis |
---|
| 6 | // California Institute of Technology |
---|
| 7 | // (C) 1998-2005 All Rights Reserved |
---|
| 8 | // |
---|
| 9 | // <LicenseText> |
---|
| 10 | // |
---|
| 11 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 12 | // |
---|
| 13 | |
---|
| 14 | //#include <portinfo> |
---|
| 15 | #include <Python.h> |
---|
| 16 | |
---|
| 17 | #include "misc.h" |
---|
| 18 | #include "sphere.h" |
---|
| 19 | #include "cylinder.h" |
---|
| 20 | #include "ellipsoid.h" |
---|
| 21 | #include "hollow_sphere.h" |
---|
| 22 | #include "single_helix.h" |
---|
| 23 | |
---|
| 24 | // copyright |
---|
| 25 | |
---|
| 26 | char pygeoshapespy_copyright__doc__[] = ""; |
---|
| 27 | char pygeoshapespy_copyright__name__[] = "copyright"; |
---|
| 28 | |
---|
| 29 | static char pygeoshapespy_copyright_note[] = |
---|
| 30 | "geoshapespy python module: Copyright (c) 1998-2005 Michael A.G. Aivazis"; |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | PyObject * pygeoshapespy_copyright(PyObject *, PyObject *) |
---|
| 34 | { |
---|
| 35 | return Py_BuildValue("s", pygeoshapespy_copyright_note); |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | //GeoShape methods |
---|
| 39 | char pygeoshapespy_set_orientation__name__[] = "set_orientation"; |
---|
| 40 | char pygeoshapespy_set_orientation__doc__[] = "Set the rotation angles"; |
---|
| 41 | |
---|
| 42 | PyObject * pygeoshapespy_set_orientation(PyObject *, PyObject *args){ |
---|
| 43 | PyObject *pyshape = 0; |
---|
| 44 | double angX=0,angY=0,angZ=0; |
---|
| 45 | |
---|
| 46 | int ok = PyArg_ParseTuple(args, "Oddd", &pyshape,&angX,&angY,&angZ); |
---|
| 47 | if(!ok) return NULL; |
---|
| 48 | |
---|
| 49 | void *temp = PyCObject_AsVoidPtr(pyshape); |
---|
| 50 | |
---|
| 51 | GeoShape *shape = static_cast<GeoShape *>(temp); |
---|
| 52 | |
---|
| 53 | shape->SetOrientation(angX,angY,angZ); |
---|
| 54 | |
---|
| 55 | return Py_BuildValue("i", 0); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | char pygeoshapespy_set_center__name__[] = "set_center"; |
---|
| 59 | char pygeoshapespy_set_center__doc__[] = "new center for points translation"; |
---|
| 60 | |
---|
| 61 | PyObject * pygeoshapespy_set_center(PyObject *, PyObject *args){ |
---|
| 62 | |
---|
| 63 | PyObject *pyshape = 0; |
---|
| 64 | double tranX=0,tranY=0,tranZ=0; |
---|
| 65 | |
---|
| 66 | int ok = PyArg_ParseTuple(args, "Oddd", &pyshape,&tranX,&tranY,&tranZ); |
---|
| 67 | if(!ok) return NULL; |
---|
| 68 | |
---|
| 69 | void *temp = PyCObject_AsVoidPtr(pyshape); |
---|
| 70 | |
---|
| 71 | GeoShape *shape = static_cast<GeoShape *>(temp); |
---|
| 72 | |
---|
| 73 | shape->SetCenter(tranX,tranY,tranZ); |
---|
| 74 | |
---|
| 75 | return Py_BuildValue("i", 0); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | //Sphere constructor |
---|
| 79 | char pyanalmodelpy_new_sphere__name__[] = "new_sphere"; |
---|
| 80 | char pyanalmodelpy_new_sphere__doc__[] = "sphere constructor"; |
---|
| 81 | |
---|
| 82 | PyObject * pyanalmodelpy_new_sphere(PyObject *, PyObject *args){ |
---|
| 83 | double r; |
---|
| 84 | int ok = PyArg_ParseTuple(args,"d",&r); |
---|
| 85 | if(!ok) return 0; |
---|
| 86 | |
---|
| 87 | Sphere *newsph = new Sphere(r); |
---|
| 88 | |
---|
| 89 | return PyCObject_FromVoidPtr(newsph, PyDelSphere); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | static void PyDelSphere(void *ptr){ |
---|
| 93 | Sphere * oldsph = static_cast<Sphere *>(ptr); |
---|
| 94 | delete oldsph; |
---|
| 95 | |
---|
| 96 | return; |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | //Cylinder constructor |
---|
| 100 | char pyanalmodelpy_new_cylinder__name__[] = "new_cylinder"; |
---|
| 101 | char pyanalmodelpy_new_cylinder__doc__[] = "cylinder constructor"; |
---|
| 102 | |
---|
| 103 | PyObject * pyanalmodelpy_new_cylinder(PyObject *, PyObject *args){ |
---|
| 104 | double r,h; |
---|
| 105 | int ok = PyArg_ParseTuple(args,"dd",&r,&h); |
---|
| 106 | if(!ok) return 0; |
---|
| 107 | |
---|
| 108 | Cylinder *newcyl = new Cylinder(r,h); |
---|
| 109 | |
---|
| 110 | return PyCObject_FromVoidPtr(newcyl, PyDelCylinder); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | static void PyDelCylinder(void *ptr){ |
---|
| 114 | Cylinder * oldcyl = static_cast<Cylinder *>(ptr); |
---|
| 115 | delete oldcyl; |
---|
| 116 | |
---|
| 117 | return; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | //Ellipsoid constructor |
---|
| 121 | char pyanalmodelpy_new_ellipsoid__name__[] = "new_ellipsoid"; |
---|
| 122 | char pyanalmodelpy_new_ellipsoid__doc__[] = "ellipsoid constructor"; |
---|
| 123 | |
---|
| 124 | PyObject * pyanalmodelpy_new_ellipsoid(PyObject *, PyObject *args){ |
---|
| 125 | double rx,ry,rz; |
---|
| 126 | int ok = PyArg_ParseTuple(args,"ddd",&rx,&ry,&rz); |
---|
| 127 | if(!ok) return 0; |
---|
| 128 | |
---|
| 129 | Ellipsoid *newelli = new Ellipsoid(rx,ry,rz); |
---|
| 130 | |
---|
| 131 | return PyCObject_FromVoidPtr(newelli, PyDelEllipsoid); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | static void PyDelEllipsoid(void *ptr){ |
---|
| 135 | Ellipsoid * oldelli = static_cast<Ellipsoid *>(ptr); |
---|
| 136 | delete oldelli; |
---|
| 137 | |
---|
| 138 | return; |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | //Hollow Sphere constructor & methods |
---|
| 142 | char pyanalmodelpy_new_hollowsphere__name__[] = "new_hollowsphere"; |
---|
| 143 | char pyanalmodelpy_new_hollowsphere__doc__[] = ""; |
---|
| 144 | |
---|
| 145 | PyObject * pyanalmodelpy_new_hollowsphere(PyObject *, PyObject *args) |
---|
| 146 | { |
---|
| 147 | double r, th; |
---|
| 148 | int ok = PyArg_ParseTuple(args,"dd",&r, &th); |
---|
| 149 | if(!ok) return 0; |
---|
| 150 | |
---|
| 151 | HollowSphere *newhosph = new HollowSphere(r,th); |
---|
| 152 | |
---|
| 153 | return PyCObject_FromVoidPtr(newhosph, PyDelHollowSphere); |
---|
| 154 | |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | static void PyDelHollowSphere(void *ptr) |
---|
| 158 | { |
---|
| 159 | HollowSphere * oldhosph = static_cast<HollowSphere *>(ptr); |
---|
| 160 | delete oldhosph; |
---|
| 161 | return; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | //Single Helix constructor & methods |
---|
| 165 | char pyanalmodelpy_new_singlehelix__name__[] = "new_singlehelix"; |
---|
| 166 | char pyanalmodelpy_new_singlehelix__doc__[] = ""; |
---|
| 167 | |
---|
| 168 | PyObject * pyanalmodelpy_new_singlehelix(PyObject *, PyObject *args) |
---|
| 169 | { |
---|
| 170 | double hr,tr,pitch,turns; |
---|
| 171 | int ok = PyArg_ParseTuple(args,"dddd",&hr,&tr,&pitch,&turns); |
---|
| 172 | if(!ok) return 0; |
---|
| 173 | |
---|
| 174 | SingleHelix *newsinhel = new SingleHelix(hr,tr,pitch,turns); |
---|
| 175 | |
---|
| 176 | return PyCObject_FromVoidPtr(newsinhel, PyDelSingleHelix); |
---|
| 177 | |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | static void PyDelSingleHelix(void *ptr) |
---|
| 181 | { |
---|
| 182 | SingleHelix * oldsinhel = static_cast<SingleHelix *>(ptr); |
---|
| 183 | delete oldsinhel; |
---|
| 184 | return; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | // version |
---|
| 188 | // $Id$ |
---|
| 189 | |
---|
| 190 | // End of file |
---|