source: sasview/realSpaceModeling/geoshapespy/geoshapespymodule/misc.cc @ f6cc57c

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since f6cc57c was f2d6445, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

moving realSpaceModeling to trunk

  • Property mode set to 100644
File size: 4.7 KB
Line 
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
26char pygeoshapespy_copyright__doc__[] = "";
27char pygeoshapespy_copyright__name__[] = "copyright";
28
29static char pygeoshapespy_copyright_note[] = 
30    "geoshapespy python module: Copyright (c) 1998-2005 Michael A.G. Aivazis";
31
32
33PyObject * pygeoshapespy_copyright(PyObject *, PyObject *)
34{
35    return Py_BuildValue("s", pygeoshapespy_copyright_note);
36}
37
38//GeoShape methods
39char pygeoshapespy_set_orientation__name__[] = "set_orientation";
40char pygeoshapespy_set_orientation__doc__[] = "Set the rotation angles";
41
42PyObject * 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
58char pygeoshapespy_set_center__name__[] = "set_center";
59char pygeoshapespy_set_center__doc__[] = "new center for points translation";
60
61PyObject * 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
79char pyanalmodelpy_new_sphere__name__[] = "new_sphere";
80char pyanalmodelpy_new_sphere__doc__[] = "sphere constructor";
81
82PyObject * 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
92static void PyDelSphere(void *ptr){
93  Sphere * oldsph = static_cast<Sphere *>(ptr);
94  delete oldsph;
95
96  return;
97}
98
99//Cylinder constructor
100char pyanalmodelpy_new_cylinder__name__[] = "new_cylinder";
101char pyanalmodelpy_new_cylinder__doc__[] = "cylinder constructor";
102
103PyObject * 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
113static void PyDelCylinder(void *ptr){
114  Cylinder * oldcyl = static_cast<Cylinder *>(ptr);
115  delete oldcyl;
116
117  return;
118}
119
120//Ellipsoid constructor
121char pyanalmodelpy_new_ellipsoid__name__[] = "new_ellipsoid";
122char pyanalmodelpy_new_ellipsoid__doc__[] = "ellipsoid constructor";
123
124PyObject * 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
134static void PyDelEllipsoid(void *ptr){
135  Ellipsoid * oldelli = static_cast<Ellipsoid *>(ptr);
136  delete oldelli;
137
138  return;
139}
140
141//Hollow Sphere constructor & methods
142char pyanalmodelpy_new_hollowsphere__name__[] = "new_hollowsphere";
143char pyanalmodelpy_new_hollowsphere__doc__[] = "";
144
145PyObject * 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
157static void PyDelHollowSphere(void *ptr)
158{
159  HollowSphere * oldhosph = static_cast<HollowSphere *>(ptr);
160  delete oldhosph;
161  return;
162}
163
164//Single Helix constructor & methods
165char pyanalmodelpy_new_singlehelix__name__[] = "new_singlehelix";
166char pyanalmodelpy_new_singlehelix__doc__[] = "";
167
168PyObject * 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
180static 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
Note: See TracBrowser for help on using the repository browser.