Computer Assited Medical Intervention Tool Kit  version 4.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-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 #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 typedef std::pair<const Atom *, const vtkIdType> AtomPointIdPair;
75 typedef std::map <const Atom *, const vtkIdType> AtomPointIdMap;
77 typedef std::map <const Atom *, const vtkIdType>::iterator AtomPointIdMapIterator;
78 }
79 
100  Q_OBJECT
101 
102 public:
105  PMLComponent(const QString& file) throw(camitk::AbortException);
106 
111  PMLComponent(PhysicalModel *p, const QString &originalFile);
112 
114  virtual ~PMLComponent();
115 
117  virtual QPixmap getIcon();
118 
120  virtual void updateProperty(QString name, QVariant value);
121 
128  virtual void setSelected(const bool b, const bool recursive = true);
129 
134  return this->physicalModel;
135  }
136 
138  vtkIdType getPointId(const Atom *a);
139 
141  void init();
143 
148  void selectCell(Cell* cell, bool showAtomGlyph);
149 
152  void selectAtom(const Atom* atom);
153 
156  void selectSC(StructuralComponent* sc, bool showAtomGlyph);
157 
160  void selectMC(MultiComponent* mc, bool showAtomGlyph);
161 
163  void unselectItems();
164 
167  void updateSelection();
168 
170  void refreshDisplay();
171 
185  virtual int addSelection ( const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, camitk::MeshSelectionModel::InsertionPolicy policy = camitk::MeshSelectionModel::REPLACE );
186 
187 
189 
190 protected:
192  virtual void initDynamicProperties();
193 
194 private:
195 
198 
200  static QPixmap * myPixmap;
201 
204 
208  vtkSmartPointer<vtkPoints> thePoints;
209 
211  vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
212 
215 
217  void create3DStructure();
218 
221  void parseMultiComponent(MultiComponent* mc);
222 
227  vtkSmartPointer<vtkCell> cellToVTK(Cell* cell);
228 
234  vtkSmartPointer<vtkPolyVertex> atomSCToVTK(StructuralComponent* sc);
235 
237 
240 
242  vtkSmartPointer<vtkIdTypeArray> selectedAtomIdArray;
243 
245  vtkSmartPointer<vtkSelection> selectedAtomSelection;
246 
250  QMap<QString, vtkSmartPointer<vtkIdTypeArray> > scCellIdArrayMap;
251 
255  QMap<QString, vtkSmartPointer<vtkSelection> > scCellSelectionMap;
256 
262  void createCellSelectionVTKPipeline(const StructuralComponent* sc);
263 
266  void createAtomSelectionVTKPipeline();
268 
269 
270 };
271 
272 // -------------------- Atom / VtkPoint Id Map --------------------
273 inline vtkIdType PMLComponent::getPointId(const Atom *a) {
274  if (!a)
275  return 0;
276  std::AtomPointIdMapIterator result = atomPointIdMap.find(a);
277  return (result == atomPointIdMap.end()) ? 0 : (result->second);
278 }
279 
280 
281 #endif
282 
283 
PhysicalModel * getPhysicalModel()
Definition: PMLComponent.h:133
std::AtomPointIdMap atomPointIdMap
the Atom / vtkPoint Id map
Definition: PMLComponent.h:214
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:46
Exception class to handle abortion in component instanciation.
Definition: AbortException.h:43
QMap< QString, vtkSmartPointer< vtkIdTypeArray > > scCellIdArrayMap
The association structural component <-> vtkIdTypeArray for Cells selection.
Definition: PMLComponent.h:250
std::map< const Atom *, const vtkIdType >::iterator AtomPointIdMapIterator
the iterator corresponding to the AtomPointIdMap map
Definition: PMLComponent.h:77
std::map< const Atom *, const vtkIdType > AtomPointIdMap
definition of the association set (=map in STL) AtomPointIdMap.
Definition: PMLComponent.h:75
STL namespace.
vtkSmartPointer< vtkSelection > selectedAtomSelection
The vtkSelection for atom selection.
Definition: PMLComponent.h:245
Definition: Action.cpp:40
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:51
vtkIdType getPointId(const Atom *a)
get the point Id from the corresponding atom, this is the opposite of pml->getAtom(id) ...
Definition: PMLComponent.h:273
vtkSmartPointer< vtkUnstructuredGrid > mainGrid
The 3D grid containing all the cells of the PML.
Definition: PMLComponent.h:211
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:203
vtkSmartPointer< vtkPoints > thePoints
Definition: PMLComponent.h:208
This class manages a physical model (PML) CamiTK component.
Definition: PMLComponent.h:99
Definition: MeshSelectionModel.h:51
static QPixmap * myPixmap
the PMLComponent icon
Definition: PMLComponent.h:200
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::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
vtkSmartPointer< vtkIdTypeArray > selectedAtomIdArray
The vtkIdTypeArray for atom selection (contains all the id array that corresponds to a selected atom)...
Definition: PMLComponent.h:242
PhysicalModel * physicalModel
The library pml object that uses pmlschema to read the pml information for the xml file...
Definition: PMLComponent.h:197
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:255