CustusX  22.04-rc5
An IGT application
cxMesh.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 
13 #ifndef SSCMESH_
14 #define SSCMESH_
15 
16 #include "cxResourceExport.h"
17 #include "cxPrecompiledHeader.h"
18 #include "cxMeshTextureData.h"
19 
20 #include <set>
21 #include <boost/shared_ptr.hpp>
22 #include "cxPatientModelService.h"
23 #include "cxSpaceProvider.h"
24 
25 #include "vtkForwardDeclarations.h"
26 #include "cxMeshPropertyData.h"
27 
28 #include <QColor>
29 #include "cxData.h"
30 
31 class QDomNode;
32 class QDomDocument;
33 
34 namespace cx
35 {
36 
37 
45 class cxResource_EXPORT Mesh: public Data
46 {
47  Q_OBJECT
48 public:
49  static MeshPtr create(const QString& uid, const QString& name = "", PatientModelServicePtr patientModelService = PatientModelService::getNullObject(),
51  Mesh(const QString& uid, const QString& name="", vtkPolyDataPtr polyData=vtkPolyDataPtr(), PatientModelServicePtr patientModelService = PatientModelService::getNullObject(),
53  virtual ~Mesh();
54 
55  void setVtkPolyData(const vtkPolyDataPtr& polyData);
56 
57  virtual vtkPolyDataPtr getVtkPolyData() const;
58  virtual vtkTexturePtr getVtkTexture() const;
59 
60  void addXml(QDomNode& dataNode);
61  virtual void parseXml(QDomNode& dataNode);
62  virtual bool load(QString path, FileManagerServicePtr filemanager);
63  virtual QString getType() const
64  {
65  return getTypeName();
66  }
67  static QString getTypeName()
68  {
69  return "mesh";
70  }
71  virtual QIcon getIcon() {return QIcon(":/icons/surface.png");}
72 
73  virtual DoubleBoundingBox3D boundingBox() const;
74  void setColor(const QColor& color);
75  QColor getColor();
76  void setUseColorFromPolydataScalars(bool on);
77  bool getUseColorFromPolydataScalars() const;
78  bool getBackfaceCulling();
79  bool getFrontfaceCulling();
80  void setIsWireframe(bool on);
81  bool getIsWireframe() const;
82  vtkPolyDataPtr getTransformedPolyDataCopy(Transform3D tranform);
83  bool isFiberBundle() const;
84  bool showGlyph();
85  bool hasGlyph();
86  double getVisSize();
87  const char * getOrientationArray();
88  const char * getColorArray();
89  const char * getGlyphLUT();
90  bool hasTexture() const;
91  QString getTextureShape();
92  QStringList getOrientationArrayList();
93  QStringList getColorArrayList();
94  const MeshPropertyData& getProperties() const;
95  const MeshTextureData& getTextureData() const;
96 
97  virtual void save(const QString &basePath, FileManagerServicePtr fileManager);
98 signals:
99  void meshChanged();
100 public slots:
101  void setBackfaceCullingSlot(bool backfaceCulling);
102  void setFrontfaceCullingSlot(bool backfaceCulling);
103  void setShowGlyph(bool val);
104  void setVisSize(double size);
105  void setOrientationArray(const char * orientationArray);
106  void setColorArray(const char * colorArray);
107  void setGlyphLUT(const char * glyphLUT);
108  void updateVtkPolyDataWithTexture();
109 private:
110  PatientModelServicePtr mPatientModelService;
111  SpaceProviderPtr mSpaceProvider;
112  vtkPolyDataPtr mVtkPolyData;
113  vtkPolyDataPtr mVtkPolyDataOriginal;
114  vtkTexturePtr mVtkTexture;
115  bool createTextureMapper(vtkDataSetAlgorithmPtr &tMapper);
116  bool mHasGlyph;
117  bool mShowGlyph;
118  bool shouldGlyphBeEnableByDefault();
119  std::string mOrientationArray;
120  std::string mColorArray;
121  std::string mGlyphLUT;
122  QStringList mOrientationArrayList;
123  QStringList mColorArrayList;
124  MeshPropertyData mProperties;
125  MeshTextureData mTextureData;
126 };
127 
128 typedef boost::shared_ptr<Mesh> MeshPtr;
129 
130 } // namespace cx
131 
132 #endif /*SSCMESH_*/
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkTexture > vtkTexturePtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
A mesh data set.
Definition: cxMesh.h:45
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkDataSetAlgorithm > vtkDataSetAlgorithmPtr
static PatientModelServicePtr getNullObject()
static SpaceProviderPtr getNullObject()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
virtual QString getType() const
Definition: cxMesh.h:63
virtual QIcon getIcon()
Definition: cxMesh.h:71
Superclass for all data objects.
Definition: cxData.h:89
static QString getTypeName()
Definition: cxMesh.h:67
boost::shared_ptr< class Mesh > MeshPtr
Namespace for all CustusX production code.