getConstraints(aFeaturesToDelete, aFeaturesToUpdate, aTangentFeatures, aCoincidenceToFeature);
std::map<AttributePtr, std::list<AttributePtr> > aBaseRefAttributes;
- getRefAttributes(aBaseFeature, aBaseRefAttributes);
+ std::list<AttributePtr> aRefsToFeature;
+ getRefAttributes(aBaseFeature, aBaseRefAttributes, aRefsToFeature);
std::map<AttributePtr, AttributePtr> aBasePointModifiedAttributes;
std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aBaseAttr);
std::cout << aPointAttr->id().c_str() << ": " << "[" << aRefAttributes.size() << "] " << aRefsInfo << std::endl;
}
+ std::cout << std::endl;
+ std::cout << std::endl << "References to base feature [" << aRefsToFeature.size() << "]" << std::endl;
+ std::list<AttributePtr>::const_iterator aRefAttrIt = aRefsToFeature.begin(),
+ aRefAttrLast = aRefsToFeature.end();
+ std::string aRefsInfo;
+ for (; aRefAttrIt != aRefAttrLast; aRefAttrIt++) {
+ if (!aRefsInfo.empty())
+ aRefsInfo.append(",");
+ AttributePtr aRAttr = *aRefAttrIt;
+ aRefsInfo.append(aRAttr->id());
+ FeaturePtr aRFeature = ModelAPI_Feature::feature(aRAttr->owner());
+ aRefsInfo.append("(" + aRFeature->name() + ") ");
+ }
+ std::cout << "[" << aRefsToFeature.size() << "] " << aRefsInfo << std::endl;
+
+
std::cout << std::endl;
std::cout << "---- SPLIT ----" << std::endl;
std::cout << std::endl;
FeaturePtr aCircleFeature = aBaseFeature;
splitCircle(aSplitFeature, aBaseFeature, anAfterFeature, aFurtherCoincidences, aCreatedFeatures,
aModifiedAttributes);
+
+ updateRefFeatureConstraints(getFeatureResult(aBaseFeature), aRefsToFeature);
+
aFeaturesToDelete.insert(aCircleFeature);
- aBaseObjectAttr->setObject(ResultPtr()); // as circle is removed, temporary fill this attribute
+ aBaseObjectAttr->setObject(ResultPtr()); // as circle is removed, temporary fill this attribute*/
}
#ifdef DEBUG_SPLIT
}
void SketchPlugin_ConstraintSplit::getRefAttributes(const FeaturePtr& theFeature,
- std::map<AttributePtr, std::list<AttributePtr> >& theRefs)
+ std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
+ std::list<AttributePtr>& theRefsToFeature)
{
theRefs.clear();
for (; aPIt != aPLast; aPIt++)
aPointAttributesSet.insert(*aPIt);
- const std::set<AttributePtr>& aRefsAttributes = theFeature->data()->refsToMe();
+ std::set<AttributePtr> aRefsAttributes = getFeatureResult(theFeature)->data()->refsToMe();
+ std::set<AttributePtr> aFRefsList = theFeature->data()->refsToMe();
+ aRefsAttributes.insert(aFRefsList.begin(), aFRefsList.end());
+
std::set<AttributePtr>::const_iterator aIt;
for (aIt = aRefsAttributes.cbegin(); aIt != aRefsAttributes.cend(); ++aIt) {
AttributePtr anAttr = (*aIt);
if (anAttrFeature.get() != this &&
anAttr.get() && anAttr->attributeType() == ModelAPI_AttributeRefAttr::typeId()) {
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttr);
- if (!aRefAttr->isObject()) {
+ if (!aRefAttr->isObject()) { /// find attributes referenced to feature point attributes
AttributePtr anAttrInRef = aRefAttr->attr();
if (anAttrInRef.get() && aPointAttributesSet.find(anAttrInRef) != aPointAttributesSet.end()) {
if (theRefs.find(anAttrInRef) != theRefs.end())
}
}
}
+ else { /// find attributes referenced to feature itself
+ theRefsToFeature.push_back(anAttr);
+ }
}
}
}
}
}
+void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(const ResultPtr& theFeatureBaseResult,
+ const std::list<AttributePtr>& theRefsToFeature)
+{
+ std::list<AttributePtr>::const_iterator anIt = theRefsToFeature.begin(),
+ aLast = theRefsToFeature.end();
+ for (; anIt != aLast; anIt++) {
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIt);
+ if (aRefAttr.get())
+ aRefAttr->setObject(theFeatureBaseResult);
+ }
+}
+
void SketchPlugin_ConstraintSplit::updateRefAttConstraints(
const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes)
std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature/*,
std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToPoint*/);
+ /// Obtains references to feature point attributes and to feature,
+ /// e.g. for feature line: 1st container is <1st line point, list<entity_a in distance, entity_b in parallel> >
+ /// <2nd line point, list<> >
+ /// for feature circle 2nd container is <entity_a in Radius, entity_b in equal, ...>
+ /// \param theFeature an investigated feature
+ /// \param theRefs a container of list of referenced attributes
void getRefAttributes(const FeaturePtr& theFeature,
- std::map<AttributePtr, std::list<AttributePtr> >& theRefs);
+ std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
+ std::list<AttributePtr>& theRefsToFeature);
/// Move coincidence constraint from feature to point if it is found
/// \param theCoincidenceToFeature coincidence to feature to be connected to new feature
const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences);
+
+ /// Move constraints from base feature to given feature
+ /// \param theFeature a base feature
+ /// \param theRefsToFeature list of attributes referenced to base feature
+ void updateRefFeatureConstraints(const std::shared_ptr<ModelAPI_Result>& theFeatureBaseResult,
+ const std::list<AttributePtr>& theRefsToFeature);
+
/// Move constraints from attribute of base feature to attribute after modification
/// \param theBaseRefAttributes container of references to the attributes of base feature
/// \param theModifiedAttributes container of attributes placed instead of base attributes