2004-05-14 17:43:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2007-11-20 10:50:32 +01:00
|
|
|
Revision 1.4 2005/02/08 14:36:20 turini
|
|
|
|
Warnings Correction
|
|
|
|
|
2005-02-08 15:38:05 +01:00
|
|
|
Revision 1.3 2004/05/17 08:22:45 turini
|
|
|
|
Minor Changes and Now Use STLContainer of Tetrahedron Pointers.
|
|
|
|
|
2004-05-17 10:22:45 +02:00
|
|
|
Revision 1.2 2004/05/14 15:51:47 turini
|
|
|
|
Adjusted VCG Style
|
|
|
|
|
2004-05-14 17:51:47 +02:00
|
|
|
Revision 1.1 2004/05/14 15:43:41 turini
|
|
|
|
Initial Commit
|
|
|
|
|
2004-05-14 17:43:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __VCGLIB_TETRASUBSET
|
|
|
|
#define __VCGLIB_TETRASUBSET
|
|
|
|
|
|
|
|
|
|
|
|
namespace vcg {
|
|
|
|
namespace tetra {
|
|
|
|
|
|
|
|
/** \addtogroup tetramesh */
|
|
|
|
/*@{*/
|
|
|
|
|
|
|
|
|
|
|
|
template <class I_TETRAMESH_TYPE>
|
|
|
|
struct InsertedVT
|
|
|
|
{
|
2004-05-17 10:22:45 +02:00
|
|
|
typedef I_TETRAMESH_TYPE ITetraMeshType;
|
|
|
|
typedef typename ITetraMeshType::VertexPointer VertexPointer;
|
|
|
|
typedef typename ITetraMeshType::TetraPointer TetraPointer;
|
|
|
|
|
|
|
|
InsertedVT(VertexPointer _v, TetraPointer _t, int _z)
|
2004-05-14 17:43:41 +02:00
|
|
|
: v(_v), t(_t), z(_z)
|
|
|
|
{}
|
|
|
|
|
2004-05-17 10:22:45 +02:00
|
|
|
VertexPointer v;
|
|
|
|
TetraPointer t;
|
2004-05-14 17:43:41 +02:00
|
|
|
int z;
|
|
|
|
|
|
|
|
const bool operator <(const InsertedVT & o)
|
|
|
|
{
|
|
|
|
return (v<o.v);
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool operator ==(const InsertedVT & o)
|
|
|
|
{
|
|
|
|
return (v==o.v);
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool operator !=(const InsertedVT & o)
|
|
|
|
{
|
|
|
|
return (v!=o.v);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** 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.
|
2004-05-17 10:22:45 +02:00
|
|
|
@param subSet Container of tetrahedron pointers !!!
|
2004-05-14 17:43:41 +02:00
|
|
|
@param m destination mesh.
|
|
|
|
*/
|
|
|
|
template <class S_TETRAMESH_TYPE, class STL_CONT >
|
2004-05-17 10:22:45 +02:00
|
|
|
void SubSet(S_TETRAMESH_TYPE & m, STL_CONT & subSet)
|
2004-05-14 17:43:41 +02:00
|
|
|
{
|
2004-05-17 10:22:45 +02:00
|
|
|
std::vector< InsertedVT<S_TETRAMESH_TYPE> > newVertices;
|
2007-11-20 10:50:32 +01:00
|
|
|
typename STL_CONT::iterator pfi;
|
2004-05-14 17:43:41 +02:00
|
|
|
newVertices.clear();
|
|
|
|
|
|
|
|
for(pfi=subSet.begin(); pfi!=subSet.end(); ++pfi)
|
2004-05-17 10:22:45 +02:00
|
|
|
m.tetra.push_back(*(*pfi));
|
2004-05-14 17:43:41 +02:00
|
|
|
|
2007-11-20 10:50:32 +01:00
|
|
|
typename S_TETRAMESH_TYPE::TetraIterator fi;
|
2004-05-14 17:43:41 +02:00
|
|
|
for(fi=m.tetra.begin(); fi!=m.tetra.end(); ++fi)
|
|
|
|
{
|
2004-05-17 10:22:45 +02:00
|
|
|
newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(0), &(*fi), 0));
|
|
|
|
newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(1), &(*fi), 1));
|
|
|
|
newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(2), &(*fi), 2));
|
|
|
|
newVertices.push_back(InsertedVT<S_TETRAMESH_TYPE>((*fi).V(3), &(*fi), 3));
|
2004-05-14 17:43:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::sort(newVertices.begin(), newVertices.end());
|
|
|
|
|
2007-11-20 10:50:32 +01:00
|
|
|
typename std::vector< InsertedVT<S_TETRAMESH_TYPE> >::iterator curr,next;
|
2004-05-14 17:43:41 +02:00
|
|
|
int pos=0;
|
|
|
|
curr=next=newVertices.begin();
|
|
|
|
while(next!=newVertices.end())
|
|
|
|
{
|
|
|
|
if((*curr)!=(*next))
|
|
|
|
pos++;
|
2007-11-20 10:50:32 +01:00
|
|
|
(*next).t->V((*next).z)=(typename S_TETRAMESH_TYPE::VertexPointer)pos;
|
2004-05-14 17:43:41 +02:00
|
|
|
curr=next;
|
|
|
|
next++;
|
|
|
|
}
|
|
|
|
|
2007-11-20 10:50:32 +01:00
|
|
|
typename std::vector< InsertedVT<S_TETRAMESH_TYPE> >::iterator newE=std::unique(newVertices.begin(), newVertices.end());
|
2004-05-14 17:43:41 +02:00
|
|
|
|
|
|
|
for(curr=newVertices.begin(); curr!=newE; ++curr)
|
|
|
|
m.vert.push_back(*((*curr).v));
|
|
|
|
|
|
|
|
for(fi=m.tetra.begin(); fi!=m.tetra.end(); ++fi)
|
|
|
|
{
|
|
|
|
(*fi).V(0)=&(m.vert[(int)(*fi).V(0)]);
|
|
|
|
(*fi).V(1)=&(m.vert[(int)(*fi).V(1)]);
|
|
|
|
(*fi).V(2)=&(m.vert[(int)(*fi).V(2)]);
|
|
|
|
(*fi).V(3)=&(m.vert[(int)(*fi).V(3)]);
|
|
|
|
}
|
2005-02-08 15:38:05 +01:00
|
|
|
m.vn=(int)m.vert.size();
|
|
|
|
m.tn=(int)m.tetra.size();
|
2004-05-14 17:43:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*@}*/
|
|
|
|
} // End namespace
|
|
|
|
} // End namespace
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|