7fd59977 |
1 | // File: DsgPrs_FilletRadiusPresentation.cxx |
2 | // Created: Mon Dec 8 12:00:59 1997 |
3 | // Author: Serguei ZARITCHNY |
4 | // <xab@zozox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <DsgPrs_FilletRadiusPresentation.ixx> |
8 | |
9 | #include <gp_Lin.hxx> |
10 | #include <gp_Dir.hxx> |
11 | #include <ElCLib.hxx> |
12 | #include <Graphic3d_Group.hxx> |
13 | #include <Graphic3d_Array1OfVertex.hxx> |
14 | #include <Prs3d_LengthAspect.hxx> |
15 | #include <Prs3d_Arrow.hxx> |
16 | #include <Prs3d_ArrowAspect.hxx> |
17 | #include <Prs3d_LineAspect.hxx> |
18 | #include <Prs3d_Text.hxx> |
19 | #include <TCollection_AsciiString.hxx> |
20 | #include <TCollection_ExtendedString.hxx> |
21 | |
22 | #include <ElCLib.hxx> |
23 | |
24 | #include <Graphic3d_Vertex.hxx> |
25 | #include <Graphic3d_AspectMarker3d.hxx> |
26 | #include <Graphic3d_AspectLine3d.hxx> |
27 | #include <Aspect_TypeOfLine.hxx> |
28 | #include <Aspect_TypeOfMarker.hxx> |
29 | #include <Aspect_AspectMarker.hxx> |
30 | #include <Quantity_Color.hxx> |
31 | #include <DsgPrs.hxx> |
32 | #include <Precision.hxx> |
33 | |
34 | #include <Geom_Circle.hxx> |
35 | #include <Geom_Line.hxx> |
36 | #include <GeomAPI_ExtremaCurveCurve.hxx> |
37 | |
38 | //pop pour NT |
39 | //#if WNT |
40 | #include <stdio.h> |
41 | //#endif |
42 | //======================================================================= |
43 | //function : Add |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, |
48 | const Handle(Prs3d_Drawer)& aDrawer, |
49 | const Standard_Real theval, |
50 | const TCollection_ExtendedString & aText, |
51 | const gp_Pnt & aPosition, |
52 | const gp_Dir & aNormalDir, |
53 | const gp_Pnt & aBasePnt, |
54 | const gp_Pnt & aFirstPoint, |
55 | const gp_Pnt & aSecondPoint, |
56 | const gp_Pnt & aCenter, |
57 | const DsgPrs_ArrowSide ArrowPrs, |
58 | const Standard_Boolean drawRevers, |
59 | gp_Pnt & DrawPosition, |
60 | gp_Pnt & EndOfArrow, |
61 | Handle(Geom_TrimmedCurve)& TrimCurve, |
62 | Standard_Boolean & HasCircle ) |
63 | { |
64 | char valcar[80]; |
65 | sprintf(valcar,"%5.2f",theval); |
66 | Standard_Real FirstParCirc, LastParCirc; |
67 | Standard_Boolean SpecCase; |
68 | gp_Dir DirOfArrow; |
69 | gp_Circ FilletCirc; |
70 | // gp_Pnt NewPosition, EndOfArrow; |
71 | Handle( Prs3d_LengthAspect ) LA = aDrawer->LengthAspect(); |
72 | Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() ); |
73 | Standard_Real ArrowLength = LA->Arrow1Aspect()->Length(); |
74 | DsgPrs::ComputeFilletRadiusPresentation( ArrowLength, |
75 | theval, |
76 | aPosition, |
77 | aNormalDir, |
78 | aFirstPoint, |
79 | aSecondPoint, |
80 | aCenter, |
81 | aBasePnt, |
82 | drawRevers, |
83 | SpecCase, |
84 | FilletCirc, |
85 | FirstParCirc, |
86 | LastParCirc, |
87 | EndOfArrow, |
88 | DirOfArrow, |
89 | DrawPosition //NewPosition |
90 | ); |
91 | // Creating the fillet's arc |
92 | if( !SpecCase ) |
93 | { |
94 | Standard_Real Alpha = Abs(LastParCirc - FirstParCirc); |
c6541a0c |
95 | Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI)); |
7fd59977 |
96 | Graphic3d_Array1OfVertex ApproxArc( 0, NodeNumber-1 ); |
97 | Standard_Real delta = Alpha / ( NodeNumber - 1 ); |
98 | gp_Pnt CurPnt; |
99 | for (Standard_Integer i = 0 ; i < NodeNumber; i++) |
100 | { |
101 | CurPnt = ElCLib::Value( FirstParCirc, FilletCirc ); |
102 | ApproxArc(i).SetCoord( CurPnt.X(), CurPnt.Y(), CurPnt.Z() ); |
103 | FirstParCirc += delta ; |
104 | } |
105 | Prs3d_Root::CurrentGroup( aPresentation )->Polyline( ApproxArc ); |
106 | HasCircle = Standard_True; |
107 | Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc ); |
108 | TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc ); |
109 | } |
110 | else // null or PI anle or Radius = 0 |
111 | { |
112 | HasCircle = Standard_False; |
113 | } |
114 | |
115 | // Line from position to intersection point on fillet's circle (EndOfArrow) |
116 | Graphic3d_Array1OfVertex Vrap(1,2); |
117 | Vrap(1).SetCoord(DrawPosition.X(), |
118 | DrawPosition.Y(), |
119 | DrawPosition.Z()); |
120 | Vrap(2).SetCoord( EndOfArrow.X(), EndOfArrow.Y(), EndOfArrow.Z() ); |
121 | Prs3d_Root::CurrentGroup( aPresentation )->Polyline( Vrap ); |
122 | // Drawing the text |
123 | Prs3d_Text::Draw(aPresentation, LA->TextAspect(), aText, DrawPosition); |
124 | |
125 | // Add presentation of arrows |
126 | DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs ); |
127 | |
128 | } |
129 | |