}
}
-// returns the center of the edge: circular or elliptical
+// returns the center of the edge: circular or elliptic
GeomShapePtr centerByEdge(GeomShapePtr theEdge, ModelAPI_AttributeSelection::CenterType theType)
{
if (theType != ModelAPI_AttributeSelection::NOT_CENTER && theEdge.get() != NULL) {
if (aCont->groupName() == ModelAPI_ResultPart::group()) {
ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aCont);
int anIndex;
- GeomShapePtr aValue = value();
- if (aValue.get())
- return aPart->data()->name() + "/" + aPart->nameInPart(aValue, anIndex);
- else
- return aPart->data()->name();
+ std::string aResult = aSubSh.get() ?
+ aPart->data()->name() + "/" + aPart->nameInPart(aSubSh, anIndex) : aPart->data()->name();
+ if (aCenterType != NOT_CENTER)
+ aResult += centersMap()[aCenterType];
+ return aResult;
}
-
// whole infinitive construction
if (aCont->groupName() == ModelAPI_ResultConstruction::group()) {
ResultConstructionPtr aConstr = std::dynamic_pointer_cast<Model_ResultConstruction>(aCont);
void Model_AttributeSelection::concealedFeature(
- const FeaturePtr theFeature, const FeaturePtr theStop, std::list<FeaturePtr>& theConcealers)
+ const FeaturePtr theFeature, const FeaturePtr theStop, std::list<FeaturePtr>& theConcealers,
+ const ResultPtr theResultOfFeature)
{
std::set<FeaturePtr> alreadyProcessed;
alreadyProcessed.insert(theFeature);
if (theStop.get())
alreadyProcessed.insert(theStop);
/// iterate all results to find the concealment-attribute
- const std::list<ResultPtr>& aRootRes = theFeature->results();
+ std::list<ResultPtr> aRootRes;
+ if (theResultOfFeature.get()) {
+ ResultPtr aRoot = ModelAPI_Tools::bodyOwner(theResultOfFeature, true);
+ aRootRes.push_back(aRoot ? aRoot : theResultOfFeature);
+ } else { // all results of a feature
+ aRootRes = theFeature->results();
+ }
std::list<ResultPtr>::const_iterator aRootIter = aRootRes.cbegin();
for(; aRootIter != aRootRes.cend(); aRootIter++) {
std::list<ResultPtr> allRes;
FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
FeaturePtr aContextOwner = theDoc->feature(theContext);
std::list<FeaturePtr> aConcealers;
- concealedFeature(aContextOwner, aThisFeature, aConcealers);
+ concealedFeature(aContextOwner, aThisFeature, aConcealers, theContext);
std::list<FeaturePtr>::iterator aConcealer = aConcealers.begin();
for(; aConcealer != aConcealers.end(); aConcealer++) {
std::list<ResultPtr> aRefResults;
if (aFeature.get()) {
FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
std::list<FeaturePtr> aConcealers;
- concealedFeature(aFeature, aThisFeature, aConcealers);
+ concealedFeature(aFeature, aThisFeature, aConcealers, ResultPtr());
if (aConcealers.empty())
return;
bool aChanged = false;
aListShapeType = GeomAPI_Shape::FACE;
}
+ // issue #3031: skip topology if there is more convenient shape type presents in the
+ // same context as a result of this
+ bool isWholeResult = myParent && myParent->isWholeResultAllowed() && !aSubShape.get();
+ GeomAPI_Shape::ShapeType allowedType = GeomAPI_Shape::SHAPE;
+ if (isWholeResult) {
+ std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
+ TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
+ for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) {
+ if (aNewValues.Value().IsNull()) { // only for the whole context
+ GeomAPI_Shape::ShapeType aShapeType = (*aNewCont)->shape()->shapeType();
+ if (allowedType == GeomAPI_Shape::SHAPE) { // just set this one
+ allowedType = aShapeType;
+ } else {
+ GeomAPI_Shape::ShapeType anAllowed = allowedType;
+ if (anAllowed != aShapeType) { // select the best, nearest to the origin
+ GeomAPI_Shape::ShapeType anOldShapeType = aContext->shape()->shapeType();
+ GeomAPI_Shape::ShapeType aDeltaAllowed =
+ (GeomAPI_Shape::ShapeType)(anOldShapeType - anAllowed);
+ if (aDeltaAllowed < 0)
+ aDeltaAllowed = (GeomAPI_Shape::ShapeType)(-aDeltaAllowed);
+ GeomAPI_Shape::ShapeType aDeltaThis =
+ (GeomAPI_Shape::ShapeType)(anOldShapeType - aShapeType);
+ if (aDeltaThis < 0)
+ aDeltaThis = (GeomAPI_Shape::ShapeType)(-aDeltaThis);
+ if (aDeltaThis == aDeltaAllowed) { // equal distance to context, select complicated
+ if (anOldShapeType < anAllowed)
+ allowedType = aShapeType;
+ } else if (aDeltaAllowed > aDeltaThis) { // this wins
+ allowedType = aShapeType;
+ }
+ }
+ }
+ }
+ }
+ }
+
std::list<ResultPtr>::iterator aNewCont = aNewContexts.begin();
TopTools_ListIteratorOfListOfShape aNewValues(aValShapes);
bool aFirst = true; // first is set to this, next are appended to parent
if (aSkippedContext.count(*aNewCont))
continue;
+ if (isWholeResult && aNewValues.Value().IsNull())
+ if (allowedType != GeomAPI_Shape::SHAPE &&
+ (*aNewCont)->shape()->shapeType() != allowedType)
+ continue; // there is better result exists with the better shape type (issue #3031)
+
GeomShapePtr aValueShape;
if (!aNewValues.Value().IsNull()) {
aValueShape = std::make_shared<GeomAPI_Shape>();
}
if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) {
// exception is for whole results selected
- if (!myParent || !myParent->isWholeResultAllowed() || aSubShape.get()) {
+ if (!isWholeResult) {
continue;
}
}