Computer Assisted Medical Intervention Tool Kit  version 5.2
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-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 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
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
Describes the properties common to all structures.
Definition: StructureProperties.h:38
GeometricType
Geometric type gives information about which kind of geometric representation is the structure.
Definition: StructureProperties.h:107
Pure virtual class that represent an element of the structure.
Definition: Structure.h:43
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:30
void removeStructuralComponent(StructuralComponent *)
remove a particular StructuralComponent from the list
Definition: Structure.h:132
std::string getName() const
get the name of the structure
Definition: Structure.cpp:48
virtual void xmlPrint(std::ostream &, const StructuralComponent *)=0
print to an output stream in "pseaudo" XML format.
unsigned int getNumberOfStructuralComponents() const
get the number of StructuralComponent that are using this structure
Definition: Structure.h:117
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
bool hasIndex
indicate if the Structure has an index (which is not the case all the time)
Definition: Structure.h:61
virtual ~Structure()=default
Virtual destructor needed here as this is an abstract class (pure virtual)
StructureProperties::GeometricType getType() const
get the type of index
Definition: Structure.cpp:40
virtual bool isInstanceOf(const char *) const =0
pure virtual method, implemented in the child-class
std::vector< StructuralComponent * > getAllStructuralComponents()
get the list of all the StructuralComponent that are using this structure
Definition: Structure.h:114
virtual void setPhysicalModel(PhysicalModel *)
set the physical model
Definition: Structure.cpp:53
Structure()
Base constructor.
Definition: Structure.h:46
void setName(std::string)
set the name of the structure
Definition: Structure.cpp:44
StructuralComponent * getStructuralComponent(unsigned int i)
get a particular StructuralComponent that is using this structure
Definition: Structure.h:120
virtual void addStructuralComponent(StructuralComponent *)
add a particular StructuralComponent in the list
Definition: Structure.h:128
virtual bool setIndex(const unsigned int)
set the index.
Definition: Structure.cpp:34