FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value());
ResultPtr aBaseFeatureResult = getFeatureResult(aBaseFeature);
std::set<FeaturePtr> aFeaturesToDelete, aFeaturesToUpdate;
+
std::map<FeaturePtr, IdToPointPair> aTangentFeatures;
std::map<FeaturePtr, IdToPointPair> aCoincidenceToFeature;
getConstraints(aFeaturesToDelete, aFeaturesToUpdate, aTangentFeatures, aCoincidenceToFeature);
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());
// coincidence to feature
updateCoincidenceConstraintsToFeature(aCoincidenceToFeature, aFurtherCoincidences,
- aFeatureResults);
+ aFeatureResults, aSplitFeature);
// tangency
updateTangentConstraintsToFeature(aTangentFeatures, aFurtherCoincidences);
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<ModelAPI_AttributeReference>(
- 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();
}
if (!aStartAttributeName.empty() && !anEndAttributeName.empty()) {
theStartPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aBaseFeature->attribute(aStartAttributeName));
+ theFeature->attribute(aStartAttributeName));
theEndPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aBaseFeature->attribute(anEndAttributeName));
+ theFeature->attribute(anEndAttributeName));
}
}
void SketchPlugin_ConstraintSplit::updateCoincidenceConstraintsToFeature(
const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
- const std::set<ResultPtr>& theFeatureResults)
+ const std::set<ResultPtr>& theFeatureResults,
+ const FeaturePtr& theSplitFeature)
{
if (theCoincidenceToFeature.empty())
return;
+ // we should build coincidence constraints to end of the split feature
+ std::set<std::shared_ptr<GeomDataAPI_Point2D> > 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<FeaturePtr, IdToPointPair>::const_iterator aCIt = theCoincidenceToFeature.begin(),
aCLast = theCoincidenceToFeature.end();
#ifdef DEBUG_SPLIT
if (aFeaturePointAttribute.get()) {
aCoincFeature->refattr(anAttributeId)->setObject(ResultPtr());
aCoincFeature->refattr(anAttributeId)->setAttr(aFeaturePointAttribute);
+ // create new coincidences to split feature points
+ std::set<AttributePoint2DPtr>::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
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;
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;
return anAttributes;
}
-
+#ifdef _DEBUG
std::string SketchPlugin_ConstraintSplit::getFeatureInfo(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const bool isUseAttributesInfo)
}
return anInfo;
}
-
+#endif