From d3721fe136cb494c4998fce055de7ac390fc3f12 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 1 Nov 2018 11:15:55 +0300 Subject: [PATCH] Fix problems reported by Christophe in mail 31.10.2018 --- src/GeomAPI/GeomAPI_Tools.cpp | 3 + .../GeomValidators_DifferentShapes.cpp | 4 +- src/Model/Model_Document.h | 2 +- src/Model/Model_ResultConstruction.cpp | 3 +- src/Model/Model_Update.cpp | 2 +- src/ModelAPI/ModelAPI_ResultPart.h | 2 +- src/Selector/Selector_Selector.cpp | 88 ++++++++++--------- 7 files changed, 58 insertions(+), 46 deletions(-) diff --git a/src/GeomAPI/GeomAPI_Tools.cpp b/src/GeomAPI/GeomAPI_Tools.cpp index 082595768..c15700df1 100644 --- a/src/GeomAPI/GeomAPI_Tools.cpp +++ b/src/GeomAPI/GeomAPI_Tools.cpp @@ -28,6 +28,9 @@ //================================================================================================== GeomShapePtr GeomAPI_Tools::getTypedShape(const GeomShapePtr& theShape) { + if (!theShape.get()) + return GeomShapePtr(); + GeomShapePtr aTypedShape = theShape; GeomAPI_Shape::ShapeType aType = theShape->shapeType(); diff --git a/src/GeomValidators/GeomValidators_DifferentShapes.cpp b/src/GeomValidators/GeomValidators_DifferentShapes.cpp index 69a981be6..e030c284e 100644 --- a/src/GeomValidators/GeomValidators_DifferentShapes.cpp +++ b/src/GeomValidators/GeomValidators_DifferentShapes.cpp @@ -171,5 +171,7 @@ bool GeomValidators_DifferentShapes::isAttrShapesEqual(const AttributePtr& theAt } GeomShapePtr aOtherTypedShape = GeomAPI_Tools::getTypedShape(anOtherShape); + if (!aTypedShape.get()) + return !aTypedShape.get() && !aOtherTypedShape.get(); return aTypedShape->isEqual(aOtherTypedShape); -} \ No newline at end of file +} diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 0e1c89a47..20626c1d7 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -370,7 +370,7 @@ class Model_Document : public ModelAPI_Document /// Appends the values to theStates list. virtual void restoreNodesState(std::list& theStates) const; - /// Label that constains structures for selection of constructions of another document + /// Label that contains structures for selection of constructions of another document TDF_Label extConstructionsLabel() const; /// searches in this document feature that contains this label diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 8de3c4165..6dc346aa0 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -130,7 +131,7 @@ bool Model_ResultConstruction::updateShape() // just restore shape GeomShapePtr aGShape(new GeomAPI_Shape); aGShape->setImpl(new TopoDS_Shape(aShape)); - myShape = aGShape; // restore the sketch sub-components + myShape = GeomAPI_Tools::getTypedShape(aGShape); // restore the sketch sub-components return true; } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index e98ccf13f..23d96f429 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -198,7 +198,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { } } } - // proccess also results + // process also results std::list allResults; // list of this feature and results ModelAPI_Tools::allResults(theFeature, allResults); std::list::iterator aRes = allResults.begin(); diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index bd8a697f8..418e2d9d9 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -63,7 +63,7 @@ class ModelAPI_ResultPart : public ModelAPI_Result /// Returns the part-document of this result virtual std::shared_ptr partDoc() = 0; - /// Returns the original part result: for transfomration features results this is + /// Returns the original part result: for transformation features results this is /// the original Part feature result virtual std::shared_ptr original() = 0; diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp index e5f0ffa07..11cfbf25f 100644 --- a/src/Selector/Selector_Selector.cpp +++ b/src/Selector/Selector_Selector.cpp @@ -73,26 +73,27 @@ static void findBases(Handle(TNaming_NamedShape) theFinal, const TopoDS_Shape& t TNaming_SameShapeIterator aLabIter(theValue, theFinal->Label()); for(; aLabIter.More(); aLabIter.Next()) { Handle(TNaming_NamedShape) aNS; - aLabIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS); - if (aMustBeAtFinal && aNS != theFinal) - continue; // looking for old at the same final label only - TNaming_Evolution anEvolution = aNS->Evolution(); - if (anEvolution == TNaming_PRIMITIVE) { - // check that this is not in the results already - const TDF_Label aResult = aNS->Label(); - TDF_LabelList::Iterator aResIter(theResult); - for(; aResIter.More(); aResIter.Next()) { - if (aResIter.Value().IsEqual(aResult)) - break; + if (aLabIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aMustBeAtFinal && aNS != theFinal) + continue; // looking for old at the same final label only + TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_PRIMITIVE) { + // check that this is not in the results already + const TDF_Label aResult = aNS->Label(); + TDF_LabelList::Iterator aResIter(theResult); + for(; aResIter.More(); aResIter.Next()) { + if (aResIter.Value().IsEqual(aResult)) + break; + } + if (!aResIter.More()) // not found, so add this new + theResult.Append(aResult); } - if (!aResIter.More()) // not found, so add this new - theResult.Append(aResult); - } - if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { - for(TNaming_Iterator aThisIter(aNS); aThisIter.More(); aThisIter.Next()) { - if (aThisIter.NewShape().IsSame(theValue)) { - // continue recursively, null NS means that any NS are ok - findBases(theFinal, aThisIter.OldShape(), false, theResult); + if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + for(TNaming_Iterator aThisIter(aNS); aThisIter.More(); aThisIter.Next()) { + if (aThisIter.NewShape().IsSame(theValue)) { + // continue recursively, null NS means that any NS are ok + findBases(theFinal, aThisIter.OldShape(), false, theResult); + } } } } @@ -537,11 +538,12 @@ bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape TopoDS_ListOfShape aCommon; myFinal = aModifList.First()->Label(); Handle(TNaming_NamedShape) aNS; - myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS); - for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { - const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); - if (!aNewShape.IsNull()) - aCommon.Append(aNewShape); + if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { + const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); + if (!aNewShape.IsNull()) + aCommon.Append(aNewShape); + } } Selector_NExplode aNexp(aCommon); myWeakIndex = aNexp.index(theValue); @@ -833,11 +835,12 @@ bool Selector_Selector::solve(const TopoDS_Shape& theContext) if (myBases.IsEmpty() && myWeakIndex) { // weak name by the final shapes index TopoDS_ListOfShape aCommon; Handle(TNaming_NamedShape) aNS; - myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS); - for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { - const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); - if (!aNewShape.IsNull()) - aCommon.Append(aNewShape); + if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { + const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); + if (!aNewShape.IsNull()) + aCommon.Append(aNewShape); + } } Selector_NExplode aNexp(aCommon); aResult = aNexp.shape(myWeakIndex); @@ -915,18 +918,21 @@ std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { aResult += '['; aResult += aSubSel->name(theNameGenerator); aResult += ']'; - TopAbs_ShapeEnum aSubType = aSubSel->value().ShapeType(); - if (aSubType != TopAbs_FACE) { // in case the sub shape type must be stored - switch(aSubType) { - case TopAbs_COMPOUND: aResult += "c"; break; - case TopAbs_COMPSOLID: aResult += "o"; break; - case TopAbs_SOLID: aResult += "s"; break; - case TopAbs_SHELL: aResult += "h"; break; - case TopAbs_WIRE: aResult += "w"; break; - case TopAbs_EDGE: aResult += "e"; break; - case TopAbs_VERTEX: aResult += "v"; break; - default: - ; + TopoDS_Shape aSubVal = aSubSel->value(); + if (!aSubVal.IsNull()) { + TopAbs_ShapeEnum aSubType = aSubVal.ShapeType(); + if (aSubType != TopAbs_FACE) { // in case the sub shape type must be stored + switch(aSubType) { + case TopAbs_COMPOUND: aResult += "c"; break; + case TopAbs_COMPSOLID: aResult += "o"; break; + case TopAbs_SOLID: aResult += "s"; break; + case TopAbs_SHELL: aResult += "h"; break; + case TopAbs_WIRE: aResult += "w"; break; + case TopAbs_EDGE: aResult += "e"; break; + case TopAbs_VERTEX: aResult += "v"; break; + default: + ; + } } } } -- 2.39.2