FeaturePtr aCoincident = PartSet_Tools::findFirstCoincidence(aFeature, aSelPnt);
// If we have coincidence then add Detach menu
if (aCoincident.get() != NULL) {
+ QList<FeaturePtr> aCoins;
mySelectedFeature = aCoincident;
- PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
+ PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_A());
- PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines,
+ PartSet_Tools::findCoincidences(mySelectedFeature, myCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_B());
if (myCoinsideLines.size() > 0) {
aIsDetach = true;
}
FeaturePtr PartSet_Tools::findFirstCoincidence(const FeaturePtr& theFeature,
- std::shared_ptr<GeomAPI_Pnt2d> thePoint,
- const bool theSearchInResults)
+ std::shared_ptr<GeomAPI_Pnt2d> thePoint)
{
FeaturePtr aCoincident;
if (theFeature.get() == NULL)
}
}
}
- if (theSearchInResults) {
- if (!aCoincident.get()) {
- std::list<ResultPtr> aResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
- ResultPtr aResult = *aIt;
- aCoincident = findFirstCoincidenceByData(aResult->data(), thePoint);
- if (aCoincident.get())
- break;
- }
+ /// Find by result
+ if (!aCoincident.get()) {
+ std::list<ResultPtr> aResults = theFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+ ResultPtr aResult = *aIt;
+ aCoincident = findFirstCoincidenceByData(aResult->data(), thePoint);
+ if (aCoincident.get())
+ break;
}
}
return aCoincident;
}
void PartSet_Tools::findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
+ QList<FeaturePtr>& theCoincidencies,
std::string theAttr)
{
+ std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
+ if (aOrig.get() == NULL)
+ return;
+
AttributeRefAttrPtr aPnt = theStartCoin->refattr(theAttr);
- if (!aPnt) return;
- FeaturePtr aObj = ModelAPI_Feature::feature(aPnt->object());
- if (!theList.contains(aObj)) {
- std::shared_ptr<GeomAPI_Pnt2d> aOrig = getCoincedencePoint(theStartCoin);
- if (aOrig.get() == NULL)
- return;
- theList.append(aObj);
- const std::set<AttributePtr>& aRefsList = aObj->data()->refsToMe();
- std::set<AttributePtr>::const_iterator aIt;
- for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
- std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
- FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
- if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
- std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
- if (aPnt.get() && aOrig->isEqual(aPnt)) {
- findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_A());
- findCoincidences(aConstrFeature, theList, SketchPlugin_ConstraintCoincidence::ENTITY_B());
+ if (!aPnt)
+ return;
+ ObjectPtr aObj = aPnt->object();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+ if (aFeature.get()) {
+ if (!theList.contains(aFeature)) {
+ theList.append(aFeature);
+ theCoincidencies.append(theStartCoin);
+ const std::set<AttributePtr>& aRefsList = aFeature->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aIt;
+ for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+ std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+ FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+ if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+ if (!theCoincidencies.contains(aConstrFeature)) {
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+ if (aPnt.get() && aOrig->isEqual(aPnt)) {
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_A());
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_B());
+ }
+ }
+ }
+ }
+ }
+ } else {
+ // Find by Results
+ ResultConstructionPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ if (aResult.get()) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aPnt->object());
+ if (!theList.contains(aFeature))
+ theList.append(aFeature);
+ theCoincidencies.append(theStartCoin);
+
+ const std::set<AttributePtr>& aRefsList = aResult->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator aIt;
+ for (aIt = aRefsList.cbegin(); aIt != aRefsList.cend(); ++aIt) {
+ std::shared_ptr<ModelAPI_Attribute> aAttr = (*aIt);
+ FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
+ if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+ if (!theCoincidencies.contains(aConstrFeature)) {
+ std::shared_ptr<GeomAPI_Pnt2d> aPnt = getCoincedencePoint(aConstrFeature);
+ if (aPnt.get() && aOrig->isEqual(aPnt)) {
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_A());
+ findCoincidences(aConstrFeature, theList, theCoincidencies,
+ SketchPlugin_ConstraintCoincidence::ENTITY_B());
+ }
+ }
}
}
}
* \return the coincidence feature or null
*/
static FeaturePtr findFirstCoincidence(const FeaturePtr& theFeature,
- std::shared_ptr<GeomAPI_Pnt2d> thePoint,
- const bool theSearchInResults = false);
+ std::shared_ptr<GeomAPI_Pnt2d> thePoint);
/**
* Returns list of features connected in a councedence feature point
* \param theAttr the attribute name
*/
static void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
+ QList<FeaturePtr>& theCoincidencies,
std::string theAttr);
/**
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
QList<FeaturePtr> aCoinsideLines;
+ QList<FeaturePtr> aCoins;
bool isObject = aRefAttr->isObject();
ObjectPtr anObject = aRefAttr->object();
AttributePtr aAR = aRAttr->attr();
if (aAR->id() != SketchPlugin_Arc::CENTER_ID()) // ignore constraint to center of arc
aCoinList.insert(aConstrFeature);
- PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
+ PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_A());
- PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines,
+ PartSet_Tools::findCoincidences(aConstrFeature, aCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_B());
}
}
if (aShape.ShapeType() == TopAbs_VERTEX) {
FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject);
if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) {
- anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY, true);
+ anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY);
}
}
}
bool PartSet_WidgetPoint2D::isOrphanPoint(const FeaturePtr& theFeature,
const CompositeFeaturePtr& theSketch,
- double theX, double theY, const bool theSearchInResults)
+ double theX, double theY)
{
bool anOrphanPoint = false;
if (theFeature.get()) {
std::shared_ptr<GeomAPI_Pnt2d> aPoint = aPointAttr->pnt();
// we need to find coincidence features in results also, because external object(point)
// uses refs to me in another feature.
- FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint, theSearchInResults);
+ FeaturePtr aCoincidence = PartSet_Tools::findFirstCoincidence(theFeature, aPoint);
anOrphanPoint = true;
// if there is at least one concident line to the point, the point is not an orphant
if (aCoincidence.get()) {
QList<FeaturePtr> aCoinsideLines;
- PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
+ QList<FeaturePtr> aCoins;
+ PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_A());
- PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines,
+ PartSet_Tools::findCoincidences(aCoincidence, aCoinsideLines, aCoins,
SketchPlugin_ConstraintCoincidence::ENTITY_B());
QList<FeaturePtr>::const_iterator anIt = aCoinsideLines.begin(),
aLast = aCoinsideLines.end();
/// \param theY an Y coordinate of the point
/// \return boolean result
static bool isOrphanPoint(const FeaturePtr& theFeature, const CompositeFeaturePtr& theSketch,
- double theX, double theY, const bool theSearchInResults = false);
+ double theX, double theY);
protected:
ModuleBase_IWorkshop* myWorkshop; ///< workshop