From b8ddfc2f5df045c0a1f4c8a3c0741b255772c0dd Mon Sep 17 00:00:00 2001 From: kgv Date: Fri, 18 Jan 2013 13:36:18 +0400 Subject: [PATCH] 0023634: Eliminate Polyline and Polygon usage in drawers Polylines and polygons removed, now everything is based on PrimitiveArrays. Added use of Graphic3d_ArrayOfSegments, some additional clean up in Graphic3d_Group. Dead code elimination in AIS and V3d Corrected compilation errors Fixed grid presentation Adding test case correction --- src/AIS/AIS_AngleDimension.cxx | 68 +- src/AIS/AIS_Axis.cxx | 9 +- src/AIS/AIS_Circle.cxx | 34 +- src/AIS/AIS_GraphicTool.cxx | 25 +- src/AIS/AIS_InteractiveContext.cxx | 28 +- src/AIS/AIS_InteractiveObject.lxx | 13 +- src/AIS/AIS_Line.cxx | 29 +- src/AIS/AIS_LocalContext_1.cxx | 22 +- src/AIS/AIS_Plane.cxx | 91 +- src/AIS/AIS_PlaneTrihedron.cxx | 5 +- src/AIS/AIS_Relation.cxx | 10 +- src/AIS/AIS_Shape.cxx | 38 +- src/AIS/AIS_Triangulation.cxx | 19 +- src/AIS/AIS_Trihedron.cxx | 5 +- src/DsgPrs/DsgPrs_AnglePresentation.cxx | 864 ++++++------- src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx | 38 +- src/DsgPrs/DsgPrs_ConcentricPresentation.cxx | 74 +- src/DsgPrs/DsgPrs_DiameterPresentation.cxx | 76 +- .../DsgPrs_EllipseRadiusPresentation.cxx | 149 +-- .../DsgPrs_EqualDistancePresentation.cxx | 151 +-- src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx | 82 +- .../DsgPrs_FilletRadiusPresentation.cxx | 57 +- src/DsgPrs/DsgPrs_FixPresentation.cxx | 56 +- src/DsgPrs/DsgPrs_IdenticPresentation.cxx | 167 ++- src/DsgPrs/DsgPrs_LengthPresentation.cxx | 266 ++-- src/DsgPrs/DsgPrs_MidPointPresentation.cxx | 379 +++--- src/DsgPrs/DsgPrs_OffsetPresentation.cxx | 118 +- src/DsgPrs/DsgPrs_ParalPresentation.cxx | 113 +- src/DsgPrs/DsgPrs_PerpenPresentation.cxx | 102 +- src/DsgPrs/DsgPrs_RadiusPresentation.cxx | 103 +- src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx | 25 +- src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx | 49 +- src/DsgPrs/DsgPrs_SymmetricPresentation.cxx | 622 ++++----- src/DsgPrs/DsgPrs_TangentPresentation.cxx | 26 +- src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx | 55 +- src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx | 31 +- src/Graphic3d/FILES | 4 +- src/Graphic3d/Graphic3d.cdl | 51 +- src/Graphic3d/Graphic3d_ArrayOfPrimitives.cdl | 165 ++- src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx | 264 ++-- src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx | 151 ++- src/Graphic3d/Graphic3d_CGroup.hxx | 7 - src/Graphic3d/Graphic3d_CStructure.hxx | 2 - src/Graphic3d/Graphic3d_GraphicDriver.cdl | 51 +- src/Graphic3d/Graphic3d_GraphicDriver.cxx | 3 +- src/Graphic3d/Graphic3d_Group.cdl | 176 --- src/Graphic3d/Graphic3d_Group.cxx | 61 +- src/Graphic3d/Graphic3d_Group_1.cxx | 52 +- src/Graphic3d/Graphic3d_Group_10.cxx | 56 +- src/Graphic3d/Graphic3d_Group_13.cxx | 55 - src/Graphic3d/Graphic3d_Group_2.cxx | 12 +- src/Graphic3d/Graphic3d_Group_3.cxx | 52 +- src/Graphic3d/Graphic3d_Group_5.cxx | 121 -- src/Graphic3d/Graphic3d_Group_7.cxx | 112 -- src/Graphic3d/Graphic3d_Group_8.cxx | 11 +- src/Graphic3d/Graphic3d_Structure.cdl | 17 +- src/Graphic3d/Graphic3d_Structure.cxx | 60 +- src/Graphic3d/Graphic3d_Structure.pxx | 6 - src/Graphic3d/Graphic3d_Vector.cxx | 14 +- src/Graphic3d/Graphic3d_Vertex.cdl | 140 -- src/Graphic3d/Graphic3d_Vertex.cxx | 115 +- src/Graphic3d/Graphic3d_Vertex.hxx | 66 + src/Graphic3d/Graphic3d_VertexC.cdl | 94 -- src/Graphic3d/Graphic3d_VertexC.cxx | 80 -- src/Graphic3d/Graphic3d_VertexN.cdl | 106 -- src/Graphic3d/Graphic3d_VertexN.cxx | 84 -- src/Graphic3d/Graphic3d_VertexNC.cdl | 110 -- src/Graphic3d/Graphic3d_VertexNC.cxx | 90 -- src/Graphic3d/Graphic3d_VertexNT.cdl | 112 -- src/Graphic3d/Graphic3d_VertexNT.cxx | 81 -- src/InterfaceGraphic/FILES | 1 - .../InterfaceGraphic_Cextern.hxx | 1143 ----------------- .../InterfaceGraphic_telem.hxx | 5 +- .../MeshVS_ElementalColorPrsBuilder.cxx | 49 - src/MeshVS/MeshVS_MeshEntityOwner.cxx | 2 - src/MeshVS/MeshVS_MeshPrsBuilder.cxx | 66 +- src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx | 7 - src/MeshVS/MeshVS_TextPrsBuilder.cxx | 4 - src/MeshVS/MeshVS_VectorPrsBuilder.cxx | 10 +- src/OpenGl/OpenGl_GraphicDriver.hxx | 16 +- src/OpenGl/OpenGl_GraphicDriver_3.cxx | 10 - src/OpenGl/OpenGl_GraphicDriver_703.cxx | 5 +- src/OpenGl/OpenGl_GraphicDriver_705.cxx | 36 - src/OpenGl/OpenGl_GraphicDriver_713.cxx | 17 - src/OpenGl/OpenGl_Group.cxx | 30 - src/OpenGl/OpenGl_Group.hxx | 3 - src/OpenGl/OpenGl_Polyline.hxx | 1 - src/OpenGl/OpenGl_Text.cxx | 8 +- src/OpenGl/OpenGl_tsm.hxx | 4 +- src/Prs3d/Prs3d_AnglePresentation.cxx | 81 +- src/Prs3d/Prs3d_Arrow.cxx | 55 +- src/Prs3d/Prs3d_Datum.gxx | 97 +- src/Prs3d/Prs3d_HLRShape.gxx | 7 +- src/Prs3d/Prs3d_LengthPresentation.cxx | 54 +- src/Prs3d/Prs3d_Line.gxx | 91 +- src/Prs3d/Prs3d_Point.gxx | 18 +- src/Prs3d/Prs3d_Vector.gxx | 31 +- .../Prs3d_WFDeflectionRestrictedFace.gxx | 142 +- src/Prs3d/Prs3d_WFRestrictedFace.gxx | 149 +-- src/Prs3d/Prs3d_WFShape.gxx | 432 ++----- src/QABugs/QABugs_PresentableObject.cxx | 2 - src/StdPrs/StdPrs_Curve.cxx | 367 +++--- src/StdPrs/StdPrs_DeflectionCurve.cdl | 49 +- src/StdPrs/StdPrs_DeflectionCurve.cxx | 496 ++++--- src/StdPrs/StdPrs_HLRPolyShape.cxx | 118 +- src/StdPrs/StdPrs_Plane.cxx | 127 +- src/StdPrs/StdPrs_PoleCurve.cxx | 26 +- src/StdPrs/StdPrs_ShadedShape.cxx | 4 - src/StdPrs/StdPrs_ShadedSurface.cxx | 2 - .../StdPrs_WFDeflectionRestrictedFace.cxx | 118 +- src/StdPrs/StdPrs_WFPoleSurface.cxx | 43 +- src/StdPrs/StdPrs_WFSurface.cxx | 22 +- src/StdSelect/StdSelect.cxx | 1 - src/StdSelect/StdSelect_ViewerSelector3d.cxx | 325 +++-- src/V3d/V3d.cxx | 239 ++-- src/V3d/V3d_CircularGrid.cdl | 6 +- src/V3d/V3d_CircularGrid.cxx | 607 ++++----- src/V3d/V3d_DirectionalLight.cxx | 16 +- src/V3d/V3d_Plane.cxx | 93 +- src/V3d/V3d_PositionLight.cxx | 97 +- src/V3d/V3d_PositionalLight.cxx | 60 +- src/V3d/V3d_RectangularGrid.cdl | 17 +- src/V3d/V3d_RectangularGrid.cxx | 738 ++++------- src/V3d/V3d_SpotLight.cxx | 82 +- src/V3d/V3d_View.cxx | 483 +++---- src/V3d/V3d_View_4.cxx | 299 +---- src/V3d/V3d_View_5.cxx | 18 +- src/V3d/V3d_Viewer.cxx | 37 +- src/V3d/V3d_Viewer_3.cxx | 96 +- src/V3d/V3d_Viewer_4.cxx | 2 +- src/ViewerTest/ViewerTest_ObjectCommands.cxx | 10 +- src/Visual3d/Visual3d_View.cxx | 24 +- src/XCAFPrs/XCAFPrs_AISObject.cxx | 1 - tests/3rdparty/export/A7 | 2 +- 134 files changed, 4289 insertions(+), 9492 deletions(-) delete mode 100755 src/Graphic3d/Graphic3d_Group_5.cxx delete mode 100755 src/Graphic3d/Graphic3d_Group_7.cxx delete mode 100755 src/Graphic3d/Graphic3d_Vertex.cdl create mode 100644 src/Graphic3d/Graphic3d_Vertex.hxx delete mode 100755 src/Graphic3d/Graphic3d_VertexC.cdl delete mode 100755 src/Graphic3d/Graphic3d_VertexC.cxx delete mode 100755 src/Graphic3d/Graphic3d_VertexN.cdl delete mode 100755 src/Graphic3d/Graphic3d_VertexN.cxx delete mode 100755 src/Graphic3d/Graphic3d_VertexNC.cdl delete mode 100755 src/Graphic3d/Graphic3d_VertexNC.cxx delete mode 100755 src/Graphic3d/Graphic3d_VertexNT.cdl delete mode 100755 src/Graphic3d/Graphic3d_VertexNT.cxx delete mode 100755 src/InterfaceGraphic/InterfaceGraphic_Cextern.hxx diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx index 76e81577e2..85590f71a8 100755 --- a/src/AIS/AIS_AngleDimension.cxx +++ b/src/AIS/AIS_AngleDimension.cxx @@ -101,7 +101,7 @@ #include #include #include -#include + //======================================================================= //function : Constructor @@ -1975,19 +1975,17 @@ void AIS_AngleDimension::ComputeConeAngleSelection(const Handle(SelectMgr_Select gp_Pnt AttachmentPnt; gp_Pnt OppositePnt; - gp_Pnt aPnt, tmpPnt; - Quantity_Length X,Y,Z; Standard_Real param = ElCLib::Parameter(myCircle, myPosition); - aPnt = Apex; + gp_Pnt aPnt = Apex; gp_Pnt P1 = ElCLib::Value(0., myCircle); gp_Pnt P2 = ElCLib::Value(M_PI, myCircle); - gce_MakePln mkPln(P1, P2, aPnt); // create a plane whitch defines plane for projection aPosition on it + gce_MakePln mkPln(P1, P2, aPnt); // create a plane whitch defines plane for projection aPosition on it - aPnt = AIS::ProjectPointOnPlane(myPosition, mkPln.Value()); - tmpPnt = aPnt; + aPnt = AIS::ProjectPointOnPlane(myPosition, mkPln.Value()); + gp_Pnt tmpPnt = aPnt; if( aPnt.Distance(P1) < aPnt.Distance(P2) ){ AttachmentPnt = P1; @@ -2015,49 +2013,30 @@ void AIS_AngleDimension::ComputeConeAngleSelection(const Handle(SelectMgr_Select if( myPosition.Distance( myCircle.Location() ) <= myCircle.Radius() ) if( 2 * myCircle.Radius() > aCircle2.Radius() * 0.4 ) IsArrowOut = Standard_False; //four times more than an arrow size - - Graphic3d_Array1OfVertex V(1, 12); - - Standard_Real angle; - param = ElCLib::Parameter(aCircle2, tmpPnt); - if(IsArrowOut) { - angle = OppParam - AttParam + M_PI / 6; //An angle between AttParam and OppParam + 30 degrees - param = AttParam - M_PI / 12; //out parts of dimension line are 15 degrees - - while ( angle > 2 * M_PI ) angle -= 2 * M_PI; - for( i = 0; i <= 11; i++ ) { //calculating of arc - aPnt = ElCLib::Value(param + angle/11 * i, aCircle2); - aPnt.Coord(X, Y, Z); - V(i+1).SetCoord(X, Y, Z); - } - - } - else { - angle = OppParam - AttParam; - param = AttParam; - while ( angle > 2 * M_PI ) angle -= 2 * M_PI; - for( i = 0; i <= 11; i++ ) { //calculating of arc - aPnt = ElCLib::Value(param + angle/11 * i, aCircle2); - aPnt.Coord(X, Y, Z); - V(i+1).SetCoord(X, Y, Z); - } + param = AttParam; + Standard_Real angle = OppParam - AttParam; + + if(IsArrowOut) + { + angle += M_PI / 6; //An angle between AttParam and OppParam + 30 degrees + param -= M_PI / 12; //out parts of dimension line are 15 degrees } - - for(i = 1; i<=11; i++) { - V(i).Coord(X, Y, Z); - P1.SetCoord(X, Y, Z); - V(i+1).Coord(X, Y, Z); - P1.SetCoord(X, Y, Z); + while ( angle > 2. * M_PI ) angle -= 2. * M_PI; - seg = new Select3D_SensitiveSegment(owner, P1, P2); - aSelection->Add(seg); + gp_Pnt Vprev = ElCLib::Value(param, aCircle2); + for( i = 1; i <= 11; i++ ) //calculating of arc + { + gp_Pnt Vcur = ElCLib::Value(param + angle/11 * i, aCircle2); + seg = new Select3D_SensitiveSegment(owner, Vprev, Vcur); + aSelection->Add(seg); + Vprev = Vcur; } - tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -1)*2); + tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -2)); - Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); + const Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( owner, tmpPnt.X(), tmpPnt.Y(), @@ -2067,6 +2046,3 @@ void AIS_AngleDimension::ComputeConeAngleSelection(const Handle(SelectMgr_Select tmpPnt.Z() + size); aSelection->Add(box); } - - - diff --git a/src/AIS/AIS_Axis.cxx b/src/AIS/AIS_Axis.cxx index debb688bf1..d6a98f38e0 100755 --- a/src/AIS/AIS_Axis.cxx +++ b/src/AIS/AIS_Axis.cxx @@ -19,15 +19,13 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #include #include #include #include #include -#include #include #include #include @@ -177,10 +175,7 @@ void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager3d)&, aPresentation->SetDisplayPriority(5); if (!myIsXYZAxis ){ GeomAdaptor_Curve curv(myComponent); - Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable(); StdPrs_Curve::Add(aPresentation,curv,myDrawer); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable(); } else { DsgPrs_XYZAxisPresentation::Add(aPresentation,myLineAspect,myDir,myVal,myText,myPfirst,myPlast); @@ -217,13 +212,11 @@ void AIS_Axis::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, void AIS_Axis::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } void AIS_Axis::SetColor(const Quantity_Color &aCol) -#endif { hasOwnColor=Standard_True; myOwnColor=aCol; diff --git a/src/AIS/AIS_Circle.cxx b/src/AIS/AIS_Circle.cxx index c96ee0c06b..92fbb3c89c 100755 --- a/src/AIS/AIS_Circle.cxx +++ b/src/AIS/AIS_Circle.cxx @@ -19,14 +19,12 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #include #include #include #include -#include #include #include #include @@ -122,7 +120,6 @@ void AIS_Circle::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, //======================================================================= void AIS_Circle::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } @@ -133,7 +130,6 @@ void AIS_Circle::SetColor(const Quantity_NameOfColor aCol) //======================================================================= void AIS_Circle::SetColor(const Quantity_Color &aCol) -#endif { hasOwnColor=Standard_True; myOwnColor=aCol; @@ -157,17 +153,10 @@ void AIS_Circle::SetWidth(const Standard_Real aValue) { myOwnWidth=aValue; -#ifndef GER61351 - Quantity_NameOfColor CC = - HasColor() ? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line); -#endif - if (!myDrawer->HasLineAspect ()) { -#ifdef GER61351 Quantity_Color CC; if( HasColor() ) CC = myOwnColor; else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); -#endif myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue)); } else myDrawer->LineAspect()->SetWidth(aValue); @@ -186,17 +175,12 @@ void AIS_Circle::UnsetColor() if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); else{ -#ifdef GER61351 - Quantity_Color CC; - if( HasColor() ) CC = myOwnColor; - else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); -#else - Quantity_NameOfColor CC = -#endif - AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line); + Quantity_Color CC; + if( HasColor() ) CC = myOwnColor; + else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); myDrawer->LineAspect()->SetColor(CC); myOwnColor = CC; - } + } } //======================================================================= @@ -225,10 +209,7 @@ void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation) GeomAdaptor_Curve curv(myComponent); Standard_Real prevdev = myDrawer->DeviationCoefficient(); myDrawer->SetDeviationCoefficient(1.e-5); - Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable(); StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable(); myDrawer->SetDeviationCoefficient(prevdev); } @@ -240,16 +221,11 @@ void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation) //======================================================================= void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation) { - GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd); Standard_Real prevdev = myDrawer->DeviationCoefficient(); myDrawer->SetDeviationCoefficient(1.e-5); - Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable(); StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable(); myDrawer->SetDeviationCoefficient(prevdev); - } //======================================================================= diff --git a/src/AIS/AIS_GraphicTool.cxx b/src/AIS/AIS_GraphicTool.cxx index 1c1b19c746..56712aefd0 100755 --- a/src/AIS/AIS_GraphicTool.cxx +++ b/src/AIS/AIS_GraphicTool.cxx @@ -19,8 +19,7 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to get an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to get an object RGB color instead a restricted object NameOfColor. @@ -92,7 +91,6 @@ static Handle(Prs3d_LineAspect) GetLineAspect(const Handle(Prs3d_Drawer)& Dr, } Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att) -#ifdef GER61351 { Quantity_Color color; GetLineColor(Dr,Att,color); @@ -100,20 +98,10 @@ Quantity_NameOfColor AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& } void AIS_GraphicTool::GetLineColor (const Handle(Prs3d_Drawer)& Dr, const AIS_TypeOfAttribute Att, Quantity_Color &aColor) -#endif { Standard_Real W; Aspect_TypeOfLine TYP; - - Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att); - -#ifdef GER61351 - LA->Aspect()->Values(aColor,TYP,W); -#else - Quantity_Color QCol; - LA->Aspect()->Values(QCol,TYP,W); - return QCol.Name(); -#endif + GetLineAspect(Dr,Att)->Aspect()->Values(aColor,TYP,W); } Standard_Real AIS_GraphicTool::GetLineWidth (const Handle(Prs3d_Drawer)& Dr, @@ -159,7 +147,6 @@ void AIS_GraphicTool::GetLineAtt(const Handle(Prs3d_Drawer)& Dr, } Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr) -#ifdef GER61351 { Quantity_Color color; GetInteriorColor(Dr,color); @@ -167,24 +154,16 @@ Quantity_NameOfColor AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer } void AIS_GraphicTool::GetInteriorColor(const Handle(Prs3d_Drawer)& Dr, Quantity_Color &aColor) -#endif { Handle(Graphic3d_AspectFillArea3d) AFA = Dr->ShadingAspect()->Aspect(); Aspect_InteriorStyle IS; Aspect_TypeOfLine T; Standard_Real W; -#ifdef GER61351 Quantity_Color EC; AFA->Values(IS,aColor,EC,T,W); -#else - Quantity_Color IC,EC; - AFA->Values(IS,IC,EC,T,W); - return IC.Name(); -#endif } Graphic3d_MaterialAspect AIS_GraphicTool::GetMaterial(const Handle(Prs3d_Drawer)& Dr) { return Dr->ShadingAspect()->Aspect()->BackMaterial(); - } diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index ad0c151e75..9d8ce8893c 100755 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -23,12 +23,11 @@ #define BUC60577 //GG_101099 Enable to compute correctly // transparency with more than one object in the view. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #define G003 //EUG_26/01/00 Degenerate support (G003) -#define IMP140200 //GG Add SetSelectedAspect() method. +//IMP140200 //GG Add SetSelectedAspect() method. #define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode() // method, compute only authorized presentation. @@ -1914,15 +1913,13 @@ UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj, //purpose : //======================================================================= -#ifdef GER61351 void AIS_InteractiveContext::SetCurrentFacingModel( const Handle(AIS_InteractiveObject)& anIObj, - const Aspect_TypeOfFacingModel aModel) { - if ( !anIObj.IsNull () ) { - anIObj->SetCurrentFacingModel(aModel); - } + const Aspect_TypeOfFacingModel aModel) +{ + if ( !anIObj.IsNull () ) + anIObj->SetCurrentFacingModel(aModel); } -#endif //======================================================================= //function : SetColor @@ -1932,7 +1929,6 @@ void AIS_InteractiveContext::SetCurrentFacingModel( void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, const Quantity_NameOfColor aColor, const Standard_Boolean updateviewer) -#ifdef GER61351 { SetColor(anIObj,Quantity_Color(aColor),updateviewer); } @@ -1940,7 +1936,6 @@ void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIOb void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, const Quantity_Color &aColor, const Standard_Boolean updateviewer) -#endif { if(anIObj.IsNull()) return ; @@ -2292,13 +2287,11 @@ Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveO return anIObj->Color(); } -#ifdef GER61351 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj, - Quantity_Color &aColor) const + Quantity_Color &aColor) const { anIObj->Color(aColor); } -#endif //======================================================================= //function : Width @@ -2541,7 +2534,6 @@ void AIS_InteractiveContext :: SetDegenerateModel ( } // end AIS_InteractiveContext :: SetDegenerateModel #endif -#ifdef IMP140200 //======================================================================= //function : SetSelectedAspect //purpose : @@ -2549,7 +2541,8 @@ void AIS_InteractiveContext :: SetDegenerateModel ( void AIS_InteractiveContext::SetSelectedAspect( const Handle(Prs3d_BasicAspect)& anAspect, const Standard_Boolean globalChange, - const Standard_Boolean updateViewer) { + const Standard_Boolean updateViewer) +{ if( !HasOpenedContext() ) { Standard_Boolean found = Standard_False; Handle(AIS_Selection) sel = @@ -2563,11 +2556,10 @@ void AIS_InteractiveContext::SetSelectedAspect( if( found && updateViewer) { myMainVwr->Update(); if( !(myIsCollClosed && myCollectorVwr.IsNull()) ) - myCollectorVwr->Update(); + myCollectorVwr->Update(); } } } -#endif //======================================================================= //function : SetLocalAttributes diff --git a/src/AIS/AIS_InteractiveObject.lxx b/src/AIS/AIS_InteractiveObject.lxx index 4057794a56..c5d000f1af 100755 --- a/src/AIS/AIS_InteractiveObject.lxx +++ b/src/AIS/AIS_InteractiveObject.lxx @@ -19,8 +19,7 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. inline Standard_Boolean AIS_InteractiveObject::AcceptShapeDecomposition() const @@ -66,19 +65,13 @@ inline Standard_Integer AIS_InteractiveObject::SelectionMode() const inline Quantity_NameOfColor AIS_InteractiveObject::Color() const { -#ifdef GER61351 - return myOwnColor.Name(); -#else - return myOwnColor; -#endif + return myOwnColor.Name(); } -#ifdef GER61351 inline void AIS_InteractiveObject::Color(Quantity_Color& aColor) const { - aColor = myOwnColor; + aColor = myOwnColor; } -#endif inline Standard_Boolean AIS_InteractiveObject::HasWidth() const {return (!myOwnWidth == 0.);} diff --git a/src/AIS/AIS_Line.cxx b/src/AIS/AIS_Line.cxx index dc51694bd9..95dfca094d 100755 --- a/src/AIS/AIS_Line.cxx +++ b/src/AIS/AIS_Line.cxx @@ -19,15 +19,13 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #include #include #include #include #include -#include #include #include #include @@ -157,13 +155,11 @@ void AIS_Line::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, //======================================================================= void AIS_Line::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } void AIS_Line::SetColor(const Quantity_Color &aCol) -#endif { hasOwnColor=Standard_True; myOwnColor=aCol; @@ -190,15 +186,9 @@ void AIS_Line::UnsetColor() if (!HasWidth()) myDrawer->SetLineAspect(NullAsp); else{ -#ifdef GER61351 Quantity_Color CC; if( HasColor() ) CC = myOwnColor; else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); -#else - Quantity_NameOfColor CC = - AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line); -#endif - myDrawer->LineAspect()->SetColor(CC); myOwnColor = CC; } @@ -212,17 +202,10 @@ void AIS_Line::SetWidth(const Standard_Real aValue) { myOwnWidth=aValue; -#ifndef GER61351 - Quantity_NameOfColor CC = - HasColor()? myOwnColor : AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line); -#endif - if (!myDrawer->HasLineAspect ()) { -#ifdef GER61351 Quantity_Color CC; if( HasColor() ) CC = myOwnColor; else AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); -#endif myDrawer->SetLineAspect (new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,aValue)); } else myDrawer->LineAspect()->SetWidth(aValue); @@ -251,16 +234,11 @@ void AIS_Line::UnsetWidth() //======================================================================= void AIS_Line::ComputeInfiniteLine( const Handle(Prs3d_Presentation)& aPresentation) { - GeomAdaptor_Curve curv(myComponent); - Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable(); StdPrs_Curve::Add(aPresentation,curv,myDrawer); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable(); //pas de prise en compte lors du FITALL aPresentation->SetInfiniteState (Standard_True); - } //======================================================================= @@ -269,7 +247,6 @@ void AIS_Line::ComputeInfiniteLine( const Handle(Prs3d_Presentation)& aPresentat //======================================================================= void AIS_Line::ComputeSegmentLine( const Handle(Prs3d_Presentation)& aPresentation) { - gp_Pnt P1 = myStartPoint->Pnt(); gp_Pnt P2 = myEndPoint->Pnt(); @@ -277,11 +254,7 @@ void AIS_Line::ComputeSegmentLine( const Handle(Prs3d_Presentation)& aPresentati Standard_Real dist = P1.Distance(P2); GeomAdaptor_Curve curv(myComponent,0.,dist); - Standard_Boolean isPrimitiveArraysEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Disable(); StdPrs_Curve::Add(aPresentation,curv,myDrawer); - if(isPrimitiveArraysEnabled) Graphic3d_ArrayOfPrimitives::Enable(); - } diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index b2eb7a8728..17592abbe6 100755 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -93,7 +93,7 @@ #include #include #include -#include +#include #include #include #include @@ -1430,17 +1430,18 @@ void AIS_LocalContext::HilightTriangle(const Standard_Integer Rank, { static Standard_Integer PrevRank(0); if(Rank==PrevRank) return; -// PrevRank = Rank; Handle(SelectBasics_SensitiveEntity) SE = myMainVS->Primitive(Rank); - if(SE->IsKind(STANDARD_TYPE(Select3D_SensitiveTriangulation))){ + if(SE->IsKind(STANDARD_TYPE(Select3D_SensitiveTriangulation))) + { Handle(Select3D_SensitiveTriangulation) Tr = *((Handle(Select3D_SensitiveTriangulation)*)&SE); gp_Pnt p1,p2,p3 ; Tr->DetectedTriangle(p1,p2,p3); - static Graphic3d_Array1OfVertex Vtt(1,3); - Vtt.SetValue(1,Graphic3d_Vertex(p1.X(),p1.Y(),p1.Z())); - Vtt.SetValue(2,Graphic3d_Vertex(p2.X(),p2.Y(),p2.Z())); - Vtt.SetValue(3,Graphic3d_Vertex(p3.X(),p3.Y(),p3.Z())); - static Handle(Prs3d_Presentation) TriPrs = + Handle(Graphic3d_ArrayOfTriangles) aTris = new Graphic3d_ArrayOfTriangles(3); + aTris->AddVertex(p1); + aTris->AddVertex(p2); + aTris->AddVertex(p3); + + static Handle(Prs3d_Presentation) TriPrs = new Prs3d_Presentation(myMainPM->StructureManager()); TriPrs->Clear(); #ifdef IMP300101 @@ -1448,20 +1449,17 @@ void AIS_LocalContext::HilightTriangle(const Standard_Integer Rank, asp->SetColor(myCTX->HilightColor()); TriPrs->SetShadingAspect(asp); #endif - Prs3d_Root::CurrentGroup(TriPrs)->Polygon(Vtt); + Prs3d_Root::CurrentGroup(TriPrs)->AddPrimitiveArray(aTris); #ifndef IMP300101 if(view->TransientManagerBeginDraw()) Visual3d_TransientManager::EndDraw(); #endif if(view->TransientManagerBeginDraw()) { - //P->Exploration(); Visual3d_TransientManager::DrawStructure(TriPrs); Visual3d_TransientManager::EndDraw(); } - } - } //======================================================================= diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index 2f32e969b9..570177e31d 100755 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -245,58 +245,59 @@ void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager3d)& , ComputeFields(); aPresentation->SetInfiniteState(myInfiniteState); - if (myCurrentMode) - myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(3); - else - myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(1); - if(aMode == 0){ - if (!myIsXYZPlane){ - ComputeFrame(); - const Handle(Geom_Plane)& pl = myComponent; - const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast - (pl->Translated(pl->Location(),myCenter)); - GeomAdaptor_Surface surf(thegoodpl); - StdPrs_Plane::Add(aPresentation,surf,myDrawer); - } - else { - DsgPrs_XYZPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); + myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0? 1 : 3); + + switch (aMode) + { + case 0: + { + if (!myIsXYZPlane) + { + ComputeFrame(); + const Handle(Geom_Plane)& pl = myComponent; + const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)); + GeomAdaptor_Surface surf(thegoodpl); + StdPrs_Plane::Add(aPresentation,surf,myDrawer); + } + else + DsgPrs_XYZPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); + break; } - } - else if (aMode == 1){ - if (!myIsXYZPlane){ - ComputeFrame(); - Handle(Prs3d_PlaneAspect) theaspect = myDrawer->PlaneAspect(); - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - gp_Pnt p1; - Standard_Real Xmax,Ymax; - Xmax = Standard_Real(theaspect->PlaneXLength())/2.; - Ymax = Standard_Real(theaspect->PlaneYLength())/2.; - static Graphic3d_Array1OfVertex vertices(1,5); - TheGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); - myComponent->D0(-Xmax,Ymax,p1); - vertices(1).SetCoord(p1.X(),p1.Y(),p1.Z()); - vertices(5).SetCoord(p1.X(),p1.Y(),p1.Z()); - myComponent->D0(Xmax,Ymax,p1); - vertices(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - myComponent->D0(Xmax,-Ymax,p1); - vertices(3).SetCoord(p1.X(),p1.Y(),p1.Z()); - myComponent->D0(-Xmax,-Ymax,p1); - vertices(4).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polygon(vertices); - + case 1: + { + if (!myIsXYZPlane) + { + ComputeFrame(); + Handle(Prs3d_PlaneAspect) theaspect = myDrawer->PlaneAspect(); + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); + TheGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); + gp_Pnt p1; + const Standard_Real Xmax = 0.5*Standard_Real(theaspect->PlaneXLength()); + const Standard_Real Ymax = 0.5*Standard_Real(theaspect->PlaneYLength()); + + Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4); + + myComponent->D0(-Xmax,Ymax,p1); + aQuads->AddVertex(p1); + myComponent->D0(Xmax,Ymax,p1); + aQuads->AddVertex(p1); + myComponent->D0(Xmax,-Ymax,p1); + aQuads->AddVertex(p1); + myComponent->D0(-Xmax,-Ymax,p1); + aQuads->AddVertex(p1); + + TheGroup->AddPrimitiveArray(aQuads); } - else{ - DsgPrs_ShadedPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); - + else + DsgPrs_ShadedPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); + break; } } - } void AIS_Plane::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { -// Standard_NotImplemented::Raise("AIS_Plane::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); - PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; + PrsMgr_PresentableObject::Compute(aProjector, aTransformation, aPresentation); } //======================================================================= diff --git a/src/AIS/AIS_PlaneTrihedron.cxx b/src/AIS/AIS_PlaneTrihedron.cxx index 5307ee50d9..947c25ccbf 100755 --- a/src/AIS/AIS_PlaneTrihedron.cxx +++ b/src/AIS/AIS_PlaneTrihedron.cxx @@ -19,8 +19,7 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #define OCC218 //SAV using DsgPrs_XYZAxisPresentation to draw axes. // + X/YAxis() returns AIS_Line instead of AIS_Axis @@ -280,13 +279,11 @@ void AIS_PlaneTrihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSe } void AIS_PlaneTrihedron::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol) -#endif { hasOwnColor=Standard_True; myOwnColor = aCol; diff --git a/src/AIS/AIS_Relation.cxx b/src/AIS/AIS_Relation.cxx index a812e249a6..7427f9ff18 100755 --- a/src/AIS/AIS_Relation.cxx +++ b/src/AIS/AIS_Relation.cxx @@ -19,14 +19,12 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #define BUC60915 //GG 05/06/01 Enable to compute the requested arrow size // if any in all dimensions. #include -#include #include #include @@ -222,13 +220,11 @@ void AIS_Relation::ComputeProjVertexPresentation(const Handle(Prs3d_Presentation //======================================================================= void AIS_Relation::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } void AIS_Relation::SetColor(const Quantity_Color &aCol) -#endif { if(hasOwnColor && myOwnColor==aCol) return; @@ -268,13 +264,9 @@ void AIS_Relation::UnsetColor() if (!hasOwnColor) return; hasOwnColor = Standard_False; const Handle(Prs3d_LineAspect)& LA = myDrawer->LineAspect(); -#ifdef GER61351 Quantity_Color CC; AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); LA->SetColor(CC); -#else - LA->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line)); -#endif myDrawer->AngleAspect()->SetLineAspect(LA); myDrawer->LengthAspect()->SetLineAspect(LA); myDrawer->SetTextAspect(myDrawer->Link()->TextAspect()); diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 0a02b79336..864bf780c2 100755 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -44,8 +44,7 @@ #include #include #include -#include -#include +#include #include #include @@ -104,24 +103,18 @@ void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs, const Bnd_Box& B, const Handle(Prs3d_Drawer)& aDrawer) { - Standard_Real X[2],Y[2],Z[2]; - Standard_Integer Indx [16] ; + static const Standard_Integer Indx[][3] = + { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 }, + { 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 }, + { 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, + { 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } }; + if ( B.IsVoid() ) return; // nothing to show - Indx [0]=1;Indx [1]=2;Indx [2]=4;Indx [3]=3; - Indx [4]=5;Indx [5]=6;Indx [6]=8;Indx [7]=7; - Indx [8]=1;Indx [9]=3;Indx [10]=7;Indx [11]=5; - Indx [12]=2;Indx [13]=4;Indx [14]=8;Indx [15]=6; + Standard_Real X[2],Y[2],Z[2]; B.Get(X[0], Y[0], Z[0], X[1], Y[1], Z[1]); - Graphic3d_Array1OfVertex V(1,8); - Standard_Integer Rank(0); - for(Standard_Integer k=0;k<=1;k++) - for(Standard_Integer j=0;j<=1;j++) - for(Standard_Integer i=0;i<=1;i++) - V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]); - Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs); Quantity_Color Q; Aspect_TypeOfLine A; @@ -130,16 +123,11 @@ void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs, G->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d(Q,Aspect_TOL_DOTDASH,W)); - G->BeginPrimitives();Standard_Integer I,J; - Graphic3d_Array1OfVertex VVV (1,5); - for(I=1;I<=4;I++){ - for(J=1;J<=4;J++){ - VVV.SetValue(J,V(Indx[J+4*I-5])); - } - VVV.SetValue(5,VVV(1)); - G->Polyline(VVV); - } - G->EndPrimitives(); + Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16); + Standard_Integer i(0); + for(;i<16;i++) + aPolyline->AddVertex(X[Indx[i][0]],Y[Indx[i][1]],Z[Indx[i][2]]); + G->AddPrimitiveArray(aPolyline); } static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode) diff --git a/src/AIS/AIS_Triangulation.cxx b/src/AIS/AIS_Triangulation.cxx index 87a0e11200..248ff48d83 100755 --- a/src/AIS/AIS_Triangulation.cxx +++ b/src/AIS/AIS_Triangulation.cxx @@ -30,7 +30,6 @@ #include #include #include -#include IMPLEMENT_STANDARD_HANDLE(AIS_Triangulation, AIS_InteractiveObject) @@ -66,7 +65,7 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre if( myFlagColor == 1 ) hasVColors = Standard_True; - Handle(Graphic3d_ArrayOfTriangles) array = + Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles ( myNbNodes, //maxVertexs myNbTriangles * 3,//maxEdges hasVNormals, //hasVNormals @@ -83,24 +82,22 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre Standard_Real ambient = aspect->FrontMaterial().Ambient(); for ( i = nodes.Lower(); i<= nodes.Upper(); i++ ){ if( myFlagColor == 1 ) - array->AddVertex( nodes(i), AttenuateColor(myColor->Value(i),ambient)); + anArray->AddVertex( nodes(i), AttenuateColor(myColor->Value(i),ambient)); if( myFlagColor == 0 ) - array->AddVertex( nodes(i) ); + anArray->AddVertex( nodes(i) ); j = (i - nodes.Lower()) * 3; - array->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3)); + anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3)); } Standard_Integer indexTriangle[3] = {0,0,0}; for ( i = triangles.Lower(); i<= triangles.Upper(); i++ ) { triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]); - array->AddEdge(indexTriangle[0]); - array->AddEdge(indexTriangle[1]); - array->AddEdge(indexTriangle[2]); + anArray->AddEdge(indexTriangle[0]); + anArray->AddEdge(indexTriangle[1]); + anArray->AddEdge(indexTriangle[2]); } TheGroup->SetPrimitivesAspect(aspect); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(array); - TheGroup->EndPrimitives(); + TheGroup->AddPrimitiveArray(anArray); break; } } diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 48204b8cce..4d3434f76d 100755 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -19,8 +19,7 @@ // and conditions governing the rights and limitations under the License. -#define GER61351 //GG_171199 Enable to set an object RGB color -// instead a restricted object NameOfColor. +//GER61351 //GG_171199 Enable to set an object RGB color instead a restricted object NameOfColor. #define IMP120100 // GG Add SetTextColor() and SetArrowColor() methods @@ -430,13 +429,11 @@ void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelecti //======================================================================= void AIS_Trihedron::SetColor(const Quantity_NameOfColor aCol) -#ifdef GER61351 { SetColor(Quantity_Color(aCol)); } void AIS_Trihedron::SetColor(const Quantity_Color &aCol) -#endif { hasOwnColor=Standard_True; myOwnColor = aCol; diff --git a/src/DsgPrs/DsgPrs_AnglePresentation.cxx b/src/DsgPrs/DsgPrs_AnglePresentation.cxx index 552581cf89..053b0be228 100755 --- a/src/DsgPrs/DsgPrs_AnglePresentation.cxx +++ b/src/DsgPrs/DsgPrs_AnglePresentation.cxx @@ -17,14 +17,13 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include -#include +#include +#include #include #include #include @@ -54,13 +53,23 @@ #include -//pop pour NT -//#if WNT #include -//#endif +//------------------------------------------------------------------------------------------------------------------ +// Returns 1 if C is above of CMin; 0 if C is bitween CMin and CMax; -1 if C is Below CMax +//----------------------------------------------------------------------------------------------------------------- +static Standard_Integer AboveInBelowCone(const gp_Circ &CMax, const gp_Circ &CMin, const gp_Circ &C) +{ + const Standard_Real D = CMax.Location().Distance( CMin.Location() ); + const Standard_Real D1 = CMax.Location().Distance( C.Location() ); + const Standard_Real D2 = CMin.Location().Distance( C.Location() ); -static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C); + if ( D >= D1 && D >= D2 ) return 0; + if ( D < D2 && D1 < D2 ) return -1; + if ( D < D1 && D2 < D1 ) return 1; + + return 0; +} //========================================================================== @@ -68,65 +77,49 @@ static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C); // purpose : draws the presentation of the cone's angle; //========================================================================== void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real aVal, - const TCollection_ExtendedString& aText, - const gp_Circ& aCircle, + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real aVal, + const TCollection_ExtendedString& aText, + const gp_Circ& aCircle, const gp_Pnt& aPosition, const gp_Pnt& Apex, - const gp_Circ& VminCircle, - const gp_Circ& VmaxCircle, - const Standard_Real aArrowSize) + const gp_Circ& VminCircle, + const gp_Circ& VmaxCircle, + const Standard_Real aArrowSize) { - - - Handle(Prs3d_AngleAspect) anAngleAspect = aDrawer->AngleAspect(); Handle(Prs3d_LengthAspect) aLengthAspect = aDrawer->LengthAspect(); - Standard_Real myArrowSize; - TCollection_ExtendedString txt = aText; - if( aArrowSize == 0.0 ) myArrowSize = aCircle.Radius()/ 10.; - else myArrowSize = aArrowSize; + TCollection_ExtendedString txt(aText); + + const Standard_Real myArrowSize = ( aArrowSize == 0.0 )? (0.1 * aCircle.Radius()) : aArrowSize; anAngleAspect->ArrowAspect()->SetLength(myArrowSize); aDrawer->ArrowAspect()->SetLength(myArrowSize); - Standard_Boolean IsArrowOut = Standard_True; //Is arrows inside or outside of the cone Standard_Boolean IsConeTrimmed = Standard_False; gp_Circ myCircle = aCircle; - - if( VminCircle.Radius() > 0.01 ) { IsConeTrimmed = Standard_True; - if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 ) myCircle = VminCircle; + if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 ) myCircle = VminCircle; } - gp_Pnt AttachmentPnt; - gp_Pnt OppositePnt; - gp_Pnt aPnt, tmpPnt; - - - Quantity_Length X,Y,Z; - - Standard_Real param = 0.; //ElCLib::Parameter(myCircle, aPosition); - - aPnt = Apex; gp_Pnt P1 = ElCLib::Value(0., myCircle); gp_Pnt P2 = ElCLib::Value(M_PI, myCircle); - gce_MakePln mkPln(P1, P2, aPnt); // create a plane whitch defines plane for projection aPosition on it + gce_MakePln mkPln(P1, P2, Apex); // create a plane whitch defines plane for projection aPosition on it gp_Vec aVector( mkPln.Value().Location(), aPosition ); //project aPosition on a plane gp_Vec Normal = mkPln.Value().Axis().Direction(); Normal = (aVector * Normal) * Normal; - aPnt = aPosition; - aPnt = aPnt.Translated( -Normal ); + gp_Pnt aPnt = aPosition; + aPnt = aPnt.Translated( -Normal ); - tmpPnt = aPnt; + gp_Pnt tmpPnt = aPnt; - if( aPnt.Distance(P1) < aPnt.Distance(P2) ){ + gp_Pnt AttachmentPnt, OppositePnt; + if( aPnt.Distance(P1) < aPnt.Distance(P2) ) { AttachmentPnt = P1; OppositePnt = P2; } @@ -134,136 +127,96 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat AttachmentPnt = P2; OppositePnt = P1; } - + aPnt = AttachmentPnt ; // Creating of circle whitch defines a plane for a dimension arc gp_Vec Vec(AttachmentPnt, Apex); // Dimension arc is a part of the circle - Vec.Scale(2); + Vec.Scale(2.); aPnt.Translate(Vec); - GC_MakeCircle mkCirc(AttachmentPnt, OppositePnt, aPnt); - gp_Circ aCircle2 = mkCirc.Value()->Circ(); + GC_MakeCircle mkCirc(AttachmentPnt, OppositePnt, aPnt); + gp_Circ aCircle2 = mkCirc.Value()->Circ(); Standard_Integer i; Standard_Real AttParam = ElCLib::Parameter(aCircle2, AttachmentPnt); //must be equal to zero (look circle construction) Standard_Real OppParam = ElCLib::Parameter(aCircle2, OppositePnt); - gp_Dir aDir, aDir2; - while ( AttParam >= 2 * M_PI ) AttParam -= 2 * M_PI; - while ( OppParam >= 2 * M_PI ) OppParam -= 2 * M_PI; + while ( AttParam >= 2. * M_PI ) AttParam -= 2. * M_PI; + while ( OppParam >= 2. * M_PI ) OppParam -= 2. * M_PI; //-------------------------- Compute angle ------------------------ - if( txt.Length() == 0 ) { - Standard_Real angle = UnitsAPI::CurrentFromLS( Abs( OppParam ),"PLANE ANGLE"); - char res[80]; - sprintf(res, "%g", angle ); - txt = TCollection_ExtendedString(res); - } + if( txt.Length() == 0 ) { + Standard_Real angle = UnitsAPI::CurrentFromLS( Abs( OppParam ),"PLANE ANGLE"); + char res[80]; + sprintf(res, "%g", angle ); + txt = TCollection_ExtendedString(res); + } //----------------------------------------------------------------- - - + Standard_Boolean IsArrowOut = Standard_True; //Is arrows inside or outside of the cone if( ElCLib::Parameter(aCircle2, tmpPnt) < OppParam ) - // if( aPosition.Distance( myCircle.Location() ) <= myCircle.Radius() ) - if( 2 * myCircle.Radius() > 4 * myArrowSize ) IsArrowOut = Standard_False; //four times more than an arrow size - - - Graphic3d_Array1OfVertex V(1, 12); - - Standard_Real angle; -// param = ElCLib::Parameter(aCircle2, tmpPnt); - angle = OppParam - AttParam; - param = AttParam; + if( 2. * myCircle.Radius() > 4. * myArrowSize ) IsArrowOut = Standard_False; //four times more than an arrow size + Standard_Real angle = OppParam - AttParam; + Standard_Real param = AttParam; + + gp_Dir aDir, aDir2; if(IsArrowOut) { - aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam - M_PI / 12, aCircle2 ), AttachmentPnt) ) ); - aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam + M_PI / 12, aCircle2 ), OppositePnt) ) ); + aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam - M_PI / 12., aCircle2 ), AttachmentPnt) ) ); + aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam + M_PI / 12., aCircle2 ), OppositePnt) ) ); } else { - aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam + M_PI / 12, aCircle2 ), AttachmentPnt ) ) ); - aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam - M_PI / 12, aCircle2 ), OppositePnt ) ) ); - } - - while ( angle > 2 * M_PI ) angle -= 2 * M_PI; - for( i = 0; i <= 11; i++ ) { //calculating of arc - ( ElCLib::Value(param + angle/11 * i, aCircle2) ).Coord(X, Y, Z); - V(i+1).SetCoord(X, Y, Z); + aDir = gp_Dir( ( gp_Vec( ElCLib::Value( AttParam + M_PI / 12., aCircle2 ), AttachmentPnt ) ) ); + aDir2 = gp_Dir( ( gp_Vec( ElCLib::Value( OppParam - M_PI / 12., aCircle2 ), OppositePnt ) ) ); } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); //add the arc + while ( angle > 2. * M_PI ) angle -= 2. * M_PI; + + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(12); + for( i = 0; i <= 11; i++ ) + aPrims->AddVertex(ElCLib::Value(param + angle/11 * i, aCircle2)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, AttachmentPnt, - AttachmentPnt, aDir, aDir, DsgPrs_AS_LASTAR); + AttachmentPnt, aDir, aDir, DsgPrs_AS_LASTAR); DsgPrs::ComputeSymbol(aPresentation, anAngleAspect, OppositePnt, - OppositePnt, aDir2, aDir2, DsgPrs_AS_LASTAR); + OppositePnt, aDir2, aDir2, DsgPrs_AS_LASTAR); param = ElCLib::Parameter(aCircle2, tmpPnt); tmpPnt = ElCLib::Value(param, aCircle2); - tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -1)*2); - Prs3d_Text::Draw(aPresentation,aLengthAspect->TextAspect(), txt, tmpPnt); //add the TCollection_ExtendedString - - angle = 2 * M_PI - param ; - if( param > OppParam ) { - while ( angle > 2 * M_PI ) angle -= 2 * M_PI; - for( i = 11; i >= 0; i-- ) { //calculating of arc - ( ElCLib::Value(-angle/11 * i, aCircle2) ).Coord(X, Y, Z); - V(i+1).SetCoord(X, Y, Z); - } - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); //add additional line + tmpPnt = tmpPnt.Translated(gp_Vec(0, 0, -2)); + Prs3d_Text::Draw(aPresentation, aLengthAspect->TextAspect(), txt, tmpPnt); //add the TCollection_ExtendedString + + angle = 2. * M_PI - param ; + if( param > OppParam ) + { + while ( angle > 2. * M_PI ) angle -= 2. * M_PI; + aPrims = new Graphic3d_ArrayOfPolylines(12); + for( i = 11; i >= 0; i-- ) + aPrims->AddVertex(ElCLib::Value(-angle/11 * i, aCircle2)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } - - if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 && !IsConeTrimmed ) { //above - Graphic3d_Array1OfVertex V2(1,3); - AttachmentPnt.Coord(X, Y, Z); - V2(1).SetCoord(X, Y, Z); - Apex.Coord(X, Y, Z); - V2(2).SetCoord(X, Y, Z); - OppositePnt.Coord(X, Y, Z); - V2(3).SetCoord(X, Y, Z); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); //add the additional lines + + if( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 1 && !IsConeTrimmed ) //above + { + aPrims = new Graphic3d_ArrayOfPolylines(3); + aPrims->AddVertex(AttachmentPnt); + aPrims->AddVertex(Apex); + aPrims->AddVertex(OppositePnt); } - else { + else + { aPnt = OppositePnt ; if ( AboveInBelowCone( VmaxCircle, VminCircle, myCircle ) == 0 ) return; - Graphic3d_Array1OfVertex V3(1,2); + gp_Pnt P11 = ElCLib::Value( 0., VmaxCircle ); gp_Pnt P12 = ElCLib::Value( M_PI, VmaxCircle ); - - AttachmentPnt.Coord(X, Y, Z); - V3(1).SetCoord(X, Y, Z); - if( aPnt.Distance(P1) < aPnt.Distance(P2) ) P12.Coord(X, Y, Z); - else P11.Coord(X, Y, Z); - V3(2).SetCoord(X, Y, Z); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3); - - OppositePnt.Coord(X, Y, Z); - V3(1).SetCoord(X, Y, Z); - if( aPnt.Distance(P1) < aPnt.Distance(P2) ) P11.Coord(X, Y, Z); - else P12.Coord(X, Y, Z); - V3(2).SetCoord(X, Y, Z); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3); - } -} -//------------------------------------------------------------------------------------------------------------------ -// Returns 1 if C is above of CMin; 0 if C is bitween CMin and CMax; -1 if C is Below CMax -//----------------------------------------------------------------------------------------------------------------- -static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C) -{ - Standard_Real D, D1, D2; - - D = CMax.Location().Distance( CMin.Location() ); - D1 = CMax.Location().Distance( C.Location() ); - D2 = CMin.Location().Distance( C.Location() ); - - - if ( D >= D1 && D >= D2 ) return 0; - if ( D < D2 && D1 < D2 ) return -1; - if ( D < D1 && D2 < D1 ) return 1; - - return 0; + aPrims = new Graphic3d_ArrayOfSegments(4); + aPrims->AddVertex(AttachmentPnt); + aPrims->AddVertex(( aPnt.Distance(P1) < aPnt.Distance(P2) )? P12 : P11); + aPrims->AddVertex(OppositePnt); + aPrims->AddVertex(( aPnt.Distance(P1) < aPnt.Distance(P2) )? P11 : P12); + } + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } @@ -274,19 +227,20 @@ static Standard_Integer AboveInBelowCone(gp_Circ CMax, gp_Circ CMin, gp_Circ C) //========================================================================== void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const TCollection_ExtendedString& aText, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const gp_Dir& axisdir, - const gp_Pnt& OffsetPoint) { + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const TCollection_ExtendedString& aText, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Pnt& AttachmentPoint2, + const gp_Dir& dir1, + const gp_Dir& dir2, + const gp_Dir& axisdir, + const gp_Pnt& OffsetPoint) +{ char valcar[80]; sprintf(valcar,"%5.2f",theval); - + Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -294,10 +248,6 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint)); gp_Vec vec1(dir1); vec1 *= cer.Radius(); -#ifdef DEB - gp_Pnt p1 = -#endif - CenterPoint.Translated(vec1); gp_Vec vec2(dir2); vec2 *= cer.Radius(); gp_Pnt p2 = CenterPoint.Translated(vec2); @@ -312,81 +262,71 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat if (uco > ufin) { if (Abs(theval) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; + if (uco > udeb+M_PI && uco < ufin+M_PI) { + udeb += M_PI; + ufin += M_PI; + uc1 = udeb; + uc2 = ufin; } } } if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) { + if ((uco-uc2) < (uc1-uco+(2.*M_PI))) { ufin = uco; } else { - udeb = uco - 2*M_PI; + udeb = uco - 2.*M_PI; } } - Standard_Real alpha = Abs(ufin-udeb); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + const Standard_Real alpha = Abs(ufin-udeb); + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+4,3); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(udeb+ dteta*(i-1),cer)); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint); + Standard_Real length = LA->ArrowAspect()->Length(); + if (length < Precision::Confusion()) length = 1.e-04; + gp_Vec vecarr; gp_Pnt ptarr; ElCLib::D1(uc1,cer,ptarr,vecarr); + gp_Ax1 ax1(ptarr, axisdir); gp_Dir dirarr(-vecarr); + //calculate angle of rotation - Standard_Real beta(0.); - Standard_Real length = LA->ArrowAspect()->Length(); - if (length < Precision::Confusion()) length = 1.e-04; gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ()); - Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); + const Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); gp_Pnt ptarr3 = ElCLib::Value(parcir, cer); - gp_Vec v1(ptarr,ptarr2 ); - gp_Vec v2(ptarr, ptarr3); - beta = v1.Angle(v2); + gp_Vec v1(ptarr,ptarr2); + gp_Vec v2(ptarr,ptarr3); + const Standard_Real beta = v1.Angle(v2); dirarr.Rotate(ax1, beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr, - LA->ArrowAspect()->Angle(), - length); - - Graphic3d_Array1OfVertex Vrap(1,2); - Vrap(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); - + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr,LA->ArrowAspect()->Angle(),length); + + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(ptarr); + ElCLib::D1(uc2,cer,ptarr,vecarr); + ax1.SetLocation(ptarr); gp_Dir dirarr2(vecarr); dirarr2.Rotate(ax1,-beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr2, - LA->ArrowAspect()->Angle(), - length); - - Vrap(1).SetCoord(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr2,LA->ArrowAspect()->Angle(),length); + + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(ptarr); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } @@ -395,23 +335,23 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat // purpose : Adds prezentation of angle between two faces //========================================================================== -void DsgPrs_AnglePresentation::Add( const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const TCollection_ExtendedString& aText, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const gp_Dir& axisdir, - const Standard_Boolean isPlane, - const gp_Ax1& AxisOfSurf, - const gp_Pnt& OffsetPoint, - const DsgPrs_ArrowSide ArrowPrs ) +void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const TCollection_ExtendedString& aText, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Pnt& AttachmentPoint2, + const gp_Dir& dir1, + const gp_Dir& dir2, + const gp_Dir& axisdir, + const Standard_Boolean isPlane, + const gp_Ax1& AxisOfSurf, + const gp_Pnt& OffsetPoint, + const DsgPrs_ArrowSide ArrowPrs ) { char valcar[80]; - sprintf( valcar, "%5.2f", theval ); + sprintf(valcar,"%5.2f",theval); Handle( Prs3d_AngleAspect ) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); @@ -443,32 +383,28 @@ void DsgPrs_AnglePresentation::Add( const Handle(Prs3d_Presentation)& aPresentat FirstParAttachCirc, LastParAttachCirc ); - Graphic3d_Array1OfVertex Vrap(1,2); - // Creating the angle's arc or line if null angle + Handle(Graphic3d_ArrayOfPrimitives) aPrims; if (theval > Precision::Angular() && Abs( M_PI-theval ) > Precision::Angular()) - { - Standard_Real Alpha = Abs( LastParAngleCirc - FirstParAngleCirc ); - Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); - Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); - Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 ); - gp_Pnt CurPnt; - for (Standard_Integer i = 0 ; i < NodeNumber; i++) - { - CurPnt = ElCLib::Value( FirstParAngleCirc, AngleCirc ); - ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - FirstParAngleCirc += delta ; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); - } + { + const Standard_Real Alpha = Abs( LastParAngleCirc - FirstParAngleCirc ); + const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); + const Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 ); + + aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber+4,3); + aPrims->AddBound(NodeNumber); + for (Standard_Integer i = 0; i < NodeNumber; i++, FirstParAngleCirc += delta) + aPrims->AddVertex(ElCLib::Value( FirstParAngleCirc, AngleCirc )); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + aPrims = new Graphic3d_ArrayOfSegments(4); + } else // null angle - { - Vrap(1).SetCoord( OffsetPoint.X(), - OffsetPoint.Y(), - OffsetPoint.Z()); - Vrap(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); - } + { + aPrims = new Graphic3d_ArrayOfSegments(6); + aPrims->AddVertex(OffsetPoint); + aPrims->AddVertex(EndOfArrow1); + } // Add presentation of arrows DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow1, EndOfArrow2, DirOfArrow1, DirOfArrow2, ArrowPrs ); @@ -477,49 +413,37 @@ void DsgPrs_AnglePresentation::Add( const Handle(Prs3d_Presentation)& aPresentat Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint ); // Line from AttachmentPoint1 to end of Arrow1 - Vrap(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrap(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); - + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(EndOfArrow1); + // Line from "projection" of AttachmentPoint2 to end of Arrow2 + aPrims->AddVertex(ProjAttachPoint2); + aPrims->AddVertex(EndOfArrow2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + // Line or arc from AttachmentPoint2 to its "projection" if (AttachmentPoint2.Distance( ProjAttachPoint2 ) > Precision::Confusion()) - { - if (isPlane) + { + if (isPlane) { // Creating the line from AttachmentPoint2 to its projection - Vrap(1).SetCoord( AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z() ); - Vrap(2).SetCoord( ProjAttachPoint2.X(), - ProjAttachPoint2.Y(), - ProjAttachPoint2.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(ProjAttachPoint2); } - else + else { // Creating the arc from AttachmentPoint2 to its projection - Standard_Real Alpha = Abs( LastParAttachCirc - FirstParAttachCirc ); - Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); - Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); - Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 ); - gp_Pnt CurPnt; - for (Standard_Integer i = 0 ; i < NodeNumber; i++) - { - CurPnt = ElCLib::Value( FirstParAttachCirc, AttachCirc ); - ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - FirstParAttachCirc += delta ; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); + const Standard_Real Alpha = Abs( LastParAttachCirc - FirstParAttachCirc ); + const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); + const Standard_Real delta = Alpha / (Standard_Real)( NodeNumber - 1 ); + + aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 0; i < NodeNumber; i++, FirstParAttachCirc += delta) + aPrims->AddVertex(ElCLib::Value( FirstParAttachCirc, AttachCirc )); } - } - // Line from "projection" of AttachmentPoint2 to end of Arrow2 - Vrap(1).SetCoord( ProjAttachPoint2.X(), - ProjAttachPoint2.Y(), - ProjAttachPoint2.Z() ); - Vrap(2).SetCoord( EndOfArrow2.X(), EndOfArrow2.Y(), EndOfArrow2.Z()); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } @@ -530,20 +454,22 @@ void DsgPrs_AnglePresentation::Add( const Handle(Prs3d_Presentation)& aPresentat //========================================================================== void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const TCollection_ExtendedString& aText, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const gp_Pnt& OffsetPoint) { + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const TCollection_ExtendedString& aText, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Pnt& AttachmentPoint2, + const gp_Dir& dir1, + const gp_Dir& dir2, + const gp_Pnt& OffsetPoint) +{ char valcar[80]; sprintf(valcar,"%5.2f",theval); Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Dir Norm; if (!dir1.IsParallel(dir2, Precision::Angular())) { Norm = dir1.Crossed(dir2); @@ -559,10 +485,6 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint)); gp_Vec vec1(dir1); vec1 *= cer.Radius(); -#ifdef DEB - gp_Pnt p1 = -#endif - CenterPoint.Translated(vec1); gp_Vec vec2(dir2); vec2 *= cer.Radius(); gp_Pnt p2 = CenterPoint.Translated(vec2); @@ -577,116 +499,103 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat if (uco > ufin) { if (Abs(theval) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; + if (uco > udeb+M_PI && uco < ufin+M_PI) { + udeb += M_PI; + ufin += M_PI; + uc1 = udeb; + uc2 = ufin; } } } if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) { + if ((uco-uc2) < (uc1-uco+(2.*M_PI))) { ufin = uco; } else { - udeb = uco - 2*M_PI; + udeb = uco - 2.*M_PI; } } - Standard_Real alpha = Abs(ufin-udeb); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + const Standard_Real alpha = Abs(ufin-udeb); + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+4,3); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(udeb+ dteta*(i-1),cer)); Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint); + Standard_Real length = LA->ArrowAspect()->Length(); + if (length < Precision::Confusion()) length = 1.e-04; + gp_Vec vecarr; gp_Pnt ptarr; ElCLib::D1(uc1,cer,ptarr,vecarr); + gp_Ax1 ax1(ptarr, Norm); gp_Dir dirarr(-vecarr); //calculate the angle of rotation - Standard_Real beta; - Standard_Real length = LA->ArrowAspect()->Length(); - if (length < Precision::Confusion()) length = 1.e-04; gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ()); - Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); + const Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); gp_Pnt ptarr3 = ElCLib::Value(parcir, cer); - gp_Vec v1(ptarr,ptarr2 ); - gp_Vec v2(ptarr, ptarr3); - beta = v1.Angle(v2); + gp_Vec v1(ptarr,ptarr2); + gp_Vec v2(ptarr,ptarr3); + const Standard_Real beta = v1.Angle(v2); dirarr.Rotate(ax1, beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr, - LA->ArrowAspect()->Angle(), - length); - Graphic3d_Array1OfVertex Vrap(1,2); - Vrap(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); - + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr,LA->ArrowAspect()->Angle(),length); + + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(ptarr); + ElCLib::D1(uc2,cer,ptarr,vecarr); + ax1.SetLocation(ptarr); gp_Dir dirarr2(vecarr); dirarr2.Rotate(ax1, - beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr2, - LA->ArrowAspect()->Angle(), - length); + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr2,LA->ArrowAspect()->Angle(),length); - Vrap(1).SetCoord(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(ptarr); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } + //========================================================================== // function : DsgPrs_AnglePresentation::Add // purpose : It is possible to choose the symbol of extremities of the face (arrow, point...) //========================================================================== void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const TCollection_ExtendedString& aText, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const gp_Pnt& OffsetPoint, - const DsgPrs_ArrowSide ArrowPrs) + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const TCollection_ExtendedString& aText, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Pnt& AttachmentPoint2, + const gp_Dir& dir1, + const gp_Dir& dir2, + const gp_Pnt& OffsetPoint, + const DsgPrs_ArrowSide ArrowPrs) { char valcar[80]; sprintf(valcar,"%5.2f",theval); Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - gp_Dir Norm = dir1.Crossed(dir2); + gp_Dir Norm = dir1.Crossed(dir2); if (Abs(theval) > M_PI) Norm.Reverse(); gp_Ax2 ax(CenterPoint,Norm,dir1); gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint)); gp_Vec vec1(dir1); vec1 *= cer.Radius(); -#ifdef DEB - gp_Pnt p1 = -#endif - CenterPoint.Translated(vec1); gp_Vec vec2(dir2); vec2 *= cer.Radius(); gp_Pnt p2 = CenterPoint.Translated(vec2); @@ -701,61 +610,57 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat if (uco > ufin) { if (Abs(theval) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; + if (uco > udeb+M_PI && uco < ufin+M_PI) { + udeb += M_PI; + ufin += M_PI; + uc1 = udeb; + uc2 = ufin; } } } if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) { + if ((uco-uc2) < (uc1-uco+(2.*M_PI))) { ufin = uco; } else { - udeb = uco - 2*M_PI; + udeb = uco - 2.*M_PI; } } - Standard_Real alpha = Abs(ufin-udeb); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + const Standard_Real alpha = Abs(ufin-udeb); + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+4,3); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(udeb+ dteta*(i-1),cer)); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint); -// Lines of recall + Standard_Real length = LA->ArrowAspect()->Length(); + if (length < Precision::Confusion()) length = 1.e-04; + + // Lines of recall gp_Vec vecarr; gp_Pnt ptarr; ElCLib::D1(uc1,cer,ptarr,vecarr); + gp_Ax1 ax1(ptarr, Norm); gp_Dir dirarr(-vecarr); //calculate angle of rotation - Standard_Real beta(0.); - Standard_Real length = LA->ArrowAspect()->Length(); - if (length < Precision::Confusion()) length = 1.e-04; gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ()); - Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); + const Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); gp_Pnt ptarr3 = ElCLib::Value(parcir, cer); gp_Vec v1(ptarr,ptarr2 ); gp_Vec v2(ptarr, ptarr3); - beta = v1.Angle(v2); + const Standard_Real beta = v1.Angle(v2); dirarr.Rotate(ax1, beta); - Graphic3d_Array1OfVertex Vrap(1,2); - Vrap(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(ptarr); gp_Vec vecarr1; gp_Pnt ptarr1; @@ -764,21 +669,17 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Dir dirarr2(vecarr1); dirarr2.Rotate(ax1, - beta); - - Vrap(1).SetCoord(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - Vrap(2).SetCoord(ptarr1.X(),ptarr1.Y(),ptarr1.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(ptarr1); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); -// One traces the arrows + // One traces the arrows DsgPrs::ComputeSymbol(aPresentation,LA,ptarr,ptarr1,dirarr,dirarr2,ArrowPrs); } - - //========================================================================== // function : DsgPrs_AnglePresentation::Add // purpose : @@ -786,35 +687,31 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat //========================================================================== void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Pnt& AttachmentPoint2, - const gp_Dir& dir1, - const gp_Dir& dir2, - const gp_Pnt& OffsetPoint) { - - + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Pnt& AttachmentPoint2, + const gp_Dir& dir1, + const gp_Dir& dir2, + const gp_Pnt& OffsetPoint) +{ char valcar[80]; sprintf(valcar,"%5.2f",theval); + TCollection_AsciiString valas(valcar); TCollection_ExtendedString aText(valas); Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - gp_Dir Norm = dir1.Crossed(dir2); + gp_Dir Norm = dir1.Crossed(dir2); if (Abs(theval) > M_PI) Norm.Reverse(); gp_Ax2 ax(CenterPoint,Norm,dir1); gp_Circ cer(ax,CenterPoint.Distance(OffsetPoint)); gp_Vec vec1(dir1); vec1 *= cer.Radius(); -#ifdef DEB - gp_Pnt p1 = -#endif - CenterPoint.Translated(vec1); gp_Vec vec2(dir2); vec2 *= cer.Radius(); gp_Pnt p2 = CenterPoint.Translated(vec2); @@ -829,90 +726,80 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat if (uco > ufin) { if (Abs(theval) udeb+M_PI && uco < ufin+M_PI){ - udeb = udeb + M_PI; - ufin = ufin + M_PI; - uc1 = udeb; - uc2 = ufin; + if (uco > udeb+M_PI && uco < ufin+M_PI) { + udeb += M_PI; + ufin += M_PI; + uc1 = udeb; + uc2 = ufin; } } } if (uco > ufin) { - if ((uco-uc2) < (uc1-uco+(2*M_PI))) { + if ((uco-uc2) < (uc1-uco+(2.*M_PI))) { ufin = uco; } else { - udeb = uco - 2*M_PI; + udeb = uco - 2.*M_PI; } } - Standard_Real alpha = Abs(ufin-udeb); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(udeb+ dteta*(i-1),cer); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + const Standard_Real alpha = Abs(ufin-udeb); + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+4,3); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(udeb+ dteta*(i-1),cer)); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,OffsetPoint); + Standard_Real length = LA->ArrowAspect()->Length(); + if (length < Precision::Confusion()) length = 1.e-04; + gp_Vec vecarr; gp_Pnt ptarr; ElCLib::D1(uc1,cer,ptarr,vecarr); + gp_Ax1 ax1(ptarr, Norm); gp_Dir dirarr(-vecarr); //calculate the angle of rotation - Standard_Real beta; - Standard_Real length = LA->ArrowAspect()->Length(); - if (length < Precision::Confusion()) length = 1.e-04; gp_Pnt ptarr2(ptarr.XYZ() + length*dirarr.XYZ()); - Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); + const Standard_Real parcir = ElCLib::Parameter(cer, ptarr2); gp_Pnt ptarr3 = ElCLib::Value(parcir, cer); gp_Vec v1(ptarr,ptarr2 ); gp_Vec v2(ptarr, ptarr3); - beta = v1.Angle(v2); + const Standard_Real beta = v1.Angle(v2); dirarr.Rotate(ax1, beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr, - LA->ArrowAspect()->Angle(), - length); - - Graphic3d_Array1OfVertex Vrap(1,2); - Vrap(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); - + + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr,LA->ArrowAspect()->Angle(),length); + + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(ptarr); + ElCLib::D1(uc2,cer,ptarr,vecarr); ax1.SetLocation(ptarr); gp_Dir dirarr2(vecarr); - dirarr2.Rotate(ax1, - beta); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - dirarr2, - LA->ArrowAspect()->Angle(), - length); + dirarr2.Rotate(ax1, -beta); + + Prs3d_Arrow::Draw(aPresentation,ptarr,dirarr2,LA->ArrowAspect()->Angle(),length); - Vrap(1).SetCoord(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - Vrap(2).SetCoord(ptarr.X(),ptarr.Y(),ptarr.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + aPrims->AddBound(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(ptarr); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, - const Handle(Prs3d_Drawer)& aDrawer, - const Standard_Real theval, - const gp_Pnt& CenterPoint, - const gp_Pnt& AttachmentPoint1, - const gp_Ax1& theAxe, - const DsgPrs_ArrowSide ArrowSide) + const Handle(Prs3d_Drawer)& aDrawer, + const Standard_Real theval, + const gp_Pnt& CenterPoint, + const gp_Pnt& AttachmentPoint1, + const gp_Ax1& theAxe, + const DsgPrs_ArrowSide ArrowSide) { Handle(Prs3d_AngleAspect) LA = aDrawer->AngleAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -921,67 +808,44 @@ void DsgPrs_AnglePresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Ax2 ax(CenterPoint,theAxe.Direction(),dir1); gp_Circ cer(ax,CenterPoint.Distance(AttachmentPoint1)); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * theval / M_PI)); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = theval/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(dteta*(i-1),cer); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * theval / M_PI)); + const Standard_Real dteta = theval/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp); + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(dteta*(i-1),cer)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + Standard_Real uc1 = 0.; Standard_Real uc2 = ElCLib::Parameter(cer,AttachmentPoint1.Rotated(theAxe,theval)); - gp_Vec vecarr; - gp_Pnt ptarr; Standard_Real length = LA->ArrowAspect()->Length(); - if (length < Precision::Confusion()) length = 1.e-04; + if (length < Precision::Confusion()) length = 1.e-04; - switch(ArrowSide) { - case DsgPrs_AS_NONE: - { - break; - } - case DsgPrs_AS_FIRSTAR: + gp_Vec vecarr; + gp_Pnt ptarr; + switch(ArrowSide) + { + case DsgPrs_AS_FIRSTAR: { ElCLib::D1(uc1,cer,ptarr,vecarr); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - gp_Dir(-vecarr), - LA->ArrowAspect()->Angle(), - length); + Prs3d_Arrow::Draw(aPresentation,ptarr,gp_Dir(-vecarr),LA->ArrowAspect()->Angle(),length); break; } - case DsgPrs_AS_LASTAR: + case DsgPrs_AS_LASTAR: { ElCLib::D1(uc2,cer,ptarr,vecarr); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - gp_Dir(vecarr), - LA->ArrowAspect()->Angle(), - length); + Prs3d_Arrow::Draw(aPresentation,ptarr,gp_Dir(vecarr),LA->ArrowAspect()->Angle(),length); break; } - case DsgPrs_AS_BOTHAR: + case DsgPrs_AS_BOTHAR: { ElCLib::D1(uc1,cer,ptarr,vecarr); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - gp_Dir(-vecarr), - LA->ArrowAspect()->Angle(), - length); + Prs3d_Arrow::Draw(aPresentation,ptarr,gp_Dir(-vecarr),LA->ArrowAspect()->Angle(),length); ElCLib::D1(uc2,cer,ptarr,vecarr); - Prs3d_Arrow::Draw(aPresentation, - ptarr, - gp_Dir(vecarr), - LA->ArrowAspect()->Angle(), - length); + Prs3d_Arrow::Draw(aPresentation,ptarr,gp_Dir(vecarr),LA->ArrowAspect()->Angle(),length); break; } - default: - break; + default: break; } } - diff --git a/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx b/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx index cae1897306..d8a157d344 100755 --- a/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx +++ b/src/DsgPrs/DsgPrs_Chamf2dPresentation.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -44,25 +44,17 @@ void DsgPrs_Chamf2dPresentation::Add( { Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Prs3d_Root::CurrentGroup(aPresentation) - ->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aPntAttach.X(),aPntAttach.Y(),aPntAttach.Z()); - - V(2).SetCoord(aPntEnd.X(),aPntEnd.Y(),aPntEnd.Z()); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPntAttach); + aPrims->AddVertex(aPntEnd); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ()); - Prs3d_Arrow::Draw(aPresentation, - aPntAttach, - ArrowDir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,aPntAttach,ArrowDir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntEnd); - } @@ -81,24 +73,18 @@ void DsgPrs_Chamf2dPresentation::Add( { Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Prs3d_Root::CurrentGroup(aPresentation) - ->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aPntAttach.X(),aPntAttach.Y(),aPntAttach.Z()); - - V(2).SetCoord(aPntEnd.X(),aPntEnd.Y(),aPntEnd.Z()); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPntAttach); + aPrims->AddVertex(aPntEnd); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntEnd); gp_Dir ArrowDir(aPntAttach.XYZ()-aPntEnd.XYZ()); - gp_Dir ArrowDir1 = ArrowDir; ArrowDir1.Reverse(); DsgPrs::ComputeSymbol(aPresentation,LA,aPntEnd,aPntAttach,ArrowDir1,ArrowDir,ArrowPrs); - - } diff --git a/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx b/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx index 08f896e941..5f34a563e1 100755 --- a/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx +++ b/src/DsgPrs/DsgPrs_ConcentricPresentation.cxx @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -47,51 +47,43 @@ void DsgPrs_ConcentricPresentation::Add( //Creation et discretisation du plus gros cercle gp_Circ Circ(gp_Ax2(aCenter,aNorm), aRadius); - Standard_Integer nbp = 50; - Standard_Real dteta = (2 * M_PI)/nbp; - Graphic3d_Array1OfVertex V(1,nbp+1); - gp_Pnt ptcur; - Standard_Real ucur = 0; + const Standard_Integer nbp = 50; + const Standard_Real dteta = (2. * M_PI)/nbp; + + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(2*nbp+6,4); + + gp_Pnt pt1 = ElCLib::Value(0., Circ); + aPrims->AddBound(nbp+1); + aPrims->AddVertex(pt1); + Standard_Real ucur = dteta; Standard_Integer i ; - for ( i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(ucur, Circ); - V(i).SetCoord(ptcur.X(), ptcur.Y(),ptcur.Z()); - ucur = ucur + dteta; - } - V(nbp+1).SetCoord( V(1).X(), V(1).Y(), V(1).Z()); - Prs3d_Root::CurrentGroup(aPresentation) - ->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + for (i = 2; i<=nbp; i++, ucur += dteta) + aPrims->AddVertex(ElCLib::Value(ucur, Circ)); + aPrims->AddVertex(pt1); //Creation et discretisation du plus petit cercle - Circ.SetRadius(aRadius/2); - ucur = 0; - for ( i = 1; i<=nbp; i++) { - ptcur = ElCLib::Value(ucur, Circ); - V(i).SetCoord(ptcur.X(), ptcur.Y(),ptcur.Z()); - ucur = ucur + dteta; - } - V(nbp+1).SetCoord( V(1).X(), V(1).Y(), V(1).Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation) - ->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Circ.SetRadius(0.5*aRadius); + pt1 = ElCLib::Value(0., Circ); + aPrims->AddBound(nbp+1); + aPrims->AddVertex(pt1); + ucur = dteta; + for (i = 2; i<=nbp; i++, ucur += dteta) + aPrims->AddVertex(ElCLib::Value(ucur, Circ)); + aPrims->AddVertex(pt1); //Creation de la croix //1er segment - gp_Dir vecnorm(aPoint.XYZ() - aCenter.XYZ() ); + gp_Dir vecnorm(aPoint.XYZ() - aCenter.XYZ()); gp_Vec vec(vecnorm); vec.Multiply(aRadius); gp_Pnt p1 = aCenter.Translated(vec); gp_Pnt p2 = aCenter.Translated(-vec); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)-> - SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex VExt(1,2); - VExt(1).SetCoord(p1.X(), p1.Y(), p1.Z()); - VExt(2).SetCoord(p2.X(), p2.Y(), p2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VExt); + + aPrims->AddBound(2); + aPrims->AddVertex(p1); + aPrims->AddVertex(p2); //2ieme segment vec.Cross(aNorm); @@ -100,12 +92,10 @@ void DsgPrs_ConcentricPresentation::Add( vec.Multiply(aRadius); p1 = aCenter.Translated(vec); p2 = aCenter.Translated(-vec); - VExt(1).SetCoord(p1.X(), p1.Y(), p1.Z()); - VExt(2).SetCoord(p2.X(), p2.Y(), p2.Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)-> - SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VExt); + aPrims->AddBound(2); + aPrims->AddVertex(p1); + aPrims->AddVertex(p2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } diff --git a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx index 606bf9ddf0..99dab747cf 100755 --- a/src/DsgPrs/DsgPrs_DiameterPresentation.cxx +++ b/src/DsgPrs/DsgPrs_DiameterPresentation.cxx @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -60,8 +60,6 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen const DsgPrs_ArrowSide ArrowPrs, const Standard_Boolean IsDiamSymbol ) { - - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -69,32 +67,26 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen gp_Pnt ptoncirc = ElCLib::Value (parat, aCircle); // sideline - gp_Pnt center = aCircle.Location(); gp_Vec vecrap (ptoncirc,center); Standard_Real dist = center.Distance(AttachmentPoint); Standard_Real aRadius = aCircle.Radius(); - Standard_Boolean inside = Standard_False; + Standard_Boolean inside = (dist < aRadius); gp_Pnt pt1 = AttachmentPoint; - if (dist < aRadius) { + if (inside) { pt1 = ptoncirc; dist = aRadius; - inside = Standard_True; } vecrap.Normalize(); vecrap *= (dist+aRadius); - gp_Pnt OppositePoint = pt1.Translated(vecrap); - + gp_Pnt OppositePoint = pt1.Translated(vecrap); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - pt1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - OppositePoint.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(pt1); + aPrims->AddVertex(OppositePoint); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // value TCollection_ExtendedString Text = aText; @@ -103,11 +95,9 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Prs3d_Text::Draw(aPresentation, LA->TextAspect(), Text, AttachmentPoint); // arrows - gp_Dir arrdir (vecrap); if (inside) arrdir.Reverse(); - gp_Vec vecrap2 = vecrap; gp_Pnt ptoncirc2 = ptoncirc; gp_Dir arrdir2 = arrdir; @@ -128,7 +118,7 @@ static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar, if(lpar > fpar) return ((para >= fpar) && (para <= lpar)); else { // fpar > lpar - Standard_Real delta = 2*M_PI-fpar; + Standard_Real delta = 2.*M_PI-fpar; Standard_Real lp, par, fp; lp = lpar + delta; par = para + delta; @@ -137,7 +127,6 @@ static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar, fp = 0.; return ((par >= fp) && (par <= lp)); } - } if (para >= (fpar+2*M_PI)) return Standard_True; if (para <= lpar) return Standard_True; @@ -162,16 +151,14 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen { Standard_Real fpara = uFirst; Standard_Real lpara = uLast; - while (lpara > 2*M_PI) { - fpara -= 2*M_PI; - lpara -= 2*M_PI; + while (lpara > 2.*M_PI) { + fpara -= 2.*M_PI; + lpara -= 2.*M_PI; } Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); -// Handle(Prs3d_TextAspect) TA = aDrawer->TextAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); -// AspectText3d from Graphic3d - Standard_Real parEndOfArrow = ElCLib::Parameter(aCircle,AttachmentPoint); // + Standard_Real parEndOfArrow = ElCLib::Parameter(aCircle,AttachmentPoint); gp_Pnt EndOfArrow; gp_Pnt DrawPosition = AttachmentPoint;// point of attachment Standard_Boolean otherside = Standard_False; @@ -194,34 +181,26 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen gp_Lin L1( Center, dir1 ); gp_Lin L2( Center, dir2 ); if(L1.Distance(AttachmentPoint) < L2.Distance(AttachmentPoint)) - { - EndOfArrow = FirstPoint; //*** - DrawPosition = ElCLib::Value(ElCLib::Parameter( L1, AttachmentPoint ), L1); - } + { + EndOfArrow = FirstPoint; //*** + DrawPosition = ElCLib::Value(ElCLib::Parameter( L1, AttachmentPoint ), L1); + } else - { - EndOfArrow = SecondPoint; //*** - DrawPosition = ElCLib::Value(ElCLib::Parameter( L2, AttachmentPoint ), L2); - } + { + EndOfArrow = SecondPoint; //*** + DrawPosition = ElCLib::Value(ElCLib::Parameter( L2, AttachmentPoint ), L2); + } } -// EndOfArrow = ElCLib::Value(parEndOfArrow, aCircle); -// DrawPosition = AttachmentPoint; } else { EndOfArrow = ElCLib::Value(parEndOfArrow, aCircle); DrawPosition = AttachmentPoint; } - Graphic3d_Array1OfVertex Vrap(1,2); - - Quantity_Length X,Y,Z; - - DrawPosition.Coord(X,Y,Z); - Vrap(1).SetCoord(X,Y,Z); - EndOfArrow.Coord(X,Y,Z); - Vrap(2).SetCoord(X,Y,Z); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrap); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(DrawPosition); + aPrims->AddVertex(EndOfArrow); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // text TCollection_ExtendedString Text = aText; @@ -229,8 +208,7 @@ void DsgPrs_DiameterPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Text = TCollection_ExtendedString("\330 ") + Text;// => \330 | \370? Prs3d_Text::Draw(aPresentation,LA->TextAspect(),Text,DrawPosition); -// Add presentation of arrow + // Add presentation of arrow gp_Dir DirOfArrow(gp_Vec(DrawPosition, EndOfArrow).XYZ()); - DsgPrs::ComputeSymbol(aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs); - + DsgPrs::ComputeSymbol(aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs); } diff --git a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx index d93871383a..9c70bedfca 100755 --- a/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_EllipseRadiusPresentation.cxx @@ -18,8 +18,6 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include @@ -27,7 +25,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -51,6 +50,7 @@ #include #include #include + //======================================================================= //function : Add //purpose : @@ -60,49 +60,34 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Handle(Prs3d_Drawer)& aDrawer, const Standard_Real theval, const TCollection_ExtendedString & aText, -// const gp_Elips & anEllipse, const gp_Pnt & aPosition, const gp_Pnt & anEndOfArrow, const gp_Pnt & aCenter, const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Standard_Boolean inside = Standard_False; -// gp_Pnt EndPoint, EndOfArrow; - gp_Pnt EndPoint; - Standard_Real dist = aCenter.Distance( aPosition ); - if( dist > theval ) EndPoint = aPosition; - else { - EndPoint = anEndOfArrow; - inside = Standard_True; - } - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - aCenter.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - EndPoint.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // value - TCollection_ExtendedString Text; - if(IsMaxRadius) - Text = TCollection_ExtendedString("a = "); - else - Text = TCollection_ExtendedString("b = "); - Text += aText; + const Standard_Real dist = aCenter.Distance( aPosition ); + const Standard_Boolean inside = ( dist <= theval ); + gp_Pnt EndPoint(inside? anEndOfArrow : aPosition); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aCenter); + aPrims->AddVertex(EndPoint); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + // value + TCollection_ExtendedString Text(IsMaxRadius? "a = " : "b = "); + Text += aText; Prs3d_Text::Draw(aPresentation, LA->TextAspect(), Text, aPosition ); - // arrows + // arrows gp_Dir arrdir( gp_Vec( aCenter, anEndOfArrow)); if (!inside) arrdir.Reverse(); - DsgPrs::ComputeSymbol(aPresentation, LA, anEndOfArrow, anEndOfArrow, arrdir, arrdir, ArrowPrs ); - + DsgPrs::ComputeSymbol(aPresentation, LA, anEndOfArrow, anEndOfArrow, arrdir, arrdir, ArrowPrs ); } //======================================================================= @@ -123,40 +108,30 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + if(!IsInDomain) - { - Standard_Real parFirst; - Standard_Real uLast = ElCLib::Parameter ( anEllipse, anEndOfArrow ); - Standard_Real Alpha = DsgPrs::DistanceFromApex(anEllipse, anEndOfArrow, uFirst);//length of ellipse arc - gp_Vec Vapex(aCenter, ElCLib::Value( uLast, anEllipse )) ; - gp_Vec Vpnt(aCenter, ElCLib::Value( uFirst, anEllipse )) ; - gp_Dir dir(Vpnt ^ Vapex); - if(anEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())) - parFirst = uLast; - else - parFirst = uFirst; - Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); - Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); - Standard_Real delta = Alpha / ( NodeNumber - 1 ); - gp_Pnt CurPnt; - for (Standard_Integer i = 0 ; i < NodeNumber; i++) - { - CurPnt = ElCLib::Value( parFirst, anEllipse ); - ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - parFirst += delta ; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); - } + { + const Standard_Real uLast = ElCLib::Parameter ( anEllipse, anEndOfArrow ); + const Standard_Real Alpha = DsgPrs::DistanceFromApex(anEllipse, anEndOfArrow, uFirst);//length of ellipse arc + gp_Vec Vapex(aCenter, ElCLib::Value( uLast, anEllipse )) ; + gp_Vec Vpnt(aCenter, ElCLib::Value( uFirst, anEllipse )) ; + gp_Dir dir(Vpnt ^ Vapex); + Standard_Real parFirst = anEllipse.Position().Direction().IsOpposite( dir, Precision::Angular())? uLast : uFirst; + const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); + const Standard_Real delta = Alpha / ( NodeNumber - 1 ); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 0 ; i < NodeNumber; i++, parFirst += delta) + aPrims->AddVertex(ElCLib::Value( parFirst, anEllipse )); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } DsgPrs_EllipseRadiusPresentation::Add(aPresentation, aDrawer, theval, aText, - aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs); - + aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs); } - //======================================================================= //function : Add //purpose : // for offset curve @@ -175,41 +150,35 @@ void DsgPrs_EllipseRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aP const Standard_Boolean IsMaxRadius, const DsgPrs_ArrowSide ArrowPrs) { - Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + if(!IsInDomain) - { - Standard_Real parFirst; - if(!aCurve->IsCN(1)) return ; - gp_Elips aBEllipse = Handle(Geom_Ellipse)::DownCast(aCurve->BasisCurve ())->Elips(); - Standard_Real Offset = aCurve->Offset(); - aBEllipse.SetMajorRadius(aBEllipse.MajorRadius() + Offset); - aBEllipse.SetMinorRadius(aBEllipse.MinorRadius() + Offset); - Standard_Real uLast = ElCLib::Parameter ( aBEllipse, anEndOfArrow ); - Standard_Real Alpha = DsgPrs::DistanceFromApex(aBEllipse, anEndOfArrow, uFirst);//length of ellipse arc - gp_Pnt p1; - aCurve->D0(uFirst, p1); - gp_Vec Vapex(aCenter, anEndOfArrow) ; - gp_Vec Vpnt (aCenter, p1) ; - gp_Dir dir(Vpnt ^ Vapex); - if(aCurve->Direction().IsOpposite( dir, Precision::Angular())) - parFirst = uLast; - else - parFirst = uFirst; - Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); - Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); - Standard_Real delta = Alpha / ( NodeNumber - 1 ); - gp_Pnt CurPnt; - for (Standard_Integer i = 0 ; i < NodeNumber; i++) + { + if(!aCurve->IsCN(1)) return ; + gp_Elips aBEllipse = Handle(Geom_Ellipse)::DownCast(aCurve->BasisCurve ())->Elips(); + const Standard_Real Offset = aCurve->Offset(); + aBEllipse.SetMajorRadius(aBEllipse.MajorRadius() + Offset); + aBEllipse.SetMinorRadius(aBEllipse.MinorRadius() + Offset); + const Standard_Real uLast = ElCLib::Parameter ( aBEllipse, anEndOfArrow ); + const Standard_Real Alpha = DsgPrs::DistanceFromApex(aBEllipse, anEndOfArrow, uFirst);//length of ellipse arc + gp_Pnt p1; + aCurve->D0(uFirst, p1); + gp_Vec Vapex(aCenter, anEndOfArrow) ; + gp_Vec Vpnt (aCenter, p1) ; + gp_Dir dir(Vpnt ^ Vapex); + Standard_Real parFirst = aCurve->Direction().IsOpposite( dir, Precision::Angular())? uLast : uFirst; + const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); + const Standard_Real delta = Alpha / ( NodeNumber - 1 ); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 0 ; i < NodeNumber; i++, parFirst += delta) { - aCurve->D0( parFirst, CurPnt ); - ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - parFirst += delta ; + aCurve->D0( parFirst, p1 ); + aPrims->AddVertex(p1); } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); - } + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } DsgPrs_EllipseRadiusPresentation::Add(aPresentation, aDrawer, theval, aText, - aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs); - + aPosition, anEndOfArrow, aCenter, IsMaxRadius, ArrowPrs); } diff --git a/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx b/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx index f0d77232ed..a75e065ff3 100755 --- a/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx +++ b/src/DsgPrs/DsgPrs_EqualDistancePresentation.cxx @@ -18,15 +18,14 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include -#include +#include +#include #include #include #include @@ -52,24 +51,17 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); - Graphic3d_Array1OfVertex VertexArray( 1, 2 ); - Quantity_Length X,Y,Z; - // Line between two middles gp_Pnt Middle12( (Point1.XYZ() + Point2.XYZ()) * 0.5 ), Middle34( (Point3.XYZ() + Point4.XYZ()) * 0.5 ); - Middle12.Coord( X, Y, Z ); - VertexArray( 1 ).SetCoord( X, Y, Z ); - Middle34.Coord( X, Y, Z ); - VertexArray( 2 ).SetCoord( X, Y, Z ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Middle12); + aPrims->AddVertex(Middle34); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // Add presentation of arrows (points) gp_Dir aDir( 0, 0, 1 ); - DsgPrs::ComputeSymbol(aPresentation, LA, - Middle12, Middle34, - aDir, aDir, - DsgPrs_AS_BOTHPT ); + DsgPrs::ComputeSymbol(aPresentation, LA, Middle12, Middle34, aDir, aDir, DsgPrs_AS_BOTHPT ); // ota -- begin -- // Two small lines in the middle of this line gp_Pnt Middle( (Middle12.XYZ() + Middle34.XYZ()) * 0.5 ), aTextPos; @@ -79,22 +71,22 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& gp_Vec LineVec, OrtVec; if (Dist > Precision::Confusion()) - { - SmallDist = Dist * 0.05; // 1/20.0 part - if (SmallDist <= Precision::Confusion()) - SmallDist = Dist; - LineDir = gce_MakeDir( Middle12, Middle34 ); - OrtDir = Plane->Pln().Axis().Direction() ^ LineDir; - LineVec = gp_Vec( LineDir ) * SmallDist; - OrtVec = gp_Vec( OrtDir ) * SmallDist; - - aTextPos = Middle.Translated( OrtVec ); - } + { + SmallDist = Dist * 0.05; // 1/20.0 part + if (SmallDist <= Precision::Confusion()) + SmallDist = Dist; + LineDir = gce_MakeDir( Middle12, Middle34 ); + OrtDir = Plane->Pln().Axis().Direction() ^ LineDir; + LineVec = gp_Vec( LineDir ) * SmallDist; + OrtVec = gp_Vec( OrtDir ) * SmallDist; + + aTextPos = Middle.Translated( OrtVec ); + } else - { - gp_Vec Vec1( Middle, Point1 ); + { + gp_Vec Vec1( Middle, Point1 ); - if (Vec1.SquareMagnitude() > Precision::SquareConfusion()) + if (Vec1.SquareMagnitude() > Precision::Confusion()*Precision::Confusion()) { Standard_Real Angle = gp_Vec( Middle, Point1 ).Angle( gp_Vec( Middle, Point3 ) ); gp_Pnt MidPnt = Point1.Rotated( Plane->Pln().Axis(), Angle*0.5 ); @@ -109,14 +101,14 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& OrtVec = gp_Vec( OrtDir ) * SmallDist; LineVec = gp_Vec( LineDir ) * SmallDist; } - else + else { SmallDist = 5.0; OrtVec = gp_Vec( Plane->Pln().XAxis().Direction() ) * SmallDist; LineVec = gp_Vec( Plane->Pln().YAxis().Direction() ) * SmallDist; } - aTextPos = Middle.Translated (OrtVec); - } + aTextPos = Middle.Translated (OrtVec); + } TCollection_ExtendedString aText("=="); @@ -124,6 +116,7 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& Prs3d_Text::Draw(aPresentation,LA->TextAspect(), aText, aTextPos); } + //================================================================================== //function : AddInterval //purpose : is used for presentation of interval between two lines or two points, @@ -140,7 +133,6 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& gp_Pnt& aProj2) { const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); -//set color Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (aPoint1,aDirection); @@ -148,39 +140,20 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& aProj1 = ElCLib::Value(ElCLib::Parameter(L1, aPosition),L1); aProj2 = ElCLib::Value(ElCLib::Parameter(L2, aPosition),L2); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - aProj1.Coord (X, Y, Z); - V(1).SetCoord(X, Y, Z); - - aPoint1.Coord(X, Y, Z); - V(2).SetCoord(X, Y, Z); - - //add first attached line - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - //add distance interval - aProj2.Coord(X, Y, Z); - V(2).SetCoord(X, Y, Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - - //add second attached line - aPoint2.Coord(X, Y, Z); - V(1).SetCoord(X, Y, Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); + aPrims->AddVertex(aPoint1); + aPrims->AddVertex(aProj1); + aPrims->AddVertex(aProj2); + aPrims->AddVertex(aPoint2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); //add arrows presentation gp_Dir aDir(aProj2.XYZ() - aProj1.XYZ()); - DsgPrs::ComputeSymbol(aPresentation, LA, - aProj1, aProj2, - aDir.Reversed(), aDir, - anArrowSide); + DsgPrs::ComputeSymbol(aPresentation, LA, aProj1, aProj2, aDir.Reversed(), aDir, anArrowSide); } + //======================================================================== // function : AddIntervalBetweenTwoArcs // purpose : is used for presentation of interval between two arcs. One @@ -197,9 +170,9 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& const gp_Pnt& aPoint4, const DsgPrs_ArrowSide anArrowSide) { -//it seems to set color const Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Standard_Real aPar11, aPar12, aPar21, aPar22; if(aCirc1.Radius() > Precision::Confusion()){ aPar11 = ElCLib::Parameter (aCirc1, aPoint1); @@ -218,49 +191,48 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& aPar22 = M_PI; } - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aPoint2.X(), aPoint2.Y(), aPoint2.Z()); - V(2).SetCoord(aPoint4.X(), aPoint4.Y(), aPoint4.Z()); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( V ); + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPoint2); + aPrims->AddVertex(aPoint4); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - Standard_Integer aNodeNb; + Standard_Integer i, aNodeNb; Standard_Real aDelta, aCurPar; - if(aPar12 < aPar11 ) aPar12 +=2*M_PI; - if (Abs(aPar12 - aPar11) > Precision::Confusion()) { + if(aPar12 < aPar11 ) aPar12 += 2.*M_PI; + if (Abs(aPar12 - aPar11) > Precision::Confusion()) + { aNodeNb = Standard_Integer(Max(Abs(aPar12 - aPar11)*50./M_PI + 0.5, 4.)); - Graphic3d_Array1OfVertex ApproxArc1( 1, aNodeNb+1); aDelta = (aPar12 - aPar11)/aNodeNb; aCurPar= aPar11; - for ( int i = 1; i<= aNodeNb ; aCurPar+= aDelta, i++) - { - gp_Pnt CurPnt = ElCLib::Value( aCurPar, aCirc1); - ApproxArc1(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - } - ApproxArc1(aNodeNb+1).SetCoord( aPoint2.X(), aPoint2.Y(), aPoint2.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc1 ); + aPrims = new Graphic3d_ArrayOfPolylines(aNodeNb+1); + for (i = 1; i<= aNodeNb; aCurPar += aDelta, i++) + aPrims->AddVertex(ElCLib::Value( aCurPar, aCirc1)); + aPrims->AddVertex(aPoint2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } - if (aPar22 < aPar21) aPar22 += 2*M_PI; - if ( Abs(aPar22 - aPar21) > Precision::Confusion()){ + if (aPar22 < aPar21) aPar22 += 2.*M_PI; + if ( Abs(aPar22 - aPar21) > Precision::Confusion()) + { aNodeNb = Standard_Integer(Max(Abs(aPar22 - aPar21)*50./M_PI + 0.5, 4.)); - Graphic3d_Array1OfVertex ApproxArc2( 1, aNodeNb+1); aDelta = (aPar22 - aPar21)/aNodeNb; aCurPar= aPar21; - for ( int i=1; i<= aNodeNb; aCurPar+= aDelta, i++) - { - gp_Pnt CurPnt = ElCLib::Value( aCurPar, aCirc2); - ApproxArc2(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - } - ApproxArc2(aNodeNb+1).SetCoord( aPoint4.X(), aPoint4.Y(), aPoint4.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc2 ); + + aPrims = new Graphic3d_ArrayOfPolylines(aNodeNb+1); + for (i = 1; i<= aNodeNb; aCurPar += aDelta, i++) + aPrims->AddVertex(ElCLib::Value( aCurPar, aCirc2)); + aPrims->AddVertex(aPoint4); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } //get the direction of interval - gp_Dir DirOfArrow; - if(aPoint4.Distance(aPoint2) > Precision::Confusion()){ + gp_Dir DirOfArrow; + if(aPoint4.Distance(aPoint2) > Precision::Confusion()) + { DirOfArrow.SetXYZ(aPoint4.XYZ() - aPoint2.XYZ()); } - else { + else + { //Let's take the radius direction gp_Pnt aCenter = aCirc1.Location(); if(aPoint4.Distance(aCenter) < Precision::Confusion()) @@ -270,6 +242,5 @@ void DsgPrs_EqualDistancePresentation::Add( const Handle( Prs3d_Presentation )& // Add presentation of arrows DsgPrs::ComputeSymbol( aPresentation, LA, aPoint2, aPoint4, DirOfArrow.Reversed(), DirOfArrow, anArrowSide ); - } //-- ota -- end diff --git a/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx index 960e676eff..e4afdb16de 100755 --- a/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_EqualRadiusPresentation.cxx @@ -18,15 +18,13 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include -#include +#include #include #include #include @@ -47,40 +45,19 @@ void DsgPrs_EqualRadiusPresentation::Add( const Handle( Prs3d_Presentation )& aP Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); - Graphic3d_Array1OfVertex VertexArray( 1, 2 ); - Quantity_Length X,Y,Z; - - // Radius lines - FirstCenter.Coord( X, Y, Z ); - VertexArray( 1 ).SetCoord( X, Y, Z ); - FirstPoint.Coord( X, Y, Z ); - VertexArray( 2 ).SetCoord( X, Y, Z ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); - - SecondCenter.Coord( X, Y, Z ); - VertexArray( 1 ).SetCoord( X, Y, Z ); - SecondPoint.Coord( X, Y, Z ); - VertexArray( 2 ).SetCoord( X, Y, Z ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); + aPrims->AddVertex(FirstPoint); + aPrims->AddVertex(FirstCenter); + aPrims->AddVertex(SecondCenter); + aPrims->AddVertex(SecondPoint); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // Add presentation of arrows gp_Dir FirstDir = gce_MakeDir( FirstCenter, FirstPoint ), SecondDir = gce_MakeDir( SecondCenter, SecondPoint ); - DsgPrs::ComputeSymbol( aPresentation, LA, - FirstCenter, FirstPoint, - FirstDir.Reversed(), FirstDir, - DsgPrs_AS_FIRSTPT_LASTAR ); - DsgPrs::ComputeSymbol( aPresentation, LA, - SecondCenter, SecondPoint, - SecondDir.Reversed(), SecondDir, - DsgPrs_AS_FIRSTPT_LASTAR ); + DsgPrs::ComputeSymbol( aPresentation, LA, FirstCenter, FirstPoint, FirstDir.Reversed(), FirstDir, DsgPrs_AS_FIRSTPT_LASTAR ); + DsgPrs::ComputeSymbol( aPresentation, LA, SecondCenter, SecondPoint, SecondDir.Reversed(), SecondDir, DsgPrs_AS_FIRSTPT_LASTAR ); - // Line between two centers - FirstCenter.Coord( X, Y, Z ); - VertexArray( 2 ).SetCoord( X, Y, Z ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); - //ota === beging === - gp_Pnt Middle( (FirstCenter.XYZ() + SecondCenter.XYZ()) *0.5 ), aTextPos; Standard_Real SmallDist; //Mark of constraint @@ -88,34 +65,33 @@ void DsgPrs_EqualRadiusPresentation::Add( const Handle( Prs3d_Presentation )& aP Standard_Real Dist = FirstCenter.Distance( SecondCenter ); if (Dist > Precision::Confusion()) - { - SmallDist = Dist * 0.05; // take 1/20 part of length; - if (SmallDist <= Precision::Confusion()) - SmallDist = Dist; - gp_Dir LineDir = gce_MakeDir( FirstCenter, SecondCenter ); - gp_Dir OrtDir = Plane->Pln().Axis().Direction() ^ LineDir; + { + SmallDist = Dist * 0.05; // take 1/20 part of length; + if (SmallDist <= Precision::Confusion()) + SmallDist = Dist; + gp_Dir LineDir = gce_MakeDir( FirstCenter, SecondCenter ); + gp_Dir OrtDir = Plane->Pln().Axis().Direction() ^ LineDir; - gp_Vec OrtVec = gp_Vec( OrtDir ) * SmallDist; + gp_Vec OrtVec = gp_Vec( OrtDir ) * SmallDist; - //Compute the text position - aTextPos = Middle.Translated(OrtVec); - } + //Compute the text position + aTextPos = Middle.Translated(OrtVec); + } else - { - Standard_Real Rad = Max(FirstCenter.Distance( FirstPoint ), - SecondCenter.Distance(SecondPoint)); + { + Standard_Real Rad = Max(FirstCenter.Distance( FirstPoint ), SecondCenter.Distance(SecondPoint)); - SmallDist = Rad *0.05; // take 1/20 part of length; - if (SmallDist <= Precision::Confusion()) - SmallDist = Rad; + SmallDist = Rad *0.05; // take 1/20 part of length; + if (SmallDist <= Precision::Confusion()) + SmallDist = Rad; - gp_Vec aVec(SmallDist, SmallDist, SmallDist); + gp_Vec aVec(SmallDist, SmallDist, SmallDist); - //Compute the text position - aTextPos = FirstCenter.Translated(aVec); - } + //Compute the text position + aTextPos = FirstCenter.Translated(aVec); + } //Draw the text - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText, aTextPos); + Prs3d_Text::Draw(aPresentation, LA->TextAspect(),aText, aTextPos); //ota === end === } diff --git a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx index 442f004855..d9ee636c30 100755 --- a/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FilletRadiusPresentation.cxx @@ -18,15 +18,14 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include -#include +#include +#include #include #include #include @@ -79,6 +78,7 @@ void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPr { char valcar[80]; sprintf(valcar,"%5.2f",theval); + Standard_Real FirstParCirc, LastParCirc; Standard_Boolean SpecCase; gp_Dir DirOfArrow; @@ -86,6 +86,7 @@ void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPr // gp_Pnt NewPosition, EndOfArrow; Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); + Standard_Real ArrowLength = LA->Arrow1Aspect()->Length(); DsgPrs::ComputeFilletRadiusPresentation( ArrowLength, theval, @@ -106,40 +107,34 @@ void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPr ); // Creating the fillet's arc if( !SpecCase ) - { - Standard_Real Alpha = Abs(LastParCirc - FirstParCirc); - Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); - Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); - Standard_Real delta = Alpha / ( NodeNumber - 1 ); - gp_Pnt CurPnt; - for (Standard_Integer i = 0 ; i < NodeNumber; i++) - { - CurPnt = ElCLib::Value( FirstParCirc, FilletCirc ); - ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - FirstParCirc += delta ; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); - HasCircle = Standard_True; - Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc ); - TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc ); - } + { + const Standard_Real Alpha = Abs(LastParCirc - FirstParCirc); + const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); + const Standard_Real delta = Alpha / ( NodeNumber - 1 ); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 0 ; i < NodeNumber; i++, FirstParCirc += delta) + aPrims->AddVertex(ElCLib::Value( FirstParCirc, FilletCirc )); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + HasCircle = Standard_True; + Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc ); + TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc ); + } else // null or PI anle or Radius = 0 - { - HasCircle = Standard_False; - } + { + HasCircle = Standard_False; + } // Line from position to intersection point on fillet's circle (EndOfArrow) - Graphic3d_Array1OfVertex Vrap(1,2); - Vrap(1).SetCoord(DrawPosition.X(), - DrawPosition.Y(), - DrawPosition.Z()); - Vrap(2).SetCoord( EndOfArrow.X(), EndOfArrow.Y(), EndOfArrow.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(DrawPosition); + aPrims->AddVertex(EndOfArrow); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + // Drawing the text Prs3d_Text::Draw(aPresentation, LA->TextAspect(), aText, DrawPosition); // Add presentation of arrows DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs ); - } - diff --git a/src/DsgPrs/DsgPrs_FixPresentation.cxx b/src/DsgPrs/DsgPrs_FixPresentation.cxx index 773a1e82ec..f14dd1e12a 100755 --- a/src/DsgPrs/DsgPrs_FixPresentation.cxx +++ b/src/DsgPrs/DsgPrs_FixPresentation.cxx @@ -18,11 +18,9 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include -#include +#include #include #include #include @@ -44,8 +42,6 @@ #include - - //======================================================================= //function : Add //purpose : @@ -62,57 +58,52 @@ void DsgPrs_FixPresentation::Add( Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(10); + //Trace du segment de raccordement - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z()); - V(2).SetCoord(aPntEnd.X(), aPntEnd.Y(), aPntEnd.Z() ); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(aPntAttach); + aPrims->AddVertex(aPntEnd); // trace du symbole 'Fix' - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - - - gp_Vec dirac(aPntAttach, aPntEnd); - // vecteur directeur du seg. de raccord + gp_Vec dirac(aPntAttach, aPntEnd); // vecteur directeur du seg. de raccord dirac.Normalize(); gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln)); gp_Ax1 ax(aPntEnd, aNormPln); - norac.Rotate(ax, M_PI/8); - // vecteur normal au seg. de raccord + norac.Rotate(ax, M_PI/8); // vecteur normal au seg. de raccord norac*=(symbsize/2); gp_Pnt P1 = aPntEnd.Translated(norac); gp_Pnt P2 = aPntEnd.Translated(-norac); - V(1).SetCoord(P1.X(),P1.Y(),P1.Z()); - V(2).SetCoord(P2.X(),P2.Y(),P2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(P1); + aPrims->AddVertex(P2); // trace des 'dents' norac*=0.8; P1 = aPntEnd.Translated(norac); P2 = aPntEnd.Translated(-norac); dirac*=(symbsize/2); - gp_Pnt PF(P1.XYZ()); + gp_Pnt PF = P1; gp_Pnt PL = PF.Translated(dirac); PL.Translate(norac); - V(1).SetCoord( PF.X(), PF.Y(), PF.Z() ); - V(2).SetCoord( PL.X(), PL.Y(), PL.Z() ); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - PF.SetXYZ(P2.XYZ()); + aPrims->AddVertex(PF); + aPrims->AddVertex(PL); + + PF = P2; PL = PF.Translated(dirac); PL.Translate(norac); - V(1).SetCoord( PF.X(), PF.Y(), PF.Z() ); - V(2).SetCoord( PL.X(), PL.Y(), PL.Z() ); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - PF.SetXYZ((P1.XYZ() + P2.XYZ())/2); + aPrims->AddVertex(PF); + aPrims->AddVertex(PL); + + PF.SetXYZ(0.5*(P1.XYZ() + P2.XYZ())); PL = PF.Translated(dirac); PL.Translate(norac); - V(1).SetCoord( PF.X(), PF.Y(), PF.Z() ); - V(2).SetCoord( PL.X(), PL.Y(), PL.Z() ); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + aPrims->AddVertex(PF); + aPrims->AddVertex(PL); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // On ajoute un rond au point d'attache Prs3d_Root::NewGroup(aPresentation); @@ -128,5 +119,4 @@ void DsgPrs_FixPresentation::Add( Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp); Graphic3d_Vertex V3d(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z()); Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d); - } diff --git a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx index 6eccd7c156..390d867435 100755 --- a/src/DsgPrs/DsgPrs_IdenticPresentation.cxx +++ b/src/DsgPrs/DsgPrs_IdenticPresentation.cxx @@ -23,7 +23,8 @@ #include #include -#include +#include +#include #include #include @@ -50,12 +51,10 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z()); - V(2).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z()); - - // trait de cote - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPntAttach); + aPrims->AddVertex(aPntOffset); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // On ajoute un rond au point d'attache Prs3d_Root::NewGroup(aPresentation); @@ -77,7 +76,6 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent } - void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const TCollection_ExtendedString& aText, @@ -88,33 +86,32 @@ void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresent Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V(1,2); - V(1).SetCoord(aFAttach.X(), aFAttach.Y(), aFAttach.Z()); - V(2).SetCoord(aSAttach.X(), aSAttach.Y(), aSAttach.Z()); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(4); - // trait de cote - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(aFAttach); + aPrims->AddVertex(aSAttach); // trait joignant aPntOffset - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Vec v1(aFAttach, aSAttach); gp_Vec v2(aSAttach, aPntOffset); - V(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z()); - if ( !v1.IsParallel(v2, Precision::Angular())) { + + aPrims->AddVertex(aPntOffset); + if ( !v1.IsParallel(v2, Precision::Angular())) + { // on joint aPntOffset a son projete gp_Lin ll(aFAttach, gp_Dir(v1)); - gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(ll,aPntOffset ), ll); - V(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z()); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(ll,aPntOffset ), ll)); } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + else + aPrims->AddVertex(aSAttach); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset); } - void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Drawer)& aDrawer, const TCollection_ExtendedString& aText, @@ -134,32 +131,29 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach); Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach); Standard_Real alpha = pSAttach - pFAttach; - if ( alpha < 0 ) alpha += 2 * M_PI; - Standard_Integer nb = (Standard_Integer )( 50. * alpha / M_PI); - Standard_Integer nbp = Max (4 , nb); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) - { - ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } + if ( alpha < 0 ) alpha += 2. * M_PI; + const Standard_Integer nb = (Standard_Integer )( 50. * alpha / M_PI); + const Standard_Integer nbp = Max (4, nb); + const Standard_Real dteta = alpha/(nbp-1); - // trait de cote - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPolylines) aPrims; // trait joignant aPntOffset - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V2(1,2); - if ( Abs((aPntOffset.Distance(aCenter) - rad )) >= Precision::Confusion() ) { - gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(CC,aPntOffset ), CC); - - V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z()); - V2(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); + if ( Abs((aPntOffset.Distance(aCenter) - rad )) >= Precision::Confusion() ) + { + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(2); + aPrims->AddVertex(aPntOffset); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(CC,aPntOffset ), CC)); + aPrims->AddBound(nbp); } + else + aPrims = new Graphic3d_ArrayOfPolylines(nbp); + + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(pFAttach + dteta*(i-1),CC)); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset); @@ -183,34 +177,32 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta ax.SetLocation(aCenter); Standard_Real rad = aCenter.Distance(aFAttach); gp_Circ CC(ax,rad ); - Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach); - Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach); + Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach); + Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach); Standard_Real alpha = pSAttach - pFAttach; - if ( alpha < 0 ) alpha += 2 * M_PI; - Standard_Integer nb = (Standard_Integer )( 50. * alpha / M_PI); - Standard_Integer nbp = Max (4 , nb); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) - { - ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } + if ( alpha < 0 ) alpha += 2. * M_PI; + const Standard_Integer nb = (Standard_Integer)( 50. * alpha / M_PI); + const Standard_Integer nbp = Max (4, nb); + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims; - // trait de cote - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - // trait joignant aPntOffset - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V2(1,2); if ( aPntOffset.Distance(aPntOnCirc) >= Precision::Confusion() ) - { - V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z()); - V2(2).SetCoord(aPntOnCirc.X(), aPntOnCirc.Y(), aPntOnCirc.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); - } + { + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(2); + aPrims->AddVertex(aPntOffset); + aPrims->AddVertex(aPntOnCirc); + aPrims->AddBound(nbp); + } + else + aPrims = new Graphic3d_ArrayOfPolylines(nbp); + + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(pFAttach + dteta*(i-1),CC)); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset); @@ -233,32 +225,29 @@ void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta Standard_Real pFAttach = ElCLib::Parameter(anEllipse, aFAttach); Standard_Real pSAttach = ElCLib::Parameter(anEllipse, aSAttach); Standard_Real alpha = pSAttach - pFAttach; - if ( alpha < 0 ) alpha += 2 * M_PI; - Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); - Standard_Integer nbp = Max (4 , nb); - Graphic3d_Array1OfVertex V(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i<=nbp; i++) - { - ptcur = ElCLib::Value(pFAttach + dteta*(i-1),anEllipse); - V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } + if ( alpha < 0 ) alpha += 2. * M_PI; + const Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); + const Standard_Integer nbp = Max (4, nb); + const Standard_Real dteta = alpha/(nbp-1); - // trait de cote - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPolylines) aPrims; // trait joignant aPntOffset - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V2(1,2); - if ( ! aPntOnElli.IsEqual(aPntOffset, Precision::Confusion()) ) - { - V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z()); - V2(2).SetCoord(aPntOnElli.X(), aPntOnElli.Y(), aPntOnElli.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); - } + { + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(2); + aPrims->AddVertex(aPntOffset); + aPrims->AddVertex(aPntOnElli); + aPrims->AddBound(nbp); + } + else + aPrims = new Graphic3d_ArrayOfPolylines(nbp); + + for (Standard_Integer i = 1; i<=nbp; i++) + aPrims->AddVertex(ElCLib::Value(pFAttach + dteta*(i-1),anEllipse)); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset); diff --git a/src/DsgPrs/DsgPrs_LengthPresentation.cxx b/src/DsgPrs/DsgPrs_LengthPresentation.cxx index 1c702fdaa2..1151215429 100755 --- a/src/DsgPrs/DsgPrs_LengthPresentation.cxx +++ b/src/DsgPrs/DsgPrs_LengthPresentation.cxx @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -53,17 +54,12 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta { Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Lin L1 (AttachmentPoint1,aDirection); gp_Lin L2 (AttachmentPoint2,aDirection); gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1); gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2); - gp_Lin L3; - if (!Proj1.IsEqual(Proj2,Precision::Confusion())) { - L3 = gce_MakeLin(Proj1,Proj2); - } - else { - L3 = gp_Lin(Proj1,aDirection); - } + gp_Lin L3 = Proj1.IsEqual(Proj2,Precision::Confusion())? gp_Lin(Proj1,aDirection) : gce_MakeLin(Proj1,Proj2); Standard_Real parmin,parmax,parcur; parmin = ElCLib::Parameter(L3,Proj1); parmax = parmin; @@ -87,67 +83,43 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // face processing : 1st group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) { + if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; - } - gp_Dir arrdir = L3.Direction().Reversed(); - if (outside) { + gp_Dir arrdir = L3.Direction().Reversed(); + if (outside) arrdir.Reverse(); - } + // arrow 1 : 2nd group - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, LA->Arrow1Aspect()->Angle(), LA->Arrow1Aspect()->Length()); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // arrow 2 : 3rd group - Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(), LA->Arrow2Aspect()->Angle(), LA->Arrow2Aspect()->Length()); Prs3d_Root::NewGroup(aPresentation); // text : 4th group Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp); - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - - Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + // processing of call 1 : 5th group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // processing of call 2 : 6th group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } //================================================================================== @@ -181,7 +153,6 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta EndOfArrow1, EndOfArrow2, DirOfArrow1 ); - Graphic3d_Array1OfVertex VertexArray( 1, 2 ); // Parameters for length's line gp_Lin LengthLine( OffsetPoint, DirOfArrow1 ); @@ -189,42 +160,37 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta Standard_Real Par2 = ElCLib::Parameter( LengthLine, EndOfArrow2 ); gp_Pnt FirstPoint, LastPoint; if (Par1 > 0.0 && Par2 > 0.0 || Par1 < 0.0 && Par2 < 0.0) - { - FirstPoint = OffsetPoint; - LastPoint = (Abs( Par1 ) > Abs( Par2 ))? EndOfArrow1 : EndOfArrow2; - } + { + FirstPoint = OffsetPoint; + LastPoint = (Abs( Par1 ) > Abs( Par2 ))? EndOfArrow1 : EndOfArrow2; + } else - { - FirstPoint = EndOfArrow1; - LastPoint = EndOfArrow2; - } + { + FirstPoint = EndOfArrow1; + LastPoint = EndOfArrow2; + } // Creating the length's line - VertexArray(1).SetCoord( FirstPoint.X(), FirstPoint.Y(), FirstPoint.Z() ); - VertexArray(2).SetCoord( LastPoint.X(), LastPoint.Y(), LastPoint.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + + aPrims->AddVertex(FirstPoint); + aPrims->AddVertex(LastPoint); // Add presentation of arrows - DsgPrs::ComputeSymbol( aPresentation, LA, - EndOfArrow1, EndOfArrow2, //EndOfArrow1, - DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs ); + DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow1, EndOfArrow2, DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs ); // Drawing the text Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint ); // Line from AttachmentPoint1 to end of Arrow1 - VertexArray(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - VertexArray(2).SetCoord( EndOfArrow1.X(), EndOfArrow1.Y(), EndOfArrow1.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(EndOfArrow1); // Line from AttachmentPoint2 to end of Arrow2 - VertexArray(1).SetCoord(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - VertexArray(2).SetCoord( EndOfArrow2.X(), EndOfArrow2.Y(), EndOfArrow2.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(EndOfArrow2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } @@ -249,13 +215,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta gp_Lin L2 (AttachmentPoint2,aDirection); gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1); gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2); - gp_Lin L3; - if (!Proj1.IsEqual(Proj2,Precision::Confusion())) { - L3 = gce_MakeLin(Proj1,Proj2); - } - else { - L3 = gp_Lin(Proj1,aDirection); - } + gp_Lin L3 = Proj1.IsEqual(Proj2,Precision::Confusion())? gp_Lin(Proj1,aDirection) : gce_MakeLin(Proj1,Proj2); Standard_Real parmin,parmax,parcur; parmin = ElCLib::Parameter(L3,Proj1); parmax = parmin; @@ -279,47 +239,29 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); + // processing of face + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); - // processing of face - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) { + if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; - } - gp_Dir arrdir = L3.Direction().Reversed(); - if (outside) { + gp_Dir arrdir = L3.Direction().Reversed(); + if (outside) arrdir.Reverse(); - } - - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - // processing of call 1 - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - // processing of call 2 - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - // text Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp); @@ -328,7 +270,6 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta } - //================================================================================== //function : Add //purpose : Adds presentation of length dimension between two curvilinear faces @@ -365,32 +306,29 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta FirstU, deltaU, FirstV, deltaV ); - Graphic3d_Array1OfVertex VertexArray( 1, 2 ); - gp_Lin LengthLine( OffsetPoint, DirOfArrow1 ); Standard_Real Par1 = ElCLib::Parameter( LengthLine, AttachmentPoint1 ); Standard_Real Par2 = ElCLib::Parameter( LengthLine, EndOfArrow2 ); gp_Pnt FirstPoint, LastPoint; if (Par1 > 0.0 && Par2 > 0.0 || Par1 < 0.0 && Par2 < 0.0) - { - FirstPoint = OffsetPoint; - LastPoint = (Abs( Par1 ) > Abs( Par2 ))? AttachmentPoint1 : EndOfArrow2; - } + { + FirstPoint = OffsetPoint; + LastPoint = (Abs( Par1 ) > Abs( Par2 ))? AttachmentPoint1 : EndOfArrow2; + } else - { - FirstPoint = AttachmentPoint1; - LastPoint = EndOfArrow2; - } + { + FirstPoint = AttachmentPoint1; + LastPoint = EndOfArrow2; + } // Creating the length's line - VertexArray(1).SetCoord( FirstPoint.X(), FirstPoint.Y(), FirstPoint.Z() ); - VertexArray(2).SetCoord( LastPoint.X(), LastPoint.Y(), LastPoint.Z() ); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(FirstPoint); + aPrims->AddVertex(LastPoint); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // Add presentation of arrows - DsgPrs::ComputeSymbol( aPresentation, LA, - AttachmentPoint1, EndOfArrow2, - DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs ); + DsgPrs::ComputeSymbol( aPresentation, LA, AttachmentPoint1, EndOfArrow2, DirOfArrow1, DirOfArrow1.Reversed(), ArrowPrs ); // Drawing the text Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, OffsetPoint ); @@ -401,41 +339,27 @@ void DsgPrs_LengthPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta Alpha = Abs( deltaU ); if (Alpha > Precision::Angular() && AlphaValue( FirstU ); - ApproxCurve(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - FirstU += delta; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxCurve ); - } + { + NodeNumber = Max( 4 , Standard_Integer (50. * Alpha / M_PI) ); + delta = deltaU / (Standard_Real)( NodeNumber - 1 ); + aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 1; i <= NodeNumber; i++, FirstU += delta) + aPrims->AddVertex(VCurve->Value( FirstU )); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } Alpha = Abs( deltaV ); if (Alpha > Precision::Angular() && AlphaValue( FirstV ); - ApproxCurve(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); - FirstV += delta; - } - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxCurve ); - } + { + NodeNumber = Max( 4 , Standard_Integer (50. * Alpha / M_PI) ); + delta = deltaV / (Standard_Real)( NodeNumber - 1 ); + aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber); + for (Standard_Integer i = 1; i <= NodeNumber; i++, FirstV += delta) + aPrims->AddVertex(UCurve->Value( FirstV )); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } - - - - //================================ // Function: // Purpose: Rob 26-mar-96 @@ -447,27 +371,25 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPrs, const gp_Pnt& Pt2, const DsgPrs_ArrowSide ArrowPrs) { - Prs3d_Root::CurrentGroup(aPrs)->BeginPrimitives(); - Graphic3d_Array1OfVertex Vx(1,2); - Vx(1).SetCoord(Pt1.X(),Pt1.Y(),Pt1.Z()); - Vx(2).SetCoord(Pt2.X(),Pt2.Y(),Pt2.Z()); - Prs3d_Root::CurrentGroup(aPrs)->Polyline(Vx); - + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Pt1); + aPrims->AddVertex(Pt2); + Prs3d_Root::CurrentGroup(aPrs)->AddPrimitiveArray(aPrims); + gp_Vec V ; - switch(ArrowPrs){ - case DsgPrs_AS_NONE: - break; - case DsgPrs_AS_LASTAR: + switch(ArrowPrs) + { + case DsgPrs_AS_LASTAR: Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(gp_Vec(Pt1,Pt2)), aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), aDrawer->LengthAspect()->Arrow1Aspect()->Length()); break; - case DsgPrs_AS_FIRSTAR: + case DsgPrs_AS_FIRSTAR: Prs3d_Arrow::Draw(aPrs,Pt1,gp_Dir(gp_Vec(Pt2,Pt1)), aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), aDrawer->LengthAspect()->Arrow1Aspect()->Length()); break; - case DsgPrs_AS_BOTHAR: + case DsgPrs_AS_BOTHAR: V = gp_Vec(Pt1,Pt2); Prs3d_Arrow::Draw(aPrs,Pt2,gp_Dir(V), aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), @@ -476,9 +398,7 @@ void DsgPrs_LengthPresentation::Add (const Handle(Prs3d_Presentation)& aPrs, aDrawer->LengthAspect()->Arrow1Aspect()->Angle(), aDrawer->LengthAspect()->Arrow1Aspect()->Length()); break; - default: + default: break; } - Prs3d_Root::CurrentGroup(aPrs)->EndPrimitives(); - } diff --git a/src/DsgPrs/DsgPrs_MidPointPresentation.cxx b/src/DsgPrs/DsgPrs_MidPointPresentation.cxx index 359a371723..352a62e5f1 100755 --- a/src/DsgPrs/DsgPrs_MidPointPresentation.cxx +++ b/src/DsgPrs/DsgPrs_MidPointPresentation.cxx @@ -17,7 +17,6 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - #include #include @@ -35,7 +34,8 @@ #include #include -#include +#include +#include #include #include @@ -58,61 +58,52 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen Standard_Real rad = AttachPoint.Distance(MidPoint)/20.0; Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Graphic3d_Array1OfVertex V(1,2); - - gp_Pnt Ptmp; gp_Ax2 ax = theAxe; ax.SetLocation(MidPoint); gp_Circ aCircleM (ax,rad); if ( first ) - { - // center of the symmetry - circle around the MidPoint - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Standard_Real alpha = 2 * M_PI; - Standard_Integer nbp = 100; - Graphic3d_Array1OfVertex VC(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(dteta*(i-1),aCircleM); - VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC); - - // segment from mid point to the text position - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - if ( Position.IsEqual(MidPoint,rad) ) - Ptmp = MidPoint; - else - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // text position - V(2).SetCoord(Position.X(),Position.Y(),Position.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // texte - TCollection_ExtendedString aText (" (+)"); - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); - } + { + // center of the symmetry - circle around the MidPoint + Prs3d_Root::NewGroup(aPresentation); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + + const Standard_Real alpha = 2. * M_PI; + const Standard_Integer nbp = 100; + const Standard_Real dteta = alpha/(nbp-1); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i <= nbp; i++) + aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM)); + + // segment from mid point to the text position + aPrims->AddBound(2); + aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point + aPrims->AddVertex(Position); // text position + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + // texte + TCollection_ExtendedString aText(" (+)"); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); + } if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) + { + if ( !first ) { - // segment from mid point to the geometry Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // attach point to the geometry - V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); } + + // segment from mid point to the geometry + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point + aPrims->AddVertex(AttachPoint); // attach point to the geometry + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } //=================================================================== @@ -133,68 +124,52 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Graphic3d_Array1OfVertex V(1,2); - - gp_Pnt Ptmp; gp_Ax2 ax = theAxe; ax.SetLocation(MidPoint); gp_Circ aCircleM (ax,rad); - if ( first ) - { - // center of the symmetry - circle around the MidPoint - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Standard_Real alpha = 2 * M_PI; - Standard_Integer nbp = 100; - Graphic3d_Array1OfVertex VC(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - gp_Pnt ptcur; - for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(dteta*(i-1),aCircleM); - VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC); - - // segment from mid point to the text position - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - if ( Position.IsEqual(MidPoint,rad) ) - Ptmp = MidPoint; - else - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // text position - V(2).SetCoord(Position.X(),Position.Y(),Position.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // texte - TCollection_ExtendedString aText (" (+)"); - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); - } - - if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) - { - // segment from mid point to the geometry - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // attach point to the geometry - V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - } - // segment on line Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - V(1).SetCoord(Point1.X(),Point1.Y(),Point1.Z()); - V(2).SetCoord(Point2.X(),Point2.Y(),Point2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Point1); + aPrims->AddVertex(Point2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + if ( first ) + { + // center of the symmetry - circle around the MidPoint + const Standard_Real alpha = 2. * M_PI; + const Standard_Integer nbp = 100; + const Standard_Real dteta = alpha/(nbp-1); + + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i <= nbp; i++) + aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM)); + + // segment from mid point to the text position + aPrims->AddBound(2); + aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point + aPrims->AddVertex(Position); // text position + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + // texte + TCollection_ExtendedString aText (" (+)"); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); + } + + if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) + { + // mid point + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); + aPrims->AddVertex(AttachPoint); // attach point to the geometry + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } //=================================================================== @@ -215,79 +190,60 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Graphic3d_Array1OfVertex V(1,2); - - gp_Pnt Ptmp,ptcur; gp_Ax2 ax = aCircle.Position(); ax.SetLocation(MidPoint); gp_Circ aCircleM (ax,rad); - if ( first ) - { - // center of the symmetry - circle around the MidPoint - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Standard_Real alpha = 2 * M_PI; - Standard_Integer nbp = 100; - Graphic3d_Array1OfVertex VC(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(dteta*(i-1),aCircleM); - VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC); - - // segment from mid point to the text position - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - if ( Position.IsEqual(MidPoint,rad) ) - Ptmp = MidPoint; - else - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // text position - V(2).SetCoord(Position.X(),Position.Y(),Position.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // texte - TCollection_ExtendedString aText (" (+)"); - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); - } - - if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) - { - // segment from mid point to the geometry - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // attach point to the geometry - V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - } - // segment on circle - Standard_Real pf = ElCLib::Parameter(aCircle,Point1); - Standard_Real pl = ElCLib::Parameter(aCircle,Point2); + Prs3d_Root::NewGroup(aPresentation); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + + const Standard_Real pf = ElCLib::Parameter(aCircle,Point1); + const Standard_Real pl = ElCLib::Parameter(aCircle,Point2); Standard_Real alpha = pl - pf; - if ( alpha < 0 ) alpha += 2 * M_PI; - Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); + if ( alpha < 0 ) alpha += 2. * M_PI; + const Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); Standard_Integer nbp = Max(4,nb); - Graphic3d_Array1OfVertex VC1(1,nbp); Standard_Real dteta = alpha/(nbp-1); + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(nbp); for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(pf + dteta*(i-1),aCircle); - VC1(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC1); + aPrims->AddVertex(ElCLib::Value(pf + dteta*(i-1),aCircle)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + if ( first ) + { + // center of the symmetry - circle around the MidPoint + alpha = 2. * M_PI; + nbp = 100; + dteta = alpha/(nbp-1); + + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i <= nbp; i++) + aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM)); + + // segment from mid point to the text position + aPrims->AddBound(2); + aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point + aPrims->AddVertex(Position); // text position + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + // texte + TCollection_ExtendedString aText (" (+)"); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); + } + + if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) + { + // segment from mid point to the geometry + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point + aPrims->AddVertex(AttachPoint); // attach point to the geometry + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } //=================================================================== @@ -308,7 +264,6 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen if ( rad <= Precision::Confusion() ) rad = Point1.Distance(Point2)/20.0; Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Graphic3d_Array1OfVertex V(1,2); gp_Pnt Ptmp,ptcur; @@ -316,69 +271,53 @@ void DsgPrs_MidPointPresentation::Add (const Handle(Prs3d_Presentation)& aPresen ax.SetLocation(MidPoint); gp_Circ aCircleM (ax,rad); - if ( first ) - { - // center of the symmetry - circle around the MidPoint - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Standard_Real alpha = 2 * M_PI; - Standard_Integer nbp = 100; - Graphic3d_Array1OfVertex VC(1,nbp); - Standard_Real dteta = alpha/(nbp-1); - for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(dteta*(i-1),aCircleM); - VC(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC); - - // segment from mid point to the text position - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - if ( Position.IsEqual(MidPoint,rad) ) - Ptmp = MidPoint; - else - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // text position - V(2).SetCoord(Position.X(),Position.Y(),Position.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // texte - TCollection_ExtendedString aText (" (+)"); - Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); - } - - if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) - { - // segment from mid point to the geometry - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - // mid point - Ptmp = ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM); - V(1).SetCoord(Ptmp.X(),Ptmp.Y(),Ptmp.Z()); - // attach point to the geometry - V(2).SetCoord(AttachPoint.X(),AttachPoint.Y(),AttachPoint.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - } - // segment on ellipse - Standard_Real pf = ElCLib::Parameter(aCircle,Point1); - Standard_Real pl = ElCLib::Parameter(aCircle,Point2); + Prs3d_Root::NewGroup(aPresentation); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + + const Standard_Real pf = ElCLib::Parameter(aCircle,Point1); + const Standard_Real pl = ElCLib::Parameter(aCircle,Point2); Standard_Real alpha = pl - pf; if ( alpha < 0 ) alpha += 2 * M_PI; - Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); + const Standard_Integer nb = (Standard_Integer)(50.0*alpha/M_PI); Standard_Integer nbp = Max(4,nb); - Graphic3d_Array1OfVertex VC1(1,nbp); Standard_Real dteta = alpha/(nbp-1); + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(nbp); for (Standard_Integer i = 1; i <= nbp; i++) - { - ptcur = ElCLib::Value(pf + dteta*(i-1),aCircle); - VC1(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z()); - } - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VC1); + aPrims->AddVertex(ElCLib::Value(pf + dteta*(i-1),aCircle)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + if ( first ) + { + // center of the symmetry - circle around the MidPoint + alpha = 2. * M_PI; + nbp = 100; + dteta = alpha/(nbp-1); + + aPrims = new Graphic3d_ArrayOfPolylines(nbp+2,2); + aPrims->AddBound(nbp); + for (Standard_Integer i = 1; i <= nbp; i++) + aPrims->AddVertex(ElCLib::Value(dteta*(i-1),aCircleM)); + + // segment from mid point to the text position + aPrims->AddBound(2); + aPrims->AddVertex(Position.IsEqual(MidPoint,rad)? MidPoint : ElCLib::Value(ElCLib::Parameter(aCircleM,Position),aCircleM)); // mid point + aPrims->AddVertex(Position); // text position + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + + // texte + TCollection_ExtendedString aText (" (+)"); + Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,Position); + } + + if ( !AttachPoint.IsEqual(MidPoint, Precision::Confusion()) ) + { + // segment from mid point to the geometry + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(ElCLib::Value(ElCLib::Parameter(aCircleM,AttachPoint),aCircleM)); // mid point + aPrims->AddVertex(AttachPoint); // attach point to the geometry + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } } diff --git a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx index 84a27a5c42..c126e9c116 100755 --- a/src/DsgPrs/DsgPrs_OffsetPresentation.cxx +++ b/src/DsgPrs/DsgPrs_OffsetPresentation.cxx @@ -18,7 +18,6 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - #include #include @@ -29,7 +28,7 @@ #include #include -#include +#include #include #include @@ -59,11 +58,11 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& AttachmentPoint2, const gp_Dir& aDirection, const gp_Dir& aDirection2, - const gp_Pnt& OffsetPoint) { - - + const gp_Pnt& OffsetPoint) +{ Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Lin L1 (AttachmentPoint1,aDirection); gp_Lin L2 (AttachmentPoint2,aDirection2); gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1); @@ -104,55 +103,34 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // trait de cote : 1er groupe - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); - if (DimNulle) { - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction(), - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Root::NewGroup(aPresentation); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction().Reversed(), - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - } else { - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) { + if (DimNulle) + { + Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,offp,L4.Direction().Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + } + else + { + if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; - } gp_Dir arrdir = L3.Direction().Reversed(); - - if (outside) { + if (outside) arrdir.Reverse(); - } + // fleche 1 : 2eme groupe - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - - + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); + Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // ball 1 : 3eme groupe - Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d(); MarkerAsp->SetType(Aspect_TOM_BALL); MarkerAsp->SetScale(0.8); @@ -171,26 +149,18 @@ void DsgPrs_OffsetPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp); } - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + // trait de rappel 1 : 5eme groupe - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // trait de rappel 2 : 6eme groupe - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPresentation, @@ -200,10 +170,8 @@ void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPres const gp_Pnt& AttachmentPoint2, const gp_Dir& aDirection, const gp_Dir& aDirection2, - const gp_Pnt& OffsetPoint) { - - - + const gp_Pnt& OffsetPoint) +{ gp_Lin L1 (AttachmentPoint1,aDirection); gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1); @@ -221,33 +189,26 @@ void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPres Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AxeAsp); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // trait d'axe : 1er groupe - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); Prs3d_Root::NewGroup(aPresentation); + Handle(Graphic3d_AspectLine3d) Axe2Asp = new Graphic3d_AspectLine3d (acolor, atype, awidth); Axe2Asp->SetType ( Aspect_TOL_DOTDASH); Axe2Asp->SetWidth ( 4.); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Axe2Asp); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // trait d'axe: 2eme groupe - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // anneau : 3eme et 4eme groupes - Graphic3d_Vertex V3d(Proj2.X() ,Proj2.Y(), Proj2.Z()); Prs3d_Root::NewGroup(aPresentation); @@ -267,5 +228,4 @@ void DsgPrs_OffsetPresentation::AddAxes (const Handle(Prs3d_Presentation)& aPres Marker2Asp->SetColor(acolor); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Marker2Asp); Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d); - } diff --git a/src/DsgPrs/DsgPrs_ParalPresentation.cxx b/src/DsgPrs/DsgPrs_ParalPresentation.cxx index 7f0c742936..d4258db6d5 100755 --- a/src/DsgPrs/DsgPrs_ParalPresentation.cxx +++ b/src/DsgPrs/DsgPrs_ParalPresentation.cxx @@ -18,15 +18,13 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include #include -#include +#include #include #include #include @@ -42,9 +40,8 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Pnt& AttachmentPoint1, const gp_Pnt& AttachmentPoint2, const gp_Dir& aDirection, - const gp_Pnt& OffsetPoint) { - - + const gp_Pnt& OffsetPoint) +{ Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Lin L1 (AttachmentPoint1,aDirection); @@ -75,67 +72,45 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // processing of side : 1st group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) { + if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; - } gp_Dir arrdir = L3.Direction().Reversed(); - - if (outside) { + if (outside) arrdir.Reverse(); - } + // arrow 1 : 2nd group - Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // arrow 2 : 3rd group - Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); Prs3d_Root::NewGroup(aPresentation); // text : 4th group Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp); - - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + // processing of call 1 : 5th group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); // processing of call 2 : 6th group - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } @@ -150,9 +125,8 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat const gp_Pnt& AttachmentPoint2, const gp_Dir& aDirection, const gp_Pnt& OffsetPoint, - const DsgPrs_ArrowSide ArrowPrs){ - - + const DsgPrs_ArrowSide ArrowPrs) +{ Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -184,53 +158,30 @@ void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentat gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - // processing of face - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) { + if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; - } gp_Dir arrdir = L3.Direction().Reversed(); - - if (outside) { + if (outside) arrdir.Reverse(); - } - - - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); // processing of call 1 - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + // processing of call 2 + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Proj2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - // processing of call 2 - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - // text Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp); //arrows DsgPrs::ComputeSymbol(aPresentation,LA,Proj1,Proj2,arrdir,arrdir.Reversed(),ArrowPrs); - - } - - diff --git a/src/DsgPrs/DsgPrs_PerpenPresentation.cxx b/src/DsgPrs/DsgPrs_PerpenPresentation.cxx index 122a02f39d..7275c1f293 100755 --- a/src/DsgPrs/DsgPrs_PerpenPresentation.cxx +++ b/src/DsgPrs/DsgPrs_PerpenPresentation.cxx @@ -38,7 +38,8 @@ #include #include #include -#include +#include +#include #include @@ -56,82 +57,49 @@ void DsgPrs_PerpenPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); // ou DOT ou DOTDASH Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V1(1,2); - Graphic3d_Array1OfVertex V2(1,2); - Quantity_Length X1,Y1,Z1; - Quantity_Length X2,Y2,Z2; - - // 1er segment - OffsetPoint.Coord(X1,Y1,Z1); - V1(1).SetCoord(X1,Y1,Z1); - pAx1.Coord(X2,Y2,Z2); - V1(2).SetCoord(X2,Y2,Z2); //ou directt dir1.XYZ - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V1); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - - // 2e segment - pAx2.Coord(X2,Y2,Z2); - V2(1).SetCoord(X1,Y1,Z1); - V2(2).SetCoord(X2,Y2,Z2); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + // segments + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines(6,2); - // points attache - Graphic3d_Array1OfVertex V3(1,2); - if (intOut1) { - pAx1.Coord(X1,Y1,Z1); - V3(1).SetCoord(X1,Y1,Z1); - pnt1.Coord(X2,Y2,Z2); - V3(2).SetCoord(X2,Y2,Z2); - LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3); - } - if (intOut2) { - pAx2.Coord(X1,Y1,Z1); - V3(1).SetCoord(X1,Y1,Z1); - pnt2.Coord(X2,Y2,Z2); - V3(2).SetCoord(X2,Y2,Z2); - LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)-> - SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V3); - } + aPrims->AddBound(3); + aPrims->AddVertex(OffsetPoint); + aPrims->AddVertex(pAx1); + aPrims->AddVertex(pAx2); // Symbol - Graphic3d_Array1OfVertex V4(1,3); gp_Vec vec1(gce_MakeDir(OffsetPoint,pAx1)); gp_Vec vec2(gce_MakeDir(OffsetPoint,pAx2)); - Standard_Real dist1(OffsetPoint.Distance(pAx1)); - Standard_Real dist2(OffsetPoint.Distance(pAx2)); - vec1 *= dist1; - vec1 *= .2; - vec2 *= dist2; - vec2 *= .2; + vec1 *= .2 * OffsetPoint.Distance(pAx1); + vec2 *= .2 * OffsetPoint.Distance(pAx2); gp_Pnt pAx11 = OffsetPoint.Translated(vec1); gp_Pnt pAx22 = OffsetPoint.Translated(vec2); gp_Pnt p_symb = pAx22.Translated(vec1); - pAx11.Coord(X1,Y1,Z1); - V4(1).SetCoord(X1,Y1,Z1); - p_symb.Coord(X1,Y1,Z1); - V4(2).SetCoord(X1,Y1,Z1); - pAx22.Coord(X1,Y1,Z1); - V4(3).SetCoord(X1,Y1,Z1); - - LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V4); - Prs3d_Root::NewGroup(aPresentation); -} - + aPrims->AddBound(3); + aPrims->AddVertex(pAx11); + aPrims->AddVertex(p_symb); + aPrims->AddVertex(pAx22); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + // points attache + if (intOut1 || intOut2) + { + LA->LineAspect()->SetTypeOfLine(Aspect_TOL_DOT); // ou DOT ou DOTDASH + Prs3d_Root::NewGroup(aPresentation); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + if (intOut1) { + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(pAx1); + aPrims->AddVertex(pnt1); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } + if (intOut2) { + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(pAx2); + aPrims->AddVertex(pnt2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } + } +} diff --git a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx index e2d129a8b8..736fa27a76 100755 --- a/src/DsgPrs/DsgPrs_RadiusPresentation.cxx +++ b/src/DsgPrs/DsgPrs_RadiusPresentation.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include @@ -48,13 +48,12 @@ static Standard_Boolean DsgPrs_InDomain(const Standard_Real fpar, - const Standard_Real lpar, - const Standard_Real para) + const Standard_Real lpar, + const Standard_Real para) { - if (fpar >= 0.) { + if (fpar >= 0.) return ((para >= fpar) && (para <= lpar)); - } - if (para >= (fpar+2*M_PI)) return Standard_True; + if (para >= (fpar+2.*M_PI)) return Standard_True; if (para <= lpar) return Standard_True; return Standard_False; } @@ -76,48 +75,36 @@ void DsgPrs_RadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta { Standard_Real fpara = firstparam; Standard_Real lpara = lastparam; - while (lpara > 2*M_PI) { - fpara -= 2*M_PI; - lpara -= 2*M_PI; + while (lpara > 2.*M_PI) { + fpara -= 2.*M_PI; + lpara -= 2.*M_PI; } Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Standard_Real parat = ElCLib::Parameter(aCircle,AttachmentPoint); gp_Pnt attpoint = AttachmentPoint; Standard_Boolean otherside = Standard_False; if ( !DsgPrs_InDomain(fpara,lpara,parat)) { Standard_Real otherpar = parat + M_PI; - if (otherpar > 2*M_PI) otherpar -= 2*M_PI; + if (otherpar > 2.*M_PI) otherpar -= 2.*M_PI; if (DsgPrs_InDomain(fpara,lpara,otherpar)) { parat = otherpar; otherside = Standard_True; } else { - Standard_Real ecartpar = Min(Abs(fpara-parat), - Abs(lpara-parat)); - Standard_Real ecartoth = Min(Abs(fpara-otherpar), - Abs(lpara-otherpar)); + const Standard_Real ecartpar = Min(Abs(fpara-parat),Abs(lpara-parat)); + const Standard_Real ecartoth = Min(Abs(fpara-otherpar),Abs(lpara-otherpar)); if (ecartpar <= ecartoth) { - if (parat < fpara) { - parat = fpara; - } - else { - parat = lpara; - } + parat = (parat < fpara)? fpara : lpara; } else { - otherside = Standard_True; - if (otherpar < fpara) { - parat = fpara; - } - else { - parat = lpara; - } + otherside = Standard_True; + parat = (otherpar < fpara)? fpara : lpara; } gp_Pnt ptdir = ElCLib::Value(parat,aCircle); - gp_Lin lsup(aCircle.Location(), - gp_Dir(ptdir.XYZ()-aCircle.Location().XYZ())); - Standard_Real parpos = ElCLib::Parameter(lsup,AttachmentPoint); + gp_Lin lsup(aCircle.Location(),gp_Dir(ptdir.XYZ()-aCircle.Location().XYZ())); + const Standard_Real parpos = ElCLib::Parameter(lsup,AttachmentPoint); attpoint = ElCLib::Value(parpos,lsup); } } @@ -126,40 +113,28 @@ void DsgPrs_RadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresenta gp_Pnt firstpoint = attpoint; gp_Pnt drawtopoint = ptoncirc; if (drawFromCenter && !otherside) { - Standard_Real uatt = ElCLib::Parameter(L,attpoint); - Standard_Real uptc = ElCLib::Parameter(L,ptoncirc); - if (Abs(uatt) > Abs(uptc)) { + const Standard_Real uatt = ElCLib::Parameter(L,attpoint); + const Standard_Real uptc = ElCLib::Parameter(L,ptoncirc); + if (Abs(uatt) > Abs(uptc)) drawtopoint = aCircle.Location(); - } - else { + else firstpoint = aCircle.Location(); - } } - Graphic3d_Array1OfVertex V(1,2); - - Quantity_Length X,Y,Z; - - firstpoint.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - drawtopoint.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(firstpoint); + aPrims->AddVertex(drawtopoint); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); gp_Dir arrdir = L.Direction(); - if (reverseArrow) { + if (reverseArrow) arrdir.Reverse(); - } + // fleche - Prs3d_Arrow::Draw(aPresentation,ptoncirc,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,ptoncirc,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); // texte Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,attpoint); - } //======================================================================= @@ -181,27 +156,19 @@ void DsgPrs_RadiusPresentation::Add( const Handle(Prs3d_Presentation)& aPresenta Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); - Graphic3d_Array1OfVertex VertexArray( 1, 2 ); - gp_Pnt LineOrigin, LineEnd; - Quantity_Length X,Y,Z; - - DsgPrs::ComputeRadiusLine( Center, EndOfArrow, AttachmentPoint, drawFromCenter, - LineOrigin, LineEnd); -// - LineOrigin.Coord( X, Y, Z ); - VertexArray(1).SetCoord( X, Y, Z ); + gp_Pnt LineOrigin, LineEnd; + DsgPrs::ComputeRadiusLine(Center, EndOfArrow, AttachmentPoint, drawFromCenter, LineOrigin, LineEnd); - LineEnd.Coord( X, Y, Z ); - VertexArray(2).SetCoord( X, Y, Z ); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(LineOrigin); + aPrims->AddVertex(LineEnd); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); - Prs3d_Root::CurrentGroup( aPresentation )->Polyline( VertexArray ); // text Prs3d_Text::Draw( aPresentation, LA->TextAspect(), aText, AttachmentPoint ); gp_Dir ArrowDir = gce_MakeDir( LineOrigin , LineEnd ); if (reverseArrow) ArrowDir.Reverse(); - DsgPrs::ComputeSymbol( aPresentation, LA, Center, EndOfArrow, ArrowDir.Reversed(), ArrowDir, - ArrowPrs, drawFromCenter ); + DsgPrs::ComputeSymbol( aPresentation, LA, Center, EndOfArrow, ArrowDir.Reversed(), ArrowDir, ArrowPrs, drawFromCenter ); } - diff --git a/src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx b/src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx index 404cbb571d..f4ba943833 100755 --- a/src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx +++ b/src/DsgPrs/DsgPrs_ShadedPlanePresentation.cxx @@ -18,15 +18,13 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include #include #include #include #include -#include +#include //======================================================================= @@ -43,18 +41,11 @@ void DsgPrs_ShadedPlanePresentation::Add(const Handle(Prs3d_Presentation)& aPres Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->PlaneAspect()->EdgesAspect()->Aspect()); TheGroup->SetPrimitivesAspect(aDrawer->ShadingAspect()->Aspect()); - Quantity_Length x1,y1,z1,x2,y2,z2,x3,y3,z3; - - aPt1.Coord(x1,y1,z1); - aPt2.Coord(x2,y2,z2); - aPt3.Coord(x3,y3,z3); - - Graphic3d_Array1OfVertex A(1,5); - A(1).SetCoord(x1,y1,z1); - A(2).SetCoord(x2,y2,z2); - A(3).SetCoord(x3,y3,z3); - A(4).SetCoord(x1,y1,z1); - A(5)=A(1); - - TheGroup->Polygon(A); + + Handle(Graphic3d_ArrayOfPolygons) aPrims = new Graphic3d_ArrayOfPolygons(4); + aPrims->AddVertex(aPt1); + aPrims->AddVertex(aPt2); + aPrims->AddVertex(aPt3); + aPrims->AddVertex(aPt1); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } diff --git a/src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx b/src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx index 171a6dab74..16e8637344 100755 --- a/src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx +++ b/src/DsgPrs/DsgPrs_ShapeDirPresentation.cxx @@ -18,8 +18,6 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include @@ -42,14 +40,12 @@ #include #include #include -//#include #include #include #include #include -#include -#include +#include #include #include @@ -57,7 +53,6 @@ #include - //======================================================================= //function : FindPointOnFace //purpose : internal use @@ -157,15 +152,9 @@ static Standard_Boolean ComputeDir(const TopoDS_Shape& shape, gp_Pnt& pt, gp_Dir Handle(Geom_Curve) curve = Handle(Geom_Curve)::DownCast(curv0->Copy()); curve->Transform(loc.Transformation()); GeomLProp_CLProps lProps(curve, 1, gp::Resolution()); - if (mode == 0) { - lProps.SetParameter(last); - } - else if (mode == 1) { - lProps.SetParameter(first); - } - if (!lProps.IsTangentDefined()) { + lProps.SetParameter((mode == 0)? last : first); + if (!lProps.IsTangentDefined()) return Standard_False; - } pt = lProps.Value(); lProps.Tangent(dir); } @@ -178,16 +167,13 @@ static Standard_Boolean ComputeDir(const TopoDS_Shape& shape, gp_Pnt& pt, gp_Dir pt2d.SetCoord((u1+u2)*0.5, (v1+v2)*0.5); } else { - Standard_Boolean found = FindPointOnFace(TopoDS::Face(shape), pt2d); - if (!found) { - return Standard_False; - } + if (!FindPointOnFace(TopoDS::Face(shape), pt2d)) + return Standard_False; } GeomLProp_SLProps lProps(surface, pt2d.X(), pt2d.Y(), 1, gp::Resolution()); - if (!lProps.IsNormalDefined()) { + if (!lProps.IsNormalDefined()) return Standard_False; - } pt = lProps.Value(); dir = lProps.Normal(); @@ -211,9 +197,8 @@ void DsgPrs_ShapeDirPresentation::Add(const Handle(Prs3d_Presentation)& prs, const Standard_Integer mode) { - if ((mode != 0) && (mode != 1)) { + if ((mode != 0) && (mode != 1)) return; - } gp_Dir dir; gp_Pnt pt; @@ -234,9 +219,8 @@ void DsgPrs_ShapeDirPresentation::Add(const Handle(Prs3d_Presentation)& prs, for (anExp.Init(TopoDS::Wire(shape)); anExp.More(); anExp.Next()) { const TopoDS_Edge& edge = anExp.Current(); nb++; - if (nb <=3) { - BRepBndLib::Add(edge, box); - } + if (nb <=3) + BRepBndLib::Add(edge, box); aList.Append(edge); } @@ -273,15 +257,14 @@ void DsgPrs_ShapeDirPresentation::Add(const Handle(Prs3d_Presentation)& prs, // mei 19/09/96 extrusion infinie -> taille fixe if (leng >= 20000.) leng = 50; - gp_Pnt pt2(pt.X()+leng*dir.X(), pt.Y()+leng*dir.Y(), pt.Z()+leng*dir.Z()); - Graphic3d_Array1OfVertex line(1,2); - line(1).SetCoord(pt.X(), pt.Y(), pt.Z()); - line(2).SetCoord(pt2.X(), pt2.Y(), pt2.Z()); - + gp_Pnt pt2(pt.XYZ()+leng*dir.XYZ()); + Prs3d_Root::CurrentGroup(prs)->SetPrimitivesAspect(drawer->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(prs)->Polyline(line); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(pt); + aPrims->AddVertex(pt2); + Prs3d_Root::CurrentGroup(prs)->AddPrimitiveArray(aPrims); Prs3d_Arrow::Draw(prs, pt2, dir, M_PI/180.*10., leng*0.3); } - - diff --git a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx index ee47926b71..8da9410fe7 100755 --- a/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx +++ b/src/DsgPrs/DsgPrs_SymmetricPresentation.cxx @@ -18,8 +18,6 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include @@ -42,7 +40,8 @@ #include #include -#include +#include +#include #include #include #include @@ -74,11 +73,11 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese const gp_Pnt& OffsetPoint) { Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis); gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis); gp_Dir aDirectionAxis = aAxis.Direction(); -// gp_Lin L1 (AttachmentPoint1,aDirection1); Standard_Real h = fabs(ProjOffsetPoint.Distance(PjAttachPnt1)/cos(aDirectionAxis.Angle(aDirection1))); gp_Vec VL1(aDirection1); @@ -132,19 +131,12 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - Graphic3d_Array1OfVertex Vc(1,3); - Quantity_Length X,Y,Z; - Standard_Real D1,coeff; - coeff = .5; - D1 = aAxis.Distance(AttachmentPoint1); - gp_Pnt pint,Pj_P1,P1Previous; - P1Previous.SetX(P1.X()); - P1Previous.SetY(P1.Y()); - P1Previous.SetZ(P1.Z()); + Quantity_Length X,Y,Z; + Standard_Real D1(aAxis.Distance(AttachmentPoint1)),coeff(.5); + gp_Pnt pint,Pj_P1,P1Previous = P1; -/*//======================================================= + //======================================================= // TO AVOID CROSSING // P1 -=- P2 P2 -=- P1 // \<-->/ |<-->| @@ -155,7 +147,6 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // Pattach2 /____\ Pattach1 Pattach2 /______\ Pattach1 // / NO \ / YES \ //======================================================= -*/ Standard_Boolean Cross = Standard_False; gp_Vec Attch1_PjAttch1(AttachmentPoint1,PjAttachPnt1); @@ -167,16 +158,15 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese P1 = P2; P2 = PntTempo; } -/* //=================================== + //=================================== // FRACTURES OF TRAITS OF CALL // / \ // / \ // | -=- | // |<------------->| //=================================== -*/ + gp_Vec Vfix; -// Standard_Real alpha,b,s,d; Standard_Real alpha,b; if(aAxis.Distance(P1) > D1*(1 + coeff) && !Cross){ @@ -184,13 +174,12 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese //==== PROCESSING OF FACE =========== Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis); gp_Vec Vp(Pj_P1,P1); Vfix = Vp.Divided(Vp.Magnitude()).Multiplied(D1*(1 + coeff)); - Pj_P1.Translated(Vfix).Coord(X,Y,Z); - P1.SetCoord(X,Y,Z); - Pj_P1.Translated(Vfix.Reversed()).Coord(X,Y,Z); - P2.SetCoord(X,Y,Z); + P1 = Pj_P1.Translated(Vfix); + P2 = Pj_P1.Translated(Vfix.Reversed()); //================================= // LISTING AT THE EXTERIOR @@ -220,49 +209,37 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese PointMin = ElCLib::Value(parmin,L3); PointMax = ElCLib::Value(parmax,L3); - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(8,3); + + aPrims->AddBound(2); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); //==== PROCESSING OF CALL 1 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint1.Coord(X,Y,Z); - Vc(1).SetCoord(X,Y,Z); - alpha = aDirectionAxis.Angle(aDirection1); b = (coeff*D1)/sin(alpha); gp_Vec Vpint(AttachmentPoint1,P1Previous); - AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)).Coord(X,Y,Z); - pint.SetCoord(X,Y,Z); - - pint.Coord(X,Y,Z); - Vc(2).SetCoord(X,Y,Z); - P1.Coord(X,Y,Z); - Vc(3).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc); - + pint = AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)); + + aPrims->AddBound(3); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(pint); + aPrims->AddVertex(P1); + //==== PROCESSING OF CALL 2 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint2.Coord(X,Y,Z); - Vc(1).SetCoord(X,Y,Z); gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis); gp_Vec V_int(pint, Pj_pint); - gp_Pnt Sym_pint; - Pj_pint.Translated(V_int).Coord(X,Y,Z); - Sym_pint.SetCoord(X,Y,Z); - - Sym_pint.Coord(X,Y,Z); - Vc(2).SetCoord(X,Y,Z); - P2.Coord(X,Y,Z); - Vc(3).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc); + gp_Pnt Sym_pint = Pj_pint.Translated(V_int); + + aPrims->AddBound(3); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Sym_pint); + aPrims->AddVertex(P2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } -/*//=================================== + //=================================== // FRACTURES OF PROCESSING OF CALL // -=- // |<--------->| @@ -270,12 +247,12 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // / \ // / \ //=================================== -*/ else if (aAxis.Distance(P1) < D1*(1 - coeff) || Cross) { //------ PROCESSING OF FACE ------------ Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis); gp_Vec VpInf(Pj_P1,P1); Vfix = VpInf.Divided(VpInf.Magnitude()).Multiplied(D1*(1 - coeff)); @@ -311,75 +288,55 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese PointMin = ElCLib::Value(parmin,L3); PointMax = ElCLib::Value(parmax,L3); - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(8,3); + + aPrims->AddBound(2); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); //==== PROCESSING OF CALL 1 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint1.Coord(X,Y,Z); - Vc(1).SetCoord(X,Y,Z); - alpha = aDirectionAxis.Angle(aDirection1); b = (coeff*D1)/sin(alpha); gp_Vec Vpint(AttachmentPoint1,P1Previous); - AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)).Coord(X,Y,Z); - pint.SetCoord(X,Y,Z); - - pint.Coord(X,Y,Z); - Vc(2).SetCoord(X,Y,Z); - P1.Coord(X,Y,Z); - Vc(3).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc); + pint = AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)); + + aPrims->AddBound(3); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(pint); + aPrims->AddVertex(P1); //==== PROCESSING OF CALL 2 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint2.Coord(X,Y,Z); - Vc(1).SetCoord(X,Y,Z); gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis); gp_Vec V_int(pint, Pj_pint); - gp_Pnt Sym_pint; - Pj_pint.Translated(V_int).Coord(X,Y,Z); - Sym_pint.SetCoord(X,Y,Z); - - Sym_pint.Coord(X,Y,Z); - Vc(2).SetCoord(X,Y,Z); - P2.Coord(X,Y,Z); - Vc(3).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc); + gp_Pnt Sym_pint = Pj_pint.Translated(V_int); + + aPrims->AddBound(3); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(Sym_pint); + aPrims->AddVertex(P2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } else { //==== PROCESSING OF FACE =========== Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); + //==== PROCESSING OF CALL 1 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - P1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(P1); //==== PROCESSING OF CALL 2 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - P2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(P2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } //==== ARROWS ================ @@ -390,14 +347,10 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); //------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -427,42 +380,35 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese else { pm = P1.Translated(Vvar.Multiplied(.5)); } - //pm = P1.Translated(Vvar.Multiplied(.5)); pOff = OffsetPoint.Translated(vecB); //Calculate the extremities of the symbol axis gp_Vec vecAxe = vecA.Multiplied(.7); - pOff.Translated(vecAxe).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(13,5); + + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vecAxe)); + aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); //Calculate the extremities of the superior segment of the symbol gp_Vec vec1 = vecAxe.Multiplied(.6); vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); gp_Vec vec2 = vecAxe.Multiplied(.4); - pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); //Calculate the extremities of the inferior segment of the symbol - pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - -/*//-------------------------------------------------------------------------------------- + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); + + //-------------------------------------------------------------------------------------- //| MARKING OF THE SYMMETRY AXIS | //-------------------------------------------------------------------------------------- // ____ @@ -470,42 +416,31 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // \/ // /\ // /__\ -*/ - Graphic3d_Array1OfVertex cursor(1,5); - Standard_Real Dist = (aAxis.Distance(AttachmentPoint1)+ - aAxis.Distance(AttachmentPoint2))/75; + Standard_Real Dist = (aAxis.Distance(AttachmentPoint1)+aAxis.Distance(AttachmentPoint2))/75; gp_Vec vs(aDirectionAxis); gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); - gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); + aPrims->AddBound(5); gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); - cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor); + aPrims->AddVertex(pm1); vsym.Multiply(4); - V(1).SetCoord(pm.Translated(vsym).X(), - pm.Translated(vsym).Y(), - pm.Translated(vsym).Z()); - V(2).SetCoord(pm.Translated(vsym.Reversed()).X(), - pm.Translated(vsym.Reversed()).Y(), - pm.Translated(vsym.Reversed()).Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddBound(2); + aPrims->AddVertex(pm.Translated(vsym)); + aPrims->AddVertex(pm.Translated(vsym.Reversed())); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } //=================================================================== @@ -522,6 +457,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese { Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Pnt OffsetPnt(OffsetPoint.X(),OffsetPoint.Y(),OffsetPoint.Z()); gp_Pnt Center1 = aCircle1.Location(); gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPnt),aAxis); @@ -529,7 +465,6 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Vec Vp(ProjCenter1,Center1); if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(aAxis.Direction())^aCircle1.Position().Direction(); - Standard_Real Dt,R,h; Dt = ProjCenter1.Distance(ProjOffsetPoint); R = aCircle1.Radius(); @@ -553,10 +488,6 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese if (parcur < parmin) parmin = parcur; if (parcur > parmax) parmax = parcur; parcur = ElCLib::Parameter(L3,OffsetPnt); -#ifdef DEB - gp_Pnt offp = -#endif - ElCLib::Value(parcur,L3); Standard_Boolean outside = Standard_False; if (parcur < parmin) { @@ -569,32 +500,23 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese } gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - + //==== PROCESSING OF FACE =========== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); //==== PROCESSING OF CALL 1 ===== Standard_Integer nbp = 10; - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Standard_Real ParamP1 = ElCLib::Parameter(aCircle1,P1); Standard_Real ParamPAttach1 = ElCLib::Parameter(aCircle1,AttachmentPoint1); -// gp_Vec Center1_PAttach1(Center1,AttachmentPoint1); -// gp_Vec Center1_P1(Center1,P1); Standard_Real alpha,Dalpha,alphaIter; alpha = fabs(ParamP1 - ParamPAttach1); if(ParamP1 < ParamPAttach1){ if(alpha > M_PI){ - alpha = (2*M_PI) - alpha; + alpha = (2.*M_PI) - alpha; nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); Dalpha = alpha/(nbp - 1); } @@ -605,7 +527,7 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese } else{ if(alpha > M_PI){ - alpha = (2*M_PI) - alpha; + alpha = (2.*M_PI) - alpha; nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); Dalpha = -alpha/(nbp - 1); } @@ -615,28 +537,17 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese } } - Graphic3d_Array1OfVertex Vc1(1,nbp); - AttachmentPoint1.Coord(X,Y,Z); - Vc1(1).SetCoord(X,Y,Z); + aPrims = new Graphic3d_ArrayOfPolylines(nbp); + aPrims->AddVertex(AttachmentPoint1); alphaIter = Dalpha; gp_Pnt PntIter; - Standard_Integer i ; - for( i = 2; i <= nbp; i++){ - PntIter = ElCLib::Value(ParamPAttach1 + alphaIter,aCircle1); - alphaIter = alphaIter + Dalpha; - PntIter.Coord(X,Y,Z); - Vc1(i).SetCoord(X,Y,Z); - - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc1); + Standard_Integer i; + for(i = 2; i <= nbp; i++, alphaIter += Dalpha) + aPrims->AddVertex(ElCLib::Value(ParamPAttach1 + alphaIter,aCircle1)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); //==== PROCESSING OF CALL 2 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); gp_Pnt Center2 = ProjCenter1.Translated(Vp.Reversed()); -// gp_Vec Center2_PAttach2(Center2,AttachmentPoint2); -// gp_Vec Center2_P2(Center2,P2); - gp_Dir DirC2 = aCircle1.Axis().Direction(); gp_Ax2 AxeC2(Center2,DirC2); gp_Circ aCircle2(AxeC2,aCircle1.Radius()); @@ -668,18 +579,13 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese } } - Graphic3d_Array1OfVertex Vc2(1,nbp); - AttachmentPoint2.Coord(X,Y,Z); - Vc2(1).SetCoord(X,Y,Z); + aPrims = new Graphic3d_ArrayOfPolylines(nbp); + aPrims->AddVertex(AttachmentPoint2); alphaIter = Dalpha; - for(i = 2; i <= nbp; i++){ - PntIter = ElCLib::Value(ParamPAttach2 + alphaIter,aCircle2); - alphaIter = alphaIter + Dalpha; - PntIter.Coord(X,Y,Z); - Vc2(i).SetCoord(X,Y,Z); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc2); - + for(i = 2; i <= nbp; i++, alphaIter += Dalpha) + aPrims->AddVertex(ElCLib::Value(ParamPAttach2 + alphaIter,aCircle2)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + //==== ARROWS ================ Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); @@ -688,14 +594,10 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); //------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -706,9 +608,8 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // ------- : Inferior Segment gp_Vec Vvar(P1,P2); - gp_Vec vec; gp_Vec Vtmp = Vvar.Divided(Vvar.Magnitude()).Multiplied(2*(aAxis.Distance(Center1))); - vec.SetCoord(Vtmp.X(),Vtmp.Y(),Vtmp.Z()); + gp_Vec vec = Vtmp; gp_Vec vecA = vec.Multiplied(.1); gp_Dir DirAxis = aAxis.Direction(); @@ -716,48 +617,36 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude()); vecB.Multiply(.5); - //gp_Vec vecB(-vec.Y(),vec.X(),vec.Z()); - //vecB.Multiply(.05); - gp_Pnt pm,pOff; - pm = P1.Translated(Vvar.Multiplied(.5)); - pOff = OffsetPnt.Translated(vecB); + gp_Pnt pm = P1.Translated(Vvar.Multiplied(.5)); + gp_Pnt pOff = OffsetPnt.Translated(vecB); //Calculation of extremas of the axis of the symbol gp_Vec vecAxe = vecA.Multiplied(.7); - pOff.Translated(vecAxe).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + aPrims = new Graphic3d_ArrayOfPolylines(13,5); + + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vecAxe)); + aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); //Calculation of extremas of the superior segment of the symbol gp_Vec vec1 = vecAxe.Multiplied(.6); - vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); - //vecAxe.SetCoord(-vecAxe.Y(),vecAxe.X(),vecAxe.Z()); - gp_Vec vec2 = vecAxe.Multiplied(.4); - pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); //Calculation of extremas of the inferior segment of the symbol - pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); -/*//-------------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------------- //| MARKING OF THE AXIS OF SYMMETRY | //-------------------------------------------------------------------------------------- // ____ @@ -765,44 +654,34 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // \/ // /\ // /__\ -*/ - Graphic3d_Array1OfVertex cursor(1,5); - //Standard_Real Dist = aCircle1.Radius()/37; Standard_Real Dist = aAxis.Distance(Center1)/37; gp_Dir aDirectionAxis = aAxis.Direction(); gp_Vec vs(aDirectionAxis); gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); - gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); + + aPrims->AddBound(5); gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); - cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor); + aPrims->AddVertex(pm1); vsym.Multiply(4); - V(1).SetCoord(pm.Translated(vsym).X(), - pm.Translated(vsym).Y(), - pm.Translated(vsym).Z()); - V(2).SetCoord(pm.Translated(vsym.Reversed()).X(), - pm.Translated(vsym.Reversed()).Y(), - pm.Translated(vsym.Reversed()).Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddBound(2); + aPrims->AddVertex(pm.Translated(vsym)); + aPrims->AddVertex(pm.Translated(vsym.Reversed())); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } - + //=================================================================== //Function:Add //Purpose: draws the representation of an axial symmetry between two vertex. @@ -817,7 +696,8 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (AttachmentPoint1.IsEqual(AttachmentPoint2,Precision::Confusion())){ + if (AttachmentPoint1.IsEqual(AttachmentPoint2,Precision::Confusion())) + { //============================================================== // SYMMETRY WHEN THE REFERENCE POINT IS ON THE AXIS OF SYM.: //============================================================== @@ -831,22 +711,17 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese LA->LineAspect()->Aspect()->Values(acolor, atype, awidth); MarkerAsp->SetColor(acolor); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp); - Graphic3d_Vertex V3d(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); + Graphic3d_Vertex V3d(AttachmentPoint1.X(),AttachmentPoint1.Y(),AttachmentPoint1.Z()); Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d); //Trace of the linking segment Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex Vrac(1,2); - Vrac(1).SetCoord(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Vrac(2).SetCoord(OffsetPoint.X(), - OffsetPoint.Y(), - OffsetPoint.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(8); + + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(OffsetPoint); //-------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -860,43 +735,39 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Vec uVAO = VAO.Divided(VAO.Magnitude()); gp_Pnt pDaxe = OffsetPoint.Translated(uVAO.Multiplied(3.)); gp_Pnt pFaxe = pDaxe.Translated(uVAO.Multiplied(12.)); - Vrac(1).SetCoord(pDaxe.X(),pDaxe.Y(),pDaxe.Z()); - Vrac(2).SetCoord(pFaxe.X(),pFaxe.Y(),pFaxe.Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac); + + aPrims->AddVertex(pDaxe); + aPrims->AddVertex(pFaxe); //Calculate extremas of the superior segment of the symbol gp_Vec nVAO (-uVAO.Y(),uVAO.X(),uVAO.Z()); gp_Pnt sgP11 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAO.Multiplied(2.))); gp_Pnt sgP12 = sgP11.Translated(uVAO.Multiplied(8.)); - Vrac(1).SetCoord(sgP11.X(),sgP11.Y(),sgP11.Z()); - Vrac(2).SetCoord(sgP12.X(),sgP12.Y(),sgP12.Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac); + + aPrims->AddVertex(sgP11); + aPrims->AddVertex(sgP12); //Calculate extremas of the inferior segment of the symbol gp_Vec nVAOr = nVAO.Reversed(); gp_Pnt sgP21 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAOr.Multiplied(2.))); gp_Pnt sgP22 = sgP21.Translated(uVAO.Multiplied(8.)); - Vrac(1).SetCoord(sgP21.X(),sgP21.Y(),sgP21.Z()); - Vrac(2).SetCoord(sgP22.X(),sgP22.Y(),sgP22.Z()); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac); + + aPrims->AddVertex(sgP21); + aPrims->AddVertex(sgP22); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } //============================================================== // OTHER CASES : //============================================================== - else{ + else { gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis); gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis); gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,AttachmentPoint1); gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1); gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed()); - + gp_Lin L3 = gce_MakeLin(P1,P2); Standard_Real parmin,parmax,parcur; parmin = ElCLib::Parameter(L3,P1); @@ -906,10 +777,6 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese if (parcur < parmin) parmin = parcur; if (parcur > parmax) parmax = parcur; parcur = ElCLib::Parameter(L3,OffsetPoint); -#ifdef DEB - gp_Pnt offp = -#endif - ElCLib::Value(parcur,L3); Standard_Boolean outside = Standard_False; if (parcur < parmin) { @@ -922,57 +789,41 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese } gp_Pnt PointMin = ElCLib::Value(parmin,L3); gp_Pnt PointMax = ElCLib::Value(parmax,L3); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - + //==== PROCESSING OF FACE =========== Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - PointMin.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - PointMax.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(6); + + aPrims->AddVertex(PointMin); + aPrims->AddVertex(PointMax); //==== PROCESSING OF CALL 1 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - P1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(P1); //==== PROCESSING OF CALL 2 ===== - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - P2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + aPrims->AddVertex(AttachmentPoint2); + aPrims->AddVertex(P2); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); //==== ARROWS ================ - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True; gp_Dir arrdir = L3.Direction().Reversed(); if (outside) arrdir.Reverse(); // arrow 1 ---- - Prs3d_Arrow::Draw(aPresentation,P1,arrdir, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P1,arrdir,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); // arrow 2 ---- - Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); //==== POINTS ================ //Marker of localization of attachment points: Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Handle(Graphic3d_AspectMarker3d) MarkerAspAtt = new Graphic3d_AspectMarker3d(); MarkerAspAtt->SetType(Aspect_TOM_BALL); MarkerAspAtt->SetScale(0.8); @@ -982,18 +833,14 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese LA->LineAspect()->Aspect()->Values(color, type, width); MarkerAspAtt->SetColor(color); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAspAtt); - Graphic3d_Vertex Vatt1(AttachmentPoint1.X(), - AttachmentPoint1.Y(), - AttachmentPoint1.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt1); + Graphic3d_Vertex Vatt1(AttachmentPoint1.X(),AttachmentPoint1.Y(),AttachmentPoint1.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt1); Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAspAtt); - Graphic3d_Vertex Vatt2(AttachmentPoint2.X(), - AttachmentPoint2.Y(), - AttachmentPoint2.Z()); - Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt2); + Graphic3d_Vertex Vatt2(AttachmentPoint2.X(),AttachmentPoint2.Y(),AttachmentPoint2.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt2); //------------------------------------------------------------------------------------- //| SYMBOL OF SYMMETRY | @@ -1011,49 +858,36 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude()); vecB.Multiply(.5); - //gp_Vec vecB(-vec.Y(),vec.X(),vec.Z()); - //vecB.Multiply(.05); - - gp_Pnt pm,pOff; - pm = P1.Translated(vec.Multiplied(.5)); - pOff = OffsetPoint.Translated(vecB); + gp_Pnt pm = P1.Translated(vec.Multiplied(.5)); + gp_Pnt pOff = OffsetPoint.Translated(vecB); //Calculate the extremas of the axis of the symbol gp_Vec vecAxe = vecA.Multiplied(.7); - pOff.Translated(vecAxe).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); + Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - + + aPrims = new Graphic3d_ArrayOfPolylines(13,5); + + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vecAxe)); + aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); + //Calculate the extremas of the superior segment of the symbol gp_Vec vec1 = vecAxe.Multiplied(.6); - vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); - - //vecAxe.SetCoord(-vecAxe.Y(),vecAxe.X(),vecAxe.Z()); gp_Vec vec2 = vecAxe.Multiplied(.4); - - pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); //Calculate the extremas of the inferior segment of the symbol - pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - -/* //-------------------------------------------------------------------------------------- + aPrims->AddBound(2); + aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); + aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); + + //-------------------------------------------------------------------------------------- //| MARKING OF THE AXIS OF SYMMETRY | //-------------------------------------------------------------------------------------- // ____ @@ -1061,49 +895,31 @@ void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPrese // \/ // /\ // /__\ -*/ - Graphic3d_Array1OfVertex cursor(1,5); Standard_Real Dist = P1.Distance(P2)/75; gp_Dir aDirectionAxis = aAxis.Direction(); gp_Vec vs(aDirectionAxis); gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); - gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); + + aPrims->AddBound(5); gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); - cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); - cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); + aPrims->AddVertex(pm1); pm1 = pm1.Translated(vsymper.Multiplied(2)); - cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z()); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor); - - vsym.Multiply(4); - V(1).SetCoord(pm.Translated(vsym).X(), - pm.Translated(vsym).Y(), - pm.Translated(vsym).Z()); - V(2).SetCoord(pm.Translated(vsym.Reversed()).X(), - pm.Translated(vsym.Reversed()).Y(), - pm.Translated(vsym.Reversed()).Z()); - - Prs3d_Root::NewGroup(aPresentation); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - } -} - - - - - - + aPrims->AddVertex(pm1); + vsym.Multiply(4); + aPrims->AddBound(2); + aPrims->AddVertex(pm.Translated(vsym)); + aPrims->AddVertex(pm.Translated(vsym.Reversed())); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + } +} diff --git a/src/DsgPrs/DsgPrs_TangentPresentation.cxx b/src/DsgPrs/DsgPrs_TangentPresentation.cxx index 074567b999..a0dbbae5fe 100755 --- a/src/DsgPrs/DsgPrs_TangentPresentation.cxx +++ b/src/DsgPrs/DsgPrs_TangentPresentation.cxx @@ -18,12 +18,10 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include #include -#include +#include #include #include #include @@ -57,27 +55,19 @@ void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresent // Array1OfVertex Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; - p1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - p2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(p1); + aPrims->AddVertex(p2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); // fleche 1 : Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,p1,aDirection, - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,p1,aDirection,LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); // fleche 2 Prs3d_Root::NewGroup(aPresentation); Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(), - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); + Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); } - - diff --git a/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx b/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx index ccbbccde6f..9372154565 100755 --- a/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx +++ b/src/DsgPrs/DsgPrs_XYZAxisPresentation.cxx @@ -18,15 +18,11 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - -#define OCC218 // SAV Enable to compute the triedhron color texts and arrows. - - #include #include #include #include -#include +#include //======================================================================= @@ -43,24 +39,18 @@ void DsgPrs_XYZAxisPresentation::Add( const gp_Pnt& aPfirst, const gp_Pnt& aPlast) { + Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation); + G->SetPrimitivesAspect(aLineAspect->Aspect()); - - Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation); - - Quantity_Length xo,yo,zo,x,y,z; - - aPfirst.Coord(xo,yo,zo); - aPlast.Coord(x,y,z); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPfirst); + aPrims->AddVertex(aPlast); + G->AddPrimitiveArray(aPrims); - Graphic3d_Array1OfVertex A(1,2); - A(1).SetCoord(xo,yo,zo); - A(2).SetCoord(x,y,z); - - G->SetPrimitivesAspect(aLineAspect->Aspect()); - G->Polyline(A); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,M_PI/180.*10.,aVal/10.); - Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.); + Prs3d_Arrow::Draw(aPresentation,aPlast,aDir,M_PI/180.*10.,aVal/10.); + Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); } @@ -74,23 +64,18 @@ void DsgPrs_XYZAxisPresentation::Add(const Handle(Prs3d_Presentation)& aPresenta const gp_Pnt& aPfirst, const gp_Pnt& aPlast) { -#ifdef OCC218 Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation); - - Quantity_Length xo,yo,zo,x,y,z; - - aPfirst.Coord(xo,yo,zo); - aPlast.Coord(x,y,z); - - Graphic3d_Array1OfVertex A(1,2); - A(1).SetCoord(xo,yo,zo); - A(2).SetCoord(x,y,z); - G->SetPrimitivesAspect(aLineAspect->Aspect()); - G->Polyline(A); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aPfirst); + aPrims->AddVertex(aPlast); + G->AddPrimitiveArray(aPrims); + G->SetPrimitivesAspect( anArrowAspect->Aspect() ); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),aDir,M_PI/180.*10.,aVal/10.); + Prs3d_Arrow::Draw(aPresentation,aPlast,aDir,M_PI/180.*10.,aVal/10.); + G->SetPrimitivesAspect(aTextAspect->Aspect()); - Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,A(2),1./81.); -#endif + Graphic3d_Vertex a2(aPlast.X(),aPlast.Y(),aPlast.Z()); + Prs3d_Root::CurrentGroup(aPresentation)->Text(aText,a2,1./81.); } diff --git a/src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx b/src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx index 18c44a04fa..1582ab92af 100755 --- a/src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx +++ b/src/DsgPrs/DsgPrs_XYZPlanePresentation.cxx @@ -18,13 +18,12 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - #include #include #include #include #include -#include +#include //======================================================================= @@ -39,23 +38,13 @@ void DsgPrs_XYZPlanePresentation::Add( const gp_Pnt& aPt2, const gp_Pnt& aPt3) { - - - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->PlaneAspect()->EdgesAspect()->Aspect()); - - Quantity_Length x1,y1,z1,x2,y2,z2,x3,y3,z3; - - aPt1.Coord(x1,y1,z1); - aPt2.Coord(x2,y2,z2); - aPt3.Coord(x3,y3,z3); - - Graphic3d_Array1OfVertex A(1,4); - A(1).SetCoord(x1,y1,z1); - A(2).SetCoord(x2,y2,z2); - A(3).SetCoord(x3,y3,z3); - A(4).SetCoord(x1,y1,z1); - - TheGroup->Polyline(A); - + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->PlaneAspect()->EdgesAspect()->Aspect()); + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); + aPrims->AddVertex(aPt1); + aPrims->AddVertex(aPt2); + aPrims->AddVertex(aPt3); + aPrims->AddVertex(aPt1); + TheGroup->AddPrimitiveArray(aPrims); } diff --git a/src/Graphic3d/FILES b/src/Graphic3d/FILES index 81fa3cee31..dc5212b0b1 100755 --- a/src/Graphic3d/FILES +++ b/src/Graphic3d/FILES @@ -31,8 +31,6 @@ Graphic3d_Group.pxx Graphic3d_Group_1.cxx Graphic3d_Group_2.cxx Graphic3d_Group_3.cxx -Graphic3d_Group_5.cxx -Graphic3d_Group_7.cxx Graphic3d_Group_8.cxx Graphic3d_Group_10.cxx Graphic3d_Structure.pxx @@ -54,3 +52,5 @@ Graphic3d_BufferType.hxx Graphic3d_Vec2.hxx Graphic3d_Vec3.hxx Graphic3d_Vec4.hxx +Graphic3d_Vertex.hxx +Graphic3d_Vertex.cxx diff --git a/src/Graphic3d/Graphic3d.cdl b/src/Graphic3d/Graphic3d.cdl index 645d2f27b2..3b98532cfd 100755 --- a/src/Graphic3d/Graphic3d.cdl +++ b/src/Graphic3d/Graphic3d.cdl @@ -69,6 +69,7 @@ uses TCollection, TColStd, + TColgp, OSD, Quantity, Aspect, @@ -502,26 +503,10 @@ is ---Purpose: 3d vector ---Category: Classes - class Vertex; + imported Vertex; ---Purpose: 3d vertex ---Category: Classes - class VertexN; - ---Purpose: 3d vertex with a normal vector - ---Category: Classes - - class VertexNT; - ---Purpose: 3d vertex with a normal vector and texture coordinate - ---Category: Classes - - class VertexC; - ---Purpose: 3d vertex with a colour - ---Category: Classes - - class VertexNC; - ---Purpose: 3d vertex with a normal and a colour - ---Category: Classes - --------------------- -- Category: Pointers --------------------- @@ -589,38 +574,6 @@ is Array2 from TCollection (Vertex from Graphic3d); ---Category: Instantiated classes - class Array1OfVertexC instantiates - Array1 from TCollection (VertexC from Graphic3d); - ---Category: Instantiated classes - - class Array2OfVertexC instantiates - Array2 from TCollection (VertexC from Graphic3d); - ---Category: Instantiated classes - - class Array1OfVertexN instantiates - Array1 from TCollection (VertexN from Graphic3d); - ---Category: Instantiated classes - - class Array2OfVertexN instantiates - Array2 from TCollection (VertexN from Graphic3d); - ---Category: Instantiated classes - - class Array1OfVertexNT instantiates - Array1 from TCollection (VertexNT from Graphic3d); - ---Category: Instantiated classes - - class Array2OfVertexNT instantiates - Array2 from TCollection (VertexNT from Graphic3d); - ---Category: Instantiated classes - - class Array1OfVertexNC instantiates - Array1 from TCollection (VertexNC from Graphic3d); - ---Category: Instantiated classes - - class Array2OfVertexNC instantiates - Array2 from TCollection (VertexNC from Graphic3d); - ---Category: Instantiated classes - class ListOfShortReal instantiates List from TCollection (ShortReal from Standard); ---Category: Instantiated classes diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cdl b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cdl index c8ef003eed..b5cc4c0aa8 100755 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cdl +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cdl @@ -85,16 +85,27 @@ is -- ------------------------------------------------------------------- AddVertex( me:mutable; - aVertice: Pnt from gp) + aVertice: Pnt from gp) returns Integer from Standard ---Level: Public ---Purpose: Adds a vertice in the array. -- returns the actual vertex number. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline + + AddVertex( me:mutable; + X,Y,Z: Real from Standard) + returns Integer from Standard + ---Level: Public + ---Purpose: Adds a vertice in the array. + -- returns the actual vertex number. + raises OutOfRange from Standard; + -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - X,Y,Z: Real from Standard) + X,Y,Z: ShortReal from Standard) returns Integer from Standard ---Level: Public ---Purpose: Adds a vertice in the array. @@ -102,9 +113,9 @@ is raises OutOfRange from Standard; -- if the actual vertex number is >= - AddVertex( me:mutable; - aVertice: Pnt from gp; - aColor: Color from Quantity) + AddVertex( me:mutable; + aVertice: Pnt from gp; + aColor: Color from Quantity) returns Integer from Standard ---Level: Public ---Purpose: Adds a vertice and vertex color in the vertex array. @@ -117,7 +128,7 @@ is AddVertex( me : mutable; aVertice : Pnt from gp; aColor : Integer from Standard) - returns Integer from Standard + returns Integer from Standard ---Level: Public ---Purpose: Adds a vertice and vertex color in the vertex array. -- returns the actual vertex number. @@ -129,37 +140,50 @@ is raises OutOfRange from Standard; -- if the actual vertex number is >= - AddVertex( me :mutable; - aVertice : Pnt from gp; - aNormal : Dir from gp) - returns Integer from Standard - ---Level: Public + aVertice : Pnt from gp; + aNormal : Dir from gp) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice and vertex normal in the vertex array. -- returns the actual vertex number. -- Warning: is ignored when the -- constructor parameter is FALSE. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - X,Y,Z: Real from Standard; - NX,NY,NZ: Real from Standard) - returns Integer from Standard - ---Level: Public + X,Y,Z: Real from Standard; + NX,NY,NZ: Real from Standard) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice and vertex normal in the vertex array. -- returns the actual vertex number. -- Warning: is ignored when the -- constructor parameter is FALSE. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - aVertice: Pnt from gp; - aNormal: Dir from gp; - aColor: Color from Quantity) - returns Integer from Standard - ---Level: Public + X,Y,Z: ShortReal from Standard; + NX,NY,NZ: ShortReal from Standard) + returns Integer from Standard + ---Level: Public + ---Purpose: Adds a vertice and vertex normal in the vertex array. + -- returns the actual vertex number. + -- Warning: is ignored when the + -- constructor parameter is FALSE. + raises OutOfRange from Standard; + -- if the actual vertex number is >= + + AddVertex( me:mutable; + aVertice: Pnt from gp; + aNormal: Dir from gp; + aColor: Color from Quantity) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice,vertex normal and color in the vertex array. -- returns the actual vertex number. -- Warning: is ignored when the @@ -173,7 +197,7 @@ is aVertice : Pnt from gp; aNormal : Dir from gp; aColor : Integer from Standard) - returns Integer from Standard + returns Integer from Standard ---Level: Public ---Purpose: Adds a vertice,vertex normal and color in the vertex array. -- returns the actual vertex number. @@ -186,38 +210,51 @@ is -- use this byte order. raises OutOfRange from Standard; -- if the actual vertex number is >= - AddVertex( me:mutable; - aVertice: Pnt from gp; - aTexel: Pnt2d from gp) - returns Integer from Standard - ---Level: Public + aVertice: Pnt from gp; + aTexel: Pnt2d from gp) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice and vertex texture in the vertex array. -- returns the actual vertex number. -- is ignored when the -- constructor parameter is FALSE. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - X,Y,Z: Real from Standard; - TX,TY: Real from Standard) - returns Integer from Standard - ---Level: Public + X,Y,Z: Real from Standard; + TX,TY: Real from Standard) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array. -- returns the actual vertex number. -- is ignored when the -- constructor parameter is FALSE. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - aVertice: Pnt from gp; - aNormal: Dir from gp; - aTexel: Pnt2d from gp) - returns Integer from Standard - ---Level: Public + X,Y,Z: ShortReal from Standard; + TX,TY: ShortReal from Standard) + returns Integer from Standard + ---Level: Public + ---Purpose: Adds a vertice and vertex texture coordinates in the vertex array. + -- returns the actual vertex number. + -- is ignored when the + -- constructor parameter is FALSE. + raises OutOfRange from Standard; + -- if the actual vertex number is >= + + AddVertex( me:mutable; + aVertice: Pnt from gp; + aNormal: Dir from gp; + aTexel: Pnt2d from gp) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice,vertex normal and texture in the vertex array. -- returns the actual vertex number. -- Warning: is ignored when the @@ -226,13 +263,30 @@ is -- constructor parameter is FALSE. raises OutOfRange from Standard; -- if the actual vertex number is >= + ---C++: inline AddVertex( me:mutable; - X,Y,Z: Real from Standard; - NX,NY,NZ: Real from Standard; - TX,TY: Real from Standard) - returns Integer from Standard - ---Level: Public + X,Y,Z: Real from Standard; + NX,NY,NZ: Real from Standard; + TX,TY: Real from Standard) + returns Integer from Standard + ---Level: Public + ---Purpose: Adds a vertice,vertex normal and texture in the vertex array. + -- returns the actual vertex number. + -- Warning: is ignored when the + -- constructor parameter is FALSE. + -- is ignored when the + -- constructor parameter is FALSE. + raises OutOfRange from Standard; + -- if the actual vertex number is >= + ---C++: inline + + AddVertex( me:mutable; + X,Y,Z: ShortReal from Standard; + NX,NY,NZ: ShortReal from Standard; + TX,TY: ShortReal from Standard) + returns Integer from Standard + ---Level: Public ---Purpose: Adds a vertice,vertex normal and texture in the vertex array. -- returns the actual vertex number. -- Warning: is ignored when the @@ -252,8 +306,8 @@ is -- if the actual Bound number is >= AddBound( me:mutable; - edgeNumber: Integer from Standard; - aBColor: Color from Quantity) + edgeNumber: Integer from Standard; + aBColor: Color from Quantity) returns Integer from Standard ---Level: Public ---Purpose: Adds a bound of length and bound color @@ -338,16 +392,16 @@ is -- or if the parameter is < 1 or > ItemNumber() SetVertice( me:mutable; - anIndex: Integer from Standard; - aVertice: Pnt from gp) + anIndex: Integer from Standard; + aVertice: Pnt from gp) ---Level: Public ---Purpose: Change the vertice of rank in the array. raises OutOfRange from Standard; -- if the index is <1 or > VertexNumber() SetVertice( me:mutable; - anIndex: Integer from Standard; - X,Y,Z: Real from Standard) + anIndex: Integer from Standard; + X,Y,Z: ShortReal from Standard) ---Level: Public ---Purpose: Change the vertice of rank in the array. raises OutOfRange from Standard; @@ -633,25 +687,6 @@ is -- Category Miscellaneous ------------------------------------------------------------------- - Enable( myclass ); - ---Level: Public - ---Purpose: Enable to use the arrays of primitives - -- Warning: Updates the current value of the environment symbol - -- CSF_USE_ARRAY_OF_PRIMITIVES - - Disable( myclass ); - ---Level: Public - ---Purpose: Disable to use the arrays of primitives - -- Warning: Updates the current value of the environment symbol - -- CSF_USE_ARRAY_OF_PRIMITIVES - - IsEnable( myclass ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns TRUE when the arrays are enable to use. - -- Warning: The initial value can be defined seting the symbol - -- CSF_USE_ARRAY_OF_PRIMITIVES to "Yes" or "No" - IsValid( me:mutable ) returns Boolean from Standard; ---Level: Public diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx index 28cb2bce0e..ef6a77426b 100755 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.cxx @@ -36,9 +36,10 @@ Graphic3d_ArrayOfPrimitives :: Graphic3d_ArrayOfPrimitives ( const Standard_Boolean hasVColors, const Standard_Boolean hasFColors, const Standard_Boolean hasVTexels, - const Standard_Boolean hasEdgeInfos -) : myMaxBounds(0),myMaxVertexs(0),myMaxEdges(0) { - Standard_Integer size = sizeof(CALL_DEF_PARRAY); + const Standard_Boolean hasEdgeInfos ) +: myMaxBounds(0),myMaxVertexs(0),myMaxEdges(0) +{ + const Standard_Integer size = sizeof(CALL_DEF_PARRAY); Standard_Integer format = MVERTICE; if( hasVNormals ) format |= MVNORMAL; if( hasVColors ) format |= MVCOLOR; @@ -98,7 +99,8 @@ Graphic3d_ArrayOfPrimitives :: Graphic3d_ArrayOfPrimitives ( myPrimitiveArray->num_edges = 0; } -void Graphic3d_ArrayOfPrimitives::Destroy ( ){ +void Graphic3d_ArrayOfPrimitives::Destroy () +{ if( myPrimitiveArray ) { if( myPrimitiveArray->vertices ){ Standard::Free( (Standard_Address&)myPrimitiveArray->vertices ); @@ -147,167 +149,86 @@ void Graphic3d_ArrayOfPrimitives::Destroy ( ){ } } -void Graphic3d_ArrayOfPrimitives::Enable() { - /// -} - -void Graphic3d_ArrayOfPrimitives::Disable() { - /// -} - -Standard_Boolean Graphic3d_ArrayOfPrimitives::IsEnable() { - return Standard_True; -} - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - return AddVertex(x,y,z); -} - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { - +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z) +{ if( !myPrimitiveArray ) return 0; - - Standard_Integer index = myPrimitiveArray->num_vertexs + 1; - if( index > myMaxVertexs ) { - Standard_OutOfRange::Raise(" TOO many VERTEX"); - } + const Standard_Integer index = myPrimitiveArray->num_vertexs + 1; SetVertice(index,X,Y,Z); return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, - const Quantity_Color& aColor) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Integer index = AddVertex(x,y,z); +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const Quantity_Color& aColor) +{ + const Standard_Integer index = AddVertex(aVertice); Standard_Real r,g,b; aColor.Values(r,g,b,Quantity_TOC_RGB); SetVertexColor(index,r,g,b); return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, - const Standard_Integer aColor) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Integer index = AddVertex(x,y,z); + +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const Standard_Integer aColor) +{ + const Standard_Integer index = AddVertex(aVertice); SetVertexColor(index,aColor); return index; } - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, - const gp_Dir& aNormal) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Real nx,ny,nz; - aNormal.Coord(nx,ny,nz); - return AddVertex(x,y,z,nx,ny,nz); -} - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const Standard_Real X, const Standard_Real Y, const Standard_Real Z, - const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ) { +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z, + const Standard_ShortReal NX, const Standard_ShortReal NY, const Standard_ShortReal NZ) +{ if( !myPrimitiveArray ) return 0; - - Standard_Integer index = myPrimitiveArray->num_vertexs + 1; - if( index > myMaxVertexs ) { - Standard_OutOfRange::Raise(" TOO many VERTEX"); - } + const Standard_Integer index = myPrimitiveArray->num_vertexs + 1; SetVertice(index,X,Y,Z); SetVertexNormal(index,NX,NY,NZ); return index; } - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal, - const Quantity_Color& aColor) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Real nx,ny,nz; - aNormal.Coord(nx,ny,nz); - Standard_Integer index = AddVertex(x,y,z,nx,ny,nz); + const Quantity_Color& aColor) +{ + const Standard_Integer index = AddVertex(aVertice,aNormal); Standard_Real r,g,b; aColor.Values(r,g,b,Quantity_TOC_RGB); SetVertexColor(index,r,g,b); return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, +Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal, - const Standard_Integer aColor) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Real nx,ny,nz; - aNormal.Coord(nx,ny,nz); - Standard_Integer index = AddVertex(x,y,z,nx,ny,nz); + const Standard_Integer aColor) +{ + const Standard_Integer index = AddVertex(aVertice,aNormal); SetVertexColor(index,aColor); return index; } Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, - const gp_Pnt2d& aTexel) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Real tx,ty; - aTexel.Coord(tx,ty); - return AddVertex(x,y,z,tx,ty); -} - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const Standard_Real X, const Standard_Real Y, const Standard_Real Z, - const Standard_Real TX, const Standard_Real TY) { + const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z, + const Standard_ShortReal TX, const Standard_ShortReal TY) +{ if( !myPrimitiveArray ) return 0; - - Standard_Integer index = myPrimitiveArray->num_vertexs + 1; - if( index > myMaxVertexs ) { - Standard_OutOfRange::Raise(" TOO many VERTEX"); - } + const Standard_Integer index = myPrimitiveArray->num_vertexs + 1; SetVertice(index,X,Y,Z); SetVertexTexel(index,TX,TY); return index; } Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const gp_Pnt& aVertice, - const gp_Dir& aNormal, - const gp_Pnt2d& aTexel) { - Standard_Real x,y,z; - aVertice.Coord(x,y,z); - Standard_Real nx,ny,nz; - aNormal.Coord(nx,ny,nz); - Standard_Real tx,ty; - aTexel.Coord(tx,ty); - return AddVertex(x,y,z,nx,ny,nz,tx,ty); -} - -Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( - const Standard_Real X, const Standard_Real Y, const Standard_Real Z, - const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ, - const Standard_Real TX, const Standard_Real TY) { + const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z, + const Standard_ShortReal NX, const Standard_ShortReal NY, const Standard_ShortReal NZ, + const Standard_ShortReal TX, const Standard_ShortReal TY) +{ if( !myPrimitiveArray ) return 0; - - Standard_Integer index = myPrimitiveArray->num_vertexs + 1; - if( index > myMaxVertexs ) { - Standard_OutOfRange::Raise(" TOO many VERTEX"); - } + const Standard_Integer index = myPrimitiveArray->num_vertexs + 1; SetVertice(index,X,Y,Z); SetVertexNormal(index,NX,NY,NZ); SetVertexTexel(index,TX,TY); return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( const Standard_Integer edgeNumber) { +Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( const Standard_Integer edgeNumber) +{ Standard_Integer index = 0; if( myPrimitiveArray && myPrimitiveArray->bounds ) { index = myPrimitiveArray->num_bounds; @@ -322,22 +243,20 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( const Standard_Integer e return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( - const Standard_Integer edgeNumber, - const Quantity_Color& aFColor -) { +Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( const Standard_Integer edgeNumber, + const Quantity_Color& aFColor) +{ Standard_Real r,g,b; aFColor.Values(r,g,b,Quantity_TOC_RGB); return AddBound(edgeNumber,r,g,b); } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( - const Standard_Integer edgeNumber, +Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( const Standard_Integer edgeNumber, const Standard_Real R, const Standard_Real G, - const Standard_Real B) { + const Standard_Real B) +{ if( !myPrimitiveArray ) return 0; - Standard_Integer index = myPrimitiveArray->num_bounds; if( index >= myMaxBounds ) { Standard_OutOfRange::Raise(" TOO many BOUND"); @@ -348,9 +267,9 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::AddBound( return index; } -Standard_Integer Graphic3d_ArrayOfPrimitives::AddEdge( - const Standard_Integer vertexIndex, - const Standard_Boolean isVisible) { +Standard_Integer Graphic3d_ArrayOfPrimitives::AddEdge(const Standard_Integer vertexIndex, + const Standard_Boolean isVisible) +{ if( !myPrimitiveArray ) return 0; Standard_Integer index = myPrimitiveArray->num_edges; @@ -371,15 +290,15 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::AddEdge( return index; } -Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate( - const gp_Dir& aNormal) { +Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate(const gp_Dir& aNormal) +{ return Orientate(1,Max(VertexNumber(),EdgeNumber()),aNormal); } -Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate( - const Standard_Integer aVertexIndex, +Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate(const Standard_Integer aVertexIndex, const Standard_Integer aVertexNumber, - const gp_Dir& aNormal) { + const gp_Dir& aNormal) +{ Standard_Boolean somethingHasChange = Standard_False; if( myPrimitiveArray && (myPrimitiveArray->num_vertexs > 2) ) { Standard_Integer i,j,k=aVertexNumber,n=aVertexIndex-1; @@ -495,9 +414,9 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate( return somethingHasChange; } -Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate( - const Standard_Integer aBoundIndex, - const gp_Dir& aNormal) { +Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate(const Standard_Integer aBoundIndex, + const gp_Dir& aNormal) +{ Standard_Boolean somethingHasChange = Standard_False; if( myPrimitiveArray && myPrimitiveArray->vertices ) { if( myPrimitiveArray->bounds && @@ -537,26 +456,25 @@ Standard_Boolean Graphic3d_ArrayOfPrimitives::Orientate( return somethingHasChange; } -void Graphic3d_ArrayOfPrimitives::SetVertice( - const Standard_Integer anIndex, - const gp_Pnt& aVertice) { +void Graphic3d_ArrayOfPrimitives::SetVertice( const Standard_Integer anIndex, + const gp_Pnt& aVertice) +{ Standard_Real x,y,z; aVertice.Coord(x,y,z); - SetVertice(anIndex,x,y,z); + SetVertice(anIndex,Standard_ShortReal(x),Standard_ShortReal(y),Standard_ShortReal(z)); } -void Graphic3d_ArrayOfPrimitives::SetVertexColor( - const Standard_Integer anIndex, - const Quantity_Color& aColor) { +void Graphic3d_ArrayOfPrimitives::SetVertexColor( const Standard_Integer anIndex, + const Quantity_Color& aColor) +{ Standard_Real r,g,b; aColor.Values(r,g,b,Quantity_TOC_RGB); SetVertexColor(anIndex,r,g,b); } -void Graphic3d_ArrayOfPrimitives::SetVertexColor( - const Standard_Integer anIndex, - const Standard_Integer aColor) { - +void Graphic3d_ArrayOfPrimitives::SetVertexColor( const Standard_Integer anIndex, + const Standard_Integer aColor) +{ if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myMaxVertexs ) { Standard_OutOfRange::Raise(" BAD VERTEX index"); @@ -580,31 +498,33 @@ void Graphic3d_ArrayOfPrimitives::SetVertexColor( } } -void Graphic3d_ArrayOfPrimitives::SetVertexNormal( - const Standard_Integer anIndex, - const gp_Dir& aNormal) { + +void Graphic3d_ArrayOfPrimitives::SetVertexNormal(const Standard_Integer anIndex, + const gp_Dir& aNormal) +{ Standard_Real x,y,z; aNormal.Coord(x,y,z); SetVertexNormal(anIndex,x,y,z); } -void Graphic3d_ArrayOfPrimitives::SetVertexTexel( - const Standard_Integer anIndex, - const gp_Pnt2d& aTexel) { +void Graphic3d_ArrayOfPrimitives::SetVertexTexel( const Standard_Integer anIndex, + const gp_Pnt2d& aTexel) +{ Standard_Real x,y; aTexel.Coord(x,y); SetVertexTexel(anIndex,x,y); } -void Graphic3d_ArrayOfPrimitives::SetBoundColor( - const Standard_Integer anIndex, - const Quantity_Color& aColor) { +void Graphic3d_ArrayOfPrimitives::SetBoundColor(const Standard_Integer anIndex, + const Quantity_Color& aColor) +{ Standard_Real r,g,b; aColor.Values(r,g,b,Quantity_TOC_RGB); SetBoundColor(anIndex,r,g,b); } -Standard_CString Graphic3d_ArrayOfPrimitives::StringType() const { +Standard_CString Graphic3d_ArrayOfPrimitives::StringType() const +{ TCollection_AsciiString name("UndefinedArray"); switch( myPrimitiveArray->type ) { case TelPointsArrayType: @@ -641,37 +561,43 @@ Standard_CString Graphic3d_ArrayOfPrimitives::StringType() const { return name.ToCString(); } -gp_Pnt Graphic3d_ArrayOfPrimitives::Vertice(const Standard_Integer aRank) const { +gp_Pnt Graphic3d_ArrayOfPrimitives::Vertice(const Standard_Integer aRank) const +{ Standard_Real x,y,z; Vertice(aRank,x,y,z); return gp_Pnt(x,y,z); } -Quantity_Color Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer aRank) const { +Quantity_Color Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer aRank) const +{ Standard_Real r,g,b; VertexColor(aRank,r,g,b); return Quantity_Color(r,g,b,Quantity_TOC_RGB); } -gp_Dir Graphic3d_ArrayOfPrimitives::VertexNormal(const Standard_Integer aRank) const { +gp_Dir Graphic3d_ArrayOfPrimitives::VertexNormal(const Standard_Integer aRank) const +{ Standard_Real x,y,z; VertexNormal(aRank,x,y,z); return gp_Dir(x,y,z); } -gp_Pnt2d Graphic3d_ArrayOfPrimitives::VertexTexel(const Standard_Integer aRank) const { +gp_Pnt2d Graphic3d_ArrayOfPrimitives::VertexTexel(const Standard_Integer aRank) const +{ Standard_Real x,y; VertexTexel(aRank,x,y); return gp_Pnt2d(x,y); } -Quantity_Color Graphic3d_ArrayOfPrimitives::BoundColor(const Standard_Integer aRank) const { +Quantity_Color Graphic3d_ArrayOfPrimitives::BoundColor(const Standard_Integer aRank) const +{ Standard_Real r,g,b; BoundColor(aRank,r,g,b); return Quantity_Color(r,g,b,Quantity_TOC_RGB); } -Standard_Integer Graphic3d_ArrayOfPrimitives::ItemNumber() const { +Standard_Integer Graphic3d_ArrayOfPrimitives::ItemNumber() const +{ Standard_Integer number=-1; if( myPrimitiveArray ) switch( myPrimitiveArray->type ) { case TelPointsArrayType: @@ -720,9 +646,9 @@ Standard_Integer Graphic3d_ArrayOfPrimitives::ItemNumber() const { return number; } -void Graphic3d_ArrayOfPrimitives::ComputeVNormals( - const Standard_Integer from, - const Standard_Integer to) { +void Graphic3d_ArrayOfPrimitives::ComputeVNormals(const Standard_Integer from, + const Standard_Integer to) +{ Standard_Integer next = from+1; Standard_Integer last = to+1; gp_Pnt p1,p2,p3; @@ -769,8 +695,8 @@ void Graphic3d_ArrayOfPrimitives::ComputeVNormals( } } -Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() { - +Standard_Boolean Graphic3d_ArrayOfPrimitives::IsValid() +{ if( !myPrimitiveArray ) return Standard_False; Standard_Integer nvertexs = myPrimitiveArray->num_vertexs; diff --git a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx index dba08d15d8..f7ba38a0ac 100755 --- a/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx +++ b/src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx @@ -23,84 +23,139 @@ #include #include -inline Graphic3d_PrimitiveArray Graphic3d_ArrayOfPrimitives::Array() const { +#include +#include +inline Graphic3d_PrimitiveArray Graphic3d_ArrayOfPrimitives::Array() const +{ return myPrimitiveArray; } -inline Graphic3d_TypeOfPrimitiveArray Graphic3d_ArrayOfPrimitives::Type() const { - +inline Graphic3d_TypeOfPrimitiveArray Graphic3d_ArrayOfPrimitives::Type() const +{ Graphic3d_TypeOfPrimitiveArray type = Graphic3d_TOPA_UNDEFINED; if( myPrimitiveArray ) type = (Graphic3d_TypeOfPrimitiveArray) myPrimitiveArray->type; return type; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexNormals() const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexNormals() const +{ Standard_Boolean defined = Standard_False; if( myPrimitiveArray && myPrimitiveArray->vnormals ) defined = Standard_True; return defined; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexColors() const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexColors() const +{ Standard_Boolean defined = Standard_False; if( myPrimitiveArray && myPrimitiveArray->vcolours ) defined = Standard_True; return defined; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexTexels() const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasVertexTexels() const +{ Standard_Boolean defined = Standard_False; if( myPrimitiveArray && myPrimitiveArray->vtexels ) defined = Standard_True; return defined; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasEdgeInfos() const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasEdgeInfos() const +{ Standard_Boolean defined = Standard_False; if( myPrimitiveArray && myPrimitiveArray->edge_vis ) defined = Standard_True; return defined; } -inline Standard_Integer Graphic3d_ArrayOfPrimitives::VertexNumber() const { +inline Standard_Integer Graphic3d_ArrayOfPrimitives::VertexNumber() const +{ Standard_Integer number = -1; if( myPrimitiveArray ) number = myPrimitiveArray->num_vertexs; return number; } +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice) +{ + return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z()); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( + const Standard_Real X, const Standard_Real Y, const Standard_Real Z) +{ + return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z)); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal) +{ + return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aNormal.X(),aNormal.Y(),aNormal.Z()); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( + const Standard_Real X, const Standard_Real Y, const Standard_Real Z, + const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ) +{ + return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z), + Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ)); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Pnt2d& aTexel) +{ + return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aTexel.X(),aTexel.Y()); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( + const Standard_Real X, const Standard_Real Y, const Standard_Real Z, + const Standard_Real TX, const Standard_Real TY) +{ + return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z), + Standard_ShortReal(TX),Standard_ShortReal(TY)); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex(const gp_Pnt& aVertice, const gp_Dir& aNormal, const gp_Pnt2d& aTexel) +{ + return AddVertex(aVertice.X(),aVertice.Y(),aVertice.Z(),aNormal.X(),aNormal.Y(),aNormal.Z(),aTexel.X(),aTexel.Y()); +} + +inline Standard_Integer Graphic3d_ArrayOfPrimitives::AddVertex( + const Standard_Real X, const Standard_Real Y, const Standard_Real Z, + const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ, + const Standard_Real TX, const Standard_Real TY) +{ + return AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z), + Standard_ShortReal(NX),Standard_ShortReal(NY),Standard_ShortReal(NZ), + Standard_ShortReal(TX),Standard_ShortReal(TY)); +} + inline void Graphic3d_ArrayOfPrimitives::SetVertice( const Standard_Integer anIndex, - const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { - + const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z) +{ if( !myPrimitiveArray ) return; - if( anIndex < 1 || anIndex > myMaxVertexs ) { + if( anIndex < 1 || anIndex > myMaxVertexs ) Standard_OutOfRange::Raise(" BAD VERTEX index"); - } - Standard_Integer index = anIndex-1; - { - if( myPrimitiveArray->vertices ) { - Tfloat *p = myPrimitiveArray->vertices[index].xyz; - *p++ = Standard_ShortReal(X); - *p++ = Standard_ShortReal(Y); - *p = Standard_ShortReal(Z); - } + if( myPrimitiveArray->vertices ) { + Tfloat *p = myPrimitiveArray->vertices[anIndex-1].xyz; + *p++ = X; + *p++ = Y; + *p = Z; } myPrimitiveArray->num_vertexs = Max(anIndex,myPrimitiveArray->num_vertexs); } - -inline void Graphic3d_ArrayOfPrimitives::SetVertexColor( - const Standard_Integer anIndex, +inline void Graphic3d_ArrayOfPrimitives::SetVertexColor(const Standard_Integer anIndex, const Standard_Real R, const Standard_Real G, - const Standard_Real B) { + const Standard_Real B) +{ if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myMaxVertexs ) { Standard_OutOfRange::Raise(" BAD VERTEX index"); } if( myPrimitiveArray->vcolours ) { - unsigned char red = (unsigned char)(R <= 0. ? 0. : R >= 1. ? 255. : R * 255.); - unsigned char green = (unsigned char)(G <= 0. ? 0. : G >= 1. ? 255. : G * 255.); - unsigned char blue = (unsigned char)(B <= 0. ? 0. : B >= 1. ? 255. : B * 255.); + unsigned char red = (unsigned int)(R * 255.); + unsigned char green = (unsigned int)(G * 255.); + unsigned char blue = (unsigned int)(B * 255.); unsigned char alpha = 0; Standard_Integer outColor ; outColor = red; @@ -136,7 +191,8 @@ inline void Graphic3d_ArrayOfPrimitives::SetVertexNormal( inline void Graphic3d_ArrayOfPrimitives::SetVertexTexel( const Standard_Integer anIndex, - const Standard_Real TX, const Standard_Real TY) { + const Standard_Real TX, const Standard_Real TY) +{ if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myMaxVertexs ) { Standard_OutOfRange::Raise(" BAD VERTEX index"); @@ -153,7 +209,8 @@ inline void Graphic3d_ArrayOfPrimitives::SetVertexTexel( inline void Graphic3d_ArrayOfPrimitives::SetBoundColor( const Standard_Integer anIndex, - const Standard_Real R, const Standard_Real G, const Standard_Real B) { + const Standard_Real R, const Standard_Real G, const Standard_Real B) +{ if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myMaxBounds ) { Standard_OutOfRange::Raise(" BAD BOUND index"); @@ -169,7 +226,8 @@ inline void Graphic3d_ArrayOfPrimitives::SetBoundColor( } inline void Graphic3d_ArrayOfPrimitives::Vertice(const Standard_Integer anIndex, - Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { + Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ X = Y = Z = 0.; if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) { @@ -184,7 +242,8 @@ inline void Graphic3d_ArrayOfPrimitives::Vertice(const Standard_Integer anIndex, } inline void Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer anIndex, - Standard_Real& R, Standard_Real& G, Standard_Real& B) const { + Standard_Real& R, Standard_Real& G, Standard_Real& B) const +{ R = G = B = 0; if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) { @@ -234,9 +293,9 @@ inline void Graphic3d_ArrayOfPrimitives::VertexColor(const Standard_Integer anIn } } - inline void Graphic3d_ArrayOfPrimitives::VertexNormal(const Standard_Integer anIndex, - Standard_Real& NX, Standard_Real& NY, Standard_Real& NZ) const { + Standard_Real& NX, Standard_Real& NY, Standard_Real& NZ) const +{ NX = NY = NZ = 0.; if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) { @@ -251,7 +310,8 @@ inline void Graphic3d_ArrayOfPrimitives::VertexNormal(const Standard_Integer anI } inline void Graphic3d_ArrayOfPrimitives::VertexTexel(const Standard_Integer anIndex, - Standard_Real& TX, Standard_Real& TY) const { + Standard_Real& TX, Standard_Real& TY) const +{ TX = TY = 0.; if( !myPrimitiveArray ) return; if( anIndex < 1 || anIndex > myPrimitiveArray->num_vertexs ) { @@ -265,14 +325,15 @@ inline void Graphic3d_ArrayOfPrimitives::VertexTexel(const Standard_Integer anIn } } -inline Standard_Integer Graphic3d_ArrayOfPrimitives::EdgeNumber() const { +inline Standard_Integer Graphic3d_ArrayOfPrimitives::EdgeNumber() const +{ Standard_Integer number = -1; if( myPrimitiveArray ) number = myPrimitiveArray->num_edges; return number; } -inline Standard_Integer Graphic3d_ArrayOfPrimitives::Edge( - const Standard_Integer anIndex ) const { +inline Standard_Integer Graphic3d_ArrayOfPrimitives::Edge(const Standard_Integer anIndex ) const +{ Standard_Integer index=0; if( myPrimitiveArray && myPrimitiveArray->edge_vis && (anIndex > 0) && (anIndex <= myPrimitiveArray->num_edges) ) { @@ -283,8 +344,8 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::Edge( return index+1; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::EdgeIsVisible( - const Standard_Integer anIndex ) const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::EdgeIsVisible(const Standard_Integer anIndex ) const +{ Standard_Boolean isVisible = Standard_False; if( myPrimitiveArray && myPrimitiveArray->edge_vis && (anIndex > 0) && (anIndex <= myPrimitiveArray->num_edges) ) { @@ -296,19 +357,22 @@ inline Standard_Boolean Graphic3d_ArrayOfPrimitives::EdgeIsVisible( return isVisible; } -inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasBoundColors() const { +inline Standard_Boolean Graphic3d_ArrayOfPrimitives::HasBoundColors() const +{ Standard_Boolean defined = Standard_False; if( myPrimitiveArray && myPrimitiveArray->fcolours ) defined = Standard_True; return defined; } -inline Standard_Integer Graphic3d_ArrayOfPrimitives::BoundNumber() const { +inline Standard_Integer Graphic3d_ArrayOfPrimitives::BoundNumber() const +{ Standard_Integer number = -1; if( myPrimitiveArray ) number = myPrimitiveArray->num_bounds; return number; } -inline Standard_Integer Graphic3d_ArrayOfPrimitives::Bound(const Standard_Integer anIndex) const { +inline Standard_Integer Graphic3d_ArrayOfPrimitives::Bound(const Standard_Integer anIndex) const +{ Standard_Integer number=-1; if( myPrimitiveArray && myPrimitiveArray->bounds && (anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) { @@ -320,7 +384,8 @@ inline Standard_Integer Graphic3d_ArrayOfPrimitives::Bound(const Standard_Intege } inline void Graphic3d_ArrayOfPrimitives::BoundColor(const Standard_Integer anIndex, - Standard_Real& R, Standard_Real& G, Standard_Real& B) const { + Standard_Real& R, Standard_Real& G, Standard_Real& B) const +{ if( myPrimitiveArray && myPrimitiveArray->fcolours && (anIndex > 0) && (anIndex <= myPrimitiveArray->num_bounds) ) { Tfloat *p = myPrimitiveArray->fcolours[anIndex-1].rgb; diff --git a/src/Graphic3d/Graphic3d_CGroup.hxx b/src/Graphic3d/Graphic3d_CGroup.hxx index c33011dca0..72afa441a3 100755 --- a/src/Graphic3d/Graphic3d_CGroup.hxx +++ b/src/Graphic3d/Graphic3d_CGroup.hxx @@ -90,12 +90,8 @@ class Graphic3d_CGroup public: - int LabelBegin; - int LabelEnd; void* ptrGroup; - int StructureEnd; - CALL_DEF_CONTEXTLINE ContextLine; CALL_DEF_CONTEXTFILLAREA ContextFillArea; CALL_DEF_CONTEXTMARKER ContextMarker; @@ -105,9 +101,6 @@ public: CALL_DEF_PICKID PickId; - unsigned IsDeleted : 1; - unsigned IsOpen : 1; - }; const Handle(Standard_Type)& TYPE(Graphic3d_CGroup); diff --git a/src/Graphic3d/Graphic3d_CStructure.hxx b/src/Graphic3d/Graphic3d_CStructure.hxx index 93091e9a9c..c00cc3379e 100755 --- a/src/Graphic3d/Graphic3d_CStructure.hxx +++ b/src/Graphic3d/Graphic3d_CStructure.hxx @@ -31,8 +31,6 @@ public: int Priority; int PreviousPriority; - int GroupBegin; - int GroupEnd; CALL_DEF_CONTEXTLINE ContextLine; CALL_DEF_CONTEXTFILLAREA ContextFillArea; diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index 24236888d2..f7db5746b9 100755 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -74,25 +74,12 @@ uses Structure from Graphic3d, TextPath from Graphic3d, TypeOfComposition from Graphic3d, - TypeOfPolygon from Graphic3d, TypeOfPrimitive from Graphic3d, Vector from Graphic3d, Array1OfVertex from Graphic3d, Array2OfVertex from Graphic3d, Vertex from Graphic3d, - Array1OfVertexC from Graphic3d, - Array2OfVertexC from Graphic3d, - VertexC from Graphic3d, - Array1OfVertexN from Graphic3d, - Array2OfVertexN from Graphic3d, - VertexN from Graphic3d, - Array1OfVertexNC from Graphic3d, - Array2OfVertexNC from Graphic3d, - VertexNC from Graphic3d, VerticalTextAlignment from Graphic3d, - VertexNT from Graphic3d, - Array1OfVertexNT from Graphic3d, - Array2OfVertexNT from Graphic3d, PrimitiveArray from Graphic3d, PtrFrameBuffer from Graphic3d, HArray1OfByte from TColStd, @@ -201,11 +188,6 @@ is is deferred; ---Purpose: call_togl_cleargroup - CloseGroup ( me : mutable; - ACGroup : CGroup from Graphic3d ) - is deferred; - ---Purpose: call_togl_closegroup - FaceContextGroup ( me : mutable; ACGroup : CGroup from Graphic3d; NoInsert : Integer from Standard ) @@ -238,11 +220,6 @@ is is deferred; ---Purpose: call_togl_markercontextgroup - OpenGroup ( me : mutable; - ACGroup : CGroup from Graphic3d ) - is deferred; - ---Purpose: call_togl_opengroup - RemoveGroup ( me : mutable; ACGroup : CGroup from Graphic3d ) is deferred; @@ -500,29 +477,14 @@ is Marker ( me : mutable; ACGroup : CGroup from Graphic3d; - APoint : Vertex from Graphic3d; - EvalMinMax : Boolean from Standard = Standard_True ) + APoint : Vertex from Graphic3d ) is deferred; MarkerSet ( me : mutable; ACGroup : CGroup from Graphic3d; - ListVertex : Array1OfVertex from Graphic3d; - EvalMinMax : Boolean from Standard = Standard_True ) + ListVertex : Array1OfVertex from Graphic3d ) is deferred; - ---------------------------------------- - -- Category: Methods to create Polygon - -- for Purpose : see Graphic3d_Group.cdl - ---------------------------------------- - - Polygon ( me : mutable; - ACGroup : CGroup from Graphic3d; - ListVertex : Array1OfVertex from Graphic3d; - AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX; - EvalMinMax : Boolean from Standard = Standard_True ) - is deferred; - ---Purpose: call_togl_polygon - ---------------------------------------- -- Category: Methods to create Text -- for Purpose : see Graphic3d_Group.cdl @@ -1013,15 +975,6 @@ is -- In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits on printing to laser printer). -- Notice however that results may differ a lot and do not contain some elements. - RemovePrimitiveArray( me : mutable; - theCGroup : CGroup from Graphic3d; - thePArray : PrimitiveArray from Graphic3d ) - is deferred; - ---Purpose: Clear visualization data in graphical driver and - -- stop displaying the primitives array of the graphical group - -- . This method is internal and should be used - -- by Graphic3d_Group only. - AddZLayer( me : mutable; theCView : CView from Graphic3d; theLayerId : Integer from Standard ) diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cxx b/src/Graphic3d/Graphic3d_GraphicDriver.cxx index c54d03585e..2d312949f4 100755 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cxx +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cxx @@ -90,8 +90,7 @@ void Graphic3d_GraphicDriver::PrintCGroup (const Graphic3d_CGroup& ACGroup, cons if (AField) { cout << "\tstruct id " << ACGroup.Struct->Id << "\n"; - cout << "\tgroup labels " << ACGroup.LabelBegin << ", " - << ACGroup.LabelEnd << "\n"; + cout << "\tgroup\n"; cout << flush; } diff --git a/src/Graphic3d/Graphic3d_Group.cdl b/src/Graphic3d/Graphic3d_Group.cdl index 742ec2d55c..5fb7fc60b6 100755 --- a/src/Graphic3d/Graphic3d_Group.cdl +++ b/src/Graphic3d/Graphic3d_Group.cdl @@ -83,27 +83,13 @@ class Group from Graphic3d inherits TShared GraphicDriver from Graphic3d, Structure from Graphic3d, TextPath from Graphic3d, - TypeOfPolygon from Graphic3d, Vector from Graphic3d, Array1OfVertex from Graphic3d, Array2OfVertex from Graphic3d, Vertex from Graphic3d, - Array1OfVertexC from Graphic3d, - Array2OfVertexC from Graphic3d, - VertexC from Graphic3d, - Array1OfVertexN from Graphic3d, - Array2OfVertexN from Graphic3d, - VertexN from Graphic3d, - Array1OfVertexNC from Graphic3d, - Array2OfVertexNC from Graphic3d, - VertexNC from Graphic3d, VerticalTextAlignment from Graphic3d, - VertexNT from Graphic3d, - Array1OfVertexNT from Graphic3d, - Array2OfVertexNT from Graphic3d, ArrayOfPrimitives from Graphic3d, ListOfPArray from Graphic3d, - ListIteratorOfListOfPArray from Graphic3d, TransModeFlags from Graphic3d, CBounds from Graphic3d @@ -282,109 +268,6 @@ class Group from Graphic3d inherits TShared -- vertices. ---Category: Methods to create Marker - -------------------------------------- - -- Category: Methods to create Polygon - -------------------------------------- - - -------------------------------------------------- - -- Summary of Polygons -- - -- -- - -- They are limited to one boundary. -- - -- -- - -- The boundary should be closed. -- - -- -- - -- They should have at least three vertices. -- - -- -- - -- They should be planar. -- - -- -- - -- They should have a normal. -- - -- -- - -- The boundary is drawn only when the interior -- - -- style is hollow. -- - -- -- - -- The boundary have the following attributes : -- - -- -- - -- Line Type. -- - -- Line Width Scale Factor. -- - -- Line Color. -- - -- -- - -- They have only interior attributes : -- - -- -- - -- Interior Style. -- - -- Interior Color. -- - -- Front Material. -- - -- Back Material. -- - -------------------------------------------------- - - Polygon ( me : mutable; - ListVertex : Array1OfVertex from Graphic3d; - AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX; - EvalMinMax : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Links up points to create a face drawn - -- using the current fill attributes (AspectFillArea3d)) - -- The first and last points are not duplicates. - ---Category: Methods to create Polygon - - PolygonSet ( me : mutable; - Bounds : Array1OfInteger from TColStd; - ListVertex : Array1OfVertex from Graphic3d; - AType : TypeOfPolygon from Graphic3d = Graphic3d_TOP_CONVEX; - EvalMinMax : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Links up points to create a set of face drawn - -- using the current fill attributes (AspectFillArea3d)) - -- The first and last points are not duplicates. - ---Category: Methods to create Polygon - - --------------------------------------- - -- Category: Methods to create Polyline - --------------------------------------- - - -------------------------------------------- - -- Summary of Polylines -- - -- -- - -- They should have two or more vertices. -- - -- -- - -- They have the following attributes. -- - -- -- - -- Line Type. -- - -- Line Width Scale Factor. -- - -- Line Color. -- - -------------------------------------------- - - Polyline ( me : mutable; - APT1 : Vertex from Graphic3d; - APT2 : Vertex from Graphic3d; - EvalMinMax : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Links up points to create a line drawn - -- using the current line attributes (AspectLine) - ---Category: Methods to create Polyline - - Polyline ( me : mutable; - ListVertex : Array1OfVertex from Graphic3d; - EvalMinMax : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Links up points to create a line drawn - -- using the current line attributes (AspectLine) - ---Category: Methods to create Polyline - - Polyline ( me : mutable; - ListVertex : Array1OfVertexC from Graphic3d; - EvalMinMax : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Links up points to create a line drawn - -- using the current line attributes (AspectLine) - -- except for the colour which is defined - -- for each vertex. - ---Category: Methods to create Polyline - ----------------------------------- -- Category: Methods to create Text ----------------------------------- @@ -511,17 +394,6 @@ class Group from Graphic3d inherits TShared ---Level: Public ---Purpose: Adds an array of primitives for display - RemovePrimitiveArray( me : mutable; - aRank : Integer from Standard) - ---Level: Public - ---Purpose: Remove the array of primitives of rank - raises OutOfRange from Standard is static; - -- if is < 1 or > ArrayNumber() - - RemovePrimitiveArrays( me : mutable); - ---Level: Public - ---Purpose: Remove all array of primitives - UserDraw ( me : mutable; AnObject : Address from Standard; EvalMinMax : Boolean from Standard = Standard_True; @@ -537,30 +409,6 @@ class Group from Graphic3d inherits TShared -- Category: Inquire methods ---------------------------- - ArrayNumber( me ) - returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of primitive array added in this group - - InitDefinedArray( me:mutable ); - ---Level: Public - ---Purpose: Initialize the array list iterator. - - NextDefinedArray( me:mutable ); - ---Level: Public - ---Purpose: Increments the array list iterator. - - MoreDefinedArray( me:mutable ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns TRUE if more array exists in the list. - - DefinedArray( me ) - returns mutable ArrayOfPrimitives from Graphic3d; - ---Level: Public - ---Purpose: Returns the current array of primitives according - -- to the array list iterator value. - IsGroupPrimitivesAspectSet ( me; theAspect : GroupAspect from Graphic3d ) returns Boolean from Standard @@ -640,13 +488,6 @@ class Group from Graphic3d inherits TShared -- Category: Private methods ---------------------------- - Labels ( me; - LB, LE : in out Integer from Standard ) - is static private; - ---Level: Internal - ---Purpose: Returns the position of the group in the structure. - ---Category: Private methods - MinMaxCoord ( me; XMin, YMin, ZMin : out Real from Standard; XMax, YMax, ZMax : out Real from Standard ) @@ -665,22 +506,6 @@ class Group from Graphic3d inherits TShared -- contains the associated Structure of the Group . ---Category: Private methods - ----------------------------- - -- Category: Internal methods - ----------------------------- - - BeginPrimitives ( me : mutable ) - is static; - ---Level: Internal - ---Category: Internal methods - - EndPrimitives ( me : mutable ) - is static; - ---Level: Internal - ---Category: Internal methods - - -- - fields -- @@ -708,7 +533,6 @@ class Group from Graphic3d inherits TShared MyBounds : CBounds from Graphic3d; MyListOfPArray : ListOfPArray from Graphic3d; - MyListOfPArrayIterator : ListIteratorOfListOfPArray from Graphic3d; MyMarkArray : HArray1OfByte from TColStd; MyMarkWidth : Integer from Standard; diff --git a/src/Graphic3d/Graphic3d_Group.cxx b/src/Graphic3d/Graphic3d_Group.cxx index 40b4383b1d..44ea7876e1 100755 --- a/src/Graphic3d/Graphic3d_Group.cxx +++ b/src/Graphic3d/Graphic3d_Group.cxx @@ -77,49 +77,38 @@ MyListOfPArray() // This () is the instance of the class, the current groupe //Handle(Graphic3d_Group) me = Handle(Graphic3d_Group)::DownCast (This ()); -Standard_Integer TheLabelBegin, TheLabelEnd; + MyPtrStructure = (void *) AStructure.operator->(); + MyStructure->Add (this); - // MyStructure = AStructure; - MyPtrStructure = (void *) AStructure.operator->(); - MyStructure->GroupLabels (TheLabelBegin, TheLabelEnd); - MyStructure->Add (this); + MyContainsFacet = Standard_False, + MyIsEmpty = Standard_True; - MyContainsFacet = Standard_False, - MyIsEmpty = Standard_True; + MyCGroup.Struct = MyStructure->CStructure(); + MyCGroup.Struct->Id = int (MyStructure->Identification ()); + MyCGroup.ptrGroup = NULL; - MyCGroup.Struct = MyStructure->CStructure(); - MyCGroup.Struct->Id = int (MyStructure->Identification ()); - MyCGroup.IsDeleted = 0; - MyCGroup.IsOpen = 0; - MyCGroup.LabelBegin = int (TheLabelBegin); - MyCGroup.LabelEnd = int (TheLabelEnd); + MyCGroup.ContextLine.IsDef = 0, + MyCGroup.ContextText.IsDef = 0, + MyCGroup.ContextMarker.IsDef = 0, + MyCGroup.ContextFillArea.IsDef = 0; - MyCGroup.StructureEnd = Structure_END; + MyCGroup.ContextLine.IsSet = 0, + MyCGroup.ContextText.IsSet = 0, + MyCGroup.ContextMarker.IsSet = 0, + MyCGroup.ContextFillArea.IsSet = 0; - MyCGroup.ContextLine.IsDef = 0, - MyCGroup.ContextText.IsDef = 0, - MyCGroup.ContextMarker.IsDef = 0, - MyCGroup.ContextFillArea.IsDef = 0; + MyCGroup.PickId.IsDef = 0, + MyCGroup.PickId.IsSet = 0, + MyCGroup.PickId.Value = 0; - MyCGroup.ContextLine.IsSet = 0, - MyCGroup.ContextText.IsSet = 0, - MyCGroup.ContextMarker.IsSet = 0, - MyCGroup.ContextFillArea.IsSet = 0; + Handle(Aspect_GraphicDriver) agd = + ((MyStructure->StructureManager ())->GraphicDevice ())->GraphicDriver (); - MyCGroup.PickId.IsDef = 0, - MyCGroup.PickId.IsSet = 0, - MyCGroup.PickId.Value = 0; + MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd; -Handle(Aspect_GraphicDriver) agd = -((MyStructure->StructureManager ())->GraphicDevice ())->GraphicDriver (); + MyGraphicDriver->Group (MyCGroup); - MyGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd; - - MyGraphicDriver->Group (MyCGroup); - - //MyCGroup.TransformPersistenceFlag = Graphic3d_TMF_None; - //MyCGroup.Struct->TransformPersistenceFlag = Graphic3d_TMF_None; - MyMarkWidth = 0; - MyMarkHeight = 0; - MyMarkArray.Nullify(); + MyMarkWidth = 0; + MyMarkHeight = 0; + MyMarkArray.Nullify(); } diff --git a/src/Graphic3d/Graphic3d_Group_1.cxx b/src/Graphic3d/Graphic3d_Group_1.cxx index 64ceef4c51..2c74cdc7c5 100755 --- a/src/Graphic3d/Graphic3d_Group_1.cxx +++ b/src/Graphic3d/Graphic3d_Group_1.cxx @@ -18,10 +18,6 @@ // and conditions governing the rights and limitations under the License. -#define XDESTROY - - - //-Version //-Design Declaration des variables specifiques aux groupes @@ -81,25 +77,22 @@ void Graphic3d_Group::Clear (Standard_Boolean theUpdateStructureMgr) Update (); } -void Graphic3d_Group::Destroy () { - -#ifdef DESTROY - cout << "Graphic3d_Group::Destroy ()\n"; -#endif - +void Graphic3d_Group::Destroy () +{ // tell graphics driver to clear internal resources of the group if (!IsEmpty () && !MyGraphicDriver.IsNull ()) MyGraphicDriver->ClearGroup (MyCGroup); } -void Graphic3d_Group::Remove () { - +void Graphic3d_Group::Remove () +{ if (IsDeleted ()) return; - MyCGroup.IsDeleted = 1; MyGraphicDriver->RemoveGroup (MyCGroup); MyStructure->Remove (this); + MyCGroup.ptrGroup = NULL; + Update (); MyBounds.XMin = ShortRealLast (), @@ -113,37 +106,4 @@ void Graphic3d_Group::Remove () { if (MyContainsFacet) MyStructure->GroupsWithFacet (-1); MyContainsFacet = Standard_False, MyIsEmpty = Standard_True; - } - -void Graphic3d_Group::BeginPrimitives () { - - if (IsDeleted ()) return; - if (MyCGroup.IsOpen) return; - - MyCGroup.IsOpen = 1; - - MyGraphicDriver->OpenGroup (MyCGroup); - -} - -void Graphic3d_Group::EndPrimitives () { - - if (IsDeleted ()) return; - if (! MyCGroup.IsOpen) return; - - MyCGroup.IsOpen = 0; - - MyGraphicDriver->CloseGroup (MyCGroup); - -} - -/*void Graphic3d_Group::SetTransformPersistence( const Graphic3d_TransModeFlags& AFlag ) -{ - //MyCGroup.TransformPersistenceFlag = AFlag; -} - -Graphic3d_TransModeFlags Graphic3d_Group::TransformPersistence() const -{ - //return MyCGroup.TransformPersistenceFlag; -}*/ diff --git a/src/Graphic3d/Graphic3d_Group_10.cxx b/src/Graphic3d/Graphic3d_Group_10.cxx index 80e3ad6067..c0e7b7c59a 100755 --- a/src/Graphic3d/Graphic3d_Group_10.cxx +++ b/src/Graphic3d/Graphic3d_Group_10.cxx @@ -57,14 +57,14 @@ void Graphic3d_Group::Text ( // Min-Max Update if (EvalMinMax) { - Standard_Real X, Y, Z; + Standard_ShortReal X, Y, Z; APoint.Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } MyGraphicDriver->Text(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax); @@ -85,14 +85,14 @@ void Graphic3d_Group::Text ( // Min-Max Update if (EvalMinMax) { - Standard_Real X, Y, Z; + Standard_ShortReal X, Y, Z; APoint.Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax); @@ -117,14 +117,14 @@ void Graphic3d_Group::Text ( // Min-Max Update if (EvalMinMax) { - Standard_Real X, Y, Z; + Standard_ShortReal X, Y, Z; APoint.Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } MyGraphicDriver->Text(MyCGroup, AText, APoint, AHeight, AAngle, ATp, AHta, AVta, EvalMinMax); @@ -145,14 +145,14 @@ void Graphic3d_Group::Text ( // Min-Max Update if (EvalMinMax) { - Standard_Real X, Y, Z; + Standard_ShortReal X, Y, Z; APoint.Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } MyGraphicDriver->Text (MyCGroup, AText, APoint, AHeight, EvalMinMax); diff --git a/src/Graphic3d/Graphic3d_Group_13.cxx b/src/Graphic3d/Graphic3d_Group_13.cxx index 850447c00c..f1f67154a9 100755 --- a/src/Graphic3d/Graphic3d_Group_13.cxx +++ b/src/Graphic3d/Graphic3d_Group_13.cxx @@ -60,61 +60,6 @@ void Graphic3d_Group :: AddPrimitiveArray ( const Handle(Graphic3d_ArrayOfPrimit Update (); } -void Graphic3d_Group :: RemovePrimitiveArrays () { - // clear primitives array's visualization data in graphics driver and remove - // references to it in driver - if (!IsEmpty() && !MyGraphicDriver.IsNull()) - { - for (Graphic3d_ListIteratorOfListOfPArray it (MyListOfPArray); - it.More(); it.Next()) - MyGraphicDriver->RemovePrimitiveArray (MyCGroup, it.Value()->Array()); - } - - // remove references to primitives arrays - MyListOfPArray.Clear(); -} - -Standard_Integer Graphic3d_Group :: ArrayNumber () const { - - return MyListOfPArray.Extent(); -} - -void Graphic3d_Group :: InitDefinedArray() { - MyListOfPArrayIterator.Initialize(MyListOfPArray); -} - -void Graphic3d_Group :: NextDefinedArray() { - MyListOfPArrayIterator.Next(); -} - -Standard_Boolean Graphic3d_Group :: MoreDefinedArray() { - return MyListOfPArrayIterator.More(); -} - -Handle(Graphic3d_ArrayOfPrimitives) Graphic3d_Group :: DefinedArray() const { - - return MyListOfPArrayIterator.Value(); -} - -void Graphic3d_Group :: RemovePrimitiveArray ( const Standard_Integer aRank ) { - - if( aRank < 1 || aRank > ArrayNumber() ) { - Standard_OutOfRange::Raise(" BAD ARRAY index"); - } - Graphic3d_ListIteratorOfListOfPArray it(MyListOfPArray); - for( Standard_Integer i=1 ; it.More() ; it.Next(),i++ ) { - if( aRank == i ) break; - } - - // clear primitives array's visualization data in graphics driver and remove - // references to it in driver - if (!IsEmpty() && !MyGraphicDriver.IsNull()) - MyGraphicDriver->RemovePrimitiveArray (MyCGroup, it.Value()->Array()); - - // remove references to primitives array - MyListOfPArray.Remove (it); -} - void Graphic3d_Group :: UserDraw ( const Standard_Address AnObject, const Standard_Boolean EvalMinMax, const Standard_Boolean ContainsFacet ) diff --git a/src/Graphic3d/Graphic3d_Group_2.cxx b/src/Graphic3d/Graphic3d_Group_2.cxx index ce9cc5a890..4e8d5fba5d 100755 --- a/src/Graphic3d/Graphic3d_Group_2.cxx +++ b/src/Graphic3d/Graphic3d_Group_2.cxx @@ -46,10 +46,7 @@ Standard_Boolean Graphic3d_Group::IsDeleted () const { - if ( (MyCGroup.IsDeleted) || (MyStructure->IsDeleted ()) ) - return (Standard_True); - else - return (Standard_False); + return ( (MyCGroup.ptrGroup == NULL) || (MyStructure->IsDeleted ()) ); } @@ -117,13 +114,6 @@ void Graphic3d_Group::MinMaxCoord (Standard_Real& XMin, Standard_Real& YMin, Sta } -void Graphic3d_Group::Labels (Standard_Integer& LB, Standard_Integer& LE) const { - - LB = Standard_Integer (MyCGroup.LabelBegin); - LE = Standard_Integer (MyCGroup.LabelEnd); - -} - void Graphic3d_Group::Update () const { if (IsDeleted ()) return; diff --git a/src/Graphic3d/Graphic3d_Group_3.cxx b/src/Graphic3d/Graphic3d_Group_3.cxx index 90a789ac59..cd58ef0a72 100755 --- a/src/Graphic3d/Graphic3d_Group_3.cxx +++ b/src/Graphic3d/Graphic3d_Group_3.cxx @@ -40,59 +40,53 @@ //-Methods, in order -void Graphic3d_Group::Marker (const Graphic3d_Vertex& APoint, const Standard_Boolean EvalMinMax) { - +void Graphic3d_Group::Marker (const Graphic3d_Vertex &APoint, const Standard_Boolean EvalMinMax) +{ if (IsDeleted ()) return; MyIsEmpty = Standard_False; // Min-Max Update if (EvalMinMax) { -Standard_Real X, Y, Z; + Standard_ShortReal X, Y, Z; APoint.Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } - MyGraphicDriver->Marker (MyCGroup, APoint, EvalMinMax); + MyGraphicDriver->Marker (MyCGroup, APoint); Update (); - } -void Graphic3d_Group::MarkerSet (const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax) { - +void Graphic3d_Group::MarkerSet (const Graphic3d_Array1OfVertex &ListVertex, const Standard_Boolean EvalMinMax) +{ if (IsDeleted ()) return; MyIsEmpty = Standard_False; -Standard_Integer i, j; - - i = ListVertex.Length (); - // Min-Max Update if (EvalMinMax) { -Standard_Real X, Y, Z; -Standard_Integer Lower = ListVertex.Lower (); -Standard_Integer Upper = ListVertex.Upper (); + Standard_ShortReal X, Y, Z; + Standard_Integer i = ListVertex.Lower (); + const Standard_Integer Upper = ListVertex.Upper (); // Parcours des sommets - for (j=0, i=Lower; i<=Upper; i++, j++) { + for (; i<=Upper; i++) { ListVertex (i).Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); + if (X < MyBounds.XMin) MyBounds.XMin = X; + if (Y < MyBounds.YMin) MyBounds.YMin = Y; + if (Z < MyBounds.ZMin) MyBounds.ZMin = Z; + if (X > MyBounds.XMax) MyBounds.XMax = X; + if (Y > MyBounds.YMax) MyBounds.YMax = Y; + if (Z > MyBounds.ZMax) MyBounds.ZMax = Z; } } - MyGraphicDriver->MarkerSet (MyCGroup, ListVertex, EvalMinMax); + MyGraphicDriver->MarkerSet (MyCGroup, ListVertex); Update (); - } diff --git a/src/Graphic3d/Graphic3d_Group_5.cxx b/src/Graphic3d/Graphic3d_Group_5.cxx deleted file mode 100755 index 56045a4c6d..0000000000 --- a/src/Graphic3d/Graphic3d_Group_5.cxx +++ /dev/null @@ -1,121 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Modified -// 27/08/97 ; PCT : ajout coordonnee texture - - -//-Version - -//-Design Declaration des variables specifiques aux groupes -// de primitives - -//-Warning Un groupe est defini dans une structure -// Il s'agit de la plus petite entite editable - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include -#include - -#include -#include - -//-Methods, in order - -void Graphic3d_Group::Polygon (const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) { - - if (IsDeleted ()) return; - - if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1); - MyContainsFacet = Standard_True; - MyIsEmpty = Standard_False; - - // Min-Max Update - if (EvalMinMax) { - - Standard_Real X, Y, Z; - Standard_Integer i, j; - Standard_Integer Lower = ListVertex.Lower (); - Standard_Integer Upper = ListVertex.Upper (); - // Parcours des sommets - for (j=0, i=Lower; i<=Upper; i++, j++) { - ListVertex (i).Coord (X, Y, Z); - if (X < MyBounds.XMin) MyBounds.XMin = Standard_ShortReal (X); - if (Y < MyBounds.YMin) MyBounds.YMin = Standard_ShortReal (Y); - if (Z < MyBounds.ZMin) MyBounds.ZMin = Standard_ShortReal (Z); - if (X > MyBounds.XMax) MyBounds.XMax = Standard_ShortReal (X); - if (Y > MyBounds.YMax) MyBounds.YMax = Standard_ShortReal (Y); - if (Z > MyBounds.ZMax) MyBounds.ZMax = Standard_ShortReal (Z); - } - } - - MyGraphicDriver->Polygon (MyCGroup, ListVertex, AType, EvalMinMax); - - Update (); - -} - -void Graphic3d_Group::PolygonSet (const TColStd_Array1OfInteger& Bounds, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType, const Standard_Boolean EvalMinMax) { - - if (IsDeleted ()) return; - - if (! MyContainsFacet) MyStructure->GroupsWithFacet (+1); - MyContainsFacet = Standard_True; - MyIsEmpty = Standard_False; - -Standard_Real X, Y, Z; - -Standard_Integer i, ii; -Standard_Integer j; -Standard_Integer begin_points; -Standard_Integer end_points; -Standard_Integer nbpoints; -Standard_Integer Lower, Upper; - - begin_points = ListVertex.Lower (); - end_points = ListVertex.Upper (); - - Lower = Bounds.Lower (); - Upper = Bounds.Upper (); - - // Parcours des facettes - for (j=Lower; j<=Upper; j++) { - nbpoints = Bounds.Value (j); - - Graphic3d_Array1OfVertex ListOfVertex (0, nbpoints-1); - - // Parcours des sommets - for (i=0, ii=begin_points; - ((ii<=end_points) && (i<=nbpoints-1)); i++, ii++) { - ListVertex (ii).Coord (X, Y, Z); - ListOfVertex (i).SetCoord (X, Y, Z); - } - - Polygon (ListOfVertex, AType, EvalMinMax); - begin_points += nbpoints; - } - -} diff --git a/src/Graphic3d/Graphic3d_Group_7.cxx b/src/Graphic3d/Graphic3d_Group_7.cxx deleted file mode 100755 index 14f8e958af..0000000000 --- a/src/Graphic3d/Graphic3d_Group_7.cxx +++ /dev/null @@ -1,112 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// 11/97 ; CAL : ajout polyline par 2 points - - -//-Version - -//-Design Declaration des variables specifiques aux groupes -// de primitives - -//-Warning Un groupe est defini dans une structure -// Il s'agit de la plus petite entite editable - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include -#include - -#include -#include -#include - -void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertex& theListVertex, - const Standard_Boolean theToEvalMinMax) -{ - if (IsDeleted()) - { - return; - } - - Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines (theListVertex.Length()); - - Standard_Real aX, aY, aZ; - Standard_Integer aVertLower = theListVertex.Lower(); - Standard_Integer aVertUpper = theListVertex.Upper(); - for (Standard_Integer aVertIter = aVertLower; aVertIter <= aVertUpper; ++aVertIter) - { - const Graphic3d_Vertex& aVert = theListVertex (aVertIter); - aVert.Coord (aX, aY, aZ); - aPrims->AddVertex (aX, aY, aZ); - } - - AddPrimitiveArray (aPrims, theToEvalMinMax); -} - -void Graphic3d_Group::Polyline (const Graphic3d_Array1OfVertexC& theListVertex, - const Standard_Boolean theToEvalMinMax) -{ - if (IsDeleted()) - { - return; - } - - Handle(Graphic3d_ArrayOfPrimitives) aPrims - = new Graphic3d_ArrayOfPolylines (theListVertex.Length(), 0, 0, Standard_True); // color per vertex - - Standard_Real aX, aY, aZ; - Standard_Integer aVertLower = theListVertex.Lower(); - Standard_Integer aVertUpper = theListVertex.Upper(); - for (Standard_Integer aVertIter = aVertLower; aVertIter <= aVertUpper; ++aVertIter) - { - const Graphic3d_VertexC& aVert = theListVertex (aVertIter); - aVert.Coord (aX, aY, aZ); - aPrims->AddVertex (gp_Pnt (aX, aY, aZ), aVert.Color()); - } - - AddPrimitiveArray (aPrims, theToEvalMinMax); -} - -void Graphic3d_Group::Polyline (const Graphic3d_Vertex& thePnt1, - const Graphic3d_Vertex& thePnt2, - const Standard_Boolean theToEvalMinMax) -{ - if (IsDeleted()) - { - return; - } - - Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfPolylines (2); - - Standard_Real aX, aY, aZ; - thePnt1.Coord (aX, aY, aZ); - aPrims->AddVertex (aX, aY, aZ); - - thePnt2.Coord (aX, aY, aZ); - aPrims->AddVertex (aX, aY, aZ); - - AddPrimitiveArray (aPrims, theToEvalMinMax); -} diff --git a/src/Graphic3d/Graphic3d_Group_8.cxx b/src/Graphic3d/Graphic3d_Group_8.cxx index c38456fe82..85676bff23 100755 --- a/src/Graphic3d/Graphic3d_Group_8.cxx +++ b/src/Graphic3d/Graphic3d_Group_8.cxx @@ -587,8 +587,8 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea Standard_ShortReal aPolyFactor, aPolyUnits; CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits); MyCGroup.ContextFillArea.PolygonOffsetMode = aPolyMode; - MyCGroup.ContextFillArea.PolygonOffsetFactor = aPolyFactor; - MyCGroup.ContextFillArea.PolygonOffsetUnits = aPolyUnits; + MyCGroup.ContextFillArea.PolygonOffsetFactor = (Standard_ShortReal)aPolyFactor; + MyCGroup.ContextFillArea.PolygonOffsetUnits = (Standard_ShortReal)aPolyUnits; // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets int noinsert = 0; @@ -1110,8 +1110,7 @@ void Graphic3d_Group::GroupPrimitivesAspect (const Handle(Graphic3d_AspectLine3d CTXF->SetFrontMaterial (Front); } -void Graphic3d_Group::PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const { - - GroupPrimitivesAspect (CTXL, CTXT, CTXM, CTXF); - +void Graphic3d_Group::PrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTXL, const Handle(Graphic3d_AspectText3d)& CTXT, const Handle(Graphic3d_AspectMarker3d)& CTXM, const Handle(Graphic3d_AspectFillArea3d)& CTXF) const +{ + GroupPrimitivesAspect (CTXL, CTXT, CTXM, CTXF); } diff --git a/src/Graphic3d/Graphic3d_Structure.cdl b/src/Graphic3d/Graphic3d_Structure.cdl index 027d9f1438..e062d4a210 100755 --- a/src/Graphic3d/Graphic3d_Structure.cdl +++ b/src/Graphic3d/Graphic3d_Structure.cdl @@ -72,9 +72,8 @@ uses TypeOfPrimitive from Graphic3d, TypeOfStructure from Graphic3d, Vector from Graphic3d, - VertexNC from Graphic3d, Vertex from Graphic3d, - TransModeFlags from Graphic3d, + TransModeFlags from Graphic3d, Pnt from gp raises @@ -236,8 +235,8 @@ is ---Level: Public ---Purpose: Modifies the order of displaying the structure. -- Values are between 0 and 10. - -- Structures are drawn according to their display priorities - -- in ascending order. + -- Structures are drawn according to their display priorities + -- in ascending order. -- A structure of priority 10 is displayed the last and appears over the others. -- The default value is 5. -- Category: Methods to modify the class definition @@ -860,13 +859,6 @@ is ---Purpose: Suppress the highlight for the structure . ---Category: Private methods - GroupLabels ( me : mutable; - LB, LE : in out Integer from Standard ) - is static private; - ---Level: Internal - ---Purpose: Returns the labels for a new group in the structure . - ---Category: Private methods - Identification ( me ) returns Integer from Standard is static; @@ -993,9 +985,6 @@ fields -- the associated C structure MyCStructure : CStructure from Graphic3d; - -- the group identifier generator - MyGroupGenId : GenId from Aspect; - -- the structures to which the structure is attached MyAncestors : SequenceOfAddress from TColStd; diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 8f0977180b..adc27d76ed 100755 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -112,7 +112,6 @@ //-Constructors Graphic3d_Structure::Graphic3d_Structure (const Handle(Graphic3d_StructureManager)& AManager): -MyGroupGenId (Group_IDMIN, Group_IDMAX), MyAncestors (), MyDescendants (), MyGroups (), @@ -171,9 +170,6 @@ MyHighlightColor (Quantity_NOC_WHITE) MyCStructure.IsInfinite = 0, MyCStructure.HLRValidation = 0; - MyCStructure.GroupBegin = Structure_GROUPBEGIN; - MyCStructure.GroupEnd = Structure_GROUPEND; - MyCStructure.ContextLine.IsDef = 1, MyCStructure.ContextFillArea.IsDef = 1, MyCStructure.ContextMarker.IsDef = 1, @@ -236,10 +232,7 @@ void Graphic3d_Structure::Clear (const Standard_Boolean WithDestruction) // only then remove group references if (WithDestruction) - { - MyGroupGenId.Free(); MyGroups.Clear(); - } MyStructureManager->Clear (this, WithDestruction); @@ -726,12 +719,6 @@ void Graphic3d_Structure::GraphicClear (const Standard_Boolean WithDestruction) if (WithDestruction) { - /* - * void Prs3d_Presentation::Clear () { - * Graphic3d_Structure::Clear (); - * myCurrentGroup = new Graphic3d_Group (this); - * } - */ while (!MyGroups.IsEmpty()) { Handle(Graphic3d_Group) aGroup = MyGroups.First(); @@ -1251,8 +1238,8 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectFill Standard_ShortReal aPolyFactor, aPolyUnits; CTX->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits); MyCStructure.ContextFillArea.PolygonOffsetMode = aPolyMode; - MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor; - MyCStructure.ContextFillArea.PolygonOffsetUnits = aPolyUnits; + MyCStructure.ContextFillArea.PolygonOffsetFactor = (Standard_ShortReal)aPolyFactor; + MyCStructure.ContextFillArea.PolygonOffsetUnits = (Standard_ShortReal)aPolyUnits; // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets MyGraphicDriver->ContextStructure (MyCStructure); @@ -1306,7 +1293,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectText MyCStructure.ContextText.ColorSubTitle.b = float (Bs); MyCStructure.ContextText.TextZoomable = ATextZoomable; MyCStructure.ContextText.TextAngle = float (ATextAngle); - MyCStructure.ContextText.TextFontAspect = (int)ATextFontAspect; + MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect); MyCStructure.ContextText.IsDef = 1; @@ -1743,13 +1730,6 @@ void Graphic3d_Structure::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin } } -void Graphic3d_Structure::GroupLabels (Standard_Integer& LB, Standard_Integer& LE) { - - LB = MyGroupGenId.Next (); - LE = MyGroupGenId.Next (); - -} - Standard_Integer Graphic3d_Structure::Identification () const { Standard_Integer Result = MyCStructure.Id; @@ -1842,20 +1822,14 @@ void Graphic3d_Structure::Remove (const Standard_Address APtr, const Graphic3d_T void Graphic3d_Structure::Remove (const Handle(Graphic3d_Group)& AGroup) { - Standard_Integer index = 0; - Standard_Integer Length = MyGroups.Length (); - for (Standard_Integer i=1; i<=Length && index==0; i++) - if (MyGroups.Value (i) == AGroup) index = i; - + const Standard_Integer Length = MyGroups.Length (); // Search in Groups - if (index != 0) { - Standard_Integer GroupLabelBegin, GroupLabelEnd; - AGroup->Labels (GroupLabelBegin, GroupLabelEnd); - MyGroupGenId.Free (GroupLabelBegin); - MyGroupGenId.Free (GroupLabelEnd); - MyGroups.Remove (index); - } - + for (Standard_Integer i=1; i<=Length; i++) + if (MyGroups.Value (i) == AGroup) + { + MyGroups.Remove (i); + return; + } } Handle(Graphic3d_StructureManager) Graphic3d_Structure::StructureManager () const { @@ -1887,11 +1861,11 @@ void Graphic3d_Structure::MinMaxCoord (Standard_Real& XMin, Standard_Real& YMin, (MyGroups.Value (i))->MinMaxValues(Xm, Ym, Zm, XM, YM, ZM); Graphic3d_Vertex vertex1(Xm, Ym, Zm); Graphic3d_Vertex vertex2(XM, YM, ZM); - Standard_Real distance = vertex1.Distance( vertex1,vertex2 ); + const Standard_Real distance = vertex1.Distance( vertex2 ); if( distance >= 500000.0){ - XMin = XMax = (Xm+ XM)/2.0; - YMin = YMax = (Ym+ YM)/2.0; - ZMin = ZMax = (Zm+ ZM)/2.0; + XMin = XMax = 0.5*(Xm+ XM); + YMin = YMax = 0.5*(Ym+ YM); + ZMin = ZMax = 0.5*(Zm+ ZM); return; } } @@ -2144,7 +2118,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)& MyCStructure.ContextText.ColorSubTitle.b = float (Bs); MyCStructure.ContextText.TextZoomable = ATextZoomable; MyCStructure.ContextText.TextAngle = float (ATextAngle); - MyCStructure.ContextText.TextFontAspect = (int)ATextFontAspect; + MyCStructure.ContextText.TextFontAspect = int (ATextFontAspect); @@ -2323,8 +2297,8 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)& Standard_ShortReal aPolyFactor, aPolyUnits; CTXF->PolygonOffsets(aPolyMode, aPolyFactor, aPolyUnits); MyCStructure.ContextFillArea.PolygonOffsetMode = aPolyMode; - MyCStructure.ContextFillArea.PolygonOffsetFactor = aPolyFactor; - MyCStructure.ContextFillArea.PolygonOffsetUnits = aPolyUnits; + MyCStructure.ContextFillArea.PolygonOffsetFactor = (Standard_ShortReal)aPolyFactor; + MyCStructure.ContextFillArea.PolygonOffsetUnits = (Standard_ShortReal)aPolyUnits; // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets } diff --git a/src/Graphic3d/Graphic3d_Structure.pxx b/src/Graphic3d/Graphic3d_Structure.pxx index 2ff921d934..adb32736ba 100755 --- a/src/Graphic3d/Graphic3d_Structure.pxx +++ b/src/Graphic3d/Graphic3d_Structure.pxx @@ -49,12 +49,6 @@ #include - // check the value of Group_IDMIN (must be > last label value) - // (today Structure_LABCONNECT) -#define Structure_GROUPBEGIN Group_IDMIN-2 -#define Structure_GROUPEND Group_IDMIN-1 -#define Structure_END Group_IDMIN-1 - #define MyStructureManager ((Graphic3d_StructureManager*) MyPtrStructureManager) #define MyFirstStructureManager ((Graphic3d_StructureManager*) MyFirstPtrStructureManager) diff --git a/src/Graphic3d/Graphic3d_Vector.cxx b/src/Graphic3d/Graphic3d_Vector.cxx index cfca00eab1..ee3163fb7a 100755 --- a/src/Graphic3d/Graphic3d_Vector.cxx +++ b/src/Graphic3d/Graphic3d_Vector.cxx @@ -72,17 +72,11 @@ MyNorme (Standard_ShortReal (Graphic3d_Vector::NormeOf (AX, AY, AZ))) { Graphic3d_Vector::Graphic3d_Vector (const Graphic3d_Vertex& APoint1, const Graphic3d_Vertex& APoint2) { -Standard_Real X1, Y1, Z1; -Standard_Real X2, Y2, Z2; + MyX = APoint2.X() - APoint1.X(); + MyY = APoint2.Y() - APoint1.Y(); + MyZ = APoint2.Z() - APoint1.Z(); - APoint1.Coord (X1, Y1, Z1); - APoint2.Coord (X2, Y2, Z2); - - MyX = Standard_ShortReal (X2 - X1); - MyY = Standard_ShortReal (Y2 - Y1); - MyZ = Standard_ShortReal (Z2 - Z1); - - MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (X2 - X1, Y2 - Y1, Z2 - Z1)); + MyNorme = Standard_ShortReal (Graphic3d_Vector::NormeOf (MyX, MyY, MyZ)); } diff --git a/src/Graphic3d/Graphic3d_Vertex.cdl b/src/Graphic3d/Graphic3d_Vertex.cdl deleted file mode 100755 index 8ffaea4da5..0000000000 --- a/src/Graphic3d/Graphic3d_Vertex.cdl +++ /dev/null @@ -1,140 +0,0 @@ --- Created by: NW,JPB,CAL --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Vertex from Graphic3d - - ---Purpose: This class allows the creation and update of a - -- 3D point. - - is - - Create - returns Vertex from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with 0.0, 0.0, 0.0 coordinates. - - Create ( APoint : Vertex from Graphic3d ) - returns Vertex from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates identical to . - -- - -- It's just a copy, but this simplifies the management - -- of the constructors of VertexC, VertexN and VertexNC. - - Create ( AX, AY ,AZ : Real from Standard ) - returns Vertex from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with , and coordinates. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetCoord ( me : in out; - Xnew, Ynew, Znew : Real from Standard ) - is static; - ---Level: Public - ---Purpose: Modifies the coordinates of the point . - ---Category: Methods to modify the class definition - - SetXCoord ( me : in out; - Xnew : Real from Standard ) - is static; - ---Level: Public - ---Purpose: Modifies the X coordinate of the point . - ---Category: Methods to modify the class definition - - SetYCoord ( me : in out; - Ynew : Real from Standard ) - is static; - ---Level: Public - ---Purpose: Modifies the Y coordinate of the point . - ---Category: Methods to modify the class definition - - SetZCoord ( me : in out; - Znew : Real from Standard ) - is static; - ---Level: Public - ---Purpose: Modifies the Z coordinate of the point . - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Coord ( me; - AX, AY, AZ : out Real from Standard ) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the point . - ---Category: Inquire methods - - X ( me ) - returns Real from Standard - is static; - ---Level: Public - ---Purpose: Returns the X coordinates of the point . - ---Category: Inquire methods - - Y ( me ) - returns Real from Standard - is static; - ---Level: Public - ---Purpose: Returns the Y coordinate of the point . - ---Category: Inquire methods - - Z ( me ) - returns Real from Standard - is static; - ---Level: Public - ---Purpose: Returns the Z coordinate of the point . - ---Category: Inquire methods - - -------------------------- - -- Category: Class methods - -------------------------- - - Distance ( myclass; - AV1 : Vertex from Graphic3d; - AV2 : Vertex from Graphic3d ) - returns Real from Standard; - ---Level: Public - ---Purpose: Returns the distance between and . - ---Category: Class methods - --- - -fields - --- --- Class : Graphic3d_Vertex --- --- Purpose : Declaration of variables specific to points --- --- Reminder : A point is defined by its coordinates --- --- - - -- the coordinates of a point - MyX : ShortReal from Standard; - MyY : ShortReal from Standard; - MyZ : ShortReal from Standard; - -end Vertex; diff --git a/src/Graphic3d/Graphic3d_Vertex.cxx b/src/Graphic3d/Graphic3d_Vertex.cxx index 224cdd369a..3d3f7faab0 100755 --- a/src/Graphic3d/Graphic3d_Vertex.cxx +++ b/src/Graphic3d/Graphic3d_Vertex.cxx @@ -17,114 +17,11 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. +#include - - -//-Version - -//-Design Declaration des variables specifiques aux points - -//-Warning Un point est defini par ses coordonnees - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions - -// -- les coordonnees du point -// MyX : Standard_ShortReal; -// MyY : Standard_ShortReal; -// MyZ : Standard_ShortReal; - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic3d_Vertex::Graphic3d_Vertex (): -MyX (Standard_ShortReal (0.0)), -MyY (Standard_ShortReal (0.0)), -MyZ (Standard_ShortReal (0.0)) { -} - -Graphic3d_Vertex::Graphic3d_Vertex (const Graphic3d_Vertex& P) { - - MyX = Standard_ShortReal (P.X ()); - MyY = Standard_ShortReal (P.Y ()); - MyZ = Standard_ShortReal (P.Z ()); - -} - -Graphic3d_Vertex::Graphic3d_Vertex (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ): -MyX (Standard_ShortReal (AX)), -MyY (Standard_ShortReal (AY)), -MyZ (Standard_ShortReal (AZ)) { -} - -void Graphic3d_Vertex::Coord (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { - - X = Standard_Real (MyX); - Y = Standard_Real (MyY); - Z = Standard_Real (MyZ); - -} - -Standard_Real Graphic3d_Vertex::X () const { - - return Standard_Real (MyX); - -} - -Standard_Real Graphic3d_Vertex::Y () const { - - return Standard_Real (MyY); - -} - -Standard_Real Graphic3d_Vertex::Z () const { - - return Standard_Real (MyZ); - -} - -void Graphic3d_Vertex::SetCoord (const Standard_Real Xnew, const Standard_Real Ynew, const Standard_Real Znew) { - - MyX = Standard_ShortReal (Xnew); - MyY = Standard_ShortReal (Ynew); - MyZ = Standard_ShortReal (Znew); - -} - -void Graphic3d_Vertex::SetXCoord (const Standard_Real Xnew) { - - MyX = Standard_ShortReal (Xnew); - -} - -void Graphic3d_Vertex::SetYCoord (const Standard_Real Ynew) { - - MyY = Standard_ShortReal (Ynew); - -} - -void Graphic3d_Vertex::SetZCoord (const Standard_Real Znew) { - - MyZ = Standard_ShortReal (Znew); - -} - -Standard_Real Graphic3d_Vertex::Distance (const Graphic3d_Vertex& AV1, const Graphic3d_Vertex& AV2) { - - return (Sqrt ( (AV1.X () - AV2.X ()) * (AV1.X () - AV2.X ()) - + (AV1.Y () - AV2.Y ()) * (AV1.Y () - AV2.Y ()) - + (AV1.Z () - AV2.Z ()) * (AV1.Z () - AV2.Z ()))); +Standard_ShortReal Graphic3d_Vertex::Distance(const Graphic3d_Vertex& AOther) const +{ + return sqrt( (X() - AOther.X()) * (X() - AOther.X()) + + (Y() - AOther.Y()) * (Y() - AOther.Y()) + + (Z() - AOther.Z()) * (Z() - AOther.Z()) ); } diff --git a/src/Graphic3d/Graphic3d_Vertex.hxx b/src/Graphic3d/Graphic3d_Vertex.hxx new file mode 100644 index 0000000000..1f92e6debe --- /dev/null +++ b/src/Graphic3d/Graphic3d_Vertex.hxx @@ -0,0 +1,66 @@ +// Created on: 2012-06-20 +// Created by: Sergey ZERCHANINOV +// Copyright (c) 2011-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#ifndef _Graphic3d_Vertex_HeaderFile +#define _Graphic3d_Vertex_HeaderFile + +#include +#include +#include +#include + +//! This class represents a graphical 3D point.
+class Graphic3d_Vertex : public TEL_POINT +{ + public: + //! Creates a point with 0.0, 0.0, 0.0 coordinates.
+ Graphic3d_Vertex() + { SetCoord(0.f,0.f,0.f); } + //! Creates a point with coordinates identical to .
+ Graphic3d_Vertex(const Graphic3d_Vertex& APoint) + { SetCoord(APoint.X(),APoint.Y(),APoint.Z()); } + //! Creates a point with , and coordinates.
+ Graphic3d_Vertex(const Standard_ShortReal AX,const Standard_ShortReal AY,const Standard_ShortReal AZ) + { SetCoord(AX,AY,AZ); } + //! Creates a point with , and coordinates.
+ Graphic3d_Vertex(const Standard_Real AX,const Standard_Real AY,const Standard_Real AZ) + { SetCoord(AX,AY,AZ); } + //! Modifies the coordinates of the point .
+ void SetCoord(const Standard_ShortReal AX,const Standard_ShortReal AY,const Standard_ShortReal AZ) + { xyz[0] = AX, xyz[1] = AY, xyz[2] = AZ; } + //! Modifies the coordinates of the point .
+ void SetCoord(const Standard_Real AX,const Standard_Real AY,const Standard_Real AZ) + { xyz[0] = Standard_ShortReal(AX), xyz[1] = Standard_ShortReal(AY), xyz[2] = Standard_ShortReal(AZ); } + //! Returns the coordinates of the point .
+ void Coord(Standard_ShortReal& AX,Standard_ShortReal& AY,Standard_ShortReal& AZ) const + { AX = xyz[0], AY = xyz[1], AZ = xyz[2]; } + //! Returns the coordinates of the point .
+ void Coord(Standard_Real& AX,Standard_Real& AY,Standard_Real& AZ) const + { AX = xyz[0], AY = xyz[1], AZ = xyz[2]; } + //! Returns the X coordinates of the point .
+ Standard_ShortReal X() const { return xyz[0]; } + //! Returns the Y coordinate of the point .
+ Standard_ShortReal Y() const { return xyz[1]; } + //! Returns the Z coordinate of the point .
+ Standard_ShortReal Z() const { return xyz[2]; } + //! Returns the distance between and .
+ Standard_EXPORT Standard_ShortReal Distance(const Graphic3d_Vertex& AOther) const; +}; + +#endif diff --git a/src/Graphic3d/Graphic3d_VertexC.cdl b/src/Graphic3d/Graphic3d_VertexC.cdl deleted file mode 100755 index 4e4105a8d6..0000000000 --- a/src/Graphic3d/Graphic3d_VertexC.cdl +++ /dev/null @@ -1,94 +0,0 @@ --- Created by: NW,JPB,CAL --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class VertexC from Graphic3d inherits Vertex from Graphic3d - - ---Version: - - ---Purpose: This class allows the creation and update of a point - -- with a colour value. - - ---Keywords: Vertex, Color, Coordinate, Point - - ---Warning: - ---References: - -uses - - Color from Quantity - ---Purpose: Returns the color of this point. -is - - Create - returns VertexC from Graphic3d; - ---Purpose: Constructs an empty point - - Create ( AX, AY ,AZ : Real from Standard; - AColor : Color from Quantity ) - returns VertexC from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates , , and - -- with colour . - - Create ( APoint : Vertex from Graphic3d; - AColor : Color from Quantity ) - returns VertexC from Graphic3d; - ---Level: Public - ---Purpose: Creates a point situated in and - -- for which the colour is . - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetColor ( me : in out; - ColorNew : Color from Quantity ) - is static; - ---Level: Public - ---Purpose: Modifies the colour of the point . - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Color ( me ) - returns Color from Quantity - is static; - ---Level: Public - ---Purpose: Returns the colour of the point . - ---Category: Inquire methods - --- - -fields - --- --- Class : Graphic3d_VertexC --- --- Purpose : Declaration of variables specific to points --- --- Reminder : a point is defined by its coordinates and its colour --- - - -- the colour of a point - MyColor : Color from Quantity; - -end VertexC; diff --git a/src/Graphic3d/Graphic3d_VertexC.cxx b/src/Graphic3d/Graphic3d_VertexC.cxx deleted file mode 100755 index 56d79135c4..0000000000 --- a/src/Graphic3d/Graphic3d_VertexC.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -//-Version - -//-Design Declaration of variables specific to points - -//-Warning A point is defined by its coordinates and color - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions - -// -- point color -// MyColor : Color; - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic3d_VertexC::Graphic3d_VertexC () { -} - -// :(AX, AY, AZ) as VertexC inherits Vertex and it is necessary to call -// constructor of Vertex with AX, AY and AZ to update fields MyX, MyY, MyZ. - -Graphic3d_VertexC::Graphic3d_VertexC (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, const Quantity_Color& AColor): -Graphic3d_Vertex (AX, AY, AZ), -MyColor (AColor) { -} - -// :(APoint) as VertexC inherits Vertex and it is necessary to call -// constructor of Vertex with APoint to update fields MyX, MyY, MyZ. - -Graphic3d_VertexC::Graphic3d_VertexC (const Graphic3d_Vertex& APoint, const Quantity_Color& AColor): -Graphic3d_Vertex (APoint), -MyColor (AColor) { -} - -Quantity_Color Graphic3d_VertexC::Color () const { - - return (MyColor); - -} - -void Graphic3d_VertexC::SetColor (const Quantity_Color& ColorNew) { - - MyColor = ColorNew; - -} diff --git a/src/Graphic3d/Graphic3d_VertexN.cdl b/src/Graphic3d/Graphic3d_VertexN.cdl deleted file mode 100755 index 3889d796d1..0000000000 --- a/src/Graphic3d/Graphic3d_VertexN.cdl +++ /dev/null @@ -1,106 +0,0 @@ --- Created by: NW,JPB,CAL --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: 03-02-98 : FMN ; Add Flag Normal - -class VertexN from Graphic3d inherits Vertex from Graphic3d - - ---Version: - - ---Purpose: This class allows the creation and update of - -- a vertex with a 3D normal. - - ---Keywords: Vertex, Normal, Coordinate, Point - - ---Warning: - ---References: - -uses - - Vector from Graphic3d - -is - - Create - returns VertexN from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with 0.0, 0.0, 0.0 coordinates - -- for which the normal is 0.0, 0.0, 1.0. - - Create ( AX, AY, AZ : Real from Standard; - ANX, ANY, ANZ : Real from Standard; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexN from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates , , and - -- for which the normal is , , . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - Create ( APoint : Vertex from Graphic3d; - AVector : Vector from Graphic3d; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexN from Graphic3d; - ---Level: Public - ---Purpose: Creates a point in for which the normal is . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetNormal ( me : in out; - NXnew, NYnew, NZnew : Real from Standard; - FlagNormalise : Boolean from Standard = Standard_True ) - is static; - ---Level: Public - ---Purpose: Modifies the normal to the point . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Normal ( me; - ANX, ANY, ANZ : out Real from Standard ) - is static; - ---Level: Public - ---Purpose: Returns the normal to the point . - ---Category: Inquire methods - --- - -fields - --- --- Class : Graphic3d_VertexN --- --- Purpose : Declaration of variables specific to points. --- --- Reminder : A point is defined by its coordinates and its normal. - - -- the normale to the point - MyDX : ShortReal from Standard; - MyDY : ShortReal from Standard; - MyDZ : ShortReal from Standard; - -end VertexN; diff --git a/src/Graphic3d/Graphic3d_VertexN.cxx b/src/Graphic3d/Graphic3d_VertexN.cxx deleted file mode 100755 index a4b4c1ff43..0000000000 --- a/src/Graphic3d/Graphic3d_VertexN.cxx +++ /dev/null @@ -1,84 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Modified: 03-02-98 : FMN ; Add Flag Normal -// Modified: 15-09-98 : CAL ; Modification champ definissant la normale -// pour permettre l'entrelacement des coordonnees dans Optimizer. - - -//-Version - -//-Design Declaration des variables specifiques aux points - -//-Warning Un point est defini par ses coordonnees et sa normale - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic3d_VertexN::Graphic3d_VertexN (): -Graphic3d_Vertex (0.0, 0.0, 0.0) { - MyDX = 0.0, - MyDY = 0.0, - MyDZ = 1.0; -} - -Graphic3d_VertexN::Graphic3d_VertexN (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, const Standard_Real ANX, const Standard_Real ANY, const Standard_Real ANZ, const Standard_Boolean FlagNormalise): -Graphic3d_Vertex (AX, AY, AZ) { - MyDX = (Standard_ShortReal ) ANX, - MyDY = (Standard_ShortReal ) ANY, - MyDZ = (Standard_ShortReal ) ANZ; -} - -Graphic3d_VertexN::Graphic3d_VertexN (const Graphic3d_Vertex& APoint, const Graphic3d_Vector& AVector, const Standard_Boolean FlagNormalise): -Graphic3d_Vertex (APoint) { -Standard_Real ANX, ANY, ANZ; - AVector.Coord (ANX, ANY, ANZ); - MyDX = (Standard_ShortReal ) ANX, - MyDY = (Standard_ShortReal ) ANY, - MyDZ = (Standard_ShortReal ) ANZ; -} - -void Graphic3d_VertexN::SetNormal (const Standard_Real ANX, const Standard_Real ANY, const Standard_Real ANZ, const Standard_Boolean FlagNormalise) { - MyDX = (Standard_ShortReal ) ANX, - MyDY = (Standard_ShortReal ) ANY, - MyDZ = (Standard_ShortReal ) ANZ; -} - -void Graphic3d_VertexN::Normal (Standard_Real& ANX, Standard_Real& ANY, Standard_Real& ANZ) const { - ANX = MyDX, - ANY = MyDY, - ANZ = MyDZ; -} diff --git a/src/Graphic3d/Graphic3d_VertexNC.cdl b/src/Graphic3d/Graphic3d_VertexNC.cdl deleted file mode 100755 index 878c5f274d..0000000000 --- a/src/Graphic3d/Graphic3d_VertexNC.cdl +++ /dev/null @@ -1,110 +0,0 @@ --- Created by: NW,JPB,CAL --- Copyright (c) 1991-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: 03-02-98 : FMN ; Add Flag Normal - -class VertexNC from Graphic3d inherits VertexN from Graphic3d - - ---Version: - - ---Purpose: This class allows the creation of a vertex with - -- a colour and a 3D normal. - - ---Keywords: Vertex, Normal, Color, Coordinate, Point - - ---Warning: - ---References: - -uses - - Color from Quantity, - - Vector from Graphic3d, - Vertex from Graphic3d - -is - - Create - returns VertexNC from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates 0.0, 0.0, 0.0 - -- for which the normal is 0.0, 0.0, 1.0 and - -- the colour is Quantity_NOC_WHITE. - - Create ( AX, AY, AZ : Real from Standard; - ANX, ANY, ANZ : Real from Standard; - AColor : Color from Quantity; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexNC from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates , , - -- for which the normal is , , and - -- the colour is . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - Create ( APoint : Vertex from Graphic3d; - AVector : Vector from Graphic3d; - AColor : Color from Quantity; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexNC from Graphic3d; - ---Level: Public - ---Purpose: Creates a point in for which the normal - -- is and the colour is . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetColor ( me : in out; - ColorNew : Color from Quantity ) - is static; - ---Level: Public - ---Purpose: Modifies the colour of the point . - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Color ( me ) - returns Color from Quantity - is static; - ---Level: Public - ---Purpose: Returns the colour of the point . - ---Category: Inquire methods - --- - -fields - --- --- Class : Graphic3d_VertexNC --- --- Purpose : Declaration of variables specific to points --- --- Reminder : A point is defined by its coordinates, its normal --- and its colour. - - -- the colour - MyColor : Color from Quantity; - -end VertexNC; diff --git a/src/Graphic3d/Graphic3d_VertexNC.cxx b/src/Graphic3d/Graphic3d_VertexNC.cxx deleted file mode 100755 index 40a79dba36..0000000000 --- a/src/Graphic3d/Graphic3d_VertexNC.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// Created by: NW,JPB,CAL -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Modified: 03-02-98 : FMN ; Add Flag Normal - - -//-Version - -//-Design Declaration of variables specific to points - -//-Warning A point is defined by its coordinates, normal -// and color - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions - -// -- the color -// MyColor : Color; - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic3d_VertexNC::Graphic3d_VertexNC (): -Graphic3d_VertexN (0.0, 0.0, 0.0, 0.0, 0.0, 1.0) { - -Quantity_Color AColor (Quantity_NOC_WHITE); - - MyColor = AColor; - -} - -// :(AX, AY, AZ) as VertexNC inherits VertexN and it is necessary to call -// constructor of VertexN with AX, AY, AZ, ANX, ANY and ANZ to -// update fields. - -Graphic3d_VertexNC::Graphic3d_VertexNC (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, const Standard_Real ANX, const Standard_Real ANY, const Standard_Real ANZ, const Quantity_Color& AColor,const Standard_Boolean FlagNormalise): -Graphic3d_VertexN (AX, AY, AZ, ANX, ANY, ANZ,FlagNormalise), -MyColor (AColor) { -} - -// :(APoint, AVector) as VertexNC inherits VertexN and it is necessary to call -// constructor of VertexN with APoint and AVector to -// update fields. - -Graphic3d_VertexNC::Graphic3d_VertexNC (const Graphic3d_Vertex& APoint, const Graphic3d_Vector& AVector, const Quantity_Color& AColor,const Standard_Boolean FlagNormalise): -Graphic3d_VertexN (APoint, AVector,FlagNormalise), -MyColor (AColor) { -} - -Quantity_Color Graphic3d_VertexNC::Color () const { - - return (MyColor); - -} - -void Graphic3d_VertexNC::SetColor (const Quantity_Color& ColorNew) { - - MyColor = ColorNew; - -} diff --git a/src/Graphic3d/Graphic3d_VertexNT.cdl b/src/Graphic3d/Graphic3d_VertexNT.cdl deleted file mode 100755 index 0d4b323456..0000000000 --- a/src/Graphic3d/Graphic3d_VertexNT.cdl +++ /dev/null @@ -1,112 +0,0 @@ --- Created on: 1997-09-27 --- Created by: PCT --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: 03-02-98 : FMN ; Add Flag Normal - -class VertexNT from Graphic3d inherits VertexN from Graphic3d - - ---Version: - - ---Purpose: This class allows the creation and update of - -- a vertex with a 3D normal and texture coordinate. - - ---Keywords: Vertex, Normal, Coordinate, Point, Texture - - ---Warning: - ---References: - -uses - - Vector from Graphic3d, - Vertex from Graphic3d - -is - - Create - returns VertexNT from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with 0.0, 0.0, 0.0 coordinates - -- for which the normal is 0.0, 0.0, 1.0. - -- texture coordinate is 0.0, 0.0. - - Create ( AX, AY, AZ : Real from Standard; - ANX, ANY, ANZ : Real from Standard; - ATX : Real from Standard; - ATY : Real from Standard = 0.0; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexNT from Graphic3d; - ---Level: Public - ---Purpose: Creates a point with coordinates , , and - -- for which the normal is , , , - -- texture coordinate is , . - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - Create ( APoint : Vertex from Graphic3d; - AVector : Vector from Graphic3d; - ATX : Real from Standard; - ATY : Real from Standard = 0.0; - FlagNormalise : Boolean from Standard = Standard_True ) - returns VertexNT from Graphic3d; - ---Level: Public - ---Purpose: Creates a point in for which the normal is . - -- , are texture coordinate. - -- If is True the normal is already normalised - -- Else the normal is not normalised, the graphic do it. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetTextureCoordinate( me : in out; - ATX : Real from Standard; - ATY : Real from Standard = 0.0) - is static; - ---Level: Public - ---Purpose: Modifies the texture coordinate to the point . - ---Category: Methods to modify the class definition - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - TextureCoordinate( me; - ATX, ATY : out Real from Standard) - is static; - ---Level: Public - ---Purpose: Returns the texture coordinate to the point . - ---Category: Inquire methods - --- - -fields - --- --- Class : Graphic3d_VertexNT --- --- Purpose : Declaration of variables specific to points. --- --- Reminder : A point is defined by its coordinates and its normal. - - -- the texel - MyTX, MyTY : Real from Standard; - -end VertexNT; diff --git a/src/Graphic3d/Graphic3d_VertexNT.cxx b/src/Graphic3d/Graphic3d_VertexNT.cxx deleted file mode 100755 index 7918497d8d..0000000000 --- a/src/Graphic3d/Graphic3d_VertexNT.cxx +++ /dev/null @@ -1,81 +0,0 @@ -// Created on: 1997-08-27 -// Created by: PCT -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Modified: 03-02-98 : FMN ; Add Flag Normal - - -//-Version - -//-Design Declaration des variables specifiques aux points - -//-Warning Un point est defini par ses coordonnees et sa normale et des coordonnees texture - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions - -// -- la normale au point -// MyTX, MyTY : Standard_Real; - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic3d_VertexNT::Graphic3d_VertexNT (): -Graphic3d_VertexN (0.0, 0.0, 0.0, 0.0, 0.0, 1.0), -MyTX(0.0), -MyTY(0.0) { -} - -Graphic3d_VertexNT::Graphic3d_VertexNT (const Standard_Real AX, const Standard_Real AY, const Standard_Real AZ, const Standard_Real ANX, const Standard_Real ANY, const Standard_Real ANZ,const Standard_Real ATX,const Standard_Real ATY,const Standard_Boolean FlagNormalise): -Graphic3d_VertexN (0.0, 0.0, 0.0, 0.0, 0.0, 1.0,FlagNormalise), -MyTX(ATX), -MyTY(ATY) { -} - -Graphic3d_VertexNT::Graphic3d_VertexNT (const Graphic3d_Vertex& APoint, const Graphic3d_Vector& AVector,const Standard_Real ATX,const Standard_Real ATY,const Standard_Boolean FlagNormalise): -Graphic3d_VertexN (APoint, AVector,FlagNormalise), -MyTX(ATX), -MyTY(ATY) { -} - -void Graphic3d_VertexNT::SetTextureCoordinate(const Standard_Real ATX,const Standard_Real ATY) -{ - MyTX = ATX; - MyTY = ATY; -} - -void Graphic3d_VertexNT::TextureCoordinate(Standard_Real& ATX,Standard_Real& ATY) const -{ - ATX = MyTX; - ATY = MyTY; -} diff --git a/src/InterfaceGraphic/FILES b/src/InterfaceGraphic/FILES index 0e5a9514c9..000f871796 100755 --- a/src/InterfaceGraphic/FILES +++ b/src/InterfaceGraphic/FILES @@ -15,4 +15,3 @@ InterfaceGraphic_PrimitiveArray.hxx InterfaceGraphic_telem.hxx InterfaceGraphic_degeneration.hxx InterfaceGraphic_tgl_all.hxx -InterfaceGraphic_Cextern.hxx diff --git a/src/InterfaceGraphic/InterfaceGraphic_Cextern.hxx b/src/InterfaceGraphic/InterfaceGraphic_Cextern.hxx deleted file mode 100755 index 2e9a516fd1..0000000000 --- a/src/InterfaceGraphic/InterfaceGraphic_Cextern.hxx +++ /dev/null @@ -1,1143 +0,0 @@ -// Copyright (c) 1991-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -/* - * Attention, ce fichier passe par InterfaceGraphic_Cextern.awk. - * Il faut donc respecter le format de declaration des fonctions. - * Voir les regles precedees par ! - * - * EXPORT call_ ( - * #ifdef INTERFACEGRAPHIC_PROTOTYPE ! ne pas changer son nom mais facultatif - * , ! virgule collee au nom - * * ! * collee au nom - * ! une declaration d'argument par ligne - * #endif ! facultatif - * ); ! ); ensembles sur une ligne - * ! et en premiere colonne - * - * Merci, CAL - * - * Fonctions enlevees le 6/3/97 - * - * call_togl_light - * call_togl_plane - * call_togl_text3 - * call_togl_light_exploration - * call_togl_build_matrix - * call_tox_xgrigri - * call_tox_set_colormap_mapping - * call_util_osd_getenv - * - * 5/08/97 ; PCT : ajout texture mapping - * 17/09/98 ; FMN/BGN : ajout (S3819) des Ponts d'entree du Triedre. - * 15/11/99 ; GG PRO603 Add call_togl_redraw_area - * 24/01/00 ; EUG G003 Add call_togl_degeneratestructure() and - * call_togl_backfacing() functions. - * 27/0302 ; GG RIC120302 Add call_togl_begin_display function - * 16/06/2000 : ATS : G005 : Add function call_togl_parray - * 23/10/01 ; SAV Add call_togl_depthtest() - * call_togl_isdepthtest() - * 25/10/01 ; SAV Add call_togl_gllight() - * call_togl_isgllight() - * 23/12/02 ; SAV Added call_togl_create_bg_texture() and - * call_togl_set_bg_texture_style() to set background image - * 15/08/05 ; SZV Added call_togl_userdraw() - * - */ - -#ifndef InterfaceGraphic_CexternHeader -#define InterfaceGraphic_CexternHeader - -#if defined (__STDC__) || defined (__cplusplus) || defined (c_plusplus) -#define INTERFACEGRAPHIC_PROTOTYPE 1 -#endif - -#define InterfaceGraphic_True 1 -#define InterfaceGraphic_False 0 - -#define InterfaceGraphic_Success 1 -#define InterfaceGraphic_Failure 0 - -#define OCC1188 /* SAV : added methods to set background image */ - -#include -#include -#include -#include - -#include - -#define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing - from higher API */ -#define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting - from higher API */ - - /* Declarations des subroutines triedron */ - -void EXPORT call_togl_ztriedron_setup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float* xcolor, - float* ycolor, - float* zcolor, - float sizeratio, - float axisdiameter, - int nbfacettes -#endif -); - -void EXPORT call_togl_triedron_display ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW * aview, - int APosition, - float r, - float g, - float b, - float AScale, - int asWireframe -#endif -); - -void EXPORT call_togl_triedron_erase ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_triedron_echo ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int AType -#endif -); - - /* Declarations des subroutines mode immediat */ - -int EXPORT call_togl_begin_ajout_mode ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_end_ajout_mode ( -); - -int EXPORT call_togl_begin_immediat_mode ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_LAYER *anunderlayer, - CALL_DEF_LAYER *anoverlayer, - int doublebuffer, - int retainmode -#endif -); - -void EXPORT call_togl_end_immediat_mode ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int synchronize -#endif -); - -void EXPORT call_togl_clear_immediat_mode ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int aFlush -#endif -); - -void EXPORT call_togl_transform ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_MATRIX4X4 amatrix, - int mode -#endif -); - -void EXPORT call_togl_begin_polyline ( -); - -void EXPORT call_togl_end_polyline ( -); - -void EXPORT call_togl_begin_polygon ( -); - -void EXPORT call_togl_end_polygon ( -); - -void EXPORT call_togl_begin_trianglemesh ( -); - -void EXPORT call_togl_end_trianglemesh ( -); - -void EXPORT call_togl_begin_marker ( -); - -void EXPORT call_togl_end_marker ( -); - -void EXPORT call_togl_begin_bezier ( -); - -void EXPORT call_togl_end_bezier ( -); - -void EXPORT call_togl_move ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z -#endif -); - -void EXPORT call_togl_movenormal ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z, - float nx, - float ny, - float nz -#endif -); - -void EXPORT call_togl_moveweight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z, - float w -#endif -); - -void EXPORT call_togl_draw ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z -#endif -); - -void EXPORT call_togl_drawnormal ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z, - float nx, - float ny, - float nz -#endif -); - -void EXPORT call_togl_drawweight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float z, - float w -#endif -); - -void EXPORT call_togl_draw_text ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_TEXT *atext -#endif -); - -void EXPORT call_togl_draw_structure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int StructId -#endif -); - -void EXPORT call_togl_set_linecolor ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_set_interiorcolor ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_set_linetype ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long type -#endif -); - -void EXPORT call_togl_set_interiortype ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long type -#endif -); - -void EXPORT call_togl_set_linewidth ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float width -#endif -); - -void EXPORT call_togl_set_textcolor ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_set_textfont ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - char *police, - float factor, - float space -#endif -); - -void EXPORT call_togl_set_markercolor ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_set_markertype ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long type, - float scale -#endif -); - -void EXPORT call_togl_set_minmax ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x1, - float y1, - float z1, - float x2, - float y2, - float z2 -#endif -); - -void EXPORT call_togl_set_rgb ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - - /* Declarations des subroutines appelees du C++ */ - /* dans les packages Graphic3d et Visual3d */ - -void EXPORT call_togl_opengroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_closegroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_cleargroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_linecontextgroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - int noinsert -#endif -); - -void EXPORT call_togl_facecontextgroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - int noinsert -#endif -); - -void EXPORT call_togl_markercontextgroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - int noinsert -#endif -); - -void EXPORT call_togl_textcontextgroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - int noinsert -#endif -); - -void EXPORT call_togl_group ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_marker ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_MARKER *amarker -#endif -); - -void EXPORT call_togl_marker_set ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTMARKERS *almarkers -#endif -); - -void EXPORT call_togl_polyline ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTPOINTS *alpoints -#endif -); - -void EXPORT call_togl_polygon ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_FACET *afacet -#endif -); - -void EXPORT call_togl_polygon_holes ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTFACETS *alfacets -#endif -); - -void EXPORT call_togl_polygon_indices ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTPOINTS *alpoints, - CALL_DEF_LISTEDGES *aledges, - CALL_DEF_LISTINTEGERS *albounds -#endif -); - -void EXPORT call_togl_pickid ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_quadrangle ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_QUAD *aquad -#endif -); - -void EXPORT call_togl_removegroup ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup -#endif -); - -void EXPORT call_togl_text ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_TEXT *atext -#endif -); - -void EXPORT call_togl_triangle ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_TRIKE *atrike -#endif -); - -void EXPORT call_togl_bezier ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTPOINTS *alpoints -#endif -); - -void EXPORT call_togl_bezier_weight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_LISTPOINTS *alpoints, - CALL_DEF_LISTREALS *alweights -#endif -); - -void EXPORT call_togl_blink ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure, - int create -#endif -); - -void EXPORT call_togl_boundarybox ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure, - int create -#endif -); - -void EXPORT call_togl_clearstructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_contextstructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_highlightcolor ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure, - CALL_DEF_COLOR *acolor, - int create -#endif -); - -void EXPORT call_togl_namesetstructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_removestructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_structure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_transformstructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_degeneratestructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *astructure -#endif -); - -void EXPORT call_togl_connect ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *afather, - CALL_DEF_STRUCTURE *ason -#endif -); - -void EXPORT call_togl_disconnect ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_STRUCTURE *afather, - CALL_DEF_STRUCTURE *ason -#endif -); - -int EXPORT call_togl_begin_animation ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_end_animation ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -int EXPORT call_togl_begin ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - char *adisplay -#endif -); - -/*RIC120302*/ -int EXPORT call_togl_begin_display ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - void *pdisplay -#endif -); -/*RIC120302*/ - -void EXPORT call_togl_end ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -void EXPORT call_togl_structure_exploration ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long Id, - long LabelBegin, - long LabelEnd -#endif -); - -void EXPORT call_togl_element_exploration ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long Id, - long elem_num, - long *type, - CALL_DEF_POINT *pt, - CALL_DEF_NORMAL *npt, - CALL_DEF_COLOR *cpt, - CALL_DEF_NORMAL *nfa -#endif -); - -void EXPORT call_togl_element_type ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long Id, - long elem_num, - long *type -#endif -); - -void EXPORT call_togl_activateview ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_antialiasing ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int tag -#endif -); - -void EXPORT call_togl_background ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_gradient_background -( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int ws, int type, - tel_colour color1, - tel_colour color2 -#endif -); - -void EXPORT call_togl_set_gradient_type -( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int ws, int type -#endif -); - -int EXPORT call_togl_project_raster ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int wsid, - float x, - float y, - float z, - int *ixr, - int *iyr -#endif -); - -int EXPORT call_togl_unproject_raster ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int wsid, - int xm, - int ym, - int xM, - int yM, - int ixr, - int iyr, - float *x, - float *y, - float *z -#endif -); - -int EXPORT call_togl_unproject_raster_with_ray ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int wsid, - int xm, - int ym, - int xM, - int yM, - int ixr, - int iyr, - float *x, - float *y, - float *z, - float *dx, - float *dy, - float *dz -#endif -); - -void EXPORT call_togl_cliplimit ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int wait -#endif -); - -void EXPORT call_togl_deactivateview ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_depthcueing ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int tag -#endif -); - -void EXPORT call_togl_displaystructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int StructId, - int Priority -#endif -); - -void EXPORT call_togl_erasestructure ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int ViewId, - int StructId -#endif -); - -void EXPORT call_togl_init_pick ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -void EXPORT call_togl_pick ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_PICK *apick -#endif -); - -void EXPORT call_togl_ratio_window ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_redraw ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_LAYER *anunderlayer, - CALL_DEF_LAYER *anoverlayer -#endif -); - -void EXPORT call_togl_redraw_area ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_LAYER *anunderlayer, - CALL_DEF_LAYER *anoverlayer, - int x, int y, int width, int height -#endif -); - -void EXPORT call_togl_removeview ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_setlight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_setplane ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_setvisualisation ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_transparency ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int WsId, - int ViewId, - int Activity -#endif -); - -void EXPORT call_togl_update ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_LAYER *anunderlayer, - CALL_DEF_LAYER *anoverlayer -#endif -); - -int EXPORT call_togl_view ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -int EXPORT call_togl_viewmapping ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int wait -#endif -); - -int EXPORT call_togl_vieworientation ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int wait -#endif -); - -int EXPORT call_togl_inquiretexture ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -int EXPORT call_togl_inquirelight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -int EXPORT call_togl_inquireplane ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -int EXPORT call_togl_inquireview ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE -#endif -); - -int EXPORT call_togl_inquiremat ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_MATRIX4X4 ori_matrix, - CALL_DEF_MATRIX4X4 map_matrix -#endif -); - -void EXPORT call_togl_view_exploration ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long Id -#endif -); - -#ifdef OCC1188 -int EXPORT call_togl_create_texture ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int Type, - unsigned int Width, - unsigned int Height, - unsigned char *Data, - char *FileName -#endif -); - -void EXPORT call_togl_create_bg_texture ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int width, - int height, - unsigned char *data, - int style -#endif -); -#endif /* OCC1188 */ - -void EXPORT call_togl_set_bg_texture_style( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW* aview, - int style -#endif -); - -void EXPORT call_togl_destroy_texture ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int TexId -#endif -); - -void EXPORT call_togl_modify_texture ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - int TexId, - CALL_DEF_INIT_TEXTURE *init_tex -#endif -); - -void EXPORT call_togl_environment ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - - /* Declarations des subroutines layer mode */ - -void EXPORT call_togl_layer2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_LAYER *alayer -#endif -); - -void EXPORT call_togl_removelayer2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_LAYER *alayer -#endif -); - -void EXPORT call_togl_begin_layer2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_LAYER *alayer -#endif -); - -void EXPORT call_togl_end_layer2d ( -); - -void EXPORT call_togl_clear_layer2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_LAYER *alayer -#endif -); - -void EXPORT call_togl_begin_polyline2d ( -); - -void EXPORT call_togl_end_polyline2d ( -); - -void EXPORT call_togl_begin_polygon2d ( -); - -void EXPORT call_togl_end_polygon2d ( -); - -void EXPORT call_togl_move2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y -#endif -); - -void EXPORT call_togl_draw2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y -#endif -); - -void EXPORT call_togl_edge2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y -#endif -); - -void EXPORT call_togl_rectangle2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float x, - float y, - float w, - float h -#endif -); - -void EXPORT call_togl_set_color ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_set_transparency ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float a -#endif -); - -void EXPORT call_togl_unset_transparency ( -); - -void EXPORT call_togl_set_line_attributes ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - long type, - float width -#endif -); - -void EXPORT call_togl_set_text_attributes ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - char* font, - long type, - float r, - float g, - float b -#endif -); - -void EXPORT call_togl_text2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - char *s, - float x, - float y, - float height -#endif -); - -void EXPORT call_togl_textsize2d ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - char *s, - float height, - float *width, - float *ascent, - float *descent -#endif -); - -void EXPORT call_togl_backfacing ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW* -#endif /* INTERFACEGRAPHIC_PROTOTYPE */ - ); - -/* *** group of parray functions *** */ - -void EXPORT call_togl_parray ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_PARRAY* parray -#endif -); - -void EXPORT call_togl_userdraw ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_GROUP *agroup, - CALL_DEF_USERDRAW *anobject -#endif -); - -/* ------------------------- */ -void EXPORT call_togl_print ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - CALL_DEF_LAYER *anunderlayer, - CALL_DEF_LAYER *anoverlayer, - const Aspect_Drawable hPrintDC, - const int background, - const char* filename -#endif -); - - -#ifdef BUC61044 -void EXPORT call_togl_depthtest ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int dFlag -#endif -); - -int EXPORT call_togl_isdepthtest ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); -#endif - -#ifdef BUC61045 -void EXPORT call_togl_gllight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview, - int dFlag -#endif -); - -int EXPORT call_togl_isgllight ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - CALL_DEF_VIEW *aview -#endif -); - -void EXPORT call_togl_graduatedtrihedron_display ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - /* View id */ - CALL_DEF_VIEW* aview, - /* Graduated trihedron data */ - const Graphic3d_CGraduatedTrihedron &cubic -#endif -); - -void EXPORT call_togl_graduatedtrihedron_erase ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - /* View id */ - CALL_DEF_VIEW* aview -#endif -); - -void EXPORT call_togl_graduatedtrihedron_minmaxvalues ( -#ifdef INTERFACEGRAPHIC_PROTOTYPE - float xmin, - float ymin, - float zmin, - float xmax, - float ymax, - float zmax -#endif -); - -#endif - -#endif /* InterfaceGraphic_CexternHeader */ diff --git a/src/InterfaceGraphic/InterfaceGraphic_telem.hxx b/src/InterfaceGraphic/InterfaceGraphic_telem.hxx index 2d42dd8b59..ef749744ad 100755 --- a/src/InterfaceGraphic/InterfaceGraphic_telem.hxx +++ b/src/InterfaceGraphic/InterfaceGraphic_telem.hxx @@ -44,9 +44,10 @@ struct TEL_TEXTURE_COORD typedef TEL_TEXTURE_COORD* tel_texture_coord; -struct TEL_POINT +class TEL_POINT { - float xyz[3]; + public: + float xyz[3]; DEFINE_STANDARD_ALLOC }; typedef TEL_POINT* tel_point; diff --git a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx index e37b6e60af..32304c5a7a 100755 --- a/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_ElementalColorPrsBuilder.cxx @@ -18,18 +18,13 @@ // and conditions governing the rights and limitations under the License. -#define _POLYGONES_ -// if define _POLYGONES_ ColorPrsBuilder use ArrayOfPolygons for drawing faces - #include #include #include #include #include -#include #include -#include #include #include @@ -375,18 +370,14 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& if ( IsPolyG ) { aGGroup->SetPrimitivesAspect ( anAsp ); - aGGroup->BeginPrimitives(); aGGroup->AddPrimitiveArray ( aPolyGArr ); - aGGroup->EndPrimitives(); } if ( IsPolyL ) { anAsp->SetEdgeOff(); aLGroup->SetPrimitivesAspect ( anAsp ); aLGroup->SetPrimitivesAspect ( anLAsp ); - aLGroup->BeginPrimitives(); aLGroup->AddPrimitiveArray ( aPolyLArr ); - aLGroup->EndPrimitives(); if (anEdgeOn) anAsp->SetEdgeOn(); else @@ -446,10 +437,8 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& if ( aSize<=0 ) continue; -#ifdef _POLYGONES_ Handle (Graphic3d_ArrayOfPolygons) aPolyArr = new Graphic3d_ArrayOfPolygons ( aMaxFaceNodes*aSize, aSize, 0, IsReflect ); -#endif MeshVS_TwoColors aTC = aColIter2.Key(); Quantity_Color aMyIntColor, aMyBackColor; @@ -469,7 +458,6 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& anAsp->SetEdgeOff(); aGroup2->SetPrimitivesAspect ( anAsp ); - aGroup2->BeginPrimitives(); for( it.Reset(); it.More(); it.Next() ) { @@ -491,15 +479,10 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Standard_Boolean hasNormals = /*IsReflect &&*/ aSource->GetNormalsByElement( aKey, IsMeshSmoothShading, aMaxFaceNodes, aNormals ); -#ifdef _POLYGONES_ aPolyArr->AddBound ( NbNodes ); -#else - Graphic3d_Array1OfVertex aVertArr ( 1, NbNodes ); -#endif for ( i=1; i<=NbNodes; i++ ) { -#ifdef _POLYGONES_ if ( IsReflect ) { hasNormals ? aPolyArr->AddVertex ( aCoords(3 * i - 2), @@ -519,43 +502,11 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& aPolyArr->AddVertex ( aCoords(3*i-2), aCoords(3*i-1), aCoords(3*i ) ); -#else - if ( IsReflect ) - { - aVertArr (i) = hasNormals ? Graphic3d_VertexN( aCoords(3 * i - 2), - aCoords(3 * i - 1), - aCoords(3 * i ), - aNormals->Value(3 * i - 2), - aNormals->Value(3 * i - 1), - aNormals->Value(3 * i ), - Standard_False ) : - Graphic3d_VertexN( aCoords(3 * i - 2), - aCoords(3 * i - 1), - aCoords(3 * i ), - 0., - 0., - 1., - Standard_False ); - - } - else - Graphic3d_Vertex ( aCoords(3 * i - 2), - aCoords(3 * i - 1), - aCoords(3 * i ) ); -#endif } - - -#ifndef _POLYGONES_ - aGroup2->Polygon ( aVertArr ); -#endif } } } -#ifdef _POLYGONES_ aGroup2->AddPrimitiveArray ( aPolyArr ); -#endif - aGroup2->EndPrimitives(); } } diff --git a/src/MeshVS/MeshVS_MeshEntityOwner.cxx b/src/MeshVS/MeshVS_MeshEntityOwner.cxx index bfd2de7734..c28cd6a7d9 100755 --- a/src/MeshVS/MeshVS_MeshEntityOwner.cxx +++ b/src/MeshVS/MeshVS_MeshEntityOwner.cxx @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx index 4c56617bdc..dce4b8932f 100755 --- a/src/MeshVS/MeshVS_MeshPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_MeshPrsBuilder.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -155,10 +156,7 @@ void MeshVS_MeshPrsBuilder::BuildNodes ( const Handle(Prs3d_Presentation)& Prs, Prs3d_Root::NewGroup ( Prs ); Handle (Graphic3d_Group) aNodeGroup = Prs3d_Root::CurrentGroup ( Prs ); aNodeGroup->SetPrimitivesAspect ( aNodeMark ); - - aNodeGroup->BeginPrimitives(); aNodeGroup->MarkerSet ( aNodePoints ); - aNodeGroup->EndPrimitives(); } } @@ -347,14 +345,6 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs // add shading presentation if ( ( IsShading || IsShrink ) && !HasSelectFlag ) AddVolumePrs ( aTopo, aCoords, NbNodes, aVolumes, IsReflect, IsShrink, HasSelectFlag, aShrinkCoef ); - - /* - Handle( Graphic3d_ArrayOfPrimitives ) anArr = aVolumes; - if( IsWireFrame || HasSelectFlag ) - anArr = aPolylines; - - AddVolumePrs ( aTopo, aCoords, NbNodes, anArr, IsReflect, IsShrink, HasSelectFlag, aShrinkCoef ); - */ } break; @@ -492,26 +482,21 @@ void MeshVS_MeshPrsBuilder::BuildHilightPrs ( const Handle(Prs3d_Presentation)& case MeshVS_ET_Link: { aHilightGroup->SetPrimitivesAspect ( aBeam ); - aHilightGroup->Polyline ( Graphic3d_Vertex ( aCoords(1), aCoords(2), aCoords(3) ), - Graphic3d_Vertex ( aCoords(4), aCoords(5), aCoords(6) ) ); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(aCoords(1),aCoords(2),aCoords(3)); + aPrims->AddVertex(aCoords(4),aCoords(5),aCoords(6)); + aHilightGroup->AddPrimitiveArray(aPrims); } break; case MeshVS_ET_Face: if ( NbNodes > 0 ) { - Standard_Real X, Y, Z; aHilightGroup->SetPrimitivesAspect ( aFill ); - Graphic3d_Array1OfVertex aVArr ( 1, NbNodes ); - + Handle(Graphic3d_ArrayOfPolygons) aPrims = new Graphic3d_ArrayOfPolygons(NbNodes); for ( Standard_Integer k=1; k<=NbNodes; k++) - { - X = aCoords(3*k-2); - Y = aCoords(3*k-1); - Z = aCoords(3*k); - aVArr.SetValue ( k, Graphic3d_Vertex ( X, Y, Z ) ); - } - aHilightGroup->Polygon ( aVArr ); + aPrims->AddVertex(aCoords(3*k-2),aCoords(3*k-1),aCoords(3*k)); + aHilightGroup->AddPrimitiveArray(aPrims); } break; @@ -524,21 +509,25 @@ void MeshVS_MeshPrsBuilder::BuildHilightPrs ( const Handle(Prs3d_Presentation)& if( aSource->Get3DGeom( ID, NbNodes, aTopo ) ) { - Standard_Integer low = aTopo->Lower(), up = aTopo->Upper(), i, j, m, ind; - for( i=low; i<=up; i++ ) + const Standard_Integer up = aTopo->Upper(); + const Standard_Integer lo = aTopo->Lower(); + Standard_Integer nbnodes = 0, i, j; + for( i=lo; i<=up; i++ ) + nbnodes += aTopo->Value( i ).Length(); + + Handle(Graphic3d_ArrayOfPolygons) aPrims = new Graphic3d_ArrayOfPolygons(nbnodes,aTopo->Length()); + for( i=lo; i<=up; i++ ) { const TColStd_SequenceOfInteger& aSeq = aTopo->Value( i ); - m = aSeq.Length(); - Graphic3d_Array1OfVertex aVArr( 1, m ); + const Standard_Integer m = aSeq.Length(); + aPrims->AddBound(m); for( j=1; j<=m; j++ ) { - ind = aSeq.Value( j ); - aVArr.SetValue( j, Graphic3d_Vertex( aCoords( 3*ind+1 ), - aCoords( 3*ind+2 ), - aCoords( 3*ind+3 ) ) ); + const Standard_Integer ind = 3*aSeq.Value( j ); + aPrims->AddVertex(aCoords(ind+1),aCoords(ind+2),aCoords(ind+3)); } - aHilightGroup->Polygon ( aVArr ); } + aHilightGroup->AddPrimitiveArray(aPrims); } } break; @@ -933,9 +922,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, if( IsFacePolygons ) { aGroup->SetPrimitivesAspect ( theFillAsp ); - aGroup->BeginPrimitives (); aGroup->AddPrimitiveArray ( thePolygons ); - aGroup->EndPrimitives (); } if( IsVolumePolygons ) @@ -952,9 +939,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, aCullFillAsp->SuppressBackFace(); aGroup->SetPrimitivesAspect ( aCullFillAsp ); - aGroup->BeginPrimitives (); aGroup->AddPrimitiveArray ( theVolumesInShad ); - aGroup->EndPrimitives (); } } @@ -972,9 +957,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, aLGroup->SetPrimitivesAspect ( new Graphic3d_AspectLine3d ( anEdgeColor, Aspect_TOL_SOLID, aWidth ) ); } - aLGroup->BeginPrimitives (); aLGroup->AddPrimitiveArray ( theLines ); - aLGroup->EndPrimitives (); theFillAsp->SetEdgeOn(); } @@ -987,10 +970,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, if ( !IsSelected ) aBeamGroup->SetPrimitivesAspect ( theFillAsp ); aBeamGroup->SetPrimitivesAspect ( theLineAsp ); - - aBeamGroup->BeginPrimitives(); aBeamGroup->AddPrimitiveArray ( theLinkLines ); - aBeamGroup->EndPrimitives(); theFillAsp->SetEdgeOn(); } @@ -1012,9 +992,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, if( IsFacePolygons ) { aGroup->SetPrimitivesAspect ( theFillAsp ); - aGroup->BeginPrimitives (); aGroup->AddPrimitiveArray ( thePolygons ); - aGroup->EndPrimitives (); } if( IsVolumePolygons ) @@ -1031,9 +1009,7 @@ void MeshVS_MeshPrsBuilder::DrawArrays( const Handle(Prs3d_Presentation)& Prs, aCullFillAsp->SuppressBackFace(); aGroup->SetPrimitivesAspect ( aCullFillAsp ); - aGroup->BeginPrimitives (); aGroup->AddPrimitiveArray ( theVolumesInShad ); - aGroup->EndPrimitives (); } } } diff --git a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx index 566f3f7899..8651e71942 100755 --- a/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_NodalColorPrsBuilder.cxx @@ -27,9 +27,7 @@ #include #include #include -#include #include -#include #include #include @@ -59,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -531,9 +528,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, Handle(Graphic3d_Group) aGroup1 = Prs3d_Root::CurrentGroup ( Prs ); aGroup1->SetPrimitivesAspect( anAsp ); - aGroup1->BeginPrimitives(); aGroup1->AddPrimitiveArray( aCPolyArr ); - aGroup1->EndPrimitives(); if (aShowEdges) { @@ -544,9 +539,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, anAsp->SetTextureMapOff(); aGroup2->SetPrimitivesAspect( anAsp ); aGroup2->SetPrimitivesAspect( anLAsp ); - aGroup2->BeginPrimitives(); aGroup2->AddPrimitiveArray( aPolyL ); - aGroup2->EndPrimitives(); anAsp->SetEdgeOn(); } } diff --git a/src/MeshVS/MeshVS_TextPrsBuilder.cxx b/src/MeshVS/MeshVS_TextPrsBuilder.cxx index 24c0475fd9..ecfc6c3847 100755 --- a/src/MeshVS/MeshVS_TextPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_TextPrsBuilder.cxx @@ -203,8 +203,6 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, aTextGroup->SetPrimitivesAspect( aTextAspect ); aTextGroup->SetPrimitivesAspect( anAspectMarker3d ); - aTextGroup->BeginPrimitives(); - MeshVS_Buffer aCoordsBuf (3*aMaxFaceNodes*sizeof(Standard_Real)); TColStd_Array1OfReal aCoords (aCoordsBuf, 1, 3*aMaxFaceNodes); Standard_Integer NbNodes; @@ -270,8 +268,6 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, } } - aTextGroup->EndPrimitives(); - if (!aCustomElements.IsEmpty()) CustomBuild ( Prs, aCustomElements, IDsToExclude, theDisplayMode ); } diff --git a/src/MeshVS/MeshVS_VectorPrsBuilder.cxx b/src/MeshVS/MeshVS_VectorPrsBuilder.cxx index 689f6697d3..8a94c7623c 100755 --- a/src/MeshVS/MeshVS_VectorPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_VectorPrsBuilder.cxx @@ -339,10 +339,8 @@ void MeshVS_VectorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, new Graphic3d_AspectLine3d ( aColor, Aspect_TOL_SOLID, 1.5 ); aVGroup->SetPrimitivesAspect( aLinAspect ); - - aVGroup->BeginPrimitives(); aVGroup->AddPrimitiveArray( aLineArray ); - aVGroup->EndPrimitives(); + if ( !myIsSimplePrs ) { Graphic3d_MaterialAspect aMatAspect; @@ -356,10 +354,7 @@ void MeshVS_VectorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, 1., aMatAspect, aMatAspect ); aVGroup->SetPrimitivesAspect( aFillAspect ); - - aVGroup->BeginPrimitives(); aVGroup->AddPrimitiveArray( aTriangleArray ); - aVGroup->EndPrimitives(); } else { @@ -367,10 +362,7 @@ void MeshVS_VectorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, new Graphic3d_AspectLine3d ( aColor, Aspect_TOL_SOLID, mySimpleWidthPrm * 1.5 ); aVGroup->SetPrimitivesAspect( anArrowLinAspect ); - - aVGroup->BeginPrimitives(); aVGroup->AddPrimitiveArray( aArrowLineArray ); - aVGroup->EndPrimitives(); } if( !aCustomElements.IsEmpty() ) diff --git a/src/OpenGl/OpenGl_GraphicDriver.hxx b/src/OpenGl/OpenGl_GraphicDriver.hxx index 41244b59e4..2ca37dce9f 100644 --- a/src/OpenGl/OpenGl_GraphicDriver.hxx +++ b/src/OpenGl/OpenGl_GraphicDriver.hxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -59,13 +58,7 @@ #include #include #include -#include -#include -#include -#include #include -#include -#include #include #include @@ -73,7 +66,6 @@ class TColStd_Array1OfInteger; class TColStd_Array1OfReal; class TColStd_Array2OfReal; class TColStd_HArray1OfByte; -class Graphic3d_VertexNC; class Graphic3d_Vector; class Quantity_Color; class Graphic3d_Vertex; @@ -108,7 +100,6 @@ public: public: // Methods for graphical groups Standard_EXPORT void ClearGroup (const Graphic3d_CGroup& ACGroup); - Standard_EXPORT void CloseGroup (const Graphic3d_CGroup& ACGroup); Standard_EXPORT void FaceContextGroup (const Graphic3d_CGroup& theCGroup, const Standard_Integer theNoInsert); Standard_EXPORT void Group (Graphic3d_CGroup& theCGroup); @@ -121,7 +112,6 @@ public: // Methods for graphical groups const Standard_Integer theMarkWidth, const Standard_Integer theMarkHeight, const Handle(TColStd_HArray1OfByte)& theTexture); - Standard_EXPORT void OpenGroup (const Graphic3d_CGroup& theCGroup); Standard_EXPORT void RemoveGroup (const Graphic3d_CGroup& theCGroup); Standard_EXPORT void TextContextGroup (const Graphic3d_CGroup& theCGroup, const Standard_Integer theNoInsert); @@ -171,9 +161,8 @@ public: Standard_EXPORT void ViewMapping (const Graphic3d_CView& ACView, const Standard_Boolean AWait); Standard_EXPORT void ViewOrientation (const Graphic3d_CView& ACView,const Standard_Boolean AWait); Standard_EXPORT void Environment (const Graphic3d_CView& ACView); - Standard_EXPORT void Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean EvalMinMax = Standard_True); - Standard_EXPORT void MarkerSet (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Standard_Boolean EvalMinMax = Standard_True); - Standard_EXPORT void Polygon (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex, const Graphic3d_TypeOfPolygon AType = Graphic3d_TOP_CONVEX, const Standard_Boolean EvalMinMax = Standard_True); + Standard_EXPORT void Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint); + Standard_EXPORT void MarkerSet (const Graphic3d_CGroup& ACGroup, const Graphic3d_Array1OfVertex& ListVertex); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const Standard_CString AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Standard_Boolean EvalMinMax = Standard_True); Standard_EXPORT void Text (const Graphic3d_CGroup& ACGroup, const TCollection_ExtendedString& AText, const Graphic3d_Vertex& APoint, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta, const Standard_Boolean EvalMinMax = Standard_True); @@ -267,7 +256,6 @@ public: //! Clear visualization data in graphical driver and stop
//! displaying the primitives array of the graphical group .
//! This method is internal and should be used by Graphic3d_Group only.
- Standard_EXPORT void RemovePrimitiveArray(const Graphic3d_CGroup& theCGroup,const Graphic3d_PrimitiveArray& thePArray); Standard_EXPORT Standard_Integer InquirePlaneLimit(); Standard_EXPORT Standard_ShortReal DefaultTextHeight() const; Standard_EXPORT void FBOGetDimensions(const Graphic3d_CView& view,const Graphic3d_PtrFrameBuffer fboPtr,Standard_Integer& width,Standard_Integer& height,Standard_Integer& widthMax,Standard_Integer& heightMax); diff --git a/src/OpenGl/OpenGl_GraphicDriver_3.cxx b/src/OpenGl/OpenGl_GraphicDriver_3.cxx index 7c67c33d62..ccf2348dfc 100755 --- a/src/OpenGl/OpenGl_GraphicDriver_3.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_3.cxx @@ -34,11 +34,6 @@ void OpenGl_GraphicDriver::ClearGroup (const Graphic3d_CGroup& theCGroup) InvalidateAllWorkspaces(); } -void OpenGl_GraphicDriver::CloseGroup (const Graphic3d_CGroup& ) -{ - // Do nothing -} - void OpenGl_GraphicDriver::FaceContextGroup (const Graphic3d_CGroup& theCGroup, const Standard_Integer theNoInsert) { @@ -96,11 +91,6 @@ void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup } } -void OpenGl_GraphicDriver::OpenGroup (const Graphic3d_CGroup& ) -{ - // Do nothing -} - void OpenGl_GraphicDriver::RemoveGroup (const Graphic3d_CGroup& theCGroup) { OpenGl_Structure* aStructure = (OpenGl_Structure* )theCGroup.Struct->ptrStructure; diff --git a/src/OpenGl/OpenGl_GraphicDriver_703.cxx b/src/OpenGl/OpenGl_GraphicDriver_703.cxx index a83c00d5bf..27da505e1f 100755 --- a/src/OpenGl/OpenGl_GraphicDriver_703.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_703.cxx @@ -31,7 +31,7 @@ static void OpenGl_CreateMarkers(const Graphic3d_CGroup& ACGroup, const Standard ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelMarkerSet, amarkerset ); } -void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex& APoint, const Standard_Boolean ) +void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphic3d_Vertex &APoint) { if (!ACGroup.ptrGroup) return; @@ -91,8 +91,7 @@ void OpenGl_GraphicDriver::Marker (const Graphic3d_CGroup& ACGroup, const Graphi } void OpenGl_GraphicDriver::MarkerSet (const Graphic3d_CGroup& ACGroup, - const Graphic3d_Array1OfVertex& ListVertex, - const Standard_Boolean ) + const Graphic3d_Array1OfVertex& ListVertex) { if (!ACGroup.ptrGroup) return; diff --git a/src/OpenGl/OpenGl_GraphicDriver_705.cxx b/src/OpenGl/OpenGl_GraphicDriver_705.cxx index 40bf3ff4f0..e69de29bb2 100755 --- a/src/OpenGl/OpenGl_GraphicDriver_705.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_705.cxx @@ -1,36 +0,0 @@ -// Created on: 2011-10-20 -// Created by: Sergey ZERCHANINOV -// Copyright (c) 2011-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -void OpenGl_GraphicDriver::Polygon (const Graphic3d_CGroup& ACGroup, - const Graphic3d_Array1OfVertex& AListVertex, - const Graphic3d_TypeOfPolygon AType, - const Standard_Boolean ) -{ - if (ACGroup.ptrGroup) - { - OpenGl_Polygon *apolygon = new OpenGl_Polygon( AListVertex, AType ); - ((OpenGl_Group *)ACGroup.ptrGroup)->AddElement( TelPolygon, apolygon ); - } -} diff --git a/src/OpenGl/OpenGl_GraphicDriver_713.cxx b/src/OpenGl/OpenGl_GraphicDriver_713.cxx index b31fb20208..d3b26cfff3 100755 --- a/src/OpenGl/OpenGl_GraphicDriver_713.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_713.cxx @@ -78,23 +78,6 @@ void OpenGl_GraphicDriver::PrimitiveArray( const Graphic3d_CGroup& ACGroup, } } -//======================================================================= -//function : RemovePrimitiveArray -//purpose : Purpose: Clear visualization data in graphical driver and -// stop displaying the primitives array of the graphical group -// . This method is internal and should be used by -// Graphic3d_Group only. -//======================================================================= - -void OpenGl_GraphicDriver::RemovePrimitiveArray (const Graphic3d_CGroup& theCGroup, - const Graphic3d_PrimitiveArray& thePArray) -{ - if (theCGroup.ptrGroup && thePArray) - { - ((OpenGl_Group* )theCGroup.ptrGroup)->RemovePrimitiveArray (GetSharedContext(), thePArray); - } -} - void OpenGl_GraphicDriver::UserDraw (const Graphic3d_CGroup& theCGroup, const Graphic3d_CUserDraw& theUserDraw) { diff --git a/src/OpenGl/OpenGl_Group.cxx b/src/OpenGl/OpenGl_Group.cxx index 4f4e2eb69f..b5788aaea7 100644 --- a/src/OpenGl/OpenGl_Group.cxx +++ b/src/OpenGl/OpenGl_Group.cxx @@ -132,36 +132,6 @@ void OpenGl_Group::AddElement (const TelType AType, OpenGl_Element *AElem ) /*----------------------------------------------------------------------*/ -void OpenGl_Group::RemovePrimitiveArray (const Handle(OpenGl_Context)& theGlCtx, - CALL_DEF_PARRAY* thePArray) -{ - OpenGl_ElementNode *prevnode = NULL, *node = myFirst; - while (node != NULL) - { - if (node->type == TelParray) - { - CALL_DEF_PARRAY* aCurPArray = ((const OpenGl_PrimitiveArray* )node->elem)->PArray(); - - // validate for correct pointer - if (aCurPArray->num_bounds == thePArray->num_bounds && - aCurPArray->num_edges == thePArray->num_edges && - aCurPArray->num_vertexs == thePArray->num_vertexs && - aCurPArray->type == thePArray->type) - { - (prevnode ? prevnode->next : myFirst) = node->next; - if (!myFirst) myLast = NULL; - OpenGl_Element::Destroy (theGlCtx, node->elem); - delete node; - break; - } - } - prevnode = node; - node = node->next; - } -} - -/*----------------------------------------------------------------------*/ - void OpenGl_Group::Render (const Handle(OpenGl_Workspace)& theWorkspace) const { // Is rendering in ADD or IMMEDIATE mode? diff --git a/src/OpenGl/OpenGl_Group.hxx b/src/OpenGl/OpenGl_Group.hxx index 705dfec949..086a299d79 100644 --- a/src/OpenGl/OpenGl_Group.hxx +++ b/src/OpenGl/OpenGl_Group.hxx @@ -55,9 +55,6 @@ public: void AddElement (const TelType, OpenGl_Element * ); - void RemovePrimitiveArray (const Handle(OpenGl_Context)& theGlCtx, - CALL_DEF_PARRAY* thePArray); - virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const; virtual void Release (const Handle(OpenGl_Context)& theGlCtx); diff --git a/src/OpenGl/OpenGl_Polyline.hxx b/src/OpenGl/OpenGl_Polyline.hxx index ac17e10903..25668fe979 100644 --- a/src/OpenGl/OpenGl_Polyline.hxx +++ b/src/OpenGl/OpenGl_Polyline.hxx @@ -26,7 +26,6 @@ #include #include -#include class OpenGl_Polyline : public OpenGl_Element { diff --git a/src/OpenGl/OpenGl_Text.cxx b/src/OpenGl/OpenGl_Text.cxx index b906a969c9..5ac80613e0 100644 --- a/src/OpenGl/OpenGl_Text.cxx +++ b/src/OpenGl/OpenGl_Text.cxx @@ -46,11 +46,9 @@ OpenGl_Text::OpenGl_Text (const TCollection_ExtendedString& AText, if (myString) delete[] myString; myString = wstr; - Standard_Real X, Y, Z; - APoint.Coord(X, Y, Z); - myAttachPnt.xyz[0] = float (X); - myAttachPnt.xyz[1] = float (Y); - myAttachPnt.xyz[2] = float (Z); + myAttachPnt.xyz[0] = APoint.X(); + myAttachPnt.xyz[1] = APoint.Y(); + myAttachPnt.xyz[2] = APoint.Z(); myParam.Height = int (AHeight); diff --git a/src/OpenGl/OpenGl_tsm.hxx b/src/OpenGl/OpenGl_tsm.hxx index 60a5d0fed1..8dbdddd26c 100755 --- a/src/OpenGl/OpenGl_tsm.hxx +++ b/src/OpenGl/OpenGl_tsm.hxx @@ -43,9 +43,7 @@ et TelBackInteriorShadingMethod #ifndef OPENGL_TSM_H #define OPENGL_TSM_H -#define OCC1188 /* SAV 23/12/02 Added structure to control background texture -+ enum to control texture fill method -*/ +// OCC1188 SAV 23/12/02 Added structure to control background texture enum to control texture fill method typedef enum { diff --git a/src/Prs3d/Prs3d_AnglePresentation.cxx b/src/Prs3d/Prs3d_AnglePresentation.cxx index 6167d57854..234f3659a7 100755 --- a/src/Prs3d/Prs3d_AnglePresentation.cxx +++ b/src/Prs3d/Prs3d_AnglePresentation.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include void Prs3d_AnglePresentation::Draw ( @@ -38,60 +38,43 @@ void Prs3d_AnglePresentation::Draw ( const gp_Pnt& AttachmentPoint1, const gp_Pnt& AttachmentPoint2, const gp_Pnt& AttachmentPoint3, - const gp_Pnt& OffsetPoint) { + const gp_Pnt& OffsetPoint) +{ + Handle(Prs3d_AngleAspect) AA = aDrawer->AngleAspect(); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AA->LineAspect()->Aspect()); - - Handle(Prs3d_AngleAspect) AA = aDrawer->AngleAspect(); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(AA->LineAspect()->Aspect()); gp_Vec V1 (AttachmentPoint1,AttachmentPoint2); gp_Vec V2 (AttachmentPoint1,AttachmentPoint3); - Standard_Real alpha = V1.Angle(V2); - Standard_Real ray = AttachmentPoint1.Distance(OffsetPoint); - + const Standard_Real alpha = V1.Angle(V2); + const Standard_Real ray = AttachmentPoint1.Distance(OffsetPoint); gp_Dir I (V1); - gp_Dir K = I.Crossed(gp_Dir(V2)); + gp_Dir K = I.Crossed(gp_Dir(V2)); gp_Dir J = K.Crossed(I); -// - Standard_Real xc,yc,zc; - AttachmentPoint1.Coord(xc,yc,zc); - Graphic3d_Array1OfVertex V(1,2); - Standard_Real x1,y1,z1,x2,y2,z2; - AttachmentPoint2.Coord(x1,y1,z1); - AttachmentPoint3.Coord(x2,y2,z2); - Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); - Standard_Real dteta = alpha/(nbp-1); - Standard_Real x,y,z; + + const Standard_Integer nbp = Max (4 , Standard_Integer (50. * alpha / M_PI)); + const Standard_Real dteta = alpha/(nbp-1); gp_Vec u; - for (Standard_Integer i = 1; i<=nbp; i++) { - u = (gp_Vec(I) * Cos ( (i-1) * dteta) - + gp_Vec(J) * Sin ( (i-1) * dteta)) * ray ; - u.Coord(x,y,z); - if(i == 1) { - V(1).SetCoord( xc + x, yc + y, zc + z); - V(2).SetCoord( x1,y1,z1); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);} - else { - V(2).SetCoord( xc + x, yc + y, zc + z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - if( i == nbp ) { - Standard_Real a1,b1,c1,a2,b2,c2; - V(1).Coord(a1,b1,c1); gp_Pnt pt1(a1,b1,c1); - V(2).Coord(a2,b2,c2); gp_Pnt pt2(a2,b2,c2); - gp_Dir dir( gp_Vec(pt1 , pt2) ); - Prs3d_Arrow::Draw(aPresentation,pt2,dir,AA->ArrowAspect()->Angle(), - AA->ArrowAspect()->Length()); - } - V(1)=V(2); - } - } - V(2).SetCoord(x2,y2,z2); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - u = (gp_Vec(I) * Cos ( alpha/2.) - + gp_Vec(J) * Sin ( alpha/2.)) * ray ; - u.Coord(x,y,z); - Prs3d_Text::Draw(aPresentation,AA->TextAspect(),aText, - gp_Pnt(xc+x,yc+y,zc+z)); -} + gp_Pnt p1, p2; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(nbp+2); + aPrims->AddVertex(AttachmentPoint2); + for (Standard_Integer i = 1; i<=nbp; i++) + { + u = (gp_Vec(I) * Cos ( (i-1) * dteta) + + gp_Vec(J) * Sin ( (i-1) * dteta)) * ray ; + p2 = AttachmentPoint1.Translated(u); + aPrims->AddVertex(p2); + if( i == nbp ) { + gp_Dir dir( gp_Vec(p1,p2) ); + Prs3d_Arrow::Draw(aPresentation,p2,dir,AA->ArrowAspect()->Angle(),AA->ArrowAspect()->Length()); + } + p1 = p2; + } + aPrims->AddVertex(AttachmentPoint3); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + u = (gp_Vec(I) * Cos (0.5*alpha) + + gp_Vec(J) * Sin (0.5*alpha)) * ray ; + Prs3d_Text::Draw(aPresentation,AA->TextAspect(),aText,AttachmentPoint1.Translated(u)); +} diff --git a/src/Prs3d/Prs3d_Arrow.cxx b/src/Prs3d/Prs3d_Arrow.cxx index f5db317eb3..f8a64e1bfb 100755 --- a/src/Prs3d/Prs3d_Arrow.cxx +++ b/src/Prs3d/Prs3d_Arrow.cxx @@ -18,7 +18,8 @@ #include #include -#include +#include +#include //======================================================================= //function : Draw @@ -27,10 +28,10 @@ void Prs3d_Arrow::Draw(const Handle(Prs3d_Presentation)& aPresentation, const gp_Pnt& aLocation, - const gp_Dir& aDirection, + const gp_Dir& aDirection, const Quantity_PlaneAngle anAngle, - const Quantity_Length aLength) { - + const Quantity_Length aLength) +{ Quantity_Length dx,dy,dz; aDirection.Coord(dx,dy,dz); // // Point of the arrow: @@ -54,34 +55,36 @@ void Prs3d_Arrow::Draw(const Handle(Prs3d_Presentation)& aPresentation, Quantity_Length Norme = sqrt ( xi*xi + yi*yi + zi*zi ); xi = xi / Norme; yi = yi / Norme; zi = zi/Norme; - Quantity_Length xj = dy * zi - dz * yi; - Quantity_Length yj = dz * xi - dx * zi; - Quantity_Length zj = dx * yi - dy * xi; + const Quantity_Length xj = dy * zi - dz * yi; + const Quantity_Length yj = dz * xi - dx * zi; + const Quantity_Length zj = dx * yi - dy * xi; - Standard_Integer NbPoints = 15; + const Standard_Integer NbPoints = 15; - Graphic3d_Array1OfVertex VN(1,NbPoints+1); - Graphic3d_Array1OfVertex V2(1,2); - V2(1).SetCoord(xo,yo,zo); + Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*NbPoints); + Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(NbPoints+1); - Quantity_Length x,y,z; - Standard_Real cosinus,sinus, Tg=tan(anAngle); + gp_Pnt p1; + const Standard_Real Tg=tan(anAngle); - for (Standard_Integer i = 1 ; i <= NbPoints ; i++) { + for (Standard_Integer i = 1; i <= NbPoints ; i++) + { + const Standard_Real cosinus = cos ( 2 * M_PI / NbPoints * (i-1) ); + const Standard_Real sinus = sin ( 2 * M_PI / NbPoints * (i-1) ); - cosinus = cos ( 2 * M_PI / NbPoints * (i-1) ); - sinus = sin ( 2 * M_PI / NbPoints * (i-1) ); + const gp_Pnt pp(xc + (cosinus * xi + sinus * xj) * aLength * Tg, + yc + (cosinus * yi + sinus * yj) * aLength * Tg, + zc + (cosinus * zi + sinus * zj) * aLength * Tg); - x = xc + (cosinus * xi + sinus * xj) * aLength * Tg; - y = yc + (cosinus * yi + sinus * yj) * aLength * Tg; - z = zc + (cosinus * zi + sinus * zj) * aLength * Tg; - - VN(i).SetCoord(x,y,z); - if(i==1) VN(NbPoints+1).SetCoord(x,y,z); - V2(2).SetCoord(x,y,z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2); + aPrims1->AddVertex(aLocation); + aPrims1->AddVertex(pp); + if(i==1) p1 = pp; + aPrims2->AddVertex(pp); } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VN); + aPrims2->AddVertex(p1); + + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims1); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims2); } //======================================================================= @@ -93,6 +96,6 @@ void Prs3d_Arrow::Fill(const Handle(Prs3d_Presentation)& /*aPresentation*/, const gp_Pnt& /*aLocation*/, const gp_Dir& /*aDirection*/, const Quantity_PlaneAngle /*anAngle*/, - const Quantity_Length /*aLength*/) + const Quantity_Length /*aLength*/) { } diff --git a/src/Prs3d/Prs3d_Datum.gxx b/src/Prs3d/Prs3d_Datum.gxx index 6d4194b74b..76230669f4 100755 --- a/src/Prs3d/Prs3d_Datum.gxx +++ b/src/Prs3d/Prs3d_Datum.gxx @@ -30,21 +30,19 @@ #include #include #include -#include +#include void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation, const anyDatum& aDatum, - const Handle(Prs3d_Drawer)& aDrawer ) { - + const Handle(Prs3d_Drawer)& aDrawer ) +{ Handle(Prs3d_DatumAspect) DA = aDrawer->DatumAspect(); - Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation); Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W; DA->FirstAxisAspect()->Aspect()->Values(Col,Tol,W); - Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d - (Aspect_TOM_BALL,Col,.1); + Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Col,.1); gp_Ax2 Axis = DatumTool::Ax2(aDatum); gp_Pnt Orig = Axis.Location(); @@ -56,72 +54,63 @@ void Prs3d_Datum::Add( const Handle(Prs3d_Presentation)& aPresentation, // Trace d'une petite sphere au debut du vecteur: // - Quantity_Length xo,yo,zo,x,y,z; - + Quantity_Length xo,yo,zo; Orig.Coord(xo,yo,zo); G->SetPrimitivesAspect(Asp); G->Marker(Graphic3d_Vertex (xo,yo,zo)); - - Graphic3d_Array1OfVertex A(1,2); - A(1).SetCoord(xo,yo,zo); - Quantity_Length DS; - -#ifdef IMP120100 Quantity_Length arrowAngle = aDrawer->ArrowAspect()->Angle(); Quantity_Length textHeight = aDrawer->TextAspect()->Height(); -#endif - if (DA->DrawFirstAndSecondAxis()) { - oX.Coord(x,y,z); + Handle(Graphic3d_ArrayOfSegments) aPrims; + if (DA->DrawFirstAndSecondAxis()) + { DS = DA->FirstAxisLength(); - x = xo + x*DS; y = yo + y*DS; z = zo + z*DS; - A(2).SetCoord(x,y,z); + const gp_Pnt p1(Orig.XYZ() + oX.XYZ()*DS); + G->SetPrimitivesAspect(DA->FirstAxisAspect()->Aspect()); - G->Polyline(A); -#ifdef IMP120100 + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Orig); + aPrims->AddVertex(p1); + G->AddPrimitiveArray(aPrims); + G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,arrowAngle,DS/10.); + Prs3d_Arrow::Draw(aPresentation,p1,oX,arrowAngle,DS/10.); G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect()); - G->Text(Standard_CString("X"),A(2),16.); -#else - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oX,M_PI/180.*10.,DS/10.); - Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("X"),A(2),1./81.); -#endif -} - if (DA->DrawFirstAndSecondAxis()) { - oY.Coord(x,y,z); + Graphic3d_Vertex v1(p1.X(),p1.Y(),p1.Z()); + G->Text(Standard_CString("X"),v1,16.); + DS = DA->SecondAxisLength(); - x = xo + x*DS; y = yo + y*DS; z = zo + z*DS; - A(2).SetCoord(x,y,z); + const gp_Pnt p2(Orig.XYZ() + oY.XYZ()*DS); + G->SetPrimitivesAspect(DA->SecondAxisAspect()->Aspect()); - G->Polyline(A); -#ifdef IMP120100 + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Orig); + aPrims->AddVertex(p2); + G->AddPrimitiveArray(aPrims); + G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,arrowAngle,DS/10.); + Prs3d_Arrow::Draw(aPresentation,p2,oY,arrowAngle,DS/10.); G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect()); - G->Text(Standard_CString("Y"),A(2),16.); -#else - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oY,M_PI/180.*10.,DS/10.); - Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Y"),A(2),1./81.); -#endif -} - if (DA->DrawThirdAxis()) { - oZ.Coord(x,y,z); + Graphic3d_Vertex v2(p2.X(),p2.Y(),p2.Z()); + G->Text(Standard_CString("Y"),v2,16.); + } + if (DA->DrawThirdAxis()) + { DS = DA->ThirdAxisLength(); - x = xo + x*DS; y = yo + y*DS; z = zo + z*DS; - A(2).SetCoord(x,y,z); + const gp_Pnt p3(Orig.XYZ() + oZ.XYZ()*DS); + G->SetPrimitivesAspect(DA->ThirdAxisAspect()->Aspect()); - G->Polyline(A); -#ifdef IMP120100 + aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Orig); + aPrims->AddVertex(p3); + G->AddPrimitiveArray(aPrims); + G->SetPrimitivesAspect(aDrawer->ArrowAspect()->Aspect()); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,arrowAngle,DS/10.); + Prs3d_Arrow::Draw(aPresentation,p3,oZ,arrowAngle,DS/10.); G->SetPrimitivesAspect(aDrawer->TextAspect()->Aspect()); - G->Text(Standard_CString("Z"),A(2),16.); -#else - Prs3d_Root::CurrentGroup(aPresentation)->Text(Standard_CString("Z"),A(2),1./81.); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x,y,z),oZ,M_PI/180.*10.,DS/10.); -#endif -} + Graphic3d_Vertex v3(p3.X(),p3.Y(),p3.Z()); + G->Text(Standard_CString("Z"),v3,16.); + } } diff --git a/src/Prs3d/Prs3d_HLRShape.gxx b/src/Prs3d/Prs3d_HLRShape.gxx index 3c57c54715..a2f78c3f90 100755 --- a/src/Prs3d/Prs3d_HLRShape.gxx +++ b/src/Prs3d/Prs3d_HLRShape.gxx @@ -40,7 +40,6 @@ void Prs3d_HLRShape::Add(const Handle (Prs3d_Presentation)& aPresentation, aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); Standard_Real anAngle = aDrawer->DeviationAngle(); TColgp_SequenceOfPnt Points; for (i=1;i<=NbEdge;i++){ @@ -49,19 +48,17 @@ void Prs3d_HLRShape::Add(const Handle (Prs3d_Presentation)& aPresentation, CurvePresentation::Add(aPresentation,TheCurve,U1,U2,def, Points, anAngle); } } - aGroup->EndPrimitives(); - if(aDrawer->DrawHiddenLine()){ + if(aDrawer->DrawHiddenLine()) + { aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); for (i=1;i<=NbEdge;i++){ for(Tool.InitHidden(i);Tool.MoreHidden();Tool.NextHidden()){ Tool.Hidden(TheCurve,U1,U2); CurvePresentation::Add(aPresentation,TheCurve,U1,U2,def, Points, anAngle); } } - aGroup->EndPrimitives(); } } diff --git a/src/Prs3d/Prs3d_LengthPresentation.cxx b/src/Prs3d/Prs3d_LengthPresentation.cxx index ae56a075d1..478c154eef 100755 --- a/src/Prs3d/Prs3d_LengthPresentation.cxx +++ b/src/Prs3d/Prs3d_LengthPresentation.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include void Prs3d_LengthPresentation::Draw ( @@ -37,53 +37,33 @@ void Prs3d_LengthPresentation::Draw ( const TCollection_ExtendedString& aText, const gp_Pnt& AttachmentPoint1, const gp_Pnt& AttachmentPoint2, - const gp_Pnt& OffsetPoint) { - - + const gp_Pnt& OffsetPoint) +{ Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect(); - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); + gp_Dir D (gp_Vec(AttachmentPoint1,AttachmentPoint2)); gp_Lin L (OffsetPoint,D); gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint1),L); gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L,AttachmentPoint2),L); - Graphic3d_Array1OfVertex V(1,2); - Quantity_Length X,Y,Z; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(4); + aPrims->AddVertex(AttachmentPoint1); + aPrims->AddVertex(Proj1); + aPrims->AddVertex(Proj2); + aPrims->AddVertex(AttachmentPoint2); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + Quantity_Length X,Y,Z; Proj1.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - - AttachmentPoint1.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); + if (LA->DrawFirstArrow()) + Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(),LA->Arrow1Aspect()->Angle(),LA->Arrow1Aspect()->Length()); - - Proj2.Coord(X,Y,Z); - V(2).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - AttachmentPoint2.Coord(X,Y,Z); - V(1).SetCoord(X,Y,Z); - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V); - - Proj1.Coord(X,Y,Z); - if (LA->DrawFirstArrow()) { - Prs3d_Arrow::Draw(aPresentation,Proj1,D.Reversed(), - LA->Arrow1Aspect()->Angle(), - LA->Arrow1Aspect()->Length()); - } Quantity_Length X2,Y2,Z2; Proj2.Coord(X2,Y2,Z2); - if (LA->DrawSecondArrow()) { - Prs3d_Arrow::Draw(aPresentation,Proj2,D, - LA->Arrow2Aspect()->Angle(), - LA->Arrow2Aspect()->Length()); - } - - gp_Pnt p; - p.SetCoord( (X+X2)/2. , (Y+Y2)/2. , (Z+Z2)/2.); + if (LA->DrawSecondArrow()) + Prs3d_Arrow::Draw(aPresentation,Proj2,D,LA->Arrow2Aspect()->Angle(),LA->Arrow2Aspect()->Length()); + gp_Pnt p( .5*(X+X2), .5*(Y+Y2), .5*(Z+Z2) ); Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,p); } - - diff --git a/src/Prs3d/Prs3d_Line.gxx b/src/Prs3d/Prs3d_Line.gxx index 0d85dc08cc..1b2eb65a73 100755 --- a/src/Prs3d/Prs3d_Line.gxx +++ b/src/Prs3d/Prs3d_Line.gxx @@ -16,7 +16,7 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -#include +#include #include #include #include @@ -26,29 +26,25 @@ #include #include -static void DrawLine (const anyLine& aLine, - const Handle(Graphic3d_Group)& aGroup) { - - Standard_Integer Count=0; +static void DrawLine (const anyLine& aLine, const Handle(Graphic3d_Group)& aGroup) +{ Quantity_Length x,y,z; - Standard_Integer Lower = LineTool::Lower(aLine); - Standard_Integer Upper = LineTool::Upper(aLine); - - Graphic3d_Array1OfVertex VertexArray(1,Upper-Lower+1); + Standard_Integer i = LineTool::Lower(aLine); + const Standard_Integer Upper = LineTool::Upper(aLine); - for (Standard_Integer i=Lower;i<=Upper;i++){ + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Upper-i+1); + for (; i <= Upper; i++) { LineTool::Coord(aLine,i,x,y,z); - VertexArray(++Count).SetCoord(x,y,z); + aPrims->AddVertex((Standard_ShortReal)x,(Standard_ShortReal)y,(Standard_ShortReal)z); } - aGroup->Polyline(VertexArray); + aGroup->AddPrimitiveArray(aPrims); } void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation, const anyLine& aLine, - const Handle (Prs3d_Drawer)& aDrawer){ - -// Prs3d_Root::NewGroup(aPresentation); + const Handle (Prs3d_Drawer)& aDrawer) +{ Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect()); DrawLine(aLine,TheGroup); @@ -68,12 +64,10 @@ void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation, } } } -void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation, - const anyLine& aLine){ - +void Prs3d_Line::Add (const Handle (Prs3d_Presentation)& aPresentation, const anyLine& aLine) +{ DrawLine (aLine,Prs3d_Root::CurrentGroup(aPresentation)); - } Standard_Integer Prs3d_Line::Pick @@ -83,46 +77,45 @@ Standard_Integer Prs3d_Line::Pick const Quantity_Length aDistance, const anyLine& aLine, const Handle (Prs3d_Drawer)& aDrawer, - const Prs3d_TypeOfLinePicking TypeOfPicking){ - - - Standard_Integer Lower = LineTool::Lower(aLine); - Standard_Integer Upper = LineTool::Upper(aLine); + const Prs3d_TypeOfLinePicking TypeOfPicking) +{ + Standard_Integer i = LineTool::Lower(aLine); + const Standard_Integer Upper = LineTool::Upper(aLine); Standard_Integer num = 0; Quantity_Length X1,Y1,Z1,X2,Y2,Z2,dist; Standard_Real DistMin = RealLast(); - for (Standard_Integer i=Lower;i<=Upper;i++){ + for (; i <= Upper; i++) + { LineTool::Coord(aLine,i,X2,Y2,Z2); switch (TypeOfPicking) { - case Prs3d_TOLP_Point: { - dist = Abs(X-X2)+Abs(Y-Y2)+ Abs(Z-Z2); - if(dist < aDistance) { - if (dist < DistMin) { - DistMin = dist; - num = i; - } + case Prs3d_TOLP_Point: { + dist = Abs(X-X2)+Abs(Y-Y2)+ Abs(Z-Z2); + if(dist < aDistance) { + if (dist < DistMin) { + DistMin = dist; + num = i; + } + } + break; } - } - break; - case Prs3d_TOLP_Segment: { - if (i > 1) { - if (Prs3d::MatchSegment - (X,Y,Z,aDistance,gp_Pnt(X1,Y1,Z1),gp_Pnt(X2,Y2,Z2),dist)){ - if(dist < aDistance) { - if (dist < DistMin) { - DistMin = dist; - num = i; - } - } - } + case Prs3d_TOLP_Segment: { + if (i > 1) { + if (Prs3d::MatchSegment(X,Y,Z,aDistance,gp_Pnt(X1,Y1,Z1),gp_Pnt(X2,Y2,Z2),dist)) { + if(dist < aDistance) { + if (dist < DistMin) { + DistMin = dist; + num = i; + } + } + } + } + X1=X2;Y1=Y2;Z1=Z2; + break; } - X1=X2;Y1=Y2;Z1=Z2; - } - break; } } - return num; + return num; } diff --git a/src/Prs3d/Prs3d_Point.gxx b/src/Prs3d/Prs3d_Point.gxx index 8dd2bbd46b..76723380c3 100755 --- a/src/Prs3d/Prs3d_Point.gxx +++ b/src/Prs3d/Prs3d_Point.gxx @@ -16,14 +16,13 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. -#include #include #include #include static void DrawPoint (const anyPoint& aPoint, - const Handle(Graphic3d_Group) aGroup) { - + const Handle(Graphic3d_Group) aGroup) +{ Quantity_Length x,y,z; PointTool::Coord(aPoint,x,y,z); Graphic3d_Vertex Vertex(x,y,z); @@ -32,16 +31,15 @@ static void DrawPoint (const anyPoint& aPoint, void Prs3d_Point::Add (const Handle (Prs3d_Presentation)& aPresentation, const anyPoint& aPoint, - const Handle (Prs3d_Drawer)& aDrawer){ - + const Handle (Prs3d_Drawer)& aDrawer) +{ Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect()); DrawPoint(aPoint,TheGroup); } -void Prs3d_Point::Add (const Handle (Prs3d_Presentation)& aPresentation, - const anyPoint& aPoint){ - +void Prs3d_Point::Add (const Handle (Prs3d_Presentation)& aPresentation, const anyPoint& aPoint) +{ DrawPoint(aPoint,Prs3d_Root::CurrentGroup(aPresentation)); } @@ -50,8 +48,8 @@ Standard_Boolean Prs3d_Point::Match (const anyPoint& aPoint, const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Z, - const Quantity_Length aDistance) { - + const Quantity_Length aDistance) +{ Quantity_Length x,y,z; PointTool::Coord(aPoint,x,y,z); return Sqrt( (X-x)*(X-x) + (Y-y)*(Y-y) + (Z-z)*(Z-z) ) <= aDistance; diff --git a/src/Prs3d/Prs3d_Vector.gxx b/src/Prs3d/Prs3d_Vector.gxx index c6449f5ee3..0453cb81f5 100755 --- a/src/Prs3d/Prs3d_Vector.gxx +++ b/src/Prs3d/Prs3d_Vector.gxx @@ -24,7 +24,7 @@ #include #include #include -#include +#include void Prs3d_Vector::Add(const Handle(Prs3d_Presentation)& aPresentation, @@ -33,9 +33,7 @@ void Prs3d_Vector::Add(const Handle(Prs3d_Presentation)& aPresentation, { gp_Pnt Pnt = VectorTool::Location(aVector); gp_Vec Vec = VectorTool::Vec(aVector); - Quantity_Length x1,y1,z1,dx,dy,dz; - Pnt.Coord(x1,y1,z1); - Vec.Coord(dx,dy,dz); + gp_Pnt Pnt2 = Pnt.Translated(Vec); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPresentation); G->SetPrimitivesAspect(aDrawer->VectorAspect()->Aspect()); @@ -43,25 +41,20 @@ void Prs3d_Vector::Add(const Handle(Prs3d_Presentation)& aPresentation, Quantity_Color Col; Aspect_TypeOfLine Tol; Standard_Real W; aDrawer->VectorAspect()->Aspect()->Values(Col,Tol,W); - Graphic3d_Array1OfVertex A(1,2); // // Trace d'une petite sphere au debut du vecteur: // - Graphic3d_Vertex VTX; - VTX.SetCoord(x1,y1,z1); - Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d - (Aspect_TOM_BALL,Col,1.); + Quantity_Length x1,y1,z1; + Pnt.Coord(x1,y1,z1); + Graphic3d_Vertex VTX(x1,y1,z1); + Handle(Graphic3d_AspectMarker3d) Asp = new Graphic3d_AspectMarker3d(Aspect_TOM_BALL,Col,1.); G->SetPrimitivesAspect(Asp); G->Marker(VTX); - A(1).SetCoord(x1,y1,z1); - A(2).SetCoord(x1+dx,y1+dy,z1+dz); - G->Polyline(A); - Prs3d_Arrow::Draw(aPresentation,gp_Pnt(x1+dx,y1+dy,z1+dz),gp_Dir(Vec), - M_PI/180.*10.,Sqrt(dx*dx+dy*dy+dz*dz)/10.); - -} - - - + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Pnt); + aPrims->AddVertex(Pnt2); + G->AddPrimitiveArray(aPrims); + Prs3d_Arrow::Draw(aPresentation,Pnt2,gp_Dir(Vec),M_PI/180.*10.,Vec.Magnitude()/10.); +} diff --git a/src/Prs3d/Prs3d_WFDeflectionRestrictedFace.gxx b/src/Prs3d/Prs3d_WFDeflectionRestrictedFace.gxx index 40b598ce25..0698fc6c8f 100755 --- a/src/Prs3d/Prs3d_WFDeflectionRestrictedFace.gxx +++ b/src/Prs3d/Prs3d_WFDeflectionRestrictedFace.gxx @@ -17,7 +17,6 @@ // and conditions governing the rights and limitations under the License. #include -#include #include #include #include @@ -26,12 +25,6 @@ #include #include -#ifdef DEBUG -#include -extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4; -#endif - - //========================================================================= // function: Add @@ -48,11 +41,6 @@ void Prs3d_WFDeflectionRestrictedFace::Add const Handle(Prs3d_Drawer)& aDrawer, Prs3d_NListOfSequenceOfPnt& Curves) { - -#ifdef DEBUG - RestrictedFaceTimer1.Start(); -#endif - RestrictionTool ToolRst (aFace); Standard_Real aLimit = aDrawer->MaximalParameterValue(); @@ -94,12 +82,6 @@ void Prs3d_WFDeflectionRestrictedFace::Add } } -#ifdef DEBUG - RestrictedFaceTimer1.Stop(); - - RestrictedFaceTimer2.Start(); -#endif - // load the isos Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented()); Standard_Boolean UClosed = aFace->IsUClosed(); @@ -134,11 +116,6 @@ void Prs3d_WFDeflectionRestrictedFace::Add } } -#ifdef DEBUG - RestrictedFaceTimer2.Stop(); - RestrictedFaceTimer3.Start(); -#endif - // trim the isos gp_Pnt2d P1,P2; Standard_Real U1, U2; @@ -182,13 +159,7 @@ void Prs3d_WFDeflectionRestrictedFace::Add } } -#ifdef DEBUG - RestrictedFaceTimer3.Stop(); - RestrictedFaceTimer4.Start(); -#endif - // draw the isos - Adaptor3d_IsoCurve anIso; anIso.Load(aFace); Standard_Integer NumberOfLines = isobuild.NbLines(); @@ -210,10 +181,6 @@ void Prs3d_WFDeflectionRestrictedFace::Add DrawFaceIso::Add(aPresentation,anIso,Deflection, aLimit); } } -#ifdef DEBUG - RestrictedFaceTimer4.Stop(); -#endif - } @@ -359,26 +326,17 @@ Standard_Boolean Prs3d_WFDeflectionRestrictedFace::Match void Prs3d_WFDeflectionRestrictedFace::Add (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - TheGroup->BeginPrimitives(); - + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_WFDeflectionRestrictedFace::Add ( aPresentation, aFace, Standard_True, Standard_True, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer); - - TheGroup->EndPrimitives(); } @@ -389,19 +347,16 @@ void Prs3d_WFDeflectionRestrictedFace::Add void Prs3d_WFDeflectionRestrictedFace::AddUIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_WFDeflectionRestrictedFace::Add ( aPresentation, aFace, Standard_True, Standard_False, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer); } @@ -413,19 +368,16 @@ void Prs3d_WFDeflectionRestrictedFace::AddUIso void Prs3d_WFDeflectionRestrictedFace::AddVIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Prs3d_WFDeflectionRestrictedFace::Add ( + const Handle (Prs3d_Drawer)& aDrawer) +{ + Prs3d_WFDeflectionRestrictedFace::Add ( aPresentation, aFace, Standard_False, Standard_True, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer); } @@ -440,20 +392,17 @@ Standard_Boolean Prs3d_WFDeflectionRestrictedFace::Match const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return Prs3d_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_True, - Standard_True, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_True, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number()); } @@ -467,20 +416,20 @@ Standard_Boolean Prs3d_WFDeflectionRestrictedFace::MatchUIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - + const Handle (Prs3d_Drawer)& aDrawer) +{ Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); Standard_Integer finu = aDrawer->UIsoAspect()->Number(); Standard_Integer finv = aDrawer->VIsoAspect()->Number(); return Prs3d_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_True, - Standard_False, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_True, + Standard_False, + Deflection, + finu, + finv); } @@ -494,20 +443,15 @@ Standard_Boolean Prs3d_WFDeflectionRestrictedFace::MatchVIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return Prs3d_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_False, - Standard_True, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_False, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number()); } - - diff --git a/src/Prs3d/Prs3d_WFRestrictedFace.gxx b/src/Prs3d/Prs3d_WFRestrictedFace.gxx index 86066ffa93..4c7b9c3761 100755 --- a/src/Prs3d/Prs3d_WFRestrictedFace.gxx +++ b/src/Prs3d/Prs3d_WFRestrictedFace.gxx @@ -19,15 +19,7 @@ // and conditions governing the rights and limitations under the License. - -#ifdef DEBUG -#include -extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4; -#endif - #include -#include -#include #include #include #include @@ -55,14 +47,9 @@ void Prs3d_WFRestrictedFace::Add const Handle(Prs3d_Drawer)& aDrawer, Prs3d_NListOfSequenceOfPnt& Curves) { - Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable(); Standard_Real aLimit = aDrawer->MaximalParameterValue(); Standard_Integer nbPoints = aDrawer->Discretisation(); -#ifdef DEBUG - RestrictedFaceTimer1.Start(); -#endif - RestrictionTool ToolRst (aFace); // compute bounds of the restriction @@ -87,12 +74,6 @@ void Prs3d_WFRestrictedFace::Add VMax = aFace->Surface().LastVParameter(); } -#ifdef DEBUG - RestrictedFaceTimer1.Stop(); - - RestrictedFaceTimer2.Start(); -#endif - // load the isos Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented()); Standard_Boolean UClosed = aFace->IsUClosed(); @@ -127,11 +108,6 @@ void Prs3d_WFRestrictedFace::Add } } -#ifdef DEBUG - RestrictedFaceTimer2.Stop(); - RestrictedFaceTimer3.Start(); -#endif - // trim the isos Standard_Real U1, U2, U, DU; @@ -165,14 +141,7 @@ void Prs3d_WFRestrictedFace::Add } } -#ifdef DEBUG - RestrictedFaceTimer3.Stop(); - RestrictedFaceTimer4.Start(); -#endif - // draw the isos - - Adaptor3d_IsoCurve anIso; anIso.Load(aFace); Handle(Geom_Curve) BC; @@ -207,7 +176,7 @@ void Prs3d_WFRestrictedFace::Add BC = GB->VIso(Coord); //Note that the isos are the part of the shape, it will be displayed after a computation the whole shape //NbPoints = 30 - default parameter for computation of such curves - DrawFaceIso::Add(aPresentation,GeomAdaptor_Curve(BC), b1, b2, aDeflection, Pnts, 30, !isPA); + DrawFaceIso::Add(aPresentation,GeomAdaptor_Curve(BC), b1, b2, aDeflection, Pnts, 30, Standard_False); Curves.Append(Pnts); } else { @@ -215,14 +184,11 @@ void Prs3d_WFRestrictedFace::Add anIso.Load(GeomAbs_IsoU,Coord,b1,b2); else anIso.Load(GeomAbs_IsoV,Coord,b1,b2); - DrawFaceIso::Add(aPresentation,anIso, aDeflection, aDrawer, Pnts, !isPA); + DrawFaceIso::Add(aPresentation,anIso, aDeflection, aDrawer, Pnts, Standard_False); Curves.Append(Pnts); } } } -#ifdef DEBUG - RestrictedFaceTimer4.Stop(); -#endif } @@ -380,12 +346,10 @@ Standard_Boolean Prs3d_WFRestrictedFace::Match } } - - return Standard_False; + return Standard_False; } - //========================================================================= // function: Add // purpose @@ -393,27 +357,19 @@ Standard_Boolean Prs3d_WFRestrictedFace::Match void Prs3d_WFRestrictedFace::Add (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); - - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - TheGroup->BeginPrimitives(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; Prs3d_WFRestrictedFace::Add ( aPresentation, aFace, Standard_True, Standard_True, - aDeflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); - - TheGroup->EndPrimitives(); } @@ -424,20 +380,17 @@ void Prs3d_WFRestrictedFace::Add void Prs3d_WFRestrictedFace::AddUIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; Prs3d_WFRestrictedFace::Add ( aPresentation, aFace, Standard_True, Standard_False, - aDeflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); } @@ -450,20 +403,17 @@ void Prs3d_WFRestrictedFace::AddUIso void Prs3d_WFRestrictedFace::AddVIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; Prs3d_WFRestrictedFace::Add ( aPresentation, aFace, Standard_False, Standard_True, - aDeflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); } @@ -479,20 +429,17 @@ Standard_Boolean Prs3d_WFRestrictedFace::Match const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return Prs3d_WFRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - Standard_True, - Standard_True, - aDeflection, - finu, - finv, - aDrawer); + aFace, + Standard_True, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), + aDrawer); } @@ -506,20 +453,17 @@ Standard_Boolean Prs3d_WFRestrictedFace::MatchUIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return Prs3d_WFRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - Standard_True, - Standard_False, - aDeflection, - finu, - finv, - aDrawer); + aFace, + Standard_True, + Standard_False, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), + aDrawer); } @@ -533,18 +477,15 @@ Standard_Boolean Prs3d_WFRestrictedFace::MatchVIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - Quantity_Length aDeflection = aDrawer->MaximalChordialDeviation(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return Prs3d_WFRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - Standard_False, - Standard_True, - aDeflection, - finu, - finv, - aDrawer); + aFace, + Standard_False, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), + aDrawer); } diff --git a/src/Prs3d/Prs3d_WFShape.gxx b/src/Prs3d/Prs3d_WFShape.gxx index 2b618e6b9a..88359b08ea 100755 --- a/src/Prs3d/Prs3d_WFShape.gxx +++ b/src/Prs3d/Prs3d_WFShape.gxx @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -55,14 +54,6 @@ #include #include -#ifdef DEB_MESH -#include -extern OSD_Timer RestrictedFaceTimer1,RestrictedFaceTimer2,RestrictedFaceTimer3,RestrictedFaceTimer4; -extern OSD_Timer ShapeTimer; -extern OSD_Timer FaceExplorerTimer, CurveExplorerTimer; -extern OSD_Timer UIsoTimer,VIsoTimer,WireTimer,FreeBoundaryTimer,UnFreeBoundaryTimer; -#endif - static Standard_Boolean IsSame(const Handle(Graphic3d_AspectLine3d)& UAspect, const Handle(Graphic3d_AspectLine3d)& VAspect) { @@ -84,50 +75,29 @@ static Standard_Boolean IsSame(const Handle(Graphic3d_AspectLine3d)& UAspect, static Standard_Boolean AddPolygon(const TopoDS_Edge& E, - Handle(Graphic3d_Group)& TheGroup, - const Standard_Real deflection, - const Handle (Prs3d_Drawer)& , - TColgp_SequenceOfPnt& Pnts) + Handle(Graphic3d_Group)& TheGroup, + const Standard_Real deflection, + const Handle (Prs3d_Drawer)& , + TColgp_SequenceOfPnt& Pnts) { TopLoc_Location l; - gp_Pnt P; - Standard_Boolean result = Standard_False; - Standard_Boolean IsPrimArray = Graphic3d_ArrayOfPrimitives::IsEnable(); - Standard_Boolean OK; Standard_Real fi, la; - - Handle(Poly_Polygon3D) Polyg; Handle(Geom_Curve) CC3d = BRep_Tool::Curve(E, fi, la); - - Polyg = BRep_Tool::Polygon3D(E, l); - if (!Polyg.IsNull()) { - OK = Polyg->Deflection() <= deflection; - OK = OK || (CC3d.IsNull()); + Handle(Poly_Polygon3D) Polyg = BRep_Tool::Polygon3D(E, l); - if (OK) { - result = Standard_True; + if (!Polyg.IsNull()) { + if ((Polyg->Deflection() <= deflection) || CC3d.IsNull()) { const TColgp_Array1OfPnt& Points = Polyg->Nodes(); - Graphic3d_Array1OfVertex V(1, Points.Length()); - Standard_Integer po, ii = 1; + Standard_Integer po = Points.Lower(); if (l.IsIdentity()) { - for (po = Points.Lower(); po <= Points.Upper(); po++) { - P = Points.Value(po); - V(ii).SetCoord(P.X(), P.Y(), P.Z()); - Pnts.Append(P); - ii++; - } + for (; po <= Points.Upper(); po++) + Pnts.Append(Points.Value(po)); } else { - for (po = Points.Lower(); po <= Points.Upper(); po++) { - P = Points.Value(po).Transformed(l); - V(ii).SetCoord(P.X(), P.Y(), P.Z()); - Pnts.Append(P); - ii++; - } + for (; po <= Points.Upper(); po++) + Pnts.Append(Points.Value(po).Transformed(l)); } - if(!IsPrimArray) - TheGroup->Polyline(V); - return result; + return Standard_True; } } @@ -135,46 +105,26 @@ static Standard_Boolean AddPolygon(const TopoDS_Edge& E, Handle(Poly_PolygonOnTriangulation) HIndices; BRep_Tool::PolygonOnTriangulation(E, HIndices, Tr, l); if (!HIndices.IsNull()) { - - OK = HIndices->Deflection() <= deflection; - OK = OK || (CC3d.IsNull()); - - if (OK) { - result = Standard_True; + if ((HIndices->Deflection() <= deflection) || CC3d.IsNull()) { const TColStd_Array1OfInteger& Indices = HIndices->Nodes(); const TColgp_Array1OfPnt& Nodes = Tr->Nodes(); - Graphic3d_Array1OfVertex V(1, Indices.Length()); - Standard_Integer po, ii = 1; + Standard_Integer po = Indices.Lower(); if (l.IsIdentity()) { - for (po = Indices.Lower(); po <= Indices.Upper(); po++) { - P = Nodes(Indices(po)); - V(ii).SetCoord(P.X(), P.Y(), P.Z()); - Pnts.Append(P); - ii++; - } + for (; po <= Indices.Upper(); po++) + Pnts.Append(Nodes(Indices(po))); } else { - for (po = Indices.Lower(); po <= Indices.Upper(); po++) { - P = Nodes(Indices(po)).Transformed(l); - V(ii).SetCoord(P.X(), P.Y(), P.Z()); - Pnts.Append(P); - ii++; - } + for (; po <= Indices.Upper(); po++) + Pnts.Append(Nodes(Indices(po)).Transformed(l)); } - if(!IsPrimArray) - TheGroup->Polyline(V); - return result; + return Standard_True; } } - return result; + return Standard_False; } - - - - //========================================================================= // function: Add // purpose @@ -185,17 +135,6 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, { if (aShape.IsNull()) return; - Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); -#ifdef DEB_MESH - RestrictedFaceTimer1.Reset(); - RestrictedFaceTimer2.Reset(); - RestrictedFaceTimer3.Reset(); - RestrictedFaceTimer4.Reset(); -#endif - -#ifdef DEB_MESH - ShapeTimer.Start(); -#endif Prs3d_ShapeTool Tool(aShape); TopTools_ListOfShape LFree, LUnFree, LWire; for (Tool.InitCurve();Tool.MoreCurve();Tool.NextCurve()) @@ -208,13 +147,6 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, default: LUnFree.Append(E); } } -#ifdef DEB_MESH - ShapeTimer.Stop(); -#endif - -#ifdef DEB_MESH - RestrictedFaceTimer1.Start(); -#endif Standard_Real aDeflection; if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) @@ -235,10 +167,6 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, else aDeflection = aDrawer->MaximalChordialDeviation(); -#ifdef DEB_MESH - RestrictedFaceTimer1.Stop(); -#endif - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); Prs3d_NListOfSequenceOfPnt UIsoCurves; @@ -252,15 +180,8 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, { const Standard_Integer isoU = aDrawer->UIsoAspect()->Number(); const Standard_Integer isoV = aDrawer->VIsoAspect()->Number(); -#ifdef DEB_MESH - UIsoTimer.Start(); -#endif if (isoU || isoV) { - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } BRepAdaptor_Surface S; for (Tool.InitFace();Tool.MoreFace();Tool.NextFace()) { @@ -285,34 +206,18 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } catch (Standard_Failure) { -#ifdef DEB_MESH - const TopoDS_Face& FF = S.Face(); - cout <<"probleme pour les isos de la face "<< (void*) &(*(FF).TShape()) << endl; -#endif } } } } - if(!isPrimArrayEnabled) - TheGroup->EndPrimitives(); } -#ifdef DEB_MESH - UIsoTimer.Stop(); -#endif } else { const Standard_Integer isoU = aDrawer->UIsoAspect()->Number(); const Standard_Integer isoV = aDrawer->VIsoAspect()->Number(); -#ifdef DEB_MESH - UIsoTimer.Start(); -#endif if (isoU) { - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } BRepAdaptor_Surface S; for (Tool.InitFace();Tool.MoreFace();Tool.NextFace()) { @@ -343,19 +248,9 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } } } - if(!isPrimArrayEnabled) - TheGroup->EndPrimitives(); } -#ifdef DEB_MESH - UIsoTimer.Stop(); - VIsoTimer.Start(); -#endif if (isoV) { - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } BRepAdaptor_Surface S; for (Tool.InitFace();Tool.MoreFace();Tool.NextFace()) { @@ -386,65 +281,48 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } } } - if (!isPrimArrayEnabled) TheGroup->EndPrimitives(); } -#ifdef DEB_MESH - VIsoTimer.Stop(); -#endif } Standard_Integer nbVertices = 0, nbBounds = 0; - if(isPrimArrayEnabled) { - if(UIsoCurves.Size() > 0) { - nbBounds = UIsoCurves.Size(); - Prs3d_NListIteratorOfListOfSequenceOfPnt It; - for( It.Init(UIsoCurves); It.More(); It.Next()) - nbVertices += It.Value().Length(); - Handle(Graphic3d_ArrayOfPolylines) UIsoArray = - new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); - for( It.Init(UIsoCurves); It.More(); It.Next()) { - TColgp_SequenceOfPnt Pnts; - Pnts.Assign(It.Value()); - UIsoArray->AddBound(Pnts.Length()); - for(int i=1; i<=Pnts.Length(); i++) - UIsoArray->AddVertex(Pnts.Value(i)); - } - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(UIsoArray); - TheGroup->EndPrimitives(); - } + if(UIsoCurves.Size() > 0) { + nbBounds = UIsoCurves.Size(); + Prs3d_NListIteratorOfListOfSequenceOfPnt It; + for( It.Init(UIsoCurves); It.More(); It.Next()) + nbVertices += It.Value().Length(); + Handle(Graphic3d_ArrayOfPolylines) UIsoArray = + new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); + for( It.Init(UIsoCurves); It.More(); It.Next()) { + TColgp_SequenceOfPnt Pnts; + Pnts.Assign(It.Value()); + UIsoArray->AddBound(Pnts.Length()); + for(int i=1; i<=Pnts.Length(); i++) + UIsoArray->AddVertex(Pnts.Value(i)); + } + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); + TheGroup->AddPrimitiveArray(UIsoArray); + } - if(VIsoCurves.Size() > 0) { - nbBounds = VIsoCurves.Size(); - Prs3d_NListIteratorOfListOfSequenceOfPnt It; - for( It.Init(VIsoCurves); It.More(); It.Next()) - nbVertices += It.Value().Length(); - Handle(Graphic3d_ArrayOfPolylines) VIsoArray = - new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); - for( It.Init(VIsoCurves); It.More(); It.Next()) { - TColgp_SequenceOfPnt Pnts; - Pnts.Assign(It.Value()); - VIsoArray->AddBound(Pnts.Length()); - for(int i=1; i<=Pnts.Length(); i++) - VIsoArray->AddVertex(Pnts.Value(i)); - } - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(VIsoArray); - TheGroup->EndPrimitives(); + if(VIsoCurves.Size() > 0) { + nbBounds = VIsoCurves.Size(); + Prs3d_NListIteratorOfListOfSequenceOfPnt It; + for( It.Init(VIsoCurves); It.More(); It.Next()) + nbVertices += It.Value().Length(); + Handle(Graphic3d_ArrayOfPolylines) VIsoArray = + new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); + for( It.Init(VIsoCurves); It.More(); It.Next()) { + TColgp_SequenceOfPnt Pnts; + Pnts.Assign(It.Value()); + VIsoArray->AddBound(Pnts.Length()); + for(int i=1; i<=Pnts.Length(); i++) + VIsoArray->AddVertex(Pnts.Value(i)); } + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); + TheGroup->AddPrimitiveArray(VIsoArray); } -#ifdef DEB_MESH - WireTimer.Start(); -#endif - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } gp_Pnt P; TopLoc_Location l; Graphic3d_Vertex V1, V2; @@ -514,11 +392,6 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, gp_Pnt P2 = Nodes(Free(2*i)).Transformed(l); SurfPnts.Append(P1); SurfPnts.Append(P2); - if(!isPrimArrayEnabled) { - V1.SetCoord(P1.X(), P1.Y(), P1.Z()); - V2.SetCoord(P2.X(), P2.Y(), P2.Z()); - TheGroup->Polyline(V1, V2); - } } } if(DispTriangles) { @@ -527,19 +400,12 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, gp_Pnt P2 = Nodes(Internal(2*i)).Transformed(l); SurfPnts.Append(P1); SurfPnts.Append(P2); - if(!isPrimArrayEnabled) { - V1.SetCoord(P1.X(), P1.Y(), P1.Z()); - V2.SetCoord(P2.X(), P2.Y(), P2.Z()); - TheGroup->Polyline(V1, V2); - } } } } } } - if(!isPrimArrayEnabled) - TheGroup->EndPrimitives(); - if(isPrimArrayEnabled && SurfPnts.Length()>0){ + if(SurfPnts.Length()>0){ nbVertices = SurfPnts.Length(); nbBounds = (Standard_Integer)nbVertices / 2; Handle(Graphic3d_ArrayOfPolylines) SurfArray = @@ -550,15 +416,11 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, SurfArray->AddVertex(SurfPnts.Value(i+1)); } Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - if(DispTriangles && Tool.HasSurface()) { + if(DispTriangles && Tool.HasSurface()) TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - } - else { + else TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect()); - } - TheGroup->BeginPrimitives(); TheGroup->AddPrimitiveArray(SurfArray); - TheGroup->EndPrimitives(); } TopTools_ListIteratorOfListOfShape It; @@ -566,7 +428,6 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, { // Wire (without any neighbour) TheGroup->SetPrimitivesAspect(aDrawer->WireAspect()->Aspect()); - TheGroup->BeginPrimitives(); for (It.Initialize(LWire); It.More(); It.Next()) { const TopoDS_Edge& E = TopoDS::Edge(It.Value()); try @@ -576,7 +437,7 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) { if (BRep_Tool::IsGeometric(E)) { BRepAdaptor_Curve C(E); - CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled); + CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, Standard_False); WireCurves.Append(Pnts); } } @@ -590,21 +451,11 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, #endif } } - TheGroup->EndPrimitives(); } -#ifdef DEB_MESH - WireTimer.Stop(); - FreeBoundaryTimer.Start(); -#endif - if (aDrawer->FreeBoundaryDraw()) { // Free boundaries; - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } for (It.Initialize(LFree); It.More(); It.Next()) { const TopoDS_Edge& E = TopoDS::Edge(It.Value()); if (!BRep_Tool::Degenerated(E)) { @@ -614,7 +465,7 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) { if (BRep_Tool::IsGeometric(E)) { BRepAdaptor_Curve C(E); - CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled); + CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, Standard_False); FreeCurves.Append(Pnts); } } @@ -629,23 +480,12 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } } } - if(!isPrimArrayEnabled) - TheGroup->EndPrimitives(); } -#ifdef DEB_MESH - FreeBoundaryTimer.Stop(); - UnFreeBoundaryTimer.Start(); -#endif - if (aDrawer->UnFreeBoundaryDraw()) { // Unfree boundaries; - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->UnFreeBoundaryAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } for (It.Initialize(LUnFree); It.More(); It.Next()) { const TopoDS_Edge& E = TopoDS::Edge(It.Value()); try @@ -655,7 +495,7 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, if (!AddPolygon(E, TheGroup, aDeflection, aDrawer, Pnts)) { if (BRep_Tool::IsGeometric(E)) { BRepAdaptor_Curve C(E); - CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, !isPrimArrayEnabled); + CurvePresentation::Add(aPresentation, C, aDeflection, aDrawer, Pnts, Standard_False); UnFreeCurves.Append(Pnts); } } @@ -669,113 +509,77 @@ void Prs3d_WFShape::Add(const Handle (Prs3d_Presentation)& aPresentation, #endif } } - if(!isPrimArrayEnabled) - TheGroup->EndPrimitives(); } - if(isPrimArrayEnabled) { - if(WireCurves.Size() > 0) { - nbBounds = WireCurves.Size(); - Prs3d_NListIteratorOfListOfSequenceOfPnt It; - for( It.Init(WireCurves); It.More(); It.Next()) - nbVertices += It.Value().Length(); - Handle(Graphic3d_ArrayOfPolylines) WireArray = - new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); - for( It.Init(WireCurves); It.More(); It.Next()) { - TColgp_SequenceOfPnt Pnts; - Pnts.Assign(It.Value()); - WireArray->AddBound(Pnts.Length()); - for(i=1; i<=Pnts.Length(); i++) - WireArray->AddVertex(Pnts.Value(i)); - } - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->WireAspect()->Aspect()); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(WireArray); - TheGroup->EndPrimitives(); - } - if(FreeCurves.Size() > 0) { - nbBounds = FreeCurves.Size(); - Prs3d_NListIteratorOfListOfSequenceOfPnt It; - for( It.Init(FreeCurves); It.More(); It.Next()) - nbVertices += It.Value().Length(); - Handle(Graphic3d_ArrayOfPolylines) FreeArray = - new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); - for( It.Init(FreeCurves); It.More(); It.Next()) { - TColgp_SequenceOfPnt Pnts; - Pnts.Assign(It.Value()); - FreeArray->AddBound(Pnts.Length()); - for(i=1; i<=Pnts.Length(); i++) - FreeArray->AddVertex(Pnts.Value(i)); - } - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect()); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(FreeArray); - TheGroup->EndPrimitives(); - } - if(UnFreeCurves.Size() > 0) { - nbBounds = UnFreeCurves.Size(); - Prs3d_NListIteratorOfListOfSequenceOfPnt It; - for( It.Init(UnFreeCurves); It.More(); It.Next()) - nbVertices += It.Value().Length(); - Handle(Graphic3d_ArrayOfPolylines) UnFreeArray = - new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); - for( It.Init(UnFreeCurves); It.More(); It.Next()) { - TColgp_SequenceOfPnt Pnts; - Pnts.Assign(It.Value()); - UnFreeArray->AddBound(Pnts.Length()); - for(i=1; i<=Pnts.Length(); i++) - UnFreeArray->AddVertex(Pnts.Value(i)); - } - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); - TheGroup->SetPrimitivesAspect(aDrawer->UnFreeBoundaryAspect()->Aspect()); - TheGroup->BeginPrimitives(); - TheGroup->AddPrimitiveArray(UnFreeArray); - TheGroup->EndPrimitives(); - } + if(WireCurves.Size() > 0) { + nbBounds = WireCurves.Size(); + Prs3d_NListIteratorOfListOfSequenceOfPnt It; + for( It.Init(WireCurves); It.More(); It.Next()) + nbVertices += It.Value().Length(); + Handle(Graphic3d_ArrayOfPolylines) WireArray = + new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); + for( It.Init(WireCurves); It.More(); It.Next()) { + TColgp_SequenceOfPnt Pnts; + Pnts.Assign(It.Value()); + WireArray->AddBound(Pnts.Length()); + for(i=1; i<=Pnts.Length(); i++) + WireArray->AddVertex(Pnts.Value(i)); + } + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->WireAspect()->Aspect()); + TheGroup->AddPrimitiveArray(WireArray); } - // Points - Standard_Boolean theFirst = Standard_True; - for(Tool.InitVertex();Tool.MoreVertex();Tool.NextVertex()){ - if(theFirst){ - theFirst = Standard_False; - if(!isPrimArrayEnabled) { - TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect()); - TheGroup->BeginPrimitives(); - } - } - TopoDS_Vertex V = Tool.GetVertex(); - if(!isPrimArrayEnabled) - PointPresentation::Add(aPresentation,V); - ShapePoints.Append(BRep_Tool::Pnt(V)); + if(FreeCurves.Size() > 0) { + nbBounds = FreeCurves.Size(); + Prs3d_NListIteratorOfListOfSequenceOfPnt It; + for( It.Init(FreeCurves); It.More(); It.Next()) + nbVertices += It.Value().Length(); + Handle(Graphic3d_ArrayOfPolylines) FreeArray = + new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); + for( It.Init(FreeCurves); It.More(); It.Next()) { + TColgp_SequenceOfPnt Pnts; + Pnts.Assign(It.Value()); + FreeArray->AddBound(Pnts.Length()); + for(i=1; i<=Pnts.Length(); i++) + FreeArray->AddVertex(Pnts.Value(i)); + } + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect()); + TheGroup->AddPrimitiveArray(FreeArray); + } + if(UnFreeCurves.Size() > 0) { + nbBounds = UnFreeCurves.Size(); + Prs3d_NListIteratorOfListOfSequenceOfPnt It; + for( It.Init(UnFreeCurves); It.More(); It.Next()) + nbVertices += It.Value().Length(); + Handle(Graphic3d_ArrayOfPolylines) UnFreeArray = + new Graphic3d_ArrayOfPolylines(nbVertices,nbBounds); + for( It.Init(UnFreeCurves); It.More(); It.Next()) { + TColgp_SequenceOfPnt Pnts; + Pnts.Assign(It.Value()); + UnFreeArray->AddBound(Pnts.Length()); + for(i=1; i<=Pnts.Length(); i++) + UnFreeArray->AddVertex(Pnts.Value(i)); + } + Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); + TheGroup->SetPrimitivesAspect(aDrawer->UnFreeBoundaryAspect()->Aspect()); + TheGroup->AddPrimitiveArray(UnFreeArray); } - if (!theFirst) TheGroup->EndPrimitives(); + + // Points + for(Tool.InitVertex();Tool.MoreVertex();Tool.NextVertex()) + ShapePoints.Append(BRep_Tool::Pnt(Tool.GetVertex())); nbVertices = ShapePoints.Length(); - if(isPrimArrayEnabled && nbVertices > 0) { + if(nbVertices > 0) { Graphic3d_Array1OfVertex PointArray(1, nbVertices); for(i=1; i<=nbVertices; i++) PointArray.SetValue(i, Graphic3d_Vertex(ShapePoints.Value(i).X(), ShapePoints.Value(i).Y(), ShapePoints.Value(i).Z())); Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->PointAspect()->Aspect()); - TheGroup->BeginPrimitives(); TheGroup->MarkerSet(PointArray); - TheGroup->EndPrimitives(); } - -#ifdef DEB_MESH - UnFreeBoundaryTimer.Stop(); -// cout << "Restrictions Min Max computation " ; -// RestrictedFaceTimer1.Show(); -// cout << "Iso loading " ; -// RestrictedFaceTimer2.Show(); -// cout << "Iso hatching " ; -// RestrictedFaceTimer3.Show(); -// cout << "Iso drawing " ; -// RestrictedFaceTimer4.Show(); -#endif } diff --git a/src/QABugs/QABugs_PresentableObject.cxx b/src/QABugs/QABugs_PresentableObject.cxx index fbbbabcded..bc87b0ddae 100644 --- a/src/QABugs/QABugs_PresentableObject.cxx +++ b/src/QABugs/QABugs_PresentableObject.cxx @@ -81,9 +81,7 @@ void QABugs_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager3d break; } - aGroup->BeginPrimitives(); aGroup->AddPrimitiveArray (aPrims); - aGroup->EndPrimitives(); } void QABugs_PresentableObject::ComputeSelection(const Handle(SelectMgr_Selection)& , diff --git a/src/StdPrs/StdPrs_Curve.cxx b/src/StdPrs/StdPrs_Curve.cxx index 6095bf4942..449b5ddc09 100755 --- a/src/StdPrs/StdPrs_Curve.cxx +++ b/src/StdPrs/StdPrs_Curve.cxx @@ -25,8 +25,8 @@ #include -#include -#include +#include +#include #include #include #include @@ -41,17 +41,14 @@ #include -static Standard_Integer myN = -1; -static Standard_Boolean first = Standard_True; - //================================================================== // function: FindLimits // purpose: //================================================================== static void FindLimits(const Adaptor3d_Curve& aCurve, - const Standard_Real aLimit, - Standard_Real& First, - Standard_Real& Last) + const Standard_Real aLimit, + Standard_Real& First, + Standard_Real& Last) { First = aCurve.FirstParameter(); Last = aCurve.LastParameter(); @@ -63,125 +60,92 @@ static void FindLimits(const Adaptor3d_Curve& aCurve, Standard_Real delta = 1; if (firstInf && lastInf) { do { - delta *= 2; - First = - delta; - Last = delta; - aCurve.D0(First,P1); - aCurve.D0(Last,P2); + delta *= 2; + First = - delta; + Last = delta; + aCurve.D0(First,P1); + aCurve.D0(Last,P2); } while (P1.Distance(P2) < aLimit); } else if (firstInf) { aCurve.D0(Last,P2); do { - delta *= 2; - First = Last - delta; - aCurve.D0(First,P1); + delta *= 2; + First = Last - delta; + aCurve.D0(First,P1); } while (P1.Distance(P2) < aLimit); } else if (lastInf) { aCurve.D0(First,P1); do { - delta *= 2; - Last = First + delta; - aCurve.D0(Last,P2); + delta *= 2; + Last = First + delta; + aCurve.D0(Last,P2); } while (P1.Distance(P2) < aLimit); } } } - //================================================================== // function: DrawCurve // purpose: //================================================================== -static void DrawCurve (const Adaptor3d_Curve& aCurve, +static void DrawCurve (const Adaptor3d_Curve& aCurve, const Handle(Graphic3d_Group) aGroup, - const Standard_Integer NbP, + const Standard_Integer NbP, const Standard_Real U1, const Standard_Real U2, - TColgp_SequenceOfPnt& Points, - const Standard_Boolean drawCurve) + TColgp_SequenceOfPnt& Points, + const Standard_Boolean drawCurve) { Standard_Integer nbintervals = 1; - + if (aCurve.GetType() == GeomAbs_BSplineCurve) { nbintervals = aCurve.NbKnots() - 1; nbintervals = Max(1, nbintervals/3); } - Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable() && !drawCurve; - switch (aCurve.GetType()) { - case GeomAbs_Line: + switch (aCurve.GetType()) + { + case GeomAbs_Line: { -#ifdef OCC64 - Graphic3d_Array1OfVertex VertexArray(1, 3); - gp_Pnt p = aCurve.Value(U1); - Points.Append(p); - VertexArray(1).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(0.5 * (U1 + U2)); - Points.Append(p); - VertexArray(2).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(U2); - Points.Append(p); - VertexArray(3).SetCoord(p.X(), p.Y(), p.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray); -#else - static Graphic3d_Array1OfVertex VertexLine(1,2); - gp_Pnt p = aCurve.Value(U1); - Points.Append(p); - VertexLine(1).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(U2); - Points.Append(p); - VertexLine(2).SetCoord(p.X(), p.Y(), p.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexLine); -#endif - } + gp_Pnt p1 = aCurve.Value(U1); + gp_Pnt p2 = aCurve.Value(U2); + Points.Append(p1); + Points.Append(p2); + if(drawCurve) + { + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(p1); + aPrims->AddVertex(p2); + aGroup->AddPrimitiveArray(aPrims); + } + } break; - default: + default: { - Standard_Real U; - Standard_Integer N = Max(2, NbP*nbintervals); - Standard_Real DU = (U2-U1) / (N-1); + const Standard_Integer N = Max(2, NbP*nbintervals); + const Standard_Real DU = (U2-U1) / (N-1); gp_Pnt p; - if (first) { - myN = N; - first = Standard_False; - } - if (myN == N) { - - static Graphic3d_Array1OfVertex VertexArray(1, N); - - for (Standard_Integer i = 1; i <= N;i++) { - U = U1 + (i-1)*DU; - p = aCurve.Value(U); - Points.Append(p); - VertexArray(i).SetCoord(p.X(), p.Y(), p.Z()); - } - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray); - } - else { - Graphic3d_Array1OfVertex VertexArray2(1, N); - - for (Standard_Integer i = 1; i <= N;i++) { - U = U1 + (i-1)*DU; - p = aCurve.Value(U); - Points.Append(p); - VertexArray2(i).SetCoord(p.X(), p.Y(), p.Z()); - } - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray2); + Handle(Graphic3d_ArrayOfPolylines) aPrims; + if(drawCurve) + aPrims = new Graphic3d_ArrayOfPolylines(N); + + for (Standard_Integer i = 1; i <= N;i++) { + p = aCurve.Value(U1 + (i-1)*DU); + Points.Append(p); + if(drawCurve) + aPrims->AddVertex(p); } + if(drawCurve) + aGroup->AddPrimitiveArray(aPrims); } } } - //================================================================== // function: MatchCurve // purpose: @@ -192,70 +156,61 @@ static Standard_Boolean MatchCurve ( const Quantity_Length Z, const Quantity_Length aDistance, const Adaptor3d_Curve& aCurve, - const Quantity_Length TheDeflection, + const Quantity_Length TheDeflection, const Standard_Integer NbP, - const Standard_Real U1, - const Standard_Real U2) + const Standard_Real U1, + const Standard_Real U2) { Quantity_Length retdist; - switch (aCurve.GetType()) { - case GeomAbs_Line: + switch (aCurve.GetType()) + { + case GeomAbs_Line: { - static Graphic3d_Array1OfVertex VertexArray(1,2); - gp_Pnt p1 = aCurve.Value(U1); - if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance) - return Standard_True; - gp_Pnt p2 = aCurve.Value(U2); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist); - } - break; - case GeomAbs_Circle: - {Standard_Real Radius = aCurve.Circle().Radius(); - Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius); - Standard_Real Er = Abs( U2 - U1) / DU; - Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er)); - gp_Pnt p1,p2; - if ( N > 0) { - Standard_Real U; - for (Standard_Integer Index = 1; Index <= N+1; Index++) { - U = U1 + (Index - 1) * DU; - p2 = aCurve.Value(U); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - - if (Index>1) { - if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) - return Standard_True; - } - p1=p2; - - } - } - return Standard_False; - } - break; - default: + gp_Pnt p1 = aCurve.Value(U1); + if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance) + return Standard_True; + gp_Pnt p2 = aCurve.Value(U2); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist); + } + case GeomAbs_Circle: + { + const Standard_Real Radius = aCurve.Circle().Radius(); + const Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius); + const Standard_Real Er = Abs( U2 - U1) / DU; + const Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er)); + if ( N > 0) { + gp_Pnt p1,p2; + for (Standard_Integer Index = 1; Index <= N+1; Index++) { + p2 = aCurve.Value(U1 + (Index - 1) * DU); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + + if (Index>1) { + if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) + return Standard_True; + } + p1=p2; + } + } + break; + } + default: { + const Standard_Real DU = (U2-U1) / (NbP-1); gp_Pnt p1,p2; - Standard_Real U; - Standard_Real DU = (U2-U1) / (NbP-1); - - for (Standard_Integer i=1;i<=NbP;i++) { - U = U1 + (i-1)*DU; - p2 = aCurve.Value(U); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - if (i>1) { - if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) - return Standard_True; - } - p1=p2; + for (Standard_Integer i=1;i<=NbP;i++) { + p2 = aCurve.Value(U1 + (i-1)*DU); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + if (i>1) { + if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) + return Standard_True; + } + p1=p2; } - return Standard_False; } - return Standard_False; } return Standard_False; } @@ -266,32 +221,26 @@ static Standard_Boolean MatchCurve ( // purpose: //================================================================== void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation, - const Adaptor3d_Curve& aCurve, - const Handle (Prs3d_Drawer)& aDrawer, - const Standard_Boolean drawCurve) { - - Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect - (aDrawer->LineAspect()->Aspect()); + const Adaptor3d_Curve& aCurve, + const Handle (Prs3d_Drawer)& aDrawer, + const Standard_Boolean drawCurve) +{ + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect()); - Standard_Integer NbPoints = aDrawer->Discretisation(); Standard_Real V1, V2; FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2); + const Standard_Integer NbPoints = aDrawer->Discretisation(); TColgp_SequenceOfPnt Pnts; - DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - NbPoints, - V1 , V2, Pnts, drawCurve); + DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Pnts,drawCurve); if (aDrawer->LineArrowDraw()) { gp_Pnt Location; gp_Vec Direction; aCurve.D1(aCurve.LastParameter(),Location,Direction); - Prs3d_Arrow::Draw (aPresentation, - Location, - gp_Dir(Direction), - aDrawer->ArrowAspect()->Angle(), - aDrawer->ArrowAspect()->Length()); + Prs3d_Arrow::Draw (aPresentation,Location,gp_Dir(Direction), + aDrawer->ArrowAspect()->Angle(), + aDrawer->ArrowAspect()->Length()); } } @@ -301,80 +250,67 @@ void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation, // purpose: //================================================================== void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation, - const Adaptor3d_Curve& aCurve, - const Quantity_Length aDeflection, - const Handle(Prs3d_Drawer)& aDrawer, - TColgp_SequenceOfPnt& Points, - const Standard_Boolean drawCurve) + const Adaptor3d_Curve& aCurve, + const Quantity_Length aDeflection, + const Handle(Prs3d_Drawer)& aDrawer, + TColgp_SequenceOfPnt& Points, + const Standard_Boolean drawCurve) { - - Standard_Integer NbPoints = aDrawer->Discretisation(); - Standard_Real aLimit = aDrawer->MaximalParameterValue(); Standard_Real V1, V2; - FindLimits(aCurve, aLimit, V1, V2); + FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2); - DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - NbPoints, - V1 , V2, Points, drawCurve); + const Standard_Integer NbPoints = aDrawer->Discretisation(); + DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Points,drawCurve); } + //================================================================== // function: Add // purpose: //================================================================== void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation, - const Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Quantity_Length aDeflection, - TColgp_SequenceOfPnt& Points, - const Standard_Integer NbPoints, - const Standard_Boolean drawCurve) { - - DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - NbPoints, - U1 , U2, Points, drawCurve); + const Adaptor3d_Curve& aCurve, + const Standard_Real U1, + const Standard_Real U2, + const Quantity_Length aDeflection, + TColgp_SequenceOfPnt& Points, + const Standard_Integer NbPoints, + const Standard_Boolean drawCurve) +{ + DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,U1,U2,Points,drawCurve); } - //================================================================== // function: Add // purpose: //================================================================== void StdPrs_Curve::Add (const Handle (Prs3d_Presentation)& aPresentation, - const Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Handle (Prs3d_Drawer)& aDrawer, - const Standard_Boolean drawCurve) { - + const Adaptor3d_Curve& aCurve, + const Standard_Real U1, + const Standard_Real U2, + const Handle (Prs3d_Drawer)& aDrawer, + const Standard_Boolean drawCurve) +{ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect()); - Standard_Integer NbPoints = aDrawer->Discretisation(); Standard_Real V1 = U1; Standard_Real V2 = U2; if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue(); if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue(); + const Standard_Integer NbPoints = aDrawer->Discretisation(); TColgp_SequenceOfPnt Pnts; - DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - NbPoints, - V1 , V2, Pnts, drawCurve); + DrawCurve(aCurve,Prs3d_Root::CurrentGroup(aPresentation),NbPoints,V1,V2,Pnts,drawCurve); if (aDrawer->LineArrowDraw()) { gp_Pnt Location; gp_Vec Direction; aCurve.D1(aCurve.LastParameter(),Location,Direction); - Prs3d_Arrow::Draw (aPresentation, - Location, - gp_Dir(Direction), - aDrawer->ArrowAspect()->Angle(), - aDrawer->ArrowAspect()->Length()); + Prs3d_Arrow::Draw (aPresentation,Location,gp_Dir(Direction), + aDrawer->ArrowAspect()->Angle(), + aDrawer->ArrowAspect()->Length()); } } @@ -388,19 +324,19 @@ Standard_Boolean StdPrs_Curve::Match const Quantity_Length Y, const Quantity_Length Z, const Quantity_Length aDistance, - const Adaptor3d_Curve& aCurve, + const Adaptor3d_Curve& aCurve, const Handle (Prs3d_Drawer)& aDrawer) { - Standard_Integer NbPoints = aDrawer->Discretisation(); Standard_Real V1, V2; FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2); + const Standard_Integer NbPoints = aDrawer->Discretisation(); return MatchCurve(X,Y,Z,aDistance,aCurve, - aDrawer->MaximalChordialDeviation(), NbPoints, - V1 , V2); + aDrawer->MaximalChordialDeviation(),NbPoints,V1,V2); } + //================================================================== // function: Match // purpose: @@ -413,19 +349,16 @@ Standard_Boolean StdPrs_Curve::Match const Adaptor3d_Curve& aCurve, const Quantity_Length aDeflection, const Standard_Real aLimit, - const Standard_Integer NbPoints) { - + const Standard_Integer NbPoints) +{ Standard_Real V1, V2; FindLimits(aCurve, aLimit, V1, V2); return MatchCurve(X,Y,Z,aDistance,aCurve, - aDeflection, NbPoints, - V1 , V2); - + aDeflection,NbPoints,V1,V2); } - //================================================================== // function: Match // purpose: @@ -438,8 +371,8 @@ Standard_Boolean StdPrs_Curve::Match const Adaptor3d_Curve& aCurve, const Standard_Real U1, const Standard_Real U2, - const Handle (Prs3d_Drawer)& aDrawer) { - + const Handle (Prs3d_Drawer)& aDrawer) +{ Standard_Real V1 = U1; Standard_Real V2 = U2; @@ -447,9 +380,8 @@ Standard_Boolean StdPrs_Curve::Match if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue(); return MatchCurve(X,Y,Z,aDistance,aCurve, - aDrawer->MaximalChordialDeviation(), - aDrawer->Discretisation(), - V1 , V2); + aDrawer->MaximalChordialDeviation(), + aDrawer->Discretisation(),V1,V2); } @@ -468,8 +400,5 @@ Standard_Boolean StdPrs_Curve::Match const Quantity_Length aDeflection, const Standard_Integer aNbPoints) { - return MatchCurve(X,Y,Z,aDistance,aCurve, - aDeflection, aNbPoints, - U1 , U2); + return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,aNbPoints,U1,U2); } - diff --git a/src/StdPrs/StdPrs_DeflectionCurve.cdl b/src/StdPrs/StdPrs_DeflectionCurve.cdl index 5c3e371c05..186e59b85c 100755 --- a/src/StdPrs/StdPrs_DeflectionCurve.cdl +++ b/src/StdPrs/StdPrs_DeflectionCurve.cdl @@ -38,12 +38,10 @@ uses is - - Add(myclass; aPresentation: Presentation from Prs3d; - aCurve : in out Curve from Adaptor3d; + aCurve : in out Curve from Adaptor3d; aDrawer : Drawer from Prs3d; - drawCurve : Boolean from Standard = Standard_True); + drawCurve : Boolean from Standard = Standard_True); ---Purpose: adds to the presentation aPresentation the drawing of the curve -- aCurve with respect to the maximal chordial deviation defined @@ -53,13 +51,11 @@ is -- it is used if the curve is a part of some shape and PrimitiveArray -- visualization approach is activated (it is activated by default). - - Add(myclass; aPresentation: Presentation from Prs3d; - aCurve : in out Curve from Adaptor3d; + aCurve : in out Curve from Adaptor3d; U1, U2 : Real from Standard; aDrawer : Drawer from Prs3d; - drawCurve : Boolean from Standard = Standard_True); + drawCurve : Boolean from Standard = Standard_True); ---Purpose: adds to the presentation aPresentation the drawing of the curve -- aCurve with respect to the maximal chordial deviation defined @@ -70,15 +66,12 @@ is -- it is used if the curve is a part of some shape and PrimitiveArray -- visualization approach is activated (it is activated by default). - - - Add(myclass; aPresentation: Presentation from Prs3d; - aCurve : in out Curve from Adaptor3d; + aCurve : in out Curve from Adaptor3d; aDeflection : Real from Standard; aLimit : Real from Standard; anAngle : Real from Standard = 0.2; - drawCurve : Boolean from Standard = Standard_True); + drawCurve : Boolean from Standard = Standard_True); ---Purpose: adds to the presentation aPresentation the drawing of the curve -- aCurve with respect to the maximal chordial deviation aDeflection. @@ -87,43 +80,38 @@ is -- it is used if the curve is a part of some shape and PrimitiveArray -- visualization approach is activated (it is activated by default). - Add(myclass; aPresentation: Presentation from Prs3d; - aCurve : in out Curve from Adaptor3d; + aCurve : in out Curve from Adaptor3d; aDeflection : Real from Standard; aDrawer : Drawer from Prs3d; Points : out SequenceOfPnt from TColgp; - drawCurve : Boolean from Standard = Standard_True); + drawCurve : Boolean from Standard = Standard_True); ---Purpose: adds to the presentation aPresentation the drawing of the curve -- aCurve with respect to the maximal chordial deviation aDeflection. -- The aspect is the current aspect - -- Points give a sequence of curve points. + -- Points give a sequence of curve points. -- If drawCurve equals Standard_False the curve will not be displayed, -- it is used if the curve is a part of some shape and PrimitiveArray -- visualization approach is activated (it is activated by default). - - - Add(myclass; aPresentation: Presentation from Prs3d; - aCurve : in out Curve from Adaptor3d; + aCurve : in out Curve from Adaptor3d; U1, U2 : Real from Standard; aDeflection : Real from Standard; - Points : out SequenceOfPnt from TColgp; + Points : out SequenceOfPnt from TColgp; anAngle : Real from Standard = 0.2; - drawCurve : Boolean from Standard = Standard_True); + drawCurve : Boolean from Standard = Standard_True); ---Purpose: adds to the presentation aPresentation the drawing of the curve -- aCurve with respect to the maximal chordial deviation aDeflection. -- The aspect is the current aspect -- The drawing will be limited between the points of parameter U1 and U2. - -- Points give a sequence of curve points. + -- Points give a sequence of curve points. -- If drawCurve equals Standard_False the curve will not be displayed, -- it is used if the curve is a part of some shape and PrimitiveArray -- visualization approach is activated (it is activated by default). - Match(myclass; X, Y, Z : Length from Quantity; aDistance : Length from Quantity; aCurve : Curve from Adaptor3d; @@ -135,8 +123,6 @@ is -- chordial deviation defined by the drawer aDrawer is less then aDistance. - - Match(myclass; X, Y, Z : Length from Quantity; aDistance: Length from Quantity; aCurve : Curve from Adaptor3d; @@ -150,8 +136,6 @@ is -- then aDistance. The drawing is considered between the points -- of parameter U1 and U2; - - Match(myclass; X,Y,Z : Length from Quantity; aDistance : Length from Quantity; aCurve : Curve from Adaptor3d; @@ -165,8 +149,6 @@ is -- aDeflection is less then aDistance. - - Match(myclass; X, Y, Z : Length from Quantity; aDistance : Length from Quantity; aCurve : Curve from Adaptor3d; @@ -180,9 +162,4 @@ is -- aDeflection is less then aDistance. The drawing is considered -- between the points of parameter U1 and U2; - - end DeflectionCurve from StdPrs; - - - diff --git a/src/StdPrs/StdPrs_DeflectionCurve.cxx b/src/StdPrs/StdPrs_DeflectionCurve.cxx index c4f02cf4ce..69c76fd32a 100755 --- a/src/StdPrs/StdPrs_DeflectionCurve.cxx +++ b/src/StdPrs/StdPrs_DeflectionCurve.cxx @@ -22,8 +22,8 @@ #include -#include -#include +#include +#include #include #include #include @@ -47,45 +47,46 @@ // purpose: //================================================================== static Standard_Real GetDeflection(const Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Handle(Prs3d_Drawer)& aDrawer) { - Standard_Real TheDeflection; - Aspect_TypeOfDeflection TOD = aDrawer->TypeOfDeflection(); - if (TOD == Aspect_TOD_RELATIVE) { -// On calcule la fleche en fonction des min max globaux de la piece: - Bnd_Box Total; - BndLib_Add3dCurve::Add(aCurve, U1, U2, 0.,Total); - Standard_Real m = RealFirst(); - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); - m = RealLast(); - if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() )) - m = Abs (aXmax-aXmin); - if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() )) - m = Max ( m , Abs (aYmax-aYmin)); - if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() )) - m = Max ( m , Abs (aZmax-aZmin)); + const Standard_Real U1, + const Standard_Real U2, + const Handle(Prs3d_Drawer)& aDrawer) +{ + Standard_Real TheDeflection; + + if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) + { + // On calcule la fleche en fonction des min max globaux de la piece: + Bnd_Box Total; + BndLib_Add3dCurve::Add(aCurve, U1, U2, 0.,Total); + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + Total.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); + Standard_Real m = RealLast(); + if ( ! (Total.IsOpenXmin() || Total.IsOpenXmax() )) + m = Abs (aXmax-aXmin); + if ( ! (Total.IsOpenYmin() || Total.IsOpenYmax() )) + m = Max ( m , Abs (aYmax-aYmin)); + if ( ! (Total.IsOpenZmin() || Total.IsOpenZmax() )) + m = Max ( m , Abs (aZmax-aZmin)); - m = Min ( m , aDrawer->MaximalParameterValue()); - m = Max(m, Precision::Confusion()); + m = Min ( m , aDrawer->MaximalParameterValue()); + m = Max(m, Precision::Confusion()); - TheDeflection = m * aDrawer->DeviationCoefficient(); - } - else - TheDeflection = aDrawer->MaximalChordialDeviation(); - - return TheDeflection; + TheDeflection = m * aDrawer->DeviationCoefficient(); } + else + TheDeflection = aDrawer->MaximalChordialDeviation(); + + return TheDeflection; +} //================================================================== // function: FindLimits // purpose: //================================================================== -static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve, - const Standard_Real aLimit, - Standard_Real& First, - Standard_Real& Last) +static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve, + const Standard_Real aLimit, + Standard_Real& First, + Standard_Real& Last) { First = aCurve.FirstParameter(); Last = aCurve.LastParameter(); @@ -98,30 +99,30 @@ static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve, Standard_Integer count = 0; if (firstInf && lastInf) { do { - if (count++ == 100000) return Standard_False; - delta *= 2; - First = - delta; - Last = delta; - aCurve.D0(First,P1); - aCurve.D0(Last,P2); + if (count++ == 100000) return Standard_False; + delta *= 2; + First = - delta; + Last = delta; + aCurve.D0(First,P1); + aCurve.D0(Last,P2); } while (P1.Distance(P2) < aLimit); } else if (firstInf) { aCurve.D0(Last,P2); do { - if (count++ == 100000) return Standard_False; - delta *= 2; - First = Last - delta; - aCurve.D0(First,P1); + if (count++ == 100000) return Standard_False; + delta *= 2; + First = Last - delta; + aCurve.D0(First,P1); } while (P1.Distance(P2) < aLimit); } else if (lastInf) { aCurve.D0(First,P1); do { - if (count++ == 100000) return Standard_False; - delta *= 2; - Last = First + delta; - aCurve.D0(Last,P2); + if (count++ == 100000) return Standard_False; + delta *= 2; + Last = First + delta; + aCurve.D0(Last,P2); } while (P1.Distance(P2) < aLimit); } } @@ -129,95 +130,80 @@ static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve, } - - //================================================================== // function: DrawCurve // purpose: //================================================================== -static void DrawCurve (Adaptor3d_Curve& aCurve, +static void DrawCurve (Adaptor3d_Curve& aCurve, const Handle(Graphic3d_Group) aGroup, const Quantity_Length TheDeflection, - const Standard_Real anAngle, + const Standard_Real anAngle, const Standard_Real U1, const Standard_Real U2, - TColgp_SequenceOfPnt& Points, - const Standard_Boolean drawCurve) + TColgp_SequenceOfPnt& Points, + const Standard_Boolean drawCurve) { - Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable() && !drawCurve; - - switch (aCurve.GetType()) { - case GeomAbs_Line: + switch (aCurve.GetType()) + { + case GeomAbs_Line: { -#ifdef OCC64 - Graphic3d_Array1OfVertex VertexArray(1, 3); - gp_Pnt p = aCurve.Value(U1); - Points.Append(p); - VertexArray(1).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(0.5 * (U1 + U2)); - Points.Append(p); - VertexArray(2).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(U2); - Points.Append(p); - VertexArray(3).SetCoord(p.X(), p.Y(), p.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray); -#else - static Graphic3d_Array1OfVertex VertexArray(1,2); - gp_Pnt p = aCurve.Value(U1); - Points.Append(p); - VertexArray(1).SetCoord(p.X(), p.Y(), p.Z()); - p = aCurve.Value(U2); - Points.Append(p); - VertexArray(2).SetCoord(p.X(), p.Y(), p.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray); -#endif - } - break; - default: + gp_Pnt p1 = aCurve.Value(U1); + gp_Pnt p2 = aCurve.Value(U2); + Points.Append(p1); + Points.Append(p2); + if(drawCurve) + { + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(p1); + aPrims->AddVertex(p2); + aGroup->AddPrimitiveArray(aPrims); + } + break; + } + default: { - Standard_Integer nbinter = aCurve.NbIntervals(GeomAbs_C1); - Standard_Integer i, j; + const Standard_Integer nbinter = aCurve.NbIntervals(GeomAbs_C1); TColStd_Array1OfReal T(1, nbinter+1); aCurve.Intervals(T, GeomAbs_C1); + Standard_Real theU1, theU2; - Standard_Integer NumberOfPoints; + Standard_Integer NumberOfPoints, i, j; TColgp_SequenceOfPnt SeqP; for (j = 1; j <= nbinter; j++) { - theU1 = T(j); theU2 = T(j+1); - if (theU2 > U1 && theU1 < U2) { - theU1 = Max(theU1, U1); - theU2 = Min(theU2, U2); - - GCPnts_TangentialDeflection Algo(aCurve, theU1, theU2, anAngle, TheDeflection); - NumberOfPoints = Algo.NbPoints(); + theU1 = T(j); theU2 = T(j+1); + if (theU2 > U1 && theU1 < U2) { + theU1 = Max(theU1, U1); + theU2 = Min(theU2, U2); - if (NumberOfPoints > 0) { - for (i=1;i 0) { + for (i=1;iAddVertex(p); } - if(!isPrimArrayEnabled) - aGroup->Polyline(VertexArray); + if(drawCurve) + aGroup->AddPrimitiveArray(aPrims); } } - } @@ -231,71 +217,65 @@ static Standard_Boolean MatchCurve ( const Quantity_Length Z, const Quantity_Length aDistance, const Adaptor3d_Curve& aCurve, - const Quantity_Length TheDeflection, + const Quantity_Length TheDeflection, const Standard_Real anAngle, - const Standard_Real U1, - const Standard_Real U2) + const Standard_Real U1, + const Standard_Real U2) { Quantity_Length retdist; - switch (aCurve.GetType()) { - case GeomAbs_Line: + switch (aCurve.GetType()) + { + case GeomAbs_Line: { - static Graphic3d_Array1OfVertex VertexArray(1,2); - gp_Pnt p1 = aCurve.Value(U1); - if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance) - return Standard_True; - gp_Pnt p2 = aCurve.Value(U2); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist); - } - break; - case GeomAbs_Circle: + gp_Pnt p1 = aCurve.Value(U1); + if ( Abs(X-p1.X()) + Abs(Y-p1.Y()) + Abs(Z-p1.Z()) <= aDistance) + return Standard_True; + gp_Pnt p2 = aCurve.Value(U2); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + return Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist); + } + case GeomAbs_Circle: { - Standard_Real Radius = aCurve.Circle().Radius(); + const Standard_Real Radius = aCurve.Circle().Radius(); if (!Precision::IsInfinite(Radius)) { - Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius); - Standard_Real Er = Abs( U2 - U1) / DU; - Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er)); - gp_Pnt p1,p2; - if ( N > 0) { - Standard_Real U; - for (Standard_Integer Index = 1; Index <= N+1; Index++) { - U = U1 + (Index - 1) * DU; - p2 = aCurve.Value(U); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - - if (Index>1) { - if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) - return Standard_True; - } - p1=p2; - - } - } + const Standard_Real DU = Sqrt(8.0 * TheDeflection / Radius); + const Standard_Real Er = Abs( U2 - U1) / DU; + const Standard_Integer N = Max(2, (Standard_Integer)IntegerPart(Er)); + if ( N > 0) { + gp_Pnt p1,p2; + for (Standard_Integer Index = 1; Index <= N+1; Index++) { + p2 = aCurve.Value(U1 + (Index - 1) * DU); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + + if (Index>1) { + if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) + return Standard_True; + } + p1=p2; + } + } } - return Standard_False; - } - break; - default: + break; + } + default: { GCPnts_TangentialDeflection Algo(aCurve,U1, U2, anAngle, TheDeflection); - gp_Pnt p1,p2; - Standard_Integer NumberOfPoints = Algo.NbPoints(); + const Standard_Integer NumberOfPoints = Algo.NbPoints(); if (NumberOfPoints > 0) { - for (Standard_Integer i=1;i<=NumberOfPoints;i++) { - p2 = Algo.Value(i); - if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) - return Standard_True; - if (i>1) { - if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) - return Standard_True; - } - p1=p2; - } + gp_Pnt p1,p2; + for (Standard_Integer i=1;i<=NumberOfPoints;i++) { + p2 = Algo.Value(i); + if ( Abs(X-p2.X()) + Abs(Y-p2.Y()) + Abs(Z-p2.Z()) <= aDistance) + return Standard_True; + if (i>1) { + if (Prs3d::MatchSegment(X,Y,Z,aDistance,p1,p2,retdist)) + return Standard_True; + } + p1=p2; + } } - return Standard_False; } } return Standard_False; @@ -307,32 +287,31 @@ static Standard_Boolean MatchCurve ( // purpose: //================================================================== void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, - Adaptor3d_Curve& aCurve, - const Handle (Prs3d_Drawer)& aDrawer, - const Standard_Boolean drawCurve) { - + Adaptor3d_Curve& aCurve, + const Handle (Prs3d_Drawer)& aDrawer, + const Standard_Boolean drawCurve) +{ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect()); - Standard_Real V1, V2, angle = aDrawer->DeviationAngle(); - Standard_Boolean OK = FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2); - - TColgp_SequenceOfPnt Points; - if (OK) { + Standard_Real V1, V2; + if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2)) + { + TColgp_SequenceOfPnt Points; DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - GetDeflection(aCurve, V1, V2, aDrawer), - angle, - V1 , V2, Points, drawCurve); - + Prs3d_Root::CurrentGroup(aPresentation), + GetDeflection(aCurve, V1, V2, aDrawer), + aDrawer->DeviationAngle(), + V1, V2, Points, drawCurve); + if (aDrawer->LineArrowDraw()) { gp_Pnt Location; gp_Vec Direction; aCurve.D1(V2, Location,Direction); Prs3d_Arrow::Draw (aPresentation, - Location, - gp_Dir(Direction), - aDrawer->ArrowAspect()->Angle(), - aDrawer->ArrowAspect()->Length()); + Location, + gp_Dir(Direction), + aDrawer->ArrowAspect()->Angle(), + aDrawer->ArrowAspect()->Length()); } } } @@ -343,38 +322,36 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati // purpose: //================================================================== void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, - Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Handle (Prs3d_Drawer)& aDrawer, - const Standard_Boolean drawCurve) { - + Adaptor3d_Curve& aCurve, + const Standard_Real U1, + const Standard_Real U2, + const Handle (Prs3d_Drawer)& aDrawer, + const Standard_Boolean drawCurve) +{ Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->LineAspect()->Aspect()); Standard_Real V1 = U1; Standard_Real V2 = U2; - if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue(); if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue(); - Standard_Real angle = aDrawer->DeviationAngle(); TColgp_SequenceOfPnt Points; DrawCurve(aCurve, - Prs3d_Root::CurrentGroup(aPresentation), - GetDeflection(aCurve, V1, V2, aDrawer), - angle, - V1 , V2, Points, drawCurve); + Prs3d_Root::CurrentGroup(aPresentation), + GetDeflection(aCurve, V1, V2, aDrawer), + aDrawer->DeviationAngle(), + V1 , V2, Points, drawCurve); if (aDrawer->LineArrowDraw()) { gp_Pnt Location; gp_Vec Direction; aCurve.D1(V2, Location,Direction); Prs3d_Arrow::Draw (aPresentation, - Location, - gp_Dir(Direction), - aDrawer->ArrowAspect()->Angle(), - aDrawer->ArrowAspect()->Length()); + Location, + gp_Dir(Direction), + aDrawer->ArrowAspect()->Angle(), + aDrawer->ArrowAspect()->Length()); } } @@ -383,36 +360,36 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati // purpose: //================================================================== void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, - Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Standard_Real aDeflection, - TColgp_SequenceOfPnt& Points, - const Standard_Real anAngle, - const Standard_Boolean drawCurve) + Adaptor3d_Curve& aCurve, + const Standard_Real U1, + const Standard_Real U2, + const Standard_Real aDeflection, + TColgp_SequenceOfPnt& Points, + const Standard_Real anAngle, + const Standard_Boolean drawCurve) { DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation), aDeflection, anAngle, U1, U2, Points, drawCurve); } - //================================================================== // function: Add // purpose: //================================================================== void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, - Adaptor3d_Curve& aCurve, - const Standard_Real aDeflection, - const Standard_Real aLimit, - const Standard_Real anAngle, - const Standard_Boolean drawCurve) + Adaptor3d_Curve& aCurve, + const Standard_Real aDeflection, + const Standard_Real aLimit, + const Standard_Real anAngle, + const Standard_Boolean drawCurve) { Standard_Real V1, V2; - Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2); - - TColgp_SequenceOfPnt Points; - if (OK) DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation), - aDeflection, anAngle, V1, V2, Points, drawCurve); + if (FindLimits(aCurve, aLimit, V1, V2)) + { + TColgp_SequenceOfPnt Points; + DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation), + aDeflection, anAngle, V1, V2, Points, drawCurve); + } } @@ -421,18 +398,16 @@ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentati // purpose: //================================================================================ void StdPrs_DeflectionCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, - Adaptor3d_Curve& aCurve, - const Standard_Real aDeflection, - const Handle(Prs3d_Drawer)& aDrawer, - TColgp_SequenceOfPnt& Points, - const Standard_Boolean drawCurve) + Adaptor3d_Curve& aCurve, + const Standard_Real aDeflection, + const Handle(Prs3d_Drawer)& aDrawer, + TColgp_SequenceOfPnt& Points, + const Standard_Boolean drawCurve) { - Standard_Real aLimit = aDrawer->MaximalParameterValue(); Standard_Real V1, V2; - Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2); - - if (OK) DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation), - aDeflection, aDrawer->DeviationAngle(), V1, V2, Points, drawCurve); + if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2)) + DrawCurve(aCurve, Prs3d_Root::CurrentGroup(aPresentation), + aDeflection, aDrawer->DeviationAngle(), V1, V2, Points, drawCurve); } @@ -449,20 +424,16 @@ Standard_Boolean StdPrs_DeflectionCurve::Match const Handle (Prs3d_Drawer)& aDrawer) { Standard_Real V1, V2; - Standard_Boolean OK = FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2); - if (OK) { + if (FindLimits(aCurve, aDrawer->MaximalParameterValue(), V1, V2)) + { return MatchCurve(X,Y,Z,aDistance,aCurve, - GetDeflection(aCurve, V1, V2, aDrawer), - aDrawer->DeviationAngle(), - V1 , V2); - } - else { - return Standard_False; + GetDeflection(aCurve, V1, V2, aDrawer), + aDrawer->DeviationAngle(), + V1, V2); } + return Standard_False; } - - //================================================================== // function: Match // purpose: @@ -478,35 +449,32 @@ Standard_Boolean StdPrs_DeflectionCurve::Match const Handle (Prs3d_Drawer)& aDrawer) { Standard_Real V1 = U1; - Standard_Real V2 = U2; + Standard_Real V2 = U2; if (Precision::IsNegativeInfinite(V1)) V1 = -aDrawer->MaximalParameterValue(); if (Precision::IsPositiveInfinite(V2)) V2 = aDrawer->MaximalParameterValue(); return MatchCurve(X,Y,Z,aDistance,aCurve, - GetDeflection(aCurve, V1, V2, aDrawer), - aDrawer->DeviationAngle(), V1 , V2); + GetDeflection(aCurve, V1, V2, aDrawer), + aDrawer->DeviationAngle(), V1, V2); } - //================================================================== // function: Match // purpose: //================================================================== Standard_Boolean StdPrs_DeflectionCurve::Match (const Quantity_Length X, - const Quantity_Length Y, - const Quantity_Length Z, - const Quantity_Length aDistance, - const Adaptor3d_Curve& aCurve, - const Standard_Real U1, - const Standard_Real U2, - const Standard_Real aDeflection, - const Standard_Real anAngle) { - - + const Quantity_Length Y, + const Quantity_Length Z, + const Quantity_Length aDistance, + const Adaptor3d_Curve& aCurve, + const Standard_Real U1, + const Standard_Real U2, + const Standard_Real aDeflection, + const Standard_Real anAngle) +{ return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,anAngle,U1,U2); - } //================================================================== @@ -521,24 +489,12 @@ Standard_Boolean StdPrs_DeflectionCurve::Match const Adaptor3d_Curve& aCurve, const Standard_Real aDeflection, const Standard_Real aLimit, - const Standard_Real anAngle) { - + const Standard_Real anAngle) +{ Standard_Real V1, V2; - Standard_Boolean OK = FindLimits(aCurve, aLimit, V1, V2); - - if (OK) { - return MatchCurve(X,Y,Z,aDistance,aCurve, - aDeflection, - anAngle, - V1 , V2); - } - else { - return Standard_False; + if (FindLimits(aCurve, aLimit, V1, V2)) + { + return MatchCurve(X,Y,Z,aDistance,aCurve,aDeflection,anAngle,V1,V2); } - + return Standard_False; } - - - - - diff --git a/src/StdPrs/StdPrs_HLRPolyShape.cxx b/src/StdPrs/StdPrs_HLRPolyShape.cxx index 09ea9f2dfd..219effb62b 100755 --- a/src/StdPrs/StdPrs_HLRPolyShape.cxx +++ b/src/StdPrs/StdPrs_HLRPolyShape.cxx @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include #include #include @@ -60,8 +58,6 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, TopExp_Explorer ex; - Standard_Boolean isPrimArrayEnabled = Graphic3d_ArrayOfPrimitives::IsEnable(); - // find vertices not under ancestors. TopAbs_ShapeEnum E = aShape.ShapeType(); if (E == TopAbs_COMPOUND) { @@ -71,14 +67,11 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } } - Graphic3d_Array1OfVertex Vertex(1,2); TColgp_SequenceOfPnt HiddenPnts; TColgp_SequenceOfPnt SeenPnts; - Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE; - Standard_Real def; - if (rel) def = aDrawer->HLRDeviationCoefficient(); - else def = aDrawer->MaximalChordialDeviation(); + const Standard_Boolean rel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE; + Standard_Real def = rel? aDrawer->HLRDeviationCoefficient() : aDrawer->MaximalChordialDeviation(); BRepMesh_IncrementalMesh mesh(aShape, def, rel, aDrawer->HLRAngle()); Handle(HLRBRep_PolyAlgo) hider = new HLRBRep_PolyAlgo(aShape); @@ -86,10 +79,8 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, hider->Projector(aProjector->Projector()); hider->Angle(aDrawer->HLRAngle()); hider->Update(); - //Standard_Integer i; Standard_Real sta,end,dx,dy,dz; Standard_ShortReal tolsta, tolend; - //gp_Pnt PSta, PEnd; HLRAlgo_EdgeStatus status; HLRAlgo_EdgeIterator It; Standard_Boolean reg1,regn,outl, intl; @@ -98,105 +89,76 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, HLRBRep_ListOfBPoint BiPntVis, BiPntHid; - for (hider->InitHide(); hider->MoreHide(); hider->NextHide()) { + for (hider->InitHide(); hider->MoreHide(); hider->NextHide()) + { hider->Hide(Coordinates, status, S, reg1, regn, outl, intl); dx = PntX2 - PntX1; dy = PntY2 - PntY1; dz = PntZ2 - PntZ1; - for (It.InitVisible(status); It.MoreVisible(); It.NextVisible()) { + for (It.InitVisible(status); It.MoreVisible(); It.NextVisible()) + { It.Visible(sta,tolsta,end,tolend); BiPntVis.Append - (HLRBRep_BiPoint - (PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz, - PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz, - S,reg1,regn,outl,intl)); + (HLRBRep_BiPoint + (PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz, + PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz, + S,reg1,regn,outl,intl)); } - for (It.InitHidden(status); It.MoreHidden(); It.NextHidden()) { + for (It.InitHidden(status); It.MoreHidden(); It.NextHidden()) + { It.Hidden(sta,tolsta,end,tolend); BiPntHid.Append - (HLRBRep_BiPoint - (PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz, - PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz, - S,reg1,regn,outl,intl)); + (HLRBRep_BiPoint + (PntX1 + sta * dx,PntY1 + sta * dy,PntZ1 + sta * dz, + PntX1 + end * dx,PntY1 + end * dy,PntZ1 + end * dz, + S,reg1,regn,outl,intl)); } } - // storage in the group: - HLRBRep_ListIteratorOfListOfBPoint ItB; if (aDrawer->DrawHiddenLine()) { - if(!isPrimArrayEnabled) { - aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); - } for (ItB.Initialize(BiPntHid); ItB.More(); ItB.Next()) { const HLRBRep_BiPoint& BP = ItB.Value(); if (!BP.RgNLine() || BP.OutLine()) { - const gp_Pnt& P1 = BP.P1(); - const gp_Pnt& P2 = BP.P2(); - HiddenPnts.Append(P1); - HiddenPnts.Append(P2); - Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z()); - Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(Vertex); + HiddenPnts.Append(BP.P1()); + HiddenPnts.Append(BP.P2()); } } - if(!isPrimArrayEnabled) - aGroup->EndPrimitives(); } - if(!isPrimArrayEnabled) { - aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); - } for (ItB.Initialize(BiPntVis); ItB.More(); ItB.Next()) { const HLRBRep_BiPoint& BP = ItB.Value(); if (!BP.RgNLine() || BP.OutLine()) { - const gp_Pnt& P1 = BP.P1(); - const gp_Pnt& P2 = BP.P2(); - SeenPnts.Append(P1); - SeenPnts.Append(P2); - Vertex(1).SetCoord(P1.X(), P1.Y(), P1.Z()); - Vertex(2).SetCoord(P2.X(), P2.Y(), P2.Z()); - if(!isPrimArrayEnabled) - aGroup->Polyline(Vertex); + SeenPnts.Append(BP.P1()); + SeenPnts.Append(BP.P2()); } } - if(!isPrimArrayEnabled) - aGroup->EndPrimitives(); - if(isPrimArrayEnabled) { - Standard_Integer nbVertices = HiddenPnts.Length(); - if(nbVertices > 0) { - Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); - for(int i=1; i<=nbVertices; i+=2) { - HiddenArray->AddBound(2); - HiddenArray->AddVertex(HiddenPnts.Value(i)); - HiddenArray->AddVertex(HiddenPnts.Value(i+1)); - } - aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); - aGroup->AddPrimitiveArray(HiddenArray); - aGroup->EndPrimitives(); + + Standard_Integer nbVertices = HiddenPnts.Length(); + if(nbVertices > 0) { + Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); + for(int i=1; i<=nbVertices; i+=2) { + HiddenArray->AddBound(2); + HiddenArray->AddVertex(HiddenPnts.Value(i)); + HiddenArray->AddVertex(HiddenPnts.Value(i+1)); } - nbVertices = SeenPnts.Length(); - if(nbVertices > 0) { - Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); - for(int i=1; i<=nbVertices; i+=2) { - SeenArray->AddBound(2); - SeenArray->AddVertex(SeenPnts.Value(i)); - SeenArray->AddVertex(SeenPnts.Value(i+1)); - } - aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect()); - aGroup->BeginPrimitives(); - aGroup->AddPrimitiveArray(SeenArray); - aGroup->EndPrimitives(); + aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); + aGroup->AddPrimitiveArray(HiddenArray); + } + nbVertices = SeenPnts.Length(); + if(nbVertices > 0) { + Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); + for(int i=1; i<=nbVertices; i+=2) { + SeenArray->AddBound(2); + SeenArray->AddVertex(SeenPnts.Value(i)); + SeenArray->AddVertex(SeenPnts.Value(i+1)); } + aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect()); + aGroup->AddPrimitiveArray(SeenArray); } } - diff --git a/src/StdPrs/StdPrs_Plane.cxx b/src/StdPrs/StdPrs_Plane.cxx index d970477a7c..aaef03f311 100755 --- a/src/StdPrs/StdPrs_Plane.cxx +++ b/src/StdPrs/StdPrs_Plane.cxx @@ -18,10 +18,9 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include -#include +#include +#include #include #include #include @@ -37,8 +36,8 @@ void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation, - const Adaptor3d_Surface& aPlane, - const Handle (Prs3d_Drawer)& aDrawer) + const Adaptor3d_Surface& aPlane, + const Handle (Prs3d_Drawer)& aDrawer) { // Prs3d_Root::NewGroup(aPresentation); Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); @@ -49,45 +48,38 @@ void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation, gp_Pnt p1; Standard_Real Xmax,Ymax; - Xmax = Standard_Real(theaspect->PlaneXLength())/2.; - Ymax = Standard_Real(theaspect->PlaneYLength())/2.; + Xmax = 0.5*Standard_Real(theaspect->PlaneXLength()); + Ymax = 0.5*Standard_Real(theaspect->PlaneYLength()); if (theaspect->DisplayEdges()) { - static Graphic3d_Array1OfVertex EdgesArray(1,5); TheGroup->SetPrimitivesAspect(theaspect->EdgesAspect()->Aspect()); - thegeom->D0(-Xmax,Ymax,p1); - EdgesArray(1).SetCoord(p1.X(),p1.Y(),p1.Z()); - EdgesArray(5).SetCoord(p1.X(),p1.Y(),p1.Z()); - thegeom->D0(Xmax,Ymax,p1); - EdgesArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - thegeom->D0(Xmax,-Ymax,p1); - EdgesArray(3).SetCoord(p1.X(),p1.Y(),p1.Z()); - thegeom->D0(-Xmax,-Ymax,p1); - EdgesArray(4).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(EdgesArray); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(5); + p1 = thegeom->Value(-Xmax,Ymax); + aPrims->AddVertex(p1); + aPrims->AddVertex(thegeom->Value( Xmax, Ymax)); + aPrims->AddVertex(thegeom->Value( Xmax,-Ymax)); + aPrims->AddVertex(thegeom->Value(-Xmax,-Ymax)); + aPrims->AddVertex(p1); + TheGroup->AddPrimitiveArray(aPrims); } if (theaspect->DisplayIso()) { - static Graphic3d_Array1OfVertex IsoArray(1,2); TheGroup->SetPrimitivesAspect(theaspect->IsoAspect()->Aspect()); - Standard_Real dist = theaspect->IsoDistance(); + const Standard_Real dist = theaspect->IsoDistance(); + const Standard_Integer nbx = Standard_Integer(Abs(2.*Xmax) / dist) - 1; + const Standard_Integer nby = Standard_Integer(Abs(2.*Ymax) / dist) - 1; + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2*(nbx+nby)); + Standard_Integer i; Standard_Real cur = -Xmax+dist; - while (cur+dist/2. <= Xmax) { - thegeom->D0(cur,Ymax,p1); - IsoArray(1).SetCoord(p1.X(),p1.Y(),p1.Z()); - thegeom->D0(cur,-Ymax,p1); - IsoArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(IsoArray); - cur += dist; + for (i = 0; i < nbx; i++, cur += dist) { + aPrims->AddVertex(thegeom->Value(cur, Ymax)); + aPrims->AddVertex(thegeom->Value(cur,-Ymax)); } cur = -Ymax+dist; - while (cur+dist/2. < Ymax) { - thegeom->D0(Xmax,cur,p1); - IsoArray(1).SetCoord(p1.X(),p1.Y(),p1.Z()); - thegeom->D0(-Xmax,cur,p1); - IsoArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(IsoArray); - cur += dist; + for (i = 0; i < nby; i++, cur += dist) { + aPrims->AddVertex(thegeom->Value( Xmax,cur)); + aPrims->AddVertex(thegeom->Value(-Xmax,cur)); } + TheGroup->AddPrimitiveArray(aPrims); } gp_Dir norm = thegeom->Pln().Axis().Direction(); @@ -97,63 +89,46 @@ void StdPrs_Plane::Add (const Handle (Prs3d_Presentation)& aPresentation, Quantity_PlaneAngle ang = theaspect->ArrowsAngle(); gp_Vec trans(norm); trans.Scale(Standard_Real(siz)); + TheGroup->SetPrimitivesAspect(theaspect->ArrowAspect()->Aspect()); - Graphic3d_Array1OfVertex ArrowArray(1,2); if (theaspect->DisplayCenterArrow()) { loc = thegeom->Location(); p1 = loc.Translated(trans); - ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z()); - ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(ArrowArray); - Prs3d_Arrow::Draw(aPresentation, - p1, - norm, - ang, - len); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(loc); + aPrims->AddVertex(p1); + TheGroup->AddPrimitiveArray(aPrims); + Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len); } if (theaspect->DisplayEdgesArrows()) { + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(8); + // thegeom->D0(-Xmax,-Ymax,loc); p1 = loc.Translated(trans); - ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z()); - ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(ArrowArray); - Prs3d_Arrow::Draw(aPresentation, - p1, - norm, - ang, - len); + aPrims->AddVertex(loc); + aPrims->AddVertex(p1); + Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len); + // thegeom->D0(-Xmax,Ymax,loc); p1 = loc.Translated(trans); - ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z()); - ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(ArrowArray); - Prs3d_Arrow::Draw(aPresentation, - p1, - norm, - ang, - len); + aPrims->AddVertex(loc); + aPrims->AddVertex(p1); + Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len); + // thegeom->D0(Xmax,Ymax,loc); p1 = loc.Translated(trans); - ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z()); - ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(ArrowArray); - Prs3d_Arrow::Draw(aPresentation, - p1, - norm, - ang, - len); + aPrims->AddVertex(loc); + aPrims->AddVertex(p1); + Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len); + // thegeom->D0(Xmax,-Ymax,loc); p1 = loc.Translated(trans); - ArrowArray(1).SetCoord(loc.X(),loc.Y(),loc.Z()); - ArrowArray(2).SetCoord(p1.X(),p1.Y(),p1.Z()); - TheGroup->Polyline(ArrowArray); - Prs3d_Arrow::Draw(aPresentation, - p1, - norm, - ang, - len); + aPrims->AddVertex(loc); + aPrims->AddVertex(p1); + Prs3d_Arrow::Draw(aPresentation,p1,norm,ang,len); + // + TheGroup->AddPrimitiveArray(aPrims); } - } Standard_Boolean StdPrs_Plane::Match diff --git a/src/StdPrs/StdPrs_PoleCurve.cxx b/src/StdPrs/StdPrs_PoleCurve.cxx index 0f4285d809..2280e9a0b6 100755 --- a/src/StdPrs/StdPrs_PoleCurve.cxx +++ b/src/StdPrs/StdPrs_PoleCurve.cxx @@ -18,10 +18,9 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include -#include + +#include #include #include #include @@ -47,27 +46,22 @@ void StdPrs_PoleCurve::Add (const Handle (Prs3d_Presentation)& aPresentation, GeomAbs_CurveType CType = aCurve.GetType(); if (CType == GeomAbs_BezierCurve || CType == GeomAbs_BSplineCurve) { - Standard_Real x,y,z; Standard_Integer i, Nb; if (CType == GeomAbs_BezierCurve) { Handle(Geom_BezierCurve) Bz = aCurve.Bezier(); Nb = Bz->NbPoles(); - Graphic3d_Array1OfVertex VertexArray(1, Nb); - for (i = 1; i <= Nb; i++) { - (Bz->Pole(i)).Coord(x,y,z); - VertexArray(i).SetCoord(x,y,z); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb); + for (i = 1; i <= Nb; i++) + aPrims->AddVertex(Bz->Pole(i)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } else if (CType == GeomAbs_BSplineCurve) { Handle(Geom_BSplineCurve) Bs = aCurve.BSpline(); Nb = Bs->NbPoles(); - Graphic3d_Array1OfVertex VertexArray(1, Nb); - for (i = 1; i <= Nb; i++) { - (Bs->Pole(i)).Coord(x,y,z); - VertexArray(i).SetCoord(x,y,z); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(Nb); + for (i = 1; i <= Nb; i++) + aPrims->AddVertex(Bs->Pole(i)); + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } } diff --git a/src/StdPrs/StdPrs_ShadedShape.cxx b/src/StdPrs/StdPrs_ShadedShape.cxx index 2dd01514c4..060e6df511 100644 --- a/src/StdPrs/StdPrs_ShadedShape.cxx +++ b/src/StdPrs/StdPrs_ShadedShape.cxx @@ -206,9 +206,7 @@ namespace } } } - Prs3d_Root::CurrentGroup (thePresentation)->BeginPrimitives(); Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPArray); - Prs3d_Root::CurrentGroup (thePresentation)->EndPrimitives(); } return Standard_True; } @@ -332,9 +330,7 @@ namespace Handle(Graphic3d_Group) aPrsGrp = Prs3d_Root::NewGroup (thePresentation); aPrsGrp->SetGroupPrimitivesAspect (aBoundaryAspect); - aPrsGrp->BeginPrimitives (); aPrsGrp->AddPrimitiveArray (aSegments); - aPrsGrp->EndPrimitives (); } }; diff --git a/src/StdPrs/StdPrs_ShadedSurface.cxx b/src/StdPrs/StdPrs_ShadedSurface.cxx index 86f1347e34..fb3ede76f1 100755 --- a/src/StdPrs/StdPrs_ShadedSurface.cxx +++ b/src/StdPrs/StdPrs_ShadedSurface.cxx @@ -76,7 +76,6 @@ void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs, gp_Pnt P1, P2; gp_Vec D1U, D1V, D1, D2; - Prs3d_Root::CurrentGroup (thePrs)->BeginPrimitives(); for (Standard_Integer NU = 1; NU <= aNBUintv; ++NU) { for (Standard_Integer NV = 1; NV <= aNBVintv; ++NV) @@ -113,6 +112,5 @@ void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs, } Prs3d_Root::CurrentGroup (thePrs)->AddPrimitiveArray (aPArray); } - Prs3d_Root::CurrentGroup (thePrs)->EndPrimitives(); } } diff --git a/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx b/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx index 2a473f7a5f..b925fcd67c 100755 --- a/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx +++ b/src/StdPrs/StdPrs_WFDeflectionRestrictedFace.cxx @@ -23,8 +23,6 @@ #include #include -#include -#include #include #include #include @@ -118,8 +116,6 @@ void StdPrs_WFDeflectionRestrictedFace::Add FFaceTimer1.Start(); #endif - Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable(); - StdPrs_ToolRFace ToolRst (aFace); Standard_Real UF, UL, VF, VL; UF = aFace->FirstUParameter(); @@ -326,7 +322,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add FindLimits(GC, aLimit,b1, b2); if (b2-b1>Precision::Confusion()) { TColgp_SequenceOfPnt Points; - StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, !isPA); + StdPrs_DeflectionCurve::Add(aPresentation, GC, b1, b2, Deflection, Points, anAngle, Standard_False); Curves.Append(Points); } } @@ -338,7 +334,7 @@ void StdPrs_WFDeflectionRestrictedFace::Add FindLimits(anIso, aLimit,b1, b2); if (b2-b1>Precision::Confusion()) { TColgp_SequenceOfPnt Points; - StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, !isPA); + StdPrs_DeflectionCurve::Add(aPresentation, anIso, b1, b2, Deflection, Points, anAngle, Standard_False); Curves.Append(Points); } } @@ -493,27 +489,18 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match void StdPrs_WFDeflectionRestrictedFace::Add (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); - - Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); - TheGroup->BeginPrimitives(); - + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; StdPrs_WFDeflectionRestrictedFace::Add (aPresentation, aFace, Standard_True, Standard_True, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); - - TheGroup->EndPrimitives(); } @@ -524,20 +511,17 @@ void StdPrs_WFDeflectionRestrictedFace::Add void StdPrs_WFDeflectionRestrictedFace::AddUIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; StdPrs_WFDeflectionRestrictedFace::Add ( aPresentation, aFace, Standard_True, Standard_False, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); } @@ -550,20 +534,17 @@ void StdPrs_WFDeflectionRestrictedFace::AddUIso void StdPrs_WFDeflectionRestrictedFace::AddVIso (const Handle (Prs3d_Presentation)& aPresentation, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ Prs3d_NListOfSequenceOfPnt Curves; StdPrs_WFDeflectionRestrictedFace::Add ( aPresentation, aFace, Standard_False, Standard_True, - Deflection, - finu, - finv, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number(), aDrawer, Curves); } @@ -579,20 +560,17 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer){ - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return StdPrs_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_True, - Standard_True, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_True, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number()); } @@ -606,20 +584,17 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchUIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return StdPrs_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_True, - Standard_False, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_True, + Standard_False, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number()); } @@ -633,20 +608,15 @@ Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchVIso const Quantity_Length Z, const Quantity_Length aDistance, const Handle(BRepAdaptor_HSurface)& aFace, - const Handle (Prs3d_Drawer)& aDrawer) { - - Quantity_Length Deflection = aDrawer->MaximalChordialDeviation(); - Standard_Integer finu = aDrawer->UIsoAspect()->Number(); - Standard_Integer finv = aDrawer->VIsoAspect()->Number(); + const Handle (Prs3d_Drawer)& aDrawer) +{ return StdPrs_WFDeflectionRestrictedFace::Match ( X,Y,Z,aDistance, - aFace, - aDrawer, - Standard_False, - Standard_True, - Deflection, - finu, - finv); + aFace, + aDrawer, + Standard_False, + Standard_True, + aDrawer->MaximalChordialDeviation(), + aDrawer->UIsoAspect()->Number(), + aDrawer->VIsoAspect()->Number()); } - - diff --git a/src/StdPrs/StdPrs_WFPoleSurface.cxx b/src/StdPrs/StdPrs_WFPoleSurface.cxx index 5c03c1d88e..5a4f87f5c5 100755 --- a/src/StdPrs/StdPrs_WFPoleSurface.cxx +++ b/src/StdPrs/StdPrs_WFPoleSurface.cxx @@ -18,48 +18,41 @@ // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. - - #include + #include #include #include -#include +#include #include #include static void AddPoles(const Handle (Prs3d_Presentation)& aPresentation, - const TColgp_Array2OfPnt& A, - const Handle (Prs3d_Drawer)& aDrawer) + const TColgp_Array2OfPnt& A, + const Handle (Prs3d_Drawer)& aDrawer) { Standard_Integer i,j; - Standard_Real x,y,z; - Standard_Integer n = A.ColLength(); - Standard_Integer m = A.RowLength(); - + const Standard_Integer n = A.ColLength(); + const Standard_Integer m = A.RowLength(); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - - Graphic3d_Array1OfVertex VertexArray1(1,m); - + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(n*m,n); for (i=1; i<=n; i++){ - for (j=1; j<=m; j++) { - A(i,j).Coord(x,y,z); - VertexArray1(j).SetCoord(x,y,z); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray1); + aPrims->AddBound(m); + for (j=1; j<=m; j++) + aPrims->AddVertex(A(i,j)); } - + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); + Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); - - Graphic3d_Array1OfVertex VertexArray2(1,n); + aPrims = new Graphic3d_ArrayOfPolylines(n*m,m); for (j=1; j<=m; j++){ - for (i=1; i<=n; i++) { - A(i,j).Coord(x,y,z); - VertexArray2(i).SetCoord(x,y,z); - } - Prs3d_Root::CurrentGroup(aPresentation)->Polyline(VertexArray2); + aPrims->AddBound(n); + for (i=1; i<=n; i++) + aPrims->AddVertex(A(i,j)); } + Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); } diff --git a/src/StdPrs/StdPrs_WFSurface.cxx b/src/StdPrs/StdPrs_WFSurface.cxx index e9f650e161..f97d8d41a1 100755 --- a/src/StdPrs/StdPrs_WFSurface.cxx +++ b/src/StdPrs/StdPrs_WFSurface.cxx @@ -144,8 +144,6 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, Standard_Real U1, U2, V1, V2; Standard_Real MaxP = aDrawer->MaximalParameterValue(); - Standard_Boolean isPA = Graphic3d_ArrayOfPrimitives::IsEnable(); - FindLimits(aSurface, MaxP, U1, U2, V1, V2); Prs3d_NListOfSequenceOfPnt freeCurves; @@ -191,22 +189,22 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, if ( !UClosed ) { anIso.Load(GeomAbs_IsoU,U1,V1,V2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); freeCurves.Append(Pnts); Pnts.Clear(); anIso.Load(GeomAbs_IsoU,U2,V1,V2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); freeCurves.Append(Pnts); Pnts.Clear(); } if ( !VClosed ) { anIso.Load(GeomAbs_IsoV,V1,U1,U2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); freeCurves.Append(Pnts); Pnts.Clear(); anIso.Load(GeomAbs_IsoV,V2,U1,U2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); freeCurves.Append(Pnts); Pnts.Clear(); } @@ -224,7 +222,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, Standard_Real du= UClosed ? (U2-U1)/fin : (U2-U1)/(1+fin); for (Standard_Integer i=1; i<=fin;i++){ anIso.Load(GeomAbs_IsoU,U1+du*i,V1,V2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); UIsoCurves.Append(Pnts); Pnts.Clear(); } @@ -238,14 +236,12 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, Standard_Real dv= VClosed ?(V2-V1)/fin : (V2-V1)/(1+fin); for (Standard_Integer i=1; i<=fin;i++){ anIso.Load(GeomAbs_IsoV,V1+dv*i,U1,U2); - StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, !isPA); + StdPrs_Curve::Add(aPresentation,anIso,TheDeflection, aDrawer, Pnts, Standard_False); VIsoCurves.Append(Pnts); Pnts.Clear(); } } - if(!Graphic3d_ArrayOfPrimitives::IsEnable()) - return; Standard_Integer nbVertices = 0, nbBounds = 0; //Draw surface via primitive array if(UIsoCurves.Size() > 0) { @@ -264,9 +260,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, } Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); TheGroup->AddPrimitiveArray(UIsoArray); - TheGroup->EndPrimitives(); } if(VIsoCurves.Size() > 0) { @@ -285,9 +279,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, } Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); - TheGroup->BeginPrimitives(); TheGroup->AddPrimitiveArray(VIsoArray); - TheGroup->EndPrimitives(); } if(freeCurves.Size() > 0) { nbBounds = freeCurves.Size(); @@ -305,9 +297,7 @@ void StdPrs_WFSurface::Add (const Handle(Prs3d_Presentation)& aPresentation, } Handle(Graphic3d_Group) TheGroup = Prs3d_Root::NewGroup(aPresentation); TheGroup->SetPrimitivesAspect(aDrawer->FreeBoundaryAspect()->Aspect()); - TheGroup->BeginPrimitives(); TheGroup->AddPrimitiveArray(freeArray); - TheGroup->EndPrimitives(); } } diff --git a/src/StdSelect/StdSelect.cxx b/src/StdSelect/StdSelect.cxx index 75bc8d29e9..81f49c82f8 100755 --- a/src/StdSelect/StdSelect.cxx +++ b/src/StdSelect/StdSelect.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 257110da56..8088c8974b 100755 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -64,6 +64,8 @@ #include #include #include +#include + static Standard_Integer StdSel_NumberOfFreeEdges (const Handle(Poly_Triangulation)& Trg) { @@ -286,9 +288,7 @@ void StdSelect_ViewerSelector3d // Purpose : Selection using a polyline //================================================== -void StdSelect_ViewerSelector3d -::Pick(const TColgp_Array1OfPnt2d& aPolyline, - const Handle(V3d_View)& aView) +void StdSelect_ViewerSelector3d::Pick(const TColgp_Array1OfPnt2d& aPolyline, const Handle(V3d_View)& aView) { if (myupdatetol && SensitivityMode() == StdSelect_SM_WINDOW) { @@ -302,8 +302,7 @@ void StdSelect_ViewerSelector3d Standard_Integer i; // Convert pixel - Handle(TColgp_HArray1OfPnt2d) P2d = - new TColgp_HArray1OfPnt2d(1,NbPix); + Handle(TColgp_HArray1OfPnt2d) P2d = new TColgp_HArray1OfPnt2d(1,NbPix); for (i = 1; i <= NbPix; ++i) { @@ -328,38 +327,31 @@ void StdSelect_ViewerSelector3d // Purpose : display the activated areas... //================================================== -void StdSelect_ViewerSelector3d:: -DisplayAreas(const Handle(V3d_View)& aView) +void StdSelect_ViewerSelector3d::DisplayAreas(const Handle(V3d_View)& aView) { if (myupdatetol && SensitivityMode() == StdSelect_SM_WINDOW) { SetSensitivity (aView->Convert (mypixtol)); - myupdatetol = Standard_False; + myupdatetol = Standard_False; } UpdateProj(aView); UpdateSort(); // Updates the activated areas if(mystruct.IsNull()) - { mystruct = new Graphic3d_Structure(aView->Viewer()->Viewer()); - } + if(myareagroup.IsNull()) - { myareagroup = new Graphic3d_Group(mystruct); - } SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities); Handle(Select3D_Projector) prj = StdSelect::GetProjector(aView); prj->SetView(aView); - - Graphic3d_Array1OfVertex Av1 (1,5); - Standard_Real xmin,ymin,xmax,ymax; gp_Pnt Pbid; SelectBasics_ListOfBox2d BoxList; - myareagroup->BeginPrimitives(); + TColgp_SequenceOfPnt aSeqLines; for (; It.More(); It.Next()) { It.Value()->Areas(BoxList); @@ -369,31 +361,40 @@ DisplayAreas(const Handle(V3d_View)& aView) Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0); prj->Transform (Pbid, prj->InvertedTransformation()); - Av1.SetValue (1, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmax + mytolerance, ymin - mytolerance, 0.0); prj->Transform (Pbid, prj->InvertedTransformation()); - Av1.SetValue (2, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmax + mytolerance, ymax + mytolerance, 0.0); prj->Transform (Pbid, prj->InvertedTransformation()); - Av1.SetValue (3, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmin - mytolerance, ymax + mytolerance, 0.0); prj->Transform (Pbid, prj->InvertedTransformation()); - Av1.SetValue (4,Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); - - Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0); - prj->Transform (Pbid, prj->InvertedTransformation()); - Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); + } + } - myareagroup->Polyline (Av1); + if (aSeqLines.Length()) + { + Standard_Integer n, np; + const Standard_Integer nbl = aSeqLines.Length() / 4; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(5*nbl,nbl); + for (np = 1, n=0; nAddBound(5); + const gp_Pnt &p1 = aSeqLines(np++); + aPrims->AddVertex(p1); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(p1); } + myareagroup->AddPrimitiveArray(aPrims); } - myareagroup->EndPrimitives(); - myareagroup->SetGroupPrimitivesAspect (new - Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); + myareagroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); myareagroup->Structure()->SetDisplayPriority(10); myareagroup->Structure()->Display(); @@ -413,8 +414,7 @@ DisplayAreas(const Handle(V3d_View)& aView) // Purpose : //================================================== -void StdSelect_ViewerSelector3d:: -ClearAreas(const Handle(V3d_View)& aView) +void StdSelect_ViewerSelector3d::ClearAreas(const Handle(V3d_View)& aView) { if(myareagroup.IsNull()) return; myareagroup->Clear(); @@ -437,8 +437,7 @@ ClearAreas(const Handle(V3d_View)& aView) // 10 1. if pers 0. else //================================================== -Standard_Boolean StdSelect_ViewerSelector3d:: -UpdateProj(const Handle(V3d_View)& aView) +Standard_Boolean StdSelect_ViewerSelector3d::UpdateProj(const Handle(V3d_View)& aView) { myprevcoeff[ 9] = 0.0; myprevcoeff[10] = 0.0; @@ -558,9 +557,7 @@ void StdSelect_ViewerSelector3d::DisplaySensitive(const Handle(V3d_View)& aViou) // Remplissage de la structure... SelectMgr_DataMapIteratorOfDataMapOfSelectionActivation It(myselections); - // Standard_Integer isel (0); - mysensgroup->BeginPrimitives(); for (; It.More(); It.Next()) { if (It.Value()==0) @@ -569,7 +566,6 @@ void StdSelect_ViewerSelector3d::DisplaySensitive(const Handle(V3d_View)& aViou) ComputeSensitivePrs(Sel); } } - mysensgroup->EndPrimitives(); mysensgroup->Structure()->SetDisplayPriority(10); mystruct->Display(); @@ -624,11 +620,8 @@ DisplaySensitive (const Handle(SelectMgr_Selection)& Sel, if(ClearOthers) mysensgroup->Clear(); - mysensgroup->BeginPrimitives(); - ComputeSensitivePrs(Sel); - mysensgroup->EndPrimitives(); mystruct->SetDisplayPriority(10); mystruct->Display(); if(aViou->TransientManagerBeginDraw()) @@ -654,18 +647,16 @@ DisplayAreas (const Handle(SelectMgr_Selection)& Sel, { if (mystruct.IsNull()) mystruct = new Graphic3d_Structure (aViou->Viewer()->Viewer()); + if (mysensgroup.IsNull()) { myareagroup = new Graphic3d_Group (mystruct); - myareagroup->SetGroupPrimitivesAspect ( - new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); + myareagroup->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); } if(ClearOthers) myareagroup->Clear(); - myareagroup->BeginPrimitives(); ComputeAreasPrs(Sel); - myareagroup->EndPrimitives(); mystruct->SetDisplayPriority(10); mystruct->Display(); @@ -686,15 +677,15 @@ DisplayAreas (const Handle(SelectMgr_Selection)& Sel, //purpose : //======================================================================= -void StdSelect_ViewerSelector3d:: -ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) +void StdSelect_ViewerSelector3d::ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) { + TColgp_SequenceOfPnt aSeqLines, aSeqFree; + TColStd_SequenceOfInteger aSeqBnds; + for(Sel->Init();Sel->More();Sel->Next()) { - Handle(Select3D_SensitiveEntity) Ent = - Handle(Select3D_SensitiveEntity)::DownCast(Sel->Sensitive()); - Standard_Boolean hasloc = (Ent.IsNull()) ? Standard_False: - (Ent->HasLocation()? Standard_True:Standard_False); + Handle(Select3D_SensitiveEntity) Ent = Handle(Select3D_SensitiveEntity)::DownCast(Sel->Sensitive()); + const Standard_Boolean hasloc = (Ent.IsNull()? Standard_False : Ent->HasLocation()); TopLoc_Location theloc; if(hasloc) @@ -709,6 +700,7 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) const Bnd_Box& B = Handle(Select3D_SensitiveBox)::DownCast (Ent)->Box(); Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; B.Get (xmin, ymin, zmin, xmax, ymax, zmax); + Standard_Integer i; gp_Pnt theboxpoint[8] = { gp_Pnt(xmin,ymin,zmin), @@ -722,38 +714,25 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) }; if(hasloc) { - for (Standard_Integer ii = 0; ii <= 7; ii++) - theboxpoint[ii].Transform (theloc.Transformation()); + for (i = 0; i <= 7; i++) + theboxpoint[i].Transform (theloc.Transformation()); } - Graphic3d_Array1OfVertex Vtx (1, 5); - Standard_Integer ip; - for (ip = 0; ip < 4; ip++) - { - Vtx.SetValue (ip + 1, Graphic3d_Vertex (theboxpoint[ip].X(), - theboxpoint[ip].Y(), - theboxpoint[ip].Z())); - } - mysensgroup->Polyline (Vtx); - for (ip = 0; ip < 4; ip++) - { - Vtx.SetValue (ip + 1, Graphic3d_Vertex (theboxpoint[ip + 4].X(), - theboxpoint[ip + 4].Y(), - theboxpoint[ip + 4].Z())); - } - mysensgroup->Polyline (Vtx); + aSeqBnds.Append(5); + for (i = 0; i < 4; i++) + aSeqLines.Append(theboxpoint[i]); + aSeqLines.Append(theboxpoint[0]); + + aSeqBnds.Append(5); + for (i = 4; i < 8; i++) + aSeqLines.Append(theboxpoint[i]); + aSeqLines.Append(theboxpoint[4]); - Graphic3d_Array1OfVertex Vtx2 (1, 2); - for (ip = 0; ip < 4; ip++) + for (i = 0; i < 4; i++) { - Vtx2.SetValue (1, Graphic3d_Vertex (theboxpoint[ip].X(), - theboxpoint[ip].Y(), - theboxpoint[ip].Z())); - - Vtx2.SetValue (2, Graphic3d_Vertex (theboxpoint[ip + 4].X(), - theboxpoint[ip + 4].Y(), - theboxpoint[ip + 4].Z())); - mysensgroup->Polyline (Vtx2); + aSeqBnds.Append(2); + aSeqLines.Append(theboxpoint[i]); + aSeqLines.Append(theboxpoint[i+4]); } } //============== @@ -766,22 +745,14 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) aFace->Points3D(TheHPts); const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - Graphic3d_Array1OfVertex Vtx (ThePts.Lower(), ThePts.Upper()); - + aSeqBnds.Append(ThePts.Length()); for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) { if (hasloc) - { - const gp_Pnt& curP = ThePts (I); - gp_Pnt ptrans = curP.Transformed (theloc.Transformation()).XYZ(); - Vtx.SetValue (I, Graphic3d_Vertex (ptrans.X(), ptrans.Y(), ptrans.Z())); - } + aSeqLines.Append(ThePts(I).Transformed (theloc.Transformation())); else - { - Vtx.SetValue (I, Graphic3d_Vertex (ThePts (I).X(), ThePts (I).Y(), ThePts (I).Z())); - } + aSeqLines.Append(ThePts(I)); } - mysensgroup->Polyline (Vtx); } //============== // Curve @@ -793,29 +764,23 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) aCurve->Points3D(TheHPts); const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - Graphic3d_Array1OfVertex Vtx (ThePts.Lower(), ThePts.Upper()); + aSeqBnds.Append(ThePts.Length()); for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) { if (hasloc) - { - gp_Pnt ptrans (ThePts (I).Transformed (theloc.Transformation()).XYZ()); - Vtx.SetValue (I, Graphic3d_Vertex (ptrans.X(), ptrans.Y(), ptrans.Z())); - } + aSeqLines.Append(ThePts(I).Transformed (theloc.Transformation())); else - { - Vtx.SetValue (I, Graphic3d_Vertex (ThePts (I).X(), ThePts (I).Y(), ThePts (I).Z())); - } + aSeqLines.Append(ThePts(I)); } - mysensgroup->Polyline (Vtx); } //============== // Wire //============= else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveWire)) { - Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast(Ent); - Select3D_SensitiveEntitySequence EntitySeq; - aWire->GetEdges (EntitySeq); + Handle(Select3D_SensitiveWire) aWire = Handle(Select3D_SensitiveWire)::DownCast(Ent); + Select3D_SensitiveEntitySequence EntitySeq; + aWire->GetEdges (EntitySeq); for (int i = 1; i <= EntitySeq.Length(); i++) { @@ -824,7 +789,6 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) //Segment if (SubEnt->DynamicType()==STANDARD_TYPE(Select3D_SensitiveSegment)) { - Graphic3d_Array1OfVertex Vtx (1, 2); gp_Pnt P1 (Handle(Select3D_SensitiveSegment)::DownCast(SubEnt)->StartPoint().XYZ()); gp_Pnt P2 (Handle(Select3D_SensitiveSegment)::DownCast(SubEnt)->EndPoint().XYZ()); if (hasloc) @@ -832,9 +796,9 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) P1.Transform(theloc.Transformation()); P2.Transform(theloc.Transformation()); } - Vtx.SetValue (1, Graphic3d_Vertex (P1.X(), P1.Y(), P1.Z())); - Vtx.SetValue (2, Graphic3d_Vertex (P2.X(), P2.Y(), P2.Z())); - mysensgroup->Polyline (Vtx); + aSeqBnds.Append(2); + aSeqLines.Append(P1); + aSeqLines.Append(P2); } //circle @@ -846,7 +810,6 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) Standard_Integer II = Lo; while (II <= Up - 2) { - Graphic3d_Array1OfVertex Vtx (1, 4); gp_Pnt ThePts[3] = { gp_Pnt (C->GetPoint3d (II).XYZ()), @@ -860,12 +823,11 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) ThePts[jj].Transform (theloc.Transformation()); } - Vtx.SetValue (1, Graphic3d_Vertex (ThePts[0].X(), ThePts[0].Y(), ThePts[0].Z())); - Vtx.SetValue (2, Graphic3d_Vertex (ThePts[1].X(), ThePts[1].Y(), ThePts[1].Z())); - Vtx.SetValue (3, Graphic3d_Vertex (ThePts[2].X(), ThePts[2].Y(), ThePts[2].Z())); - Vtx.SetValue (4, Graphic3d_Vertex (ThePts[0].X(), ThePts[0].Y(), ThePts[0].Z())); - - mysensgroup->Polyline (Vtx); + aSeqBnds.Append(4); + aSeqLines.Append(ThePts[0]); + aSeqLines.Append(ThePts[1]); + aSeqLines.Append(ThePts[2]); + aSeqLines.Append(ThePts[0]); } } @@ -876,20 +838,15 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) Handle(TColgp_HArray1OfPnt) TheHPts; aCurve->Points3D (TheHPts); const TColgp_Array1OfPnt& ThePts = TheHPts->Array1(); - Graphic3d_Array1OfVertex Vtx (ThePts.Lower(), ThePts.Upper()); + + aSeqBnds.Append(ThePts.Length()); for (Standard_Integer I = ThePts.Lower(); I <= ThePts.Upper(); I++) { if (hasloc) - { - gp_Pnt ptrans (ThePts (I).Transformed (theloc.Transformation()).XYZ()); - Vtx.SetValue (I, Graphic3d_Vertex (ptrans.X(), ptrans.Y(), ptrans.Z())); - } + aSeqLines.Append(ThePts(I).Transformed (theloc.Transformation())); else - { - Vtx.SetValue (I, Graphic3d_Vertex (ThePts (I).X(), ThePts (I).Y(), ThePts (I).Z())); - } + aSeqLines.Append(ThePts(I)); } - mysensgroup->Polyline (Vtx); } } } @@ -898,7 +855,6 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) //============= else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveSegment)) { - Graphic3d_Array1OfVertex Vtx (1,2); gp_Pnt P1 (Handle(Select3D_SensitiveSegment)::DownCast(Ent)->StartPoint().XYZ()); gp_Pnt P2 (Handle(Select3D_SensitiveSegment)::DownCast(Ent)->EndPoint().XYZ()); if (hasloc) @@ -906,9 +862,9 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) P1.Transform (theloc.Transformation()); P2.Transform (theloc.Transformation()); } - Vtx.SetValue (1, Graphic3d_Vertex (P1.X(), P1.Y(), P1.Z())); - Vtx.SetValue (2, Graphic3d_Vertex (P2.X(), P2.Y(), P2.Z())); - mysensgroup->Polyline (Vtx); + aSeqBnds.Append(2); + aSeqLines.Append(P1); + aSeqLines.Append(P2); } //============== // Circle @@ -921,7 +877,6 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) Standard_Integer II = Lo; while (II <= Up - 2) { - Graphic3d_Array1OfVertex Vtx (1,4); gp_Pnt ThePts[3] = { gp_Pnt (C->GetPoint3d (II).XYZ()), @@ -935,12 +890,11 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) ThePts[jj].Transform (theloc.Transformation()); } - Vtx.SetValue (1, Graphic3d_Vertex (ThePts[0].X(), ThePts[0].Y(), ThePts[0].Z())); - Vtx.SetValue (2, Graphic3d_Vertex (ThePts[1].X(), ThePts[1].Y(), ThePts[1].Z())); - Vtx.SetValue (3, Graphic3d_Vertex (ThePts[2].X(), ThePts[2].Y(), ThePts[2].Z())); - Vtx.SetValue (4, Graphic3d_Vertex (ThePts[0].X(), ThePts[0].Y(), ThePts[0].Z())); - - mysensgroup->Polyline (Vtx); + aSeqBnds.Append(4); + aSeqLines.Append(ThePts[0]); + aSeqLines.Append(ThePts[1]); + aSeqLines.Append(ThePts[2]); + aSeqLines.Append(ThePts[0]); } } //============== @@ -964,9 +918,7 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) const Poly_Array1OfTriangle& triangles = PT->Triangles(); const TColgp_Array1OfPnt& Nodes = PT->Nodes(); - // gp_Pnt P1, P2, P3; Standard_Integer n[3]; - Graphic3d_Array1OfVertex AV (1, 4); TopLoc_Location iloc, bidloc; if ((*((Handle(Select3D_SensitiveTriangulation)*) &Ent))->HasInitLocation()) @@ -988,16 +940,15 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) gp_XYZ V2 (P2.XYZ()); gp_XYZ V3 (P3.XYZ()); gp_XYZ CDG (P1.XYZ()); CDG += (P2.XYZ()); CDG += (P3.XYZ()); CDG /= 3.0; - V1 -= CDG; V2 -= CDG; V3 -= CDG; - V1 *= 0.9; V2 *= 0.9; V3 *= 0.9; V1 += CDG; V2 += CDG; V3 += CDG; - AV.SetValue (1, Graphic3d_Vertex (V1.X(), V1.Y(), V1.Z())); - AV.SetValue (2, Graphic3d_Vertex (V2.X(), V2.Y(), V2.Z())); - AV.SetValue (3, Graphic3d_Vertex (V3.X(), V3.Y(), V3.Z())); - AV.SetValue (4, Graphic3d_Vertex (V1.X(), V1.Y(), V1.Z())); - mysensgroup->Polyline (AV); + + aSeqBnds.Append(4); + aSeqLines.Append(gp_Pnt(V1)); + aSeqLines.Append(gp_Pnt(V2)); + aSeqLines.Append(gp_Pnt(V3)); + aSeqLines.Append(gp_Pnt(V1)); } // recherche des bords libres... @@ -1023,44 +974,59 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) } } } - Standard_Integer Node1, Node2; - mysensgroup->SetPrimitivesAspect ( - new Graphic3d_AspectLine3d (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0)); for (Standard_Integer ifri = 1; ifri <= FreeE.Length(); ifri += 2) { - Node1 = FreeE (ifri); - Node2 = FreeE (ifri + 1); - Graphic3d_Array1OfVertex FE (1, 2); - gp_Pnt pe1 (Nodes (Node1).Transformed (iloc)), pe2 (Nodes (Node2).Transformed (iloc)); - FE.SetValue (1,Graphic3d_Vertex (pe1.X(), pe1.Y(), pe1.Z())); - FE.SetValue (2,Graphic3d_Vertex (pe2.X(), pe2.Y(), pe2.Z())); - mysensgroup->Polyline (FE); + gp_Pnt pe1 (Nodes (FreeE (ifri)).Transformed (iloc)), pe2 (Nodes (FreeE (ifri + 1)).Transformed (iloc)); + aSeqFree.Append(pe1); + aSeqFree.Append(pe2); } - - mysensgroup->SetPrimitivesAspect ( - new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); } else if (Ent->DynamicType()==STANDARD_TYPE(Select3D_SensitiveTriangle)) { Handle(Select3D_SensitiveTriangle) Str = Handle(Select3D_SensitiveTriangle)::DownCast(Ent); - gp_Pnt P1, P2, P3, CDG; - Graphic3d_Array1OfVertex AV (1, 4); + gp_Pnt P1, P2, P3; Str->Points3D (P1, P2, P3); - CDG = Str->Center3D(); + gp_Pnt CDG = Str->Center3D(); gp_XYZ V1 (P1.XYZ()); V1 -= (CDG.XYZ()); gp_XYZ V2 (P2.XYZ()); V2 -= (CDG.XYZ()); gp_XYZ V3 (P3.XYZ()); V3 -= (CDG.XYZ()); - V1 *= 0.9; V2 *= 0.9; V3 *= 0.9; V1 += CDG.XYZ(); V2 += CDG.XYZ(); V3 += CDG.XYZ(); - AV.SetValue (1, Graphic3d_Vertex (V1.X(), V1.Y(), V1.Z())); - AV.SetValue (2, Graphic3d_Vertex (V2.X(), V2.Y(), V2.Z())); - AV.SetValue (3, Graphic3d_Vertex (V3.X(), V3.Y(), V3.Z())); - AV.SetValue (4, Graphic3d_Vertex (V1.X(), V1.Y(), V1.Z())); - mysensgroup->Polyline (AV); + + aSeqBnds.Append(4); + aSeqLines.Append(gp_Pnt(V1)); + aSeqLines.Append(gp_Pnt(V2)); + aSeqLines.Append(gp_Pnt(V3)); + aSeqLines.Append(gp_Pnt(V1)); } } + + Standard_Integer i; + + if (aSeqLines.Length()) + { + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqLines.Length(),aSeqBnds.Length()); + for (i = 1; i <= aSeqLines.Length(); i++) + aPrims->AddVertex(aSeqLines(i)); + for (i = 1; i <= aSeqBnds.Length(); i++) + aPrims->AddBound(aSeqBnds(i)); + myareagroup->AddPrimitiveArray(aPrims); + } + + if (aSeqFree.Length()) + { + mysensgroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 2.0)); + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqFree.Length(),aSeqFree.Length()/2); + for (i = 1; i <= aSeqFree.Length(); i++) + { + aPrims->AddBound(2); + aPrims->AddVertex(aSeqLines(i++)); + aPrims->AddVertex(aSeqLines(i)); + } + mysensgroup->AddPrimitiveArray(aPrims); + mysensgroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); + } } //======================================================================= @@ -1068,15 +1034,13 @@ ComputeSensitivePrs(const Handle(SelectMgr_Selection)& Sel) //purpose : //======================================================================= -void StdSelect_ViewerSelector3d:: -ComputeAreasPrs (const Handle(SelectMgr_Selection)& Sel) +void StdSelect_ViewerSelector3d::ComputeAreasPrs (const Handle(SelectMgr_Selection)& Sel) { - // Select3D_Projector myprj = StdSelect::GetProjector (aView); - Graphic3d_Array1OfVertex Av1 (1, 5); Standard_Real xmin, ymin, xmax, ymax; gp_Pnt Pbid; SelectBasics_ListOfBox2d BoxList; + TColgp_SequenceOfPnt aSeqLines; for (Sel->Init(); Sel->More(); Sel->Next()) { Sel->Sensitive()->Areas (BoxList); @@ -1086,26 +1050,37 @@ ComputeAreasPrs (const Handle(SelectMgr_Selection)& Sel) Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0); myprj->Transform (Pbid, myprj->InvertedTransformation()); - Av1.SetValue (1, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmax + mytolerance, ymin - mytolerance, 0.0); myprj->Transform (Pbid, myprj->InvertedTransformation()); - Av1.SetValue (2, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmax + mytolerance, ymax + mytolerance, 0.0); myprj->Transform (Pbid, myprj->InvertedTransformation()); - Av1.SetValue (3, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); Pbid.SetCoord (xmin - mytolerance, ymax + mytolerance, 0.0); myprj->Transform (Pbid, myprj->InvertedTransformation()); - Av1.SetValue (4, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); - - Pbid.SetCoord (xmin - mytolerance, ymin - mytolerance, 0.0); - myprj->Transform (Pbid, myprj->InvertedTransformation()); - Av1.SetValue (5, Graphic3d_Vertex (Pbid.X(), Pbid.Y(), Pbid.Z())); + aSeqLines.Append(Pbid); + } + } - myareagroup->Polyline (Av1); + if (aSeqLines.Length()) + { + Standard_Integer n, np; + const Standard_Integer nbl = aSeqLines.Length() / 4; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(5*nbl,nbl); + for (np = 1, n=0; nAddBound(5); + const gp_Pnt &p1 = aSeqLines(np++); + aPrims->AddVertex(p1); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(aSeqLines(np++)); + aPrims->AddVertex(p1); } + myareagroup->AddPrimitiveArray(aPrims); } } diff --git a/src/V3d/V3d.cxx b/src/V3d/V3d.cxx index 6cb022a31d..d3bef1ac0e 100755 --- a/src/V3d/V3d.cxx +++ b/src/V3d/V3d.cxx @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -138,96 +138,103 @@ Graphic3d_Vector Vec ; return Vec ; } -void V3d::ArrowOfRadius(const Handle(Graphic3d_Group)& garrow,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real Dx,const Standard_Real Dy,const Standard_Real Dz,const Standard_Real Alpha,const Standard_Real Lng) { - -Standard_Real Xc,Yc,Zc,Xi,Yi,Zi,Xj,Yj,Zj; -Standard_Real Xn,Yn,Zn,X,Y,Z,Norme; -Standard_Integer NbPoints = 10, i; -Graphic3d_Array1OfVertex VN(1,NbPoints+1); -Graphic3d_Array1OfVertex V2(1,2); +void V3d::ArrowOfRadius(const Handle(Graphic3d_Group)& garrow,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real Dx,const Standard_Real Dy,const Standard_Real Dz,const Standard_Real Alpha,const Standard_Real Lng) +{ + Standard_Real Xc,Yc,Zc,Xi,Yi,Zi,Xj,Yj,Zj; + Standard_Real Xn,Yn,Zn,X,Y,Z,X1,Y1,Z1,Norme; + const Standard_Integer NbPoints = 10; // Centre du cercle base de la fleche : - Xc = X0 - Dx * Lng; - Yc = Y0 - Dy * Lng; - Zc = Z0 - Dz * Lng; + Xc = X0 - Dx * Lng; + Yc = Y0 - Dy * Lng; + Zc = Z0 - Dz * Lng; // Construction d'un repere i,j pour le cercle: - Xn=0., Yn=0., Zn=0.; - - if ( Abs(Dx) <= Abs(Dy) && Abs(Dx) <= Abs(Dz)) Xn=1.; - else if ( Abs(Dy) <= Abs(Dz) && Abs(Dy) <= Abs(Dx)) Yn=1.; - else Zn=1.; - Xi = Dy * Zn - Dz * Yn; - Yi = Dz * Xn - Dx * Zn; - Zi = Dx * Yn - Dy * Xn; - - Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi ); - Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme; - - Xj = Dy * Zi - Dz * Yi; - Yj = Dz * Xi - Dx * Zi; - Zj = Dx * Yi - Dy * Xi; - - V2(1).SetCoord(X0,Y0,Z0); - - Standard_Real cosinus,sinus, Tg=Tan(Alpha); - - for (i = 1 ; i <= NbPoints ; i++) { - - cosinus = Cos ( 2 * M_PI / NbPoints * (i-1) ); - sinus = Sin ( 2 * M_PI / NbPoints * (i-1) ); - - X = Xc + (cosinus * Xi + sinus * Xj) * Lng * Tg; - Y = Yc + (cosinus * Yi + sinus * Yj) * Lng * Tg; - Z = Zc + (cosinus * Zi + sinus * Zj) * Lng * Tg; + Xn=0., Yn=0., Zn=0.; + + if ( Abs(Dx) <= Abs(Dy) && Abs(Dx) <= Abs(Dz)) Xn=1.; + else if ( Abs(Dy) <= Abs(Dz) && Abs(Dy) <= Abs(Dx)) Yn=1.; + else Zn=1.; + Xi = Dy * Zn - Dz * Yn; + Yi = Dz * Xn - Dx * Zn; + Zi = Dx * Yn - Dy * Xn; + + Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi ); + Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme; + + Xj = Dy * Zi - Dz * Yi; + Yj = Dz * Xi - Dx * Zi; + Zj = Dx * Yi - Dy * Xi; + + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(3*NbPoints,NbPoints); + + Standard_Integer i; + const Standard_Real Tg = Tan(Alpha); + for (i = 1; i <= NbPoints; i++) + { + const Standard_Real cosinus = Cos ( 2. * M_PI / NbPoints * (i-1) ); + const Standard_Real sinus = Sin ( 2. * M_PI / NbPoints * (i-1) ); + + X = Xc + (cosinus * Xi + sinus * Xj) * Lng * Tg; + Y = Yc + (cosinus * Yi + sinus * Yj) * Lng * Tg; + Z = Zc + (cosinus * Zi + sinus * Zj) * Lng * Tg; + + if(i==1) { X1=X, Y1=Y, Z1=Z; } + else aPrims->AddVertex(X,Y,Z); + aPrims->AddBound(3); + aPrims->AddVertex(X0,Y0,Z0); + aPrims->AddVertex(X,Y,Z); + } + aPrims->AddVertex(X1,Y1,Z1); - VN(i).SetCoord(X,Y,Z); - if(i==1) VN(NbPoints+1).SetCoord(X,Y,Z); - V2(2).SetCoord(X,Y,Z); - garrow->Polyline(V2); - } - garrow->Polyline(VN); + garrow->AddPrimitiveArray(aPrims); } -void V3d::CircleInPlane(const Handle(Graphic3d_Group)& gcircle,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real DX,const Standard_Real DY,const Standard_Real DZ,const Standard_Real Rayon) { - -Standard_Real VX,VY,VZ,X,Y,Z,Xn,Yn,Zn,Xi,Yi,Zi,Xj,Yj,Zj,Norme; -Standard_Integer NFACES = 30 , i; -Standard_Real Alpha = 0. ; -Standard_Real Dalpha = 2. * M_PI / NFACES ; -Graphic3d_Array1OfVertex Points(0,NFACES); +void V3d::CircleInPlane(const Handle(Graphic3d_Group)& gcircle,const Standard_Real X0,const Standard_Real Y0,const Standard_Real Z0,const Standard_Real DX,const Standard_Real DY,const Standard_Real DZ,const Standard_Real Rayon) +{ + Standard_Real Norme = Sqrt ( DX*DX + DY*DY + DZ*DZ ); + if ( Norme >= 0.0001 ) + { + Standard_Real VX,VY,VZ,X,Y,Z,Xn,Yn,Zn,Xi,Yi,Zi,Xj,Yj,Zj; - Norme = Sqrt ( DX*DX + DY*DY + DZ*DZ ); - if ( Norme >= 0.0001 ) { - VX= DX/Norme; VY = DY/Norme; VZ = DZ/Norme; + VX= DX/Norme; VY = DY/Norme; VZ = DZ/Norme; //Construction of marker i,j for the circle: - Xn=0., Yn=0., Zn=0.; - if ( Abs(VX) <= Abs(VY) && Abs(VX) <= Abs(VZ)) Xn=1.; - else if ( Abs(VY) <= Abs(VZ) && Abs(VY) <= Abs(VX)) Yn=1.; - else Zn=1.; - Xi = VY * Zn - VZ * Yn; - Yi = VZ * Xn - VX * Zn; - Zi = VX * Yn - VY * Xn; - - Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi ); - Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme; - - Xj = VY * Zi - VZ * Yi; - Yj = VZ * Xi - VX * Zi; - Zj = VX * Yi - VY * Xi; - - for (i = 0 ; i <= NFACES ; i++) { - X = X0 + (Cos(Alpha) * Xi + Sin(Alpha) * Xj) * Rayon; - Y = Y0 + (Cos(Alpha) * Yi + Sin(Alpha) * Yj) * Rayon; - Z = Z0 + (Cos(Alpha) * Zi + Sin(Alpha) * Zj) * Rayon; - Alpha +=Dalpha; - Points(i).SetCoord(X,Y,Z); - } - - gcircle->Polyline(Points); - } + Xn=0., Yn=0., Zn=0.; + if ( Abs(VX) <= Abs(VY) && Abs(VX) <= Abs(VZ)) Xn=1.; + else if ( Abs(VY) <= Abs(VZ) && Abs(VY) <= Abs(VX)) Yn=1.; + else Zn=1.; + Xi = VY * Zn - VZ * Yn; + Yi = VZ * Xn - VX * Zn; + Zi = VX * Yn - VY * Xn; + + Norme = Sqrt ( Xi*Xi + Yi*Yi + Zi*Zi ); + Xi= Xi / Norme; Yi = Yi / Norme; Zi = Zi/Norme; + + Xj = VY * Zi - VZ * Yi; + Yj = VZ * Xi - VX * Zi; + Zj = VX * Yi - VY * Xi; + + const Standard_Integer NFACES = 30; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NFACES+1); + + Standard_Integer i = 0; + Standard_Real Alpha = 0.; + const Standard_Real Dalpha = 2. * M_PI / NFACES; + for (; i <= NFACES; i++, Alpha += Dalpha) + { + const Standard_Real cosinus = Cos(Alpha); + const Standard_Real sinus = Sin(Alpha); + + X = X0 + (cosinus * Xi + sinus * Xj) * Rayon; + Y = Y0 + (cosinus * Yi + sinus * Yj) * Rayon; + Z = Z0 + (cosinus * Zi + sinus * Zj) * Rayon; + + aPrims->AddVertex(X,Y,Z); + } + gcircle->AddPrimitiveArray(aPrims); + } } @@ -239,58 +246,56 @@ void V3d::SwitchViewsinWindow(const Handle(V3d_View)& aPreviousView, aNextView->Viewer()->SetViewOn(aNextView); } -void V3d::DrawSphere(const Handle(V3d_Viewer)& aViewer,const Quantity_Length ray) { - Standard_Boolean inf = ray < 0; - Standard_Real aRadius = Abs(ray); +void V3d::DrawSphere(const Handle(V3d_Viewer)& aViewer,const Quantity_Length ray) +{ + const Standard_Boolean inf = ray < 0; + const Standard_Real aRadius = Standard_ShortReal(Abs(ray)); Handle(Graphic3d_Structure) Struct = new Graphic3d_Structure(aViewer->Viewer()) ; Handle(Graphic3d_Group) Group = new Graphic3d_Group(Struct) ; Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ; LineAttrib->SetColor(Quantity_Color(Quantity_NOC_YELLOW)); Struct->SetPrimitivesAspect(LineAttrib) ; - - Standard_Integer NFACES = 30; - Graphic3d_Array1OfVertex Points(0,NFACES) ; - Standard_Real R,X,Y,Z ; - Standard_Real Beta = 0. ; - Standard_Real Alpha = 0. ; - Standard_Real Dbeta = 2. * M_PI / NFACES ; - Standard_Real Dalpha = 2. * M_PI / NFACES ; + + const Standard_Integer NFACES = 30; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NFACES*(NFACES+1),NFACES); + + const Standard_Real Dbeta = 2. * M_PI / NFACES; + const Standard_Real Dalpha = 2. * M_PI / NFACES; + Standard_ShortReal X,Y,Z,X0,Y0,Z0; + Standard_Real R, Alpha, Beta = 0.; Standard_Integer i,j ; - for( j=0 ; jAddBound(NFACES+1); + R = aRadius*sin(Beta); + Z = Standard_ShortReal(aRadius*cos(Beta)); + for( i=0, Alpha = 0.; iAddVertex(X,Y,Z); + if (i==0) { X0=X, Y0=Y, Z0=Z; } } - Points(0).Coord(X,Y,Z) ; - Points(NFACES).SetCoord(X,Y,Z) ; - Group->Polyline(Points) ; + aPrims->AddVertex(X0,Y0,Z0); } - for( j=0 ; jAddBound(NFACES+1); + R = aRadius*sin(Beta); + Y = Standard_ShortReal(aRadius*cos(Beta)); Beta += Dbeta ; - for( i=0 ; iAddVertex(X,Y,Z); + if (i==0) { X0=X, Y0=Y, Z0=Z; } } - Points(0).Coord(X,Y,Z) ; - Points(NFACES).SetCoord(X,Y,Z) ; - Group->Polyline(Points) ; + aPrims->AddVertex(X0,Y0,Z0); } - if(inf) Struct->SetInfiniteState(Standard_True); + Group->AddPrimitiveArray(aPrims); + if(inf) Struct->SetInfiniteState(Standard_True); Struct->Display(); aViewer->Update(); } + void V3d::SetPlane(const Handle(V3d_Viewer)& aViewer, const Standard_Real x1, const Standard_Real y1, diff --git a/src/V3d/V3d_CircularGrid.cdl b/src/V3d/V3d_CircularGrid.cdl index e2b4d6490b..6385698d87 100755 --- a/src/V3d/V3d_CircularGrid.cdl +++ b/src/V3d/V3d_CircularGrid.cdl @@ -72,10 +72,8 @@ is fields myStructure : Structure from Graphic3d; - myGroup1, myGroup2 : Group from Graphic3d; - myCurViewPlane : Ax3 from gp; --- myColor, myTenthColor : Color from Quantity; --- myCurColor1, myCurColor2: Color from Quantity; + myGroup : Group from Graphic3d; + myCurViewPlane : Ax3 from gp; myViewer : ViewerPointer from V3d; myCurAreDefined : Boolean from Standard; myCurDrawMode : GridDrawMode from Aspect; diff --git a/src/V3d/V3d_CircularGrid.cxx b/src/V3d/V3d_CircularGrid.cxx index 39b7d8e956..05d2658a39 100755 --- a/src/V3d/V3d_CircularGrid.cxx +++ b/src/V3d/V3d_CircularGrid.cxx @@ -52,377 +52,312 @@ #include #include #include +#include +#include #include #include +#include /*----------------------------------------------------------------------*/ /* * Constant */ -#define NO_TRACE_MINMAX -#define NO_TRACE_MAKE -#define NO_TRACE_VALUES - #define DIVISION 8 #define MYMINMAX 25. #define MYFACTOR 50. /*----------------------------------------------------------------------*/ -V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor): - Aspect_CircularGrid (1.,8), - myStructure (new Graphic3d_Structure (aViewer->Viewer ())), - myGroup1 (new Graphic3d_Group (myStructure)), - myGroup2 (new Graphic3d_Group (myStructure)), -// myColor (aColor), -// myTenthColor (aTenthColor), - myViewer (aViewer), - myCurAreDefined (Standard_False) +V3d_CircularGrid::V3d_CircularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor) +: Aspect_CircularGrid (1.,8), + myStructure (new Graphic3d_Structure (aViewer->Viewer ())), + myGroup (new Graphic3d_Group (myStructure)), + myViewer (aViewer), + myCurAreDefined (Standard_False) { - myColor = aColor; - myTenthColor = aTenthColor; + myColor = aColor; + myTenthColor = aTenthColor; - myStructure->SetInfiniteState (Standard_True); + myStructure->SetInfiniteState (Standard_True); -Standard_Real step = 10.; -#ifdef IMP200100 -Standard_Real size = myViewer->DefaultViewSize()/2.; - SetGraphicValues (size, step/MYFACTOR); -#else - SetGraphicValues (25., step/MYFACTOR); -#endif - SetRadiusStep (step); + const Standard_Real step = 10.; + const Standard_Real size = 0.5*myViewer->DefaultViewSize(); + SetGraphicValues (size, step/MYFACTOR); + SetRadiusStep (step); } -void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) { - if( myColor != aColor || myTenthColor != aTenthColor ) { - myColor = aColor; - myTenthColor = aTenthColor; - myCurAreDefined = Standard_False; - UpdateDisplay(); - } +void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) +{ + if( myColor != aColor || myTenthColor != aTenthColor ) { + myColor = aColor; + myTenthColor = aTenthColor; + myCurAreDefined = Standard_False; + UpdateDisplay(); + } } -void V3d_CircularGrid::Display () { - myStructure->Display (1); +void V3d_CircularGrid::Display () +{ + myStructure->Display (1); } -void V3d_CircularGrid::Erase () const { - myStructure->Erase (); +void V3d_CircularGrid::Erase () const +{ + myStructure->Erase (); } -Standard_Boolean V3d_CircularGrid::IsDisplayed () const { - return myStructure->IsDisplayed (); +Standard_Boolean V3d_CircularGrid::IsDisplayed () const +{ + return myStructure->IsDisplayed (); } -void V3d_CircularGrid::UpdateDisplay () { -#ifdef TRACE_MINMAX - cout << "V3d_CircularGrid::UpdateDisplay ()\n"; -#endif - -gp_Ax3 ThePlane; - ThePlane = myViewer->PrivilegedPlane (); - -Standard_Boolean MakeTransform = Standard_False; -Standard_Real xl, yl, zl; -Standard_Real xdx, xdy, xdz; -Standard_Real ydx, ydy, ydz; -Standard_Real dx, dy, dz; - ThePlane.Location ().Coord (xl, yl, zl); - ThePlane.XDirection ().Coord (xdx, xdy, xdz); - ThePlane.YDirection ().Coord (ydx, ydy, ydz); - ThePlane.Direction ().Coord (dx, dy, dz); - if (! myCurAreDefined) - MakeTransform = Standard_True; - else { - if (RotationAngle () != myCurAngle - || XOrigin () != myCurXo || YOrigin () != myCurYo) - MakeTransform = Standard_True; - if (! MakeTransform) { -Standard_Real curxl, curyl, curzl; -Standard_Real curxdx, curxdy, curxdz; -Standard_Real curydx, curydy, curydz; -Standard_Real curdx, curdy, curdz; - myCurViewPlane.Location ().Coord (curxl, curyl, curzl); - myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz); - myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz); - myCurViewPlane.Direction ().Coord (curdx, curdy, curdz); - if (xl != curxl || yl != curyl || zl != curzl - || xdx != curxdx || xdy != curxdy || xdz != curxdz - || ydx != curydx || ydy != curydy || ydz != curydz - || dx != curdx || dy != curdy || dz != curdz) - MakeTransform = Standard_True; - } - } - - if (MakeTransform) { -#ifdef TRACE_MAKE - cout << "MakeTransform" << endl; -#endif -Standard_Real CosAlpha = Cos (RotationAngle ()); -Standard_Real SinAlpha = Sin (RotationAngle ()); -TColStd_Array2OfReal Trsf (1, 4, 1, 4); - Trsf (4, 4) = 1.0; - Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0; - // Translation - Trsf (1, 4) = xl, - Trsf (2, 4) = yl, - Trsf (3, 4) = zl; - // Transformation change of marker - Trsf (1, 1) = xdx, - Trsf (2, 1) = xdy, - Trsf (3, 1) = xdz, - Trsf (1, 2) = ydx, - Trsf (2, 2) = ydy, - Trsf (3, 2) = ydz, - Trsf (1, 3) = dx, - Trsf (2, 3) = dy, - Trsf (3, 3) = dz; - myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE); - - // Translation of the origin - Trsf (1, 4) = -XOrigin (), - Trsf (2, 4) = -YOrigin (), - Trsf (3, 4) = 0.0; - // Rotation Alpha around axis -Z - Trsf (1, 1) = CosAlpha, - Trsf (2, 1) = -SinAlpha, - Trsf (3, 1) = 0.0, - Trsf (1, 2) = SinAlpha, - Trsf (2, 2) = CosAlpha, - Trsf (3, 2) = 0.0, - Trsf (1, 3) = 0.0, - Trsf (2, 3) = 0.0, - Trsf (3, 3) = 1.0; - myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE); - - -#ifdef TRACE_VALUES -Standard_Integer i, j; -TColStd_Array2OfReal TheMatrix (1, 4, 1, 4); - myStructure->Transform (TheMatrix); - - for (i=1; i<=4; i++) { - for (j=1; j<=4; j++) - cout << TheMatrix (i, j) << "\t"; - cout << endl; - } -#endif - - myCurAngle = RotationAngle (); - myCurXo = XOrigin (), myCurYo = YOrigin (); - myCurViewPlane = ThePlane; - } - - switch (DrawMode ()) { - default: - case Aspect_GDM_Points: - if (! myCurAreDefined || myCurAreDefined && - myCurDrawMode == Aspect_GDM_Lines) - myGroup2->Clear (); - DefinePoints (); - myCurDrawMode = Aspect_GDM_Points; - break; - case Aspect_GDM_Lines: - DefineLines (); - myCurDrawMode = Aspect_GDM_Lines; - break; +void V3d_CircularGrid::UpdateDisplay () +{ + gp_Ax3 ThePlane = myViewer->PrivilegedPlane(); + + Standard_Real xl, yl, zl; + Standard_Real xdx, xdy, xdz; + Standard_Real ydx, ydy, ydz; + Standard_Real dx, dy, dz; + ThePlane.Location ().Coord (xl, yl, zl); + ThePlane.XDirection ().Coord (xdx, xdy, xdz); + ThePlane.YDirection ().Coord (ydx, ydy, ydz); + ThePlane.Direction ().Coord (dx, dy, dz); + + Standard_Boolean MakeTransform = !myCurAreDefined; + if (!MakeTransform) + { + MakeTransform = (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo); + if (!MakeTransform) + { + Standard_Real curxl, curyl, curzl; + Standard_Real curxdx, curxdy, curxdz; + Standard_Real curydx, curydy, curydz; + Standard_Real curdx, curdy, curdz; + myCurViewPlane.Location ().Coord (curxl, curyl, curzl); + myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz); + myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz); + myCurViewPlane.Direction ().Coord (curdx, curdy, curdz); + if (xl != curxl || yl != curyl || zl != curzl || + xdx != curxdx || xdy != curxdy || xdz != curxdz || + ydx != curydx || ydy != curydy || ydz != curydz || + dx != curdx || dy != curdy || dz != curdz) + MakeTransform = Standard_True; + } + } + + if (MakeTransform) + { + const Standard_Real CosAlpha = Cos (RotationAngle ()); + const Standard_Real SinAlpha = Sin (RotationAngle ()); + TColStd_Array2OfReal Trsf (1, 4, 1, 4); + Trsf (4, 4) = 1.0; + Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0; + // Translation + Trsf (1, 4) = xl, + Trsf (2, 4) = yl, + Trsf (3, 4) = zl; + // Transformation change of marker + Trsf (1, 1) = xdx, + Trsf (2, 1) = xdy, + Trsf (3, 1) = xdz, + Trsf (1, 2) = ydx, + Trsf (2, 2) = ydy, + Trsf (3, 2) = ydz, + Trsf (1, 3) = dx, + Trsf (2, 3) = dy, + Trsf (3, 3) = dz; + myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE); + + // Translation of the origin + Trsf (1, 4) = -XOrigin (), + Trsf (2, 4) = -YOrigin (), + Trsf (3, 4) = 0.0; + // Rotation Alpha around axis -Z + Trsf (1, 1) = CosAlpha, + Trsf (2, 1) = -SinAlpha, + Trsf (3, 1) = 0.0, + Trsf (1, 2) = SinAlpha, + Trsf (2, 2) = CosAlpha, + Trsf (3, 2) = 0.0, + Trsf (1, 3) = 0.0, + Trsf (2, 3) = 0.0, + Trsf (3, 3) = 1.0; + myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE); + + myCurAngle = RotationAngle (); + myCurXo = XOrigin (), myCurYo = YOrigin (); + myCurViewPlane = ThePlane; + } + + switch (DrawMode()) + { + default: + //case Aspect_GDM_Points: + DefinePoints (); + myCurDrawMode = Aspect_GDM_Points; + break; + case Aspect_GDM_Lines: + DefineLines (); + myCurDrawMode = Aspect_GDM_Lines; + break; #ifdef IMP210100 - case Aspect_GDM_None: - myCurDrawMode = Aspect_GDM_None; - break; -#endif - } - myCurAreDefined = Standard_True; - -#ifdef TRACE_VALUES -Standard_Real a11, a12, a13, a21, a22, a23, a31, a32, a33; - ThePlane.XDirection ().Coord (a11, a12, a13); - ThePlane.YDirection ().Coord (a21, a22, a23); - ThePlane.Direction ().Coord (a31, a32, a33); -cout << "Test Plane XDirection " << a11 << ", " << a12 << ", " << a13 << endl; -cout << "Test Plane YDirection " << a21 << ", " << a22 << ", " << a23 << endl; -cout << "Test Plane Direction " << a31 << ", " << a32 << ", " << a33 << endl; + case Aspect_GDM_None: + myCurDrawMode = Aspect_GDM_None; + break; #endif + } + myCurAreDefined = Standard_True; } -void V3d_CircularGrid::DefineLines () { - -Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); - LineAttrib->SetColor (myColor); - LineAttrib->SetType (Aspect_TOL_SOLID); - LineAttrib->SetWidth (1.0); - -Standard_Real r; -Standard_Real aStep = RadiusStep (); -Standard_Real aDivision = DivisionNumber (); -Standard_Real alpha = M_PI / aDivision; - -Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION)); -Graphic3d_Array1OfVertex Cercle (0, 2*Division); -Standard_Real xl, yl, zl = myOffSet; - -Standard_Integer i; - -Graphic3d_Vertex P1, P2; - -Standard_Boolean MakeDiametres = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points) - MakeDiametres = Standard_True; - else { - if (aDivision != myCurDivi) - MakeDiametres = Standard_True; - } - - if (MakeDiametres) { -#ifdef TRACE_MAKE - cout << "MakeDiametres" << endl; -#endif - // diametres - myGroup1->Clear (); -#ifdef IMP300300 - LineAttrib->SetColor (myTenthColor); -#endif - myGroup1->SetGroupPrimitivesAspect (LineAttrib); - myGroup1->BeginPrimitives (); - P1.SetCoord (0.0, 0.0, -zl); - for (i=1; i<=2*aDivision; i++) { - xl = Cos (alpha*i)*myRadius; - yl = Sin (alpha*i)*myRadius; - P2.SetCoord (xl, yl, -zl); - myGroup1->Polyline (P1, P2, Standard_False); - } - myGroup1->EndPrimitives (); - myGroup1->SetMinMaxValues - (-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0); - } - -Standard_Boolean MakeCercles = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points) - MakeCercles = Standard_True; - else { - if (aStep != myCurStep || aDivision != myCurDivi) - MakeCercles = Standard_True; - } - - if (MakeCercles) { -#ifdef TRACE_MAKE - cout << "MakeCercles" << endl; -#endif - // circles -#ifdef IMP300300 - Standard_Integer nblines = 0; -#endif - myGroup2->Clear (); -#ifndef IMP300300 - myGroup2->SetGroupPrimitivesAspect (LineAttrib); -#endif - myGroup2->BeginPrimitives (); - alpha = M_PI / Division; - for (r=aStep; r<=myRadius; r+=aStep) { - for (i=0; i<=2*Division; i++) { - xl = Cos (alpha*i)*r; - yl = Sin (alpha*i)*r; - Cercle (i).SetCoord (xl, yl, -zl); - } -#ifdef IMP300300 - if (Modulus (nblines, 10) != 0) { - myGroup2->Polyline (Cercle, Standard_False); - } else { - LineAttrib->SetColor (myTenthColor); - myGroup2->SetPrimitivesAspect (LineAttrib); - myGroup2->Polyline (Cercle, Standard_False); - LineAttrib->SetColor (myColor); - myGroup2->SetPrimitivesAspect (LineAttrib); - } - nblines++; -#else - myGroup2->Polyline (Cercle, Standard_False); -#endif - } - myGroup2->EndPrimitives (); - myGroup2->SetMinMaxValues - (-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0); - } - myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision; +void V3d_CircularGrid::DefineLines () +{ + const Standard_Real aStep = RadiusStep (); + const Standard_Real aDivision = DivisionNumber (); + const Standard_Boolean toUpdate = !myCurAreDefined + || myCurDrawMode != Aspect_GDM_Lines + || aDivision != myCurDivi + || aStep != myCurStep; + if (!toUpdate) + { + return; + } + + myGroup->Clear (); + + Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); + LineAttrib->SetColor (myColor); + LineAttrib->SetType (Aspect_TOL_SOLID); + LineAttrib->SetWidth (1.0); + + const Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION)); + + Standard_Integer nbpnts = 2 * Division; + // diametres + Standard_Real alpha = M_PI / aDivision; + LineAttrib->SetColor (myTenthColor); + myGroup->SetGroupPrimitivesAspect (LineAttrib); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2*nbpnts); + const gp_Pnt p0(0., 0., -myOffSet); + for (Standard_Integer i=1; i<=nbpnts; i++) { + aPrims->AddVertex(p0); + aPrims->AddVertex(Cos(alpha*i)*myRadius, Sin(alpha*i)*myRadius, -myOffSet); + } + myGroup->AddPrimitiveArray(aPrims, Standard_False); + + // circles + nbpnts = 2 * Division + 1; + alpha = M_PI / Division; + Standard_Integer nblines = 0; + TColgp_SequenceOfPnt aSeqLines, aSeqTenth; + for (Standard_Real r=aStep; r<=myRadius; r+=aStep, nblines++) { + const Standard_Boolean isTenth = (Modulus(nblines, 10) == 0); + for (Standard_Integer i=0; iSetColor (myTenthColor); + myGroup->SetGroupPrimitivesAspect (LineAttrib); + Standard_Integer n, np; + const Standard_Integer nbl = aSeqTenth.Length() / nbpnts; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqTenth.Length(),nbl); + for (np = 1, n=0; nAddBound(nbpnts); + for (Standard_Integer i=0; iAddVertex(aSeqTenth(np)); + } + myGroup->AddPrimitiveArray(aPrims, Standard_False); + } + if (aSeqLines.Length()) + { + LineAttrib->SetColor (myColor); + myGroup->SetPrimitivesAspect (LineAttrib); + Standard_Integer n, np; + const Standard_Integer nbl = aSeqLines.Length() / nbpnts; + Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(aSeqLines.Length(),nbl); + for (np = 1, n=0; nAddBound(nbpnts); + for (Standard_Integer i=0; iAddVertex(aSeqLines(np)); + } + myGroup->AddPrimitiveArray(aPrims, Standard_False); + } + + myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0); + myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision; } -void V3d_CircularGrid::DefinePoints () { - -Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); - MarkerAttrib->SetColor (myColor); - MarkerAttrib->SetType (Aspect_TOM_POINT); - MarkerAttrib->SetScale (3.); - -Standard_Real r; -Standard_Real aStep = RadiusStep (); -Standard_Real aDivision = DivisionNumber (); -Standard_Real alpha = M_PI / aDivision; - -Graphic3d_Array1OfVertex Cercle (0,(Standard_Integer )(2*aDivision)); -Standard_Real xl, yl, zl = myOffSet; - -Standard_Integer i; - -Graphic3d_Vertex Point (0.0, 0.0, -zl); - -Standard_Boolean MakeDiametres = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Lines) - MakeDiametres = Standard_True; - else { - if (aDivision != myCurDivi || aStep != myCurStep) - MakeDiametres = Standard_True; - } - - if (MakeDiametres) { -#ifdef TRACE_MAKE - cout << "MakeDiametres" << endl; -#endif - // diameters - myGroup1->Clear (); - myGroup1->SetGroupPrimitivesAspect (MarkerAttrib); - myGroup1->BeginPrimitives (); - myGroup1->Marker (Point, Standard_False); - for (r=aStep; r<=myRadius; r+=aStep) { - for (i=0; i<=2*aDivision; i++) { - xl = Cos (alpha*i)*r; - yl = Sin (alpha*i)*r; - Cercle (i).SetCoord (xl, yl, -zl); - } - myGroup1->MarkerSet (Cercle, Standard_False); - } - myGroup1->EndPrimitives (); - myGroup1->SetMinMaxValues - (-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0); - } - myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision; +void V3d_CircularGrid::DefinePoints () +{ + const Standard_Real aStep = RadiusStep(); + const Standard_Real aDivision = DivisionNumber(); + const Standard_Boolean toUpdate = !myCurAreDefined + || myCurDrawMode != Aspect_GDM_Points + || aDivision != myCurDivi + || aStep != myCurStep; + if (!toUpdate) + { + return; + } + + myGroup->Clear (); + + Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); + MarkerAttrib->SetColor (myColor); + MarkerAttrib->SetType (Aspect_TOM_POINT); + MarkerAttrib->SetScale (3.); + + const Standard_Integer nbpnts = Standard_Integer (2*aDivision); + Standard_Real r, alpha = M_PI / aDivision; + + // diameters + TColgp_SequenceOfPnt aSeqPnts; + aSeqPnts.Append(gp_Pnt(0.0, 0.0, -myOffSet)); + for (r=aStep; r<=myRadius; r+=aStep) { + for (Standard_Integer i=0; iSetGroupPrimitivesAspect (MarkerAttrib); + if (aSeqPnts.Length()) + { + Standard_Real X,Y,Z; + const Standard_Integer nbv = aSeqPnts.Length(); + Graphic3d_Array1OfVertex Cercle (1,nbv); + for (Standard_Integer i=1; i<=nbv; i++) + { + aSeqPnts(i).Coord(X,Y,Z); + Cercle(i).SetCoord(X,Y,Z); + } + myGroup->MarkerSet (Cercle, Standard_False); + } + myGroup->SetMinMaxValues(-myRadius, -myRadius, 0.0, myRadius, myRadius, 0.0); + + myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision; } -void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& theOffSet) const { - - theRadius = myRadius; - theOffSet = myOffSet; +void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& theOffSet) const +{ + theRadius = myRadius; + theOffSet = myOffSet; } -void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet) { - -#ifdef TRACE_MINMAX - cout << "theRadius " << theRadius << " theOffSet " << theOffSet << endl; -#endif - if (! myCurAreDefined) { - myRadius = theRadius; - myOffSet = theOffSet; - } - if (myRadius != theRadius) { - myRadius = theRadius; - myCurAreDefined = Standard_False; - } - if (myOffSet != theOffSet) { - myOffSet = theOffSet; - myCurAreDefined = Standard_False; - } -#ifdef IMP200300 - if( !myCurAreDefined ) UpdateDisplay(); -#endif +void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet) +{ + if (! myCurAreDefined) { + myRadius = theRadius; + myOffSet = theOffSet; + } + if (myRadius != theRadius) { + myRadius = theRadius; + myCurAreDefined = Standard_False; + } + if (myOffSet != theOffSet) { + myOffSet = theOffSet; + myCurAreDefined = Standard_False; + } + if( !myCurAreDefined ) UpdateDisplay(); } diff --git a/src/V3d/V3d_DirectionalLight.cxx b/src/V3d/V3d_DirectionalLight.cxx index d2588cac83..91ac0b36e3 100755 --- a/src/V3d/V3d_DirectionalLight.cxx +++ b/src/V3d/V3d_DirectionalLight.cxx @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -136,14 +136,13 @@ void V3d_DirectionalLight::DisplayPosition(Standard_Real& Xp, Standard_Real& Yp, MyDisplayPosition.Coord(Xp,Yp,Zp) ; } -void V3d_DirectionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const Handle(V3d_View)& aView) const { - +void V3d_DirectionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const Handle(V3d_View)& aView) const +{ Standard_Real Xi,Yi,Zi,Xf,Yf,Zf,Rayon,PXT,PYT,X,Y,Z,XT,YT,ZT; Standard_Real A,B,C,Dist,Beta,CosBeta,SinBeta,Coef,X1,Y1,Z1; Standard_Real DX,DY,DZ,VX,VY,VZ; Standard_Integer IXP,IYP,j; TColStd_Array2OfReal MatRot(0,2,0,2); - Graphic3d_Array1OfVertex Line(0,1); aView->Proj(VX,VY,VZ); this->DisplayPosition(Xi,Yi,Zi); @@ -192,9 +191,12 @@ void V3d_DirectionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const Rayon = this->Radius(); this->Direction(DX,DY,DZ); X = Xi + DX*Rayon/10.; Y = Yi + DY*Rayon/10.; Z = Zi + DZ*Rayon/10.; - Line(0).SetCoord(Xi,Yi,Zi); - Line(1).SetCoord(X,Y,Z); - gsymbol->Polyline(Line); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(Standard_ShortReal(Xi),Standard_ShortReal(Yi),Standard_ShortReal(Zi)); + aPrims->AddVertex(Standard_ShortReal(X),Standard_ShortReal(Y),Standard_ShortReal(Z)); + gsymbol->AddPrimitiveArray(aPrims); + V3d::ArrowOfRadius(gsymbol, X, Y, Z, DX, DY, DZ, M_PI / 15., Rayon / 20.); } diff --git a/src/V3d/V3d_Plane.cxx b/src/V3d/V3d_Plane.cxx index 969e1639ae..64d55ed743 100755 --- a/src/V3d/V3d_Plane.cxx +++ b/src/V3d/V3d_Plane.cxx @@ -34,14 +34,14 @@ #include #include -#include +#include #include #include //-Constructors -V3d_Plane::V3d_Plane(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) { - +V3d_Plane::V3d_Plane(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) +{ Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::V3d_Plane, bad plane coefficients"); MyPlane = new Visual3d_ClipPlane(A,B,C,D) ; @@ -49,70 +49,71 @@ V3d_Plane::V3d_Plane(const Standard_Real A, const Standard_Real B, const Standar //-Methods, in order -void V3d_Plane::SetPlane( const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) { - +void V3d_Plane::SetPlane(const Standard_Real A, const Standard_Real B, const Standard_Real C, const Standard_Real D) +{ Viewer_BadValue_Raise_if( sqrt(A*A + B*B + C*C) <= 0., "V3d_Plane::SetPlane, bad plane coefficients"); MyPlane->SetPlane(A,B,C,D) ; - - if( IsDisplayed() ) { + if( IsDisplayed() ) Update(); - } } void V3d_Plane::Display(const Handle(V3d_View)& aView, - const Quantity_Color& aColor) { - Handle(V3d_Viewer) theViewer = aView->Viewer(); - if (!MyGraphicStructure.IsNull()) { - MyGraphicStructure->Clear(); - } - Standard_Real size = theViewer->DefaultViewSize(); - Standard_Real offset = size/10000.; - MyGraphicStructure = new Graphic3d_Structure(theViewer->Viewer()); - Handle(Graphic3d_Group) group = new Graphic3d_Group(MyGraphicStructure); - Handle(Graphic3d_AspectFillArea3d) aspect = - new Graphic3d_AspectFillArea3d(); - Graphic3d_MaterialAspect plastic(Graphic3d_NOM_PLASTIC); - plastic.SetColor(aColor); - plastic.SetTransparency(0.5); - aView->SetTransparency(Standard_True); - aspect->SetFrontMaterial(plastic); -// aspect->SetInteriorStyle (Aspect_IS_SOLID); - aspect->SetInteriorStyle (Aspect_IS_HATCH); - aspect->SetHatchStyle (Aspect_HS_GRID_DIAGONAL_WIDE); - MyGraphicStructure->SetPrimitivesAspect(aspect); - Graphic3d_Array1OfVertex p(1,4); - p(1).SetCoord(-size/2.,-size/2.,offset); - p(2).SetCoord(-size/2., size/2.,offset); - p(3).SetCoord( size/2., size/2.,offset); - p(4).SetCoord( size/2.,-size/2.,offset); - group->Polygon(p); - MyGraphicStructure->Display(0); - Update(); + const Quantity_Color& aColor) +{ + Handle(V3d_Viewer) theViewer = aView->Viewer(); + if (!MyGraphicStructure.IsNull()) + MyGraphicStructure->Clear(); + + MyGraphicStructure = new Graphic3d_Structure(theViewer->Viewer()); + Handle(Graphic3d_Group) group = new Graphic3d_Group(MyGraphicStructure); + Handle(Graphic3d_AspectFillArea3d) aspect = new Graphic3d_AspectFillArea3d(); + Graphic3d_MaterialAspect plastic(Graphic3d_NOM_PLASTIC); + plastic.SetColor(aColor); + plastic.SetTransparency(0.5); + aView->SetTransparency(Standard_True); + aspect->SetFrontMaterial(plastic); + aspect->SetInteriorStyle (Aspect_IS_HATCH); + aspect->SetHatchStyle (Aspect_HS_GRID_DIAGONAL_WIDE); + MyGraphicStructure->SetPrimitivesAspect(aspect); + + const Standard_ShortReal size = (Standard_ShortReal)(0.5*theViewer->DefaultViewSize()); + const Standard_ShortReal offset = size/5000.F; + + Handle(Graphic3d_ArrayOfQuadrangles) aPrims = new Graphic3d_ArrayOfQuadrangles(4); + aPrims->AddVertex(-size,-size,offset); + aPrims->AddVertex(-size, size,offset); + aPrims->AddVertex( size, size,offset); + aPrims->AddVertex( size,-size,offset); + group->AddPrimitiveArray(aPrims); + + MyGraphicStructure->Display(0); + Update(); } -void V3d_Plane::Erase() { +void V3d_Plane::Erase() +{ if (!MyGraphicStructure.IsNull()) MyGraphicStructure->Erase(); } -void V3d_Plane::Plane(Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D)const { - +void V3d_Plane::Plane(Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const +{ MyPlane->Plane(A,B,C,D) ; } -Handle(Visual3d_ClipPlane) V3d_Plane::Plane()const { - - return MyPlane ; +Handle(Visual3d_ClipPlane) V3d_Plane::Plane()const +{ + return MyPlane; } -Standard_Boolean V3d_Plane::IsDisplayed() const { - +Standard_Boolean V3d_Plane::IsDisplayed() const +{ if( MyGraphicStructure.IsNull() ) return Standard_False; return MyGraphicStructure->IsDisplayed(); } -void V3d_Plane::Update() { - +void V3d_Plane::Update() +{ if( !MyGraphicStructure.IsNull() ) { TColStd_Array2OfReal matrix(1,4,1,4); Standard_Real A,B,C,D; diff --git a/src/V3d/V3d_PositionLight.cxx b/src/V3d/V3d_PositionLight.cxx index f88109175e..8a7a640b17 100755 --- a/src/V3d/V3d_PositionLight.cxx +++ b/src/V3d/V3d_PositionLight.cxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -141,9 +141,8 @@ void V3d_PositionLight::Target(Standard_Real& Xp, Standard_Real& Yp, Standard_Re } void V3d_PositionLight::Display( const Handle(V3d_View)& aView, - const V3d_TypeOfRepresentation TPres ) { - - Graphic3d_Array1OfVertex PRadius(0,1); + const V3d_TypeOfRepresentation TPres ) +{ Graphic3d_Vertex PText ; Standard_Real X,Y,Z,Rayon; Standard_Real X0,Y0,Z0,VX,VY,VZ; @@ -158,37 +157,35 @@ void V3d_PositionLight::Display( const Handle(V3d_View)& aView, // Creation of a structure snopick of non-markable elements (target, meridian and // parallel). + Pres = TPres; + Handle(V3d_Viewer) TheViewer = aView->Viewer(); + UpdSov = TheViewer->UpdateMode(); + TheViewer->SetUpdateMode(V3d_WAIT); + if (!MyGraphicStructure.IsNull()) { + MyGraphicStructure->Disconnect(MyGraphicStructure1); + MyGraphicStructure->Clear(); + MyGraphicStructure1->Clear(); + if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; + } + else { + if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; + Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure = slight; + Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure1 = snopick; + } - Pres = TPres; - Handle(V3d_Viewer) TheViewer = aView->Viewer(); - UpdSov = TheViewer->UpdateMode(); - TheViewer->SetUpdateMode(V3d_WAIT); - if (!MyGraphicStructure.IsNull()) { - MyGraphicStructure->Disconnect(MyGraphicStructure1); - MyGraphicStructure->Clear(); - MyGraphicStructure1->Clear(); - if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; - } - else { - if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; - Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure = slight; - Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure1 = snopick; - } + Handle(Graphic3d_Group) gradius; + Handle(Graphic3d_Group) gExtArrow; + Handle(Graphic3d_Group) gIntArrow; - - Handle(Graphic3d_Group) gradius; - Handle(Graphic3d_Group) gExtArrow; - Handle(Graphic3d_Group) gIntArrow; - - if (MyType != V3d_DIRECTIONAL) { - if (Pres == V3d_COMPLETE) { - gradius = new Graphic3d_Group(MyGraphicStructure); - gExtArrow = new Graphic3d_Group(MyGraphicStructure); - gIntArrow = new Graphic3d_Group(MyGraphicStructure); - } - } + if (MyType != V3d_DIRECTIONAL) { + if (Pres == V3d_COMPLETE) { + gradius = new Graphic3d_Group(MyGraphicStructure); + gExtArrow = new Graphic3d_Group(MyGraphicStructure); + gIntArrow = new Graphic3d_Group(MyGraphicStructure); + } + } Handle(Graphic3d_Group) glight = new Graphic3d_Group(MyGraphicStructure); Handle(Graphic3d_Group) gsphere; if (Pres == V3d_COMPLETE || Pres == V3d_PARTIAL) gsphere = new Graphic3d_Group(MyGraphicStructure); @@ -217,32 +214,28 @@ void V3d_PositionLight::Display( const Handle(V3d_View)& aView, aView->Proj(VX,VY,VZ); V3d::CircleInPlane(gsphere,X0,Y0,Z0,VX,VY,VZ,Rayon); - - if (MyType != V3d_DIRECTIONAL) { + if (MyType != V3d_DIRECTIONAL) { //Display of the radius of the sphere (line + text) - if (Pres == V3d_COMPLETE) { - PRadius(0).SetCoord(X0,Y0,Z0); - this->Position(X,Y,Z); - PRadius(1).SetCoord(X,Y,Z); - gnopick->Polyline(PRadius); - V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10., - Y-(Y-Y0)/10., - Z-(Z-Z0)/10.,X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.); - V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.); - TCollection_AsciiString ValOfRadius(Rayon); - PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. ); - gradius->Text(ValOfRadius.ToCString(),PText,0.01); - } - } - + if (Pres == V3d_COMPLETE) { + this->Position(X,Y,Z); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(X0,Y0,Z0); + aPrims->AddVertex(X,Y,Z); + gnopick->AddPrimitiveArray(aPrims); + V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.); + V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.); + TCollection_AsciiString ValOfRadius(Rayon); + PText.SetCoord( .5*(X0+X), .5*(Y0+Y), .5*(Z0+Z) ); + gradius->Text(ValOfRadius.ToCString(),PText,0.01); + } + } // Display of the meridian Quantity_Color Col2(Quantity_NOC_GREEN); - Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d - (Col2,Aspect_TOL_SOLID,1.); + Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d(Col2,Aspect_TOL_SOLID,1.); gnopick->SetPrimitivesAspect(Asp2); // Definition of the axis of circle diff --git a/src/V3d/V3d_PositionalLight.cxx b/src/V3d/V3d_PositionalLight.cxx index ab9d5c5e28..cf5bcd6191 100755 --- a/src/V3d/V3d_PositionalLight.cxx +++ b/src/V3d/V3d_PositionalLight.cxx @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -185,9 +185,8 @@ void V3d_PositionalLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, const void V3d_PositionalLight::Display( const Handle(V3d_View)& aView, - const V3d_TypeOfRepresentation TPres ) { - - Graphic3d_Array1OfVertex PRadius(0,1); + const V3d_TypeOfRepresentation TPres ) +{ Graphic3d_Vertex PText ; Standard_Real X,Y,Z,Rayon; Standard_Real X0,Y0,Z0,VX,VY,VZ; @@ -202,24 +201,24 @@ void V3d_PositionalLight::Display( const Handle(V3d_View)& aView, // Creation of a structure snopick of non-markable elements (target, meridian and // parallel). - Pres = TPres; - Handle(V3d_Viewer) TheViewer = aView->Viewer(); - UpdSov = TheViewer->UpdateMode(); - TheViewer->SetUpdateMode(V3d_WAIT); - if (!MyGraphicStructure.IsNull()) { - MyGraphicStructure->Disconnect(MyGraphicStructure1); - MyGraphicStructure->Clear(); - MyGraphicStructure1->Clear(); - if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; - } - else { - if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; - Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure = slight; - Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure1 = snopick; - } - + Pres = TPres; + Handle(V3d_Viewer) TheViewer = aView->Viewer(); + UpdSov = TheViewer->UpdateMode(); + TheViewer->SetUpdateMode(V3d_WAIT); + if (!MyGraphicStructure.IsNull()) { + MyGraphicStructure->Disconnect(MyGraphicStructure1); + MyGraphicStructure->Clear(); + MyGraphicStructure1->Clear(); + if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; + } + else { + if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; + Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure = slight; + Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure1 = snopick; + } + Handle(Graphic3d_Group) gradius; Handle(Graphic3d_Group) gExtArrow; Handle(Graphic3d_Group) gIntArrow; @@ -259,24 +258,22 @@ void V3d_PositionalLight::Display( const Handle(V3d_View)& aView, // Display of the radius of the sphere (line + text) if (Pres == V3d_COMPLETE) { - PRadius(0).SetCoord(X0,Y0,Z0); this->Position(X,Y,Z); - PRadius(1).SetCoord(X,Y,Z); - gnopick->Polyline(PRadius); - V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10., - Y-(Y-Y0)/10., - Z-(Z-Z0) / 10., X-X0, Y-Y0, Z-Z0, M_PI / 15., Rayon / 20.); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(X0,Y0,Z0); + aPrims->AddVertex(X,Y,Z); + gnopick->AddPrimitiveArray(aPrims); + V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.); V3d::ArrowOfRadius(gIntArrow, X0, Y0, Z0, X0-X, Y0-Y, Z0-Z, M_PI / 15., Rayon / 20.); TCollection_AsciiString ValOfRadius(Rayon); - PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. ); + PText.SetCoord( 0.5*(X0+X), 0.5*(Y0+Y), 0.5*(Z0+Z) ); gradius->Text(ValOfRadius.ToCString(),PText,0.01); } // Display of the meridian Quantity_Color Col2(Quantity_NOC_GREEN); - Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d - (Col2,Aspect_TOL_SOLID,1.); + Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d(Col2,Aspect_TOL_SOLID,1.); gnopick->SetPrimitivesAspect(Asp2); // Definition of the axis of circle @@ -304,7 +301,6 @@ void V3d_PositionalLight::Display( const Handle(V3d_View)& aView, VZ = DXRef*DYini - DYRef*DXini; V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon); - } MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT); diff --git a/src/V3d/V3d_RectangularGrid.cdl b/src/V3d/V3d_RectangularGrid.cdl index 95ad1f18ee..33f42e1b2b 100755 --- a/src/V3d/V3d_RectangularGrid.cdl +++ b/src/V3d/V3d_RectangularGrid.cdl @@ -72,24 +72,15 @@ is fields myStructure : Structure from Graphic3d; - myGroup1, myGroup2 : Group from Graphic3d; - myCurViewPlane : Ax3 from gp; --- myColor, myTenthColor : Color from Quantity; --- myCurColor1, myCurColor2: Color from Quantity; + myGroup : Group from Graphic3d; + myCurViewPlane : Ax3 from gp; myViewer : ViewerPointer from V3d; - myCurAreDefined : Boolean from Standard; - myCurDrawMode : GridDrawMode from Aspect; + myCurAreDefined : Boolean from Standard; + myCurDrawMode : GridDrawMode from Aspect; myCurXo, myCurYo : Real from Standard; myCurAngle : Real from Standard; myCurXStep, myCurYStep : Real from Standard; myXSize, myYSize : Real from Standard; myOffSet : Real from Standard; - -- Debug - -- myStructureGridPlane : Structure from Graphic3d; - -- myStructureViewPlane : Structure from Graphic3d; - -- myGroupGridPlane : Group from Graphic3d; - -- myGroupViewPlane : Group from Graphic3d; - -- myGridPlane : Ax3 from gp; - end RectangularGrid from V3d; diff --git a/src/V3d/V3d_RectangularGrid.cxx b/src/V3d/V3d_RectangularGrid.cxx index 3b6e1cb411..d96f45b955 100755 --- a/src/V3d/V3d_RectangularGrid.cxx +++ b/src/V3d/V3d_RectangularGrid.cxx @@ -56,503 +56,315 @@ #include #include #include +#include +#include /*----------------------------------------------------------------------*/ /* * Constant */ -#define NO_TRACE_MINMAX -#define NO_TRACE_MAKE -#define NO_TRACE_VALUES -#define NO_TRACE_PLANE - #define MYMINMAX 25. #define MYFACTOR 50. /*----------------------------------------------------------------------*/ -V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor): - Aspect_RectangularGrid (1.,1.), - myStructure (new Graphic3d_Structure (aViewer->Viewer ())), - myGroup1 (new Graphic3d_Group (myStructure)), - myGroup2 (new Graphic3d_Group (myStructure)), - myViewer (aViewer), - myCurAreDefined (Standard_False) -#ifdef TRACE_PLANE - ,myStructureGridPlane (new Graphic3d_Structure (aViewer->Viewer ())), - myStructureViewPlane (new Graphic3d_Structure (aViewer->Viewer ())), - myGroupGridPlane (new Graphic3d_Group (myStructureGridPlane)), - myGroupViewPlane (new Graphic3d_Group (myStructureViewPlane)), - myGridPlane (gp_Ax3 (gp_Pnt (0.,0.,0), gp_Dir (0.,0.,1.), gp_Dir (1.,0.,0.))) -#endif +V3d_RectangularGrid::V3d_RectangularGrid (const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor) +: Aspect_RectangularGrid (1.,1.), + myStructure (new Graphic3d_Structure (aViewer->Viewer ())), + myGroup (new Graphic3d_Group (myStructure)), + myViewer (aViewer), + myCurAreDefined (Standard_False) { - myColor = aColor; - myTenthColor = aTenthColor; + myColor = aColor; + myTenthColor = aTenthColor; - myStructure->SetInfiniteState (Standard_True); -#ifdef TRACE_PLANE - myStructureGridPlane->SetInfiniteState (Standard_True); - myStructureViewPlane->SetInfiniteState (Standard_True); -#endif + myStructure->SetInfiniteState (Standard_True); -#ifdef IMP200100 - Standard_Real step = 10.; - Standard_Real gstep = step/MYFACTOR; - Standard_Real size = myViewer->DefaultViewSize()/2.; -#else - Standard_Real step = 10.; - Standard_Real gstep = step/MYFACTOR; - Standard_Real size = MYMINMAX; -#endif - SetGraphicValues (size, size, gstep); - SetXStep (step); - SetYStep (step); + const Standard_Real step = 10.; + const Standard_Real gstep = step/MYFACTOR; + const Standard_Real size = 0.5*myViewer->DefaultViewSize(); + SetGraphicValues (size, size, gstep); + SetXStep (step); + SetYStep (step); } -void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) { - if( myColor != aColor || myTenthColor != aTenthColor ) { - myColor = aColor; - myTenthColor = aTenthColor; - myCurAreDefined = Standard_False; - UpdateDisplay(); - } +void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) +{ + if( myColor != aColor || myTenthColor != aTenthColor ) { + myColor = aColor; + myTenthColor = aTenthColor; + myCurAreDefined = Standard_False; + UpdateDisplay(); + } } -void V3d_RectangularGrid::Display () { - myStructure->Display (1); -#ifdef TRACE_PLANE - myStructureGridPlane->Display (1); - myStructureViewPlane->Display (1); -#endif +void V3d_RectangularGrid::Display () +{ + myStructure->Display (1); } -void V3d_RectangularGrid::Erase () const { - myStructure->Erase (); -#ifdef TRACE_PLANE - myStructureGridPlane->Erase (); - myStructureViewPlane->Erase (); -#endif +void V3d_RectangularGrid::Erase () const +{ + myStructure->Erase (); } -Standard_Boolean V3d_RectangularGrid::IsDisplayed () const { - return myStructure->IsDisplayed (); +Standard_Boolean V3d_RectangularGrid::IsDisplayed () const +{ + return myStructure->IsDisplayed (); } -void V3d_RectangularGrid::UpdateDisplay () { -#ifdef TRACE_MINMAX - cout << "V3d_RectangularGrid::UpdateDisplay ()" << endl; -#endif - -gp_Ax3 ThePlane; - ThePlane = myViewer->PrivilegedPlane (); - -Standard_Boolean MakeTransform = Standard_False; -Standard_Real xl, yl, zl; -Standard_Real xdx, xdy, xdz; -Standard_Real ydx, ydy, ydz; -Standard_Real dx, dy, dz; - ThePlane.Location ().Coord (xl, yl, zl); - ThePlane.XDirection ().Coord (xdx, xdy, xdz); - ThePlane.YDirection ().Coord (ydx, ydy, ydz); - ThePlane.Direction ().Coord (dx, dy, dz); - if (! myCurAreDefined) - MakeTransform = Standard_True; - else { - if (RotationAngle () != myCurAngle - || XOrigin () != myCurXo || YOrigin () != myCurYo) - MakeTransform = Standard_True; - if (! MakeTransform) { -Standard_Real curxl, curyl, curzl; -Standard_Real curxdx, curxdy, curxdz; -Standard_Real curydx, curydy, curydz; -Standard_Real curdx, curdy, curdz; - myCurViewPlane.Location ().Coord (curxl, curyl, curzl); - myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz); - myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz); - myCurViewPlane.Direction ().Coord (curdx, curdy, curdz); - if (xl != curxl || yl != curyl || zl != curzl - || xdx != curxdx || xdy != curxdy || xdz != curxdz - || ydx != curydx || ydy != curydy || ydz != curydz - || dx != curdx || dy != curdy || dz != curdz) - MakeTransform = Standard_True; - } - } - - if (MakeTransform) { -#ifdef TRACE_MAKE - cout << "MakeTransform" << endl; -#endif -Standard_Real CosAlpha = Cos (RotationAngle ()); -Standard_Real SinAlpha = Sin (RotationAngle ()); -TColStd_Array2OfReal Trsf (1, 4, 1, 4); - Trsf (4, 4) = 1.0; - Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0; - // Translation - Trsf (1, 4) = xl, - Trsf (2, 4) = yl, - Trsf (3, 4) = zl; - // Transformation of change of marker - Trsf (1, 1) = xdx, - Trsf (2, 1) = xdy, - Trsf (3, 1) = xdz, - Trsf (1, 2) = ydx, - Trsf (2, 2) = ydy, - Trsf (3, 2) = ydz, - Trsf (1, 3) = dx, - Trsf (2, 3) = dy, - Trsf (3, 3) = dz; - myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE); - - // Translation of the origin - Trsf (1, 4) = -XOrigin (), - Trsf (2, 4) = -YOrigin (), - Trsf (3, 4) = 0.0; - // Rotation Alpha around axis -Z - Trsf (1, 1) = CosAlpha, - Trsf (2, 1) = -SinAlpha, - Trsf (3, 1) = 0.0, - Trsf (1, 2) = SinAlpha, - Trsf (2, 2) = CosAlpha, - Trsf (3, 2) = 0.0, - Trsf (1, 3) = 0.0, - Trsf (2, 3) = 0.0, - Trsf (3, 3) = 1.0; - myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE); - - -#ifdef TRACE_VALUES -Standard_Integer i, j; -TColStd_Array2OfReal TheMatrix (1, 4, 1, 4); - myStructure->Transform (TheMatrix); - - for (i=1; i<=4; i++) { - for (j=1; j<=4; j++) - cout << TheMatrix (i, j) << "\t"; - cout << endl; - } -#endif - - myCurAngle = RotationAngle (); - myCurXo = XOrigin (), myCurYo = YOrigin (); - myCurViewPlane = ThePlane; - } - - switch (DrawMode ()) { - default: - case Aspect_GDM_Points: -#ifdef IMP210100 - if (! myCurAreDefined || - (myCurDrawMode == Aspect_GDM_Lines) ) -#else - if (! myCurAreDefined || myCurAreDefined && - myCurDrawMode == Aspect_GDM_Lines) -#endif - myGroup2->Clear (); - DefinePoints (); - myCurDrawMode = Aspect_GDM_Points; - break; - case Aspect_GDM_Lines: - DefineLines (); - myCurDrawMode = Aspect_GDM_Lines; - break; +void V3d_RectangularGrid::UpdateDisplay () +{ + gp_Ax3 ThePlane = myViewer->PrivilegedPlane (); + + Standard_Boolean MakeTransform = Standard_False; + Standard_Real xl, yl, zl; + Standard_Real xdx, xdy, xdz; + Standard_Real ydx, ydy, ydz; + Standard_Real dx, dy, dz; + ThePlane.Location ().Coord (xl, yl, zl); + ThePlane.XDirection ().Coord (xdx, xdy, xdz); + ThePlane.YDirection ().Coord (ydx, ydy, ydz); + ThePlane.Direction ().Coord (dx, dy, dz); + if (! myCurAreDefined) + MakeTransform = Standard_True; + else { + if (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo) + MakeTransform = Standard_True; + if (! MakeTransform) { + Standard_Real curxl, curyl, curzl; + Standard_Real curxdx, curxdy, curxdz; + Standard_Real curydx, curydy, curydz; + Standard_Real curdx, curdy, curdz; + myCurViewPlane.Location ().Coord (curxl, curyl, curzl); + myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz); + myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz); + myCurViewPlane.Direction ().Coord (curdx, curdy, curdz); + if (xl != curxl || yl != curyl || zl != curzl || + xdx != curxdx || xdy != curxdy || xdz != curxdz || + ydx != curydx || ydy != curydy || ydz != curydz || + dx != curdx || dy != curdy || dz != curdz) + MakeTransform = Standard_True; + } + } + + if (MakeTransform) { + const Standard_Real CosAlpha = Cos (RotationAngle ()); + const Standard_Real SinAlpha = Sin (RotationAngle ()); + TColStd_Array2OfReal Trsf (1, 4, 1, 4); + Trsf (4, 4) = 1.0; + Trsf (4, 1) = Trsf (4, 2) = Trsf (4, 3) = 0.0; + // Translation + Trsf (1, 4) = xl, + Trsf (2, 4) = yl, + Trsf (3, 4) = zl; + // Transformation of change of marker + Trsf (1, 1) = xdx, + Trsf (2, 1) = xdy, + Trsf (3, 1) = xdz, + Trsf (1, 2) = ydx, + Trsf (2, 2) = ydy, + Trsf (3, 2) = ydz, + Trsf (1, 3) = dx, + Trsf (2, 3) = dy, + Trsf (3, 3) = dz; + myStructure->SetTransform (Trsf, Graphic3d_TOC_REPLACE); + + // Translation of the origin + Trsf (1, 4) = -XOrigin (), + Trsf (2, 4) = -YOrigin (), + Trsf (3, 4) = 0.0; + // Rotation Alpha around axis -Z + Trsf (1, 1) = CosAlpha, + Trsf (2, 1) = -SinAlpha, + Trsf (3, 1) = 0.0, + Trsf (1, 2) = SinAlpha, + Trsf (2, 2) = CosAlpha, + Trsf (3, 2) = 0.0, + Trsf (1, 3) = 0.0, + Trsf (2, 3) = 0.0, + Trsf (3, 3) = 1.0; + myStructure->SetTransform (Trsf,Graphic3d_TOC_POSTCONCATENATE); + + myCurAngle = RotationAngle (); + myCurXo = XOrigin (), myCurYo = YOrigin (); + myCurViewPlane = ThePlane; + } + + switch (DrawMode ()) + { + default: + //case Aspect_GDM_Points: + DefinePoints (); + myCurDrawMode = Aspect_GDM_Points; + break; + case Aspect_GDM_Lines: + DefineLines (); + myCurDrawMode = Aspect_GDM_Lines; + break; #ifdef IMP210100 - case Aspect_GDM_None: - myCurDrawMode = Aspect_GDM_None; - break; + case Aspect_GDM_None: + myCurDrawMode = Aspect_GDM_None; + break; #endif } myCurAreDefined = Standard_True; - -#ifdef TRACE_PLANE -Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); -Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d (); -Graphic3d_Array1OfVertex Points (0, 1); -Standard_Real ay, by, cy; - - myGroupViewPlane->Clear (); - - LineAttrib->SetColor (Quantity_Color (Quantity_NOC_GREEN)); - myGroupViewPlane->SetGroupPrimitivesAspect (LineAttrib); - - TextAttrib->SetColor (Quantity_Color(Quantity_NOC_GREEN)); - myGroupViewPlane->SetGroupPrimitivesAspect (TextAttrib); - - ThePlane.Location ().Coord (xl, yl, zl); - Points (0).SetCoord (xl, yl, zl); - - myGroupViewPlane->BeginPrimitives (); - myGroupViewPlane->Text ("VIEWER PLANE", Points (0), 1./81.); - - myViewer->PrivilegedPlane ().XDirection ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupViewPlane->Polyline (Points); - myGroupViewPlane->Text ("X", Points (1), 1./81.); - - myViewer->PrivilegedPlane ().YDirection ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupViewPlane->Polyline (Points); - myGroupViewPlane->Text ("Y", Points (1), 1./81.); - - myViewer->PrivilegedPlane ().Direction ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupViewPlane->Polyline (Points); - myGroupViewPlane->Text ("Z", Points (1), 1./81.); - myGroupViewPlane->EndPrimitives (); - -#ifdef TRACE_VALUES -Standard_Real xangle, yangle, angle; -Standard_Real a11, a12, a13, a21, a22, a23, a31, a32, a33; - xangle = ThePlane.XDirection ().Angle (myGridPlane.XDirection ()); - yangle = ThePlane.YDirection ().Angle (myGridPlane.YDirection ()); - angle = ThePlane.Direction ().Angle (myGridPlane.Direction ()); -cout << "Angle entre Directions " << angle << endl; -cout << "Angle entre XDirections " << xangle << endl; -cout << "Angle entre YDirections " << yangle << endl; - ThePlane.XDirection ().Coord (a11, a12, a13); - ThePlane.YDirection ().Coord (a21, a22, a23); - ThePlane.Direction ().Coord (a31, a32, a33); -cout << "Test Plane XDirection " << a11 << ", " << a12 << ", " << a13 << endl; -cout << "Test Plane YDirection " << a21 << ", " << a22 << ", " << a23 << endl; -cout << "Test Plane Direction " << a31 << ", " << a32 << ", " << a33 << endl; -#endif - - myGroupGridPlane->Clear (); - - LineAttrib->SetColor (Quantity_Color (Quantity_NOC_RED)); - myGroupGridPlane->SetGroupPrimitivesAspect (LineAttrib); - - TextAttrib->SetColor (Quantity_Color(Quantity_NOC_RED)); - myGroupGridPlane->SetGroupPrimitivesAspect (TextAttrib); - - myGridPlane.Location ().Coord (xl, yl, zl); - Points (0).SetCoord (xl, yl, zl); - - myGroupGridPlane->BeginPrimitives (); - myGroupGridPlane->Text ("GRID PLANE", Points (0), 1./81.); - - myGridPlane.XDirection ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupGridPlane->Polyline (Points); - myGroupGridPlane->Text ("X", Points (1), 1./81.); - - myGridPlane.YDirection ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupGridPlane->Polyline (Points); - myGroupGridPlane->Text ("Y", Points (1), 1./81.); - - myGridPlane.Direction ().Coord (ay, by, cy); - Points (1).SetCoord - (xl + XStep ()*ay, yl + XStep ()*by, zl + XStep ()*cy); - myGroupGridPlane->Polyline (Points); - myGroupGridPlane->Text ("Z", Points (1), 1./81.); - myGroupGridPlane->EndPrimitives (); -#endif } -void V3d_RectangularGrid::DefineLines () { - -Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); - LineAttrib->SetColor (myColor); - LineAttrib->SetType (Aspect_TOL_SOLID); - LineAttrib->SetWidth (1.0); - -Standard_Real aXStep = XStep (); -Standard_Real aYStep = YStep (); -Standard_Integer nblines, p; -Standard_Real xl, yl, zl = myOffSet; - -Graphic3d_Vertex P1, P2; - -Standard_Boolean MakeVerticales = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points) - MakeVerticales = Standard_True; - else { - if (aXStep != myCurXStep) - MakeVerticales = Standard_True; - } - - if (MakeVerticales) { -#ifdef TRACE_MAKE - cout << "MakeVerticales" << endl; -#endif - // verticals - myGroup1->Clear (); - LineAttrib->SetColor (myTenthColor); - myGroup1->SetGroupPrimitivesAspect (LineAttrib); - myGroup1->BeginPrimitives (); - P1.SetCoord (0.0, -myYSize, -zl); - P2.SetCoord (0.0, myYSize, -zl); - myGroup1->Polyline (P1, P2, Standard_False); - nblines = 1; // start with a dark grey line - LineAttrib->SetColor (myColor); - myGroup1->SetPrimitivesAspect (LineAttrib); - for (xl = aXStep; xl < myXSize; xl += aXStep) { - P1.SetCoord (xl, -myYSize, -zl); - P2.SetCoord (xl, myYSize, -zl); - p = Modulus (nblines, 10); - if (p != 0) { - myGroup1->Polyline (P1, P2, Standard_False); - P1.SetCoord (-xl, -myYSize, -zl); - P2.SetCoord (-xl, myYSize, -zl); - myGroup1->Polyline (P1, P2, Standard_False); - } - else { - LineAttrib->SetColor (myTenthColor); - myGroup1->SetPrimitivesAspect (LineAttrib); - myGroup1->Polyline (P1, P2, Standard_False); - P1.SetCoord (-xl, -myYSize, -zl); - P2.SetCoord (-xl, myYSize, -zl); - myGroup1->Polyline (P1, P2, Standard_False); - LineAttrib->SetColor (myColor); - myGroup1->SetPrimitivesAspect (LineAttrib); - } - nblines ++; - } - myGroup1->EndPrimitives (); - myGroup1->SetMinMaxValues - (-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0); - } - -Standard_Boolean MakeHorizontales = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Points) - MakeHorizontales = Standard_True; - else { - if (aYStep != myCurYStep) - MakeHorizontales = Standard_True; - } - - if (MakeHorizontales) { -#ifdef TRACE_MAKE - cout << "MakeHorizontales" << endl; -#endif - // horizontals - myGroup2->Clear (); - LineAttrib->SetColor (myTenthColor); - myGroup2->SetGroupPrimitivesAspect (LineAttrib); - myGroup2->BeginPrimitives (); - P1.SetCoord (-myXSize, 0., -zl); - P2.SetCoord (myXSize, 0., -zl); - myGroup2->Polyline (P1, P2, Standard_False); - nblines = 1; // start with a dark grey line - LineAttrib->SetColor (myColor); - myGroup2->SetPrimitivesAspect (LineAttrib); - for (yl = aYStep; yl < myYSize; yl += aYStep) { - P1.SetCoord (-myXSize, yl, -zl); - P2.SetCoord (myXSize, yl, -zl); - p = Modulus (nblines, 10); - if (p != 0) { - myGroup2->Polyline (P1, P2, Standard_False); - P1.SetCoord (-myXSize, -yl, -zl); - P2.SetCoord (myXSize, -yl, -zl); - myGroup2->Polyline (P1, P2, Standard_False); - } - else { - LineAttrib->SetColor (myTenthColor); - myGroup2->SetPrimitivesAspect (LineAttrib); - myGroup2->Polyline (P1, P2, Standard_False); - P1.SetCoord (-myXSize, -yl, -zl); - P2.SetCoord (myXSize, -yl, -zl); - myGroup2->Polyline (P1, P2, Standard_False); - LineAttrib->SetColor (myColor); - myGroup2->SetPrimitivesAspect (LineAttrib); - } - nblines ++; - } - myGroup2->EndPrimitives (); - myGroup2->SetMinMaxValues - (-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0); - } - myCurXStep = aXStep, myCurYStep = aYStep; +void V3d_RectangularGrid::DefineLines () +{ + const Standard_Real aXStep = XStep(); + const Standard_Real aYStep = YStep(); + const Standard_Boolean toUpdate = !myCurAreDefined + || myCurDrawMode != Aspect_GDM_Lines + || aXStep != myCurXStep + || aYStep != myCurYStep; + if (!toUpdate) + { + return; + } + + myGroup->Clear(); + + Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); + LineAttrib->SetColor (myColor); + LineAttrib->SetType (Aspect_TOL_SOLID); + LineAttrib->SetWidth (1.0); + + Standard_Integer nblines; + Standard_Real xl, yl, zl = myOffSet; + + TColgp_SequenceOfPnt aSeqLines, aSeqTenth; + + // verticals + aSeqTenth.Append(gp_Pnt(0., -myYSize, -zl)); + aSeqTenth.Append(gp_Pnt(0., myYSize, -zl)); + for (nblines = 1, xl = aXStep; xl < myXSize; xl += aXStep, nblines++) + { + TColgp_SequenceOfPnt &aSeq = (Modulus(nblines, 10) != 0)? aSeqLines : aSeqTenth; + aSeq.Append(gp_Pnt( xl, -myYSize, -zl)); + aSeq.Append(gp_Pnt( xl, myYSize, -zl)); + aSeq.Append(gp_Pnt(-xl, -myYSize, -zl)); + aSeq.Append(gp_Pnt(-xl, myYSize, -zl)); + } + + // horizontals + aSeqTenth.Append(gp_Pnt(-myXSize, 0., -zl)); + aSeqTenth.Append(gp_Pnt( myXSize, 0., -zl)); + for (nblines = 1, yl = aYStep; yl < myYSize; yl += aYStep, nblines++) + { + TColgp_SequenceOfPnt &aSeq = (Modulus(nblines, 10) != 0)? aSeqLines : aSeqTenth; + aSeq.Append(gp_Pnt(-myXSize, yl, -zl)); + aSeq.Append(gp_Pnt( myXSize, yl, -zl)); + aSeq.Append(gp_Pnt(-myXSize, -yl, -zl)); + aSeq.Append(gp_Pnt( myXSize, -yl, -zl)); + } + + if (aSeqLines.Length()) + { + LineAttrib->SetColor (myColor); + myGroup->SetPrimitivesAspect (LineAttrib); + const Standard_Integer nbv = aSeqLines.Length(); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv); + Standard_Integer n = 1; + while (n<=nbv) + aPrims->AddVertex(aSeqLines(n++)); + myGroup->AddPrimitiveArray(aPrims, Standard_False); + } + if (aSeqTenth.Length()) + { + LineAttrib->SetColor (myTenthColor); + myGroup->SetPrimitivesAspect (LineAttrib); + const Standard_Integer nbv = aSeqTenth.Length(); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv); + Standard_Integer n = 1; + while (n<=nbv) + aPrims->AddVertex(aSeqTenth(n++)); + myGroup->AddPrimitiveArray(aPrims, Standard_False); + } + + myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0); + myCurXStep = aXStep, myCurYStep = aYStep; } -void V3d_RectangularGrid::DefinePoints () { - -Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); - MarkerAttrib->SetColor (myColor); - MarkerAttrib->SetType (Aspect_TOM_POINT); - MarkerAttrib->SetScale (3.); - -Standard_Real aXStep = XStep (); -Standard_Real aYStep = YStep (); -Standard_Integer i, nbpoints; - nbpoints = Standard_Integer (myYSize/aYStep); - nbpoints = 4 * nbpoints + 2; - -Graphic3d_Array1OfVertex Vertical (1, nbpoints); -Standard_Real xl, yl, zl = myOffSet; - -Standard_Boolean MakeHorizontales = Standard_False; - if (! myCurAreDefined || myCurDrawMode == Aspect_GDM_Lines) - MakeHorizontales = Standard_True; - else { - if (aXStep != myCurXStep || aYStep != myCurYStep) - MakeHorizontales = Standard_True; - } - - if (MakeHorizontales) { -#ifdef TRACE_MAKE - cout << "MakeHorizontales" << endl; -#endif - // horizontals - myGroup1->Clear (); - myGroup1->SetGroupPrimitivesAspect (MarkerAttrib); - myGroup1->BeginPrimitives (); - for (xl = 0.0; xl <= myXSize; xl += aXStep) { - i = 1; - Vertical (i++).SetCoord (xl, 0.0, -zl); - Vertical (i++).SetCoord (-xl, 0.0, -zl); - for (yl = aYStep; yl <= myYSize; yl += aYStep) { - if (i<=nbpoints) Vertical (i++).SetCoord (xl, yl, -zl); - if (i<=nbpoints) Vertical (i++).SetCoord (xl, -yl, -zl); - if (i<=nbpoints) Vertical (i++).SetCoord (-xl, yl, -zl); - if (i<=nbpoints) Vertical (i++).SetCoord (-xl, -yl, -zl); - } - myGroup1->MarkerSet (Vertical, Standard_False); - } - myGroup1->EndPrimitives (); - myGroup1->SetMinMaxValues - (-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0); - } - myCurXStep = aXStep, myCurYStep = aYStep; +void V3d_RectangularGrid::DefinePoints () +{ + const Standard_Real aXStep = XStep(); + const Standard_Real aYStep = YStep(); + const Standard_Boolean toUpdate = !myCurAreDefined + || myCurDrawMode != Aspect_GDM_Points + || aXStep != myCurXStep + || aYStep != myCurYStep; + if (!toUpdate) + { + return; + } + + myGroup->Clear (); + + Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); + MarkerAttrib->SetColor (myColor); + MarkerAttrib->SetType (Aspect_TOM_POINT); + MarkerAttrib->SetScale (3.); + + // horizontals + Standard_Real xl, yl; + TColgp_SequenceOfPnt aSeqPnts; + for (xl = 0.0; xl <= myXSize; xl += aXStep) { + aSeqPnts.Append(gp_Pnt( xl, 0.0, -myOffSet)); + aSeqPnts.Append(gp_Pnt(-xl, 0.0, -myOffSet)); + for (yl = aYStep; yl <= myYSize; yl += aYStep) { + aSeqPnts.Append(gp_Pnt( xl, yl, -myOffSet)); + aSeqPnts.Append(gp_Pnt( xl, -yl, -myOffSet)); + aSeqPnts.Append(gp_Pnt(-xl, yl, -myOffSet)); + aSeqPnts.Append(gp_Pnt(-xl, -yl, -myOffSet)); + } + } + if (aSeqPnts.Length()) + { + Standard_Integer i; + Standard_Real X,Y,Z; + const Standard_Integer nbv = aSeqPnts.Length(); + Graphic3d_Array1OfVertex Vertical (1,nbv); + for (i=1; i<=nbv; i++) + { + aSeqPnts(i).Coord(X,Y,Z); + Vertical(i).SetCoord(X,Y,Z); + } + myGroup->SetGroupPrimitivesAspect (MarkerAttrib); + myGroup->MarkerSet (Vertical, Standard_False); + } + + myGroup->SetMinMaxValues(-myXSize, -myYSize, 0.0, myXSize, myYSize, 0.0); + myCurXStep = aXStep, myCurYStep = aYStep; } -void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real& theYSize, Standard_Real& theOffSet) const { - - theXSize = myXSize; - theYSize = myYSize; - theOffSet = myOffSet; +void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real& theYSize, Standard_Real& theOffSet) const +{ + theXSize = myXSize; + theYSize = myYSize; + theOffSet = myOffSet; } -void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet) { - -#ifdef TRACE_MINMAX - cout << "theXSize " << theXSize << " theYSize " << theYSize - << " theOffSet " << theOffSet << endl; -#endif - if (! myCurAreDefined) { - myXSize = theXSize; - myYSize = theYSize; - myOffSet = theOffSet; - } - if (myXSize != theXSize) { - myXSize = theXSize; - myCurAreDefined = Standard_False; - } - if (myYSize != theYSize) { - myYSize = theYSize; - myCurAreDefined = Standard_False; - } - if (myOffSet != theOffSet) { - myOffSet = theOffSet; - myCurAreDefined = Standard_False; - } -#ifdef IMP200300 - if( !myCurAreDefined ) UpdateDisplay(); -#endif +void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet) +{ + if (! myCurAreDefined) { + myXSize = theXSize; + myYSize = theYSize; + myOffSet = theOffSet; + } + if (myXSize != theXSize) { + myXSize = theXSize; + myCurAreDefined = Standard_False; + } + if (myYSize != theYSize) { + myYSize = theYSize; + myCurAreDefined = Standard_False; + } + if (myOffSet != theOffSet) { + myOffSet = theOffSet; + myCurAreDefined = Standard_False; + } + if( !myCurAreDefined ) UpdateDisplay(); } diff --git a/src/V3d/V3d_SpotLight.cxx b/src/V3d/V3d_SpotLight.cxx index 7fb8507a46..5efaad003e 100755 --- a/src/V3d/V3d_SpotLight.cxx +++ b/src/V3d/V3d_SpotLight.cxx @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -176,8 +176,8 @@ void V3d_SpotLight::Attenuation(Standard_Real& A1, Standard_Real& A2) const { MyLight->Values(C,P,D,CN,A1,A2,AN) ; } -Standard_Real V3d_SpotLight::Concentration()const { - +Standard_Real V3d_SpotLight::Concentration()const +{ Quantity_Color C ; Graphic3d_Vector D ; Graphic3d_Vertex P ; @@ -187,8 +187,8 @@ Standard_Real V3d_SpotLight::Concentration()const { return CN ; } -Standard_Real V3d_SpotLight::Angle()const { - +Standard_Real V3d_SpotLight::Angle()const +{ Quantity_Color C ; Graphic3d_Vector D ; Graphic3d_Vertex P ; @@ -199,22 +199,19 @@ Standard_Real V3d_SpotLight::Angle()const { } void V3d_SpotLight::Symbol (const Handle(Graphic3d_Group)& gsymbol, -// const Handle(V3d_View)& aView) const { - const Handle(V3d_View)& ) const { - - Standard_Real X,Y,Z,Rayon; + const Handle(V3d_View)& ) const +{ + Standard_Real X,Y,Z; Standard_Real DX,DY,DZ; - this->Position(X,Y,Z); this->Direction(DX,DY,DZ); - Rayon = this->Radius(); - V3d::ArrowOfRadius(gsymbol,X,Y,Z,-DX,-DY,-DZ,M_PI/8.,Rayon/15.); + + V3d::ArrowOfRadius(gsymbol,X,Y,Z,-DX,-DY,-DZ,M_PI/8.,this->Radius()/15.); } void V3d_SpotLight::Display( const Handle(V3d_View)& aView, - const V3d_TypeOfRepresentation TPres) { - - Graphic3d_Array1OfVertex PRadius(0,1); + const V3d_TypeOfRepresentation TPres) +{ Graphic3d_Vertex PText ; Standard_Real X,Y,Z,Rayon; Standard_Real X0,Y0,Z0,VX,VY,VZ; @@ -229,24 +226,24 @@ void V3d_SpotLight::Display( const Handle(V3d_View)& aView, // Creation of a structure snopick of non-markable elements (target, meridian and // parallel).// - Pres = TPres; - Handle(V3d_Viewer) TheViewer = aView->Viewer(); - UpdSov = TheViewer->UpdateMode(); - TheViewer->SetUpdateMode(V3d_WAIT); - if (!MyGraphicStructure.IsNull()) { - MyGraphicStructure->Disconnect(MyGraphicStructure1); - MyGraphicStructure->Clear(); - MyGraphicStructure1->Clear(); - if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; - } - else { - if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; - Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure = slight; - Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); - MyGraphicStructure1 = snopick; - } - + Pres = TPres; + Handle(V3d_Viewer) TheViewer = aView->Viewer(); + UpdSov = TheViewer->UpdateMode(); + TheViewer->SetUpdateMode(V3d_WAIT); + if (!MyGraphicStructure.IsNull()) { + MyGraphicStructure->Disconnect(MyGraphicStructure1); + MyGraphicStructure->Clear(); + MyGraphicStructure1->Clear(); + if (Pres == V3d_SAMELAST) Pres = MyTypeOfRepresentation; + } + else { + if (Pres == V3d_SAMELAST) Pres = V3d_SIMPLE; + Handle(Graphic3d_Structure) slight = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure = slight; + Handle(Graphic3d_Structure) snopick = new Graphic3d_Structure(TheViewer->Viewer()); + MyGraphicStructure1 = snopick; + } + Handle(Graphic3d_Group) gradius; Handle(Graphic3d_Group) gExtArrow; Handle(Graphic3d_Group) gIntArrow; @@ -286,24 +283,22 @@ void V3d_SpotLight::Display( const Handle(V3d_View)& aView, // Display of the radius of the sphere (line + text) if (Pres == V3d_COMPLETE) { - PRadius(0).SetCoord(X0,Y0,Z0); this->Position(X,Y,Z); - PRadius(1).SetCoord(X,Y,Z); - gnopick->Polyline(PRadius); - V3d::ArrowOfRadius(gExtArrow,X-(X-X0)/10., - Y-(Y-Y0)/10., - Z-(Z-Z0) / 10., X-X0, Y-Y0, Z-Z0, M_PI / 15., Rayon / 20.); - V3d::ArrowOfRadius(gIntArrow, X0, Y0, Z0, X0-X, Y0-Y, Z0-Z, M_PI / 15., Rayon / 20.); + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); + aPrims->AddVertex(X0,Y0,Z0); + aPrims->AddVertex(X,Y,Z); + gnopick->AddPrimitiveArray(aPrims); + V3d::ArrowOfRadius(gExtArrow,X-.1*(X-X0),Y-.1*(Y-Y0),Z-.1*(Z-Z0),X-X0,Y-Y0,Z-Z0,M_PI/15.,Rayon/20.); + V3d::ArrowOfRadius(gIntArrow,X0,Y0,Z0,X0-X,Y0-Y,Z0-Z,M_PI/15.,Rayon/20.); TCollection_AsciiString ValOfRadius(Rayon); - PText.SetCoord( (X0+X)/2., (Y0+Y)/2. , (Z0+Z)/2. ); + PText.SetCoord( .5*(X0+X), .5*(Y0+Y), .5*(Z0+Z) ); gradius->Text(ValOfRadius.ToCString(),PText,0.01); } // Display of the meridian Quantity_Color Col2(Quantity_NOC_GREEN); - Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d - (Col2,Aspect_TOL_SOLID,1.); + Handle(Graphic3d_AspectLine3d) Asp2 = new Graphic3d_AspectLine3d(Col2,Aspect_TOL_SOLID,1.); gnopick->SetPrimitivesAspect(Asp2); // Definition of the axis of the circle @@ -331,7 +326,6 @@ void V3d_SpotLight::Display( const Handle(V3d_View)& aView, VZ = DXRef*DYini - DYRef*DXini; V3d::CircleInPlane(gnopick,X0,Y0,Z0,VX,VY,VZ,Rayon); - } MyGraphicStructure->Connect(MyGraphicStructure1,Graphic3d_TOC_DESCENDANT); diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index a6b0e526f6..0f5dd258e9 100755 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -79,8 +79,7 @@ To solve the problem (for lack of a better solution) I make 2 passes. ************************************************************************/ -#define GER61351 //GG_15/12/99 Add SetBackgroundColor() -// and BackgroundColor() methods +//GER61351 //GG_15/12/99 Add SetBackgroundColor() and BackgroundColor() methods #define IMP240100 //GG @@ -206,11 +205,6 @@ static OSD_Timer FullTimer; #define Zmargin 1. #define DEUXPI (2. * M_PI) -// in case of NO_TRACE_ECHO and NO_TRACE_POINTS, in V3d_View_4.cxx and in -// V3d_View.cxx, change MyGridEchoStructure and MyGridEchoGroup in cdl -#define NO_TRACE_ECHO -#define NO_TRACE_POINTS - /*----------------------------------------------------------------------*/ /* * Local data definitions @@ -303,12 +297,7 @@ myActivePlanesIterator(), SwitchSetFront(Standard_False), MyTrsf (1, 4, 1, 4), // S3892 MyProjModel(V3d_TPM_SCREEN) -#if defined(TRACE_POINTS) -,MyGridEchoStructure (new Graphic3d_Structure (VM->Viewer ())), // S3892 -MyGridEchoGroup (new Graphic3d_Group (MyGridEchoStructure)) // S3892 -#endif { - myImmediateUpdate = Standard_False; MyView = new Visual3d_View(MyViewer->Viewer()); @@ -391,13 +380,6 @@ MyGridEchoGroup (new Graphic3d_Group (MyGridEchoStructure)) // S3892 // S3892 #ifndef IMP240100 -#if defined(TRACE_POINTS) - Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); - MarkerAttrib->SetColor (Quantity_Color (Quantity_NOC_GRAY90)); - MarkerAttrib->SetScale (3.0); - MarkerAttrib->SetType (Aspect_TOM_STAR); - MyGridEchoStructure->SetPrimitivesAspect (MarkerAttrib); -#endif #endif //IMP240100 #ifdef G003 @@ -407,7 +389,6 @@ MyGridEchoGroup (new Graphic3d_Group (MyGridEchoStructure)) // S3892 #ifdef IMP210200 MyTransparencyFlag = Standard_False; #endif - } /*----------------------------------------------------------------------*/ @@ -423,12 +404,7 @@ myActivePlanesIterator(), SwitchSetFront(Standard_False), MyTrsf (1, 4, 1, 4), // S3892 MyProjModel(V3d_TPM_SCREEN) -#if defined(TRACE_POINTS) -,MyGridEchoStructure (new Graphic3d_Structure (VM->Viewer ())), // S3892 -MyGridEchoGroup (new Graphic3d_Group (MyGridEchoStructure)) // S3892 -#endif { - Handle(Visual3d_View) FromView = V->View() ; myImmediateUpdate = Standard_False; @@ -453,21 +429,9 @@ MyGridEchoGroup (new Graphic3d_Group (MyGridEchoStructure)) // S3892 Init(); myImmediateUpdate = Standard_True; - // S3892 -#ifndef IMP240100 -#if defined(TRACE_ECHO) - Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d (); - MarkerAttrib->SetColor (Quantity_Color (Quantity_NOC_GRAY90)); - MarkerAttrib->SetScale (3.0); - MarkerAttrib->SetType (Aspect_TOM_STAR); - MyGridEchoStructure->SetPrimitivesAspect (MarkerAttrib); -#endif -#endif //IMP240100 - #ifdef G003 MyAnimationFlags = 0; #endif - } /*----------------------------------------------------------------------*/ @@ -481,7 +445,6 @@ void V3d_View::SetMagnify(const Handle(Aspect_Window)& TheWindow, const Standard_Integer x2, const Standard_Integer y2) { - if( !MyView->IsDefined() ) { Standard_Real a,b,c,d; aPreviousView->Convert(x1,y1,a,b); @@ -496,14 +459,12 @@ void V3d_View::SetMagnify(const Handle(Aspect_Window)& TheWindow, MyView->Redraw() ; SetViewMappingDefault(); } - } /*----------------------------------------------------------------------*/ void V3d_View::SetWindow(const Handle(Aspect_Window)& TheWindow) { - Standard_MultiplyDefined_Raise_if( MyView->IsDefined(), "V3d_View::SetWindow, window of view already defined"); @@ -521,12 +482,7 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)& TheWindow) MyView->SetViewOrientation(MyViewOrientation) ; MyView->SetBackground(MyBackground) ; MyViewer->SetViewOn(this) ; -#ifdef TRACE_POINTS - MyGridEchoStructure->SetInfiniteState (Standard_True); // S3892 - MyGridEchoStructure->Display (); // S3892 -#endif MyView->Redraw() ; - } // RIC120302 @@ -537,7 +493,6 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)& aWindow, const Aspect_GraphicCallbackProc& aDisplayCB, const Standard_Address aClientData) { - Standard_MultiplyDefined_Raise_if( MyView->IsDefined(), "V3d_View::SetWindow, " "window of view already defined"); @@ -554,7 +509,6 @@ void V3d_View::SetWindow(const Handle(Aspect_Window)& aWindow, MyView->SetBackground(MyBackground) ; MyViewer->SetViewOn(this) ; MyView->Redraw() ; - } // RIC120302 @@ -570,15 +524,18 @@ void V3d_View::Remove() const /*----------------------------------------------------------------------*/ -void V3d_View::Update() const { +void V3d_View::Update() const +{ if( MyView->IsDefined() ) MyView->Update() ; } /*----------------------------------------------------------------------*/ -void V3d_View::Redraw() const { +void V3d_View::Redraw() const +{ if( MyView->IsDefined() ) MyView->Redraw() ; } + /*----------------------------------------------------------------------*/ void V3d_View::Redraw(const Standard_Integer xc,const Standard_Integer yc, @@ -589,27 +546,28 @@ void V3d_View::Redraw(const Standard_Integer xc,const Standard_Integer yc, /*----------------------------------------------------------------------*/ -Standard_Boolean V3d_View::IsEmpty() const { - +Standard_Boolean V3d_View::IsEmpty() const +{ Standard_Boolean TheStatus = Standard_True ; if( MyView->IsDefined() ) { Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ; if( Nstruct > 0 ) TheStatus = Standard_False ; } return (TheStatus) ; - } /*----------------------------------------------------------------------*/ -void V3d_View::UpdateLights() const { +void V3d_View::UpdateLights() const +{ MyView->SetContext(MyViewContext); Update(); } /*----------------------------------------------------------------------*/ -void V3d_View::DoMapping() { +void V3d_View::DoMapping() +{ if( MyView->IsDefined() ) { (MyView->Window())->DoMapping() ; } @@ -617,8 +575,8 @@ void V3d_View::DoMapping() { /*----------------------------------------------------------------------*/ -void V3d_View::MustBeResized() { - +void V3d_View::MustBeResized() +{ if ( !MyLayerMgr.IsNull() ) MyLayerMgr->Resized(); @@ -627,7 +585,6 @@ void V3d_View::MustBeResized() { MyViewMapping = MyView->ViewMapping(); MyView->Redraw(); } - } /*----------------------------------------------------------------------*/ @@ -639,18 +596,9 @@ void V3d_View::SetBackgroundColor(const Quantity_TypeOfColor Type, const Standar Standard_Real V3 = Max( Min( v3, 1.0 ), 0.0 ); Quantity_Color C( V1, V2, V3, Type ); -#ifdef GER61351 SetBackgroundColor( C ); -#else - MyBackground.SetColor( C ); - if ( MyView->IsDefined() ) - MyView->SetBackground( MyBackground ); - if ( !MyLayerMgr.IsNull() ) - MyLayerMgr->Resized(); -#endif } -#ifdef GER61351 /*----------------------------------------------------------------------*/ void V3d_View::SetBackgroundColor(const Quantity_Color &Color) @@ -662,22 +610,13 @@ void V3d_View::SetBackgroundColor(const Quantity_Color &Color) if ( !MyLayerMgr.IsNull() ) MyLayerMgr->Resized(); } -#endif /*----------------------------------------------------------------------*/ void V3d_View::SetBackgroundColor(const Quantity_NameOfColor Name) { Quantity_Color C( Name ); -#ifdef GER61351 SetBackgroundColor( C ); -#else - MyBackground.SetColor( C ); - if ( MyView->IsDefined() ) - MyView->SetBackground( MyBackground ); - if ( !MyColorScale.IsNull() ) - MyColorScale->Resized(); -#endif } /*----------------------------------------------------------------------*/ @@ -687,11 +626,9 @@ void V3d_View::SetBgGradientColors( const Quantity_Color& Color1, const Aspect_GradientFillMethod FillStyle, const Standard_Boolean status) { - MyGradientBackground.SetColors(Color1, Color2, FillStyle); if ( MyView->IsDefined() ) MyView->SetGradientBackground( MyGradientBackground, status ); - } /*----------------------------------------------------------------------*/ @@ -745,8 +682,8 @@ void V3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle, /*----------------------------------------------------------------------*/ -void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz) { - +void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz) +{ Standard_Real D,Nx = Vx,Ny = Vy,Nz = Vz ; D = Sqrt( Vx*Vx + Vy*Vy + Vz*Vz ) ; @@ -755,49 +692,44 @@ void V3d_View::SetAxis(const Standard_Real X, const Standard_Real Y, const Stand MyDefaultViewPoint.SetCoord(X,Y,Z) ; MyDefaultViewAxis.SetCoord(Nx,Ny,Nz) ; MyDefaultViewAxis.Normalize() ; - } /*----------------------------------------------------------------------*/ -void V3d_View::SetShadingModel(const V3d_TypeOfShadingModel Model) { - +void V3d_View::SetShadingModel(const V3d_TypeOfShadingModel Model) +{ MyViewContext.SetModel((Visual3d_TypeOfModel) Model) ; MyView->SetContext(MyViewContext) ; - } /*----------------------------------------------------------------------*/ -void V3d_View::SetSurfaceDetail(const V3d_TypeOfSurfaceDetail Model) { - +void V3d_View::SetSurfaceDetail(const V3d_TypeOfSurfaceDetail Model) +{ MyViewContext.SetSurfaceDetail((Visual3d_TypeOfSurfaceDetail) Model) ; MyView->SetContext(MyViewContext) ; - } /*----------------------------------------------------------------------*/ -void V3d_View::SetTextureEnv(const Handle(Graphic3d_TextureEnv)& ATexture) { - +void V3d_View::SetTextureEnv(const Handle(Graphic3d_TextureEnv)& ATexture) +{ MyViewContext.SetTextureEnv(ATexture) ; MyView->SetContext(MyViewContext) ; - } /*----------------------------------------------------------------------*/ -void V3d_View::SetVisualization(const V3d_TypeOfVisualization Mode) { - +void V3d_View::SetVisualization(const V3d_TypeOfVisualization Mode) +{ MyViewContext.SetVisualization((Visual3d_TypeOfVisualization) Mode); MyView->SetContext(MyViewContext) ; - } /*----------------------------------------------------------------------*/ -void V3d_View::SetFront() { - +void V3d_View::SetFront() +{ gp_Ax3 a = MyViewer->PrivilegedPlane(); Standard_Real xo,yo,zo,vx,vy,vz,xu,yu,zu; @@ -818,13 +750,12 @@ void V3d_View::SetFront() { MyView->SetViewOrientation(MyViewOrientation) ; ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ -void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start) { - +void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start) +{ Standard_Real Ax = ax ; Standard_Real Ay = ay ; Standard_Real Az = az ; @@ -868,7 +799,6 @@ void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Stan SetZSize(0.) ; #endif ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ @@ -876,7 +806,6 @@ void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Stan void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start) { - Standard_Real Ax = ax ; Standard_Real Ay = ay ; Standard_Real Az = az ; @@ -924,13 +853,12 @@ void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Stan SetZSize(0.) ; #endif ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ -void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start) { - +void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start) +{ switch (Axe) { case V3d_X : Rotate(angle,0.,0.,Start); @@ -942,7 +870,6 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Rotate(0.,0.,angle,Start); break ; } - } /*----------------------------------------------------------------------*/ @@ -950,7 +877,6 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start) { - Standard_Real Angle = angle ; Graphic3d_Vector Vpn,Vup ; Graphic3d_Vertex Vrp ; @@ -989,13 +915,12 @@ void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, SetZSize(0.) ; #endif ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ -void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start) { - +void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start) +{ Standard_Real Angle = angle ; Graphic3d_Vector Vpn,Vup ; TColStd_Array2OfReal Matrix(0,3,0,3) ; @@ -1024,14 +949,12 @@ void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start) { SetZSize(0.) ; #endif ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start) { - Standard_Real Ax = ax ; Standard_Real Ay = ay ; Standard_Real Az = az ; @@ -1093,14 +1016,12 @@ void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standa } #endif ImmediateUpdate(); - } /*----------------------------------------------------------------------*/ void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start) { - switch (Axe) { case V3d_X : Turn(angle,0.,0.,Start); @@ -1114,7 +1035,8 @@ void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const St } } -void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start) { +void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start) +{ Standard_Real Angle = angle ; Graphic3d_Vertex Vrp,Eye ; Graphic3d_Vector Vpn,Vup ; @@ -1156,11 +1078,10 @@ void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start) { } #endif ImmediateUpdate(); - } -void V3d_View::SetTwist(const Standard_Real angle) { - +void V3d_View::SetTwist(const Standard_Real angle) +{ Standard_Real Angle = angle ; TColStd_Array2OfReal Matrix(0,3,0,3) ; Standard_Boolean TheStatus ; @@ -1191,26 +1112,22 @@ void V3d_View::SetTwist(const Standard_Real angle) { MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ; MyView->SetViewOrientation(MyViewOrientation) ; ImmediateUpdate(); - } #ifdef IMP240100 void V3d_View::SetProjModel( const V3d_TypeOfProjectionModel aModel ) { - MyProjModel = aModel; - } -V3d_TypeOfProjectionModel V3d_View::ProjModel() const { - +V3d_TypeOfProjectionModel V3d_View::ProjModel() const +{ return MyProjModel; - } #endif -void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) { - +void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) +{ Standard_Real Angle,Xat,Yat,Zat,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn ; Angle = Twist() ; MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ; @@ -1253,11 +1170,10 @@ void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard #endif myImmediateUpdate = update; ImmediateUpdate(); - } -void V3d_View::SetDepth(const Standard_Real Depth) { - +void V3d_View::SetDepth(const Standard_Real Depth) +{ Standard_Real Xrp,Yrp,Zrp ; #ifdef IMP250200 Viewer_BadValue_Raise_if( Depth == 0. ,"V3d_View::SetDepth, bad depth"); @@ -1265,10 +1181,6 @@ void V3d_View::SetDepth(const Standard_Real Depth) { Viewer_BadValue_Raise_if( Depth <= 0. ,"V3d_View::SetDepth, bad depth"); #endif -#ifdef DEB - Standard_Real twist = -#endif - Twist(); MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ; MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ; MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ; @@ -1317,13 +1229,11 @@ void V3d_View::SetDepth(const Standard_Real Depth) { #endif ImmediateUpdate(); - } void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Standard_Real Vz ) { - Standard_Real Angle ; Viewer_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0., @@ -1341,15 +1251,14 @@ void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Sta #endif myImmediateUpdate = update; ImmediateUpdate(); - } -void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation ) { - +void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation ) +{ MyViewReferencePlane = V3d::GetProjAxis(Orientation) ; MyViewOrientation.SetViewReferencePlane(MyViewReferencePlane) ; // MSV 14.03.2007: reset ViewReferencePoint to debug LH3D14955 - MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex(0,0,0)); + MyViewOrientation.SetViewReferencePoint(Graphic3d_Vertex (0.0f, 0.0f, 0.0f)); Standard_Real Xpn=0; Standard_Real Ypn=0; Standard_Real Zpn=0; @@ -1369,11 +1278,10 @@ void V3d_View::SetProj( const V3d_TypeOfOrientation Orientation ) { SetZSize(0.) ; #endif ImmediateUpdate(); - } -void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) { - +void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z) +{ Standard_Real Angle,Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ; Standard_Real Xeye,Yeye,Zeye ; @@ -1424,11 +1332,10 @@ void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_ #endif myImmediateUpdate = update; ImmediateUpdate(); - } -void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz) { - +void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standard_Real Vz) +{ Standard_Boolean TheStatus ; Viewer_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0. , "V3d_View::SetUp, nullUp vector"); @@ -1459,11 +1366,10 @@ void V3d_View::SetUp(const Standard_Real Vx,const Standard_Real Vy,const Standar MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ; MyView->SetViewOrientation(MyViewOrientation) ; ImmediateUpdate(); - } -void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation ) { - +void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation ) +{ Standard_Boolean TheStatus ; MyViewReferenceUp = V3d::GetProjAxis(Orientation) ; @@ -1491,7 +1397,6 @@ void V3d_View::SetUp( const V3d_TypeOfOrientation Orientation ) { MyViewOrientation.SetViewReferenceUp(MyViewReferenceUp) ; MyView->SetViewOrientation(MyViewOrientation) ; ImmediateUpdate(); - } void V3d_View::SetViewOrientation(const Visual3d_ViewOrientation& VO) @@ -1501,22 +1406,22 @@ void V3d_View::SetViewOrientation(const Visual3d_ViewOrientation& VO) ImmediateUpdate(); } -void V3d_View::SetViewOrientationDefault() { - +void V3d_View::SetViewOrientationDefault() +{ MyView->SetViewOrientation(MyViewOrientation) ; MyView->SetViewOrientationDefault() ; ImmediateUpdate(); } -void V3d_View::ResetViewOrientation() { - +void V3d_View::ResetViewOrientation() +{ MyView->ViewOrientationReset() ; MyViewOrientation = MyView->ViewOrientation() ; ImmediateUpdate(); } -void V3d_View::Reset( const Standard_Boolean update ) { - +void V3d_View::Reset( const Standard_Boolean update ) +{ MyView->ViewOrientationReset() ; MyViewOrientation = MyView->ViewOrientation() ; MyView->ViewMappingReset(); @@ -1529,12 +1434,10 @@ void V3d_View::Reset( const Standard_Boolean update ) { #else ImmediateUpdate(); #endif - } void V3d_View::Panning(const Standard_Real Dx, const Standard_Real Dy, const Quantity_Factor aZoomFactor, const Standard_Boolean Start) { - Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp,Dxv,Dyv ; Viewer_BadValue_Raise_if( aZoomFactor <= 0.,"V3d_View::Panning, bad zoom factor"); @@ -1561,16 +1464,17 @@ void V3d_View::Panning(const Standard_Real Dx, const Standard_Real Dy, const Qua } MyView->SetViewMapping(MyViewMapping) ; ImmediateUpdate(); - } -void V3d_View::SetCenter(const Standard_Integer X, const Standard_Integer Y) { + +void V3d_View::SetCenter(const Standard_Integer X, const Standard_Integer Y) +{ Standard_Real x,y; Convert(X,Y,x,y); SetCenter(x,y); } -void V3d_View::SetCenter(const Standard_Real Xc, const Standard_Real Yc){ - +void V3d_View::SetCenter(const Standard_Real Xc, const Standard_Real Yc) +{ Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Zrp ; MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ; @@ -1590,12 +1494,10 @@ void V3d_View::SetCenter(const Standard_Real Xc, const Standard_Real Yc){ } MyView->SetViewMapping(MyViewMapping) ; ImmediateUpdate(); - } void V3d_View::SetSize(const Standard_Real Size) { - Standard_Real Umin,Vmin,Umax,Vmax,Rap ; Viewer_BadValue_Raise_if( Size <= 0., @@ -1620,12 +1522,10 @@ void V3d_View::SetSize(const Standard_Real Size) MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ; MyView->SetViewMapping(MyViewMapping) ; ImmediateUpdate(); - } void V3d_View::SetZSize(const Standard_Real Size) { - Standard_Real Zmax = Size/2.; #ifdef IMP020300 @@ -1657,17 +1557,16 @@ void V3d_View::SetZSize(const Standard_Real Size) MyView->SetViewMapping(MyViewMapping) ; if( MyViewContext.FrontZClippingIsOn() || - MyViewContext.BackZClippingIsOn() ) { - MyViewContext.SetZClippingFrontPlane(Front) ; - MyViewContext.SetZClippingBackPlane(Back) ; - MyView->SetContext(MyViewContext) ; - } - + MyViewContext.BackZClippingIsOn() ) + { + MyViewContext.SetZClippingFrontPlane(Front) ; + MyViewContext.SetZClippingBackPlane(Back) ; + MyView->SetContext(MyViewContext) ; + } } void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start) { - Standard_Real Umin,Vmin,Umax,Vmax,Dxv,Dyv ; Viewer_BadValue_Raise_if( Coef <= 0.,"V3d_View::SetZoom, bad coefficient"); @@ -1699,7 +1598,8 @@ void V3d_View::SetZoom(const Standard_Real Coef,const Standard_Boolean Start) ImmediateUpdate(); } -void V3d_View::SetScale( const Standard_Real Coef ) { +void V3d_View::SetScale( const Standard_Real Coef ) +{ Standard_Real Umin,Vmin,Umax,Vmax,Xrp,Yrp,Dxv,Dyv ; Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ; @@ -1715,11 +1615,10 @@ void V3d_View::SetScale( const Standard_Real Coef ) { MyViewMapping.SetWindowLimit(Umin,Vmin,Umax,Vmax) ; MyView->SetViewMapping(MyViewMapping) ; ImmediateUpdate(); - } -void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz ) { - +void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz ) +{ Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ; Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ; Viewer_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient"); @@ -1766,7 +1665,6 @@ void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, co if( Wmax > 0. ) { SetZSize(2.*Wmax + Wmax) ; } - } void V3d_View::FitAll(const Standard_Real Coef, const Standard_Boolean FitZ, @@ -1949,8 +1847,8 @@ void V3d_View::FitAll(const Standard_Real Coef, const Standard_Boolean FitZ, #endif } -void V3d_View::ZFitAll(const Standard_Real Coef) { - +void V3d_View::ZFitAll(const Standard_Real Coef) +{ Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ; Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ; // CAL 6/11/98 @@ -2078,18 +1976,21 @@ void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect, ImmediateUpdate(); } -void V3d_View::FitAll(const Standard_Real Xmin, const Standard_Real Ymin, const Standard_Real Xmax, const Standard_Real Ymax) { +void V3d_View::FitAll(const Standard_Real Xmin, const Standard_Real Ymin, const Standard_Real Xmax, const Standard_Real Ymax) +{ FitAll(MyWindow,Xmin,Ymin,Xmax,Ymax); #ifndef IMP020300 ImmediateUpdate(); #endif } -void V3d_View::WindowFitAll(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) { +void V3d_View::WindowFitAll(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) +{ WindowFit(Xmin,Ymin,Xmax,Ymax); - } -void V3d_View::WindowFit(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) { + +void V3d_View::WindowFit(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) +{ Standard_Real x1,y1,x2,y2; Convert(Xmin,Ymin,x1,y1); Convert(Xmax,Ymax,x2,y2); @@ -2110,14 +2011,15 @@ void V3d_View::SetViewMapping(const Visual3d_ViewMapping& VM) ImmediateUpdate(); } -void V3d_View::SetViewMappingDefault() { +void V3d_View::SetViewMappingDefault() +{ MyView->SetViewMapping(MyViewMapping) ; MyView->SetViewMappingDefault(); ImmediateUpdate(); } -void V3d_View::ResetViewMapping() { - +void V3d_View::ResetViewMapping() +{ MyView->ViewMappingReset(); MyViewMapping = MyView->ViewMapping() ; #ifdef IMP020300 @@ -2128,7 +2030,8 @@ void V3d_View::ResetViewMapping() { #endif } -Standard_Real V3d_View::Convert(const Standard_Integer Vp) const { +Standard_Real V3d_View::Convert(const Standard_Integer Vp) const +{ Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Vv ; Standard_Integer Dxw,Dyw ; @@ -2142,7 +2045,8 @@ Standard_Real V3d_View::Convert(const Standard_Integer Vp) const { return Vv ; } -void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xv, Standard_Real& Yv) const { +void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xv, Standard_Real& Yv) const +{ Standard_Real Umin,Umax,Vmin,Vmax,Dxv,Dyv ; Standard_Integer Dxw,Dyw ; @@ -2186,8 +2090,8 @@ void V3d_View::Convert(const Standard_Real Xv, const Standard_Real Yv, Standard_ Yp = Dyw - RealToInt (Dyw*(Yv - Vmin)/Dyv); } -void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { - +void V3d_View::Convert(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ Graphic3d_Vertex Vrp ; Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ; Vrp.Coord(X,Y,Z) ; @@ -2215,8 +2119,8 @@ void V3d_View::ConvertWithProj(const Standard_Integer Xp, const Standard_Integer } #ifdef IMP240100 -void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const { - +void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const +{ Graphic3d_Vertex Vrp ; Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ; if( MyViewer->Grid()->IsActive() ) { @@ -2226,8 +2130,8 @@ void V3d_View::ConvertToGrid(const Standard_Integer Xp, const Standard_Integer Y Vrp.Coord(Xg,Yg,Zg) ; } -void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const { - +void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Real& Xg, Standard_Real& Yg, Standard_Real& Zg) const +{ if( MyViewer->Grid()->IsActive() ) { Graphic3d_Vertex Vrp(X,Y,Z) ; Graphic3d_Vertex NewVrp = Compute(Vrp) ; @@ -2239,8 +2143,8 @@ void V3d_View::ConvertToGrid(const Standard_Real X, const Standard_Real Y, const #endif #ifndef IMP240100 -void V3d_View::PixToRef(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { - +void V3d_View::PixToRef(const Standard_Integer Xp, const Standard_Integer Yp, Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ Graphic3d_Vertex Vrp ; Vrp = (MyViewer->Viewer())->ConvertCoord(MyWindow,Xp,Yp) ; Vrp.Coord(X,Y,Z) ; @@ -2252,11 +2156,11 @@ void V3d_View::PixToRef(const Standard_Integer Xp, const Standard_Integer Yp, St #endif #ifdef IMP240100 -void V3d_View::Convert(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const { +void V3d_View::Convert(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const #else -void V3d_View::RefToPix(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const { +void V3d_View::RefToPix(const Standard_Real X, const Standard_Real Y, const Standard_Real Z, Standard_Integer& Xp, Standard_Integer& Yp) const #endif - +{ Graphic3d_Vertex Vrp(X,Y,Z) ; (MyViewer->Viewer())->ConvertCoord(MyWindow,Vrp,Xp,Yp) ; } @@ -2278,33 +2182,29 @@ void V3d_View::Project(const Standard_Real X, const Standard_Real Y, const Stand } } -void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,Standard_Real& V1, Standard_Real& V2, Standard_Real& V3)const { - -#ifdef GER61351 +void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,Standard_Real& V1, Standard_Real& V2, Standard_Real& V3) const +{ Quantity_Color C = BackgroundColor() ; -#else - Quantity_Color C ; - C = MyBackground.Color() ; -#endif C.Values(V1,V2,V3,Type) ; } -#ifdef GER61351 -Quantity_Color V3d_View::BackgroundColor() const { - +Quantity_Color V3d_View::BackgroundColor() const +{ return MyBackground.Color() ; } -#endif -void V3d_View::GradientBackgroundColors(Quantity_Color& Color1,Quantity_Color& Color2) const{ +void V3d_View::GradientBackgroundColors(Quantity_Color& Color1,Quantity_Color& Color2) const +{ MyGradientBackground.Colors(Color1, Color2); } -Aspect_GradientBackground V3d_View::GradientBackground() const { +Aspect_GradientBackground V3d_View::GradientBackground() const +{ return MyGradientBackground; } -Standard_Real V3d_View::Scale()const { +Standard_Real V3d_View::Scale() const +{ Standard_Real Umin,Vmin,Umax,Vmax,Dxv ; Visual3d_ViewMapping VMD = MyView->ViewMappingDefault() ; Standard_Real S = 0. ; @@ -2316,12 +2216,13 @@ Standard_Real V3d_View::Scale()const { return S ; } -void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz)const { +void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const +{ MyViewOrientation.AxialScale( Sx, Sy, Sz ); } -void V3d_View::Center(Standard_Real& Xc, Standard_Real& Yc) const { - +void V3d_View::Center(Standard_Real& Xc, Standard_Real& Yc) const +{ Standard_Real Umin,Vmin,Umax,Vmax ; MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ; @@ -2329,8 +2230,8 @@ void V3d_View::Center(Standard_Real& Xc, Standard_Real& Yc) const { Yc = (Vmin + Vmax)/2. ; } -void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const { - +void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const +{ Standard_Real Umin,Vmin,Umax,Vmax ; MyViewMapping.WindowLimit(Umin,Vmin,Umax,Vmax) ; @@ -2338,8 +2239,8 @@ void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const { Height = Vmax - Vmin ; } -Standard_Real V3d_View::ZSize() const { - +Standard_Real V3d_View::ZSize() const +{ Standard_Real Wmin,Wmax,Depth ; Wmax = MyViewMapping.FrontPlaneDistance() ; @@ -2348,8 +2249,8 @@ Standard_Real V3d_View::ZSize() const { return (Depth) ; } -Standard_Integer V3d_View::MinMax(Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const { - +Standard_Integer V3d_View::MinMax(Standard_Real& Umin, Standard_Real& Vmin, Standard_Real& Umax, Standard_Real& Vmax) const +{ Standard_Real Wmin,Wmax,U,V,W ; Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax ; // CAL 6/11/98 @@ -2387,7 +2288,8 @@ Standard_Integer V3d_View::MinMax(Standard_Real& Umin, Standard_Real& Vmin, Stan return Nstruct ; } -Standard_Integer V3d_View::MinMax(Standard_Real& Xmin, Standard_Real& Ymin, Standard_Real& Zmin, Standard_Real& Xmax, Standard_Real& Ymax, Standard_Real& Zmax) const { +Standard_Integer V3d_View::MinMax(Standard_Real& Xmin, Standard_Real& Ymin, Standard_Real& Zmin, Standard_Real& Xmax, Standard_Real& Ymax, Standard_Real& Zmax) const +{ // CAL 6/11/98 // Standard_Integer Nstruct = (MyView->DisplayedStructures())->Extent() ; Standard_Integer Nstruct = MyView->NumberOfDisplayedStructures() ; @@ -2398,8 +2300,8 @@ Standard_Integer V3d_View::MinMax(Standard_Real& Xmin, Standard_Real& Ymin, Stan return Nstruct ; } -Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { - +Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W ; Standard_Real Umin,Vmin,Umax,Vmax ; Standard_Integer Nstruct,Npoint ; @@ -2463,7 +2365,8 @@ Standard_Integer V3d_View::Gravity(Standard_Real& X, Standard_Real& Y, Standard_ return Nstruct ; } -void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { +void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ Graphic3d_Vertex Prp ; Graphic3d_Vector Vpn ; Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xat,Yat,Zat ; @@ -2477,8 +2380,8 @@ void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { X = Zrp*Xpn + Xat; Y = Zrp*Ypn + Yat; Z = Zrp*Zpn + Zat; } -void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_Real& Z) const { - +void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_Real& Z) const +{ Graphic3d_Vertex PRP,VRPoint; Graphic3d_Vector VRPlane; Standard_Real FPD,Xprp,Yprp,Zprp; @@ -2499,8 +2402,8 @@ void V3d_View::FocalReferencePoint(Standard_Real& X, Standard_Real& Y,Standard_R else Eye(X,Y,Z); } -void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, const Standard_Integer Ypix, Standard_Real& XP, Standard_Real& YP, Standard_Real& ZP, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ) const { - +void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, const Standard_Integer Ypix, Standard_Real& XP, Standard_Real& YP, Standard_Real& ZP, Standard_Real& VX, Standard_Real& VY, Standard_Real& VZ) const +{ Standard_Real Xo,Yo,Zo; Convert(Xpix,Ypix,XP,YP,ZP); @@ -2515,8 +2418,8 @@ void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix, const Standard_Inte } } - -Standard_Real V3d_View::Depth() const { +Standard_Real V3d_View::Depth() const +{ Graphic3d_Vertex Prp ; Standard_Real Xrp,Yrp,Zrp ; @@ -2525,28 +2428,32 @@ Standard_Real V3d_View::Depth() const { return Zrp ; } -void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const { +void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const +{ Graphic3d_Vector Vpn ; Vpn = MyViewOrientation.ViewReferencePlane() ; Vpn.Coord(Dx,Dy,Dz) ; } -void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const { +void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const +{ Graphic3d_Vertex Vrp ; Vrp = MyViewOrientation.ViewReferencePoint() ; Vrp.Coord(X,Y,Z) ; } -void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const { +void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const +{ Graphic3d_Vector Vup ; Vup = MyViewOrientation.ViewReferenceUp() ; Vup.Coord(Vx,Vy,Vz) ; } -Standard_Real V3d_View::Twist()const { +Standard_Real V3d_View::Twist() const +{ Standard_Real Xup,Yup,Zup,Xpn,Ypn,Zpn,X0,Y0,Z0 ; Standard_Real pvx,pvy,pvz,pvn,sca,angle ; Graphic3d_Vector Vpn,Vup,Xaxis,Yaxis,Zaxis ; @@ -2586,53 +2493,60 @@ Standard_Real V3d_View::Twist()const { return angle ; } -V3d_TypeOfShadingModel V3d_View::ShadingModel()const { +V3d_TypeOfShadingModel V3d_View::ShadingModel() const +{ V3d_TypeOfShadingModel SM = (V3d_TypeOfShadingModel)MyViewContext.Model() ; return SM ; } -V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail()const { +V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail() const +{ V3d_TypeOfSurfaceDetail SM = (V3d_TypeOfSurfaceDetail)MyViewContext.SurfaceDetail() ; return SM ; } - -Handle_Graphic3d_TextureEnv V3d_View::TextureEnv() const { +Handle_Graphic3d_TextureEnv V3d_View::TextureEnv() const +{ Handle(Graphic3d_TextureEnv) SM = MyViewContext.TextureEnv() ; return SM ; } -V3d_TypeOfVisualization V3d_View::Visualization()const { +V3d_TypeOfVisualization V3d_View::Visualization() const +{ V3d_TypeOfVisualization V = (V3d_TypeOfVisualization)MyViewContext.Visualization() ; return V ; } -Standard_Boolean V3d_View::Antialiasing()const { +Standard_Boolean V3d_View::Antialiasing() const +{ Standard_Boolean A = MyViewContext.AliasingIsOn() ; return A ; } -Handle(V3d_Viewer) V3d_View::Viewer() const { +Handle(V3d_Viewer) V3d_View::Viewer() const +{ return MyViewer ; } -Standard_Boolean V3d_View::IfWindow() const { +Standard_Boolean V3d_View::IfWindow() const +{ Standard_Boolean TheStatus = MyView->IsDefined() ; return TheStatus ; } -Handle(Aspect_Window) V3d_View::Window() const { +Handle(Aspect_Window) V3d_View::Window() const +{ return MyWindow; } -V3d_TypeOfView V3d_View::Type() const { - +V3d_TypeOfView V3d_View::Type() const +{ return (MyType) ; } -void V3d_View::SetFocale( const Standard_Real focale ) { - +void V3d_View::SetFocale( const Standard_Real focale ) +{ Standard_TypeMismatch_Raise_if (MyType != V3d_PERSPECTIVE, "the view is not a perspective view"); Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ; @@ -2651,7 +2565,8 @@ void V3d_View::SetFocale( const Standard_Real focale ) { ImmediateUpdate(); } -Standard_Real V3d_View::Focale( ) const { +Standard_Real V3d_View::Focale( ) const +{ Standard_Real Xrp,Yrp,Zrp,ViewPlane,FrontPlane ; Standard_Real focale = 0.0 ; Graphic3d_Vertex Prp ; @@ -2725,7 +2640,8 @@ Visual3d_ViewOrientation V3d_View::ViewOrientation() const return MyViewOrientation; } -Standard_Boolean V3d_View::ScreenAxis( const Graphic3d_Vector &Vpn, const Graphic3d_Vector &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe) { +Standard_Boolean V3d_View::ScreenAxis( const Graphic3d_Vector &Vpn, const Graphic3d_Vector &Vup, Graphic3d_Vector &Xaxe, Graphic3d_Vector &Yaxe, Graphic3d_Vector &Zaxe) +{ Standard_Real Xpn,Ypn,Zpn,Xup,Yup,Zup ; Standard_Real dx1,dy1,dz1,dx2,dy2,dz2,xx,yy,zz ; @@ -2752,7 +2668,8 @@ Standard_Boolean V3d_View::ScreenAxis( const Graphic3d_Vector &Vpn, const Graphi return Standard_True ; } -void V3d_View::InitMatrix( TColStd_Array2OfReal& Matrix ) { +void V3d_View::InitMatrix( TColStd_Array2OfReal& Matrix ) +{ Standard_Integer LR = Matrix.LowerRow() ; Standard_Integer UR = Matrix.UpperRow() ; Standard_Integer LC = Matrix.LowerCol() ; @@ -2765,8 +2682,8 @@ void V3d_View::InitMatrix( TColStd_Array2OfReal& Matrix ) { for( I=LR,J=LC ; I<=UR ; I++,J++ ) Matrix(I,J) = 1. ; } -Standard_Boolean V3d_View::Multiply (const TColStd_Array2OfReal& Left, const TColStd_Array2OfReal& Right, TColStd_Array2OfReal& Matrix) { - +Standard_Boolean V3d_View::Multiply (const TColStd_Array2OfReal& Left, const TColStd_Array2OfReal& Right, TColStd_Array2OfReal& Matrix) +{ Standard_Integer llr = Left.LowerRow (); Standard_Integer llc = Left.LowerCol (); Standard_Integer luc = Left.UpperCol (); @@ -2819,7 +2736,8 @@ Standard_Boolean V3d_View::Multiply (const TColStd_Array2OfReal& Left, const TCo /*----------------------------------------------------------------------*/ -void V3d_View::RotAxis( const Graphic3d_Vertex &Vrp, const Graphic3d_Vector &Axe, const Standard_Real angle, TColStd_Array2OfReal& Matrix ) { +void V3d_View::RotAxis( const Graphic3d_Vertex &Vrp, const Graphic3d_Vector &Axe, const Standard_Real angle, TColStd_Array2OfReal& Matrix ) +{ Standard_Real Xrp,Yrp,Zrp,Xaxe,Yaxe,Zaxe ; Standard_Real sina,cosa,cos1m,terms1,terms2,terms3 ; Standard_Real termc12,termc13,termc23,vcal ; @@ -2873,7 +2791,8 @@ void V3d_View::RotAxis( const Graphic3d_Vertex &Vrp, const Graphic3d_Vector &Axe /*----------------------------------------------------------------------*/ -Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix ) { +Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Array2OfReal &Matrix ) +{ Graphic3d_Vertex PP ; Standard_Real X,Y,Z,XX,YY,ZZ ; @@ -2901,7 +2820,8 @@ Graphic3d_Vertex V3d_View::TrsPoint( const Graphic3d_Vertex &P, const TColStd_Ar return PP ; } -Graphic3d_Vector V3d_View::TrsPoint( const Graphic3d_Vector& V, const TColStd_Array2OfReal& Matrix ) { +Graphic3d_Vector V3d_View::TrsPoint( const Graphic3d_Vector& V, const TColStd_Array2OfReal& Matrix ) +{ Graphic3d_Vector VV ; Standard_Real X,Y,Z,XX,YY,ZZ ; @@ -2924,11 +2844,9 @@ Graphic3d_Vector V3d_View::TrsPoint( const Graphic3d_Vector& V, const TColStd_Ar return VV ; } - -void V3d_View::Pan(const Standard_Integer Dx, const Standard_Integer Dy,const Quantity_Factor aZoomFactor) { - +void V3d_View::Pan(const Standard_Integer Dx, const Standard_Integer Dy,const Quantity_Factor aZoomFactor) +{ Panning(Convert(Dx),Convert(Dy),aZoomFactor,Standard_True); - } void V3d_View::Zoom (const Standard_Integer X1, @@ -3206,7 +3124,8 @@ void V3d_View::SetAnimationModeOff () { #endif } -Standard_Boolean V3d_View::AnimationModeIsOn () const { +Standard_Boolean V3d_View::AnimationModeIsOn () const +{ return MyView->AnimationModeIsOn(); } @@ -3217,7 +3136,6 @@ void V3d_View :: SetAnimationMode const Standard_Boolean aDegenerationFlag ) { - if ( anAnimationFlag ) MyAnimationFlags |= V3d_FLAG_ANIMATION; else @@ -3232,13 +3150,13 @@ void V3d_View :: SetAnimationMode Standard_Boolean V3d_View::AnimationMode( Standard_Boolean& isDegenerate ) const { - isDegenerate = MyAnimationFlags & V3d_FLAG_DEGENERATION; return MyAnimationFlags & V3d_FLAG_ANIMATION; } #endif -void V3d_View::SetDegenerateModeOn() { +void V3d_View::SetDegenerateModeOn() +{ #ifdef G003 SetComputedMode(Standard_False); #else @@ -3271,7 +3189,6 @@ Standard_Boolean V3d_View::DegenerateModeIsOn() const #ifdef G003 void V3d_View :: SetComputedMode ( const Standard_Boolean aMode ) { - if( aMode ) { if( myComputedMode ) { MyView -> SetComputedMode ( Standard_True ); @@ -3281,44 +3198,42 @@ void V3d_View :: SetComputedMode ( const Standard_Boolean aMode ) MyView -> SetComputedMode ( Standard_False ); Update (); } - -} // end V3d_View :: SetComputedMode +} Standard_Boolean V3d_View :: ComputedMode () const { - return MyView -> ComputedMode (); +} -} // end V3d_View :: ComputedMode - -void V3d_View :: SetBackFacingModel ( - const V3d_TypeOfBackfacingModel aModel) +void V3d_View :: SetBackFacingModel (const V3d_TypeOfBackfacingModel aModel) { - MyView -> SetBackFacingModel ( Visual3d_TypeOfBackfacingModel(aModel) ); Redraw(); -} // end V3d_View :: SetBackFacingModel - -V3d_TypeOfBackfacingModel V3d_View :: BackFacingModel () const { +} +V3d_TypeOfBackfacingModel V3d_View :: BackFacingModel () const +{ return V3d_TypeOfBackfacingModel(MyView -> BackFacingModel ()); - -} // end V3d_View :: BackFacingModel +} #endif -Standard_Boolean V3d_View::TransientManagerBeginDraw(const Standard_Boolean DoubleBuffer,const Standard_Boolean RetainMode) const { +Standard_Boolean V3d_View::TransientManagerBeginDraw(const Standard_Boolean DoubleBuffer,const Standard_Boolean RetainMode) const +{ return Visual3d_TransientManager::BeginDraw(MyView,DoubleBuffer,RetainMode); } -void V3d_View::TransientManagerClearDraw() const { +void V3d_View::TransientManagerClearDraw() const +{ Visual3d_TransientManager::ClearDraw(MyView); } -Standard_Boolean V3d_View::TransientManagerBeginAddDraw() const { +Standard_Boolean V3d_View::TransientManagerBeginAddDraw() const +{ return Visual3d_TransientManager::BeginAddDraw(MyView); } -void V3d_View::Init() { +void V3d_View::Init() +{ myComputedMode = MyViewer->ComputedMode(); #ifdef G003 if( !myComputedMode || !MyViewer->DefaultComputedMode() ) { @@ -3337,24 +3252,21 @@ void V3d_View::Init() { if ( env_walkthrow.Value () != "" ) MyProjModel = V3d_TPM_WALKTHROUGH; else MyProjModel = V3d_TPM_SCREEN; #endif - } -void V3d_View::SetPlotter(const Handle(Graphic3d_Plotter)& aPlotter) { +void V3d_View::SetPlotter(const Handle(Graphic3d_Plotter)& aPlotter) +{ MyPlotter = aPlotter; } void V3d_View::Plot() { - Viewer_BadValue_Raise_if( !MyPlotter.IsNull(), "view has no plotter"); - MyView->Plot(MyPlotter); } Standard_Real V3d_View::Tumble (const Standard_Integer NbImages, const Standard_Boolean AnimationMode) { - FullTimer.Reset (); FullTimer.Start (); @@ -3387,7 +3299,6 @@ Standard_Real V3d_View::Tumble (const Standard_Integer NbImages, const Standard_ << endl; return NbImages/CPUtime; - } #define SCREENCOPY_FILENAME "screencopy3d.gif" diff --git a/src/V3d/V3d_View_4.cxx b/src/V3d/V3d_View_4.cxx index b0b049ce1e..d73e42571f 100755 --- a/src/V3d/V3d_View_4.cxx +++ b/src/V3d/V3d_View_4.cxx @@ -60,80 +60,29 @@ * Constant */ -// in case NO_TRACE_ECHO and NO_TRACE_POINTS, in V3d_View_4.cxx and -// V3d_View.cxx, suspend MyGridEchoStructure and MyGridEchoGroup in cdl -#define TRACE_ECHO -#define NO_TRACE_VALUES -#define NO_TRACE_POINTS - #define MYEPSILON1 0.0001 // Comparison with 0.0 #define MYEPSILON2 M_PI / 180. // Delta between 2 angles -#ifdef TRACE_POINTS -#include -#include -#endif - -#ifdef TRACE_VALUES -#include -#endif - -#if defined TRACE_VALUES || defined TRACE_POINTS -static char *CAR [26] = {"a", "b", "c", "d", "e", "f", "g", "h", - "i", "j", "k", "l", "m", "n", "o", "p", - "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; -#endif - /*----------------------------------------------------------------------*/ -void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid) { - +void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid) +{ MyPlane = aPlane; MyGrid = aGrid; -#ifdef TRACE_VALUES - if (MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid))) { - cout << "Aspect_RectangularGrid" << endl; -Handle(Aspect_RectangularGrid) theGrid = *(Handle(Aspect_RectangularGrid) *) &MyGrid; - cout << "\tOrigine : " << theGrid->XOrigin () << ", " - << theGrid->YOrigin () << endl; - cout << "\tAngle : " << theGrid->RotationAngle () << endl; - cout << "\tSteps : " << theGrid->XStep () << ", " - << theGrid->YStep () << endl; - } - else { - cout << "Aspect_CircularGrid" << endl; -Handle(Aspect_CircularGrid) theGrid = *(Handle(Aspect_CircularGrid) *) &MyGrid; - cout << "\tOrigine : " << theGrid->XOrigin () << ", " - << theGrid->YOrigin () << endl; - cout << "\tAngle : " << theGrid->RotationAngle () << endl; - cout << "\tRadiusStep, Division : " << theGrid->RadiusStep () - << ", " << theGrid->DivisionNumber () << endl; - } - -#endif - -Standard_Real xl, yl, zl; -Standard_Real xdx, xdy, xdz; -Standard_Real ydx, ydy, ydz; -Standard_Real dx, dy, dz; + Standard_Real xl, yl, zl; + Standard_Real xdx, xdy, xdz; + Standard_Real ydx, ydy, ydz; + Standard_Real dx, dy, dz; aPlane.Location ().Coord (xl, yl, zl); aPlane.XDirection ().Coord (xdx, xdy, xdz); aPlane.YDirection ().Coord (ydx, ydy, ydz); aPlane.Direction ().Coord (dx, dy, dz); -#ifdef TRACE_VALUES -cout << "Grid Plane " << xl << ", " << yl << ", " << zl << endl; -cout << "\tLocation " << xl << ", " << yl << ", " << zl << endl; -cout << "\tDirection " << dx << ", " << dy << ", " << dz << endl; -cout << "\tXDirection " << xdx << ", " << xdy << ", " << xdz << endl; -cout << "\tYDirection " << ydx << ", " << ydy << ", " << ydz << endl; -#endif - -Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ()); -Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ()); + Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ()); + Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ()); -TColStd_Array2OfReal Trsf1 (1, 4, 1, 4); + TColStd_Array2OfReal Trsf1 (1, 4, 1, 4); Trsf1 (4, 4) = 1.0; Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0; // Translation @@ -151,7 +100,7 @@ TColStd_Array2OfReal Trsf1 (1, 4, 1, 4); Trsf1 (2, 3) = dy, Trsf1 (3, 3) = dz; -TColStd_Array2OfReal Trsf2 (1, 4, 1, 4); + TColStd_Array2OfReal Trsf2 (1, 4, 1, 4); Trsf2 (4, 4) = 1.0; Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0; // Translation of the origin @@ -169,10 +118,10 @@ TColStd_Array2OfReal Trsf2 (1, 4, 1, 4); Trsf2 (2, 3) = 0.0, Trsf2 (3, 3) = 1.0; -Standard_Real valuetrsf; -Standard_Real valueoldtrsf; -Standard_Real valuenewtrsf; -Standard_Integer i, j, k; + Standard_Real valuetrsf; + Standard_Real valueoldtrsf; + Standard_Real valuenewtrsf; + Standard_Integer i, j, k; // Calculation of the product of matrices for (i=1; i<=4; i++) for (j=1; j<=4; j++) { @@ -184,125 +133,52 @@ Standard_Integer i, j, k; MyTrsf (i, j) = valuenewtrsf; } } - } -void V3d_View::SetGridActivity (const Standard_Boolean AFlag) { - +void V3d_View::SetGridActivity (const Standard_Boolean AFlag) +{ if (AFlag) MyGrid->Activate (); else MyGrid->Deactivate (); - } -void V3d_View::SetGridGraphicValues (const Handle(Aspect_Grid)& -#ifdef TRACE_VALUES - aGrid -#endif - ) { - -#ifdef TRACE_VALUES -Standard_Real XSize, YSize, Radius, OffSet; - if (aGrid->IsKind (STANDARD_TYPE (V3d_RectangularGrid))) { - cout << "V3d_RectangularGrid" << endl; -Handle(V3d_RectangularGrid) theGrid = *(Handle(V3d_RectangularGrid) *) &aGrid; - theGrid->GraphicValues (XSize, YSize, OffSet); - cout << "\tSizes : " << XSize << ", " << YSize << endl; - cout << "\tOffSet : " << OffSet << endl; - } - else { - cout << "V3d_CircularGrid" << endl; -Handle(V3d_CircularGrid) theGrid = *(Handle(V3d_CircularGrid) *) &aGrid; - theGrid->GraphicValues (Radius, OffSet); - cout << "\tRadius : " << Radius << endl; - cout << "\tOffSet : " << OffSet << endl; - } -#endif - +void V3d_View::SetGridGraphicValues (const Handle(Aspect_Grid)& ) +{ } -Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const { - -Graphic3d_Vertex CurPoint, NewPoint; -Standard_Real X1, Y1, Z1, X2, Y2, Z2; -Standard_Real XPp, YPp; +Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex & AVertex) const +{ + Graphic3d_Vertex CurPoint, NewPoint; + Standard_Real X1, Y1, Z1, X2, Y2, Z2; + Standard_Real XPp, YPp; MyView->ViewOrientation ().ViewReferencePlane ().Coord (X1, Y1, Z1); MyPlane.Direction ().Coord (X2, Y2, Z2); -gp_Dir VPN (X1, Y1, Z1); -gp_Dir GPN (X2, Y2, Z2); - -#ifdef TRACE_VALUES - cout << "View Plane : " << X1 << ", " << Y1 << ", " << Z1 << endl; - cout << "Grid Plane " << X2 << ", " << Y2 << ", " << Z2 << endl; - cout << "Angle VPN GPN : " << VPN.Angle (GPN) << endl; -#endif + gp_Dir VPN (X1, Y1, Z1); + gp_Dir GPN (X2, Y2, Z2); AVertex.Coord (X1, Y1, Z1); Project (X1, Y1, Z1, XPp, YPp); -#ifdef TRACE_VALUES - cout << "AVertex : " << X1 << ", " << Y1 << ", " << Z1 << endl; -#endif - // Casw when the plane of the grid and the plane of the view // are perpendicular to MYEPSILON2 close radians if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2) { NewPoint.SetCoord (X1, Y1, Z1); -#ifdef TRACE_POINTS - TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED)); - MyGridEchoGroup->SetPrimitivesAspect (TextAttrib); - MyGridEchoGroup->Text ("Q", NewPoint, 1./81.); - MyGridEchoGroup->Polyline (AVertex, NewPoint); - Update (); -#endif #ifdef IMP240100 MyViewer->ShowGridEcho(this,NewPoint); -#else -#ifdef TRACE_ECHO -char *trace_echo = NULL; - trace_echo = (char *)(getenv ("CSF_GraphicEcho")); - if (trace_echo) { - MyGridEchoGroup->Clear (); - MyGridEchoGroup->Marker (NewPoint); - Visual3d_TransientManager::BeginDraw - (MyView, Standard_False, Standard_False); - Visual3d_TransientManager::DrawStructure (MyGridEchoStructure); - Visual3d_TransientManager::EndDraw (Standard_True); - } -#endif #endif //IMP240100 return NewPoint; } -#ifdef TRACE_POINTS -Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d (); -Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d (); - - MyGridEchoGroup->Clear (); - - LineAttrib->SetColor (Quantity_Color (Quantity_NOC_RED)); - MyGridEchoGroup->SetGroupPrimitivesAspect (LineAttrib); - - TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED)); - MyGridEchoGroup->SetGroupPrimitivesAspect (TextAttrib); - - MyGridEchoGroup->Text ("P", AVertex, 1./81.); - CurPoint.SetCoord (AVertex.X (), AVertex.Y (), AVertex.Z ()); - - TextAttrib->SetColor (Quantity_Color (Quantity_NOC_GREEN)); - MyGridEchoGroup->SetPrimitivesAspect (TextAttrib); -#endif - -Standard_Boolean IsRectangular = + Standard_Boolean IsRectangular = MyGrid->IsKind (STANDARD_TYPE (Aspect_RectangularGrid)); -Graphic3d_Vertex P1; + Graphic3d_Vertex P1; -Standard_Real XO = 0.0, YO = 0.0; -Standard_Real XOp, YOp; -Standard_Real XAp, YAp; -Standard_Real XBp, YBp; + Standard_Real XO = 0.0, YO = 0.0; + Standard_Real XOp, YOp; + Standard_Real XAp, YAp; + Standard_Real XBp, YBp; X1 = XO, Y1 = YO, Z1 = 0.0; // MyTrsf * Point to return to the plane of 3D grid @@ -312,18 +188,9 @@ Standard_Real XBp, YBp; Project (X2, Y2, Z2, XOp, YOp); XPp = XPp - XOp, YPp = YPp - YOp; -#ifdef TRACE_POINTS - MyGridEchoGroup->Text ("O", CurPoint, 1./81.); -#endif - -#ifdef TRACE_VALUES - cout << "Projection de P : " << XPp << ", " << YPp << endl; - cout << "Projection de O : " << XOp << ", " << YOp << endl; -#endif - - if (IsRectangular) { -Standard_Real XS, YS; -Handle(Aspect_RectangularGrid) theGrid = + if (IsRectangular) { + Standard_Real XS, YS; + Handle(Aspect_RectangularGrid) theGrid = *(Handle(Aspect_RectangularGrid) *) &MyGrid; XS = theGrid->XStep (), YS = theGrid->YStep (); @@ -335,10 +202,6 @@ Handle(Aspect_RectangularGrid) theGrid = Project (X2, Y2, Z2, XAp, YAp); XAp = XAp - XOp, YAp = YAp - YOp; -#ifdef TRACE_POINTS - MyGridEchoGroup->Text ("A", CurPoint, 1./81.); -#endif - X1 = XO, Y1 = YO + YS, Z1 = 0.0; // MyTrsf * Point to return to the plane of 3D grid P1.SetCoord (X1, Y1, Z1); @@ -347,16 +210,7 @@ Handle(Aspect_RectangularGrid) theGrid = Project (X2, Y2, Z2, XBp, YBp); XBp = XBp - XOp, YBp = YBp - YOp; -#ifdef TRACE_POINTS - MyGridEchoGroup->Text ("B", CurPoint, 1./81.); -#endif - -#ifdef TRACE_VALUES - cout << "Projection de A : " << XAp << ", " << YAp << endl; - cout << "Projection de B : " << XBp << ", " << YBp << endl; -#endif - -Standard_Real Determin = XAp*YBp - XBp*YAp; + Standard_Real Determin = XAp*YBp - XBp*YAp; Z1 = 0.0; if (Abs (Determin) > MYEPSILON1) { @@ -368,41 +222,35 @@ Standard_Real Determin = XAp*YBp - XBp*YAp; Y1 = (Y1 > 0. ? Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS : - Standard_Real (Standard_Integer (Abs (Y1)+0.5)) * YS); -#ifdef TRACE_VALUES - cout << "Chosen point : " << X1 << ", " << Y1 << endl; -#endif // MyTrsf * Point to return to the plane of 3D grid P1.SetCoord (X1, Y1, Z1); CurPoint = V3d_View::TrsPoint (P1, MyTrsf); CurPoint.Coord (X2, Y2, Z2); } else { -cout << "*****************" << endl; -cout << "Zero Determinant!" << endl; -cout << "*****************" << endl; -#ifdef TRACE_VALUES - cout << "Zero Determinant !" << endl; -#endif + //cout << "*****************" << endl; + //cout << "Zero Determinant!" << endl; + //cout << "*****************" << endl; AVertex.Coord (X2, Y2, Z2); CurPoint.SetCoord (X2, Y2, Z2); } } // IsRectangular - else { -Standard_Real RS; -Standard_Integer DN; -Standard_Real Alpha; -Handle(Aspect_CircularGrid) theGrid = + else { + Standard_Real RS; + Standard_Integer DN; + Standard_Real Alpha; + Handle(Aspect_CircularGrid) theGrid = *(Handle(Aspect_CircularGrid) *) &MyGrid; RS = theGrid->RadiusStep (); DN = theGrid->DivisionNumber (); Alpha = M_PI / Standard_Real (DN); -Standard_Real DistOP = Sqrt (XPp*XPp + YPp*YPp); + Standard_Real DistOP = Sqrt (XPp*XPp + YPp*YPp); -Standard_Integer i, ICur=0; -Standard_Real Angle, AngleCur; -Standard_Real XCurp=0, YCurp=0; -gp_Dir2d OP (XPp, YPp); + Standard_Integer i, ICur=0; + Standard_Real Angle, AngleCur; + Standard_Real XCurp=0, YCurp=0; + gp_Dir2d OP (XPp, YPp); AngleCur = 2 * M_PI; for (i=1; i<=DN*2; i++) { X1 = XO + Cos (Alpha * i) * RS, @@ -420,33 +268,20 @@ gp_Dir2d OP (XPp, YPp); ICur = i; AngleCur = Angle; XCurp = XAp, YCurp = YAp; -#ifdef TRACE_VALUES - cout << "Angle between OP and O" << CAR [i-1] - << " : " << Angle << endl; -#endif } -#ifdef TRACE_POINTS - MyGridEchoGroup->Text (CAR [i-1], CurPoint, 1./81.); -#endif } // for (i=1; i<=DN*2; i++) -Standard_Real DistOCur = Sqrt (XCurp*XCurp + YCurp*YCurp); + Standard_Real DistOCur = Sqrt (XCurp*XCurp + YCurp*YCurp); // Determination of the circle of the grid closest to P -Standard_Integer N = Standard_Integer (DistOP / DistOCur + 0.5); -Standard_Real Radius = N * RS; -#ifdef TRACE_VALUES - cout << "Circle : " << N << " Radius : " << Radius << endl; -#endif + Standard_Integer N = Standard_Integer (DistOP / DistOCur + 0.5); + Standard_Real Radius = N * RS; X1 = Cos (Alpha * ICur) * Radius, Y1 = Sin (Alpha * ICur) * Radius, Z1 = 0.0; -#ifdef TRACE_VALUES - cout << "Chosen Point : " << X1 << ", " << Y1 << endl; -#endif // MyTrsf * Point to return to the plane of 3D grid P1.SetCoord (X1, Y1, Z1); CurPoint = V3d_View::TrsPoint (P1, MyTrsf); @@ -455,28 +290,8 @@ Standard_Real Radius = N * RS; NewPoint.SetCoord (CurPoint.X (), CurPoint.Y (), CurPoint.Z ()); -#ifdef TRACE_POINTS - TextAttrib->SetColor (Quantity_Color (Quantity_NOC_RED)); - MyGridEchoGroup->SetPrimitivesAspect (TextAttrib); - MyGridEchoGroup->Text ("Q", NewPoint, 1./81.); - MyGridEchoGroup->Polyline (AVertex, NewPoint); - Update (); -#endif #ifdef IMP240100 MyViewer->ShowGridEcho(this,NewPoint); -#else -#ifdef TRACE_ECHO -char *trace_echo = NULL; - trace_echo = (char *)(getenv ("CSF_GraphicEcho")); - if (trace_echo) { - MyGridEchoGroup->Clear (); - MyGridEchoGroup->Marker (NewPoint); - Visual3d_TransientManager::BeginDraw - (MyView, Standard_False, Standard_False); - Visual3d_TransientManager::DrawStructure (MyGridEchoStructure); - Visual3d_TransientManager::EndDraw (Standard_True); - } -#endif #endif //IMP240100 return NewPoint; } @@ -494,18 +309,18 @@ void V3d_View::ZBufferTriedronSetup(const Quantity_NameOfColor XColor, } void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, - const Quantity_NameOfColor AColor, const Standard_Real AScale, const V3d_TypeOfVisualization AMode ) { - + const Quantity_NameOfColor AColor, const Standard_Real AScale, const V3d_TypeOfVisualization AMode ) +{ MyView->TriedronDisplay (APosition, AColor, AScale, (AMode == V3d_WIREFRAME)); } -void V3d_View::TriedronErase ( ) { - +void V3d_View::TriedronErase ( ) +{ MyView->TriedronErase ( ); } -void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) { - +void V3d_View::TriedronEcho (const Aspect_TypeOfTriedronEcho AType ) +{ MyView->TriedronEcho (AType); } diff --git a/src/V3d/V3d_View_5.cxx b/src/V3d/V3d_View_5.cxx index 4e7aa5c0f3..06212e9a8a 100755 --- a/src/V3d/V3d_View_5.cxx +++ b/src/V3d/V3d_View_5.cxx @@ -33,42 +33,28 @@ */ #include -#define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing - from higher API */ -#define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting - from higher API */ +//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API +//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API void V3d_View::EnableDepthTest( const Standard_Boolean enable ) const { -#ifdef BUC61044 MyView->EnableDepthTest( enable ); -#endif } Standard_Boolean V3d_View::IsDepthTestEnabled() const { -#ifdef BUC61044 return MyView->IsDepthTestEnabled(); -#else - return Standard_True; -#endif } void V3d_View::EnableGLLight( const Standard_Boolean enable ) const { -#ifdef BUC61045 MyView->EnableGLLight( enable ); -#endif } Standard_Boolean V3d_View::IsGLLightEnabled() const { -#ifdef BUC61045 return MyView->IsGLLightEnabled(); -#else - return Standard_True; -#endif } void V3d_View::SetLayerMgr(const Handle(V3d_LayerMgr)& aMgr) diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index 25b46ca31c..393489b780 100755 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -31,8 +31,7 @@ ************************************************************************/ -#define GER61351 //GG_15/12/99 Adds SetDefaultBackgroundColor() -// and DefaultBackgroundColor() methods +//GER61351 //GG_15/12/99 Adds SetDefaultBackgroundColor() and DefaultBackgroundColor() methods #define IMP240100 //GG // Initalize grid echo fields @@ -202,29 +201,19 @@ void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_TypeOfColor Type, cons if( V3 < 0. ) V3 = 0. ; else if( V3 > 1. ) V3 = 1. ; Quantity_Color C(V1,V2,V3,Type) ; -#ifdef GER61351 SetDefaultBackgroundColor(C); -#else - MyBackground.SetColor(C) ; -#endif } -void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_NameOfColor Name) { - +void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_NameOfColor Name) +{ Quantity_Color C(Name) ; -#ifdef GER61351 SetDefaultBackgroundColor(C); -#else - MyBackground.SetColor(C) ; -#endif } -#ifdef GER61351 -void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_Color &Color) { - +void V3d_Viewer::SetDefaultBackgroundColor(const Quantity_Color &Color) +{ MyBackground.SetColor(Color) ; } -#endif void V3d_Viewer::SetDefaultBgGradientColors( const Quantity_NameOfColor Name1, const Quantity_NameOfColor Name2, @@ -290,23 +279,19 @@ void V3d_Viewer::SetUpdateMode(const V3d_TypeOfUpdate Mode) { MyViewer->SetUpdateMode((Aspect_TypeOfUpdate)Mode) ; } -void V3d_Viewer::DefaultBackgroundColor(const Quantity_TypeOfColor Type,Standard_Real &V1,Standard_Real &V2,Standard_Real &V3) const { - -#ifdef GER61351 +void V3d_Viewer::DefaultBackgroundColor(const Quantity_TypeOfColor Type,Standard_Real &V1,Standard_Real &V2,Standard_Real &V3) const +{ Quantity_Color C = DefaultBackgroundColor(); -#else - Quantity_Color C = MyBackground.Color() ; -#endif C.Values(V1,V2,V3,Type) ; } -#ifdef GER61351 -Quantity_Color V3d_Viewer::DefaultBackgroundColor() const { +Quantity_Color V3d_Viewer::DefaultBackgroundColor() const +{ return MyBackground.Color() ; } -#endif -void V3d_Viewer::DefaultBgGradientColors(Quantity_Color& Color1,Quantity_Color& Color2) const{ +void V3d_Viewer::DefaultBgGradientColors(Quantity_Color& Color1,Quantity_Color& Color2) const +{ MyGradientBackground.Colors(Color1,Color2); } diff --git a/src/V3d/V3d_Viewer_3.cxx b/src/V3d/V3d_Viewer_3.cxx index 028a1e89e3..beedf4ffa9 100755 --- a/src/V3d/V3d_Viewer_3.cxx +++ b/src/V3d/V3d_Viewer_3.cxx @@ -49,7 +49,7 @@ #include #include -#include +#include /*----------------------------------------------------------------------*/ /* @@ -84,39 +84,34 @@ return ZLetter; /*----------------------------------------------------------------------*/ -void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) { +void V3d_Viewer::SetPrivilegedPlane(const gp_Ax3& aPlane) +{ myPrivilegedPlane = aPlane; -#ifdef IMP240300 Grid()->SetDrawMode(Grid()->DrawMode()); - for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) { + for (InitActiveViews (); MoreActiveViews (); NextActiveViews ()) ActiveView ()->SetGrid (myPrivilegedPlane, Grid ()); - } -#endif - if(myDisplayPlane) { - Standard_Real s = myDisplayPlaneLength; - DisplayPrivilegedPlane(Standard_True,s); -#ifdef IMP240300 - } else { - Update(); -#else + if(myDisplayPlane) + DisplayPrivilegedPlane(Standard_True,myDisplayPlaneLength); + else Update(); -#endif - } } /*----------------------------------------------------------------------*/ -gp_Ax3 V3d_Viewer::PrivilegedPlane() const { + +gp_Ax3 V3d_Viewer::PrivilegedPlane() const +{ return myPrivilegedPlane; - } /*----------------------------------------------------------------------*/ -void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quantity_Length aSize) { - Standard_Boolean Change = myDisplayPlane != OnOff; +void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quantity_Length aSize) +{ + Standard_Boolean Change = (myDisplayPlane != OnOff); myDisplayPlane = OnOff; myDisplayPlaneLength = aSize; - if(myDisplayPlane) { + if(myDisplayPlane) + { if(myPlaneStructure.IsNull()) { myPlaneStructure = new Graphic3d_Structure(MyViewer); myPlaneStructure->SetInfiniteState(Standard_True); @@ -124,9 +119,8 @@ void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quan } else myPlaneStructure->Clear(); - -// Handle(Graphic3d_Structure) thePlaneStructure = new Graphic3d_Structure(MyViewer); - Handle(Graphic3d_Group) Group = new Graphic3d_Group(myPlaneStructure) ; + + Handle(Graphic3d_Group) Group = new Graphic3d_Group(myPlaneStructure); Handle(Graphic3d_AspectLine3d) LineAttrib = new Graphic3d_AspectLine3d() ; LineAttrib->SetColor(Quantity_Color(Quantity_NOC_GRAY60)); @@ -135,39 +129,33 @@ void V3d_Viewer::DisplayPrivilegedPlane(const Standard_Boolean OnOff, const Quan Handle(Graphic3d_AspectText3d) TextAttrib = new Graphic3d_AspectText3d(); TextAttrib->SetColor(Quantity_Color(Quantity_NOC_ROYALBLUE1)); Group->SetPrimitivesAspect(TextAttrib); + + Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); + + const gp_Pnt &p0 = myPrivilegedPlane.Location(); + + const gp_Pnt pX(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.XDirection().XYZ()); + aPrims->AddVertex(p0); + aPrims->AddVertex(pX); + Group->Text(XLetter.ToCString(),Graphic3d_Vertex(pX.X(),pX.Y(),pX.Z()),1./81.); + + const gp_Pnt pY(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.YDirection().XYZ()); + aPrims->AddVertex(p0); + aPrims->AddVertex(pY); + Group->Text(YLetter.ToCString(),Graphic3d_Vertex(pY.X(),pY.Y(),pY.Z()),1./81.); - Graphic3d_Array1OfVertex Points(0,1) ; - Standard_Real xl,yl,zl; - myPrivilegedPlane.Location().Coord(xl,yl,zl); - Points(0).SetCoord(xl,yl,zl); - - Standard_Real ay,by,cy; - - myPrivilegedPlane.XDirection().Coord(ay,by,cy); - Points(1).SetCoord(xl+myDisplayPlaneLength*ay, - yl+myDisplayPlaneLength*by, - zl+myDisplayPlaneLength*cy); - Group->Polyline(Points); - Group->Text(XLetter.ToCString(),Points(1),1./81.); - - myPrivilegedPlane.YDirection().Coord(ay,by,cy); - Points(1).SetCoord(xl+myDisplayPlaneLength*ay, - yl+myDisplayPlaneLength*by, - zl+myDisplayPlaneLength*cy); - Group->Polyline(Points); - Group->Text(YLetter.ToCString(),Points(1),1./81.); - - myPrivilegedPlane.Direction().Coord(ay,by,cy); - Points(1).SetCoord(xl+myDisplayPlaneLength*ay, - yl+myDisplayPlaneLength*by, - zl+myDisplayPlaneLength*cy); - Group->Polyline(Points); - Group->Text(ZLetter.ToCString(),Points(1),1./81.); -#ifdef IMP240300 - myPlaneStructure->Display(); - } else { + const gp_Pnt pZ(p0.XYZ() + myDisplayPlaneLength*myPrivilegedPlane.Direction().XYZ()); + aPrims->AddVertex(p0); + aPrims->AddVertex(pZ); + Group->Text(ZLetter.ToCString(),Graphic3d_Vertex(pZ.X(),pZ.Y(),pZ.Z()),1./81.); + + Group->AddPrimitiveArray(aPrims); + + myPlaneStructure->Display(); + } + else + { if( !myPlaneStructure.IsNull() ) myPlaneStructure->Erase(); -#endif } if(Change) Update(); } diff --git a/src/V3d/V3d_Viewer_4.cxx b/src/V3d/V3d_Viewer_4.cxx index 6830bb4da6..d2b47c2332 100755 --- a/src/V3d/V3d_Viewer_4.cxx +++ b/src/V3d/V3d_Viewer_4.cxx @@ -211,7 +211,7 @@ void V3d_Viewer::ShowGridEcho( const Handle(V3d_View)& aView, } static Graphic3d_Vertex lastVertex; - if( Graphic3d_Vertex::Distance(aVertex,lastVertex) != 0.0 ) { + if( aVertex.Distance(lastVertex) != 0.0 ) { lastVertex = aVertex; myGridEchoGroup->Clear(); #ifdef OCC281 diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 28b72e7c7e..0af0617f48 100755 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2257,7 +2257,6 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha #include #include #include -#include #include #include #include @@ -2389,9 +2388,7 @@ void MyTextClass::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentat Graphic3d_Vertex vertices_text; vertices_text.SetCoord(aPosition.X(),aPosition.Y(),aPosition.Y()); TheGroup->SetPrimitivesAspect(aspect); - TheGroup->BeginPrimitives(); TheGroup->Text(aText,vertices_text,aHeight,Standard_True); - TheGroup->EndPrimitives(); */ }; @@ -2489,7 +2486,6 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** #include #include #include -#include #include #include #include @@ -3205,11 +3201,7 @@ void MyPArrayObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPrese const Standard_Integer aMode) { aPresentation->Clear(); - - Handle (Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation); - aGroup->BeginPrimitives (); - aGroup->AddPrimitiveArray (myArray); - aGroup->EndPrimitives (); + Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (myArray); } static bool CheckInputCommand (const TCollection_AsciiString theCommand, diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index c8e33cce2f..4866531b56 100755 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -91,12 +91,10 @@ #define RIC120302 //GG Add a NEW SetWindow method which enable // to connect a graphic widget and context to OGL. -#define BUC61044 /* 25/10/01 SAV ; added functionality to control gl depth testing - from higher API */ -#define BUC61045 /* 25/10/01 SAV ; added functionality to control gl lighting - from higher API */ +//BUC61044 25/10/01 SAV ; added functionality to control gl depth testing from higher API +//BUC61045 25/10/01 SAV ; added functionality to control gl lighting from higher API -#define OCC1188 //SAV Added methods to set background image +//OCC1188 SAV Added methods to set background image /*----------------------------------------------------------------------*/ /* @@ -995,7 +993,6 @@ void Visual3d_View::SetBackgroundImage( const Standard_CString FileName, const Aspect_FillMethod FillStyle, const Standard_Boolean update ) { -#ifdef OCC1188 if ( IsDeleted() ) return; if ( !IsDefined() ) @@ -1007,13 +1004,11 @@ void Visual3d_View::SetBackgroundImage( const Standard_CString FileName, Update(); else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) Update(); -#endif } void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle, const Standard_Boolean update ) { -#ifdef OCC1188 if ( IsDeleted() ) return; if ( !IsDefined() ) @@ -1025,7 +1020,6 @@ void Visual3d_View::SetBgImageStyle( const Aspect_FillMethod FillStyle, Update(); else if ( MyViewManager->UpdateMode() == Aspect_TOU_ASAP ) Update(); -#endif } Aspect_Background Visual3d_View::Background () const { @@ -4190,18 +4184,12 @@ Visual3d_TypeOfBackfacingModel Visual3d_View :: BackFacingModel () const { void Visual3d_View::EnableDepthTest( const Standard_Boolean enable ) const { -#ifdef BUC61044 MyGraphicDriver->SetDepthTestEnabled( MyCView, enable ); -#endif } Standard_Boolean Visual3d_View::IsDepthTestEnabled() const { -#ifdef BUC61044 return MyGraphicDriver->IsDepthTestEnabled( MyCView ); -#else - return Standard_True; -#endif } void Visual3d_View::ReadDepths(const Standard_Integer x, @@ -4248,19 +4236,13 @@ Standard_Boolean Visual3d_View::BufferDump (Image_PixMap& theImage void Visual3d_View::EnableGLLight( const Standard_Boolean enable ) const { -#ifdef BUC61045 MyGraphicDriver->SetGLLightEnabled( MyCView, enable ); -#endif } Standard_Boolean Visual3d_View::IsGLLightEnabled() const { -#ifdef BUC61045 return MyGraphicDriver->IsGLLightEnabled( MyCView ); -#else - return Standard_True; -#endif } Standard_Boolean Visual3d_View::Export (const Standard_CString theFileName, diff --git a/src/XCAFPrs/XCAFPrs_AISObject.cxx b/src/XCAFPrs/XCAFPrs_AISObject.cxx index 60d430fc56..4e579b928f 100755 --- a/src/XCAFPrs/XCAFPrs_AISObject.cxx +++ b/src/XCAFPrs/XCAFPrs_AISObject.cxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/3rdparty/export/A7 b/tests/3rdparty/export/A7 index 750628d49b..c31233fd87 100644 --- a/tests/3rdparty/export/A7 +++ b/tests/3rdparty/export/A7 @@ -34,4 +34,4 @@ set aFile $imagedir/ExportToPGF.pgf set format PGF -set size 21886 +set size 20398 -- 2.20.1