// 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;
private:
/// Returns geom point attribute of the feature bounds. It processes line or arc.
/// For circle feature, the result attributes are null
+ /// \param theFeature a source feature
/// \param theStartPointAttr an out attribute to start point
/// \param theStartPointAttr an out attribute to end point
- void getFeaturePoints(std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
+ void getFeaturePoints(const FeaturePtr& theFeature,
+ std::shared_ptr<GeomDataAPI_Point2D>& theStartPointAttr,
std::shared_ptr<GeomDataAPI_Point2D>& theEndPointAttr);
/// Returns cast of attribute to geometrical point if the attribute is a ref attr attribute
/// Move coincidence constraint from feature to point if it is found
/// \param theCoincidenceToFeature coincidence to feature to be connected to new feature
/// \param theFurtherCoincidences a list of points where coincidences will be build
- /// \paramv theFeatureResults created results after split where constaint might be connected
+ /// \param theFeatureResults created results after split where constaint might be connected
+ /// \param theSplitFeature feature created by split, new coincidences to points should be created
+ /// if theCoincidenceToFeature contains equal points
void 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);
/// Move tangency constraint to the nearest split feature that has a coincidence to the tangent
/// \param theTangentFeatures tangencies to feature to be connected to nearest feature