Computer Assited Medical Intervention Tool Kit  version 5.0
Cell.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 CELL_H
27 #define CELL_H
28 
29 #include "Structure.h"
30 #include "StructuralComponent.h"
31 
32 //pmlschema forward declarations
33 namespace physicalModel {
34 class Cell;
35 }
36 
37 class CellProperties;
46 class Cell : public Structure, public StructuralComponent {
47 public:
53 
59  Cell(PhysicalModel* myPM, physicalModel::Cell xmlCell, StructuralComponent* sc);
60 
66  Cell(PhysicalModel* myPM, const StructureProperties::GeometricType t, const unsigned int ind);
67 
69  ~Cell() override;
70 
76 // as Cell inherits both Structure and StructuralComponent, it is correct to override
77 // the xmlPrint in StructuralComponent while reimplementing xmlPrint from Structure
78 #if defined(__has_warning)
79 # pragma GCC diagnostic push
80 # if __has_warning("-Woverloaded-virtual")
81 # pragma GCC diagnostic ignored "-Woverloaded-virtual"
82 # endif
83 #endif
84  void xmlPrint(std::ostream&, const StructuralComponent*) override;
85 #if defined(__has_warning)
86 # pragma GCC diagnostic pop
87 #endif
88 
89 
91  bool isInstanceOf(const char*) const override;
92 
99  void deleteAllStructures() override;
100 
103 
106 
110  bool makePrintData(const StructuralComponent*);
111 
118  bool setIndex(const unsigned int) override;
119 
123  double* normal();
124 
127 
130 
132  double surface();
133 
135  double volume();
136 
148  double signedVolumeTriangle(double p1[3], double p2[3], double p3[3]);
149 
152  return this->parentSC;
153  }
154 
157 
158 private:
161 
162 };
163 
164 // ------- INLINE -----------
165 inline bool Cell::isInstanceOf(const char* className) const {
166  return (std::string(className) == std::string("Cell"));
167 }
168 
171 }
172 
175  if (!parentSC) {
176  parentSC = sc;
177  }
178 }
179 
180 #endif //CELL_H
Cell::setIndex
bool setIndex(const unsigned int) override
set the index.
Definition: Cell.cpp:139
StructuralComponent::ComposedBy
ComposedBy
What this structural component is made of.
Definition: StructuralComponent.h:173
Cell::addStructuralComponent
void addStructuralComponent(StructuralComponent *) override
add a particular StructuralComponent in the list (and set parentSC if null)
Definition: Cell.h:173
Cell.h
Cell::surface
double surface()
Compute the surface of the cell.
Definition: Cell.cpp:492
Cell::getQuadFaces
StructuralComponent * getQuadFaces()
Return a new structural component directly representing the Cell as a list of quad faces (when possib...
Definition: Cell.cpp:385
StructureProperties::WEDGE
@ WEDGE
the structure is a wedge (like the Pink Floyd's "Dark Side Of the Moon" prism), it must be a cell and...
Definition: StructureProperties.h:160
StructureProperties::TETRAHEDRON
@ TETRAHEDRON
the structure is a tetrahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:159
StructuralComponent::getNumberOfStructures
unsigned int getNumberOfStructures() const
get the number of structures
Definition: StructuralComponent.h:252
StructureProperties::GeometricType
GeometricType
Geometric type gives information about which kind of geometric representation is the structure.
Definition: StructureProperties.h:130
Cell::~Cell
~Cell() override
the destructor, my tailor. BECAREFUL: the atoms should not not be deleted here...
Definition: Cell.cpp:118
PhysicalModel::addGlobalIndexCellPair
bool addGlobalIndexCellPair(std::GlobalIndexStructurePair)
add or update a pair to the cell map.
Definition: PhysicalModel.cpp:633
Structure::getType
StructureProperties::GeometricType getType() const
get the type of index
Definition: Structure.cpp:40
Atom
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
Cell::Cell
Cell(PhysicalModel *myPM, const StructureProperties::GeometricType t)
constructor that generates a unique index
Definition: Cell.cpp:36
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
Component::removeFromParents
void removeFromParents()
this tell the parent components that this component is removed from memory.
Definition: modeling/libraries/pml/Component.cpp:48
Cell::xmlPrint
void xmlPrint(std::ostream &, const StructuralComponent *) override
print to an output stream in "pseudo" XML format.
Definition: Cell.cpp:179
Cell::normal
double * normal()
compute the normal of the facet Warning : Only available for QUAD and TRIANGLE type cells
Definition: Cell.cpp:460
CellProperties.h
Cell::volume
double volume()
Compute the volume of the cell.
Definition: Cell.cpp:545
Cell::getProperties
CellProperties * getProperties()
return the property
Definition: Cell.cpp:226
Component::properties
Properties * properties
Definition: modeling/libraries/pml/Component.h:118
a
#define a
Structure::getNumberOfStructuralComponents
unsigned int getNumberOfStructuralComponents() const
get the number of StructuralComponent that are using this structure
Definition: Structure.h:117
PhysicalModel::getAtom
Atom * getAtom(const unsigned int id)
Get the atom that has the global index given in parameters.
Definition: PhysicalModel.h:385
Structure::getIndex
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:30
Cell::composedBy
StructuralComponent::ComposedBy composedBy() override
overloaded from Structural component, always return StructuralComponent::ATOMS
Definition: Cell.h:169
StructuralComponent::setColor
void setColor(const StructuralComponentProperties::Color c)
Set the new color (using a StructuralComponentProperties::Color enum)
Definition: StructuralComponent.cpp:105
Component::deleteProperties
void deleteProperties()
delete the "properties" pointer and set it to NULL
Definition: modeling/libraries/pml/Component.cpp:42
CellProperties
Describes and manages the properties attached to cells.
Definition: CellProperties.h:44
StructuralComponent
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
Cell::makePrintData
bool makePrintData(const StructuralComponent *)
is this sc the one that will be the one that will make the cell to print out all its data or is this ...
Definition: Cell.cpp:147
Structure
Pure virtual class that represent an element of the structure. This implies that every structure coul...
Definition: Structure.h:43
StructuralComponent::addStructure
void addStructure(Structure *s, bool check=true)
Add a Structure in the list (and tells the structure to add this structural component in its list).
Definition: StructuralComponent.h:212
StructuralComponentProperties
A class that manages the structural component properties.
Definition: StructuralComponentProperties.h:44
StructuralComponent::StructuralComponent
StructuralComponent(PhysicalModel *)
Default Constructor.
Definition: StructuralComponent.cpp:37
Structure::addStructuralComponent
virtual void addStructuralComponent(StructuralComponent *)
add a particular StructuralComponent in the list
Definition: Structure.h:128
PhysicalModel
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:86
StructureProperties::INVALID
@ INVALID
invalid geometry type
Definition: StructureProperties.h:154
Cell
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:46
Cell::getTriangleFaces
StructuralComponent * getTriangleFaces()
Return a new structural component directly representing the Cell as a list of triangular faces (when ...
Definition: Cell.cpp:231
StructureProperties::PYRAMID
@ PYRAMID
the structure has a quad base and one vertex outside the defined base plane (like an egyptian pyramid...
Definition: StructureProperties.h:161
Structure::properties
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
StructuralComponent.h
Cell::getParentSC
const StructuralComponent * getParentSC()
Get the direct parent structural that own this cell.
Definition: Cell.h:151
StructuralComponent::structures
std::vector< Structure * > structures
List of the structure representing this component, all the structure in this list are either all Atom...
Definition: StructuralComponent.h:203
StructuralComponent::getColor
double * getColor() const
Get the color.
Definition: StructuralComponent.cpp:116
StructureProperties::HEXAHEDRON
@ HEXAHEDRON
the structure is a hexahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:162
StructuralComponentProperties::DEFAULT
@ DEFAULT
no color given, decided by the GUI
Definition: StructuralComponentProperties.h:50
StructuralComponent::atomList
StructuralComponent * atomList
List of all the atoms of this structural component, build the first time.
Definition: StructuralComponent.h:207
StructureProperties::TRIANGLE
@ TRIANGLE
the structure is a triangle, i.e it must be a cell composed of 3 atoms
Definition: StructureProperties.h:157
StructureProperties::LINE
@ LINE
the structure is a simple line, i.e it must be a cell composed of only 2 atoms
Definition: StructureProperties.h:156
Cell::deleteAllStructures
void deleteAllStructures() override
This method overload the one defined in StructuralComponent.
Definition: Cell.cpp:215
StructuralComponent::getStructure
Structure * getStructure(const unsigned int) const
get a structure by its index (fisrt structure is at index 0)
Definition: StructuralComponent.h:220
Cell::isInstanceOf
bool isInstanceOf(const char *) const override
return true only if the parameter is equal to "MultiComponent"
Definition: Cell.h:165
PhysicalModel.h
physicalModel
Definition: Atom.h:36
StructuralComponent::getCell
Cell * getCell(unsigned int) const override
get cell by order number (not cell index)
Definition: StructuralComponent.cpp:197
StructureProperties::POLY_VERTEX
@ POLY_VERTEX
the structure is a poly vertex, i.e it must be a cell and it is a point clouds
Definition: StructureProperties.h:164
StructureProperties::ATOM
@ ATOM
the structure is an atom, and hence should be represented by a single point
Definition: StructureProperties.h:155
Cell::parentSC
StructuralComponent * parentSC
Keep a reference to the direct parent structural component.
Definition: Cell.h:160
Structure.h
StructureProperties::QUAD
@ QUAD
the structure is a quad, i.e it must be a cell composed of 4 atoms
Definition: StructureProperties.h:158
Structure::setIndex
virtual bool setIndex(const unsigned int)
set the index.
Definition: Structure.cpp:34
StructuralComponent::getNumberOfCells
unsigned int getNumberOfCells() const override
get the total nr of cell of the component
Definition: StructuralComponent.cpp:183
Cell::signedVolumeTriangle
double signedVolumeTriangle(double p1[3], double p2[3], double p3[3])
Compute the volume of a triangle with the origin of the coordinate system.
Definition: Cell.cpp:598
StructuralComponent::ATOMS
@ ATOMS
the structural component is made of atoms
Definition: StructuralComponent.h:176
Structure::getStructuralComponent
StructuralComponent * getStructuralComponent(unsigned int i)
get a particular StructuralComponent that is using this structure
Definition: Structure.h:120
Component::isExclusive
bool isExclusive() const
tell if this component is exclusive or not
Definition: modeling/libraries/pml/Component.h:144
StructureProperties::POLY_LINE
@ POLY_LINE
the structure is a polyline, i.e it must be a cell and the order of the atom in the cell are arranged...
Definition: StructureProperties.h:163
Component::getPhysicalModel
PhysicalModel * getPhysicalModel() const
get the physical model
Definition: modeling/libraries/pml/Component.h:184
StructuralComponent::plannedNumberOfStructures
void plannedNumberOfStructures(const unsigned int)
optimize the I/O of the std:vector structures.
Definition: StructuralComponent.h:270