source: sasview/sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp @ 5eb9154

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 5eb9154 was 5eb9154, checked in by Jae Cho <jhjcho@…>, 15 years ago

calculation of the effective radius are added

  • Property mode set to 100644
File size: 22.1 KB
Line 
1/**
2        This software was developed by the University of Tennessee as part of the
3        Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4        project funded by the US National Science Foundation.
5
6        If you use DANSE applications to do scientific research that leads to
7        publication, we ask that you acknowledge the use of the software with the
8        following sentence:
9
10        "This work benefited from DANSE software developed under NSF award DMR-0520547."
11
12        copyright 2008, University of Tennessee
13 */
14
15/** CFlexibleCylinderModel
16 *
17 * C extension
18 *
19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
20 *          DO NOT MODIFY THIS FILE, MODIFY flexible_cylinder.h
21 *          AND RE-RUN THE GENERATOR SCRIPT
22 *
23 */
24#define NO_IMPORT_ARRAY
25#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
26 
27extern "C" {
28#include <Python.h>
29#include <arrayobject.h>
30#include "structmember.h"
31#include <stdio.h>
32#include <stdlib.h>
33#include <math.h>
34#include <time.h>
35#include "flexible_cylinder.h"
36}
37
38#include "models.hh"
39#include "dispersion_visitor.hh"
40
41/// Error object for raised exceptions
42static PyObject * CFlexibleCylinderModelError = NULL;
43
44
45// Class definition
46typedef struct {
47    PyObject_HEAD
48    /// Parameters
49    PyObject * params;
50    /// Dispersion parameters
51    PyObject * dispersion;
52    /// Underlying model object
53    FlexibleCylinderModel * model;
54    /// Log for unit testing
55    PyObject * log;
56} CFlexibleCylinderModel;
57
58
59static void
60CFlexibleCylinderModel_dealloc(CFlexibleCylinderModel* self)
61{
62    self->ob_type->tp_free((PyObject*)self);
63   
64
65}
66
67static PyObject *
68CFlexibleCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
69{
70    CFlexibleCylinderModel *self;
71   
72    self = (CFlexibleCylinderModel *)type->tp_alloc(type, 0);
73   
74    return (PyObject *)self;
75}
76
77static int
78CFlexibleCylinderModel_init(CFlexibleCylinderModel *self, PyObject *args, PyObject *kwds)
79{
80    if (self != NULL) {
81       
82        // Create parameters
83        self->params = PyDict_New();
84        self->dispersion = PyDict_New();
85        self->model = new FlexibleCylinderModel();
86       
87        // Initialize parameter dictionary
88        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000));
89        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",1000.000000));
90        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000));
91        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000100));
92        PyDict_SetItemString(self->params,"kuhn_length",Py_BuildValue("d",100.000000));
93        PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005));
94        // Initialize dispersion / averaging parameter dict
95        DispersionVisitor* visitor = new DispersionVisitor();
96        PyObject * disp_dict;
97        disp_dict = PyDict_New();
98        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
99        PyDict_SetItemString(self->dispersion, "length", disp_dict);
100        disp_dict = PyDict_New();
101        self->model->kuhn_length.dispersion->accept_as_source(visitor, self->model->kuhn_length.dispersion, disp_dict);
102        PyDict_SetItemString(self->dispersion, "kuhn_length", disp_dict);
103        disp_dict = PyDict_New();
104        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
105        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
106
107
108         
109        // Create empty log
110        self->log = PyDict_New();
111       
112       
113
114    }
115    return 0;
116}
117
118static PyMemberDef CFlexibleCylinderModel_members[] = {
119    {"params", T_OBJECT, offsetof(CFlexibleCylinderModel, params), 0,
120     "Parameters"},
121        {"dispersion", T_OBJECT, offsetof(CFlexibleCylinderModel, dispersion), 0,
122          "Dispersion parameters"},     
123    {"log", T_OBJECT, offsetof(CFlexibleCylinderModel, log), 0,
124     "Log"},
125    {NULL}  /* Sentinel */
126};
127
128/** Read double from PyObject
129    @param p PyObject
130    @return double
131*/
132double CFlexibleCylinderModel_readDouble(PyObject *p) {
133    if (PyFloat_Check(p)==1) {
134        return (double)(((PyFloatObject *)(p))->ob_fval);
135    } else if (PyInt_Check(p)==1) {
136        return (double)(((PyIntObject *)(p))->ob_ival);
137    } else if (PyLong_Check(p)==1) {
138        return (double)PyLong_AsLong(p);
139    } else {
140        return 0.0;
141    }
142}
143/**
144 * Function to call to evaluate model
145 * @param args: input numpy array q[]
146 * @return: numpy array object
147 */
148 
149static PyObject *evaluateOneDim(FlexibleCylinderModel* model, PyArrayObject *q){
150    PyArrayObject *result;
151   
152    // Check validity of array q , q must be of dimension 1, an array of double
153    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
154    {
155        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
156        //PyErr_SetString(PyExc_ValueError , message);
157        return NULL;
158    }
159    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 
160                                                                                  PyArray_DOUBLE);
161        if (result == NULL) {
162        const char * message= "Could not create result ";
163        PyErr_SetString(PyExc_RuntimeError , message);
164                return NULL;
165        }
166         for (int i = 0; i < q->dimensions[0]; i++){
167      double q_value  = *(double *)(q->data + i*q->strides[0]);
168      double *result_value = (double *)(result->data + i*result->strides[0]);
169      *result_value =(*model)(q_value);
170        }
171    return PyArray_Return(result); 
172 }
173
174 /**
175 * Function to call to evaluate model
176 * @param args: input numpy array  [x[],y[]]
177 * @return: numpy array object
178 */
179 static PyObject * evaluateTwoDimXY( FlexibleCylinderModel* model, 
180                              PyArrayObject *x, PyArrayObject *y)
181 {
182    PyArrayObject *result;
183    int i,j, x_len, y_len, dims[2];
184    //check validity of input vectors
185    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
186        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
187        || y->dimensions[1] != x->dimensions[0]){
188        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
189        PyErr_SetString(PyExc_ValueError , message); 
190        return NULL;
191    }
192   
193        if (PyArray_Check(x) && PyArray_Check(y)) {
194               
195            x_len = dims[1]= x->dimensions[0];
196        y_len = dims[0]= y->dimensions[1];
197           
198            // Make a new double matrix of same dims
199        result=(PyArrayObject *) PyArray_FromDims(2,dims,NPY_DOUBLE);
200        if (result == NULL){
201            const char * message= "Could not create result ";
202        PyErr_SetString(PyExc_RuntimeError , message);
203            return NULL;
204            }
205       
206        /* Do the calculation. */
207        for ( j=0; j< y_len; j++) {
208            for ( i=0; i< x_len; i++) {
209                double x_value = *(double *)(x->data + i*x->strides[0]);
210                    double y_value = *(double *)(y->data + j*y->strides[1]);
211                        double *result_value = (double *)(result->data +
212                              j*result->strides[0] + i*result->strides[1]);
213                        *result_value = (*model)(x_value, y_value);
214            }           
215        }
216        return PyArray_Return(result); 
217       
218        }else{
219                    PyErr_SetString(CFlexibleCylinderModelError, 
220                   "CFlexibleCylinderModel.evaluateTwoDimXY couldn't run.");
221                return NULL;
222                }       
223}
224/**
225 *  evalDistribution function evaluate a model function with input vector
226 *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
227 *
228 */ 
229static PyObject * evalDistribution(CFlexibleCylinderModel *self, PyObject *args){
230        PyObject *qx, *qy;
231        PyArrayObject * pars;
232        int npars ,mpars;
233       
234        // Get parameters
235       
236            // Reader parameter dictionary
237    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
238    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
239    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
240    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
241    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
242    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
243    // Read in dispersion parameters
244    PyObject* disp_dict;
245    DispersionVisitor* visitor = new DispersionVisitor();
246    disp_dict = PyDict_GetItemString(self->dispersion, "length");
247    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
248    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
249    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
250    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
251    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
252
253       
254        // Get input and determine whether we have to supply a 1D or 2D return value.
255        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
256            PyErr_SetString(CFlexibleCylinderModelError, 
257                "CFlexibleCylinderModel.evalDistribution expects a q value.");
258                return NULL;
259        }
260    // Check params
261       
262    if(PyArray_Check(pars)==1) {
263               
264            // Length of list should 1 or 2
265            npars = pars->nd; 
266            if(npars==1) {
267                // input is a numpy array
268                if (PyArray_Check(pars)) {
269                        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
270                    }
271                }else{
272                    PyErr_SetString(CFlexibleCylinderModelError, 
273                   "CFlexibleCylinderModel.evalDistribution expect numpy array of one dimension.");
274                return NULL;
275                }
276    }else if( PyList_Check(pars)==1) {
277        // Length of list should be 2 for I(qx,qy)
278            mpars = PyList_GET_SIZE(pars); 
279            if(mpars!=2) {
280                PyErr_SetString(CFlexibleCylinderModelError, 
281                        "CFlexibleCylinderModel.evalDistribution expects a list of dimension 2.");
282                return NULL;
283            }
284             qx = PyList_GET_ITEM(pars,0);
285             qy = PyList_GET_ITEM(pars,1);
286             if (PyArray_Check(qx) && PyArray_Check(qy)) {
287                 return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
288                           (PyArrayObject*)qy);
289                 }else{
290                    PyErr_SetString(CFlexibleCylinderModelError, 
291                   "CFlexibleCylinderModel.evalDistribution expect 2 numpy arrays in list.");
292                return NULL;
293             }
294        }
295        PyErr_SetString(CFlexibleCylinderModelError, 
296                   "CFlexibleCylinderModel.evalDistribution couln't be run.");
297        return NULL;
298       
299}
300
301/**
302 * Function to call to evaluate model
303 * @param args: input q or [q,phi]
304 * @return: function value
305 */
306static PyObject * run(CFlexibleCylinderModel *self, PyObject *args) {
307        double q_value, phi_value;
308        PyObject* pars;
309        int npars;
310       
311        // Get parameters
312       
313            // Reader parameter dictionary
314    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
315    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
316    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
317    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
318    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
319    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
320    // Read in dispersion parameters
321    PyObject* disp_dict;
322    DispersionVisitor* visitor = new DispersionVisitor();
323    disp_dict = PyDict_GetItemString(self->dispersion, "length");
324    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
325    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
326    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
327    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
328    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
329
330       
331        // Get input and determine whether we have to supply a 1D or 2D return value.
332        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
333            PyErr_SetString(CFlexibleCylinderModelError, 
334                "CFlexibleCylinderModel.run expects a q value.");
335                return NULL;
336        }
337         
338        // Check params
339        if( PyList_Check(pars)==1) {
340               
341                // Length of list should be 2 for I(q,phi)
342            npars = PyList_GET_SIZE(pars); 
343            if(npars!=2) {
344                PyErr_SetString(CFlexibleCylinderModelError, 
345                        "CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
346                return NULL;
347            }
348            // We have a vector q, get the q and phi values at which
349            // to evaluate I(q,phi)
350            q_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
351            phi_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
352            // Skip zero
353            if (q_value==0) {
354                return Py_BuildValue("d",0.0);
355            }
356                return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
357
358        } else {
359
360                // We have a scalar q, we will evaluate I(q)
361                q_value = CFlexibleCylinderModel_readDouble(pars);             
362               
363                return Py_BuildValue("d",(*(self->model))(q_value));
364        }       
365}
366/**
367 * Function to call to calculate_ER
368 * @return: effective radius value
369 */
370static PyObject * calculate_ER(CFlexibleCylinderModel *self) {
371
372        PyObject* pars;
373        int npars;
374       
375        // Get parameters
376       
377            // Reader parameter dictionary
378    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
379    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
380    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
381    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
382    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
383    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
384    // Read in dispersion parameters
385    PyObject* disp_dict;
386    DispersionVisitor* visitor = new DispersionVisitor();
387    disp_dict = PyDict_GetItemString(self->dispersion, "length");
388    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
389    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
390    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
391    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
392    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
393
394               
395        return Py_BuildValue("d",(*(self->model)).calculate_ER());
396
397}
398/**
399 * Function to call to evaluate model in cartesian coordinates
400 * @param args: input q or [qx, qy]]
401 * @return: function value
402 */
403static PyObject * runXY(CFlexibleCylinderModel *self, PyObject *args) {
404        double qx_value, qy_value;
405        PyObject* pars;
406        int npars;
407       
408        // Get parameters
409       
410            // Reader parameter dictionary
411    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
412    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
413    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
414    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
415    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
416    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
417    // Read in dispersion parameters
418    PyObject* disp_dict;
419    DispersionVisitor* visitor = new DispersionVisitor();
420    disp_dict = PyDict_GetItemString(self->dispersion, "length");
421    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
422    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
423    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
424    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
425    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
426
427       
428        // Get input and determine whether we have to supply a 1D or 2D return value.
429        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
430            PyErr_SetString(CFlexibleCylinderModelError, 
431                "CFlexibleCylinderModel.run expects a q value.");
432                return NULL;
433        }
434         
435        // Check params
436        if( PyList_Check(pars)==1) {
437               
438                // Length of list should be 2 for I(qx, qy))
439            npars = PyList_GET_SIZE(pars); 
440            if(npars!=2) {
441                PyErr_SetString(CFlexibleCylinderModelError, 
442                        "CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
443                return NULL;
444            }
445            // We have a vector q, get the qx and qy values at which
446            // to evaluate I(qx,qy)
447            qx_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
448            qy_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
449            return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
450
451        } else {
452
453                // We have a scalar q, we will evaluate I(q)
454                qx_value = CFlexibleCylinderModel_readDouble(pars);             
455               
456                return Py_BuildValue("d",(*(self->model))(qx_value));
457        }       
458}
459
460static PyObject * reset(CFlexibleCylinderModel *self, PyObject *args) {
461   
462
463    return Py_BuildValue("d",0.0);
464}
465
466static PyObject * set_dispersion(CFlexibleCylinderModel *self, PyObject *args) {
467        PyObject * disp;
468        const char * par_name;
469
470        if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
471            PyErr_SetString(CFlexibleCylinderModelError,
472                "CFlexibleCylinderModel.set_dispersion expects a DispersionModel object.");
473                return NULL;
474        }
475        void *temp = PyCObject_AsVoidPtr(disp);
476        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
477
478
479        // Ugliness necessary to go from python to C
480            // TODO: refactor this
481    if (!strcmp(par_name, "length")) {
482        self->model->length.dispersion = dispersion;
483    } else    if (!strcmp(par_name, "kuhn_length")) {
484        self->model->kuhn_length.dispersion = dispersion;
485    } else    if (!strcmp(par_name, "radius")) {
486        self->model->radius.dispersion = dispersion;
487    } else {
488            PyErr_SetString(CFlexibleCylinderModelError,
489                "CFlexibleCylinderModel.set_dispersion expects a valid parameter name.");
490                return NULL;
491        }
492
493        DispersionVisitor* visitor = new DispersionVisitor();
494        PyObject * disp_dict = PyDict_New();
495        dispersion->accept_as_source(visitor, dispersion, disp_dict);
496        PyDict_SetItemString(self->dispersion, par_name, disp_dict);
497    return Py_BuildValue("i",1);
498}
499
500
501static PyMethodDef CFlexibleCylinderModel_methods[] = {
502    {"run",      (PyCFunction)run     , METH_VARARGS,
503      "Evaluate the model at a given Q or Q, phi"},
504    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
505      "Evaluate the model at a given Q or Qx, Qy"},
506    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
507      "Evaluate the model at a given Q or Q, phi"},
508     
509    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
510      "Evaluate the model at a given Q or Qx, Qy vector "},
511    {"reset",    (PyCFunction)reset   , METH_VARARGS,
512      "Reset pair correlation"},
513    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
514      "Set the dispersion model for a given parameter"},
515   {NULL}
516};
517
518static PyTypeObject CFlexibleCylinderModelType = {
519    PyObject_HEAD_INIT(NULL)
520    0,                         /*ob_size*/
521    "CFlexibleCylinderModel",             /*tp_name*/
522    sizeof(CFlexibleCylinderModel),             /*tp_basicsize*/
523    0,                         /*tp_itemsize*/
524    (destructor)CFlexibleCylinderModel_dealloc, /*tp_dealloc*/
525    0,                         /*tp_print*/
526    0,                         /*tp_getattr*/
527    0,                         /*tp_setattr*/
528    0,                         /*tp_compare*/
529    0,                         /*tp_repr*/
530    0,                         /*tp_as_number*/
531    0,                         /*tp_as_sequence*/
532    0,                         /*tp_as_mapping*/
533    0,                         /*tp_hash */
534    0,                         /*tp_call*/
535    0,                         /*tp_str*/
536    0,                         /*tp_getattro*/
537    0,                         /*tp_setattro*/
538    0,                         /*tp_as_buffer*/
539    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
540    "CFlexibleCylinderModel objects",           /* tp_doc */
541    0,                         /* tp_traverse */
542    0,                         /* tp_clear */
543    0,                         /* tp_richcompare */
544    0,                         /* tp_weaklistoffset */
545    0,                         /* tp_iter */
546    0,                         /* tp_iternext */
547    CFlexibleCylinderModel_methods,             /* tp_methods */
548    CFlexibleCylinderModel_members,             /* tp_members */
549    0,                         /* tp_getset */
550    0,                         /* tp_base */
551    0,                         /* tp_dict */
552    0,                         /* tp_descr_get */
553    0,                         /* tp_descr_set */
554    0,                         /* tp_dictoffset */
555    (initproc)CFlexibleCylinderModel_init,      /* tp_init */
556    0,                         /* tp_alloc */
557    CFlexibleCylinderModel_new,                 /* tp_new */
558};
559
560
561//static PyMethodDef module_methods[] = {
562//    {NULL}
563//};
564
565/**
566 * Function used to add the model class to a module
567 * @param module: module to add the class to
568 */ 
569void addCFlexibleCylinderModel(PyObject *module) {
570        PyObject *d;
571       
572    if (PyType_Ready(&CFlexibleCylinderModelType) < 0)
573        return;
574
575    Py_INCREF(&CFlexibleCylinderModelType);
576    PyModule_AddObject(module, "CFlexibleCylinderModel", (PyObject *)&CFlexibleCylinderModelType);
577   
578    d = PyModule_GetDict(module);
579    CFlexibleCylinderModelError = PyErr_NewException("CFlexibleCylinderModel.error", NULL, NULL);
580    PyDict_SetItemString(d, "CFlexibleCylinderModelError", CFlexibleCylinderModelError);
581}
582
Note: See TracBrowser for help on using the repository browser.