Changeset 2087


Ignore:
Timestamp:
02/05/07 13:28:27 (17 years ago)
Author:
gumbau
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h

    r1526 r2087  
    1010 
    1111using   namespace       Geometry; 
    12  
     12using   namespace       std; 
     13 
     14//------------------------------------------------------------------------- 
     15// Class to create a map without repeated vertices 
     16//------------------------------------------------------------------------- 
     17class _float3_ 
     18{ 
     19        public: 
     20 
     21                float x,y,z; 
     22 
     23                _float3_(float x=0.0f, float y=0.0f, float z=0.0f) 
     24                { 
     25                        this->x = x; this->y = y; this->z = z; 
     26                } 
     27 
     28                _float3_(const _float3_ &f) 
     29                { 
     30                        x=f.x; y=f.y; z=f.z; 
     31                } 
     32 
     33                _float3_ & operator=(const _float3_ &f) 
     34                { 
     35                        x=f.x; y=f.y; z=f.z; return *this; 
     36                } 
     37 
     38                bool operator<(const _float3_ &f) const 
     39                { 
     40                        if (x<f.x) return true; 
     41                        if (x>f.x) return false; 
     42                        if (y<f.y) return true; 
     43                        if (y>f.y) return false; 
     44                        if (z<f.z) return true; 
     45                        if (z>f.z) return false; 
     46                        return false; 
     47                } 
     48}; 
     49 
     50//------------------------------------------------------------------------- 
     51// Class to perform mesh simplification. 
     52//------------------------------------------------------------------------- 
    1353class SimplificationMethod 
    1454{ 
     
    2161                simplif::Model M0; 
    2262 
    23                 simplif::array<simplif::vert_info> vinfo; 
     63                simplif::buffer<simplif::vert_info> vinfo; 
    2464 
    2565                simplif::Heap *heap; 
     
    90130                std::map< int,  std::vector<int> > vertexbuffermap; 
    91131 
     132                //      Multimap to store current vertex in a simplification state. 
     133                typedef multimap<_float3_,      int>    vertex_map; 
     134                typedef vertex_map::iterator                    vertex_map_str; 
     135                typedef vertex_map::value_type          vertex_pair; 
     136 
     137                //      Store unique vertices by submesh (without repetitions). 
     138                typedef std::map<int,int> MAPAINDIND; 
     139 
     140                //      Store all the indices by submesh (with repetitions). 
     141                typedef std::vector<int> REPINDLIST; 
     142 
     143                vertex_map      vertexMultimap; 
     144 
    92145                //      Simplification sequence of the simplification method. 
    93146                std::vector<Geometry::MeshSimplificationSequence::Step> decim_data; 
     
    101154                int indexMeshLeaves; 
    102155 
    103                 //      Contract lonely vertices that have same coords than the contracted one. 
     156                //      Contract lonely vertices that have same coords  
     157                //      than the contracted one. 
    104158                void    contractLonelyVertices( simplif::Model  &m, 
    105159                                                                                                                                        simplif::Vertex *v0, 
     
    107161                                                                                                                                        simplif::Vec3           candidate); 
    108162 
    109                 //      Remove twin edges. 
    110                 void    removeTwinEdges(simplif::Model  &m, 
    111                                                                                                         simplif::Vertex *v0, 
    112                                                                                                         simplif::Vertex *v1, 
    113                                                                                                         simplif::Vec3           candidate); 
     163                //      Find twin vertices to the contracted one and contract them. 
     164                void    removeTwinVertices(     simplif::Model  &m, 
     165                                                                                                                        simplif::Vertex *v0, 
     166                                                                                                                        simplif::Vertex *v1, 
     167                                                                                                                        simplif::Vec3           candidate); 
     168 
     169                void    fillUpSharedVertices(   MAPAINDIND      &shared_vertex_map, 
     170                                                                                                                                REPINDLIST *ver_inds_rep_by_geo); 
     171 
     172                void    fillUpVertices( MAPAINDIND      *unique_verts_inds_by_geo, 
     173                                                                                                        REPINDLIST *ver_inds_rep_by_geo); 
     174 
     175                void    addNewBoneAssignments(); 
     176 
     177                void    eraseVoidSubMeshes(Mesh *geoMesh); 
    114178 
    115179        public: 
    116180 
    117                 const Geometry::Mesh *objmesh; 
     181                Mesh *mInitialMesh; 
    118182 
    119183                //      Total number of triangles of all the submeshes. 
    120184                int number_of_triangles; 
    121185 
    122                 SimplificationMethod(const Geometry::Mesh *m); 
    123  
    124                 void    generateSimplifModel(void); 
    125  
    126                 Geometry::MeshSimplificationSequence *Decimate( float lod, 
    127                                 int simpliftype, 
    128                                 Geometry::TIPOFUNC      upb=0); 
    129  
    130                 void setMeshLeaves(int meshLeaves); 
    131  
    132                 ///     Gets mesh simplified. 
    133                 Geometry::Mesh  *       GetMesh(); 
     186                ///     Constructor. 
     187                SimplificationMethod(const Mesh *m); 
    134188 
    135189                ///     Destructor. 
    136190                ~SimplificationMethod(); 
     191 
     192                void    generateSimplifModel(void); 
     193 
     194                MeshSimplificationSequence *Decimate(   float                   lod, 
     195                                                                                                                                                                        int                             simpliftype, 
     196                                                                                                                                                                        TIPOFUNC        upb=0); 
     197 
     198                void setMeshLeaves(int meshLeaves); 
     199 
     200                ///     Gets mesh simplified. 
     201                Mesh    *       GetMesh(); 
     202 
    137203}; 
    138204 
Note: See TracChangeset for help on using the changeset viewer.