1 // Created on: 1994-03-10
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // Modifed: Porting NT 7-5-97 DPF (stdio.h)
22 // Apr 16 2002 eap, classification against infinite solid (occ299)
25 // Modified by skv - Thu Sep 4 12:29:30 2003 OCC578
27 //-- Process the case of a hole!!
33 #include <BRepClass3d_SolidExplorer.ixx>
36 #include <BRepAdaptor_Curve2d.hxx>
37 #include <BRepTools.hxx>
38 #include <Geom2d_Curve.hxx>
39 #include <gp_Vec2d.hxx>
40 #include <GeomAbs_Shape.hxx>
41 #include <BRepAdaptor_Surface.hxx>
42 #include <BRepClass_FacePassiveClassifier.hxx>
43 #include <TopAbs_Orientation.hxx>
44 #include <TopExp_Explorer.hxx>
45 #include <BRepClass_Edge.hxx>
47 #include <Bnd_Box.hxx>
48 #include <BRepBndLib.hxx>
50 #include <BRepAdaptor_HSurface.hxx>
54 #include <BRepClass3d_DataMapIteratorOfMapOfInter.hxx>
55 #include <Precision.hxx>
57 #include <Extrema_ExtPS.hxx>
58 #include <BRep_Tool.hxx>
59 #include <BRepClass_FaceClassifier.hxx>
62 //=======================================================================
63 //function : FindAPointInTheFace
64 //purpose : Compute a point P in the face F. Param is a Real in
65 // ]0,1[ and is used to initialise the algorithm. For
66 // different values , different points are returned.
67 //=======================================================================
69 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
70 (const TopoDS_Face& _face,
72 Standard_Real& param_)
75 Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u,v,param_);
79 //=======================================================================
80 //function : FindAPointInTheFace
82 //=======================================================================
84 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
85 (const TopoDS_Face& _face,
87 Standard_Real& u_, Standard_Real& v_,
88 Standard_Real& param_)
90 gp_Vec aVecD1U, aVecD1V;
91 return FindAPointInTheFace (_face, APoint_, u_, v_, param_, aVecD1U, aVecD1V);
94 //=======================================================================
95 //function : FindAPointInTheFace
97 //=======================================================================
99 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
100 (const TopoDS_Face& _face,
102 Standard_Real& u_, Standard_Real& v_,
103 Standard_Real& param_,
107 TopoDS_Face face = _face;
108 face.Orientation (TopAbs_FORWARD);
110 TopExp_Explorer faceexplorer;
111 BRepAdaptor_Curve2d c;
115 for (faceexplorer.Init(face,TopAbs_EDGE);
119 TopoDS_Edge Edge = TopoDS::Edge (faceexplorer.Current());
120 c.Initialize (Edge, face);
121 c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(),P,T);
123 Standard_Real x = T.X();
124 Standard_Real y = T.Y();
125 if (Edge.Orientation() == TopAbs_FORWARD)
133 Standard_Real ParamInit = RealLast();
134 Standard_Real TolInit = 0.00001;
135 Standard_Boolean APointExist = Standard_False;
137 BRepClass_FacePassiveClassifier FClassifier;
140 P.SetCoord (P.X() + TolInit * T.X(), P.Y() + TolInit * T.Y());
141 FClassifier.Reset (gp_Lin2d (P, T), ParamInit, RealEpsilon()); //-- Length and Tolerance #######
143 TopExp_Explorer otherfaceexplorer;
144 Standard_Integer aNbEdges = 0;
145 for (otherfaceexplorer.Init (face, TopAbs_EDGE);
146 otherfaceexplorer.More();
147 otherfaceexplorer.Next(), ++aNbEdges)
149 TopoDS_Edge OtherEdge = TopoDS::Edge (otherfaceexplorer.Current());
150 if (OtherEdge.Orientation() != TopAbs_EXTERNAL && OtherEdge != Edge)
152 BRepClass_Edge AEdge (OtherEdge, face);
153 FClassifier.Compare (AEdge, OtherEdge.Orientation());
154 if (FClassifier.ClosestIntersection())
156 if(ParamInit > FClassifier.Parameter())
158 ParamInit = FClassifier.Parameter();
159 APointExist = Standard_True;
167 BRepClass_Edge AEdge (Edge, face);
168 FClassifier.Compare (AEdge, Edge.Orientation());
169 if (FClassifier.ClosestIntersection())
171 if (ParamInit > FClassifier.Parameter())
173 ParamInit = FClassifier.Parameter();
174 APointExist = Standard_True;
181 ParamInit *= 0.41234;
182 u_ = P.X() + ParamInit* T.X();
183 v_ = P.Y() + ParamInit* T.Y();
184 BRepAdaptor_Surface s;
185 s.Initialize (face, Standard_False);
186 s.D1 (u_, v_, APoint_, theVecD1U, theVecD1V);
187 return Standard_True;
190 return Standard_False;
193 //=======================================================================
194 //function : PointInTheFace
196 //=======================================================================
198 Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
199 (const TopoDS_Face& Face,
201 Standard_Real& u_, Standard_Real& v_,
202 Standard_Real& param_,
203 Standard_Integer& IndexPoint,
204 const Handle(BRepAdaptor_HSurface)& surf,
205 const Standard_Real U1,
206 const Standard_Real V1,
207 const Standard_Real U2,
208 const Standard_Real V2) const
210 gp_Vec aVecD1U, aVecD1V;
211 return PointInTheFace (Face, APoint_, u_, v_, param_, IndexPoint, surf,
212 U1, V1, U2, V2, aVecD1U, aVecD1V);
215 //=======================================================================
216 //function : PointInTheFace
218 //=======================================================================
220 Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
221 (const TopoDS_Face& Face,
223 Standard_Real& u_, Standard_Real& v_,
224 Standard_Real& param_,
225 Standard_Integer& IndexPoint,
226 const Handle(BRepAdaptor_HSurface)& surf,
227 const Standard_Real U1,
228 const Standard_Real V1,
229 const Standard_Real U2,
230 const Standard_Real V2,
232 gp_Vec& theVecD1V) const
234 Standard_Real u,du = (U2-U1)/6.0;
235 Standard_Real v,dv = (V2-V1)/6.0;
236 if(du<1e-12) du=1e-12;
237 if(dv<1e-12) dv=1e-12;
238 Standard_Integer NbPntCalc=0;
239 if(myMapOfInter.IsBound(Face)) {
240 void *ptr = (void*)(myMapOfInter.Find(Face));
242 const IntCurvesFace_Intersector& TheIntersector = (*((IntCurvesFace_Intersector *)ptr));
243 //-- Take 4 points in each Quarter of surface
244 //-- -> Index : 1 -> 16
247 //-- Then take a matrix of points on a tight grid
249 for(u=du+(U1+U2)*0.5; u<U2; u+=du) { //-- 0 X u increases
250 for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) { //-- 0 0 v increases
251 if(++NbPntCalc>=IndexPoint) {
252 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
254 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
255 IndexPoint = NbPntCalc;
256 return(Standard_True);
262 for(u=-du+(U1+U2)*0.5; u>U1; u-=du) { //-- 0 0 u decreases
263 for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) { //-- X 0 v decreases
264 if(++NbPntCalc>=IndexPoint) {
265 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
267 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
268 IndexPoint = NbPntCalc;
269 return(Standard_True);
274 for(u=-du+(U1+U2)*0.5; u>U1; u-=du) { //-- X 0 u decreases
275 for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) { //-- 0 0 v increases
276 if(++NbPntCalc>=IndexPoint) {
277 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
279 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
280 IndexPoint = NbPntCalc;
281 return(Standard_True);
286 for(u=du+(U1+U2)*0.5; u<U2; u+=du) { //-- 0 0 u increases
287 for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) { //-- 0 X v decreases
288 if(++NbPntCalc>=IndexPoint) {
289 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
291 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
292 IndexPoint = NbPntCalc;
293 return(Standard_True);
301 if(du<1e-12) du=1e-12;
302 if(dv<1e-12) dv=1e-12;
304 for(u=du+U1; u<U2; u+=du) {
305 for(v=dv+V1; v<V2; v+=dv) {
306 if(++NbPntCalc>=IndexPoint) {
307 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
309 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
310 IndexPoint = NbPntCalc;
311 return(Standard_True);
318 if(++NbPntCalc>=IndexPoint) {
319 if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
321 surf->D1 (u, v, APoint_, theVecD1U, theVecD1V);
322 IndexPoint = NbPntCalc;
323 return(Standard_True);
327 IndexPoint = NbPntCalc;
330 //printf("BRepClass3d_SolidExplorer Face not found ds the map \n");
333 return BRepClass3d_SolidExplorer
334 ::FindAPointInTheFace (Face,APoint_, u_, v_, param_, theVecD1U, theVecD1V);
337 //=======================================================================
338 //function : LimitInfiniteUV
339 //purpose : Limit infinite parameters
340 //=======================================================================
342 static void LimitInfiniteUV (Standard_Real& U1,
348 infU1 = Precision::IsNegativeInfinite(U1),
349 infV1 = Precision::IsNegativeInfinite(V1),
350 infU2 = Precision::IsPositiveInfinite(U2),
351 infV2 = Precision::IsPositiveInfinite(V2);
353 if (infU1) U1 = -1e10;
354 if (infV1) V1 = -1e10;
355 if (infU2) U2 = 1e10;
356 if (infV2) V2 = 1e10;
358 // Modified by skv - Tue Sep 16 13:50:38 2003 OCC578 Begin
360 // static Standard_Boolean IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, Standard_Real& U2, Standard_Real& V2) {
361 // return (Precision::IsNegativeInfinite(U1) || Precision::IsNegativeInfinite(V1) ||
362 // Precision::IsNegativeInfinite(U2) || Precision::IsNegativeInfinite(V2));
364 static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1,
365 Standard_Real& U2, Standard_Real& V2) {
366 Standard_Integer aVal = 0;
368 if (Precision::IsInfinite(U1))
371 if (Precision::IsInfinite(V1))
374 if (Precision::IsInfinite(U2))
377 if (Precision::IsInfinite(V2))
383 // Modified by skv - Tue Sep 16 13:50:39 2003 OCC578 End
384 //=======================================================================
385 //function : OtherSegment
386 //purpose : Returns in <L>, <Par> a segment having at least
387 // one intersection with the shape boundary to
388 // compute intersections.
389 // The First Call to this method returns a line which
390 // point to a point of the first face of the shape.
391 // The Second Call provide a line to the second face
393 //=======================================================================
394 //modified by NIZNHY-PKV Thu Nov 14 14:34:05 2002 f
395 //void BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
397 // Standard_Real& _Par)
398 Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
401 //modified by NIZNHY-PKV Thu Nov 14 14:34:10 2002 t
403 const Standard_Real TolU = Precision::PConfusion();
404 const Standard_Real TolV = TolU;
407 TopExp_Explorer faceexplorer;
408 //TopExp_Explorer edgeexplorer;
410 gp_Vec aVecD1U, aVecD1V;
411 Standard_Real maxscal=0;
412 Standard_Boolean ptfound=Standard_False;
414 //Standard_Integer i=1;
416 Standard_Integer IndexPoint=0;
417 Standard_Integer NbPointsOK=0;
418 Standard_Integer NbFacesInSolid=0;
422 faceexplorer.Init(myShape,TopAbs_FACE);
423 // look for point on face starting from myFirstFace
424 // Modified by skv - Thu Sep 4 14:31:12 2003 OCC578 Begin
425 // while (faceexplorer.More()) {
426 for (; faceexplorer.More(); faceexplorer.Next()) {
427 // Modified by skv - Thu Sep 4 14:31:12 2003 OCC578 End
429 if (myFirstFace > NbFacesInSolid) continue;
430 face = TopoDS::Face(faceexplorer.Current());
432 Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
433 surf->ChangeSurface().Initialize(face);
434 Standard_Real U1,V1,U2,V2;
435 U1 = surf->FirstUParameter();
436 V1 = surf->FirstVParameter();
437 U2 = surf->LastUParameter();
438 V2 = surf->LastVParameter();
439 face.Orientation(TopAbs_FORWARD);
441 //avoid process faces from uncorrected shells
442 if( Abs (U2 - U1) < 1.e-12 || Abs(V2 - V1) < 1.e-12) {
443 //modified by NIZNHY-PKV Thu Nov 14 15:03:18 2002 f
444 //gp_Vec avoidV(gp_Pnt(0.,0.,0.),gp_Pnt(0.,0.,1.));
445 //gp_Lin avoidL(gp_Pnt(0.,0.,0.),avoidV);
450 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
453 Standard_Real svmyparam=myParamOnEdge;
455 // Modified by skv - Tue Sep 16 13:55:27 2003 OCC578 Begin
456 // Check if the point is on the face or the face is infinite.
457 Standard_Integer anInfFlag = IsInfiniteUV(U1,V1,U2,V2);
459 // if(IsInfiniteUV(U1,V1,U2,V2)){//OCC454(apo)->
460 GeomAdaptor_Surface GA(BRep_Tool::Surface(face));
461 Extrema_ExtPS Ext(P,GA,TolU,TolV);
462 if (Ext.IsDone() && Ext.NbExt() > 0) {
463 // evaluate the lower distance and its index;
464 Standard_Real Dist2, Dist2Min = Ext.SquareDistance(1);
465 Standard_Integer iNear = 1, i = 2, iEnd = Ext.NbExt();
466 for (i = 2; i <= iEnd; i++) {
467 Dist2 = Ext.SquareDistance(i);
468 if (Dist2 < Dist2Min) {
469 Dist2Min = Dist2; iNear = i;
472 //modified by NIZNHY-PKV Thu Nov 14 12:31:01 2002 f
473 Standard_Real aDist2Tresh=1.e-24;
475 if (Dist2Min<aDist2Tresh) {
479 BRepClass_FaceClassifier classifier2d;
483 (Ext.Point(iNear)).Parameter(aU, aV);
485 gp_Pnt2d aPuv(aU, aV);
487 classifier2d.Perform(face,aPuv,Precision::PConfusion());
489 TopAbs_State aState = classifier2d.State();
491 if (aState == TopAbs_IN || aState == TopAbs_ON)
494 return 3; // skv - the point is on surface but outside face.
497 //modified by NIZNHY-PKV Thu Nov 14 12:31:03 2002 t
499 APoint = (Ext.Point(iNear)).Value();
501 _Par = V.Magnitude();
503 ptfound=Standard_True;
504 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
507 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
512 //The point is not ON the face or surface. The face is restricted.
513 // find point in a face not too far from a projection of P on face
514 // Modified by skv - Tue Sep 16 15:25:00 2003 OCC578 End
517 if (PointInTheFace (face, APoint, _u, _v, myParamOnEdge, ++IndexPoint, surf,
522 gp_Vec V (P, APoint);
524 if (Par > gp::Resolution())
526 gp_Vec Norm = aVecD1U.Crossed (aVecD1V);
527 Standard_Real tt = Norm.Magnitude();
528 tt = Abs (Norm.Dot (V)) / (tt * Par);
534 ptfound = Standard_True;
537 myParamOnEdge=svmyparam;
544 while(IndexPoint<200 && NbPointsOK<16);
546 myParamOnEdge=svmyparam;
548 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
551 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
555 // Modified by skv - Thu Sep 4 14:32:14 2003 OCC578 Begin
556 // Next is done in the main for(..) loop.
557 // faceexplorer.Next();
558 // Modified by skv - Thu Sep 4 14:32:14 2003 OCC578 End
561 Standard_Boolean encoreuneface = faceexplorer.More();
562 if(ptfound==Standard_False && encoreuneface==Standard_False) {
563 if(myParamOnEdge < 0.0001) {
564 //-- This case takes place when the point is on the solid
565 //-- and this solid is reduced to a face
566 gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
571 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
574 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
575 //-- cout<<" FindAPoint **** Pas OK "<<endl;
578 } //-- Exploration of the faces
580 if(NbFacesInSolid==0) {
582 myReject=Standard_True;
584 cout<<"\nWARNING : BRepClass3d_SolidExplorer.cxx (Solid without face)"<<endl;
586 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
589 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
593 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
596 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
599 if(myParamOnEdge==0.512345) myParamOnEdge = 0.4;
600 else if(myParamOnEdge==0.4) myParamOnEdge = 0.6;
601 else if(myParamOnEdge==0.6) myParamOnEdge = 0.3;
602 else if(myParamOnEdge==0.3) myParamOnEdge = 0.7;
603 else if(myParamOnEdge==0.7) myParamOnEdge = 0.2;
604 else if(myParamOnEdge==0.2) myParamOnEdge = 0.8;
605 else if(myParamOnEdge==0.8) myParamOnEdge = 0.1;
606 else if(myParamOnEdge==0.1) myParamOnEdge = 0.9;
607 else { myParamOnEdge*=0.5; }
612 //modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
615 //modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
618 // Modified by skv - Thu Sep 4 12:30:14 2003 OCC578 Begin
619 //=======================================================================
620 //function : GetFaceSegmentIndex
621 //purpose : Returns the index of face for which last segment is calculated.
622 //=======================================================================
624 Standard_Integer BRepClass3d_SolidExplorer::GetFaceSegmentIndex() const
628 // Modified by skv - Thu Sep 4 12:30:14 2003 OCC578 End
630 //=======================================================================
631 //function : PointInTheFace
633 //=======================================================================
635 Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
636 (const TopoDS_Face& _face,
638 Standard_Real& u_, Standard_Real& v_,
639 Standard_Real& param_,
640 Standard_Integer& IndexPoint) const
642 TopoDS_Face Face = _face;
643 Face.Orientation(TopAbs_FORWARD);
644 Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
645 surf->ChangeSurface().Initialize(Face);
646 Standard_Real U1,V1,U2,V2;//,u,v;
647 U1 = surf->FirstUParameter();
648 V1 = surf->FirstVParameter();
649 U2 = surf->LastUParameter();
650 V2 = surf->LastVParameter();
651 LimitInfiniteUV (U1,V1,U2,V2);
652 return(PointInTheFace(Face,APoint_,u_,v_,param_,IndexPoint,surf,U1,V1,U2,V2));
655 //=======================================================================
656 //function : FindAPointInTheFace
658 //=======================================================================
660 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
661 (const TopoDS_Face& _face,
663 Standard_Real& u_,Standard_Real& v_)
665 Standard_Real param = 0.1;
666 Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u_,v_,param);
670 //=======================================================================
671 //function : FindAPointInTheFace
673 //=======================================================================
675 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
676 (const TopoDS_Face& _face,
679 Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u,v);
683 //=======================================================================
684 //function : FindAPointInTheFace
686 //=======================================================================
688 Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
689 (const TopoDS_Face& _face,
690 Standard_Real& u_,Standard_Real& v_)
692 Standard_Boolean r = FindAPointInTheFace(_face,APoint,u_,v_);
696 //=======================================================================
697 //function : BRepClass3d_SolidExplorer
699 //=======================================================================
701 BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer()
704 #include <Standard_ConstructionError.hxx>
706 //=======================================================================
707 //function : BRepClass3d_SolidExplorer
708 //purpose : Raise if called.
709 //=======================================================================
711 //BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth)
712 BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& )
714 Standard_ConstructionError::Raise("Magic constructor not allowed");
717 //=======================================================================
718 //function : BRepClass3d_SolidExplorer
720 //=======================================================================
722 BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const TopoDS_Shape& S)
727 //=======================================================================
730 //=======================================================================
732 void BRepClass3d_SolidExplorer::Delete()
737 //=======================================================================
739 //purpose : C++: alias ~
740 //=======================================================================
742 void BRepClass3d_SolidExplorer::Destroy() {
743 BRepClass3d_DataMapIteratorOfMapOfInter iter(myMapOfInter);
744 for(;iter.More();iter.Next()) {
745 void *ptr=iter.Value();
747 delete (IntCurvesFace_Intersector *)ptr;
748 myMapOfInter.ChangeFind(iter.Key()) = NULL;
751 myMapOfInter.Clear();
754 //=======================================================================
755 //function : InitShape
757 //=======================================================================
759 void BRepClass3d_SolidExplorer::InitShape(const TopoDS_Shape& S)
763 myParamOnEdge = 0.512345;
764 //-- Exploring of the Map and removal of allocated objects
767 BRepClass3d_DataMapIteratorOfMapOfInter iter(myMapOfInter);
768 for(;iter.More();iter.Next()) {
769 void *ptr=iter.Value();
771 delete (IntCurvesFace_Intersector *)ptr;
772 myMapOfInter.ChangeFind(iter.Key()) = NULL;
776 myMapOfInter.Clear();
778 myReject = Standard_True; //-- case of infinite solid (without any face)
780 TopExp_Explorer Expl;
781 for(Expl.Init(S,TopAbs_FACE);
784 const TopoDS_Face Face = TopoDS::Face(Expl.Current());
785 void *ptr = (void *)(new IntCurvesFace_Intersector(Face,Precision::Confusion()));
786 myMapOfInter.Bind(Face,ptr);
787 myReject=Standard_False; //-- at least one face in the solid
792 cout<<"\nWARNING : BRepClass3d_SolidExplorer.cxx (Solid without face)"<<endl;
797 BRepBndLib::Add(myShape,myBox);
801 //=======================================================================
803 //purpose : Should return True if P outside of bounding vol. of the shape
804 //=======================================================================
806 //Standard_Boolean BRepClass3d_SolidExplorer::Reject(const gp_Pnt& P) const
807 Standard_Boolean BRepClass3d_SolidExplorer::Reject(const gp_Pnt& ) const
809 return(myReject); // case of solid without face
812 //=======================================================================
813 //function : InitShell
814 //purpose : Starts an exploration of the shells.
815 //=======================================================================
817 void BRepClass3d_SolidExplorer::InitShell()
819 myShellExplorer.Init(myShape,TopAbs_SHELL);
822 //=======================================================================
823 //function : MoreShell
824 //purpose : Returns True if there is a current shell.
825 //=======================================================================
827 Standard_Boolean BRepClass3d_SolidExplorer::MoreShell() const
829 return(myShellExplorer.More());
832 //=======================================================================
833 //function : NextShell
834 //purpose : Sets the explorer to the next shell.
835 //=======================================================================
837 void BRepClass3d_SolidExplorer::NextShell()
839 myShellExplorer.Next();
842 //=======================================================================
843 //function : CurrentShell
844 //purpose : Returns the current shell.
845 //=======================================================================
847 TopoDS_Shell BRepClass3d_SolidExplorer::CurrentShell() const
849 return(TopoDS::Shell(myShellExplorer.Current()));
852 //=======================================================================
853 //function : RejectShell
854 //purpose : Returns True if the Shell is rejected.
855 //=======================================================================
857 Standard_Boolean BRepClass3d_SolidExplorer::RejectShell(const gp_Lin& ) const
859 return(Standard_False);
862 //=======================================================================
863 //function : InitFace
864 //purpose : Starts an exploration of the faces of the current shell.
865 //=======================================================================
867 void BRepClass3d_SolidExplorer::InitFace()
869 myFaceExplorer.Init(TopoDS::Shell(myShellExplorer.Current()),TopAbs_FACE);
872 //=======================================================================
873 //function : MoreFace
874 //purpose : Returns True if current face in current shell.
875 //=======================================================================
877 Standard_Boolean BRepClass3d_SolidExplorer::MoreFace() const
879 return(myFaceExplorer.More());
882 //=======================================================================
883 //function : NextFace
884 //purpose : Sets the explorer to the next Face of the current shell.
885 //=======================================================================
887 void BRepClass3d_SolidExplorer::NextFace()
889 myFaceExplorer.Next();
892 //=======================================================================
893 //function : CurrentFace
894 //purpose : Returns the current face.
895 //=======================================================================
897 TopoDS_Face BRepClass3d_SolidExplorer::CurrentFace() const
899 return(TopoDS::Face(myFaceExplorer.Current()));
902 //=======================================================================
903 //function : RejectFace
904 //purpose : returns True if the face is rejected.
905 //=======================================================================
907 Standard_Boolean BRepClass3d_SolidExplorer::RejectFace(const gp_Lin& ) const
909 return(Standard_False);
913 #include <TopAbs_State.hxx>
916 //=======================================================================
918 //purpose : Returns in <L>, <Par> a segment having at least
919 // one intersection with the shape boundary to
920 // compute intersections.
921 //=======================================================================
922 //modified by NIZNHY-PKV Thu Nov 14 14:40:35 2002 f
923 //void BRepClass3d_SolidExplorer::Segment(const gp_Pnt& P,
925 // Standard_Real& Par) {
927 // OtherSegment(P,L,Par);
929 Standard_Integer BRepClass3d_SolidExplorer::Segment(const gp_Pnt& P,
933 Standard_Integer bRetFlag;
935 bRetFlag=OtherSegment(P,L,Par);
938 //modified by NIZNHY-PKV Thu Nov 14 14:41:48 2002 t
940 //=======================================================================
941 //function : Intersector
943 //=======================================================================
945 IntCurvesFace_Intersector& BRepClass3d_SolidExplorer::Intersector(const TopoDS_Face& F) const {
946 void *ptr = (void*)(myMapOfInter.Find(F));
948 IntCurvesFace_Intersector& curr = (*((IntCurvesFace_Intersector *)ptr));
951 return(*((IntCurvesFace_Intersector *)ptr));
955 //=======================================================================
958 //=======================================================================
960 const Bnd_Box& BRepClass3d_SolidExplorer::Box() const {
964 //=======================================================================
965 //function : DumpSegment
967 //=======================================================================
969 void BRepClass3d_SolidExplorer::DumpSegment(const gp_Pnt&,
972 const TopAbs_State) const