1 |
+ |
/* |
2 |
+ |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
* |
4 |
+ |
* The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
* non-exclusive, royalty free, license to use, modify and |
6 |
+ |
* redistribute this software in source and binary code form, provided |
7 |
+ |
* that the following conditions are met: |
8 |
+ |
* |
9 |
+ |
* 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
* publication of scientific results based in part on use of the |
11 |
+ |
* program. An acceptable form of acknowledgement is citation of |
12 |
+ |
* the article in which the program was described (Matthew |
13 |
+ |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
* |
18 |
+ |
* 2. Redistributions of source code must retain the above copyright |
19 |
+ |
* notice, this list of conditions and the following disclaimer. |
20 |
+ |
* |
21 |
+ |
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
* notice, this list of conditions and the following disclaimer in the |
23 |
+ |
* documentation and/or other materials provided with the |
24 |
+ |
* distribution. |
25 |
+ |
* |
26 |
+ |
* This software is provided "AS IS," without a warranty of any |
27 |
+ |
* kind. All express or implied conditions, representations and |
28 |
+ |
* warranties, including any implied warranty of merchantability, |
29 |
+ |
* fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
* excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
* be liable for any damages suffered by licensee as a result of |
32 |
+ |
* using, modifying or distributing the software or its |
33 |
+ |
* derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
* licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
* direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
* damages, however caused and regardless of the theory of liability, |
37 |
+ |
* arising out of the use of or inability to use software, even if the |
38 |
+ |
* University of Notre Dame has been advised of the possibility of |
39 |
+ |
* such damages. |
40 |
+ |
*/ |
41 |
+ |
|
42 |
|
#include <stdlib.h> |
43 |
|
#include <stdio.h> |
44 |
|
#include <string.h> |
46 |
|
|
47 |
|
#include "types/AtomStamp.hpp" |
48 |
|
|
49 |
< |
AtomStamp::AtomStamp(){ |
50 |
< |
|
51 |
< |
unhandled = NULL; |
11 |
< |
have_position = 0; |
12 |
< |
have_orientation = 0; |
13 |
< |
have_type = 0; |
14 |
< |
have_extras = 0; |
49 |
> |
namespace oopse { |
50 |
> |
AtomStamp::AtomStamp(int index) : havePos_(false), haveOrt_(false), index_(index) { |
51 |
> |
DefineParameter(Type, "type"); |
52 |
|
} |
53 |
|
|
54 |
< |
AtomStamp::~AtomStamp(){ |
55 |
< |
|
56 |
< |
if( unhandled != NULL ) delete unhandled; |
54 |
> |
bool AtomStamp::setPosition(const std::vector<double>& pos) { |
55 |
> |
bool ret = false; |
56 |
> |
if (pos.size() == 3) { |
57 |
> |
position_[0] = pos[0]; |
58 |
> |
position_[1] = pos[1]; |
59 |
> |
position_[2] = pos[2]; |
60 |
> |
havePos_ = true; |
61 |
> |
}else { |
62 |
> |
std::cout << "invalid position\n"; |
63 |
> |
} |
64 |
> |
return ret; |
65 |
|
} |
66 |
|
|
67 |
< |
void AtomStamp::setPosition( double x, double y, double z ){ |
68 |
< |
|
69 |
< |
pos[0] = x; |
70 |
< |
pos[1] = y; |
71 |
< |
pos[2] = z; |
72 |
< |
|
73 |
< |
have_position = 1; |
67 |
> |
bool AtomStamp::setOrientation(const std::vector<double>& ort) { |
68 |
> |
bool ret = false; |
69 |
> |
if (ort.size() == 3) { |
70 |
> |
position_[0] = ort[0]; |
71 |
> |
position_[1] = ort[1]; |
72 |
> |
position_[2] = ort[2]; |
73 |
> |
haveOrt_ = true; |
74 |
> |
}else { |
75 |
> |
std::cout << "invalid orientation\n"; |
76 |
> |
} |
77 |
> |
|
78 |
> |
return ret; |
79 |
|
} |
80 |
|
|
81 |
< |
void AtomStamp::setOrientation( double phi, double theta, double psi ){ |
81 |
> |
AtomStamp* AtomStamp::getNextBondedAtom() { |
82 |
|
|
33 |
– |
ornt[0] = phi; |
34 |
– |
ornt[1] = theta; |
35 |
– |
ornt[2] = psi; |
36 |
– |
|
37 |
– |
have_orientation = 1; |
83 |
|
} |
84 |
|
|
85 |
< |
char* AtomStamp::assignString( char* lhs, char* rhs ){ |
86 |
< |
|
87 |
< |
if( !strcmp( lhs, "type" ) ){ |
43 |
< |
strcpy( type, rhs ); |
44 |
< |
have_type = 1; |
45 |
< |
} |
46 |
< |
else{ |
47 |
< |
if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); |
48 |
< |
else unhandled->add( lhs, rhs ); |
49 |
< |
have_extras = 1; |
50 |
< |
} |
51 |
< |
return NULL; |
85 |
> |
void AtomStamp::validate() { |
86 |
> |
DataHolder::validate(); |
87 |
> |
CheckParameter(Type, isNotEmpty()); |
88 |
|
} |
89 |
|
|
90 |
< |
char* AtomStamp::assignDouble( char* lhs, double rhs ){ |
55 |
< |
|
56 |
< |
if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); |
57 |
< |
else unhandled->add( lhs, rhs ); |
58 |
< |
have_extras = 1; |
59 |
< |
return NULL; |
60 |
< |
} |
61 |
< |
|
62 |
< |
char* AtomStamp::assignInt( char* lhs, int rhs ){ |
63 |
< |
|
64 |
< |
if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs ); |
65 |
< |
else unhandled->add( lhs, rhs ); |
66 |
< |
have_extras = 1; |
67 |
< |
return NULL; |
68 |
< |
} |
69 |
< |
|
70 |
< |
char* AtomStamp::checkMe( void ){ |
71 |
< |
|
72 |
< |
if( !have_type ){ |
73 |
< |
return strdup( "AtomStamp error. Atom was untyped." ); |
74 |
< |
} |
75 |
< |
return NULL; |
76 |
< |
} |
90 |
> |
} |