1 // Created on: 1997-12-08
2 // Created by: Serguei ZARITCHNY
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <DsgPrs_FilletRadiusPresentation.hxx>
21 #include <Geom_Circle.hxx>
22 #include <Geom_Line.hxx>
23 #include <Geom_TrimmedCurve.hxx>
24 #include <GeomAPI_ExtremaCurveCurve.hxx>
28 #include <Graphic3d_ArrayOfPolylines.hxx>
29 #include <Graphic3d_ArrayOfSegments.hxx>
30 #include <Graphic3d_AspectLine3d.hxx>
31 #include <Graphic3d_AspectMarker3d.hxx>
32 #include <Graphic3d_Group.hxx>
33 #include <Precision.hxx>
34 #include <Prs3d_Arrow.hxx>
35 #include <Prs3d_ArrowAspect.hxx>
36 #include <Prs3d_DimensionAspect.hxx>
37 #include <Prs3d_LineAspect.hxx>
38 #include <Prs3d_Presentation.hxx>
39 #include <Prs3d_Text.hxx>
40 #include <TCollection_AsciiString.hxx>
41 #include <TCollection_ExtendedString.hxx>
44 //=======================================================================
47 //=======================================================================
48 void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
49 const Handle(Prs3d_Drawer)& aDrawer,
50 const Standard_Real theval,
51 const TCollection_ExtendedString & aText,
52 const gp_Pnt & aPosition,
53 const gp_Dir & aNormalDir,
54 const gp_Pnt & aBasePnt,
55 const gp_Pnt & aFirstPoint,
56 const gp_Pnt & aSecondPoint,
57 const gp_Pnt & aCenter,
58 const DsgPrs_ArrowSide ArrowPrs,
59 const Standard_Boolean drawRevers,
60 gp_Pnt & DrawPosition,
62 Handle(Geom_TrimmedCurve)& TrimCurve,
63 Standard_Boolean & HasCircle )
66 sprintf(valcar,"%5.2f",theval);
68 Standard_Real FirstParCirc, LastParCirc;
69 Standard_Boolean SpecCase;
72 // gp_Pnt NewPosition, EndOfArrow;
73 Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect();
74 Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
76 Standard_Real ArrowLength = LA->ArrowAspect()->Length();
77 DsgPrs::ComputeFilletRadiusPresentation( ArrowLength,
92 DrawPosition //NewPosition
94 // Creating the fillet's arc
97 const Standard_Real Alpha = Abs(LastParCirc - FirstParCirc);
98 const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI));
99 const Standard_Real delta = Alpha / ( NodeNumber - 1 );
101 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber);
102 for (Standard_Integer i = 0 ; i < NodeNumber; i++, FirstParCirc += delta)
103 aPrims->AddVertex(ElCLib::Value( FirstParCirc, FilletCirc ));
104 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
106 HasCircle = Standard_True;
107 Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc );
108 TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc );
110 else // null or PI anle or Radius = 0
112 HasCircle = Standard_False;
115 // Line from position to intersection point on fillet's circle (EndOfArrow)
116 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
117 aPrims->AddVertex(DrawPosition);
118 aPrims->AddVertex(EndOfArrow);
119 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
122 Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (aPresentation), LA->TextAspect(), aText, DrawPosition);
124 // Add presentation of arrows
125 DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs );