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.ixx>
18 #include <GeomAdaptor_Curve.hxx>
19 #include <BRepAdaptor_Curve.hxx>
20 #include <TopTools_IndexedMapOfShape.hxx>
22 #include <TopExp_Explorer.hxx>
23 #include <BRepTools_WireExplorer.hxx>
24 #include <Select3D_SensitivePoint.hxx>
25 #include <StdSelect_BRepOwner.hxx>
27 #include <BRepAdaptor_Curve.hxx>
28 #include <BRepAdaptor_Surface.hxx>
29 #include <GeomAbs_SurfaceType.hxx>
30 #include <BRepBndLib.hxx>
31 #include <Bnd_Box.hxx>
32 #include <BRep_Tool.hxx>
33 #include <Geom_Circle.hxx>
34 #include <Select3D_SensitiveCircle.hxx>
35 #include <Select3D_SensitiveCurve.hxx>
36 #include <Select3D_SensitiveSegment.hxx>
37 #include <Select3D_SensitiveWire.hxx>
38 #include <Select3D_SensitiveFace.hxx>
39 #include <Select3D_SensitiveBox.hxx>
40 #include <Select3D_SensitiveTriangulation.hxx>
41 #include <Select3D_SensitiveTriangle.hxx>
42 #include <Select3D_SensitiveGroup.hxx>
44 #include <Select3D_ListIteratorOfListOfSensitive.hxx>
45 #include <Select3D_ListOfSensitiveTriangle.hxx>
46 #include <TColgp_HArray1OfPnt.hxx>
47 #include <TColgp_SequenceOfPnt.hxx>
48 #include <TColStd_Array1OfReal.hxx>
49 #include <BRep_Tool.hxx>
50 #include <BRepTools.hxx>
51 #include <Select3D_TypeOfSensitivity.hxx>
52 #include <Precision.hxx>
53 #include <gp_Circ.hxx>
54 #include <GCPnts_TangentialDeflection.hxx>
55 #include <TopoDS_Wire.hxx>
56 #include <Poly_Array1OfTriangle.hxx>
57 #include <Poly_Polygon3D.hxx>
58 #include <Poly_PolygonOnTriangulation.hxx>
59 #include <Poly_Triangulation.hxx>
60 #include <BRepMesh_IncrementalMesh.hxx>
61 #include <Standard_NullObject.hxx>
62 #include <Standard_ErrorHandler.hxx>
64 //==================================================
67 //==================================================
68 void StdSelect_BRepSelectionTool
69 ::Load (const Handle(SelectMgr_Selection)& theSelection,
70 const TopoDS_Shape& theShape,
71 const TopAbs_ShapeEnum theType,
72 const Standard_Real theDeflection,
73 const Standard_Real theDeviationAngle,
74 const Standard_Boolean isAutoTriangulation,
75 const Standard_Integer thePriority,
76 const Standard_Integer theNbPOnEdge,
77 const Standard_Real theMaxParam)
79 Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
81 if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
83 BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle);
86 Handle(StdSelect_BRepOwner) aBrepOwner;
95 case TopAbs_COMPSOLID:
97 TopTools_IndexedMapOfShape aSubShapes;
98 TopExp::MapShapes (theShape, theType, aSubShapes);
100 Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1)));
101 for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex)
103 const TopoDS_Shape& aSubShape = aSubShapes (aShIndex);
104 aBrepOwner = new StdSelect_BRepOwner (aSubShape, aPriority, isComesFromDecomposition);
105 ComputeSensitive (aSubShape, aBrepOwner,
111 isAutoTriangulation);
117 aBrepOwner = new StdSelect_BRepOwner (theShape, aPriority);
118 ComputeSensitive (theShape, aBrepOwner,
124 isAutoTriangulation);
129 //==================================================
132 //==================================================
133 void StdSelect_BRepSelectionTool
134 ::Load (const Handle(SelectMgr_Selection)& theSelection,
135 const Handle(SelectMgr_SelectableObject)& theSelectableObj,
136 const TopoDS_Shape& theShape,
137 const TopAbs_ShapeEnum theType,
138 const Standard_Real theDeflection,
139 const Standard_Real theDeviationAngle,
140 const Standard_Boolean isAutoTriangulation,
141 const Standard_Integer thePriority,
142 const Standard_Integer theNbPOnEdge,
143 const Standard_Real theMaxParam)
155 // loading of selectables...
156 for (theSelection->Init(); theSelection->More(); theSelection->Next())
158 Handle(SelectMgr_EntityOwner) anOwner
159 = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->OwnerId());
160 anOwner->Set (theSelectableObj);
164 //==================================================
165 // Function: ComputeSensitive
167 //==================================================
168 void StdSelect_BRepSelectionTool
169 ::ComputeSensitive (const TopoDS_Shape& theShape,
170 const Handle(StdSelect_BRepOwner)& theOwner,
171 const Handle(SelectMgr_Selection)& theSelection,
172 const Standard_Real theDeflection,
173 const Standard_Real theDeviationAngle,
174 const Standard_Integer theNbPOnEdge,
175 const Standard_Real theMaxParam,
176 const Standard_Boolean isAutoTriangulation)
178 switch (theShape.ShapeType())
182 theSelection->Add (new Select3D_SensitivePoint
183 (theOwner, BRep_Tool::Pnt (TopoDS::Vertex (theShape))));
188 Handle(Select3D_SensitiveEntity) aSensitive;
189 GetEdgeSensitive (theShape, theOwner, theSelection,
190 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam,
192 if (!aSensitive.IsNull())
194 theSelection->Add (aSensitive);
200 BRepTools_WireExplorer aWireExp (TopoDS::Wire (theShape));
201 Handle (Select3D_SensitiveEntity) aSensitive;
202 Handle (Select3D_SensitiveWire) aWireSensitive = new Select3D_SensitiveWire (theOwner);
203 theSelection->Add (aWireSensitive);
204 while (aWireExp.More())
206 GetEdgeSensitive (aWireExp.Current(), theOwner, theSelection,
207 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam,
209 if (!aSensitive.IsNull())
211 aWireSensitive->Add (aSensitive);
219 const TopoDS_Face& aFace = TopoDS::Face (theShape);
220 Select3D_ListOfSensitive aSensitiveList;
221 GetSensitiveForFace (aFace, theOwner,
223 isAutoTriangulation, theNbPOnEdge, theMaxParam);
224 for (Select3D_ListIteratorOfListOfSensitive aSensIter (aSensitiveList);
225 aSensIter.More(); aSensIter.Next())
227 theSelection->Add (aSensIter.Value());
233 case TopAbs_COMPSOLID:
235 TopTools_IndexedMapOfShape aSubfacesMap;
236 TopExp::MapShapes (theShape, TopAbs_FACE, aSubfacesMap);
237 for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
239 ComputeSensitive (aSubfacesMap (aShIndex), theOwner,
241 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
245 case TopAbs_COMPOUND:
248 TopExp_Explorer anExp;
250 for (anExp.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); anExp.More(); anExp.Next())
252 ComputeSensitive (anExp.Current(), theOwner,
254 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
257 for (anExp.Init (theShape, TopAbs_EDGE, TopAbs_FACE); anExp.More(); anExp.Next())
259 ComputeSensitive (anExp.Current(), theOwner,
261 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
264 for (anExp.Init (theShape, TopAbs_WIRE, TopAbs_FACE); anExp.More(); anExp.Next())
266 ComputeSensitive (anExp.Current(), theOwner,
268 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
272 TopTools_IndexedMapOfShape aSubfacesMap;
273 TopExp::MapShapes (theShape, TopAbs_FACE, aSubfacesMap);
274 for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
276 ComputeSensitive (aSubfacesMap (aShIndex), theOwner,
278 theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
284 //==================================================
285 // Function: GetPointsFromPolygon
287 //==================================================
288 static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theEdge,
289 const Standard_Real theDeflection)
291 Handle(TColgp_HArray1OfPnt) aResultPoints;
293 Standard_Real fi, la;
294 Handle(Geom_Curve) CC3d = BRep_Tool::Curve (theEdge, fi, la);
296 TopLoc_Location aLocation;
297 Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
298 if (!aPolygon.IsNull())
300 Standard_Boolean isOK = aPolygon->Deflection() <= theDeflection;
301 isOK = isOK || (CC3d.IsNull());
304 const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
305 aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
306 if (aLocation.IsIdentity())
308 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
310 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
315 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
317 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
320 return aResultPoints;
324 Handle(Poly_Triangulation) aTriangulation;
325 Handle(Poly_PolygonOnTriangulation) anHIndices;
326 BRep_Tool::PolygonOnTriangulation (theEdge, anHIndices, aTriangulation, aLocation);
327 if (!anHIndices.IsNull())
329 Standard_Boolean isOK = anHIndices->Deflection() <= theDeflection;
330 isOK = isOK || (CC3d.IsNull());
333 const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
334 const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
336 aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
338 if (aLocation.IsIdentity())
340 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
342 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
347 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
349 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
352 return aResultPoints;
355 return aResultPoints;
358 //==================================================
359 // Function: FindLimits
361 //==================================================
362 static Standard_Boolean FindLimits (const Adaptor3d_Curve& theCurve,
363 const Standard_Real theLimit,
364 Standard_Real& theFirst,
365 Standard_Real& theLast)
367 theFirst = theCurve.FirstParameter();
368 theLast = theCurve.LastParameter();
369 Standard_Boolean isFirstInf = Precision::IsNegativeInfinite (theFirst);
370 Standard_Boolean isLastInf = Precision::IsPositiveInfinite (theLast);
371 if (isFirstInf || isLastInf)
374 Standard_Real aDelta = 1.0;
375 Standard_Integer anIterCount = 0;
376 if (isFirstInf && isLastInf)
379 if (anIterCount++ >= 100000) return Standard_False;
383 theCurve.D0 (theFirst, aPnt1);
384 theCurve.D0 (theLast, aPnt2);
385 } while (aPnt1.Distance (aPnt2) < theLimit);
389 theCurve.D0 (theLast, aPnt2);
391 if (anIterCount++ >= 100000) return Standard_False;
393 theFirst = theLast - aDelta;
394 theCurve.D0 (theFirst, aPnt1);
395 } while (aPnt1.Distance (aPnt2) < theLimit);
399 theCurve.D0 (theFirst, aPnt1);
401 if (anIterCount++ >= 100000) return Standard_False;
403 theLast = theFirst + aDelta;
404 theCurve.D0 (theLast, aPnt2);
405 } while (aPnt1.Distance (aPnt2) < theLimit);
408 return Standard_True;
411 //=====================================================
412 // Function : GetEdgeSensitive
413 // Purpose : create a sensitive edge to add it
414 // in computeselection to "aselection" (case of selection of an edge)
415 // or to "aSensitiveWire" (case of selection of a wire; in this case,
416 // the sensitive wire is added to "aselection" )
417 // odl - for selection by rectangle -
418 //=====================================================
419 void StdSelect_BRepSelectionTool
420 ::GetEdgeSensitive (const TopoDS_Shape& theShape,
421 const Handle(StdSelect_BRepOwner)& theOwner,
422 const Handle(SelectMgr_Selection)& theSelection,
423 const Standard_Real theDeflection,
424 const Standard_Real theDeviationAngle,
425 const Standard_Integer theNbPOnEdge,
426 const Standard_Real theMaxParam,
427 Handle(Select3D_SensitiveEntity)& theSensitive)
429 const TopoDS_Edge& anEdge = TopoDS::Edge (theShape);
430 BRepAdaptor_Curve cu3d;
433 cu3d.Initialize (anEdge);
434 } catch (Standard_NullObject) {
438 // try to get points from existing polygons
439 Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge, theDeflection);
440 if (!aPoints.IsNull() && aPoints->Length() > 0)
442 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
446 Standard_Real aParamFirst = cu3d.FirstParameter();
447 Standard_Real aParamLast = cu3d.LastParameter();
448 switch (cu3d.GetType())
452 BRep_Tool::Range (anEdge, aParamFirst, aParamLast);
453 theSensitive = new Select3D_SensitiveSegment (theOwner,
454 cu3d.Value (aParamFirst),
455 cu3d.Value (aParamLast));
460 Handle (Geom_Circle) aCircle = new Geom_Circle (cu3d.Circle());
461 if (aCircle->Radius() <= Precision::Confusion())
463 theSelection->Add (new Select3D_SensitivePoint (theOwner, aCircle->Location()));
467 theSensitive = new Select3D_SensitiveCircle (theOwner, aCircle,
468 aParamFirst, aParamLast, Standard_False, 16);
474 // reproduce drawing behaviour
475 // TODO: remove copy-paste from StdPrs_Curve and some others...
476 if (FindLimits (cu3d, theMaxParam, aParamFirst, aParamLast))
478 Standard_Integer aNbIntervals = cu3d.NbIntervals (GeomAbs_C1);
479 TColStd_Array1OfReal anIntervals (1, aNbIntervals + 1);
480 cu3d.Intervals (anIntervals, GeomAbs_C1);
481 Standard_Real aV1, aV2;
482 Standard_Integer aNumberOfPoints;
483 TColgp_SequenceOfPnt aPointsSeq;
484 for (Standard_Integer anIntervalId = 1; anIntervalId <= aNbIntervals; ++anIntervalId)
486 aV1 = anIntervals (anIntervalId);
487 aV2 = anIntervals (anIntervalId + 1);
488 if (aV2 > aParamFirst && aV1 < aParamLast)
490 aV1 = Max (aV1, aParamFirst);
491 aV2 = Min (aV2, aParamLast);
493 GCPnts_TangentialDeflection anAlgo (cu3d, aV1, aV2, theDeviationAngle, theDeflection);
494 aNumberOfPoints = anAlgo.NbPoints();
496 for (Standard_Integer aPntId = 1; aPntId < aNumberOfPoints; ++aPntId)
498 aPointsSeq.Append (anAlgo.Value (aPntId));
500 if (aNumberOfPoints > 0 && anIntervalId == aNbIntervals)
502 aPointsSeq.Append (anAlgo.Value (aNumberOfPoints));
507 aPoints = new TColgp_HArray1OfPnt (1, aPointsSeq.Length());
508 for (Standard_Integer aPntId = 1; aPntId <= aPointsSeq.Length(); ++aPntId)
510 aPoints->SetValue (aPntId, aPointsSeq.Value (aPntId));
512 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
516 // simple subdivisions
517 Standard_Integer nbintervals = 1;
518 if (cu3d.GetType() == GeomAbs_BSplineCurve)
520 nbintervals = cu3d.NbKnots() - 1;
521 nbintervals = Max (1, nbintervals / 3);
524 Standard_Real aParam;
525 Standard_Integer aPntNb = Max (2, theNbPOnEdge * nbintervals);
526 Standard_Real aParamDelta = (aParamLast - aParamFirst) / (aPntNb - 1);
527 Handle(TColgp_HArray1OfPnt) aPointArray = new TColgp_HArray1OfPnt (1, aPntNb);
528 for (Standard_Integer aPntId = 1; aPntId <= aPntNb; ++aPntId)
530 aParam = aParamFirst + aParamDelta * (aPntId - 1);
531 aPointArray->SetValue (aPntId, cu3d.Value (aParam));
533 theSensitive = new Select3D_SensitiveCurve (theOwner, aPointArray);
539 //=====================================================
540 // Function : GetStandardPriority
542 //=====================================================
543 Standard_Integer StdSelect_BRepSelectionTool::GetStandardPriority (const TopoDS_Shape& theShape,
544 const TopAbs_ShapeEnum theType)
548 case TopAbs_VERTEX: return 8;
549 case TopAbs_EDGE: return 7;
550 case TopAbs_WIRE: return 6;
551 case TopAbs_FACE: return 5;
554 switch (theShape.ShapeType())
556 case TopAbs_VERTEX: return 9;
557 case TopAbs_EDGE: return 8;
558 case TopAbs_WIRE: return 7;
559 case TopAbs_FACE: return 6;
560 case TopAbs_SHELL: return 5;
561 case TopAbs_COMPOUND:
562 case TopAbs_COMPSOLID:
571 //=======================================================================
572 //function : GetSensitiveEntityForFace
574 //=======================================================================
575 Standard_Boolean StdSelect_BRepSelectionTool
576 ::GetSensitiveForFace (const TopoDS_Face& theFace,
577 const Handle(StdSelect_BRepOwner)& theOwner,
578 Select3D_ListOfSensitive& theSensitiveList,
579 const Standard_Boolean /*theAutoTriangulation*/,
580 const Standard_Integer NbPOnEdge,
581 const Standard_Real theMaxParam,
582 const Standard_Boolean theInteriorFlag)
584 // check if there is triangulation of the face...
585 TopLoc_Location aLoc;
586 Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
588 if (!aTriangulation.IsNull())
590 Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
591 theSensitiveList.Append (STG);
592 return Standard_True;
595 // for faces with triangulation bugs or without autotriangulation ....
596 // very ugly and should not even exist ...
597 BRepAdaptor_Surface BS;
598 BS.Initialize (theFace);
600 Standard_Real FirstU = BS.FirstUParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstUParameter();
601 Standard_Real LastU = BS.LastUParameter() >= Precision::Infinite() ? theMaxParam : BS.LastUParameter();
602 Standard_Real FirstV = BS.FirstVParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstVParameter();
603 Standard_Real LastV = BS.LastVParameter() >= Precision::Infinite() ? theMaxParam : BS.LastVParameter();
605 if (BS.GetType() == GeomAbs_Plane)
608 Handle(TColgp_HArray1OfPnt) P = new TColgp_HArray1OfPnt (1, 5);
609 BS.D0 (FirstU, FirstV, pcur);
610 P->SetValue (1, pcur);
611 BS.D0 (LastU, FirstV, pcur);
612 P->SetValue (2, pcur);
613 BS.D0 (LastU, LastV, pcur);
614 P->SetValue (3, pcur);
615 BS.D0 (FirstU, LastV, pcur);
616 P->SetValue (4, pcur);
617 P->SetValue (5, P->Value (1));
618 // if the plane is "infinite", it is sensitive only on the border limited by MaxParam
619 if (FirstU == -theMaxParam && LastU == theMaxParam && FirstV == -theMaxParam && LastV == theMaxParam)
621 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, Select3D_TOS_BOUNDARY));
625 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
626 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, TS));
628 return Standard_True;
631 // This is construction of a sevsitive polygon from the exterior contour of the face...
632 // It is not good at all, but...
634 TopExp_Explorer anExpWiresInFace (theFace, TopAbs_WIRE);
635 if (anExpWiresInFace.More())
637 // believing that this is the first... to be seen
638 aWire = TopoDS::Wire (anExpWiresInFace.Current());
642 return Standard_False;
645 TColgp_SequenceOfPnt WirePoints;
646 Standard_Boolean FirstExp = Standard_True;
647 Standard_Real wf, wl;
648 BRepAdaptor_Curve cu3d;
649 for (BRepTools_WireExplorer aWireExplorer (aWire);
650 aWireExplorer.More(); aWireExplorer.Next())
652 cu3d.Initialize (aWireExplorer.Current());
653 BRep_Tool::Range (aWireExplorer.Current(), wf, wl);
654 if (Abs (wf - wl) <= Precision::Confusion())
657 cout<<" StdSelect_BRepSelectionTool : Curve where ufirst = ulast ...."<<endl;
664 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
666 WirePoints.Append (cu3d.Value (wf));
670 WirePoints.Append (cu3d.Value (wl));
672 FirstExp = Standard_False;
675 switch (cu3d.GetType())
679 WirePoints.Append (cu3d.Value ((aWireExplorer.Orientation() == TopAbs_FORWARD) ? wl : wf));
684 if (2 * M_PI - Abs (wl - wf) <= Precision::Confusion())
686 if (BS.GetType() == GeomAbs_Cylinder ||
687 BS.GetType() == GeomAbs_Torus ||
688 BS.GetType() == GeomAbs_Cone ||
689 BS.GetType() == GeomAbs_BSplineSurface) // beuurkk pour l'instant...
691 Standard_Real ff = wf ,ll = wl;
692 Standard_Real dw =(Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
693 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
695 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
697 WirePoints.Append (cu3d.Value (wc));
700 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
702 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
704 WirePoints.Append (cu3d.Value (wc));
710 if (cu3d.Circle().Radius() <= Precision::Confusion())
712 theSensitiveList.Append (new Select3D_SensitivePoint (theOwner, cu3d.Circle().Location()));
716 theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16));
722 Standard_Real ff = wf, ll = wl;
723 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
724 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
726 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
728 WirePoints.Append (cu3d.Value (wc));
731 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
733 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
735 WirePoints.Append (cu3d.Value (wc));
743 Standard_Real ff = wf, ll = wl;
744 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
745 if (aWireExplorer.Orientation()==TopAbs_FORWARD)
747 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
749 WirePoints.Append (cu3d.Value (wc));
752 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
754 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
756 WirePoints.Append (cu3d.Value (wc));
763 Standard_Integer ArrayPosition = WirePoints.Length();
765 Handle(TColgp_HArray1OfPnt) facepoints = new TColgp_HArray1OfPnt (1, ArrayPosition);
766 for (Standard_Integer I = 1; I <= ArrayPosition; ++I)
768 facepoints->SetValue (I, WirePoints.Value(I));
771 if ((facepoints->Array1()).Length() > 1)
772 { //1 if only one circular edge
773 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
774 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, facepoints, TS));
776 return Standard_True;