@Helvetosaur posted a new topic, subject "Substitute/workaround for CrvDeviation". It read:

   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

@Jess replied

    Looks like another RTree challenge…

To which @Helvetosaur replied

    Jess:
    
    > Looks like another RTree challenge
    
    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…

After which, @Jess added

    Helvetosaur:
    
    > You can use that to actually sample curve to curve distances for nearly identical curves?
    
    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.” 
    
    I can clean up my RTree hack a bit and post it later if there is interest…
    
    Jess
    
    CrvDeviation.3dm (28.4 KB)

To which @Helvetosaur replied

    Jess:
    
    > I guess now I understand what it means if “Curves do not overlap”.
    
    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

Then @Jess said

    Helvetosaur:
    
    > as I use this to find “near-dups” within a certain tolerance.
    
    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?

Then @Helvetosaur said

    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)

So @Jess replied

    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

To which @spb (Steven Burzinski) replied

    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.

So @Jess replied

    spb:
    
    > Curve.GetDistancesBetweenCurves
    
    …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!

To which @Ncik replied

    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?

To which @Helvetosaur replied

    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


{'source': 'discourse', 'url': 'https://discourse.mcneel.com/t/substitute-workaround-for-crvdeviation/50531', 'title': 'Substitute/workaround for CrvDeviation', 'views': 783, 'has_accepted_answer': False, 'word_count': 857, 'like_count': 1, 'reply_count': 8, 'participant_count': 4, 'posts': 12, 'tags': 'crvdeviation', 'author': '@Helvetosaur', 'participants': '@Helvetosaur, @Jess, @spb (Steven Burzinski), @Ncik', 'image_url': [None], 'created_at': '2017-11-30T14:09:43.554Z', 'last_posted_at': '2017-12-15T07:46:20.742Z'}