23 #ifndef __VCGLIB_TRIALLOCATOR
24 #define __VCGLIB_TRIALLOCATOR
29 #include <vcg/container/simple_temporary_data.h>
31 #include "used_types.h"
39 template<
class MeshType>
40 size_t Index(
const MeshType &m,
const typename MeshType::VertexType &v) {
return &v-&*m.vert.begin();}
41 template<
class MeshType>
42 size_t Index(
const MeshType &m,
const typename MeshType::FaceType &f) {
return &f-&*m.face.begin();}
43 template<
class MeshType>
44 size_t Index(
const MeshType &m,
const typename MeshType::EdgeType &e) {
return &e-&*m.edge.begin();}
45 template<
class MeshType>
46 size_t Index(
const MeshType &m,
const typename MeshType::HEdgeType &h) {
return &h-&*m.hedge.begin();}
47 template <
class MeshType>
48 size_t Index(
const MeshType &m,
const typename MeshType::TetraType &t) {
return &t - &*m.tetra.begin(); }
51 template<
class MeshType>
52 size_t Index(
const MeshType &m,
const typename MeshType::VertexType *vp) {
return vp-&*m.vert.begin();}
53 template<
class MeshType>
54 size_t Index(
const MeshType &m,
const typename MeshType::FaceType * fp) {
return fp-&*m.face.begin();}
55 template<
class MeshType>
56 size_t Index(
const MeshType &m,
const typename MeshType::EdgeType* e) {
return e-&*m.edge.begin();}
57 template<
class MeshType>
58 size_t Index(
const MeshType &m,
const typename MeshType::HEdgeType* h) {
return h-&*m.hedge.begin();}
59 template <
class MeshType>
60 size_t Index(
const MeshType &m,
const typename MeshType::TetraType *t) {
return t - &*m.tetra.begin(); }
63 template<
class MeshType>
64 bool IsValidPointer( MeshType & m,
const typename MeshType::VertexType *vp) {
return ( m.vert.size() > 0 && (vp >= &*m.vert.begin()) && (vp <= &m.vert.back()) ); }
65 template<
class MeshType>
66 bool IsValidPointer(MeshType & m,
const typename MeshType::EdgeType *ep) {
return ( m.edge.size() > 0 && (ep >= &*m.edge.begin()) && (ep <= &m.edge.back())); }
67 template<
class MeshType>
68 bool IsValidPointer(MeshType & m,
const typename MeshType::FaceType *fp) {
return ( m.face.size() > 0 && (fp >= &*m.face.begin()) && (fp <= &m.face.back())); }
69 template<
class MeshType>
70 bool IsValidPointer(MeshType & m,
const typename MeshType::HEdgeType *hp) {
return ( m.hedge.size() > 0 && (hp >= &*m.hedge.begin()) && (hp <= &m.hedge.back())); }
71 template <
class MeshType>
72 bool IsValidPointer(MeshType &m,
const typename MeshType::TetraType *tp) {
return (m.tetra.size() > 0 && (tp >= &*m.tetra.begin()) && (tp <= &m.tetra.back())); }
74 template <
class MeshType,
class ATTR_CONT>
75 void ReorderAttribute(ATTR_CONT &c, std::vector<size_t> & newVertIndex, MeshType & ){
76 typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
77 for(ai = c.begin(); ai != c.end(); ++ai)
78 ((
typename MeshType::PointerToAttribute)(*ai)).Reorder(newVertIndex);
81 template <
class MeshType,
class ATTR_CONT>
82 void ResizeAttribute(ATTR_CONT &c,
size_t sz, MeshType &){
83 typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
84 for(ai =c.begin(); ai != c.end(); ++ai)
85 ((
typename MeshType::PointerToAttribute)(*ai)).Resize(sz);
95 template <
class MeshType>
100 typedef typename MeshType::VertexType VertexType;
101 typedef typename MeshType::VertexPointer VertexPointer;
102 typedef typename MeshType::VertexIterator VertexIterator;
103 typedef typename MeshType::VertContainer VertContainer;
105 typedef typename MeshType::EdgeType EdgeType;
106 typedef typename MeshType::EdgePointer EdgePointer;
107 typedef typename MeshType::EdgeIterator EdgeIterator;
108 typedef typename MeshType::EdgeContainer EdgeContainer;
110 typedef typename MeshType::FaceType FaceType;
111 typedef typename MeshType::FacePointer FacePointer;
112 typedef typename MeshType::FaceIterator FaceIterator;
113 typedef typename MeshType::FaceContainer FaceContainer;
115 typedef typename MeshType::HEdgeType HEdgeType;
116 typedef typename MeshType::HEdgePointer HEdgePointer;
117 typedef typename MeshType::HEdgeIterator HEdgeIterator;
118 typedef typename MeshType::HEdgeContainer HEdgeContainer;
120 typedef typename MeshType::TetraType TetraType;
121 typedef typename MeshType::TetraPointer TetraPointer;
122 typedef typename MeshType::TetraIterator TetraIterator;
123 typedef typename MeshType::TetraContainer TetraContainer;
125 typedef typename MeshType::CoordType CoordType;
127 typedef typename MeshType::PointerToAttribute PointerToAttribute;
128 typedef typename std::set<PointerToAttribute>::iterator AttrIterator;
129 typedef typename std::set<PointerToAttribute>::const_iterator AttrConstIterator;
130 typedef typename std::set<PointerToAttribute >::iterator PAIte;
143 template<
class SimplexPo
interType>
147 PointerUpdater(
void) : newBase(0), oldBase(0), newEnd(0), oldEnd(0), preventUpdateFlag(
false) { ; }
148 void Clear(){newBase=oldBase=newEnd=oldEnd=0; remap.clear();}
156 if(vp<oldBase || vp>oldEnd)
return;
159 vp=newBase+(vp-oldBase);
161 vp = newBase + remap[vp-newBase];
166 bool NeedUpdate() {
if((oldBase && newBase!=oldBase && !preventUpdateFlag) || !remap.empty())
return true;
else return false;}
168 SimplexPointerType newBase;
169 SimplexPointerType oldBase;
170 SimplexPointerType newEnd;
171 SimplexPointerType oldEnd;
172 std::vector<size_t> remap;
174 bool preventUpdateFlag;
199 pu.oldBase=&*m.vert.begin();
200 pu.oldEnd=&m.vert.back()+1;
203 m.vert.resize(m.vert.size()+n);
206 typename std::set<PointerToAttribute>::iterator ai;
207 for(ai = m.vert_attr.begin(); ai != m.vert_attr.end(); ++ai)
208 ((PointerToAttribute)(*ai)).Resize(m.vert.size());
210 pu.newBase = &*m.vert.begin();
211 pu.newEnd = &m.vert.back()+1;
214 for (FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi)
216 for(
int i=0; i < (*fi).VN(); ++i)
217 if ((*fi).cV(i)!=0) pu.
Update((*fi).V(i));
219 for (EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei)
229 for (hi=m.hedge.begin(); hi!=m.hedge.end(); ++hi)
232 if(HasHVAdjacency (m))
238 for (TetraIterator ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
240 for (
int i = 0; i < 4; ++i)
241 if ((*ti).cV(i) != 0)
246 size_t siz=(size_t)(m.vert.size()-n);
248 last = m.vert.begin();
264 static VertexIterator
AddVertices(MeshType &m,
size_t n, std::vector<VertexPointer *> &local_vec)
269 typename std::vector<VertexPointer *>::iterator vi;
270 for(vi=local_vec.begin();vi!=local_vec.end();++vi)
278 static VertexIterator
AddVertices(MeshType &m,
const Eigen::MatrixXf &vm)
281 VertexIterator v_start = v_ret;
282 for(
int i=0;i<vm.rows();++i)
284 v_ret->P()[0]=vm(i,0);
285 v_ret->P()[1]=vm(i,1);
286 v_ret->P()[2]=vm(i,2);
295 static VertexIterator
AddVertex(MeshType &m,
const CoordType &p)
304 static VertexIterator
AddVertex(MeshType &m,
const CoordType &p,
const CoordType &n)
335 if(n == 0)
return m.edge.end();
337 if(m.edge.empty()) pu.oldBase=0;
339 pu.oldBase=&*m.edge.begin();
340 pu.oldEnd=&m.edge.back()+1;
343 m.edge.resize(m.edge.size()+n);
345 size_t siz=(size_t)(m.edge.size()-n);
346 EdgeIterator firstNewEdge = m.edge.begin();
347 advance(firstNewEdge,siz);
349 typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
350 for(ai = m.edge_attr.begin(); ai != m.edge_attr.end(); ++ai)
351 ((
typename MeshType::PointerToAttribute)(*ai)).Resize(m.edge.size());
353 pu.newBase = &*m.edge.begin();
354 pu.newEnd = &m.edge.back()+1;
357 if(HasFEAdjacency(m))
358 for (FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi){
360 for(
int i=0; i < (*fi).VN(); ++i)
361 if ((*fi).cFEp(i)!=0) pu.
Update((*fi).FEp(i));
364 if(HasVEAdjacency(m)){
365 for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
367 if ((*vi).cVEp()!=0) pu.
Update((*vi).VEp());
368 for(EdgeIterator ei=m.edge.begin();ei!=firstNewEdge;++ei)
371 if ((*ei).cVEp(0)!=0) pu.
Update((*ei).VEp(0));
372 if ((*ei).cVEp(1)!=0) pu.
Update((*ei).VEp(1));
376 if(HasHEAdjacency(m))
377 for (HEdgeIterator hi=m.hedge.begin(); hi!=m.hedge.end(); ++hi)
379 if ((*hi).cHEp()!=0) pu.
Update((*hi).HEp());
387 static EdgeIterator
AddEdge(MeshType &m, VertexPointer v0, VertexPointer v1)
397 static EdgeIterator
AddEdge(MeshType &m,
size_t v0,
size_t v1)
400 assert(v0>=0 && v0<m.vert.size());
401 assert(v1>=0 && v1<m.vert.size());
402 return AddEdge(m,&(m.vert[v0]),&(m.vert[v1]));
408 static EdgeIterator
AddEdge(MeshType &m, CoordType p0, CoordType p1)
422 static EdgeIterator
AddEdges(MeshType &m,
size_t n)
431 static EdgeIterator
AddEdges(MeshType &m,
size_t n, std::vector<EdgePointer*> &local_vec)
434 EdgeIterator v_ret =
AddEdges(m, n,pu);
436 typename std::vector<EdgePointer *>::iterator ei;
437 for(ei=local_vec.begin();ei!=local_vec.end();++ei)
456 if(n == 0)
return m.hedge.end();
458 if(m.hedge.empty()) pu.oldBase=0;
460 pu.oldBase=&*m.hedge.begin();
461 pu.oldEnd=&m.hedge.back()+1;
464 m.hedge.resize(m.hedge.size()+n);
467 pu.newBase = &*m.hedge.begin();
468 pu.newEnd = &m.hedge.back()+1;
472 if(HasFHAdjacency(m)) {
473 for (FaceIterator fi=m.face.begin(); fi!=m.face.end(); ++fi)
475 if(!(*fi).IsD() && (*fi).FHp())
479 if(HasVHAdjacency(m)) {
480 for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
481 if(!(*vi).IsD() && (*vi).cVHp()!=0)
484 if(HasEHAdjacency(m)) {
485 for (EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei)
486 if(!(*ei).IsD() && (*ei).cEHp()!=0)
491 HEdgeIterator hi = m.hedge.begin();
492 while(ii < m.hn -
int(n))
496 if(HasHNextAdjacency(m)) pu.
Update((*hi).HNp());
497 if(HasHPrevAdjacency(m)) pu.
Update((*hi).HPp());
498 if(HasHOppAdjacency(m)) pu.
Update((*hi).HOp());
504 size_t siz = (size_t)(m.hedge.size()-n);
506 last = m.hedge.begin();
524 static HEdgeIterator
AddHEdges(MeshType &m,
size_t n, std::vector<HEdgePointer*> &local_vec)
527 HEdgeIterator v_ret =
AddHEdges(m, n,pu);
529 typename std::vector<HEdgePointer *>::iterator ei;
530 for(ei=local_vec.begin();ei!=local_vec.end();++ei)
539 static FaceIterator
AddFace(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2)
541 assert(m.vert.size()>0);
542 assert((v0!=v1) && (v1!=v2) && (v0!=v2));
543 assert(v0>=&m.vert.front() && v0<=&m.vert.back());
544 assert(v1>=&m.vert.front() && v1<=&m.vert.back());
545 assert(v2>=&m.vert.front() && v2<=&m.vert.back());
557 static FaceIterator
AddFace(MeshType &m,
size_t v0,
size_t v1,
size_t v2)
559 assert((v0!=v1) && (v1!=v2) && (v0!=v2));
560 assert(v0>=0 && v0<m.vert.size());
561 assert(v1>=0 && v1<m.vert.size());
562 assert(v2>=0 && v2<m.vert.size());
563 return AddFace(m,&(m.vert[v0]),&(m.vert[v1]),&(m.vert[v2]));
567 static FaceIterator
AddFace(MeshType &m, CoordType p0, CoordType p1, CoordType p2)
585 static FaceIterator
AddQuadFace(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2, VertexPointer v3)
587 assert(m.vert.size()>0);
588 assert(v0>=&m.vert.front() && v0<=&m.vert.back());
589 assert(v1>=&m.vert.front() && v1<=&m.vert.back());
590 assert(v2>=&m.vert.front() && v2<=&m.vert.back());
591 assert(v3>=&m.vert.front() && v3<=&m.vert.back());
593 if(FaceType::HasPolyInfo())
597 fi->V(0)=v0; fi->V(1)=v1;
598 fi->V(2)=v2; fi->V(3)=v3;
604 fi->Alloc(3); fi->V(0)=v0; fi->V(1)=v1; fi->V(2)=v2;
607 fi->Alloc(3); fi->V(0)=v0; fi->V(1)=v2; fi->V(2)=v3;
615 static FaceIterator
AddFaces(MeshType &m,
size_t n)
624 static FaceIterator
AddFaces(MeshType &m,
size_t n,std::vector<FacePointer *> &local_vec)
627 FaceIterator f_ret=
AddFaces(m,n,pu);
629 typename std::vector<FacePointer *>::iterator fi;
630 for(fi=local_vec.begin();fi!=local_vec.end();++fi)
638 static FaceIterator
AddFaces(MeshType &m,
const Eigen::MatrixXi &fm)
641 FaceIterator f_start =
AddFaces(m,fm.rows(),pu);
642 FaceIterator f_ret=f_start;
643 for(
int i=0;i<fm.rows();++i)
645 f_start->V(0)= &m.vert[fm(i,0)];
646 f_start->V(1)= &m.vert[fm(i,1)];
647 f_start->V(2)= &m.vert[fm(i,2)];
668 if(n == 0)
return m.face.end();
671 pu.oldBase=&*m.face.begin();
672 pu.oldEnd=&m.face.back()+1;
675 m.face.resize(m.face.size()+n);
678 size_t siz=(size_t)(m.face.size()-n);
679 FaceIterator firstNewFace = m.face.begin();
680 advance(firstNewFace,siz);
682 typename std::set<PointerToAttribute>::iterator ai;
683 for(ai = m.face_attr.begin(); ai != m.face_attr.end(); ++ai)
684 ((PointerToAttribute)(*ai)).Resize(m.face.size());
686 pu.newBase = &*m.face.begin();
687 pu.newEnd = &m.face.back()+1;
691 if(HasFFAdjacency(m))
693 for(FaceIterator fi=m.face.begin();fi!=firstNewFace;++fi)
695 for(
int i = 0; i < (*fi).VN(); ++i)
696 if ((*fi).cFFp(i)!=0) pu.
Update((*fi).FFp(i));
699 if(HasPerVertexVFAdjacency(m) && HasPerFaceVFAdjacency(m))
701 for(FaceIterator fi=m.face.begin();fi!=firstNewFace;++fi)
703 for(
int i = 0; i < (*fi).VN(); ++i)
704 if ((*fi).cVFp(i)!=0) pu.
Update((*fi).VFp(i));
706 for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
707 if(!(*vi).IsD() && (*vi).cVFp()!=0)
711 if(HasEFAdjacency(m))
713 for (EdgeIterator ei=m.edge.begin(); ei!=m.edge.end(); ++ei)
714 if(!(*ei).IsD() && (*ei).cEFp()!=0)
718 if(HasHFAdjacency(m))
720 for (HEdgeIterator hi=m.hedge.begin(); hi!=m.hedge.end(); ++hi)
721 if(!(*hi).IsD() && (*hi).cHFp()!=0)
747 return m.tetra.end();
755 pu.oldBase = &*m.tetra.begin();
756 pu.oldEnd = &m.tetra.back() + 1;
760 m.tetra.resize(m.tetra.size() + n);
764 size_t oldSize = (size_t)(m.tetra.size() - n);
766 TetraIterator firstNewTetra = m.tetra.begin();
767 advance(firstNewTetra, oldSize);
770 typename std::set<typename MeshType::PointerToAttribute>::iterator ai;
771 for (ai = m.tetra_attr.begin(); ai != m.tetra_attr.end(); ++ai)
772 ((
typename MeshType::PointerToAttribute)(*ai)).Resize(m.tetra.size());
775 pu.newBase = &*m.tetra.begin();
776 pu.newEnd = &m.tetra.back() + 1;
779 if (HasVTAdjacency(m))
781 for (VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
785 for (TetraIterator ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
796 if (HasTTAdjacency(m))
797 for (TetraIterator ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
807 return firstNewTetra;
813 static TetraIterator
AddTetra(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2, VertexPointer v3)
815 assert(m.vert.size() > 0);
816 assert((v0 != v1) && (v0 != v2) && (v0 != v3) && (v1 != v2) && (v1 != v3) && (v2 != v3));
817 assert(v0 >= &m.vert.front() && v0 <= &m.vert.back());
818 assert(v1 >= &m.vert.front() && v1 <= &m.vert.back());
819 assert(v2 >= &m.vert.front() && v2 <= &m.vert.back());
820 assert(v3 >= &m.vert.front() && v3 <= &m.vert.back());
838 static TetraIterator
AddTetra(MeshType &m,
const size_t v0,
const size_t v1,
const size_t v2,
const size_t v3)
840 assert(m.vert.size() > 0);
841 assert((v0 != v1) && (v0 != v2) && (v0 != v3) && (v1 != v2) && (v1 != v3) && (v2 != v3));
842 assert(v0 >= 0 && v0 < m.vert.size());
843 assert(v1 >= 0 && v1 < m.vert.size());
844 assert(v2 >= 0 && v2 < m.vert.size());
845 assert(v3 >= 0 && v3 < m.vert.size());
847 return AddTetra(m, &(m.vert[v0]), &(m.vert[v1]), &(m.vert[v2]), &(m.vert[v3]));
851 static TetraIterator
AddTetra(MeshType &m,
const CoordType & p0,
const CoordType & p1,
const CoordType & p2,
const CoordType & p3)
855 VertexPointer v0 = &*vi++;
856 VertexPointer v1 = &*vi++;
857 VertexPointer v2 = &*vi++;
858 VertexPointer v3 = &*vi++;
907 static TetraIterator
AddTetras(MeshType &m,
size_t n, std::vector<TetraPointer *> &local_vec)
910 TetraIterator t_ret =
AddTetras(m, n, pu);
912 typename std::vector<TetraPointer *>::iterator ti;
913 for (ti = local_vec.begin(); ti != local_vec.end(); ++ti)
925 assert(&f >= &m.face.front() && &f <= &m.face.back());
937 assert(&v >= &m.vert.front() && &v <= &m.vert.back());
948 assert(&e >= &m.edge.front() && &e <= &m.edge.back());
959 assert(&h >= &m.hedge.front() && &h <= &m.hedge.back());
970 assert(&t >= &m.tetra.front() && &t <= &m.tetra.back());
985 static void PermutateVertexVector(MeshType &m, PointerUpdater<VertexPointer> &pu)
987 if(m.vert.empty())
return;
988 for(
size_t i=0;i<m.vert.size();++i)
990 if(pu.remap[i]<
size_t(m.vn))
992 assert(!m.vert[i].IsD());
993 m.vert[ pu.remap [i] ].ImportData(m.vert[i]);
994 if(HasVFAdjacency(m))
996 if (m.vert[i].IsVFInitialized())
998 m.vert[ pu.remap[i] ].VFp() = m.vert[i].cVFp();
999 m.vert[ pu.remap[i] ].VFi() = m.vert[i].cVFi();
1001 else m.vert [ pu.remap[i] ].VFClear();
1003 if(HasVEAdjacency(m))
1005 if (m.vert[i].IsVEInitialized())
1007 m.vert[ pu.remap[i] ].VEp() = m.vert[i].cVEp();
1008 m.vert[ pu.remap[i] ].VEi() = m.vert[i].cVEi();
1010 else m.vert [ pu.remap[i] ].VEClear();
1012 if (HasVTAdjacency(m))
1014 if (m.vert[i].IsVTInitialized())
1016 m.vert[ pu.remap[i] ].VTp() = m.vert[i].cVTp();
1017 m.vert[ pu.remap[i] ].VTi() = m.vert[i].cVTi();
1019 else m.vert[ pu.remap[i] ].VTClear();
1025 ReorderAttribute(m.vert_attr,pu.remap,m);
1028 pu.oldBase = &m.vert[0];
1029 pu.oldEnd = &m.vert.back()+1;
1032 m.vert.resize(m.vn);
1035 pu.newBase = (m.vert.empty())?0:&m.vert[0];
1036 pu.newEnd = (m.vert.empty())?0:&m.vert.back()+1;
1039 ResizeAttribute(m.vert_attr,m.vn,m);
1042 for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
1044 for(
int i=0;i<fi->VN();++i)
1046 size_t oldIndex = (*fi).V(i) - pu.oldBase;
1047 assert(pu.oldBase <= (*fi).V(i) && oldIndex < pu.remap.size());
1048 (*fi).V(i) = pu.newBase+pu.remap[oldIndex];
1051 for(TetraIterator ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
1053 for(
int i = 0; i < 4; ++i)
1055 size_t oldIndex = (*ti).V(i) - pu.oldBase;
1056 assert(pu.oldBase <= (*ti).V(i) && oldIndex < pu.remap.size());
1057 (*ti).V(i) = pu.newBase+pu.remap[oldIndex];
1061 for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
1064 pu.Update((*ei).V(0));
1065 pu.Update((*ei).V(1));
1069 static void CompactEveryVector(MeshType &m)
1087 if(m.vn==(
int)m.vert.size())
return;
1090 pu.remap.resize( m.vert.size(),std::numeric_limits<size_t>::max() );
1095 for(i=0;i<m.vert.size();++i)
1097 if(!m.vert[i].IsD())
1103 assert((
int)pos==m.vn);
1105 PermutateVertexVector(m, pu);
1125 if(m.en==(
int)m.edge.size())
return;
1128 pu.remap.resize( m.edge.size(),std::numeric_limits<size_t>::max() );
1133 for(i=0;i<m.edge.size();++i)
1135 if(!m.edge[i].IsD())
1141 assert((
int)pos==m.en);
1144 for(
size_t i=0;i<m.edge.size();++i)
1146 if(pu.remap[i]<
size_t(m.en))
1148 assert(!m.edge[i].IsD());
1149 m.edge[ pu.remap [i] ].ImportData(m.edge[i]);
1151 m.edge[ pu.remap[i] ].V(0) = m.edge[i].cV(0);
1152 m.edge[ pu.remap[i] ].V(1) = m.edge[i].cV(1);
1154 if(HasVEAdjacency(m))
1157 m.edge[ pu.remap[i] ].VEp(0) = m.edge[i].cVEp(0);
1158 m.edge[ pu.remap[i] ].VEi(0) = m.edge[i].cVEi(0);
1159 m.edge[ pu.remap[i] ].VEp(1) = m.edge[i].cVEp(1);
1160 m.edge[ pu.remap[i] ].VEi(1) = m.edge[i].cVEi(1);
1162 if(HasEEAdjacency(m))
1165 m.edge[ pu.remap[i] ].EEp(0) = m.edge[i].cEEp(0);
1166 m.edge[ pu.remap[i] ].EEi(0) = m.edge[i].cEEi(0);
1167 m.edge[ pu.remap[i] ].EEp(1) = m.edge[i].cEEp(1);
1168 m.edge[ pu.remap[i] ].EEi(1) = m.edge[i].cEEi(1);
1170 if(HasEFAdjacency(m))
1173 m.edge[ pu.remap[i] ].EFp() = m.edge[i].cEFp();
1174 m.edge[ pu.remap[i] ].EFi() = m.edge[i].cEFi();
1175 m.edge[ pu.remap[i] ].EFp() = m.edge[i].cEFp();
1176 m.edge[ pu.remap[i] ].EFi() = m.edge[i].cEFi();
1183 ReorderAttribute(m.edge_attr, pu.remap,m);
1186 pu.oldBase = &m.edge[0];
1187 pu.oldEnd = &m.edge.back()+1;
1190 m.edge.resize(m.en);
1193 pu.newBase = (m.edge.empty())?0:&m.edge[0];
1194 pu.newEnd = (m.edge.empty())?0:&m.edge.back()+1;
1197 ResizeAttribute(m.edge_attr,m.en,m);
1200 if(HasVEAdjacency(m))
1201 for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
1202 if(!(*vi).IsD()) pu.
Update((*vi).VEp());
1205 for(EdgeIterator ei=m.edge.begin();ei!=m.edge.end();++ei)
1206 for(
unsigned int i=0;i<2;++i)
1208 if(HasVEAdjacency(m))
1210 if(HasEEAdjacency(m))
1234 if(m.fn==(
int)m.face.size())
return;
1237 pu.remap.resize( m.face.size(),std::numeric_limits<size_t>::max() );
1240 for(
size_t i=0;i<m.face.size();++i)
1242 if(!m.face[i].IsD())
1246 m.face[pos].ImportData(m.face[i]);
1247 if(FaceType::HasPolyInfo())
1249 m.face[pos].Dealloc();
1250 m.face[pos].Alloc(m.face[i].VN());
1252 for(
int j=0;j<m.face[i].VN();++j)
1253 m.face[pos].V(j) = m.face[i].V(j);
1255 if(HasVFAdjacency(m))
1256 for(
int j=0;j<m.face[i].VN();++j)
1258 if (m.face[i].IsVFInitialized(j)) {
1259 m.face[pos].VFp(j) = m.face[i].cVFp(j);
1260 m.face[pos].VFi(j) = m.face[i].cVFi(j);
1262 else m.face[pos].VFClear(j);
1264 if(HasFFAdjacency(m))
1265 for(
int j=0;j<m.face[i].VN();++j)
1267 m.face[pos].FFp(j) = m.face[i].cFFp(j);
1268 m.face[pos].FFi(j) = m.face[i].cFFi(j);
1275 assert((
int)pos==m.fn);
1278 ReorderAttribute(m.face_attr,pu.remap,m);
1280 FacePointer fbase=&m.face[0];
1283 if(HasVFAdjacency(m))
1285 for (VertexIterator vi=m.vert.begin(); vi!=m.vert.end(); ++vi)
1288 if ((*vi).IsVFInitialized() && (*vi).VFp()!=0 )
1290 size_t oldIndex = (*vi).cVFp() - fbase;
1291 assert(fbase <= (*vi).cVFp() && oldIndex < pu.remap.size());
1292 (*vi).VFp() = fbase+pu.remap[oldIndex];
1298 pu.oldBase = &m.face[0];
1299 pu.oldEnd = &m.face.back()+1;
1300 for(
size_t i=m.fn;i<m.face.size();++i)
1301 m.face[i].Dealloc();
1302 m.face.resize(m.fn);
1303 pu.newBase = (m.face.empty())?0:&m.face[0];
1304 pu.newEnd = (m.face.empty())?0:&m.face.back()+1;
1308 ResizeAttribute(m.face_attr,m.fn,m);
1311 for(FaceIterator fi=m.face.begin();fi!=m.face.end();++fi)
1314 if(HasVFAdjacency(m))
1315 for(
int i=0;i<(*fi).VN();++i)
1316 if ((*fi).IsVFInitialized(i) && (*fi).VFp(i)!=0 )
1318 size_t oldIndex = (*fi).VFp(i) - fbase;
1319 assert(fbase <= (*fi).VFp(i) && oldIndex < pu.remap.size());
1320 (*fi).VFp(i) = fbase+pu.remap[oldIndex];
1322 if(HasFFAdjacency(m))
1323 for(
int i=0;i<(*fi).VN();++i)
1324 if ((*fi).cFFp(i)!=0)
1326 size_t oldIndex = (*fi).FFp(i) - fbase;
1327 assert(fbase <= (*fi).FFp(i) && oldIndex < pu.remap.size());
1328 (*fi).FFp(i) = fbase+pu.remap[oldIndex];
1353 if (
size_t(m.tn) == m.tetra.size())
1357 pu.remap.resize(m.tetra.size(), std::numeric_limits<size_t>::max());
1362 for (
size_t i = 0; i < m.tetra.size(); ++i)
1364 if (!m.tetra[i].IsD())
1369 m.tetra[pos].ImportData(m.tetra[i]);
1371 for (
int j = 0; j < 4; ++j)
1372 m.tetra[pos].V(j) = m.tetra[i].V(j);
1374 if (HasVTAdjacency(m))
1375 for (
int j = 0; j < 4; ++j)
1377 if (m.tetra[i].IsVTInitialized(j))
1379 m.tetra[pos].VTp(j) = m.tetra[i].VTp(j);
1380 m.tetra[pos].VTi(j) = m.tetra[i].VTi(j);
1383 m.tetra[pos].VTClear(j);
1386 if (HasTTAdjacency(m))
1387 for (
int j = 0; j < 4; ++j)
1389 m.tetra[pos].TTp(j) = m.tetra[i].cTTp(j);
1390 m.tetra[pos].TTi(j) = m.tetra[i].cTTi(j);
1399 assert(
size_t(m.tn) == pos);
1401 ReorderAttribute(m.tetra_attr, pu.remap, m);
1403 ResizeAttribute(m.tetra_attr, m.tn, m);
1406 pu.oldBase = &m.tetra[0];
1407 pu.oldEnd = &m.tetra.back() + 1;
1409 m.tetra.resize(m.tn);
1410 pu.newBase = (m.tetra.empty()) ? 0 : &m.tetra[0];
1411 pu.newEnd = (m.tetra.empty()) ? 0 : &m.tetra.back() + 1;
1413 TetraPointer tbase = &m.tetra[0];
1416 if (HasVTAdjacency(m))
1418 for (VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
1421 if ((*vi).IsVTInitialized() && (*vi).VTp() != 0)
1423 size_t oldIndex = (*vi).cVTp() - tbase;
1424 assert(tbase <= (*vi).cVTp() && oldIndex < pu.remap.size());
1425 (*vi).VTp() = tbase + pu.remap[oldIndex];
1431 for (TetraIterator ti = m.tetra.begin(); ti != m.tetra.end(); ++ti)
1435 if (HasVTAdjacency(m))
1436 for (
int i = 0; i < 4; ++i)
1437 if ((*ti).IsVTInitialized(i) && (*ti).VTp(i) != 0)
1439 size_t oldIndex = (*ti).VTp(i) - tbase;
1440 assert(tbase <= (*ti).VTp(i) && oldIndex < pu.remap.size());
1441 (*ti).VTp(i) = tbase + pu.remap[oldIndex];
1444 if (HasTTAdjacency(m))
1445 for (
int i = 0; i < 4; ++i)
1446 if ((*ti).cTTp(i) != 0)
1448 size_t oldIndex = (*ti).TTp(i) - tbase;
1449 assert(tbase <= (*ti).TTp(i) && oldIndex < pu.remap.size());
1450 (*ti).TTp(i) = tbase + pu.remap[oldIndex];
1468 template <
class ATTR_TYPE>
1470 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE> & a){
1471 if(a._handle ==
nullptr)
return false;
1472 for(AttrIterator i = m.vert_attr.begin(); i!=m.vert_attr.end();++i)
1473 if ( (*i).n_attr == a.n_attr )
return true;
1480 template <
class ATTR_TYPE>
1482 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE> & a){
1483 if(a._handle ==
nullptr)
return false;
1484 for(AttrIterator i = m.vert_attr.begin(); i!=m.vert_attr.end();++i)
1485 if ( (*i).n_attr == a.n_attr )
return true;
1493 template <
class ATTR_TYPE>
1495 typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>
1498 PointerToAttribute h;
1501 i = m.vert_attr.find(h);
1502 assert(i ==m.vert_attr.end() );
1505 h._sizeof =
sizeof(ATTR_TYPE);
1507 h._handle =
new SimpleTempData<VertContainer,ATTR_TYPE>(m.vert);
1508 h._type =
typeid(ATTR_TYPE);
1511 std::pair < AttrIterator , bool> res = m.vert_attr.insert(h);
1512 return typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>(res.first->_handle,res.first->n_attr );
1515 template <
class ATTR_TYPE>
1516 static typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>
1518 return AddPerVertexAttribute<ATTR_TYPE>(m,std::string(
""));
1525 template <
class ATTR_TYPE>
1527 typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>
1529 typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE> h;
1531 h = FindPerVertexAttribute<ATTR_TYPE>(m,name);
1535 return AddPerVertexAttribute<ATTR_TYPE>(m,name);
1542 template <
class ATTR_TYPE>
1544 typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
1546 return FindPerVertexAttribute<ATTR_TYPE>(m,name);
1552 template <
class ATTR_TYPE>
1553 static typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>
1556 assert(!name.empty());
1557 PointerToAttribute h1; h1._name = name;
1558 typename std::set<PointerToAttribute > :: iterator i;
1560 i =m.vert_attr.find(h1);
1561 if(i!=m.vert_attr.end())
1562 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1563 if( (*i)._padding != 0 ){
1564 PointerToAttribute attr = (*i);
1565 m.vert_attr.erase(i);
1566 FixPaddedPerVertexAttribute<ATTR_TYPE>(m,attr);
1567 std::pair<AttrIterator,bool> new_i = m.vert_attr.insert(attr);
1568 assert(new_i.second);
1571 return typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1573 return typename MeshType:: template PerVertexAttributeHandle<ATTR_TYPE>(
nullptr,0);
1582 template <
class ATTR_TYPE>
1583 static typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>
1587 PointerToAttribute h1; h1._name = name;
1588 typename std::set<PointerToAttribute > :: iterator i;
1590 i =m.vert_attr.find(h1);
1591 if(i!=m.vert_attr.end()){
1592 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1593 return typename MeshType::template ConstPerVertexAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1597 return typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE>(
nullptr,0);
1603 template <
class ATTR_TYPE>
1606 typename std::set<PointerToAttribute > ::const_iterator i;
1607 for(i = m.vert_attr.begin(); i != m.vert_attr.end(); ++i )
1608 if(!(*i)._name.empty())
1610 typename MeshType:: template ConstPerVertexAttributeHandle<ATTR_TYPE> hh;
1612 if(IsValidHandle<ATTR_TYPE>(m,hh))
1613 all.push_back((*i)._name);
1617 template <
class ATTR_TYPE>
1620 ClearPerVertexAttribute( MeshType & m,
typename MeshType::template PerVertexAttributeHandle<ATTR_TYPE> & h,
const ATTR_TYPE & initVal = ATTR_TYPE()){
1621 typename std::set<PointerToAttribute > ::iterator i;
1622 for( i = m.vert_attr.begin(); i != m.vert_attr.end(); ++i)
1623 if( (*i)._handle == h._handle ){
1624 for(
typename MeshType::VertexIterator vi = m.vert.begin(); vi != m.vert.end(); ++vi)
1632 template <
class ATTR_TYPE>
1636 typename std::set<PointerToAttribute > ::iterator i;
1637 for( i = m.vert_attr.begin(); i != m.vert_attr.end(); ++i)
1638 if( (*i)._handle == h._handle ){
1639 delete ((SimpleTempData<VertContainer,ATTR_TYPE>*)(*i)._handle);
1640 m.vert_attr.erase(i);
1650 PointerToAttribute h1; h1._name = name;
1651 i = m.vert_attr.find(h1);
1652 if(i==m.vert_attr.end())
return false;
1653 delete ((SimpleTempDataBase*)(*i)._handle);
1654 m.vert_attr.erase(i);
1661 template <
class ATTR_TYPE>
1663 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE> & a){
1664 if(a._handle ==
nullptr)
return false;
1665 for(AttrIterator i = m.edge_attr.begin(); i!=m.edge_attr.end();++i)
1666 if ( (*i).n_attr == a.n_attr )
return true;
1670 template <
class ATTR_TYPE>
1672 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template ConstPerEdgeAttributeHandle<ATTR_TYPE> & a){
1673 if(a._handle ==
nullptr)
return false;
1674 for(AttrIterator i = m.edge_attr.begin(); i!=m.edge_attr.end();++i)
1675 if ( (*i).n_attr == a.n_attr )
return true;
1679 template <
class ATTR_TYPE>
1681 typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>
1682 AddPerEdgeAttribute( MeshType & m, std::string name){
1684 PointerToAttribute h;
1687 i = m.edge_attr.find(h);
1688 assert(i ==m.edge_attr.end() );
1690 h._sizeof =
sizeof(ATTR_TYPE);
1693 h._handle =
new SimpleTempData<EdgeContainer,ATTR_TYPE>(m.edge);
1694 h._type =
typeid(ATTR_TYPE);
1697 std::pair < AttrIterator , bool> res = m.edge_attr.insert(h);
1698 return typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>(res.first->_handle,res.first->n_attr);
1701 template <
class ATTR_TYPE>
1703 typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>
1704 AddPerEdgeAttribute( MeshType & m){
1705 return AddPerEdgeAttribute<ATTR_TYPE>(m,std::string(
""));
1712 template <
class ATTR_TYPE>
1714 typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>
1716 typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE> h;
1718 h = FindPerEdgeAttribute<ATTR_TYPE>(m,name);
1722 return AddPerEdgeAttribute<ATTR_TYPE>(m,name);
1725 template <
class ATTR_TYPE>
1727 typename MeshType::template ConstPerEdgeAttributeHandle<ATTR_TYPE>
1729 return FindPerEdgeAttribute<ATTR_TYPE>(m,name);
1732 template <
class ATTR_TYPE>
1734 typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>
1735 FindPerEdgeAttribute( MeshType & m,
const std::string & name){
1736 assert(!name.empty());
1737 PointerToAttribute h1; h1._name = name;
1738 typename std::set<PointerToAttribute > ::const_iterator i;
1740 i =m.edge_attr.find(h1);
1741 if(i!=m.edge_attr.end())
1742 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1743 if( (*i)._padding != 0 ){
1744 PointerToAttribute attr = (*i);
1745 m.edge_attr.erase(i);
1746 FixPaddedPerEdgeAttribute<ATTR_TYPE>(m,attr);
1747 std::pair<AttrIterator,bool> new_i = m.edge_attr.insert(attr);
1748 assert(new_i.second);
1751 return typename MeshType::template PerEdgeAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1754 return typename MeshType:: template PerEdgeAttributeHandle<ATTR_TYPE>(
nullptr,0);
1757 template <
class ATTR_TYPE>
1759 typename MeshType::template ConstPerEdgeAttributeHandle<ATTR_TYPE>
1760 FindPerEdgeAttribute(
const MeshType & m,
const std::string & name){
1762 PointerToAttribute h1; h1._name = name;
1763 typename std::set<PointerToAttribute > ::const_iterator i;
1765 i =m.edge_attr.find(h1);
1766 if(i!=m.edge_attr.end()){
1767 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1768 return typename MeshType::template ConstPerEdgeAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1772 return typename MeshType:: template ConstPerEdgeAttributeHandle<ATTR_TYPE>(
nullptr,0);
1775 template <
class ATTR_TYPE>
1776 static void GetAllPerEdgeAttribute(
const MeshType & m, std::vector<std::string> &all){
1778 typename std::set<PointerToAttribute > :: const_iterator i;
1779 for(i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i )
1780 if(!(*i)._name.empty())
1782 typename MeshType:: template ConstPerEdgeAttributeHandle<ATTR_TYPE> hh;
1783 hh = Allocator<MeshType>:: template FindPerEdgeAttribute <ATTR_TYPE>(m,(*i)._name);
1784 if(IsValidHandle<ATTR_TYPE>(m,hh))
1785 all.push_back((*i)._name);
1791 template <
class ATTR_TYPE>
1795 typename std::set<PointerToAttribute > ::iterator i;
1796 for( i = m.edge_attr.begin(); i != m.edge_attr.end(); ++i)
1797 if( (*i)._handle == h._handle ){
1798 delete ((SimpleTempData<EdgeContainer,ATTR_TYPE>*)(*i)._handle);
1799 m.edge_attr.erase(i);
1809 PointerToAttribute h1; h1._name = name;
1810 i = m.edge_attr.find(h1);
1811 if(i==m.edge_attr.end())
return false;
1812 delete ((SimpleTempDataBase*)(*i)._handle);
1813 m.edge_attr.erase(i);
1821 template <
class ATTR_TYPE>
1823 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE> & a){
1824 if(a._handle ==
nullptr)
return false;
1825 for(AttrIterator i = m.face_attr.begin(); i!=m.face_attr.end();++i)
1826 if ( (*i).n_attr == a.n_attr )
return true;
1833 template <
class ATTR_TYPE>
1835 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE> & a){
1836 if(a._handle ==
nullptr)
return false;
1837 for(AttrIterator i = m.face_attr.begin(); i!=m.face_attr.end();++i)
1838 if ( (*i).n_attr == a.n_attr )
return true;
1842 template <
class ATTR_TYPE>
1844 typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
1845 AddPerFaceAttribute( MeshType & m, std::string name){
1847 PointerToAttribute h;
1850 i = m.face_attr.find(h);
1851 assert(i ==m.face_attr.end() );
1854 h._sizeof =
sizeof(ATTR_TYPE);
1856 h._handle =
new SimpleTempData<FaceContainer,ATTR_TYPE>(m.face);
1857 h._type =
typeid(ATTR_TYPE);
1860 std::pair < AttrIterator , bool> res = m.face_attr.insert(h);
1861 return typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>(res.first->_handle,res.first->n_attr);
1864 template <
class ATTR_TYPE>
1866 typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
1867 AddPerFaceAttribute( MeshType & m){
1868 return AddPerFaceAttribute<ATTR_TYPE>(m,std::string(
""));
1875 template <
class ATTR_TYPE>
1877 typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
1879 typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE> h;
1881 h = FindPerFaceAttribute<ATTR_TYPE>(m,name);
1885 return AddPerFaceAttribute<ATTR_TYPE>(m,name);
1892 template <
class ATTR_TYPE>
1894 typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>
1896 return FindPerFaceAttribute<ATTR_TYPE>(m,name);
1899 template <
class ATTR_TYPE>
1901 typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>
1902 FindPerFaceAttribute( MeshType & m,
const std::string & name){
1903 assert(!name.empty());
1904 PointerToAttribute h1; h1._name = name;
1905 typename std::set<PointerToAttribute > ::iterator i;
1907 i =m.face_attr.find(h1);
1908 if(i!=m.face_attr.end())
1909 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1910 if( (*i)._padding != 0 ){
1911 PointerToAttribute attr = (*i);
1912 m.face_attr.erase(i);
1913 FixPaddedPerFaceAttribute<ATTR_TYPE>(m,attr);
1914 std::pair<AttrIterator,bool> new_i = m.face_attr.insert(attr);
1915 assert(new_i.second);
1918 return typename MeshType::template PerFaceAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1920 return typename MeshType:: template PerFaceAttributeHandle<ATTR_TYPE>(
nullptr,0);
1929 template <
class ATTR_TYPE>
1931 typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>
1934 PointerToAttribute h1; h1._name = name;
1935 typename std::set<PointerToAttribute > ::iterator i;
1937 i =m.face_attr.find(h1);
1938 if(i!=m.face_attr.end()){
1939 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
1940 return typename MeshType::template ConstPerFaceAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
1944 return typename MeshType:: template ConstPerFaceAttributeHandle<ATTR_TYPE>(
nullptr,0);
1947 template <
class ATTR_TYPE>
1948 static void GetAllPerFaceAttribute(
const MeshType & m, std::vector<std::string> &all){
1950 typename std::set<PointerToAttribute > :: const_iterator i;
1951 for(i = m.face_attr.begin(); i != m.face_attr.end(); ++i )
1952 if(!(*i)._name.empty())
1954 typename MeshType:: template ConstPerFaceAttributeHandle<ATTR_TYPE> hh;
1956 if(IsValidHandle<ATTR_TYPE>(m,hh))
1957 all.push_back((*i)._name);
1963 template <
class ATTR_TYPE>
1965 typename std::set<PointerToAttribute > ::iterator i;
1966 for( i = m.face_attr.begin(); i != m.face_attr.end(); ++i)
1967 if( (*i)._handle == h._handle ){
1968 delete ((SimpleTempData<FaceContainer,ATTR_TYPE>*)(*i)._handle);
1969 m.face_attr.erase(i);
1979 PointerToAttribute h1; h1._name = name;
1980 i = m.face_attr.find(h1);
1981 if(i==m.face_attr.end())
return false;
1982 delete ((SimpleTempDataBase*)(*i)._handle);
1983 m.face_attr.erase(i);
1988 template <
class ATTR_TYPE>
1989 static bool IsValidHandle(
const MeshType & m,
const typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE> & a)
1991 if (a._handle ==
nullptr)
1993 for (AttrIterator i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i)
1994 if ((*i).n_attr == a.n_attr)
1999 template <
class ATTR_TYPE>
2000 static bool IsValidHandle(
const MeshType & m,
const typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE> & a)
2002 if (a._handle ==
nullptr)
2004 for (AttrIterator i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i)
2005 if ((*i).n_attr == a.n_attr)
2010 template <
class ATTR_TYPE>
2011 static typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE> AddPerTetraAttribute(MeshType & m, std::string name)
2014 PointerToAttribute h;
2018 i = m.tetra_attr.find(h);
2019 assert(i == m.tetra_attr.end());
2022 h._sizeof =
sizeof(ATTR_TYPE);
2024 h._handle =
new SimpleTempData<TetraContainer, ATTR_TYPE>(m.tetra);
2025 h._type =
typeid(ATTR_TYPE);
2028 std::pair<AttrIterator, bool> res = m.tetra_attr.insert(h);
2029 return typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE>(res.first->_handle, res.first->n_attr);
2032 template <
class ATTR_TYPE>
2033 static typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE> AddPerTetraAttribute(MeshType &m)
2035 return AddPerTetraAttribute<ATTR_TYPE>(m, std::string(
""));
2042 template <
class ATTR_TYPE>
2043 static typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE>
GetPerTetraAttribute(MeshType &m, std::string name = std::string(
""))
2045 typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE> h;
2048 h = FindPerTetraAttribute<ATTR_TYPE>(m, name);
2052 return AddPerTetraAttribute<ATTR_TYPE>(m, name);
2055 template <
class ATTR_TYPE>
2056 static typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE>
GetPerTetraAttribute(
const MeshType &m, std::string name = std::string(
""))
2058 return FindPerTetraAttribute<ATTR_TYPE>(m, name);
2061 template <
class ATTR_TYPE>
2062 static typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE> FindPerTetraAttribute(MeshType &m,
const std::string &name)
2064 assert(!name.empty());
2065 PointerToAttribute h1;
2067 typename std::set<PointerToAttribute>::iterator i;
2069 i = m.tetra_attr.find(h1);
2070 if (i != m.tetra_attr.end())
2071 if ((*i)._sizeof ==
sizeof(ATTR_TYPE))
2073 if ((*i)._padding != 0)
2075 PointerToAttribute attr = (*i);
2076 m.tetra_attr.erase(i);
2077 FixPaddedPerTetraAttribute<ATTR_TYPE>(m, attr);
2078 std::pair<AttrIterator, bool> new_i = m.tetra_attr.insert(attr);
2079 assert(new_i.second);
2082 return typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE>((*i)._handle, (*i).n_attr);
2084 return typename MeshType::template PerTetraAttributeHandle<ATTR_TYPE>(
nullptr, 0);
2087 template <
class ATTR_TYPE>
2088 static typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE> FindPerTetraAttribute(
const MeshType &m,
const std::string &name)
2091 PointerToAttribute h1;
2093 typename std::set<PointerToAttribute>::iterator i;
2095 i = m.tetra_attr.find(h1);
2096 if (i != m.tetra_attr.end()){
2097 if ((*i)._sizeof ==
sizeof(ATTR_TYPE))
2099 return typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE>((*i)._handle, (*i).n_attr);
2103 return typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE>(
nullptr, 0);
2106 template <
class ATTR_TYPE>
2107 static void GetAllPerTetraAttribute(
const MeshType &m, std::vector<std::string> &all)
2110 typename std::set<PointerToAttribute>::const_iterator i;
2111 for (i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i)
2112 if (!(*i)._name.empty())
2114 typename MeshType::template ConstPerTetraAttributeHandle<ATTR_TYPE> hh;
2115 hh = Allocator<MeshType>::template FindPerTetraAttribute<ATTR_TYPE>(m, (*i)._name);
2116 if (IsValidHandle<ATTR_TYPE>(m, hh))
2117 all.push_back((*i)._name);
2123 template <
class ATTR_TYPE>
2126 typename std::set<PointerToAttribute>::iterator i;
2127 for (i = m.tetra_attr.begin(); i != m.tetra_attr.end(); ++i)
2128 if ((*i)._handle == h._handle)
2130 delete ((SimpleTempData<TetraContainer, ATTR_TYPE> *)(*i)._handle);
2131 m.tetra_attr.erase(i);
2142 PointerToAttribute h1;
2144 i = m.tetra_attr.find(h1);
2145 if (i == m.tetra_attr.end())
2147 delete ((SimpleTempDataBase *)(*i)._handle);
2148 m.tetra_attr.erase(i);
2154 template <
class ATTR_TYPE>
2156 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE> & a){
2157 if(a._handle ==
nullptr)
return false;
2158 for(AttrIterator i = m.mesh_attr.begin(); i!=m.mesh_attr.end();++i)
2159 if ( (*i).n_attr == a.n_attr )
return true;
2163 template <
class ATTR_TYPE>
2165 bool IsValidHandle(
const MeshType & m,
const typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE> & a){
2166 if(a._handle ==
nullptr)
return false;
2167 for(AttrIterator i = m.mesh_attr.begin(); i!=m.mesh_attr.end();++i)
2168 if ( (*i).n_attr == a.n_attr )
return true;
2172 template <
class ATTR_TYPE>
2174 typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>
2175 AddPerMeshAttribute( MeshType & m, std::string name){
2177 PointerToAttribute h;
2180 i = m.mesh_attr.find(h);
2181 assert(i ==m.mesh_attr.end() );
2183 h._sizeof =
sizeof(ATTR_TYPE);
2185 h._handle =
new Attribute<ATTR_TYPE>();
2186 h._type =
typeid(ATTR_TYPE);
2189 std::pair < AttrIterator , bool> res = m.mesh_attr.insert(h);
2190 return typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>(res.first->_handle,res.first->n_attr);
2197 template <
class ATTR_TYPE>
2199 typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>
2201 typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE> h;
2203 h = FindPerMeshAttribute<ATTR_TYPE>(m,name);
2207 return AddPerMeshAttribute<ATTR_TYPE>(m,name);
2210 template <
class ATTR_TYPE>
2212 typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>
2214 return FindPerMeshAttribute<ATTR_TYPE>(m,name);
2217 template <
class ATTR_TYPE>
2219 typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>
2220 FindPerMeshAttribute( MeshType & m,
const std::string & name){
2221 assert(!name.empty());
2222 PointerToAttribute h1; h1._name = name;
2223 typename std::set<PointerToAttribute > ::iterator i;
2225 i =m.mesh_attr.find(h1);
2226 if(i!=m.mesh_attr.end())
2227 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
2228 if( (*i)._padding != 0 ){
2229 PointerToAttribute attr = (*i);
2230 m.mesh_attr.erase(i);
2231 FixPaddedPerMeshAttribute<ATTR_TYPE>(m,attr);
2232 std::pair<AttrIterator,bool> new_i = m.mesh_attr.insert(attr);
2233 assert(new_i.second);
2237 return typename MeshType::template PerMeshAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
2240 return typename MeshType:: template PerMeshAttributeHandle<ATTR_TYPE>(
nullptr,0);
2243 template <
class ATTR_TYPE>
2245 typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>
2246 FindPerMeshAttribute(
const MeshType & m,
const std::string & name){
2248 PointerToAttribute h1; h1._name = name;
2249 typename std::set<PointerToAttribute > ::iterator i;
2250 i =m.mesh_attr.find(h1);
2251 if(i!=m.mesh_attr.end()){
2252 if((*i)._sizeof ==
sizeof(ATTR_TYPE) ){
2253 return typename MeshType::template ConstPerMeshAttributeHandle<ATTR_TYPE>((*i)._handle,(*i).n_attr);
2258 return typename MeshType:: template ConstPerMeshAttributeHandle<ATTR_TYPE>(
nullptr,0);
2261 template <
class ATTR_TYPE>
2262 static void GetAllPerMeshAttribute(
const MeshType & m, std::vector<std::string> &all){
2263 typename std::set<PointerToAttribute > :: iterator i;
2264 for(i = m.mesh_attr.begin(); i != m.mesh_attr.end(); ++i )
2265 if((*i)._sizeof ==
sizeof(ATTR_TYPE))
2266 all.push_back((*i)._name);
2271 template <
class ATTR_TYPE>
2273 typename std::set<PointerToAttribute > ::iterator i;
2274 for( i = m.mesh_attr.begin(); i != m.mesh_attr.end(); ++i)
2275 if( (*i)._handle == h._handle ){
2276 delete (( Attribute<ATTR_TYPE> *)(*i)._handle);
2277 m.mesh_attr.erase(i);
2286 PointerToAttribute h1; h1._name = name;
2287 i = m.mesh_attr.find(h1);
2288 if (i==m.mesh_attr.end())
2290 delete ((SimpleTempDataBase *)(*i)._handle);
2291 m.mesh_attr.erase(i);
2295 template <
class ATTR_TYPE>
2296 static void FixPaddedPerVertexAttribute (MeshType & m, PointerToAttribute & pa){
2299 SimpleTempData<VertContainer,ATTR_TYPE>* _handle =
new SimpleTempData<VertContainer,ATTR_TYPE>(m.vert);
2302 _handle->Resize(m.vert.size());
2303 for(
size_t i = 0; i < m.vert.size(); ++i){
2304 ATTR_TYPE * dest = &(*_handle)[i];
2305 char * ptr = (
char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
2306 ATTR_TYPE* attrptr = (ATTR_TYPE*)ptr;
2307 *dest = attrptr[i * pa._sizeof ];
2313 delete ((SimpleTempDataBase*) pa._handle);
2316 pa._sizeof =
sizeof(ATTR_TYPE);
2319 pa._handle = _handle;
2324 template <
class ATTR_TYPE>
2325 static void FixPaddedPerEdgeAttribute (MeshType & m, PointerToAttribute & pa){
2328 SimpleTempData<EdgeContainer,ATTR_TYPE>* _handle =
new SimpleTempData<EdgeContainer,ATTR_TYPE>(m.edge);
2331 _handle->Resize(m.edge.size());
2332 for(
size_t i = 0; i < m.edge.size(); ++i){
2333 ATTR_TYPE * dest = &(*_handle)[i];
2334 char * ptr = (
char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
2335 ATTR_TYPE* attrptr = (ATTR_TYPE*)ptr;
2336 *dest = attrptr[i * pa._sizeof ];
2342 delete ((SimpleTempDataBase*) pa._handle);
2345 pa._sizeof =
sizeof(ATTR_TYPE);
2348 pa._handle = _handle;
2354 template <
class ATTR_TYPE>
2355 static void FixPaddedPerFaceAttribute ( MeshType & m,PointerToAttribute & pa){
2358 SimpleTempData<FaceContainer,ATTR_TYPE>* _handle =
new SimpleTempData<FaceContainer,ATTR_TYPE>(m.face);
2361 _handle->Resize(m.face.size());
2362 for(
size_t i = 0; i < m.face.size(); ++i){
2363 ATTR_TYPE * dest = &(*_handle)[i];
2364 char * ptr = (
char*)( ((SimpleTempDataBase *)pa._handle)->DataBegin());
2365 ATTR_TYPE* attrptr = (ATTR_TYPE*)ptr;
2366 *dest = attrptr[i * pa._sizeof ];
2372 delete ((SimpleTempDataBase*) pa._handle);
2375 pa._sizeof =
sizeof(ATTR_TYPE);
2378 pa._handle = _handle;
2384 template <
class ATTR_TYPE>
2385 static void FixPaddedPerTetraAttribute(MeshType &m, PointerToAttribute &pa)
2389 SimpleTempData<TetraContainer, ATTR_TYPE> *_handle =
new SimpleTempData<TetraContainer, ATTR_TYPE>(m.tetra);
2392 _handle->Resize(m.tetra.size());
2393 for (
size_t i = 0; i < m.tetra.size(); ++i)
2395 ATTR_TYPE *dest = &(*_handle)[i];
2396 char *ptr = (
char *)(((SimpleTempDataBase *)pa._handle)->DataBegin());
2397 ATTR_TYPE* attrptr = (ATTR_TYPE*)ptr;
2398 *dest = attrptr[i * pa._sizeof ];
2404 delete ((SimpleTempDataBase *)pa._handle);
2407 pa._sizeof =
sizeof(ATTR_TYPE);
2410 pa._handle = _handle;
2416 template <
class ATTR_TYPE>
2417 static void FixPaddedPerMeshAttribute ( MeshType & ,PointerToAttribute & pa){
2420 Attribute<ATTR_TYPE> * _handle =
new Attribute<ATTR_TYPE>();
2423 ATTR_TYPE* dest = (ATTR_TYPE*)_handle->DataBegin();
2424 char* ptr = (
char*)( ((Attribute<ATTR_TYPE> *)pa._handle)->DataBegin());
2425 ATTR_TYPE* attrptr = (ATTR_TYPE*)ptr;
2430 delete ( (Attribute<ATTR_TYPE> *) pa._handle);
2433 pa._sizeof =
sizeof(ATTR_TYPE);
2436 pa._handle = _handle;
Accessory class to update pointers after eventual reallocation caused by adding elements.
Definition: allocate.h:145
void Update(SimplexPointerType &vp)
Update a pointer to an element of a mesh after a reallocation.
Definition: allocate.h:153
bool NeedUpdate()
return true if the allocation operation that initialized this PointerUpdater has caused a reallocatio...
Definition: allocate.h:166
Class to safely add and delete elements in a mesh.
Definition: allocate.h:97
static VertexIterator AddVertices(MeshType &m, size_t n)
Wrapper to AddVertices(); no PointerUpdater.
Definition: allocate.h:256
static HEdgeIterator AddHEdges(MeshType &m, size_t n, std::vector< HEdgePointer * > &local_vec)
Definition: allocate.h:524
static VertexIterator AddVertices(MeshType &m, size_t n, std::vector< VertexPointer * > &local_vec)
Wrapper to AddVertices() no PointerUpdater but a vector of VertexPointer pointers to be updated.
Definition: allocate.h:264
static MeshType::template PerVertexAttributeHandle< ATTR_TYPE > AddPerVertexAttribute(MeshType &m, std::string name)
Add a Per-Vertex Attribute of the given ATTR_TYPE with the given name.
Definition: allocate.h:1496
static VertexIterator AddVertex(MeshType &m, const CoordType &p)
Wrapper to AddVertices() to add a single vertex with given coords.
Definition: allocate.h:295
static bool IsValidHandle(const MeshType &m, const typename MeshType::template PerTetraAttributeHandle< ATTR_TYPE > &a)
Per Tetra Attributes.
Definition: allocate.h:1989
static MeshType::template ConstPerFaceAttributeHandle< ATTR_TYPE > FindPerFaceAttribute(const MeshType &m, const std::string &name)
Try to retrieve a const handle to an attribute with a given name and ATTR_TYPE, from the given const ...
Definition: allocate.h:1932
static void DeleteTetra(MeshType &m, TetraType &t)
Definition: allocate.h:968
static MeshType::template PerVertexAttributeHandle< ATTR_TYPE > FindPerVertexAttribute(MeshType &m, const std::string &name)
Try to retrieve an handle to an attribute with a given name and ATTR_TYPE.
Definition: allocate.h:1554
static EdgeIterator AddEdges(MeshType &m, size_t n, PointerUpdater< EdgePointer > &pu)
Add n edges to the mesh. Function to add n edges to the mesh. The elements are added always to the en...
Definition: allocate.h:333
static void DeletePerEdgeAttribute(MeshType &m, typename MeshType::template PerEdgeAttributeHandle< ATTR_TYPE > &h)
If the per-edge attribute exists, delete it.
Definition: allocate.h:1794
static VertexIterator AddVertex(MeshType &m, const CoordType &p, const Color4b &c)
Wrapper to AddVertices() to add a single vertex with given coords and color.
Definition: allocate.h:314
static VertexIterator AddVertex(MeshType &m, const CoordType &p, const CoordType &n)
Wrapper to AddVertices() to add a single vertex with given coords and normal.
Definition: allocate.h:304
static VertexIterator AddVertices(MeshType &m, const Eigen::MatrixXf &vm)
Wrapper to AddVertices() to add an eigen matrix of (vn,3) it returns the iterator to the first vertex...
Definition: allocate.h:278
static MeshType::template PerTetraAttributeHandle< ATTR_TYPE > GetPerTetraAttribute(MeshType &m, std::string name=std::string(""))
gives a handle to a per-tetra attribute with a given name and ATTR_TYPE
Definition: allocate.h:2043
static TetraIterator AddTetras(MeshType &m, size_t n, std::vector< TetraPointer * > &local_vec)
Function to add n faces to the mesh. Second Wrapper, with a vector of face pointer to be updated.
Definition: allocate.h:907
static void CompactFaceVector(MeshType &m, PointerUpdater< FacePointer > &pu)
Compact face vector by removing deleted elements.
Definition: allocate.h:1231
static TetraIterator AddTetra(MeshType &m, const CoordType &p0, const CoordType &p1, const CoordType &p2, const CoordType &p3)
Definition: allocate.h:851
static void DeletePerTetraAttribute(MeshType &m, typename MeshType::template PerTetraAttributeHandle< ATTR_TYPE > &h)
If the per-face attribute exists, delete it.
Definition: allocate.h:2124
static void CompactFaceVector(MeshType &m)
Wrapper without the PointerUpdater.
Definition: allocate.h:1337
static void DeleteFace(MeshType &m, FaceType &f)
Definition: allocate.h:923
static void CompactVertexVector(MeshType &m, PointerUpdater< VertexPointer > &pu)
Compact vector of vertices removing deleted elements. Deleted elements are put to the end of the vect...
Definition: allocate.h:1084
static void CompactEdgeVector(MeshType &m)
Wrapper without the PointerUpdater.
Definition: allocate.h:1218
static HEdgeIterator AddHEdges(MeshType &m, size_t n)
Definition: allocate.h:515
static void DeleteVertex(MeshType &m, VertexType &v)
Definition: allocate.h:935
static MeshType::template PerFaceAttributeHandle< ATTR_TYPE > GetPerFaceAttribute(MeshType &m, std::string name=std::string(""))
gives a handle to a per-face attribute with a given name and ATTR_TYPE
Definition: allocate.h:1878
static bool IsValidHandle(const MeshType &m, const typename MeshType::template PerFaceAttributeHandle< ATTR_TYPE > &a)
Per Face Attributes.
Definition: allocate.h:1823
static void DeleteHEdge(MeshType &m, HEdgeType &h)
Definition: allocate.h:957
static bool IsValidHandle(const MeshType &m, const typename MeshType::template ConstPerFaceAttributeHandle< ATTR_TYPE > &a)
Checks if a const handle to a Per-Face attribute is valid.
Definition: allocate.h:1835
static FaceIterator AddFaces(MeshType &m, size_t n, PointerUpdater< FacePointer > &pu)
Function to add n faces to the mesh. This is the only full featured function that is able to manage c...
Definition: allocate.h:665
static void CompactEdgeVector(MeshType &m, PointerUpdater< EdgePointer > &pu)
Compact vector of edges removing deleted elements.
Definition: allocate.h:1122
static VertexIterator AddVertices(MeshType &m, size_t n, PointerUpdater< VertexPointer > &pu)
Add n vertices to the mesh. Function to add n vertices to the mesh. The elements are added always to ...
Definition: allocate.h:189
static FaceIterator AddFaces(MeshType &m, const Eigen::MatrixXi &fm)
Function to add n faces to the mesh getting indexes from a (fn, 3) eigen matrix of int .
Definition: allocate.h:638
static bool IsValidHandle(const MeshType &m, const typename MeshType::template ConstPerVertexAttributeHandle< ATTR_TYPE > &a)
Checks if a const handle to a Per-Vertex Attribute is valid.
Definition: allocate.h:1482
static void CompactTetraVector(MeshType &m)
Wrapper without the PointerUpdater.
Definition: allocate.h:1456
static bool IsValidHandle(const MeshType &m, const typename MeshType::template PerVertexAttributeHandle< ATTR_TYPE > &a)
Checks if a handle to a Per-Vertex Attribute is valid.
Definition: allocate.h:1470
static FaceIterator AddFace(MeshType &m, CoordType p0, CoordType p1, CoordType p2)
Definition: allocate.h:567
static void CompactTetraVector(MeshType &m, PointerUpdater< TetraPointer > &pu)
Compact tetra vector by removing deleted elements.
Definition: allocate.h:1350
static MeshType::template PerEdgeAttributeHandle< ATTR_TYPE > GetPerEdgeAttribute(MeshType &m, std::string name=std::string(""))
gives a handle to a per-edge attribute with a given name and ATTR_TYPE
Definition: allocate.h:1715
static void DeletePerVertexAttribute(MeshType &m, typename MeshType::template PerVertexAttributeHandle< ATTR_TYPE > &h)
If the per-vertex attribute exists, delete it.
Definition: allocate.h:1635
static FaceIterator AddFaces(MeshType &m, size_t n)
Function to add n faces to the mesh. First wrapper, with no parameters.
Definition: allocate.h:615
static MeshType::template ConstPerVertexAttributeHandle< ATTR_TYPE > FindPerVertexAttribute(const MeshType &m, const std::string &name)
Try to retrieve a const handle to an attribute with a given name and ATTR_TYPE, from the given const ...
Definition: allocate.h:1584
static FaceIterator AddFaces(MeshType &m, size_t n, std::vector< FacePointer * > &local_vec)
Function to add n faces to the mesh. Second Wrapper, with a vector of face pointer to be updated.
Definition: allocate.h:624
static EdgeIterator AddEdge(MeshType &m, VertexPointer v0, VertexPointer v1)
Definition: allocate.h:387
static MeshType::template ConstPerVertexAttributeHandle< ATTR_TYPE > GetPerVertexAttribute(const MeshType &m, std::string name=std::string(""))
gives a const handle to a per-vertex attribute with a given name and ATTR_TYPE
Definition: allocate.h:1545
static FaceIterator AddQuadFace(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2, VertexPointer v3)
Definition: allocate.h:585
static void GetAllPerVertexAttribute(const MeshType &m, std::vector< std::string > &all)
query the mesh for all the attributes per vertex
Definition: allocate.h:1604
static void DeleteEdge(MeshType &m, EdgeType &e)
Definition: allocate.h:946
static bool IsValidHandle(const MeshType &m, const typename MeshType::template PerMeshAttributeHandle< ATTR_TYPE > &a)
Per Mesh Attributes.
Definition: allocate.h:2156
static EdgeIterator AddEdge(MeshType &m, CoordType p0, CoordType p1)
Definition: allocate.h:408
static MeshType::template PerVertexAttributeHandle< ATTR_TYPE > GetPerVertexAttribute(MeshType &m, std::string name=std::string(""))
gives a handle to a per-vertex attribute with a given name and ATTR_TYPE
Definition: allocate.h:1528
static MeshType::template ConstPerFaceAttributeHandle< ATTR_TYPE > GetPerFaceAttribute(const MeshType &m, std::string name=std::string(""))
gives a handle to a per-face attribute with a given name and ATTR_TYPE
Definition: allocate.h:1895
static TetraIterator AddTetras(MeshType &m, size_t n, PointerUpdater< TetraPointer > &pu)
Function to add n tetras to the mesh. This is the only full featured function that is able to manage ...
Definition: allocate.h:743
static TetraIterator AddTetras(MeshType &m, size_t n)
Function to add n faces to the mesh. First wrapper, with no parameters.
Definition: allocate.h:898
static void DeletePerMeshAttribute(MeshType &m, typename MeshType::template PerMeshAttributeHandle< ATTR_TYPE > &h)
If the per-mesh attribute exists, delete it.
Definition: allocate.h:2272
static TetraIterator AddTetra(MeshType &m, const size_t v0, const size_t v1, const size_t v2, const size_t v3)
Definition: allocate.h:838
static FaceIterator AddFace(MeshType &m, size_t v0, size_t v1, size_t v2)
Definition: allocate.h:557
static void CompactVertexVector(MeshType &m)
Wrapper without the PointerUpdater.
Definition: allocate.h:1109
static EdgeIterator AddEdges(MeshType &m, size_t n, std::vector< EdgePointer * > &local_vec)
Definition: allocate.h:431
static FaceIterator AddFace(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2)
Definition: allocate.h:539
static EdgeIterator AddEdges(MeshType &m, size_t n)
Definition: allocate.h:422
static TetraIterator AddTetra(MeshType &m, VertexPointer v0, VertexPointer v1, VertexPointer v2, VertexPointer v3)
Definition: allocate.h:813
static void DeletePerFaceAttribute(MeshType &m, typename MeshType::template PerFaceAttributeHandle< ATTR_TYPE > &h)
If the per-face attribute exists, delete it.
Definition: allocate.h:1964
static bool IsValidHandle(const MeshType &m, const typename MeshType::template PerEdgeAttributeHandle< ATTR_TYPE > &a)
Per Edge Attributes.
Definition: allocate.h:1663
static HEdgeIterator AddHEdges(MeshType &m, size_t n, PointerUpdater< HEdgePointer > &pu)
Definition: allocate.h:453
static EdgeIterator AddEdge(MeshType &m, size_t v0, size_t v1)
Definition: allocate.h:397
static MeshType::template PerMeshAttributeHandle< ATTR_TYPE > GetPerMeshAttribute(MeshType &m, std::string name=std::string(""))
gives a handle to a per-edge attribute with a given name and ATTR_TYPE
Definition: allocate.h:2200
Definition: namespaces.dox:6