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 
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 
214 
218  vtkSmartPointer<vtkPoints> thePoints;
219 
221  vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
222 
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  }
287  std::AtomPointIdMapIterator result = atomPointIdMap.find(a);
288  return (result == atomPointIdMap.end()) ? 0 : (result->second);
289 }
290 
291 
292 #endif
293 
294 
PhysicalModel * getPhysicalModel()
Definition: PMLComponent.h:136
std::AtomPointIdMap atomPointIdMap
the Atom / vtkPoint Id map
Definition: PMLComponent.h:224
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:46
std::map< const Atom *, const vtkIdType > AtomPointIdMap
definition of the association set (=map in STL) AtomPointIdMap.
Definition: PMLComponent.h:75
QMap< QString, vtkSmartPointer< vtkIdTypeArray > > scCellIdArrayMap
The association structural component <-> vtkIdTypeArray for Cells selection.
Definition: PMLComponent.h:260
STL namespace.
vtkSmartPointer< vtkSelection > selectedAtomSelection
The vtkSelection for atom selection.
Definition: PMLComponent.h:255
Definition: Action.cpp:36
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
vtkIdType getPointId(const Atom *a)
get the point Id from the corresponding atom, this is the opposite of pml->getAtom(id) ...
Definition: PMLComponent.h:283
vtkSmartPointer< vtkUnstructuredGrid > mainGrid
The 3D grid containing all the cells of the PML.
Definition: PMLComponent.h:221
#define a
Definition: Atom.h:36
#define PML_COMPONENT_API
Definition: PMLComponentAPI.h:12
bool neverSelected
the first selection should trigger the pml exporer action (default action)
Definition: PMLComponent.h:213
vtkSmartPointer< vtkPoints > thePoints
Definition: PMLComponent.h:218
This class manages a physical model (PML) CamiTK component.
Definition: PMLComponent.h:99
Definition: MeshSelectionModel.h:51
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:69
static QPixmap * myPixmap
the PMLComponent icon
Definition: PMLComponent.h:210
InsertionPolicy
Definition: MeshSelectionModel.h:50
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
This is the main class of this project.
Definition: PhysicalModel.h:86
std::map< const Atom *, const vtkIdType >::iterator AtomPointIdMapIterator
the iterator corresponding to the AtomPointIdMap map
Definition: PMLComponent.h:77
vtkSmartPointer< vtkIdTypeArray > selectedAtomIdArray
The vtkIdTypeArray for atom selection (contains all the id array that corresponds to a selected atom)...
Definition: PMLComponent.h:252
PhysicalModel * physicalModel
The library pml object that uses pmlschema to read the pml information for the xml file...
Definition: PMLComponent.h:207
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
A multi-component stores other components, hence providing a way to have an tree representation of co...
Definition: MultiComponent.h:44
QMap< QString, vtkSmartPointer< vtkSelection > > scCellSelectionMap
The association structural component <-> vtkSelection for Cells selection.
Definition: PMLComponent.h:265