1 // Created on: 2005-02-14
2 // Created by: Alexey MORENOV
3 // Copyright (c) 2005-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <ShapeAnalysis_BoxBndTree.hxx>
22 #include <Standard_NoSuchObject.hxx>
23 #include <ShapeAnalysis_Edge.hxx>
24 #include <TopoDS_Vertex.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Wire.hxx>
28 #include <ShapeAnalysis.hxx>
30 #include <TColStd_ListIteratorOfListOfInteger.hxx>
31 #include <BRep_Tool.hxx>
32 #include <Precision.hxx>
34 //=======================================================================
37 //=======================================================================
39 Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
40 Reject (const Bnd_Box& theBnd) const
42 Standard_Boolean fch = myFBox.IsOut(theBnd);
43 Standard_Boolean lch = myLBox.IsOut(theBnd);
44 if (fch == Standard_False || lch == Standard_False) return Standard_False;
48 //=======================================================================
51 //=======================================================================
53 Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
54 Accept (const Standard_Integer& theObj)
56 if (theObj < 1 || theObj > mySeq->Length())
57 Standard_NoSuchObject::Raise
58 ("ShapeAnalysis_BoxBndTreeSelector::Accept : no such object for current index");
59 Standard_Boolean IsAccept = Standard_False;
60 if (myList.Contains(theObj))
61 return Standard_False;
68 TopoDS_Wire W = TopoDS::Wire (mySeq->Value (theObj));
70 ShapeAnalysis::FindBounds (W,V1,V2);
72 if (myLVertex.IsSame(V1)){
73 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
74 IsAccept = Standard_True;
75 myArrIndices(Last) = theObj;
78 if (myLVertex.IsSame(V2)){
79 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
80 IsAccept = Standard_True;
81 myArrIndices(Last) = theObj;
84 if (myFVertex.IsSame(V2)){
85 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
86 IsAccept = Standard_True;
87 myArrIndices(First) = theObj;
90 if (myFVertex.IsSame(V1)){
91 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4);
92 IsAccept = Standard_True;
93 myArrIndices(First) = theObj;
95 else myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
104 if(myArrIndices(Last))
105 myStop = Standard_True;
106 return Standard_True;
108 else myStop = Standard_False;
112 gp_Pnt p1 = BRep_Tool::Pnt(V1);
113 gp_Pnt p2 = BRep_Tool::Pnt(V2);
115 Standard_Real tailhead, tailtail, headhead, headtail;
116 tailhead = p1.Distance(myLPnt);
117 tailtail = p2.Distance(myLPnt);
118 headhead = p1.Distance(myFPnt);
119 headtail = p2.Distance(myFPnt);
120 Standard_Real dm1 = tailhead, dm2 = headtail;
121 Standard_Integer res1 = 0, res2 = 0;
122 if (tailhead > tailtail) {res1 = 1; dm1 = tailtail;}
123 if (headtail > headhead) {res2 = 1; dm2 = headhead;}
124 Standard_Integer result = res1;
126 min3d = Min (dm1, dm2);
128 return Standard_False;
130 Standard_Integer minInd = (dm1 > dm2 ? First : Last );
131 Standard_Integer maxInd = (dm1 > dm2 ? Last : First);
132 myArrIndices(minInd) = theObj;
133 if((min3d - myMin3d) > RealSmall())
134 myArrIndices(maxInd) = 0;
139 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
140 return Standard_False;
143 Standard_Integer anObj = (myArrIndices(Last) ? myArrIndices(Last) : myArrIndices(First));
146 if (min3d == 0 && minInd == Last)
147 myStop = Standard_True;
157 case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
158 case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
159 case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
160 case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
163 return Standard_True;
167 return Standard_False;