1 // Created on: 2005-02-14
2 // Created by: Alexey MORENOV
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <ShapeAnalysis_BoxBndTree.hxx>
17 #include <Standard_NoSuchObject.hxx>
18 #include <ShapeAnalysis_Edge.hxx>
19 #include <TopoDS_Vertex.hxx>
20 #include <TopoDS_Edge.hxx>
21 #include <TopoDS_Wire.hxx>
23 #include <ShapeAnalysis.hxx>
25 #include <TColStd_ListIteratorOfListOfInteger.hxx>
26 #include <BRep_Tool.hxx>
27 #include <Precision.hxx>
29 //=======================================================================
32 //=======================================================================
34 Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
35 Reject (const Bnd_Box& theBnd) const
37 Standard_Boolean fch = myFBox.IsOut(theBnd);
38 Standard_Boolean lch = myLBox.IsOut(theBnd);
39 if (fch == Standard_False || lch == Standard_False) return Standard_False;
43 //=======================================================================
46 //=======================================================================
48 Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
49 Accept (const Standard_Integer& theObj)
51 if (theObj < 1 || theObj > mySeq->Length())
52 Standard_NoSuchObject::Raise
53 ("ShapeAnalysis_BoxBndTreeSelector::Accept : no such object for current index");
54 Standard_Boolean IsAccept = Standard_False;
55 if (myList.Contains(theObj))
56 return Standard_False;
63 TopoDS_Wire W = TopoDS::Wire (mySeq->Value (theObj));
65 ShapeAnalysis::FindBounds (W,V1,V2);
67 if (myLVertex.IsSame(V1)){
68 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
69 IsAccept = Standard_True;
70 myArrIndices(Last) = theObj;
73 if (myLVertex.IsSame(V2)){
74 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
75 IsAccept = Standard_True;
76 myArrIndices(Last) = theObj;
79 if (myFVertex.IsSame(V2)){
80 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
81 IsAccept = Standard_True;
82 myArrIndices(First) = theObj;
85 if (myFVertex.IsSame(V1)){
86 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4);
87 IsAccept = Standard_True;
88 myArrIndices(First) = theObj;
90 else myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
99 if(myArrIndices(Last))
100 myStop = Standard_True;
101 return Standard_True;
103 else myStop = Standard_False;
107 gp_Pnt p1 = BRep_Tool::Pnt(V1);
108 gp_Pnt p2 = BRep_Tool::Pnt(V2);
110 Standard_Real tailhead, tailtail, headhead, headtail;
111 tailhead = p1.Distance(myLPnt);
112 tailtail = p2.Distance(myLPnt);
113 headhead = p1.Distance(myFPnt);
114 headtail = p2.Distance(myFPnt);
115 Standard_Real dm1 = tailhead, dm2 = headtail;
116 Standard_Integer res1 = 0, res2 = 0;
117 if (tailhead > tailtail) {res1 = 1; dm1 = tailtail;}
118 if (headtail > headhead) {res2 = 1; dm2 = headhead;}
119 Standard_Integer result = res1;
121 min3d = Min (dm1, dm2);
123 return Standard_False;
125 Standard_Integer minInd = (dm1 > dm2 ? First : Last );
126 Standard_Integer maxInd = (dm1 > dm2 ? Last : First);
127 myArrIndices(minInd) = theObj;
128 if((min3d - myMin3d) > RealSmall())
129 myArrIndices(maxInd) = 0;
134 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
135 return Standard_False;
138 Standard_Integer anObj = (myArrIndices(Last) ? myArrIndices(Last) : myArrIndices(First));
141 if (min3d == 0 && minInd == Last)
142 myStop = Standard_True;
152 case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
153 case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
154 case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
155 case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
158 return Standard_True;
162 return Standard_False;