From: vsv Date: Tue, 21 Apr 2015 13:15:18 +0000 (+0300) Subject: Coincident with objects X-Git-Tag: V_1.2.0~189 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=47bc42239a014ab54525f88916f2633b9d520f58;p=modules%2Fshaper.git Coincident with objects --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 91b6f859e..42f95fb33 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -99,10 +99,6 @@ std::shared_ptr getPoint(std::shared_ptr& theFe aPointAttr = std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); - else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID()) - aPointAttr = std::dynamic_pointer_cast( - aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); - else if (anAttr->attr()) { aPointAttr = std::dynamic_pointer_cast(anAttr->attr()); } @@ -121,6 +117,8 @@ void findCoincidences(FeaturePtr theStartCoin, QList& theList, std:: FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object()); if (!theList.contains(aObj)) { std::shared_ptr aOrig = getPoint(theStartCoin, theAttr); + if (aOrig.get() == NULL) + return; theList.append(aObj); const std::set& aRefsList = aObj->data()->refsToMe(); std::set::const_iterator aIt; @@ -129,7 +127,7 @@ void findCoincidences(FeaturePtr theStartCoin, QList& theList, std:: FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { std::shared_ptr aPnt = getPoint(aConstrFeature, theAttr); - if (aOrig->isEqual(aPnt)) { + if (aPnt.get() && aOrig->isEqual(aPnt)) { findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_A()); findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_B()); } @@ -191,11 +189,18 @@ bool PartSet_MenuMgr::addViewerItems(QMenu* theMenu, const QMap aAttr = (*aIt); FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { - std::shared_ptr a2dPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A()); - if (aSelPnt->isEqual(a2dPnt)) { + std::shared_ptr a2dPnt = + getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A()); + if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { aCoincident = aConstrFeature; break; - } + } else { + a2dPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B()); + if (a2dPnt.get() && aSelPnt->isEqual(a2dPnt)) { + aCoincident = aConstrFeature; + break; + } + } } } // If we have coincidence then add Detach menu @@ -269,6 +274,9 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction) int aId = theAction->data().toInt(); FeaturePtr aLine = myCoinsideLines.at(aId); std::shared_ptr aOrig = getPoint(mySelectedFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A()); + if (aOrig.get() == NULL) + aOrig = getPoint(mySelectedFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B()); + gp_Pnt aOr = aOrig->impl(); const std::set& aRefsList = aLine->data()->refsToMe(); @@ -280,6 +288,10 @@ void PartSet_MenuMgr::onLineDetach(QAction* theAction) FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { std::shared_ptr aPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_A()); + if (aPnt.get() == NULL) + aPnt = getPoint(aConstrFeature, SketchPlugin_ConstraintCoincidence::ENTITY_B()); + if (aPnt.get() == NULL) + return; gp_Pnt aP = aPnt->impl(); if (aOrig->isEqual(aPnt)) { aToDelFeatures.append(aConstrFeature); diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp index b85d018b3..bc7d7824e 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.cpp +++ b/src/SketcherPrs/SketcherPrs_Coincident.cpp @@ -46,6 +46,8 @@ void SketcherPrs_Coincident::Compute(const Handle(PrsMgr_PresentationManager3d)& { std::shared_ptr aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_A()); + if (aPnt.get() == NULL) + aPnt = SketcherPrs_Tools::getPoint(myConstraint, SketchPlugin_Constraint::ENTITY_B()); if (aPnt.get() == NULL) return; diff --git a/src/SketcherPrs/SketcherPrs_Tools.cpp b/src/SketcherPrs/SketcherPrs_Tools.cpp index aeefdb8e7..f8891b225 100644 --- a/src/SketcherPrs/SketcherPrs_Tools.cpp +++ b/src/SketcherPrs/SketcherPrs_Tools.cpp @@ -58,10 +58,6 @@ std::shared_ptr getPoint(ModelAPI_Feature* theFeature, aPointAttr = std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); - else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID()) - aPointAttr = std::dynamic_pointer_cast( - aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); - else if (anAttr->attr()) { aPointAttr = std::dynamic_pointer_cast(anAttr->attr()); } @@ -89,10 +85,6 @@ std::shared_ptr getFeaturePoint(DataPtr theData, aPointAttr = std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); - else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID()) - aPointAttr = std::dynamic_pointer_cast( - aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); - else if (anAttr->attr()) { aPointAttr = std::dynamic_pointer_cast(anAttr->attr()); }