#include <TopoDS.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
+#include <ElCLib.hxx>
+#include <GCPnts_UniformAbscissa.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
double aInStart, aInEnd;
Handle(Geom_Curve) aInCurve = BRep_Tool::Curve(TopoDS::Edge(aInShape), aInStart, aInEnd);
+ // Check that end point parameters are the same
+ if ((aMyStart != aInStart) || (aMyEnd != aInEnd))
+ return false;
+
// Check that curves a the same type
GeomAdaptor_Curve aMyAdaptor(aMyCurve);
GeomAdaptor_Curve aInAdaptor(aInCurve);
if (aMyAdaptor.GetType() != aInAdaptor.GetType())
return false;
- // Check that end point parameters are the same
- if ((aMyStart != aInStart) || (aMyEnd != aInEnd))
- return false;
-
// Check that end points are equal
gp_Pnt aMyPnt1 = aMyAdaptor.Value(aMyStart);
gp_Pnt aMyPnt2 = aMyAdaptor.Value(aMyEnd);
if (aIntersect.IsDone() && (aIntersect.NbPoints() > 0)) {
gp_Pnt aPnt;
for (int i = 1; i <= aIntersect.NbPoints(); i++) {
+ // check the parameter of intersection in the edge range
+ aIntersect.Parameters(i, A, B, C);
+ if (aCurve->IsPeriodic())
+ C = ElCLib::InPeriod(C, aFirst, aFirst + aCurve->Period());
+ if (C < aFirst - Precision::PConfusion() || C > aLast + Precision::PConfusion())
+ continue;
+
+ // obtain intersection point
aPnt = aIntersect.Point(i);
std::shared_ptr<GeomAPI_Pnt> aPntPtr(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
theResult.push_back(aPntPtr);
TopExp::Vertices(anEdge, aVFirst, aVLast);
BRep_Builder().UpdateVertex(aVLast, theTolerance);
}
+
+GeomPointPtr GeomAPI_Edge::middlePoint() const
+{
+ GeomPointPtr aMiddlePoint;
+
+ const TopoDS_Edge& anEdge = impl<TopoDS_Edge>();
+ if (anEdge.IsNull())
+ return aMiddlePoint;
+ double aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
+ if (aCurve.IsNull())
+ return aMiddlePoint;
+
+ static const int NB_POINTS = 3;
+ GeomAdaptor_Curve aCurveAdaptor(aCurve, aFirst, aLast);
+ GCPnts_UniformAbscissa anAlgo(aCurveAdaptor, NB_POINTS);
+ if (anAlgo.IsDone()) {
+ gp_Pnt aPnt = aCurveAdaptor.Value(anAlgo.Parameter(2));
+ aMiddlePoint = GeomPointPtr(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+ }
+ return aMiddlePoint;
+}