source: GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h @ 1007

Revision 1007, 2.8 KB checked in by gumbau, 18 years ago (diff)
Line 
1#pragma once
2
3#include <set>
4#include <map>
5#include <vector>
6#include <list>
7#include <iostream>
8#include <qslim.h>
9#include <GeoMeshSimplifier.h>
10
11class SimplificationMethod
12{
13private:
14        Geometry::Mesh  *mGeoMesh;
15        void compute_pair_info(qslim::pair_info*);
16        qslim::Model M0;
17        qslim::array<qslim::vert_info> vinfo;
18        qslim::Heap *heap;
19        qslim::real proximity_limit;    // distance threshold squared
20        int initialVertCount;
21        int initialEdgeCount;
22        int initialFaceCount;
23
24        inline qslim::vert_info& vertex_info(qslim::Vertex *v)
25        {
26                return vinfo(v->validID());
27        }
28       
29        qslim::real pair_mesh_penalty(qslim::Model& M,
30                                                                                                                                qslim::Vertex *v1,
31                                                                                                                                qslim::Vertex *v2,
32                                                                                                                                qslim::Vec3& vnew);
33       
34        int predict_face(qslim::Face& F,
35                                                                        qslim::Vertex *v1,
36                                                                        qslim::Vertex *v2,
37                                                                        qslim::Vec3& vnew,
38                                                                        qslim::Vec3& f1,
39                                                                        qslim::Vec3& f2,
40                                                                        qslim::Vec3& f3);
41       
42        bool check_for_pair(qslim::Vertex *v0, qslim::Vertex *v1);
43       
44        qslim::pair_info *new_pair(qslim::Vertex *v0, qslim::Vertex *v1);
45       
46        void delete_pair(qslim::pair_info *pair);
47       
48        void do_contract(qslim::Model& m, qslim::pair_info *pair);
49       
50        bool decimate_quadric(qslim::Vertex *v, qslim::Mat4& Q);
51       
52        void decimate_contract(qslim::Model& m);
53       
54        qslim::real decimate_error(qslim::Vertex *v);
55       
56        qslim::real decimate_min_error();
57       
58        qslim::real decimate_max_error(qslim::Model& m);
59       
60        void decimate_init(qslim::Model& m, qslim::real limit);
61       
62        bool pair_is_valid(qslim::Vertex *u, qslim::Vertex *v);
63       
64        void simplifmethod_run(int,     Geometry::TIPOFUNC      upb=0);
65       
66        void simplifmethod_runv(int,    Geometry::TIPOFUNC      upb=0);
67       
68        void simplifmethod_init(void);
69
70        //      To map the mesh with de simplification method structure.
71        //      Submeshes which pertains each vertex.
72        std::map<int,std::vector<int> > submeshmap;
73       
74        //      Vertices of the VertexBuffer that point
75        //      at this vertex of the simplification method.
76        std::map<int,std::vector<int> > vertexbuffermap;
77
78        //      Simplification sequence of the simplification method.
79        std::vector<Geometry::MeshSimplificationSequence::Step> decim_data;
80       
81        std::string meshName;
82       
83        void WriteOBJ(void);
84       
85        unsigned int *first_index_submesh;
86       
87        //std::vector<qslim::pair_info *> pointers_to_remove;
88
89        int indexMeshLeaves;
90       
91public:
92       
93        const Geometry::Mesh *objmesh;
94       
95        //      Total number of triangles of all the submeshes.
96        int number_of_triangles;
97       
98        SimplificationMethod(const Geometry::Mesh *m);
99       
100        void geomesh2simplifModel(void);
101       
102        Geometry::MeshSimplificationSequence *Decimate( float lod,
103                                                                                                                                                                                                        int simpliftype,
104                                                                                                                                                                                                        Geometry::TIPOFUNC      upb=0);
105       
106        void setMeshLeaves(int meshLeaves);
107
108        ///     Gets mesh simplified.
109        Geometry::Mesh  *       GetMesh();
110       
111        ///Destructor
112        ~SimplificationMethod();
113};
114
Note: See TracBrowser for help on using the repository browser.