From adeca3e96f5e329a725b5015fdde7a152abfc9bf Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Mon, 26 Apr 2004 09:40:15 +0000 Subject: [PATCH] *** empty log message *** --- apps/test/tetramesh/test/test.cpp | 31 ++++++- apps/test/tetramesh/test/test.suo | Bin 8192 -> 10752 bytes apps/test/tetramesh/test/test.vcproj | 15 +++ vcg/complex/tetramesh/update/allocate.h | 116 ++++++++++++++++-------- vcg/complex/tetramesh/update/topology.h | 51 +++++------ vcg/simplex/tetrahedron/base.h | 59 ++++++------ vcg/simplex/vertex/base.h | 27 ++++++ vcg/simplex/vertex/with/a.h | 23 +++++ 8 files changed, 223 insertions(+), 99 deletions(-) create mode 100644 vcg/simplex/vertex/with/a.h diff --git a/apps/test/tetramesh/test/test.cpp b/apps/test/tetramesh/test/test.cpp index 2a3c3590..8559e4d1 100644 --- a/apps/test/tetramesh/test/test.cpp +++ b/apps/test/tetramesh/test/test.cpp @@ -1,7 +1,32 @@ -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace vcg; +using namespace tetra; +using namespace tri; +#include + int main( int argc, char **argv ) { - + MyMesh tm=MyMesh(); + UpdateTopology,vector > ut= UpdateTopology,vector >(); + Allocator All= Allocator(); + vector local_var=vector(); + char* filename="sphere.ts"; + tm.LoadTs(filename,1); + ut.TTTopology(tm.vert,tm.tetra); + ut.TestTTTopology(tm.vert,tm.tetra); + ut.VTTopology(tm.vert,tm.tetra); + All.AddVertices(tm,10,local_var); + All.AddVertices(tm,10); + ut.TestTTTopology(tm.vert,tm.tetra); + MyTriMesh mesh; + TriConverter tric=TriConverter(); + tric.Convert(tm,mesh); } \ No newline at end of file diff --git a/apps/test/tetramesh/test/test.suo b/apps/test/tetramesh/test/test.suo index a239603772096f944f97087d1f7340b705815ad4..b0513d4b42a7b7cc5fb8adacf6c2ea54c7833d04 100644 GIT binary patch delta 1842 zcmbu9OKcNY6o$`?$7byMH8IA9JlsGM0x3!C1V~!bn(_=Wm`4zyst}KuMgv185LU=l;*l>`rpgmkTH!EJ=9eV??7o>&v<3 zmV;N7*Zej(?3ajotNUb+N7ArQ=gXlX+3A*yJmt5c#>pdehQ?`vPEnpN(zjHkvvdNI zJQe6T=7;GJMtMZ*I1*zi6diX{-QhpfzNeL)A=AQt|OD;By=$cb7+mH*GB_^dd zzb!JNi+7fwJR8Yr{5Y5_7vtAd&NQCnKb!PGjoVy_##+xI2xD-z2xqM@$gb0L9+Iu!kN1d?Cd&9RtA^W_r;^|btB8aH+Asc z#+xhb#4oFV>=plIB=|R@8z+0C6SiFvVyUx3)Q_O<*z5l6cFGOf9dkQZn^(Y(8uk@BoTt@k3@AIPY|4eQp1Uwgpvf$Z$TjnFdh( ztK|itIi%=c!~4R<-+%l%!`r=sAC6A^U(spD&FNb~YPIjXjlTLodaHe(^c?ebdZp9JdtGC% zNoO`~u`P?pTCemyX=&DHSyr9Tb%|TSQ5|>Vdxf|ifSBhn)vp zE)~vJDrQ#a&dT{(eU7dp(YIbiO=``amgdTmj*^iJXj+M#;6Hw3_%b0 z~!MjOg^g{W*H8gu-lFw#l-n@D9zHhghTlJk;jhh1# zyLUf|wrq$bm*lY9`T48zZRD%a3Fh&pTu5c$nV<*bv^BlZgLeZAgCe-jFU-lC`{+?YGzq4_G&m0~fQ#S~xC~~%EU1Dj zK6f=ts=QYee$=w^IJNE8l&em2N9qk|3;VK?hb)gTOVZ#B-3jdIb-hrbJ&81D}} za@4@+F8E!#!4Ha4yi;(GDKP?w(t-#pxcwSEp~w6q|L{z|VfpBWf4Fn<6>9!0&9I(Z#mqHX-al> + + + + + + + + + + -class Allocate + +template < class TM_TYPE > +class Allocator { public: - /// The vertex container - typedef STL_VERT_CONT VertexContainer; - - /// The tethaedhron container - typedef STL_TETRA_CONT TetraContainer; + /// The tetramesh type + typedef TM_TYPE TetraMeshType; + /// The vertex type - typedef typename STL_VERT_CONT::value_type VertexType; + typedef typename TM_TYPE::VertexType VertexType; /// The tetrahedron type - typedef typename STL_TETRA_CONT::value_type TetraType; + typedef typename TM_TYPE::TetraType TetraType; /// The type of vertex iterator - typedef typename STL_VERT_CONT::iterator VertexIterator; + typedef typename TM_TYPE::VertexIterator VertexIterator; /// The type of tetra iterator - typedef typename STL_TETRA_CONT::iterator TetraIterator; + typedef typename TM_TYPE::TetraIterator TetraIterator; /// The type of constant vertex iterator - typedef typename STL_VERT_CONT::const_iterator const_VertexIterator; + typedef typename TM_TYPE::const_VertexIterator const_VertexIterator; /// The type of constant face iterator - typedef typename STL_TETRA_CONT::const_iterator const_TetraIterator; + typedef typename TM_TYPE::const_TetraIterator const_TetraIterator; -private: - VertexContainer* _vert; - TetraContainer* _tetra; public: - ///defaul constructor - Allocate(VertexContainer *v,TetraContainer *t) - { - _vert=v; - _tetra=t; - } - + /** Function to add n vertices to the mesh. The second parameter hold a vector of pointers to pointer to elements of the mesh that should be updated after a possible vector realloc. @@ -92,30 +81,30 @@ possible vector realloc. restituisce l'iteratore al primo elemento aggiunto. */ -VertexIterator AddVertices(int n, vector &local_var) +VertexIterator AddVertices(TetraMeshType &m,int n, vector &local_var) { VertexIterator oldbegin, newbegin; - oldbegin = _vert->begin(); - VertexIterator last=_vert->end(); - if(_vert->empty()) last=0; // if the vector is empty we cannot find the last valid element + oldbegin = m.vert.begin(); + VertexIterator last=m.vert.end(); + if(m.vert.empty()) last=0; // if the vector is empty we cannot find the last valid element else --last; unsigned int siz=0; #ifdef __STL_CONFIG_H -if(last!=0) distance(_vert->begin(),last,siz); +if(last!=0) distance(m.vert.begin(),last,siz); #else -if(last!=0) siz=distance(_vert->begin(),last); +if(last!=0) siz=distance(m.vert.begin(),last); #endif for(unsigned int i=0; ipush_back(VertexType()); - _vert->back().Supervisor_Flags() = 0; + m.vert.push_back(VertexType()); + m.vert.back().ClearFlags(); } - vn+=n; - newbegin = _vert->begin(); + m.vn+=n; + newbegin = m.vert.begin(); if(newbegin != oldbegin) { TetraIterator f; - for (f=_tetra->begin(); f!=_tetra->end(); ++f) + for (f=m.tetra.begin(); f!=m.tetra.end(); ++f) if(!(*f).IsD()) for(unsigned int k=0; k<4; ++k) (*f).V(k)= (*f).V(k)-&*oldbegin+&*newbegin; @@ -126,15 +115,64 @@ if(last!=0) siz=distance(_vert->begin(),last); // e poiche' lo spazio e' cambiato si ricalcola last da zero if(last!=0) { - last = _vert->begin(); + last = m.vert.begin(); advance(last,siz+1); } - else last=_vert->begin(); + else last=m.vert.begin(); } else { // se non e'cambiato lo spazio (vector abbastanza grande o lista) - if(last==0) last = _vert->begin(); // se il vettore era vuoto si restituisce begin + if(last==0) last = m.vert.begin(); // se il vettore era vuoto si restituisce begin + else advance(last,1); // altrimenti il primo dopo quello che era in precedenza l'ultimo valido. + } + return last; +} + + /** Function to add n vertices to the mesh. +@param n Il numero di vertici che si vuole aggiungere alla mesh. +*/ +VertexIterator AddVertices(TetraMeshType &m,int n) +{ + VertexIterator oldbegin, newbegin; + oldbegin = m.vert.begin(); + VertexIterator last=m.vert.end(); + if(m.vert.empty()) last=0; // if the vector is empty we cannot find the last valid element + else --last; + unsigned int siz=0; +#ifdef __STL_CONFIG_H +if(last!=0) distance(m.vert.begin(),last,siz); +#else +if(last!=0) siz=distance(m.vert.begin(),last); +#endif + for(unsigned int i=0; iFp(); - (*t).zv[j] = (*t).V(j)->Zp(); + (*t).TV(j) = (*t).V(j)->Fp(); + (*t).ZV(j) = (*t).V(j)->Zp(); (*t).V(j)->Fp() = &(*t); (*t).V(j)->Zp() = j; } @@ -218,17 +209,17 @@ void VTTopology() } /// clear the Vertex-Tetra topology - void ClearVTTopology() + void ClearVTTopology(VertexContainer &vert,TetraContainer &tetra) { - vertex_iterator v; - for(v=_vert->begin();v!=_vert->end();++v) + VertexIterator v; + for(v=vert.begin();v!=vert.end();++v) { v->Fp() = 0; v->Zp() = 0; } - tetra_iterator t; - for(t=_tetra->begin();t!=_tetra->end();++t) + TetraIterator t; + for(t=tetra.begin();t!=tetra.end();++t) for(int j=0;j<4;++j) { (*t).TV(j) = 0; @@ -303,14 +294,14 @@ void InsertVTTopology(TetraType *t) **/ //@{ ///Build the Tetrahedron-Tetrahedron Topology (by Face) -void TTTopology() +void TTTopology(VertexContainer &vert,TetraContainer &tetra) { vector > VF; VertexType* v0; VertexType* v1; VertexType* v2; - for (TetraIterator ti=_tetra->begin();ti!=_tetra->end();ti++) + for (TetraIterator ti=tetra.begin();ti!=tetra.end();ti++) { if (!(*ti).IsD()) { @@ -376,14 +367,14 @@ void TTTopology() } ///Test the Tetrahedron-Tetrahedron Topology (by Face) -void TestTTTopology() +void TestTTTopology(VertexContainer &vert,TetraContainer &tetra) { int i; - for (TetraIterator ti=_tetra->begin();ti!=_tetra->end();ti++) + for (TetraIterator ti=tetra.begin();ti!=tetra.end();ti++) { for (i=0;i<4;i++) { - if ((!(*ti).IsD())&& ((*ti).T(i)!=&(*ti))) + if ((!(*ti).IsD())&&((*ti).T(i)!=&(*ti))) { assert( ((((*ti).T(i))->T((*ti).Z(i)))==&(*ti))); @@ -394,9 +385,9 @@ void TestTTTopology() TetraType *t1=(TetraType*)(*ti).T(i); int z1=(*ti).Z(i); - VertexType *vo0=(*ti).V(Tetra4::VofF(z1,0)); - VertexType *vo1=(*ti).V(Tetra4::VofF(z1,1)); - VertexType *vo2=(*ti).V(Tetra4::VofF(z1,2)); + VertexType *vo0=(*t1).V(Tetra4::VofF(z1,0)); + VertexType *vo1=(*t1).V(Tetra4::VofF(z1,1)); + VertexType *vo2=(*t1).V(Tetra4::VofF(z1,2)); assert((v0!=v1)&&(v0!=v2)&&(v1!=v2)); assert((vo0!=vo1)&&(vo0!=vo2)&&(vo1!=vo2)); diff --git a/vcg/simplex/tetrahedron/base.h b/vcg/simplex/tetrahedron/base.h index 3e82f7d2..31ec6d4d 100644 --- a/vcg/simplex/tetrahedron/base.h +++ b/vcg/simplex/tetrahedron/base.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.2 2004/04/20 12:42:37 pietroni +*** empty log message *** + Revision 1.1 2004/04/15 08:54:20 pietroni *** empty log message *** @@ -140,20 +143,7 @@ bool HaveBorderF() {return ((_flags & (BORDERF0 | BORDERF1 | BORDERF2 | BORDERF3 /// This function return true if the face is extern. bool IsBorderF(int face) { assert ((face<4)&&(face>-1)); - switch (face) { - case 0: - {return ((_flags & BORDERF0) != 0);} - break; - case 1: - {return ((_flags & BORDERF1) != 0);} - break; - case 2: - {return ((_flags & BORDERF2) != 0);} - break; - case 3: - {return ((_flags & BORDERF3) != 0);} - break; - } + return (this->T(face) == this); } //@} @@ -166,18 +156,33 @@ For each Tetrahedron we store 4 pointers to vertex protected: VertexType *_v[4]; public: - /// The Functions to access a vertex - inline VertexType * &V(int index) - { - return _v[index]; + +/** Return the pointer to the j-th vertex of the terahedron. + @param j Index of the tetrahedron's vertex. + */ + inline VertexType * & V( const int j ) + { + assert( (_flags & DELETED) == 0 ); + assert(j >= 0); + assert(j < 4); + return _v[j]; } - /// The Functions to access a vertex - inline const VertexType * &V(int index) const - { - return _v[index]; - } - //@} + inline const VertexType * const & V( const int j ) const + { + assert( (_flags & DELETED) == 0 ); + assert(j>=0); + assert(j<4); + return _v[j]; + } + + inline const VertexType * const & cV( const int j ) const + { + assert( (_flags & DELETED) == 0 ); + assert(j>=0); + assert(j<4); + return _v[j]; + } /***********************************************/ /** @name Topology Structures @@ -216,12 +221,12 @@ public: ///Function to access the Next Tetrahedron of the list that share the index-face (end of list is Null) TETRA_TYPE *&TV(const int &index) { - return t[index]; + return _tv[index]; } ///Function to see the index of the Vertex as seen from the next tetrahedron of the list ( end of list is -1) - int &ZV(const int &index) + short int &ZV(const int &index) { - return z[index]; + return _zv[index]; } #endif //@} diff --git a/vcg/simplex/vertex/base.h b/vcg/simplex/vertex/base.h index 1d0ca74a..f0a28219 100644 --- a/vcg/simplex/vertex/base.h +++ b/vcg/simplex/vertex/base.h @@ -24,6 +24,12 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2004/04/23 14:55:06 pietroni +conversion funtion + +Revision 1.5 2004/03/10 00:59:06 cignoni +minor changes + Revision 1.4 2004/03/03 16:07:57 cignoni Yet another cr lf mismatch @@ -561,8 +567,29 @@ static bool HasVFAdjacency() { } //@} +/***********************************************/ + /** @Conversion to other vertex + **/ + //@{ +template +inline Convert( const VERT_TYPE &v ) +{ + this->P()=v->P(); + this._flags=v._flags; + if (this->HasNormal())&&(v.HasNormal()) + this->N()=v->N(); + if (this->HasColor())&&(v.HasColor()) + this->C()=v->C(); + if (this->HasMark())&&(v.HasMark()) + this.IMark()=v.IMark(); + if (this->HasQuality())&&(v.HasQuality()) + this->Q()=v->Q(); + if (this->HasTexture())&&(v.HasTexture()) + this->T()=v->T(); +} + //@} enum { // This bit indicate that the vertex is deleted from the mesh diff --git a/vcg/simplex/vertex/with/a.h b/vcg/simplex/vertex/with/a.h new file mode 100644 index 00000000..848bbbe4 --- /dev/null +++ b/vcg/simplex/vertex/with/a.h @@ -0,0 +1,23 @@ +#ifndef __VCGLIB_VERTEX__A__TYPE +#define __VCGLIB_VERTEX__A__TYPE + +#define VERTEX_TYPE VertexA + +#define __VCGLIB_VERTEX_A + +#include + +#undef VERTEX_TYPE +#undef __VCGLIB_VERTEX_A + +namespace vcg { + +template +class VertexAf : public VertexA {}; + +template +class VertexAd : public VertexA {}; + +} + +#endif