// Created by: Peter KURNEV // 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 //======================================================================= //function : //purpose : //======================================================================= inline BOPTools_ShapeSet::BOPTools_ShapeSet() { } //======================================================================= //function : //purpose : //======================================================================= inline BOPTools_ShapeSet::BOPTools_ShapeSet(const Handle(NCollection_BaseAllocator)& theObj) : myMap(100, theObj) { } //======================================================================= //function : ~ //purpose : //======================================================================= inline BOPTools_ShapeSet::~BOPTools_ShapeSet() { } //======================================================================= //function : Clear //purpose : //======================================================================= inline void BOPTools_ShapeSet::Clear() { myMap.Clear(); } //======================================================================= //function : SetShape //purpose : //======================================================================= inline void BOPTools_ShapeSet::SetShape(const TopoDS_Shape& theShape) { myShape=theShape; } //======================================================================= //function : Shape //purpose : //======================================================================= inline const TopoDS_Shape& BOPTools_ShapeSet::Shape()const { return myShape; } //======================================================================= //function : Add //purpose : //======================================================================= inline void BOPTools_ShapeSet::Add(const TopoDS_Shape& theShape) { myMap.Add(theShape); } //======================================================================= //function : Add //purpose : //======================================================================= inline void BOPTools_ShapeSet::Add(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) { TopExp_Explorer aExp(theShape, theType); for(; aExp.More(); aExp.Next()) { const TopoDS_Shape& aS=aExp.Current(); myMap.Add(aS); } } //======================================================================= //function : Add //purpose : //======================================================================= inline void BOPTools_ShapeSet::Add(const BOPCol_ListOfShape& theLS) { BOPCol_ListIteratorOfListOfShape aIt; // aIt.Init(theLS); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); myMap.Add(aS); } } //======================================================================= //function : AddEdge //purpose : //======================================================================= inline void BOPTools_ShapeSet::AddEdge(const TopoDS_Edge& theEdge) { if (!BRep_Tool::Degenerated(theEdge)){ myMap.Add(theEdge); } } //======================================================================= //function : AddEdges //purpose : //======================================================================= inline void BOPTools_ShapeSet::AddEdges(const BOPCol_ListOfShape& theLS) { BOPCol_ListIteratorOfListOfShape aIt; // aIt.Initialize(theLS); for (; aIt.More(); aIt.Next()) { const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aIt.Value()); AddEdge(aE); } } //======================================================================= //function : AddEdges //purpose : //======================================================================= inline void BOPTools_ShapeSet::AddEdges(const TopoDS_Shape& theFace) { TopExp_Explorer aExp(theFace, TopAbs_EDGE); for(; aExp.More(); aExp.Next()) { const TopoDS_Edge& aE=(*(TopoDS_Edge*)&aExp.Current()); AddEdge(aE); } } //======================================================================= //function : Get //purpose : //======================================================================= inline void BOPTools_ShapeSet::Get(BOPCol_ListOfShape& theLS)const { BOPCol_MapIteratorOfMapOfOrientedShape aIt; // aIt.Initialize(myMap); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); theLS.Append(aS); } } //======================================================================= //function : Contains //purpose : //======================================================================= inline Standard_Boolean BOPTools_ShapeSet::Contains(const BOPTools_ShapeSet& theOther)const { Standard_Boolean bRet; BOPCol_MapIteratorOfMapOfOrientedShape aIt; // aIt.Initialize(theOther.myMap); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); bRet=myMap.Contains(aS); if (!bRet) { break; } } return bRet; } //======================================================================= //function : Subtract //purpose : //======================================================================= inline void BOPTools_ShapeSet::Subtract(const BOPTools_ShapeSet& theOther) { BOPCol_MapIteratorOfMapOfOrientedShape aIt; // aIt.Initialize(theOther.myMap); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); if (myMap.Contains(aS)) { myMap.Remove(aS); } } }