Computer Assisted Medical Intervention Tool Kit  version 5.2
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-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, 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 
219  bool neverSelected;
220 
223 
225  vtkSmartPointer<vtkPoints> thePoints;
226 
228  vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
229 
231  std::AtomPointIdMap atomPointIdMap;
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  }
294  std::AtomPointIdMapIterator result = atomPointIdMap.find(a);
295  return (result == atomPointIdMap.end()) ? 0 : (result->second);
296 }
297 
298 
299 #endif
300 
301 
#define a
#define PML_COMPONENT_API
Definition: PMLComponentAPI.h:12
std::map< const Atom *, const vtkIdType > AtomPointIdMap
definition of the association set (=map in STL) AtomPointIdMap.
Definition: PMLComponent.h:79
std::map< const Atom *, const vtkIdType >::iterator AtomPointIdMapIterator
the iterator corresponding to the AtomPointIdMap map
Definition: PMLComponent.h:81
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
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
A cell has an unique index in the physical model object, is composed by atoms, and different basic pr...
Definition: Cell.h:46
A multi-component stores other components, hence providing a way to have an tree representation of co...
Definition: MultiComponent.h:44
This class manages a physical model (PML) CamiTK component.
Definition: PMLComponent.h:103
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
This is the main class of this project.
Definition: PhysicalModel.h:86
A structural component is composed either by cell or by atoms.
Definition: StructuralComponent.h:52
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:424
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
virtual int addSelection(const QString &name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy=MeshSelectionModel::REPLACE)
Add a selection.
Definition: MeshComponent.cpp:560
void initDynamicProperties()
create and initialize dynamic properties
Definition: MeshComponent.cpp:372
QPixmap getIcon() override
Get the pixmap that will be displayed for this node.
Definition: MeshComponent.cpp:1256
void updateProperty(QString, QVariant) override
update property: no specific properties to manage, this is needed to avoid console warnings.
Definition: MeshComponent.h:134
InsertionPolicy
Definition: MeshSelectionModel.h:50
@ REPLACE
Definition: MeshSelectionModel.h:51
Definition: Action.cpp:36
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding)
Definition: Atom.h:36