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

Revision 1024, 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        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                        //      Sort mesh bones.
70                        void    sortBones();
71        };
72
73        /// Implementation of a simplification algorithm based on viewpoint.
74        /** This class implements a simplification algorithm based on a viewpoint evaluation technique. */
75        class ViewPointDrivenSimplifier : public MeshSimplifier
76        {
77        private:
78               
79                //      Auxiliar vertex buffer.
80                Geometry::VertexBuffer  *mVB;
81               
82                //      Loads a vmi mesh with a given geometry mesh.
83                VMI::Mesh * initMeshStructure(Geometry::Mesh    *geoMesh);
84
85                //      Loads a geometry mesh with a given vmi mesh.
86                void    loadMesh();
87
88                //      Find vertex in auxiliar vertex buffer.
89                void    findVertex(size_t       submesh, size_t index);
90               
91                //      Gets the VMI mesh simplification sequence.
92                void    GetMeshSimpSequence();
93
94        public:
95
96                /// Class constructor. Will call Simplifier class constructor.
97                ViewPointDrivenSimplifier(      const Geometry::Mesh    *geoMesh,
98                                                                                                                                Geometry::TIPOFUNC              upb=0);
99
100                /// Class destructor.
101                ~ViewPointDrivenSimplifier(void);
102
103                /// Copy constructor
104                //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&);
105
106                /// Assignment operator
107                //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&);
108
109                /// 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.
110                void Simplify(Geometry::Real);
111
112                /// 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.
113                void Simplify(Geometry::uint32);
114
115                // Returns the simplified mesh.
116                //Mesh *GetMesh();
117        };
118
119        /// Implementation of a simplification algorithm based on geometry information.
120        /** This class implements a simplification algorithm based on a classic geometry evaluation technique. */
121        class GeometryBasedSimplifier : public MeshSimplifier
122        {
123        public:
124                /// Class constructor. Will call Simplifier class constructor.
125                GeometryBasedSimplifier(        const Geometry::Mesh    *geoMesh,
126                                                                                                                        Geometry::TIPOFUNC              upb=0);
127
128                /// Class destructor.
129                ~GeometryBasedSimplifier(void);
130
131                /// Copy constructor
132                //GeometryBasedSimplifier(const GeometryBasedSimplifier&);
133
134                /// Assignment operator
135                //GeometryBasedSimplifier& operator =(const GeometryBasedSimplifier&);
136
137                /// 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.
138                void Simplify(Geometry::Real);
139
140                /// 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.
141                void Simplify(Geometry::uint32);
142        };
143} // end of Geometry namespace;
144
145#endif
146
Note: See TracBrowser for help on using the repository browser.