Integration of OCCT 6.5.0 from SVN
[occt.git] / src / DsgPrs / DsgPrs_IdenticPresentation.cxx
CommitLineData
7fd59977 1// File: DsgPrs_IdenticPresentation.cxx
2// Created: Fri Jan 3 18:05:10 1997
3// Author: Flore Lantheaume
4// <fla@chariox.paris1.matra-dtv.fr>
5
6
7#include <DsgPrs_IdenticPresentation.ixx>
8
9#include <Graphic3d_Group.hxx>
10#include <Graphic3d_Array1OfVertex.hxx>
11#include <Graphic3d_AspectMarker3d.hxx>
12#include <Graphic3d_AspectLine3d.hxx>
13
14#include <Prs3d_LineAspect.hxx>
15#include <Prs3d_LengthAspect.hxx>
16#include <Prs3d_Text.hxx>
17
18#include <TCollection_AsciiString.hxx>
19
20#include <gp_Vec.hxx>
21#include <gp_Dir.hxx>
22
23#include <ElCLib.hxx>
24
25#include <Precision.hxx>
26#include <gp_Elips.hxx>
27
28void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
29 const Handle(Prs3d_Drawer)& aDrawer,
30 const TCollection_ExtendedString& aText,
31 const gp_Pnt& aPntAttach,
32 const gp_Pnt& aPntOffset)
33{
34 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
35 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
36
37 Graphic3d_Array1OfVertex V(1,2);
38 V(1).SetCoord(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
39 V(2).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
40
41 // trait de cote
42 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
43
44 // On ajoute un rond au point d'attache
45 Prs3d_Root::NewGroup(aPresentation);
46 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
47 Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
48 MarkerAsp->SetType(Aspect_TOM_BALL);
49 MarkerAsp->SetScale(0.8);
50 Quantity_Color acolor;
51 Aspect_TypeOfLine atype;
52 Standard_Real awidth;
53 LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
54 MarkerAsp->SetColor(acolor);
55 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
56 Graphic3d_Vertex V3d(aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z());
57 Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
58
59 // texte
60 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
61}
62
63
64
65void DsgPrs_IdenticPresentation::Add( const Handle(Prs3d_Presentation)& aPresentation,
66 const Handle(Prs3d_Drawer)& aDrawer,
67 const TCollection_ExtendedString& aText,
68 const gp_Pnt& aFAttach,
69 const gp_Pnt& aSAttach,
70 const gp_Pnt& aPntOffset)
71{
72 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
73 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
74
75 Graphic3d_Array1OfVertex V(1,2);
76 V(1).SetCoord(aFAttach.X(), aFAttach.Y(), aFAttach.Z());
77 V(2).SetCoord(aSAttach.X(), aSAttach.Y(), aSAttach.Z());
78
79 // trait de cote
80 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
81
82 // trait joignant aPntOffset
83 Prs3d_Root::NewGroup(aPresentation);
84 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
85 gp_Vec v1(aFAttach, aSAttach);
86 gp_Vec v2(aSAttach, aPntOffset);
87 V(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
88 if ( !v1.IsParallel(v2, Precision::Angular())) {
89 // on joint aPntOffset a son projete
90 gp_Lin ll(aFAttach, gp_Dir(v1));
91 gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(ll,aPntOffset ), ll);
92 V(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z());
93 }
94 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
95
96 // texte
97 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
98}
99
100
101
102void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
103 const Handle(Prs3d_Drawer)& aDrawer,
104 const TCollection_ExtendedString& aText,
105 const gp_Ax2& theAxe,
106 const gp_Pnt& aCenter,
107 const gp_Pnt& aFAttach,
108 const gp_Pnt& aSAttach,
109 const gp_Pnt& aPntOffset)
110{
111 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
112 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
113
114 gp_Ax2 ax = theAxe;
115 ax.SetLocation(aCenter);
116 Standard_Real rad = aCenter.Distance(aFAttach);
117 gp_Circ CC(ax,rad );
118 Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach);
119 Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach);
120 Standard_Real alpha = pSAttach - pFAttach;
121 if ( alpha < 0 ) alpha += 2*Standard_PI;
122 Standard_Integer nb = (Standard_Integer )( 50. * alpha / PI);
123 Standard_Integer nbp = Max (4 , nb);
124 Graphic3d_Array1OfVertex V(1,nbp);
125 Standard_Real dteta = alpha/(nbp-1);
126 gp_Pnt ptcur;
127 for (Standard_Integer i = 1; i<=nbp; i++)
128 {
129 ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC);
130 V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
131 }
132
133 // trait de cote
134 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
135
136 // trait joignant aPntOffset
137 Prs3d_Root::NewGroup(aPresentation);
138 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
139 Graphic3d_Array1OfVertex V2(1,2);
140 if ( Abs((aPntOffset.Distance(aCenter) - rad )) >= Precision::Confusion() ) {
141 gp_Pnt ProjPntOffset = ElCLib::Value(ElCLib::Parameter(CC,aPntOffset ), CC);
142
143 V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
144 V2(2).SetCoord(ProjPntOffset.X(), ProjPntOffset.Y(), ProjPntOffset.Z());
145 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
146 }
147
148 // texte
149 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
150}
151
152// jfa 16/10/2000
153void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
154 const Handle(Prs3d_Drawer)& aDrawer,
155 const TCollection_ExtendedString& aText,
156 const gp_Ax2& theAxe,
157 const gp_Pnt& aCenter,
158 const gp_Pnt& aFAttach,
159 const gp_Pnt& aSAttach,
160 const gp_Pnt& aPntOffset,
161 const gp_Pnt& aPntOnCirc)
162{
163 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
164 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
165
166 gp_Ax2 ax = theAxe;
167 ax.SetLocation(aCenter);
168 Standard_Real rad = aCenter.Distance(aFAttach);
169 gp_Circ CC(ax,rad );
170 Standard_Real pFAttach = ElCLib::Parameter(CC, aFAttach);
171 Standard_Real pSAttach = ElCLib::Parameter(CC, aSAttach);
172 Standard_Real alpha = pSAttach - pFAttach;
173 if ( alpha < 0 ) alpha += 2*Standard_PI;
174 Standard_Integer nb = (Standard_Integer )( 50. * alpha / PI);
175 Standard_Integer nbp = Max (4 , nb);
176 Graphic3d_Array1OfVertex V(1,nbp);
177 Standard_Real dteta = alpha/(nbp-1);
178 gp_Pnt ptcur;
179 for (Standard_Integer i = 1; i<=nbp; i++)
180 {
181 ptcur = ElCLib::Value(pFAttach + dteta*(i-1),CC);
182 V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
183 }
184
185 // trait de cote
186 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
187
188 // trait joignant aPntOffset
189 Prs3d_Root::NewGroup(aPresentation);
190 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
191 Graphic3d_Array1OfVertex V2(1,2);
192 if ( aPntOffset.Distance(aPntOnCirc) >= Precision::Confusion() )
193 {
194 V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
195 V2(2).SetCoord(aPntOnCirc.X(), aPntOnCirc.Y(), aPntOnCirc.Z());
196 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
197 }
198
199 // texte
200 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
201}
202// jfa 16/10/2000 end
203
204// jfa 10/10/2000
205void DsgPrs_IdenticPresentation::Add(const Handle(Prs3d_Presentation)& aPresentation,
206 const Handle(Prs3d_Drawer)& aDrawer,
207 const TCollection_ExtendedString& aText,
208 const gp_Elips& anEllipse,
209 const gp_Pnt& aFAttach,
210 const gp_Pnt& aSAttach,
211 const gp_Pnt& aPntOffset,
212 const gp_Pnt& aPntOnElli)
213{
214 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
215 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
216
217 Standard_Real pFAttach = ElCLib::Parameter(anEllipse, aFAttach);
218 Standard_Real pSAttach = ElCLib::Parameter(anEllipse, aSAttach);
219 Standard_Real alpha = pSAttach - pFAttach;
220 if ( alpha < 0 ) alpha += 2*Standard_PI;
221 Standard_Integer nb = (Standard_Integer)(50.0*alpha/PI);
222 Standard_Integer nbp = Max (4 , nb);
223 Graphic3d_Array1OfVertex V(1,nbp);
224 Standard_Real dteta = alpha/(nbp-1);
225 gp_Pnt ptcur;
226 for (Standard_Integer i = 1; i<=nbp; i++)
227 {
228 ptcur = ElCLib::Value(pFAttach + dteta*(i-1),anEllipse);
229 V(i).SetCoord(ptcur.X(),ptcur.Y(),ptcur.Z());
230 }
231
232 // trait de cote
233 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
234
235 // trait joignant aPntOffset
236 Prs3d_Root::NewGroup(aPresentation);
237 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
238 Graphic3d_Array1OfVertex V2(1,2);
239
240 if ( ! aPntOnElli.IsEqual(aPntOffset, Precision::Confusion()) )
241 {
242 V2(1).SetCoord(aPntOffset.X(), aPntOffset.Y(), aPntOffset.Z());
243 V2(2).SetCoord(aPntOnElli.X(), aPntOnElli.Y(), aPntOnElli.Z());
244 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V2);
245 }
246
247 // texte
248 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,aPntOffset);
249}
250// jfa 10/10/2000 end