Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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]; pos[1]=X[1]; pos[2]=X[2];
130 }
131 
132 inline void BasicAtomProperties::setPosition(const double pos[3]) {
133  X[0]=pos[0]; X[1]=pos[1]; X[2]=pos[2];
134 }
135 
136 inline void BasicAtomProperties::setPosition(const double x,const double y,const double z) {
137  X[0]=x; X[1]=y; X[2]=z;
138 }
139 
140 #endif //BasicAtomProperties_H
double * X
Pointer to the memory triplet that stores the atom's position.
Definition: BasicAtomProperties.h:121
void allocate()
allocate the memory needed for the position (double[3]).
void setPosition(const double[3])
set the position of the atom
Definition: BasicAtomProperties.h:132
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.
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: BasicAtomProperties.h:128
virtual ~BasicAtomProperties()
the destructor...
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
static void resetUniqueIndex()
Reinitialize the unique index to zero (usually that what you want to do when you start to load a new ...
void endXML(std::ostream &)
write the default xml properties (end)
void beginXML(std::ostream &)
write the default xml properties (beginning)
void setPositionPointer(double *ptr, bool update=true)
change the position pointer.