Chemical Data Processing Library C++ API - Version 1.4.0
TriangleMesh3D.hpp
Go to the documentation of this file.
1 /*
2  * TriangleMesh3D.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_TRIANGLEMESH3D_HPP
30 #define CDPL_VIS_TRIANGLEMESH3D_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Vis/Shape3D.hpp"
37 
38 
39 namespace CDPL
40 {
41 
42  namespace Vis
43  {
44 
50  {
51 
52  public:
56  typedef std::shared_ptr<TriangleMesh3D> SharedPointer;
57 
63 
68  void accept(Shape3DVisitor& visitor) const;
69 
75 
81 
88  void addVertex(double x, double y, double z);
89 
94  std::size_t getNumVertices() const;
95 
101 
107 
114  void addVertexNormal(double x, double y, double z);
115 
120  std::size_t getNumVertexNormals() const;
121 
127 
133 
140  void addFace(unsigned long v1_idx, unsigned long v2_idx, unsigned long v3_idx);
141 
146  std::size_t getNumFaces() const;
147 
152  bool isClosed() const;
153 
158  void setClosed(bool closed = true);
159 
163  void clear();
164 
169  void swap(TriangleMesh3D& mesh);
170 
177 
178  private:
179  Math::Vector3DArray vertices;
180  Math::Vector3DArray normals;
181  Math::Vector3ULArray faces;
182  bool closed{false};
183  };
184  } // namespace Vis
185 } // namespace CDPL
186 
187 #endif // CDPL_VIS_TRIANGLEMESH3D_HPP
Definition of class CDPL::Vis::Shape3D.
Definition of class CDPL::Math::VectorArray.
Definition of the preprocessor macro CDPL_VIS_API.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
The base of all Vis::Shape3D visitor implementations [VPTN].
Definition: Shape3DVisitor.hpp:49
The abstract base of all classes describing the geometric shape of 3D objects.
Definition: Shape3D.hpp:50
std::shared_ptr< Shape3D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated Shape3D instances.
Definition: Shape3D.hpp:56
Data structure for the storage of 3D triangle mesh vertices, vertex normals and faces.
Definition: TriangleMesh3D.hpp:50
void addVertex(double x, double y, double z)
Appends a new vertex at the position (x, y, z).
std::shared_ptr< TriangleMesh3D > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated TriangleMesh3D instances.
Definition: TriangleMesh3D.hpp:56
void accept(Shape3DVisitor &visitor) const
Accepts the Vis::Shape3DVisitor instance visitor by dispatching to its visitTriangleMesh() method [VP...
const Math::Vector3DArray & getVertices() const
Returns a const reference to the array storing the mesh vertices.
std::size_t getNumVertexNormals() const
Returns the number of stored vertex normals.
std::size_t getNumVertices() const
Returns the number of stored vertices.
bool isClosed() const
Tells whether the mesh has been flagged as a closed surface.
Shape3D::SharedPointer clone() const
Creates a dynamically allocated copy of the triangle mesh.
Math::Vector3ULArray & getFaces()
Returns a non-const reference to the array storing the triangle faces.
Math::Vector3DArray & getVertices()
Returns a non-const reference to the array storing the mesh vertices.
std::size_t getNumFaces() const
Returns the number of stored triangle faces.
TriangleMesh3D & operator+=(const TriangleMesh3D &mesh)
Appends the vertices, vertex normals and (vertex index corrected) faces of mesh to this mesh.
Math::Vector3DArray & getVertexNormals()
Returns a non-const reference to the array storing the per-vertex normals.
const Math::Vector3ULArray & getFaces() const
Returns a const reference to the array storing the triangle faces.
const Math::Vector3DArray & getVertexNormals() const
Returns a const reference to the array storing the per-vertex normals.
void addFace(unsigned long v1_idx, unsigned long v2_idx, unsigned long v3_idx)
Appends a new triangle face defined by the three vertex indices v1_idx, v2_idx and v3_idx.
void setClosed(bool closed=true)
Sets the flag that marks the mesh as a closed surface.
void addVertexNormal(double x, double y, double z)
Appends a new vertex normal with the components (x, y, z).
void clear()
Removes all vertices, vertex normals and faces and resets the closed-surface flag.
void swap(TriangleMesh3D &mesh)
Swaps the vertices, vertex normals and faces of this mesh with those of mesh.
VectorArray< Vector3D > Vector3DArray
Array storing vectors of type Math::Vector3D.
Definition: VectorArray.hpp:87
VectorArray< Vector3UL > Vector3ULArray
Array storing vectors of type Math::Vector3UL.
Definition: VectorArray.hpp:107
The namespace of the Chemical Data Processing Library.