X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Tools.cpp;h=9157938f1fbb2e37928d7173ae094eb1acd5c5dd;hb=6f84fd29d85b783864cdbb3ac9fdd6a3ad3cbb7c;hp=3eb4cc1fb6f2b4f24a879494ad909d804ec2ead5;hpb=871b614264ee552393170b1dec8942f831fba188;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 3eb4cc1fb..9157938f1 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -220,7 +220,7 @@ std::shared_ptr PartSet_Tools::getFeaturePoint(FeaturePtr t std::shared_ptr aClickedPoint = std::shared_ptr( new GeomAPI_Pnt2d(theX, theY)); std::list > anAttiributes = - theFeature->data()->attributes(GeomDataAPI_Point2D::type()); + theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list >::const_iterator anIt = anAttiributes.begin(), aLast = anAttiributes.end(); std::shared_ptr aFPoint; @@ -308,6 +308,35 @@ void PartSet_Tools::createConstraint(CompositeFeaturePtr theSketch, aFeature->execute(); } +std::shared_ptr PartSet_Tools:: + findAttributePoint(CompositeFeaturePtr theSketch, double theX, double theY, + double theTolerance, const QList& theIgnore) +{ + std::shared_ptr aClickedPoint = std::shared_ptr( + new GeomAPI_Pnt2d(theX, theY)); + + std::list > anAttiributes; + for (int i = 0; i < theSketch->numberOfSubs(); i++) { + FeaturePtr aFeature = theSketch->subFeature(i); + if (!theIgnore.contains(aFeature)) { + anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); + + std::list >::const_iterator anIt; + for (anIt = anAttiributes.cbegin(); anIt != anAttiributes.cend(); ++anIt) { + std::shared_ptr aCurPoint = + std::dynamic_pointer_cast(*anIt); + double x = aCurPoint->x(); + double y = aCurPoint->y(); + if (aCurPoint && (aCurPoint->pnt()->distance(aClickedPoint) < theTolerance)) { + return aCurPoint; + } + } + } + } + return std::shared_ptr(); +} + + void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr theFeature, const std::string& theAttribute, double theClickedX, double theClickedY) @@ -333,15 +362,17 @@ void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr the for (; anIt != aLast; anIt++) { FeaturePtr aFeature = std::dynamic_pointer_cast(*anIt); // find the given point in the feature attributes - anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type()); + anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list >::const_iterator anIt = anAttiributes.begin(), aLast = anAttiributes.end(); std::shared_ptr aFPoint; for (; anIt != aLast && !aFPoint; anIt++) { - std::shared_ptr aCurPoint = std::dynamic_pointer_cast< - GeomDataAPI_Point2D>(*anIt); - if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion()) + std::shared_ptr aCurPoint = + std::dynamic_pointer_cast(*anIt); + if (aCurPoint && (aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion())) { aFPoint = aCurPoint; + break; + } } if (aFPoint) PartSet_Tools::createConstraint(theSketch, aFPoint, aFeaturePoint); @@ -595,7 +626,7 @@ AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj, // find the given point in the feature attributes std::list anAttiributes = - aFeature->data()->attributes(GeomDataAPI_Point2D::type()); + aFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list::const_iterator anIt = anAttiributes.begin(), aLast = anAttiributes.end(); for (; anIt != aLast && !anAttribute; anIt++) {