1 // Created on: 1995-03-14
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <StdSelect_BRepSelectionTool.hxx>
19 #include <Bnd_Box.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepAdaptor_Curve.hxx>
22 #include <BRepAdaptor_Surface.hxx>
23 #include <BRepBndLib.hxx>
24 #include <BRepMesh_IncrementalMesh.hxx>
25 #include <BRepTools.hxx>
26 #include <BRepTools_WireExplorer.hxx>
27 #include <GCPnts_TangentialDeflection.hxx>
28 #include <Geom_Circle.hxx>
29 #include <GeomAbs_SurfaceType.hxx>
30 #include <GeomAdaptor_Curve.hxx>
31 #include <gp_Circ.hxx>
32 #include <Poly_Array1OfTriangle.hxx>
33 #include <Poly_Polygon3D.hxx>
34 #include <Poly_PolygonOnTriangulation.hxx>
35 #include <Poly_Triangulation.hxx>
36 #include <Precision.hxx>
37 #include <Select3D_SensitiveBox.hxx>
38 #include <Select3D_SensitiveCircle.hxx>
39 #include <Select3D_SensitiveCurve.hxx>
40 #include <Select3D_SensitiveEntity.hxx>
41 #include <Select3D_SensitiveFace.hxx>
42 #include <Select3D_SensitiveGroup.hxx>
43 #include <Select3D_SensitivePoint.hxx>
44 #include <Select3D_SensitiveSegment.hxx>
45 #include <Select3D_SensitiveTriangle.hxx>
46 #include <Select3D_SensitiveTriangulation.hxx>
47 #include <Select3D_SensitiveWire.hxx>
48 #include <Select3D_TypeOfSensitivity.hxx>
49 #include <SelectMgr_EntityOwner.hxx>
50 #include <SelectMgr_SelectableObject.hxx>
51 #include <SelectMgr_Selection.hxx>
52 #include <Standard_ErrorHandler.hxx>
53 #include <Standard_NullObject.hxx>
54 #include <StdSelect_BRepOwner.hxx>
55 #include <TColgp_HArray1OfPnt.hxx>
56 #include <TColgp_SequenceOfPnt.hxx>
57 #include <TColStd_Array1OfReal.hxx>
59 #include <TopExp_Explorer.hxx>
61 #include <TopoDS_Face.hxx>
62 #include <TopoDS_Shape.hxx>
63 #include <TopoDS_Wire.hxx>
64 #include <TopTools_IndexedMapOfShape.hxx>
66 #define BVH_PRIMITIVE_LIMIT 800000
68 //==================================================
69 // function: PreBuildBVH
70 // purpose : Pre-builds BVH tree for heavyweight
71 // sensitive entities with sub-elements
72 // amount more than BVH_PRIMITIVE_LIMIT
73 //==================================================
74 void StdSelect_BRepSelectionTool::PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection)
76 for (theSelection->Init(); theSelection->More(); theSelection->Next())
78 const Handle(SelectBasics_SensitiveEntity)& aSensitive = theSelection->Sensitive()->BaseSensitive();
79 if (aSensitive->NbSubElements() >= BVH_PRIMITIVE_LIMIT)
84 if (aSensitive->IsInstance ("Select3D_SensitiveGroup"))
86 Handle(Select3D_SensitiveGroup) aGroup (Handle(Select3D_SensitiveGroup)::DownCast (aSensitive));
87 const Select3D_EntitySequence& aSubEntities = aGroup->GetEntities();
88 for (Select3D_EntitySequenceIter aSubEntitiesIter (aSubEntities); aSubEntitiesIter.More(); aSubEntitiesIter.Next())
90 const Handle(Select3D_SensitiveEntity)& aSubEntity = aSubEntitiesIter.Value();
91 if (aSubEntity->NbSubElements() >= BVH_PRIMITIVE_LIMIT)
100 //==================================================
103 //==================================================
104 void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSelection,
105 const TopoDS_Shape& theShape,
106 const TopAbs_ShapeEnum theType,
107 const Standard_Real theDeflection,
108 const Standard_Real theDeviationAngle,
109 const Standard_Boolean isAutoTriangulation,
110 const Standard_Integer thePriority,
111 const Standard_Integer theNbPOnEdge,
112 const Standard_Real theMaxParam)
114 Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
116 if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
118 BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle);
121 Handle(StdSelect_BRepOwner) aBrepOwner;
130 case TopAbs_COMPSOLID:
132 TopTools_IndexedMapOfShape aSubShapes;
133 TopExp::MapShapes (theShape, theType, aSubShapes);
135 Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1)));
136 for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex)
138 const TopoDS_Shape& aSubShape = aSubShapes (aShIndex);
139 aBrepOwner = new StdSelect_BRepOwner (aSubShape, aPriority, isComesFromDecomposition);
140 ComputeSensitive (aSubShape, aBrepOwner,
146 isAutoTriangulation);
152 aBrepOwner = new StdSelect_BRepOwner (theShape, aPriority);
153 ComputeSensitive (theShape, aBrepOwner,
159 isAutoTriangulation);
164 //==================================================
167 //==================================================
168 void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSelection,
169 const Handle(SelectMgr_SelectableObject)& theSelectableObj,
170 const TopoDS_Shape& theShape,
171 const TopAbs_ShapeEnum theType,
172 const Standard_Real theDeflection,
173 const Standard_Real theDeviationAngle,
174 const Standard_Boolean isAutoTriangulation,
175 const Standard_Integer thePriority,
176 const Standard_Integer theNbPOnEdge,
177 const Standard_Real theMaxParam)
189 // loading of selectables...
190 for (theSelection->Init(); theSelection->More(); theSelection->Next())
192 Handle(SelectMgr_EntityOwner) anOwner
193 = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId());
194 anOwner->Set (theSelectableObj);
197 PreBuildBVH (theSelection);
200 //==================================================
201 // Function: ComputeSensitive
203 //==================================================
204 void StdSelect_BRepSelectionTool::ComputeSensitive (const TopoDS_Shape& theShape,
205 const Handle(SelectMgr_EntityOwner)& theOwner,
206 const Handle(SelectMgr_Selection)& theSelection,
207 const Standard_Real theDeflection,
208 const Standard_Real theDeviationAngle,
209 const Standard_Integer theNbPOnEdge,
210 const Standard_Real theMaxParam,
211 const Standard_Boolean isAutoTriangulation)
213 switch (theShape.ShapeType())
217 theSelection->Add (new Select3D_SensitivePoint
218 (theOwner, BRep_Tool::Pnt (TopoDS::Vertex (theShape))));
223 Handle(Select3D_SensitiveEntity) aSensitive;
224 GetEdgeSensitive (theShape, theOwner, theSelection,
225 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam,
227 if (!aSensitive.IsNull())
229 theSelection->Add (aSensitive);
235 BRepTools_WireExplorer aWireExp (TopoDS::Wire (theShape));
236 Handle (Select3D_SensitiveEntity) aSensitive;
237 Handle (Select3D_SensitiveWire) aWireSensitive = new Select3D_SensitiveWire (theOwner);
238 theSelection->Add (aWireSensitive);
239 while (aWireExp.More())
241 GetEdgeSensitive (aWireExp.Current(), theOwner, theSelection,
242 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam,
244 if (!aSensitive.IsNull())
246 aWireSensitive->Add (aSensitive);
254 const TopoDS_Face& aFace = TopoDS::Face (theShape);
255 Select3D_EntitySequence aSensitiveList;
256 GetSensitiveForFace (aFace, theOwner,
258 isAutoTriangulation, theNbPOnEdge, theMaxParam);
259 for (Select3D_EntitySequenceIter aSensIter (aSensitiveList);
260 aSensIter.More(); aSensIter.Next())
262 theSelection->Add (aSensIter.Value());
268 case TopAbs_COMPSOLID:
270 TopTools_IndexedMapOfShape aSubfacesMap;
271 TopExp::MapShapes (theShape, TopAbs_FACE, aSubfacesMap);
272 for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
274 ComputeSensitive (aSubfacesMap (aShIndex), theOwner,
276 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
280 case TopAbs_COMPOUND:
283 TopExp_Explorer anExp;
285 for (anExp.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); anExp.More(); anExp.Next())
287 ComputeSensitive (anExp.Current(), theOwner,
289 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
292 for (anExp.Init (theShape, TopAbs_EDGE, TopAbs_FACE); anExp.More(); anExp.Next())
294 ComputeSensitive (anExp.Current(), theOwner,
296 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
299 for (anExp.Init (theShape, TopAbs_WIRE, TopAbs_FACE); anExp.More(); anExp.Next())
301 ComputeSensitive (anExp.Current(), theOwner,
303 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
307 TopTools_IndexedMapOfShape aSubfacesMap;
308 TopExp::MapShapes (theShape, TopAbs_FACE, aSubfacesMap);
309 for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
311 ComputeSensitive (aSubfacesMap (aShIndex), theOwner,
313 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
319 //==================================================
320 // Function: GetPointsFromPolygon
322 //==================================================
323 static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theEdge)
325 Handle(TColgp_HArray1OfPnt) aResultPoints;
327 TopLoc_Location aLocation;
328 Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
329 if (!aPolygon.IsNull())
331 const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
332 aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
333 if (aLocation.IsIdentity())
335 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
337 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
342 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
344 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
347 return aResultPoints;
350 Handle(Poly_Triangulation) aTriangulation;
351 Handle(Poly_PolygonOnTriangulation) anHIndices;
352 BRep_Tool::PolygonOnTriangulation (theEdge, anHIndices, aTriangulation, aLocation);
353 if (!anHIndices.IsNull())
355 const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
356 const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
358 aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
360 if (aLocation.IsIdentity())
362 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
364 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
369 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
371 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
374 return aResultPoints;
376 return aResultPoints;
379 //==================================================
380 // Function: FindLimits
382 //==================================================
383 static Standard_Boolean FindLimits (const Adaptor3d_Curve& theCurve,
384 const Standard_Real theLimit,
385 Standard_Real& theFirst,
386 Standard_Real& theLast)
388 theFirst = theCurve.FirstParameter();
389 theLast = theCurve.LastParameter();
390 Standard_Boolean isFirstInf = Precision::IsNegativeInfinite (theFirst);
391 Standard_Boolean isLastInf = Precision::IsPositiveInfinite (theLast);
392 if (isFirstInf || isLastInf)
395 Standard_Real aDelta = 1.0;
396 Standard_Integer anIterCount = 0;
397 if (isFirstInf && isLastInf)
400 if (anIterCount++ >= 100000) return Standard_False;
404 theCurve.D0 (theFirst, aPnt1);
405 theCurve.D0 (theLast, aPnt2);
406 } while (aPnt1.Distance (aPnt2) < theLimit);
410 theCurve.D0 (theLast, aPnt2);
412 if (anIterCount++ >= 100000) return Standard_False;
414 theFirst = theLast - aDelta;
415 theCurve.D0 (theFirst, aPnt1);
416 } while (aPnt1.Distance (aPnt2) < theLimit);
420 theCurve.D0 (theFirst, aPnt1);
422 if (anIterCount++ >= 100000) return Standard_False;
424 theLast = theFirst + aDelta;
425 theCurve.D0 (theLast, aPnt2);
426 } while (aPnt1.Distance (aPnt2) < theLimit);
429 return Standard_True;
432 //=====================================================
433 // Function : GetEdgeSensitive
435 //=====================================================
436 void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape,
437 const Handle(SelectMgr_EntityOwner)& theOwner,
438 const Handle(SelectMgr_Selection)& theSelection,
439 const Standard_Real theDeflection,
440 const Standard_Real theDeviationAngle,
441 const Standard_Integer theNbPOnEdge,
442 const Standard_Real theMaxParam,
443 Handle(Select3D_SensitiveEntity)& theSensitive)
445 const TopoDS_Edge& anEdge = TopoDS::Edge (theShape);
446 BRepAdaptor_Curve cu3d;
449 cu3d.Initialize (anEdge);
450 } catch (Standard_NullObject) {
454 // try to get points from existing polygons
455 Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge);
456 if (!aPoints.IsNull() && aPoints->Length() > 0)
458 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
462 Standard_Real aParamFirst = cu3d.FirstParameter();
463 Standard_Real aParamLast = cu3d.LastParameter();
464 switch (cu3d.GetType())
468 BRep_Tool::Range (anEdge, aParamFirst, aParamLast);
469 theSensitive = new Select3D_SensitiveSegment (theOwner,
470 cu3d.Value (aParamFirst),
471 cu3d.Value (aParamLast));
476 Handle (Geom_Circle) aCircle = new Geom_Circle (cu3d.Circle());
477 if (aCircle->Radius() <= Precision::Confusion())
479 theSelection->Add (new Select3D_SensitivePoint (theOwner, aCircle->Location()));
483 theSensitive = new Select3D_SensitiveCircle (theOwner, aCircle,
484 aParamFirst, aParamLast, Standard_False, 16);
490 // reproduce drawing behaviour
491 // TODO: remove copy-paste from StdPrs_Curve and some others...
492 if (FindLimits (cu3d, theMaxParam, aParamFirst, aParamLast))
494 Standard_Integer aNbIntervals = cu3d.NbIntervals (GeomAbs_C1);
495 TColStd_Array1OfReal anIntervals (1, aNbIntervals + 1);
496 cu3d.Intervals (anIntervals, GeomAbs_C1);
497 Standard_Real aV1, aV2;
498 Standard_Integer aNumberOfPoints;
499 TColgp_SequenceOfPnt aPointsSeq;
500 for (Standard_Integer anIntervalId = 1; anIntervalId <= aNbIntervals; ++anIntervalId)
502 aV1 = anIntervals (anIntervalId);
503 aV2 = anIntervals (anIntervalId + 1);
504 if (aV2 > aParamFirst && aV1 < aParamLast)
506 aV1 = Max (aV1, aParamFirst);
507 aV2 = Min (aV2, aParamLast);
509 GCPnts_TangentialDeflection anAlgo (cu3d, aV1, aV2, theDeviationAngle, theDeflection);
510 aNumberOfPoints = anAlgo.NbPoints();
512 for (Standard_Integer aPntId = 1; aPntId < aNumberOfPoints; ++aPntId)
514 aPointsSeq.Append (anAlgo.Value (aPntId));
516 if (aNumberOfPoints > 0 && anIntervalId == aNbIntervals)
518 aPointsSeq.Append (anAlgo.Value (aNumberOfPoints));
523 aPoints = new TColgp_HArray1OfPnt (1, aPointsSeq.Length());
524 for (Standard_Integer aPntId = 1; aPntId <= aPointsSeq.Length(); ++aPntId)
526 aPoints->SetValue (aPntId, aPointsSeq.Value (aPntId));
528 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
532 // simple subdivisions
533 Standard_Integer nbintervals = 1;
534 if (cu3d.GetType() == GeomAbs_BSplineCurve)
536 nbintervals = cu3d.NbKnots() - 1;
537 nbintervals = Max (1, nbintervals / 3);
540 Standard_Real aParam;
541 Standard_Integer aPntNb = Max (2, theNbPOnEdge * nbintervals);
542 Standard_Real aParamDelta = (aParamLast - aParamFirst) / (aPntNb - 1);
543 Handle(TColgp_HArray1OfPnt) aPointArray = new TColgp_HArray1OfPnt (1, aPntNb);
544 for (Standard_Integer aPntId = 1; aPntId <= aPntNb; ++aPntId)
546 aParam = aParamFirst + aParamDelta * (aPntId - 1);
547 aPointArray->SetValue (aPntId, cu3d.Value (aParam));
549 theSensitive = new Select3D_SensitiveCurve (theOwner, aPointArray);
555 //=======================================================================
556 //function : GetSensitiveEntityForFace
558 //=======================================================================
559 Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_Face& theFace,
560 const Handle(SelectMgr_EntityOwner)& theOwner,
561 Select3D_EntitySequence& theSensitiveList,
562 const Standard_Boolean /*theAutoTriangulation*/,
563 const Standard_Integer NbPOnEdge,
564 const Standard_Real theMaxParam,
565 const Standard_Boolean theInteriorFlag)
567 // check if there is triangulation of the face...
568 TopLoc_Location aLoc;
569 Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
571 if (!aTriangulation.IsNull())
573 Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
574 theSensitiveList.Append (STG);
575 return Standard_True;
578 // for faces with triangulation bugs or without autotriangulation ....
579 // very ugly and should not even exist ...
580 BRepAdaptor_Surface BS;
581 BS.Initialize (theFace);
583 Standard_Real FirstU = BS.FirstUParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstUParameter();
584 Standard_Real LastU = BS.LastUParameter() >= Precision::Infinite() ? theMaxParam : BS.LastUParameter();
585 Standard_Real FirstV = BS.FirstVParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstVParameter();
586 Standard_Real LastV = BS.LastVParameter() >= Precision::Infinite() ? theMaxParam : BS.LastVParameter();
588 if (BS.GetType() == GeomAbs_Plane)
591 Handle(TColgp_HArray1OfPnt) P = new TColgp_HArray1OfPnt (1, 5);
592 BS.D0 (FirstU, FirstV, pcur);
593 P->SetValue (1, pcur);
594 BS.D0 (LastU, FirstV, pcur);
595 P->SetValue (2, pcur);
596 BS.D0 (LastU, LastV, pcur);
597 P->SetValue (3, pcur);
598 BS.D0 (FirstU, LastV, pcur);
599 P->SetValue (4, pcur);
600 P->SetValue (5, P->Value (1));
601 // if the plane is "infinite", it is sensitive only on the border limited by MaxParam
602 if (FirstU == -theMaxParam && LastU == theMaxParam && FirstV == -theMaxParam && LastV == theMaxParam)
604 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, Select3D_TOS_BOUNDARY));
608 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
609 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, TS));
611 return Standard_True;
614 // This is construction of a sevsitive polygon from the exterior contour of the face...
615 // It is not good at all, but...
617 TopExp_Explorer anExpWiresInFace (theFace, TopAbs_WIRE);
618 if (anExpWiresInFace.More())
620 // believing that this is the first... to be seen
621 aWire = TopoDS::Wire (anExpWiresInFace.Current());
625 return Standard_False;
628 TColgp_SequenceOfPnt WirePoints;
629 Standard_Boolean FirstExp = Standard_True;
630 Standard_Real wf, wl;
631 BRepAdaptor_Curve cu3d;
632 for (BRepTools_WireExplorer aWireExplorer (aWire);
633 aWireExplorer.More(); aWireExplorer.Next())
635 cu3d.Initialize (aWireExplorer.Current());
636 BRep_Tool::Range (aWireExplorer.Current(), wf, wl);
637 if (Abs (wf - wl) <= Precision::Confusion())
640 cout<<" StdSelect_BRepSelectionTool : Curve where ufirst = ulast ...."<<endl;
647 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
649 WirePoints.Append (cu3d.Value (wf));
653 WirePoints.Append (cu3d.Value (wl));
655 FirstExp = Standard_False;
658 switch (cu3d.GetType())
662 WirePoints.Append (cu3d.Value ((aWireExplorer.Orientation() == TopAbs_FORWARD) ? wl : wf));
667 if (2 * M_PI - Abs (wl - wf) <= Precision::Confusion())
669 if (BS.GetType() == GeomAbs_Cylinder ||
670 BS.GetType() == GeomAbs_Torus ||
671 BS.GetType() == GeomAbs_Cone ||
672 BS.GetType() == GeomAbs_BSplineSurface) // beuurkk pour l'instant...
674 Standard_Real ff = wf ,ll = wl;
675 Standard_Real dw =(Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
676 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
678 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
680 WirePoints.Append (cu3d.Value (wc));
683 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
685 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
687 WirePoints.Append (cu3d.Value (wc));
693 if (cu3d.Circle().Radius() <= Precision::Confusion())
695 theSensitiveList.Append (new Select3D_SensitivePoint (theOwner, cu3d.Circle().Location()));
699 theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16));
705 Standard_Real ff = wf, ll = wl;
706 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
707 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
709 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
711 WirePoints.Append (cu3d.Value (wc));
714 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
716 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
718 WirePoints.Append (cu3d.Value (wc));
726 Standard_Real ff = wf, ll = wl;
727 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
728 if (aWireExplorer.Orientation()==TopAbs_FORWARD)
730 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
732 WirePoints.Append (cu3d.Value (wc));
735 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
737 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
739 WirePoints.Append (cu3d.Value (wc));
746 Standard_Integer ArrayPosition = WirePoints.Length();
748 Handle(TColgp_HArray1OfPnt) facepoints = new TColgp_HArray1OfPnt (1, ArrayPosition);
749 for (Standard_Integer I = 1; I <= ArrayPosition; ++I)
751 facepoints->SetValue (I, WirePoints.Value(I));
754 if ((facepoints->Array1()).Length() > 1)
755 { //1 if only one circular edge
756 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
757 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, facepoints, TS));
759 return Standard_True;