template<typename Kernel>
class CGAL::Polyhedron_traits_with_normals_3< Kernel >
The class Polyhedron_traits_with_normals_3
is a model of the PolyhedronTraits_3
concept. It defines the geometric types and primitive operations used in the polyhedral surface data structure Polyhedron_3<PolyhedronTraits_3>
. Polyhedron_traits_with_normals_3
uses the normal vector from Kernel
for the plane equation in facets. It keeps a local copy of the kernel which makes it suitable for kernels with local state.
- Is Model Of:
PolyhedronTraits_3
- See also
CGAL::Polyhedron_traits_3<Kernel>
Example
We use this traits class to instantiate a polyhedral surface with a normal vector and no plane equation for each facet. We compute the normal vector assuming exact arithmetic (integers in this example) and convex planar facets.
File Polyhedron/polyhedron_prog_normals.cpp
#include <CGAL/Homogeneous.h>
#include <CGAL/Polyhedron_traits_with_normals_3.h>
#include <CGAL/Polyhedron_3.h>
#include <iostream>
#include <algorithm>
struct Normal_vector {
template <class Facet>
typename Facet::Plane_3 operator()( Facet& f) {
typename Facet::Halfedge_handle h = f.halfedge();
h->next()->vertex()->point() - h->vertex()->point(),
h->next()->next()->vertex()->point() - h->next()->vertex()->point());
}
};
int main() {
Polyhedron P;
P.make_tetrahedron( p, q, r, s);
Normal_vector());
std::copy( P.planes_begin(), P.planes_end(),
std::ostream_iterator<Vector_3>( std::cout, "\n"));
return 0;
}
- Examples
- Polyhedron/polyhedron_prog_normals.cpp.