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_SensitiveEntity.hxx>
35 #include <Select3D_SensitiveCircle.hxx>
36 #include <Select3D_SensitiveCurve.hxx>
37 #include <Select3D_SensitiveSegment.hxx>
38 #include <Select3D_SensitiveWire.hxx>
39 #include <Select3D_SensitiveFace.hxx>
40 #include <Select3D_SensitiveBox.hxx>
41 #include <Select3D_SensitiveTriangulation.hxx>
42 #include <Select3D_SensitiveTriangle.hxx>
43 #include <Select3D_SensitiveGroup.hxx>
44 #include <SelectMgr_Selection.hxx>
45 #include <TColgp_HArray1OfPnt.hxx>
46 #include <TColgp_SequenceOfPnt.hxx>
47 #include <TColStd_Array1OfReal.hxx>
48 #include <BRep_Tool.hxx>
49 #include <BRepTools.hxx>
50 #include <Select3D_TypeOfSensitivity.hxx>
51 #include <Precision.hxx>
52 #include <gp_Circ.hxx>
53 #include <GCPnts_TangentialDeflection.hxx>
54 #include <TopoDS_Wire.hxx>
55 #include <Poly_Array1OfTriangle.hxx>
56 #include <Poly_Polygon3D.hxx>
57 #include <Poly_PolygonOnTriangulation.hxx>
58 #include <Poly_Triangulation.hxx>
59 #include <BRepMesh_IncrementalMesh.hxx>
60 #include <Standard_NullObject.hxx>
61 #include <Standard_ErrorHandler.hxx>
63 #define BVH_PRIMITIVE_LIMIT 800000
65 //==================================================
66 // function: preBuildBVH
67 // purpose : Pre-builds BVH tree for heavyweight
68 // sensitive entities with sub-elements
69 // amount more than BVH_PRIMITIVE_LIMIT
70 //==================================================
71 void StdSelect_BRepSelectionTool::preBuildBVH (const Handle(SelectMgr_Selection)& theSelection)
73 for (theSelection->Init(); theSelection->More(); theSelection->Next())
75 const Handle(SelectBasics_SensitiveEntity)& aSensitive = theSelection->Sensitive()->BaseSensitive();
76 if (aSensitive->NbSubElements() >= BVH_PRIMITIVE_LIMIT)
81 if (aSensitive->IsInstance ("Select3D_SensitiveGroup"))
83 const Handle(Select3D_SensitiveGroup)& aGroup = Handle(Select3D_SensitiveGroup)::DownCast (aSensitive);
84 const Select3D_EntitySequence& aSubEntities = aGroup->GetEntities();
85 for (Select3D_EntitySequenceIter aSubEntitiesIter (aSubEntities); aSubEntitiesIter.More(); aSubEntitiesIter.Next())
87 const Handle(Select3D_SensitiveEntity)& aSubEntity = aSubEntitiesIter.Value();
88 if (aSubEntity->NbSubElements() >= BVH_PRIMITIVE_LIMIT)
97 //==================================================
100 //==================================================
101 void StdSelect_BRepSelectionTool
102 ::Load (const Handle(SelectMgr_Selection)& theSelection,
103 const TopoDS_Shape& theShape,
104 const TopAbs_ShapeEnum theType,
105 const Standard_Real theDeflection,
106 const Standard_Real theDeviationAngle,
107 const Standard_Boolean isAutoTriangulation,
108 const Standard_Integer thePriority,
109 const Standard_Integer theNbPOnEdge,
110 const Standard_Real theMaxParam)
112 Standard_Integer aPriority = (thePriority == -1) ? GetStandardPriority (theShape, theType) : thePriority;
114 if( isAutoTriangulation && !BRepTools::Triangulation (theShape, Precision::Infinite()) )
116 BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle);
119 Handle(StdSelect_BRepOwner) aBrepOwner;
128 case TopAbs_COMPSOLID:
130 TopTools_IndexedMapOfShape aSubShapes;
131 TopExp::MapShapes (theShape, theType, aSubShapes);
133 Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1)));
134 for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex)
136 const TopoDS_Shape& aSubShape = aSubShapes (aShIndex);
137 aBrepOwner = new StdSelect_BRepOwner (aSubShape, aPriority, isComesFromDecomposition);
138 ComputeSensitive (aSubShape, aBrepOwner,
144 isAutoTriangulation);
150 aBrepOwner = new StdSelect_BRepOwner (theShape, aPriority);
151 ComputeSensitive (theShape, aBrepOwner,
157 isAutoTriangulation);
162 //==================================================
165 //==================================================
166 void StdSelect_BRepSelectionTool
167 ::Load (const Handle(SelectMgr_Selection)& theSelection,
168 const Handle(SelectMgr_SelectableObject)& theSelectableObj,
169 const TopoDS_Shape& theShape,
170 const TopAbs_ShapeEnum theType,
171 const Standard_Real theDeflection,
172 const Standard_Real theDeviationAngle,
173 const Standard_Boolean isAutoTriangulation,
174 const Standard_Integer thePriority,
175 const Standard_Integer theNbPOnEdge,
176 const Standard_Real theMaxParam)
188 // loading of selectables...
189 for (theSelection->Init(); theSelection->More(); theSelection->Next())
191 Handle(SelectMgr_EntityOwner) anOwner
192 = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId());
193 anOwner->Set (theSelectableObj);
196 preBuildBVH (theSelection);
199 //==================================================
200 // Function: ComputeSensitive
202 //==================================================
203 void StdSelect_BRepSelectionTool
204 ::ComputeSensitive (const TopoDS_Shape& theShape,
205 const Handle(StdSelect_BRepOwner)& 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,
324 const Standard_Real theDeflection)
326 Handle(TColgp_HArray1OfPnt) aResultPoints;
328 Standard_Real fi, la;
329 Handle(Geom_Curve) CC3d = BRep_Tool::Curve (theEdge, fi, la);
331 TopLoc_Location aLocation;
332 Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
333 if (!aPolygon.IsNull())
335 Standard_Boolean isOK = aPolygon->Deflection() <= theDeflection;
336 isOK = isOK || (CC3d.IsNull());
339 const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
340 aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
341 if (aLocation.IsIdentity())
343 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
345 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
350 for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
352 aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
355 return aResultPoints;
359 Handle(Poly_Triangulation) aTriangulation;
360 Handle(Poly_PolygonOnTriangulation) anHIndices;
361 BRep_Tool::PolygonOnTriangulation (theEdge, anHIndices, aTriangulation, aLocation);
362 if (!anHIndices.IsNull())
364 Standard_Boolean isOK = anHIndices->Deflection() <= theDeflection;
365 isOK = isOK || (CC3d.IsNull());
368 const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
369 const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
371 aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
373 if (aLocation.IsIdentity())
375 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
377 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
382 for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
384 aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
387 return aResultPoints;
390 return aResultPoints;
393 //==================================================
394 // Function: FindLimits
396 //==================================================
397 static Standard_Boolean FindLimits (const Adaptor3d_Curve& theCurve,
398 const Standard_Real theLimit,
399 Standard_Real& theFirst,
400 Standard_Real& theLast)
402 theFirst = theCurve.FirstParameter();
403 theLast = theCurve.LastParameter();
404 Standard_Boolean isFirstInf = Precision::IsNegativeInfinite (theFirst);
405 Standard_Boolean isLastInf = Precision::IsPositiveInfinite (theLast);
406 if (isFirstInf || isLastInf)
409 Standard_Real aDelta = 1.0;
410 Standard_Integer anIterCount = 0;
411 if (isFirstInf && isLastInf)
414 if (anIterCount++ >= 100000) return Standard_False;
418 theCurve.D0 (theFirst, aPnt1);
419 theCurve.D0 (theLast, aPnt2);
420 } while (aPnt1.Distance (aPnt2) < theLimit);
424 theCurve.D0 (theLast, aPnt2);
426 if (anIterCount++ >= 100000) return Standard_False;
428 theFirst = theLast - aDelta;
429 theCurve.D0 (theFirst, aPnt1);
430 } while (aPnt1.Distance (aPnt2) < theLimit);
434 theCurve.D0 (theFirst, aPnt1);
436 if (anIterCount++ >= 100000) return Standard_False;
438 theLast = theFirst + aDelta;
439 theCurve.D0 (theLast, aPnt2);
440 } while (aPnt1.Distance (aPnt2) < theLimit);
443 return Standard_True;
446 //=====================================================
447 // Function : GetEdgeSensitive
448 // Purpose : create a sensitive edge to add it
449 // in computeselection to "aselection" (case of selection of an edge)
450 // or to "aSensitiveWire" (case of selection of a wire; in this case,
451 // the sensitive wire is added to "aselection" )
452 // odl - for selection by rectangle -
453 //=====================================================
454 void StdSelect_BRepSelectionTool
455 ::GetEdgeSensitive (const TopoDS_Shape& theShape,
456 const Handle(StdSelect_BRepOwner)& theOwner,
457 const Handle(SelectMgr_Selection)& theSelection,
458 const Standard_Real theDeflection,
459 const Standard_Real theDeviationAngle,
460 const Standard_Integer theNbPOnEdge,
461 const Standard_Real theMaxParam,
462 Handle(Select3D_SensitiveEntity)& theSensitive)
464 const TopoDS_Edge& anEdge = TopoDS::Edge (theShape);
465 BRepAdaptor_Curve cu3d;
468 cu3d.Initialize (anEdge);
469 } catch (Standard_NullObject) {
473 // try to get points from existing polygons
474 Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (anEdge, theDeflection);
475 if (!aPoints.IsNull() && aPoints->Length() > 0)
477 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
481 Standard_Real aParamFirst = cu3d.FirstParameter();
482 Standard_Real aParamLast = cu3d.LastParameter();
483 switch (cu3d.GetType())
487 BRep_Tool::Range (anEdge, aParamFirst, aParamLast);
488 theSensitive = new Select3D_SensitiveSegment (theOwner,
489 cu3d.Value (aParamFirst),
490 cu3d.Value (aParamLast));
495 Handle (Geom_Circle) aCircle = new Geom_Circle (cu3d.Circle());
496 if (aCircle->Radius() <= Precision::Confusion())
498 theSelection->Add (new Select3D_SensitivePoint (theOwner, aCircle->Location()));
502 theSensitive = new Select3D_SensitiveCircle (theOwner, aCircle,
503 aParamFirst, aParamLast, Standard_False, 16);
509 // reproduce drawing behaviour
510 // TODO: remove copy-paste from StdPrs_Curve and some others...
511 if (FindLimits (cu3d, theMaxParam, aParamFirst, aParamLast))
513 Standard_Integer aNbIntervals = cu3d.NbIntervals (GeomAbs_C1);
514 TColStd_Array1OfReal anIntervals (1, aNbIntervals + 1);
515 cu3d.Intervals (anIntervals, GeomAbs_C1);
516 Standard_Real aV1, aV2;
517 Standard_Integer aNumberOfPoints;
518 TColgp_SequenceOfPnt aPointsSeq;
519 for (Standard_Integer anIntervalId = 1; anIntervalId <= aNbIntervals; ++anIntervalId)
521 aV1 = anIntervals (anIntervalId);
522 aV2 = anIntervals (anIntervalId + 1);
523 if (aV2 > aParamFirst && aV1 < aParamLast)
525 aV1 = Max (aV1, aParamFirst);
526 aV2 = Min (aV2, aParamLast);
528 GCPnts_TangentialDeflection anAlgo (cu3d, aV1, aV2, theDeviationAngle, theDeflection);
529 aNumberOfPoints = anAlgo.NbPoints();
531 for (Standard_Integer aPntId = 1; aPntId < aNumberOfPoints; ++aPntId)
533 aPointsSeq.Append (anAlgo.Value (aPntId));
535 if (aNumberOfPoints > 0 && anIntervalId == aNbIntervals)
537 aPointsSeq.Append (anAlgo.Value (aNumberOfPoints));
542 aPoints = new TColgp_HArray1OfPnt (1, aPointsSeq.Length());
543 for (Standard_Integer aPntId = 1; aPntId <= aPointsSeq.Length(); ++aPntId)
545 aPoints->SetValue (aPntId, aPointsSeq.Value (aPntId));
547 theSensitive = new Select3D_SensitiveCurve (theOwner, aPoints);
551 // simple subdivisions
552 Standard_Integer nbintervals = 1;
553 if (cu3d.GetType() == GeomAbs_BSplineCurve)
555 nbintervals = cu3d.NbKnots() - 1;
556 nbintervals = Max (1, nbintervals / 3);
559 Standard_Real aParam;
560 Standard_Integer aPntNb = Max (2, theNbPOnEdge * nbintervals);
561 Standard_Real aParamDelta = (aParamLast - aParamFirst) / (aPntNb - 1);
562 Handle(TColgp_HArray1OfPnt) aPointArray = new TColgp_HArray1OfPnt (1, aPntNb);
563 for (Standard_Integer aPntId = 1; aPntId <= aPntNb; ++aPntId)
565 aParam = aParamFirst + aParamDelta * (aPntId - 1);
566 aPointArray->SetValue (aPntId, cu3d.Value (aParam));
568 theSensitive = new Select3D_SensitiveCurve (theOwner, aPointArray);
574 //=====================================================
575 // Function : GetStandardPriority
577 //=====================================================
578 Standard_Integer StdSelect_BRepSelectionTool::GetStandardPriority (const TopoDS_Shape& theShape,
579 const TopAbs_ShapeEnum theType)
583 case TopAbs_VERTEX: return 8;
584 case TopAbs_EDGE: return 7;
585 case TopAbs_WIRE: return 6;
586 case TopAbs_FACE: return 5;
589 switch (theShape.ShapeType())
591 case TopAbs_VERTEX: return 9;
592 case TopAbs_EDGE: return 8;
593 case TopAbs_WIRE: return 7;
594 case TopAbs_FACE: return 6;
595 case TopAbs_SHELL: return 5;
596 case TopAbs_COMPOUND:
597 case TopAbs_COMPSOLID:
606 //=======================================================================
607 //function : GetSensitiveEntityForFace
609 //=======================================================================
610 Standard_Boolean StdSelect_BRepSelectionTool
611 ::GetSensitiveForFace (const TopoDS_Face& theFace,
612 const Handle(StdSelect_BRepOwner)& theOwner,
613 Select3D_EntitySequence& theSensitiveList,
614 const Standard_Boolean /*theAutoTriangulation*/,
615 const Standard_Integer NbPOnEdge,
616 const Standard_Real theMaxParam,
617 const Standard_Boolean theInteriorFlag)
619 // check if there is triangulation of the face...
620 TopLoc_Location aLoc;
621 Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLoc);
623 if (!aTriangulation.IsNull())
625 Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
626 theSensitiveList.Append (STG);
627 return Standard_True;
630 // for faces with triangulation bugs or without autotriangulation ....
631 // very ugly and should not even exist ...
632 BRepAdaptor_Surface BS;
633 BS.Initialize (theFace);
635 Standard_Real FirstU = BS.FirstUParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstUParameter();
636 Standard_Real LastU = BS.LastUParameter() >= Precision::Infinite() ? theMaxParam : BS.LastUParameter();
637 Standard_Real FirstV = BS.FirstVParameter() <= -Precision::Infinite() ? -theMaxParam : BS.FirstVParameter();
638 Standard_Real LastV = BS.LastVParameter() >= Precision::Infinite() ? theMaxParam : BS.LastVParameter();
640 if (BS.GetType() == GeomAbs_Plane)
643 Handle(TColgp_HArray1OfPnt) P = new TColgp_HArray1OfPnt (1, 5);
644 BS.D0 (FirstU, FirstV, pcur);
645 P->SetValue (1, pcur);
646 BS.D0 (LastU, FirstV, pcur);
647 P->SetValue (2, pcur);
648 BS.D0 (LastU, LastV, pcur);
649 P->SetValue (3, pcur);
650 BS.D0 (FirstU, LastV, pcur);
651 P->SetValue (4, pcur);
652 P->SetValue (5, P->Value (1));
653 // if the plane is "infinite", it is sensitive only on the border limited by MaxParam
654 if (FirstU == -theMaxParam && LastU == theMaxParam && FirstV == -theMaxParam && LastV == theMaxParam)
656 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, Select3D_TOS_BOUNDARY));
660 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
661 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, P, TS));
663 return Standard_True;
666 // This is construction of a sevsitive polygon from the exterior contour of the face...
667 // It is not good at all, but...
669 TopExp_Explorer anExpWiresInFace (theFace, TopAbs_WIRE);
670 if (anExpWiresInFace.More())
672 // believing that this is the first... to be seen
673 aWire = TopoDS::Wire (anExpWiresInFace.Current());
677 return Standard_False;
680 TColgp_SequenceOfPnt WirePoints;
681 Standard_Boolean FirstExp = Standard_True;
682 Standard_Real wf, wl;
683 BRepAdaptor_Curve cu3d;
684 for (BRepTools_WireExplorer aWireExplorer (aWire);
685 aWireExplorer.More(); aWireExplorer.Next())
687 cu3d.Initialize (aWireExplorer.Current());
688 BRep_Tool::Range (aWireExplorer.Current(), wf, wl);
689 if (Abs (wf - wl) <= Precision::Confusion())
692 cout<<" StdSelect_BRepSelectionTool : Curve where ufirst = ulast ...."<<endl;
699 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
701 WirePoints.Append (cu3d.Value (wf));
705 WirePoints.Append (cu3d.Value (wl));
707 FirstExp = Standard_False;
710 switch (cu3d.GetType())
714 WirePoints.Append (cu3d.Value ((aWireExplorer.Orientation() == TopAbs_FORWARD) ? wl : wf));
719 if (2 * M_PI - Abs (wl - wf) <= Precision::Confusion())
721 if (BS.GetType() == GeomAbs_Cylinder ||
722 BS.GetType() == GeomAbs_Torus ||
723 BS.GetType() == GeomAbs_Cone ||
724 BS.GetType() == GeomAbs_BSplineSurface) // beuurkk pour l'instant...
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));
745 if (cu3d.Circle().Radius() <= Precision::Confusion())
747 theSensitiveList.Append (new Select3D_SensitivePoint (theOwner, cu3d.Circle().Location()));
751 theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, new Geom_Circle (cu3d.Circle()), theInteriorFlag, 16));
757 Standard_Real ff = wf, ll = wl;
758 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
759 if (aWireExplorer.Orientation() == TopAbs_FORWARD)
761 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
763 WirePoints.Append (cu3d.Value (wc));
766 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
768 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
770 WirePoints.Append (cu3d.Value (wc));
778 Standard_Real ff = wf, ll = wl;
779 Standard_Real dw = (Max (wf, wl) - Min (wf, wl)) / (Standard_Real )Max (2, NbPOnEdge - 1);
780 if (aWireExplorer.Orientation()==TopAbs_FORWARD)
782 for (Standard_Real wc = wf + dw; wc <= wl; wc += dw)
784 WirePoints.Append (cu3d.Value (wc));
787 else if (aWireExplorer.Orientation() == TopAbs_REVERSED)
789 for (Standard_Real wc = ll - dw; wc >= ff; wc -= dw)
791 WirePoints.Append (cu3d.Value (wc));
798 Standard_Integer ArrayPosition = WirePoints.Length();
800 Handle(TColgp_HArray1OfPnt) facepoints = new TColgp_HArray1OfPnt (1, ArrayPosition);
801 for (Standard_Integer I = 1; I <= ArrayPosition; ++I)
803 facepoints->SetValue (I, WirePoints.Value(I));
806 if ((facepoints->Array1()).Length() > 1)
807 { //1 if only one circular edge
808 Select3D_TypeOfSensitivity TS = theInteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
809 theSensitiveList.Append (new Select3D_SensitiveFace (theOwner, facepoints, TS));
811 return Standard_True;