From 4a26c71e63d7dc7c53e64ef35a593098705fa871 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 14 Feb 2011 10:53:33 +0000 Subject: [PATCH] added a safety check for the feature point to be in the cell (could jump outside for numerical errors...) --- vcg/complex/trimesh/create/extended_marching_cubes.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vcg/complex/trimesh/create/extended_marching_cubes.h b/vcg/complex/trimesh/create/extended_marching_cubes.h index 70edbfbe..b48c241f 100644 --- a/vcg/complex/trimesh/create/extended_marching_cubes.h +++ b/vcg/complex/trimesh/create/extended_marching_cubes.h @@ -211,7 +211,7 @@ namespace vcg for (n=0; n create triangle fan around feature vertex @@ -289,11 +289,12 @@ namespace vcg CoordType *points = new CoordType[ vertices_num ]; CoordType *normals = new CoordType[ vertices_num ]; - + Box3 bb; for (i=0; ivert[ vertices_idx[i] ].P(); normals[i].Import(_mesh->vert[ vertices_idx[i] ].N()); + bb.Add(points[i]); } // move barycenter of points into (0, 0, 0) @@ -377,6 +378,10 @@ namespace vcg CoordType point((ScalarType) x[0], (ScalarType) x[1], (ScalarType) x[2]); point += center; + // Safety check if the feature point found by svd is + // out of the bbox of the vertices perhaps it is better to put it back in the center... + if(!bb.IsIn(point)) point = center; + // insert the feature-point VertexPointer mean_point = &*AllocatorType::AddVertices( *_mesh, 1); mean_point->SetUserBit(_featureFlag);