some minor comments on the code, Best regards, andreas

This commit is contained in:
Andreas Fabri 2012-06-12 14:02:15 +00:00
parent 8f38cf67e4
commit 16ce6302fb
1 changed files with 10 additions and 2 deletions

View File

@ -13,7 +13,7 @@
* +) Deciding how to generate rays in cone: for now using "polar angle" and "accept-reject (square)" and "concentric mapping" techniques * +) Deciding how to generate rays in cone: for now using "polar angle" and "accept-reject (square)" and "concentric mapping" techniques
*/ */
//AF: just remove the next 3 lines
//#include "Expectation_maximization.h" //#include "Expectation_maximization.h"
//#include "K_means_clustering.h" //#include "K_means_clustering.h"
//#include "Timer.h" //#include "Timer.h"
@ -21,6 +21,7 @@
#include <CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h> #include <CGAL/internal/Surface_mesh_segmentation/Expectation_maximization.h>
#include <CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h> #include <CGAL/internal/Surface_mesh_segmentation/K_means_clustering.h>
//AF: This files does not use Simple_cartesian
#include <CGAL/Simple_cartesian.h> #include <CGAL/Simple_cartesian.h>
#include <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
@ -36,6 +37,7 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
//AF: macros must be prefixed with "CGAL_"
#define LOG_5 1.60943791 #define LOG_5 1.60943791
#define NORMALIZATION_ALPHA 4.0 #define NORMALIZATION_ALPHA 4.0
#define ANGLE_ST_DEV_DIVIDER 3.0 #define ANGLE_ST_DEV_DIVIDER 3.0
@ -192,8 +194,10 @@ inline double
Surface_mesh_segmentation<Polyhedron>::calculate_sdf_value_of_facet( Surface_mesh_segmentation<Polyhedron>::calculate_sdf_value_of_facet(
const Facet_handle& facet, const Tree& tree) const const Facet_handle& facet, const Tree& tree) const
{ {
// AF: Use const Point&
Point p1 = facet->halfedge()->vertex()->point(); Point p1 = facet->halfedge()->vertex()->point();
Point p2 = facet->halfedge()->next()->vertex()->point(); Point p2 = facet->halfedge()->next()->vertex()->point();
//AF: Use previous instead of next()->next()
Point p3 = facet->halfedge()->next()->next()->vertex()->point(); Point p3 = facet->halfedge()->next()->next()->vertex()->point();
Point center = CGAL::centroid(p1, p2, p3); Point center = CGAL::centroid(p1, p2, p3);
Vector normal = CGAL::unit_normal(p1, p2, Vector normal = CGAL::unit_normal(p1, p2,
@ -255,6 +259,8 @@ Surface_mesh_segmentation<Polyhedron>::cast_and_return_minimum(
} }
Point i_point; Point i_point;
//AF: Use object_cast as it is faster than assign
if(!CGAL::assign(i_point, object)) { if(!CGAL::assign(i_point, object)) {
continue; //What to do here (in case of intersection object is a segment), I am not sure ??? continue; //What to do here (in case of intersection object is a segment), I am not sure ???
} }
@ -376,6 +382,7 @@ Surface_mesh_segmentation<Polyhedron>::calculate_sdf_value_from_rays(
for(std::vector<double>::iterator dist_it = ray_distances.begin(); for(std::vector<double>::iterator dist_it = ray_distances.begin();
dist_it != ray_distances.end(); dist_it != ray_distances.end();
++dist_it, ++w_it) { ++dist_it, ++w_it) {
// AF: replace fabs with CGAL::abs
if(fabs((*dist_it) - median_sdf) > st_dev) { if(fabs((*dist_it) - median_sdf) > st_dev) {
continue; continue;
} }
@ -761,6 +768,7 @@ Surface_mesh_segmentation<Polyhedron>::apply_GMM_fitting_with_K_means_init()
} }
} }
//AF: it is not common in CGAL to have functions with a file name as argument
template <class Polyhedron> template <class Polyhedron>
inline void Surface_mesh_segmentation<Polyhedron>::write_sdf_values( inline void Surface_mesh_segmentation<Polyhedron>::write_sdf_values(
const char* file_name) const char* file_name)
@ -813,4 +821,4 @@ inline void Surface_mesh_segmentation<Polyhedron>::read_center_ids(
#ifdef SEG_DEBUG #ifdef SEG_DEBUG
#undef SEG_DEBUG #undef SEG_DEBUG
#endif #endif
#endif //CGAL_SURFACE_MESH_SEGMENTATION_H #endif //CGAL_SURFACE_MESH_SEGMENTATION_H