Bug in simplify curve?


#1

There seems to be a bug in SimplifyCrv where it ignores the document tolerance settings.

I would also like to see a tolerance setting for the python version.

Thnx!


(Dale Fugier) #2

I can assure you it isn’t. What problem are you seeing?

– Dale


#3

It is possible using RhinoCommon. Agree that this would be nice to have in rhinoscriptsyntax. --Mitch


#4

The problem I was seeing was that there were no difference in reduction at different tolerance settings, but if I scaled down the curve to 10% then the command still didn’t reduce it until I sat the tolerance to 1 when it suddenly reduced it to only two points…

I’ll see if I can muster up an example for you later today.


#5

I tried to understand Rhino common yesterday, but it was a bit too hard for me.
So I wrote a simpler simplify curve script that got the job done.


(Pascal Golay) #6

Hi Jorgen - is this showing up a particular curve, or in general?

-Pascal


#7

It’s in general, both V5 and V6.
(V6 is really slow on working on curves like these. Try to pick one and move it, then compare to V5, also scrolling with the mouse wheel is really slow in V6. Tested now on a Geforce 750m)

The curves are the result of tracing curves down a mesh, so many of the curve points should be in line within the tolerance if the document tolerance is sat lower. At least that is how it is logical for me as a user.

Here’s what I’d like you to test:
1 - Copy the curves so you can compare the results.
2 - Turn on controlpoints and run SimplifyCrv on the copies
3 - Lower tolerance to 0.1 and run SimplifyCrv (not much changes)
4 - Lower tolerance to 1 and run SimplifyCrv (not much changes)
5 - Lower tolerance to 10 and run SimplifyCrv (all curves changes)

The strange thing to me is that when tolerance is 10 (or if you scale down the curves to 0.1 and set tolerance to 1) then they all become straight lines.

Is this as you expect it to behave?

Note: if you look at a curve properties details it will tell you the curve is invalid… why is that?

Simplify curves tolerance ignored.3dm (927.5 KB)


#8

In here, using V6, SimplifyCrv doesn’t do anything!
And yes, the curves are invalid.

After Explode and Join it works.
Hmm?

-C-H-A-R-L-E-S-


#9

Generally, commands can be expected to fail if the objects are invalid, and some functions may even be programmed to ignore those completely. However, @pascal it might be a good idea to inform the user that a command failed or was not executed because one or more of the objects involved was invalid…

Yes, this is typically how to fix invalid polycurves. Usually this means that there were one or more micro segments in the curve - way below file tolerance - and in exploding/rejoining, Rhino automatically eliminates those.

–Mitch


(Pascal Golay) #10

Hi Mitch - yeah… I’m not sure how that can be best handled - command by command (complicated, I would guess) , or, possibly a general command line report at the end of commands, regardless of the outcome, that there was invalid geometry in the inputs.

-Pascal


#11

Thanks for the feedback guys!
I had no idea that my rs.AddPolyLine made invalid data if the input points were duplicate or too close to each other. Are there any script commands to fix a curve like this either after it is made, or prior to making it (is there a cull duplicate points command?), or would I have to make it a macro command like rs.Command(explode join unselectall)

Here’s how I envision a feedback on invalid data:
Invalid data is something a user never wants. Pop up a warning that can be supressed for the session and disabled in the settings for pro users who deal a lot with invalid data and who doesn’t want to press the supress button each day.

Or state on the commandline that there was invalid data in the input and/or output and color code the command line background orange to draw attention to the feedback.

Anyhow I do think SimplifyCrv should handle these curves automatically since the fix is as easy as explode-join, so please treat it as a bug since SimplifyCrv neither does anything nor gives any feedback.


(Pascal Golay) #12

In RhinoCommon there’s Polyline.CollpaseShortSegments() which takes a tolerance paramter. I don’t think there is anything in rhinoscriptsyntax for this though.

-Pascal


#13

Excellent, I’ll check it out!


#14

Meh… Rhino common is still to cryptic for my mind to bend around to just utilize a fraction of the command… :smiley:

But I found that rs.CullDuplicatePoints() was even better for me as it fixed the data before generating a degenerate curve. So thanks for pushing me in the right direction.

I still think that Simplify Curve has a bug though, as it is obvious that culling duplicate points is simplifying a curve.
So flag it as something to fix for V6 please.


#15

One last thing guys, Does this seem right to you guys? :

To me there should be steps between those results. Suddenly going all straight line is just odd. Of course the turning point value represents the distance between the line from curve start to curve end and it’s maksimum distance to one of the controlpoints. But that doesn’t justify not simplifying the other points when the values are lower.

What do you think @dale ?

Simplify curves tolerance odd.3dm (30.7 KB)