From 7a1cc6ac852df40b22c6bff8963e3aee281ef3b1 Mon Sep 17 00:00:00 2001 From: Laurent Saboret Date: Thu, 5 Jun 2008 17:03:34 +0000 Subject: [PATCH] Update to main copy in demo/poisson --- .../include/enriched_polyhedron.h | 230 +++++++++--------- 1 file changed, 116 insertions(+), 114 deletions(-) diff --git a/Surface_reconstruction_3/test/Surface_reconstruction_3/include/enriched_polyhedron.h b/Surface_reconstruction_3/test/Surface_reconstruction_3/include/enriched_polyhedron.h index 4b0eb287d8c..02d75a302f8 100644 --- a/Surface_reconstruction_3/test/Surface_reconstruction_3/include/enriched_polyhedron.h +++ b/Surface_reconstruction_3/test/Surface_reconstruction_3/include/enriched_polyhedron.h @@ -4,8 +4,8 @@ // // /////////////////////////////////////////////////////////////////////////// -#ifndef _POLYGON_MESH_ -#define _POLYGON_MESH_ +#ifndef _POLYGON_MESH_ +#define _POLYGON_MESH_ // CGAL #include @@ -18,146 +18,148 @@ struct Vertex_normal; struct Facet_normal; + // a refined facet with a normal -template -class Enriched_facet : public CGAL::HalfedgeDS_face_base +template +class Enriched_facet : public CGAL::HalfedgeDS_face_base { // normal Norm m_normal; public: - // life cycle + // life cycle Enriched_facet() { } // normal - typedef Norm Normal_3; - Normal_3& normal() { return m_normal; } - const Normal_3& normal() const { return m_normal; } + typedef Norm Normal_3; + Normal_3& normal() { return m_normal; } + const Normal_3& normal() const { return m_normal; } }; + // a refined halfedge with a general tag -template -class Enriched_halfedge : public CGAL::HalfedgeDS_halfedge_base +template +class Enriched_halfedge : public CGAL::HalfedgeDS_halfedge_base { private: public: - // life cycle + // life cycle Enriched_halfedge() { } }; - -// a refined vertex with a normal and a tag -template -class Enriched_vertex : public CGAL::HalfedgeDS_vertex_base +// a refined vertex with a normal, tag and camera +template +class Enriched_vertex : public CGAL::HalfedgeDS_vertex_base { // normal Norm m_normal; public: - // life cycle - Enriched_vertex() {} - // repeat mandatory constructors - Enriched_vertex(const P& pt) - : CGAL::HalfedgeDS_vertex_base(pt) + // life cycle + Enriched_vertex() {} + // repeat mandatory constructors + Enriched_vertex(const Point_3_& pt) + : CGAL::HalfedgeDS_vertex_base(pt) { } // normal - typedef Norm Normal_3; - Normal_3& normal() { return m_normal; } - const Normal_3& normal() const { return m_normal; } + typedef Norm Normal_3; + Normal_3& normal() { return m_normal; } + const Normal_3& normal() const { return m_normal; } }; // A redefined items class for the Polyhedron_3 -// with a refined vertex class that contains a -// member for the normal vector and a refined -// facet with a normal vector instead of the -// plane equation (this is an alternative -// solution instead of using +// with a refined vertex class that contains a +// member for the normal vector and a refined +// facet with a normal vector instead of the +// plane equation (this is an alternative +// solution instead of using // Polyhedron_traits_with_normals_3). -struct Enriched_items : public CGAL::Polyhedron_items_3 +struct Enriched_items : public CGAL::Polyhedron_items_3 { - // wrap vertex - template - struct Vertex_wrapper - { - typedef typename Traits::Point_3 Point; - typedef typename Traits::Vector_3 Normal; - typedef Enriched_vertex Vertex; - }; + // wrap vertex + template + struct Vertex_wrapper + { + typedef typename Traits::Point_3 Point; + typedef typename Traits::Vector_3 Normal; + typedef Enriched_vertex Vertex; + }; - // wrap face - template - struct Face_wrapper - { - typedef typename Traits::Point_3 Point; - typedef typename Traits::Vector_3 Normal; - typedef Enriched_facet Face; - }; + // wrap face + template + struct Face_wrapper + { + typedef typename Traits::Point_3 Point; + typedef typename Traits::Vector_3 Normal; + typedef Enriched_facet Face; + }; - // wrap halfedge - template - struct Halfedge_wrapper - { - typedef typename Traits::Vector_3 Normal; - typedef Enriched_halfedge Halfedge; - }; + // wrap halfedge + template + struct Halfedge_wrapper + { + typedef typename Traits::Vector_3 Normal; + typedef Enriched_halfedge Halfedge; + }; }; // Enriched polyhedron -template -class Enriched_polyhedron - : public CGAL::Polyhedron_3 +template +class Enriched_polyhedron + : public CGAL::Polyhedron_3 { -// Private types + // Private types private: - typedef CGAL::Polyhedron_3 Base; + typedef CGAL::Polyhedron_3 Base; -// Public types + // Public types public: - typedef typename PolyhedronTraits_3::FT FT; - typedef typename PolyhedronTraits_3::Point_3 Point; + typedef typename PolyhedronTraits_3::FT FT; + typedef typename PolyhedronTraits_3::Point_3 Point; // Repeat Polyhedron_3 public types - typedef typename Base::HalfedgeDS HalfedgeDS; - typedef typename Base::Vertex Vertex; - typedef typename Base::Halfedge Halfedge; - typedef typename Base::Facet Facet; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Vertex_const_handle Vertex_const_handle; - typedef typename Base::Halfedge_handle Halfedge_handle; - typedef typename Base::Halfedge_const_handle Halfedge_const_handle; - typedef typename Base::Facet_handle Facet_handle; - typedef typename Base::Facet_const_handle Facet_const_handle; - typedef typename Base::Vertex_iterator Vertex_iterator; - typedef typename Base::Vertex_const_iterator Vertex_const_iterator; - typedef typename Base::Halfedge_iterator Halfedge_iterator; - typedef typename Base::Halfedge_const_iterator Halfedge_const_iterator; - typedef typename Base::Facet_iterator Facet_iterator; - typedef typename Base::Facet_const_iterator Facet_const_iterator; - typedef typename Base::Point_iterator Point_iterator; - typedef typename Base::Point_const_iterator Point_const_iterator; + typedef typename Base::HalfedgeDS HalfedgeDS; + typedef typename Base::Vertex Vertex; + typedef typename Base::Halfedge Halfedge; + typedef typename Base::Facet Facet; + typedef typename Base::Vertex_handle Vertex_handle; + typedef typename Base::Vertex_const_handle Vertex_const_handle; + typedef typename Base::Halfedge_handle Halfedge_handle; + typedef typename Base::Halfedge_const_handle Halfedge_const_handle; + typedef typename Base::Facet_handle Facet_handle; + typedef typename Base::Facet_const_handle Facet_const_handle; + typedef typename Base::Vertex_iterator Vertex_iterator; + typedef typename Base::Vertex_const_iterator Vertex_const_iterator; + typedef typename Base::Halfedge_iterator Halfedge_iterator; + typedef typename Base::Halfedge_const_iterator Halfedge_const_iterator; + typedef typename Base::Facet_iterator Facet_iterator; + typedef typename Base::Facet_const_iterator Facet_const_iterator; + typedef typename Base::Point_iterator Point_iterator; + typedef typename Base::Point_const_iterator Point_const_iterator; typedef typename Base::Halfedge_around_facet_circulator Halfedge_around_facet_circulator; typedef typename Base::Halfedge_around_facet_const_circulator Halfedge_around_facet_const_circulator; typedef typename Base::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator; @@ -175,7 +177,7 @@ public : Base::vertices_begin; Base::vertices_end; - // Compute normals using mesh connectivity (per facet, then per vertex) + // Compute normals using mesh connectivity (per facet, then per vertex) void compute_normals_per_facet() { std::for_each(facets_begin(),facets_end(),Facet_normal()); @@ -194,24 +196,24 @@ public : // compute facet normal (functor) struct Facet_normal { - template + template void operator()(Facet& f) { typename Facet::Normal_3 sum = CGAL::NULL_VECTOR; typename Facet::Halfedge_around_facet_circulator h = f.facet_begin(); do { - typename Facet::Normal_3 normal = CGAL::cross_product( + typename Facet::Normal_3 normal = CGAL::cross_product( h->next()->vertex()->point() - h->vertex()->point(), h->next()->next()->vertex()->point() - h->next()->vertex()->point()); - double sqnorm = normal * normal; - if(sqnorm != 0) - normal = normal / (double)std::sqrt(sqnorm); - sum = sum + normal; + double sqnorm = normal * normal; + if(sqnorm != 0) + normal = normal / (double)std::sqrt(sqnorm); + sum = sum + normal; } - while(++h != f.facet_begin()); + while(++h != f.facet_begin()); double sqnorm = sum * sum; - if(sqnorm != 0.0) + if(sqnorm != 0.0) f.normal() = sum / std::sqrt(sqnorm); else { @@ -222,25 +224,25 @@ struct Facet_normal }; -// compute vertex normal (functor) +// compute vertex normal (functor) struct Vertex_normal { - template - void operator()(Vertex& v) - { - typename Vertex::Normal_3 normal = CGAL::NULL_VECTOR; - typename Vertex::Halfedge_around_vertex_const_circulator pHalfedge = v.vertex_begin(); - typename Vertex::Halfedge_around_vertex_const_circulator begin = pHalfedge; - CGAL_For_all(pHalfedge,begin) - if(!pHalfedge->is_border()) - normal = normal + pHalfedge->facet()->normal(); - double sqnorm = normal * normal; - if(sqnorm != 0.0f) - v.normal() = normal / (float)std::sqrt(sqnorm); - else - v.normal() = CGAL::NULL_VECTOR; - } + template + void operator()(Vertex& v) + { + typename Vertex::Normal_3 normal = CGAL::NULL_VECTOR; + typename Vertex::Halfedge_around_vertex_const_circulator pHalfedge = v.vertex_begin(); + typename Vertex::Halfedge_around_vertex_const_circulator begin = pHalfedge; + CGAL_For_all(pHalfedge,begin) + if(!pHalfedge->is_border()) + normal = normal + pHalfedge->facet()->normal(); + double sqnorm = normal * normal; + if(sqnorm != 0.0f) + v.normal() = normal / (float)std::sqrt(sqnorm); + else + v.normal() = CGAL::NULL_VECTOR; + } }; -#endif // _POLYGON_MESH_ +#endif // _POLYGON_MESH_