NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkBasicMesh.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3 NifTK: A software platform for medical image computing.
4 
5 Copyright (c) University College London (UCL). All rights reserved.
6 
7 This software is distributed WITHOUT ANY WARRANTY; without even
8 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9 PURPOSE.
10 
11 See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkBasicMesh_h
16 #define niftkBasicMesh_h
17 
18 #include <vector>
19 #include "niftkCoreExports.h"
20 #include "niftkBasicVertex.h"
21 #include "niftkBasicTriangle.h"
22 
23 namespace niftk
24 {
25 
30 
31 class NIFTKCORE_EXPORT BasicMesh
32 {
33 public:
35  BasicMesh();
37  BasicMesh(std::vector<BasicVertex> &vertices, std::vector<BasicTriangle> &triangles, int numOfVerts, int numOfTris);
39  virtual ~BasicMesh();
40 
42  void InitWithVertsAndTris(std::vector<BasicVertex> &vertices, std::vector<BasicTriangle> &triangles, int numOfVerts, int numOfTris);
43 
45  BasicMesh(const BasicMesh&);
47  BasicMesh& operator=(const BasicMesh&);
48 
50  BasicVertex& GetVertex(int index) { return m_VertList[index]; }
52  const BasicVertex& GetVertex(int index) const { return m_VertList[index]; }
54  BasicTriangle& GetTri(int index) { return m_TriList[index]; }
56  const BasicTriangle& GetTri(int index) const { return m_TriList[index]; }
57 
59  int GetNumVerts() { return m_NumVerts; }
61  void SetNumVerts(int n) { m_NumVerts = n; }
63  int GetNumTriangles() { return m_NumTriangles; }
65  void SetNumTriangles(int n) { m_NumTriangles = n; }
66 
68  void Normalize();
69 
71  void CalcOneVertNormal(unsigned vert);
72 
74  void PrintStatus();
75 
76 private:
78  bool operator==(const BasicMesh&);
79 
81  void SetMinMax(float min[3], float max[3]);
82 
84  void CalcVertNormals();
85 
86 private:
87  std::vector<BasicVertex> m_VertList; // list of vertices in mesh
88  std::vector<BasicTriangle> m_TriList; // list of triangles in mesh
89 
90  int m_NumVerts;
91  int m_NumTriangles;
92 };
93 
94 }
95 
96 #endif
void SetNumTriangles(int n)
Set number of triangles.
Definition: niftkBasicMesh.h:65
BasicVertex & GetVertex(int index)
Get reference to the vertex with the specified index.
Definition: niftkBasicMesh.h:50
bool operator==(niftk::BasicVertex const &x, niftk::BasicVertex const &y)
Definition: niftkMeshSmoother.cxx:31
BasicTriangle & GetTri(int index)
Get reference to the triangle with the specified index.
Definition: niftkBasicMesh.h:54
int GetNumTriangles()
Get number of triangles.
Definition: niftkBasicMesh.h:63
void Normalize(std::vector< double > &x)
Definition: niftiImageToMitk.cxx:34
Simple vertex implementation that is used in the Surface Extraction and surface smoothing and decimat...
Definition: niftkBasicVertex.h:77
GLuint index
Definition: glew.h:1798
Simple mesh implementation that is used in the Surface Extraction and surface smoothing and decimatio...
Definition: niftkBasicMesh.h:31
void SetNumVerts(int n)
Set number of vertices.
Definition: niftkBasicMesh.h:61
GLclampd n
Definition: glew.h:6789
int GetNumVerts()
Get number of vertices.
Definition: niftkBasicMesh.h:59
Simple triangle implementation that is used in the Surface Extraction and surface smoothing and decim...
Definition: niftkBasicTriangle.h:34
const BasicVertex & GetVertex(int index) const
Get const reference to the vertex with the specified index.
Definition: niftkBasicMesh.h:52
const BasicTriangle & GetTri(int index) const
Get const reference to the triangle with the specified index.
Definition: niftkBasicMesh.h:56
Definition: niftkExceptionObject.h:21