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
|
# Pyrex file for base classes
# Copyright 2006-2007 Nanorex, Inc. See LICENSE file for details.
cdef extern from "Numeric/arrayobject.h":
object PyArray_FromDims(int nd, int *d, int type)
cdef extern from "basehelp.c":
#checkForErrors()
cdef struct atomset:
pass
cdef struct chunkbase:
pass
cdef struct atombase:
int positionIndex
atomset *atomset_init()
atomset_size(atomset*)
void atomset_del(atomset*)
atomset_contains(atomset*, int)
atomset_remove(atomset*, int)
atomset_set(atomset*, int, PyObject)
atomset_get(atomset*, int)
atomset_asarray(atomset*)
void atomset_quickfill(atomset*, int, int, int)
double atomset_contains_performance(atomset*, int)
double atomset_set_performance(atomset*, int)
double atomset_asarray_performance(atomset*, int)
chunkbase *chunkbase_init()
chunkbase_addatom(chunkbase*, atombase*, int, double, double, double)
void chunkbase_del(chunkbase*)
atombase *atombase_init()
void atombase_del(atombase*)
cdef class __AtomSet:
cdef atomset *x
def __init__(self):
self.x = atomset_init()
#checkForErrors()
def __del__(self):
atomset_del(self.x)
def __len__(self):
return atomset_size(self.x)
def __setitem__(self, n, obj):
atomset_set(self.x, n, obj)
def __getitem__(self, n):
return atomset_get(self.x, n)
def __delitem__(self, n):
atomset_remove(self.x, n)
def asArray(self):
return atomset_asarray(self.x)
def contains(self, n):
return atomset_contains(self.x, n)
def contains_performance(self, n):
return atomset_contains_performance(self.x, n)
def set_performance(self, n):
return atomset_set_performance(self.x, n)
def asarray_performance(self, n):
return atomset_asarray_performance(self.x, n)
def quickFill(self, n, div=1):
atomset_quickfill(self.x, n, div, 0)
class AtomSet(__AtomSet):
# __del__ doesn't get used until you derive a non-cdef class
pass
cdef class __AtomBase:
cdef atombase *x
def __init__(self):
self.x = atombase_init()
#checkForErrors()
def __del__(self):
atombase_del(self.x)
class AtomBase(__AtomBase):
pass
cdef class BondBase:
pass
cdef class __ChunkBase:
cdef chunkbase *x
def __init__(self):
self.x = chunkbase_init()
#checkForErrors()
def __del__(self):
chunkbase_del(self.x)
def addatom(self, __AtomBase atm, tp, x, y, z):
chunkbase_addatom(self.x, atm.x, tp, x, y, z)
class ChunkBase(__ChunkBase):
# Maintain a normal Python list of atoms so that the
# atoms don't get GCed while the chunk is still alive
def __init__(self):
__ChunkBase.__init__(self)
self.atomlist = [ ]
def addatom(self, ab, tp, x, y, z):
__ChunkBase.addatom(self, ab, tp, x, y, z)
self.atomlist.append(ab)
|