mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-13 19:04:10 +08: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:
131
src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx
Normal file
131
src/BRepAlgoAPI/BRepAlgoAPI_Splitter.cxx
Normal file
@@ -0,0 +1,131 @@
|
||||
// Created by: Eugeny MALTCHIKOV
|
||||
// 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 <BRepAlgoAPI_Splitter.hxx>
|
||||
|
||||
#include <BOPAlgo_PaveFiller.hxx>
|
||||
#include <BOPAlgo_Splitter.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// function: Empty constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter()
|
||||
: BRepAlgoAPI_BuilderAlgo() {}
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor with already filled PaveFiller
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Splitter::BRepAlgoAPI_Splitter(const BOPAlgo_PaveFiller& thePF)
|
||||
: BRepAlgoAPI_BuilderAlgo(thePF) {}
|
||||
|
||||
//=======================================================================
|
||||
// function: Destructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
BRepAlgoAPI_Splitter::~BRepAlgoAPI_Splitter()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: SetTools
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Splitter::SetTools(const TopTools_ListOfShape& theLS)
|
||||
{
|
||||
myTools = theLS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Tools
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BRepAlgoAPI_Splitter::Tools() const
|
||||
{
|
||||
return myTools;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Build
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void BRepAlgoAPI_Splitter::Build()
|
||||
{
|
||||
NotDone();
|
||||
myErrorStatus = 0;
|
||||
//
|
||||
if (myArguments.IsEmpty() ||
|
||||
(myArguments.Extent() + myTools.Extent()) < 2) {
|
||||
myErrorStatus = 1;
|
||||
return;
|
||||
}
|
||||
//
|
||||
Clear();
|
||||
//
|
||||
if (myEntryType) {
|
||||
if (myDSFiller) {
|
||||
delete myDSFiller;
|
||||
}
|
||||
myDSFiller = new BOPAlgo_PaveFiller(myAllocator);
|
||||
//
|
||||
TopTools_ListOfShape aLArgs;
|
||||
TopTools_ListIteratorOfListOfShape aItLA(myArguments);
|
||||
for (; aItLA.More(); aItLA.Next()) {
|
||||
aLArgs.Append(aItLA.Value());
|
||||
}
|
||||
//
|
||||
aItLA.Initialize(myTools);
|
||||
for (; aItLA.More(); aItLA.Next()) {
|
||||
aLArgs.Append(aItLA.Value());
|
||||
}
|
||||
//
|
||||
myDSFiller->SetArguments(aLArgs);
|
||||
//
|
||||
myDSFiller->SetRunParallel(myRunParallel);
|
||||
myDSFiller->SetProgressIndicator(myProgressIndicator);
|
||||
myDSFiller->SetFuzzyValue(myFuzzyValue);
|
||||
myDSFiller->SetNonDestructive(myNonDestructive);
|
||||
myDSFiller->SetGlue(myGlue);
|
||||
//
|
||||
myDSFiller->Perform();
|
||||
Standard_Integer iErr = myDSFiller->ErrorStatus();
|
||||
if (iErr) {
|
||||
myErrorStatus = 2;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (myBuilder) {
|
||||
delete myBuilder;
|
||||
}
|
||||
//
|
||||
{
|
||||
BOPAlgo_Splitter *pSplitter = new BOPAlgo_Splitter(myAllocator);
|
||||
pSplitter->SetArguments(myArguments);
|
||||
pSplitter->SetTools(myTools);
|
||||
myBuilder = pSplitter;
|
||||
}
|
||||
//
|
||||
myBuilder->SetRunParallel(myRunParallel);
|
||||
myBuilder->SetProgressIndicator(myProgressIndicator);
|
||||
//
|
||||
myBuilder->PerformWithFiller(*myDSFiller);
|
||||
Standard_Integer iErr = myBuilder->ErrorStatus();
|
||||
if (iErr) {
|
||||
myErrorStatus = 3;
|
||||
}
|
||||
//
|
||||
Done();
|
||||
myShape = myBuilder->Shape();
|
||||
}
|
||||
Reference in New Issue
Block a user