- Fix an old and minor bug (from revisions 38635+38306 in a branch, the bug

was merged in trunk at revision 38638). The image data should be
  deallocated, now.
  Actually, that bug exists since the begin of Gray_level_image_3
  (CGAL-3.2). I thought I fixed it with revision 38306, but I failed to
  correctly fix it.

- Add the possibility to define the interior of the object by f(x)>0,
  instead of f(x)>0. That will be superseeded very soon.
This commit is contained in:
Laurent Rineau 2008-01-24 13:25:16 +00:00
parent 73dde4f8c9
commit 42f222c01c
1 changed files with 22 additions and 11 deletions

View File

@ -53,8 +53,8 @@ class Gray_level_image_3
{
#ifdef CGAL_SURFACE_MESHER_DEBUG_GRAY_LEVEL_IMAGE_3_CONSTRUCTOR
std::cerr << ::boost::format("Deletion of image %1%.\n") % image;
::_freeImage(image);
#endif
::_freeImage(image);
}
};
typedef boost::shared_ptr<_image> Image_shared_ptr;
@ -64,9 +64,9 @@ class Gray_level_image_3
float min_x, min_y, min_z;
float max_x, max_y, max_z;
bool is_valid;
bool positive_inside;
public:
Gray_level_image_3(const char* file, float isoval)
Gray_level_image_3(const char* file, float isoval, bool positive_inside_=true)
: isovalue(isoval),
min_x(0.f),
min_y(0.f),
@ -74,7 +74,8 @@ public:
max_x(0.f),
max_y(0.f),
max_z(0.f),
is_valid(false)
is_valid(false),
positive_inside(positive_inside_)
{
#ifdef CGAL_SURFACE_MESHER_DEBUG_GRAY_LEVEL_IMAGE_3_CONSTRUCTOR
std::cerr <<
@ -87,7 +88,6 @@ public:
std::cerr << ::boost::format(" = %1%\n") % image_ptr.get();
#endif
is_valid = true;
::convertImageTypeToFloat(image_ptr.get());
isovalue=isoval;
::_get_image_bounding_box(image_ptr.get(),
&min_x, &min_y, &min_z,
@ -123,13 +123,24 @@ public:
return FT(1);
else{
float value = ::triLinInterp(image_ptr.get(), X, Y, Z);
if (value > isovalue) // inside
return FT(-1);
else if (value < isovalue) // outside
return FT(1);
if (positive_inside)
{
if (value > isovalue) // inside
return FT(-1);
else if (value < isovalue) // outside
return FT(1);
else
return FT(0);
}
else
return FT(0);
{
if (value < isovalue) // inside
return FT(-1);
else if (value > isovalue) // outside
return FT(1);
else
return FT(0);
}
}
}
}; // end Gray_level_image_3