Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2014 UJF-Grenoble 1, 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) {}
48  virtual ~Structure() {}
49 
53  virtual void xmlPrint(std::ostream &, const StructuralComponent *) = 0;
54 
56  virtual bool isInstanceOf(const char *) const = 0;
57 
59  unsigned int getIndex() const;
60 
67  virtual bool setIndex(const unsigned int);
68 
71 
73  std::vector <StructuralComponent *> getAllStructuralComponents();
74 
76  unsigned int getNumberOfStructuralComponents() const;
77 
80 
83 
86 
88  void setName(std::string);
89 
91  std::string getName() const;
92 
94  virtual void setPhysicalModel(PhysicalModel *);
95 
96 protected:
97 
100 
101 private:
102 
104  std::vector <StructuralComponent *> mySCs;
105 
106 };
107 
108 // -------------------- inline ---------------------
109 inline std::vector <StructuralComponent *> Structure::getAllStructuralComponents() {
110  return mySCs;
111 }
112 inline unsigned int Structure::getNumberOfStructuralComponents() const {
113  return mySCs.size();
114 }
116  if (i<mySCs.size())
117  return mySCs[i];
118  else
119  return NULL;
120 }
122  mySCs.push_back(sc);
123 }
124 
126  std::vector <StructuralComponent *>::iterator it = std::find(mySCs.begin(), mySCs.end(), sc);
127  if (it != mySCs.end())
128  mySCs.erase(it);
129 }
130 
131 
132 #endif // STRUCTURE_H
virtual bool setIndex(const unsigned int)
set the index.
StructuralComponent * getStructuralComponent(unsigned int i)
get a particular StructuralComponent that is using this structure
Definition: Structure.h:115
Pure virtual class that represent an element of the structure.
Definition: Structure.h:43
unsigned int getNumberOfStructuralComponents() const
get the number of StructuralComponent that are using this structure
Definition: Structure.h:112
unsigned int getIndex() const
get the structure unique index (stored in its property)
virtual void xmlPrint(std::ostream &, const StructuralComponent *)=0
print to an output stream in "pseaudo" XML format.
GeometricType
Geometric type gives information about which kind of geometric representation is the structure...
Definition: StructureProperties.h:107
void removeStructuralComponent(StructuralComponent *)
remove a particular StructuralComponent from the list
Definition: Structure.h:125
StructureProperties * properties
Property of the current structure.
Definition: Structure.h:99
virtual ~Structure()
Virtual destructor needed here as this is an abstract class (pure virtual)
Definition: Structure.h:48
StructureProperties::GeometricType getType() const
get the type of index
std::vector< StructuralComponent * > getAllStructuralComponents()
get the list of all the StructuralComponent that are using this structure
Definition: Structure.h:109
This is the main class of this project.
Definition: PhysicalModel.h:74
Describes the properties common to all structures.
Definition: StructureProperties.h:38
Structure()
Base constructor.
Definition: Structure.h:46
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:48
void setName(std::string)
set the name of the structure
virtual void setPhysicalModel(PhysicalModel *)
set the physical model
void addStructuralComponent(StructuralComponent *)
add a particular StructuralComponent in the list
Definition: Structure.h:121
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:104
std::string getName() const
get the name of the structure