Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around lacking robustness of isEqual() and isSame() functions #1532

Open
mxmws opened this issue Mar 9, 2024 · 4 comments
Open

Work around lacking robustness of isEqual() and isSame() functions #1532

mxmws opened this issue Mar 9, 2024 · 4 comments
Labels
question Further information is requested

Comments

@mxmws
Copy link

mxmws commented Mar 9, 2024

Hi,

extremely small changes due to rounding already result in isEqual() and isSame() returning false. For example when I export a shape as a .step file and import it again it's not considered the same anymore.

I'm hoping for suggestions on how to work around this! One idea was to compare parameters like area and center of mass and consider two shapes equal if the difference between those parameters is very small. If someone has a better idea please suggest it to me. Thanks!

@adam-urbanczyk adam-urbanczyk added the question Further information is requested label Mar 9, 2024
@adam-urbanczyk
Copy link
Member

You are misinterpreting what those methods are for, see the docstring:

Returns True if other and this shape are same, i.e. if they share the
same TShape with the same Locations. Orientations may differ.

They are checking the internal representations of the Shape objects, not geometric equality.

If you want geometric approximate equality, you'll have to implement it yourself. You could indeed compare center of mass, volume, area, number of vertices/edges/faces. I do wonder why do you actually need it.

@mxmws
Copy link
Author

mxmws commented Mar 9, 2024

Thank you for your reply. I need it to evaluate a library that generates CSG trees from step files. So I'm converting step to CSG and back to step to see if it's still the same.

@adam-urbanczyk
Copy link
Member

If you are able to load the model back to CQ, you could use bool cut to compare the original and final. There is a tol parameter that might be very useful in your use case.

@mxmws
Copy link
Author

mxmws commented Mar 10, 2024

You mean I could use a fuzzy boolean operation to subtract one shape from the other and see if anything is left? That's a cool idea! Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants