Substitute/workaround for CrvDeviation

Since CrvDeviation - and its RhinoCommon companion Rhino.Geometry.Curve.GetDistancesBetweenCurves() - are fairly unreliable at this point and it doesn’t look like anything will get fixed in the near future (nearest “target” is 6.1, otherwise 6.x)…

https://mcneel.myjetbrains.com/youtrack/issue/RH-38227
https://mcneel.myjetbrains.com/youtrack/issue/RH-38212

– is there any better/faster way of checking two curves against each other besides just (lots and lots of) sampling?

Thx, --Mitch

Looks like another RTree challenge… :wink:

You can use that to actually sample curve to curve distances for nearly identical curves? Well, anyway, I have never been able to get my tiny head around the rTree programming concept… :grimacing:

Sure, but if it is useful depends how you define maximum deviation.
Assuming we divide both curves and find the closest point for each test point on the other curve…
Is the longest of all closest point calculations the maximum deviation?

Please have a look at the attached file. The longest CP distance is shown in red. But if you make a cross-check from that closest point back to the original curve it will not be near the test point - I guess now I understand what it means if “Curves do not overlap.” :wink:

I can clean up my RTree hack a bit and post it later if there is interest…

Jess

CrvDeviation.3dm (28.4 KB)

Yes, of course, it does not make sense to use this function on curves that are wildly different in shape/disposition in space. Unfortunately, we often get the “unable to find overlapping intervals” or some really far off match points even when the curves are almost identical and on top of each other… that’s mainly my complaint here - as I use this to find “near-dups” within a certain tolerance.

–Mitch

Just to make sure I understand… do you want to find curves which are more than your tolerance off from another curve, or do you want to find curves which overlap (partly) within your tolerance?

The second… The types of curves that SelDup does not find. For example, a circle that has been copied in place and turned into a dense polyline. Generally I check the fast, easy-to-get criteria first for correspondence (bounding box, length etc.) and then if that results in a possible candidate, I would like to run Cdev as a final check that it’s within tolerance everywhere. This is where sometimes it works, and sometimes it doesn’t…

Here is a typical CDev failure example… Both V5 and V6.

CircleCDevFail.3dm (41.3 KB)

Hi Mitch,

attached you’ll find a simple script for V6 to check if the deviation of two curves is within tolerance.
There is quite some potential for optimization, error trapping and so on, but I hope it gets you moving on…
Of course it would also be possible to create a mark at the maximum found deviation…CheckCurveDeviation_V6.py (2.4 KB)

Jess

If either curve is a PolyCurve or Polyline, create a list of curves for each curve, substituting the PolyCurves and Polyline with results from Curve.DuplicateSegments. Apply Curve.GetDistancesBetweenCurves to each combination of one curve from list A with one from list B, accumulating the results for subsequent analysis.

…fails if the “Curves do not overlap.” I think this phrase is not the best wording for the actual situation, but I think I understand what it means. However, what we need is a command/method which will find the longest of all closest point calculations between the two (sampled) curves. No matter if the “cross-check” fails like shown in the file attached to post #4 of this tread. The script I’ve posted can handle that situation. Thanks!

If you know the curves are already close with your other checks (bbox, length, etc), but not sure how close, can you check the starting points are close (or make them close), reparameterise both of them to a 0-1 domain then just compare the curve distances at/between each domain?

That’s pretty much what I do, just sample one curve and compare distances. But it’s slow if you have a lot of curves that are near-dupes and a fine sample distance. Jess provided an octree solution for the sampling, I haven’t had time to try it yet…

–Mitch

1 Like