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

0023709: Redesign of hlrtest command: vhlr and vhlrtype commands were added; hlr type changing was added to AIS_Shape, AIS_Drawer and Prs3d_Drawer

QuickHLR and ExactHLR items removed from AIS_DisplayMode enumeration as unused.
Minor coding style and CDL documentation corrections applied.
Compiler error in AIS_Shape::SetTypeOfHLR() corrected
Corrections in HLR algorithm.
Compiler error in AIS_Shape::TypeOfHLR() corrected
Added test cases bugs vis bug23709_1/bug23709_2/bug23709_3/bug23709_4
This commit is contained in:
aba
2013-04-15 18:06:26 +04:00
parent d9e8bb0884
commit 0a768f5684
23 changed files with 554 additions and 215 deletions

View File

@@ -3351,129 +3351,6 @@ static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a
Ctx->Display(ais);
return 0;
}
//============================================================================
#include <HLRAlgo_Projector.hxx>
#include <Prs3d_Projector.hxx>
#include <gp.hxx>
Standard_Integer hlrtest(Draw_Interpretor&, Standard_Integer n, const char** a)
{
/*Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext();
/////////////////////
TopoDS_Shape aShape = DBRep::Get(a[1]);
aContext2D->EraseAll(Standard_True);
//Standard_Integer aPolyAlgo = 0;
Standard_Boolean IsPoly = Standard_False;
gp_Ax2 anAx2 = gp::XOY();
//if(n > 2) aPolyAlgo = Draw::Atoi(a[2]);
//IsPoly = aPolyAlgo > 0;
TopoDS_Shape aResult = aShape;
if (n == 11)
{
Standard_Real x = Draw::Atof(a[2]);
Standard_Real y = Draw::Atof(a[3]);
Standard_Real z = Draw::Atof(a[4]);
Standard_Real dx = Draw::Atof(a[5]);
Standard_Real dy = Draw::Atof(a[6]);
Standard_Real dz = Draw::Atof(a[7]);
Standard_Real dx1 = Draw::Atof(a[8]);
Standard_Real dy1 = Draw::Atof(a[9]);
Standard_Real dz1 = Draw::Atof(a[10]);
gp_Pnt anOrigin (x, y, z);
gp_Dir aNormal (dx, dy, dz);
gp_Dir aDX (dx1, dy1, dz1);
anAx2 = gp_Ax2(anOrigin, aNormal, aDX);
}
HLRAlgo_Projector aProjector(anAx2);
//Prs3d_Projector aProjector_t(Standard_False,1, 0,0,1,0,0,1000,0,1,0);
//aProjector = aProjector_t.Projector();
Handle(AIS2D_ProjShape) myDisplayableShape =
new AIS2D_ProjShape(aProjector,0,IsPoly, Standard_False);
myDisplayableShape->ShowEdges(Standard_True, Standard_False,
Standard_False, Standard_True, Standard_False);
myDisplayableShape->Add( aResult );
aContext2D->Display( myDisplayableShape,Standard_True );
aContext2D->UpdateCurrentViewer();*/
return 0;
}
Standard_Integer phlrtest(Draw_Interpretor&, Standard_Integer n, const char** a)
{
/*Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext();
/////////////////////
TopoDS_Shape aShape = DBRep::Get(a[1]);
aContext2D->EraseAll(Standard_True);
//Standard_Integer aPolyAlgo = 0;
Standard_Boolean IsPoly = Standard_True;
gp_Ax2 anAx2 = gp::XOY();
//if(n > 2) aPolyAlgo = Draw::Atoi(a[2]);
//IsPoly = aPolyAlgo > 0;
TopoDS_Shape aResult = aShape;
if (n == 11)
{
Standard_Real x = Draw::Atof(a[2]);
Standard_Real y = Draw::Atof(a[3]);
Standard_Real z = Draw::Atof(a[4]);
Standard_Real dx = Draw::Atof(a[5]);
Standard_Real dy = Draw::Atof(a[6]);
Standard_Real dz = Draw::Atof(a[7]);
Standard_Real dx1 = Draw::Atof(a[8]);
Standard_Real dy1 = Draw::Atof(a[9]);
Standard_Real dz1 = Draw::Atof(a[10]);
gp_Pnt anOrigin (x, y, z);
gp_Dir aNormal (dx, dy, dz);
gp_Dir aDX (dx1, dy1, dz1);
anAx2 = gp_Ax2(anOrigin, aNormal, aDX);
}
HLRAlgo_Projector aProjector(anAx2);
//Prs3d_Projector aProjector_t(Standard_False,1, 0,0,1,0,0,1000,0,1,0);
//aProjector = aProjector_t.Projector();
Handle(AIS2D_ProjShape) myDisplayableShape =
new AIS2D_ProjShape(aProjector,0,IsPoly, Standard_False);
myDisplayableShape->ShowEdges(Standard_True, Standard_False,
Standard_False, Standard_True, Standard_False);
myDisplayableShape->Add( aResult );
aContext2D->Display( myDisplayableShape,Standard_True );
aContext2D->UpdateCurrentViewer();*/
return 0;
}
//==============================================================================
//function : ViewerTest::Commands
@@ -3678,9 +3555,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
theCommands.Add("vr", "vr : reading of the shape",
__FILE__,vr, group);
theCommands.Add("hlrtest" , "Usage: hlrtest s1 s2 ...", __FILE__, hlrtest, group);
theCommands.Add("phlrtest" , "Usage: hlrtest s1 s2 ...", __FILE__, phlrtest, group);
}
//=====================================================================

View File

@@ -29,6 +29,12 @@
#include <windows.h>
#endif
#include <AIS_Shape.hxx>
#include <AIS_Drawer.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <DBRep.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_ExportFormat.hxx>
@@ -320,6 +326,108 @@ static int VInit (Draw_Interpretor& , Standard_Integer argc, const char** argv)
return 0;
}
//==============================================================================
//function : VHLR
//purpose : hidden lines removal algorithm
//==============================================================================
static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (ViewerTest::CurrentView().IsNull())
{
di << argv[0] << ": Call vinit before this command, please.\n";
return 1;
}
if (argc != 2)
{
di << argv[0] << ": Wrong number of command arguments.\n"
<< "Type help " << argv[0] << " for more information.\n";
return 1;
}
Standard_Boolean isHLROn =
(!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False;
if (isHLROn == MyHLRIsOn)
{
return 0;
}
MyHLRIsOn = isHLROn;
ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn);
return 0;
}
//==============================================================================
//function : VHLRType
//purpose : change type of using HLR algorithm
//==============================================================================
static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (ViewerTest::CurrentView().IsNull())
{
di << argv[0] << ": Call vinit before this command, please.\n";
return 1;
}
if (argc < 2)
{
di << argv[0] << ": Wrong number of command arguments.\n"
<< "Type help " << argv[0] << " for more information.\n";
return 1;
}
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());
if (aShape.IsNull())
continue;
if (aShape->TypeOfHLR() != aTypeOfHLR)
aShape->SetTypeOfHLR (aTypeOfHLR);
if (MyHLRIsOn)
aShape->Redisplay();
}
ViewerTest::CurrentView()->Update();
return 0;
}
else
{
for (Standard_Integer i = 2; i < argc; ++i)
{
ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
TCollection_AsciiString aName (argv[i]);
if (!aMap.IsBound2 (aName))
{
di << argv[0] << ":" << " Wrong shape name:" << aName.ToCString() << ".\n";
continue;
}
Handle(AIS_Shape) anAISObject =
Handle(AIS_Shape)::DownCast (aMap.Find2(aName));
if (anAISObject.IsNull())
continue;
anAISObject->SetTypeOfHLR (aTypeOfHLR);
if (MyHLRIsOn)
anAISObject->Redisplay();
}
ViewerTest::CurrentView()->Update();
}
return 0;
}
//==============================================================================
//function : VT_ProcessKeyPress
//purpose : Handle KeyPress event from a CString
@@ -352,6 +460,48 @@ void VT_ProcessKeyPress (const char* buf_ret)
aView->SetComputedMode (!aView->ComputedMode());
MyHLRIsOn = aView->ComputedMode();
}
else if ( !strcasecmp(buf_ret, "P") ) {
// Type of HLR
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
if (aContext->DefaultDrawer()->TypeOfHLR() == Prs3d_TOH_Algo)
aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_PolyAlgo);
else
aContext->DefaultDrawer()->SetTypeOfHLR(Prs3d_TOH_Algo);
if (aContext->NbCurrents()==0 || aContext->NbSelected() == 0)
{
AIS_ListOfInteractive aListOfShapes;
aContext->DisplayedObjects(aListOfShapes);
for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes);
anIter.More(); anIter.Next())
{
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value());
if (aShape.IsNull())
continue;
if (aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
else
aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
aShape->Redisplay();
}
}
else
{
for (aContext->InitCurrent();aContext->MoreCurrent();aContext->NextCurrent())
{
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(aContext->Current());
if (aShape.IsNull())
continue;
if(aShape->TypeOfHLR() == Prs3d_TOH_PolyAlgo)
aShape->SetTypeOfHLR (Prs3d_TOH_Algo);
else
aShape->SetTypeOfHLR (Prs3d_TOH_PolyAlgo);
aShape->Redisplay();
}
}
aContext->UpdateCurrentViewer();
}
else if ( !strcasecmp(buf_ret, "S") ) {
// SHADING
cout << "passage en mode 1 (shading pour les shapes)" << endl;
@@ -3935,4 +4085,17 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
" ts, tt - translation for s and t texture coordinates\n"
" rot - texture rotation angle in degrees",
__FILE__, VTextureEnv, group);
theCommands.Add("vhlr" ,
"is_enabled={on|off}"
" - Hidden line removal algorithm:"
" - is_enabled: if is on HLR algorithm is applied\n",
__FILE__,VHLR,group);
theCommands.Add("vhlrtype" ,
"algo_type={algo|polyalgo} [shape_1 ... shape_n]"
" - Changes the type of HLR algorithm using for shapes."
" - algo_type: if equals to algo, exact HLR algorithm is applied;\n"
" if equals to polyalgo, polygonal HLR algorithm is applied."
"If shapes are not given HLR algoithm of given type is applied"
" to all shapes in the view\n",
__FILE__,VHLRType,group);
}