0029524: Modeling Algorithms - access violation in HLRBRep_PolyAlgo while computing...
authorkgv <kgv@opencascade.com>
Thu, 22 Feb 2018 15:42:15 +0000 (18:42 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 2 Mar 2018 12:27:49 +0000 (15:27 +0300)
src/HLRBRep/HLRBRep_PolyAlgo.cxx
tests/bugs/modalg_7/bug29524 [new file with mode: 0644]

index d1f8f29..4571e19 100644 (file)
@@ -438,13 +438,20 @@ void HLRBRep_PolyAlgo::StoreShell (const TopoDS_Shape& Shape,
          PD (f) = new HLRAlgo_PolyData();
          psd->PolyData().ChangeValue(iFace) = PD(f);
          PID(f) = new HLRAlgo_PolyInternalData(nbN,nbT);
-         Handle(HLRAlgo_PolyInternalData)& pid = 
-           *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
-         Handle(Geom_Surface) S = BRep_Tool::Surface(F);
-         if (S->DynamicType() == STANDARD_TYPE(Geom_RectangularTrimmedSurface))
-           S = Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface();
-         GeomAdaptor_Surface AS(S);
-         pid->Planar(AS.GetType() == GeomAbs_Plane);
+         Handle(HLRAlgo_PolyInternalData)& pid = *(Handle(HLRAlgo_PolyInternalData)*)&(PID(f));
+         if (Handle(Geom_Surface) S = BRep_Tool::Surface(F))
+         {
+           if (Handle(Geom_RectangularTrimmedSurface) aRectTrimSurf = Handle(Geom_RectangularTrimmedSurface)::DownCast(S))
+           {
+             S = aRectTrimSurf->BasisSurface();
+           }
+           GeomAdaptor_Surface AS(S);
+           pid->Planar(AS.GetType() == GeomAbs_Plane);
+         }
+         else
+         {
+           pid->Planar (false);
+         }
          HLRAlgo_Array1OfTData* TData = &pid->TData();
          HLRAlgo_Array1OfPISeg* PISeg = &pid->PISeg();
          HLRAlgo_Array1OfPINod* PINod = &pid->PINod();
diff --git a/tests/bugs/modalg_7/bug29524 b/tests/bugs/modalg_7/bug29524
new file mode 100644 (file)
index 0000000..49e5b39
--- /dev/null
@@ -0,0 +1,14 @@
+puts "========"
+puts "0029524: Modeling Algorithms - access violation in HLRBRep_PolyAlgo while computing HLR for triangulation-only surface"
+puts "========"
+puts ""
+
+pload VISUALIZATION XDE MODELING
+readstl m [locate_data_file model_stl_045.stl] triangulation
+vclear
+vinit View1
+vdisplay -dispMode 1 m
+vfit
+vdump $imagedir/${casename}_shading.png
+vhlr on -showHidden 0 -algoType polyAlgo
+vdump $imagedir/${casename}_hlr.png