1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0023634: Eliminate Polyline and Polygon usage in drawers

Polylines and polygons removed, now everything is based on PrimitiveArrays.
Added use of Graphic3d_ArrayOfSegments, some additional clean up in Graphic3d_Group.
Dead code elimination in AIS and V3d
Corrected compilation errors
Fixed grid presentation
Adding test case correction
This commit is contained in:
kgv
2013-01-18 13:36:18 +04:00
parent 44cf55e600
commit b8ddfc2f5d
134 changed files with 4369 additions and 9572 deletions

View File

@@ -26,8 +26,6 @@
#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPrimitives.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Prs3d_LineAspect.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
@@ -60,8 +58,6 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
TopExp_Explorer ex;
Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable();
// find vertices not under ancestors.
TopAbs_ShapeEnum E = aShape.ShapeType();
if (E == TopAbs_COMPOUND) {
@@ -71,14 +67,11 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
}
}
Graphic3d_Array1OfVertex Vertex(1,2);
TColgp_SequenceOfPnt HiddenPnts;
TColgp_SequenceOfPnt SeenPnts;
Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
Standard_Real def;
if (rel) def = aDrawer->HLRDeviationCoefficient();
else def = aDrawer->MaximalChordialDeviation();
const Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
Standard_Real def = rel? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation();
BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle());
Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape);
@@ -86,10 +79,8 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
hider->Projector(aProjector->Projector());
hider->Angle(aDrawer->HLRAngle());
hider->Update();
//Standard_Integer i;
Standard_Real sta,end,dx,dy,dz;
Standard_ShortReal tolsta, tolend;
//gp_Pnt PSta, PEnd;
HLRAlgo_EdgeStatus status;
HLRAlgo_EdgeIterator It;
Standard_Boolean reg1,regn,outl, intl;
@@ -98,105 +89,76 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
HLRBRep_ListOfBPoint BiPntVis, BiPntHid;
for (hider->InitHide(); hider->MoreHide(); hider->NextHide()) {
for (hider->InitHide(); hider->MoreHide(); hider->NextHide())
{
hider->Hide(Coordinates, status, S, reg1, regn, outl, intl);
dx = PntX2 - PntX1;
dy = PntY2 - PntY1;
dz = PntZ2 - PntZ1;
for (It.InitVisible(status); It.MoreVisible(); It.NextVisible()) {
for (It.InitVisible(status); It.MoreVisible(); It.NextVisible())
{
It.Visible(sta,tolsta,end,tolend);
BiPntVis.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
}
for (It.InitHidden(status); It.MoreHidden(); It.NextHidden()) {
for (It.InitHidden(status); It.MoreHidden(); It.NextHidden())
{
It.Hidden(sta,tolsta,end,tolend);
BiPntHid.Append
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
(HLRBRep_BiPoint
(PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz,
PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz,
S,reg1,regn,outl,intl));
}
}
// storage in the group:
HLRBRep_ListIteratorOfListOfBPoint ItB;
if (aDrawer->DrawHiddenLine()) {
if(!isPrimArrayEnabled) {
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->BeginPrimitives();
}
for (ItB.Initialize(BiPntHid); ItB.More(); ItB.Next()) {
const HLRBRep_BiPoint& BP = ItB.Value();
if (!BP.RgNLine() || BP.OutLine()) {
const gp_Pnt& P1 = BP.P1();
const gp_Pnt& P2 = BP.P2();
HiddenPnts.Append(P1);
HiddenPnts.Append(P2);
Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z());
Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(Vertex);
HiddenPnts.Append(BP.P1());
HiddenPnts.Append(BP.P2());
}
}
if(!isPrimArrayEnabled)
aGroup->EndPrimitives();
}
if(!isPrimArrayEnabled) {
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->BeginPrimitives();
}
for (ItB.Initialize(BiPntVis); ItB.More(); ItB.Next()) {
const HLRBRep_BiPoint& BP = ItB.Value();
if (!BP.RgNLine() || BP.OutLine()) {
const gp_Pnt& P1 = BP.P1();
const gp_Pnt& P2 = BP.P2();
SeenPnts.Append(P1);
SeenPnts.Append(P2);
Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z());
Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z());
if(!isPrimArrayEnabled)
aGroup->Polyline(Vertex);
SeenPnts.Append(BP.P1());
SeenPnts.Append(BP.P2());
}
}
if(!isPrimArrayEnabled)
aGroup->EndPrimitives();
if(isPrimArrayEnabled) {
Standard_Integer nbVertices = HiddenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
HiddenArray->AddBound(2);
HiddenArray->AddVertex(HiddenPnts.Value(i));
HiddenArray->AddVertex(HiddenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->BeginPrimitives();
aGroup->AddPrimitiveArray(HiddenArray);
aGroup->EndPrimitives();
Standard_Integer nbVertices = HiddenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
HiddenArray->AddBound(2);
HiddenArray->AddVertex(HiddenPnts.Value(i));
HiddenArray->AddVertex(HiddenPnts.Value(i+1));
}
nbVertices = SeenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
SeenArray->AddBound(2);
SeenArray->AddVertex(SeenPnts.Value(i));
SeenArray->AddVertex(SeenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->BeginPrimitives();
aGroup->AddPrimitiveArray(SeenArray);
aGroup->EndPrimitives();
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect());
aGroup->AddPrimitiveArray(HiddenArray);
}
nbVertices = SeenPnts.Length();
if(nbVertices > 0) {
Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2);
for(int i=1; i<=nbVertices; i+=2) {
SeenArray->AddBound(2);
SeenArray->AddVertex(SeenPnts.Value(i));
SeenArray->AddVertex(SeenPnts.Value(i+1));
}
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->AddPrimitiveArray(SeenArray);
}
}