Computer Assited Medical Intervention Tool Kit  version 5.0
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-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 #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 // disable warning generated by clang about the surrounded headers
61 #include <CamiTKDisableWarnings>
62 #include <vtkExtractSelection.h>
63 #include <CamiTKReEnableWarnings>
64 
65 #include <vtkSelectionNode.h>
66 
67 namespace std {
73 using AtomPointIdPair = std::pair<const Atom*, const vtkIdType>;
79 using AtomPointIdMap = std::map <const Atom*, const vtkIdType>;
81 using AtomPointIdMapIterator = std::map <const Atom*, const vtkIdType>::iterator;
82 }
83 
104  Q_OBJECT
105 
106 public:
112  PMLComponent(const QString& file);
113 
118  PMLComponent(PhysicalModel* p, const QString& originalFile);
119 
121  virtual ~PMLComponent();
122 
124  virtual QPixmap getIcon();
125 
127  virtual void updateProperty(QString name, QVariant value);
128 
135  virtual void setSelected(const bool b, const bool recursive = true);
136 
140  PhysicalModel* getPhysicalModel();
141 
143  vtkIdType getPointId(const Atom* a);
144 
146  void init();
148 
151 
155  void selectCell(Cell* cell, bool showAtomGlyph);
156 
159  void selectAtom(const Atom* atom);
160 
164  void selectSC(StructuralComponent* sc, bool showAtomGlyph);
165 
169  void selectMC(MultiComponent* mc, bool showAtomGlyph);
170 
172  void unselectItems();
173 
176  void updateSelection();
177 
186  void refreshDisplay();
187 
201  virtual int addSelection(const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, camitk::MeshSelectionModel::InsertionPolicy policy = camitk::MeshSelectionModel::REPLACE);
202 
203 
205 
206 protected:
208  virtual void initDynamicProperties();
209 
210 private:
211 
214 
216  static QPixmap* myPixmap;
217 
220 
223 
225  vtkSmartPointer<vtkPoints> thePoints;
226 
228  vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
229 
232 
234  void create3DStructure();
235 
238  void parseMultiComponent(MultiComponent* mc);
239 
244  vtkSmartPointer<vtkCell> cellToVTK(Cell* cell);
245 
251  vtkSmartPointer<vtkPolyVertex> atomSCToVTK(StructuralComponent* sc);
252 
254 
257 
259  vtkSmartPointer<vtkIdTypeArray> selectedAtomIdArray;
260 
262  vtkSmartPointer<vtkSelection> selectedAtomSelection;
263 
267  QMap<QString, vtkSmartPointer<vtkIdTypeArray> > scCellIdArrayMap;
268 
272  QMap<QString, vtkSmartPointer<vtkSelection> > scCellSelectionMap;
273 
279  void createCellSelectionVTKPipeline(const StructuralComponent* sc);
280 
283  void createAtomSelectionVTKPipeline();
285 
286 
287 };
288 
289 // -------------------- Atom / VtkPoint Id Map --------------------
290 inline vtkIdType PMLComponent::getPointId(const Atom* a) {
291  if (!a) {
292  return 0;
293  }
295  return (result == atomPointIdMap.end()) ? 0 : (result->second);
296 }
297 
298 
299 #endif
300 
301 
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:473
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:290
camitk::Component::vtkSmartPointer< vtkActor >
vtkSmartPointer< vtkPointSet > vtkSmartPointer< vtkAlgorithmOutput > vtkSmartPointer< vtkActor >
Definition: sdk/libraries/core/component/Component.h:589
PMLComponent::updateProperty
virtual void updateProperty(QString name, QVariant value)
update top-level properties and synchronize the physical model values
Definition: PMLComponent.cpp:169
PMLComponent::mainGrid
vtkSmartPointer< vtkUnstructuredGrid > mainGrid
The 3D grid containing all the cells of the PML.
Definition: PMLComponent.h:228
StructureProperties::WEDGE
@ 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:160
StructureProperties::TETRAHEDRON
@ TETRAHEDRON
the structure is a tetrahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:159
StructuralComponent::getNumberOfStructures
unsigned int getNumberOfStructures() const
get the number of structures
Definition: StructuralComponent.h:252
std::AtomPointIdMapIterator
std::map< const Atom *, const vtkIdType >::iterator AtomPointIdMapIterator
the iterator corresponding to the AtomPointIdMap map
Definition: PMLComponent.h:81
Structure::getType
StructureProperties::GeometricType getType() const
get the type of index
Definition: Structure.cpp:40
MultiComponent::getSubComponent
Component * getSubComponent(const unsigned int) const
get a subcomponent by its order number (index in the list of subcomponents)
Definition: MultiComponent.h:114
Atom
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
PMLComponent::getPhysicalModel
PhysicalModel * getPhysicalModel()
Definition: PMLComponent.cpp:104
camitk::Component::addProp
bool addProp(const QString &name, vtkSmartPointer< vtkProp > prop) override
insert an additional prop, defining it by its name (default visibility = false)
Definition: sdk/libraries/core/component/Component.h:626
camitk::MeshSelectionModel::InsertionPolicy
InsertionPolicy
Definition: MeshSelectionModel.h:50
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:332
camitk::MeshComponent::updateProperty
void updateProperty(QString, QVariant) override
update property: no specific properties to manage, this is needed to avoid console warnings.
Definition: MeshComponent.h:134
a
#define a
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:73
Geometry.h
PMLComponent::selectAtom
void selectAtom(const Atom *atom)
Select the given atom in the 3D structure.
Definition: PMLComponent.cpp:441
PMLComponent::create3DStructure
void create3DStructure()
Create the 3D VTK structure representing the mesh.
Definition: PMLComponent.cpp:184
camitk::MeshComponent::init
void init()
initialisation of the mesh component members
Definition: MeshComponent.cpp:128
Structure::getIndex
unsigned int getIndex() const
get the structure unique index (stored in its property)
Definition: Structure.cpp:30
MultiComponent::getNumberOfSubComponents
unsigned int getNumberOfSubComponents() const
return the number of subcomponents
Definition: MultiComponent.h:111
camitk::Component::getBoundingRadius
double getBoundingRadius() override
compute the object's bounding sphere radius,
Definition: sdk/libraries/core/component/Component.cpp:701
PMLComponent::myPixmap
static QPixmap * myPixmap
the PMLComponent icon
Definition: PMLComponent.h:216
Action.h
StructuralComponent
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
PMLAbortException
Exception class to handle abortion in the xmlReading Particularly useful to handle constructor's abor...
Definition: PMLAbortException.h:39
PMLComponent::initDynamicProperties
virtual void initDynamicProperties()
create and initialize dynamic properties using the global xml attributes from the PhysicalModel objec...
Definition: PMLComponent.cpp:139
PMLComponent::neverSelected
bool neverSelected
the first selection should trigger the pml exporer action (default action)
Definition: PMLComponent.h:219
PMLComponent::createAtomSelectionVTKPipeline
void createAtomSelectionVTKPipeline()
Create the VTK selection pipeline (selection, extractor, mapper, actor) needed to represent the selec...
Definition: PMLComponent.cpp:360
camitk::MeshSelectionModel::REPLACE
@ REPLACE
Definition: MeshSelectionModel.h:51
PMLComponent::updateSelection
void updateSelection()
Update the POINTS and CELLS selection for the whole 3D structure by telling the corresponding extract...
Definition: PMLComponent.cpp:513
camitk::Property
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:303
Atom.h
camitk::Component::getDataPort
vtkSmartPointer< vtkPointSet > getDataPort
Definition: sdk/libraries/core/component/Component.h:585
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:86
camitk::Action
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:231
camitk::Action::getQAction
virtual QAction * getQAction(Component *target=nullptr)
Get the corresponding QAction.
Definition: Action.cpp:204
Property.h
PMLComponent::init
void init()
initialize information (properties) and geometric representation from the physical model
Definition: PMLComponent.cpp:109
camitk::MeshComponent::getSelectionIndex
int getSelectionIndex(const QString &name) const
Get the selection index in the list from its name.
Definition: MeshComponent.cpp:495
PMLComponent::thePoints
vtkSmartPointer< vtkPoints > thePoints
The 3D VTK cloud points of the atoms read.
Definition: PMLComponent.h:225
Cell
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:46
Component::getName
const std::string getName() const
get the name of the component
Definition: modeling/libraries/pml/Component.h:147
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:564
PMLComponent::parseMultiComponent
void parseMultiComponent(MultiComponent *mc)
Create the 3D structure of the given MultiComponent and its children (recursively).
Definition: PMLComponent.cpp:239
PMLComponent::physicalModel
PhysicalModel * physicalModel
The library pml object that uses pmlschema to read the pml information for the xml file.
Definition: PMLComponent.h:213
camitk::AbortException
Exception class to handle abortion in component instantiation. Particularly useful to handle construc...
Definition: AbortException.h:66
CAMITK_ERROR
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:276
StructureProperties::PYRAMID
@ PYRAMID
the structure has a quad base and one vertex outside the defined base plane (like an egyptian pyramid...
Definition: StructureProperties.h:161
PML_COMPONENT_API
#define PML_COMPONENT_API
Definition: PMLComponentAPI.h:12
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:445
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:824
PMLComponent
This class manages a physical model (PML) CamiTK component.
Definition: PMLComponent.h:103
PMLAbortException::what
const char * what() const noexcept
get the detailed reason from the exception
Definition: PMLAbortException.h:71
Cell::getParentSC
const StructuralComponent * getParentSC()
Get the direct parent structural that own this cell.
Definition: Cell.h:151
StructuralComponent::getColor
double * getColor() const
Get the color.
Definition: StructuralComponent.cpp:116
camitk::policy
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding)
camitk::Component::removeProp
bool removeProp(const QString &name) override
remove a given additional prop.
Definition: sdk/libraries/core/component/Component.h:638
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:296
StructureProperties::HEXAHEDRON
@ HEXAHEDRON
the structure is a hexahedron, it must be a cell and have sub-structures that are atoms
Definition: StructureProperties.h:162
StructuralComponent::CELLS
@ CELLS
the structural component is made of cells
Definition: StructuralComponent.h:175
PMLComponent::selectCell
void selectCell(Cell *cell, bool showAtomGlyph)
Select the given cell in the 3D structure.
Definition: PMLComponent.cpp:447
StructureProperties::TRIANGLE
@ TRIANGLE
the structure is a triangle, i.e it must be a cell composed of 3 atoms
Definition: StructureProperties.h:157
StructureProperties::LINE
@ LINE
the structure is a simple line, i.e it must be a cell composed of only 2 atoms
Definition: StructureProperties.h:156
PMLComponent::scCellSelectionMap
QMap< QString, vtkSmartPointer< vtkSelection > > scCellSelectionMap
The association structural component <-> vtkSelection for Cells selection.
Definition: PMLComponent.h:272
PMLComponent::selectedAtomIdArray
vtkSmartPointer< vtkIdTypeArray > selectedAtomIdArray
The vtkIdTypeArray for atom selection (contains all the id array that corresponds to a selected atom)
Definition: PMLComponent.h:259
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:398
camitk::Component::setVisibility
virtual void setVisibility(QString, bool)
set the visibility inside the viewer of the given name (the viewer needs to be a registered viewer)
Definition: sdk/libraries/core/component/Component.cpp:224
StructuralComponent::getStructure
Structure * getStructure(const unsigned int) const
get a structure by its index (fisrt structure is at index 0)
Definition: StructuralComponent.h:220
PMLComponent::atomPointIdMap
std::AtomPointIdMap atomPointIdMap
the Atom / vtkPoint Id map
Definition: PMLComponent.h:231
PMLComponent::getIcon
virtual QPixmap getIcon()
get the pixmap for physical model component
Definition: PMLComponent.cpp:584
PhysicalModel.h
std::AtomPointIdMap
std::map< const Atom *, const vtkIdType > AtomPointIdMap
definition of the association set (=map in STL) AtomPointIdMap.
Definition: PMLComponent.h:79
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:140
PMLComponent::cellToVTK
vtkSmartPointer< vtkCell > cellToVTK(Cell *cell)
Create a 3D vtkCell corresponding to a structural component's cell.
Definition: PMLComponent.cpp:268
physicalModel
Definition: Atom.h:36
StructuralComponent::getCell
Cell * getCell(unsigned int) const override
get cell by order number (not cell index)
Definition: StructuralComponent.cpp:197
StructureProperties::POLY_VERTEX
@ POLY_VERTEX
the structure is a poly vertex, i.e it must be a cell and it is a point clouds
Definition: StructureProperties.h:164
camitk::Property::setReadOnly
void setReadOnly(bool)
set this property as read-only
Definition: Property.cpp:82
MultiComponent.h
Properties
Describes the properties common to all structures and components.
Definition: Properties.h:59
StructureProperties::QUAD
@ QUAD
the structure is a quad, i.e it must be a cell composed of 4 atoms
Definition: StructureProperties.h:158
camitk::Component::setName
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:932
camitk::MeshComponent
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
Properties::set
void set(std::string attName, double val)
field modificator: set field attName using a double value
Definition: Properties.h:200
camitk::MeshComponent::getIcon
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: MeshComponent.cpp:1172
camitk::Component::refresh
virtual void refresh()
refresh all the viewer that are currently displaying this Component At the end the InterfaceNode modi...
Definition: sdk/libraries/core/component/Component.cpp:286
camitk::Component::addProperty
bool addProperty(Property *) override
Add a new CamiTK property to the component.
Definition: sdk/libraries/core/component/Component.cpp:517
PMLComponent::scCellIdArrayMap
QMap< QString, vtkSmartPointer< vtkIdTypeArray > > scCellIdArrayMap
The association structural component <-> vtkIdTypeArray for Cells selection.
Definition: PMLComponent.h:267
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:519
StructuralComponent::ATOMS
@ ATOMS
the structural component is made of atoms
Definition: StructuralComponent.h:176
PMLComponent::PMLComponent
PMLComponent(const QString &file)
Construct the PML component directly from the .pml xml file.
Definition: PMLComponent.cpp:77
PMLComponent::~PMLComponent
virtual ~PMLComponent()
destructor
Definition: PMLComponent.cpp:96
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:500
PMLComponent::unselectItems
void unselectItems()
Unselect all the SC, MC, Atoms and Cells previously selected on the 3D structure.
Definition: PMLComponent.cpp:551
MultiComponent
A multi-component stores other components, hence providing a way to have an tree representation of co...
Definition: MultiComponent.h:44
camitk::MeshComponent::initDynamicProperties
void initDynamicProperties()
create and initialize dynamic properties
Definition: MeshComponent.cpp:331
PMLComponent::refreshDisplay
void refreshDisplay()
Refresh the display of the component according to the selected 3D items by the user.
Definition: PMLComponent.cpp:349
PMLComponent::selectedAtomSelection
vtkSmartPointer< vtkSelection > selectedAtomSelection
The vtkSelection for atom selection.
Definition: PMLComponent.h:262
StructureProperties::POLY_LINE
@ 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:163
camitk::MeshComponent::initRepresentation
void initRepresentation() override final
the concrete building of the 3D objects (Slice/Geometry): none in this case, everything is done by in...
Definition: MeshComponent.h:399
camitk::InterfaceGeometry::setEnhancedModes
virtual void setEnhancedModes(const EnhancedModes)=0
set the enhanced mode
Application.h
camitk
Definition: Action.cpp:35
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:123