Computer Assisted Medical Intervention Tool Kit  version 5.2
Atom.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 ATOM_H
27 #define ATOM_H
28 
29 #include <string>
30 
31 #include "Structure.h"
32 #include "AtomProperties.h"
33 #include "RenderingMode.h"
34 
35 //pmlschema forward declarations
36 namespace physicalModel {
37 class Atom;
38 }
39 
49 class Atom : public Structure {
50 public:
54  Atom(PhysicalModel* myPM);
55 
62  Atom(PhysicalModel* myPM, physicalModel::Atom atom, unsigned int id = -1);
63 
68  Atom(PhysicalModel* myPM, const double pos[3]);
69 
74  Atom(PhysicalModel* myPM, const unsigned int ind);
75 
81  Atom(PhysicalModel* myPM, const unsigned int ind, const double pos[3]);
82 
84  ~Atom() override;
85 
88  void xmlPrint(std::ostream&, const StructuralComponent*) override;
89 
91  void getPosition(double pos[3]) const;
92 
94  void setPosition(const double [3]);
95 
97  void setPosition(const double, const double, const double);
98 
105  bool setIndex(const unsigned int) override;
106 
108  unsigned int getIndexInAtoms() const;
109 
111  bool isInstanceOf(const char*) const override;
112 
114  AtomProperties* getProperties() const;
115 
116 private:
117  unsigned int indexInAtoms;
118 };
119 
120 // -------------------- inline ---------------------
121 inline void Atom::getPosition(double p[3]) const {
122  return getProperties()->getPosition(p);
123 }
124 
125 inline void Atom::setPosition(const double pos[3]) {
126  getProperties()->setPosition(pos);
127 }
128 inline void Atom::setPosition(const double x, const double y, const double z) {
129  getProperties()->setPosition(x, y, z);
130 }
131 
132 inline bool Atom::isInstanceOf(const char* className) const {
133  return (std::string(className) == std::string("Atom"));
134 }
136  return (AtomProperties*) properties;
137 }
138 
139 #endif //ATOM_H
This class manages all the properties attached to an atom.
Definition: AtomProperties.h:45
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: AtomProperties.h:125
void setPosition(const double[3])
set the position of the atom
Definition: AtomProperties.h:131
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
void xmlPrint(std::ostream &, const StructuralComponent *) override
print to an output stream in "pseudo" XML format.
Definition: Atom.cpp:76
void setPosition(const double[3])
set the position of the atom
Definition: Atom.h:125
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: Atom.h:121
unsigned int getIndexInAtoms() const
get the index of this atom in the global atom structural component, i.e. its order number in atoms
Definition: Atom.cpp:71
Atom(PhysicalModel *myPM)
Default constructor : set the position to the origin, generate a unique index.
Definition: Atom.cpp:34
~Atom() override
std destructor
Definition: Atom.cpp:57
AtomProperties * getProperties() const
Get a ptr to the AtomProperties.
Definition: Atom.h:135
bool isInstanceOf(const char *) const override
return true only if the parameter is equal to "Atom"
Definition: Atom.h:132
bool setIndex(const unsigned int) override
set the index.
Definition: Atom.cpp:63
This is the main class of this project.
Definition: PhysicalModel.h:86
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
Pure virtual class that represent an element of the structure.
Definition: Structure.h:43
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
Definition: Atom.h:36