added method MergeFlatFaces (does what it says). Plus clean-ups.
This commit is contained in:
parent
45b0deb7eb
commit
240b88a582
|
@ -29,9 +29,8 @@
|
||||||
#include <vcg/simplex/face/jumping_pos.h>
|
#include <vcg/simplex/face/jumping_pos.h>
|
||||||
#include <vcg/space/planar_polygon_tessellation.h>
|
#include <vcg/space/planar_polygon_tessellation.h>
|
||||||
|
|
||||||
namespace vcg
|
namespace vcg {
|
||||||
{
|
namespace tri {
|
||||||
namespace tri{
|
|
||||||
/// \ingroup trimesh
|
/// \ingroup trimesh
|
||||||
|
|
||||||
/// \headerfile polygon_support.h vcg/complex/algorithms/polygon_support.h
|
/// \headerfile polygon_support.h vcg/complex/algorithms/polygon_support.h
|
||||||
|
@ -47,6 +46,27 @@ namespace vcg
|
||||||
template <class TriMeshType,class PolyMeshType >
|
template <class TriMeshType,class PolyMeshType >
|
||||||
struct PolygonSupport{
|
struct PolygonSupport{
|
||||||
|
|
||||||
|
/**
|
||||||
|
Given a tri mesh (with per-face normals and FF connectivity),
|
||||||
|
merges flat faces into larger polygons.
|
||||||
|
**/
|
||||||
|
static void MergeFlatFaces(TriMeshType & tm, double tolerance = 0.1E-4){
|
||||||
|
typedef typename TriMeshType::CoordType::ScalarType Scalar;
|
||||||
|
typedef typename TriMeshType::FaceIterator FaceIterator;
|
||||||
|
typedef typename TriMeshType::FaceType FaceType;
|
||||||
|
Scalar minDist = 1 - Scalar(tolerance);
|
||||||
|
for (FaceIterator fi=tm.face.begin(); fi!=tm.face.end(); fi++) {
|
||||||
|
FaceType *fa = &*fi;
|
||||||
|
for (int w=0; w<3; w++) {
|
||||||
|
FaceType *fb = fa->FFp(w);
|
||||||
|
if ( (fb>fa) && (fa->N()*fb->N() > minDist) ) {
|
||||||
|
fa->SetF( w );
|
||||||
|
fb->SetF( fa->FFi(w) ); // reciprocate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Import a trianglemesh from a polygon mesh
|
Import a trianglemesh from a polygon mesh
|
||||||
**/
|
**/
|
||||||
|
|
Loading…
Reference in New Issue