summaryrefslogtreecommitdiff
path: root/esolid/wrapper/wrapper.pyx
blob: 41a741eeaffdd12dab424188f1995845f7b01527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
cdef extern from "bigint.h":
    cdef cppclass bigint:
        bigint()
        #bigint(unsigned int)
        #bigint(signed int)
        #bigint(unsigned long)
        #bigint(signed long)
        bigint(double)
        bigint(bigint&)
        
        #operators
        bigint operator++()
        bigint operator++(int)
        bigint operator--()
        bigint operator--(int)

        #comparison
        int operator==(bigint&, bigint&)
        int operator!=(bigint&, bigint&)
        int operator<(bigint&, bigint&)
        int operator>(bigint&, bigint&)
        int operator<=(bigint&, bigint&)
        int operator>=(bigint&, bigint&)
        #int operator &&(bigint&, bigint&)
        #int operator ||(bigint&, bigint&)
        #int operator!(bigint&)

        #bit
        bigint operator &(bigint&, bigint&)
        bigint operator |(bigint&, bigint&)
        bigint operator ^(bigint&, bigint&)

        #arithmetic and assignment
        #bigint& operator+=(bigint&)
        #bigint& operator-=(bigint&)
        #bigint& operator*=(bigint&)
        #bigint& operator/=(bigint&)
        #bigint& operator<<=(unsigned long)
        #bigint& operator>>=(unsigned long)
        #bigint& operator&=(bigint&)
        #bigint& operator|=(bigint&)
        #bigint& operator^=(bigint&)

        #stream
        #ostream& operator<<(ostream&, bigint&)
        #istream& operator>>(istream&, bigint&)

        unsigned long len()
        int fits_long()
        int fits_unsigned_long()
        long as_long()
        unsigned long as_unsigned_long()
        
    cdef bigint operator+(bigint&, bigint&)
    cdef bigint operator-(bigint&, bigint&)
    cdef bigint operator-(bigint&)
    cdef bigint operator*(bigint&, bigint&)
    cdef bigint operator/(bigint&, bigint&)
    cdef bigint operator<<(bigint&, unsigned long)
    cdef bigint operator>>(bigint&, unsigned long)

    cdef int sgn(bigint&)
    cdef int bit(unsigned long)

    cdef bigint abs(bigint&)
    cdef bigint sqrt(bigint&)
    cdef bigint root(bigint&)
    cdef double frexp(bigint&, long*)

    #algebra
    cdef bigint gcd(bigint&, bigint&)
    cdef bigint lcm(bigint&, bigint&)

cdef class Py_bigint:
    cdef bigint *thisptr
    def __cinit__(self):
        self.thisptr = new bigint()
    def len(self):
        return self.thisptr.len()
    def fits_long(self):
        return self.thisptr.fits_long()
    def fits_unsigned_long(self):
        return self.thisptr.fits_unsigned_long()
    def as_long(self):
        return self.thisptr.as_long()
    def as_unsigned_long(self):
        return self.thisptr.as_unsigned_long()

cdef extern from "bigint_vector.h":
    cdef cppclass bigint_vector:
        bigint_vector()

cdef class Py_bigint_vector:
    cdef bigint_vector *thisptr
    def __cinit__(self):
        self.thisptr = new bigint_vector()

cdef extern from "bigint_matrix.h":
    cdef cppclass bigint_matrix:
        bigint_matrix()

cdef class Py_bigint_matrix:
    cdef bigint_matrix *thisptr
    def __cinit__(self):
        self.thisptr = new bigint_matrix()

cdef extern from "kintpoly.h":
    cdef cppclass K_INTPOLY:
        K_INTPOLY()

cdef class Py_K_INTPOLY:
    cdef K_INTPOLY *thisptr
    def __cinit__(self):
        self.thisptr = new K_INTPOLY()

cdef extern from "kfloatpoly.h":
    cdef cppclass K_FLOATPOLY:
        K_FLOATPOLY()

cdef class Py_K_FLOATPOLY:
    cdef K_FLOATPOLY *thisptr
    def __cinit__(self):
        self.thisptr = new K_FLOATPOLY()

cdef extern from "bigrational.h":
    cdef cppclass bigrational:
        bigrational()
        bigrational(unsigned int)
        bigrational(signed int)
        bigrational(unsigned long)
        bigrational(signed long)
        bigrational(double)
        bigrational(bigint&)
        bigrational(bigint&, bigint&)
        bigrational(bigrational&)

        unsigned long len()
        double as_double()
        int fits_bigint()
        bigint as_bigint()

cdef class Py_bigrational:
    cdef bigrational *thisptr
    def __cinit__(self):
        self.thisptr = new bigrational()

cdef extern from "bigrational_vector.h":
    cdef cppclass bigrational_vector:
        bigrational_vector()
    
    cdef bigrational_vector Solve_VDM_GE(bigrational_vector&, bigrational_vector&)

cdef class Py_bigrational_vector:
    cdef bigrational_vector *thisptr
    def __cinit__(self):
        self.thisptr = new bigrational_vector()

cdef extern from "bigrational_matrix.h":
    cdef cppclass bigrational_matrix:
        bigrational_matrix()

cdef class Py_bigrational_matrix:
    cdef bigrational_matrix *thisptr
    def __cinit__(self):
        self.thisptr = new bigrational_matrix()

cdef extern from "kboxco2.h":
    cdef cppclass K_BOXCO2:
        K_BOXCO2()

cdef class Py_K_BOXCO2:
    cdef K_BOXCO2 *thisptr
    def __cinit__(self):
        self.thisptr = new K_BOXCO2()

cdef extern from "kratpoly.h":
    cdef cppclass K_RATPOLY:
        K_RATPOLY()

cdef class Py_K_RATPOLY:
    cdef K_RATPOLY *thisptr
    def __cinit__(self):
        self.thisptr = new K_RATPOLY()

cdef extern from "root1.h":
    cdef cppclass ROOT1:
        ROOT1()
        ROOT1(K_RATPOLY&, bigrational&, bigrational&, long, long)
        ROOT1(K_RATPOLY&, bigrational&, bigrational&, double)
        ROOT1(ROOT1&)

        unsigned long isolate_roots(ROOT1*&, bigrational&)

cdef class Py_ROOT1:
    cdef ROOT1 *thisptr
    def __cinit__(self):
        self.thisptr = new ROOT1()

cdef extern from "kpoint1d.h":
    cdef cppclass K_POINT1D:
        K_POINT1D()

cdef class Py_K_POINT1D:
    cdef K_POINT1D *thisptr
    def __cinit__(self):
        self.thisptr = new K_POINT1D()

cdef extern from "kpoint2d.h":
    cdef cppclass K_POINT2D:
        K_POINT2D()

cdef class Py_K_POINT2D:
    cdef K_POINT2D *thisptr
    def __cinit__(self):
        self.thisptr = new K_POINT2D()

cdef extern from "kpoly.h":
    cdef cppclass K_POLY:
        K_POLY()

cdef class Py_K_POLY:
    cdef K_POLY *thisptr
    def __cinit__(self):
        self.thisptr = new K_POLY()

cdef extern from "kcurve.h":
    cdef cppclass K_CURVE:
        K_CURVE()

cdef class Py_K_CURVE:
    cdef K_CURVE *thisptr
    def __cinit__(self):
        self.thisptr = new K_CURVE()

cdef extern from "ksegment.h":
    cdef cppclass K_SEGMENT:
        pass #no public members?
#cdef class Py_K_SEGMENT:
#    cdef K_SEGMENT *thisptr
#    def __cinit__(self):
#        self.thisptr = new K_SEGMENT()

cdef extern from "kpartition.h":
    cdef cppclass K_PARTITION:
        K_PARTITION()

cdef class Py_K_PARTITION:
    cdef K_PARTITION *thisptr
    def __cinit__(self):
        self.thisptr = new K_PARTITION()

cdef extern from "kgraph.h":
    cdef cppclass K_GRAPH:
        K_GRAPH()

cdef class Py_K_GRAPH:
    cdef K_GRAPH *thisptr
    def __cinit__(self):
        self.thisptr = new K_GRAPH()

cdef extern from "kpatch.h":
    cdef cppclass K_PATCH:
        K_PATCH()

cdef class Py_K_PATCH:
    cdef K_PATCH *thisptr
    def __cinit__(self):
        self.thisptr = new K_PATCH()

cdef extern from "kbox3d.h":
    cdef cppclass K_BOX3D:
        K_BOX3D()

cdef class Py_K_BOX3D:
    cdef K_BOX3D *thisptr
    def __cinit__(self):
        self.thisptr = new K_BOX3D()

cdef extern from "ksurf.h":
    cdef cppclass K_SURF:
        K_SURF()

cdef class Py_K_SURF:
    cdef K_SURF *thisptr
    def __cinit__(self):
        self.thisptr = new K_SURF()

cdef extern from "ksolid.h":
    cdef cppclass K_SOLID:
        K_SOLID()
        K_SOLID(K_PATCH*, unsigned long)
        K_SOLID(K_SOLID&)

        unsigned long num_patches
        K_PATCH** patches

        void internal_gen_box(bigrational_vector*, long unsigned int)
        void initialize_from_patches(K_PATCH*, long unsigned int)
        void bryan_read_box_from_file(char *)
        K_SOLID transform(bigrational_matrix&)
        #void internal_read_box(std::istream&, bigrational&)
        #int Bezier_output(ostream&)

        int classify_pt(bigrational&, bigrational&, bigrational&)
        int classify_pt(bigrational_vector&)

        K_SOLID boolean(K_SOLID&, char)
        K_SOLID merge(K_SOLID&)
        
    cdef K_SOLID read_CSG(char*, char*, bigrational&)
    #K_SOLID read_solid(istream&, bigrational&)
    #bigrational_matrix read_BRLCAD_matrix(istream&)

cdef class Py_K_SOLID:
    cdef K_SOLID *thisptr
    def __cinit__(self):
        self.thisptr = new K_SOLID()

    property num_patches:
        def __get__(self): return self.thisptr.num_patches
        def __set__(self, value): self.thisptr.num_patches = value