// Created on: 1993-07-08 // Created by: Jean Yves LEBEY // Copyright (c) 1993-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #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 TOPOPEBREPTOOL_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 "<