1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00

0028895: Visualization, V3d_View::SetComputedMode() - HLR calculation is performed multiple times when 'hlr on' has been called

V3d_View::SetComputedMode() - removed implicit View update.

Graphic3d_CView::SetComputedMode(), ::ReCompute() - fixed
uninitialized bounding box of Computed structure.

PrsMgr_Presentation::Compute() - fixed computation of Computed structure
with transformation within Connected presentation.

StdPrs_HLRPolyShape::Add() now creates Graphic3d_ArrayOfSegments instead of
inefficient Graphic3d_ArrayOfPolylines with boundaries at every segment.

Fixed error in test case bugs/vis/bug24388_1.
This commit is contained in:
kgv 2017-07-10 15:43:25 +03:00 committed by bugmaster
parent 851dacdbb9
commit 1eeef710bb
15 changed files with 316 additions and 187 deletions
samples
CSharp
OCCTProxy
OCCTProxy_D3D
mfc
occtdemo/Common/WNT
standard
04_Viewer3d/src
08_HLR/src
09_Animation/src
10_Convert/src/WNT
Common
qt/Common/src
src
tests/bugs/vis

@ -133,6 +133,7 @@ public:
if (!myView().IsNull()) if (!myView().IsNull())
{ {
myView()->SetComputedMode (Standard_False); myView()->SetComputedMode (Standard_False);
myView()->Redraw();
} }
} }
@ -144,6 +145,7 @@ public:
if (!myView().IsNull()) if (!myView().IsNull())
{ {
myView()->SetComputedMode (Standard_True); myView()->SetComputedMode (Standard_True);
myView()->Redraw();
} }
} }

@ -148,6 +148,7 @@ public:
if (!myView().IsNull()) if (!myView().IsNull())
{ {
myView()->SetComputedMode (Standard_False); myView()->SetComputedMode (Standard_False);
myView()->Redraw();
} }
} }
@ -159,6 +160,7 @@ public:
if (!myView().IsNull()) if (!myView().IsNull())
{ {
myView()->SetComputedMode (Standard_True); myView()->SetComputedMode (Standard_True);
myView()->Redraw();
} }
} }

@ -278,6 +278,7 @@ void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True); myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
myCurrentMode = CurAction3d_Nothing; myCurrentMode = CurAction3d_Nothing;
@ -301,6 +302,7 @@ void COCCDemoView::OnRButtonUp(UINT nFlags, CPoint point)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True); myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
} }
@ -497,14 +499,17 @@ void COCCDemoView::RedrawVisMode()
case VIS_WIREFRAME: case VIS_WIREFRAME:
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame); GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_SHADE: case VIS_SHADE:
GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded); GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_HLR: case VIS_HLR:
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (Standard_True); myView->SetComputedMode (Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame); GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
break; break;

@ -306,6 +306,7 @@ void CViewer3dView::OnBUTTONHlrOff()
{ {
myHlrModeIsOn = Standard_False; myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_False);\n" TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_False);\n"
" "); " ");
@ -319,6 +320,7 @@ void CViewer3dView::OnBUTTONHlrOn()
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myHlrModeIsOn = Standard_True; myHlrModeIsOn = Standard_True;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_True);\n" TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_True);\n"
@ -616,7 +618,11 @@ void CViewer3dView::OnRButtonDown(UINT nFlags, CPoint point)
void CViewer3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) void CViewer3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (myHlrModeIsOn); if (myHlrModeIsOn)
{
myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
@ -1177,14 +1183,17 @@ void CViewer3dView::RedrawVisMode()
case VIS_WIREFRAME: case VIS_WIREFRAME:
GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_SHADE: case VIS_SHADE:
GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_HLR: case VIS_HLR:
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (Standard_True); myView->SetComputedMode (Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
break; break;

@ -435,11 +435,13 @@ void CSelectionDialog::OnHlrMode()
if (!m_HlrModeIsOn) if (!m_HlrModeIsOn)
{ {
myActiveView->SetComputedMode (m_HlrModeIsOn != 0); myActiveView->SetComputedMode (m_HlrModeIsOn != 0);
myActiveView->Redraw();
} }
else else
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myActiveView->SetComputedMode (m_HlrModeIsOn != 0); myActiveView->SetComputedMode (m_HlrModeIsOn != 0);
myActiveView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
OnDisplay(false); OnDisplay(false);
@ -500,7 +502,11 @@ void CSelectionDialog::OnRButtonUp(UINT nFlags, CPoint point)
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
// reset the good HLR mode according to the stored one // reset the good HLR mode according to the stored one
// --> dynamic rotation may have change it // --> dynamic rotation may have change it
myActiveView->SetComputedMode (m_HlrModeIsOn != 0); if (m_HlrModeIsOn != 0)
{
myActiveView->SetComputedMode (true);
myActiveView->Redraw();
}
OnDisplay(false); OnDisplay(false);
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }

@ -258,6 +258,7 @@ void CAnimationView3D::OnBUTTONHlrOff()
{ {
myHlrModeIsOn = Standard_False; myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
} }
void CAnimationView3D::OnBUTTONHlrOn() void CAnimationView3D::OnBUTTONHlrOn()
@ -265,6 +266,7 @@ void CAnimationView3D::OnBUTTONHlrOn()
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myHlrModeIsOn = Standard_True; myHlrModeIsOn = Standard_True;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
@ -470,7 +472,11 @@ void CAnimationView3D::OnRButtonDown(UINT nFlags, CPoint point)
void CAnimationView3D::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) void CAnimationView3D::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (myHlrModeIsOn); if (myHlrModeIsOn)
{
myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }

@ -277,6 +277,7 @@ void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True); myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
myCurrentMode = CurAction3d_Nothing; myCurrentMode = CurAction3d_Nothing;
@ -300,6 +301,7 @@ void COCCDemoView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True); myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
} }
@ -496,14 +498,17 @@ void COCCDemoView::RedrawVisMode()
case VIS_WIREFRAME: case VIS_WIREFRAME:
GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_SHADE: case VIS_SHADE:
GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True);
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
myView->Redraw();
break; break;
case VIS_HLR: case VIS_HLR:
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (Standard_True); myView->SetComputedMode (Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True);
break; break;

@ -216,6 +216,7 @@ void OCC_3dView::OnBUTTONHlrOff()
{ {
myHlrModeIsOn = Standard_False; myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
} }
void OCC_3dView::OnBUTTONHlrOn() void OCC_3dView::OnBUTTONHlrOn()
@ -223,6 +224,7 @@ void OCC_3dView::OnBUTTONHlrOn()
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myHlrModeIsOn = Standard_True; myHlrModeIsOn = Standard_True;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }
@ -365,6 +367,7 @@ void OCC_3dView::OnLButtonUp(UINT nFlags, CPoint point)
{ {
CWaitCursor aWaitCursor; CWaitCursor aWaitCursor;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
} }
else else
{ {
@ -415,7 +418,11 @@ void OCC_3dView::OnRButtonDown(UINT nFlags, CPoint point)
void OCC_3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) void OCC_3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/)
{ {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (myHlrModeIsOn); if (myHlrModeIsOn)
{
myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
}
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
} }

@ -204,6 +204,7 @@ void View::hlrOff()
QApplication::setOverrideCursor( Qt::WaitCursor ); QApplication::setOverrideCursor( Qt::WaitCursor );
myHlrModeIsOn = Standard_False; myHlrModeIsOn = Standard_False;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -212,6 +213,7 @@ void View::hlrOn()
QApplication::setOverrideCursor( Qt::WaitCursor ); QApplication::setOverrideCursor( Qt::WaitCursor );
myHlrModeIsOn = Standard_True; myHlrModeIsOn = Standard_True;
myView->SetComputedMode (myHlrModeIsOn); myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@ -742,7 +744,11 @@ void View::onRButtonUp( Qt::MouseButtons /*nFlags*/, const QPoint point )
QApplication::setOverrideCursor( Qt::WaitCursor ); QApplication::setOverrideCursor( Qt::WaitCursor );
// reset tyhe good Degenerated mode according to the strored one // reset tyhe good Degenerated mode according to the strored one
// --> dynamic rotation may have change it // --> dynamic rotation may have change it
myView->SetComputedMode (myHlrModeIsOn); if (myHlrModeIsOn)
{
myView->SetComputedMode (myHlrModeIsOn);
myView->Redraw();
}
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
myCurrentMode = CurAction3d_Nothing; myCurrentMode = CurAction3d_Nothing;
} }

@ -258,6 +258,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode)
myStructsComputed .Append (aCompStruct); myStructsComputed .Append (aCompStruct);
} }
aCompStruct->CalculateBoundBox();
eraseStructure (aStruct->CStructure()); eraseStructure (aStruct->CStructure());
displayStructure (aCompStruct->CStructure(), aStruct->DisplayPriority()); displayStructure (aCompStruct->CStructure(), aStruct->DisplayPriority());
} }
@ -306,6 +307,7 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct)
theStruct->IsTransformed() ? theStruct->Compute (this, theStruct->Transformation(), aCompStruct) theStruct->IsTransformed() ? theStruct->Compute (this, theStruct->Transformation(), aCompStruct)
: theStruct->Compute (this, aCompStruct); : theStruct->Compute (this, aCompStruct);
aCompStruct->SetHLRValidation (Standard_True); aCompStruct->SetHLRValidation (Standard_True);
aCompStruct->CalculateBoundBox();
// of which type will be the computed? // of which type will be the computed?
const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME

@ -287,31 +287,7 @@ Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d
const Handle(Geom_Transformation)& theTrsf) const Handle(Geom_Transformation)& theTrsf)
{ {
Handle(Prs3d_Presentation) aPrs3d = new Prs3d_Presentation (myPresentationManager->StructureManager()); Handle(Prs3d_Presentation) aPrs3d = new Prs3d_Presentation (myPresentationManager->StructureManager());
if (theTrsf->Form() == gp_Translation) myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d);
{
myPresentableObject->Compute (Projector (theProjector), aPrs3d);
aPrs3d->SetTransformation (theTrsf);
return aPrs3d;
}
// waiting that something is done in gp_Trsf...rob
for (Standard_Integer i = 1; i <= 3; ++i)
{
for (Standard_Integer j = 1; j <= 3; ++j)
{
if (i != j)
{
if (Abs (theTrsf->Value (i, j)) > Precision::Confusion())
{
myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d);
return aPrs3d;
}
}
}
}
myPresentableObject->Compute (Projector (theProjector), aPrs3d);
aPrs3d->SetTransformation (theTrsf);
return aPrs3d; return aPrs3d;
} }

@ -14,9 +14,10 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <StdPrs_HLRPolyShape.hxx>
#include <BRepMesh_IncrementalMesh.hxx> #include <BRepMesh_IncrementalMesh.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx> #include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <HLRAlgo_EdgeIterator.hxx> #include <HLRAlgo_EdgeIterator.hxx>
#include <HLRAlgo_EdgeStatus.hxx> #include <HLRAlgo_EdgeStatus.hxx>
@ -27,7 +28,6 @@
#include <Prs3d_LineAspect.hxx> #include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx> #include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx> #include <Prs3d_Projector.hxx>
#include <StdPrs_HLRPolyShape.hxx>
#include <StdPrs_WFShape.hxx> #include <StdPrs_WFShape.hxx>
#include <TColgp_SequenceOfPnt.hxx> #include <TColgp_SequenceOfPnt.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
@ -64,9 +64,6 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
} }
} }
TColgp_SequenceOfPnt HiddenPnts;
TColgp_SequenceOfPnt SeenPnts;
if (aDrawer->IsAutoTriangulation()) if (aDrawer->IsAutoTriangulation())
{ {
const Standard_Boolean aRel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE; const Standard_Boolean aRel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE;
@ -121,48 +118,64 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
S,reg1,regn,outl,intl)); S,reg1,regn,outl,intl));
} }
} }
// storage in the group:
HLRBRep_ListIteratorOfListOfBPoint ItB;
if (aDrawer->DrawHiddenLine()) { // storage in the group
for (ItB.Initialize(BiPntHid); ItB.More(); ItB.Next()) { if (aDrawer->DrawHiddenLine())
const HLRBRep_BiPoint& BP = ItB.Value(); {
if (!BP.RgNLine() || BP.OutLine()) { Standard_Integer aNbHiddenSegments = 0;
HiddenPnts.Append(BP.P1()); for (HLRBRep_ListIteratorOfListOfBPoint aBPntHidIter (BiPntHid); aBPntHidIter.More(); aBPntHidIter.Next())
HiddenPnts.Append(BP.P2()); {
const HLRBRep_BiPoint& aBPnt = aBPntHidIter.Value();
if (!aBPnt.RgNLine()
|| aBPnt.OutLine())
{
++aNbHiddenSegments;
} }
} }
} if (aNbHiddenSegments > 0)
{
Handle(Graphic3d_ArrayOfSegments) aHiddenArray = new Graphic3d_ArrayOfSegments (aNbHiddenSegments * 2);
for (HLRBRep_ListIteratorOfListOfBPoint aBPntHidIter (BiPntHid); aBPntHidIter.More(); aBPntHidIter.Next())
{
const HLRBRep_BiPoint& aBPnt = aBPntHidIter.Value();
if (!aBPnt.RgNLine()
|| aBPnt.OutLine())
{
aHiddenArray->AddVertex (aBPnt.P1());
aHiddenArray->AddVertex (aBPnt.P2());
}
}
for (ItB.Initialize(BiPntVis); ItB.More(); ItB.Next()) { aGroup->SetPrimitivesAspect (aDrawer->HiddenLineAspect()->Aspect());
const HLRBRep_BiPoint& BP = ItB.Value(); aGroup->AddPrimitiveArray (aHiddenArray);
if (!BP.RgNLine() || BP.OutLine()) {
SeenPnts.Append(BP.P1());
SeenPnts.Append(BP.P2());
} }
} }
{
Standard_Integer nbVertices = HiddenPnts.Length(); Standard_Integer aNbSeenSegments = 0;
if(nbVertices > 0) { for (HLRBRep_ListIteratorOfListOfBPoint aBPntVisIter (BiPntVis); aBPntVisIter.More(); aBPntVisIter.Next())
Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); {
for(int i=1; i<=nbVertices; i+=2) { const HLRBRep_BiPoint& aBPnt = aBPntVisIter.Value();
HiddenArray->AddBound(2); if (!aBPnt.RgNLine()
HiddenArray->AddVertex(HiddenPnts.Value(i)); || aBPnt.OutLine())
HiddenArray->AddVertex(HiddenPnts.Value(i+1)); {
++aNbSeenSegments;
}
} }
aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); if (aNbSeenSegments > 0)
aGroup->AddPrimitiveArray(HiddenArray); {
} Handle(Graphic3d_ArrayOfSegments) aSeenArray = new Graphic3d_ArrayOfSegments (aNbSeenSegments * 2);
nbVertices = SeenPnts.Length(); for (HLRBRep_ListIteratorOfListOfBPoint aBPntVisIter (BiPntVis); aBPntVisIter.More(); aBPntVisIter.Next())
if(nbVertices > 0) { {
Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); const HLRBRep_BiPoint& aBPnt = aBPntVisIter.Value();
for(int i=1; i<=nbVertices; i+=2) { if (!aBPnt.RgNLine()
SeenArray->AddBound(2); || aBPnt.OutLine())
SeenArray->AddVertex(SeenPnts.Value(i)); {
SeenArray->AddVertex(SeenPnts.Value(i+1)); aSeenArray->AddVertex (aBPnt.P1());
aSeenArray->AddVertex (aBPnt.P2());
}
}
aGroup->SetPrimitivesAspect (aDrawer->SeenLineAspect()->Aspect());
aGroup->AddPrimitiveArray (aSeenArray);
} }
aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect());
aGroup->AddPrimitiveArray(SeenArray);
} }
} }

@ -2710,13 +2710,11 @@ void V3d_View::SetComputedMode (const Standard_Boolean theMode)
if (myComputedMode) if (myComputedMode)
{ {
myView->SetComputedMode (Standard_True); myView->SetComputedMode (Standard_True);
Update();
} }
} }
else else
{ {
myView->SetComputedMode (Standard_False); myView->SetComputedMode (Standard_False);
Update();
} }
} }

@ -163,8 +163,6 @@ Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow)
} }
#endif #endif
static Standard_Boolean MyHLRIsOn = Standard_False;
NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews; NCollection_DoubleMap <TCollection_AsciiString, Handle(V3d_View)> ViewerTest_myViews;
static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts; static NCollection_DoubleMap <TCollection_AsciiString, Handle(AIS_InteractiveContext)> ViewerTest_myContexts;
static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers; static NCollection_DoubleMap <TCollection_AsciiString, Handle(Graphic3d_GraphicDriver)> ViewerTest_myDrivers;
@ -185,6 +183,7 @@ static struct
//============================================================================== //==============================================================================
static int Start_Rot = 0; static int Start_Rot = 0;
Standard_Boolean HasHlrOnBeforeRotation = Standard_False;
int X_Motion = 0; // Current cursor position int X_Motion = 0; // Current cursor position
int Y_Motion = 0; int Y_Motion = 0;
int X_ButtonPress = 0; // Last ButtonPress position int X_ButtonPress = 0; // Last ButtonPress position
@ -717,7 +716,6 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft
// Set parameters for V3d_View and V3d_Viewer // Set parameters for V3d_View and V3d_Viewer
const Handle (V3d_View) aV3dView = ViewerTest::CurrentView(); const Handle (V3d_View) aV3dView = ViewerTest::CurrentView();
aV3dView->SetComputedMode(Standard_False); aV3dView->SetComputedMode(Standard_False);
MyHLRIsOn = aV3dView->ComputedMode();
a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
if (toCreateViewer) if (toCreateViewer)
@ -850,76 +848,142 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha
return 0; return 0;
} }
//! Parse HLR algo type.
static Standard_Boolean parseHlrAlgoType (const char* theName,
Prs3d_TypeOfHLR& theType)
{
TCollection_AsciiString aName (theName);
aName.LowerCase();
if (aName == "polyalgo")
{
theType = Prs3d_TOH_PolyAlgo;
}
else if (aName == "algo")
{
theType = Prs3d_TOH_Algo;
}
else
{
return Standard_False;
}
return Standard_True;
}
//============================================================================== //==============================================================================
//function : VHLR //function : VHLR
//purpose : hidden lines removal algorithm //purpose : hidden lines removal algorithm
//draw args: vhlr is_enabled={on|off} [show_hidden={1|0}]
//============================================================================== //==============================================================================
static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{ {
if (ViewerTest::CurrentView().IsNull()) const Handle(V3d_View) aView = ViewerTest::CurrentView();
const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (aView.IsNull())
{ {
di << argv[0] << ": Call vinit before this command, please.\n"; std::cerr << "Error: No opened viewer!\n";
return 1; return 1;
} }
if (argc < 2) Standard_Boolean hasHlrOnArg = Standard_False;
Standard_Boolean hasShowHiddenArg = Standard_False;
Standard_Boolean isHLROn = Standard_False;
Standard_Boolean toShowHidden = aCtx->DefaultDrawer()->DrawHiddenLine();
Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet;
ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
{ {
di << argv[0] << ": Wrong number of command arguments.\n" TCollection_AsciiString anArg (argv[anArgIter]);
<< "Type help " << argv[0] << " for more information.\n"; anArg.LowerCase();
return 1; if (anUpdateTool.parseRedrawMode (anArg))
}
// Enable or disable HLR mode.
Standard_Boolean isHLROn =
(!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False;
if (isHLROn != MyHLRIsOn)
{
MyHLRIsOn = isHLROn;
ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn);
}
// Show or hide hidden lines in HLR mode.
Standard_Boolean isCurrentShowHidden
= ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine();
Standard_Boolean isShowHidden =
(argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False)
: isCurrentShowHidden;
if (isShowHidden != isCurrentShowHidden)
{
if (isShowHidden)
{ {
ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine(); continue;
}
else if (anArg == "-showhidden"
&& anArgIter + 1 < argc
&& ViewerTest::ParseOnOff (argv[anArgIter + 1], toShowHidden))
{
++anArgIter;
hasShowHiddenArg = Standard_True;
continue;
}
else if ((anArg == "-type"
|| anArg == "-algo"
|| anArg == "-algotype")
&& anArgIter + 1 < argc
&& parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR))
{
++anArgIter;
continue;
}
else if (!hasHlrOnArg
&& ViewerTest::ParseOnOff (argv[anArgIter], isHLROn))
{
hasHlrOnArg = Standard_True;
continue;
}
// old syntax
else if (!hasShowHiddenArg
&& ViewerTest::ParseOnOff(argv[anArgIter], toShowHidden))
{
hasShowHiddenArg = Standard_True;
continue;
} }
else else
{ {
ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine(); std::cout << "Syntax error at '" << argv[anArgIter] << "'\n";
return 1;
} }
}
// Redisplay shapes. if (!hasHlrOnArg)
if (MyHLRIsOn) {
di << "HLR: " << aView->ComputedMode() << "\n";
di << "HiddenLine: " << aCtx->DefaultDrawer()->DrawHiddenLine() << "\n";
di << "HlrAlgo: ";
switch (aCtx->DefaultDrawer()->TypeOfHLR())
{ {
AIS_ListOfInteractive aListOfShapes; case Prs3d_TOH_NotSet: di << "NotSet\n"; break;
ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); case Prs3d_TOH_PolyAlgo: di << "PolyAlgo\n"; break;
case Prs3d_TOH_Algo: di << "Algo\n"; break;
}
anUpdateTool.Invalidate();
return 0;
}
for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) Standard_Boolean toRecompute = Standard_False;
if (aTypeOfHLR != Prs3d_TOH_NotSet
&& aTypeOfHLR != aCtx->DefaultDrawer()->TypeOfHLR())
{
toRecompute = Standard_True;
aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR);
}
if (toShowHidden != aCtx->DefaultDrawer()->DrawHiddenLine())
{
toRecompute = Standard_True;
if (toShowHidden)
{
aCtx->DefaultDrawer()->EnableDrawHiddenLine();
}
else
{
aCtx->DefaultDrawer()->DisableDrawHiddenLine();
}
}
// redisplay shapes
if (aView->ComputedMode() && isHLROn && toRecompute)
{
AIS_ListOfInteractive aListOfShapes;
aCtx->DisplayedObjects (aListOfShapes);
for (AIS_ListIteratorOfListOfInteractive anIter (aListOfShapes); anIter.More(); anIter.Next())
{
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()))
{ {
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value()); aCtx->Redisplay (aShape, Standard_False);
if (aShape.IsNull())
{
continue;
}
ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
} }
} }
} }
ViewerTest::CurrentView()->Update(); aView->SetComputedMode (isHLROn);
return 0; return 0;
} }
@ -928,66 +992,95 @@ static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
//purpose : change type of using HLR algorithm //purpose : change type of using HLR algorithm
//============================================================================== //==============================================================================
static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv) static int VHLRType (Draw_Interpretor& , Standard_Integer argc, const char** argv)
{ {
if (ViewerTest::CurrentView().IsNull()) const Handle(V3d_View) aView = ViewerTest::CurrentView();
const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
if (aView.IsNull())
{ {
di << argv[0] << ": Call vinit before this command, please.\n"; std::cerr << "Error: No opened viewer!\n";
return 1; return 1;
} }
if (argc < 2) Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet;
ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView);
AIS_ListOfInteractive aListOfShapes;
for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
{ {
di << argv[0] << ": Wrong number of command arguments.\n" TCollection_AsciiString anArg (argv[anArgIter]);
<< "Type help " << argv[0] << " for more information.\n"; anArg.LowerCase();
return 1; if (anUpdateTool.parseRedrawMode (anArg))
}
Prs3d_TypeOfHLR aTypeOfHLR =
(!strcasecmp (argv[1], "algo")) ? Prs3d_TOH_Algo : Prs3d_TOH_PolyAlgo;
if (argc == 2)
{
AIS_ListOfInteractive aListOfShapes;
ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes);
ViewerTest::GetAISContext()->DefaultDrawer()->SetTypeOfHLR(aTypeOfHLR);
for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
anIter.More(); anIter.Next())
{ {
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); continue;
if (aShape.IsNull())
continue;
if (aShape->TypeOfHLR() != aTypeOfHLR)
aShape->SetTypeOfHLR (aTypeOfHLR);
if (MyHLRIsOn)
ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False);
} }
ViewerTest::CurrentView()->Update(); else if ((anArg == "-type"
return 0; || anArg == "-algo"
} || anArg == "-algotype")
else && anArgIter + 1 < argc
{ && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR))
for (Standard_Integer i = 2; i < argc; ++i) {
++anArgIter;
continue;
}
// old syntax
else if (aTypeOfHLR == Prs3d_TOH_NotSet
&& parseHlrAlgoType (argv[anArgIter], aTypeOfHLR))
{
continue;
}
else
{ {
ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
TCollection_AsciiString aName (argv[i]); TCollection_AsciiString aName (argv[anArgIter]);
if (!aMap.IsBound2 (aName)) if (!aMap.IsBound2 (aName))
{ {
di << argv[0] << ": Wrong shape name:" << aName.ToCString() << ".\n"; std::cout << "Syntax error: Wrong shape name '" << aName << "'.\n";
continue; return 1;
} }
Handle(AIS_Shape) anAISObject =
Handle(AIS_Shape)::DownCast (aMap.Find2(aName)); Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (aMap.Find2 (aName));
if (anAISObject.IsNull()) if (aShape.IsNull())
continue; {
anAISObject->SetTypeOfHLR (aTypeOfHLR); std::cout << "Syntax error: '" << aName << "' is not a shape presentation.\n";
if (MyHLRIsOn) return 1;
ViewerTest::GetAISContext()->Redisplay (anAISObject, Standard_False); }
aListOfShapes.Append (aShape);
continue;
} }
ViewerTest::CurrentView()->Update(); }
if (aTypeOfHLR == Prs3d_TOH_NotSet)
{
std::cout << "Syntax error: wrong number of arguments!\n";
return 1;
} }
const Standard_Boolean isGlobal = aListOfShapes.IsEmpty();
if (isGlobal)
{
aCtx->DisplayedObjects (aListOfShapes);
aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR);
}
for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next())
{
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
if (aShape.IsNull())
{
continue;
}
const bool toUpdateShape = aShape->TypeOfHLR() != aTypeOfHLR
&& aView->ComputedMode();
if (!isGlobal
|| aShape->TypeOfHLR() != aTypeOfHLR)
{
aShape->SetTypeOfHLR (aTypeOfHLR);
}
if (toUpdateShape)
{
aCtx->Redisplay (aShape, Standard_False);
}
}
return 0; return 0;
} }
@ -1030,13 +1123,10 @@ void ActivateView (const TCollection_AsciiString& theViewName)
} }
ViewerTest::CurrentView (aView); ViewerTest::CurrentView (aView);
// Update degenerate mode
MyHLRIsOn = ViewerTest::CurrentView()->ComputedMode();
ViewerTest::SetAISContext (anAISContext); ViewerTest::SetAISContext (anAISContext);
TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - "); TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - ") + theViewName + "(*)";
aTitle = aTitle + theViewName + "(*)";
SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString());
#if defined(_WIN32) || defined(__WIN32__) #if defined(_WIN32)
VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window()); VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window());
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window()); VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window());
@ -1390,9 +1480,9 @@ void VT_ProcessKeyPress (const char* buf_ret)
else if (!strcasecmp (buf_ret, "H")) else if (!strcasecmp (buf_ret, "H"))
{ {
// HLR // HLR
cout << "HLR" << endl; std::cout << "HLR" << std::endl;
aView->SetComputedMode (!aView->ComputedMode()); aView->SetComputedMode (!aView->ComputedMode());
MyHLRIsOn = aView->ComputedMode(); aView->Redraw();
} }
else if (!strcasecmp (buf_ret, "P")) else if (!strcasecmp (buf_ret, "P"))
{ {
@ -1638,7 +1728,8 @@ void VT_ProcessButton1Release (Standard_Boolean theIsShift)
void VT_ProcessButton3Press() void VT_ProcessButton3Press()
{ {
Start_Rot = 1; Start_Rot = 1;
if (MyHLRIsOn) HasHlrOnBeforeRotation = ViewerTest::CurrentView()->ComputedMode();
if (HasHlrOnBeforeRotation)
{ {
ViewerTest::CurrentView()->SetComputedMode (Standard_False); ViewerTest::CurrentView()->SetComputedMode (Standard_False);
} }
@ -1654,9 +1745,11 @@ void VT_ProcessButton3Release()
if (Start_Rot) if (Start_Rot)
{ {
Start_Rot = 0; Start_Rot = 0;
if (MyHLRIsOn) if (HasHlrOnBeforeRotation)
{ {
HasHlrOnBeforeRotation = Standard_False;
ViewerTest::CurrentView()->SetComputedMode (Standard_True); ViewerTest::CurrentView()->SetComputedMode (Standard_True);
ViewerTest::CurrentView()->Redraw();
} }
} }
} }
@ -11152,19 +11245,18 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
" ts, tt - translation for s and t texture coordinates\n" " ts, tt - translation for s and t texture coordinates\n"
" rot - texture rotation angle in degrees", " rot - texture rotation angle in degrees",
__FILE__, VTextureEnv, group); __FILE__, VTextureEnv, group);
theCommands.Add("vhlr" , theCommands.Add("vhlr",
"is_enabled={on|off} [show_hidden={1|0}]" "vhlr {on|off} [-showHidden={1|0}] [-algoType={algo|polyAlgo}] [-noupdate]"
" - Hidden line removal algorithm:" "\n\t\t: Hidden Line Removal algorithm."
" - is_enabled: if is on HLR algorithm is applied\n" "\n\t\t: -showHidden if set ON, hidden lines are drawn as dotted ones"
" - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n", "\n\t\t: -algoType type of HLR algorithm.\n",
__FILE__,VHLR,group); __FILE__,VHLR,group);
theCommands.Add("vhlrtype" , theCommands.Add("vhlrtype",
"algo_type={algo|polyalgo} [shape_1 ... shape_n]" "vhlrtype {algo|polyAlgo} [shape_1 ... shape_n] [-noupdate]"
" - Changes the type of HLR algorithm using for shapes." "\n\t\t: Changes the type of HLR algorithm using for shapes:"
" - algo_type: if equals to algo, exact HLR algorithm is applied;\n" "\n\t\t: 'algo' - exact HLR algorithm is applied"
" if equals to polyalgo, polygonal HLR algorithm is applied." "\n\t\t: 'polyAlgo' - polygonal HLR algorithm is applied"
"If shapes are not given HLR algoithm of given type is applied" "\n\t\t: If shapes are not given - option is applied to all shapes in the view",
" to all shapes in the view\n",
__FILE__,VHLRType,group); __FILE__,VHLRType,group);
theCommands.Add("vclipplane", theCommands.Add("vclipplane",
"vclipplane planeName [{0|1}]" "vclipplane planeName [{0|1}]"

@ -13,7 +13,7 @@ vdisplay b
vrotate 35 0 0 vrotate 35 0 0
vfit vfit
vhlr on 1 vhlr on 1
vhlrtype algo a vhlrtype algo b
vmoveto 76 304 vmoveto 76 304