From 0a768f56848d12b18c41422554f35a40c72b6d02 Mon Sep 17 00:00:00 2001 From: aba Date: Mon, 15 Apr 2013 18:06:26 +0400 Subject: [PATCH] 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 --- src/AIS/AIS.cdl | 2 +- src/AIS/AIS_Drawer.cdl | 19 ++- src/AIS/AIS_Drawer.cxx | 2 +- src/AIS/AIS_Drawer.lxx | 10 ++ src/AIS/AIS_InteractiveObject.cdl | 4 - src/AIS/AIS_Shape.cdl | 11 +- src/AIS/AIS_Shape.cxx | 10 +- src/AIS/AIS_Shape.lxx | 11 +- src/HLRBRep/HLRBRep.cxx | 166 +++++++++++-------- src/HLRBRep/HLRBRep_Curve.cdl | 24 ++- src/HLRBRep/HLRBRep_Curve.cxx | 44 +++++ src/HLRBRep/HLRBRep_Curve.lxx | 8 + src/HLRBRep/HLRBRep_Data.cxx | 2 +- src/HLRBRep/HLRBRep_ShapeToHLR.cxx | 10 +- src/Prs3d/Prs3d.cdl | 10 ++ src/Prs3d/Prs3d_Drawer.cdl | 19 ++- src/Prs3d/Prs3d_Drawer.cxx | 23 ++- src/ViewerTest/ViewerTest.cxx | 126 -------------- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 163 ++++++++++++++++++ tests/bugs/vis/bug23709_1 | 27 +++ tests/bugs/vis/bug23709_2 | 27 +++ tests/bugs/vis/bug23709_3 | 25 +++ tests/bugs/vis/bug23709_4 | 26 +++ 23 files changed, 554 insertions(+), 215 deletions(-) create mode 100644 tests/bugs/vis/bug23709_1 create mode 100644 tests/bugs/vis/bug23709_2 create mode 100644 tests/bugs/vis/bug23709_3 create mode 100644 tests/bugs/vis/bug23709_4 diff --git a/src/AIS/AIS.cdl b/src/AIS/AIS.cdl index b52fe7b230..59caa1d754 100755 --- a/src/AIS/AIS.cdl +++ b/src/AIS/AIS.cdl @@ -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: diff --git a/src/AIS/AIS_Drawer.cdl b/src/AIS/AIS_Drawer.cdl index b3113854fe..c314945be5 100755 --- a/src/AIS/AIS_Drawer.cdl +++ b/src/AIS/AIS_Drawer.cdl @@ -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,8 +125,17 @@ 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 -- to a maximal chordal deviation. A Deviation coefficient @@ -626,9 +636,8 @@ fields myhasOwnHLRDeviationAngle : Boolean from Standard; myOwnHLRDeviationAngle : Real from Standard; - myPreviousHLRDeviationAngle : Real from Standard; - - myHasOwnFaceBoundaryDraw : Boolean from Standard; + myPreviousHLRDeviationAngle : Real from Standard; + myHasOwnFaceBoundaryDraw : Boolean from Standard; end Drawer; diff --git a/src/AIS/AIS_Drawer.cxx b/src/AIS/AIS_Drawer.cxx index c3d6cc227c..d810c4f19e 100755 --- a/src/AIS/AIS_Drawer.cxx +++ b/src/AIS/AIS_Drawer.cxx @@ -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 diff --git a/src/AIS/AIS_Drawer.lxx b/src/AIS/AIS_Drawer.lxx index c4608ca747..6d1cdbd251 100755 --- a/src/AIS/AIS_Drawer.lxx +++ b/src/AIS/AIS_Drawer.lxx @@ -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; +} diff --git a/src/AIS/AIS_InteractiveObject.cdl b/src/AIS/AIS_InteractiveObject.cdl index 335833c4d6..ef1bb097f1 100755 --- a/src/AIS/AIS_InteractiveObject.cdl +++ b/src/AIS/AIS_InteractiveObject.cdl @@ -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. diff --git a/src/AIS/AIS_Shape.cdl b/src/AIS/AIS_Shape.cdl index d18fbf46b5..921c48e0ea 100755 --- a/src/AIS/AIS_Shape.cdl +++ b/src/AIS/AIS_Shape.cdl @@ -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... diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 91cfc10cb2..01cf77f01a 100755 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -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 diff --git a/src/AIS/AIS_Shape.lxx b/src/AIS/AIS_Shape.lxx index 5c711d1b4a..86838828b7 100755 --- a/src/AIS/AIS_Shape.lxx +++ b/src/AIS/AIS_Shape.lxx @@ -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 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(); +} diff --git a/src/HLRBRep/HLRBRep.cxx b/src/HLRBRep/HLRBRep.cxx index 9d2e5d6eed..e84a9668e2 100755 --- a/src/HLRBRep/HLRBRep.cxx +++ b/src/HLRBRep/HLRBRep.cxx @@ -23,9 +23,16 @@ #include #include #include +#include #include #include #include +#include +#include +#include +#include +#include + //======================================================================= //function : MakeEdge @@ -42,90 +49,119 @@ TopoDS_Edge HLRBRep::MakeEdge (const HLRBRep_Curve& ec, switch (ec.GetType()) { - case GeomAbs_Line: - Edg = BRepLib_MakeEdge2d(ec.Line(),sta,end); - break; - - case GeomAbs_Circle: - Edg = BRepLib_MakeEdge2d(ec.Circle(),sta,end); - break; - - case GeomAbs_Ellipse: - Edg = BRepLib_MakeEdge2d(ec.Ellipse(),sta,end); - break; - - case GeomAbs_Hyperbola: - Edg = BRepLib_MakeEdge2d(ec.Hyperbola(),sta,end); - break; - - case GeomAbs_Parabola: - Edg = BRepLib_MakeEdge2d(ec.Parabola(),sta,end); - break; - - case GeomAbs_BezierCurve: { - TColgp_Array1OfPnt2d Poles(1,ec.NbPoles()); - Handle(Geom2d_BezierCurve) ec2d; - if (ec.IsRational()) { - TColStd_Array1OfReal Weights(1,ec.NbPoles()); - ec.PolesAndWeights(Poles,Weights); - ec2d = new Geom2d_BezierCurve(Poles,Weights); + case GeomAbs_Line: + Edg = BRepLib_MakeEdge2d(ec.Line(),sta,end); + break; + + case GeomAbs_Circle: + Edg = BRepLib_MakeEdge2d(ec.Circle(),sta,end); + break; + + case GeomAbs_Ellipse: + Edg = BRepLib_MakeEdge2d(ec.Ellipse(),sta,end); + break; + + case GeomAbs_Hyperbola: + Edg = BRepLib_MakeEdge2d(ec.Hyperbola(),sta,end); + break; + + case GeomAbs_Parabola: + Edg = BRepLib_MakeEdge2d(ec.Parabola(),sta,end); + break; + + case GeomAbs_BezierCurve: { + TColgp_Array1OfPnt2d Poles(1,ec.NbPoles()); + Handle(Geom2d_BezierCurve) ec2d; + if (ec.IsRational()) { + TColStd_Array1OfReal Weights(1,ec.NbPoles()); + ec.PolesAndWeights(Poles,Weights); + ec2d = new Geom2d_BezierCurve(Poles,Weights); + } + else { + ec.Poles(Poles); + ec2d = new Geom2d_BezierCurve(Poles); + } + BRepLib_MakeEdge2d mke2d(ec2d,sta,end); + if (mke2d.IsDone()) + Edg = mke2d.Edge(); + break; + } + + 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(Poles); - ec2d = new Geom2d_BezierCurve(Poles); + ec.Poles(theCurve, Poles); + ec2d = new Geom2d_BSplineCurve(Poles, knots, mults, + theCurve->Degree(), theCurve->IsPeriodic()); } - BRepLib_MakeEdge2d mke2d(ec2d,sta,end); - if (mke2d.IsDone()) - Edg = mke2d.Edge(); - break; } - - case GeomAbs_BSplineCurve: { + 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); - if (mke2d.IsDone()) - Edg = mke2d.Edge(); - break; } - - default: { - const Standard_Integer nbPnt = 15; - TColgp_Array1OfPnt2d Poles(1,nbPnt); - TColStd_Array1OfReal knots(1,nbPnt); - TColStd_Array1OfInteger mults(1,nbPnt); - mults.Init(1); - mults(1 ) = 2; - mults(nbPnt) = 2; - const Standard_Real step = (U2-U1)/(nbPnt-1); - Standard_Real par3d = U1; - for (Standard_Integer i = 1; i < nbPnt; i++) { - Poles(i) = ec.Value(par3d); - knots(i) = par3d; - par3d += step; - } - Poles(nbPnt) = ec.Value(U2); - knots(nbPnt) = U2; - - Handle(Geom2d_BSplineCurve) ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,1); - BRepLib_MakeEdge2d mke2d(ec2d,sta,end); - if (mke2d.IsDone()) - Edg = mke2d.Edge(); + BRepLib_MakeEdge2d mke2d(ec2d, sta, end); + if (mke2d.IsDone()) + Edg = mke2d.Edge(); + break; + } + default: { + const Standard_Integer nbPnt = 15; + TColgp_Array1OfPnt2d Poles(1,nbPnt); + TColStd_Array1OfReal knots(1,nbPnt); + TColStd_Array1OfInteger mults(1,nbPnt); + mults.Init(1); + mults(1 ) = 2; + mults(nbPnt) = 2; + const Standard_Real step = (U2-U1)/(nbPnt-1); + Standard_Real par3d = U1; + for (Standard_Integer i = 1; i < nbPnt; i++) { + Poles(i) = ec.Value(par3d); + knots(i) = par3d; + par3d += step; } + Poles(nbPnt) = ec.Value(U2); + knots(nbPnt) = U2; + + Handle(Geom2d_BSplineCurve) ec2d = new Geom2d_BSplineCurve(Poles,knots,mults,1); + BRepLib_MakeEdge2d mke2d(ec2d,sta,end); + if (mke2d.IsDone()) + Edg = mke2d.Edge(); + } } return Edg; } diff --git a/src/HLRBRep/HLRBRep_Curve.cdl b/src/HLRBRep/HLRBRep_Curve.cdl index 102fdf6cec..c216e085b6 100755 --- a/src/HLRBRep/HLRBRep_Curve.cdl +++ b/src/HLRBRep/HLRBRep_Curve.cdl @@ -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 diff --git a/src/HLRBRep/HLRBRep_Curve.cxx b/src/HLRBRep/HLRBRep_Curve.cxx index 18ee19d5d6..3cba5e81c0 100755 --- a/src/HLRBRep/HLRBRep_Curve.cxx +++ b/src/HLRBRep/HLRBRep_Curve.cxx @@ -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 : diff --git a/src/HLRBRep/HLRBRep_Curve.lxx b/src/HLRBRep/HLRBRep_Curve.lxx index 9b93d915d9..5074506376 100755 --- a/src/HLRBRep/HLRBRep_Curve.lxx +++ b/src/HLRBRep/HLRBRep_Curve.lxx @@ -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 : diff --git a/src/HLRBRep/HLRBRep_Data.cxx b/src/HLRBRep/HLRBRep_Data.cxx index 3ef3b7e740..5f4ee8ceab 100755 --- a/src/HLRBRep/HLRBRep_Data.cxx +++ b/src/HLRBRep/HLRBRep_Data.cxx @@ -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()) { diff --git a/src/HLRBRep/HLRBRep_ShapeToHLR.cxx b/src/HLRBRep/HLRBRep_ShapeToHLR.cxx index f33a22e328..53ab5c8987 100755 --- a/src/HLRBRep/HLRBRep_ShapeToHLR.cxx +++ b/src/HLRBRep/HLRBRep_ShapeToHLR.cxx @@ -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()) - ne++; + { + 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); diff --git a/src/Prs3d/Prs3d.cdl b/src/Prs3d/Prs3d.cdl index 11b62d8801..1324665a9c 100755 --- a/src/Prs3d/Prs3d.cdl +++ b/src/Prs3d/Prs3d.cdl @@ -64,6 +64,16 @@ is enumeration TypeOfLinePicking is TOLP_Point, 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 diff --git a/src/Prs3d/Prs3d_Drawer.cdl b/src/Prs3d/Prs3d_Drawer.cdl index 6699d1bc21..9220196e28 100755 --- a/src/Prs3d/Prs3d_Drawer.cdl +++ b/src/Prs3d/Prs3d_Drawer.cdl @@ -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; @@ -160,6 +161,15 @@ is IsoOnPlane(me) returns Boolean from Standard ---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 -- @@ -561,7 +571,8 @@ fields myLengthAspect: LengthAspect from Prs3d is protected; myAngleAspect: AngleAspect from Prs3d is protected; myRadiusAspect: RadiusAspect from Prs3d is protected; - mySectionAspect: LineAspect from Prs3d is protected; - myFaceBoundaryDraw : Boolean from Standard is protected; - myFaceBoundaryAspect : LineAspect from Prs3d is protected; + 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; diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 3c5a637030..ff44b2bd51 100755 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -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; +} diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index e837cd4a34..cca7e9ba3f 100755 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -3351,129 +3351,6 @@ static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a Ctx->Display(ais); return 0; } -//============================================================================ -#include -#include -#include -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); - } //===================================================================== diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index fb85961bd0..98546d846f 100755 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -29,6 +29,12 @@ #include #endif +#include +#include +#include +#include +#include +#include #include #include #include @@ -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); } diff --git a/tests/bugs/vis/bug23709_1 b/tests/bugs/vis/bug23709_1 new file mode 100644 index 0000000000..60a928ac08 --- /dev/null +++ b/tests/bugs/vis/bug23709_1 @@ -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 diff --git a/tests/bugs/vis/bug23709_2 b/tests/bugs/vis/bug23709_2 new file mode 100644 index 0000000000..507df8c832 --- /dev/null +++ b/tests/bugs/vis/bug23709_2 @@ -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 diff --git a/tests/bugs/vis/bug23709_3 b/tests/bugs/vis/bug23709_3 new file mode 100644 index 0000000000..4c5f174e5e --- /dev/null +++ b/tests/bugs/vis/bug23709_3 @@ -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 + + + diff --git a/tests/bugs/vis/bug23709_4 b/tests/bugs/vis/bug23709_4 new file mode 100644 index 0000000000..5186c2bf09 --- /dev/null +++ b/tests/bugs/vis/bug23709_4 @@ -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 + + + + -- 2.20.1