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 #include <Prs3d_WFShape.hxx>
20 #include <Bnd_Box.hxx>
21 #include <BRepAdaptor_HSurface.hxx>
22 #include <BRepAdaptor_Curve.hxx>
23 #include <BRepBndLib.hxx>
24 #include <BRep_Tool.hxx>
25 #include <Graphic3d_Group.hxx>
26 #include <Graphic3d_AspectLine3d.hxx>
27 #include <Graphic3d_ArrayOfPolylines.hxx>
28 #include <Graphic3d_Array1OfVertex.hxx>
30 #include <Poly_Connect.hxx>
31 #include <Poly_Triangulation.hxx>
32 #include <Poly_Array1OfTriangle.hxx>
33 #include <Poly_Polygon3D.hxx>
34 #include <Poly_PolygonOnTriangulation.hxx>
35 #include <Prs3d_Drawer.hxx>
36 #include <Prs3d_IsoAspect.hxx>
37 #include <Prs3d_PointAspect.hxx>
38 #include <Prs3d_NListIteratorOfListOfSequenceOfPnt.hxx>
39 #include <Prs3d_ShapeTool.hxx>
40 #include <Standard_ErrorHandler.hxx>
41 #include <TColgp_Array1OfPnt.hxx>
42 #include <TColgp_SequenceOfPnt.hxx>
43 #include <TopoDS_Edge.hxx>
45 #include <TopTools_HSequenceOfShape.hxx>
46 #include <TopTools_ListOfShape.hxx>
47 #include <TopTools_ListIteratorOfListOfShape.hxx>
52 //! Compare two aspects
53 inline Standard_Boolean IsSame (const Handle(Graphic3d_AspectLine3d)& theUAspect,
54 const Handle(Graphic3d_AspectLine3d)& theVAspect)
56 Quantity_Color aCU, aCV;
57 Aspect_TypeOfLine aTlU, aTlV;
58 Standard_Real aWU, aWV;
59 theUAspect->Values (aCU, aTlU, aWU);
60 theVAspect->Values (aCV, aTlV, aWV);
68 // =========================================================================
69 // function: AddPolygon
71 // =========================================================================
72 Standard_Boolean Prs3d_WFShape::AddPolygon (const TopoDS_Edge& theEdge,
73 const Standard_Real theDeflection,
74 TColgp_SequenceOfPnt& thePoints)
76 TopLoc_Location aLocation;
77 Standard_Real aFirst, aLast;
78 Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (theEdge, aFirst, aLast);
79 Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
80 if (!aPolygon.IsNull())
82 if ((aPolygon->Deflection() <= theDeflection) || aCurve3d.IsNull())
84 const TColgp_Array1OfPnt& aPoints = aPolygon->Nodes();
85 Standard_Integer anIndex = aPoints.Lower();
86 if (aLocation.IsIdentity())
88 for (; anIndex <= aPoints.Upper(); ++anIndex)
90 thePoints.Append (aPoints.Value (anIndex));
95 for (; anIndex <= aPoints.Upper(); ++anIndex)
97 thePoints.Append (aPoints.Value (anIndex).Transformed (aLocation));
100 return Standard_True;
104 Handle(Poly_Triangulation) aTriangulation;
105 Handle(Poly_PolygonOnTriangulation) aHIndices;
106 BRep_Tool::PolygonOnTriangulation (theEdge, aHIndices, aTriangulation, aLocation);
107 if (!aHIndices.IsNull())
109 if ((aHIndices->Deflection() <= theDeflection) || aCurve3d.IsNull())
111 const TColStd_Array1OfInteger& anIndices = aHIndices->Nodes();
112 const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
114 Standard_Integer anIndex = anIndices.Lower();
115 if (aLocation.IsIdentity())
117 for (; anIndex <= anIndices.Upper(); ++anIndex)
119 thePoints.Append (aNodes (anIndices (anIndex)));
124 for (; anIndex <= anIndices.Upper(); ++anIndex)
126 thePoints.Append (aNodes (anIndices (anIndex)).Transformed (aLocation));
129 return Standard_True;
132 return Standard_False;
135 // =========================================================================
138 // =========================================================================
139 void Prs3d_WFShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
140 const TopoDS_Shape& theShape,
141 const Handle (Prs3d_Drawer)& theDrawer)
143 if (theShape.IsNull())
148 Prs3d_ShapeTool aTool (theShape);
149 TopTools_ListOfShape aLFree, aLUnFree, aLWire;
150 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
152 const TopoDS_Edge& anEdge = aTool.GetCurve();
153 switch (aTool.Neighbours())
155 case 0: aLWire.Append (anEdge); break;
156 case 1: aLFree.Append (anEdge); break;
157 default: aLUnFree.Append (anEdge); break;
161 Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
162 if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
164 // The arrow calculation is based on the global min max
166 BRepBndLib::Add (theShape, aBndBox);
167 if (!aBndBox.IsVoid())
169 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
170 aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
171 aDeflection = Max (aXmax-aXmin, Max (aYmax-aYmin, aZmax-aZmin))
172 * theDrawer->DeviationCoefficient();
176 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePresentation);
178 Prs3d_NListOfSequenceOfPnt anUIsoCurves;
179 Prs3d_NListOfSequenceOfPnt aVIsoCurves;
180 Prs3d_NListOfSequenceOfPnt aWireCurves;
181 Prs3d_NListOfSequenceOfPnt aFreeCurves;
182 Prs3d_NListOfSequenceOfPnt anUnFreeCurves;
183 TColgp_SequenceOfPnt aShapePoints;
185 const Standard_Integer anIsoU = theDrawer->UIsoAspect()->Number();
186 const Standard_Integer anIsoV = theDrawer->VIsoAspect()->Number();
188 Standard_Boolean hasIsoU = anIsoU > 0;
189 Standard_Boolean hasIsoV = anIsoV > 0;
191 if (IsSame (theDrawer->UIsoAspect()->Aspect(),
192 theDrawer->VIsoAspect()->Aspect()))
194 if (hasIsoU || hasIsoV)
196 BRepAdaptor_Surface aSurface;
197 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
199 if (aTool.HasSurface())
201 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
203 aSurface.Initialize (aTool.GetFace());
204 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface (aSurface);
208 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
209 myFaceAlgo.Add (thePresentation, aHSurface,
215 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
216 for (anIt.Init (aCurUIsoCurves); anIt.More(); anIt.Next())
218 anUIsoCurves.Append (anIt.Value());
221 catch (Standard_Failure)
233 BRepAdaptor_Surface aSurface;
234 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
236 if (aTool.HasSurface())
238 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
240 aSurface.Initialize (aTool.GetFace());
241 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface (aSurface);
245 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
246 myFaceAlgo.Add (thePresentation, aHSurface,
247 hasIsoU, Standard_False,
253 catch (Standard_Failure)
256 const TopoDS_Face& aFace = aSurface.Face();
257 std::cout << "Problem with the face " << (void* ) &(*(aFace).TShape()) << std::endl;
266 BRepAdaptor_Surface aSurface;
267 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
269 if (aTool.HasSurface())
271 if (!aTool.IsPlanarFace() || theDrawer->IsoOnPlane())
273 aSurface.Initialize (aTool.GetFace());
274 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface (aSurface);
278 Prs3d_NListOfSequenceOfPnt aCurUIsoCurves;
279 myFaceAlgo.Add (thePresentation, aHSurface,
280 Standard_False, hasIsoV,
286 catch (Standard_Failure)
289 const TopoDS_Face& aFace = aSurface.Face();
290 std::cout << "Problem with the face " << (void* ) &(*(aFace).TShape()) << std::endl;
299 Standard_Integer aNbVertices = 0, aNbBounds = 0;
300 if (anUIsoCurves.Size() > 0)
302 aNbBounds = anUIsoCurves.Size();
303 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
304 for (anIt.Init (anUIsoCurves); anIt.More(); anIt.Next())
306 aNbVertices += anIt.Value().Length();
308 Handle(Graphic3d_ArrayOfPolylines) anUIsoArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
309 for (anIt.Init (anUIsoCurves); anIt.More(); anIt.Next())
311 TColgp_SequenceOfPnt aPoints;
312 aPoints.Assign (anIt.Value());
313 anUIsoArray->AddBound (aPoints.Length());
314 for (Standard_Integer anI = 1; anI <= aPoints.Length(); ++anI)
316 anUIsoArray->AddVertex (aPoints.Value (anI));
319 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
320 aGroup->SetPrimitivesAspect (theDrawer->UIsoAspect()->Aspect());
321 aGroup->AddPrimitiveArray (anUIsoArray);
324 if (aVIsoCurves.Size() > 0)
326 aNbBounds = aVIsoCurves.Size();
327 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
328 for (anIt.Init (aVIsoCurves); anIt.More(); anIt.Next())
330 aNbVertices += anIt.Value().Length();
332 Handle(Graphic3d_ArrayOfPolylines) VIsoArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
333 for (anIt.Init (aVIsoCurves); anIt.More(); anIt.Next())
335 TColgp_SequenceOfPnt aPoints;
336 aPoints.Assign (anIt.Value());
337 VIsoArray->AddBound (aPoints.Length());
338 for (int anI = 1; anI <= aPoints.Length(); anI++)
340 VIsoArray->AddVertex (aPoints.Value (anI));
343 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
344 aGroup->SetPrimitivesAspect (theDrawer->VIsoAspect()->Aspect());
345 aGroup->AddPrimitiveArray (VIsoArray);
348 TopLoc_Location aLocation;
349 Standard_Integer anI, aJ, aN[3];
351 Standard_Boolean isDispTriangles = Standard_False;
352 const char* anEnvVar = getenv ("DEBUG_TRIANGLES");
353 if (anEnvVar != NULL)
355 isDispTriangles = (atol (anEnvVar) != 0);
358 TColgp_SequenceOfPnt aSurfPoints;
359 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
361 if (!aTool.HasSurface() || isDispTriangles)
363 Handle(Poly_Triangulation) T = aTool.CurrentTriangulation (aLocation);
366 const TColgp_Array1OfPnt& aNodes = T->Nodes();
367 // Build the connect tool
368 Poly_Connect aPolyConnect (T);
370 Standard_Integer aNbTriangles = T->NbTriangles();
371 Standard_Integer aT[3];
373 // Count the free edges
374 Standard_Integer aNbFree = 0;
375 for (anI = 1; anI <= aNbTriangles; ++anI)
377 aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
378 for (aJ = 0; aJ < 3; ++aJ)
387 // Allocate the arrays
388 TColStd_Array1OfInteger aFree (1, 2 * aNbFree);
389 Standard_Integer aNbInternal = (3 * aNbTriangles - aNbFree) / 2;
390 TColStd_Array1OfInteger anInternal (0, 2 * aNbInternal);
392 Standard_Integer aFreeIndex = 1, anIntIndex = 1;
393 const Poly_Array1OfTriangle& aTriangles = T->Triangles();
394 for (anI = 1; anI <= aNbTriangles; ++anI)
396 aPolyConnect.Triangles (anI, aT[0], aT[1], aT[2]);
397 aTriangles (anI).Get (aN[0], aN[1], aN[2]);
398 for (aJ = 0; aJ < 3; aJ++)
400 Standard_Integer k = (aJ + 1) % 3;
403 aFree (aFreeIndex) = aN[aJ];
404 aFree (aFreeIndex + 1) = aN[k];
407 // internal edge if this triangle has a lower index than the adjacent
408 else if (anI < aT[aJ])
410 anInternal (anIntIndex) = aN[aJ];
411 anInternal (anIntIndex + 1) = aN[k];
417 if (!aTool.HasSurface())
420 Standard_Integer aFreeHalfNb = aFree.Length() / 2;
421 for (anI = 1; anI <= aFreeHalfNb; ++anI)
423 gp_Pnt aPoint1 = aNodes (aFree (2 * anI - 1)).Transformed (aLocation);
424 gp_Pnt aPoint2 = aNodes (aFree (2 * anI )).Transformed (aLocation);
425 aSurfPoints.Append (aPoint1);
426 aSurfPoints.Append (aPoint2);
431 for (anI = 1; anI <= aNbInternal; ++anI)
433 gp_Pnt aPoint1 = aNodes (anInternal (2 * anI - 1)).Transformed (aLocation);
434 gp_Pnt aPoint2 = aNodes (anInternal (2 * anI )).Transformed (aLocation);
435 aSurfPoints.Append (aPoint1);
436 aSurfPoints.Append (aPoint2);
442 if (aSurfPoints.Length() > 0)
444 aNbVertices = aSurfPoints.Length();
445 aNbBounds = (Standard_Integer)aNbVertices / 2;
446 Handle(Graphic3d_ArrayOfPolylines) aSurfArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
447 for (anI = 1; anI <= aNbVertices; anI += 2)
449 aSurfArray->AddBound (2);
450 aSurfArray->AddVertex (aSurfPoints.Value (anI));
451 aSurfArray->AddVertex (aSurfPoints.Value (anI + 1));
453 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
454 aGroup->SetPrimitivesAspect ((isDispTriangles && aTool.HasSurface())
455 ? theDrawer->UIsoAspect()->Aspect()
456 : theDrawer->FreeBoundaryAspect()->Aspect());
457 aGroup->AddPrimitiveArray (aSurfArray);
460 TopTools_ListIteratorOfListOfShape anIt;
461 if (theDrawer->WireDraw())
463 // Wire (without any neighbour)
464 aGroup->SetPrimitivesAspect (theDrawer->WireAspect()->Aspect());
465 for (anIt.Initialize(aLWire); anIt.More(); anIt.Next())
467 const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
471 TColgp_SequenceOfPnt aPoints;
472 if (!AddPolygon (anEdge, aDeflection, aPoints))
474 if (BRep_Tool::IsGeometric (anEdge))
476 BRepAdaptor_Curve aCurve (anEdge);
477 myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer,
478 aPoints, Standard_False);
479 aWireCurves.Append (aPoints);
484 aWireCurves.Append (aPoints);
487 catch (Standard_Failure)
490 std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
496 if (theDrawer->FreeBoundaryDraw())
499 for (anIt.Initialize (aLFree); anIt.More(); anIt.Next())
501 const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
502 if (!BRep_Tool::Degenerated (anEdge))
507 TColgp_SequenceOfPnt aPoints;
508 if (!AddPolygon (anEdge, aDeflection, aPoints))
510 if (BRep_Tool::IsGeometric (anEdge))
512 BRepAdaptor_Curve aCurve (anEdge);
513 myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer,
514 aPoints, Standard_False);
515 aFreeCurves.Append (aPoints);
520 aFreeCurves.Append (aPoints);
523 catch (Standard_Failure)
526 std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
533 if (theDrawer->UnFreeBoundaryDraw())
535 // Unfree boundaries;
536 for (anIt.Initialize (aLUnFree); anIt.More(); anIt.Next())
538 const TopoDS_Edge& anEdge = TopoDS::Edge (anIt.Value());
542 TColgp_SequenceOfPnt aPoints;
543 if (!AddPolygon (anEdge, aDeflection, aPoints))
545 if (BRep_Tool::IsGeometric (anEdge))
547 BRepAdaptor_Curve aCurve (anEdge);
548 myCurveAlgo.Add (thePresentation, aCurve, aDeflection, theDrawer, aPoints, Standard_False);
549 anUnFreeCurves.Append (aPoints);
554 anUnFreeCurves.Append (aPoints);
557 catch (Standard_Failure)
560 std::cout << "probleme sur aLocation'edge " << (void* ) &(*(anEdge).TShape()) << std::endl;
566 if (aWireCurves.Size() > 0)
568 aNbBounds = aWireCurves.Size();
569 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
570 for (anIt.Init (aWireCurves); anIt.More(); anIt.Next())
572 aNbVertices += anIt.Value().Length();
574 Handle(Graphic3d_ArrayOfPolylines) WireArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
575 for (anIt.Init (aWireCurves); anIt.More(); anIt.Next())
577 TColgp_SequenceOfPnt aPoints;
578 aPoints.Assign (anIt.Value());
579 WireArray->AddBound (aPoints.Length());
580 for (anI = 1; anI <= aPoints.Length(); ++anI)
582 WireArray->AddVertex (aPoints.Value (anI));
585 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
586 aGroup->SetPrimitivesAspect (theDrawer->WireAspect()->Aspect());
587 aGroup->AddPrimitiveArray (WireArray);
590 if (aFreeCurves.Size() > 0)
592 aNbBounds = aFreeCurves.Size();
593 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
594 for (anIt.Init (aFreeCurves); anIt.More(); anIt.Next())
596 aNbVertices += anIt.Value().Length();
598 Handle(Graphic3d_ArrayOfPolylines) aFreeArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
599 for (anIt.Init(aFreeCurves); anIt.More(); anIt.Next())
601 TColgp_SequenceOfPnt aPoints;
602 aPoints.Assign (anIt.Value());
603 aFreeArray->AddBound (aPoints.Length());
604 for (anI = 1; anI <= aPoints.Length(); ++anI)
606 aFreeArray->AddVertex (aPoints.Value (anI));
609 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
610 aGroup->SetPrimitivesAspect (theDrawer->FreeBoundaryAspect()->Aspect());
611 aGroup->AddPrimitiveArray (aFreeArray);
614 if (anUnFreeCurves.Size() > 0)
616 aNbBounds = anUnFreeCurves.Size();
617 Prs3d_NListIteratorOfListOfSequenceOfPnt anIt;
618 for (anIt.Init (anUnFreeCurves); anIt.More(); anIt.Next())
620 aNbVertices += anIt.Value().Length();
622 Handle(Graphic3d_ArrayOfPolylines) anUnFreeArray = new Graphic3d_ArrayOfPolylines (aNbVertices, aNbBounds);
623 for (anIt.Init (anUnFreeCurves); anIt.More(); anIt.Next())
625 TColgp_SequenceOfPnt aPoints;
626 aPoints.Assign (anIt.Value());
627 anUnFreeArray->AddBound (aPoints.Length());
628 for (anI = 1; anI <= aPoints.Length(); ++anI)
630 anUnFreeArray->AddVertex (aPoints.Value (anI));
633 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
634 aGroup->SetPrimitivesAspect (theDrawer->UnFreeBoundaryAspect()->Aspect());
635 aGroup->AddPrimitiveArray (anUnFreeArray);
639 for (aTool.InitVertex(); aTool.MoreVertex(); aTool.NextVertex())
641 aShapePoints.Append (BRep_Tool::Pnt (aTool.GetVertex()));
644 aNbVertices = aShapePoints.Length();
647 Graphic3d_Array1OfVertex aPointArray (1, aNbVertices);
648 for (anI = 1; anI <= aNbVertices; ++anI)
650 aPointArray.SetValue (anI, Graphic3d_Vertex (aShapePoints.Value (anI).X(),
651 aShapePoints.Value (anI).Y(),
652 aShapePoints.Value (anI).Z()));
655 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePresentation);
656 aGroup->SetPrimitivesAspect (theDrawer->PointAspect()->Aspect());
657 aGroup->MarkerSet (aPointArray);
661 // =========================================================================
662 // function: PickCurve
664 // =========================================================================
665 Handle(TopTools_HSequenceOfShape) Prs3d_WFShape::PickCurve
666 (const Quantity_Length theX,
667 const Quantity_Length theY,
668 const Quantity_Length theZ,
669 const Quantity_Length theDistance,
670 const TopoDS_Shape& theShape,
671 const Handle (Prs3d_Drawer)& theDrawer)
673 Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape();
674 Prs3d_ShapeTool aTool (theShape);
675 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
677 Bnd_Box aBndBox = aTool.CurveBound();
678 aBndBox.Enlarge (theDistance);
679 if (!aBndBox.IsOut (gp_Pnt (theX, theY, theZ)))
681 if (myCurveAlgo.Match (theX, theY, theZ, theDistance,
682 BRepAdaptor_Curve (aTool.GetCurve()), theDrawer))
684 Standard_Boolean isContain = Standard_False;
685 for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
687 if (aSeq->Value (anI) == (aTool.GetCurve()))
689 isContain = Standard_True;
695 aSeq->Append (aTool.GetCurve());
703 // =========================================================================
704 // function: PickPatch
706 // =========================================================================
707 Handle(TopTools_HSequenceOfShape) Prs3d_WFShape::PickPatch
708 (const Quantity_Length theX,
709 const Quantity_Length theY,
710 const Quantity_Length theZ,
711 const Quantity_Length theDistance,
712 const TopoDS_Shape& theShape,
713 const Handle(Prs3d_Drawer)& theDrawer)
715 Handle(TopTools_HSequenceOfShape) aSeq = new TopTools_HSequenceOfShape();
716 Prs3d_ShapeTool aTool (theShape);
718 Standard_Boolean aRba1 = theDrawer->UIsoAspect()->Number() != 0;
719 Standard_Boolean aRba2 = theDrawer->VIsoAspect()->Number() != 0;
720 Standard_Boolean isContain;
724 BRepAdaptor_Surface aSurface;
725 for (aTool.InitFace(); aTool.MoreFace(); aTool.NextFace())
727 Bnd_Box aBndBox = aTool.FaceBound();
728 aBndBox.Enlarge (theDistance);
729 if (!aBndBox.IsOut (gp_Pnt (theX, theY, theZ)))
731 aSurface.Initialize (aTool.GetFace());
732 Handle(BRepAdaptor_HSurface) aHSurface = new BRepAdaptor_HSurface (aSurface);
733 if (myFaceAlgo.Match (theX, theY, theZ, theDistance, aHSurface, theDrawer))
735 isContain = Standard_False;
736 for (Standard_Integer anI = 1; anI <= aSeq->Length(); ++anI)
738 if (aSeq->Value (anI) == (aTool.GetFace()))
740 isContain = Standard_True;
746 aSeq->Append (aTool.GetFace());
753 for (aTool.InitCurve(); aTool.MoreCurve(); aTool.NextCurve())
755 Bnd_Box aBndBox = aTool.CurveBound();
756 aBndBox.Enlarge (theDistance);
757 if (!aBndBox.IsOut (gp_Pnt (theX, theY, theZ)))
759 if (myCurveAlgo.Match (theX, theY, theZ, theDistance,
760 BRepAdaptor_Curve(aTool.GetCurve()), theDrawer))
762 Handle(TopTools_HSequenceOfShape) aSurface = aTool.FacesOfEdge();
763 for (Standard_Integer anI = 1; anI <= aSurface->Length(); ++anI)
765 isContain = Standard_False;
766 for (Standard_Integer aJ = 1; aJ <= aSeq->Length(); ++aJ)
768 if (aSeq->Value (aJ) == (aSurface->Value (anI)))
770 isContain = Standard_True;
776 aSeq->Append (aSurface->Value (anI));