1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0029186: Move AddTool(), SetTools(), Tools() and other common methods of BOP tools to separate interface class

Methods AddTool(), SetTools(), Tools() have been moved to BOPAlgo_ToolsProvider class;
BOPAlgo_BOP and BOPAlgo_Splitter are now successors of BOPAlgo_ToolsProvider
This commit is contained in:
oan 2017-10-12 13:47:00 +03:00 committed by bugmaster
parent 744d9c0d22
commit 5fbe3d01e6
7 changed files with 151 additions and 122 deletions

View File

@ -71,10 +71,7 @@ static
//purpose :
//=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP()
:
BOPAlgo_Builder(),
myTools(myAllocator),
myMapTools(100, myAllocator)
: BOPAlgo_ToolsProvider()
{
Clear();
}
@ -82,12 +79,8 @@ BOPAlgo_BOP::BOPAlgo_BOP()
//function :
//purpose :
//=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Builder(theAllocator),
myTools(myAllocator),
myMapTools(100, myAllocator)
BOPAlgo_BOP::BOPAlgo_BOP(const Handle(NCollection_BaseAllocator)& theAllocator)
: BOPAlgo_ToolsProvider(theAllocator)
{
Clear();
}
@ -105,12 +98,10 @@ BOPAlgo_BOP::~BOPAlgo_BOP()
void BOPAlgo_BOP::Clear()
{
myOperation=BOPAlgo_UNKNOWN;
myTools.Clear();
myMapTools.Clear();
myDims[0]=-1;
myDims[1]=-1;
//
BOPAlgo_Builder::Clear();
BOPAlgo_ToolsProvider::Clear();
}
//=======================================================================
//function : SetOperation
@ -129,31 +120,6 @@ BOPAlgo_Operation BOPAlgo_BOP::Operation()const
return myOperation;
}
//=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape)) {
myTools.Append(theShape);
}
}
//=======================================================================
//function : SetTools
//purpose :
//=======================================================================
void BOPAlgo_BOP::SetTools(const BOPCol_ListOfShape& theShapes)
{
BOPCol_ListIteratorOfListOfShape aIt;
//
myTools.Clear();
aIt.Initialize(theShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
AddTool(aS);
}
}
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================

View File

@ -24,7 +24,7 @@
#include <TopoDS_Shape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_ToolsProvider.hxx>
#include <BOPCol_BaseAllocator.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <Standard_Boolean.hxx>
@ -66,7 +66,7 @@ class BOPAlgo_PaveFiller;
//! - *BOPAlgo_AlertSolidBuilderFailed* - in case the BuilderSolid algorithm failed to
//! produce the Fused solid.
//!
class BOPAlgo_BOP : public BOPAlgo_Builder
class BOPAlgo_BOP : public BOPAlgo_ToolsProvider
{
public:
@ -75,18 +75,13 @@ public:
//! Empty constructor
Standard_EXPORT BOPAlgo_BOP();
Standard_EXPORT virtual ~BOPAlgo_BOP();
Standard_EXPORT virtual ~BOPAlgo_BOP();
Standard_EXPORT BOPAlgo_BOP(const BOPCol_BaseAllocator& theAllocator);
//! Clears internal fields and arguments
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Adds Tool argument of the operation
Standard_EXPORT virtual void AddTool (const TopoDS_Shape& theShape);
Standard_EXPORT virtual void SetTools (const BOPCol_ListOfShape& theShapes);
Standard_EXPORT void SetOperation (const BOPAlgo_Operation theOperation);
Standard_EXPORT BOPAlgo_Operation Operation() const;
@ -116,16 +111,11 @@ protected:
//! all shapes in one of the groups are empty shapes.
Standard_EXPORT Standard_Boolean TreatEmptyShape();
protected:
BOPAlgo_Operation myOperation;
Standard_Integer myDims[2];
TopoDS_Shape myRC;
BOPCol_ListOfShape myTools;
BOPCol_MapOfShape myMapTools;
private:
};
#endif // _BOPAlgo_BOP_HeaderFile

View File

@ -22,22 +22,15 @@
//purpose :
//=======================================================================
BOPAlgo_Splitter::BOPAlgo_Splitter()
:
BOPAlgo_Builder(),
myTools(myAllocator),
myMapTools(100, myAllocator)
: BOPAlgo_ToolsProvider()
{
}
//=======================================================================
//function :
//purpose :
//=======================================================================
BOPAlgo_Splitter::BOPAlgo_Splitter
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Builder(theAllocator),
myTools(myAllocator),
myMapTools(100, myAllocator)
BOPAlgo_Splitter::BOPAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator)
: BOPAlgo_ToolsProvider(theAllocator)
{
}
//=======================================================================
@ -47,39 +40,6 @@ BOPAlgo_Splitter::BOPAlgo_Splitter
BOPAlgo_Splitter::~BOPAlgo_Splitter()
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_Splitter::Clear()
{
BOPAlgo_Builder::Clear();
myTools.Clear();
myMapTools.Clear();
}
//=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_Splitter::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape)) {
myTools.Append(theShape);
}
}
//=======================================================================
//function : SetTools
//purpose :
//=======================================================================
void BOPAlgo_Splitter::SetTools(const BOPCol_ListOfShape& theShapes)
{
myTools.Clear();
BOPCol_ListIteratorOfListOfShape aIt(theShapes);
for (; aIt.More(); aIt.Next()) {
AddTool(aIt.Value());
}
}
//=======================================================================
// function: CheckData
// purpose:

View File

@ -19,7 +19,7 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_ToolsProvider.hxx>
//! The **Splitter algorithm** is the algorithm for splitting a group of
//! arbitrary shapes by the other group of arbitrary shapes.<br>
@ -47,7 +47,7 @@
//! into result, does not have to be overridden, because its native implementation
//! performs the necessary actions for the Splitter algorithm - it adds
//! the split parts of only Objects into result, avoiding the split parts of Tools.
class BOPAlgo_Splitter : public BOPAlgo_Builder
class BOPAlgo_Splitter : public BOPAlgo_ToolsProvider
{
public:
@ -59,35 +59,13 @@ public:
Standard_EXPORT BOPAlgo_Splitter(const BOPCol_BaseAllocator& theAllocator);
//! Clears internal fields and arguments
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Adds Tool argument of the operation
Standard_EXPORT virtual void AddTool(const TopoDS_Shape& theShape);
//! Adds the Tool arguments of the operation
Standard_EXPORT virtual void SetTools(const BOPCol_ListOfShape& theShapes);
//! Returns the Tool arguments of the operation
const BOPCol_ListOfShape& Tools() const
{
return myTools;
}
//! Performs the operation
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
protected:
//! Checks the input data
Standard_EXPORT virtual void CheckData() Standard_OVERRIDE;
BOPCol_ListOfShape myTools;
BOPCol_MapOfShape myMapTools;
private:
};
#endif // _BOPAlgo_Splitter_HeaderFile

View File

@ -0,0 +1,76 @@
// Created by: Oleg AGASHIN
// Copyright (c) 2017 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 <BOPAlgo_ToolsProvider.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Alerts.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BOPAlgo_ToolsProvider::BOPAlgo_ToolsProvider()
:
BOPAlgo_Builder(),
myTools(myAllocator),
myMapTools(100, myAllocator)
{
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BOPAlgo_ToolsProvider::BOPAlgo_ToolsProvider
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Builder(theAllocator),
myTools(myAllocator),
myMapTools(100, myAllocator)
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPAlgo_ToolsProvider::Clear()
{
BOPAlgo_Builder::Clear();
myTools.Clear();
myMapTools.Clear();
}
//=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_ToolsProvider::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape))
myTools.Append(theShape);
}
//=======================================================================
//function : SetTools
//purpose :
//=======================================================================
void BOPAlgo_ToolsProvider::SetTools(const BOPCol_ListOfShape& theShapes)
{
myTools.Clear();
BOPCol_ListIteratorOfListOfShape aIt(theShapes);
for (; aIt.More(); aIt.Next())
AddTool(aIt.Value());
}

View File

@ -0,0 +1,57 @@
// Created by: Oleg AGASHIN
// Copyright (c) 2017 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.
#ifndef _BOPAlgo_ToolsProvider_HeaderFile
#define _BOPAlgo_ToolsProvider_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <BOPAlgo_Builder.hxx>
//! Auxiliary class providing API to operate tool arguments.
class BOPAlgo_ToolsProvider : public BOPAlgo_Builder
{
public:
DEFINE_STANDARD_ALLOC
//! Empty constructor
Standard_EXPORT BOPAlgo_ToolsProvider();
Standard_EXPORT BOPAlgo_ToolsProvider(const BOPCol_BaseAllocator& theAllocator);
//! Clears internal fields and arguments
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
//! Adds Tool argument of the operation
Standard_EXPORT virtual void AddTool(const TopoDS_Shape& theShape);
//! Adds the Tool arguments of the operation
Standard_EXPORT virtual void SetTools(const BOPCol_ListOfShape& theShapes);
//! Returns the Tool arguments of the operation
const BOPCol_ListOfShape& Tools() const
{
return myTools;
}
protected:
BOPCol_ListOfShape myTools;
BOPCol_MapOfShape myMapTools;
};
#endif // _BOPAlgo_ToolsProvider_HeaderFile

View File

@ -3,6 +3,8 @@ BOPAlgo_Algo.hxx
BOPAlgo_ArgumentAnalyzer.cxx
BOPAlgo_ArgumentAnalyzer.hxx
BOPAlgo_ArgumentAnalyzer.lxx
BOPAlgo_ToolsProvider.cxx
BOPAlgo_ToolsProvider.hxx
BOPAlgo_BOP.cxx
BOPAlgo_BOP.hxx
BOPAlgo_Builder.cxx