1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0026874: Implementation of the Partition operator in OCCT

1. The partition operation allows splitting an arbitrary number of shapes of an arbitrary dimension
by other arbitrary shapes. The algorithm has been implemented in the class BOPAlgo_Splitter.

The API operator Splitter has been implemented in the class BRepAlgoAPI_Splitter.

2. The draw commands for usage the new algorithm have been implemented - bsplit and bapisplit.
The commands are identical, but one uses the BOPAlgo_Splitter, the other uses BRepAlgoAPI_Splitter.
Both commands should be used after Pave Filler is filled.

3. Test cases for the new algorithm.

4. Documentation has been updated.

Small corrections.
This commit is contained in:
emv
2017-03-03 15:58:11 +03:00
committed by bugmaster
parent 093a3fe5bb
commit c58055adeb
33 changed files with 1391 additions and 435 deletions

View File

@@ -23,6 +23,7 @@
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepAlgoAPI_Splitter.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <TopoDS_Shape.hxx>
@@ -34,8 +35,9 @@ static
void ConvertList(const BOPCol_ListOfShape& aLSB,
TopTools_ListOfShape& aLS);
static Standard_Integer bapibuild(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bapibop (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bapibuild(Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bapibop (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bapisplit(Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : APICommands
@@ -51,6 +53,7 @@ void BOPTest::APICommands(Draw_Interpretor& theCommands)
// Commands
theCommands.Add("bapibuild", "use bapibuild r" , __FILE__, bapibuild, g);
theCommands.Add("bapibop", "use bapibop r type" , __FILE__, bapibop, g);
theCommands.Add("bapisplit", "use bapisplit r" , __FILE__, bapisplit, g);
}
//=======================================================================
//function : bapibop
@@ -219,3 +222,46 @@ void ConvertList(const BOPCol_ListOfShape& aLSB,
}
}
//=======================================================================
//function : bapisplit
//purpose :
//=======================================================================
Standard_Integer bapisplit(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n < 2) {
di << " use bapisplit r\n";
return 1;
}
//
BRepAlgoAPI_Splitter aSplitter;
// setting arguments
aSplitter.SetArguments(BOPTest_Objects::Shapes());
aSplitter.SetTools(BOPTest_Objects::Tools());
// setting options
aSplitter.SetRunParallel(BOPTest_Objects::RunParallel());
aSplitter.SetFuzzyValue(BOPTest_Objects::FuzzyValue());
aSplitter.SetNonDestructive(BOPTest_Objects::NonDestructive());
aSplitter.SetGlue(BOPTest_Objects::Glue());
//
// performing operation
aSplitter.Build();
// checking error status
Standard_Integer iErr = aSplitter.ErrorStatus();
if (iErr) {
di << "Error: " << iErr << "\n";
return 0;
}
//
// getting the result of the operation
const TopoDS_Shape& aR = aSplitter.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}

View File

@@ -19,6 +19,7 @@
#include <BOPAlgo_Section.hxx>
#include <BOPTest_Objects.hxx>
#include <BOPAlgo_CellsBuilder.hxx>
#include <BOPAlgo_Splitter.hxx>
#include <NCollection_BaseAllocator.hxx>
static Handle(NCollection_BaseAllocator)& Allocator1();
@@ -254,6 +255,15 @@ BOPAlgo_CellsBuilder& BOPTest_Objects::CellsBuilder()
return sCBuilder;
}
//=======================================================================
//function : Splitter
//purpose :
//=======================================================================
BOPAlgo_Splitter& BOPTest_Objects::Splitter()
{
static BOPAlgo_Splitter aSplitter(Allocator1());
return aSplitter;
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================

View File

@@ -31,10 +31,10 @@ class BOPAlgo_PaveFiller;
class BOPAlgo_Builder;
class BOPAlgo_BOP;
class BOPAlgo_Section;
class BOPAlgo_Splitter;
class BOPTest_Objects
class BOPTest_Objects
{
public:
@@ -57,6 +57,8 @@ public:
Standard_EXPORT static BOPAlgo_CellsBuilder& CellsBuilder();
Standard_EXPORT static BOPAlgo_Splitter& Splitter();
Standard_EXPORT static BOPCol_ListOfShape& Shapes();
Standard_EXPORT static BOPCol_ListOfShape& Tools();
@@ -84,22 +86,8 @@ public:
protected:
private:
};
#endif // _BOPTest_Objects_HeaderFile

View File

@@ -18,6 +18,7 @@
#include <BOPAlgo_Operation.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Section.hxx>
#include <BOPAlgo_Splitter.hxx>
#include <BOPTest.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
@@ -32,9 +33,10 @@
#include <string.h>
//
//
static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bsplit (Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : PartitionCommands
@@ -51,6 +53,7 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
theCommands.Add("bfillds", "use bfillds [-t]" , __FILE__, bfillds, g);
theCommands.Add("bbuild" , "use bbuild r [-t]" , __FILE__, bbuild, g);
theCommands.Add("bbop" , "use bbop r op [-t]", __FILE__, bbop, g);
theCommands.Add("bsplit" , "use bsplit r [-t]" , __FILE__, bsplit, g);
}
//=======================================================================
//function : bfillds
@@ -330,3 +333,74 @@ Standard_Integer bbop(Draw_Interpretor& di,
return 0;
}
//=======================================================================
//function : bsplit
//purpose :
//=======================================================================
Standard_Integer bsplit(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n < 2) {
di << " use bsplit r [-t (show time)]\n";
return 1;
}
//
BOPDS_PDS pDS = BOPTest_Objects::PDS();
if (!pDS) {
di << " prepare PaveFiller first\n";
return 0;
}
//
BOPAlgo_PaveFiller& aPF = BOPTest_Objects::PaveFiller();
//
BOPAlgo_Splitter* pSplitter = &BOPTest_Objects::Splitter();
pSplitter->Clear();
//
// set objects
const BOPCol_ListOfShape& aLSObjects = BOPTest_Objects::Shapes();
pSplitter->SetArguments(aLSObjects);
//
// set tools
BOPCol_ListOfShape& aLSTools = BOPTest_Objects::Tools();
pSplitter->SetTools(aLSTools);
//
// set options
pSplitter->SetRunParallel(BOPTest_Objects::RunParallel());
pSplitter->SetNonDestructive(BOPTest_Objects::NonDestructive());
pSplitter->SetFuzzyValue(BOPTest_Objects::FuzzyValue());
//
// measure the time of the operation
OSD_Timer aTimer;
aTimer.Start();
//
// perform the operation
pSplitter->PerformWithFiller(aPF);
//
aTimer.Stop();
//
Standard_Integer iErr = pSplitter->ErrorStatus();
if (iErr) {
di << " error: " << iErr << "\n";
return 0;
}
//
// show time if necessary
if (n == 3 && !strcmp(a[2], "-t")) {
char buf[20];
Sprintf(buf, " Tps: %7.2lf\n", aTimer.ElapsedTime());
di << buf;
}
//
// DRAW history support
BOPTest_Objects::SetBuilder(pSplitter);
//
const TopoDS_Shape& aR = pSplitter->Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}