// Created on: 1993-07-08 // Created by: Jean Yves LEBEY // Copyright (c) 1993-1999 Matra Datavision // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. #include #include #include #include #include #include #include #include #include #include #include #ifdef DEB #define TBOX TopOpeBRepTool_GettraceBOX() #endif //======================================================================= //function : TopOpeBRepTool_HBoxTool //purpose : //======================================================================= TopOpeBRepTool_HBoxTool::TopOpeBRepTool_HBoxTool() { } //======================================================================= //function : Clear //purpose : //======================================================================= void TopOpeBRepTool_HBoxTool::Clear() { myIMS.Clear(); } //======================================================================= //function : ComputeBoxes //purpose : //======================================================================= void TopOpeBRepTool_HBoxTool::AddBoxes(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA) { TopExp_Explorer ex; for (ex.Init(S,TS,TA);ex.More();ex.Next()) { // for (TopExp_Explorer ex(S,TS,TA);ex.More();ex.Next()) { const TopoDS_Shape& ss = ex.Current(); AddBox(ss); } } //======================================================================= //function : AddBox //purpose : //======================================================================= void TopOpeBRepTool_HBoxTool::AddBox(const TopoDS_Shape& S) { #ifdef DEB TopAbs_ShapeEnum t = #endif S.ShapeType(); Standard_Boolean hasb = HasBox(S); if (hasb) return; Bnd_Box B; ComputeBox(S,B); myIMS.Add(S,B); #ifdef DEB if (TBOX) { DumpB(Box(S));cout<<"; # HBT::AddBox "<= 1 && I <= iu); if (!hb) { Standard_ProgramError::Raise("HBT::Box2"); } const Bnd_Box& B = myIMS.FindFromIndex(I); return B; } //======================================================================= //function : HasBox //purpose : //======================================================================= Standard_Boolean TopOpeBRepTool_HBoxTool::HasBox(const TopoDS_Shape& S) const { Standard_Boolean hb = myIMS.Contains(S); return hb; } //======================================================================= //function : Shape //purpose : //======================================================================= const TopoDS_Shape& TopOpeBRepTool_HBoxTool::Shape(const Standard_Integer I) const { Standard_Integer iu = Extent(); Standard_Integer hs = (I >= 1 && I <= iu); if (!hs) { Standard_ProgramError::Raise("HBT::Box4"); } const TopoDS_Shape& S = myIMS.FindKey(I); return S; } //======================================================================= //function : Index //purpose : //======================================================================= Standard_Integer TopOpeBRepTool_HBoxTool::Index(const TopoDS_Shape& S) const { Standard_Integer i = myIMS.FindIndex(S); return i; } //======================================================================= //function : Extent //purpose : //======================================================================= Standard_Integer TopOpeBRepTool_HBoxTool::Extent() const { Standard_Integer n = myIMS.Extent(); return n; } //======================================================================= //function : ChangeIMS //purpose : //======================================================================= TopOpeBRepTool_IndexedDataMapOfShapeBox& TopOpeBRepTool_HBoxTool::ChangeIMS() { return myIMS; } //======================================================================= //function : IMS //purpose : //======================================================================= const TopOpeBRepTool_IndexedDataMapOfShapeBox& TopOpeBRepTool_HBoxTool::IMS() const { return myIMS; } //======================================================================= //function : DumpB //purpose : //======================================================================= void TopOpeBRepTool_HBoxTool::DumpB #ifdef DEB (const Bnd_Box& B) { if (B.IsVoid()) cout<<"# IsVoid"; else if (B.IsWhole()) cout<<"# IsWhole"; else { Standard_Real x,y,z,X,Y,Z; B.Get(x,y,z,X,Y,Z); cout<<"bounding "<