Good morning !
In OCC, does it exist a function to know whether a TopoDS_Edge is on a Face, and is on its boundary ?
Thank you very much !
As far as I know there is no such function. But you can implement it by
1. Get the boundary of the face.
There is a function called BRepTools::OutWire(), but sometimes it does not work.
aOuterWire = BRepTools::OuterWire(aFace);
2. Compare the edge with edges on the boundary.
If the edge share the same TEdge with an edge on the boundary, you can just
compare the TEdges and locations of the two edges.
Edge1.TShape() == Edge2.TShape() && Loc1 == Loc2
For shape (here: edge) comparison, you can also use the following functions of TopoDS_Shape:
See corresponding Doxygen documentation for details.
Thank you for this answer. I tried this with a square face and an edge corresponding of one of the "sub-edges" of my face, but they returned false.
Using TopExp::FirstVertex / LastVertex, I discovered that :
- the extremities (equal in my CAO) had not exactly the same coordinates (an error about 1e-17) Is there a way to define the tolerance ?
- they were reversed (first vertex of one corresponding to last vertex of the other). Is there any way to fix that ?
Thank you !
The TopoDS_Shape functions are only helpful if two edges share the same TEdge object as George Feng explained. I don't know when exactly this is the case. Probably, e.g. when you sew two faces they share the same common edge. Or if you copy an edge or transform it.
In your case, you probably have to compare geometrical properties, e.g. the position of first and last vertex, the type of geometry,...
Does somebody know if there is a standard way to do such comparisons?
I think the error is caused by approximation of the initial CAO (STEP created by Rhino).
After trying using some different classes (IntToolsEdgeEdge, BRepExtrema_ExtCC, GeomAPI_ExtremaCurveCurve), without any success), I thought that the only way was to compare two Edges A et B was
- to performe bool operations : C = CUT( A, COMMON(A,B) )
- to test C.IsNull, or C is a compound of vertex or very small edges.
Do you think it will work ? Is there a less complex operation possible ?
I have seen a part of codes in OCC, where the first and last parametersand, and points at u=0.3*C1f+0.7*C1l of two edges are compared.
//function : SameCurve
Standard_Boolean SameCurve(const Handle_Adaptor2d_HCurve2d& C1,const Handle_Adaptor2d_HCurve2d& C2)
Standard_Real C1f = C1->FirstParameter();
Standard_Real C2f = C2->FirstParameter();
Standard_Real C1l = C1->LastParameter();
Standard_Real C2l = C2->LastParameter();
gp_Pnt2d P1 = C1->Value(u);
gp_Pnt2d P2 = C2->Value(u);
You can also compare the types of the two edges as suggested by Timo.
The above method is only an approximate justification whether two edges are the same.
I also test three points in my program. If someone get some better methods to justify whether two edges are the same, please post here and thanks a lot.
int OccUtility::IsCurveEqual(TopoDS_Edge &aEdge_1, TopoDS_Edge &aEdge_2)
int nResult = 0;
int IsSatisfied_1 = 1, IsSatisfied_2 = 1;