-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "SketcherPrs_PositionMgr.h"
#include "SketcherPrs_Tools.h"
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_Curve.h>
-#include <GeomAPI_Vertex.h>
-#include <GeomAPI_Dir.h>
#include <GeomAPI_Ax3.h>
#include <GeomAPI_Circ.h>
+#include <GeomAPI_Curve.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Ellipse.h>
+#include <GeomAPI_Dir.h>
#include <GeomAPI_Lin2d.h>
+#include <GeomAPI_Vertex.h>
#include <GeomDataAPI_Point2D.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_ConstraintTangent.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Ellipse.h>
+#include <SketchPlugin_Line.h>
#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintTangent.h>
#include <TopoDS_Vertex.hxx>
#include <Geom_Curve.hxx>
if (aUseFeature) {
DataPtr aData = aFeature->data();
AttributeRefAttrPtr aObjRef = aData->refattr(SketchPlugin_Constraint::ENTITY_A());
- FeaturePtr aObj = ModelAPI_Feature::feature(aObjRef->object());
+ FeaturePtr aObj;
+ if (aObjRef)
+ aObj = ModelAPI_Feature::feature(aObjRef->object());
bool aContains = false;
- if (containsPoint(aObj, aPnt2d, thePos)) {
+ if (aObj && containsPoint(aObj, aPnt2d, thePos)) {
aContains = true;
} else {
aObjRef = aData->refattr(SketchPlugin_Constraint::ENTITY_B());
- aObj = ModelAPI_Feature::feature(aObjRef->object());
- if (containsPoint(aObj, aPnt2d, thePos)) {
+ if (aObjRef)
+ aObj = ModelAPI_Feature::feature(aObjRef->object());
+ if (aObj && containsPoint(aObj, aPnt2d, thePos)) {
aContains = true;
}
}
std::shared_ptr<GeomAPI_Curve> aCurve =
std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
- if (aCurve->isCircle()) {
+ if (aCurve->isCircle() || aCurve->isEllipse()) {
Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
GeomAPI_ProjectPointOnCurve anExtr(theP, aCurv);
double aParam = anExtr.LowerDistanceParameter();
if (aDist <= Precision::Confusion())
aList.push_back(aFeature->firstResult());
}
- } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) ||
- (aFeature->getKind() == SketchPlugin_Arc::ID())) {
+ } else {
GeomCurvePtr aCurve;
ObjectPtr aResObj;
std::list<ResultPtr> aResults = aFeature->results();
}
}
if (aCurve.get()) {
- double aStart = aCurve->startParam();
- double aEnd = aCurve->endParam();
- GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve));
- GeomPointPtr aProjPnt = aCircle->project(thePnt);
+ GeomPointPtr aProjPnt;
+ if (aFeature->getKind() == SketchPlugin_Circle::ID() ||
+ aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve));
+ aProjPnt = aCircle->project(thePnt);
+ }
+ else if (aFeature->getKind() == SketchPlugin_Ellipse::ID()) {
+ GeomEllipsePtr anEllipse = GeomEllipsePtr(new GeomAPI_Ellipse(aCurve));
+ aProjPnt = anEllipse->project(thePnt);
+ }
if (aProjPnt && thePnt->distance(aProjPnt) <= Precision::Confusion())
aList.push_back(aResObj);
}
double theStep, GeomPointPtr thePnt)
{
gp_Pnt aP = thePnt->impl<gp_Pnt>();
+ if (!thePrs->plane().get())
+ return aP;
GeomDirPtr aNormal = thePrs->plane()->normal();
gp_Dir aNormDir = aNormal->impl<gp_Dir>();