Computer Assited Medical Intervention Tool Kit  version 5.0
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-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 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
Atom::getProperties
AtomProperties * getProperties() const
Get a ptr to the AtomProperties.
Definition: Atom.h:135
PhysicalModel::addGlobalIndexAtomPair
bool addGlobalIndexAtomPair(std::GlobalIndexStructurePair)
add or update a pair to the atom map.
Definition: PhysicalModel.cpp:605
AtomProperties::setPosition
void setPosition(const double[3])
set the position of the atom
Definition: AtomProperties.h:131
AtomProperties.h
Atom::getPosition
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: Atom.h:121
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
std::GlobalIndexStructurePair
std::pair< unsigned int, Structure * > GlobalIndexStructurePair
definition of a couple (=STL pair) (int , Structure *) this associates a global cell/atom index to th...
Definition: PhysicalModel.h:66
RenderingMode.h
Structure::getIndex
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:30
Atom::~Atom
~Atom() override
std destructor
Definition: Atom.cpp:57
Atom::Atom
Atom(PhysicalModel *myPM)
Default constructor : set the position to the origin, generate a unique index.
Definition: Atom.cpp:34
StructuralComponent
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
Structure
Pure virtual class that represent an element of the structure. This implies that every structure coul...
Definition: Structure.h:43
Atom.h
Atom::indexInAtoms
unsigned int indexInAtoms
Definition: Atom.h:117
Atom::setIndex
bool setIndex(const unsigned int) override
set the index.
Definition: Atom.cpp:63
PhysicalModel
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:86
Properties::getPhysicalModel
PhysicalModel * getPhysicalModel() const
get the physical model
Definition: Properties.h:262
Atom::xmlPrint
void xmlPrint(std::ostream &, const StructuralComponent *) override
print to an output stream in "pseudo" XML format.
Definition: Atom.cpp:76
Atom::isInstanceOf
bool isInstanceOf(const char *) const override
return true only if the parameter is equal to "Atom"
Definition: Atom.h:132
Structure::properties
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
StructuralComponent.h
Atom::setPosition
void setPosition(const double[3])
set the position of the atom
Definition: Atom.h:125
Atom::getIndexInAtoms
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
AtomProperties::getPosition
void getPosition(double pos[3]) const
get the position of the atom (array of 3 doubles)
Definition: AtomProperties.h:125
PhysicalModel.h
physicalModel
Definition: Atom.h:36
PhysicalModel::getAtoms
StructuralComponent * getAtoms() const
get all the atoms
Definition: PhysicalModel.h:380
Structure.h
Structure::setIndex
virtual bool setIndex(const unsigned int)
set the index.
Definition: Structure.cpp:34