Fraxinus  17.12
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #ifndef SSCMESH_
35 #define SSCMESH_
36 
37 #include "cxResourceExport.h"
38 #include "cxPrecompiledHeader.h"
39 #include "cxMeshTextureData.h"
40 
41 #include <set>
42 #include <boost/shared_ptr.hpp>
43 #include "cxPatientModelService.h"
44 #include "cxSpaceProvider.h"
45 
46 #include "vtkForwardDeclarations.h"
47 #include "cxMeshPropertyData.h"
48 
49 #include <QColor>
50 #include "cxData.h"
51 
52 class QDomNode;
53 class QDomDocument;
54 
55 namespace cx
56 {
57 
58 
66 class cxResource_EXPORT Mesh: public Data
67 {
68  Q_OBJECT
69 public:
70  static MeshPtr create(const QString& uid, const QString& name = "", PatientModelServicePtr patientModelService = PatientModelService::getNullObject(),
72  Mesh(const QString& uid, const QString& name="", vtkPolyDataPtr polyData=vtkPolyDataPtr(), PatientModelServicePtr patientModelService = PatientModelService::getNullObject(),
74  virtual ~Mesh();
75 
76  void setVtkPolyData(const vtkPolyDataPtr& polyData);
77 
78  virtual vtkPolyDataPtr getVtkPolyData() const;
79  virtual vtkTexturePtr getVtkTexture() const;
80 
81  void addXml(QDomNode& dataNode);
82  virtual void parseXml(QDomNode& dataNode);
83  virtual bool load(QString path);
84  virtual QString getType() const
85  {
86  return getTypeName();
87  }
88  static QString getTypeName()
89  {
90  return "mesh";
91  }
92  virtual QIcon getIcon() {return QIcon(":/icons/surface.png");}
93 
94  virtual DoubleBoundingBox3D boundingBox() const;
95  void setColor(const QColor& color);
96  QColor getColor();
97  void setUseColorFromPolydataScalars(bool on);
98  bool getUseColorFromPolydataScalars() const;
99  bool getBackfaceCulling();
100  bool getFrontfaceCulling();
101  void setIsWireframe(bool on);
102  bool getIsWireframe() const;
103  vtkPolyDataPtr getTransformedPolyDataCopy(Transform3D tranform);
104  bool isFiberBundle() const;
105  bool showGlyph();
106  bool hasGlyph();
107  double getVisSize();
108  const char * getOrientationArray();
109  const char * getColorArray();
110  const char * getGlyphLUT();
111  bool hasTexture() const;
112  QString getTextureShape();
113  QStringList getOrientationArrayList();
114  QStringList getColorArrayList();
115  const MeshPropertyData& getProperties() const;
116  const MeshTextureData& getTextureData() const;
117 
118  virtual void save(const QString &basePath);
119 signals:
120  void meshChanged();
121 public slots:
122  void setBackfaceCullingSlot(bool backfaceCulling);
123  void setFrontfaceCullingSlot(bool backfaceCulling);
124  void setShowGlyph(bool val);
125  void setVisSize(double size);
126  void setOrientationArray(const char * orientationArray);
127  void setColorArray(const char * colorArray);
128  void setGlyphLUT(const char * glyphLUT);
129  void updateVtkPolyDataWithTexture();
130 private:
131  PatientModelServicePtr mPatientModelService;
132  SpaceProviderPtr mSpaceProvider;
133  vtkPolyDataPtr mVtkPolyData;
134  vtkPolyDataPtr mVtkPolyDataOriginal;
135  vtkTexturePtr mVtkTexture;
136  bool createTextureMapper(vtkDataSetAlgorithmPtr &tMapper);
137  bool mHasGlyph;
138  bool mShowGlyph;
139  bool shouldGlyphBeEnableByDefault();
140  std::string mOrientationArray;
141  std::string mColorArray;
142  std::string mGlyphLUT;
143  QStringList mOrientationArrayList;
144  QStringList mColorArrayList;
145  MeshPropertyData mProperties;
146  MeshTextureData mTextureData;
147 };
148 
149 typedef boost::shared_ptr<Mesh> MeshPtr;
150 
151 } // namespace cx
152 
153 #endif /*SSCMESH_*/
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
vtkSmartPointer< class vtkTexture > vtkTexturePtr
A mesh data set.
Definition: cxMesh.h:66
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:84
virtual QIcon getIcon()
Definition: cxMesh.h:92
Superclass for all data objects.
Definition: cxData.h:109
static QString getTypeName()
Definition: cxMesh.h:88
boost::shared_ptr< class Mesh > MeshPtr
Namespace for all CustusX production code.