0023855: Old BOPs fail on Win7 64bit when using TBB
authorRoman Lygin <roman.lygin@gmail.com>
Thu, 30 Jan 2014 08:58:31 +0000 (12:58 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 30 Jan 2014 08:59:32 +0000 (12:59 +0400)
Minor code refactoring (readability)

Test case for issue CR23855

src/TopOpeBRep/TopOpeBRep_sort.cxx
tests/bugs/modalg_5/bug23855 [new file with mode: 0644]

index f4c4737..1cecf17 100644 (file)
 #include <stdlib.h>
 #include <TopOpeBRep_define.hxx>
 
-typedef Standard_Address BOA_t;
+typedef TopOpeBRepDS_ListOfInterference* BOA_t;
 
-int compll(const void* v1, const void* v2) {
-  const TopOpeBRepDS_ListOfInterference* l1 = (const TopOpeBRepDS_ListOfInterference*)(*((long int*)v1));
-  const TopOpeBRepDS_ListOfInterference* l2 = (const TopOpeBRepDS_ListOfInterference*)(*((long int*)v2));
+static int compll(const void* v1, const void* v2) {
+  BOA_t l1 = *(BOA_t*)v1;
+  BOA_t l2 = *(BOA_t*)v2;
   if      (l1->Extent() == 0) return (0);
   else if (l2->Extent() == 0) return (0);
 
-  Handle(TopOpeBRepDS_CurvePointInterference) i1 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l1->First()); if (i1.IsNull()) return (0);
-  Handle(TopOpeBRepDS_CurvePointInterference) i2 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l2->First()); if (i2.IsNull()) return (0);
+  Handle(TopOpeBRepDS_CurvePointInterference) i1 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l1->First());
+  if (i1.IsNull())
+    return 0;
+  Handle(TopOpeBRepDS_CurvePointInterference) i2 = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(l2->First());
+  if (i2.IsNull())
+    return 0;
   Standard_Real p1 = i1->Parameter();
   Standard_Real p2 = i2->Parameter();
   if      (p1 < p2) return (-1);
   else if (p1 > p2) return (1);
-  else return (0);
+  return 0;
 }
      
-Standard_EXPORT void BREP_sortonparameter2(TopOpeBRepDS_ListOfInterference& LOI)
+static void BREP_sortonparameter2(TopOpeBRepDS_ListOfInterference& LOI)
 {
-  TopOpeBRepDS_TKI tki;tki.FillOnGeometry(LOI);
-  Standard_Integer ng=0; for(tki.Init();tki.More();tki.Next()) ng++;
-  size_t sng=(size_t)ng;size_t sad=sizeof(BOA_t);
-  BOA_t* T = (BOA_t*)malloc((size_t)(sng*sad));TopOpeBRepDS_Kind K;Standard_Integer G;Standard_Integer j=0;
-  for(tki.Init();tki.More();tki.Next(),j++) T[j]=(BOA_t)&(tki.Value(K,G));
+  TopOpeBRepDS_TKI tki;
+  tki.FillOnGeometry(LOI);
+  Standard_Integer ng=0;
+  for(tki.Init();tki.More();tki.Next())
+    ng++;
+  size_t sng=(size_t)ng;
+  size_t sad=sizeof(BOA_t);
+  BOA_t* T = (BOA_t*)Standard::Allocate (sng*sad);
+  TopOpeBRepDS_Kind K;
+  Standard_Integer G, j=0;
+  for(tki.Init();tki.More();tki.Next(),j++)
+    T[j]= &(tki.ChangeValue(K,G));
   qsort(T,sng,sad,compll);
-  LOI.Clear();for(j=0;j<ng;j++) {TopOpeBRepDS_ListOfInterference& l=*((TopOpeBRepDS_ListOfInterference*)T[j]);LOI.Append(l);}
-  free(T);
+  LOI.Clear();
+  for(j=0;j<ng;j++)
+  {
+    TopOpeBRepDS_ListOfInterference& l=*T[j];
+    LOI.Append(l);
+  }
+  Standard::Free(T);
 }
 
 Standard_EXPORT void BREP_sortonparameter(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
diff --git a/tests/bugs/modalg_5/bug23855 b/tests/bugs/modalg_5/bug23855
new file mode 100644 (file)
index 0000000..eb6769a
--- /dev/null
@@ -0,0 +1,11 @@
+puts "========="
+puts "OCC23855"
+puts "========="
+puts ""
+###########################################################
+# Old BOPs fail on Win7 64bit when using TBB
+###########################################################
+
+psphere s1 10
+psphere s2 10
+common result s1 s2