]> OCCT Git - occt.git/commitdiff
0029029: Exception Raised with no Result during reading file 2033zsh1_1.stp
authorgka <gka@opencascade.com>
Tue, 3 Oct 2017 14:28:32 +0000 (17:28 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 6 Oct 2017 07:28:25 +0000 (10:28 +0300)
Static function stepstrcmp() in StepData_StepReaderData.cxx is replaced by plain strcmp() to have the full strings compared (stepstrcmp() returned true if one of strings was longer than the other but common part was equal).
Protection is added to avoid exception for cases when representation entities are NULL

src/STEPConstruct/STEPConstruct_Assembly.cxx
src/STEPControl/STEPControl_ActorRead.cxx
src/StepData/StepData_StepReaderData.cxx
tests/bugs/step/bug29029 [new file with mode: 0644]

index 74d212bbc45e5c4b4566c9795e494ac56bf945d0..9c511fb526f5b5a648b9b1bb0d84ca0ce84cbd97 100644 (file)
@@ -197,6 +197,8 @@ Standard_Boolean STEPConstruct_Assembly::CheckSRRReversesNAUO(const Interface_Gr
   Handle(StepBasic_ProductDefinition) pd1, pd2;
   Handle(StepRepr_Representation) rep1 = CDSR->RepresentationRelation()->Rep1();
   Handle(StepRepr_Representation) rep2 = CDSR->RepresentationRelation()->Rep2();
+  if( rep1.IsNull() || rep2.IsNull())
+    return Standard_False;
   
   // find SDRs corresponding to Rep1 and Rep2 and remember their PDs
   Handle(Standard_Type) tSDR = STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation);
index db1b5038575520f4c79dc94cc09e81a370b14633..1dbbc2c2261ed1d5006aed632e1effbcbb30d343 100644 (file)
@@ -679,6 +679,8 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han
       if (RR.IsNull()) continue;
       SRRReversed = STEPConstruct_Assembly::CheckSRRReversesNAUO ( graph, CDSR );
       Handle(StepRepr_Representation) rep = ( SRRReversed ? RR->Rep2() : RR->Rep1() );
+      if(rep.IsNull())
+        continue;
       iatrsf = ComputeSRRWT ( RR, TP, Trsf );
       // find real ProductDefinition used rep
       Interface_EntityIterator subs3 = TP->Graph().Sharings(rep);
index bcfd329a9a38b7217d521c0dd8ab614b380425a6..3634d55ef0ed964e85d333bccc125863fabcd643 100644 (file)
@@ -342,31 +342,6 @@ Standard_Integer StepData_StepReaderData::NextForComplex
   return next;
 }
 
-
-//=======================================================================
-//function : stepstrcmp
-//purpose  : 
-//=======================================================================
-static Standard_Boolean stepstrcmp(const Standard_CString type,
-                                   const Standard_CString name)
-{
-//  name peut etre d un tenant ou de deux : auquel cas il a une partie LONGUE
-//  et une partie COURTE separees par un blanc
-//  Attention : False pour dire OK, True sinon (car remplace strcmp)
-  Standard_Integer i,j = 0; Standard_Boolean res = Standard_False;
-  for (i = 0; name[i] != '\0' && type[i] != '\0' && !res ; i ++) {
-    if (name[i] == ' ' && type[i] == '\0') { j = i; break; }
-    if (type[i] != name[i]) res = Standard_True;
-  }
-  if (!res || (j == 0)) return res;
-//  Pas trouve et un blanc suit : on continue
-  for (i = j+1; name[i] != '\0'; i ++) {
-    if (type[i-j-1] != name[i]) return Standard_True;
-  }
-  return Standard_False;
-}
-
-
 //=======================================================================
 //function : NamedForComplex
 //purpose  : 
@@ -379,7 +354,7 @@ Standard_Boolean  StepData_StepReaderData::NamedForComplex
   //Standard_Boolean stat = Standard_True;
   Standard_Integer n = (num <= 0 ? num0 : NextForComplex(num));
   // sln 04,10.2001. BUC61003. if(n==0) the next  function is not called in order to avoid exception
-  if ((n!=0) && (!stepstrcmp (RecordType(n).ToCString(),name)))
+  if ((n!=0) && (!strcmp( RecordType(n).ToCString(), name )) )
     {  num = n;  return Standard_True;  }
   
   if (n == 0) /*stat =*/ NamedForComplex (name,num0,n,ach);  // on a rembobine
@@ -387,7 +362,7 @@ Standard_Boolean  StepData_StepReaderData::NamedForComplex
   Handle(String) errmess = new String("Parameter n0.%d (%s) not a LIST");
   sprintf (txtmes,errmess->ToCString(),num0,name);
   for (n = num0; n > 0; n = NextForComplex(n)) {
-    if (!stepstrcmp (RecordType(n).ToCString(),name))  {
+    if (!strcmp( RecordType(n).ToCString(), name))  {
       num = n;
       errmess = new String("Complex Record n0.%d, member type %s not in alphabetic order");
       sprintf (txtmes,errmess->ToCString(),num0,name);
@@ -413,18 +388,22 @@ Standard_Boolean  StepData_StepReaderData::NamedForComplex
    Handle(Interface_Check)& ach) const
 {
   Standard_Integer n = (num <= 0 ? num0 : NextForComplex(num));
-  if ((n!=0) && !(stepstrcmp(RecordType(n).ToCString(),theName) &&
-                  stepstrcmp(RecordType(n).ToCString(), theShortName)))
-    {  num = n;  return Standard_True;  }
+  if ((n!=0) && (!strcmp( RecordType(n).ToCString(), theName) ||
+                 !strcmp(RecordType(n).ToCString(), theShortName)) )
+  {
+    num = n;
+    return Standard_True;
+  }
   
-  if (n == 0) 
-    NamedForComplex (theName, theShortName, num0, n, ach);
   //entities are not in alphabetical order
   Handle(String) errmess = new String("Parameter n0.%d (%s) not a LIST");
   sprintf (txtmes,errmess->ToCString(), num0, theName);
-  for (n = num0; n > 0; n = NextForComplex(n)) {
-    if (!(stepstrcmp(RecordType(n).ToCString(),theName) &&
-          stepstrcmp(RecordType(n).ToCString(), theShortName)))  {
+  for (n = num0; n > 0; n = NextForComplex(n))
+  {
+    if (!strcmp(RecordType(n).ToCString(),theName) ||
+        !strcmp(RecordType(n).ToCString(), theShortName))
+    {
       num = n;
       errmess = new String("Complex Record n0.%d, member type %s not in alphabetic order");
       sprintf (txtmes,errmess->ToCString(), num0, theName);
diff --git a/tests/bugs/step/bug29029 b/tests/bugs/step/bug29029
new file mode 100644 (file)
index 0000000..5559422
--- /dev/null
@@ -0,0 +1,15 @@
+puts "# ====================================================================="
+puts "# 0029029: E x c e p t i o n Raised with no Result during reading file 2033zsh1_1.stp"
+puts "# ====================================================================="
+puts ""
+puts "TODO 29029 ALL: Faulty shapes in variables faulty_1 to faulty_2"
+
+set filepath [locate_data_file bug29029_2033zsh1_1.stp]
+stepread $filepath a *
+tpcompound result
+    
+checkshape result
+checkprops result -s 10647.3
+checknbshapes result -wire 196 -face 196 -shell 1 -solid 1 -compound 2
+
+# checkview -display result -2d -path ${imagedir}/${test_image}.png