mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-06 18:26:22 +03:00
0025768: Visualization, Graphic3d_Structure - do not use invalid bounding boxes of empty groups
Prs3d_WFShape::Add() - do not create empty group Graphic3d_Structure::minMaxCoord() - do not use uninitialized bounding box Added test case bugs/vis/bug25768
This commit is contained in:
parent
15b54261a3
commit
8d3aa19e69
@ -853,8 +853,7 @@ is
|
|||||||
---Purpose: Returns the identification number of the structure <me>.
|
---Purpose: Returns the identification number of the structure <me>.
|
||||||
---Category: Private methods
|
---Category: Private methods
|
||||||
|
|
||||||
minMaxCoord (me;
|
minMaxCoord (me)
|
||||||
theToIgnoreInfiniteFlag : Boolean from Standard = Standard_False)
|
|
||||||
returns BndBox4f from Graphic3d
|
returns BndBox4f from Graphic3d
|
||||||
is static private;
|
is static private;
|
||||||
---Purpose: Returns the extreme coordinates found in the structure <me> without transformation applied.
|
---Purpose: Returns the extreme coordinates found in the structure <me> without transformation applied.
|
||||||
|
@ -1749,22 +1749,13 @@ Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager() const
|
|||||||
//function : minMaxCoord
|
//function : minMaxCoord
|
||||||
//purpose :
|
//purpose :
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord (const Standard_Boolean theToIgnoreInfiniteFlag) const
|
Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord() const
|
||||||
{
|
{
|
||||||
Graphic3d_BndBox4f aBnd;
|
Graphic3d_BndBox4f aBnd;
|
||||||
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (myCStructure->Groups()); aGroupIter.More(); aGroupIter.Next())
|
||||||
{
|
|
||||||
if (!theToIgnoreInfiniteFlag)
|
|
||||||
{
|
{
|
||||||
aBnd.Combine (aGroupIter.Value()->BoundingBox());
|
aBnd.Combine (aGroupIter.Value()->BoundingBox());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Graphic3d_BndBox4f aValidBnd (aGroupIter.Value()->BoundingBox().CornerMin(),
|
|
||||||
aGroupIter.Value()->BoundingBox().CornerMax());
|
|
||||||
aBnd.Combine (aValidBnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aBnd;
|
return aBnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1775,7 +1766,7 @@ Graphic3d_BndBox4f Graphic3d_Structure::minMaxCoord (const Standard_Boolean theT
|
|||||||
void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
|
void Graphic3d_Structure::getBox (Graphic3d_BndBox4d& theBox,
|
||||||
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
const Standard_Boolean theToIgnoreInfiniteFlag) const
|
||||||
{
|
{
|
||||||
Graphic3d_BndBox4f aBoxF = minMaxCoord (theToIgnoreInfiniteFlag);
|
Graphic3d_BndBox4f aBoxF = minMaxCoord();
|
||||||
if (aBoxF.IsValid())
|
if (aBoxF.IsValid())
|
||||||
{
|
{
|
||||||
theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(),
|
theBox = Graphic3d_BndBox4d (Graphic3d_Vec4d ((Standard_Real )aBoxF.CornerMin().x(),
|
||||||
|
@ -157,8 +157,6 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
|
|||||||
|
|
||||||
Standard_Real aDeflection = Prs3d::GetDeflection(theShape, theDrawer);
|
Standard_Real aDeflection = Prs3d::GetDeflection(theShape, theDrawer);
|
||||||
|
|
||||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
|
|
||||||
|
|
||||||
Prs3d_NListOfSequenceOfPnt anUIsoCurves;
|
Prs3d_NListOfSequenceOfPnt anUIsoCurves;
|
||||||
Prs3d_NListOfSequenceOfPnt aVIsoCurves;
|
Prs3d_NListOfSequenceOfPnt aVIsoCurves;
|
||||||
Prs3d_NListOfSequenceOfPnt aWireCurves;
|
Prs3d_NListOfSequenceOfPnt aWireCurves;
|
||||||
@ -424,7 +422,6 @@ void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
|
|||||||
if (theDrawer->WireDraw())
|
if (theDrawer->WireDraw())
|
||||||
{
|
{
|
||||||
// Wire (without any neighbour)
|
// Wire (without any neighbour)
|
||||||
aGroup->SetPrimitivesAspect (theDrawer->WireAspect()->Aspect());
|
|
||||||
for (anIt.Initialize(aLWire); anIt.More(); anIt.Next())
|
for (anIt.Initialize(aLWire); anIt.More(); anIt.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
|
const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
|
||||||
|
@ -127,17 +127,16 @@ static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
|
|||||||
|
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
// function: DrawCurve
|
// function: drawCurve
|
||||||
// purpose:
|
// purpose:
|
||||||
//==================================================================
|
//==================================================================
|
||||||
static void DrawCurve (Adaptor3d_Curve& aCurve,
|
static void drawCurve (Adaptor3d_Curve& aCurve,
|
||||||
const Handle(Graphic3d_Group) aGroup,
|
const Handle(Graphic3d_Group)& aGroup,
|
||||||
const Quantity_Length TheDeflection,
|
const Quantity_Length TheDeflection,
|
||||||
const Standard_Real anAngle,
|
const Standard_Real anAngle,
|
||||||
const Standard_Real U1,
|
const Standard_Real U1,
|
||||||
const Standard_Real U2,
|
const Standard_Real U2,
|
||||||
TColgp_SequenceOfPnt& Points,
|
TColgp_SequenceOfPnt& Points)
|
||||||
const Standard_Boolean drawCurve)
|
|
||||||
{
|
{
|
||||||
switch (aCurve.GetType())
|
switch (aCurve.GetType())
|
||||||
{
|
{
|
||||||
@ -147,7 +146,7 @@ static void DrawCurve (Adaptor3d_Curve& aCurve,
|
|||||||
gp_Pnt p2 = aCurve.Value(U2);
|
gp_Pnt p2 = aCurve.Value(U2);
|
||||||
Points.Append(p1);
|
Points.Append(p1);
|
||||||
Points.Append(p2);
|
Points.Append(p2);
|
||||||
if(drawCurve)
|
if (!aGroup.IsNull())
|
||||||
{
|
{
|
||||||
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
|
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
|
||||||
aPrims->AddVertex(p1);
|
aPrims->AddVertex(p1);
|
||||||
@ -187,17 +186,21 @@ static void DrawCurve (Adaptor3d_Curve& aCurve,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Handle(Graphic3d_ArrayOfPolylines) aPrims;
|
Handle(Graphic3d_ArrayOfPolylines) aPrims;
|
||||||
if(drawCurve)
|
if (!aGroup.IsNull())
|
||||||
aPrims = new Graphic3d_ArrayOfPolylines(SeqP.Length());
|
aPrims = new Graphic3d_ArrayOfPolylines(SeqP.Length());
|
||||||
|
|
||||||
for (i = 1; i <= SeqP.Length(); i++) {
|
for (i = 1; i <= SeqP.Length(); i++) {
|
||||||
const gp_Pnt& p = SeqP.Value(i);
|
const gp_Pnt& p = SeqP.Value(i);
|
||||||
Points.Append(p);
|
Points.Append(p);
|
||||||
if(drawCurve)
|
if (!aGroup.IsNull())
|
||||||
|
{
|
||||||
aPrims->AddVertex(p);
|
aPrims->AddVertex(p);
|
||||||
}
|
}
|
||||||
if(drawCurve)
|
}
|
||||||
aGroup->AddPrimitiveArray(aPrims);
|
if (!aGroup.IsNull())
|
||||||
|
{
|
||||||
|
aGroup->AddPrimitiveArray (aPrims);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +288,7 @@ static Standard_Boolean MatchCurve (
|
|||||||
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation,
|
||||||
Adaptor3d_Curve& aCurve,
|
Adaptor3d_Curve& aCurve,
|
||||||
const Handle (Prs3d_Drawer)& aDrawer,
|
const Handle (Prs3d_Drawer)& aDrawer,
|
||||||
const Standard_Boolean drawCurve)
|
const Standard_Boolean theToDrawCurve)
|
||||||
{
|
{
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
|
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
|
||||||
|
|
||||||
@ -293,11 +296,17 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
|
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
|
||||||
{
|
{
|
||||||
TColgp_SequenceOfPnt Points;
|
TColgp_SequenceOfPnt Points;
|
||||||
DrawCurve(aCurve,
|
Handle(Graphic3d_Group) aGroup;
|
||||||
Prs3d_Root::CurrentGroup(aPresentation),
|
if (theToDrawCurve)
|
||||||
|
{
|
||||||
|
aGroup = Prs3d_Root::CurrentGroup (aPresentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCurve(aCurve,
|
||||||
|
aGroup,
|
||||||
GetDeflection(aCurve, V1, V2, aDrawer),
|
GetDeflection(aCurve, V1, V2, aDrawer),
|
||||||
aDrawer->DeviationAngle(),
|
aDrawer->DeviationAngle(),
|
||||||
V1, V2, Points, drawCurve);
|
V1, V2, Points);
|
||||||
|
|
||||||
if (aDrawer->LineArrowDraw()) {
|
if (aDrawer->LineArrowDraw()) {
|
||||||
gp_Pnt Location;
|
gp_Pnt Location;
|
||||||
@ -322,9 +331,14 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
const Standard_Real U1,
|
const Standard_Real U1,
|
||||||
const Standard_Real U2,
|
const Standard_Real U2,
|
||||||
const Handle (Prs3d_Drawer)& aDrawer,
|
const Handle (Prs3d_Drawer)& aDrawer,
|
||||||
const Standard_Boolean drawCurve)
|
const Standard_Boolean theToDrawCurve)
|
||||||
{
|
{
|
||||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
|
Handle(Graphic3d_Group) aGroup;
|
||||||
|
if (theToDrawCurve)
|
||||||
|
{
|
||||||
|
aGroup = Prs3d_Root::CurrentGroup (aPresentation);
|
||||||
|
aGroup->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect());
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Real V1 = U1;
|
Standard_Real V1 = U1;
|
||||||
Standard_Real V2 = U2;
|
Standard_Real V2 = U2;
|
||||||
@ -333,11 +347,11 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
|
if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue();
|
||||||
|
|
||||||
TColgp_SequenceOfPnt Points;
|
TColgp_SequenceOfPnt Points;
|
||||||
DrawCurve(aCurve,
|
drawCurve(aCurve,
|
||||||
Prs3d_Root::CurrentGroup(aPresentation),
|
aGroup,
|
||||||
GetDeflection(aCurve, V1, V2, aDrawer),
|
GetDeflection(aCurve, V1, V2, aDrawer),
|
||||||
aDrawer->DeviationAngle(),
|
aDrawer->DeviationAngle(),
|
||||||
V1 , V2, Points, drawCurve);
|
V1 , V2, Points);
|
||||||
|
|
||||||
if (aDrawer->LineArrowDraw()) {
|
if (aDrawer->LineArrowDraw()) {
|
||||||
gp_Pnt Location;
|
gp_Pnt Location;
|
||||||
@ -362,10 +376,15 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
const Standard_Real aDeflection,
|
const Standard_Real aDeflection,
|
||||||
TColgp_SequenceOfPnt& Points,
|
TColgp_SequenceOfPnt& Points,
|
||||||
const Standard_Real anAngle,
|
const Standard_Real anAngle,
|
||||||
const Standard_Boolean drawCurve)
|
const Standard_Boolean theToDrawCurve)
|
||||||
{
|
{
|
||||||
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
|
Handle(Graphic3d_Group) aGroup;
|
||||||
aDeflection, anAngle, U1, U2, Points, drawCurve);
|
if (theToDrawCurve)
|
||||||
|
{
|
||||||
|
aGroup = Prs3d_Root::CurrentGroup (aPresentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
drawCurve (aCurve, aGroup, aDeflection, anAngle, U1, U2, Points);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
@ -377,15 +396,22 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
const Standard_Real aDeflection,
|
const Standard_Real aDeflection,
|
||||||
const Standard_Real aLimit,
|
const Standard_Real aLimit,
|
||||||
const Standard_Real anAngle,
|
const Standard_Real anAngle,
|
||||||
const Standard_Boolean drawCurve)
|
const Standard_Boolean theToDrawCurve)
|
||||||
{
|
{
|
||||||
Standard_Real V1, V2;
|
Standard_Real V1, V2;
|
||||||
if (FindLimits(aCurve, aLimit, V1, V2))
|
if (!FindLimits(aCurve, aLimit, V1, V2))
|
||||||
{
|
{
|
||||||
TColgp_SequenceOfPnt Points;
|
return;
|
||||||
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
|
|
||||||
aDeflection, anAngle, V1, V2, Points, drawCurve);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle(Graphic3d_Group) aGroup;
|
||||||
|
if (theToDrawCurve)
|
||||||
|
{
|
||||||
|
aGroup = Prs3d_Root::CurrentGroup (aPresentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
TColgp_SequenceOfPnt Points;
|
||||||
|
drawCurve (aCurve, aGroup, aDeflection, anAngle, V1, V2, Points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -398,12 +424,20 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati
|
|||||||
const Standard_Real aDeflection,
|
const Standard_Real aDeflection,
|
||||||
const Handle(Prs3d_Drawer)& aDrawer,
|
const Handle(Prs3d_Drawer)& aDrawer,
|
||||||
TColgp_SequenceOfPnt& Points,
|
TColgp_SequenceOfPnt& Points,
|
||||||
const Standard_Boolean drawCurve)
|
const Standard_Boolean theToDrawCurve)
|
||||||
{
|
{
|
||||||
Standard_Real V1, V2;
|
Standard_Real V1, V2;
|
||||||
if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
|
if (!FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2))
|
||||||
DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation),
|
{
|
||||||
aDeflection, aDrawer->DeviationAngle(), V1, V2, Points, drawCurve);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(Graphic3d_Group) aGroup;
|
||||||
|
if (theToDrawCurve)
|
||||||
|
{
|
||||||
|
aGroup = Prs3d_Root::CurrentGroup (aPresentation);
|
||||||
|
}
|
||||||
|
drawCurve (aCurve, aGroup, aDeflection, aDrawer->DeviationAngle(), V1, V2, Points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
28
tests/bugs/vis/bug25768
Normal file
28
tests/bugs/vis/bug25768
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
puts "========="
|
||||||
|
puts "CR25768"
|
||||||
|
puts "========="
|
||||||
|
puts ""
|
||||||
|
###########################################################################################
|
||||||
|
# Visualization, Graphic3d_Structure - do not use invalid bounding boxes of empty groups
|
||||||
|
###########################################################################################
|
||||||
|
box b 100 0 0 2 1 1
|
||||||
|
vinit View1
|
||||||
|
vclear
|
||||||
|
vaxo
|
||||||
|
vsetdispmode 0
|
||||||
|
vdisplay b
|
||||||
|
vfit
|
||||||
|
vzoom 0.1
|
||||||
|
vbounding b
|
||||||
|
|
||||||
|
set x_coord 115
|
||||||
|
set y_coord 153
|
||||||
|
checkcolor $x_coord $y_coord 0 0 0
|
||||||
|
|
||||||
|
if { $stat != 1 } {
|
||||||
|
puts "Error: invalid broken bounding boxes"
|
||||||
|
} else {
|
||||||
|
puts "OK: valid boundong box"
|
||||||
|
}
|
||||||
|
|
||||||
|
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user