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

0024825: Fit Boolean Operation Algorithm to treat multiple arguments.

class BOPTest
class BOPAlgo_BOP
class BOPAlgo_Builder
class BOPTest
class BRepFeat_Builder
class BRepFeat_MakeCylindricalHole

The format of the command has been changed:
bbop r op [-s -t]
The following options has been added:
-s - run in serial mode
-t  - print the CPU time

Test cases for issue CR24825
This commit is contained in:
pkv 2014-04-17 16:04:29 +04:00 committed by apn
parent d7515f9afb
commit 8620e18d6e
16 changed files with 774 additions and 407 deletions

View File

@ -10,20 +10,26 @@
-- distribution for complete text of the license and disclaimer of any warranty. -- distribution for complete text of the license and disclaimer of any warranty.
-- --
-- Alternatively, this file may be used under the terms of Open CASCADE -- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement. -- commercial license or contractual agreement.
--BOPAlgo_BOP.cdl
class BOP from BOPAlgo class BOP from BOPAlgo
inherits Builder from BOPAlgo inherits Builder from BOPAlgo
---Purpose: ---Purpose:
uses uses
Shape from TopoDS, ShapeEnum from TopAbs,
Shape from TopoDS,
ListOfShape from TopTools,
--
BaseAllocator from BOPCol, BaseAllocator from BOPCol,
ListOfShape from BOPCol, ListOfShape from BOPCol,
ListOfShape from TopTools, MapOfShape from BOPCol,
MapOfShape from BOPCol, IndexedDataMapOfShapeListOfShape from BOPCol,
IndexedDataMapOfShapeListOfShape from BOPCol, --
Operation from BOPAlgo, Operation from BOPAlgo,
PaveFiller from BOPAlgo PaveFiller from BOPAlgo
--raises --raises
@ -31,85 +37,79 @@ uses
is is
Create Create
---Purpose: Empty constructor ---Purpose: Empty constructor
returns BOP from BOPAlgo; returns BOP from BOPAlgo;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BOP();" ---C++: alias "Standard_EXPORT virtual ~BOPAlgo_BOP();"
Create (theAllocator: BaseAllocator from BOPCol) Create (theAllocator: BaseAllocator from BOPCol)
returns BOP from BOPAlgo; returns BOP from BOPAlgo;
Clear(me:out) Clear(me:out)
is redefined; is redefined;
---Purpose: Clears internal fields and arguments ---Purpose: Clears internal fields and arguments
AddArgument (me:out;
theShape: Shape from TopoDS)
---Purpose: Adds Object argument of the operation
is redefined;
AddTool (me:out; AddTool (me:out;
theShape: Shape from TopoDS) theShape: Shape from TopoDS)
---Purpose: Adds Tool argument of the operation ---Purpose: Adds Tool argument of the operation
is virtual; is virtual;
Object(me)
returns Shape from TopoDS;
---C++: return const &
Tool(me)
returns Shape from TopoDS;
---C++: return const &
SetOperation(me:out; SetOperation(me:out;
theOperation: Operation from BOPAlgo); theOperation: Operation from BOPAlgo);
Operation(me) Operation(me)
returns Operation from BOPAlgo; returns Operation from BOPAlgo;
--
Perform(me:out)
is redefined;
-- --
-- protected methods -- protected methods
-- --
CheckData(me:out) CheckData(me:out)
is redefined protected; is redefined protected;
Prepare(me:out) Prepare(me:out)
is redefined protected; is redefined protected;
---Purpose: Provides preparing actions ---Purpose: Provides preparing actions
PerformInternal(me:out; PerformInternal(me:out;
thePF:PaveFiller from BOPAlgo) thePF:PaveFiller from BOPAlgo)
is redefined protected; is redefined protected;
---Purpose: Performs calculations using prepared Filler ---Purpose: Performs calculations using prepared Filler
-- object theDSF -- object theDSF
BuildResult(me:out;
theType: ShapeEnum from TopAbs)
is redefined protected;
BuildShape(me:out) BuildShape(me:out)
is protected; is protected;
BuildRC(me:out) BuildRC(me:out)
is protected; is protected;
BuildSolid(me:out) BuildSolid(me:out)
is protected; is protected;
BuildSection(me:out) BuildSection(me:out)
is protected; is protected;
IsBoundSplits(me:out; IsBoundSplits(me:out;
theS:Shape from TopoDS; theS:Shape from TopoDS;
theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol) theMEF:out IndexedDataMapOfShapeListOfShape from BOPCol)
returns Boolean from Standard returns Boolean from Standard
is protected; is protected;
Generated (me:out; Generated (me:out;
theS : Shape from TopoDS) theS : Shape from TopoDS)
returns ListOfShape from TopTools
is redefined;
---C++: return const &
---Purpose: Returns the list of shapes generated from the ---Purpose: Returns the list of shapes generated from the
-- shape theS. -- shape theS.
returns ListOfShape from TopTools
is redefined;
---C++: return const &
fields fields
myNbArgs : Integer from Standard is protected;
myOperation : Operation from BOPAlgo is protected; myOperation : Operation from BOPAlgo is protected;
myArgs : Shape from TopoDS[2] is protected;
myDims : Integer from Standard[2] is protected; myDims : Integer from Standard[2] is protected;
-- --
myRC : Shape from TopoDS is protected; myRC : Shape from TopoDS is protected;

View File

@ -18,58 +18,69 @@
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx>
#include <BOPCol_IndexedMapOfShape.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPTools.hxx> #include <BOPTools.hxx>
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx> #include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPAlgo_BuilderSolid.hxx> #include <BOPAlgo_BuilderSolid.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Tool.hxx>
static static
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim); TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim);
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
//======================================================================= //=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP() BOPAlgo_BOP::BOPAlgo_BOP()
: :
BOPAlgo_Builder(), BOPAlgo_Builder(),
myTools(myAllocator), myTools(myAllocator),
myMapTools(100, myAllocator) myMapTools(100, myAllocator)
{ {
myNbArgs=2;
Clear(); Clear();
} }
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
//======================================================================= //=======================================================================
BOPAlgo_BOP::BOPAlgo_BOP(const Handle(NCollection_BaseAllocator)& theAllocator) BOPAlgo_BOP::BOPAlgo_BOP
(const Handle(NCollection_BaseAllocator)& theAllocator)
: :
BOPAlgo_Builder(theAllocator), BOPAlgo_Builder(theAllocator),
myTools(myAllocator), myTools(myAllocator),
myMapTools(100, myAllocator) myMapTools(100, myAllocator)
{ {
myNbArgs=2;
Clear(); Clear();
} }
//======================================================================= //=======================================================================
//function : ~ //function : ~
//purpose : //purpose :
//======================================================================= //=======================================================================
BOPAlgo_BOP::~BOPAlgo_BOP() BOPAlgo_BOP::~BOPAlgo_BOP()
{ {
} }
//======================================================================= //=======================================================================
//function : Clear //function : Clear
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::Clear() void BOPAlgo_BOP::Clear()
{ {
myOperation=BOPAlgo_UNKNOWN; myOperation=BOPAlgo_UNKNOWN;
myTools.Clear(); myTools.Clear();
@ -80,52 +91,10 @@ static
BOPAlgo_Builder::Clear(); BOPAlgo_Builder::Clear();
} }
//======================================================================= //=======================================================================
//function : AddArgument
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddArgument(const TopoDS_Shape& theShape)
{
if (myMapFence.Add(theShape)) {
myArguments.Append(theShape);
myArgs[0]=theShape;
}
}
//=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape)) {
myTools.Append(theShape);
myArgs[1]=theShape;
//
if (myMapFence.Add(theShape)) {
myArguments.Append(theShape);
}
}
}
//=======================================================================
//function : Object
//purpose :
//=======================================================================
const TopoDS_Shape& BOPAlgo_BOP::Object()const
{
return myArgs[0];
}
//=======================================================================
//function : Tool
//purpose :
//=======================================================================
const TopoDS_Shape& BOPAlgo_BOP::Tool()const
{
return myArgs[1];
}
//=======================================================================
//function : SetOperation //function : SetOperation
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation) void BOPAlgo_BOP::SetOperation(const BOPAlgo_Operation theOperation)
{ {
myOperation=theOperation; myOperation=theOperation;
} }
@ -133,27 +102,42 @@ static
//function : Operation //function : Operation
//purpose : //purpose :
//======================================================================= //=======================================================================
BOPAlgo_Operation BOPAlgo_BOP::Operation()const BOPAlgo_Operation BOPAlgo_BOP::Operation()const
{ {
return myOperation; return myOperation;
} }
//======================================================================= //=======================================================================
//function : AddTool
//purpose :
//=======================================================================
void BOPAlgo_BOP::AddTool(const TopoDS_Shape& theShape)
{
if (myMapTools.Add(theShape)) {
myTools.Append(theShape);
}
}
//=======================================================================
//function : CheckData //function : CheckData
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::CheckData() void BOPAlgo_BOP::CheckData()
{ {
Standard_Integer i, aNb; Standard_Integer i, j, iDim, aNbArgs, aNbTools;
Standard_Boolean bFlag; Standard_Boolean bFlag;
BOPCol_ListIteratorOfListOfShape aItLS;
// //
myErrorStatus=0; myErrorStatus=0;
// //
aNb=myArguments.Extent(); aNbArgs=myArguments.Extent();
if (aNb!=myNbArgs) { if (!aNbArgs) {
if (aNb!=1 || !(myArgs[0].IsSame(myArgs[1]))) { myErrorStatus=100; // invalid number of Arguments
myErrorStatus=10; // invalid number of arguments return;
return; }
} //
aNbTools=myTools.Extent();
if (!aNbTools) {
myErrorStatus=100; // invalid number of Tools
return;
} }
// //
if (!myPaveFiller) { if (!myPaveFiller) {
@ -166,25 +150,31 @@ static
return; return;
} }
// //
for (i=0; i<myNbArgs; ++i) { for (i=0; i<2; ++i) {
if (myArgs[i].IsNull()) { const BOPCol_ListOfShape& aLS=(!i)? myArguments : myTools;
myErrorStatus=11; // argument is null shape aItLS.Initialize(aLS);
return; for (j=0; aItLS.More(); aItLS.Next(), ++j) {
} const TopoDS_Shape& aS=aItLS.Value();
} bFlag=BOPTools_AlgoTools3D::IsEmptyShape(aS);
// if(bFlag) {
for (i=0; i<myNbArgs; ++i) { myWarningStatus=2;
bFlag = BOPTools_AlgoTools3D::IsEmptyShape(myArgs[i]); }
if(bFlag) { //
myWarningStatus = 2; iDim=BOPTools_AlgoTools::Dimension(aS);
} if (iDim<0) {
} myErrorStatus=13; // non-homogenious argument
// return;
for (i=0; i<myNbArgs; ++i) { }
myDims[i]=BOPTools_AlgoTools::Dimension(myArgs[i]); //
if (myDims[i]<0) { if (!j) {
myErrorStatus=13; // non-homogenious argument myDims[i]=iDim;
return; continue;
}
//
if (iDim!=myDims[i]) {
myErrorStatus=13; // non-homogenious argument
return;
}
} }
} }
// //
@ -211,47 +201,142 @@ static
//function : Prepare //function : Prepare
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::Prepare() void BOPAlgo_BOP::Prepare()
{ {
Standard_Integer i;
BRep_Builder aBB;
// //
BOPAlgo_Builder::Prepare(); BOPAlgo_Builder::Prepare();
// //
if(myWarningStatus == 2) { if(myWarningStatus == 2) {
Standard_Integer i;
BRep_Builder aBB;
BOPCol_ListIteratorOfListOfShape aItLS;
//
switch(myOperation) { switch(myOperation) {
case BOPAlgo_FUSE: case BOPAlgo_FUSE: {
for ( i = 0; i < myNbArgs; i++ ) { for (i=0; i<2; ++i) {
aBB.Add(myShape, myArgs[i]); const BOPCol_ListOfShape& aLS=(!i)? myArguments : myTools;
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
aBB.Add(myShape, aS);
}
} }
}
break; break;
//
case BOPAlgo_CUT: {
aItLS.Initialize(myArguments);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
if(!BOPTools_AlgoTools3D::IsEmptyShape(aS)) {
aBB.Add(myShape, aS);
}
}
}
break;
case BOPAlgo_CUT21: {
aItLS.Initialize(myTools);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
if(!BOPTools_AlgoTools3D::IsEmptyShape(aS)) {
aBB.Add(myShape, aS);
}
}
}
break;
//
case BOPAlgo_COMMON: case BOPAlgo_COMMON:
case BOPAlgo_SECTION: case BOPAlgo_SECTION:
break;
case BOPAlgo_CUT:
if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[0])) {
break;
} else {
aBB.Add(myShape, myArgs[0]);
}
break;
case BOPAlgo_CUT21:
if(BOPTools_AlgoTools3D::IsEmptyShape(myArgs[1])) {
break;
} else {
aBB.Add(myShape, myArgs[1]);
}
break;
default: default:
break; break;
}
}
}
//=======================================================================
//function : BuildResult
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildResult(const TopAbs_ShapeEnum theType)
{
TopAbs_ShapeEnum aType;
BRep_Builder aBB;
BOPCol_MapOfShape aM;
BOPCol_ListIteratorOfListOfShape aIt, aItIm;
//
myErrorStatus=0;
//
const BOPCol_ListOfShape& aLA=myDS->Arguments();
aIt.Initialize(aLA);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aType=aS.ShapeType();
if (aType==theType) {
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
if (aM.Add(aSIm)) {
aBB.Add(myShape, aSIm);
}
}
}
else {
if (aM.Add(aS)) {
aBB.Add(myShape, aS);
}
}
} }
} }
} }
//======================================================================= //=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BOPAlgo_BOP::Perform()
{
Handle(NCollection_BaseAllocator) aAllocator;
BOPAlgo_PaveFiller* pPF;
BOPCol_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
//
if (myEntryPoint==1) {
if (myPaveFiller) {
delete myPaveFiller;
myPaveFiller=NULL;
}
}
//
aAllocator=new NCollection_IncAllocator;
BOPCol_ListOfShape aLS(aAllocator);
//
aItLS.Initialize(myArguments);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
aLS.Append(aS);
}
//
aItLS.Initialize(myTools);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aS=aItLS.Value();
aLS.Append(aS);
}
//
pPF=new BOPAlgo_PaveFiller(aAllocator);
pPF->SetArguments(aLS);
//
pPF->Perform();
//
myEntryPoint=1;
PerformInternal(*pPF);
}
//=======================================================================
//function : PerformInternal //function : PerformInternal
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller) void BOPAlgo_BOP::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
{ {
myErrorStatus=0; myErrorStatus=0;
myWarningStatus=0; myWarningStatus=0;
@ -271,10 +356,10 @@ static
if (myErrorStatus) { if (myErrorStatus) {
return; return;
} }
//
if(myWarningStatus == 2) { if(myWarningStatus == 2) {
return; return;
} }
//
// 3. Fill Images // 3. Fill Images
// 3.1 Vertices // 3.1 Vertices
FillImagesVertices(); FillImagesVertices();
@ -296,14 +381,14 @@ static
if (myErrorStatus) { if (myErrorStatus) {
return; return;
} }
//-------------------------------- SECTION f //-------------------------------- SECTION
if (myOperation==BOPAlgo_SECTION) { if (myOperation==BOPAlgo_SECTION) {
BuildSection(); BuildSection();
PrepareHistory(); PrepareHistory();
PostTreat(); PostTreat();
return; return;
} }
//-------------------------------- SECTION t //--------------------------------
// //
// 3.3 Wires // 3.3 Wires
FillImagesContainers(TopAbs_WIRE); FillImagesContainers(TopAbs_WIRE);
@ -368,21 +453,204 @@ static
return; return;
} }
// //
// 6.BuildShape; // 4.BuildShape;
BuildShape(); BuildShape();
if (myErrorStatus) {
return;
}
// //
// 4.History // 5.History
PrepareHistory(); PrepareHistory();
// //
// 5 Post-treatment // 6 Post-treatment
PostTreat(); PostTreat();
} }
//======================================================================= //=======================================================================
//function : BuildRC
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildRC()
{
Standard_Boolean bFlag1, bFlag2, bIsBound;
Standard_Integer aDmin;
TopAbs_ShapeEnum aTmin;
TopoDS_Compound aC;
TopoDS_Shape aSAIm, aSTIm;
BRep_Builder aBB;
TopExp_Explorer aExp;
BOPCol_DataMapOfShapeShape aDMSSA;
BOPCol_ListIteratorOfListOfShape aItLS, aItIm;
//
myErrorStatus=0;
//
aBB.MakeCompound(aC);
//
// A. Fuse
if (myOperation==BOPAlgo_FUSE) {
aTmin=TypeToExplore(myDims[0]);
aExp.Init(myShape, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aS=aExp.Current();
aBB.Add(aC, aS);
}
myRC=aC;
return;
}
//
aDmin=myDims[1];
if (myDims[0] < myDims[1]) {
aDmin=myDims[0];
}
aTmin=TypeToExplore(aDmin);
//
// B. Common, Cut, Cut21
//
bFlag1=(myOperation==BOPAlgo_COMMON || myOperation==BOPAlgo_CUT21);
bFlag2=(myOperation==BOPAlgo_CUT || myOperation==BOPAlgo_CUT21);
//
const BOPCol_ListOfShape& aLA=( bFlag1) ? myArguments : myTools;
aItLS.Initialize(aLA);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSA=aItLS.Value();
//
if (myImages.IsBound(aSA)){
const BOPCol_ListOfShape& aLSAIm=myImages.Find(aSA);
aItIm.Initialize(aLSAIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSAIm=aItIm.Value();
aExp.Init(aSAIm, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aSIm=aExp.Current();
aDMSSA.Bind(aSIm, aSIm);
}
}
}
//
else {
aExp.Init(aSA, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aSIm=aExp.Current();
aDMSSA.Bind(aSIm, aSIm);
}
}
} //for (; aItLS.More(); aItLS.Next())
//
const BOPCol_ListOfShape& aLT=(!bFlag1) ? myArguments : myTools;
aItLS.Initialize(aLT);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aST=aItLS.Value();
if (myImages.IsBound(aST)){
const BOPCol_ListOfShape& aLSTIm=myImages.Find(aST);
aItIm.Initialize(aLSTIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSTIm=aItIm.Value();
aExp.Init(aSTIm, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aSIm=aExp.Current();
// skip degenerated edges
if (aTmin==TopAbs_EDGE) {
const TopoDS_Edge& aEIm=*((TopoDS_Edge*)&aSIm);
if (BRep_Tool::Degenerated(aEIm)) {
continue;
}
}
//
bIsBound=aDMSSA.IsBound(aSIm);
if (!bFlag2) { // ie common
if (bIsBound) {
const TopoDS_Shape& aSImA=aDMSSA.Find(aSIm);
aBB.Add(aC, aSImA);
}
}
else {// ie cut or cut21
if (!bIsBound) {
aBB.Add(aC, aSIm);
}
}
}
}
}
else {
aExp.Init(aST, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aSIm=aExp.Current();
// skip degenerated edges
if (aTmin==TopAbs_EDGE) {
const TopoDS_Edge& aEIm=*((TopoDS_Edge*)&aSIm);
if (BRep_Tool::Degenerated(aEIm)) {
continue;
}
}
bIsBound=aDMSSA.IsBound(aSIm);
if (!bFlag2) { // ie common
if (bIsBound) {
const TopoDS_Shape& aSImA=aDMSSA.Find(aSIm);
aBB.Add(aC, aSImA);
}
}
else {// ie cut or cut21
if (!bIsBound) {
aBB.Add(aC, aSIm);
}
}
}
}
} //for (; aItLS.More(); aItLS.Next())
//
// the squats around degeneracy
if (aTmin!=TopAbs_EDGE) {
myRC=aC;
return;
}
//---------------------------------------------------------
//
// The squats around degenerated edges
Standard_Integer i, aNbS, nVD;
TopAbs_ShapeEnum aType;
BOPCol_IndexedMapOfShape aMVC;
//
// 1. Vertices of aC
BOPTools::MapShapes(aC, TopAbs_VERTEX, aMVC);
//
// 2. DE candidates
aNbS=myDS->NbSourceShapes();
for (i=0; i<aNbS; ++i) {
const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
aType=aSI.ShapeType();
if (aType!=aTmin) {
continue;
}
//
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aSI.Shape());
if (!BRep_Tool::Degenerated(aE)) {
continue;
}
//
nVD=aSI.SubShapes().First();
const TopoDS_Shape& aVD=myDS->Shape(nVD);
//
if (!aMVC.Contains(aVD)) {
continue;
}
//
if (myDS->IsNewShape(nVD)) {
continue;
}
//
if (myDS->HasInterf(nVD)) {
continue;
}
//
aBB.Add(aC, aE);
}
//
myRC=aC;
}
//=======================================================================
//function : BuildShape //function : BuildShape
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::BuildShape() void BOPAlgo_BOP::BuildShape()
{ {
Standard_Integer aDmin, aNbLCB; Standard_Integer aDmin, aNbLCB;
TopAbs_ShapeEnum aT1, aT2, aTR; TopAbs_ShapeEnum aT1, aT2, aTR;
@ -395,7 +663,6 @@ static
myErrorStatus=0; myErrorStatus=0;
// //
BuildRC(); BuildRC();
//myShape=myRC;
// //
aDmin=myDims[1]; aDmin=myDims[1];
if (myDims[0]<myDims[1]) { if (myDims[0]<myDims[1]) {
@ -417,7 +684,8 @@ static
aTR=TopAbs_SHELL; aTR=TopAbs_SHELL;
} }
// //
BOPTools_AlgoTools::MakeConnexityBlocks(myRC, aT1, aT2, aLCB); BOPTools_AlgoTools::MakeConnexityBlocks
(myRC, aT1, aT2, aLCB);
aNbLCB=aLCB.Extent(); aNbLCB=aLCB.Extent();
if (!aNbLCB) { if (!aNbLCB) {
myShape=myRC; myShape=myRC;
@ -446,186 +714,30 @@ static
myShape=aRC; myShape=aRC;
}// elase if (aDmin==1 || aDmin==2) { }// elase if (aDmin==1 || aDmin==2) {
else { //aDmin=3 else {//aDmin=3
if (myOperation==BOPAlgo_FUSE) { Standard_Integer aNbObjs, aNbTools;
BuildSolid(); //
} aNbObjs=myArguments.Extent();
else { aNbTools=myTools.Extent();
myShape=myRC; //
} if (aNbObjs==1 && aNbTools==1) {
} if (myOperation==BOPAlgo_FUSE) {
} BuildSolid();
//=======================================================================
//function : BuildRC
//purpose :
//=======================================================================
void BOPAlgo_BOP::BuildRC()
{
Standard_Boolean bFlag;
Standard_Integer i, aDmin, aNb[2], iX = 0, iY = 0;
TopAbs_ShapeEnum aTmin;
TopoDS_Compound aC, aCS[2];
BRep_Builder aBB;
TopExp_Explorer aExp;
BOPCol_ListIteratorOfListOfShape aItIm;
BOPCol_IndexedMapOfShape aMS[2];
BOPCol_IndexedMapOfShape aMSV[2];
//
myErrorStatus=0;
//
// A. Fuse
if (myOperation==BOPAlgo_FUSE) {
aBB.MakeCompound(aC);
aTmin=TypeToExplore(myDims[0]);
aExp.Init(myShape, aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aS=aExp.Current();
aBB.Add(aC, aS);
}
myRC=aC;
return;
}
//
// B. Non-Fuse
//
// 1. Compounds CS that consist of an Arg or Images of the Arg
for (i=0; i<myNbArgs; ++i) {
aBB.MakeCompound(aCS[i]);
const TopoDS_Shape& aS=myArgs[i];
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
aBB.Add(aCS[i], aSIm);
}
}
else {
aBB.Add(aCS[i], aS);
}
}
//
aDmin=myDims[1];
if (myDims[0]<myDims[1]) {
aDmin=myDims[0];
}
aTmin=TypeToExplore(aDmin);
for (i=0; i<myNbArgs; ++i) {
aExp.Init(aCS[i], aTmin);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape aS=aExp.Current();
if (aTmin == TopAbs_EDGE) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aS));
if (BRep_Tool::Degenerated(aE)) {
TopExp_Explorer aExpE(aE, TopAbs_VERTEX);
TopoDS_Shape aS1 = aExpE.Current();
if (myImages.IsBound(aS1)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS1);
const TopoDS_Shape& aSIm=aLSIm.First();
aMSV[i].Add(aSIm);
} else {
aMSV[i].Add(aS1);
}
}
}
//
if (myImages.IsBound(aS)){
const BOPCol_ListOfShape& aLSIm=myImages.Find(aS);
aItIm.Initialize(aLSIm);
for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aSIm=aItIm.Value();
aMS[i].Add(aSIm);
}
} }
else { else {
aMS[i].Add(aS); myShape=myRC;
} }
} }
aNb[i]=aMS[i].Extent(); else {
} BuildSolid();
//
aBB.MakeCompound(aC);
//
// 3. Find common parts
if (myOperation==BOPAlgo_COMMON) {
if (myDims[0]==myDims[1]) {
iX=(aNb[0]>aNb[1])? 1 : 0;
} else {
iX=(myDims[0]<myDims[1]) ? 0 : 1;
}
iY=(iX+1)%2;
}
else if (myOperation==BOPAlgo_CUT) {
iX=0;
iY=1;
}
else if (myOperation==BOPAlgo_CUT21) {
iX=1;
iY=0;
}
for (i=1; i<=aNb[iX]; ++i) {
const TopoDS_Shape& aSx=aMS[iX].FindKey(i);
bFlag=aMS[iY].Contains(aSx);
if (aTmin == TopAbs_EDGE) {
const TopoDS_Edge& aE = (*(TopoDS_Edge*)(&aSx));
if (BRep_Tool::Degenerated(aE)) {
TopExp_Explorer aExpE(aE, TopAbs_VERTEX);
TopoDS_Shape aSx1 = aExpE.Current();
TopoDS_Shape aSIm;
if (myImages.IsBound(aSx1)) {
const BOPCol_ListOfShape& aLSIm=myImages.Find(aSx1);
aSIm=aLSIm.First();
} else {
aSIm = aSx1;
}
bFlag=aMSV[iY].Contains(aSIm);
}
}
//
if (myOperation!=BOPAlgo_COMMON) {
bFlag=!bFlag;
}
//
if (bFlag) {
aBB.Add(aC, aSx);
} }
} }
//
myRC=aC;
}
//
//=======================================================================
//function : TypeToExplore
//purpose :
//=======================================================================
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
{
TopAbs_ShapeEnum aRet;
//
switch(theDim) {
case 0:
aRet=TopAbs_VERTEX;
break;
case 1:
aRet=TopAbs_EDGE;
break;
case 2:
aRet=TopAbs_FACE;
break;
case 3:
aRet=TopAbs_SOLID;
break;
default:
aRet=TopAbs_SHAPE;
break;
}
return aRet;
} }
//======================================================================= //=======================================================================
//function : BuildSolid //function : BuildSolid
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::BuildSolid() void BOPAlgo_BOP::BuildSolid()
{ {
Standard_Integer i, aNbF, aNbSx, iX, iErr; Standard_Integer i, aNbF, aNbSx, iX, iErr;
TopAbs_Orientation aOr, aOr1; TopAbs_Orientation aOr, aOr1;
@ -672,8 +784,8 @@ TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
} }
} }
} }
// //faces that will be added in the end;
BOPCol_ListOfShape aLF, aLFx; //faces that will be added in the end; BOPCol_ListOfShape aLF, aLFx;
// SFS // SFS
aNbF=aMFS.Extent(); aNbF=aMFS.Extent();
for (i=1; i<=aNbF; ++i) { for (i=1; i<=aNbF; ++i) {
@ -681,7 +793,8 @@ TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
const BOPCol_ListOfShape& aLSx=aMFS(i); const BOPCol_ListOfShape& aLSx=aMFS(i);
aNbSx=aLSx.Extent(); aNbSx=aLSx.Extent();
if (aNbSx==1) { if (aNbSx==1) {
BOPTools::MapShapesAndAncestors(aFx, TopAbs_EDGE, TopAbs_FACE, aMEF); BOPTools::MapShapesAndAncestors
(aFx,TopAbs_EDGE, TopAbs_FACE, aMEF);
if (IsBoundSplits(aFx, aMEF)){ if (IsBoundSplits(aFx, aMEF)){
aLFx.Append(aFx); aLFx.Append(aFx);
continue; continue;
@ -734,13 +847,13 @@ TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
} }
myShape=aRC; myShape=aRC;
} }
//======================================================================= //=======================================================================
//function : IsBoundImages //function : IsBoundImages
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BOPAlgo_BOP::IsBoundSplits(const TopoDS_Shape& aS, Standard_Boolean BOPAlgo_BOP::IsBoundSplits
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF) (const TopoDS_Shape& aS,
BOPCol_IndexedDataMapOfShapeListOfShape& aMEF)
{ {
Standard_Boolean bRet = Standard_False; Standard_Boolean bRet = Standard_False;
if (mySplits.IsBound(aS) || myOrigins.IsBound(aS)) { if (mySplits.IsBound(aS) || myOrigins.IsBound(aS)) {
@ -774,11 +887,38 @@ TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
aIt.Initialize(aLS); aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx = aIt.Value(); const TopoDS_Shape& aSx = aIt.Value();
if (mySplits.IsBound(aSx) || myOrigins.IsBound(aS)) { if (mySplits.IsBound(aSx) || myOrigins.IsBound(aS)) {
return !bRet; return !bRet;
} }
} }
} }
//
return bRet; return bRet;
} }
//=======================================================================
//function : TypeToExplore
//purpose :
//=======================================================================
TopAbs_ShapeEnum TypeToExplore(const Standard_Integer theDim)
{
TopAbs_ShapeEnum aRet;
//
switch(theDim) {
case 0:
aRet=TopAbs_VERTEX;
break;
case 1:
aRet=TopAbs_EDGE;
break;
case 2:
aRet=TopAbs_FACE;
break;
case 3:
aRet=TopAbs_SOLID;
break;
default:
aRet=TopAbs_SHAPE;
break;
}
return aRet;
}

View File

@ -36,7 +36,7 @@
//function : BuildSection //function : BuildSection
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_BOP::BuildSection() void BOPAlgo_BOP::BuildSection()
{ {
Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF; Standard_Integer i, j, k, nE, nF1, nF2, aNbPB, aNbFF;
@ -113,35 +113,14 @@
} }
} }
// //
//case when arguments are the same
if (!aNbFF) {
if (myArgs[0].IsSame(myArgs[1])) {
TopExp_Explorer anExpF, anExpE;
//
anExpF.Init(myArgs[0], TopAbs_FACE);
for(; anExpF.More(); anExpF.Next()) {
const TopoDS_Shape& aF = anExpF.Current();
//
anExpE.Init(aF, TopAbs_EDGE);
for (; anExpE.More(); anExpE.Next()) {
const TopoDS_Shape& aE = anExpE.Current();
//
if (aME.Add(aE)) {
aBB.Add(aRC, aE);
}
}
}
}
}
//
myShape=aRC; myShape=aRC;
} }
//======================================================================= //=======================================================================
//function : Generated //function : Generated
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopTools_ListOfShape& BOPAlgo_BOP::Generated(const TopoDS_Shape& theS) const TopTools_ListOfShape& BOPAlgo_BOP::Generated
(const TopoDS_Shape& theS)
{ {
myHistShapes.Clear(); myHistShapes.Clear();
if (theS.IsNull() || (myOperation != BOPAlgo_SECTION)) { if (theS.IsNull() || (myOperation != BOPAlgo_SECTION)) {

View File

@ -640,7 +640,8 @@ void BOPAlgo_Builder::FillInternalShapes()
// 1.1 Shapes from pure arguments aMSI // 1.1 Shapes from pure arguments aMSI
// 1.1.1 vertex, edge, wire // 1.1.1 vertex, edge, wire
// //
aIt.Initialize(myArguments); const BOPCol_ListOfShape& aArguments=myDS->Arguments();
aIt.Initialize(aArguments);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value(); const TopoDS_Shape& aS=aIt.Value();
TreatCompound(aS, aMFence, aLSC); TreatCompound(aS, aMFence, aLSC);

View File

@ -22,14 +22,18 @@
#include <BOPCol_ListOfShape.hxx> #include <BOPCol_ListOfShape.hxx>
#include <BOPCol_MapOfShape.hxx> #include <BOPCol_MapOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPTools_AlgoTools.hxx> #include <BOPTools_AlgoTools.hxx>
#include <BOPTools.hxx> #include <BOPTools.hxx>
//======================================================================= //=======================================================================
//function : Generated //function : Generated
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopTools_ListOfShape& BOPAlgo_Builder::Generated(const TopoDS_Shape&) const TopTools_ListOfShape& BOPAlgo_Builder::Generated
(const TopoDS_Shape&)
{ {
myHistShapes.Clear(); myHistShapes.Clear();
return myHistShapes; return myHistShapes;
@ -38,7 +42,8 @@
//function : Modified //function : Modified
//purpose : //purpose :
//======================================================================= //=======================================================================
const TopTools_ListOfShape& BOPAlgo_Builder::Modified(const TopoDS_Shape& theS) const TopTools_ListOfShape& BOPAlgo_Builder::Modified
(const TopoDS_Shape& theS)
{ {
Standard_Boolean bHasImage, bToReverse; Standard_Boolean bHasImage, bToReverse;
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
@ -78,7 +83,8 @@
aSp.Orientation(theS.Orientation()); aSp.Orientation(theS.Orientation());
} }
else { else {
bToReverse=BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext); bToReverse=
BOPTools_AlgoTools::IsSplitToReverse(aSp, theS, myContext);
if (bToReverse) { if (bToReverse) {
aSp.Reverse(); aSp.Reverse();
} }
@ -94,7 +100,8 @@
//function : IsDeleted //function : IsDeleted
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BOPAlgo_Builder::IsDeleted(const TopoDS_Shape& theS) Standard_Boolean BOPAlgo_Builder::IsDeleted
(const TopoDS_Shape& theS)
{ {
Standard_Boolean bRet, bHasImage, bContains; Standard_Boolean bRet, bHasImage, bContains;
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
@ -147,7 +154,7 @@
//function : PrepareHistory //function : PrepareHistory
//purpose : //purpose :
//======================================================================= //=======================================================================
void BOPAlgo_Builder::PrepareHistory() void BOPAlgo_Builder::PrepareHistory()
{ {
if (!myFlagHistory) { if (!myFlagHistory) {
return; return;
@ -170,7 +177,8 @@
BOPTools::MapShapes(myShape, myMapShape); BOPTools::MapShapes(myShape, myMapShape);
// //
// 3. MS - all argument shapes with theirs sub-shapes // 3. MS - all argument shapes with theirs sub-shapes
aIt.Initialize(myArguments); const BOPCol_ListOfShape& aArguments=myDS->Arguments();
aIt.Initialize(aArguments);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value(); const TopoDS_Shape& aSx=aIt.Value();
BOPTools::MapShapes(aSx, aMS); BOPTools::MapShapes(aSx, aMS);

View File

@ -30,6 +30,7 @@ static Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer , co
static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** ); static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer , const char** );
// //
//======================================================================= //=======================================================================
//function :ObjCommands //function :ObjCommands
@ -43,11 +44,12 @@ static Standard_Integer baddcompound(Draw_Interpretor& , Standard_Integer , cons
// Chapter's name // Chapter's name
const char* g = "BOP commands"; const char* g = "BOP commands";
// Commands // Commands
theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g); theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g);
theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g); theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g);
theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g); theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g);
theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g); theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g);
theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g); theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g);
theCommands.Add("baddctools" , "baddctools c" , __FILE__, baddctools, g);
} }
//======================================================================= //=======================================================================
//function : baddcompound //function : baddcompound
@ -74,6 +76,31 @@ Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const cha
// //
return 0; return 0;
} }
//=======================================================================
//function : baddctools
//purpose :
//=======================================================================
Standard_Integer baddctools (Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n<2) {
printf(" Use baddctools c\n");
return 0;
}
//
TopoDS_Iterator aIt;
TopoDS_Shape aS;
//
aS=DBRep::Get(a[1]);
//
BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
aLT.Append(aSx);
}
//
return 0;
}
// //
//======================================================================= //=======================================================================
//function :baddobjects //function :baddobjects

View File

@ -117,10 +117,10 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
// Chapter's name // Chapter's name
const char* g = "Partition commands"; const char* g = "Partition commands";
// Commands // Commands
theCommands.Add("bfillds" , "use bfillds [-s -t]" , __FILE__, bfillds, g); theCommands.Add("bfillds", "use bfillds [-s -t]" , __FILE__, bfillds, g);
theCommands.Add("bbuild" , "use bbuild r [-s -t]", __FILE__, bbuild, g); theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g); theCommands.Add("bbop" , "use bbop r op [-s -t]", __FILE__, bbop, g);
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g); theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
} }
//======================================================================= //=======================================================================
@ -314,8 +314,8 @@ Standard_Integer bbop(Draw_Interpretor& di,
Standard_Integer n, Standard_Integer n,
const char** a) const char** a)
{ {
if (n!=3) { if (n<3) {
di << " use bbop r op\n"; di << " use bbop r op [-s -t]\n";
return 0; return 0;
} }
// //
@ -326,16 +326,30 @@ Standard_Integer bbop(Draw_Interpretor& di,
} }
// //
char buf[32]; char buf[32];
Standard_Integer iErr, iOp; Standard_Boolean bRunParallel, bShowTime;
Standard_Integer iErr, iOp, i;
BOPAlgo_Operation aOp; BOPAlgo_Operation aOp;
BOPCol_ListIteratorOfListOfShape aIt; BOPCol_ListIteratorOfListOfShape aIt;
BOPTime_Chronometer aChrono;
// //
iOp=Draw::Atoi(a[2]); iOp=Draw::Atoi(a[2]);
if (iOp<0 || iOp>4) { if (iOp<0 || iOp>4) {
di << " invalid operation type\n"; di << " invalid operation type\n";
return 0;
} }
aOp=(BOPAlgo_Operation)iOp; aOp=(BOPAlgo_Operation)iOp;
// //
bShowTime=Standard_False;
bRunParallel=Standard_True;
for (i=3; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
}
else if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
}
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller(); BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
// //
BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP(); BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
@ -356,6 +370,9 @@ Standard_Integer bbop(Draw_Interpretor& di,
} }
// //
aBOP.SetOperation(aOp); aBOP.SetOperation(aOp);
aBOP.SetRunParallel(bRunParallel);
//
aChrono.Start();
// //
aBOP.PerformWithFiller(aPF); aBOP.PerformWithFiller(aPF);
iErr=aBOP.ErrorStatus(); iErr=aBOP.ErrorStatus();
@ -365,6 +382,16 @@ Standard_Integer bbop(Draw_Interpretor& di,
return 0; return 0;
} }
// //
aChrono.Stop();
//
if (bShowTime) {
Standard_Real aTime;
//
aTime=aChrono.Time();
Sprintf(buf, " Tps: %7.2lf\n", aTime);
di << buf;
}
//
const TopoDS_Shape& aR=aBOP.Shape(); const TopoDS_Shape& aR=aBOP.Shape();
if (aR.IsNull()) { if (aR.IsNull()) {
di << " null shape\n"; di << " null shape\n";

View File

@ -198,19 +198,23 @@
void BRepFeat_Builder::FillRemoved() void BRepFeat_Builder::FillRemoved()
{ {
TopExp_Explorer aExp; TopExp_Explorer aExp;
aExp.Init(myArgs[0], TopAbs_SOLID); //
const TopoDS_Shape& aArgs0=myArguments.First();
const TopoDS_Shape& aArgs1=myTools.First();
//
aExp.Init(aArgs0, TopAbs_SOLID);
for (; aExp.More(); aExp.Next()) { for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aS = aExp.Current(); const TopoDS_Shape& aS = aExp.Current();
myImages.UnBind(aS); myImages.UnBind(aS);
} }
// //
if (!myImages.IsBound(myArgs[1])) { if (!myImages.IsBound(aArgs1)) {
return; return;
} }
// //
BOPCol_ListIteratorOfListOfShape aItIm; BOPCol_ListIteratorOfListOfShape aItIm;
// //
BOPCol_ListOfShape& aLS = myImages.ChangeFind(myArgs[1]); BOPCol_ListOfShape& aLS = myImages.ChangeFind(aArgs1);
aItIm.Initialize(aLS); aItIm.Initialize(aLS);
for (; aItIm.More(); aItIm.Next()) { for (; aItIm.More(); aItIm.Next()) {
const TopoDS_Shape& aS = aItIm.Value(); const TopoDS_Shape& aS = aItIm.Value();
@ -675,8 +679,11 @@
BOPCol_ListIteratorOfListOfShape aIt; BOPCol_ListIteratorOfListOfShape aIt;
TopExp_Explorer aExp, aExpF; TopExp_Explorer aExp, aExpF;
Standard_Boolean bFlagSD; Standard_Boolean bFlagSD;
//
const TopoDS_Shape& aArgs0=myArguments.First();
const TopoDS_Shape& aArgs1=myTools.First();
// //
const BOPCol_ListOfShape& aLSIm = myImages.Find(myArgs[1]); const BOPCol_ListOfShape& aLSIm = myImages.Find(aArgs1);
aIt.Initialize(aLSIm); aIt.Initialize(aLSIm);
for(;aIt.More();aIt.Next()) { for(;aIt.More();aIt.Next()) {
const TopoDS_Shape& aSolIm = aIt.Value(); const TopoDS_Shape& aSolIm = aIt.Value();
@ -686,7 +693,7 @@
aMST.Add(aST); aMST.Add(aST);
} }
// //
aExp.Init(myArgs[0], TopAbs_SOLID); aExp.Init(aArgs0, TopAbs_SOLID);
for(; aExp.More(); aExp.Next()) { for(; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aSolid = aExp.Current(); const TopoDS_Shape& aSolid = aExp.Current();
if (myImages.IsBound(aSolid)) { if (myImages.IsBound(aSolid)) {

View File

@ -56,14 +56,15 @@ static void BoxParameters(const TopoDS_Shape&,
void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius) void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius)
{ {
if (Object().IsNull() || !myAxDef) { const TopoDS_Shape& aObject=myArguments.First();
if (aObject.IsNull() || !myAxDef) {
Standard_ConstructionError::Raise(); Standard_ConstructionError::Raise();
} }
myIsBlind = Standard_False; myIsBlind = Standard_False;
myStatus = BRepFeat_NoError; myStatus = BRepFeat_NoError;
LocOpe_CurveShapeIntersector theASI(myAxis,Object()); LocOpe_CurveShapeIntersector theASI(myAxis,aObject);
if (!theASI.IsDone() || theASI.NbPoints() <= 0) { if (!theASI.IsDone() || theASI.NbPoints() <= 0) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;
@ -76,7 +77,7 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius)
// It is not possible to use infinite cylinder for topological operations. // It is not possible to use infinite cylinder for topological operations.
Standard_Real PMin,PMax; Standard_Real PMin,PMax;
BoxParameters(Object(),myAxis,PMin,PMax); BoxParameters(aObject,myAxis,PMin,PMax);
Standard_Real Heigth = 2.*(PMax-PMin); Standard_Real Heigth = 2.*(PMax-PMin);
gp_XYZ theOrig = myAxis.Location().XYZ(); gp_XYZ theOrig = myAxis.Location().XYZ();
theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ();
@ -102,9 +103,7 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius)
// //
AddTool(theTool); AddTool(theTool);
SetOperation(Fuse); SetOperation(Fuse);
BOPAlgo_Builder::Perform(); BOPAlgo_BOP::Perform();
//myBuilder.Perform(theTool,theList,Fuse);
// myBuilder.PerformResult();
} }
@ -116,8 +115,9 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius)
void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius, void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius,
const Standard_Boolean Cont) const Standard_Boolean Cont)
{ {
//
if (Object().IsNull() || !myAxDef) { const TopoDS_Shape& aObject=myArguments.First();
if (aObject.IsNull() || !myAxDef) {
Standard_ConstructionError::Raise(); Standard_ConstructionError::Raise();
} }
@ -125,7 +125,7 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius,
myValidate = Cont; myValidate = Cont;
myStatus = BRepFeat_NoError; myStatus = BRepFeat_NoError;
LocOpe_CurveShapeIntersector theASI(myAxis,Object()); LocOpe_CurveShapeIntersector theASI(myAxis,aObject);
if (!theASI.IsDone()) { if (!theASI.IsDone()) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;
@ -180,7 +180,7 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius,
// It is not possible to use infinite cylinder for topological operations. // It is not possible to use infinite cylinder for topological operations.
Standard_Real PMin,PMax; Standard_Real PMin,PMax;
BoxParameters(Object(),myAxis,PMin,PMax); BoxParameters(aObject,myAxis,PMin,PMax);
Standard_Real Heigth = 2.*(PMax-PMin); Standard_Real Heigth = 2.*(PMax-PMin);
gp_XYZ theOrig = myAxis.Location().XYZ(); gp_XYZ theOrig = myAxis.Location().XYZ();
theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ();
@ -274,8 +274,9 @@ void BRepFeat_MakeCylindricalHole::PerformThruNext(const Standard_Real Radius,
void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius, void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius,
const Standard_Boolean Cont) const Standard_Boolean Cont)
{ {
//
if (Object().IsNull() || !myAxDef) { const TopoDS_Shape& aObject=myArguments.First();
if (aObject.IsNull() || !myAxDef) {
Standard_ConstructionError::Raise(); Standard_ConstructionError::Raise();
} }
@ -283,7 +284,7 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius,
myValidate = Cont; myValidate = Cont;
myStatus = BRepFeat_NoError; myStatus = BRepFeat_NoError;
LocOpe_CurveShapeIntersector theASI(myAxis,Object()); LocOpe_CurveShapeIntersector theASI(myAxis,aObject);
if (!theASI.IsDone()) { if (!theASI.IsDone()) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;
@ -330,7 +331,7 @@ void BRepFeat_MakeCylindricalHole::PerformUntilEnd(const Standard_Real Radius,
// It is not possible to use infinite cylinder for topological operations. // It is not possible to use infinite cylinder for topological operations.
Standard_Real PMin,PMax; Standard_Real PMin,PMax;
BoxParameters(Object(),myAxis,PMin,PMax); BoxParameters(aObject,myAxis,PMin,PMax);
Standard_Real Heigth = 2.*(PMax-PMin); Standard_Real Heigth = 2.*(PMax-PMin);
gp_XYZ theOrig = myAxis.Location().XYZ(); gp_XYZ theOrig = myAxis.Location().XYZ();
theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ();
@ -392,8 +393,9 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius,
const Standard_Real PTo, const Standard_Real PTo,
const Standard_Boolean Cont) const Standard_Boolean Cont)
{ {
//
if (Object().IsNull() || !myAxDef) { const TopoDS_Shape& aObject=myArguments.First();
if (aObject.IsNull() || !myAxDef) {
Standard_ConstructionError::Raise(); Standard_ConstructionError::Raise();
} }
@ -401,7 +403,7 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius,
myValidate = Cont; myValidate = Cont;
myStatus = BRepFeat_NoError; myStatus = BRepFeat_NoError;
LocOpe_CurveShapeIntersector theASI(myAxis,Object()); LocOpe_CurveShapeIntersector theASI(myAxis,aObject);
if (!theASI.IsDone()) { if (!theASI.IsDone()) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;
@ -458,7 +460,7 @@ void BRepFeat_MakeCylindricalHole::Perform(const Standard_Real Radius,
// // It is not possible to use infinite cylinder for topological operations. // // It is not possible to use infinite cylinder for topological operations.
Standard_Real PMin,PMax; Standard_Real PMin,PMax;
BoxParameters(Object(),myAxis,PMin,PMax); BoxParameters(aObject,myAxis,PMin,PMax);
Standard_Real Heigth = 2.*(PMax-PMin); Standard_Real Heigth = 2.*(PMax-PMin);
gp_XYZ theOrig = myAxis.Location().XYZ(); gp_XYZ theOrig = myAxis.Location().XYZ();
theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ(); theOrig += ((3.*PMin-PMax)/2.) * myAxis.Direction().XYZ();
@ -522,8 +524,9 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius,
const Standard_Real Length, const Standard_Real Length,
const Standard_Boolean Cont) const Standard_Boolean Cont)
{ {
//
if (Object().IsNull() || !myAxDef || Length <= 0.) { const TopoDS_Shape& aObject=myArguments.First();
if (aObject.IsNull() || !myAxDef || Length <= 0.) {
Standard_ConstructionError::Raise(); Standard_ConstructionError::Raise();
} }
@ -531,7 +534,7 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius,
myValidate = Cont; myValidate = Cont;
myStatus = BRepFeat_NoError; myStatus = BRepFeat_NoError;
LocOpe_CurveShapeIntersector theASI(myAxis,Object()); LocOpe_CurveShapeIntersector theASI(myAxis,aObject);
if (!theASI.IsDone()) { if (!theASI.IsDone()) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;
@ -582,7 +585,7 @@ void BRepFeat_MakeCylindricalHole::PerformBlind(const Standard_Real Radius,
//// It is not possible to use infinite cylinder for topological operations. //// It is not possible to use infinite cylinder for topological operations.
Standard_Real PMin,PMax; Standard_Real PMin,PMax;
BoxParameters(Object(),myAxis,PMin,PMax); BoxParameters(aObject,myAxis,PMin,PMax);
if (PMin > Length) { if (PMin > Length) {
myStatus = BRepFeat_InvalidPlacement; myStatus = BRepFeat_InvalidPlacement;
return; return;

2
tests/boolean/bcommon_2d/A7 Normal file → Executable file
View File

@ -3,4 +3,4 @@ restore [locate_data_file case_1_wire3.brep] b
bcommon result b a bcommon result b a
set length 942.478 set length 942.478
set nbsh_v 2 set nbsh_v 2
set nbsh_e 4 set nbsh_e 2

2
tests/boolean/bcommon_2d/B1 Normal file → Executable file
View File

@ -3,4 +3,4 @@ restore [locate_data_file case_1_wire3.brep] b
bcommon result b a bcommon result b a
set length 942.478 set length 942.478
set nbsh_v 2 set nbsh_v 2
set nbsh_e 4 set nbsh_e 2

2
tests/boolean/bopcommon_2d/A7 Normal file → Executable file
View File

@ -4,4 +4,4 @@ bop a b
bopcommon result bopcommon result
set length 942.478 set length 942.478
set nbsh_v 2 set nbsh_v 2
set nbsh_e 4 set nbsh_e 2

2
tests/boolean/bopcommon_2d/B1 Normal file → Executable file
View File

@ -4,4 +4,4 @@ bop a b
bopcommon result bopcommon result
set length 942.478 set length 942.478
set nbsh_v 2 set nbsh_v 2
set nbsh_e 4 set nbsh_e 2

View File

@ -0,0 +1,58 @@
puts "========="
puts "OCC24825"
puts "========="
puts ""
###########################################################
# Fit Boolean Operation Algorithm to treat multiple arguments.
###########################################################
restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1
restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2
restore [locate_data_file bug24825_steering-wheel-drum.brep] b4
restore [locate_data_file bug24825_steering-wheel-handle.brep] hb
set qs {}
set N 10
set N1 [expr 360. / $N ]
for {set i 0} {$i < $N} {incr i} {
tcopy hb hb_${i}
trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ]
lappend qs hb_${i}
}
eval compound $qs b3
tcopy b1 b5
ttranslate b5 0 0 100
tcopy b2 b6
ttranslate b6 0 0 100
tcopy b3 b7
ttranslate b7 0 0 100
#-common-#
bclearobjects
bcleartools
baddobjects b2 b6 b4 b1 b5
baddctools b3
baddctools b7
bfillds
bbop result 0
set square 10008.5
set nb_v_good 86
set nb_e_good 132
set nb_w_good 126
set nb_f_good 126
set nb_sh_good 40
set nb_sol_good 40
set nb_compsol_good 0
set nb_compound_good 1
set nb_shape_good 551
set 2dviewer 1

View File

@ -0,0 +1,58 @@
puts "========="
puts "OCC24825"
puts "========="
puts ""
###########################################################
# Fit Boolean Operation Algorithm to treat multiple arguments.
###########################################################
restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1
restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2
restore [locate_data_file bug24825_steering-wheel-drum.brep] b4
restore [locate_data_file bug24825_steering-wheel-handle.brep] hb
set qs {}
set N 10
set N1 [expr 360. / $N ]
for {set i 0} {$i < $N} {incr i} {
tcopy hb hb_${i}
trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ]
lappend qs hb_${i}
}
eval compound $qs b3
tcopy b1 b5
ttranslate b5 0 0 100
tcopy b2 b6
ttranslate b6 0 0 100
tcopy b3 b7
ttranslate b7 0 0 100
#-cut-#
bclearobjects
bcleartools
baddobjects b2 b6 b4 b1 b5
baddctools b3
baddctools b7
bfillds
bbop result 2
set square 103838
set nb_v_good 106
set nb_e_good 164
set nb_w_good 142
set nb_f_good 80
set nb_sh_good 3
set nb_sol_good 3
set nb_compsol_good 0
set nb_compound_good 1
set nb_shape_good 499
set 2dviewer 1

View File

@ -0,0 +1,59 @@
puts "========="
puts "OCC24825"
puts "========="
puts ""
###########################################################
# Fit Boolean Operation Algorithm to treat multiple arguments.
###########################################################
restore [locate_data_file bug24825_steering-wheel-ring1.brep] b1
restore [locate_data_file bug24825_steering-wheel-ring2.brep] b2
restore [locate_data_file bug24825_steering-wheel-drum.brep] b4
restore [locate_data_file bug24825_steering-wheel-handle.brep] hb
set qs {}
set N 10
set N1 [expr 360. / $N ]
for {set i 0} {$i < $N} {incr i} {
tcopy hb hb_${i}
trotate hb_${i} 0. 0. 0. 0. 0. 1. [expr $i * $N1 ]
lappend qs hb_${i}
}
eval compound $qs b3
tcopy b1 b5
ttranslate b5 0 0 100
tcopy b2 b6
ttranslate b6 0 0 100
tcopy b3 b7
ttranslate b7 0 0 100
#-fuse-#
bclearobjects
bcleartools
baddobjects b2 b6 b4
baddtools b1 b5
baddctools b3
baddctools b7
bfillds
bbop result 1
set square 157211
set nb_v_good 106
set nb_e_good 164
set nb_w_good 142
set nb_f_good 80
set nb_sh_good 1
set nb_sol_good 1
set nb_compsol_good 0
set nb_compound_good 1
set nb_shape_good 495
set 2dviewer 1