0023709: Redesign of hlrtest command: vhlr and vhlrtype commands were added; hlr...
authoraba <aba@opencascade.com>
Mon, 15 Apr 2013 14:06:26 +0000 (18:06 +0400)
committeraba <aba@opencascade.com>
Mon, 15 Apr 2013 14:06:26 +0000 (18:06 +0400)
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

23 files changed:
src/AIS/AIS.cdl
src/AIS/AIS_Drawer.cdl
src/AIS/AIS_Drawer.cxx
src/AIS/AIS_Drawer.lxx
src/AIS/AIS_InteractiveObject.cdl
src/AIS/AIS_Shape.cdl
src/AIS/AIS_Shape.cxx
src/AIS/AIS_Shape.lxx
src/HLRBRep/HLRBRep.cxx
src/HLRBRep/HLRBRep_Curve.cdl
src/HLRBRep/HLRBRep_Curve.cxx
src/HLRBRep/HLRBRep_Curve.lxx
src/HLRBRep/HLRBRep_Data.cxx
src/HLRBRep/HLRBRep_ShapeToHLR.cxx
src/Prs3d/Prs3d.cdl
src/Prs3d/Prs3d_Drawer.cdl
src/Prs3d/Prs3d_Drawer.cxx
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/vis/bug23709_1 [new file with mode: 0644]
tests/bugs/vis/bug23709_2 [new file with mode: 0644]
tests/bugs/vis/bug23709_3 [new file with mode: 0644]
tests/bugs/vis/bug23709_4 [new file with mode: 0644]

index b52fe7b..59caa1d 100755 (executable)
@@ -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:
index b311385..c314945 100755 (executable)
@@ -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;
  
 
index c3d6cc2..d810c4f 100755 (executable)
@@ -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
index c4608ca..6d1cdbd 100755 (executable)
@@ -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;
+}
index 335833c..ef1bb09 100755 (executable)
@@ -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.
 
index d18fbf4..921c48e 100755 (executable)
@@ -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...
index 91cfc10..01cf77f 100755 (executable)
@@ -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
index 5c711d1..8683882 100755 (executable)
@@ -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();
+}
index 9d2e5d6..e84a966 100755 (executable)
 #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
@@ -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;
 }
index 102fdf6..c216e08 100755 (executable)
@@ -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
index 18ee19d..3cba5e8 100755 (executable)
@@ -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  : 
index 9b93d91..5074506 100755 (executable)
@@ -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  : 
index 3ef3b7e..5f4ee8c 100755 (executable)
@@ -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()) {
index f33a22e..53ab5c8 100755 (executable)
@@ -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);
index 11b62d8..1324665 100755 (executable)
@@ -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
index 6699d1b..9220196 100755 (executable)
@@ -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;
index 3c5a637..ff44b2b 100755 (executable)
@@ -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;
+}
index e837cd4..cca7e9b 100755 (executable)
@@ -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);
-
 }
 
 //=====================================================================
index fb85961..98546d8 100755 (executable)
 #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);
 }
diff --git a/tests/bugs/vis/bug23709_1 b/tests/bugs/vis/bug23709_1
new file mode 100644 (file)
index 0000000..60a928a
--- /dev/null
@@ -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 (file)
index 0000000..507df8c
--- /dev/null
@@ -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 (file)
index 0000000..4c5f174
--- /dev/null
@@ -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 (file)
index 0000000..5186c2b
--- /dev/null
@@ -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
+
+
+
+