X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintSplit.cpp;h=ccf819ab626e340bb18825946e1a40a6387a9e3d;hb=8f060aedd5949990421a96e3b4086f43efa13d24;hp=9ff84a54232f270380c0109a62c09e52b7ae6111;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 9ff84a542..ccf819ab6 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -93,6 +93,7 @@ void SketchPlugin_ConstraintSplit::execute() FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value()); ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature); std::set aFeaturesToDelete, aFeaturesToUpdate; + std::map aTangentFeatures; std::map aCoincidenceToFeature; getConstraints(aFeaturesToDelete, aFeaturesToUpdate, aTangentFeatures, aCoincidenceToFeature); @@ -216,6 +217,7 @@ void SketchPlugin_ConstraintSplit::execute() updateRefFeatureConstraints(getFeatureResult(aBaseFeature), aRefsToFeature); + AttributePtr aCenterAttr = aCircleFeature->attribute(SketchPlugin_Circle::CENTER_ID()); aFeaturesToDelete.insert(aCircleFeature); // as circle is removed, temporary fill this attribute*/ aBaseObjectAttr->setObject(ResultPtr()); @@ -278,7 +280,7 @@ void SketchPlugin_ConstraintSplit::execute() // coincidence to feature updateCoincidenceConstraintsToFeature(aCoincidenceToFeature, aFurtherCoincidences, - aFeatureResults); + aFeatureResults, aSplitFeature); // tangency updateTangentConstraintsToFeature(aTangentFeatures, aFurtherCoincidences); @@ -392,16 +394,11 @@ std::shared_ptr SketchPlugin_ConstraintSplit::getPointOfRef return aPointAttribute; } -void SketchPlugin_ConstraintSplit::getFeaturePoints(AttributePoint2DPtr& theStartPointAttr, +void SketchPlugin_ConstraintSplit::getFeaturePoints(const FeaturePtr& theFeature, + AttributePoint2DPtr& theStartPointAttr, AttributePoint2DPtr& theEndPointAttr) { - AttributePoint2DPtr aPointAttribute; - - AttributeReferencePtr aBaseObjectAttr = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Constraint::VALUE())); - FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value()); - - std::string aFeatureKind = aBaseFeature->getKind(); + std::string aFeatureKind = theFeature->getKind(); std::string aStartAttributeName, anEndAttributeName; if (aFeatureKind == SketchPlugin_Line::ID()) { aStartAttributeName = SketchPlugin_Line::START_ID(); @@ -413,9 +410,9 @@ void SketchPlugin_ConstraintSplit::getFeaturePoints(AttributePoint2DPtr& theStar } if (!aStartAttributeName.empty() && !anEndAttributeName.empty()) { theStartPointAttr = std::dynamic_pointer_cast( - aBaseFeature->attribute(aStartAttributeName)); + theFeature->attribute(aStartAttributeName)); theEndPointAttr = std::dynamic_pointer_cast( - aBaseFeature->attribute(anEndAttributeName)); + theFeature->attribute(anEndAttributeName)); } } @@ -588,11 +585,21 @@ void SketchPlugin_ConstraintSplit::getRefAttributes(const FeaturePtr& theFeature void SketchPlugin_ConstraintSplit::updateCoincidenceConstraintsToFeature( const std::map, IdToPointPair>& theCoincidenceToFeature, const std::set >& theFurtherCoincidences, - const std::set& theFeatureResults) + const std::set& theFeatureResults, + const FeaturePtr& theSplitFeature) { if (theCoincidenceToFeature.empty()) return; + // we should build coincidence constraints to end of the split feature + std::set > aNewCoincidencesToSplitFeature; + AttributePoint2DPtr aStartPointAttr, anEndPointAttr; + getFeaturePoints(theSplitFeature, aStartPointAttr, anEndPointAttr); + if (theFurtherCoincidences.find(aStartPointAttr) == theFurtherCoincidences.end()) + aNewCoincidencesToSplitFeature.insert(aStartPointAttr); + if (theFurtherCoincidences.find(anEndPointAttr) == theFurtherCoincidences.end()) + aNewCoincidencesToSplitFeature.insert(anEndPointAttr); + std::map::const_iterator aCIt = theCoincidenceToFeature.begin(), aCLast = theCoincidenceToFeature.end(); #ifdef DEBUG_SPLIT @@ -615,6 +622,19 @@ void SketchPlugin_ConstraintSplit::updateCoincidenceConstraintsToFeature( if (aFeaturePointAttribute.get()) { aCoincFeature->refattr(anAttributeId)->setObject(ResultPtr()); aCoincFeature->refattr(anAttributeId)->setAttr(aFeaturePointAttribute); + // create new coincidences to split feature points + std::set::const_iterator aSFIt = aNewCoincidencesToSplitFeature.begin(), + aSFLast = aNewCoincidencesToSplitFeature.end(); + for (; aSFIt != aSFLast; aSFIt++) { + AttributePoint2DPtr aSFAttribute = *aSFIt; + if (aCoincPnt->isEqual(aSFAttribute->pnt())) { + std::string aSecondAttribute = SketchPlugin_Constraint::ENTITY_A(); + if (anAttributeId == SketchPlugin_Constraint::ENTITY_A()) + aSecondAttribute = SketchPlugin_Constraint::ENTITY_B(); + createConstraint(SketchPlugin_ConstraintCoincidence::ID(), + aSFAttribute, aCoincFeature->refattr(aSecondAttribute)->attr()); + } + } } else { /// find feature by shape intersected the point @@ -751,7 +771,8 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); AttributePoint2DPtr aStartPointAttrOfBase, anEndPointAttrOfBase; - getFeaturePoints(aStartPointAttrOfBase, anEndPointAttrOfBase); + + getFeaturePoints(aBaseFeature, aStartPointAttrOfBase, anEndPointAttrOfBase); if (!aStartPointAttrOfBase.get() && !anEndPointAttrOfBase.get()) { setError("Error: Feature has no start and end points."); return; @@ -884,7 +905,7 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); AttributePoint2DPtr aStartPointAttrOfBase, anEndPointAttrOfBase; - getFeaturePoints(aStartPointAttrOfBase, anEndPointAttrOfBase); + getFeaturePoints(aBaseFeature, aStartPointAttrOfBase, anEndPointAttrOfBase); if (!aStartPointAttrOfBase.get() && !anEndPointAttrOfBase.get()) { setError("Error: Feature has no start and end points."); return; @@ -1283,7 +1304,7 @@ std::set > SketchPlugin_ConstraintSplit::get return anAttributes; } - +#ifdef _DEBUG std::string SketchPlugin_ConstraintSplit::getFeatureInfo( const std::shared_ptr& theFeature, const bool isUseAttributesInfo) @@ -1344,4 +1365,4 @@ std::string SketchPlugin_ConstraintSplit::getFeatureInfo( } return anInfo; } - +#endif