Computer Assited Medical Intervention Tool Kit  version 5.0
AtomProperties.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef ATOMPROPERTIES_H
27 #define ATOMPROPERTIES_H
28 
29 //pmlschema forward declarations
30 namespace physicalModel {
31 class Atom;
32 class AtomProperties;
33 }
34 
35 #include "PhysicalModelIO.h"
36 #include "StructureProperties.h"
37 
46 public:
51 
56  AtomProperties(PhysicalModel* myPM, physicalModel::AtomProperties xmlAtomProp);
57 
62  AtomProperties(PhysicalModel* myPM, const unsigned int ind);
63 
68  AtomProperties(PhysicalModel* myPM, const double pos[3]);
69 
75  AtomProperties(PhysicalModel* myPM, const unsigned int ind, const double pos[3]);
76 
78  ~AtomProperties() override;
79 
81  virtual void xmlPrint(std::ostream&);
82 
86  static void resetUniqueIndex();
87 
89  void getPosition(double pos[3]) const;
90 
92  void setPosition(const double [3]);
93 
95  void setPosition(const double, const double, const double);
96 
105  void setPositionPointer(double* ptr, bool update = true);
106 
107 private:
109  static unsigned int maxUniqueIndex;
110 
115  void allocate();
116 
118  double* X;
119 
121  bool allocated;
122 };
123 
124 // --------------- inlines ---------------
125 inline void AtomProperties::getPosition(double pos[3]) const {
126  pos[0] = X[0];
127  pos[1] = X[1];
128  pos[2] = X[2];
129 }
130 
131 inline void AtomProperties::setPosition(const double pos[3]) {
132  X[0] = pos[0];
133  X[1] = pos[1];
134  X[2] = pos[2];
135 }
136 
137 inline void AtomProperties::setPosition(const double x, const double y, const double z) {
138  X[0] = x;
139  X[1] = y;
140  X[2] = z;
141 }
142 
143 #endif // ATOMPROPERTIES_H
StructureProperties
Describes the properties common to all structures.
Definition: StructureProperties.h:38
AtomProperties::setPositionPointer
void setPositionPointer(double *ptr, bool update=true)
change the position pointer.
Definition: AtomProperties.cpp:106
AtomProperties::setPosition
void setPosition(const double[3])
set the position of the atom
Definition: AtomProperties.h:131
AtomProperties.h
AtomProperties
This class manages all the properties attached to an atom.
Definition: AtomProperties.h:45
Atom
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
AtomProperties::AtomProperties
AtomProperties(PhysicalModel *myPM)
Default constructor : set the position to the origin, and generate an unique index.
Definition: AtomProperties.cpp:44
Properties::xmlToFields
void xmlToFields(xsd::cxx::tree::attribute_set< char > attrs)
convert the xml node parameters to data fields
Definition: Properties.cpp:41
AtomProperties::allocate
void allocate()
allocate the memory needed for the position (double[3]).
Definition: AtomProperties.cpp:100
Properties::myPM
PhysicalModel * myPM
pointer to the physical model the object is in
Definition: Properties.h:136
AtomProperties::X
double * X
Pointer to the memory triplet that stores the atom's position.
Definition: AtomProperties.h:118
StructureProperties.h
AtomProperties::allocated
bool allocated
true only if the memory used for the position was allocated in the constructor and not changed afterw...
Definition: AtomProperties.h:121
Properties::getName
std::string getName() const
get the name (be careful, this method DOES NOT return a copy, so you got the direct ptr to the name!...
Definition: Properties.h:250
PhysicalModel
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:86
PhysicalModelIO.h
StructureProperties::setIndex
void setIndex(const unsigned int)
set the index (BECAREFUL: it MUST be unique !!!)
Definition: StructureProperties.h:169
AtomProperties::getPosition
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: AtomProperties.h:125
Properties::setName
void setName(std::string)
set the name (use the string = operator)
Definition: Properties.h:254
StructureProperties::index
unsigned int index
unique index in the global structure
Definition: StructureProperties.h:178
AtomProperties::~AtomProperties
~AtomProperties() override
the destructor...
Definition: AtomProperties.cpp:93
physicalModel
Definition: Atom.h:36
AtomProperties::maxUniqueIndex
static unsigned int maxUniqueIndex
unique number (used to generate unique index for atoms if not given at the instantiation)
Definition: AtomProperties.h:109
AtomProperties::xmlPrint
virtual void xmlPrint(std::ostream &)
print to an output stream in "pseudo" XML format.
Definition: AtomProperties.cpp:129
Properties::fields
std::map< std::string, std::string > fields
map containing all the different fields (name, value stored as string )
Definition: Properties.h:129
AtomProperties::resetUniqueIndex
static void resetUniqueIndex()
Reinitialize the unique index to zero (usually that what you want to do when you start to load a new ...
Definition: AtomProperties.cpp:36