]> OCCT Git - occt.git/commitdiff
0030378: Data Exchange - extract of subset of model entities fails (regression)
authorabv <abv@opencascade.com>
Sat, 3 Oct 2020 04:03:51 +0000 (07:03 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 6 Oct 2020 17:40:20 +0000 (20:40 +0300)
Field theflags in class Interface_BitMap is always initialized to avoid exception on operations with the class.

Added test bugs step bug30378

src/Interface/Interface_BitMap.cxx
src/Interface/Interface_BitMap.hxx
tests/bugs/step/bug30378 [new file with mode: 0644]

index 8b10c9a3a06d326462c813f7ae4831d045dc9d24..db011deb1e3e92d4797835aa6c806279bfc8f16a 100644 (file)
@@ -33,11 +33,7 @@ void Interface_BitMap::Initialize(const Standard_Integer nbitems, const Standard
   thenbitems = nbitems;
   thenbwords = nbitems/32 + 1;
   thenbflags = 0;
-  if(nbitems)
-  {
-    theflags   = new TColStd_HArray1OfInteger (0,thenbwords*(resflags+1));  
-    theflags->Init(0);
-  }
+  theflags = new TColStd_HArray1OfInteger(0, thenbwords*(resflags + 1), 0);
 }
 
 Interface_BitMap::Interface_BitMap
@@ -50,33 +46,24 @@ Interface_BitMap::Interface_BitMap
 void Interface_BitMap::Initialize(const Interface_BitMap& other,
                                   const Standard_Boolean copied)
 {
-  other.Internals (thenbitems,thenbwords,thenbflags,theflags,thenames);
-  if (!copied) return;
-  Standard_Integer nb = theflags->Upper ();
-  Handle(TColStd_HArray1OfInteger) flags = new TColStd_HArray1OfInteger(0,nb);
-  Standard_Integer i; // svv Jan11 2000 : porting on DEC
-  for (i = 0; i <= nb; i ++)
-    flags->SetValue (i,theflags->Value(i));
-  theflags = flags;
-  if (thenames.IsNull()) return;
-  nb = thenames->Length();
-  Handle(TColStd_HSequenceOfAsciiString) names = new TColStd_HSequenceOfAsciiString();
-  for (i = 1; i <= nb; i ++)
-    names->Append ( TCollection_AsciiString(thenames->Value(i)) );
-  thenames = names;
-}
-
-void  Interface_BitMap::Internals
-(Standard_Integer& nbitems, Standard_Integer& nbwords,
- Standard_Integer& nbflags,
- Handle(TColStd_HArray1OfInteger)& flags,
- Handle(TColStd_HSequenceOfAsciiString)& names) const
-{
-  nbitems = thenbitems;  nbwords = thenbwords;  nbflags = thenbflags;
-  flags = theflags;  names = thenames;
+  thenbitems = other.thenbitems;
+  thenbwords = other.thenbwords;
+  thenbflags = other.thenbflags;
+  if (!copied)
+  {
+    theflags = other.theflags;
+    thenames = other.thenames;
+  }
+  else
+  {
+    theflags = new TColStd_HArray1OfInteger(other.theflags->Array1());
+    if (! other.thenames.IsNull())
+    {
+      thenames = new TColStd_HSequenceOfAsciiString(other.thenames->Sequence());
+    }
+  }
 }
 
-
 void  Interface_BitMap::Reservate (const Standard_Integer moreflags)
 {
   Standard_Integer nb = theflags->Upper ();
index 913236f57d3c30a2890b4a5d0e74fd6667bef343..8cbf2d4e33d573ddb8a544db85084348e8698a16 100644 (file)
@@ -70,10 +70,6 @@ public:
   //! Initialize a BitMap from another one
   Standard_EXPORT void Initialize (const Interface_BitMap& other, const Standard_Boolean copied = Standard_False);
   
-  //! Returns internal values, used for copying
-  //! Flags values start at false
-  Standard_EXPORT void Internals (Standard_Integer& nbitems, Standard_Integer& nbwords, Standard_Integer& nbflags, Handle(TColStd_HArray1OfInteger)& flags, Handle(TColStd_HSequenceOfAsciiString)& names) const;
-  
   //! Reservates for a count of more flags
   Standard_EXPORT void Reservate (const Standard_Integer moreflags);
   
diff --git a/tests/bugs/step/bug30378 b/tests/bugs/step/bug30378
new file mode 100644 (file)
index 0000000..6efdc38
--- /dev/null
@@ -0,0 +1,14 @@
+puts "# ==============================================================================="
+puts "# 0030378: Data Exchange - extract of subset of model entities fails (regression)"
+puts "# ==============================================================================="
+
+puts "Prepare simple STEP model"
+pload MODELING XSDRAW
+box b 10 10 10
+stepwrite a b
+
+puts "Write entity #3"
+set res [writeent ${imagedir}/${test_image}.stp 3]
+if { ! [regexp {Write\s+Done} $res] } {
+  puts "Error: expected output is not found"
+}