CGAL 6.2 - 3D Polyhedral Surface: CGAL::Polyhedron_traits_with_normals_3< Kernel > Class Template Reference

CGAL 6.2 - 3D Polyhedral Surface

Loading...
Searching...
No Matches
List of all members
CGAL::Polyhedron_traits_with_normals_3< Kernel > Class Template Reference
Reference Manual

`#include <CGAL/Polyhedron_traits_with_normals_3.h>`

## Definition

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.

Example: Polyhedron/polyhedron_prog_normals.cpp

Show / Hide
#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();
// Facet::Plane_3 is the normal vector type. We assume the
// CGAL Kernel here and use its global functions.
return CGAL::cross_product(
h->next()->vertex()->point() - h->vertex()->point(),
h->next()->next()->vertex()->point() - h->next()->vertex()->point());
}
};
typedef CGAL::Homogeneous<int> Kernel;
typedef Kernel::Point_3 Point_3;
typedef Kernel::Vector_3 Vector_3;
typedef CGAL::Polyhedron_traits_with_normals_3<Kernel> Traits;
typedef CGAL::Polyhedron_3<Traits> Polyhedron;
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);
std::transform( P.facets_begin(), P.facets_end(), P.planes_begin(),
Normal_vector());
CGAL::IO::set_pretty_mode( std::cout);
std::copy( P.planes_begin(), P.planes_end(),
std::ostream_iterator<Vector_3>( std::cout, "\n"));
return 0;
}
CGAL::Polyhedron_3
A polyhedral surface Polyhedron_3 consists of vertices V, edges E, facets F and an incidence relation...
Definition: Polyhedron_3.h:113
CGAL::Polyhedron_traits_with_normals_3
The class Polyhedron_traits_with_normals_3 is a model of the PolyhedronTraits_3 concept.
Definition: Polyhedron_traits_with_normals_3.h:30
CGAL::Polyhedron_traits_with_normals_3::Kernel
unspecified_type Kernel
the Kernel model.
Definition: Polyhedron_traits_with_normals_3.h:39
CGAL::Polyhedron_traits_with_normals_3::Point_3
Kernel::Point_3 Point_3
Definition: Polyhedron_traits_with_normals_3.h:44
Kernel::Point_3
Kernel::Vector_3
CGAL::IO::set_pretty_mode
Mode set_pretty_mode(std::ios &s)
CGAL::cross_product
CGAL::Vector_3< Kernel > cross_product(const CGAL::Vector_3< Kernel > &u, const CGAL::Vector_3< Kernel > &v)
CGAL::Homogeneous

Examples
  Polyhedron/polyhedron_prog_normals.cpp.

## Types
typedef unspecified_type | Kernel
| the `Kernel` model.
typedef Kernel::Point_3 | Point_3
typedef Kernel::Vector_3 | Plane_3
typedef Kernel::Construct_opposite_vector_3 | Construct_opposite_plane_3

## Creation
| Polyhedron_traits_with_normals_3 ()
| default constructor, uses `Kernel()` as local reference to the kernel.
| Polyhedron_traits_with_normals_3 (const Kernel &kernel)
| stores `kernel` as local reference.

## Operations
Construct_opposite_plane_3 | construct_opposite_plane_3_object ()
| forwarded to `kernel`.