Computer Assited Medical Intervention Tool Kit  version 4.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-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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:
46  Structure() : properties(NULL) {
47  hasIndex = false;
48  }
50  virtual ~Structure() {}
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  else
124  return NULL;
125 }
127  mySCs.push_back(sc);
128 }
129 
131  std::vector <StructuralComponent *>::iterator it = std::find(mySCs.begin(), mySCs.end(), sc);
132  if (it != mySCs.end())
133  mySCs.erase(it);
134 }
135 
136 
137 #endif // STRUCTURE_H
StructuralComponent * getStructuralComponent(unsigned int i)
get a particular StructuralComponent that is using this structure
Definition: Structure.h:120
Pure virtual class that represent an element of the structure.
Definition: Structure.h:43
virtual void xmlPrint(std::ostream &, const StructuralComponent *)=0
print to an output stream in "pseaudo" XML format.
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:130
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:104
virtual ~Structure()
Virtual destructor needed here as this is an abstract class (pure virtual)
Definition: Structure.h:50
unsigned int getNumberOfStructuralComponents() const
get the number of StructuralComponent that are using this structure
Definition: Structure.h:117
std::vector< StructuralComponent * > getAllStructuralComponents()
get the list of all the StructuralComponent that are using this structure
Definition: Structure.h:114
virtual bool setIndex(const unsigned int)
set the index.
Definition: Structure.cpp:34
This is the main class of this project.
Definition: PhysicalModel.h:86
Describes the properties common to all structures.
Definition: StructureProperties.h:38
Structure()
Base constructor.
Definition: Structure.h:46
GeometricType
Geometric type gives information about which kind of geometric representation is the structure...
Definition: StructureProperties.h:107
std::string getName() const
get the name of the structure
Definition: Structure.cpp:48
bool hasIndex
indicate if the Structure has an index (which is not the case all the time)
Definition: Structure.h:61
virtual void setPhysicalModel(PhysicalModel *)
set the physical model
Definition: Structure.cpp:53
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
void setName(std::string)
set the name of the structure
Definition: Structure.cpp:44
virtual void addStructuralComponent(StructuralComponent *)
add a particular StructuralComponent in the list
Definition: Structure.h:126
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 * > mySCs
list of StructuralComponent that are using this structure
Definition: Structure.h:109