1 | #pragma once
|
---|
2 |
|
---|
3 | #include <set>
|
---|
4 | #include <map>
|
---|
5 | #include <vector>
|
---|
6 | #include <list>
|
---|
7 | #include <iostream>
|
---|
8 | #include <simplif.h>
|
---|
9 | #include <GeoMeshSimplifier.h>
|
---|
10 |
|
---|
11 | class SimplificationMethod
|
---|
12 | {
|
---|
13 | private:
|
---|
14 | Geometry::Mesh *mGeoMesh;
|
---|
15 | void compute_pair_info(simplif::pair_info*);
|
---|
16 | simplif::Model M0;
|
---|
17 | simplif::array<simplif::vert_info> vinfo;
|
---|
18 | simplif::Heap *heap;
|
---|
19 | simplif::real proximity_limit; // distance threshold squared
|
---|
20 | int initialVertCount;
|
---|
21 | int initialEdgeCount;
|
---|
22 | int initialFaceCount;
|
---|
23 |
|
---|
24 | inline simplif::vert_info& vertex_info(simplif::Vertex *v)
|
---|
25 | {
|
---|
26 | return vinfo(v->validID());
|
---|
27 | }
|
---|
28 |
|
---|
29 | simplif::real pair_mesh_penalty(simplif::Model& M,
|
---|
30 | simplif::Vertex *v1,
|
---|
31 | simplif::Vertex *v2,
|
---|
32 | simplif::Vec3& vnew);
|
---|
33 |
|
---|
34 | int predict_face(simplif::Face& F,
|
---|
35 | simplif::Vertex *v1,
|
---|
36 | simplif::Vertex *v2,
|
---|
37 | simplif::Vec3& vnew,
|
---|
38 | simplif::Vec3& f1,
|
---|
39 | simplif::Vec3& f2,
|
---|
40 | simplif::Vec3& f3);
|
---|
41 |
|
---|
42 | bool check_for_pair(simplif::Vertex *v0, simplif::Vertex *v1);
|
---|
43 |
|
---|
44 | simplif::pair_info *new_pair(simplif::Vertex *v0, simplif::Vertex *v1);
|
---|
45 |
|
---|
46 | void delete_pair(simplif::pair_info *pair);
|
---|
47 |
|
---|
48 | void do_contract(simplif::Model& m, simplif::pair_info *pair);
|
---|
49 |
|
---|
50 | bool decimate_quadric(simplif::Vertex *v, simplif::Mat4& Q);
|
---|
51 |
|
---|
52 | void decimate_contract(simplif::Model& m);
|
---|
53 |
|
---|
54 | simplif::real decimate_error(simplif::Vertex *v);
|
---|
55 |
|
---|
56 | simplif::real decimate_min_error();
|
---|
57 |
|
---|
58 | simplif::real decimate_max_error(simplif::Model& m);
|
---|
59 |
|
---|
60 | void decimate_init(simplif::Model& m, simplif::real limit);
|
---|
61 |
|
---|
62 | bool pair_is_valid(simplif::Vertex *u, simplif::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<simplif::pair_info *> pointers_to_remove;
|
---|
88 |
|
---|
89 | int indexMeshLeaves;
|
---|
90 |
|
---|
91 | public:
|
---|
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 |
|
---|