CustusX  16.12
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  bool getBackfaceCulling();
98  bool getFrontfaceCulling();
99  void setIsWireframe(bool on);
100  bool getIsWireframe() const;
101  vtkPolyDataPtr getTransformedPolyData(Transform3D tranform);
102  bool isFiberBundle() const;
103  bool showGlyph();
104  bool hasGlyph();
105  double getVisSize();
106  const char * getOrientationArray();
107  const char * getColorArray();
108  const char * getGlyphLUT();
109  bool hasTexture() const;
110  QString getTextureShape();
111  QStringList getOrientationArrayList();
112  QStringList getColorArrayList();
113  const MeshPropertyData& getProperties() const;
114  const MeshTextureData& getTextureData() const;
115 
116  virtual void save(const QString &basePath);
117 signals:
118  void meshChanged();
119 public slots:
120  void setBackfaceCullingSlot(bool backfaceCulling);
121  void setFrontfaceCullingSlot(bool backfaceCulling);
122  void setShowGlyph(bool val);
123  void setVisSize(double size);
124  void setOrientationArray(const char * orientationArray);
125  void setColorArray(const char * colorArray);
126  void setGlyphLUT(const char * glyphLUT);
127  void updateVtkPolyDataWithTexture();
128 private:
129  PatientModelServicePtr mPatientModelService;
130  SpaceProviderPtr mSpaceProvider;
131  vtkPolyDataPtr mVtkPolyData;
132  vtkTexturePtr mVtkTexture;
133  bool createTextureMapper(vtkDataSetAlgorithmPtr &tMapper);
134  bool mHasGlyph;
135  bool mShowGlyph;
136  bool shouldGlyphBeEnableByDefault();
137  std::string mOrientationArray;
138  std::string mColorArray;
139  std::string mGlyphLUT;
140  QStringList mOrientationArrayList;
141  QStringList mColorArrayList;
142  MeshPropertyData mProperties;
143  MeshTextureData mTextureData;
144 };
145 
146 typedef boost::shared_ptr<Mesh> MeshPtr;
147 
148 } // namespace cx
149 
150 #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()
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
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.
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
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