From: vsv Date: Thu, 20 Jul 2017 09:39:42 +0000 (+0300) Subject: Issue #2208: Development X-Git-Tag: V_2.9.0~23^2~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=75e130f1c5c99bface65d619c0b285d81191f9bf;p=modules%2Fshaper.git Issue #2208: Development --- diff --git a/src/GeomAPI/GeomAPI_Ax3.h b/src/GeomAPI/GeomAPI_Ax3.h index 6e743363c..3da31148a 100644 --- a/src/GeomAPI/GeomAPI_Ax3.h +++ b/src/GeomAPI/GeomAPI_Ax3.h @@ -94,4 +94,7 @@ public: }; +//! Pointer on the object +typedef std::shared_ptr GeomAx3Ptr; + #endif \ No newline at end of file diff --git a/src/GeomAPI/GeomAPI_Pnt2d.h b/src/GeomAPI/GeomAPI_Pnt2d.h index ef633be17..ac6365a71 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.h +++ b/src/GeomAPI/GeomAPI_Pnt2d.h @@ -76,5 +76,8 @@ class GeomAPI_Pnt2d : public GeomAPI_Interface bool isEqual(const std::shared_ptr& theOther) const; }; +//! Pointer on the object +typedef std::shared_ptr GeomPnt2dPtr; + #endif diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index b57344d71..8897fa16e 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -25,10 +25,16 @@ #include #include #include +#include + +#include +#include +#include #include #include #include +#include static SketcherPrs_PositionMgr* MyPosMgr = NULL; @@ -176,10 +182,45 @@ gp_Pnt SketcherPrs_PositionMgr::getPosition(ObjectPtr theShape, return aP; } + +//***************************************************************** +//! Returns curves connected to the given point +TColGeom_SequenceOfCurve getCurves(const GeomPointPtr& thePnt, const SketcherPrs_SymbolPrs* thePrs) +{ + TColGeom_SequenceOfCurve aList; + //GeomAx3Ptr aAx3 = thePrs->plane(); + //CompositeFeaturePtr aOwner = thePrs->sketcher(); + //GeomPnt2dPtr aPnt2d = thePnt->to2D(aAx3->origin(), aAx3->dirX(), aAx3->dirY()); + + //int aNbSubs = aOwner->numberOfSubs(); + //for (int i = 0; i < aNbSubs; i++) { + // FeaturePtr aFeature = aOwner->subFeature(i); + // if (aFeature->getKind() == SketchPlugin_Line::ID()) { + // GeomPnt2dPtr aPnt1 = + // SketcherPrs_Tools::getPoint(aFeature.get(), SketchPlugin_Line::START_ID()); + // GeomPnt2dPtr aPnt2 = + // SketcherPrs_Tools::getPoint(aFeature.get(), SketchPlugin_Line::END_ID()); + // if (aPnt1->isEqual(aPnt2d) || aPnt2->isEqual(aPnt2d)) { + // GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult()); + // GeomCurvePtr aCurv = std::shared_ptr(new GeomAPI_Curve(aShp)); + // aList.Append(aCurv->impl()); + // } + // } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) || + // (aFeature->getKind() == SketchPlugin_Arc::ID())) { + // GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult()); + // GeomCurvePtr aCurv = std::shared_ptr(new GeomAPI_Curve(aShp)); + // } + //} + return aList; +} + +//***************************************************************** gp_Pnt SketcherPrs_PositionMgr::getPointPosition( ObjectPtr theLine, const SketcherPrs_SymbolPrs* thePrs, double theStep, GeomPointPtr thePnt) { + TColGeom_SequenceOfCurve aCurves = getCurves(thePnt, thePrs); + gp_Pnt aP = thePnt->impl(); gp_Vec aVec1 = getVector(theLine, thePrs->plane()->dirX(), aP); @@ -191,7 +232,7 @@ gp_Pnt SketcherPrs_PositionMgr::getPointPosition( return aP; } - +//***************************************************************** void SketcherPrs_PositionMgr::deleteConstraint(const SketcherPrs_SymbolPrs* thePrs) { std::map::iterator aIt; diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index 2f0758204..2f75d8519 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -413,3 +415,8 @@ void SketcherPrs_SymbolPrs::BoundingBox(Bnd_Box& theBndBox) aTmpBox.CornerMax().x(), aTmpBox.CornerMax().y(), aTmpBox.CornerMax().z()); } +//********************************************************************************* +CompositeFeaturePtr SketcherPrs_SymbolPrs::sketcher() const +{ + return ModelAPI_Tools::compositeOwner(FeaturePtr(myConstraint)); +} \ No newline at end of file diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index a8b64d21e..c1cf2b554 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -24,6 +24,7 @@ #include "SketcherPrs_SensitivePoint.h" #include #include +#include #include #include @@ -76,6 +77,9 @@ public: /// Returns feature object Standard_EXPORT ModelAPI_Feature* feature() const { return myConstraint; } + /// Returns Sketcher object (owner of the constraint) + Standard_EXPORT CompositeFeaturePtr sketcher() const; + /// Return array of points where symbols will be placed const Handle(Graphic3d_ArrayOfPoints)& pointsArray() const { return myPntArray; } diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 8358b07e6..017e5fc64 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -78,19 +78,24 @@ bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep, bool withColor) GeomCurvePtr aLine; GeomCirclePtr aCircle; + double aFirst, aLast; if (aCurv1->isLine()) { aLine = aCurv1; aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurv2)); + aFirst = aCurv2->startParam(); + aLast = aCurv2->endParam(); } else { aLine = aCurv2; aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurv1)); + aFirst = aCurv1->startParam(); + aLast = aCurv1->endParam(); } GeomPointPtr aPnt1 = aLine->getPoint(aLine->startParam()); GeomPointPtr aPnt2 = aLine->getPoint(aLine->endParam()); double aParam; GeomPointPtr aPnt; - if (aCircle->parameter(aPnt1, 1.e-4, aParam)) + if (aCircle->parameter(aPnt1, 1.e-4, aParam) && (aParam >= aFirst) && (aParam <= aLast)) aPnt = aPnt1; else aPnt = aPnt2;