1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +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

@ -157,7 +157,7 @@ uses
is
enumeration DisplayMode is WireFrame, Shaded, QuickHLR, ExactHLR;
enumeration DisplayMode is WireFrame, Shaded;
---Purpose:
-- Sets display modes other than neutral point ones,
-- for interactive objects. The possibilities include:

View File

@ -65,7 +65,8 @@ uses
TypeOfDeflection from Aspect,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity
Length from Quantity,
TypeOfHLR from Prs3d
is
Create returns mutable Drawer from AIS;
@ -124,7 +125,16 @@ is
-- sets myOwnHLRDeviationAngle and myPreviousHLRDeviationAngle
is redefined static;
SetTypeOfHLR(me: mutable; theTypeOfHLR: TypeOfHLR from Prs3d)
is redefined;
---Purpose: Sets the type of HLR algorithm
-- used by drawer's interactive objects
---C++: inline
TypeOfHLR(me) returns TypeOfHLR from Prs3d
is redefined;
---Purpose: Returns the type of HLR algorithm currently in use.
---C++: inline
DeviationCoefficient(me) returns Real from Standard
---Purpose: Drawings of curves or patches are made with respect
@ -627,7 +637,6 @@ fields
myhasOwnHLRDeviationAngle : Boolean from Standard;
myOwnHLRDeviationAngle : Real from Standard;
myPreviousHLRDeviationAngle : Real from Standard;
myHasOwnFaceBoundaryDraw : Boolean from Standard;
end Drawer;

View File

@ -31,6 +31,7 @@ myHasOwnFaceBoundaryDraw (Standard_False)
{
SetMaximalParameterValue(500000.);
myLink->SetMaximalParameterValue(500000.);
SetTypeOfHLR (Prs3d_TOH_NotSet);
}
@ -104,7 +105,6 @@ void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
myhasOwnHLRDeviationAngle = Standard_True;
}
/////// Get
//=======================================================================
//function : DeviationCoefficient

View File

@ -99,3 +99,13 @@ inline Standard_Boolean AIS_Drawer::IsOwnFaceBoundaryDraw () const
inline Standard_Boolean AIS_Drawer::IsOwnFaceBoundaryAspect () const
{ return !myFaceBoundaryAspect.IsNull (); }
inline void AIS_Drawer::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
{
myTypeOfHLR = theTypeOfHLR;
}
inline Prs3d_TypeOfHLR AIS_Drawer::TypeOfHLR ( ) const
{
return (myTypeOfHLR == Prs3d_TOH_NotSet) ? myLink->TypeOfHLR() : myTypeOfHLR;
}

View File

@ -300,8 +300,6 @@ is
-- The range of possibilities currently proposed is the following:
-- - AIS_WireFrame
-- - AIS_Shaded
-- - AIS_QuickHLR
-- - AIS_ExactHLR
-- This range can, however, be extended through the creation of new display modes.
UnsetDisplayMode(me : mutable);
@ -315,8 +313,6 @@ is
-- The range of possibilities is the following:
-- - AIS_WireFrame
-- - AIS_Shaded
-- - AIS_QuickHLR
-- - AIS_ExactHLR
-- This range can, however, be extended through the
-- creation of new display modes.

View File

@ -67,7 +67,8 @@ uses
Selection from SelectMgr,
KindOfInteractive from AIS,
Transformation from Geom,
Drawer from Prs3d
Drawer from Prs3d,
TypeOfHLR from Prs3d
is
Create(shap: Shape from TopoDS)
@ -161,7 +162,13 @@ uses
-- already set, false is returned.
SetTypeOfHLR(me: mutable; theTypeOfHLR: TypeOfHLR from Prs3d);
---Purpose: Sets the type of HLR algorithm used by the shape
---C++: inline
TypeOfHLR(me) returns TypeOfHLR from Prs3d;
---Purpose: Gets the type of HLR algorithm
---C++: inline
---Category: Redefine Compute Methods...

View File

@ -340,7 +340,15 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
{
try {
OCC_CATCH_SIGNALS
StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
switch (TypeOfHLR()) {
case Prs3d_TOH_Algo:
StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
break;
case Prs3d_TOH_PolyAlgo:
default:
StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
break;
}
}
catch (Standard_Failure) {
#ifdef DEB

View File

@ -18,7 +18,7 @@
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <AIS_Drawer.hxx>
inline void AIS_Shape::Set(const TopoDS_Shape& ashap)
{
@ -32,3 +32,12 @@ AIS_Shape::Shape() const
return myshape;
}
inline void AIS_Shape::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
{
myDrawer->SetTypeOfHLR (theTypeOfHLR);
}
inline Prs3d_TypeOfHLR AIS_Shape::TypeOfHLR ( ) const
{
return myDrawer->TypeOfHLR();
}

View File

@ -23,9 +23,16 @@
#include <BRepLib_MakeEdge2d.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <BRep_Builder.hxx>
//=======================================================================
//function : MakeEdge
@ -81,28 +88,57 @@ TopoDS_Edge HLRBRep::MakeEdge (const HLRBRep_Curve& ec,
}
case GeomAbs_BSplineCurve: {
Handle(Geom2d_BSplineCurve) ec2d;
GeomAdaptor_Curve GAcurve = ec.GetCurve().Curve();
TopoDS_Edge anEdge = ec.GetCurve().Edge();
Standard_Real fpar, lpar;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar);
const Handle(Geom_BSplineCurve)& BSplCurve = Handle(Geom_BSplineCurve)::DownCast(aCurve);
Handle(Geom_BSplineCurve) theCurve = Handle(Geom_BSplineCurve)::DownCast(BSplCurve->Copy());
if (theCurve->IsPeriodic() && !GAcurve.IsClosed())
{
theCurve->Segment(sta, end);
TColgp_Array1OfPnt2d Poles(1, theCurve->NbPoles());
TColStd_Array1OfReal knots(1, theCurve->NbKnots());
TColStd_Array1OfInteger mults(1, theCurve->NbKnots());
//-- ec.KnotsAndMultiplicities(knots,mults);
theCurve->Knots(knots);
theCurve->Multiplicities(mults);
if (theCurve->IsRational()) {
TColStd_Array1OfReal Weights(1, theCurve->NbPoles());
ec.PolesAndWeights(theCurve, Poles, Weights);
ec2d = new Geom2d_BSplineCurve(Poles, Weights, knots, mults,
theCurve->Degree(), theCurve->IsPeriodic());
}
else {
ec.Poles(theCurve, Poles);
ec2d = new Geom2d_BSplineCurve(Poles, knots, mults,
theCurve->Degree(), theCurve->IsPeriodic());
}
}
else
{
TColgp_Array1OfPnt2d Poles(1,ec.NbPoles());
TColStd_Array1OfReal knots(1,ec.NbKnots());
TColStd_Array1OfInteger mults(1,ec.NbKnots());
//-- ec.KnotsAndMultiplicities(knots,mults);
ec.Knots(knots);
ec.Multiplicities(mults);
Handle(Geom2d_BSplineCurve) ec2d;
if (ec.IsRational()) {
TColStd_Array1OfReal Weights(1,ec.NbPoles());
ec.PolesAndWeights(Poles,Weights);
ec2d = new Geom2d_BSplineCurve(Poles,Weights,knots,mults,ec.Degree());
ec2d = new Geom2d_BSplineCurve(Poles,Weights,knots,mults,ec.Degree(),ec.IsPeriodic());
}
else {
ec.Poles(Poles);
ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,ec.Degree());
ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,ec.Degree(),ec.IsPeriodic());
}
BRepLib_MakeEdge2d mke2d(ec2d,sta,end);
}
BRepLib_MakeEdge2d mke2d(ec2d, sta, end);
if (mke2d.IsDone())
Edg = mke2d.Edge();
break;
}
default: {
const Standard_Integer nbPnt = 15;
TColgp_Array1OfPnt2d Poles(1,nbPnt);

View File

@ -47,7 +47,8 @@ uses
Array1OfReal from TColStd,
Array1OfInteger from TColStd,
Edge from TopoDS,
Curve from BRepAdaptor
Curve from BRepAdaptor,
BSplineCurve from Geom
raises
NoSuchObject from Standard,
@ -74,6 +75,12 @@ is
---Purpose: Sets the 3D curve to be projected.
is static;
GetCurve(me) returns Curve from BRepAdaptor
---Purpose: Returns the 3D curve.
---C++: return const &
---C++: inline
is static;
Parameter2d(me; P3d : Real from Standard) returns Real from Standard
---Purpose: Returns the parameter on the 2d curve from the
-- parameter on the 3d curve.
@ -305,6 +312,13 @@ is
OutOfRange from Standard -- if TP has not length NbPoles
is static;
Poles(me; aCurve : BSplineCurve from Geom;
TP : in out Array1OfPnt2d from TColgp)
raises
NoSuchObject from Standard, -- if rational
OutOfRange from Standard -- if TP has not length NbPoles
is static;
PolesAndWeights(me; TP : in out Array1OfPnt2d from TColgp;
TW : in out Array1OfReal from TColStd)
raises
@ -312,6 +326,14 @@ is
OutOfRange from Standard -- if TW has not length NbPoles
is static;
PolesAndWeights(me; aCurve : BSplineCurve from Geom;
TP : in out Array1OfPnt2d from TColgp;
TW : in out Array1OfReal from TColStd)
raises
NoSuchObject from Standard, -- if not rational
OutOfRange from Standard -- if TW has not length NbPoles
is static;
NbKnots(me) returns Integer from Standard
raises
NoSuchObject from Standard

View File

@ -520,6 +520,26 @@ void HLRBRep_Curve::Poles (TColgp_Array1OfPnt2d& TP) const
}
}
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
void HLRBRep_Curve::Poles (const Handle(Geom_BSplineCurve)& aCurve,
TColgp_Array1OfPnt2d& TP) const
{
Standard_Integer i1 = TP.Lower();
Standard_Integer i2 = TP.Upper();
TColgp_Array1OfPnt TP3(i1,i2);
//-- HLRBRep_BCurveTool::Poles(myCurve,TP3);
aCurve->Poles(TP3);
for (Standard_Integer i = i1; i <= i2; i++) {
((HLRAlgo_Projector*) myProj)->Transform(TP3(i));
TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
}
}
//=======================================================================
//function : PolesAndWeights
//purpose :
@ -551,6 +571,30 @@ void HLRBRep_Curve::PolesAndWeights (TColgp_Array1OfPnt2d& TP,
}
}
//=======================================================================
//function : PolesAndWeights
//purpose :
//=======================================================================
void HLRBRep_Curve::PolesAndWeights (const Handle(Geom_BSplineCurve)& aCurve,
TColgp_Array1OfPnt2d& TP,
TColStd_Array1OfReal& TW) const
{
Standard_Integer i1 = TP.Lower();
Standard_Integer i2 = TP.Upper();
TColgp_Array1OfPnt TP3(i1,i2);
//-- HLRBRep_BCurveTool::PolesAndWeights(myCurve,TP3,TW);
aCurve->Poles(TP3);
aCurve->Weights(TW);
//-- (HLRBRep_BCurveTool::BSpline(myCurve))->PolesAndWeights(TP3,TW);
for (Standard_Integer i = i1; i <= i2; i++) {
((HLRAlgo_Projector*) myProj)->Transform(TP3(i));
TP(i).SetCoord(TP3(i).X(),TP3(i).Y());
}
}
//=======================================================================
//function : Knots
//purpose :

View File

@ -45,6 +45,14 @@ inline void HLRBRep_Curve::Projector(const Standard_Address Proj)
inline BRepAdaptor_Curve& HLRBRep_Curve::Curve()
{ return myCurve; }
//=======================================================================
//function : GetCurve
//purpose :
//=======================================================================
inline const BRepAdaptor_Curve& HLRBRep_Curve::GetCurve() const
{ return myCurve; }
//=======================================================================
//function : Value3D
//purpose :

View File

@ -820,7 +820,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
fd->Side(FS.IsSide(tol,myToler*10));
Standard_Boolean inverted = Standard_False;
if (fd->WithOutL() && !fd->Side()) {
inverted = OrientOutLine(face,*fd);
//inverted = OrientOutLine(face,*fd);
OrientOthEdge(face,*fd);
}
if (fd->Side()) {

View File

@ -203,7 +203,11 @@ HLRBRep_ShapeToHLR::ExploreFace(const Handle(HLRTopoBRep_OutLiner)& S,
Standard_Integer ne = 0;
for (Ex2.Init(Ex1.Current(), TopAbs_EDGE); Ex2.More(); Ex2.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(Ex2.Current());
if (!BRep_Tool::Degenerated(anEdge))
ne++;
}
fd.SetWire (nw, ne);
ne = 0;
@ -211,8 +215,10 @@ HLRBRep_ShapeToHLR::ExploreFace(const Handle(HLRTopoBRep_OutLiner)& S,
for (Ex2.Init(Ex1.Current(), TopAbs_EDGE);
Ex2.More();
Ex2.Next()) {
ne++;
const TopoDS_Edge& E = TopoDS::Edge(Ex2.Current());
if (BRep_Tool::Degenerated(E))
continue;
ne++;
Standard_Integer ie = EM.FindIndex(E);
TopAbs_Orientation orient = E.Orientation();
Standard_Boolean Int = TopDS.IsIntLFaceEdge(F,E);

View File

@ -65,6 +65,16 @@ is
TOLP_Segment
end TypeOfLinePicking;
enumeration TypeOfHLR is TOH_NotSet,
TOH_PolyAlgo,
TOH_Algo;
---Purpose: Declares types of hidden line removal algorithm.
--TOH_Algo enables using of exact HLR algorithm.
--TOH_PolyAlgo enables using of polygonal HLR algorithm.
--TOH_NotSet is used by AIS_Drawer class, it means that the drawer should return the global value.
--For more details see AIS_Drawer class, AIS_Shape::Compute() method and
--HLRAlgo package from TKHLR toolkit.
class Presentation;
---Purpose: defines the presentation object. This object can be
-- displayed, highlighted, erased, etc... The output

View File

@ -47,7 +47,8 @@ uses
TypeOfDeflection from Aspect,
NameOfColor from Quantity,
PlaneAngle from Quantity,
Length from Quantity
Length from Quantity,
TypeOfHLR from Prs3d
is
Create returns mutable Drawer from Prs3d;
@ -161,6 +162,15 @@ is
---Purpose: Returns True if the drawing of isos on planes is enabled.
is virtual;
SetTypeOfHLR(me: mutable; theTypeOfHLR: TypeOfHLR from Prs3d)
is virtual;
---Purpose: Sets the type of HLR algorithm
-- used by drawer's interactive objects
TypeOfHLR(me) returns TypeOfHLR from Prs3d
is virtual;
---Purpose: Gets the myTypeOfHLR value
--
-- Attributes for the U Isoparametric lines of patches.
@ -564,4 +574,5 @@ fields
mySectionAspect: LineAspect from Prs3d is protected;
myFaceBoundaryDraw : Boolean from Standard is protected;
myFaceBoundaryAspect : LineAspect from Prs3d is protected;
myTypeOfHLR : TypeOfHLR from Prs3d is protected;
end Drawer;

View File

@ -37,7 +37,8 @@ Prs3d_Drawer::Prs3d_Drawer(): myNbPoints(30),myIsoOnPlane(Standard_False),
myHLRAngle(20*M_PI/180),
myLineDrawArrow(Standard_False),
myDrawHiddenLine(Standard_False),
myFaceBoundaryDraw(Standard_False)
myFaceBoundaryDraw(Standard_False),
myTypeOfHLR(Prs3d_TOH_PolyAlgo)
{
}
@ -481,3 +482,23 @@ Handle_Prs3d_LineAspect Prs3d_Drawer::FaceBoundaryAspect ()
return myFaceBoundaryAspect;
}
// =======================================================================
// function : SetTypeOfHLR
// purpose : set type of HLR algorithm
// =======================================================================
void Prs3d_Drawer::SetTypeOfHLR ( const Prs3d_TypeOfHLR theTypeOfHLR)
{
myTypeOfHLR = theTypeOfHLR;
}
// =======================================================================
// function : TypeOfHLR
// purpose : gets type of HLR algorithm
// =======================================================================
Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR ( ) const
{
return myTypeOfHLR;
}

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);
}

27
tests/bugs/vis/bug23709_1 Normal file
View File

@ -0,0 +1,27 @@
puts "============"
puts "OCC23709"
puts "============"
puts ""
############################################################################
# Redesign of hlrtest command
############################################################################
pcone a 5 0 10
box b 15 0 0 10 10 10
vinit
vdisplay a
vdisplay b
vrotate 35 0 0
vfit
vhlr on
vhlrtype polyalgo b
set x_coord 290
set y_coord 170
checkcolor $x_coord $y_coord 1 1 0
set x_coord 86
set y_coord 221
checkcolor $x_coord $y_coord 0 0 0
set only_screen 1

27
tests/bugs/vis/bug23709_2 Normal file
View File

@ -0,0 +1,27 @@
puts "============"
puts "OCC23709"
puts "============"
puts ""
############################################################################
# Redesign of hlrtest command
############################################################################
pcone a 5 0 10
box b 15 0 0 10 10 10
vinit
vdisplay a
vdisplay b
vrotate 35 0 0
vfit
vhlr on
vhlrtype algo a
set x_coord 290
set y_coord 170
checkcolor $x_coord $y_coord 1 1 0
set x_coord 86
set y_coord 221
checkcolor $x_coord $y_coord 0 0 0
set only_screen 1

25
tests/bugs/vis/bug23709_3 Normal file
View File

@ -0,0 +1,25 @@
puts "==========="
puts "OCC23709"
puts "==========="
puts ""
##################################
# Redesign of hlrtest command
##################################
set x_coord 183
set y_coord 267
restore [locate_data_file bug23709_solidcone.brep] result
vinit
vdisplay result
vrotate 35 0 0
vfit
vhlr on
vhlrtype algo result
checkcolor $x_coord $y_coord 1 1 0
set only_screen 1

26
tests/bugs/vis/bug23709_4 Normal file
View File

@ -0,0 +1,26 @@
puts "==========="
puts "OCC23709"
puts "==========="
puts ""
##################################
# Redesign of hlrtest command
##################################
set x_coord 183
set y_coord 267
restore [locate_data_file bug23709_surfcone.brep] result
vinit
vdisplay result
vrotate 35 0 0
vfit
vhlr on
vhlrtype algo result
checkcolor $x_coord $y_coord 1 1 0
set only_screen 1