*** empty log message ***

This commit is contained in:
Nico Pietroni 2004-04-26 09:40:15 +00:00
parent 00de9443f0
commit adeca3e96f
8 changed files with 223 additions and 99 deletions

View File

@ -1,7 +1,32 @@
#include <simplex\vertex\with\cn.h> #include <simplex\vertex\with\a.h>
#include <simplex\tetrahedron\base.h> #include <simplex\tetrahedron\with\avq.h>
#include <simplex\face\with\fa.h>
#include <complex\tetramesh\base.h>
#include <complex\tetramesh\update\topology.h>
#include <complex\tetramesh\update\allocate.h>
#include<vector>
#include<complex\tetramesh\update\triconvert.h>
#include<complex\trimesh\base.h>
using namespace vcg; using namespace vcg;
using namespace tetra;
using namespace tri;
#include<apps\test\tetramesh\test\myclasses.h>
int main( int argc, char **argv ) int main( int argc, char **argv )
{ {
MyMesh tm=MyMesh();
UpdateTopology<vector<MyVertex>,vector<MyTetrahedron> > ut= UpdateTopology<vector<MyVertex>,vector<MyTetrahedron> >();
Allocator<MyMesh> All= Allocator<MyMesh>();
vector<MyVertex **> local_var=vector<MyVertex **>();
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 <MyMesh,MyTriMesh>tric=TriConverter<MyMesh,MyTriMesh>();
tric.Convert(tm,mesh);
} }

Binary file not shown.

View File

@ -110,12 +110,27 @@
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc"> Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="..\..\..\..\vcg\complex\tetramesh\update\allocate.h">
</File>
<File <File
RelativePath="..\..\..\..\vcg\simplex\tetrahedron\base.h"> RelativePath="..\..\..\..\vcg\simplex\tetrahedron\base.h">
</File> </File>
<File
RelativePath="..\..\..\..\vcg\complex\tetramesh\base.h">
</File>
<File
RelativePath="myclasses.h">
</File>
<File <File
RelativePath="..\..\..\..\vcg\space\tetra4.h"> RelativePath="..\..\..\..\vcg\space\tetra4.h">
</File> </File>
<File
RelativePath="..\..\..\..\vcg\complex\tetramesh\update\topology.h">
</File>
<File
RelativePath="..\..\..\..\vcg\complex\tetramesh\update\triconvert.h">
</File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"

View File

@ -39,51 +39,40 @@ namespace tetra {
/** Class Allocate. /** Class Allocate.
This is class for Allocate new vertices or tetrahedron on the mesh. This is class for Allocate new vertices or tetrahedron on the mesh.
@param STL_VERT_CONT (Template Parameter) Specifies the type of the vertices container any the vertex type. @param TM_TYPE (Template Parameter) Specifies the type of the tetrahedral mesh.
@param STL_TETRA_CONT (Template Parameter) Specifies the type of the tetrahedrons container any the tetrahedrons type.
*/ */
template < class STL_VERT_CONT ,class STL_TETRA_CONT >
class Allocate template < class TM_TYPE >
class Allocator
{ {
public: public:
/// The vertex container /// The tetramesh type
typedef STL_VERT_CONT VertexContainer; typedef TM_TYPE TetraMeshType;
/// The tethaedhron container
typedef STL_TETRA_CONT TetraContainer;
/// The vertex type /// The vertex type
typedef typename STL_VERT_CONT::value_type VertexType; typedef typename TM_TYPE::VertexType VertexType;
/// The tetrahedron type /// The tetrahedron type
typedef typename STL_TETRA_CONT::value_type TetraType; typedef typename TM_TYPE::TetraType TetraType;
/// The type of vertex iterator /// The type of vertex iterator
typedef typename STL_VERT_CONT::iterator VertexIterator; typedef typename TM_TYPE::VertexIterator VertexIterator;
/// The type of tetra iterator /// The type of tetra iterator
typedef typename STL_TETRA_CONT::iterator TetraIterator; typedef typename TM_TYPE::TetraIterator TetraIterator;
/// The type of constant vertex iterator /// 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 /// 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: 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 /** 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 pointers to pointer to elements of the mesh that should be updated after a
possible vector realloc. possible vector realloc.
@ -92,30 +81,30 @@ possible vector realloc.
restituisce l'iteratore al primo elemento aggiunto. restituisce l'iteratore al primo elemento aggiunto.
*/ */
VertexIterator AddVertices(int n, vector<VertexType **> &local_var) VertexIterator AddVertices(TetraMeshType &m,int n, vector<VertexType **> &local_var)
{ {
VertexIterator oldbegin, newbegin; VertexIterator oldbegin, newbegin;
oldbegin = _vert->begin(); oldbegin = m.vert.begin();
VertexIterator last=_vert->end(); VertexIterator last=m.vert.end();
if(_vert->empty()) last=0; // if the vector is empty we cannot find the last valid element if(m.vert.empty()) last=0; // if the vector is empty we cannot find the last valid element
else --last; else --last;
unsigned int siz=0; unsigned int siz=0;
#ifdef __STL_CONFIG_H #ifdef __STL_CONFIG_H
if(last!=0) distance(_vert->begin(),last,siz); if(last!=0) distance(m.vert.begin(),last,siz);
#else #else
if(last!=0) siz=distance(_vert->begin(),last); if(last!=0) siz=distance(m.vert.begin(),last);
#endif #endif
for(unsigned int i=0; i<n; ++i) for(unsigned int i=0; i<n; ++i)
{ {
_vert->push_back(VertexType()); m.vert.push_back(VertexType());
_vert->back().Supervisor_Flags() = 0; m.vert.back().ClearFlags();
} }
vn+=n; m.vn+=n;
newbegin = _vert->begin(); newbegin = m.vert.begin();
if(newbegin != oldbegin) if(newbegin != oldbegin)
{ {
TetraIterator f; TetraIterator f;
for (f=_tetra->begin(); f!=_tetra->end(); ++f) for (f=m.tetra.begin(); f!=m.tetra.end(); ++f)
if(!(*f).IsD()) if(!(*f).IsD())
for(unsigned int k=0; k<4; ++k) for(unsigned int k=0; k<4; ++k)
(*f).V(k)= (*f).V(k)-&*oldbegin+&*newbegin; (*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 // e poiche' lo spazio e' cambiato si ricalcola last da zero
if(last!=0) if(last!=0)
{ {
last = _vert->begin(); last = m.vert.begin();
advance(last,siz+1); advance(last,siz+1);
} }
else last=_vert->begin(); else last=m.vert.begin();
} }
else else
{ {
// se non e'cambiato lo spazio (vector abbastanza grande o lista) // 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; i<n; ++i)
{
m.vert.push_back(VertexType());
m.vert.back().ClearFlags();
}
m.vn+=n;
newbegin = m.vert.begin();
if(newbegin != oldbegin)
{
TetraIterator 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;
// deve restituire l'iteratore alla prima faccia aggiunta;
// e poiche' lo spazio e' cambiato si ricalcola last da zero
if(last!=0)
{
last = m.vert.begin();
advance(last,siz+1);
}
else last=m.vert.begin();
}
else
{
// se non e'cambiato lo spazio (vector abbastanza grande o lista)
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. else advance(last,1); // altrimenti il primo dopo quello che era in precedenza l'ultimo valido.
} }
return last; return last;

View File

@ -181,36 +181,27 @@ public:
/// The type of constant face iterator /// The type of constant face iterator
typedef typename STL_TETRA_CONT::const_iterator const_TetraIterator; typedef typename STL_TETRA_CONT::const_iterator const_TetraIterator;
private:
VertexContainer* _vert;
TetraContainer* _tetra;
public: public:
///defaul constructor
UpdateTopology(VertexContainer *v,TetraContainer *t)
{
_vert=v;
_tetra=t;
}
/***********************************************/ /***********************************************/
/** @Vertex-Tetrahedron Topology Funtions /** @Vertex-Tetrahedron Topology Funtions
**/ **/
//@{ //@{
///create the VT topology for tetrahedrons that are into containers ///create the VT topology for tetrahedrons that are into containers
void VTTopology() void VTTopology(VertexContainer &vert,TetraContainer &tetra)
{ {
vertex_iterator v; VertexIterator v;
tetra_iterator t; TetraIterator t;
ClearVTTopology(); ClearVTTopology(vert,tetra);
for(t=_tetra.begin();t!=_tetra.end();++t) for(t=tetra.begin();t!=tetra.end();++t)
if( ! (*t).IsD()) if( ! (*t).IsD())
for(int j=0;j<4;++j) for(int j=0;j<4;++j)
{ {
(*t).tv[j] = (*t).V(j)->Fp(); (*t).TV(j) = (*t).V(j)->Fp();
(*t).zv[j] = (*t).V(j)->Zp(); (*t).ZV(j) = (*t).V(j)->Zp();
(*t).V(j)->Fp() = &(*t); (*t).V(j)->Fp() = &(*t);
(*t).V(j)->Zp() = j; (*t).V(j)->Zp() = j;
} }
@ -218,17 +209,17 @@ void VTTopology()
} }
/// clear the Vertex-Tetra topology /// clear the Vertex-Tetra topology
void ClearVTTopology() void ClearVTTopology(VertexContainer &vert,TetraContainer &tetra)
{ {
vertex_iterator v; VertexIterator v;
for(v=_vert->begin();v!=_vert->end();++v) for(v=vert.begin();v!=vert.end();++v)
{ {
v->Fp() = 0; v->Fp() = 0;
v->Zp() = 0; v->Zp() = 0;
} }
tetra_iterator t; TetraIterator t;
for(t=_tetra->begin();t!=_tetra->end();++t) for(t=tetra.begin();t!=tetra.end();++t)
for(int j=0;j<4;++j) for(int j=0;j<4;++j)
{ {
(*t).TV(j) = 0; (*t).TV(j) = 0;
@ -303,14 +294,14 @@ void InsertVTTopology(TetraType *t)
**/ **/
//@{ //@{
///Build the Tetrahedron-Tetrahedron Topology (by Face) ///Build the Tetrahedron-Tetrahedron Topology (by Face)
void TTTopology() void TTTopology(VertexContainer &vert,TetraContainer &tetra)
{ {
vector <Facet<VertexType,TetraType> > VF; vector <Facet<VertexType,TetraType> > VF;
VertexType* v0; VertexType* v0;
VertexType* v1; VertexType* v1;
VertexType* v2; VertexType* v2;
for (TetraIterator ti=_tetra->begin();ti!=_tetra->end();ti++) for (TetraIterator ti=tetra.begin();ti!=tetra.end();ti++)
{ {
if (!(*ti).IsD()) if (!(*ti).IsD())
{ {
@ -376,14 +367,14 @@ void TTTopology()
} }
///Test the Tetrahedron-Tetrahedron Topology (by Face) ///Test the Tetrahedron-Tetrahedron Topology (by Face)
void TestTTTopology() void TestTTTopology(VertexContainer &vert,TetraContainer &tetra)
{ {
int i; 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++) 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))); assert( ((((*ti).T(i))->T((*ti).Z(i)))==&(*ti)));
@ -394,9 +385,9 @@ void TestTTTopology()
TetraType *t1=(TetraType*)(*ti).T(i); TetraType *t1=(TetraType*)(*ti).T(i);
int z1=(*ti).Z(i); int z1=(*ti).Z(i);
VertexType *vo0=(*ti).V(Tetra4<double>::VofF(z1,0)); VertexType *vo0=(*t1).V(Tetra4<double>::VofF(z1,0));
VertexType *vo1=(*ti).V(Tetra4<double>::VofF(z1,1)); VertexType *vo1=(*t1).V(Tetra4<double>::VofF(z1,1));
VertexType *vo2=(*ti).V(Tetra4<double>::VofF(z1,2)); VertexType *vo2=(*t1).V(Tetra4<double>::VofF(z1,2));
assert((v0!=v1)&&(v0!=v2)&&(v1!=v2)); assert((v0!=v1)&&(v0!=v2)&&(v1!=v2));
assert((vo0!=vo1)&&(vo0!=vo2)&&(vo1!=vo2)); assert((vo0!=vo1)&&(vo0!=vo2)&&(vo1!=vo2));

View File

@ -24,6 +24,9 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.1 2004/04/15 08:54:20 pietroni
*** empty log message *** *** empty log message ***
@ -140,20 +143,7 @@ bool HaveBorderF() {return ((_flags & (BORDERF0 | BORDERF1 | BORDERF2 | BORDERF3
/// This function return true if the face is extern. /// This function return true if the face is extern.
bool IsBorderF(int face) { bool IsBorderF(int face) {
assert ((face<4)&&(face>-1)); assert ((face<4)&&(face>-1));
switch (face) { return (this->T(face) == this);
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;
}
} }
//@} //@}
@ -166,18 +156,33 @@ For each Tetrahedron we store 4 pointers to vertex
protected: protected:
VertexType *_v[4]; VertexType *_v[4];
public: public:
/// The Functions to access a vertex
inline VertexType * &V(int index) /** Return the pointer to the j-th vertex of the terahedron.
{ @param j Index of the tetrahedron's vertex.
return _v[index]; */
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 /** @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) ///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) 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) ///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 #endif
//@} //@}

View File

@ -24,6 +24,12 @@
History History
$Log: not supported by cvs2svn $ $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 Revision 1.4 2004/03/03 16:07:57 cignoni
Yet another cr lf mismatch Yet another cr lf mismatch
@ -561,8 +567,29 @@ static bool HasVFAdjacency() {
} }
//@} //@}
/***********************************************/
/** @Conversion to other vertex
**/
//@{
template <class VERT_TYPE>
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 { enum {
// This bit indicate that the vertex is deleted from the mesh // This bit indicate that the vertex is deleted from the mesh

View File

@ -0,0 +1,23 @@
#ifndef __VCGLIB_VERTEX__A__TYPE
#define __VCGLIB_VERTEX__A__TYPE
#define VERTEX_TYPE VertexA
#define __VCGLIB_VERTEX_A
#include <vcg/simplex/vertex/base.h>
#undef VERTEX_TYPE
#undef __VCGLIB_VERTEX_A
namespace vcg {
template <class VFTYPE>
class VertexAf : public VertexA<float,VFTYPE> {};
template <class VFTYPE>
class VertexAd : public VertexA<double,VFTYPE> {};
}
#endif