Salome HOME
Fix problems reported by Christophe in mail 31.10.2018
authormpv <mpv@opencascade.com>
Thu, 1 Nov 2018 08:15:55 +0000 (11:15 +0300)
committermpv <mpv@opencascade.com>
Mon, 19 Nov 2018 08:45:52 +0000 (11:45 +0300)
src/GeomAPI/GeomAPI_Tools.cpp
src/GeomValidators/GeomValidators_DifferentShapes.cpp
src/Model/Model_Document.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_Update.cpp
src/ModelAPI/ModelAPI_ResultPart.h
src/Selector/Selector_Selector.cpp

index 0825957681036ae6d31270139c4cd882d46b6512..c15700df1cbc68621f0320f5efe17ae32116bc34 100644 (file)
@@ -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();
index 69a981be699f7741b1e34a6091e1d5dc344c0afb..e030c284e0cef28e6185e55d682a1fbb5c85a610 100644 (file)
@@ -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
+}
index 0e1c89a475478947d6ec1e10621fc355704aed18..20626c1d784502e167cc2289b4f840ce309072e3 100644 (file)
@@ -370,7 +370,7 @@ class Model_Document : public ModelAPI_Document
   /// Appends the values to theStates list.
   virtual void restoreNodesState(std::list<bool>& 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
index 8de3c4165aff45c0b604ab2a3db9d8e0346ae996..6dc346aa0d27bdc5a8dd6da55b90db06609b2467 100644 (file)
@@ -23,6 +23,7 @@
 #include <Model_Data.h>
 #include <ModelAPI_CompositeFeature.h>
 #include <GeomAlgoAPI_SketchBuilder.h>
+#include <GeomAPI_Tools.h>
 #include <ModelAPI_Events.h>
 #include <Model_Document.h>
 #include <GeomAPI_PlanarEdges.h>
@@ -130,7 +131,7 @@ bool Model_ResultConstruction::updateShape()
         // just restore shape
         GeomShapePtr aGShape(new GeomAPI_Shape);
         aGShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aShape));
-        myShape = aGShape; // restore the sketch sub-components
+        myShape = GeomAPI_Tools::getTypedShape(aGShape); // restore the sketch sub-components
         return true;
       }
     }
index e98ccf13f6221bb4528ffeee668ca1bdc4147d21..23d96f4298a3d909c0a248f30e9c9f3e19a32080 100755 (executable)
@@ -198,7 +198,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) {
       }
     }
   }
-  // proccess also results
+  // process also results
   std::list<ResultPtr> allResults; // list of this feature and results
   ModelAPI_Tools::allResults(theFeature, allResults);
   std::list<ResultPtr>::iterator aRes = allResults.begin();
index bd8a697f8529060f2e3249b01bf9d3534b13171e..418e2d9d9f3aed4d8bda51447a0d4c511ee61b14 100644 (file)
@@ -63,7 +63,7 @@ class ModelAPI_ResultPart : public ModelAPI_Result
   /// Returns the part-document of this result
   virtual std::shared_ptr<ModelAPI_Document> 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<ModelAPI_ResultPart> original() = 0;
 
index e5f0ffa07c4474086f6b358dda8b1c8b3a20b0cd..11cfbf25fd5ed25abbbfb053d34a9f43098dad23 100644 (file)
@@ -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:
+            ;
+          }
         }
       }
     }