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 |
|
---|
11 | class SimplificationMethod
|
---|
12 | {
|
---|
13 | private:
|
---|
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){ return vinfo(v->validID()); }
|
---|
25 | qslim::real pair_mesh_penalty(qslim::Model& M, qslim::Vertex *v1, qslim::Vertex *v2, qslim::Vec3& vnew);
|
---|
26 | int predict_face(qslim::Face& F, qslim::Vertex *v1, qslim::Vertex *v2, qslim::Vec3& vnew, qslim::Vec3& f1, qslim::Vec3& f2, qslim::Vec3& f3);
|
---|
27 | bool check_for_pair(qslim::Vertex *v0, qslim::Vertex *v1);
|
---|
28 | qslim::pair_info *new_pair(qslim::Vertex *v0, qslim::Vertex *v1);
|
---|
29 | void delete_pair(qslim::pair_info *pair);
|
---|
30 | void do_contract(qslim::Model& m, qslim::pair_info *pair);
|
---|
31 | bool decimate_quadric(qslim::Vertex *v, qslim::Mat4& Q);
|
---|
32 | void decimate_contract(qslim::Model& m);
|
---|
33 | qslim::real decimate_error(qslim::Vertex *v);
|
---|
34 | qslim::real decimate_min_error();
|
---|
35 | qslim::real decimate_max_error(qslim::Model& m);
|
---|
36 | void decimate_init(qslim::Model& m, qslim::real limit);
|
---|
37 | bool pair_is_valid(qslim::Vertex *u, qslim::Vertex *v);
|
---|
38 | void simplifmethod_run(int, Geometry::TIPOFUNC upb=0);
|
---|
39 | void simplifmethod_runv(int, Geometry::TIPOFUNC upb=0);
|
---|
40 | void simplifmethod_init(void);
|
---|
41 |
|
---|
42 | //To map the mesh with de simplification method structure
|
---|
43 | std::map<int,std::vector<int> > submeshmap; //submeshes which pertains each vertex
|
---|
44 | std::map<int,std::vector<int> > vertexbuffermap; //vertices of the VertexBuffer that point at this vertex of the simplification method
|
---|
45 |
|
---|
46 | //simplification sequence of the simplification method
|
---|
47 | std::vector<Geometry::MeshSimplificationSequence::Step> decim_data;
|
---|
48 | std::string meshName;
|
---|
49 | void WriteOBJ(void);
|
---|
50 | unsigned int *first_index_submesh;
|
---|
51 | //std::vector<qslim::pair_info *> pointers_to_remove;
|
---|
52 |
|
---|
53 | int indexMeshLeaves;
|
---|
54 | public:
|
---|
55 | const Geometry::Mesh *objmesh;
|
---|
56 | int number_of_triangles; //total number of triangles of all the submeshes
|
---|
57 | SimplificationMethod(const Geometry::Mesh *m);
|
---|
58 | void geomesh2simplifModel(void);
|
---|
59 | Geometry::MeshSimplificationSequence *Decimate(float lod, int simpliftype,Geometry::TIPOFUNC upb=0);
|
---|
60 | void setMeshLeaves(int meshLeaves);
|
---|
61 |
|
---|
62 | // Gets mesh simplified.
|
---|
63 | Geometry::Mesh * GetMesh();
|
---|
64 |
|
---|
65 | ///Destructor
|
---|
66 | ~SimplificationMethod();
|
---|
67 | };
|
---|