mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-08 18:40:55 +03:00
0028404: DRAW - avoid useless preparation of display data when shape is not shown
Class DBRep_DrawableShape is changed to postpone generation of display data until the shape is actually displayed (for the first time). Test perf draw bug28404 is added.
This commit is contained in:
parent
9775fa6110
commit
6662fe6313
@ -104,18 +104,16 @@ DBRep_DrawableShape::DBRep_DrawableShape
|
|||||||
myRgN(Standard_False),
|
myRgN(Standard_False),
|
||||||
myHid(Standard_False)
|
myHid(Standard_False)
|
||||||
{
|
{
|
||||||
Set(aShape);
|
myShape = aShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Set
|
//function : updateDisplayData
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void DBRep_DrawableShape::Set(const TopoDS_Shape& aShape)
|
void DBRep_DrawableShape::updateDisplayData () const
|
||||||
{
|
{
|
||||||
myShape = aShape;
|
|
||||||
|
|
||||||
myFaces.Clear();
|
myFaces.Clear();
|
||||||
myEdges.Clear();
|
myEdges.Clear();
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ void DBRep_DrawableShape::Set(const TopoDS_Shape& aShape)
|
|||||||
//==============================================================
|
//==============================================================
|
||||||
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
|
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
|
||||||
TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
|
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
|
||||||
Standard_Integer iedge;
|
Standard_Integer iedge;
|
||||||
|
|
||||||
for (iedge = 1; iedge <= edgemap.Extent(); iedge++) {
|
for (iedge = 1; iedge <= edgemap.Extent(); iedge++) {
|
||||||
@ -358,6 +356,9 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (myFaces.IsEmpty() || myEdges.IsEmpty())
|
||||||
|
updateDisplayData();
|
||||||
|
|
||||||
// hidden lines
|
// hidden lines
|
||||||
if (myHLR) {
|
if (myHLR) {
|
||||||
DBRep_DrawableShape* p = (DBRep_DrawableShape*) this;
|
DBRep_DrawableShape* p = (DBRep_DrawableShape*) this;
|
||||||
@ -610,7 +611,7 @@ void DBRep_DrawableShape::DrawOn(Draw_Display& dis) const
|
|||||||
if (aSurf.IsNull() || mytriangulations) {
|
if (aSurf.IsNull() || mytriangulations) {
|
||||||
Tr = BRep_Tool::Triangulation(F->Face(), loc);
|
Tr = BRep_Tool::Triangulation(F->Face(), loc);
|
||||||
if (!Tr.IsNull()) {
|
if (!Tr.IsNull()) {
|
||||||
Display(Tr, loc.Transformation(), dis);
|
display(Tr, loc.Transformation(), dis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itf.Next();
|
itf.Next();
|
||||||
@ -1093,11 +1094,11 @@ void DBRep_DrawableShape::LastPick(TopoDS_Shape& s,
|
|||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Display
|
//function : display
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void DBRep_DrawableShape::Display(const Handle(Poly_Triangulation)& T,
|
void DBRep_DrawableShape::display(const Handle(Poly_Triangulation)& T,
|
||||||
const gp_Trsf& tr,
|
const gp_Trsf& tr,
|
||||||
Draw_Display& dis) const
|
Draw_Display& dis) const
|
||||||
{
|
{
|
||||||
|
@ -53,8 +53,6 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C, const Draw_Color& FreeCol, const Draw_Color& ConnCol, const Draw_Color& EdgeCol, const Draw_Color& IsosCol, const Standard_Real size, const Standard_Integer nbisos, const Standard_Integer discret);
|
Standard_EXPORT DBRep_DrawableShape(const TopoDS_Shape& C, const Draw_Color& FreeCol, const Draw_Color& ConnCol, const Draw_Color& EdgeCol, const Draw_Color& IsosCol, const Standard_Real size, const Standard_Integer nbisos, const Standard_Integer discret);
|
||||||
|
|
||||||
Standard_EXPORT void Set (const TopoDS_Shape& C);
|
|
||||||
|
|
||||||
//! Changes the number of isoparametric curves in a shape.
|
//! Changes the number of isoparametric curves in a shape.
|
||||||
Standard_EXPORT void ChangeNbIsos (const Standard_Integer NbIsos);
|
Standard_EXPORT void ChangeNbIsos (const Standard_Integer NbIsos);
|
||||||
|
|
||||||
@ -113,20 +111,21 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape,Draw_Drawable3D)
|
DEFINE_STANDARD_RTTIEXT(DBRep_DrawableShape,Draw_Drawable3D)
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
void display (const Handle(Poly_Triangulation)& T, const gp_Trsf& tr, Draw_Display& dis) const;
|
||||||
|
|
||||||
|
//! Updates internal data necessary for display
|
||||||
|
void updateDisplayData () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
Standard_EXPORT void Display (const Handle(Poly_Triangulation)& T, const gp_Trsf& tr, Draw_Display& dis) const;
|
|
||||||
|
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
DBRep_ListOfEdge myEdges;
|
|
||||||
DBRep_ListOfFace myFaces;
|
mutable DBRep_ListOfEdge myEdges;
|
||||||
|
mutable DBRep_ListOfFace myFaces;
|
||||||
DBRep_ListOfHideData myHidData;
|
DBRep_ListOfHideData myHidData;
|
||||||
|
|
||||||
Standard_Real mySize;
|
Standard_Real mySize;
|
||||||
Standard_Integer myDiscret;
|
Standard_Integer myDiscret;
|
||||||
Draw_Color myFreeCol;
|
Draw_Color myFreeCol;
|
||||||
|
38
tests/perf/draw/bug28404
Normal file
38
tests/perf/draw/bug28404
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
puts "0028404: DRAW is slow"
|
||||||
|
|
||||||
|
# Test performance of code generating deep nested compound
|
||||||
|
# involving simple shape (box) around 93 K times
|
||||||
|
|
||||||
|
pload MODELING
|
||||||
|
|
||||||
|
# replicate shape nb times, adding rotation and translation to each copy
|
||||||
|
# (except first)
|
||||||
|
proc replicate {result shape nb cx cy cz rx ry rz angle tx ty tz} {
|
||||||
|
upvar $result res
|
||||||
|
upvar $shape s
|
||||||
|
|
||||||
|
copy s a0
|
||||||
|
set ll a0
|
||||||
|
for {set i 1} {$i < $nb} {incr i} {
|
||||||
|
copy "a[expr $i - 1]" a$i
|
||||||
|
trotate a$i $cx $cy $cz $rx $ry $rz $angle
|
||||||
|
ttranslate a$i $tx $ty $tz
|
||||||
|
lappend ll a$i
|
||||||
|
}
|
||||||
|
eval compound $ll res
|
||||||
|
return $result
|
||||||
|
}
|
||||||
|
|
||||||
|
# switch off autodisplay of shapes
|
||||||
|
autodisplay 0
|
||||||
|
|
||||||
|
chrono s restart
|
||||||
|
box b 10 10 10
|
||||||
|
replicate r1 b 12 0 0 0 0 0 1 30 15 20 3
|
||||||
|
replicate r2 r1 36 50 -50 0 1 1 0 10 0 0 0
|
||||||
|
replicate r3 r2 18 250 250 0 1 -1 0 20 100 100 20
|
||||||
|
replicate r4 r3 12 -300 -300 0 0 0 1 30 300 300 0
|
||||||
|
chrono s stop counter "huge compound generation CPU"
|
||||||
|
|
||||||
|
# return autodisplay
|
||||||
|
autodisplay 1
|
@ -10,3 +10,4 @@
|
|||||||
010 moddata
|
010 moddata
|
||||||
011 sewing
|
011 sewing
|
||||||
012 vis
|
012 vis
|
||||||
|
013 draw
|
||||||
|
Loading…
x
Reference in New Issue
Block a user