Computer Assisted Medical Intervention Tool Kit  version 5.2
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-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, 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
This class manages all the properties attached to an atom.
Definition: AtomProperties.h:45
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
AtomProperties(PhysicalModel *myPM)
Default constructor : set the position to the origin, and generate an unique index.
Definition: AtomProperties.cpp:44
void setPositionPointer(double *ptr, bool update=true)
change the position pointer.
Definition: AtomProperties.cpp:106
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: AtomProperties.h:125
~AtomProperties() override
the destructor...
Definition: AtomProperties.cpp:93
void setPosition(const double[3])
set the position of the atom
Definition: AtomProperties.h:131
virtual void xmlPrint(std::ostream &)
print to an output stream in "pseudo" XML format.
Definition: AtomProperties.cpp:129
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
This is the main class of this project.
Definition: PhysicalModel.h:86
Describes the properties common to all structures.
Definition: StructureProperties.h:38
Definition: Atom.h:36