1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #ifndef _Prs3d_WFShape_H__
19 #define _Prs3d_WFShape_H__
21 #include <Bnd_Box.hxx>
22 #include <BRepAdaptor_HSurface.hxx>
23 #include <BRepAdaptor_Curve.hxx>
24 #include <BRepBndLib.hxx>
25 #include <BRep_Builder.hxx>
26 #include <BRep_Tool.hxx>
27 #include <Graphic3d_Group.hxx>
28 #include <Graphic3d_AspectLine3d.hxx>
29 #include <Graphic3d_ArrayOfPolylines.hxx>
30 #include <Graphic3d_Array1OfVertex.hxx>
31 #include <GCPnts_TangentialDeflection.hxx>
32 #include <GCPnts_UniformDeflection.hxx>
33 #include <gp_Circ.hxx>
35 #include <Poly_Connect.hxx>
36 #include <Poly_Triangulation.hxx>
37 #include <Poly_Array1OfTriangle.hxx>
38 #include <Poly_Polygon3D.hxx>
39 #include <Poly_PolygonOnTriangulation.hxx>
40 #include <Precision.hxx>
41 #include <Prs3d_Root.hxx>
42 #include <Prs3d_Drawer.hxx>
43 #include <Prs3d_IsoAspect.hxx>
44 #include <Prs3d_PointAspect.hxx>
45 #include <Prs3d_NListOfSequenceOfPnt.hxx>
46 #include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
47 #include <Prs3d_ShapeTool.hxx>
48 #include <Standard_ErrorHandler.hxx>
49 #include <TColgp_Array1OfPnt.hxx>
50 #include <TColgp_SequenceOfPnt.hxx>
51 #include <TColStd_Array1OfReal.hxx>
52 #include <TColStd_HArray1OfInteger.hxx>
53 #include <TopoDS_Edge.hxx>
54 #include <TopoDS_Vertex.hxx>
56 #include <TopTools_HSequenceOfShape.hxx>
57 #include <TopTools_ListOfShape.hxx>
58 #include <TopTools_ListIteratorOfListOfShape.hxx>
60 template <class FacePresentation, class CurvePresentation, class PointPresentation>
61 class Prs3d_WFShape : Prs3d_Root
69 //=========================================================================
72 //=========================================================================
74 Standard_EXPORT static Standard_Boolean IsSame (const Handle(Graphic3d_AspectLine3d)& theUAspect,
75 const Handle(Graphic3d_AspectLine3d)& theVAspect)
77 Standard_Boolean isSame = Standard_True;
78 Quantity_Color aCU, aCV;
79 Aspect_TypeOfLine aTlU, aTlV;
80 Standard_Real aWU, aWV;
82 theUAspect->Values(aCU, aTlU, aWU);
83 theVAspect->Values(aCV, aTlV, aWV);
85 if (aCU != aCV || aTlU != aTlV || aWU != aWV)
87 isSame = Standard_False;
93 //=========================================================================
94 // function: AddPolygon
96 //=========================================================================
98 Standard_EXPORT static Standard_Boolean AddPolygon (const TopoDS_Edge& theEdge,
99 Handle(Graphic3d_Group)& ,
100 const Standard_Real theDeflection,
101 const Handle (Prs3d_Drawer)& ,
102 TColgp_SequenceOfPnt& thePoints)
104 TopLoc_Location aLocation;
105 Standard_Real aFirst, aLast;
106 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve(theEdge, aFirst, aLast);
107 Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D(theEdge, aLocation);
109 if (!aPolygon.IsNull())
111 if ((aPolygon->Deflection() <= theDeflection) || aCurve3d.IsNull())
113 const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
114 Standard_Integer anIndex = aPoints.Lower();
115 if (aLocation.IsIdentity())
117 for (; anIndex <= aPoints.Upper(); anIndex++)
118 thePoints.Append(aPoints.Value(anIndex));
122 for (; anIndex <= aPoints.Upper(); anIndex++)
123 thePoints.Append(aPoints.Value(anIndex).Transformed(aLocation));
125 return Standard_True;
129 Handle(Poly_Triangulation) aTriangulation;
130 Handle(Poly_PolygonOnTriangulation) aHIndices;
131 BRep_Tool::PolygonOnTriangulation(theEdge, aHIndices, aTriangulation, aLocation);
132 if (!aHIndices.IsNull())
134 if ((aHIndices->Deflection() <= theDeflection) || aCurve3d.IsNull())
136 const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
137 const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
139 Standard_Integer anIndex = anIndices.Lower();
140 if (aLocation.IsIdentity())
142 for (; anIndex <= anIndices.Upper(); anIndex++)
143 thePoints.Append(aNodes(anIndices(anIndex)));
147 for (; anIndex <= anIndices.Upper(); anIndex++)
148 thePoints.Append(aNodes(anIndices(anIndex)).Transformed(aLocation));
150 return Standard_True;
153 return Standard_False;
158 //=========================================================================
161 //=========================================================================
163 Standard_EXPORT static void Add (const Handle (Prs3d_Presentation)& thePresentation,
164 const TopoDS_Shape& theShape,
165 const Handle (Prs3d_Drawer)& theDrawer)
167 if (theShape.IsNull()) return;
169 Prs3d_ShapeTool aTool(theShape);
170 TopTools_ListOfShape aLFree, aLUnFree, aLWire;
171 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
173 const TopoDS_Edge& anEdge = aTool.GetCurve();
174 switch (aTool.Neighbours())
176 case 0: aLWire.Append(anEdge); break;
177 case 1: aLFree.Append(anEdge); break;
178 default: aLUnFree.Append(anEdge);
182 Standard_Real aDeflection;
183 if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
185 // The arrow calculation is based on the global min max
187 BRepBndLib::Add(theShape, aBndBox);
188 if (! aBndBox.IsVoid())
190 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
191 aBndBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
192 aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin)) *
193 theDrawer->DeviationCoefficient();
196 aDeflection = theDrawer->MaximalChordialDeviation();
199 aDeflection = theDrawer->MaximalChordialDeviation();
201 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
203 Prs3d_NListOfSequenceOfPnt anUIsoCurves;
204 Prs3d_NListOfSequenceOfPnt aVIsoCurves;
205 Prs3d_NListOfSequenceOfPnt aWireCurves;
206 Prs3d_NListOfSequenceOfPnt aFreeCurves;
207 Prs3d_NListOfSequenceOfPnt anUnFreeCurves;
208 TColgp_SequenceOfPnt aShapePoints;
210 if (IsSame(theDrawer->UIsoAspect()->Aspect(), theDrawer->VIsoAspect()->Aspect()))
212 const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
213 const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
214 if (anIsoU || anIsoV)
216 BRepAdaptor_Surface aSurface;
217 for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
219 if (aTool.HasSurface())
221 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
223 aSurface.Initialize(aTool.GetFace());
224 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
227 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
228 FacePresentation::Add(thePresentation, aHSurface,
234 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
235 for( anIt.Init(aCurUIsoCurves); anIt.More(); anIt.Next())
236 anUIsoCurves.Append(anIt.Value());
238 catch (Standard_Failure)
248 const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
249 const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
252 BRepAdaptor_Surface aSurface;
253 for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
255 if (aTool.HasSurface())
257 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
259 aSurface.Initialize(aTool.GetFace());
260 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
264 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
265 FacePresentation::Add(thePresentation, aHSurface,
266 anIsoU, Standard_False,
272 catch (Standard_Failure)
275 const TopoDS_Face& aFace = aSurface.Face();
276 cout <<"Problem with the face "<< (void*) &(*(aFace).TShape()) << endl;
285 BRepAdaptor_Surface aSurface;
286 for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
288 if (aTool.HasSurface())
290 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
292 aSurface.Initialize(aTool.GetFace());
293 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
297 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
298 FacePresentation::Add(thePresentation, aHSurface,
299 Standard_False, anIsoV,
305 catch (Standard_Failure)
308 const TopoDS_Face& aFace = aSurface.Face();
309 cout <<"Problem with the face "<< (void*) &(*(aFace).TShape()) << endl;
317 Standard_Integer aNbVertices = 0, aNbBounds = 0;
319 if(anUIsoCurves.Size() > 0) {
320 aNbBounds = anUIsoCurves.Size();
321 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
322 for( anIt.Init(anUIsoCurves); anIt.More(); anIt.Next())
323 aNbVertices += anIt.Value().Length();
324 Handle(Graphic3d_ArrayOfPolylines) anUIsoArray =
325 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
326 for( anIt.Init(anUIsoCurves); anIt.More(); anIt.Next()) {
327 TColgp_SequenceOfPnt aPoints;
328 aPoints.Assign(anIt.Value());
329 anUIsoArray->AddBound(aPoints.Length());
330 for(Standard_Integer anI = 1; anI <= aPoints.Length(); ++anI)
331 anUIsoArray->AddVertex(aPoints.Value(anI));
333 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
334 aGroup->SetPrimitivesAspect(theDrawer->UIsoAspect()->Aspect());
335 aGroup->AddPrimitiveArray(anUIsoArray);
338 if(aVIsoCurves.Size() > 0) {
339 aNbBounds = aVIsoCurves.Size();
340 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
341 for( anIt.Init(aVIsoCurves); anIt.More(); anIt.Next())
342 aNbVertices += anIt.Value().Length();
343 Handle(Graphic3d_ArrayOfPolylines) VIsoArray =
344 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
345 for( anIt.Init(aVIsoCurves); anIt.More(); anIt.Next()) {
346 TColgp_SequenceOfPnt aPoints;
347 aPoints.Assign(anIt.Value());
348 VIsoArray->AddBound(aPoints.Length());
349 for(int anI=1; anI<=aPoints.Length(); anI++)
350 VIsoArray->AddVertex(aPoints.Value(anI));
352 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
353 aGroup->SetPrimitivesAspect(theDrawer->VIsoAspect()->Aspect());
354 aGroup->AddPrimitiveArray(VIsoArray);
357 TopLoc_Location aLocation;
358 Standard_Integer anI, aJ, aN[3];
360 Standard_Boolean isDispTriangles = Standard_False;
361 const char* anEnvVar = getenv("DEBUG_TRIANGLES");
362 if (anEnvVar != 0L) {
363 isDispTriangles = (atol(anEnvVar) != 0);
366 TColgp_SequenceOfPnt aSurfPoints;
367 for (aTool.InitFace();aTool.MoreFace();aTool.NextFace())
369 if (!aTool.HasSurface() || isDispTriangles)
371 Handle(Poly_Triangulation) T = aTool.CurrentTriangulation(aLocation);
374 const TColgp_Array1OfPnt& aNodes = T->Nodes();
375 // Build the connect tool
376 Poly_Connect aPolyConnect(T);
378 Standard_Integer aNbFree, aNbInternal, aNbTriangles = T->NbTriangles();
379 Standard_Integer aT[3];
381 // Count the free edges
383 for (anI = 1; anI <= aNbTriangles; anI++) {
384 aPolyConnect.Triangles(anI,aT[0],aT[1],aT[2]);
385 for (aJ = 0; aJ < 3; aJ++)
386 if (aT[aJ] == 0) aNbFree++;
389 // Allocate the arrays
390 TColStd_Array1OfInteger aFree(1,2*aNbFree);
391 aNbInternal = (3*aNbTriangles - aNbFree) / 2;
392 TColStd_Array1OfInteger anInternal(0,2*aNbInternal);
394 Standard_Integer aFreeIndex = 1, anIntIndex = 1;
395 const Poly_Array1OfTriangle& aTriangles = T->Triangles();
396 for (anI = 1; anI <= aNbTriangles; anI++) {
397 aPolyConnect.Triangles(anI,aT[0],aT[1],aT[2]);
398 aTriangles(anI).Get(aN[0],aN[1],aN[2]);
399 for (aJ = 0; aJ < 3; aJ++) {
400 Standard_Integer k = (aJ+1) % 3;
402 aFree(aFreeIndex) = aN[aJ];
403 aFree(aFreeIndex+1) = aN[k];
406 // internal edge if this triangle has a lower index than the adjacent
407 else if (anI < aT[aJ]) {
408 anInternal(anIntIndex) = aN[aJ];
409 anInternal(anIntIndex+1) = aN[k];
415 if(!aTool.HasSurface())
418 Standard_Integer aFreeHalfNb = aFree.Length() / 2;
419 for (anI = 1; anI <= aFreeHalfNb; anI++) {
420 gp_Pnt aPoint1 = aNodes(aFree(2*anI-1)).Transformed(aLocation);
421 gp_Pnt aPoint2 = aNodes(aFree(2*anI)).Transformed(aLocation);
422 aSurfPoints.Append(aPoint1);
423 aSurfPoints.Append(aPoint2);
428 for (anI = 1; anI <= aNbInternal; anI++) {
429 gp_Pnt aPoint1 = aNodes(anInternal(2*anI-1)).Transformed(aLocation);
430 gp_Pnt aPoint2 = aNodes(anInternal(2*anI)).Transformed(aLocation);
431 aSurfPoints.Append(aPoint1);
432 aSurfPoints.Append(aPoint2);
438 if(aSurfPoints.Length()>0){
439 aNbVertices = aSurfPoints.Length();
440 aNbBounds = (Standard_Integer)aNbVertices / 2;
441 Handle(Graphic3d_ArrayOfPolylines) aSurfArray =
442 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
443 for(anI=1; anI<=aNbVertices; anI+=2) {
444 aSurfArray->AddBound(2);
445 aSurfArray->AddVertex(aSurfPoints.Value(anI));
446 aSurfArray->AddVertex(aSurfPoints.Value(anI+1));
448 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
449 if(isDispTriangles && aTool.HasSurface())
450 aGroup->SetPrimitivesAspect(theDrawer->UIsoAspect()->Aspect());
452 aGroup->SetPrimitivesAspect(theDrawer->FreeBoundaryAspect()->Aspect());
453 aGroup->AddPrimitiveArray(aSurfArray);
455 TopTools_ListIteratorOfListOfShape anIt;
457 if (theDrawer->WireDraw())
459 // Wire (without any neighbour)
460 aGroup->SetPrimitivesAspect(theDrawer->WireAspect()->Aspect());
461 for (anIt.Initialize(aLWire); anIt.More(); anIt.Next()) {
462 const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
466 TColgp_SequenceOfPnt aPoints;
467 if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints))
469 if (BRep_Tool::IsGeometric(anEdge))
471 BRepAdaptor_Curve aCurve(anEdge);
472 CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer,
473 aPoints, Standard_False);
474 aWireCurves.Append(aPoints);
478 aWireCurves.Append(aPoints);
480 catch(Standard_Failure)
483 cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
489 if (theDrawer->FreeBoundaryDraw())
492 for (anIt.Initialize(aLFree); anIt.More(); anIt.Next())
494 const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
495 if (!BRep_Tool::Degenerated(anEdge))
499 TColgp_SequenceOfPnt aPoints;
500 if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints)) {
501 if (BRep_Tool::IsGeometric(anEdge)) {
502 BRepAdaptor_Curve aCurve(anEdge);
503 CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer,
504 aPoints, Standard_False);
505 aFreeCurves.Append(aPoints);
509 aFreeCurves.Append(aPoints);
511 catch(Standard_Failure)
514 cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
521 if (theDrawer->UnFreeBoundaryDraw())
523 // Unfree boundaries;
525 for (anIt.Initialize(aLUnFree); anIt.More(); anIt.Next())
527 const TopoDS_Edge& anEdge = TopoDS::Edge(anIt.Value());
531 TColgp_SequenceOfPnt aPoints;
532 if (!AddPolygon(anEdge, aGroup, aDeflection, theDrawer, aPoints)) {
533 if (BRep_Tool::IsGeometric(anEdge)) {
534 BRepAdaptor_Curve aCurve(anEdge);
535 CurvePresentation::Add(thePresentation, aCurve, aDeflection, theDrawer, aPoints, Standard_False);
536 anUnFreeCurves.Append(aPoints);
540 anUnFreeCurves.Append(aPoints);
542 catch(Standard_Failure)
545 cout <<"probleme sur aLocation'edge "<< (void*) &(*(anEdge).TShape()) << endl;
551 if(aWireCurves.Size() > 0)
553 aNbBounds = aWireCurves.Size();
554 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
555 for( anIt.Init(aWireCurves); anIt.More(); anIt.Next())
556 aNbVertices += anIt.Value().Length();
557 Handle(Graphic3d_ArrayOfPolylines) WireArray =
558 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
559 for( anIt.Init(aWireCurves); anIt.More(); anIt.Next()) {
560 TColgp_SequenceOfPnt aPoints;
561 aPoints.Assign(anIt.Value());
562 WireArray->AddBound(aPoints.Length());
563 for(anI=1; anI<=aPoints.Length(); ++anI)
564 WireArray->AddVertex(aPoints.Value(anI));
566 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
567 aGroup->SetPrimitivesAspect(theDrawer->WireAspect()->Aspect());
568 aGroup->AddPrimitiveArray(WireArray);
570 if(aFreeCurves.Size() > 0) {
571 aNbBounds = aFreeCurves.Size();
572 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
573 for( anIt.Init(aFreeCurves); anIt.More(); anIt.Next())
574 aNbVertices += anIt.Value().Length();
575 Handle(Graphic3d_ArrayOfPolylines) aFreeArray =
576 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
577 for( anIt.Init(aFreeCurves); anIt.More(); anIt.Next()) {
578 TColgp_SequenceOfPnt aPoints;
579 aPoints.Assign(anIt.Value());
580 aFreeArray->AddBound(aPoints.Length());
581 for(anI=1; anI<=aPoints.Length(); anI++)
582 aFreeArray->AddVertex(aPoints.Value(anI));
584 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
585 aGroup->SetPrimitivesAspect(theDrawer->FreeBoundaryAspect()->Aspect());
586 aGroup->AddPrimitiveArray(aFreeArray);
588 if(anUnFreeCurves.Size() > 0) {
589 aNbBounds = anUnFreeCurves.Size();
590 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
591 for( anIt.Init(anUnFreeCurves); anIt.More(); anIt.Next())
592 aNbVertices += anIt.Value().Length();
593 Handle(Graphic3d_ArrayOfPolylines) anUnFreeArray =
594 new Graphic3d_ArrayOfPolylines(aNbVertices,aNbBounds);
595 for( anIt.Init(anUnFreeCurves); anIt.More(); anIt.Next()) {
596 TColgp_SequenceOfPnt aPoints;
597 aPoints.Assign(anIt.Value());
598 anUnFreeArray->AddBound(aPoints.Length());
599 for(anI=1; anI<=aPoints.Length(); anI++)
600 anUnFreeArray->AddVertex(aPoints.Value(anI));
602 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
603 aGroup->SetPrimitivesAspect(theDrawer->UnFreeBoundaryAspect()->Aspect());
604 aGroup->AddPrimitiveArray(anUnFreeArray);
608 for(aTool.InitVertex();aTool.MoreVertex();aTool.NextVertex())
609 aShapePoints.Append(BRep_Tool::Pnt(aTool.GetVertex()));
611 aNbVertices = aShapePoints.Length();
612 if(aNbVertices > 0) {
613 Graphic3d_Array1OfVertex aPointArray(1, aNbVertices);
614 for(anI=1; anI<=aNbVertices; anI++)
615 aPointArray.SetValue(anI, Graphic3d_Vertex(aShapePoints.Value(anI).X(), aShapePoints.Value(anI).Y(), aShapePoints.Value(anI).Z()));
617 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
618 aGroup->SetPrimitivesAspect(theDrawer->PointAspect()->Aspect());
619 aGroup->MarkerSet(aPointArray);
623 //=========================================================================
624 // function: PickCurve
626 //=========================================================================
628 Standard_EXPORT static Handle(TopTools_HSequenceOfShape) PickCurve
629 (const Quantity_Length theX,
630 const Quantity_Length theY,
631 const Quantity_Length theZ,
632 const Quantity_Length theDistance,
633 const TopoDS_Shape& theShape,
634 const Handle (Prs3d_Drawer)& theDrawer)
636 Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
637 Prs3d_ShapeTool aTool(theShape);
638 Standard_Boolean isContain;
640 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
642 Bnd_Box aBndBox = aTool.CurveBound();
643 aBndBox.Enlarge(theDistance);
644 if (! aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
646 if (CurvePresentation::Match(theX, theY, theZ, theDistance,
647 BRepAdaptor_Curve(aTool.GetCurve()), theDrawer))
649 isContain = Standard_False;
650 for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
652 if (aSeq->Value(anI) == (aTool.GetCurve()))
654 isContain = Standard_True;
658 if (!isContain) aSeq->Append(aTool.GetCurve());
666 //=========================================================================
667 // function: PickPatch
669 //=========================================================================
671 Standard_EXPORT static Handle(TopTools_HSequenceOfShape) PickPatch
672 (const Quantity_Length theX,
673 const Quantity_Length theY,
674 const Quantity_Length theZ,
675 const Quantity_Length theDistance,
676 const TopoDS_Shape& theShape,
677 const Handle(Prs3d_Drawer)& theDrawer)
680 Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape;
681 Prs3d_ShapeTool aTool(theShape);
683 Standard_Boolean aRba1 = theDrawer->UIsoAspect()->Number() != 0;
684 Standard_Boolean aRba2 = theDrawer->VIsoAspect()->Number() != 0;
685 Standard_Boolean isContain;
689 BRepAdaptor_Surface aSurface;
690 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
692 Bnd_Box aBndBox = aTool.FaceBound();
693 aBndBox.Enlarge(theDistance);
694 if (!aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
696 aSurface.Initialize(aTool.GetFace());
697 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface(aSurface);
698 if (FacePresentation::Match(theX, theY, theZ, theDistance, aHSurface, theDrawer))
700 isContain = Standard_False;
701 for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
703 if (aSeq->Value(anI) == (aTool.GetFace()))
705 isContain = Standard_True;
710 aSeq->Append(aTool.GetFace());
716 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
718 Bnd_Box aBndBox = aTool.CurveBound();
719 aBndBox.Enlarge(theDistance);
720 if (!aBndBox.IsOut(gp_Pnt(theX, theY, theZ)))
722 if(CurvePresentation::Match(theX, theY, theZ, theDistance,
723 BRepAdaptor_Curve(aTool.GetCurve()), theDrawer))
725 Handle(TopTools_HSequenceOfShape) aSurface = aTool.FacesOfEdge();
726 for (Standard_Integer anI = 1; anI <= aSurface->Length(); ++anI)
728 isContain = Standard_False;
729 for (Standard_Integer aJ = 1; aJ <= aSeq->Length(); ++aJ)
731 if (aSeq->Value(aJ) == (aSurface->Value(anI)))
733 isContain = Standard_True;
738 aSeq->Append(aSurface->Value(anI));