mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-05 18:16:23 +03:00
0027821: Visualization, AIS_Shape - add NULL checks for displaying TopoDS_Face with NULL surface NULL surface
This commit is contained in:
parent
fe0d928d97
commit
413b1c1a97
@ -72,13 +72,17 @@ void BRepAdaptor_Surface::Initialize(const TopoDS_Face& F,
|
||||
{
|
||||
myFace = F;
|
||||
TopLoc_Location L;
|
||||
const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface(F, L);
|
||||
if (aSurface.IsNull())
|
||||
return;
|
||||
|
||||
if (Restriction) {
|
||||
Standard_Real umin,umax,vmin,vmax;
|
||||
BRepTools::UVBounds(F,umin,umax,vmin,vmax);
|
||||
mySurf.Load(BRep_Tool::Surface(F,L),umin,umax,vmin,vmax);
|
||||
mySurf.Load(aSurface,umin,umax,vmin,vmax);
|
||||
}
|
||||
else
|
||||
mySurf.Load(BRep_Tool::Surface(F,L));
|
||||
mySurf.Load(aSurface);
|
||||
myTrsf = L.Transformation();
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,14 @@ void BRepTools::UVBounds(const TopoDS_Face& F,
|
||||
{
|
||||
Bnd_Box2d B;
|
||||
AddUVBounds(F,B);
|
||||
if (!B.IsVoid())
|
||||
{
|
||||
B.Get(UMin,VMin,UMax,VMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
UMin = UMax = VMin = VMax = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -89,7 +96,14 @@ void BRepTools::UVBounds(const TopoDS_Face& F,
|
||||
{
|
||||
Bnd_Box2d B;
|
||||
AddUVBounds(F,W,B);
|
||||
if (!B.IsVoid())
|
||||
{
|
||||
B.Get(UMin,VMin,UMax,VMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
UMin = UMax = VMin = VMax = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +119,14 @@ void BRepTools::UVBounds(const TopoDS_Face& F,
|
||||
{
|
||||
Bnd_Box2d B;
|
||||
AddUVBounds(F,E,B);
|
||||
if (!B.IsVoid())
|
||||
{
|
||||
B.Get(UMin,VMin,UMax,VMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
UMin = UMax = VMin = VMax = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -130,7 +151,13 @@ void BRepTools::AddUVBounds(const TopoDS_Face& FF, Bnd_Box2d& B)
|
||||
if (aBox.IsVoid()) {
|
||||
Standard_Real UMin,UMax,VMin,VMax;
|
||||
TopLoc_Location L;
|
||||
BRep_Tool::Surface(F,L)->Bounds(UMin,UMax,VMin,VMax);
|
||||
const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(F, L);
|
||||
if (aSurf.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
aSurf->Bounds(UMin,UMax,VMin,VMax);
|
||||
aBox.Update(UMin,VMin,UMax,VMax);
|
||||
}
|
||||
|
||||
@ -162,7 +189,7 @@ void BRepTools::AddUVBounds(const TopoDS_Face& aF,
|
||||
const TopoDS_Edge& aE,
|
||||
Bnd_Box2d& aB)
|
||||
{
|
||||
Standard_Real aT1, aT2, aXmin, aYmin, aXmax, aYmax;
|
||||
Standard_Real aT1, aT2, aXmin = 0.0, aYmin = 0.0, aXmax = 0.0, aYmax = 0.0;
|
||||
Standard_Real aUmin, aUmax, aVmin, aVmax;
|
||||
Bnd_Box2d aBoxC, aBoxS;
|
||||
TopLoc_Location aLoc;
|
||||
@ -173,7 +200,10 @@ void BRepTools::AddUVBounds(const TopoDS_Face& aF,
|
||||
}
|
||||
//
|
||||
BndLib_Add2dCurve::Add(aC2D, aT1, aT2, 0., aBoxC);
|
||||
if (!aBoxC.IsVoid())
|
||||
{
|
||||
aBoxC.Get(aXmin, aYmin, aXmax, aYmax);
|
||||
}
|
||||
//
|
||||
Handle(Geom_Surface) aS = BRep_Tool::Surface(aF, aLoc);
|
||||
aS->Bounds(aUmin, aUmax, aVmin, aVmax);
|
||||
|
@ -147,6 +147,11 @@ Standard_Boolean Prs3d_ShapeTool::IsPlanarFace() const
|
||||
TopLoc_Location l;
|
||||
const TopoDS_Face& F = TopoDS::Face(myFaceExplorer.Current());
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F, l);
|
||||
if (S.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) TheType = S->DynamicType();
|
||||
|
||||
if (TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
|
||||
|
@ -178,6 +178,10 @@ void StdPrs_Isolines::AddOnTriangulation (const TopoDS_Face& theFace,
|
||||
// Access surface definition.
|
||||
TopLoc_Location aLocSurface;
|
||||
Handle(Geom_Surface) aSurface = BRep_Tool::Surface (theFace, aLocSurface);
|
||||
if (aSurface.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Access triangulation.
|
||||
TopLoc_Location aLocTriangulation;
|
||||
@ -611,7 +615,11 @@ void StdPrs_Isolines::UVIsoParameters (const TopoDS_Face& theFace,
|
||||
aVmax = Min (aVmax, theUVLimit);
|
||||
|
||||
TopLoc_Location aLocation;
|
||||
Handle(Geom_Surface) aSurface = BRep_Tool::Surface (theFace, aLocation);
|
||||
const Handle(Geom_Surface)& aSurface = BRep_Tool::Surface (theFace, aLocation);
|
||||
if (aSurface.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Boolean isUClosed = aSurface->IsUClosed();
|
||||
const Standard_Boolean isVClosed = aSurface->IsVClosed();
|
||||
|
@ -304,6 +304,11 @@ void StdPrs_WFShape::addEdgesOnTriangulation (const Handle(Prs3d_Presentation)&
|
||||
}
|
||||
}
|
||||
|
||||
if (aNbFree == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Allocate the arrays.
|
||||
TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
|
||||
Standard_Integer aNbInternal = (3 * aNbTriangles - aNbFree) / 2;
|
||||
|
20
tests/bugs/vis/bug27821
Normal file
20
tests/bugs/vis/bug27821
Normal file
@ -0,0 +1,20 @@
|
||||
puts "========"
|
||||
puts "AIS_Shape - displaying TopoDS_Face with NULL surface (test case checks there is no crash)"
|
||||
puts "========"
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
restore [locate_data_file bug27821_nullsurf.brep] s
|
||||
explode s F
|
||||
|
||||
vclear
|
||||
vinit View1
|
||||
vaxo
|
||||
vdisplay -noupdate -dispMode 0 s
|
||||
vaspects s -subshapes s_1 -setcolor RED
|
||||
vdisplay -noupdate -dispMode 1 s
|
||||
vshowfaceboundary s 1
|
||||
vfit
|
||||
vselect 250 250
|
||||
|
||||
vdump $imagedir/${casename}.png
|
Loading…
x
Reference in New Issue
Block a user