Changeset 2291 for GTP/trunk/Lib/Geom/shared/GTGeometry
- Timestamp:
- 03/26/07 08:46:55 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h
r2194 r2291 142 142 Mesh *mInitialMesh; 143 143 MeshSimplificationSequence *msimpsequence; 144 const Mesh *objmesh;145 144 146 145 Geometry::Index indexMeshLeaves; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
r2194 r2291 24 24 *mInitialMesh = *m; 25 25 26 objmesh = m;27 26 mGeoMesh = NULL; 28 27 msimpsequence = NULL; … … 120 119 } 121 120 122 123 121 ////////////////////////////////////////////////////////////////////////// 124 122 // // … … 150 148 void GeometryBasedSimplifier::Simplify(Real paramlod) 151 149 { 152 SimplificationMethod *m_qslim = new SimplificationMethod( objmesh);150 SimplificationMethod *m_qslim = new SimplificationMethod(mInitialMesh); 153 151 154 152 m_qslim->setMeshLeaves(indexMeshLeaves); … … 169 167 void GeometryBasedSimplifier::Simplify(uint32 numvertices) 170 168 { 171 SimplificationMethod *m_qslim = new SimplificationMethod( objmesh);169 SimplificationMethod *m_qslim = new SimplificationMethod(mInitialMesh); 172 170 173 171 m_qslim->setMeshLeaves(indexMeshLeaves); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/AdjModel.h
r1526 r2291 70 70 // Basic model accessor functions 71 71 // 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);} 77 77 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();} 83 83 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;} 87 87 88 88 // … … 124 124 int in_TexCoord(const Vec2&); 125 125 126 int in_Face(int v1, int v2, int v3, 126 int in_Face(int v1, int v2, int v3, 127 127 int n1, int n2, int n3, 128 128 int t1, int t2, int t3); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp
r2194 r2291 44 44 simplif::Vertex *v1 = auxpair->v1; 45 45 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; 51 51 52 52 auxpair->cost = simplif::quadrix_pair_target( Q, … … 178 178 simplif::Vertex *v1) 179 179 { 180 const simplif::pair_buffer& pairs = vertex_info(v0) .pairs;180 const simplif::pair_buffer& pairs = vertex_info(v0)->pairs; 181 181 182 182 for(int i=0; i<pairs.length(); i++) … … 197 197 simplif::Vertex *v1) 198 198 { 199 simplif::vert_info& v0_info = vertex_info(v0);200 simplif::vert_info& v1_info = vertex_info(v1);201 202 199 simplif::pair_info *pair = new simplif::pair_info(v0,v1); 203 200 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); 206 206 207 207 return pair; … … 213 213 void SimplificationMethod::delete_pair(simplif::pair_info *auxpair) 214 214 { 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()) 222 222 { 223 223 heap->kill(auxpair->getHeapPos()); … … 272 272 } 273 273 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); 276 276 277 277 // Simplification step. … … 314 314 315 315 // 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; 318 318 319 319 simplif::Vec3 p(vnew); … … 405 405 406 406 // 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); 410 410 compute_pair_info(p); 411 411 } … … 418 418 419 419 // 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); 423 423 424 424 simplif::Vertex *u; … … 445 445 p->v1 = u; 446 446 447 v0_info .pairs.add(p);447 v0_info->pairs.add(p); 448 448 compute_pair_info(p); 449 449 } … … 461 461 462 462 // Safety precaution. 463 v1_info .pairs.reset();463 v1_info->pairs.reset(); 464 464 } 465 465 … … 471 471 if( vinfo.length() > 0 ) 472 472 { 473 Q = vinfo(v->uniqID) .Q;473 Q = vinfo(v->uniqID)->Q; 474 474 return true; 475 475 } … … 607 607 float x,y,z; 608 608 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 { 632 674 // 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 } 789 771 } 790 772 … … 793 775 simplif::real SimplificationMethod::decimate_error(simplif::Vertex *v) 794 776 { 795 simplif::vert_info &info = vertex_info(v);796 797 simplif::real err = simplif::quadrix_evaluate_vertex(*v, info .Q);798 799 800 801 err /= info.norm;802 803 804 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; 805 787 } 806 788 … … 817 799 top = heap->top(); 818 800 819 if( !top)801 if(!top) 820 802 { 821 803 return -1.0; … … 824 806 pair = (simplif::pair_info *)top->obj; 825 807 826 if( pair->isValid())808 if(pair->isValid()) 827 809 { 828 810 break; … … 844 826 845 827 for(int i=0; i<m.vertCount(); i++) 846 if( m.vertex(i)->isValid())828 if(m.vertex(i)->isValid()) 847 829 { 848 830 max_err = MAX(max_err, decimate_error(m.vertex(i))); … … 861 843 862 844 // 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 } 864 853 865 854 if (simplif::will_use_vertex_constraint) … … 872 861 if (v->isValid()) 873 862 { 874 vertex_info(v) .Q = simplif::quadrix_vertex_constraint(*v);863 vertex_info(v)->Q = simplif::quadrix_vertex_constraint(*v); 875 864 } 876 865 } … … 895 884 for (j = 0; j < 3; j++) 896 885 { 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; 899 888 } 900 889 } … … 919 908 920 909 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; 925 915 } 926 916 } … … 937 927 if (m.edge(i)->isValid()) 938 928 { 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 940 932 //pointers_to_remove.push_back(pair); 941 933 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.h
r2194 r2291 78 78 simplif::Model M0; 79 79 80 simplif::buffer<simplif::vert_info > vinfo;80 simplif::buffer<simplif::vert_info *> vinfo; 81 81 82 82 simplif::Heap *heap; 83 simplif::real proximity_limit; // distance threshold squared83 simplif::real proximity_limit; // Distance threshold squared. 84 84 85 85 int initialVertCount; … … 90 90 MeshSimplificationSequence *msimpseq; 91 91 92 inline simplif::vert_info &vertex_info(simplif::Vertex *v)92 inline simplif::vert_info * vertex_info(simplif::Vertex *v) 93 93 { 94 94 return vinfo(v->validID()); 95 95 } 96 96 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); 109 109 110 110 bool check_for_pair(simplif::Vertex *v0, simplif::Vertex *v1); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Array.h
r1526 r2291 37 37 inline void array<T>::init(int l) 38 38 { 39 data =new T[l];40 len =l;39 data = new T[l]; 40 len = l; 41 41 } 42 42 … … 44 44 inline void array<T>::f_r_e_e() 45 45 { 46 if( data)46 if(data) 47 47 { 48 delete [] data;48 delete [] data; 49 49 data = NULL; 50 50 } … … 55 55 { 56 56 #ifdef SAFETY 57 assert( data);58 assert( i>=0 && i<len);57 assert(data); 58 assert(i >= 0 && i < len); 59 59 #endif 60 60 return data[i]; … … 65 65 { 66 66 #ifdef SAFETY 67 assert( data);68 assert( i>=0 && i<len);67 assert(data); 68 assert(i >= 0 && i < len); 69 69 #endif 70 70 return data[i]; … … 74 74 inline void array<T>::resize(int l) 75 75 { 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; 81 82 } 82 83 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Buffer.h
r2090 r2291 7 7 { 8 8 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); } 17 15 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; } 24 17 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 }; 29 29 30 30 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) 34 32 { 35 resize( len*2 ); 33 if(fill == len) 34 { 35 resize(len * 2); 36 } 37 38 data[fill] = t; 39 40 return fill++; 36 41 } 37 42 38 data[fill] = t; 39 40 return fill++; 41 } 43 template<class T> 44 inline void buffer<T>::reset() 45 { 46 fill = 0; 47 } 42 48 43 49 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 } 48 58 49 59 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 55 66 56 return -1; 57 } 67 fill--; 68 T temp = data[i]; 69 data[i] = data[fill]; 70 71 return temp; 72 } 58 73 59 74 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)); 66 79 67 fill--; 68 T temp = data[i]; 69 data[i] = data[fill]; 70 71 return temp; 72 } 80 return fill; 81 } 73 82 74 83 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() 87 85 { 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 } 94 96 } 95 }96 }97 97 } 98 98 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/gfx/tools/Heap.h
r1600 r2291 33 33 { 34 34 public: 35 35 36 float import; 36 37 Heapable *obj; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/simplif.h
r1526 r2291 13 13 { 14 14 public: 15 15 16 Vertex *v0, *v1; 16 17
Note: See TracChangeset
for help on using the changeset viewer.