-
Notifications
You must be signed in to change notification settings - Fork 0
/
molecule.i
117 lines (97 loc) · 1.79 KB
/
molecule.i
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
/* File: molecule.i */
%module molecule
%{
#include "mol.h"
%}
%include "mol.h"
%extend atom {
atom( char element[3], double x, double y, double z )
{
atom *a;
a = (atom *)malloc( sizeof(atom) );
atomset( a, element, &x, &y, &z );
return a;
}
~atom()
{
free($self);
}
};
%extend bond {
bond( bond *bond )
{
return bond;
}
};
%extend mx_wrapper {
mx_wrapper( int xrot, int yrot, int zrot )
{
mx_wrapper *mx;
mx = malloc( sizeof( mx_wrapper ) );
if ( (xrot!=0) && (yrot==0) && (zrot==0) )
{
xrotation( mx->xform_matrix, xrot );
}
if ( (xrot==0) && (yrot!=0) && (zrot==0) )
{
yrotation( mx->xform_matrix, yrot );
}
if ( (xrot==0) && (yrot==0) && (zrot!=0) )
{
zrotation( mx->xform_matrix, zrot );
}
return mx;
}
~mx_wrapper()
{
free( $self );
}
};
%extend molecule {
molecule()
{
molecule *mol;
mol = molmalloc( 0, 0 );
return mol;
}
~molecule()
{
molfree($self);
}
void append_atom( char element[3], double x, double y, double z )
{
atom a1;
strcpy( a1.element, element );
a1.x = x;
a1.y = y;
a1.z = z;
molappend_atom( $self, &a1 );
}
void append_bond( unsigned short a1, unsigned short a2, unsigned char epairs )
{
bond b1;
b1.a1 = a1;
b1.a2 = a2;
b1.atoms = $self->atoms;
b1.epairs = epairs;
compute_coords( &b1 );
// printf( ">A> %hu %hu %lf\n", b1.a1, b1.a2, b1.z );
molappend_bond( $self, &b1 );
}
atom *get_atom( unsigned short i )
{
return $self->atom_ptrs[i];
}
bond *get_bond( unsigned short i )
{
return $self->bond_ptrs[i];
}
void sort()
{
molsort( $self );
}
void xform( xform_matrix xform_matrix )
{
mol_xform( self, xform_matrix );
}
};