1 | #ifndef __GEO_MESH_SIMPLIFIER__
|
---|
2 | #define __GEO_MESH_SIMPLIFIER__
|
---|
3 |
|
---|
4 | #include <math.h>
|
---|
5 | #include "GeoMesh.h"
|
---|
6 | #include "GeoMeshSimpSequence.h"
|
---|
7 | #include "vmi_simplifier.h"
|
---|
8 | #include "change.h"
|
---|
9 |
|
---|
10 | //#include "SimplificationMethod.h"
|
---|
11 |
|
---|
12 | namespace Geometry
|
---|
13 | {
|
---|
14 | /// Mesh simplificator interface.
|
---|
15 | /** This module is used by both models, general mesh models and the plant and tree models for the trunk and the branches. It contains functions that generate simplified versions of 3D objects made out of triangles. Given a 3D object, this module computes a sequence of geometric transformations that reduce the objects geometric detail while preserving its appearance. For each simplification step, returns a simplification sequence containing the edge to be collapse, the two triangles being removed and the new triangles remapped to the model.\n\n
|
---|
16 |
|
---|
17 | Inputs:\n
|
---|
18 | - A pointer to the Geometry::Mesh object containing the 3D model to be simplified.
|
---|
19 | .
|
---|
20 |
|
---|
21 | Outputs:\n
|
---|
22 | -# The simplified mesh, contained in a Geometry::Mesh object.
|
---|
23 | -# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object.
|
---|
24 | */
|
---|
25 |
|
---|
26 | class MeshSimplifier
|
---|
27 | {
|
---|
28 | public:
|
---|
29 | /// Class constructor. Retrieves a pointer to a valid Geometry::Mesh object to simplify.
|
---|
30 | MeshSimplifier( const Geometry::Mesh *,
|
---|
31 | Geometry::TIPOFUNC upb=0);
|
---|
32 |
|
---|
33 | /// Virtual class destructor.
|
---|
34 | virtual ~MeshSimplifier (void);
|
---|
35 |
|
---|
36 | /// Copy constructor
|
---|
37 | //MeshSimplifier(const MeshSimplifier&);
|
---|
38 |
|
---|
39 | /// Assignment operator
|
---|
40 | //MeshSimplifier& operator =(const MeshSimplifier&);
|
---|
41 |
|
---|
42 | /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. This is a pure virtual method and must be overloaded in a derived class that implements a simplification algorithm.
|
---|
43 | virtual void Simplify(Geometry::Real)=0;
|
---|
44 |
|
---|
45 | /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. This is a pure virtual method and must be overloaded in a derived class that implements a simplification algorithm.
|
---|
46 | virtual void Simplify(Geometry::uint32)=0;
|
---|
47 |
|
---|
48 | /// Returns the simplified mesh.
|
---|
49 | Mesh *GetMesh();
|
---|
50 |
|
---|
51 | /// Returns the simplification sequence for general meshes.
|
---|
52 | MeshSimplificationSequence *GetSimplificationSequence();
|
---|
53 |
|
---|
54 | // Sets what is the mesh that stores the leaves
|
---|
55 | void setMeshLeaves(Geometry::Index);
|
---|
56 |
|
---|
57 | protected:
|
---|
58 |
|
---|
59 | //private: // fer protected
|
---|
60 | Mesh *mGeoMesh;
|
---|
61 | Mesh *mInitialMesh;
|
---|
62 | MeshSimplificationSequence *msimpsequence;
|
---|
63 | const Mesh *objmesh;
|
---|
64 |
|
---|
65 | Geometry::Index indexMeshLeaves;
|
---|
66 |
|
---|
67 | // Progress bar function.
|
---|
68 | Geometry::TIPOFUNC mUPB;
|
---|
69 |
|
---|
70 | // Sort mesh bones.
|
---|
71 | void sortBones();
|
---|
72 | };
|
---|
73 |
|
---|
74 | /// Implementation of a simplification algorithm based on viewpoint.
|
---|
75 | /** This class implements a simplification algorithm based on a viewpoint evaluation technique. */
|
---|
76 | class ViewPointDrivenSimplifier : public MeshSimplifier
|
---|
77 | {
|
---|
78 | private:
|
---|
79 |
|
---|
80 | // Auxiliar vertex buffer.
|
---|
81 | Geometry::VertexBuffer *mVB;
|
---|
82 |
|
---|
83 | // Loads a vmi mesh with a given geometry mesh.
|
---|
84 | VMI::Mesh * initMeshStructure(Geometry::Mesh *geoMesh);
|
---|
85 |
|
---|
86 | // Loads a geometry mesh with a given vmi mesh.
|
---|
87 | void loadMesh();
|
---|
88 |
|
---|
89 | // Find vertex in auxiliar vertex buffer.
|
---|
90 | void findVertex(size_t submesh, size_t index);
|
---|
91 |
|
---|
92 | // Gets the VMI mesh simplification sequence.
|
---|
93 | void GetMeshSimpSequence();
|
---|
94 |
|
---|
95 | public:
|
---|
96 |
|
---|
97 | /// Class constructor. Will call Simplifier class constructor.
|
---|
98 | ViewPointDrivenSimplifier( const Geometry::Mesh *geoMesh,
|
---|
99 | Geometry::TIPOFUNC upb=0);
|
---|
100 |
|
---|
101 | /// Class destructor.
|
---|
102 | ~ViewPointDrivenSimplifier(void);
|
---|
103 |
|
---|
104 | /// Copy constructor
|
---|
105 | //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&);
|
---|
106 |
|
---|
107 | /// Assignment operator
|
---|
108 | //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&);
|
---|
109 |
|
---|
110 | /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification.
|
---|
111 | void Simplify(Geometry::Real);
|
---|
112 |
|
---|
113 | /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification.
|
---|
114 | void Simplify(Geometry::uint32);
|
---|
115 |
|
---|
116 | // Returns the simplified mesh.
|
---|
117 | //Mesh *GetMesh();
|
---|
118 | };
|
---|
119 |
|
---|
120 | /// Implementation of a simplification algorithm based on geometry information.
|
---|
121 | /** This class implements a simplification algorithm based on a classic geometry evaluation technique. */
|
---|
122 | class GeometryBasedSimplifier : public MeshSimplifier
|
---|
123 | {
|
---|
124 | public:
|
---|
125 | /// Class constructor. Will call Simplifier class constructor.
|
---|
126 | GeometryBasedSimplifier( const Geometry::Mesh *geoMesh,
|
---|
127 | Geometry::TIPOFUNC upb=0);
|
---|
128 |
|
---|
129 | /// Class destructor.
|
---|
130 | ~GeometryBasedSimplifier(void);
|
---|
131 |
|
---|
132 | /// Copy constructor
|
---|
133 | //GeometryBasedSimplifier(const GeometryBasedSimplifier&);
|
---|
134 |
|
---|
135 | /// Assignment operator
|
---|
136 | //GeometryBasedSimplifier& operator =(const GeometryBasedSimplifier&);
|
---|
137 |
|
---|
138 | /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification.
|
---|
139 | void Simplify(Geometry::Real);
|
---|
140 |
|
---|
141 | /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification.
|
---|
142 | void Simplify(Geometry::uint32);
|
---|
143 | };
|
---|
144 | } // end of Geometry namespace;
|
---|
145 |
|
---|
146 | #endif
|
---|
147 |
|
---|