b311480e |
1 | // Created on: 1997-03-03 |
2 | // Created by: Jean-Pierre COMBE |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
7fd59977 |
17 | #include <Standard_NotImplemented.hxx> |
18 | |
19 | #include <AIS_SymmetricRelation.ixx> |
20 | #include <AIS.hxx> |
7fd59977 |
21 | |
22 | #include <gce_MakeLin.hxx> |
23 | #include <SelectMgr_EntityOwner.hxx> |
f751596e |
24 | #include <SelectMgr_Selection.hxx> |
7fd59977 |
25 | #include <Select3D_SensitiveSegment.hxx> |
26 | #include <Select3D_SensitiveBox.hxx> |
27 | #include <Precision.hxx> |
28 | #include <TopoDS.hxx> |
29 | #include <BRep_Tool.hxx> |
30 | #include <BRepAdaptor_Surface.hxx> |
31 | #include <BRepAdaptor_Curve.hxx> |
32 | #include <gp_Lin.hxx> |
33 | #include <gp_Circ.hxx> |
34 | #include <gp_Pnt.hxx> |
35 | #include <ElCLib.hxx> |
36 | #include <gp_Pln.hxx> |
37 | #include <gp_Dir.hxx> |
38 | #include <gp_Ax1.hxx> |
39 | #include <gp_Ax2.hxx> |
40 | |
41 | #include <Geom_Plane.hxx> |
42 | #include <Geom_Line.hxx> |
43 | #include <Geom_Circle.hxx> |
44 | #include <TopExp_Explorer.hxx> |
45 | |
46 | #include <Precision.hxx> |
47 | #include <Prs3d_Drawer.hxx> |
48 | #include <Prs3d_ArrowAspect.hxx> |
a6eb515f |
49 | #include <Prs3d_DimensionAspect.hxx> |
7fd59977 |
50 | |
51 | #include <DsgPrs_SymmetricPresentation.hxx> |
52 | |
53 | //======================================================================= |
54 | //function : AIS_SymmetricRelation |
55 | //purpose : |
56 | //======================================================================= |
57 | AIS_SymmetricRelation::AIS_SymmetricRelation(const TopoDS_Shape& aSymmTool, |
58 | const TopoDS_Shape& FirstShape, |
59 | const TopoDS_Shape& SecondShape, |
60 | const Handle(Geom_Plane)& aPlane) |
61 | :AIS_Relation(), |
62 | myTool(aSymmTool) |
63 | { |
64 | SetFirstShape(FirstShape); |
65 | SetSecondShape(SecondShape); |
66 | SetPlane(aPlane); |
67 | myPosition = aPlane->Pln().Location(); |
68 | } |
69 | |
70 | //======================================================================= |
71 | //function : Compute |
72 | //purpose : |
73 | //======================================================================= |
74 | void AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&, |
75 | const Handle(Prs3d_Presentation)& aprs, |
76 | const Standard_Integer) |
77 | { |
78 | aprs->Clear(); |
79 | |
80 | switch (myFShape.ShapeType()) { |
81 | case TopAbs_FACE : |
82 | { |
83 | // cas symetrie entre deux faces |
84 | ComputeTwoFacesSymmetric(aprs); |
85 | } |
86 | break; |
87 | case TopAbs_EDGE : |
88 | { |
89 | // cas symetrie entre deux edges |
90 | ComputeTwoEdgesSymmetric(aprs); |
91 | } |
92 | break; |
93 | case TopAbs_VERTEX : |
94 | { |
95 | // cas symetrie entre deux vertexs |
96 | ComputeTwoVerticesSymmetric(aprs); |
97 | } |
98 | break; |
99 | default: |
100 | break; |
101 | } |
102 | if (myTool.ShapeType() == TopAbs_EDGE) { |
103 | Handle(Geom_Curve) aCurve,extcurve; |
104 | gp_Pnt p1,p2; |
105 | Standard_Boolean isinfinite,isonplane; |
106 | if (AIS::ComputeGeometry(TopoDS::Edge(myTool), |
107 | aCurve,p1,p2, |
108 | extcurve, |
109 | isinfinite, |
110 | isonplane, |
111 | myPlane)) { |
112 | if (!extcurve.IsNull()) { |
113 | gp_Pnt pf, pl; |
114 | if (!isinfinite) { |
115 | pf = p1; |
116 | pl = p2; |
117 | } |
118 | if (isinfinite) aprs->SetInfiniteState(Standard_True); |
119 | ComputeProjEdgePresentation(aprs,TopoDS::Edge(myTool),aCurve,pf,pl); |
120 | } |
121 | } |
122 | } |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : Compute |
127 | //purpose : to avoid warning at compilation (SUN) |
128 | //======================================================================= |
129 | void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector*/, |
130 | const Handle(Prs3d_Presentation)& /*aPresentation*/) |
131 | { |
132 | // Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)"); |
133 | // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; |
134 | } |
135 | |
857ffd5e |
136 | void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)& aProjector, |
137 | const Handle(Geom_Transformation)& aTransformation, |
138 | const Handle(Prs3d_Presentation)& aPresentation) |
7fd59977 |
139 | { |
857ffd5e |
140 | Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)"); |
7fd59977 |
141 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ; |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : ComputeSelection |
146 | //purpose : |
147 | //======================================================================= |
148 | void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, |
149 | const Standard_Integer) |
150 | { |
151 | Handle(Select3D_SensitiveSegment) seg; |
152 | Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7); |
153 | Standard_Real F,L; |
154 | |
155 | Handle(Geom_Line) geom_axis,extcurve; |
156 | gp_Pnt p1,p2; |
157 | Standard_Boolean isinfinite,isonplane; |
158 | if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), |
159 | geom_axis,p1,p2, |
160 | extcurve, |
161 | isinfinite, |
162 | isonplane, |
163 | myPlane)) return; |
164 | |
165 | gp_Lin laxis (geom_axis->Lin()); |
166 | |
167 | if(myFShape.ShapeType() != TopAbs_VERTEX){ |
168 | BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); |
169 | |
170 | if(cu1.GetType() == GeomAbs_Line) { |
171 | // gp_Lin L1 (myFAttach,myFDirAttach); |
172 | gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
173 | gp_Pnt PjOffSetPnt = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis); |
174 | Standard_Real h = fabs(PjOffSetPnt.Distance(PjAttachPnt1)/cos(myAxisDirAttach.Angle(myFDirAttach))); |
175 | gp_Vec VL1(myFDirAttach); |
176 | gp_Vec VLa(PjAttachPnt1,PjOffSetPnt); |
177 | Standard_Real scal = VL1.Dot(VLa); |
178 | if(scal < 0) VL1.Reverse(); |
179 | VL1.Multiply(h); |
180 | gp_Pnt P1 = myFAttach.Translated(VL1); |
181 | gp_Pnt ProjAxis = ElCLib::Value(ElCLib::Parameter(laxis,P1),laxis); |
182 | gp_Vec v(P1,ProjAxis); |
183 | gp_Pnt P2 = ProjAxis.Translated(v); |
184 | |
185 | gp_Lin L3; |
186 | |
187 | if (!P1.IsEqual(P2,Precision::Confusion())) { |
188 | L3 = gce_MakeLin(P1,P2); |
189 | } |
190 | else { |
191 | L3 = gce_MakeLin(P1,myFDirAttach); |
192 | Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); |
193 | Handle(Select3D_SensitiveBox) box = |
194 | new Select3D_SensitiveBox(own, |
195 | myPosition.X(), |
196 | myPosition.Y(), |
197 | myPosition.Z(), |
198 | myPosition.X()+size, |
199 | myPosition.Y()+size, |
200 | myPosition.Z()+size); |
201 | aSel->Add(box); |
202 | } |
203 | Standard_Real parmin,parmax,parcur; |
204 | parmin = ElCLib::Parameter(L3,P1); |
205 | parmax = parmin; |
206 | |
207 | parcur = ElCLib::Parameter(L3,P2); |
208 | parmin = Min(parmin,parcur); |
209 | parmax = Max(parmax,parcur); |
210 | |
211 | parcur = ElCLib::Parameter(L3,myPosition); |
212 | parmin = Min(parmin,parcur); |
213 | parmax = Max(parmax,parcur); |
214 | |
215 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); |
216 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); |
217 | |
218 | if (!PointMin.IsEqual(PointMax,Precision::Confusion())) { |
219 | seg = new Select3D_SensitiveSegment(own, |
220 | PointMin, |
221 | PointMax); |
222 | aSel->Add(seg); |
223 | } |
224 | if (!myFAttach.IsEqual(P1,Precision::Confusion())) { |
225 | seg = new Select3D_SensitiveSegment(own, |
226 | myFAttach, |
227 | P1); |
228 | aSel->Add(seg); |
229 | } |
230 | if (!mySAttach.IsEqual(P2,Precision::Confusion())) { |
231 | seg = new Select3D_SensitiveSegment(own, |
232 | mySAttach, |
233 | P2); |
234 | aSel->Add(seg); |
235 | } |
236 | } |
237 | |
238 | //=======================Pour les arcs====================== |
239 | if(cu1.GetType() == GeomAbs_Circle) { |
7fd59977 |
240 | Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
c5f3a425 |
241 | Handle(Geom_Circle) geom_circ1 = Handle(Geom_Circle)::DownCast (aGeomCurve) ; |
7fd59977 |
242 | // Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
243 | gp_Circ circ1(geom_circ1->Circ()); |
244 | gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z()); |
245 | gp_Pnt Center1 = circ1.Location(); |
246 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis); |
247 | gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis); |
248 | gp_Vec Vp(ProjCenter1,Center1); |
249 | if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction(); |
250 | Standard_Real Dt,R,h; |
251 | Dt = ProjCenter1.Distance(ProjOffsetPoint); |
252 | R = circ1.Radius(); |
253 | if (Dt > .999*R) { |
254 | Dt = .999*R; |
255 | gp_Vec Vout(ProjCenter1,ProjOffsetPoint); |
256 | ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt)); |
257 | OffsetPnt = ProjOffsetPoint; |
258 | } |
259 | h = Sqrt(R*R - Dt*Dt); |
260 | gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h))); |
261 | gp_Vec v(P1,ProjOffsetPoint); |
262 | gp_Pnt P2 = ProjOffsetPoint.Translated(v); |
263 | |
264 | gp_Lin L3; |
265 | if (!P1.IsEqual(P2,Precision::Confusion())) { |
266 | L3 = gce_MakeLin(P1,P2); |
267 | } |
268 | else { |
269 | L3 = gce_MakeLin(P1,laxis.Direction()); |
270 | Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); |
271 | Handle(Select3D_SensitiveBox) box = |
272 | new Select3D_SensitiveBox(own, |
273 | myPosition.X(), |
274 | myPosition.Y(), |
275 | myPosition.Z(), |
276 | myPosition.X()+size, |
277 | myPosition.Y()+size, |
278 | myPosition.Z()+size); |
279 | aSel->Add(box); |
280 | } |
281 | Standard_Real parmin,parmax,parcur; |
282 | parmin = ElCLib::Parameter(L3,P1); |
283 | parmax = parmin; |
284 | |
285 | parcur = ElCLib::Parameter(L3,P2); |
286 | parmin = Min(parmin,parcur); |
287 | parmax = Max(parmax,parcur); |
288 | |
289 | parcur = ElCLib::Parameter(L3,myPosition); |
290 | parmin = Min(parmin,parcur); |
291 | parmax = Max(parmax,parcur); |
292 | |
293 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); |
294 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); |
295 | |
296 | if (!PointMin.IsEqual(PointMax,Precision::Confusion())) { |
297 | seg = new Select3D_SensitiveSegment(own, |
298 | PointMin, |
299 | PointMax); |
300 | aSel->Add(seg); |
301 | } |
302 | } |
303 | } |
304 | //=======================Pour les points====================== |
305 | else { |
306 | if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) { |
307 | seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach); |
308 | aSel->Add(seg); |
309 | } |
310 | else{ |
311 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis); |
312 | gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
313 | gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach); |
314 | gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1); |
315 | gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed()); |
316 | gp_Lin L3; |
317 | |
318 | if (!P1.IsEqual(P2,Precision::Confusion())) { |
319 | L3 = gce_MakeLin(P1,P2); |
320 | } |
321 | else { |
322 | L3 = gce_MakeLin(P1,myFDirAttach); |
323 | Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); |
324 | Handle(Select3D_SensitiveBox) box = |
325 | new Select3D_SensitiveBox(own, |
326 | myPosition.X(), |
327 | myPosition.Y(), |
328 | myPosition.Z(), |
329 | myPosition.X()+size, |
330 | myPosition.Y()+size, |
331 | myPosition.Z()+size); |
332 | aSel->Add(box); |
333 | } |
334 | Standard_Real parmin,parmax,parcur; |
335 | parmin = ElCLib::Parameter(L3,P1); |
336 | parmax = parmin; |
337 | |
338 | parcur = ElCLib::Parameter(L3,P2); |
339 | parmin = Min(parmin,parcur); |
340 | parmax = Max(parmax,parcur); |
341 | |
342 | parcur = ElCLib::Parameter(L3,myPosition); |
343 | parmin = Min(parmin,parcur); |
344 | parmax = Max(parmax,parcur); |
345 | |
346 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); |
347 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); |
348 | |
349 | if (!PointMin.IsEqual(PointMax,Precision::Confusion())) { |
350 | seg = new Select3D_SensitiveSegment(own,PointMin,PointMax); |
351 | aSel->Add(seg); |
352 | } |
353 | if (!myFAttach.IsEqual(P1,Precision::Confusion())) { |
354 | seg = new Select3D_SensitiveSegment(own,myFAttach,P1); |
355 | aSel->Add(seg); |
356 | } |
357 | if (!mySAttach.IsEqual(P2,Precision::Confusion())) { |
358 | seg = new Select3D_SensitiveSegment(own,mySAttach,P2); |
359 | aSel->Add(seg); |
360 | } |
361 | } |
362 | } |
363 | } |
364 | |
365 | //======================================================================= |
366 | //function : ComputeTwoFacesSymmetric |
367 | //purpose : |
368 | //======================================================================= |
369 | void AIS_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&) |
370 | { |
371 | } |
372 | |
373 | //======================================================================= |
374 | //function : ComputeTwoEdgesSymmetric |
375 | //purpose : |
376 | //======================================================================= |
377 | void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs) |
378 | { |
379 | BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); |
380 | if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return; |
381 | BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape)); |
382 | if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return; |
383 | // gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22; |
384 | gp_Pnt ptat11,ptat12,ptat21,ptat22; |
385 | Handle(Geom_Curve) geom1,geom2; |
386 | Standard_Boolean isInfinite1,isInfinite2; |
387 | Handle(Geom_Curve) extCurv; |
388 | if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape), |
389 | TopoDS::Edge(mySShape), |
390 | myExtShape, |
391 | geom1, |
392 | geom2, |
393 | ptat11, |
394 | ptat12, |
395 | ptat21, |
396 | ptat22, |
397 | extCurv, |
398 | isInfinite1,isInfinite2, |
399 | myPlane)) { |
400 | return; |
401 | } |
402 | aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0)); |
403 | Handle(Geom_Line) geom_axis,extcurve; |
404 | gp_Pnt p1,p2; |
405 | Standard_Boolean isinfinite,isonplane; |
406 | if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), |
407 | geom_axis,p1,p2, |
408 | extcurve, |
409 | isinfinite, |
410 | isonplane, |
411 | myPlane)) return; |
412 | |
413 | gp_Lin laxis (geom_axis->Lin()); |
414 | myAxisDirAttach = laxis.Direction(); |
415 | |
416 | if(cu1.GetType() == GeomAbs_Line){ |
c5f3a425 |
417 | Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1)); |
7fd59977 |
418 | gp_Lin l1(geom_lin1->Lin()); |
419 | myFDirAttach = l1.Direction(); |
420 | } |
421 | gp_Circ circ; |
422 | if(cu1.GetType() == GeomAbs_Circle){ |
c5f3a425 |
423 | Handle(Geom_Circle) geom_cir1 (Handle(Geom_Circle)::DownCast (geom1)); |
7fd59977 |
424 | gp_Circ c(geom_cir1->Circ()); |
425 | circ = c; |
426 | } |
427 | |
428 | // recherche points attache |
429 | gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis); |
430 | |
431 | /*//---------------------------------------------------- |
432 | //Quand on fait la symetrie de 2 edges consecutifs: |
433 | // |
434 | // :<-- Axe |
435 | // : |
436 | // /:\ |
437 | // Edge n --->/ : \ |
438 | // / : \<-- Edge n+1 |
439 | // : |
440 | //---------------------------------------------------- |
441 | */ |
442 | Standard_Boolean idem = Standard_False; |
443 | if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes |
c5f3a425 |
444 | const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin(); |
7fd59977 |
445 | if (myAutomaticPosition) { |
c5f3a425 |
446 | myFAttach = Handle(Geom_Line)::DownCast (geom1)->Lin().Location(); |
7fd59977 |
447 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
448 | } |
449 | else { |
c5f3a425 |
450 | const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin(); |
7fd59977 |
451 | myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1); |
452 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
453 | } |
454 | } |
455 | else if (!isInfinite1 && !isInfinite2) { |
456 | if (ptat11.IsEqual(ptat21,Precision::Confusion())) { |
457 | myFAttach = ptat12; |
458 | mySAttach = ptat22; |
459 | idem = Standard_True; |
460 | } |
461 | if (ptat11.IsEqual(ptat22,Precision::Confusion())) { |
462 | myFAttach = ptat12; |
463 | mySAttach = ptat21; |
464 | idem = Standard_True; |
465 | } |
466 | if (ptat12.IsEqual(ptat21,Precision::Confusion())) { |
467 | myFAttach = ptat11; |
468 | mySAttach = ptat22; |
469 | idem = Standard_True; |
470 | } |
471 | if (ptat12.IsEqual(ptat22,Precision::Confusion())) { |
472 | myFAttach = ptat11; |
473 | mySAttach = ptat21; |
474 | idem = Standard_True; |
475 | } |
476 | if(!idem){ |
477 | if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12; |
478 | else myFAttach = ptat11; |
479 | |
480 | if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22; |
481 | else mySAttach = ptat21; |
482 | } |
483 | } |
484 | else if (isInfinite1) {// geom1 et geom2 sont des lignes |
485 | mySAttach = ptat21; |
c5f3a425 |
486 | const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin(); |
7fd59977 |
487 | myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1); |
488 | } |
489 | else if (isInfinite2) {// geom1 et geom2 sont des lignes |
490 | myFAttach = ptat11; |
c5f3a425 |
491 | const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin(); |
7fd59977 |
492 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
493 | } |
494 | |
7fd59977 |
495 | if( !myArrowSizeIsDefined ) |
7fd59977 |
496 | myArrowSize = myFAttach.Distance(mySAttach)/50.; |
497 | //---------------------------------------------------- |
498 | |
499 | //---------------------------------------------------- |
500 | // Si myFAttach <> mySAttach et PjFAttach = myFAttach |
501 | //---------------------------------------------------- |
502 | gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
503 | |
504 | if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){ |
c5f3a425 |
505 | Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2)); |
7fd59977 |
506 | gp_Lin l2(geom_lin2->Lin()); |
507 | myFDirAttach = l2.Direction(); |
508 | gp_Pnt PntTempo; |
509 | PntTempo = myFAttach; |
510 | myFAttach = mySAttach; |
511 | mySAttach = PntTempo; |
512 | PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
513 | } |
514 | |
515 | //---------------------------------------------------- |
516 | // gp_Pnt curpos; |
517 | |
518 | if (myAutomaticPosition) { |
519 | //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
520 | // offset pour eviter confusion Edge et Dimension |
521 | gp_Vec offset(myAxisDirAttach); |
522 | offset = offset * myArrowSize * (-5); |
523 | gp_Vec Vt(myFAttach, PjFAttach); |
524 | gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15))); |
525 | myPosition = curpos; |
526 | } |
527 | |
528 | gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
529 | gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis); |
530 | if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion()) myArrowSize = 0.; |
a6eb515f |
531 | Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); |
532 | Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); |
7fd59977 |
533 | arr->SetLength(myArrowSize); |
a6eb515f |
534 | arr = la->ArrowAspect(); |
7fd59977 |
535 | arr->SetLength(myArrowSize); |
536 | if(cu1.GetType() == GeomAbs_Line) |
537 | DsgPrs_SymmetricPresentation::Add(aprs, |
538 | myDrawer, |
539 | myFAttach, |
540 | mySAttach, |
541 | myFDirAttach, |
542 | laxis, |
543 | myPosition); |
544 | |
545 | if(cu1.GetType() == GeomAbs_Circle) |
546 | DsgPrs_SymmetricPresentation::Add(aprs, |
547 | myDrawer, |
548 | myFAttach, |
549 | mySAttach, |
550 | circ, |
551 | laxis, |
552 | myPosition); |
553 | if ( (myExtShape != 0) && !extCurv.IsNull()) { |
554 | gp_Pnt pf, pl; |
555 | if ( myExtShape == 1 ) { |
556 | if (!isInfinite1) { |
557 | pf = ptat11; |
558 | pl = ptat12; |
559 | } |
560 | ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl); |
561 | } |
562 | else { |
563 | if (!isInfinite2) { |
564 | pf = ptat21; |
565 | pl = ptat22; |
566 | } |
567 | ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl); |
568 | } |
569 | } |
570 | } |
571 | |
572 | //======================================================================= |
573 | //function : ComputeTwoVertexsSymmetric |
574 | //purpose : |
575 | //======================================================================= |
576 | void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs) |
577 | { |
578 | if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return; |
579 | Handle(Geom_Line) geom_axis,extcurve; |
580 | gp_Pnt p1,p2; |
581 | Standard_Boolean isinfinite,isonplane; |
582 | if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), |
583 | geom_axis,p1,p2, |
584 | extcurve, |
585 | isinfinite, |
586 | isonplane, |
587 | myPlane)) return; |
588 | |
589 | Standard_Boolean isOnPlane1, isOnPlane2; |
590 | |
591 | AIS::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1); |
592 | AIS::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2); |
593 | |
7fd59977 |
594 | if( !myArrowSizeIsDefined ) |
7fd59977 |
595 | myArrowSize = myFAttach.Distance(mySAttach)/50.; |
596 | |
597 | if (isOnPlane1 && isOnPlane2) |
598 | myExtShape = 0; |
599 | else if ( isOnPlane1 && !isOnPlane2) |
600 | myExtShape = 2; |
601 | else if (!isOnPlane1 && isOnPlane2) |
602 | myExtShape = 1; |
603 | else |
604 | return ; |
605 | gp_Lin laxis (geom_axis->Lin()); |
606 | myAxisDirAttach = laxis.Direction(); |
607 | |
608 | // recherche points attache |
609 | // gp_Pnt curpos; |
610 | if (myAutomaticPosition) { |
611 | gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
612 | // offset pour eviter confusion Edge et Dimension |
613 | gp_Vec offset(myAxisDirAttach); |
614 | offset = offset * myArrowSize * (-5); |
615 | gp_Vec Vt(myFAttach, PjFAttach); |
616 | gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15))); |
617 | myPosition = curpos; |
618 | } |
619 | if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.; |
a6eb515f |
620 | Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); |
621 | Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); |
7fd59977 |
622 | arr->SetLength(myArrowSize); |
a6eb515f |
623 | arr = la->ArrowAspect(); |
7fd59977 |
624 | arr->SetLength(myArrowSize); |
625 | DsgPrs_SymmetricPresentation::Add(aprs, |
626 | myDrawer, |
627 | myFAttach, |
628 | mySAttach, |
629 | laxis, |
630 | myPosition); |
631 | if ( myExtShape == 1) |
632 | ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach); |
633 | else if ( myExtShape == 2) |
634 | ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach); |
635 | } |
636 | |
637 | |
638 | |
639 | |
640 | |
641 | |