Get the tolerance related to Curve/Surface Evaluator

We use the following code to get tolerance.

double dDocTol = m_pDoc->AbsoluteTolerance();

However, Curve/Surface Evaluator returns values related to the unit setting. How to get the tolerance related to Curve/Surface Evaluator or the unit setting?

Hi @XNurbs,

double abs_tol = pDoc->AbsoluteTolerance();

is just a shortcut for this:

double abs_tol = pDoc->Properties().UnitsAndTolerances().m_absolute_tolerance;

Does this help?

– Dale

We want to get the tolerance related to Curve/Surface Evaluator or the unit setting. For example, m_pDoc->AbsoluteTolerance() would always return 0.00001. However, Curve/Surface Evaluator returns values related to the unit setting, i.e, the tolerance they use is 0.01 (m -> mm). Not sure how to get the tolerance related to Curve/Surface Evaluator or the unit setting

This is not true. CRhinoDoc::AbsoluteTolerance returns the model absolute tolerance as set by the user (File → Properties → Units → Model → Absolute tolerance).

I am confused as to what problem you are trying to solve, as Rhino geometry calculations are not unit-based. Perhaps I need more details, or is there a specific function you have a question about?

– Dale

We want to get the tolerance related to Curve/Surface Evaluator or the unit setting.

For example, to the attached model, AbsoluteTolerance() would always return 0.00001. However, Curve/Surface Evaluator returns values, e.g., (0.000000 30.000000 15.000000), and (-15.000000 30.000000 15.000000), which are 1000 times larger compared with AbsoluteTolerance()!

We check other CAD systems, the values they return are (0.000000 0.03 0.015), and (-15.000000/1000 30.000000/1000 15.000000/1000).

So we need to get the tolerance related to Curve/Surface Evaluator or the unit setting.

FilletUnit.3dm (28.4 KB)

This is really a user question, The numbers that you see in Rhino are controlled by the user settings.

The file you posted has
units set to Millimeters
absolute tolerance set to .000001
display tolerance set to 1.000

The user can change any of those document property>Units settings .
if you change the units in your file to meters and display setting to 1.000000 the numbers should match what you are seeing in your other CAD system.

Curve/surface evaluation should be as precise as the floating point arithmetic can produce. The absolute tolerance should play no role in any calculations that are not approximate. The display tolerance will determine how many digits are shown to the user but internally the numbers will be stored as doubles.

There are two ways the unit settings can be changed. Either directly by the user at any time or indirectly by opening a file that contains the settings. When a new session of Rhino is started a user template file is opened that contains the settings .

I am afraid that you misunderstand the question…

We need to get a tolerance setting which can be used for numerical calculation, e.g., calculating a surface. The tolerance is a very basic concept for any numerical algorithm. AbsoluteTolerance() would always return 0.00001, i.e., 0.00001mm. We cannot use it for any numerical algorithm.

So we need get the tolerance related to Curve/Surface Evaluator or the unit setting.

Yes it seems I do not understand.

I thought the question was rabout evaluating the point at the corner of a surface in your file.
The question I answered was → why does Rhino return (0.000000 30.000000 15.000000) and another CAD program returns (0.000000 0.03 0.015) for that point

The answer to that question is that Rhino is showing the result in mm and the other CAD is showing the result in meters. If you want the user to see the same result as the other CAD program either your plugin or the user must change the units setting in your file to meters. Also, If you don’t like the tolerance setting you (or the user) can change that.

Does the link below show the surface evaluator that you used to get the result in Rhino?
ON_Surface::PointAt :
https://developer.rhino3d.com/api/cpp/class_o_n___surface.html#a540c9be4e61afd522ced8ee37cb0a47f

I don’t believe there is any tolerance setting that affects that function

We need to set a tolerance for our plugin. Obviously, AbsoluteTolerance() and Curve/Surface Evaluator do not match with each other!

The tolerance is a very basic concept for any computational algorithm and any professional computational algorithm would need it.

The surface evaluator is irrelevant to the question we asked and it does not need a tolerance setting at all.

Again, our question here is “We need to set a tolerance for our plugin, which uses the tolerance for other calculation. AbsoluteTolerance() and Curve/Surface Evaluator do not match with each other!”.

@XNurbs, you should re-read the comments from @jim.

Regarding the “other” CAD package, what unit system it is using with this model?

I should also add that the model’s absolute tolerance seem unusually high. What is the requirement for this?

https://wiki.mcneel.com/rhino/faqtolerances

Dale:

I restate the question:

We need to set a tolerance for our plugin, which uses the tolerance for other calculation. We call AbsoluteTolerance() to get the tolerance, which return 0.000001 (i.e., 0.000001 mm). As you said the model’s absolute tolerance seems unusually high. In other words, the tolerance returned by AbsoluteTolerance() dose NOT make any sense and we CANNOT use the tolerance setting. So the question is “how we can get the tolerance setting for a document”?

Jim,

I use that model to explain that Rhino geometry calculations may be unit-based. @dale said “Rhino geometry calculations are not unit-based”. That Rhino model shows that Rhino geometry calculations (curve/the surface evaluator) may be based on mm, but AbsoluteTolerance() may be based on meter.

Hope you can understand now?

Dale,

Need to mention that we did not set the document tolerance. We just use the default tolerance when Rhino opens a regular STEP file.

So let me see if I understand you correctly: You’d like to set an absolute tolerance for some algorithms which can be modified by the user, which is not dependent on the unit of the document.

If that is the case then looking at the document tolerances is probably not the best approach. The best way to do this in my opinion would be to create an options page ( example in rhino 6 , same example in rhino 5 , other example in rhino 5 ) that is unique to your plugin where you could set the tolerance (along with any other values) in any way you choose, disregarding the units and tolerances set by the user.

~robin

That must be a typo. Of course Rhino geometry calculations are unit-based

Yes I understand now. The tolerance setting when opening SWX files is not correct. I do not know if that is a Rhino bug or a SWX bug. I have seen this bug myself many times recently (the bug has only been around for about 6 months). This bug makes it more difficult to open SWX Step files reliably.

The workaround for this bug s to use “Import” command to bring in SWX geometry,
So you would start with a template file with tolerance set to .01 and units mm and then import the SWX data. Importing geometry won’t change the tolerance to something ridiculous.

To answer your original question, the tolerance your plug-in should use for its numerical algorithms is the Rhino absolute tolerance. Keep in mind that your users will not likely be working on a SWX STEP file that they opened. The vast majority of mm files will have a tolerance of .01-.001. But if the user is making something really large like a building or a ship they may set the tolerance to 1.0-0.1 mm or if they are modeling something very tiny (say smaller than a mm) they may set the tolerance to smaller than .001 mm.

It is important that your plugin use the same tolerance that the user sets for absolute tolerance . The reason is that if you use a tolerance that is looser than the user’s tolerance then your geometry will likely not join to the user’s geometry and if your tolerance is smaller than the user tolerance it will produce curves and surfaces that are much denser than they need to be.

If your numerical algorithms only work within a narrow range of tolerance you should give the user a pop-up message box that explains this fact. The user can then adjust the tolerance, units or even scale the model size so that the can work within the plugins tolerance range. One of the things Rhino users must learn very early is to set the units and tolerance so as to achieve the best results for their own particular modeling needs,

Jim,

“It is important that your plugin use the same tolerance that the user sets for absolute tolerance.”
This is what we try to do. However, when opening STEP files etc., Rhino sets a wrong tolerance (I guess they mistakenly use meters for the document tolerance and use mm for other calculations.)

“Keep in mind that your users will not likely be working on a SWX STEP file that they opened. The vast majority of mm files will have a tolerance of .01-.001.”
Our plugin should work for all files. As @robin_l suggested, ‘looking at the document tolerances is probably not the best approach’.

Thank you guys.

@chuck, the user is reporting a tolerance issue when opening STEP files created with SolidWorks. Can you work with @XNurbs to resolve this?

– Dale

A STEP file has a tolerance entity that is used to determine the Rhino document tolerance. Whether or not the data in the STEP file is accurate to within this tolerance is up to the exporting software. In many cases it is not.

Then the bug is Rhino 6 reads this entity incorrectly.

What tolerance does Rhino6 use to join edges when it reads in a STEP file. Does it ignore the tolerance all together and just join anything where there are edges that have overlapping intervals?

Here is a file that my Rhino6 says the tolerance is 0.000001

corep.stp (60.1 KB)