Subject: CGAL users discussion list
List archive
[cgal-discuss] Using Polyhedron & Nef Polyhedron with item class does not compile.
Chronological Thread
- From: Gilles <>
- To:
- Subject: [cgal-discuss] Using Polyhedron & Nef Polyhedron with item class does not compile.
- Date: Tue, 10 Nov 2015 22:04:15 -0800 (PST)
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=None ; spf=None
- Ironport-phdr: 9a23:Mtsu/xUibNGEiOLyxTfpRq7gyOLV8LGtZVwlr6E/grcLSJyIuqrYZhCOt8tkgFKBZ4jH8fUM07OQ6PC9HzBeqsfd+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8CVP1sD1Wb1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3MVv9mHPkBVHxmaDhtpZ6jiR6WRgSG4j4QU34djwFTKwnD9hDzGJnr4QXgse8o9yieOcDtBeQ3Xzm/9LwtRzf0jz0BMCV/+2bS3J8jxJlHqQ6s8kUsi7XfZ5uYYaEmJq4=
Hello,
I slightly modify the "polyhedron_prog_vertex_normal.cpp" example, to use
Nef Polyhedron.
However, I just cannot compile. The first error message is :
/incomplete type
'CGAL::internal::Plane_constructor<CGAL::HalfedgeDS_face_base<CGAL::HalfedgeDS_list_types<CGAL::Epeck,
CGAL::I_Polyhedron_derived_items_3<My_items>, std::allocator<int> >,
CGAL::Boolean_tag<true>, CGAL::Boolean_tag<false> >::Plane_not_supported>'
used in nested name specifier
!internal::Plane_constructor<Plane>::get_plane(pe_prev->facet(),pe_prev->facet()->plane()).is_degenerate());/
^
*
Here is the code (in bold are the modifications) :*
///#include <CGAL/Simple_cartesian.h>
*#include <CGAL/Exact_predicates_exact_constructions_kernel.h>*
#include <CGAL/Polyhedron_3.h>
*#include <CGAL/Nef_polyhedron_3.h>*
#include <iostream>
#include <algorithm>
// Two functors to compute the normals: We assume the
// Simple_cartesian<double> Kernel here and use its global functions.
struct Facet_normal {
template <class Facet>
void operator()( Facet& f) {
typename Facet::Halfedge_handle h = f.halfedge();
typename Facet::Normal_3 normal = CGAL::cross_product(
h->next()->vertex()->point() - h->vertex()->point(),
h->next()->next()->vertex()->point() -
h->next()->vertex()->point());
f.normal() = normal / std::sqrt( normal * normal);
}
};
struct Vertex_normal {
template <class Vertex>
void operator()( Vertex& v) {
typename Vertex::Normal_3 normal = CGAL::NULL_VECTOR;
typedef typename Vertex::Halfedge_around_vertex_const_circulator
Circ;
Circ c = v.vertex_begin();
Circ d = c;
CGAL_For_all( c, d) {
if ( ! c->is_border())
normal = normal + c->facet()->normal();
}
v.normal() = normal / std::sqrt( normal * normal);
}
};
template <class Refs, class T, class P, class Norm>
class My_vertex : public CGAL::HalfedgeDS_vertex_base<Refs, T, P> {
Norm norm;
public:
My_vertex() {} // repeat mandatory constructors
My_vertex( const P& pt) : CGAL::HalfedgeDS_vertex_base<Refs, T, P>(pt)
{}
typedef Norm Normal_3;
Normal_3& normal() { return norm; }
const Normal_3& normal() const { return norm; }
};
template <class Refs, class T, class Norm>
class My_facet : public CGAL::HalfedgeDS_face_base<Refs, T> {
Norm norm;
public:
// no constructors to repeat, since only default constructor mandatory
typedef Norm Normal_3;
Normal_3& normal() { return norm; }
const Normal_3& normal() const { return norm; }
};
struct My_items : public CGAL::Polyhedron_items_3 {
template <class Refs, class Traits>
struct Vertex_wrapper {
typedef typename Traits::Point_3 Point;
typedef typename Traits::Vector_3 Normal;
typedef My_vertex<Refs, CGAL::Tag_true, Point, Normal> Vertex;
};
template <class Refs, class Traits>
struct Face_wrapper {
typedef typename Traits::Vector_3 Normal;
typedef My_facet<Refs, CGAL::Tag_true, Normal> Face;
};
};
// Tie all types together and a small main function using it.
//typedef CGAL::Simple_cartesian<double> Kernel;
*typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;*
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel, My_items> Polyhedron;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
int main() {
Point_3 p( 1, 0, 0);
Point_3 q( 0, 1, 0);
Point_3 r( 0, 0, 1);
Point_3 s( 0, 0, 0);
Polyhedron P;
P.make_tetrahedron( p, q, r, s);
* Nef_polyhedron N1(P);*
std::for_each( P.facets_begin(), P.facets_end(), Facet_normal());
std::for_each( P.vertices_begin(), P.vertices_end(), Vertex_normal());
CGAL::set_pretty_mode( std::cout);
for ( Vertex_iterator i = P.vertices_begin(); i != P.vertices_end();
++i)
std::cout << i->normal() << std::endl;
return 0;
}/
Can someone help me ?
Gilles
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Using-Polyhedron-Nef-Polyhedron-with-item-class-does-not-compile-tp4661327.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Using Polyhedron & Nef Polyhedron with item class does not compile., Gilles, 11/11/2015
- Re: [cgal-discuss] Polyhedron (with item class) & Nef Polyhedron does not compile., Gilles, 11/12/2015
- Re: [cgal-discuss] Polyhedron (with item class) & Nef Polyhedron does not compile., Andreas Fabri, 11/12/2015
- Re: [cgal-discuss] Polyhedron (with item class) & Nef Polyhedron does not compile., Gilles, 11/13/2015
- Re: [cgal-discuss] Polyhedron (with item class) & Nef Polyhedron does not compile., Gilles, 11/12/2015
Archive powered by MHonArc 2.6.18.