0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / DsgPrs / DsgPrs_ParalPresentation.cxx
CommitLineData
7fd59977 1// File: DsgPrs_ParalPresentation.cxx
2// Created: Tue Nov 28 10:14:40 1995
3// Author: Jean-Pierre COMBE
4// <jpi>
5
6
7#include <DsgPrs_ParalPresentation.ixx>
8#include <gp_Lin.hxx>
9#include <gp_Dir.hxx>
10#include <ElCLib.hxx>
11#include <gce_MakeLin.hxx>
12#include <Graphic3d_Group.hxx>
13#include <Graphic3d_Array1OfVertex.hxx>
14#include <Prs3d_Arrow.hxx>
15#include <Prs3d_ArrowAspect.hxx>
16#include <Prs3d_LineAspect.hxx>
17#include <Prs3d_LengthAspect.hxx>
18#include <TCollection_AsciiString.hxx>
19#include <Graphic3d_AspectLine3d.hxx>
20#include <Prs3d_Text.hxx>
21#include <DsgPrs.hxx>
22
23void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
24 const Handle(Prs3d_Drawer)& aDrawer,
25 const TCollection_ExtendedString& aText,
26 const gp_Pnt& AttachmentPoint1,
27 const gp_Pnt& AttachmentPoint2,
28 const gp_Dir& aDirection,
29 const gp_Pnt& OffsetPoint) {
30
31
32 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
33 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
34 gp_Lin L1 (AttachmentPoint1,aDirection);
35 gp_Lin L2 (AttachmentPoint2,aDirection);
36 gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
37 gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
38 gp_Lin L3 = gce_MakeLin(Proj1,Proj2);
39 Standard_Real parmin,parmax,parcur;
40 parmin = ElCLib::Parameter(L3,Proj1);
41 parmax = parmin;
42 parcur = ElCLib::Parameter(L3,Proj2);
43 Standard_Real dist = Abs(parmin-parcur);
44 if (parcur < parmin) parmin = parcur;
45 if (parcur > parmax) parmax = parcur;
46 parcur = ElCLib::Parameter(L3,OffsetPoint);
47 gp_Pnt offp = ElCLib::Value(parcur,L3);
48
49 Standard_Boolean outside = Standard_False;
50 if (parcur < parmin) {
51 parmin = parcur;
52 outside = Standard_True;
53 }
54 if (parcur > parmax) {
55 parmax = parcur;
56 outside = Standard_True;
57 }
58
59 gp_Pnt PointMin = ElCLib::Value(parmin,L3);
60 gp_Pnt PointMax = ElCLib::Value(parmax,L3);
61
62 Graphic3d_Array1OfVertex V(1,2);
63
64 Quantity_Length X,Y,Z;
65
66 PointMin.Coord(X,Y,Z);
67 V(1).SetCoord(X,Y,Z);
68
69 PointMax.Coord(X,Y,Z);
70 V(2).SetCoord(X,Y,Z);
81bba717 71 // processing of side : 1st group
7fd59977 72 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
73
74 Prs3d_Root::NewGroup(aPresentation);
75 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
76
77 if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
78 outside = Standard_True;
79 }
80 gp_Dir arrdir = L3.Direction().Reversed();
81
82 if (outside) {
83 arrdir.Reverse();
84 }
81bba717 85 // arrow 1 : 2nd group
7fd59977 86 Prs3d_Arrow::Draw(aPresentation,Proj1,arrdir,
87 LA->Arrow1Aspect()->Angle(),
88 LA->Arrow1Aspect()->Length());
89
90 Prs3d_Root::NewGroup(aPresentation);
91 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
92
81bba717 93 // arrow 2 : 3rd group
7fd59977 94 Prs3d_Arrow::Draw(aPresentation,Proj2,arrdir.Reversed(),
95 LA->Arrow2Aspect()->Angle(),
96 LA->Arrow2Aspect()->Length());
97
98 Prs3d_Root::NewGroup(aPresentation);
99
81bba717 100 // text : 4th group
7fd59977 101 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
102
103 AttachmentPoint1.Coord(X,Y,Z);
104 V(1).SetCoord(X,Y,Z);
105 Proj1.Coord(X,Y,Z);
106 V(2).SetCoord(X,Y,Z);
107
108 Prs3d_Root::NewGroup(aPresentation);
109 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
81bba717 110 // processing of call 1 : 5th group
7fd59977 111 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
112
113 AttachmentPoint2.Coord(X,Y,Z);
114 V(1).SetCoord(X,Y,Z);
115 Proj2.Coord(X,Y,Z);
116 V(2).SetCoord(X,Y,Z);
117
118 Prs3d_Root::NewGroup(aPresentation);
119 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
81bba717 120 // processing of call 2 : 6th group
7fd59977 121 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
122
123}
124
125
126//==========================================================================
127// function : DsgPrs_ParalPresentation::Add
81bba717 128// purpose : it is possible to choose the symbol of extremities of the face (arrow, point...)
7fd59977 129//==========================================================================
130void DsgPrs_ParalPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
131 const Handle(Prs3d_Drawer)& aDrawer,
132 const TCollection_ExtendedString& aText,
133 const gp_Pnt& AttachmentPoint1,
134 const gp_Pnt& AttachmentPoint2,
135 const gp_Dir& aDirection,
136 const gp_Pnt& OffsetPoint,
137 const DsgPrs_ArrowSide ArrowPrs){
138
139
140 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
141 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
142
143 gp_Lin L1 (AttachmentPoint1,aDirection);
144 gp_Lin L2 (AttachmentPoint2,aDirection);
145 gp_Pnt Proj1 = ElCLib::Value(ElCLib::Parameter(L1,OffsetPoint),L1);
146 gp_Pnt Proj2 = ElCLib::Value(ElCLib::Parameter(L2,OffsetPoint),L2);
147 gp_Lin L3 = gce_MakeLin(Proj1,Proj2);
148 Standard_Real parmin,parmax,parcur;
149 parmin = ElCLib::Parameter(L3,Proj1);
150 parmax = parmin;
151 parcur = ElCLib::Parameter(L3,Proj2);
152 Standard_Real dist = Abs(parmin-parcur);
153 if (parcur < parmin) parmin = parcur;
154 if (parcur > parmax) parmax = parcur;
155 parcur = ElCLib::Parameter(L3,OffsetPoint);
156 gp_Pnt offp = ElCLib::Value(parcur,L3);
157
158 Standard_Boolean outside = Standard_False;
159 if (parcur < parmin) {
160 parmin = parcur;
161 outside = Standard_True;
162 }
163 if (parcur > parmax) {
164 parmax = parcur;
165 outside = Standard_True;
166 }
167
168 gp_Pnt PointMin = ElCLib::Value(parmin,L3);
169 gp_Pnt PointMax = ElCLib::Value(parmax,L3);
170
171 Graphic3d_Array1OfVertex V(1,2);
172
173 Quantity_Length X,Y,Z;
174
175 PointMin.Coord(X,Y,Z);
176 V(1).SetCoord(X,Y,Z);
177
178 PointMax.Coord(X,Y,Z);
179 V(2).SetCoord(X,Y,Z);
180
81bba717 181 // processing of face
7fd59977 182 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
183
184 if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) {
185 outside = Standard_True;
186 }
187 gp_Dir arrdir = L3.Direction().Reversed();
188
189 if (outside) {
190 arrdir.Reverse();
191 }
192
193
194 AttachmentPoint1.Coord(X,Y,Z);
195 V(1).SetCoord(X,Y,Z);
196 Proj1.Coord(X,Y,Z);
197 V(2).SetCoord(X,Y,Z);
198
81bba717 199 // processing of call 1
7fd59977 200 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
201
202 AttachmentPoint2.Coord(X,Y,Z);
203 V(1).SetCoord(X,Y,Z);
204 Proj2.Coord(X,Y,Z);
205 V(2).SetCoord(X,Y,Z);
206
81bba717 207 // processing of call 2
7fd59977 208 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
209
210
81bba717 211 // text
7fd59977 212 Prs3d_Text::Draw(aPresentation,LA->TextAspect(),aText,offp);
213
81bba717 214 //arrows
7fd59977 215 DsgPrs::ComputeSymbol(aPresentation,LA,Proj1,Proj2,arrdir,arrdir.Reversed(),ArrowPrs);
216
217
218}
219
220