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

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

changed classtemplate for 2d evaluation from matrix form to 1d array form

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