Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 7a55f17

Browse files
committed
Renamed Topology to Entity and combined some functionality together
1 parent e45a809 commit 7a55f17

17 files changed

+2494
-2624
lines changed

src/acis_entity.cpp

Lines changed: 2101 additions & 0 deletions
Large diffs are not rendered by default.

src/acis_entity.h

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
/**
2+
*
3+
* Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler
4+
*
5+
* ACIS and SAT are registered trademarks of Spatial Corporation.
6+
*
7+
* The Python module is developed by Onur R. Bingol and released under MIT license.
8+
* Please see the LICENSE file for details.
9+
*
10+
*/
11+
12+
#ifndef ACIS_ENTITY_H
13+
#define ACIS_ENTITY_H
14+
15+
#include <Python.h>
16+
#include <structmember.h>
17+
18+
#include "kernapi.hxx"
19+
#include <entity.hxx>
20+
#include <body.hxx>
21+
#include <face.hxx>
22+
#include <at_name.hxx>
23+
#include <at_int.hxx>
24+
25+
#include "acis_entity_export.h"
26+
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
// Types and their functions
33+
34+
// Define ENTITY as a base class
35+
typedef struct
36+
{
37+
PyObject_HEAD
38+
ENTITY *_acis_obj;
39+
PyObject *attrib_name;
40+
PyObject *attrib_object_id;
41+
} ACIS_Entity_ENTITY;
42+
43+
int ACIS_ENTITY_EXPORT ACIS_Entity_traverse_ENTITY(ACIS_Entity_ENTITY *self, visitproc visit, void *arg);
44+
45+
int ACIS_ENTITY_EXPORT ACIS_Entity_clear_ENTITY(ACIS_Entity_ENTITY *self);
46+
47+
void ACIS_ENTITY_EXPORT ACIS_Entity_dealloc_ENTITY(ACIS_Entity_ENTITY *self);
48+
49+
PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_new_ENTITY(PyTypeObject *type, PyObject *args, PyObject *kwargs);
50+
51+
int ACIS_ENTITY_EXPORT ACIS_Entity_init_ENTITY(ACIS_Entity_ENTITY *self, PyObject *args, PyObject *kwargs);
52+
53+
PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_repr_ENTITY(ACIS_Entity_ENTITY *self);
54+
55+
PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_str_ENTITY(ACIS_Entity_ENTITY *self);
56+
57+
PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure);
58+
59+
int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_name(ACIS_Entity_ENTITY *self, PyObject *value, void *closure);
60+
61+
PyObject ACIS_ENTITY_EXPORT *ACIS_Entity_method_ENTITY_get_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure);
62+
63+
int ACIS_ENTITY_EXPORT ACIS_Entity_method_ENTITY_set_attrib_obj_id(ACIS_Entity_ENTITY *self, PyObject *value, void *closure);
64+
65+
static PyGetSetDef
66+
ACIS_Entity_getseters_ENTITY[] =
67+
{
68+
{ (char *) "name", (getter) ACIS_Entity_method_ENTITY_get_attrib_name, (setter) ACIS_Entity_method_ENTITY_set_attrib_name, (char *) "object name", NULL },
69+
{ (char *) "id", (getter) ACIS_Entity_method_ENTITY_get_attrib_obj_id, (setter) ACIS_Entity_method_ENTITY_set_attrib_obj_id, (char *) "object id", NULL },
70+
{ NULL } /* Sentinel */
71+
};
72+
73+
static PyMemberDef
74+
ACIS_Entity_members_ENTITY[] =
75+
{
76+
{ NULL } /* Sentinel */
77+
};
78+
79+
static PyMethodDef
80+
ACIS_Entity_methods_ENTITY[] =
81+
{
82+
{ NULL } /* Sentinel */
83+
};
84+
85+
static PyTypeObject
86+
ACIS_Entity_type_ENTITY =
87+
{
88+
PyVarObject_HEAD_INIT(NULL, 0)
89+
"ACIS.ENTITY", /* tp_name */
90+
sizeof(ACIS_Entity_ENTITY), /* tp_basicsize */
91+
0, /* tp_itemsize */
92+
(destructor) ACIS_Entity_dealloc_ENTITY, /* tp_dealloc */
93+
0, /* tp_print */
94+
0, /* tp_getattr */
95+
0, /* tp_setattr */
96+
0, /* tp_reserved */
97+
(reprfunc) ACIS_Entity_repr_ENTITY, /* tp_repr */
98+
0, /* tp_as_number */
99+
0, /* tp_as_sequence */
100+
0, /* tp_as_mapping */
101+
0, /* tp_hash */
102+
0, /* tp_call */
103+
(reprfunc) ACIS_Entity_str_ENTITY, /* tp_str */
104+
0, /* tp_getattro */
105+
0, /* tp_setattro */
106+
0, /* tp_as_buffer */
107+
Py_TPFLAGS_DEFAULT |
108+
Py_TPFLAGS_BASETYPE |
109+
Py_TPFLAGS_HAVE_GC, /* tp_flags */
110+
"ACIS ENTITY class", /* tp_doc */
111+
(traverseproc) ACIS_Entity_traverse_ENTITY, /* tp_traverse */
112+
(inquiry) ACIS_Entity_clear_ENTITY, /* tp_clear */
113+
0, /* tp_richcompare */
114+
0, /* tp_weaklistoffset */
115+
0, /* tp_iter */
116+
0, /* tp_iternext */
117+
ACIS_Entity_methods_ENTITY, /* tp_methods */
118+
ACIS_Entity_members_ENTITY, /* tp_members */
119+
ACIS_Entity_getseters_ENTITY, /* tp_getset */
120+
0, /* tp_base */
121+
0, /* tp_dict */
122+
0, /* tp_descr_get */
123+
0, /* tp_descr_set */
124+
0, /* tp_dictoffset */
125+
(initproc) ACIS_Entity_init_ENTITY, /* tp_init */
126+
0, /* tp_alloc */
127+
ACIS_Entity_new_ENTITY, /* tp_new */
128+
};
129+
130+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_ENTITY();
131+
132+
bool ACIS_ENTITY_EXPORT _ACIS_check_ENTITY(PyObject *ob);
133+
134+
// Define BODY
135+
typedef struct
136+
{
137+
ACIS_Entity_ENTITY base_obj;
138+
} ACIS_Entity_BODY;
139+
140+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_BODY();
141+
142+
bool ACIS_ENTITY_EXPORT _ACIS_check_BODY(PyObject *ob);
143+
144+
// Define FACE
145+
typedef struct
146+
{
147+
ACIS_Entity_ENTITY base_obj;
148+
} ACIS_Entity_FACE;
149+
150+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_FACE();
151+
152+
bool ACIS_ENTITY_EXPORT _ACIS_check_FACE(PyObject *ob);
153+
154+
// Define EDGE
155+
typedef struct
156+
{
157+
ACIS_Entity_ENTITY base_obj;
158+
} ACIS_Entity_EDGE;
159+
160+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_EDGE();
161+
162+
bool ACIS_ENTITY_EXPORT _ACIS_check_EDGE(PyObject *ob);
163+
164+
// Define WIRE
165+
typedef struct
166+
{
167+
ACIS_Entity_ENTITY base_obj;
168+
} ACIS_Entity_WIRE;
169+
170+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_WIRE();
171+
172+
bool ACIS_ENTITY_EXPORT _ACIS_check_WIRE(PyObject *ob);
173+
174+
// Define LUMP
175+
typedef struct
176+
{
177+
ACIS_Entity_ENTITY base_obj;
178+
} ACIS_Entity_LUMP;
179+
180+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LUMP();
181+
182+
bool ACIS_ENTITY_EXPORT _ACIS_check_LUMP(PyObject *ob);
183+
184+
// Define SHELL
185+
typedef struct
186+
{
187+
ACIS_Entity_ENTITY base_obj;
188+
} ACIS_Entity_SHELL;
189+
190+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SHELL();
191+
192+
bool ACIS_ENTITY_EXPORT _ACIS_check_SHELL(PyObject *ob);
193+
194+
// Define SUBSHELL
195+
typedef struct
196+
{
197+
ACIS_Entity_ENTITY base_obj;
198+
} ACIS_Entity_SUBSHELL;
199+
200+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SUBSHELL();
201+
202+
bool ACIS_ENTITY_EXPORT _ACIS_check_SUBSHELL(PyObject *ob);
203+
204+
// Define COEDGE
205+
typedef struct
206+
{
207+
ACIS_Entity_ENTITY base_obj;
208+
} ACIS_Entity_COEDGE;
209+
210+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_COEDGE();
211+
212+
bool ACIS_ENTITY_EXPORT _ACIS_check_COEDGE(PyObject *ob);
213+
214+
// Define LOOP
215+
typedef struct
216+
{
217+
ACIS_Entity_ENTITY base_obj;
218+
} ACIS_Entity_LOOP;
219+
220+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_LOOP();
221+
222+
bool ACIS_ENTITY_EXPORT _ACIS_check_LOOP(PyObject *ob);
223+
224+
// Define VERTEX
225+
typedef struct
226+
{
227+
ACIS_Entity_ENTITY base_obj;
228+
} ACIS_Entity_VERTEX;
229+
230+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_VERTEX();
231+
232+
bool ACIS_ENTITY_EXPORT _ACIS_check_VERTEX(PyObject *ob);
233+
234+
// Define SURFACE
235+
typedef struct
236+
{
237+
ACIS_Entity_ENTITY base_obj;
238+
} ACIS_Entity_SURFACE;
239+
240+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SURFACE();
241+
242+
bool ACIS_ENTITY_EXPORT _ACIS_check_SURFACE(PyObject *ob);
243+
244+
// Define CONE
245+
typedef struct
246+
{
247+
ACIS_Entity_ENTITY base_obj;
248+
} ACIS_Entity_CONE;
249+
250+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_CONE();
251+
252+
bool ACIS_ENTITY_EXPORT _ACIS_check_CONE(PyObject *ob);
253+
254+
// Define PLANE
255+
typedef struct
256+
{
257+
ACIS_Entity_ENTITY base_obj;
258+
} ACIS_Entity_PLANE;
259+
260+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_PLANE();
261+
262+
bool ACIS_ENTITY_EXPORT _ACIS_check_PLANE(PyObject *ob);
263+
264+
// Define SPHERE
265+
typedef struct
266+
{
267+
ACIS_Entity_ENTITY base_obj;
268+
} ACIS_Entity_SPHERE;
269+
270+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPHERE();
271+
272+
bool ACIS_ENTITY_EXPORT _ACIS_check_SPHERE(PyObject *ob);
273+
274+
// Define SPLINE
275+
typedef struct
276+
{
277+
ACIS_Entity_ENTITY base_obj;
278+
} ACIS_Entity_SPLINE;
279+
280+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_SPLINE();
281+
282+
bool ACIS_ENTITY_EXPORT _ACIS_check_SPLINE(PyObject *ob);
283+
284+
// Define TORUS
285+
typedef struct
286+
{
287+
ACIS_Entity_ENTITY base_obj;
288+
} ACIS_Entity_TORUS;
289+
290+
PyObject ACIS_ENTITY_EXPORT *_ACIS_new_TORUS();
291+
292+
bool ACIS_ENTITY_EXPORT _ACIS_check_TORUS(PyObject *ob);
293+
294+
295+
// Additional functions
296+
297+
/**
298+
* Sets the internal ocis_obj variable to NULL
299+
* @param ob Topology object, such as ENTITY, BODY, FACE, etc.
300+
*/
301+
void ACIS_ENTITY_EXPORT _ACIS_make_null(PyObject *ob);
302+
303+
#ifdef __cplusplus
304+
}
305+
#endif
306+
307+
#endif // !ACIS_ENTITY_H

src/acis_geometric_atoms.cpp

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,18 +1557,62 @@ static PyTypeObject
15571557
* Python module definitions
15581558
*/
15591559

1560+
static PyObject *
1561+
ACIS_GeometricAtoms_method_translate_transf(PyObject *self, PyObject *args, PyObject *kwargs)
1562+
{
1563+
PyObject *input_disp = NULL;
1564+
1565+
// List of keyword arguments that this function can take
1566+
static char *kwlist[] =
1567+
{
1568+
(char *) "disp",
1569+
NULL
1570+
};
1571+
1572+
// Try to parse input arguments and/or keywords
1573+
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwlist, &input_disp))
1574+
return NULL;
1575+
1576+
// "disp" must be a SPAvector object
1577+
if (!_ACIS_check_SPAvector(input_disp))
1578+
{
1579+
PyErr_SetString(PyExc_TypeError, "Expecting SPAvector object");
1580+
return NULL;
1581+
}
1582+
1583+
// Get the ACIS object from the user input
1584+
SPAvector *&_disp = ((ACIS_GeometricAtoms_SPAvector *) input_disp)->_acis_obj;
1585+
1586+
// Execute ACIS function
1587+
SPAtransf retval = translate_transf(*_disp);
1588+
1589+
// Generate a new SPAtransf python object and set its ACIS object value
1590+
PyObject *retobj = _ACIS_new_SPAtransf();
1591+
*((ACIS_GeometricAtoms_SPAtransf *) retobj)->_acis_obj = retval;
1592+
1593+
// Return SPAtransf python object
1594+
return retobj;
1595+
}
1596+
1597+
static PyMethodDef
1598+
module_methods[] =
1599+
{
1600+
{ "translate_transf", (PyCFunction) ACIS_GeometricAtoms_method_translate_transf, METH_VARARGS | METH_KEYWORDS, "Constructs a transformation corresponding to a translation by a given vector" },
1601+
{ NULL, NULL, 0, NULL }
1602+
};
1603+
15601604
// Module documentation can be accessible via __doc__
15611605
const char *module_name = "GeometricAtoms";
15621606
const char *module_documentation = "Contains 3D ACIS Modeler geometric atoms, e.g. SPAposition, SPApar_pos, etc.";
15631607

1564-
static PyModuleDef
1608+
static struct PyModuleDef
15651609
ACIS_GeometricAtoms_module =
15661610
{
15671611
PyModuleDef_HEAD_INIT,
1568-
module_name,
1569-
module_documentation,
1570-
-1,
1571-
NULL, NULL, NULL, NULL, NULL
1612+
module_name, // name of the module
1613+
module_documentation, // module documentation, may be NULL
1614+
-1, // size of per-interpreter state of the module, or -1 if the module keeps state in global variables.
1615+
module_methods
15721616
};
15731617

15741618
PyMODINIT_FUNC

0 commit comments

Comments
 (0)