Grasshopper

algorithmic modeling for Rhino

How to represent an invalid or empty Cylinder, Cone, Torus?

Hi,

I searched this in the discussions and found no prior thread.

It seems that all these are non-nullable items and do not come with .unset property. 

If I use Surface.TryGetCone(). What will be the return value if it's not successful?

In a word, how to represent them as vacant or invalid like Plane.Unset or null?

 

Thanks,

-Jerome

Views: 759

Replies to This Discussion

Hi Jerome,

 

There are several things that can make a Cylinder or Cone or Torus invalid. Zero or negative radii, an unset base plane etc. But you're right, there should be a Cylinder.Unset field. I'll add those.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, David.

Cone and Cylinder also needs that, as far as I can see.

The reply I attached below is still that validity problem I am facing these days(I asked you yesterday). Please check if you have time :)

 

Thank you!

-Jerome

Hi Jerome,

in addition to David's answer, the return value of the TryGetCone method will be false.

In general, in the Try___ pattern, you should not infer the validity from the object that is passed by the out reference, but rather from the boolean value that is returned.

http://www.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Surface_...

- Giulio
_______________
giulio@mcneel.com

Thanks, Giulio

It seems that the boolean value is not an ultimate tool to determine the validity of the resultant geometry.

Here is an example of TryGetTorus. Boolean returns true, then I convert these torus to nurbssurface and nurbssurface.isValid also returns true. Finally, I conver those nurbssurface to brep, brep.isValid still returns true. But, magically, the output parameter of the c# component is telling me that the output surfaces are all invalid. I can even visualize these invalid Torus in the Rhinoviewport. I'm really confused now. How to test the validity of these Torus? It seems that the ultimate tool is the output parameter of c# component which I lost control of.

I attached definition below.

 

Thanks!

-Jerome

Attachments:

These invalid messages appear to be mostly about tolerances. If the edge curve of a brep is too far away from the surface, it will become invalid. This might happen spontaneously if your geometry is very big.

 

I measured the radii of the torii (try saying that ten times fast) and it works out as follows:

 

something * 10 to the power 16 is pretty big. Double-precision-floating-point numbers have about 16 decimal places. By coincidence this is the same number as your power of ten, but it means that any two subsequent numbers in this range of the number scale will be ~roughly 1.0 apart. In other words, take these two subsequent numbers:

 

1.4905937400825007e+16

1.4905937400825008e+16

 

There are no floating point numbers in between these two, because there's only so many unique numbers you can represent in 64 bits. The absolute difference between these numbers is 1.0e+0. In other words, this far away from zero, the numbers start to get really coarse and unreliable.

 

I'm actually not sure if it's even possible to have a valid brep this size, but I'd have tto check that with the Seattle math guys.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, Daivd. Your answer is really comprehensive and vivid.

That looks like the only way to check the validity of the torus is to check the radii of the torii, right? In this case, checking the radii seem to be more efficient than using .IsValid, right?

One tricky thing in my definition above is Brep.IsValid returns true while the output Breps(from the output parameter) are deemed as Invalid in that yellow panel. Is there a way to incorporate the method which are embedded in the output procedure of the c# component into my code?

I did another test. I created a List<Brep> to hold the torus before output. This time, the yellow panel which wired to the output parameter didn't deem them as invalid as before. But, that Null Component think they are invalid(which shows valid in my prior definition). I can't really understand the logic behind these.

Thank you again for your time.

 

-Jerome

another test

Attachments:

"One tricky thing in my definition above is Brep.IsValid returns true while the output Breps(from the output parameter) are deemed as Invalid in that yellow panel."

 

yeah that is a bit odd. Not quite sure why that happens. I'll need to dig a bit further.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks!

Looks like the mechanism between these two validation methods are different.

Looking forward to your in-depth finding :)

David, Sorry to bother.

Any findings on this problem yet?

Thanks!

Ok, the bug is in the Null component, it actually outputs TRUE if the data is valid as opposed to what it claims it does.

I'll fix the component.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks, David.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service