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) { |
240 | BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
241 | // Handle(Geom_Circle) geom_circ1 = (Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
242 | //JR/Hp |
243 | Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
244 | Handle(Geom_Circle) geom_circ1 = (Handle(Geom_Circle)&) aGeomCurve ; |
245 | // Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L); |
246 | gp_Circ circ1(geom_circ1->Circ()); |
247 | gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z()); |
248 | gp_Pnt Center1 = circ1.Location(); |
249 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis); |
250 | gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis); |
251 | gp_Vec Vp(ProjCenter1,Center1); |
252 | if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction(); |
253 | Standard_Real Dt,R,h; |
254 | Dt = ProjCenter1.Distance(ProjOffsetPoint); |
255 | R = circ1.Radius(); |
256 | if (Dt > .999*R) { |
257 | Dt = .999*R; |
258 | gp_Vec Vout(ProjCenter1,ProjOffsetPoint); |
259 | ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt)); |
260 | OffsetPnt = ProjOffsetPoint; |
261 | } |
262 | h = Sqrt(R*R - Dt*Dt); |
263 | gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h))); |
264 | gp_Vec v(P1,ProjOffsetPoint); |
265 | gp_Pnt P2 = ProjOffsetPoint.Translated(v); |
266 | |
267 | gp_Lin L3; |
268 | if (!P1.IsEqual(P2,Precision::Confusion())) { |
269 | L3 = gce_MakeLin(P1,P2); |
270 | } |
271 | else { |
272 | L3 = gce_MakeLin(P1,laxis.Direction()); |
273 | Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); |
274 | Handle(Select3D_SensitiveBox) box = |
275 | new Select3D_SensitiveBox(own, |
276 | myPosition.X(), |
277 | myPosition.Y(), |
278 | myPosition.Z(), |
279 | myPosition.X()+size, |
280 | myPosition.Y()+size, |
281 | myPosition.Z()+size); |
282 | aSel->Add(box); |
283 | } |
284 | Standard_Real parmin,parmax,parcur; |
285 | parmin = ElCLib::Parameter(L3,P1); |
286 | parmax = parmin; |
287 | |
288 | parcur = ElCLib::Parameter(L3,P2); |
289 | parmin = Min(parmin,parcur); |
290 | parmax = Max(parmax,parcur); |
291 | |
292 | parcur = ElCLib::Parameter(L3,myPosition); |
293 | parmin = Min(parmin,parcur); |
294 | parmax = Max(parmax,parcur); |
295 | |
296 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); |
297 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); |
298 | |
299 | if (!PointMin.IsEqual(PointMax,Precision::Confusion())) { |
300 | seg = new Select3D_SensitiveSegment(own, |
301 | PointMin, |
302 | PointMax); |
303 | aSel->Add(seg); |
304 | } |
305 | } |
306 | } |
307 | //=======================Pour les points====================== |
308 | else { |
309 | if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) { |
310 | seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach); |
311 | aSel->Add(seg); |
312 | } |
313 | else{ |
314 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis); |
315 | gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
316 | gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach); |
317 | gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1); |
318 | gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed()); |
319 | gp_Lin L3; |
320 | |
321 | if (!P1.IsEqual(P2,Precision::Confusion())) { |
322 | L3 = gce_MakeLin(P1,P2); |
323 | } |
324 | else { |
325 | L3 = gce_MakeLin(P1,myFDirAttach); |
326 | Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6)); |
327 | Handle(Select3D_SensitiveBox) box = |
328 | new Select3D_SensitiveBox(own, |
329 | myPosition.X(), |
330 | myPosition.Y(), |
331 | myPosition.Z(), |
332 | myPosition.X()+size, |
333 | myPosition.Y()+size, |
334 | myPosition.Z()+size); |
335 | aSel->Add(box); |
336 | } |
337 | Standard_Real parmin,parmax,parcur; |
338 | parmin = ElCLib::Parameter(L3,P1); |
339 | parmax = parmin; |
340 | |
341 | parcur = ElCLib::Parameter(L3,P2); |
342 | parmin = Min(parmin,parcur); |
343 | parmax = Max(parmax,parcur); |
344 | |
345 | parcur = ElCLib::Parameter(L3,myPosition); |
346 | parmin = Min(parmin,parcur); |
347 | parmax = Max(parmax,parcur); |
348 | |
349 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); |
350 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); |
351 | |
352 | if (!PointMin.IsEqual(PointMax,Precision::Confusion())) { |
353 | seg = new Select3D_SensitiveSegment(own,PointMin,PointMax); |
354 | aSel->Add(seg); |
355 | } |
356 | if (!myFAttach.IsEqual(P1,Precision::Confusion())) { |
357 | seg = new Select3D_SensitiveSegment(own,myFAttach,P1); |
358 | aSel->Add(seg); |
359 | } |
360 | if (!mySAttach.IsEqual(P2,Precision::Confusion())) { |
361 | seg = new Select3D_SensitiveSegment(own,mySAttach,P2); |
362 | aSel->Add(seg); |
363 | } |
364 | } |
365 | } |
366 | } |
367 | |
368 | //======================================================================= |
369 | //function : ComputeTwoFacesSymmetric |
370 | //purpose : |
371 | //======================================================================= |
372 | void AIS_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&) |
373 | { |
374 | } |
375 | |
376 | //======================================================================= |
377 | //function : ComputeTwoEdgesSymmetric |
378 | //purpose : |
379 | //======================================================================= |
380 | void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs) |
381 | { |
382 | BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape)); |
383 | if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return; |
384 | BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape)); |
385 | if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return; |
386 | // gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22; |
387 | gp_Pnt ptat11,ptat12,ptat21,ptat22; |
388 | Handle(Geom_Curve) geom1,geom2; |
389 | Standard_Boolean isInfinite1,isInfinite2; |
390 | Handle(Geom_Curve) extCurv; |
391 | if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape), |
392 | TopoDS::Edge(mySShape), |
393 | myExtShape, |
394 | geom1, |
395 | geom2, |
396 | ptat11, |
397 | ptat12, |
398 | ptat21, |
399 | ptat22, |
400 | extCurv, |
401 | isInfinite1,isInfinite2, |
402 | myPlane)) { |
403 | return; |
404 | } |
405 | aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0)); |
406 | Handle(Geom_Line) geom_axis,extcurve; |
407 | gp_Pnt p1,p2; |
408 | Standard_Boolean isinfinite,isonplane; |
409 | if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), |
410 | geom_axis,p1,p2, |
411 | extcurve, |
412 | isinfinite, |
413 | isonplane, |
414 | myPlane)) return; |
415 | |
416 | gp_Lin laxis (geom_axis->Lin()); |
417 | myAxisDirAttach = laxis.Direction(); |
418 | |
419 | if(cu1.GetType() == GeomAbs_Line){ |
420 | const Handle(Geom_Line)& geom_lin1 = (Handle(Geom_Line)&) geom1; |
421 | gp_Lin l1(geom_lin1->Lin()); |
422 | myFDirAttach = l1.Direction(); |
423 | } |
424 | gp_Circ circ; |
425 | if(cu1.GetType() == GeomAbs_Circle){ |
426 | const Handle(Geom_Circle)& geom_cir1 = (Handle(Geom_Circle)&) geom1; |
427 | gp_Circ c(geom_cir1->Circ()); |
428 | circ = c; |
429 | } |
430 | |
431 | // recherche points attache |
432 | gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis); |
433 | |
434 | /*//---------------------------------------------------- |
435 | //Quand on fait la symetrie de 2 edges consecutifs: |
436 | // |
437 | // :<-- Axe |
438 | // : |
439 | // /:\ |
440 | // Edge n --->/ : \ |
441 | // / : \<-- Edge n+1 |
442 | // : |
443 | //---------------------------------------------------- |
444 | */ |
445 | Standard_Boolean idem = Standard_False; |
446 | if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes |
447 | const gp_Lin& line2 = ((Handle(Geom_Line)&) geom2)->Lin(); |
448 | if (myAutomaticPosition) { |
449 | myFAttach = ((Handle(Geom_Line)&) geom1)->Lin().Location(); |
450 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
451 | } |
452 | else { |
453 | const gp_Lin& line1 = ((Handle(Geom_Line)&) geom1)->Lin(); |
454 | myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1); |
455 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
456 | } |
457 | } |
458 | else if (!isInfinite1 && !isInfinite2) { |
459 | if (ptat11.IsEqual(ptat21,Precision::Confusion())) { |
460 | myFAttach = ptat12; |
461 | mySAttach = ptat22; |
462 | idem = Standard_True; |
463 | } |
464 | if (ptat11.IsEqual(ptat22,Precision::Confusion())) { |
465 | myFAttach = ptat12; |
466 | mySAttach = ptat21; |
467 | idem = Standard_True; |
468 | } |
469 | if (ptat12.IsEqual(ptat21,Precision::Confusion())) { |
470 | myFAttach = ptat11; |
471 | mySAttach = ptat22; |
472 | idem = Standard_True; |
473 | } |
474 | if (ptat12.IsEqual(ptat22,Precision::Confusion())) { |
475 | myFAttach = ptat11; |
476 | mySAttach = ptat21; |
477 | idem = Standard_True; |
478 | } |
479 | if(!idem){ |
480 | if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12; |
481 | else myFAttach = ptat11; |
482 | |
483 | if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22; |
484 | else mySAttach = ptat21; |
485 | } |
486 | } |
487 | else if (isInfinite1) {// geom1 et geom2 sont des lignes |
488 | mySAttach = ptat21; |
489 | const gp_Lin& line1 = ((Handle(Geom_Line)&) geom1)->Lin(); |
490 | myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1); |
491 | } |
492 | else if (isInfinite2) {// geom1 et geom2 sont des lignes |
493 | myFAttach = ptat11; |
494 | const gp_Lin& line2 = ((Handle(Geom_Line)&) geom2)->Lin(); |
495 | mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2); |
496 | } |
497 | |
7fd59977 |
498 | if( !myArrowSizeIsDefined ) |
7fd59977 |
499 | myArrowSize = myFAttach.Distance(mySAttach)/50.; |
500 | //---------------------------------------------------- |
501 | |
502 | //---------------------------------------------------- |
503 | // Si myFAttach <> mySAttach et PjFAttach = myFAttach |
504 | //---------------------------------------------------- |
505 | gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
506 | |
507 | if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){ |
508 | const Handle(Geom_Line)& geom_lin2 = (Handle(Geom_Line)&) geom2; |
509 | gp_Lin l2(geom_lin2->Lin()); |
510 | myFDirAttach = l2.Direction(); |
511 | gp_Pnt PntTempo; |
512 | PntTempo = myFAttach; |
513 | myFAttach = mySAttach; |
514 | mySAttach = PntTempo; |
515 | PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
516 | } |
517 | |
518 | //---------------------------------------------------- |
519 | // gp_Pnt curpos; |
520 | |
521 | if (myAutomaticPosition) { |
522 | //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
523 | // offset pour eviter confusion Edge et Dimension |
524 | gp_Vec offset(myAxisDirAttach); |
525 | offset = offset * myArrowSize * (-5); |
526 | gp_Vec Vt(myFAttach, PjFAttach); |
527 | gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15))); |
528 | myPosition = curpos; |
529 | } |
530 | |
531 | gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
532 | gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis); |
533 | if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion()) myArrowSize = 0.; |
a6eb515f |
534 | Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); |
535 | Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); |
7fd59977 |
536 | arr->SetLength(myArrowSize); |
a6eb515f |
537 | arr = la->ArrowAspect(); |
7fd59977 |
538 | arr->SetLength(myArrowSize); |
539 | if(cu1.GetType() == GeomAbs_Line) |
540 | DsgPrs_SymmetricPresentation::Add(aprs, |
541 | myDrawer, |
542 | myFAttach, |
543 | mySAttach, |
544 | myFDirAttach, |
545 | laxis, |
546 | myPosition); |
547 | |
548 | if(cu1.GetType() == GeomAbs_Circle) |
549 | DsgPrs_SymmetricPresentation::Add(aprs, |
550 | myDrawer, |
551 | myFAttach, |
552 | mySAttach, |
553 | circ, |
554 | laxis, |
555 | myPosition); |
556 | if ( (myExtShape != 0) && !extCurv.IsNull()) { |
557 | gp_Pnt pf, pl; |
558 | if ( myExtShape == 1 ) { |
559 | if (!isInfinite1) { |
560 | pf = ptat11; |
561 | pl = ptat12; |
562 | } |
563 | ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl); |
564 | } |
565 | else { |
566 | if (!isInfinite2) { |
567 | pf = ptat21; |
568 | pl = ptat22; |
569 | } |
570 | ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl); |
571 | } |
572 | } |
573 | } |
574 | |
575 | //======================================================================= |
576 | //function : ComputeTwoVertexsSymmetric |
577 | //purpose : |
578 | //======================================================================= |
579 | void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs) |
580 | { |
581 | if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return; |
582 | Handle(Geom_Line) geom_axis,extcurve; |
583 | gp_Pnt p1,p2; |
584 | Standard_Boolean isinfinite,isonplane; |
585 | if (!AIS::ComputeGeometry(TopoDS::Edge(myTool), |
586 | geom_axis,p1,p2, |
587 | extcurve, |
588 | isinfinite, |
589 | isonplane, |
590 | myPlane)) return; |
591 | |
592 | Standard_Boolean isOnPlane1, isOnPlane2; |
593 | |
594 | AIS::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1); |
595 | AIS::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2); |
596 | |
7fd59977 |
597 | if( !myArrowSizeIsDefined ) |
7fd59977 |
598 | myArrowSize = myFAttach.Distance(mySAttach)/50.; |
599 | |
600 | if (isOnPlane1 && isOnPlane2) |
601 | myExtShape = 0; |
602 | else if ( isOnPlane1 && !isOnPlane2) |
603 | myExtShape = 2; |
604 | else if (!isOnPlane1 && isOnPlane2) |
605 | myExtShape = 1; |
606 | else |
607 | return ; |
608 | gp_Lin laxis (geom_axis->Lin()); |
609 | myAxisDirAttach = laxis.Direction(); |
610 | |
611 | // recherche points attache |
612 | // gp_Pnt curpos; |
613 | if (myAutomaticPosition) { |
614 | gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); |
615 | // offset pour eviter confusion Edge et Dimension |
616 | gp_Vec offset(myAxisDirAttach); |
617 | offset = offset * myArrowSize * (-5); |
618 | gp_Vec Vt(myFAttach, PjFAttach); |
619 | gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15))); |
620 | myPosition = curpos; |
621 | } |
622 | if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.; |
a6eb515f |
623 | Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect(); |
624 | Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect(); |
7fd59977 |
625 | arr->SetLength(myArrowSize); |
a6eb515f |
626 | arr = la->ArrowAspect(); |
7fd59977 |
627 | arr->SetLength(myArrowSize); |
628 | DsgPrs_SymmetricPresentation::Add(aprs, |
629 | myDrawer, |
630 | myFAttach, |
631 | mySAttach, |
632 | laxis, |
633 | myPosition); |
634 | if ( myExtShape == 1) |
635 | ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach); |
636 | else if ( myExtShape == 2) |
637 | ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach); |
638 | } |
639 | |
640 | |
641 | |
642 | |
643 | |
644 | |