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

Revision 1007, 5.4 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#include        "change.h"
9
10//#include "SimplificationMethod.h"
11
12namespace 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 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
16
17Inputs:\n
18        - A pointer to the Geometry::Mesh object containing the 3D model to be simplified.
19        .
20       
21Outputs:\n
22        -# The simplified mesh, contained in a Geometry::Mesh object.
23        -# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object.
24       
25        */
26
27        class MeshSimplifier
28        {
29                public:
30                        /// Class constructor. Retrieves a pointer to a valid Geometry::Mesh object to simplify.
31                        MeshSimplifier( const Geometry::Mesh    *,
32                                                                                        Geometry::TIPOFUNC              upb=0);
33
34                        /// Virtual class destructor.
35                        virtual ~MeshSimplifier (void);
36
37                        /// Copy constructor
38                        //MeshSimplifier(const MeshSimplifier&);
39
40                        /// Assignment operator
41                        //MeshSimplifier& operator =(const MeshSimplifier&);
42
43                        /// 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.
44                        virtual void Simplify(Geometry::Real)=0;
45
46                        /// 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.
47                        virtual void Simplify(Geometry::uint32)=0;
48
49                        /// Returns the simplified mesh.
50                        Mesh *GetMesh();
51
52                        /// Returns the simplification sequence for general meshes.
53                        MeshSimplificationSequence *GetSimplificationSequence();
54
55                        // Sets what is the mesh that stores the leaves
56                        void setMeshLeaves(Geometry::Index);
57
58                protected:
59
60                        //private: // fer protected
61                        Mesh                                                                                            *mGeoMesh;
62                        MeshSimplificationSequence      *msimpsequence;
63                        const Mesh                                                                      *objmesh;
64
65                        Geometry::Index indexMeshLeaves;
66
67                        //      Progress bar function.
68                        Geometry::TIPOFUNC      mUPB;
69        };
70
71        /// Implementation of a simplification algorithm based on viewpoint.
72        /** This class implements a simplification algorithm based on a viewpoint evaluation technique. */
73        class ViewPointDrivenSimplifier : public MeshSimplifier
74        {
75        private:
76               
77                //      Auxiliar vertex buffer.
78                Geometry::VertexBuffer  *mVB;
79               
80                //      Loads a vmi mesh with a given geometry mesh.
81                VMI::Mesh * initMeshStructure(Geometry::Mesh    *geoMesh);
82
83                //      Loads a geometry mesh with a given vmi mesh.
84                void    loadMesh();
85
86                //      Find vertex in auxiliar vertex buffer.
87                void    findVertex(size_t       submesh, size_t index);
88               
89                //      Gets the VMI mesh simplification sequence.
90                void    GetMeshSimpSequence();
91
92        public:
93
94                /// Class constructor. Will call Simplifier class constructor.
95                ViewPointDrivenSimplifier(      const Geometry::Mesh    *geoMesh,
96                                                                                                                                Geometry::TIPOFUNC              upb=0);
97
98                /// Class destructor.
99                ~ViewPointDrivenSimplifier(void);
100
101                /// Copy constructor
102                //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&);
103
104                /// Assignment operator
105                //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&);
106
107                /// 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.
108                void Simplify(Geometry::Real);
109
110                /// 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.
111                void Simplify(Geometry::uint32);
112
113                // Returns the simplified mesh.
114                //Mesh *GetMesh();
115
116
117        };
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
Note: See TracBrowser for help on using the repository browser.