added a basic Function computing the intersection between a trimesh and a plane that does not require a spatial search structure (useful if you want to make a small number of slices)

This commit is contained in:
Paolo Cignoni 2008-08-14 10:04:01 +00:00
parent 7c66288207
commit 19b903e34b
1 changed files with 63 additions and 37 deletions

View File

@ -115,19 +115,8 @@ bool Intersect( GridType & grid,Plane3<ScalarType> plane, std::vector<typename
}
/*@}*/
/** \addtogroup complex */
/*@{*/
/**
Function computing the intersection between a trimesh and a plane. It returns an EdgeMesh.
Note: This version always returns a segment for each triangle of the mesh which intersects with the plane. In other
words there are 2*n vertices where n is the number of segments fo the mesh. You can run vcg::edge::Unify to unify
the vertices closer that a given value epsilon. Note that, due to subtraction error during triangle plane intersection,
it is not safe to put epsilon to 0.
// TODO si dovrebbe considerare la topologia face-face della trimesh per derivare quella della edge mesh..
*/
template < typename TriMeshType, typename EdgeMeshType, class ScalarType, class IndexingType >
bool Intersection( /*TriMeshType & m, */
template < typename TriMeshType, typename EdgeMeshType, class ScalarType, class IndexingType >
bool Intersection( /*TriMeshType & m, */
Plane3<ScalarType> pl,
EdgeMeshType & em,
double& ave_length,
@ -179,6 +168,43 @@ bool Intersection( /*TriMeshType & m, */
return true;
}
/** \addtogroup complex */
/*@{*/
/**
Basic Function computing the intersection between a trimesh and a plane. It returns an EdgeMesh without needing anything else.
Note: This version always returns a segment for each triangle of the mesh which intersects with the plane. In other
words there are 2*n vertices where n is the number of segments fo the mesh. You can run vcg::edge::Unify to unify
the vertices closer that a given value epsilon. Note that, due to subtraction error during triangle plane intersection,
it is not safe to put epsilon to 0.
// TODO si dovrebbe considerare la topologia face-face della trimesh per derivare quella della edge mesh..
*/
template < typename TriMeshType, typename EdgeMeshType, class ScalarType >
bool Intersection(TriMeshType & m,
Plane3<ScalarType> pl,
EdgeMeshType & em)
{
typename EdgeMeshType::VertexIterator vi;
typename TriMeshType::FaceIterator fi;
em.Clear();
Segment3<ScalarType> seg;
for(fi=m.face.begin();fi!=m.face.end();++fi)
if(!(*fi).IsD())
{
if(vcg::IntersectionPlaneTriangle(pl,*fi,seg))// intersezione piano triangolo
{
vcg::edge::Allocator<EdgeMeshType>::AddEdges(em,1);
vi = vcg::edge::Allocator<EdgeMeshType>::AddVertices(em,2);
(*vi).P() = seg.P0();
em.edges.back().V(0) = &(*vi);
vi++;
(*vi).P() = seg.P1();
em.edges.back().V(1) = &(*vi);
}
}//end for
return true;
}
/** \addtogroup complex */
/*@{*/
/**