how to verify 2 faces share one same edge

For any 2 faces that join at one edge, I usually iterate each edge edge1 from face 1 and edge2 from face 2, and then make a comparison by using the below code:
edge1.TShape() == edge2.TShape()
or
edge1.IsPartner(edge2)

It doesn't work as expected always, as sometimes the edges' TShape do differ, even though they're actually the same in the model, I mean, they have the same curve type and start/end points.

Is there a better way to verify it?

Thanks.

Boqing Dong's picture

I tried to dump the json data of the 2 edges in question if it's goanna help:

The json data here:

Edge1:
"className": "BRep_TEdge"
"className": "TopoDS_TShape"
"this": "0x2137B5F97F0"
"ShapeType": 6
"NbChildren": 2
"Flags": 10
"Free": 0
"Free": 0
"Locked": 0
"Modified": 1
"Checked": 0
"Orientable": 1
"Closed": 0
"Infinite": 0
"Convex": 0
"Tolerance": 1e-07
"Flags": 3
"CurveRepresentation":
{
"className": "BRep_Curve3D", "className": "BRep_GCurve", "className": "BRep_CurveRepresentation", "Location": {"className": "TopLoc_Location", "Transformation": {"Location": [0, 0, 0], "Matrix": [1, 0, 0, 0, 1, 0, 0, 0, 1], "shape": 0, "scale": 1}, "IsIdentity": 1}, "First": 0, "Last": 10, "Curve": {"className": "Geom_BSplineCurve", "className": "Geom_BoundedCurve", "className": "Geom_Curve", "className": "Geom_Geometry", "rational": 0, "periodic": 0, "knotSet": 3, "smooth": 6, "deg": 1, "poles->Size": 2, "flatknots->Size": 4, "knots->Size": 2, "mults->Size": 2, "maxderivinv": 0, "maxderivinvok": 0}}
"CurveRepresentation":
{
"className": "BRep_CurveOnSurface", "className": "BRep_GCurve", "className": "BRep_CurveRepresentation", "Location": {"className": "TopLoc_Location", "Transformation": {"Location": [0, 0, 0], "Matrix": [1, 0, 0, 0, 1, 0, 0, 0, 1], "shape": 0, "scale": 1}, "IsIdentity": 1}, "First": 0, "Last": 10, "UV1": {"gp_Pnt2d": [0, 10]}, "UV2": {"gp_Pnt2d": [10, 10]}, "PCurve": {"className": "Geom2d_Line", "className": "Geom2d_Curve", "className": "Geom2d_Geometry", "pos": {"className": "gp_Ax2d", "loc": {"gp_Pnt2d": [0, 10]}, "vdir": {"gp_Dir2d": [1, 0]}}}, "Surface": {"className": "Geom_BSplineSurface", "className": "Geom_Surface", "className": "Geom_Geometry", "urational": 0, "vrational": 0, "uperiodic": 0, "vperiodic": 0, "uknotSet": 3, "vknotSet": 3, "Usmooth": 6, "Vsmooth": 6, "udeg": 1, "vdeg": 1, "poles->Size": 4, "weights->Size": 4, "ufknots->Size": 4, "vfknots->Size": 4, "uknots->Size": 2, "vknots->Size": 2, "umults->Size": 2, "vmults->Size": 2, "umaxderivinv": 0.707107, "vmaxderivinv": 0.707107, "maxderivinvok": 1}}
===============================================================================================

Edge2:
"className": "BRep_TEdge"
"className": "TopoDS_TShape"
"this": "0x2137B5F9F70"
"ShapeType": 6
"NbChildren": 2
"Flags": 10
"Free": 0
"Free": 0
"Locked": 0
"Modified": 1
"Checked": 0
"Orientable": 1
"Closed": 0
"Infinite": 0
"Convex": 0
"Tolerance": 1e-07
"Flags": 3
"CurveRepresentation":
{
"className": "BRep_Curve3D", "className": "BRep_GCurve", "className": "BRep_CurveRepresentation", "Location": {"className": "TopLoc_Location", "Transformation": {"Location": [0, 0, 0], "Matrix": [1, 0, 0, 0, 1, 0, 0, 0, 1], "shape": 0, "scale": 1}, "IsIdentity": 1}, "First": 20, "Last": 30, "Curve": {"className": "Geom_BSplineCurve", "className": "Geom_BoundedCurve", "className": "Geom_Curve", "className": "Geom_Geometry", "rational": 0, "periodic": 0, "knotSet": 3, "smooth": 6, "deg": 1, "poles->Size": 2, "flatknots->Size": 4, "knots->Size": 2, "mults->Size": 2, "maxderivinv": 0, "maxderivinvok": 0}}
"CurveRepresentation":
{
"className": "BRep_CurveOnSurface", "className": "BRep_GCurve", "className": "BRep_CurveRepresentation", "Location": {"className": "TopLoc_Location", "Transformation": {"Location": [0, 0, 0], "Matrix": [1, 0, 0, 0, 1, 0, 0, 0, 1], "shape": 0, "scale": 1}, "IsIdentity": 1}, "First": 20, "Last": 30, "UV1": {"gp_Pnt2d": [20, 10]}, "UV2": {"gp_Pnt2d": [30, 10]}, "PCurve": {"className": "Geom2d_Line", "className": "Geom2d_Curve", "className": "Geom2d_Geometry", "pos": {"className": "gp_Ax2d", "loc": {"gp_Pnt2d": [0, 10]}, "vdir": {"gp_Dir2d": [1, 0]}}}, "Surface": {"className": "Geom_BSplineSurface", "className": "Geom_Surface", "className": "Geom_Geometry", "urational": 0, "vrational": 0, "uperiodic": 0, "vperiodic": 0, "uknotSet": 3, "vknotSet": 3, "Usmooth": 6, "Vsmooth": 6, "udeg": 1, "vdeg": 1, "poles->Size": 4, "weights->Size": 4, "ufknots->Size": 4, "vfknots->Size": 4, "uknots->Size": 2, "vknots->Size": 2, "umults->Size": 2, "vmults->Size": 2, "umaxderivinv": 0.707107, "vmaxderivinv": 0.707107, "maxderivinvok": 1}}

Dmitrii Pasukhin's picture

Hello, in this case it is not possible to easy equal. The pointers are different. As a solution, you can additionally compare Handle of own curve. If the the same, it can helps. But if it is not. You will need to make deep comparison. Unfortunately, I don't know the prepared functions for that.

Best regards,Dmitrii.

Boqing Dong's picture

Dear Dmitrii,

Thank you very much for the elaboration.

You mentioned the comparison of curve handles. Can you give me a quick example of how to do it?

Best regards, Boqing

Dmitrii Pasukhin's picture
TopoDS_Edge anOrigin, aNewEdge;
TopLoc_Location aDummyLoc;
Standard_Real aDummyEnd, aDummyStart;
cons auto anOrigCurve = BRep_Tool::Curve(anOrigin, aDummyLoc, aDummyStart, aDummyEnd);
cons auto anNewCurve = BRep_Tool::Curve(aNewEdge, aDummyLoc, aDummyStart, aDummyEnd);
return anOrigCurve == anNewCurve;