source: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoTreeSimplifier.h @ 1070

Revision 1070, 3.6 KB checked in by gumbau, 18 years ago (diff)
Line 
1#ifndef __GEO_TREE_SIMPLIFIER__
2#define __GEO_TREE_SIMPLIFIER__
3
4#include "GeoMesh.h"
5#include "GeoTreeSimpSequence.h"
6
7#define K1              0.8f //distance factor
8#define K2              0.2f //coplanar factor
9
10class LeafOctree;
11class Leaf;
12
13namespace Geometry
14{
15        /// Tree Simplifier interface
16        /*** This module is used by LODTree to simplify leaves of a tree. It contains functions that generate simplified
17        versions of 3D objects made out of quads (represented as pairs of texture-mapped triangles). Given a 3D object, this
18        module computes a sequence of geometric transformations that reduce the object’s geometric detail while preserving
19        its appearance.\n\n
20
21        For each simplification step, the module returns a simplification sequence containing the leaf collapsed, the two
22        leaves being removed, and the resulting leaf for that contraction.\n\n
23
24       
25Inputs:\n
26        - A pointer to the Geometry::Mesh object containing the tree to be simplified.
27        .
28
29Outputs:\n
30        -# The simplified mesh, contained in a Geometry::Mesh object.
31        -# Simplification sequence, represented by a Geometry::TreeSimplificationSequence object.
32        */
33
34        class TreeSimplifier
35        {
36        public:
37                /// Class constructor. Retrieves a pointer to a valid Mesh object to simplify
38                TreeSimplifier(const Geometry::Mesh *, Geometry::TIPOFUNC upb=0);
39
40                /// Class destructor.
41                ~TreeSimplifier(void);
42
43                /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1].
44                void Simplify(Geometry::Real,Geometry::Index);
45       
46                /// Returns the simplified mesh.
47                Mesh *GetMesh();
48
49                /// Returns the simplification sequence for leaves.
50                TreeSimplificationSequence *GetSimplificationSequence();
51
52        private:
53                void CalculateLeafCenter(Leaf &);
54                void CalculateLeafNormal(Leaf &);
55                float CalculateLeafArea(Leaf &) const;
56                void CoplanarBetweenLeaves(void);
57                float BoundingSphereDiameter() const;
58//              void SetCriteria(float);  // to be erased: obsolete!
59                void SetCriteriaOptimized(float);
60
61                float max(float, float) const;
62                float min(float, float) const;
63
64                long int Collapse(float);
65                void TwoGreater(float*, int* );
66                void ChooseVertices(Leaf& , Leaf& , long int);
67                float HausdorffOptimized(const Leaf &, const Leaf&) const;
68                float DistanceFromCenters(const Leaf &, const Leaf &) const;
69                float distan(float, float, float, float, float, float) const;
70                long int MinDistance(void);
71                void NormalizeDistance(float diametro);
72//              void SetCriteria2(float, long int); obsolete!
73                void SetCriteria2Optimized(float, long int);
74                long int MinCriteria(void);
75
76                void Mesh2Structure(const Geometry::Mesh *,Index);
77                void BuildOutputMesh(int);
78                void CrossProduct(const float *v1, const float *v2, float *res) const;
79                float SquaredModule(const float *v) const;
80
81                Mesh                    *mesh; // simplified mesh object (for output)
82                const                   Mesh *objmesh;
83                float                   (*Vertex)[3];
84                Leaf                    *Leaves;
85                long int        activeLeaves, countLeaves;
86                TreeSimplificationSequence      *mtreesimpsequence;
87               
88                //      Update progress bar.
89                Geometry::TIPOFUNC      mUPB;
90
91                // the octree used to speed up the simplification process
92                LeafOctree *octree;
93                void RecursiveCreateLeafOctree(LeafOctree*, int deep); // this is called from CreateLeafNode
94                void RecursiveFillOctreeWithLeaves(LeafOctree*);
95                LeafOctree* CreateLeafOctree(int deep); // generates a new leaf octree and returns its root node
96                size_t  vertex_count;
97                LeafOctree ** octree_owning_leaf;
98                LeafOctree *GetMinOctreeNodeForLeaf(LeafOctree *start, const Leaf &leaf);
99                bool PruneOctree(LeafOctree *); // erases one octree level and translates its leaves to the parent. Returns true if the node itself was pruned
100        };
101}
102
103#endif
Note: See TracBrowser for help on using the repository browser.