Computer Assited Medical Intervention Tool Kit  version 3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
BasicAtomProperties.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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 BASICATOMPROPERTIES_H
27 #define BASICATOMPROPERTIES_H
28 
29 
30 #include "PhysicalModelIO.h"
31 #include "StructureProperties.h"
42 public:
47 
52  BasicAtomProperties(PhysicalModel *myPM, xmlNodePtr n);
53 
58  BasicAtomProperties(PhysicalModel *myPM, const unsigned int ind);
59 
64  BasicAtomProperties(PhysicalModel *myPM, const double pos[3]);
65 
71  BasicAtomProperties(PhysicalModel *myPM, const unsigned int ind, const double pos[3]);
72 
74  virtual ~BasicAtomProperties();
75 
77  virtual void xmlPrint(std::ostream &) =0;
78 
82  static void resetUniqueIndex();
83 
85  void getPosition(double pos[3]) const;
86 
88  void setPosition(const double [3]);
89 
91  void setPosition(const double, const double, const double);
92 
101  void setPositionPointer(double *ptr, bool update = true);
102 
103 protected:
105  void beginXML(std::ostream &);
106 
108  void endXML(std::ostream &);
109 
110 private:
112  static unsigned int maxUniqueIndex;
113 
118  void allocate();
119 
121  double *X;
122 
124  bool allocated;
125 };
126 
127 // --------------- inlines ---------------
128 inline void BasicAtomProperties::getPosition(double pos[3]) const {
129  pos[0]=X[0];
130  pos[1]=X[1];
131  pos[2]=X[2];
132 }
133 
134 inline void BasicAtomProperties::setPosition(const double pos[3]) {
135  X[0]=pos[0];
136  X[1]=pos[1];
137  X[2]=pos[2];
138 }
139 
140 inline void BasicAtomProperties::setPosition(const double x,const double y,const double z) {
141  X[0]=x;
142  X[1]=y;
143  X[2]=z;
144 }
145 
146 #endif //BasicAtomProperties_H
void update(MultiComponent *mc)
Definition: optimizeMesh.cpp:188
double * X
Pointer to the memory triplet that stores the atom's position.
Definition: BasicAtomProperties.h:121
static void resetUniqueIndex()
Reinitialize the unique index to zero (usually that what you want to do when you start to load a new ...
Definition: BasicAtomProperties.cpp:28
virtual ~BasicAtomProperties()
the destructor...
Definition: BasicAtomProperties.cpp:127
void allocate()
allocate the memory needed for the position (double[3]).
Definition: BasicAtomProperties.cpp:133
void setPosition(const double[3])
set the position of the atom
Definition: BasicAtomProperties.h:134
static unsigned int maxUniqueIndex
unique number (used to generate unique index for atoms if not given at the instanciation) ...
Definition: BasicAtomProperties.h:112
bool allocated
true only if the memory used for the position was allocated in the constructor and not changed afterw...
Definition: BasicAtomProperties.h:124
virtual void xmlPrint(std::ostream &)=0
print to an output stream in "pseudo" XML format.
BasicAtomProperties(PhysicalModel *myPM)
Default constructor : set the position to the origin, and generate an unique index.
Definition: BasicAtomProperties.cpp:36
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: BasicAtomProperties.h:128
PhysicalModel * myPM
pointer to the physical model the object is in
Definition: Properties.h:134
This is the main class of this project.
Definition: PhysicalModel.h:74
Describes the properties common to all structures.
Definition: StructureProperties.h:38
This class is the basic Atom Properties class.
Definition: BasicAtomProperties.h:41
void endXML(std::ostream &)
write the default xml properties (end)
Definition: BasicAtomProperties.cpp:167
void beginXML(std::ostream &)
write the default xml properties (beginning)
Definition: BasicAtomProperties.cpp:158
void setPositionPointer(double *ptr, bool update=true)
change the position pointer.
Definition: BasicAtomProperties.cpp:139