CGAL 6.2 - 3D Generalized Barycentric Coordinates
Loading...
Searching...
No Matches

Free functions to compute barycentric coordinates.

Functions

template<typename TriangleMesh , typename CoordinateRange , typename VertexPointMap , typename GeomTraits = typename CGAL::Kernel_traits<typename boost::property_traits<VertexPointMap>::value_type>::type>
boost::property_traits< VertexPointMap >::value_type CGAL::Barycentric_coordinates::apply_barycentric_coordinates (const TriangleMesh &tmesh, const CoordinateRange &coordinates, VertexPointMap vpm, GeomTraits geom_traits=GeomTraits())
 computes a point location from barycentric coordinates with respect to a triangle mesh.
 
template<typename PointRange , typename CoordinateRange , typename GeomTraits = typename Kernel_traits<typename boost::range_value<PointRange>::type>::Kernel>
boost::range_value< PointRange >::type CGAL::Barycentric_coordinates::apply_barycentric_coordinates (const PointRange &points, const CoordinateRange &coordinates, GeomTraits geom_traits=GeomTraits())
 computes a point location from barycentric coordinates with respect to a set of points.
 
template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 (const TriangleMesh &tmesh, const Point &query, OutputIterator oi, const NamedParameters &np=parameters::default_values())
 computes boundary barycentric coordinates with respect to a closed convex triangle mesh.
 
template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::discrete_harmonic_coordinates_3 (const TriangleMesh &tmesh, const Point &query, OutputIterator oi, const NamedParameters &np=parameters::default_values())
 computes 3D discrete harmonic coordinates with respect to a closed convex triangle mesh.
 
template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::mean_value_coordinates_3 (const TriangleMesh &tmesh, const Point &query, OutputIterator oi, const NamedParameters &np=parameters::default_values())
 computes 3D mean value barycentric coordinates with respect to a closed triangle mesh.
 
template<typename OutputIterator , typename GeomTraits >
OutputIterator CGAL::Barycentric_coordinates::tetrahedron_coordinates (const typename GeomTraits::Point_3 &p0, const typename GeomTraits::Point_3 &p1, const typename GeomTraits::Point_3 &p2, const typename GeomTraits::Point_3 &p3, const typename GeomTraits::Point_3 &query, OutputIterator oi, const GeomTraits &traits)
 computes barycentric coordinates with respect to a tetrahedron.
 
template<typename GeomTraits >
std::array< typename GeomTraits::FT, 4 > CGAL::Barycentric_coordinates::tetrahedron_coordinates (const typename GeomTraits::Point_3 &p0, const typename GeomTraits::Point_3 &p1, const typename GeomTraits::Point_3 &p2, const typename GeomTraits::Point_3 &p3, const typename GeomTraits::Point_3 &query, const GeomTraits &traits)
 computes barycentric coordinates with respect to a tetrahedron.
 
template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::wachspress_coordinates_3 (const TriangleMesh &tmesh, const Point query, OutputIterator oi, const NamedParameters &np=parameters::default_values())
 computes 3D Wachspress coordinates with respect to a closed convex triangle mesh.
 

Function Documentation

◆ apply_barycentric_coordinates() [1/2]

template<typename PointRange , typename CoordinateRange , typename GeomTraits = typename Kernel_traits<typename boost::range_value<PointRange>::type>::Kernel>
boost::range_value< PointRange >::type CGAL::Barycentric_coordinates::apply_barycentric_coordinates ( const PointRange &  points,
const CoordinateRange &  coordinates,
GeomTraits  geom_traits = GeomTraits() 
)

#include <CGAL/Barycentric_coordinates_3.h>

computes a point location from barycentric coordinates with respect to a set of points.

This function a computes point location from barycentric coordinates with respect to a set of points.

Template Parameters
PointRangeis a model of ConstRange and RandomAccessRange with value type GeomTraits::Point_3
CoordinateRangea range whose iterator is a model of ForwardIterator with value type GeomTraits::FT
GeomTraitsa model of BarycentricTraits_3, deduced from the value type of PointRange by default.
Parameters
pointsa range of input points
coordinatesbarycentric coordinates of the point
geom_traitsan instance of GeomTraits
Returns
point with type GeomTraits::Point_3
Precondition
pts.size() == coords.size()

◆ apply_barycentric_coordinates() [2/2]

template<typename TriangleMesh , typename CoordinateRange , typename VertexPointMap , typename GeomTraits = typename CGAL::Kernel_traits<typename boost::property_traits<VertexPointMap>::value_type>::type>
boost::property_traits< VertexPointMap >::value_type CGAL::Barycentric_coordinates::apply_barycentric_coordinates ( const TriangleMesh &  tmesh,
const CoordinateRange &  coordinates,
VertexPointMap  vpm,
GeomTraits  geom_traits = GeomTraits() 
)

#include <CGAL/Barycentric_coordinates_3.h>

computes a point location from barycentric coordinates with respect to a triangle mesh.

This function computes a point location from barycentric coordinates with respect to the vertices of tmesh

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph
CoordinateRangea range whose iterator is a model of ForwardIterator with value type GeomTraits::FT
VertexPointMapa property map with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and GeomTraits::Point_3 as value type.
GeomTraitsa model of BarycentricTraits_3, deduced from the value type of VertexPointMap, using CGAL::Kernel_traits.
Parameters
tmeshan instance of TriangleMesh
coordinatesbarycentric coordinates of the point
geom_traitsan instance of GeomTraits
vpman instance of VertexPointMap that maps a vertex from tmesh to GeomTraits::Point_3
Returns
point with type boost::property_traits<VertexPointMap>::value_type
Precondition
vertices(tmesh).size() == coords.size()
Examples
Barycentric_coordinates_3/shape_deformation_3.cpp.

◆ boundary_coordinates_3()

template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 ( const TriangleMesh &  tmesh,
const Point &  query,
OutputIterator  oi,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Barycentric_coordinates_3/boundary_coordinates_3.h>

computes boundary barycentric coordinates with respect to a closed convex triangle mesh.

This function computes boundary barycentric coordinates at a given query point with respect to the vertices of a simple polyhedron, that is one coordinate per vertex. The coordinates are stored in a destination range beginning at oi.

If query is at the vertex, the corresponding coordinate is set to 1, while all other coordinates are 0. If query is on the face, the three corresponding coordinates are triangle coordinates, while all other coordinates are set to 0. If query is not on the boundary, all the coordinates are set to 0.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph.
PointA model of GeomTraits::Point_3 with GeomTraits being the type of the named parameter geom_traits.
OutputIteratormust be an output iterator accepting GeomTraits::FT with GeomTraits being the type of the named parameter geom_traits.
NamedParametersa sequence of Named Parameters
Parameters
tmeshan instance of TriangleMesh, which must be a convex simplicial polyhedron
querya query point
oithe beginning of the destination range with the computed coordinates
npan optional sequence of Named Parameters among the ones listed below
Returns
an output iterator to the element in the destination range, one past the last coordinate stored + the flag indicating whether the query point belongs to the polyhedron boundary
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.
  • an instance of a geometric traits class
  • Type: a class model of BarycentricTraits_3
  • Default: a CGAL Kernel deduced from the value type of the vertex-point map, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
Precondition
num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh)
CGAL::is_closed(tmesh).
CGAL::is_strongly_convex_3(tmesh).

◆ discrete_harmonic_coordinates_3()

template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::discrete_harmonic_coordinates_3 ( const TriangleMesh &  tmesh,
const Point &  query,
OutputIterator  oi,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Barycentric_coordinates_3/Discrete_harmonic_coordinates_3.h>

computes 3D discrete harmonic coordinates with respect to a closed convex triangle mesh.

This function computes 3D discrete harmonic coordinates at a given query point with respect to the vertices of a convex polyhedron with triangular faces, that is one coordinate per vertex. The coordinates are stored in a destination range beginning at oi.

Internally, the class Discrete_harmonic_coordinates_3 is used. If one wants to process multiple query points, it is better to use that class. When using the free function, internal memory is allocated for each query point, while when using the class, it is allocated only once, which is much more efficient. However, for a few query points, it is easier to use this function. It can also be used when the processing time is not a concern.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph
PointA model of GeomTraits::Point_3 with GeomTraits being the type of the named parameter geom_traits.
OutputIteratormust be an output iterator accepting GeomTraits::FT with GeomTraits being the type of the named parameter geom_traits.
NamedParametersa sequence of Named Parameters
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
npan optional sequence of Named Parameters among the ones listed below
Returns
an output iterator to the element in the destination range, one past the last coordinate stored
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.
  • an instance of a geometric traits class
  • Type: a class model of BarycentricTraits_3
  • Default: a CGAL Kernel deduced from the value type of the vertex-point map, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
Precondition
num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh).
CGAL::is_closed(tmesh).
CGAL::is_strongly_convex_3(tmesh).
Examples
Barycentric_coordinates_3/discrete_harmonic_coordinates_3.cpp.

◆ mean_value_coordinates_3()

template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::mean_value_coordinates_3 ( const TriangleMesh &  tmesh,
const Point &  query,
OutputIterator  oi,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Barycentric_coordinates_3/Mean_value_coordinates_3.h>

computes 3D mean value barycentric coordinates with respect to a closed triangle mesh.

This function computes 3D mean value coordinates at a given query point with respect to the vertices of tmesh, that is one weight per vertex. The coordinates are stored in a destination range beginning at oi.

Internally, the class Mean_value_coordinates_3 is used. If one wants to process multiple query points, it is better to use that class. When using the free function, internal memory is allocated for each query point, while when using the class, it is allocated only once, which is much more efficient. However, for a few query points, it is easier to use this function. It can also be used when the processing time is not a concern.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph
PointA model of GeomTraits::Point_3 with GeomTraits being the type of the named parameter geom_traits.
OutputIteratormust be an output iterator accepting GeomTraits::FT with GeomTraits being the type of the named parameter geom_traits.
NamedParametersa sequence of Named Parameters
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
npan optional sequence of Named Parameters among the ones listed below
Returns
an output iterator to the element in the destination range, one past the last coordinates stored
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.
  • an instance of a geometric traits class
  • Type: a class model of BarycentricTraits_3
  • Default: a CGAL Kernel deduced from the value type of the vertex-point map, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
Precondition
num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh)
CGAL::is_closed(tmesh).
Examples
Barycentric_coordinates_3/mean_value_coordinates_3.cpp.

◆ tetrahedron_coordinates() [1/2]

template<typename GeomTraits >
std::array< typename GeomTraits::FT, 4 > CGAL::Barycentric_coordinates::tetrahedron_coordinates ( const typename GeomTraits::Point_3 &  p0,
const typename GeomTraits::Point_3 &  p1,
const typename GeomTraits::Point_3 &  p2,
const typename GeomTraits::Point_3 &  p3,
const typename GeomTraits::Point_3 &  query,
const GeomTraits &  traits 
)

#include <CGAL/Barycentric_coordinates_3/tetrahedron_coordinates.h>

computes barycentric coordinates with respect to a tetrahedron.

This function computes barycentric coordinates at a given query point with respect to the points p0, p1, p2, and p3, which form a tetrahedron, that is one coordinate per point. The coordinates are returned in an array.

After the coordinates \(b_0\), \(b_1\), \(b_2\), and \(b_3\) are computed, the query point \(q\) can be obtained as \(q = b_0p_0 + b_1p_1 + b_2p_2 + b_3p_3\).

Template Parameters
GeomTraitsa model of BarycentricTraits_3
Parameters
p0the first vertex of a tetrahedron
p1the second vertex of a tetrahedron
p2the third vertex of a tetrahedron
p3the fourth vertex of a tetrahedron
querya query point
traitsa traits class with geometric objects, predicates, and constructions; this parameter can be omitted if the traits class can be deduced from the point type
Returns
an array std::array<GeomTraits::FT, 4> with the computed coordinates
Precondition
traits.compute_volume_3_object()(p0, p1, p2, p3) != 0

◆ tetrahedron_coordinates() [2/2]

template<typename OutputIterator , typename GeomTraits >
OutputIterator CGAL::Barycentric_coordinates::tetrahedron_coordinates ( const typename GeomTraits::Point_3 &  p0,
const typename GeomTraits::Point_3 &  p1,
const typename GeomTraits::Point_3 &  p2,
const typename GeomTraits::Point_3 &  p3,
const typename GeomTraits::Point_3 &  query,
OutputIterator  oi,
const GeomTraits &  traits 
)

#include <CGAL/Barycentric_coordinates_3/tetrahedron_coordinates.h>

computes barycentric coordinates with respect to a tetrahedron.

This function computes barycentric coordinates at a given query point with respect to the points p0, p1, p2, and p3, which form a tetrahedron, that is one coordinate per point. The coordinates are stored in a destination range beginning at oi.

After the coordinates \(b_0\), \(b_1\), \(b_2\), and \(b_2\) are computed, the query point \(q\) can be obtained as \(q = b_0p_0 + b_1p_1 + b_2p_2 + b_3p_3\).

Template Parameters
OutputIteratora model of OutputIterator that accepts values of type GeomTraits::FT
GeomTraitsa model of BarycentricTraits_3
Parameters
p0the first vertex of a tetrahedron
p1the second vertex of a tetrahedron
p2the third vertex of a tetrahedron
p3the fourth vertex of a tetrahedron
querya query point
oithe beginning of the destination range with the computed coordinates
traitsa traits class with geometric objects, predicates, and constructions; this parameter can be omitted if the traits class can be deduced from the point type
Returns
an output iterator to the element in the destination range, one past the last coordinate stored
Precondition
traits.compute_volume_3_object()(p0, p1, p2, p3) != 0
Examples
Barycentric_coordinates_3/tetrahedron_coordinates.cpp.

◆ wachspress_coordinates_3()

template<typename TriangleMesh , typename Point , typename OutputIterator , typename NamedParameters = parameters::Default_named_parameters>
OutputIterator CGAL::Barycentric_coordinates::wachspress_coordinates_3 ( const TriangleMesh &  tmesh,
const Point  query,
OutputIterator  oi,
const NamedParameters &  np = parameters::default_values() 
)

#include <CGAL/Barycentric_coordinates_3/Wachspress_coordinates_3.h>

computes 3D Wachspress coordinates with respect to a closed convex triangle mesh.

This function computes 3D Wachspress coordinates at a given query point with respect to the vertices of tmesh, that is one coordinate per vertex. The coordinates are stored in a destination range beginning at oi.

Internally, the class Wachspress_coordinates_3 is used. If one wants to process multiple query points, it is better to use that class. When using the free function, internal memory is allocated for each query point, while when using the class, it is allocated only once, which is much more efficient. However, for a few query points, it is easier to use this function. It can also be used when the processing time is not a concern.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph
PointA model of GeomTraits::Point_3 with GeomTraits being the type of the named parameter geom_traits.
OutputIteratormust be an output iterator accepting GeomTraits::FT with GeomTraits being the type of the named parameter geom_traits.
NamedParametersa sequence of Named Parameters
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
npan optional sequence of Named Parameters among the ones listed below
Returns
an output iterator to the element in the destination range, one past the last coordinate stored
Optional Named Parameters
  • a property map associating points to the vertices of tmesh
  • Type: a class model of ReadablePropertyMap with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point as value type
  • Default: boost::get(CGAL::vertex_point, tmesh)
  • Extra: If this parameter is omitted, an internal property map for CGAL::vertex_point_t must be available in TriangleMesh.
  • an instance of a geometric traits class
  • Type: a class model of BarycentricTraits_3
  • Default: a CGAL Kernel deduced from the value type of the vertex-point map, using CGAL::Kernel_traits
  • Extra: The geometric traits class must be compatible with the vertex point type.
Precondition
num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh).
CGAL::is_closed(tmesh).
CGAL::is_strongly_convex_3(tmesh).