Skip to content

Commit

Permalink
demo algorithm instance member
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudev committed Aug 15, 2017
1 parent 9b030fa commit d71e777
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 40 deletions.
Expand Up @@ -68,28 +68,6 @@ struct PointProxyFitting {
const FacetAreaMap area_pmap;
};

Scene::Scene() :
m_fidx_pmap(m_fidx_map),
m_normal_pmap(m_facet_normals),
m_center_pmap(m_facet_centers),
m_area_pmap(m_facet_areas)
{
m_pmesh = NULL;

// view options
m_view_polyhedron = false;
m_view_wireframe = false;
m_view_seg_boundary = false;
m_view_anchors = false;

m_px_num = 0;
}

Scene::~Scene()
{
delete m_pmesh;
}

void Scene::update_bbox()
{
if(m_pmesh == NULL) {
Expand Down Expand Up @@ -202,31 +180,30 @@ void Scene::l21_approximation(
m_anchor_pos.clear();
m_anchor_vtx.clear();

VSAL21 vsa_l21(L21Metric(m_normal_pmap, m_area_pmap), L21ProxyFitting(m_normal_pmap, m_area_pmap));
vsa_l21.set_mesh(*m_pmesh);
m_vsa_l21.set_mesh(*m_pmesh);

if (static_cast<VSAL21::Initialization>(init) == VSAL21::IncrementalInit) {
// for comparision
vsa_l21.init_proxies(num_proxies / 2, VSAL21::RandomInit);
m_vsa_l21.init_proxies(num_proxies / 2, VSAL21::RandomInit);
for (std::size_t i = 0; i < num_iterations; ++i)
vsa_l21.run_one_step();
vsa_l21.add_proxies(VSAL21::IncrementalInit, num_proxies - num_proxies / 2, num_iterations);
m_vsa_l21.run_one_step();
m_vsa_l21.add_proxies(VSAL21::IncrementalInit, num_proxies - num_proxies / 2, num_iterations);
for (std::size_t i = 0; i < num_iterations; ++i)
vsa_l21.run_one_step();
m_vsa_l21.run_one_step();
}
else {
vsa_l21.init_proxies(num_proxies, static_cast<VSAL21::Initialization>(init));
m_vsa_l21.init_proxies(num_proxies, static_cast<VSAL21::Initialization>(init));
for (std::size_t i = 0; i < num_iterations; ++i)
vsa_l21.run_one_step();
m_vsa_l21.run_one_step();
}

Polyhedron_3 out_mesh;
vsa_l21.meshing(out_mesh);
vsa_l21.get_proxy_map(m_fidx_pmap);
m_tris = vsa_l21.get_indexed_triangles();
m_anchor_pos = vsa_l21.get_anchor_points();
m_anchor_vtx = vsa_l21.get_anchor_vertices();
m_bdrs = vsa_l21.get_indexed_boundary_polygons();
m_vsa_l21.meshing(out_mesh);
m_vsa_l21.get_proxy_map(m_fidx_pmap);
m_tris = m_vsa_l21.get_indexed_triangles();
m_anchor_pos = m_vsa_l21.get_anchor_points();
m_anchor_vtx = m_vsa_l21.get_anchor_vertices();
m_bdrs = m_vsa_l21.get_indexed_boundary_polygons();

m_px_num = num_proxies;
m_view_seg_boundary = true;
Expand Down
19 changes: 17 additions & 2 deletions Surface_mesh_approximation/demo/Surface_mesh_approximation/Scene.h
Expand Up @@ -44,8 +44,20 @@ typedef CGAL::VSA_approximation<Polyhedron_3, PCAPlaneFitting, L21Metric, L2Prox
class Scene
{
public:
Scene();
~Scene();
Scene() :
m_pmesh(NULL),
m_fidx_pmap(m_fidx_map),
m_normal_pmap(m_facet_normals),
m_center_pmap(m_facet_centers),
m_area_pmap(m_facet_areas),
m_vsa_l21(L21Metric(m_normal_pmap, m_area_pmap), L21ProxyFitting(m_normal_pmap, m_area_pmap)),
m_px_num(0),
m_view_polyhedron(false),
m_view_wireframe(false),
m_view_seg_boundary(false),
m_view_anchors(false) {}

~Scene() { delete m_pmesh; }

void update_bbox();
Bbox_3 bbox() { return m_bbox; }
Expand Down Expand Up @@ -113,6 +125,9 @@ class Scene
FacetAreaMap m_area_pmap;
VertexPointMap m_point_pmap;

// algorithm instance
VSAL21 m_vsa_l21;

std::vector<Point_3> m_anchor_pos;
std::vector<Polyhedron_3::Vertex_handle> m_anchor_vtx;
std::vector<std::vector<std::size_t> > m_bdrs; // anchor borders
Expand Down
4 changes: 2 additions & 2 deletions Surface_mesh_approximation/include/CGAL/VSA_approximation.h
Expand Up @@ -122,10 +122,10 @@ class VSA_approximation {
boost::associative_property_map<std::map<face_descriptor, std::size_t> > seg_pmap;

// The error metric.
const ErrorMetric &fit_error;
const ErrorMetric fit_error;

// The proxy fitting functor.
const ProxyFitting &proxy_fitting;
const ProxyFitting proxy_fitting;

/**************** Mesh Extraction *******************/

Expand Down

0 comments on commit d71e777

Please sign in to comment.