X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Tools.cpp;h=8a4c158f3935ca4a311730804b968411d35990c2;hb=857b1f72d9703c46c6c8c9bb239821d314344c86;hp=f9c42efa58aa0457e1ea33ab00829d396bb86cec;hpb=2775c2b7d34412925b56421691e6d4cb412e20c4;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp old mode 100644 new mode 100755 index f9c42efa5..8a4c158f3 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -178,68 +178,6 @@ std::shared_ptr PartSet_Tools::convertTo3D(const double theX, const return aPnt2d->to3D(aC->pnt(), aX->dir(), aY); } -ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, - FeaturePtr theSketch, - const QList& theSelected, - const QList& theHighlighted) -{ - // firstly it finds the feature in the list of highlight - ObjectPtr aDeltaObject = nearestFeature(thePoint, theView, theSketch, theHighlighted); - if (!aDeltaObject) - // secondly it finds the feature in the list of selected objects - aDeltaObject = nearestFeature(thePoint, theView, theSketch, theSelected); - - return aDeltaObject; -} - -ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, - FeaturePtr theSketch, - const QList& thePresentations) -{ - ObjectPtr aDeltaObject; - - CompositeFeaturePtr aSketch = - std::dynamic_pointer_cast(theSketch); - // 1. find it in the selected list by the selected point - if (!aDeltaObject) { - double aX, anY; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView); - PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY); - - FeaturePtr aFeature; - double aMinDelta = -1; - ModuleBase_ViewerPrs aPrs; - foreach (ModuleBase_ViewerPrs aPrs, thePresentations) { - if (!aPrs.object()) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); - std::shared_ptr aSketchFeature = std::dynamic_pointer_cast< - SketchPlugin_Feature>(aFeature); - if (!aSketchFeature || !aSketch->isSub(aSketchFeature)) - continue; - - double aDelta = aSketchFeature->distanceToPoint( - std::shared_ptr(new GeomAPI_Pnt2d(aX, anY))); - if (aMinDelta < 0 || aMinDelta > aDelta) { - aMinDelta = aDelta; - // TODO aDeltaObject = aPrs.result(); - } - } - } - // 2. if the object is not found, returns the first selected sketch feature - if (!aDeltaObject && thePresentations.size() > 0) { - // there can be some highlighted objects, e.g. a result of boolean operation and a sketch point - foreach (ModuleBase_ViewerPrs aPrs, thePresentations) { - if (!aPrs.object()) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aPrs.object()); - if (aFeature && aSketch->isSub(aFeature)) - aDeltaObject = aPrs.object(); - } - } - return aDeltaObject; -} - std::shared_ptr PartSet_Tools::document() { return ModelAPI_Session::get()->moduleDocument(); @@ -480,8 +418,9 @@ ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape, } ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, - const ObjectPtr& theObject, - CompositeFeaturePtr theSketch) + const ObjectPtr& theObject, + CompositeFeaturePtr theSketch, + const bool theTemporary) { if (theShape.ShapeType() == TopAbs_EDGE) { Standard_Real aStart, aEnd; @@ -517,14 +456,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap anEdge->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, anEdge); - - aMyFeature->execute(); - - // fix this edge - FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); - aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> - setObject(aMyFeature->lastResult()); - + //if (!theTemporary) { + aMyFeature->execute(); + + // fix this edge + FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); + aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> + setObject(aMyFeature->lastResult()); + //} return aMyFeature->lastResult(); } } @@ -544,13 +483,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap aVert->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, aVert); - aMyFeature->execute(); - - // fix this edge - FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); - aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> - setObject(aMyFeature->lastResult()); - + //if (theTemporary) { + aMyFeature->execute(); + + // fix this edge + FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); + aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> + setObject(aMyFeature->lastResult()); + //} return aMyFeature->lastResult(); } } @@ -712,8 +652,10 @@ std::shared_ptr PartSet_Tools::getPoint(std::shared_ptr anAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(theFeature->data()->attribute(theAttribute)); - if (anAttr) - aFeature = ModelAPI_Feature::feature(anAttr->object()); + if (!anAttr) + return std::shared_ptr(); + + aFeature = ModelAPI_Feature::feature(anAttr->object()); if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) aPointAttr = std::dynamic_pointer_cast( @@ -731,6 +673,7 @@ void PartSet_Tools::findCoincidences(FeaturePtr theStartCoin, QList& std::string theAttr) { AttributeRefAttrPtr aPnt = theStartCoin->refattr(theAttr); + if (!aPnt) return; FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object()); if (!theList.contains(aObj)) { std::shared_ptr aOrig = getPoint(theStartCoin, theAttr);