mirror of https://github.com/CGAL/cgal
in triangulate_hole_polyline, replace begin and end iterators by PointRanges
This commit is contained in:
parent
282264a73a
commit
d39f201724
|
|
@ -106,6 +106,18 @@ See http://www.boost.org/libs/property_map/doc/ReadablePropertyMap.html
|
|||
*/
|
||||
class ReadablePropertyMap {};
|
||||
|
||||
/*!
|
||||
See http://www.boost.org/libs/range/doc/html/range/concepts/single_pass_range.html
|
||||
/// \cgalConcept
|
||||
*/
|
||||
class SinglePassRange {};
|
||||
|
||||
/*!
|
||||
See http://www.boost.org/libs/range/doc/html/range/concepts/forward_range.html
|
||||
/// \cgalConcept
|
||||
*/
|
||||
class ForwardRange {};
|
||||
|
||||
/*!
|
||||
This indicates that the definition of a type nested in a class is not documented.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ int main() {
|
|||
|
||||
patch_1.reserve(polyline.size() -2); // there will be exactly n-2 triangles in the patch
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
polyline.begin(), polyline.end(), back_inserter(patch_1));
|
||||
polyline, back_inserter(patch_1));
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
polyline.begin(), polyline.end(), back_inserter(patch_2));
|
||||
polyline, back_inserter(patch_2));
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
polyline.begin(), polyline.end(), back_inserter(patch_3));
|
||||
polyline, back_inserter(patch_3));
|
||||
|
||||
for(std::size_t i = 0; i < patch_1.size(); ++i) {
|
||||
std::cout << "Triangle " << i << ": " << patch_1[i].get<0>() << " "
|
||||
|
|
@ -54,7 +54,7 @@ int main() {
|
|||
polyline_collinear.push_back(Point_3(4.,0.,0.));
|
||||
std::vector<My_triangle> patch_will_be_empty;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
polyline_collinear.begin(), polyline_collinear.end(),
|
||||
polyline_collinear,
|
||||
back_inserter(patch_will_be_empty));
|
||||
CGAL_assertion(patch_will_be_empty.empty());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1153,20 +1153,26 @@ public:
|
|||
* Internal entry point for both polyline and Polyhedron_3 triangulation functions
|
||||
***********************************************************************************/
|
||||
template <
|
||||
typename Point_3,
|
||||
typename PointRange,
|
||||
typename Tracer,
|
||||
typename WeightCalculator
|
||||
>
|
||||
typename WeightCalculator::Weight
|
||||
triangulate_hole_polyline(std::vector<Point_3>& P,
|
||||
std::vector<Point_3>& Q,
|
||||
triangulate_hole_polyline(const PointRange& points,
|
||||
const PointRange& third_points,
|
||||
Tracer& tracer,
|
||||
const WeightCalculator& WC,
|
||||
bool use_delaunay_triangulation)
|
||||
{
|
||||
typedef typename CGAL::Kernel_traits<Point_3>::Kernel Kernel;
|
||||
typedef CGAL::internal::Triangulate_hole_polyline_DT<Kernel, Tracer, WeightCalculator> Fill_DT;
|
||||
typedef CGAL::internal::Triangulate_hole_polyline<Kernel, Tracer, WeightCalculator> Fill;
|
||||
typedef typename PointRange::iterator InIterator;
|
||||
typedef typename std::iterator_traits<InIterator>::value_type Point_3;
|
||||
typedef typename CGAL::Kernel_traits<Point_3>::Kernel K;
|
||||
|
||||
typedef CGAL::internal::Triangulate_hole_polyline_DT<K, Tracer, WeightCalculator> Fill_DT;
|
||||
typedef CGAL::internal::Triangulate_hole_polyline<K, Tracer, WeightCalculator> Fill;
|
||||
|
||||
std::vector<Point_3> P(boost::begin(points), boost::end(points));
|
||||
std::vector<Point_3> Q(boost::begin(third_points), boost::end(third_points));
|
||||
|
||||
if(P.front() != P.back()){
|
||||
P.push_back(P.front());
|
||||
|
|
|
|||
|
|
@ -247,34 +247,33 @@ namespace Polygon_mesh_processing {
|
|||
|
||||
/*!
|
||||
\ingroup PkgPolygonMeshProcessing
|
||||
Creates triangles to fill the hole defined by points in the range (@a pbegin, @a pend). Triangles are put into @a out
|
||||
using the indices of the input points in the range (@a pbegin, @a pend).
|
||||
Note that no degenerate triangle is allowed during filling. If no possible patch is found, then no triangle is put into @a out.
|
||||
Creates triangles to fill the hole defined by points in the range (@a points). Triangles are put into @a out
|
||||
using the indices of the input points in the range (@a points).
|
||||
Note that no degenerate triangles are allowed during filling. If no possible patch is found, then no triangle is put into @a out.
|
||||
|
||||
The optional range (@a qbegin, @a qend) indicate for each pair of consecutive points in the range (@a pbegin, @a pend),
|
||||
The optional range (@a third_points) indicates for each pair of consecutive points in the range (@a points),
|
||||
the third point of the facet this segment is incident to.
|
||||
|
||||
Note that the range (@a pbegin, @a pend) and (@a qbegin, @a qend) may or may not contain duplicated first point at the end of sequence.
|
||||
Note that the ranges (@a points) and (@a third_points) may or may not contain duplicated first point at the end of sequence.
|
||||
|
||||
@tparam OutputIteratorValueType value type of OutputIterator having a constructor `OutputIteratorValueType(int p0, int p1, int p2)` available.
|
||||
It is default to value_type_traits<OutputIterator>::type, and can be omitted when the default is fine
|
||||
@tparam InputIterator iterator over input points
|
||||
It defaults to `value_type_traits<OutputIterator>::type`, and can be omitted when the default is fine.
|
||||
|
||||
@tparam PointRange range of points, model of `SinglePassRange`
|
||||
@tparam OutputIterator iterator over patch triangles
|
||||
@param pbegin first iterator of the range of points
|
||||
@param pend past-the-end iterator of the range of points
|
||||
@param qbegin first iterator of the range of third points, can be omitted
|
||||
@param qend past-the-end iterator of the range of third points, can be omitted
|
||||
@param points the range of input points
|
||||
@param third_points the range of third points, can be omitted
|
||||
@param out iterator over output patch triangles
|
||||
@param use_delaunay_triangulation if `true`, use the Delaunay triangulation facet search space
|
||||
@param use_delaunay_triangulation if `true`, use the Delaunay triangulation facet search space, defaults to true if omitted.
|
||||
|
||||
\todo handle islands
|
||||
*/
|
||||
template <typename OutputIteratorValueType,
|
||||
typename InputIterator,
|
||||
typename PointRange,
|
||||
typename OutputIterator>
|
||||
OutputIterator
|
||||
triangulate_hole_polyline(InputIterator pbegin, InputIterator pend,
|
||||
InputIterator qbegin, InputIterator qend,
|
||||
triangulate_hole_polyline(const PointRange& points,
|
||||
const PointRange& third_points,
|
||||
OutputIterator out,
|
||||
bool use_delaunay_triangulation = true)
|
||||
{
|
||||
|
|
@ -284,32 +283,32 @@ namespace Polygon_mesh_processing {
|
|||
#else
|
||||
use_delaunay_triangulation;
|
||||
#endif
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Point_3;
|
||||
typedef typename PointRange::iterator InIterator;
|
||||
typedef typename std::iterator_traits<InIterator>::value_type Point_3;
|
||||
|
||||
typedef CGAL::internal::Weight_min_max_dihedral_and_area Weight;
|
||||
typedef CGAL::internal::Weight_calculator<Weight,
|
||||
CGAL::internal::Is_not_degenerate_triangle> WC;
|
||||
typedef std::vector<std::pair<int, int> > Holes;
|
||||
typedef std::back_insert_iterator<Holes> Holes_out;
|
||||
|
||||
std::vector<Point_3> P(pbegin, pend);
|
||||
std::vector<Point_3> Q(qbegin, qend);
|
||||
Holes holes;//just to check there is no holes
|
||||
Holes holes;//just to check there is no holes left
|
||||
|
||||
CGAL::internal::Tracer_polyline_incomplete<OutputIteratorValueType, OutputIterator, Holes_out>
|
||||
tracer(out, Holes_out(holes));
|
||||
triangulate_hole_polyline(P, Q, tracer, WC(), use_dt3);
|
||||
triangulate_hole_polyline(points, third_points, tracer, WC(), use_dt3);
|
||||
CGAL_assertion(holes.empty());
|
||||
return tracer.out;
|
||||
}
|
||||
|
||||
// overload for OutputIteratorValueType
|
||||
template <typename InputIterator,
|
||||
template <typename PointRange,
|
||||
typename OutputIterator>
|
||||
OutputIterator
|
||||
triangulate_hole_polyline(InputIterator pbegin, InputIterator pend,
|
||||
InputIterator qbegin, InputIterator qend,
|
||||
OutputIterator out,
|
||||
bool use_delaunay_triangulation = true)
|
||||
triangulate_hole_polyline(const PointRange& points,
|
||||
const PointRange& third_points,
|
||||
OutputIterator out,
|
||||
bool use_delaunay_triangulation = true)
|
||||
{
|
||||
bool use_dt3 =
|
||||
#ifdef CGAL_HOLE_FILLING_DO_NOT_USE_DT3
|
||||
|
|
@ -318,15 +317,15 @@ namespace Polygon_mesh_processing {
|
|||
use_delaunay_triangulation;
|
||||
#endif
|
||||
return triangulate_hole_polyline<typename value_type_traits<OutputIterator>::type>
|
||||
(pbegin, pend, qbegin, qend, out, use_dt3);
|
||||
(points, third_points, out, use_dt3);
|
||||
}
|
||||
|
||||
// overload no (qbegin, qend)
|
||||
template <typename OutputIteratorValueType,
|
||||
typename InputIterator,
|
||||
typename PointRange,
|
||||
typename OutputIterator>
|
||||
OutputIterator
|
||||
triangulate_hole_polyline(InputIterator pbegin, InputIterator pend,
|
||||
triangulate_hole_polyline(const PointRange& points,
|
||||
OutputIterator out,
|
||||
bool use_delaunay_triangulation = true)
|
||||
{
|
||||
|
|
@ -336,18 +335,16 @@ namespace Polygon_mesh_processing {
|
|||
#else
|
||||
use_delaunay_triangulation;
|
||||
#endif
|
||||
typedef typename std::iterator_traits<InputIterator>::value_type Point;
|
||||
typedef std::vector<Point> Polyline_3;
|
||||
Polyline_3 Q;
|
||||
|
||||
return triangulate_hole_polyline<OutputIteratorValueType>
|
||||
(pbegin, pend, Q.begin(), Q.end(), out, use_dt3);
|
||||
(points, PointRange(), out, use_dt3);
|
||||
}
|
||||
|
||||
// overload for OutputIteratorValueType
|
||||
template <typename InputIterator,
|
||||
template <typename PointRange,
|
||||
typename OutputIterator>
|
||||
OutputIterator
|
||||
triangulate_hole_polyline(InputIterator pbegin, InputIterator pend,
|
||||
triangulate_hole_polyline(const PointRange& points,
|
||||
OutputIterator out,
|
||||
bool use_delaunay_triangulation = true)
|
||||
{
|
||||
|
|
@ -358,7 +355,7 @@ namespace Polygon_mesh_processing {
|
|||
use_delaunay_triangulation;
|
||||
#endif
|
||||
return triangulate_hole_polyline<typename value_type_traits<OutputIterator>::type>
|
||||
(pbegin, pend, out, use_dt3);
|
||||
(points, out, use_dt3);
|
||||
}
|
||||
|
||||
} //end namespace Polygon_mesh_processing
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ void test_1(const char* file_name, bool use_DT) {
|
|||
read_polyline_one_line(file_name, points);
|
||||
|
||||
std::vector<boost::tuple<int, int, int> > tris;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(points.begin(),
|
||||
--points.end(), std::back_inserter(tris), use_DT);
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
points, std::back_inserter(tris), use_DT);
|
||||
|
||||
check_triangles(points, tris);
|
||||
check_constructed_polyhedron(file_name, &tris, &points);
|
||||
|
|
@ -156,8 +156,8 @@ void test_2(const char* file_name, bool use_DT) {
|
|||
read_polyline_with_extra_points(file_name, points, extras);
|
||||
|
||||
std::vector<boost::tuple<int, int, int> > tris;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(points.begin(),
|
||||
points.end(), extras.begin(), extras.end(), std::back_inserter(tris), use_DT);
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
points, extras, std::back_inserter(tris), use_DT);
|
||||
|
||||
check_triangles(points, tris);
|
||||
check_constructed_polyhedron(file_name, &tris, &points);
|
||||
|
|
@ -173,7 +173,7 @@ void test_should_be_no_output(const char* file_name, bool use_DT) {
|
|||
|
||||
std::vector<boost::tuple<int, int, int> > tris;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(
|
||||
points.begin(), points.end(), std::back_inserter(tris), use_DT);
|
||||
points, std::back_inserter(tris), use_DT);
|
||||
|
||||
if(!tris.empty()) {
|
||||
std::cerr << " Error: patch should be empty" << std::endl;
|
||||
|
|
|
|||
|
|
@ -125,8 +125,7 @@ public slots:
|
|||
|
||||
CGAL::Timer timer; timer.start();
|
||||
std::vector<CGAL::Triple<int, int, int> > patch;
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(it->begin(),
|
||||
--it->end(), std::back_inserter(patch), use_DT);
|
||||
CGAL::Polygon_mesh_processing::triangulate_hole_polyline(*it, std::back_inserter(patch), use_DT);
|
||||
print_message(QString("Triangulated in %1 sec.").arg(timer.time()));
|
||||
|
||||
if(patch.empty()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue