Computer Assited Medical Intervention Tool Kit  version 4.1
PMLComponent.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2018 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 #ifndef PML_COMPONENT_H
26 #define PML_COMPONENT_H
27 
28 // stl includes
29 #include <map>
30 
31 // QT forward declaration
32 class QString;
33 
34 // Qt includes
35 #include <QObject>
36 
37 // lib pml forward declaration
38 class PhysicalModel;
40 class MultiComponent;
41 class Atom;
42 class Cell;
43 
44 // vtk forward declarations
45 class vtkUnstructuredGrid;
46 class vtkPolyVertex;
47 class vtkSelection;
48 class vtkIdTypeArray;
49 
50 // CamiTK forward declaration
51 namespace camitk {
52 class AbortException;
53 }
54 
55 // CamiTK include
56 #include <MeshComponent.h>
57 #include "PMLComponentAPI.h"
58 
59 // VTK includes
60 #include <vtkSelectionNode.h>
61 #include <vtkExtractSelection.h>
62 
63 namespace std {
69 using AtomPointIdPair = std::pair<const Atom*, const vtkIdType>;
75 using AtomPointIdMap = std::map <const Atom*, const vtkIdType>;
77 using AtomPointIdMapIterator = std::map <const Atom*, const vtkIdType>::iterator;
78 }
79 
100  Q_OBJECT
101 
102 public:
108  PMLComponent(const QString& file);
109 
114  PMLComponent(PhysicalModel* p, const QString& originalFile);
115 
117  virtual ~PMLComponent();
118 
120  virtual QPixmap getIcon();
121 
123  virtual void updateProperty(QString name, QVariant value);
124 
131  virtual void setSelected(const bool b, const bool recursive = true);
132 
136  PhysicalModel* getPhysicalModel() {
137  return this->physicalModel;
138  }
139 
141  vtkIdType getPointId(const Atom* a);
142 
144  void init();
146 
151  void selectCell(Cell* cell, bool showAtomGlyph);
152 
155  void selectAtom(const Atom* atom);
156 
159  void selectSC(StructuralComponent* sc, bool showAtomGlyph);
160 
163  void selectMC(MultiComponent* mc, bool showAtomGlyph);
164 
166  void unselectItems();
167 
170  void updateSelection();
171 
180  void refreshDisplay();
181 
195  virtual int addSelection(const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, camitk::MeshSelectionModel::InsertionPolicy policy = camitk::MeshSelectionModel::REPLACE);
196 
197 
199 
200 protected:
202  virtual void initDynamicProperties();
203 
204 private:
205 
208 
210  static QPixmap* myPixmap;
211 
213  bool neverSelected;
214 
218  vtkSmartPointer<vtkPoints> thePoints;
219 
221  vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
222 
224  std::AtomPointIdMap atomPointIdMap;
225 
227  void create3DStructure();
228 
231  void parseMultiComponent(MultiComponent* mc);
232 
237  vtkSmartPointer<vtkCell> cellToVTK(Cell* cell);
238 
244  vtkSmartPointer<vtkPolyVertex> atomSCToVTK(StructuralComponent* sc);
245 
247 
250 
252  vtkSmartPointer<vtkIdTypeArray> selectedAtomIdArray;
253 
255  vtkSmartPointer<vtkSelection> selectedAtomSelection;
256 
260  QMap<QString, vtkSmartPointer<vtkIdTypeArray> > scCellIdArrayMap;
261 
265  QMap<QString, vtkSmartPointer<vtkSelection> > scCellSelectionMap;
266 
272  void createCellSelectionVTKPipeline(const StructuralComponent* sc);
273 
276  void createAtomSelectionVTKPipeline();
278 
279 
280 };
281 
282 // -------------------- Atom / VtkPoint Id Map --------------------
283 inline vtkIdType PMLComponent::getPointId(const Atom* a) {
284  if (!a) {
285  return 0;
286  }
288  return (result == atomPointIdMap.end()) ? 0 : (result->second);
289 }
290 
291 
292 #endif
293 
294 
PMLComponent::selectSC
void selectSC(StructuralComponent *sc, bool showAtomGlyph)
Select the given structural component in the 3D structure by highlighting all its atoms and cells.
Definition: PMLComponent.cpp:465
Cell::setIndex
bool setIndex(const unsigned int) override
set the index.
Definition: Cell.cpp:139
PMLComponent::getPointId
vtkIdType getPointId(const Atom *a)
get the point Id from the corresponding atom, this is the opposite of pml->getAtom(id)
Definition: PMLComponent.h:282
camitk::Component::vtkSmartPointer< vtkActor >
vtkSmartPointer< vtkPointSet > vtkSmartPointer< vtkAlgorithmOutput > vtkSmartPointer< vtkActor >
Definition: sdk/libraries/core/component/Component.h:552
PMLComponent::updateProperty
virtual void updateProperty(QString name, QVariant value)
update top-level properties and synchronize the physical model values
Definition: PMLComponent.cpp:161
camitk::Component::removeProp
bool removeProp(const QString &name)
remove a given additional prop.
Definition: sdk/libraries/core/component/Component.h:597
PMLComponent::mainGrid
vtkSmartPointer< vtkUnstructuredGrid > mainGrid
The 3D grid containing all the cells of the PML.
Definition: PMLComponent.h:220
StructureProperties::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:157
StructureProperties::TETRAHEDRON
the structure is a tetrahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:156
StructuralComponent::getNumberOfStructures
unsigned int getNumberOfStructures() const
get the number of structures
Definition: StructuralComponent.h:251
std::AtomPointIdMapIterator
std::map< const Atom *, const vtkIdType >::iterator AtomPointIdMapIterator
the iterator corresponding to the AtomPointIdMap map
Definition: PMLComponent.h:76
Structure::getType
StructureProperties::GeometricType getType() const
get the type of index
Definition: Structure.cpp:39
MultiComponent::getSubComponent
Component * getSubComponent(const unsigned int) const
get a subcomponent by its order number (index in the list of subcomponents)
Definition: MultiComponent.h:113
Atom
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:48
camitk::MeshSelectionModel::InsertionPolicy
InsertionPolicy
Definition: MeshSelectionModel.h:49
AbortException.h
CellProperties.h
PMLComponent::atomSCToVTK
vtkSmartPointer< vtkPolyVertex > atomSCToVTK(StructuralComponent *sc)
Create a 3D vtkPolyVertex of a structural component which ONLY contains atoms ref.
Definition: PMLComponent.cpp:324
a
#define a
camitk::Action::getQAction
QAction * getQAction()
Get the corresponding QAction.
Definition: Action.cpp:182
std::AtomPointIdPair
std::pair< const Atom *, const vtkIdType > AtomPointIdPair
As the PhysicalModel atom index can be different to the node index (continuity in id is not mandatory...
Definition: PMLComponent.h:68
Geometry.h
PMLComponent::selectAtom
void selectAtom(const Atom *atom)
Select the given pml::Atom in the 3D structure.
Definition: PMLComponent.cpp:433
PMLComponent::create3DStructure
void create3DStructure()
Create the 3D VTK structure representing the mesh.
Definition: PMLComponent.cpp:176
camitk::MeshComponent::init
void init()
initialisation of the mesh component members
Definition: MeshComponent.cpp:122
Structure::getIndex
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:29
MultiComponent::getNumberOfSubComponents
unsigned int getNumberOfSubComponents() const
return the number of subcomponents
Definition: MultiComponent.h:110
camitk::Component::getBoundingRadius
double getBoundingRadius() override
compute the object's bounding sphere radius,
Definition: sdk/libraries/core/component/Component.cpp:488
PMLComponent::myPixmap
static QPixmap * myPixmap
the PMLComponent icon
Definition: PMLComponent.h:209
Action.h
StructuralComponent
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:51
PMLAbortException
Exception class to handle abortion in the xmlReading Particularly useful to handle constructor's abor...
Definition: PMLAbortException.h:38
PMLComponent::initDynamicProperties
virtual void initDynamicProperties()
create and initialize dynamic properties using the global xml attributes from the PhysicalModel objec...
Definition: PMLComponent.cpp:131
PMLComponent::neverSelected
bool neverSelected
the first selection should trigger the pml exporer action (default action)
Definition: PMLComponent.h:212
PMLComponent::createAtomSelectionVTKPipeline
void createAtomSelectionVTKPipeline()
Create the VTK selection pipeline (selection, extractor, mapper, actor) needed to represent the selec...
Definition: PMLComponent.cpp:352
camitk::MeshSelectionModel::REPLACE
Definition: MeshSelectionModel.h:50
PMLComponent::updateSelection
void updateSelection()
Update the POINTS and CELLS selection for the whole 3D structure by telling the corresponding extract...
Definition: PMLComponent.cpp:505
camitk::Property
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:312
Atom.h
Log.h
MeshComponent.h
camitk::InterfaceGeometry::getPointSet
virtual vtkSmartPointer< vtkPointSet > getPointSet()=0
PhysicalModel
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:85
camitk::Action
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:228
Property.h
PMLComponent::init
void init()
initialize information (properties) and geometric representation from the physical model
Definition: PMLComponent.cpp:101
camitk::MeshComponent::getSelectionIndex
int getSelectionIndex(const QString &name) const
Get the selection index in the list from its name.
Definition: MeshComponent.cpp:488
PMLComponent::thePoints
vtkSmartPointer< vtkPoints > thePoints
Definition: PMLComponent.h:217
Cell
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:45
Component::getName
const std::string getName() const
get the name of the component
Definition: modeling/libraries/pml/Component.h:146
camitk::Component::addProp
bool addProp(const QString &name, vtkSmartPointer< vtkProp > prop)
insert an additional prop, defining it by its name (default visibility = false)
Definition: sdk/libraries/core/component/Component.h:586
PMLComponent::addSelection
virtual int addSelection(const QString &name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, camitk::MeshSelectionModel::InsertionPolicy policy=camitk::MeshSelectionModel::REPLACE)
Add a selection (inherited from MeshComponent inorder to show a glyph on selected atoms).
Definition: PMLComponent.cpp:556
PMLComponent::parseMultiComponent
void parseMultiComponent(MultiComponent *mc)
Create the 3D structure of the given MultiComponent and its children (recursively).
Definition: PMLComponent.cpp:231
PMLComponent::physicalModel
PhysicalModel * physicalModel
The library pml object that uses pmlschema to read the pml information for the xml file.
Definition: PMLComponent.h:206
camitk::AbortException
Exception class to handle abortion in component instantiation. Particularly useful to handle construc...
Definition: AbortException.h:64
CAMITK_ERROR
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:271
StructureProperties::PYRAMID
the structure has a quad base and one vertex outside the defined base plane (like an egyptian pyramid...
Definition: StructureProperties.h:158
PML_COMPONENT_API
#define PML_COMPONENT_API
Definition: PMLComponentAPI.h:12
camitk::Component::setVisibility
virtual void setVisibility(Viewer *, bool)
set the visibility for a viewer
Definition: sdk/libraries/core/component/Component.cpp:275
StructuralComponent.h
camitk::Component::setSelected
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:557
camitk::Component::myGeometry
InterfaceGeometry * myGeometry
myGeometry is the 3d representation of this Component, the Component delegates all InterfaceGeometry ...
Definition: sdk/libraries/core/component/Component.h:757
PMLComponent
This class manages a physical model (PML) CamiTK component.
Definition: PMLComponent.h:98
PMLAbortException::what
const char * what() const noexcept
get the detailed reason from the exception
Definition: PMLAbortException.h:70
Cell::getParentSC
const StructuralComponent * getParentSC()
Get the direct parent structural that own this cell.
Definition: Cell.h:138
StructuralComponent::getColor
double * getColor() const
Get the color.
Definition: StructuralComponent.cpp:115
camitk::policy
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding)
PMLComponentAPI.h
StructuralComponent::composedBy
virtual ComposedBy composedBy()
return the type of structure composing the structural component: a structural component is either a l...
Definition: StructuralComponent.cpp:295
StructureProperties::HEXAHEDRON
the structure is a hexahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:159
StructuralComponent::CELLS
the structural component is made of cells
Definition: StructuralComponent.h:174
PMLComponent::selectCell
void selectCell(Cell *cell, bool showAtomGlyph)
Definition: PMLComponent.cpp:439
camitk::InterfaceGeometry::getDataPort
virtual vtkSmartPointer< vtkAlgorithmOutput > getDataPort() const =0
get the custom algorithm pipeline input.
StructureProperties::TRIANGLE
the structure is a triangle, i.e it must be a cell composed of 3 atoms
Definition: StructureProperties.h:154
camitk::MeshComponent::updateProperty
void updateProperty(QString, QVariant)
update property: no specific properties to manage, this is needed to avoid console warnings.
Definition: MeshComponent.h:133
StructureProperties::LINE
the structure is a simple line, i.e it must be a cell composed of only 2 atoms
Definition: StructureProperties.h:153
PMLComponent::scCellSelectionMap
QMap< QString, vtkSmartPointer< vtkSelection > > scCellSelectionMap
The association structural component <-> vtkSelection for Cells selection.
Definition: PMLComponent.h:264
PMLComponent::selectedAtomIdArray
vtkSmartPointer< vtkIdTypeArray > selectedAtomIdArray
The vtkIdTypeArray for atom selection (contains all the id array that corresponds to a selected atom)
Definition: PMLComponent.h:251
PMLComponent::createCellSelectionVTKPipeline
void createCellSelectionVTKPipeline(const StructuralComponent *sc)
Create a new VTK selection pipeline (selection, extractor, mapper, actor) for a given SC if it does n...
Definition: PMLComponent.cpp:390
StructuralComponent::getStructure
Structure * getStructure(const unsigned int) const
get a structure by its index (fisrt structure is at index 0)
Definition: StructuralComponent.h:219
PMLComponent::atomPointIdMap
std::AtomPointIdMap atomPointIdMap
the Atom / vtkPoint Id map
Definition: PMLComponent.h:223
PMLComponent::getIcon
virtual QPixmap getIcon()
get the pixmap for physical model component
Definition: PMLComponent.cpp:576
camitk::MeshComponent::initRepresentation
void initRepresentation()
the concrete building of the 3D objects (Slice/Geometry): none in this case, everything is done by in...
Definition: MeshComponent.h:398
PhysicalModel.h
std::AtomPointIdMap
std::map< const Atom *, const vtkIdType > AtomPointIdMap
definition of the association set (=map in STL) AtomPointIdMap.
Definition: PMLComponent.h:74
Properties::isAField
bool isAField(std::string attName) const
check if the field exist in the XML document, return false if it does not
Definition: Properties.h:139
InteractiveViewer.h
PMLComponent::cellToVTK
vtkSmartPointer< vtkCell > cellToVTK(Cell *cell)
Create a 3D vtkCell corresponding to a structural component's cell.
Definition: PMLComponent.cpp:260
physicalModel
Definition: Atom.h:35
StructuralComponent::getCell
Cell * getCell(unsigned int) const override
get cell by order number (not cell index)
Definition: StructuralComponent.cpp:196
StructureProperties::POLY_VERTEX
the structure is a poly vertex, i.e it must be a cell and it is a point clouds
Definition: StructureProperties.h:161
camitk::Property::setReadOnly
void setReadOnly(bool)
set this property as read-only
Definition: Property.cpp:81
MultiComponent.h
Properties
Describes the properties common to all structures and components.
Definition: Properties.h:58
StructureProperties::QUAD
the structure is a quad, i.e it must be a cell composed of 4 atoms
Definition: StructureProperties.h:155
camitk::Component::setName
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:873
camitk::MeshComponent
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:52
Properties::set
void set(std::string attName, double val)
field modificator: set field attName using a double value
Definition: Properties.h:199
camitk::MeshComponent::getIcon
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: MeshComponent.cpp:1122
camitk::Component::addProperty
bool addProperty(Property *) override
Add a new CamiTK property to the component.
Definition: sdk/libraries/core/component/Component.cpp:220
PMLComponent::scCellIdArrayMap
QMap< QString, vtkSmartPointer< vtkIdTypeArray > > scCellIdArrayMap
The association structural component <-> vtkIdTypeArray for Cells selection.
Definition: PMLComponent.h:259
PMLComponent.h
camitk::MeshComponent::addSelection
virtual int addSelection(const QString &name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy=MeshSelectionModel::REPLACE)
Add a selection.
Definition: MeshComponent.cpp:512
StructuralComponent::ATOMS
the structural component is made of atoms
Definition: StructuralComponent.h:175
PMLComponent::PMLComponent
PMLComponent(const QString &file)
Construct the PML component directly from the .pml xml file.
Definition: PMLComponent.cpp:74
PMLComponent::~PMLComponent
virtual ~PMLComponent()
destructor
Definition: PMLComponent.cpp:93
PMLComponent::selectMC
void selectMC(MultiComponent *mc, bool showAtomGlyph)
Select the given multi component in the 3D structure by highlighting all its structural components.
Definition: PMLComponent.cpp:492
PMLComponent::unselectItems
void unselectItems()
Unselect all the SC, MC, Atoms and Cells previously selected on the 3D structure.
Definition: PMLComponent.cpp:543
MultiComponent
A multi-component stores other components, hence providing a way to have an tree representation of co...
Definition: MultiComponent.h:43
camitk::MeshComponent::initDynamicProperties
virtual void initDynamicProperties()
create and initialize dynamic properties
Definition: MeshComponent.cpp:324
PMLComponent::refreshDisplay
void refreshDisplay()
Refresh the display of the component according to the selected 3D items by the user.
Definition: PMLComponent.cpp:341
PMLComponent::selectedAtomSelection
vtkSmartPointer< vtkSelection > selectedAtomSelection
The vtkSelection for atom selection.
Definition: PMLComponent.h:254
StructureProperties::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:160
camitk::InterfaceGeometry::setEnhancedModes
virtual void setEnhancedModes(const EnhancedModes)=0
set the enhanced mode
Application.h
camitk
Definition: Action.cpp:36
PMLComponent::setSelected
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag (this method is overridden in order to show the default modeling action whe...
Definition: PMLComponent.cpp:115