]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2208: Development
authorvsv <vsv@opencascade.com>
Thu, 20 Jul 2017 09:39:42 +0000 (12:39 +0300)
committervsv <vsv@opencascade.com>
Thu, 20 Jul 2017 09:39:42 +0000 (12:39 +0300)
src/GeomAPI/GeomAPI_Ax3.h
src/GeomAPI/GeomAPI_Pnt2d.h
src/SketcherPrs/SketcherPrs_PositionMgr.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Tangent.cpp

index 6e743363c3bcb13816b901238501675be0f22d36..3da31148a9aeeee0be0122fb20e52478d2ac705b 100644 (file)
@@ -94,4 +94,7 @@ public:
 };
 
 
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Ax3> GeomAx3Ptr;
+
 #endif
\ No newline at end of file
index ef633be17ccb9d0836ab3da0d72fc0c34d379535..ac6365a717d3fcdba76937ef82c96c8fc9e21976 100644 (file)
@@ -76,5 +76,8 @@ class GeomAPI_Pnt2d : public GeomAPI_Interface
   bool isEqual(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
 };
 
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Pnt2d> GeomPnt2dPtr;
+
 #endif
 
index b57344d712d5be8cf88d19ed41c6658f2902ebcc..8897fa16e1566da48e06ea8e27fb2c23c5bf0e81 100644 (file)
 #include <GeomAPI_Curve.h>
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Dir.h>
+#include <GeomAPI_Ax3.h>
+
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
 
 #include <BRepExtrema_ExtPC.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <Geom_Curve.hxx>
+#include <TColGeom_SequenceOfCurve.hxx>
 
 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<GeomAPI_Curve>(new GeomAPI_Curve(aShp));
+  //      aList.Append(aCurv->impl<Handle(Geom_Curve)>());
+  //    }
+  //  } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) ||
+  //            (aFeature->getKind() == SketchPlugin_Arc::ID())) {
+  //    GeomShapePtr aShp = SketcherPrs_Tools::getShape(aFeature->firstResult());
+  //    GeomCurvePtr aCurv = std::shared_ptr<GeomAPI_Curve>(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_Pnt>();
   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<ObjectPtr, PositionsMap>::iterator aIt;
index 2f0758204701392a23a1d1c4133a5a926a593fbe..2f75d85191941b669f27c53da05f8b1252bc0b3b 100644 (file)
@@ -26,6 +26,8 @@
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Curve.h>
 
+#include <ModelAPI_Tools.h>
+
 #include <Events_InfoMessage.h>
 
 #include <Graphic3d_ArrayOfSegments.hxx>
@@ -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
index a8b64d21e52d847f65ed413b512ef2be1c82e2b5..c1cf2b55477f6484125f61f95a70fc8ee7d4cf0d 100644 (file)
@@ -24,6 +24,7 @@
 #include "SketcherPrs_SensitivePoint.h"
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_CompositeFeature.h>
 
 #include <AIS_InteractiveObject.hxx>
 #include <GeomAPI_Ax3.h>
@@ -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; }
 
index 8358b07e6f5e703938dd766cb45bcbd0eb44f444..017e5fc64d621a31bd4fb9352de62f33c934e780 100644 (file)
@@ -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;