/usr/include/camitk-4.0/components/pmlcomponent/PMLComponent.h is in libcamitk-dev 4.0.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | /*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef PML_COMPONENT_H
#define PML_COMPONENT_H
// stl includes
#include <map>
// QT forward declaration
class QString;
// Qt includes
#include <QObject>
// lib pml forward declaration
class PhysicalModel;
class StructuralComponent;
class MultiComponent;
class Atom;
class Cell;
// vtk forward declarations
class vtkUnstructuredGrid;
class vtkPolyVertex;
class vtkSelection;
class vtkIdTypeArray;
// CamiTK forward declaration
namespace camitk {
class AbortException;
}
// CamiTK include
#include <MeshComponent.h>
#include "PMLComponentAPI.h"
// VTK includes
#include <vtkSelectionNode.h>
#include <vtkExtractSelection.h>
namespace std {
/** As the PhysicalModel atom index can be different to the node index (continuity in id is not mandatory in PML)
* a map is needed to link the atom index with its corresponding vtkPoint Id
* definition of a couple (=STL pair) [Atom *, vtkIdType]
* this associates an atom to its vtkPoint Id
*/
typedef std::pair<const Atom *, const vtkIdType> AtomPointIdPair;
/** definition of the association set (=map in STL) AtomPointIdMap.
* AtomPointIdMap associate all the Atom with their vtkPoint Id.
* The key is the atom, so that it is simple to retrieve its corresponding point Id
* (which is supposed to be the most often used functionnality).
*/
typedef std::map <const Atom *, const vtkIdType> AtomPointIdMap;
/** the iterator corresponding to the AtomPointIdMap map */
typedef std::map <const Atom *, const vtkIdType>::iterator AtomPointIdMapIterator;
}
/**
* @ingroup group_cepmodeling_components_pml
*
* @brief
* This class manages a physical model (PML) CamiTK component.
*
* This class inherits from camitk::MeshComponent.
* It creates the 3D VTK structures corresponding to the PML structures (atoms, cells, structural components),
* allows to quickly selecting PML element and highlight them in the 3D structure (using vtkSelection extractors) and
* display usefull PML properties (given as XML attributes in the PML files) as @see camitk::Property.
*
* @note There are several vtkSelection extractor (2 per structural component in the PML structure).
* One for the POINTS selection (the atoms) and one for the CELLS (the PML Cells).
* They are configured to display the corresponding selection in the Structural Component color property (if provided).
*
* @note The action PMLExploreAction uses this selection methods to allows selecting PML structure elements throught a simple
* tree view widget.
*
**/
class PML_COMPONENT_API PMLComponent : public camitk::MeshComponent {
Q_OBJECT
public:
/// Construct the PML component directly from the .pml xml file.
/// @param filename: The input .pml xml file to build the physical model from.
PMLComponent(const QString& file) throw(camitk::AbortException);
/** Create the PML component directly from the PhysicalModel (also have to give the original pml filename)
* @param p the physicalModel (already instanciated and build)
* @param originalFile the filename from which p was build
*/
PMLComponent(PhysicalModel *p, const QString &originalFile);
/// destructor
virtual ~PMLComponent();
/// get the pixmap for physical model component
virtual QPixmap getIcon();
/// update top-level properties and synchronize the physical model values
virtual void updateProperty(QString name, QVariant value);
/** Update the selection flag (this method is overridden in order to show the default
* modeling action when the component is selected for the first time).
*
* @param b the value of the flag (true means "is selected")
* @param recursive if true (default), also updates the children Component selection flags.
*/
virtual void setSelected(const bool b, const bool recursive = true);
///@name Specific methods for PML component
///@{
/// Return the PhysicalModel object associated to the component
PhysicalModel* getPhysicalModel() {
return this->physicalModel;
}
/// get the point Id from the corresponding atom, this is the opposite of pml->getAtom(id)
vtkIdType getPointId(const Atom *a);
/// initialize information (properties) and geometric representation from the physical model
void init();
///@}
/// @name 3D structure element selection methods
///@{
/// Select the given pml::Cell in the 3D strucutre
/// @param cell The Cell to highlight
void selectCell(Cell* cell, bool showAtomGlyph);
/// Select the given pml::Atom in the 3D structure
/// @param atom The Atom to highlight
void selectAtom(const Atom* atom);
/// Select the given structural component in the 3D structure by highlighting all its atoms and cells
/// @param sc The structural component to highlight
void selectSC(StructuralComponent* sc, bool showAtomGlyph);
/// Select the given multi component in the 3D structure by highlighting all its structural components
/// @param mc The multi component to highlight
void selectMC(MultiComponent* mc, bool showAtomGlyph);
/// Unselect all the SC, MC, Atoms and Cells previously selected on the 3D structure
void unselectItems();
/// Update the POINTS and CELLS selection for the whole 3D structure by telling the corresponding extractors
/// new vtkIds have been added to the selection lists.
void updateSelection();
/// Refresh the display of the component according to the selected 3D items by the user.
void refreshDisplay();
/**
* @brief Add a selection (inherited from MeshComponent inorder to show a glyph on selected atoms).
*
* If the name of the selection already exists, the data of the existing
* selection are updated according to the SelectionPolicy flag.
*
* @param name name of the selection
* @param fieldType field type of the selection (one of vtkSelectionNode::SelectionField)
* @param contentType content type (one of vtkSelectionNode::SelectionContent)
* @param array array of the selection
* @param policy policy to update the existing selection
* @return the index of the added selection in the selection list
*/
virtual int addSelection ( const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, camitk::MeshSelectionModel::InsertionPolicy policy = camitk::MeshSelectionModel::REPLACE );
///@}
protected:
/// create and initialize dynamic properties using the global xml attributes from the PhysicalModel object
virtual void initDynamicProperties();
private:
/// The library pml object that uses pmlschema to read the pml information for the xml file.
PhysicalModel* physicalModel;
/// the PMLComponent icon
static QPixmap * myPixmap;
/// the first selection should trigger the pml exporer action (default action)
bool neverSelected;
/// @name 3D structure creation
///@{
/// The 3D VTK cloup points of the atoms read
vtkSmartPointer<vtkPoints> thePoints;
/// The 3D grid containing all the cells of the PML
vtkSmartPointer<vtkUnstructuredGrid> mainGrid;
/// the Atom / vtkPoint Id map
std::AtomPointIdMap atomPointIdMap;
/// Create the 3D VTK structure representing the mesh.
void create3DStructure();
/// Create the 3D structure of the given MultiComponent and its children (recursively).
/// @param mc: The MultiComponent to build a 3D structure from.
void parseMultiComponent(MultiComponent* mc);
/// Create a 3D vtkCell corresponding to a structural component's cell
/// @param cell: The PML Cell, created by the library pml
/// @return A pointor to the vtkCell structure.
/// @note thePoints must not be NULL before calling this method (we create the vtkCell using points references)
vtkSmartPointer<vtkCell> cellToVTK(Cell* cell);
/// Create a 3D vtkPolyVertex of a structural component which ONLY contains atoms ref
/// @param sc: The PML structural component object that only contains atoms references.
/// @return a pointor to the vtkCell structure.
/// @note this method may be removed as soon as we change the PML XSD schema.
/// @note thePoints must not be NULL before calling this method (we create the vtkPolyVertex using points references)
vtkSmartPointer<vtkPolyVertex> atomSCToVTK(StructuralComponent* sc);
///@}
/// @name 3D structure element selection
///@{
/// The vtkIdTypeArray for atom selection (contains all the id array that corresponds to a selected atom)
vtkSmartPointer<vtkIdTypeArray> selectedAtomIdArray;
/// The vtkSelection for atom selection
vtkSmartPointer<vtkSelection> selectedAtomSelection;
/// The association structural component <-> vtkIdTypeArray for Cells selection.
/// Structural component name is the key.
/// scCellIdArrayMap(sc->getName().c_str()) contains the id of all the cells selected in the StructuralComponent sc
QMap<QString, vtkSmartPointer<vtkIdTypeArray> > scCellIdArrayMap;
/// The association structural component <-> vtkSelection for Cells selection.
/// Structural component name is the key.
/// scCellSelectionMap(sc->getName().c_str()) manages the vtkSelection of the StructuralComponent sc
QMap<QString, vtkSmartPointer<vtkSelection> > scCellSelectionMap;
/// Create a new VTK selection pipeline (selection, extractor, mapper, actor) for a given SC
/// if it does not allready exists.
/// A VTK selection pipeline is needed to represent the given structural component
/// There is one VTK selection pipeline per SC.
/// @param sc the input structural component to create the vtk extract selection from.
void createCellSelectionVTKPipeline(const StructuralComponent* sc);
/// Create the VTK selection pipeline (selection, extractor, mapper, actor) needed to
/// represent the selection of atoms.
void createAtomSelectionVTKPipeline();
///@}
};
// -------------------- Atom / VtkPoint Id Map --------------------
inline vtkIdType PMLComponent::getPointId(const Atom *a) {
if (!a)
return 0;
std::AtomPointIdMapIterator result = atomPointIdMap.find(a);
return (result == atomPointIdMap.end()) ? 0 : (result->second);
}
#endif
|