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)
 computes a point location from barycentric coordinates with respect to a triangle mesh.
 
template<typename PointRange , typename CoordinateRange , typename GeomTraits = typename boost::range_value<PointRange>::type>
boost::range_value< PointRange >::type CGAL::Barycentric_coordinates::apply_barycentric_coordinates (const PointRange &points, const CoordinateRange &coordinates)
 computes a point location from barycentric coordinates with respect to a set of points.
 
template<typename TriangleMesh , typename OutputIterator , typename GeomTraits , typename VertexPointMap >
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 (const TriangleMesh &tmesh, const typename GeomTraits::Point_3 &query, OutputIterator oi, const GeomTraits &traits, const VertexPointMap vertex_point_map)
 computes boundary barycentric coordinates with respect to a closed convex triangle mesh.
 
template<typename TriangleMesh , typename Point_3 , typename OutputIterator , typename VertexPointMap = typename boost::property_map<TriangleMesh, CGAL::vertex_point_t>::const_type>
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 (const TriangleMesh &tmesh, const Point_3 &query, OutputIterator oi, const VertexPointMap vertex_point_map)
 computes boundary barycentric coordinates with respect to a closed convex triangle mesh.
 
template<typename Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::discrete_harmonic_coordinates_3 (const TriangleMesh &tmesh, const Point_3 &query, OutputIterator oi, const Computation_policy_3 policy=Computation_policy_3::FAST)
 computes 3D discrete harmonic coordinates with respect to a closed convex triangle mesh.
 
template<typename Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::mean_value_coordinates_3 (const TriangleMesh &tmesh, const Point_3 &query, OutputIterator oi, const Computation_policy_3 policy=Computation_policy_3::FAST_WITH_EDGE_CASES)
 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 Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::wachspress_coordinates_3 (const TriangleMesh &tmesh, const Point_3 &query, OutputIterator oi, const Computation_policy_3 policy=Computation_policy_3::FAST)
 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 boost::range_value<PointRange>::type>
boost::range_value< PointRange >::type CGAL::Barycentric_coordinates::apply_barycentric_coordinates ( const PointRange &  points,
const CoordinateRange &  coordinates 
)

#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
Parameters
pointsa range of input points
coordinatesbarycentric coordinates of the point
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 
)

#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
Parameters
tmeshan instance of TriangleMesh
coordinatesbarycentric coordinates of the point
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() [1/2]

template<typename TriangleMesh , typename Point_3 , typename OutputIterator , typename VertexPointMap = typename boost::property_map<TriangleMesh, CGAL::vertex_point_t>::const_type>
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 ( const TriangleMesh &  tmesh,
const Point_3 query,
OutputIterator  oi,
const VertexPointMap  vertex_point_map 
)

#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 one, while all other coordinates are zero. If query is on the face, the three corresponding coordinates are triangle coordinates, while all other coordinates are set to zero. If query is not on the boundary, all the coordinates are set to zero.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph.
Point_3a model of Kernel::Point_3
OutputIteratora model of OutputIterator that accepts values of type GeomTraits::FT
VertexPointMapa property map with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and Point_3 as value type. The default is property_map_selector<TriangleMesh, CGAL::vertex_point_t>.
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
vertex_point_mapan instance of VertexPointMap that maps a vertex from tmesh to Point_3; the default initialization is provided
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
Precondition
boost::num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh)
CGAL::is_closed(tmesh).
CGAL::is_strongly_convex_3(tmesh).

◆ boundary_coordinates_3() [2/2]

template<typename TriangleMesh , typename OutputIterator , typename GeomTraits , typename VertexPointMap >
std::pair< OutputIterator, bool > CGAL::Barycentric_coordinates::boundary_coordinates_3 ( const TriangleMesh &  tmesh,
const typename GeomTraits::Point_3 &  query,
OutputIterator  oi,
const GeomTraits &  traits,
const VertexPointMap  vertex_point_map 
)

#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 convex simplicial 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 one, while all other coordinates are zero. If query is on the face, the three corresponding coordinates are triangle coordinates, while all other coordinates are set to zero. If query is not on the boundary, all the coordinates are set to zero.

Template Parameters
TriangleMeshmust be a model of the concept FaceListGraph.
GeomTraitsa model of BarycentricTraits_3
OutputIteratora model of OutputIterator that accepts values of type GeomTraits::FT
VertexPointMapa property map with boost::graph_traits<TriangleMesh>::vertex_descriptor as key type and GeomTraits::Point_3 as value type
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
traitsa traits class with geometric objects, predicates, and constructions; the default initialization is provided
vertex_point_mapan instance of VertexPointMap that maps a vertex from tmesh to Point_3; the default initialization is provided
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
Precondition
boost::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 Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::discrete_harmonic_coordinates_3 ( const TriangleMesh &  tmesh,
const Point_3 query,
OutputIterator  oi,
const Computation_policy_3  policy = Computation_policy_3::FAST 
)

#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
Point_3A model of Kernel::Point_3
TriangleMeshmust be a model of the concept FaceListGraph
OutputIteratora model of OutputIterator that accepts values of type GeomTraits::FT
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
policyone of the CGAL::Barycentric_coordinates::Computation_policy_3; the default is Computation_policy_3::FAST_WITH_EDGE_CASES
Returns
an output iterator to the element in the destination range, one past the last coordinate stored
Precondition
boost::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 Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::mean_value_coordinates_3 ( const TriangleMesh &  tmesh,
const Point_3 query,
OutputIterator  oi,
const Computation_policy_3  policy = Computation_policy_3::FAST_WITH_EDGE_CASES 
)

#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 a polyhedron with triangular faces, 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
Point_3A model of Kernel::Point_3
TriangleMeshmust be a model of the concept FaceListGraph
OutputIteratora model of OutputIterator that accepts values of type Kernel_traits<Point_3>::Kernel::FT
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
policyone of the CGAL::Barycentric_coordinates::Computation_policy_3; the default is Computation_policy_3::FAST_WITH_EDGE_CASES
Returns
an output iterator to the element in the destination range, one past the last coordinates stored
Precondition
boost::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 Point_3 , typename TriangleMesh , typename OutputIterator >
OutputIterator CGAL::Barycentric_coordinates::wachspress_coordinates_3 ( const TriangleMesh &  tmesh,
const Point_3 query,
OutputIterator  oi,
const Computation_policy_3  policy = Computation_policy_3::FAST 
)

#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 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 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
Point_3A model of Kernel::Point_3
TriangleMeshmust be a model of the concept FaceListGraph
OutputIteratora model of OutputIterator that accepts values of type GeomTraits::FT
Parameters
tmeshan instance of TriangleMesh
querya query point
oithe beginning of the destination range with the computed coordinates
policyone of the CGAL::Barycentric_coordinates::Computation_policy_3; the default is Computation_policy_3::FAST_WITH_EDGE_CASES
Returns
an output iterator to the element in the destination range, one past the last coordinate stored
Precondition
boost::num_vertices(tmesh) >= 4.
CGAL::is_triangle_mesh(tmesh).
CGAL::is_closed(tmesh).
CGAL::is_strongly_convex_3(tmesh).