Changeset 2291


Ignore:
Timestamp:
03/26/07 08:46:55 (17 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h

    r2194 r2291  
    142142                        Mesh                                                                                            *mInitialMesh; 
    143143                        MeshSimplificationSequence      *msimpsequence; 
    144                         const Mesh                                                                      *objmesh; 
    145144 
    146145                        Geometry::Index indexMeshLeaves; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp

    r2194 r2291  
    2424        *mInitialMesh   =       *m; 
    2525         
    26         objmesh                                 =       m; 
    2726        mGeoMesh                                =       NULL; 
    2827        msimpsequence           =       NULL; 
     
    120119} 
    121120 
    122  
    123121////////////////////////////////////////////////////////////////////////// 
    124122//                                                                                                                                                                                                                                                                                      // 
     
    150148void GeometryBasedSimplifier::Simplify(Real paramlod) 
    151149{ 
    152         SimplificationMethod *m_qslim   =       new SimplificationMethod(objmesh); 
     150        SimplificationMethod *m_qslim   =       new SimplificationMethod(mInitialMesh); 
    153151 
    154152        m_qslim->setMeshLeaves(indexMeshLeaves); 
     
    169167void GeometryBasedSimplifier::Simplify(uint32 numvertices) 
    170168{ 
    171         SimplificationMethod *m_qslim   =       new SimplificationMethod(objmesh); 
     169        SimplificationMethod *m_qslim   =       new SimplificationMethod(mInitialMesh); 
    172170         
    173171        m_qslim->setMeshLeaves(indexMeshLeaves); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/AdjModel.h

    r1526 r2291  
    7070                        // Basic model accessor functions 
    7171                        // 
    72                         simplif::Vertex *vertex(int i) { return vertices(i); } 
    73                         simplif::Vec3 & normal(int i){ return normals(i); } 
    74                         simplif::Vec2 & texcoord(int i){ return texcoords(i); } 
    75                         simplif::Edge *edge(int i) { return edges(i); } 
    76                         simplif::Face *face(int i) { return faces(i); } 
     72                        simplif::Vertex *vertex(int i) {return vertices(i);} 
     73                        simplif::Vec3 & normal(int i){return normals(i);} 
     74                        simplif::Vec2 & texcoord(int i){return texcoords(i);} 
     75                        simplif::Edge *edge(int i) {return edges(i);} 
     76                        simplif::Face *face(int i) {return faces(i);} 
    7777 
    78                         int vertCount() { return vertices.length(); } 
    79                         int normCount() { return normals.length();  } 
    80                         int texcoordCount() { return texcoords.length();  } 
    81                         int edgeCount() { return edges.length();    } 
    82                         int faceCount() { return faces.length();    } 
     78                        int vertCount() {return vertices.length();} 
     79                        int normCount() {return normals.length();} 
     80                        int texcoordCount() {return texcoords.length();} 
     81                        int edgeCount() {return edges.length();} 
     82                        int faceCount() {return faces.length();} 
    8383 
    84                         vert_buffer& allVertices() { return vertices; } 
    85                         edge_buffer& allEdges()    { return edges;    } 
    86                         face_buffer& allFaces()    { return faces;    } 
     84                        vert_buffer& allVertices() {return vertices;} 
     85                        edge_buffer& allEdges()    {return edges;} 
     86                        face_buffer& allFaces()    {return faces;} 
    8787 
    8888                        // 
     
    124124                        int in_TexCoord(const Vec2&); 
    125125 
    126                         int in_Face(int v1, int v2, int v3,  
     126                        int in_Face(int v1, int v2, int v3, 
    127127                                                                        int n1, int n2, int n3, 
    128128                                                                        int t1, int t2, int t3); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp

    r2194 r2291  
    4444        simplif::Vertex *v1 = auxpair->v1; 
    4545 
    46         simplif::vert_info& v0_info = vertex_info(v0); 
    47         simplif::vert_info& v1_info = vertex_info(v1); 
    48  
    49         simplif::Mat4 Q                 =       v0_info.Q + v1_info.Q; 
    50         simplif::real norm      =       v0_info.norm + v1_info.norm; 
     46        simplif::vert_info      *v0_info = vertex_info(v0); 
     47        simplif::vert_info      *v1_info = vertex_info(v1); 
     48 
     49        simplif::Mat4 Q                 =       v0_info->Q + v1_info->Q; 
     50        simplif::real norm      =       v0_info->norm + v1_info->norm; 
    5151 
    5252        auxpair->cost = simplif::quadrix_pair_target(   Q, 
     
    178178                                                                                                                                                                        simplif::Vertex *v1) 
    179179{ 
    180         const simplif::pair_buffer& pairs = vertex_info(v0).pairs; 
     180        const simplif::pair_buffer& pairs = vertex_info(v0)->pairs; 
    181181 
    182182        for(int i=0; i<pairs.length(); i++) 
     
    197197                                                                                                                                                                                                                simplif::Vertex *v1) 
    198198{ 
    199         simplif::vert_info& v0_info = vertex_info(v0); 
    200         simplif::vert_info& v1_info = vertex_info(v1); 
    201  
    202199        simplif::pair_info *pair = new simplif::pair_info(v0,v1); 
    203200 
    204         v0_info.pairs.add(pair); 
    205         v1_info.pairs.add(pair); 
     201        simplif::vert_info              *v0_info = vertex_info(v0); 
     202        v0_info->pairs.add(pair); 
     203 
     204        simplif::vert_info              *v1_info = vertex_info(v1); 
     205        v1_info->pairs.add(pair); 
    206206 
    207207        return pair; 
     
    213213void SimplificationMethod::delete_pair(simplif::pair_info *auxpair) 
    214214{ 
    215         simplif::vert_info& v0_info = vertex_info(auxpair->v0); 
    216         simplif::vert_info& v1_info = vertex_info(auxpair->v1); 
    217  
    218         v0_info.pairs.remove(v0_info.pairs.find(auxpair)); 
    219         v1_info.pairs.remove(v1_info.pairs.find(auxpair)); 
    220  
    221         if ( auxpair->isInHeap() ) 
     215        simplif::vert_info      *v0_info = vertex_info(auxpair->v0); 
     216        simplif::vert_info      *v1_info = vertex_info(auxpair->v1); 
     217 
     218        v0_info->pairs.remove(v0_info->pairs.find(auxpair)); 
     219        v1_info->pairs.remove(v1_info->pairs.find(auxpair)); 
     220 
     221        if (auxpair->isInHeap()) 
    222222        { 
    223223                heap->kill(auxpair->getHeapPos()); 
     
    272272        } 
    273273 
    274         simplif::vert_info&     v0_info = vertex_info(v0); 
    275         simplif::vert_info&     v1_info = vertex_info(v1); 
     274        simplif::vert_info      *v0_info = vertex_info(v0); 
     275        simplif::vert_info      *v1_info = vertex_info(v1); 
    276276 
    277277        //      Simplification step. 
     
    314314 
    315315        //      Make v0 be the new vertex 
    316         v0_info.Q                       += v1_info.Q; 
    317         v0_info.norm    += v1_info.norm; 
     316        v0_info->Q              += v1_info->Q; 
     317        v0_info->norm   += v1_info->norm; 
    318318 
    319319        simplif::Vec3 p(vnew); 
     
    405405 
    406406        //      Recalculate pairs associated with v0. 
    407         for (i  =       0;      i < v0_info.pairs.length();     i++) 
    408         { 
    409                 simplif::pair_info *p = v0_info.pairs(i); 
     407        for (i  =       0;      i < v0_info->pairs.length();    i++) 
     408        { 
     409                simplif::pair_info *p = v0_info->pairs(i); 
    410410                compute_pair_info(p); 
    411411        } 
     
    418418 
    419419        //      Recalculate pairs associated with v1. 
    420         for (i  =       0;      i < v1_info.pairs.length(); i++) 
    421         { 
    422                 simplif::pair_info *p = v1_info.pairs(i); 
     420        for (i  =       0;      i < v1_info->pairs.length(); i++) 
     421        { 
     422                simplif::pair_info *p = v1_info->pairs(i); 
    423423 
    424424                simplif::Vertex *u; 
     
    445445                        p->v1   =       u; 
    446446 
    447                         v0_info.pairs.add(p); 
     447                        v0_info->pairs.add(p); 
    448448                        compute_pair_info(p); 
    449449                } 
     
    461461 
    462462        //      Safety precaution. 
    463         v1_info.pairs.reset(); 
     463        v1_info->pairs.reset(); 
    464464} 
    465465 
     
    471471        if( vinfo.length() > 0 ) 
    472472        { 
    473                 Q = vinfo(v->uniqID).Q; 
     473                Q = vinfo(v->uniqID)->Q; 
    474474                return true; 
    475475        } 
     
    607607        float                                                           x,y,z; 
    608608 
    609         /* 
    610         if ((*v0) != (*v1)) 
    611         { 
    612         */ 
    613                 //      Gets the vertex that is not the candidate. 
    614                 if ((*v1) == candidate) 
    615                 { 
    616                         vert                                                            = v0; 
    617                         v0                                                                      =       v1; 
    618                         v1                                                                      =       vert; 
    619                 } 
    620  
    621                 take_bone_from_vert = v0; 
    622  
    623                 f0      =       _float3_((*v0)[X],(*v0)[Y],(*v0)[Z]); 
    624                 f1      =       _float3_((*v1)[X],(*v1)[Y],(*v1)[Z]); 
    625  
    626                 while ((it = vertexMultimap.find(f1)) != vertexMultimap.end()) 
    627                 { 
    628                         twin_found      =       false; 
    629  
    630                         lonely_vert     =       m.vertex((*it).second); 
    631  
     609        //      Gets the vertex that is not the candidate. 
     610        if ((*v1) == candidate) 
     611        { 
     612                vert                                                            = v0; 
     613                v0                                                                      =       v1; 
     614                v1                                                                      =       vert; 
     615        } 
     616 
     617        take_bone_from_vert = v0; 
     618 
     619        f0      =       _float3_((*v0)[X],(*v0)[Y],(*v0)[Z]); 
     620        f1      =       _float3_((*v1)[X],(*v1)[Y],(*v1)[Z]); 
     621 
     622        while ((it = vertexMultimap.find(f1)) != vertexMultimap.end()) 
     623        { 
     624                twin_found      =       false; 
     625 
     626                lonely_vert     =       m.vertex((*it).second); 
     627 
     628                //      Debug. 
     629                if ((*it).second == 10988) 
     630                { 
     631                        cout    <<      "Lonely: " 
     632                                <<      lonely_vert->vID 
     633                                <<      endl; 
     634                } 
     635 
     636                for (int        i       =       0;      i < lonely_vert->edgeUses().length();   i++) 
     637                { 
     638                        econ    =       lonely_vert->edgeUses()(i); 
     639 
     640                        if (((*econ->org()) == (*v0)) 
     641                                        || 
     642                                        ((*econ->dest()) == (*v0))) 
     643                        { 
     644                                lb      =       vertexMultimap.lower_bound(f0); 
     645                                ub      =       vertexMultimap.upper_bound(f0); 
     646 
     647                                //      For each vertex. 
     648                                while   (lb != ub) 
     649                                { 
     650                                        //      If removed vertex is found. 
     651                                        if (((*lb).second == econ->org()->vID) 
     652                                                        || 
     653                                                        ((*lb).second == econ->dest()->vID)) 
     654                                        { 
     655                                                twin_found      =       true; 
     656 
     657                                                //      Break while. 
     658                                                lb      =       ub; 
     659                                        } 
     660                                        else 
     661                                        { 
     662                                                //      Next iteration. 
     663                                                lb++; 
     664                                        } 
     665                                } 
     666 
     667                                break; 
     668                        } 
     669                } 
     670 
     671                //      If a twin edge has been found. 
     672                if (twin_found) 
     673                { 
    632674                        //      Debug. 
    633                         if ((*it).second == 10988) 
    634                         { 
    635                                 cout    <<      "Lonely: " 
    636                                                         <<      lonely_vert->vID 
    637                                                         <<      endl; 
    638                         } 
    639                          
    640                         for (int        i       =       0;      i < lonely_vert->edgeUses().length();   i++) 
    641                         { 
    642                                 econ    =       lonely_vert->edgeUses()(i); 
    643  
    644                                 if (((*econ->org()) == (*v0)) 
    645                                                 || 
    646                                                 ((*econ->dest()) == (*v0))) 
    647                                 { 
    648                                         lb      =       vertexMultimap.lower_bound(f0); 
    649                                         ub      =       vertexMultimap.upper_bound(f0); 
    650  
    651                                         //      For each vertex. 
    652                                         while   (lb != ub) 
    653                                         { 
    654                                                 //      If removed vertex is found. 
    655                                                 if (((*lb).second == econ->org()->vID) 
    656                                                                 || 
    657                                                                 ((*lb).second == econ->dest()->vID)) 
    658                                                 { 
    659                                                         twin_found      =       true; 
    660  
    661                                                         //      Break while. 
    662                                                         lb      =       ub; 
    663                                                 } 
    664                                                 else 
    665                                                 { 
    666                                                         //      Next iteration. 
    667                                                         lb++; 
    668                                                 } 
    669                                         } 
    670  
    671                                         break; 
    672                                 } 
    673                         } 
    674  
    675                         //      If a twin edge has been found. 
    676                         if (twin_found) 
    677                         { 
    678                                 //      Debug. 
    679                                 cout    <<      "Twin Contracted..."    <<      endl; 
    680  
    681                                 //      Extract twin edge from heap. 
    682                                 pair    =       new_pair(econ->org(),econ->dest()); 
    683  
    684                                 //      Copy candidate. 
    685                                 pair->candidate =       candidate; 
    686  
    687                                 pair->notInHeap(); 
    688  
    689                                 //      Contract twin pair. 
    690                                 do_contract(m, pair, 1); 
    691                                 M0.validVertCount--; 
    692                         } 
    693                         else 
    694                         { 
    695                                 //      Debug. 
    696                                 cout    <<      "Contracting new pair..."       <<      endl; 
    697  
    698                                 new_vert        =       m.newVertex(candidate[X],candidate[Y],candidate[Z]); 
    699  
    700                                 //      Add new vert to multimap. 
    701                                 x       =       (*new_vert)[X]; 
    702                                 y       =       (*new_vert)[Y]; 
    703                                 z       =       (*new_vert)[Z]; 
    704  
    705                                 simplif::Vertex *v; 
    706  
    707                                 //      Debug. 
    708                                 if (new_vert->vID == 10988) 
    709                                 { 
    710                                         cout    <<      "[" 
    711                                                                 <<      x 
    712                                                                 <<      "," 
    713                                                                 <<      y 
    714                                                                 <<      "," 
    715                                                                 <<      z 
    716                                                                 <<      "]" 
    717                                                                 <<      endl; 
    718  
    719                                          
    720                                         v       =       m.vertex(10988); 
    721                                 } 
    722  
    723                                 //      Adds new vertex to multimap. 
    724                                 vertexMultimap.insert(vertex_pair(_float3_(x,y,z),new_vert->vID)); 
    725  
    726                                 //      Creates new edge. 
    727                                 edge    =       m.newEdge(new_vert,lonely_vert); 
    728  
    729                                 //      We assume here there are the same number of vertices 
    730                                 //      and texture coordinates and normals. 
    731  
    732                                 // Assign a texture coordinate for the vertex. 
    733                                 simplif::Vec2 newtexcoord = m.texcoord(lonely_vert->vID); 
    734                                 m.in_TexCoord(newtexcoord); 
    735  
    736                                 //      Assign a normal coordinate for the vbertex. 
    737                                 simplif::Vec3 newnormal = m.normal(lonely_vert->vID); 
    738                                 m.in_Normal(newnormal); 
    739  
    740                                 //      Adds new vertex information to simplification sequence. 
    741                                 vertex_added.id                         =       new_vert->vID; 
    742  
    743                                 vertex_added.bonefrom   =       take_bone_from_vert->vID; 
    744  
    745                                 vertex_added.position   =       Vector3(candidate[X], 
    746                                                                                                                                                                 candidate[Y], 
    747                                                                                                                                                                 candidate[Z]); 
    748  
    749                                 simplif::Vec2 tc                        = m.texcoord(new_vert->vID); 
    750                                 vertex_added.texcoord   =       Vector2(tc[X],tc[Y]); 
    751  
    752                                 simplif::Vec3 vn                = m.normal(new_vert->vID); 
    753                                 vertex_added.normal     =       Vector3(vn[X],vn[Y],vn[Z]); 
    754  
    755                                 msimpseq->mNewVertices.push_back(vertex_added); 
    756  
    757                                 pair                                            =       new_pair(new_vert,lonely_vert); 
    758                                 pair->candidate =       candidate; 
    759                                 pair->notInHeap(); 
    760  
    761                                 //      Debug. 
    762                                 cout    <<      "new: " 
    763                                                         <<      new_vert->vID 
    764                                                         <<      "(" 
    765                                                         <<      (*new_vert)[X] 
    766                                                         <<      "," 
    767                                                         <<      (*new_vert)[Y] 
    768                                                         <<      "," 
    769                                                         <<      (*new_vert)[Z] 
    770                                                         <<      ") lonely: " 
    771                                                         <<      lonely_vert->vID 
    772                                                         <<      "(" 
    773                                                         <<      (*lonely_vert)[X] 
    774                                                         <<      "," 
    775                                                         <<      (*lonely_vert)[Y] 
    776                                                         <<      "," 
    777                                                         <<      (*lonely_vert)[Z] 
    778                                                         <<      ")" 
    779                                                         <<      endl; 
    780  
    781                                 //      Contract new pair. 
    782                                 do_contract(m, pair, 1); 
    783                                 M0.validVertCount--; 
    784                         } 
    785                 } 
    786         /* 
    787         } 
    788         */ 
     675                        cout    <<      "Twin Contracted..."    <<      endl; 
     676 
     677                        //      Extract twin edge from heap. 
     678                        pair    =       new_pair(econ->org(),econ->dest()); 
     679 
     680                        //      Copy candidate. 
     681                        pair->candidate =       candidate; 
     682 
     683                        pair->notInHeap(); 
     684 
     685                        //      Contract twin pair. 
     686                        do_contract(m, pair, 1); 
     687                        M0.validVertCount--; 
     688                } 
     689                else 
     690                { 
     691                        //      Debug. 
     692                        cout    <<      "Contracting new pair..."       <<      endl; 
     693 
     694                        new_vert        =       m.newVertex(candidate[X],candidate[Y],candidate[Z]); 
     695 
     696                        //      Add new vert to multimap. 
     697                        x       =       (*new_vert)[X]; 
     698                        y       =       (*new_vert)[Y]; 
     699                        z       =       (*new_vert)[Z]; 
     700 
     701                        //      Adds new vertex to multimap. 
     702                        vertexMultimap.insert(vertex_pair(_float3_(x,y,z),new_vert->vID)); 
     703 
     704                        //      Creates new edge. 
     705                        edge    =       m.newEdge(new_vert,lonely_vert); 
     706 
     707                        //      We assume here there are the same number of vertices 
     708                        //      and texture coordinates and normals. 
     709 
     710                        // Assign a texture coordinate for the vertex. 
     711                        simplif::Vec2 newtexcoord = m.texcoord(lonely_vert->vID); 
     712                        m.in_TexCoord(newtexcoord); 
     713 
     714                        //      Assign a normal coordinate for the vbertex. 
     715                        simplif::Vec3 newnormal = m.normal(lonely_vert->vID); 
     716                        m.in_Normal(newnormal); 
     717 
     718                        //      Adds new vertex information to simplification sequence. 
     719                        vertex_added.id                         =       new_vert->vID; 
     720 
     721                        vertex_added.bonefrom   =       take_bone_from_vert->vID; 
     722 
     723                        vertex_added.position   =       Vector3(candidate[X], 
     724                                                                                                                                                        candidate[Y], 
     725                                                                                                                                                        candidate[Z]); 
     726 
     727                        simplif::Vec2 tc                        = m.texcoord(new_vert->vID); 
     728                        vertex_added.texcoord   =       Vector2(tc[X],tc[Y]); 
     729 
     730                        simplif::Vec3 vn                = m.normal(new_vert->vID); 
     731                        vertex_added.normal     =       Vector3(vn[X],vn[Y],vn[Z]); 
     732 
     733                        msimpseq->mNewVertices.push_back(vertex_added); 
     734 
     735                        //      Debug. 
     736                        vert_info               *new_vert_info; 
     737                        new_vert_info   =       new vert_info(); 
     738 
     739                        vinfo.add(new_vert_info); 
     740                        //------------------------------ 
     741 
     742                        pair                                            =       new_pair(new_vert,lonely_vert); 
     743                        pair->candidate =       candidate; 
     744                        pair->notInHeap(); 
     745 
     746                        //      Debug. 
     747                        cout    <<      "new: " 
     748                                <<      new_vert->vID 
     749                                <<      "(" 
     750                                <<      (*new_vert)[X] 
     751                                <<      "," 
     752                                <<      (*new_vert)[Y] 
     753                                <<      "," 
     754                                <<      (*new_vert)[Z] 
     755                                <<      ") lonely: " 
     756                                <<      lonely_vert->vID 
     757                                <<      "(" 
     758                                <<      (*lonely_vert)[X] 
     759                                <<      "," 
     760                                <<      (*lonely_vert)[Y] 
     761                                <<      "," 
     762                                <<      (*lonely_vert)[Z] 
     763                                <<      ")" 
     764                                <<      endl; 
     765 
     766                        //      Contract new pair. 
     767                        do_contract(m, pair, 1); 
     768                        M0.validVertCount--; 
     769                } 
     770        } 
    789771} 
    790772 
     
    793775simplif::real SimplificationMethod::decimate_error(simplif::Vertex *v) 
    794776{ 
    795         simplif::vert_info& info = vertex_info(v); 
    796  
    797         simplif::real err = simplif::quadrix_evaluate_vertex(*v, info.Q); 
    798  
    799     if ( simplif::will_weight_by_area ) 
    800                 { 
    801                         err /= info.norm; 
    802                 } 
    803  
    804     return err; 
     777        simplif::vert_info      *info = vertex_info(v); 
     778 
     779        simplif::real err = simplif::quadrix_evaluate_vertex(*v, info->Q); 
     780 
     781        if ( simplif::will_weight_by_area ) 
     782        { 
     783                err /= info->norm; 
     784        } 
     785 
     786        return err; 
    805787} 
    806788 
     
    817799                top = heap->top(); 
    818800                 
    819                 if( !top ) 
     801                if(!top) 
    820802                { 
    821803                        return -1.0; 
     
    824806                pair = (simplif::pair_info *)top->obj; 
    825807 
    826                 if( pair->isValid() ) 
     808                if(pair->isValid()) 
    827809                { 
    828810                        break; 
     
    844826 
    845827        for(int i=0; i<m.vertCount(); i++) 
    846                 if( m.vertex(i)->isValid() ) 
     828                if(m.vertex(i)->isValid()) 
    847829                { 
    848830                        max_err = MAX(max_err, decimate_error(m.vertex(i))); 
     
    861843 
    862844        //      Reserve memory for vert_info array. 
    863         vinfo.init(m.vertCount()*2); 
     845 
     846        for (i  =       0; i < m.vertCount(); i++) 
     847        { 
     848                vert_info                       *new_vert_info; 
     849                new_vert_info   =       new vert_info(); 
     850 
     851                vinfo.add(new_vert_info); 
     852        } 
    864853 
    865854        if (simplif::will_use_vertex_constraint) 
     
    872861                        if (v->isValid()) 
    873862                        { 
    874                                 vertex_info(v).Q = simplif::quadrix_vertex_constraint(*v); 
     863                                vertex_info(v)->Q = simplif::quadrix_vertex_constraint(*v); 
    875864                        } 
    876865                } 
     
    895884                                for (j  =       0;      j < 3;  j++) 
    896885                                { 
    897                                         vertex_info(m.face(i)->vertex(j)).Q                     +=      Q; 
    898                                         vertex_info(m.face(i)->vertex(j)).norm  +=      norm; 
     886                                        vertex_info(m.face(i)->vertex(j))->Q            +=      Q; 
     887                                        vertex_info(m.face(i)->vertex(j))->norm +=      norm; 
    899888                                } 
    900889                        } 
     
    919908 
    920909                                B *= simplif::boundary_constraint_weight; 
    921                                 vertex_info(m.edge(i)->org()).Q += B; 
    922                                 vertex_info(m.edge(i)->org()).norm += norm; 
    923                                 vertex_info(m.edge(i)->dest()).Q += B; 
    924                                 vertex_info(m.edge(i)->dest()).norm += norm; 
     910 
     911                                vertex_info(m.edge(i)->org())->Q                        += B; 
     912                                vertex_info(m.edge(i)->org())->norm             += norm; 
     913                                vertex_info(m.edge(i)->dest())->Q                       += B; 
     914                                vertex_info(m.edge(i)->dest())->norm    += norm; 
    925915                        } 
    926916                } 
     
    937927                if (m.edge(i)->isValid()) 
    938928                { 
    939                         simplif::pair_info *pair = new_pair(m.edge(i)->org(), m.edge(i)->dest()); 
     929                        simplif::pair_info *pair = new_pair(m.edge(i)->org(), 
     930                                                                                                                                                                        m.edge(i)->dest()); 
     931 
    940932                        //pointers_to_remove.push_back(pair); 
    941933 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h

    r2194 r2291  
    7878                simplif::Model M0; 
    7979 
    80                 simplif::buffer<simplif::vert_info> vinfo; 
     80                simplif::buffer<simplif::vert_info *> vinfo; 
    8181 
    8282                simplif::Heap *heap; 
    83                 simplif::real proximity_limit;    // distance threshold squared 
     83                simplif::real proximity_limit;  // Distance threshold squared. 
    8484 
    8585                int initialVertCount; 
     
    9090                MeshSimplificationSequence      *msimpseq; 
    9191 
    92                 inline simplif::vert_info& vertex_info(simplif::Vertex *v) 
     92                inline simplif::vert_info       * vertex_info(simplif::Vertex *v) 
    9393                { 
    9494                        return vinfo(v->validID()); 
    9595                } 
    9696 
    97                 simplif::real pair_mesh_penalty(simplif::Model& M, 
    98                                 simplif::Vertex *v1, 
    99                                 simplif::Vertex *v2, 
    100                                 simplif::Vec3& vnew); 
    101  
    102                 int predict_face(simplif::Face& F, 
    103                                 simplif::Vertex *v1, 
    104                                 simplif::Vertex *v2, 
    105                                 simplif::Vec3& vnew, 
    106                                 simplif::Vec3& f1, 
    107                                 simplif::Vec3& f2, 
    108                                 simplif::Vec3& f3); 
     97                simplif::real pair_mesh_penalty(simplif::Model  &M, 
     98                                                                                                                                                simplif::Vertex *v1, 
     99                                                                                                                                                simplif::Vertex *v2, 
     100                                                                                                                                                simplif::Vec3& vnew); 
     101 
     102                int predict_face(       simplif::Face           &F, 
     103                                                                                        simplif::Vertex *v1, 
     104                                                                                        simplif::Vertex *v2, 
     105                                                                                        simplif::Vec3& vnew, 
     106                                                                                        simplif::Vec3& f1, 
     107                                                                                        simplif::Vec3& f2, 
     108                                                                                        simplif::Vec3& f3); 
    109109 
    110110                bool check_for_pair(simplif::Vertex *v0, simplif::Vertex *v1); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Array.h

    r1526 r2291  
    3737                inline void array<T>::init(int l) 
    3838                { 
    39                         data = new T[l]; 
    40                         len = l; 
     39                        data    =       new T[l]; 
     40                        len             =       l; 
    4141                } 
    4242 
     
    4444                inline void array<T>::f_r_e_e() 
    4545                { 
    46                         if( data ) 
     46                        if(data) 
    4747                        { 
    48                                 delete[] data; 
     48                                delete  [] data; 
    4949                                data = NULL; 
    5050                        } 
     
    5555                { 
    5656#ifdef SAFETY 
    57                         assert( data ); 
    58                         assert( i>=0 && i<len ); 
     57                        assert(data); 
     58                        assert(i >= 0 && i < len); 
    5959#endif 
    6060                        return data[i]; 
     
    6565                { 
    6666#ifdef SAFETY 
    67                         assert( data ); 
    68                         assert( i>=0 && i<len ); 
     67                        assert(data); 
     68                        assert(i >= 0 && i < len); 
    6969#endif 
    7070                        return data[i]; 
     
    7474                inline void array<T>::resize(int l) 
    7575                { 
    76                         T *old = data; 
    77                         data = new T[l]; 
    78                         data = (T *)memcpy(data,old,MIN(len,l)*sizeof(T)); 
    79                         len = l; 
    80                         delete[] old; 
     76                        T *old  =       data; 
     77                        data            =       new T[l]; 
     78                        data            =       (T *)memcpy(data,old,MIN(len,l)*sizeof(T)); 
     79                        len                     =       l; 
     80 
     81                        delete  [] old; 
    8182                } 
    8283} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Buffer.h

    r2090 r2291  
    77{ 
    88        template<class T> 
    9         class buffer : public array<T> { 
    10         protected: 
    11                 int fill; 
    12         public: 
    13                 buffer() { init(8); } 
    14                 buffer(int l) { init(l); } 
    15      
    16                 inline void init(int l) { array<T>::init(l); fill=0; } 
     9                class buffer : public array<T> { 
     10                        protected: 
     11                                int fill; 
     12                        public: 
     13                                buffer() { init(8); } 
     14                                buffer(int l) { init(l); } 
    1715 
    18                 inline int add(const T& t); 
    19                 inline void reset(); 
    20                 inline int find(const T&); 
    21                 inline T remove(int i); 
    22                 inline int addAll(const buffer<T>& buf); 
    23                 inline void removeDuplicates(); 
     16                                inline void init(int l) { array<T>::init(l); fill=0; } 
    2417 
    25                 inline int length() const { return fill; } 
    26                 inline int maxLength() const { return len; } 
    27                 inline void setFill(int l){fill =       l;} 
    28         }; 
     18                                inline int add(const T& t); 
     19                                inline void reset(); 
     20                                inline int find(const T&); 
     21                                inline T remove(int i); 
     22                                inline int addAll(const buffer<T>& buf); 
     23                                inline void removeDuplicates(); 
     24 
     25                                inline int length() const { return fill; } 
     26                                inline int maxLength() const { return len; } 
     27                                inline void setFill(int l){fill =       l;} 
     28                }; 
    2929 
    3030        template<class T> 
    31         inline int buffer<T>::add(const T& t) 
    32         { 
    33                 if( fill == len ) 
     31                inline int buffer<T>::add(const T& t) 
    3432                { 
    35                         resize( len*2 ); 
     33                        if(fill == len) 
     34                        { 
     35                                resize(len * 2); 
     36                        } 
     37 
     38                        data[fill] = t; 
     39 
     40                        return fill++; 
    3641                } 
    3742 
    38                 data[fill] = t; 
    39  
    40                 return fill++; 
    41         } 
     43        template<class T> 
     44                inline void buffer<T>::reset() 
     45                { 
     46                        fill = 0; 
     47                } 
    4248 
    4349        template<class T> 
    44         inline void buffer<T>::reset() 
    45         { 
    46                 fill = 0; 
    47         } 
     50                inline int buffer<T>::find(const T& t) 
     51                { 
     52                        for(int i=0;i<fill;i++) 
     53                                if( data[i] == t ) 
     54                                        return i; 
     55 
     56                        return -1; 
     57                } 
    4858 
    4959        template<class T> 
    50         inline int buffer<T>::find(const T& t) 
    51         { 
    52                 for(int i=0;i<fill;i++) 
    53                 if( data[i] == t ) 
    54                         return i; 
     60                inline T buffer<T>::remove(int i) 
     61                { 
     62#ifdef SAFETY 
     63                        assert( i>=0 ); 
     64                        assert( i<fill ); 
     65#endif 
    5566 
    56                 return -1; 
    57         } 
     67                        fill--; 
     68                        T temp = data[i]; 
     69                        data[i] = data[fill]; 
     70 
     71                        return temp; 
     72                } 
    5873 
    5974        template<class T> 
    60         inline T buffer<T>::remove(int i) 
    61         { 
    62         #ifdef SAFETY 
    63                 assert( i>=0 ); 
    64                 assert( i<fill ); 
    65         #endif 
     75                inline int buffer<T>::addAll(const buffer<T>& buf) 
     76                { 
     77                        for (int i=0; i<buf.fill; i++) 
     78                                add(buf(i)); 
    6679 
    67                 fill--; 
    68                 T temp = data[i]; 
    69                 data[i] = data[fill]; 
    70  
    71                 return temp; 
    72         } 
     80                        return fill; 
     81                } 
    7382 
    7483        template<class T> 
    75         inline int buffer<T>::addAll(const buffer<T>& buf) 
    76         { 
    77                 for(int i=0; i<buf.fill; i++) 
    78                 add(buf(i)); 
    79  
    80                 return fill; 
    81         } 
    82  
    83         template<class T> 
    84         inline void buffer<T>::removeDuplicates() 
    85         { 
    86                 for(int i=0; i<fill; i++) 
     84                inline void buffer<T>::removeDuplicates() 
    8785                { 
    88                 for(int j=i+1; j<fill; ) 
    89                 { 
    90                         if( data[j] == data[i] ) 
    91                         remove(j); 
    92                         else 
    93                         j++; 
     86                        for (int i=0; i<fill; i++) 
     87                        { 
     88                                for (int j=i+1; j<fill; ) 
     89                                { 
     90                                        if ( data[j] == data[i] ) 
     91                                                remove(j); 
     92                                        else 
     93                                                j++; 
     94                                } 
     95                        } 
    9496                } 
    95                 } 
    96         } 
    9797} 
    9898 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Heap.h

    r1600 r2291  
    3333        { 
    3434                public: 
     35 
    3536                        float import; 
    3637                        Heapable *obj; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/simplif.h

    r1526 r2291  
    1313        { 
    1414                public: 
     15 
    1516                        Vertex *v0, *v1; 
    1617 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r2194 r2291  
    3636        static char pattern[] = "*.{jpg|tga|png|bmp}"; 
    3737 
    38         fltk::FileChooser       *fcho = new fltk::FileChooser("",pattern,fltk::FileChooser::CREATE,"Open image file"); 
     38        fltk::FileChooser       *fcho = new fltk::FileChooser("", 
     39                                                                                                                                                                                                        pattern, 
     40                                                                                                                                                                                                        fltk::FileChooser::CREATE, 
     41                                                                                                                                                                                                        "Open image file"); 
     42 
    3943        fcho->exec(); 
    4044        char filename[256]="";   
     
    183187 
    184188                        //      Cut extension. 
    185                         ptr                             =       strtok(file_name,"."); 
     189                        ptr     =       strtok(file_name,"."); 
    186190 
    187191                        //      If has extension. 
     
    221225                        } 
    222226                } 
     227 
    223228                //      Repaint the window. 
    224229                mMainWindow->redraw(); 
     
    21372142        geoMeshView->saveContext(); 
    21382143 
    2139         //    Debug. 
     2144        //      Debug. 
    21402145        cout    <<    "Mesh Reduction: " 
    21412146                <<    mMeshReduction->fvalue() 
    21422147                <<    endl; 
    21432148 
    2144         //    Gets simplify option. 
     2149        //      Gets simplify option. 
    21452150        if (mGeometryBased->value()) 
    21462151        { 
     
    21602165        if (mPercent->value()) 
    21612166        { 
    2162                 // Simplificaci?n por porcentaje 
     2167                // Simplification percent value. 
    21632168                if (mMeshReduction->fvalue() <= 100.0 && 
    21642169                                mMeshReduction->fvalue() > 0.0) 
     
    21662171                        percent =       mMeshReduction->fvalue(); 
    21672172                        percent =       percent / 100.0; 
    2168  
    2169                         //      Simplifica el geomesh -> Par?metro es un factor LOD [0,1]. 
    21702173 
    21712174                        mMeshSimplifier->Simplify(percent); 
     
    21932196        else 
    21942197        { 
    2195                 //      Simplificar hasta un n?mero de v?rtices. 
     2198                //      Simplification until number of vertices. 
    21962199                uint32 v        =       (uint32)mMeshReduction->fvalue(); 
    21972200 
    2198                 //      Simplifica el geomesh -> Par?metro es un factor LOD [0,1]. 
    21992201                mMeshSimplifier->Simplify(v); 
    22002202 
     
    22502252 
    22512253                // Simplify 
    2252                 if(idMeshLeaves !=      (unsigned short)-1) 
     2254                if (idMeshLeaves        !=      (unsigned short)-1) 
    22532255                { 
    22542256                        // Simplify 
Note: See TracChangeset for help on using the changeset viewer.