Computer Assited Medical Intervention Tool Kit  version 5.0
Structure.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 STRUCTURE_H
27 #define STRUCTURE_H
28 
29 #include "PhysicalModelIO.h"
30 #include <vector>
31 #include <algorithm> // for the remove
32 #include "StructureProperties.h"
43 class Structure {
44 public:
47  hasIndex = false;
48  }
50  virtual ~Structure() = default;
51 
55  virtual void xmlPrint(std::ostream&, const StructuralComponent*) = 0;
56 
58  virtual bool isInstanceOf(const char*) const = 0;
59 
61  bool hasIndex;
62 
64  unsigned int getIndex() const;
65 
72  virtual bool setIndex(const unsigned int);
73 
76 
78  std::vector <StructuralComponent*> getAllStructuralComponents();
79 
81  unsigned int getNumberOfStructuralComponents() const;
82 
85 
88 
91 
93  void setName(std::string);
94 
96  std::string getName() const;
97 
99  virtual void setPhysicalModel(PhysicalModel*);
100 
101 protected:
102 
105 
106 private:
107 
109  std::vector <StructuralComponent*> mySCs;
110 
111 };
112 
113 // -------------------- inline ---------------------
114 inline std::vector <StructuralComponent*> Structure::getAllStructuralComponents() {
115  return mySCs;
116 }
117 inline unsigned int Structure::getNumberOfStructuralComponents() const {
118  return (unsigned int) mySCs.size();
119 }
121  if (i < mySCs.size()) {
122  return mySCs[i];
123  }
124  else {
125  return nullptr;
126  }
127 }
129  mySCs.push_back(sc);
130 }
131 
133  auto it = std::find(mySCs.begin(), mySCs.end(), sc);
134  if (it != mySCs.end()) {
135  mySCs.erase(it);
136  }
137 }
138 
139 
140 #endif // STRUCTURE_H
StructureProperties
Describes the properties common to all structures.
Definition: StructureProperties.h:38
Structure::Structure
Structure()
Base constructor.
Definition: Structure.h:46
Structure::getName
std::string getName() const
get the name of the structure
Definition: Structure.cpp:48
Structure::~Structure
virtual ~Structure()=default
Virtual destructor needed here as this is an abstract class (pure virtual)
StructureProperties::GeometricType
GeometricType
Geometric type gives information about which kind of geometric representation is the structure.
Definition: StructureProperties.h:130
Structure::getType
StructureProperties::GeometricType getType() const
get the type of index
Definition: Structure.cpp:40
Structure::isInstanceOf
virtual bool isInstanceOf(const char *) const =0
pure virtual method, implemented in the child-class
Structure::xmlPrint
virtual void xmlPrint(std::ostream &, const StructuralComponent *)=0
print to an output stream in "pseaudo" XML format.
StructureProperties::getIndex
unsigned int getIndex() const
return the unique index in the global structure
Definition: StructureProperties.h:166
Structure::getNumberOfStructuralComponents
unsigned int getNumberOfStructuralComponents() const
get the number of StructuralComponent that are using this structure
Definition: Structure.h:117
StructureProperties.h
Structure::getIndex
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:30
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
Properties::getName
std::string getName() const
get the name (be careful, this method DOES NOT return a copy, so you got the direct ptr to the name!...
Definition: Properties.h:250
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
Properties::setPhysicalModel
void setPhysicalModel(PhysicalModel *)
set the physical model
Definition: Properties.h:258
PhysicalModelIO.h
Structure::properties
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
StructureProperties::setIndex
void setIndex(const unsigned int)
set the index (BECAREFUL: it MUST be unique !!!)
Definition: StructureProperties.h:169
Structure::setPhysicalModel
virtual void setPhysicalModel(PhysicalModel *)
set the physical model
Definition: Structure.cpp:53
Properties::setName
void setName(std::string)
set the name (use the string = operator)
Definition: Properties.h:254
Structure::hasIndex
bool hasIndex
indicate if the Structure has an index (which is not the case all the time)
Definition: Structure.h:61
Structure::getAllStructuralComponents
std::vector< StructuralComponent * > getAllStructuralComponents()
get the list of all the StructuralComponent that are using this structure
Definition: Structure.h:114
Structure.h
Structure::setIndex
virtual bool setIndex(const unsigned int)
set the index.
Definition: Structure.cpp:34
Structure::removeStructuralComponent
void removeStructuralComponent(StructuralComponent *)
remove a particular StructuralComponent from the list
Definition: Structure.h:132
Structure::getStructuralComponent
StructuralComponent * getStructuralComponent(unsigned int i)
get a particular StructuralComponent that is using this structure
Definition: Structure.h:120
Structure::setName
void setName(std::string)
set the name of the structure
Definition: Structure.cpp:44
StructureProperties::getType
GeometricType getType() const
Return the type of force.
Definition: StructureProperties.h:160
Structure::mySCs
std::vector< StructuralComponent * > mySCs
list of StructuralComponent that are using this structure
Definition: Structure.h:109