
Sat, 06/28/2003 - 04:26
Forums:
Hello,
If I make two spheres:
TopoDS_Shape Shape1 = BRepPrimAPI_MakeSphere(10);
TopoDS_Shape Shape2 = BRepPrimAPI_MakeSphere(10);
Shape1 == Shape2 returns false.
Is there a method that compares two shapes to determine if they are equivalent?
Thank you for any help,
Mike
Sat, 06/28/2003 - 05:37
Hi,
the == operator don't take care of the content, but only take care of the pointers of TShape, and Location,etc inside the TopoDS_Shape.
So, if you build two shapes by builder API, they are totally different shapes, even though they have same geometry, because they have different memory allocations.
If you want to know they have equivalent geometry, I think you should go inside the geometries of the shape, and compare them one by one.
If anyone have a better solution, please let me know.
I hope this helps you...
Thanks.
Mon, 06/30/2003 - 18:08
That's the only solution I see, too.
Tue, 07/01/2003 - 04:28
Hi,
Maybe your can find out the Sphere Center and Radius and then compare them.
TopoDS_Face F;
for (TopExp_Explorer exp(Shape1,TopAbs_FACE); exp.More(); exp.Next()) {
F = TopoDS::Face(exp.Current());
}
Handle(Geom_Surface) S = BRep_Tool::Surface (F);
gp_Pnt Center1 = (Handle Geom_SphericalSurface)::DownCast(S))->Sphere().Location();
Standard_Real Radius1=Handle Geom_SphericalSurface)::DownCast(S))->Radisu();
Sincerely,
Angel
Tue, 07/01/2003 - 07:09
Hi,
That would probably work for the spheres, but I'm afraid I mislead you with the way I worded the question. I'm actually inquiring about a method to compare two TopoDS_Shape objects of arbitrary shape. I used the spheres only to demonstrate the problem.
Regards,
Mike
Tue, 07/01/2003 - 07:24
Hi,
I'm sorry, my suggestion focus on sphere.
Mon, 06/30/2003 - 15:51
to compare two shapes you can use the IsPartner() or IsSame() methods from TopoDS_Shape.
good luck
Mon, 06/30/2003 - 19:49
Since Shape1 and Shape2 do not share the same underlying shape, these methods return false.
Thu, 02/10/2005 - 22:15
Have you solved this problem? I also have the same problem. If so, would you let me pls? email: m.li@cs.cf.ac.uk
Thu, 02/10/2005 - 22:19
Why not use boolean operations to compare the two? Subtract one from the other and if you're left with nothing they're equal. I've never tried it, but shouldn't that work?
Thu, 02/10/2005 - 22:59
They might be of the same geometric expression equation but of different U,V parameters.
Fri, 12/21/2018 - 13:37
Was there ever something made for this problem? I want to compare shapes too and see if they are equal. I need this to remove all duplicate items in big assemblies so I only have to process them once.
Please help I've tried everything I could find but nothing worked so far.
Fri, 12/21/2018 - 14:15
Hi Rudie,
You may want to try out hunting down duplicates function in CAD Processor software (https://www.opencascade.com/content/cad-processor). Free trial is available for downloading. Just select the root assembly item, then click "Assembly", then "Duplicates".
Kind regards,
Sergey.
Fri, 12/21/2018 - 15:16
Hi Sergey,
Yes that function does exactly what I need only I want to do it automated via the open source library is that possible or is this only possible with the CAD Processor SDK? Thanks for the help.
Fri, 12/21/2018 - 15:46
Rudie, this function is a part of our commercial software package. CAD Processor is based on OCCT and, of course, this function operates with topological and geometric data structures of the kernel. But the algorithm itself is entirely custom. Also, to optimize assemblies, we use a dedicated data framework (XDE) which represents those assemblies with preserved instancing. Whenever you optimize duplicates, you should usually care about associated metadata (colors, PMIs), so this feature is not 100% geometric.
CAD Processor can be used not only as SDK but also as a batch utility if you consider converting your files all at once in a separate process. The most affordable option will be to use STEP format as input, STEP format as an output and scripting (Tcl) for automation of the logic. If you ever consider using our commercial offer like this, please, contact our sales via the contact form.
Hope this helps,
Sergey.
Mon, 02/24/2020 - 18:25
Hi, this is a very old post. This is a working solution