1 |
gezelter |
1490 |
#include <stdlib.h> |
2 |
|
|
#include <stdio.h> |
3 |
|
|
#include <string.h> |
4 |
|
|
|
5 |
|
|
#include "MakeStamps.hpp" |
6 |
|
|
#include "MoleculeStamp.hpp" |
7 |
|
|
#include "RigidBodyStamp.hpp" |
8 |
|
|
#include "CutoffGroupStamp.hpp" |
9 |
|
|
#include "simError.h" |
10 |
|
|
#ifdef IS_MPI |
11 |
|
|
#include "mpiBASS.h" |
12 |
|
|
#endif // is_mpi |
13 |
|
|
|
14 |
|
|
LinkedMolStamp::~LinkedMolStamp(){ |
15 |
|
|
if( mol_stamp != NULL ) delete mol_stamp; |
16 |
|
|
if( next != NULL ) delete next; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
void LinkedMolStamp::add( LinkedMolStamp* newbie ){ |
20 |
|
|
|
21 |
|
|
if( next != NULL ) next->add( newbie ); |
22 |
|
|
else{ |
23 |
|
|
next = newbie; |
24 |
|
|
next->setPrev( this ); |
25 |
|
|
} |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
MoleculeStamp* LinkedMolStamp::match( char* id ){ |
29 |
|
|
|
30 |
|
|
if( mol_stamp != NULL ){ |
31 |
|
|
if(!strcmp( mol_stamp->getID(), id )){ |
32 |
|
|
|
33 |
|
|
// make sure we aren't hiding somebody else with the same name |
34 |
|
|
if(next != NULL ){ |
35 |
|
|
if( next->match( id ) != NULL){ |
36 |
|
|
sprintf( painCave.errMsg, |
37 |
|
|
"Molecule Stamp Error. Two separate of declarations of " |
38 |
|
|
"%s present.\n", |
39 |
|
|
id ); |
40 |
|
|
painCave.isFatal = 1; |
41 |
|
|
simError(); |
42 |
|
|
#ifdef IS_MPI |
43 |
|
|
if( painCave.isEventLoop ){ |
44 |
|
|
if( worldRank == 0 ) mpiInterfaceExit(); |
45 |
|
|
} |
46 |
|
|
#endif //is_mpi |
47 |
|
|
} |
48 |
|
|
else return mol_stamp; |
49 |
|
|
} |
50 |
|
|
else return mol_stamp; |
51 |
|
|
} |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
if( next != NULL ) return next->match( id ); |
55 |
|
|
|
56 |
|
|
return NULL; |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
LinkedMolStamp* LinkedMolStamp::extract( char* id ){ |
60 |
|
|
|
61 |
|
|
if( mol_stamp != NULL ){ |
62 |
|
|
if(!strcmp( mol_stamp->getID(), id )){ |
63 |
|
|
|
64 |
|
|
// make sure we aren't hiding somebody else with the same name |
65 |
|
|
if(next != NULL ){ |
66 |
|
|
if( next->match( id ) != NULL){ |
67 |
|
|
sprintf( painCave.errMsg, |
68 |
|
|
"Molecule Stamp Error. Two separate of declarations of " |
69 |
|
|
"%s present.\n", |
70 |
|
|
id ); |
71 |
|
|
painCave.isFatal = 1; |
72 |
|
|
simError(); |
73 |
|
|
#ifdef IS_MPI |
74 |
|
|
if( painCave.isEventLoop ){ |
75 |
|
|
if( worldRank == 0 ) mpiInterfaceExit(); |
76 |
|
|
} |
77 |
|
|
#endif //is_mpi |
78 |
|
|
} |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
prev->setNext( next ); |
82 |
|
|
if( next != NULL ) next->setPrev( prev ); |
83 |
|
|
return this; |
84 |
|
|
} |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
if( next != NULL ) return next->extract( id ); |
88 |
|
|
|
89 |
|
|
return NULL; |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
MakeStamps::MakeStamps(){ |
93 |
|
|
|
94 |
|
|
int i; |
95 |
|
|
|
96 |
|
|
hash_size = 47; |
97 |
|
|
hash_shift = 4; |
98 |
|
|
|
99 |
|
|
my_mols = new LinkedMolStamp*[hash_size]; |
100 |
|
|
for( i=0; i<hash_size; i++ ){ |
101 |
|
|
my_mols[i] = new LinkedMolStamp(); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
MakeStamps::~MakeStamps(){ |
107 |
|
|
|
108 |
|
|
int i; |
109 |
|
|
|
110 |
|
|
for( i=0; i<hash_size; i++ ){ |
111 |
|
|
if( my_mols[i] != NULL ) delete my_mols[i]; |
112 |
|
|
} |
113 |
|
|
delete[] my_mols; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
int MakeStamps::hash( char* text ){ |
117 |
|
|
|
118 |
|
|
register unsigned short int i = 0; // loop counter |
119 |
|
|
int key = 0; // the hash key |
120 |
|
|
|
121 |
|
|
while( text[i] != '\0' ){ |
122 |
|
|
|
123 |
|
|
key = ( ( key << hash_shift ) + text[i] ) % hash_size; |
124 |
|
|
|
125 |
|
|
i++; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
if( key < 0 ){ |
129 |
|
|
|
130 |
|
|
// if the key is less than zero, we've had an overflow error |
131 |
|
|
|
132 |
|
|
sprintf( painCave.errMsg, |
133 |
|
|
"There has been an overflow error in the MakeStamps hash key."); |
134 |
|
|
painCave.isFatal = 1; |
135 |
|
|
simError(); |
136 |
|
|
#ifdef IS_MPI |
137 |
|
|
if( painCave.isEventLoop ){ |
138 |
|
|
if( worldRank == 0 ) mpiInterfaceExit(); |
139 |
|
|
} |
140 |
|
|
#endif //is_mpi |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
return key; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
LinkedMolStamp* MakeStamps::extractMolStamp( char* the_id ){ |
147 |
|
|
int key; |
148 |
|
|
|
149 |
|
|
key = hash( the_id ); |
150 |
|
|
if( my_mols[key] != NULL ){ |
151 |
|
|
return my_mols[key]->extract( the_id ); |
152 |
|
|
} |
153 |
|
|
|
154 |
|
|
return NULL; |
155 |
|
|
} |
156 |
|
|
|
157 |
|
|
void MakeStamps::addMolStamp( MoleculeStamp* the_stamp ){ |
158 |
|
|
|
159 |
|
|
int key; |
160 |
|
|
LinkedMolStamp* linked_mol; |
161 |
|
|
|
162 |
|
|
key = hash( the_stamp->getID() ); |
163 |
|
|
|
164 |
|
|
linked_mol = new LinkedMolStamp; |
165 |
|
|
linked_mol->setStamp( the_stamp ); |
166 |
|
|
|
167 |
|
|
my_mols[key]->add( linked_mol ); |
168 |
|
|
|
169 |
|
|
} |
170 |
|
|
|
171 |
|
|
|
172 |
|
|
int MakeStamps::newMolecule( event* the_event ){ |
173 |
|
|
|
174 |
|
|
current_mol = new MoleculeStamp; |
175 |
|
|
return 1; |
176 |
|
|
} |
177 |
|
|
|
178 |
|
|
int MakeStamps::moleculeAssign( event* the_event ){ |
179 |
|
|
|
180 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
181 |
|
|
|
182 |
|
|
case STRING: |
183 |
|
|
the_event->err_msg = current_mol->assignString( the_event->evt.asmt.lhs, |
184 |
|
|
the_event->evt.asmt.rhs.sval ); |
185 |
|
|
break; |
186 |
|
|
|
187 |
|
|
case DOUBLE: |
188 |
|
|
the_event->err_msg = current_mol->assignDouble( the_event->evt.asmt.lhs, |
189 |
|
|
the_event->evt.asmt.rhs.dval ); |
190 |
|
|
break; |
191 |
|
|
|
192 |
|
|
case INT: |
193 |
|
|
the_event->err_msg = current_mol->assignInt( the_event->evt.asmt.lhs, |
194 |
|
|
the_event->evt.asmt.rhs.ival ); |
195 |
|
|
break; |
196 |
|
|
|
197 |
|
|
default: |
198 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid molecule" |
199 |
|
|
" assignment type" ); |
200 |
|
|
return 0; |
201 |
|
|
break; |
202 |
|
|
} |
203 |
|
|
if( the_event->err_msg != NULL ) return 0; |
204 |
|
|
return 1; |
205 |
|
|
} |
206 |
|
|
|
207 |
|
|
int MakeStamps::moleculeEnd( event* the_event ){ |
208 |
|
|
|
209 |
|
|
the_event->err_msg = current_mol->checkMe(); |
210 |
|
|
// if err_msg is set, then something is wrong |
211 |
|
|
if( the_event->err_msg != NULL ) return 0; |
212 |
|
|
|
213 |
|
|
addMolStamp( current_mol ); |
214 |
|
|
return 1; |
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
int MakeStamps::newRigidBody( event* the_event ){ |
218 |
|
|
|
219 |
|
|
current_rigidbody = new RigidBodyStamp; |
220 |
|
|
|
221 |
|
|
the_event->err_msg = current_mol->addRigidBody( current_rigidbody, |
222 |
|
|
the_event->evt.blk_index ); |
223 |
|
|
if( the_event->err_msg != NULL ) return 0; |
224 |
|
|
return 1; |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
int MakeStamps::rigidBodyAssign( event* the_event ){ |
228 |
|
|
|
229 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
230 |
|
|
|
231 |
|
|
case STRING: |
232 |
|
|
the_event->err_msg = |
233 |
|
|
current_rigidbody->assignString( the_event->evt.asmt.lhs, |
234 |
|
|
the_event->evt.asmt.rhs.sval ); |
235 |
|
|
if( the_event->err_msg != NULL ) return 0; |
236 |
|
|
return 1; |
237 |
|
|
break; |
238 |
|
|
|
239 |
|
|
case DOUBLE: |
240 |
|
|
the_event->err_msg = |
241 |
|
|
current_rigidbody->assignDouble( the_event->evt.asmt.lhs, |
242 |
|
|
the_event->evt.asmt.rhs.dval ); |
243 |
|
|
if( the_event->err_msg != NULL ) return 0; |
244 |
|
|
return 1; |
245 |
|
|
break; |
246 |
|
|
|
247 |
|
|
case INT: |
248 |
|
|
the_event->err_msg = |
249 |
|
|
current_rigidbody->assignInt( the_event->evt.asmt.lhs, |
250 |
|
|
the_event->evt.asmt.rhs.ival ); |
251 |
|
|
if( the_event->err_msg != NULL ) return 0; |
252 |
|
|
return 1; |
253 |
|
|
break; |
254 |
|
|
|
255 |
|
|
default: |
256 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid rigidBody" |
257 |
|
|
" assignment type" ); |
258 |
|
|
return 0; |
259 |
|
|
break; |
260 |
|
|
} |
261 |
|
|
return 0; |
262 |
|
|
} |
263 |
|
|
|
264 |
|
|
int MakeStamps::rigidBodyMembers( event* the_event ){ |
265 |
|
|
|
266 |
|
|
int i; |
267 |
|
|
|
268 |
|
|
if( the_event->evt.mbrs.nMembers > 0 ){ |
269 |
|
|
|
270 |
|
|
for (i = 0; i < the_event->evt.mbrs.nMembers; i++) { |
271 |
|
|
current_rigidbody->addMember(the_event->evt.mbrs.memberList[i]); |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
return 1; |
275 |
|
|
|
276 |
|
|
} else { |
277 |
|
|
the_event->err_msg = strdup( "MakeStamp error. No members in memberList " |
278 |
|
|
" for this rigidBody."); |
279 |
|
|
return 0; |
280 |
|
|
|
281 |
|
|
} |
282 |
|
|
} |
283 |
|
|
|
284 |
|
|
int MakeStamps::rigidBodyEnd( event* the_event ){ |
285 |
|
|
|
286 |
|
|
the_event->err_msg = current_rigidbody->checkMe(); |
287 |
|
|
if( the_event->err_msg != NULL ) return 0; |
288 |
|
|
|
289 |
|
|
return 1; |
290 |
|
|
} |
291 |
|
|
|
292 |
|
|
int MakeStamps::newCutoffGroup( event* the_event ){ |
293 |
|
|
|
294 |
|
|
current_cutoffgroup = new CutoffGroupStamp; |
295 |
|
|
|
296 |
|
|
the_event->err_msg = current_mol->addCutoffGroup( current_cutoffgroup, |
297 |
|
|
the_event->evt.blk_index ); |
298 |
|
|
if( the_event->err_msg != NULL ) return 0; |
299 |
|
|
return 1; |
300 |
|
|
} |
301 |
|
|
|
302 |
|
|
int MakeStamps::cutoffGroupAssign( event* the_event ){ |
303 |
|
|
|
304 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
305 |
|
|
|
306 |
|
|
case STRING: |
307 |
|
|
the_event->err_msg = |
308 |
|
|
current_cutoffgroup->assignString( the_event->evt.asmt.lhs, |
309 |
|
|
the_event->evt.asmt.rhs.sval ); |
310 |
|
|
if( the_event->err_msg != NULL ) return 0; |
311 |
|
|
return 1; |
312 |
|
|
break; |
313 |
|
|
|
314 |
|
|
case DOUBLE: |
315 |
|
|
the_event->err_msg = |
316 |
|
|
current_cutoffgroup->assignDouble( the_event->evt.asmt.lhs, |
317 |
|
|
the_event->evt.asmt.rhs.dval ); |
318 |
|
|
if( the_event->err_msg != NULL ) return 0; |
319 |
|
|
return 1; |
320 |
|
|
break; |
321 |
|
|
|
322 |
|
|
case INT: |
323 |
|
|
the_event->err_msg = |
324 |
|
|
current_cutoffgroup->assignInt( the_event->evt.asmt.lhs, |
325 |
|
|
the_event->evt.asmt.rhs.ival ); |
326 |
|
|
if( the_event->err_msg != NULL ) return 0; |
327 |
|
|
return 1; |
328 |
|
|
break; |
329 |
|
|
|
330 |
|
|
default: |
331 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid CutoffGroup" |
332 |
|
|
" assignment type" ); |
333 |
|
|
return 0; |
334 |
|
|
break; |
335 |
|
|
} |
336 |
|
|
return 0; |
337 |
|
|
} |
338 |
|
|
|
339 |
|
|
int MakeStamps::cutoffGroupMembers( event* the_event ){ |
340 |
|
|
|
341 |
|
|
int i; |
342 |
|
|
|
343 |
|
|
if( the_event->evt.mbrs.nMembers > 0 ){ |
344 |
|
|
|
345 |
|
|
for (i = 0; i < the_event->evt.mbrs.nMembers; i++) { |
346 |
|
|
current_cutoffgroup->addMember(the_event->evt.mbrs.memberList[i]); |
347 |
|
|
} |
348 |
|
|
|
349 |
|
|
return 1; |
350 |
|
|
|
351 |
|
|
} else { |
352 |
|
|
the_event->err_msg = strdup( "MakeStamp error. No members in memberList " |
353 |
|
|
" for this CutoffGroup."); |
354 |
|
|
return 0; |
355 |
|
|
|
356 |
|
|
} |
357 |
|
|
} |
358 |
|
|
|
359 |
|
|
int MakeStamps::cutoffGroupEnd( event* the_event ){ |
360 |
|
|
|
361 |
|
|
the_event->err_msg = current_cutoffgroup->checkMe(); |
362 |
|
|
if( the_event->err_msg != NULL ) return 0; |
363 |
|
|
|
364 |
|
|
return 1; |
365 |
|
|
} |
366 |
|
|
|
367 |
|
|
int MakeStamps::newAtom( event* the_event ){ |
368 |
|
|
|
369 |
|
|
current_atom = new AtomStamp; |
370 |
|
|
|
371 |
|
|
the_event->err_msg = current_mol->addAtom( current_atom, |
372 |
|
|
the_event->evt.blk_index ); |
373 |
|
|
|
374 |
|
|
if( the_event->err_msg != NULL ) return 0; |
375 |
|
|
return 1; |
376 |
|
|
} |
377 |
|
|
|
378 |
|
|
int MakeStamps::atomPosition( event* the_event ){ |
379 |
|
|
|
380 |
|
|
current_atom->setPosition( the_event->evt.pos.x, |
381 |
|
|
the_event->evt.pos.y, |
382 |
|
|
the_event->evt.pos.z ); |
383 |
|
|
return 1; |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
|
387 |
|
|
int MakeStamps::atomOrientation( event* the_event ){ |
388 |
|
|
|
389 |
|
|
current_atom->setOrientation( the_event->evt.ornt.phi, |
390 |
|
|
the_event->evt.ornt.theta, |
391 |
|
|
the_event->evt.ornt.psi ); |
392 |
|
|
return 1; |
393 |
|
|
} |
394 |
|
|
|
395 |
|
|
int MakeStamps::atomAssign( event* the_event ){ |
396 |
|
|
|
397 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
398 |
|
|
|
399 |
|
|
case STRING: |
400 |
|
|
the_event->err_msg = |
401 |
|
|
current_atom->assignString( the_event->evt.asmt.lhs, |
402 |
|
|
the_event->evt.asmt.rhs.sval ); |
403 |
|
|
if( the_event->err_msg != NULL ) return 0; |
404 |
|
|
return 1; |
405 |
|
|
break; |
406 |
|
|
|
407 |
|
|
case DOUBLE: |
408 |
|
|
the_event->err_msg = |
409 |
|
|
current_atom->assignDouble( the_event->evt.asmt.lhs, |
410 |
|
|
the_event->evt.asmt.rhs.dval ); |
411 |
|
|
if( the_event->err_msg != NULL ) return 0; |
412 |
|
|
return 1; |
413 |
|
|
break; |
414 |
|
|
|
415 |
|
|
case INT: |
416 |
|
|
the_event->err_msg = |
417 |
|
|
current_atom->assignInt( the_event->evt.asmt.lhs, |
418 |
|
|
the_event->evt.asmt.rhs.ival ); |
419 |
|
|
if( the_event->err_msg != NULL ) return 0; |
420 |
|
|
return 1; |
421 |
|
|
break; |
422 |
|
|
|
423 |
|
|
default: |
424 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid atom" |
425 |
|
|
" assignment type" ); |
426 |
|
|
return 0; |
427 |
|
|
break; |
428 |
|
|
} |
429 |
|
|
return 0; |
430 |
|
|
} |
431 |
|
|
|
432 |
|
|
int MakeStamps::atomEnd( event* the_event ){ |
433 |
|
|
|
434 |
|
|
the_event->err_msg = current_atom->checkMe(); |
435 |
|
|
if( the_event->err_msg != NULL ) return 0; |
436 |
|
|
|
437 |
|
|
return 1; |
438 |
|
|
} |
439 |
|
|
|
440 |
|
|
int MakeStamps::newBond( event* the_event ){ |
441 |
|
|
|
442 |
|
|
current_bond = new BondStamp; |
443 |
|
|
|
444 |
|
|
the_event->err_msg = current_mol->addBond( current_bond, |
445 |
|
|
the_event->evt.blk_index ); |
446 |
|
|
if( the_event->err_msg != NULL ) return 0; |
447 |
|
|
|
448 |
|
|
return 1; |
449 |
|
|
} |
450 |
|
|
|
451 |
|
|
int MakeStamps::bondAssign( event* the_event ){ |
452 |
|
|
|
453 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
454 |
|
|
|
455 |
|
|
case STRING: |
456 |
|
|
current_bond->assignString( the_event->evt.asmt.lhs, |
457 |
|
|
the_event->evt.asmt.rhs.sval ); |
458 |
|
|
return 1; |
459 |
|
|
break; |
460 |
|
|
|
461 |
|
|
case DOUBLE: |
462 |
|
|
current_bond->assignDouble( the_event->evt.asmt.lhs, |
463 |
|
|
the_event->evt.asmt.rhs.dval ); |
464 |
|
|
return 1; |
465 |
|
|
break; |
466 |
|
|
|
467 |
|
|
case INT: |
468 |
|
|
current_bond->assignInt( the_event->evt.asmt.lhs, |
469 |
|
|
the_event->evt.asmt.rhs.ival ); |
470 |
|
|
return 1; |
471 |
|
|
break; |
472 |
|
|
|
473 |
|
|
default: |
474 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid bond" |
475 |
|
|
" assignment type" ); |
476 |
|
|
return 0; |
477 |
|
|
break; |
478 |
|
|
} |
479 |
|
|
return 0; |
480 |
|
|
} |
481 |
|
|
|
482 |
|
|
int MakeStamps::bondMembers( event* the_event ){ |
483 |
|
|
|
484 |
|
|
if( the_event->evt.mbrs.nMembers == 2 ){ |
485 |
|
|
|
486 |
|
|
current_bond->members( the_event->evt.mbrs.memberList[0], |
487 |
|
|
the_event->evt.mbrs.memberList[1] ); |
488 |
|
|
return 1; |
489 |
|
|
|
490 |
|
|
} else { |
491 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Wrong number of members " |
492 |
|
|
" in bond"); |
493 |
|
|
return 0; |
494 |
|
|
|
495 |
|
|
} |
496 |
|
|
|
497 |
|
|
} |
498 |
|
|
|
499 |
|
|
int MakeStamps::bondConstraint( event* the_event ){ |
500 |
|
|
|
501 |
|
|
current_bond->constrain( the_event->evt.cnstr ); |
502 |
|
|
return 1; |
503 |
|
|
} |
504 |
|
|
|
505 |
|
|
int MakeStamps::bondEnd( event* the_event ){ |
506 |
|
|
|
507 |
|
|
the_event->err_msg = current_bond->checkMe(); |
508 |
|
|
if( the_event->err_msg != NULL ) return 0; |
509 |
|
|
|
510 |
|
|
return 1; |
511 |
|
|
} |
512 |
|
|
|
513 |
|
|
int MakeStamps::newBend( event* the_event ){ |
514 |
|
|
|
515 |
|
|
current_bend = new BendStamp; |
516 |
|
|
|
517 |
|
|
the_event->err_msg = current_mol->addBend( current_bend, |
518 |
|
|
the_event->evt.blk_index ); |
519 |
|
|
if( the_event->err_msg != NULL ) return 0; |
520 |
|
|
|
521 |
|
|
return 1; |
522 |
|
|
} |
523 |
|
|
|
524 |
|
|
int MakeStamps::bendAssign( event* the_event ){ |
525 |
|
|
|
526 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
527 |
|
|
|
528 |
|
|
case STRING: |
529 |
|
|
current_bend->assignString( the_event->evt.asmt.lhs, |
530 |
|
|
the_event->evt.asmt.rhs.sval ); |
531 |
|
|
return 1; |
532 |
|
|
break; |
533 |
|
|
|
534 |
|
|
case DOUBLE: |
535 |
|
|
current_bend->assignDouble( the_event->evt.asmt.lhs, |
536 |
|
|
the_event->evt.asmt.rhs.dval ); |
537 |
|
|
return 1; |
538 |
|
|
break; |
539 |
|
|
|
540 |
|
|
case INT: |
541 |
|
|
current_bend->assignInt( the_event->evt.asmt.lhs, |
542 |
|
|
the_event->evt.asmt.rhs.ival ); |
543 |
|
|
return 1; |
544 |
|
|
break; |
545 |
|
|
|
546 |
|
|
default: |
547 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid bend" |
548 |
|
|
" assignment type" ); |
549 |
|
|
return 0; |
550 |
|
|
break; |
551 |
|
|
} |
552 |
|
|
return 0; |
553 |
|
|
} |
554 |
|
|
|
555 |
|
|
int MakeStamps::bendMembers( event* the_event ){ |
556 |
|
|
|
557 |
|
|
|
558 |
|
|
switch( the_event->evt.mbrs.nMembers ) { |
559 |
|
|
case 3: |
560 |
|
|
current_bend->members( the_event->evt.mbrs.memberList[0], |
561 |
|
|
the_event->evt.mbrs.memberList[1], |
562 |
|
|
the_event->evt.mbrs.memberList[2]); |
563 |
|
|
return 1; |
564 |
|
|
break; |
565 |
|
|
case 2: |
566 |
|
|
current_bend->members( the_event->evt.mbrs.memberList[0], |
567 |
|
|
the_event->evt.mbrs.memberList[1], |
568 |
|
|
0 ); |
569 |
|
|
return 1; |
570 |
|
|
break; |
571 |
|
|
default: |
572 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Wrong number of members " |
573 |
|
|
"in bend."); |
574 |
|
|
return 0; |
575 |
|
|
break; |
576 |
|
|
} |
577 |
|
|
return 0; |
578 |
|
|
} |
579 |
|
|
|
580 |
|
|
int MakeStamps::bendConstraint( event* the_event ){ |
581 |
|
|
|
582 |
|
|
current_bend->constrain( the_event->evt.cnstr ); |
583 |
|
|
return 1; |
584 |
|
|
} |
585 |
|
|
|
586 |
|
|
int MakeStamps::bendEnd( event* the_event ){ |
587 |
|
|
|
588 |
|
|
the_event->err_msg = current_bend->checkMe(); |
589 |
|
|
if( the_event->err_msg != NULL ) return 0; |
590 |
|
|
|
591 |
|
|
return 1; |
592 |
|
|
} |
593 |
|
|
|
594 |
|
|
int MakeStamps::newTorsion( event* the_event ){ |
595 |
|
|
|
596 |
|
|
current_torsion = new TorsionStamp; |
597 |
|
|
|
598 |
|
|
the_event->err_msg = current_mol->addTorsion( current_torsion, |
599 |
|
|
the_event->evt.blk_index ); |
600 |
|
|
if( the_event->err_msg != NULL ) return 0; |
601 |
|
|
|
602 |
|
|
return 1; |
603 |
|
|
} |
604 |
|
|
|
605 |
|
|
int MakeStamps::torsionAssign( event* the_event ){ |
606 |
|
|
|
607 |
|
|
switch( the_event->evt.asmt.asmt_type ){ |
608 |
|
|
|
609 |
|
|
case STRING: |
610 |
|
|
current_torsion->assignString( the_event->evt.asmt.lhs, |
611 |
|
|
the_event->evt.asmt.rhs.sval ); |
612 |
|
|
return 1; |
613 |
|
|
break; |
614 |
|
|
|
615 |
|
|
case DOUBLE: |
616 |
|
|
current_torsion->assignDouble( the_event->evt.asmt.lhs, |
617 |
|
|
the_event->evt.asmt.rhs.dval ); |
618 |
|
|
return 1; |
619 |
|
|
break; |
620 |
|
|
|
621 |
|
|
case INT: |
622 |
|
|
current_torsion->assignInt( the_event->evt.asmt.lhs, |
623 |
|
|
the_event->evt.asmt.rhs.ival ); |
624 |
|
|
return 1; |
625 |
|
|
break; |
626 |
|
|
|
627 |
|
|
default: |
628 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Invalid torsion" |
629 |
|
|
" assignment type" ); |
630 |
|
|
return 0; |
631 |
|
|
break; |
632 |
|
|
} |
633 |
|
|
return 0; |
634 |
|
|
} |
635 |
|
|
|
636 |
|
|
int MakeStamps::torsionMembers( event* the_event ){ |
637 |
|
|
|
638 |
|
|
if( the_event->evt.mbrs.nMembers == 4 ){ |
639 |
|
|
|
640 |
|
|
current_torsion->members( the_event->evt.mbrs.memberList[0], |
641 |
|
|
the_event->evt.mbrs.memberList[1], |
642 |
|
|
the_event->evt.mbrs.memberList[2], |
643 |
|
|
the_event->evt.mbrs.memberList[3]); |
644 |
|
|
return 1; |
645 |
|
|
|
646 |
|
|
} else { |
647 |
|
|
the_event->err_msg = strdup( "MakeStamp error. Wrong number of members " |
648 |
|
|
" in torsion"); |
649 |
|
|
return 0; |
650 |
|
|
|
651 |
|
|
} |
652 |
|
|
} |
653 |
|
|
|
654 |
|
|
int MakeStamps::torsionConstraint( event* the_event ){ |
655 |
|
|
|
656 |
|
|
current_torsion->constrain( the_event->evt.cnstr ); |
657 |
|
|
return 1; |
658 |
|
|
} |
659 |
|
|
|
660 |
|
|
int MakeStamps::torsionEnd( event* the_event ){ |
661 |
|
|
|
662 |
|
|
the_event->err_msg = current_torsion->checkMe(); |
663 |
|
|
if( the_event->err_msg != NULL ) return 0; |
664 |
|
|
|
665 |
|
|
return 1; |
666 |
|
|
} |