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
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:
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;
-- 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
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;
{
SetMaximalParameterValue(500000.);
myLink->SetMaximalParameterValue(500000.);
+ SetTypeOfHLR (Prs3d_TOH_NotSet);
}
myhasOwnHLRDeviationAngle = Standard_True;
}
-
/////// Get
//=======================================================================
//function : DeviationCoefficient
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;
+}
-- 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);
-- 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.
Selection from SelectMgr,
KindOfInteractive from AIS,
Transformation from Geom,
- Drawer from Prs3d
+ Drawer from Prs3d,
+ TypeOfHLR from Prs3d
is
Create(shap: Shape from TopoDS)
-- 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...
{
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
// 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)
{
return myshape;
}
+inline void AIS_Shape::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
+{
+ myDrawer->SetTypeOfHLR (theTypeOfHLR);
+}
+
+inline Prs3d_TypeOfHLR AIS_Shape::TypeOfHLR ( ) const
+{
+ return myDrawer->TypeOfHLR();
+}
#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
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;
}
Array1OfReal from TColStd,
Array1OfInteger from TColStd,
Edge from TopoDS,
- Curve from BRepAdaptor
+ Curve from BRepAdaptor,
+ BSplineCurve from Geom
raises
NoSuchObject from Standard,
---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.
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
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
}
}
+//=======================================================================
+//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 :
}
}
+//=======================================================================
+//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 :
inline BRepAdaptor_Curve& HLRBRep_Curve::Curve()
{ return myCurve; }
+//=======================================================================
+//function : GetCurve
+//purpose :
+//=======================================================================
+
+inline const BRepAdaptor_Curve& HLRBRep_Curve::GetCurve() const
+{ return myCurve; }
+
//=======================================================================
//function : Value3D
//purpose :
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()) {
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;
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);
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
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;
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
--
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;
myHLRAngle(20*M_PI/180),
myLineDrawArrow(Standard_False),
myDrawHiddenLine(Standard_False),
- myFaceBoundaryDraw(Standard_False)
+ myFaceBoundaryDraw(Standard_False),
+ myTypeOfHLR(Prs3d_TOH_PolyAlgo)
{
}
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;
+}
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
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);
-
}
//=====================================================================
#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>
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
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;
" 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);
}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
+
+
+
--- /dev/null
+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
+
+
+
+