cgal icon indicating copy to clipboard operation
cgal copied to clipboard

PMP: Polyline Snapping

Open sgiraudot opened this issue 7 years ago • 18 comments

Summary of Changes

This introduces an internal non-documented function to snap a set of polylines under a user-specified tolerance. I also put a test and a plug-in for the demo.

Release Management

  • Affected package(s): PMP

sgiraudot avatar Feb 28 '18 09:02 sgiraudot

For which release do we want this PR? 4.12 or 4.13?

lrineau avatar Feb 28 '18 13:02 lrineau

It's honestly no rush at all, so unless @sloriot (or you) can do a review and that the testsuite looks good soon enough for 4.12, it can easily be postponed to 4.13.

sgiraudot avatar Feb 28 '18 14:02 sgiraudot

This change is Reviewable

lrineau avatar Mar 12 '18 11:03 lrineau

Warnings:

In file included from /Users/cgaltester/cgal_test/CGAL-4.12-Ic-200/cmake/platforms/x86-64_Darwin-13.0_Apple-clang-5.0_Release/test/Polyhedron_Demo/Plugins/PMP/Snap_polylines_plugin.cpp:7:
/Users/cgaltester/cgal_test/CGAL-4.12-Ic-200/include/CGAL/Polygon_mesh_processing/polyline_snapping.h:275:64: warning: unused typedef 'PointIterator' [-Wunused-local-typedef]
  typedef typename boost::range_const_iterator<Polyline>::type PointIterator;
                                                               ^
/Users/cgaltester/cgal_test/CGAL-4.12-Ic-200/include/CGAL/Polygon_mesh_processing/polyline_snapping.h:281:84: warning: unused typedef 'OutputType' [-Wunused-local-typedef]
  typedef cpp11::tuple<std::size_t, std::size_t, std::size_t, std::size_t, FT, FT> OutputType;
                                                                                   ^
/Users/cgaltester/cgal_test/CGAL-4.12-Ic-200/include/CGAL/Polygon_mesh_processing/polyline_snapping.h:273:69: warning: unused typedef 'PolylineIterator' [-Wunused-local-typedef]
  typedef typename boost::range_const_iterator<PolylineRange>::type PolylineIterator;
                                                                    ^
3 warnings generated.

Maybe have a look at the other columns, because there might be other warnings: https://cgal.geometryfactory.com/CGAL/testsuite/results-4.12-Ic-200.shtml#Polyhedron_Demo

lrineau avatar Mar 16 '18 10:03 lrineau

@lrineau I see you push it to the testsuite (there are warnings I'm going to take care of). Do you want this to be in 4.12? As I said, I don't mind waiting for 4.13 for this.

sgiraudot avatar Mar 20 '18 08:03 sgiraudot

We said we would try to push it in CGAL-4.12. So I included it.

lrineau avatar Mar 20 '18 11:03 lrineau

Testsuite looks good.

sgiraudot avatar Mar 21 '18 06:03 sgiraudot

I have temporarily added the label "not yet approved", to avoid that I accidentally merge this PR, before the discussion between Sébastien and Simon is over.

lrineau avatar Mar 21 '18 08:03 lrineau

After a discussion with @sgiraudot, we have decided to postpone the test of this PR for CGAL-4.13.

To be done:

  • handle the case where the segments are colinear,
  • even when segment are not colinear, handle the cases where the point of a segment s1 that is closest to a segment s2 is not the intersection of projections.

Maybe Simon you want to add things. I think we should in the end modify the first message of the discussion, with a summary of the to-do list.

lrineau avatar Mar 22 '18 11:03 lrineau

@sgiraudot Have a look whether you want to refresh this PR and have it tested for CGAL-4.13.

lrineau avatar Jun 07 '18 11:06 lrineau

I don't think I'll have time to do the work that has to be done (summed up in your message of March 22nd) before the release, so we should probably postpone it.

sgiraudot avatar Jun 11 '18 08:06 sgiraudot

Shall @maxGimeno take over this PR?

sloriot avatar Oct 23 '18 09:10 sloriot

@sgiraudot what do we do with this PR ?

maxGimeno avatar Jan 10 '19 13:01 maxGimeno

I honestly don't know. There's still quite a lot of work to do and it's quite low priority, so I don't see it improving anytime soon…

sgiraudot avatar Jan 10 '19 13:01 sgiraudot

Ok, let's postpone it then

maxGimeno avatar Jan 10 '19 14:01 maxGimeno

Conflicts

maxGimeno avatar Jun 17 '19 07:06 maxGimeno

I rebased the branch and did some more work on it:

  • the algorithm now takes a Graph as input and directly modifies it
  • degenerate cases (collinear segments or coplanar segments) are well detected, and a first version of proximities detection is done
  • so far, some cases are not handled, specifically cases were a segment is completely included in the tolerance cylinder of another coplanar segment

Actually, it is really difficult to figure out a way to deal with all possible cases. The problem seems ill-posed, as the same polyline set will give very different results depending on how densely it's sampled: it seems we should consider polylines as a linear distribution and not a set of segments, otherwise we are dependent on vertex densities/positions. But on the other hand, I don't see an easy way to do it without the points.

Handling collinear segments gives also a sort of instability: two segments almost collinear would snap at 1 point, but as soon as they become collinear, they should snap as a common segment?

Depending on how the handle proximities, we can also get quite different outputs, see this coplanar example:

image

There does not seem to be a right answer. If you start considering cases where N polylines might snap at the same location with a combination of degenerate cases, it quickly becomes a nightmare.

In all cases, we also have the problem that applying the algorithm several times would sequentially collapse the polylines onto each other, which is not the case with non-degenerate cases (that would remain stable).

I'm wondering if we should not just make it a precondition that no segments are collinear/coplanar (or use random perturbations to make sure of that), but that might be too restrictive.

sgiraudot avatar May 06 '21 11:05 sgiraudot

Problems in license :

 There are modifications in licenses (check if all modified/added headers files contain a valid SPDX tag compatible with the one in package_info/PKG/license and that no license text is present):
 M Polygon_mesh_processing/package_info/Polygon_mesh_processing/license.txt

maxGimeno avatar May 06 '21 11:05 maxGimeno