- }
- return aIntCount;
-}
-
-static Standard_Integer IntersectCurve(
- const NCollection_Vector<TopoDS_Edge>& theEdges,
- const TopoDS_Wire& theWire,
- NCollection_Vector<NCollection_Sequence<Standard_Real> >& theParameters)
-{
- Standard_Integer aIntCount = 0;
- const Standard_Integer aECount1 = theEdges.Size();
- for (Standard_Integer aEI1 = 0; aEI1 < aECount1; ++aEI1)
- {
- const TopoDS_Edge& aEdge1 = theEdges(aEI1);
- TopExp_Explorer aEIt2(theWire, TopAbs_EDGE);
- for (; aEIt2.More(); aEIt2.Next())
- {
- aIntCount += IntersectEdge(aEdge1,
- TopoDS::Edge(aEIt2.Current()), theParameters(aEI1));
- }
- }
- return aIntCount;
-}
-
-static void CloseCurve(NCollection_Sequence<TopoDS_Edge>& theCurve)
-{
- const TopoDS_Vertex aVertex = TopoDS::Vertex(TopExp::LastVertex(
- theCurve.Last(), Standard_True).Oriented(TopAbs_FORWARD));
- const TopoDS_Edge& aEdge = theCurve.First();
- const TopoDS_Edge aForwardEdge = TopoDS::Edge(aEdge.Oriented(TopAbs_FORWARD));
- theCurve.ChangeFirst() = TopoDS::Edge(ShapeBuild_Edge().CopyReplaceVertices(
- aForwardEdge, aVertex, TopoDS_Vertex()).Oriented(aEdge.Orientation()));
-}
-
-static Standard_Boolean IsClosed(
- const NCollection_Sequence<TopoDS_Edge>& theCurve)
-{
- return TopExp::FirstVertex(theCurve.First(), Standard_True).
- IsSame(TopExp::LastVertex(theCurve.Last(), Standard_True));
-}
-
-static void ExtendCurve(
- const Standard_Integer thePosition,
- NCollection_Sequence<TopoDS_Edge>& theCurve,
- NCollection_Sequence<TopoDS_Edge>& theExtension)
-{
- if (thePosition == 0)
- {
- const TopoDS_Vertex aVertex = TopoDS::Vertex(TopExp::LastVertex(
- theExtension.Last(), Standard_True).Oriented(TopAbs_FORWARD));
- TopoDS_Edge& aEdge = theCurve.ChangeFirst();
- aEdge = TopoDS::Edge(ShapeBuild_Edge().CopyReplaceVertices(
- TopoDS::Edge(aEdge.Oriented(TopAbs_FORWARD)), aVertex, TopoDS_Vertex()).
- Oriented(aEdge.Orientation()));
- theCurve.Prepend(theExtension);
- }
- else
- {
- const TopoDS_Vertex aVertex = TopoDS::Vertex(TopExp::FirstVertex(
- theExtension.First(), Standard_True).Oriented(TopAbs_REVERSED));
- TopoDS_Edge& aEdge = theCurve.ChangeLast();
- aEdge = TopoDS::Edge(ShapeBuild_Edge().CopyReplaceVertices(
- TopoDS::Edge(aEdge.Oriented(TopAbs_FORWARD)), TopoDS_Vertex(), aVertex).
- Oriented(aEdge.Orientation()));
- theCurve.Append(theExtension);
- }
-}
-
-static void ExtendCurve(
- const Standard_Integer thePosition,
- const TopoDS_Edge& theExtension,
- NCollection_Sequence<TopoDS_Edge>& theCurve)
-{
- NCollection_Sequence<TopoDS_Edge> aExtension;
- aExtension.Append(theExtension);
- ExtendCurve(thePosition, theCurve, aExtension);
-}
-
-static gp_XYZ Tangent(
- const Adaptor3d_Curve& theCurve, const Standard_Integer thePosition)
-{
- const Standard_Real aParam = (thePosition == 0) ?
- theCurve.FirstParameter() : theCurve.LastParameter();
- gp_Pnt aP;
- gp_Vec aV;
- theCurve.D1(aParam, aP, aV);
- Standard_Real aNorm = aV.Magnitude();
- aNorm = (aNorm >= Precision::PConfusion()) ? aNorm : 0;
- return ((1 / aNorm) * aV).XYZ();
-}
-
-static gp_XYZ Tangent(
- const TopoDS_Edge& theEdge, const Standard_Integer thePosition)
-{
- BRepAdaptor_Curve aCurve(theEdge);
- return Tangent(BRepAdaptor_Curve(theEdge), thePosition);
-}