source: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h @ 980

Revision 980, 5.3 KB checked in by gumbau, 18 years ago (diff)
Line 
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
9//#include "SimplificationMethod.h"
10
11namespace Geometry
12{
13        /// Mesh simplificator interface.
14        /** 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 object’s 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
15
16Inputs:\n
17        - A pointer to the Geometry::Mesh object containing the 3D model to be simplified.
18        .
19       
20Outputs:\n
21        -# The simplified mesh, contained in a Geometry::Mesh object.
22        -# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object.
23       
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                        MeshSimplificationSequence      *msimpsequence;
62                        const Mesh                                                                      *objmesh;
63
64                        Geometry::Index indexMeshLeaves;
65
66                        //      Progress bar function.
67                        Geometry::TIPOFUNC      mUPB;
68        };
69
70        /// Implementation of a simplification algorithm based on viewpoint.
71        /** This class implements a simplification algorithm based on a viewpoint evaluation technique. */
72        class ViewPointDrivenSimplifier : public MeshSimplifier
73        {
74        private:
75               
76                //      Auxiliar vertex buffer.
77                Geometry::VertexBuffer  *mVB;
78               
79                //      Loads a vmi mesh with a given geometry mesh.
80                VMI::Mesh * initMeshStructure(Geometry::Mesh    *geoMesh);
81
82                //      Loads a geometry mesh with a given vmi mesh.
83                void    loadMesh();
84
85                //      Find vertex in auxiliar vertex buffer.
86                void    findVertex(size_t       submesh, size_t index);
87               
88        public:
89
90                /// Class constructor. Will call Simplifier class constructor.
91                ViewPointDrivenSimplifier(      const Geometry::Mesh    *geoMesh,
92                                                                                                                                Geometry::TIPOFUNC              upb=0);
93
94                /// Class destructor.
95                ~ViewPointDrivenSimplifier(void);
96
97                /// Copy constructor
98                //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&);
99
100                /// Assignment operator
101                //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&);
102
103                /// 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.
104                void Simplify(Geometry::Real);
105
106                /// 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.
107                void Simplify(Geometry::uint32);
108
109                // Returns the simplified mesh.
110                //Mesh *GetMesh();
111
112
113        };
114
115
116        /// Implementation of a simplification algorithm based on geometry information.
117        /** This class implements a simplification algorithm based on a classic geometry evaluation technique. */
118        class GeometryBasedSimplifier : public MeshSimplifier
119        {
120        public:
121                /// Class constructor. Will call Simplifier class constructor.
122                GeometryBasedSimplifier(        const Geometry::Mesh    *geoMesh,
123                                                                                                                        Geometry::TIPOFUNC              upb=0);
124
125                /// Class destructor.
126                ~GeometryBasedSimplifier(void);
127
128                /// Copy constructor
129                //GeometryBasedSimplifier(const GeometryBasedSimplifier&);
130
131                /// Assignment operator
132                //GeometryBasedSimplifier& operator =(const GeometryBasedSimplifier&);
133
134                /// 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.
135                void Simplify(Geometry::Real);
136
137                /// 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.
138                void Simplify(Geometry::uint32);
139        };
140} // end of Geometry namespace;
141
142#endif
143
Note: See TracBrowser for help on using the repository browser.