0029827: Modeling Data - TopoDS_Shape::Nullify() does not reset location
authorakaftasev <akaftasev@opencascade.com>
Tue, 10 Nov 2020 06:41:23 +0000 (09:41 +0300)
committerbugmaster <bugmaster@opencascade.com>
Sat, 21 Nov 2020 09:19:48 +0000 (12:19 +0300)
TopoDS_Shape::Nullify() nullify not only myTShape but myLocation and myOrient.
Nullified shapes are equal and same now.
Added test.

src/BRepTest/BRepTest_BasicCommands.cxx
src/QABugs/QABugs_20.cxx
src/TopLoc/TopLoc_Location.hxx
src/TopoDS/TopoDS_Shape.hxx
tests/bugs/moddata_3/bug29827 [new file with mode: 0644]

index d12d9da..6880175 100644 (file)
@@ -1327,11 +1327,6 @@ static Standard_Integer compareshapes(Draw_Interpretor& di,
   // get shapes
   TopoDS_Shape aS1 = DBRep::Get(a[1]);
   TopoDS_Shape aS2 = DBRep::Get(a[2]);
-  // check shapes
-  if (aS1.IsNull() || aS2.IsNull()) {
-    di << "null shapes\n";
-    return 0;
-  }
   // compare shapes
   if (aS1.IsSame(aS2)) {
     di << "same shapes\n";
index 3ea3d46..fe72445 100644 (file)
@@ -3870,6 +3870,21 @@ static Standard_Integer OCC31785 (Draw_Interpretor& theDI,
   return 0;
 }
 
+static Standard_Integer QANullifyShape(Draw_Interpretor& di,
+  Standard_Integer n,
+  const char** a)
+{
+  if (n != 2) {
+    di << "Wrong usage.\n";
+    di << "Usage: QANullifyShape shape\n";
+    return 1;
+  }
+  TopoDS_Shape aShape = DBRep::Get(a[1]);
+  aShape.Nullify();
+  DBRep::Set(a[1], aShape);
+  return 0;
+}
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3945,5 +3960,10 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
                   "OCC31785 file.xbf : test reading XBF file in another thread",
                   __FILE__, OCC31785, group);
 
+
+  theCommands.Add("QANullifyShape",
+                  "Nullify shape. Usage: QANullifyShape shape",
+                  __FILE__, QANullifyShape, group);
+
   return;
 }
index f3d3081..dc25847 100644 (file)
@@ -148,6 +148,12 @@ Standard_Boolean operator != (const TopLoc_Location& Other) const
   //! Prints the contents of <me> on the stream <s>.
   Standard_EXPORT void ShallowDump (Standard_OStream& S) const;
 
+  //! Clear myItems
+  void Clear()
+  {
+    myItems.Clear();
+  }
+
 
 
 
index 52e4012..d44175f 100644 (file)
@@ -80,7 +80,12 @@ public:
 
   //! Destroys the reference to the underlying shape
   //! stored in this shape. As a result, this shape becomes null.
-  void Nullify() { myTShape.Nullify(); }
+  void Nullify() 
+  { 
+    myTShape.Nullify(); 
+    myLocation.Clear();
+    myOrient = TopAbs_EXTERNAL;
+  }
 
   //! Returns the shape local coordinate system.
   const TopLoc_Location& Location() const { return myLocation; }
diff --git a/tests/bugs/moddata_3/bug29827 b/tests/bugs/moddata_3/bug29827
new file mode 100644 (file)
index 0000000..de21d85
--- /dev/null
@@ -0,0 +1,26 @@
+puts "=========="
+puts "0029827: Modeling Data - TopoDS_Shape::Nullify() does not reset location"
+puts "=========="
+puts ""
+
+pload QAcommands
+
+box b1 1 2 1
+box b2 1 1 1 
+
+ttranslate b1 0 1 1
+ttranslate b2 1 1 1 
+
+QANullifyShape b1
+QANullifyShape b2
+
+set result [compare b1 b2]
+
+set ctr { "same shapes" "equal shapes" }
+
+foreach data ${ctr} {
+    if ![regexp $data $result] {
+       puts "Error: Shapes are not '$data'"
+       break; 
+    }
+}
\ No newline at end of file