Minor Changes and Now Use STLContainer of Tetrahedron Pointers.

This commit is contained in:
Paolo Cignoni 2004-05-17 08:22:45 +00:00
parent 0ccf940115
commit 2c83cc632c
1 changed files with 21 additions and 14 deletions

View File

@ -26,6 +26,9 @@
History History
$Log: not supported by cvs2svn $ $Log: not supported by cvs2svn $
Revision 1.2 2004/05/14 15:51:47 turini
Adjusted VCG Style
Revision 1.1 2004/05/14 15:43:41 turini Revision 1.1 2004/05/14 15:43:41 turini
Initial Commit Initial Commit
@ -48,12 +51,16 @@ namespace tetra {
template <class I_TETRAMESH_TYPE> template <class I_TETRAMESH_TYPE>
struct InsertedVT struct InsertedVT
{ {
InsertedVT(I_TETRAMESH_TYPE::VertexType *_v, I_TETRAMESH_TYPE::TetraType *_t, int _z) typedef I_TETRAMESH_TYPE ITetraMeshType;
typedef typename ITetraMeshType::VertexPointer VertexPointer;
typedef typename ITetraMeshType::TetraPointer TetraPointer;
InsertedVT(VertexPointer _v, TetraPointer _t, int _z)
: v(_v), t(_t), z(_z) : v(_v), t(_t), z(_z)
{} {}
I_TETRAMESH_TYPE::VertexType *v; VertexPointer v;
I_TETRAMESH_TYPE::TetraType *t; TetraPointer t;
int z; int z;
const bool operator <(const InsertedVT & o) const bool operator <(const InsertedVT & o)
@ -75,43 +82,43 @@ struct InsertedVT
/** Create a copy of the mesh with tetrahedron that are into the templated container /** Create a copy of the mesh with tetrahedron that are into the templated container
@param ST_CONT (Template Parameter) Specifies the type of the container of tetrahedron. @param ST_CONT (Template Parameter) Specifies the type of the container of tetrahedron.
@param subSet Container of tetrahedron. @param subSet Container of tetrahedron pointers !!!
@param m destination mesh. @param m destination mesh.
*/ */
template <class S_TETRAMESH_TYPE, class STL_CONT > template <class S_TETRAMESH_TYPE, class STL_CONT >
void SubSet(TM_TYPE & m, STL_CONT & subSet, ) void SubSet(S_TETRAMESH_TYPE & m, STL_CONT & subSet)
{ {
std::vector<InsertedVT> newVertices; std::vector< InsertedVT<S_TETRAMESH_TYPE> > newVertices;
STL_CONT::iterator pfi; STL_CONT::iterator pfi;
newVertices.clear(); newVertices.clear();
for(pfi=subSet.begin(); pfi!=subSet.end(); ++pfi) for(pfi=subSet.begin(); pfi!=subSet.end(); ++pfi)
m.tetra.push_back((*pfi)); m.tetra.push_back(*(*pfi));
S_TETRAMESH_TYPE::TetraIterator fi; S_TETRAMESH_TYPE::TetraIterator fi;
for(fi=m.tetra.begin(); fi!=m.tetra.end(); ++fi) for(fi=m.tetra.begin(); fi!=m.tetra.end(); ++fi)
{ {
newVertices.push_back(InsertedVT((*fi).V(0), &(*fi), 0)); newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(0), &(*fi), 0));
newVertices.push_back(InsertedVT((*fi).V(1), &(*fi), 1)); newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(1), &(*fi), 1));
newVertices.push_back(InsertedVT((*fi).V(2), &(*fi), 2)); newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(2), &(*fi), 2));
newVertices.push_back(InsertedVT((*fi).V(3), &(*fi), 3)); newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(3), &(*fi), 3));
} }
std::sort(newVertices.begin(), newVertices.end()); std::sort(newVertices.begin(), newVertices.end());
std::vector<InsertedVT>::iterator curr,next; std::vector< InsertedVT<S_TETRAMESH_TYPE> >::iterator curr,next;
int pos=0; int pos=0;
curr=next=newVertices.begin(); curr=next=newVertices.begin();
while(next!=newVertices.end()) while(next!=newVertices.end())
{ {
if((*curr)!=(*next)) if((*curr)!=(*next))
pos++; pos++;
(*next).t->V((*next).z)=(VertexType*)pos; (*next).t->V((*next).z)=(S_TETRAMESH_TYPE::VertexPointer)pos;
curr=next; curr=next;
next++; next++;
} }
std::vector<InsertedVT >::iterator newE=std::unique(newVertices.begin(), newVertices.end()); std::vector< InsertedVT<S_TETRAMESH_TYPE> >::iterator newE=std::unique(newVertices.begin(), newVertices.end());
for(curr=newVertices.begin(); curr!=newE; ++curr) for(curr=newVertices.begin(); curr!=newE; ++curr)
m.vert.push_back(*((*curr).v)); m.vert.push_back(*((*curr).v));