mirror of https://github.com/CGAL/cgal
use a named parameter for choosing inward or outward orientation
This commit is contained in:
parent
a49f50c8aa
commit
4b1430ca07
|
|
@ -367,6 +367,14 @@ and perturbation is not deterministic
|
|||
\b Default is that this variable is not set
|
||||
\cgalNPEnd
|
||||
|
||||
|
||||
\cgalNPBegin{outward_orientation} \anchor PMP_outward_orientation
|
||||
Parameter used in orientation functions to choose between an outward or inward orientation.
|
||||
\n
|
||||
\b Type : `bool` \n
|
||||
\b Default value is `true`
|
||||
\cgalNPEnd
|
||||
|
||||
\cgalNPTableEnd
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ CGAL_add_named_parameter(number_of_points_per_edge_t, number_of_points_per_edge,
|
|||
CGAL_add_named_parameter(number_of_points_on_edges_t, number_of_points_on_edges, number_of_points_on_edges)
|
||||
CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, number_of_points_per_area_unit)
|
||||
CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit)
|
||||
CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation)
|
||||
|
||||
//to be documented
|
||||
CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map)
|
||||
|
|
|
|||
|
|
@ -439,8 +439,6 @@ void recursive_orient_volume_ccs( TriangleMesh& tm,
|
|||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tm a closed triangulated surface mesh
|
||||
* @param orient_outward `true` indicates that each connected component will be outward oriented,
|
||||
* (inward oriented if `false`). Default value is true.
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
|
|
@ -452,10 +450,14 @@ void recursive_orient_volume_ccs( TriangleMesh& tm,
|
|||
* \cgalParamBegin{face_index_map}
|
||||
* a property map containing the index of each face of `tm`.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{outward_orientation}
|
||||
* if set to `true` (default) indicates that each connected component will be outward oriented,
|
||||
* (inward oriented if `false`).
|
||||
* \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*/
|
||||
template<class TriangleMesh, class NamedParameters>
|
||||
void orient(TriangleMesh& tm, bool orient_outward, const NamedParameters& np)
|
||||
void orient(TriangleMesh& tm, const NamedParameters& np)
|
||||
{
|
||||
typedef boost::graph_traits<TriangleMesh> Graph_traits;
|
||||
typedef typename Graph_traits::vertex_descriptor vertex_descriptor;
|
||||
|
|
@ -473,6 +475,9 @@ void orient(TriangleMesh& tm, bool orient_outward, const NamedParameters& np)
|
|||
using boost::choose_param;
|
||||
using boost::get_param;
|
||||
|
||||
bool orient_outward = choose_param(
|
||||
get_param(np, internal_np::outward_orientation),true);
|
||||
|
||||
Vpm vpm = choose_param(get_param(np, internal_np::vertex_point),
|
||||
get_const_property_map(boost::vertex_point, tm));
|
||||
|
||||
|
|
@ -521,16 +526,10 @@ void orient(TriangleMesh& tm, bool orient_outward, const NamedParameters& np)
|
|||
}
|
||||
}
|
||||
|
||||
template<class TriangleMesh>
|
||||
void orient(TriangleMesh& tm, bool orient_outward)
|
||||
{
|
||||
orient(tm, orient_outward, parameters::all_default());
|
||||
}
|
||||
|
||||
template<class TriangleMesh>
|
||||
void orient(TriangleMesh& tm)
|
||||
{
|
||||
orient(tm, true, parameters::all_default());
|
||||
orient(tm, parameters::all_default());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -545,9 +544,6 @@ void orient(TriangleMesh& tm)
|
|||
* @tparam NamedParameters a sequence of \ref namedparameters
|
||||
*
|
||||
* @param tm a closed triangulated surface mesh
|
||||
* @param orient_outward if `true` the outer connected components will be outward oriented (inward oriented if `false`).
|
||||
* If the outer connected components are inward oriented, it means that the infinity will be considered
|
||||
* as part of the volume bounded by `tm`. Default value is `true`.
|
||||
* @param np optional sequence of \ref namedparameters among the ones listed below
|
||||
*
|
||||
* \cgalNamedParamsBegin
|
||||
|
|
@ -559,13 +555,17 @@ void orient(TriangleMesh& tm)
|
|||
* \cgalParamBegin{face_index_map}
|
||||
* a property map containing the index of each face of `tm`.
|
||||
* \cgalParamEnd
|
||||
* \cgalParamBegin{outward_orientation}
|
||||
* if set to `true` (default) the outer connected components will be outward oriented (inward oriented if set to `false`).
|
||||
* If the outer connected components are inward oriented, it means that the infinity will be considered
|
||||
* as part of the volume bounded by `tm`.
|
||||
* \cgalParamEnd
|
||||
* \cgalNamedParamsEnd
|
||||
*
|
||||
* \see `CGAL::Polygon_mesh_processing::does_bound_a_volume()`
|
||||
*/
|
||||
template <class TriangleMesh, class NamedParameters>
|
||||
void orient_to_bound_a_volume(TriangleMesh& tm,
|
||||
const bool orient_outward,
|
||||
const NamedParameters& np)
|
||||
{
|
||||
typedef boost::graph_traits<TriangleMesh> Graph_traits;
|
||||
|
|
@ -582,6 +582,9 @@ void orient_to_bound_a_volume(TriangleMesh& tm,
|
|||
using boost::choose_param;
|
||||
using boost::get_param;
|
||||
|
||||
bool orient_outward = choose_param(
|
||||
get_param(np, internal_np::outward_orientation),true);
|
||||
|
||||
Vpm vpm = choose_param(get_param(np, internal_np::vertex_point),
|
||||
get_const_property_map(boost::vertex_point, tm));
|
||||
|
||||
|
|
@ -635,16 +638,10 @@ void orient_to_bound_a_volume(TriangleMesh& tm,
|
|||
is_parent_outward_oriented);
|
||||
}
|
||||
|
||||
template <class TriangleMesh>
|
||||
void orient_to_bound_a_volume(TriangleMesh& tm, const bool orient_outward)
|
||||
{
|
||||
orient_to_bound_a_volume(tm, orient_outward, parameters::all_default());
|
||||
}
|
||||
|
||||
template <class TriangleMesh>
|
||||
void orient_to_bound_a_volume(TriangleMesh& tm)
|
||||
{
|
||||
orient_to_bound_a_volume(tm, true, parameters::all_default());
|
||||
orient_to_bound_a_volume(tm, parameters::all_default());
|
||||
}
|
||||
} // namespace Polygon_mesh_processing
|
||||
} // namespace CGAL
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int main()
|
|||
Ppmap vpmap2 = get(CGAL::vertex_point, sm2);
|
||||
Fidmap fidmap2 = get(CGAL::face_index, sm2);
|
||||
|
||||
PMP::orient(sm2, true, PMP::parameters::vertex_point_map(vpmap2)
|
||||
PMP::orient(sm2, PMP::parameters::vertex_point_map(vpmap2)
|
||||
.face_index_map(fidmap2));
|
||||
if(!test_orientation(sm2, true, PMP::parameters::vertex_point_map(vpmap2)
|
||||
.face_index_map(fidmap2)))
|
||||
|
|
@ -99,7 +99,7 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
PMP::orient(sm3, false);
|
||||
PMP::orient(sm3, PMP::parameters::outward_orientation(false));
|
||||
if(!test_orientation(sm3, false, PMP::parameters::all_default()))
|
||||
{
|
||||
std::cerr << "ERROR for test2\n";
|
||||
|
|
@ -109,8 +109,9 @@ int main()
|
|||
Ppmap vpmap4 = get(CGAL::vertex_point, sm4);
|
||||
Fidmap fidmap4 = get(CGAL::face_index, sm4);
|
||||
|
||||
PMP::orient(sm4, false, PMP::parameters::vertex_point_map(vpmap4)
|
||||
.face_index_map(fidmap4));
|
||||
PMP::orient(sm4, PMP::parameters::vertex_point_map(vpmap4)
|
||||
.face_index_map(fidmap4)
|
||||
.outward_orientation(false));
|
||||
if(!test_orientation(sm4, false, PMP::parameters::vertex_point_map(vpmap4)
|
||||
.face_index_map(fidmap4)))
|
||||
{
|
||||
|
|
@ -118,7 +119,7 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
PMP::orient_to_bound_a_volume(volume, true);
|
||||
PMP::orient_to_bound_a_volume(volume);
|
||||
if( !PMP::does_bound_a_volume(volume))
|
||||
{
|
||||
std::cerr << "ERROR for test4\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue