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

0025614: Provide API access to the new fuctionalities of Boolean Components

I. New features:
1.1. class BOPAlgo_PaveFiller
method:
void BOPAlgo_PaveFiller::SetArguments(const TopTools_ListOfShape& theLS)
has been added to provide the setting argumemts  through
TopTools_ListOfShape

1.2. class BOPAlgo_Builder
method:
void BOPAlgo_Builder::SetArguments(const TopTools_ListOfShape& theLS)
has been added to provide the setting argumemts  through
TopTools_ListOfShape

1.3. class BOPAlgo_BOP
method:
void BOPAlgo_BOP::SetTools(const TopTools_ListOfShape& theLS)
has been added to provide the setting tools through
TopTools_ListOfShape

1.4. class BRepAlgoAPI_BuilderAlgo
construcror:
BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo
  (const BOPAlgo_PaveFiller& aPF)
has been added to provide the construction
of the object using BOPAlgo_PaveFiller object

method:
void BRepAlgoAPI_BuilderAlgo::SetArguments
 (const TopTools_ListOfShape& theLS)
has been added to provide the setting argumemts

method:
const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Arguments()const
has been added to provide access to the argumemts

1.5. class BRepAlgoAPI_BooleanOperation
method:
void BRepAlgoAPI_BooleanOperation::SetTools
  (const TopTools_ListOfShape& theLS)
has been added to provide the setting tools

method:
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Tools()const
has been added to provide access to the tools

1.6. class BRepAlgoAPI_Common
construcror:
BRepAlgoAPI_Common::BRepAlgoAPI_Common
(const BOPAlgo_PaveFiller& aPF)
has been added to provide the construction
of the object using BOPAlgo_PaveFiller object

1.7. class BRepAlgoAPI_Cut
construcror:
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut
(const BOPAlgo_PaveFiller& aPF)
has been added to provide the construction
of the object using BOPAlgo_PaveFiller object

1.8. class BRepAlgoAPI_Fuse
construcror:
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse
(const BOPAlgo_PaveFiller& aPF)
has been added to provide the construction
of the object using BOPAlgo_PaveFiller object

1.9. class BRepAlgoAPI_Section
construcror:
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const BOPAlgo_PaveFiller& aPF)
has been added to provide the construction
of the object using BOPAlgo_PaveFiller object

1.10. class BOPTest
method:
void BOPTest::APICommands(Draw_Interpretor& theCommands)
has been added to provide tcl commands to launch the algorithms
implemented in BRepAlgoAPI package using DRAWEXE application.

Commands:
 >bapibuild r
   performs General Fuse algorithm.
     r -the result of the operation

 >bapibop r type
   performs Boolean Operation agorithm
      r -the result of the operation
      type -type of the operation:
        0-common
        1-fuse
        2-cut
        3-cut21
        4-section

method:
void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
has been added to provide tcl commands to set/get the options that is
necessary for the algorithms implemented in BRepAlgoAPI package.

Commands:
 >boptions
   dump the state of current options

  >brunparallel [0/1]
   1 -sets the parallel mode of the computations
   0 -sets the sequential mode of the computations

  >bfuzzyvalue value
    sets the fuzzy value

-------------------------------------------------------------------------------------------------------------
II. Changes:
II.1. class BRepAlgoAPI_BuilderAlgo
methods:
const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Generated
  (const TopoDS_Shape& aS)
const TopTools_ListOfShape& BRepAlgoAPI_BuilderAlgo::Modified
  (const TopoDS_Shape& aS)
Standard_Boolean BRepAlgoAPI_BuilderAlgo::IsDeleted
  (const TopoDS_Shape& aS)
Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasModified() const
Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasGenerated() const
Standard_Boolean BRepAlgoAPI_BuilderAlgo::HasDeleted() const
has been redefined to provide access to the history

II.1. class BOPTest
method:
void BOPTest::APICommands(Draw_Interpretor& theCommands)
has been added to provide tcl commands to launch the algorithms
implemented in BRepAlgoAPI package using DRAWEXE application.

method:
void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
has been added to provide tcl commands to set/get the options that is
necessary for the algorithms implemented in BRepAlgoAPI package.

II.2. class BRepAlgoAPI
method:
void BRepAlgoAPI::DumpOper(const Standard_CString theFilePath,
                           const TopoDS_Shape& theShape1,
                           const TopoDS_Shape& theShape2,
                           const TopoDS_Shape& theResult,
                           BOPAlgo_Operation theOperation,
                           Standard_Boolean isNonValidArgs)
has been removed. The contents has been shifted into the file:
BRepAlgoAPI_BooleanOperation.cxx

II.3. classes QANewModTopOpe_Glue, QANewModTopOpe_Intersection
the modifications have been done to provide the consistency with the
modifications in BRepAlgoAPI package [I].
-------------------------------------------------------------------------------------------------------------
III. Modified entities:
packages:
BOPAlgo
BRepAlgoAPI
BOPTest
QANewModTopOpe

Test cases for issue CR25614
This commit is contained in:
pkv
2014-12-25 17:55:02 +03:00
committed by bugmaster
parent 6219c44ce7
commit 49b0c452e2
44 changed files with 2160 additions and 1030 deletions

View File

@@ -12,7 +12,7 @@
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
package BOPTest
---Purpose:
@@ -39,6 +39,8 @@ is
LowCommands (aDI:out Interpretor from Draw);
ObjCommands (aDI:out Interpretor from Draw);
PartitionCommands (aDI:out Interpretor from Draw);
APICommands (aDI:out Interpretor from Draw);
OptionCommands (aDI:out Interpretor from Draw);
Factory (aDI:out Interpretor from Draw);
end BOPTest;

View File

@@ -20,9 +20,7 @@
#include <GeometryTest.hxx>
#include <BRepTest.hxx>
#include <MeshTest.hxx>
//#include <CorrectTest.hxx>
#include <HLRTest.hxx>
//#include <stdio.h>
//=======================================================================
//function : AllCommands
@@ -40,6 +38,8 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands)
BOPTest::TolerCommands (theCommands);
BOPTest::ObjCommands (theCommands);
BOPTest::PartitionCommands (theCommands);
BOPTest::APICommands (theCommands);
BOPTest::OptionCommands (theCommands);
}
//=======================================================================
//function : Factory
@@ -57,10 +57,6 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands)
GeometryTest::AllCommands(theCommands);
BRepTest::AllCommands(theCommands);
MeshTest::Commands(theCommands);
//CorrectTest::CorrectCommands(theCommands);
HLRTest::Commands(theCommands);
BOPTest::AllCommands(theCommands);
//printf(" BOP Plugin is loaded\n");
}
//#include <Draw_PluginMacro.hxx>
//DPLUGIN(BOPTest)

View File

@@ -0,0 +1,217 @@
// Created by: Peter KURNEV
// Copyright (c) 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 <BOPTest.ixx>
#include <stdio.h>
#include <string.h>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPTest_Objects.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BRepAlgoAPI_BooleanOperation.hxx>
#include <BRepAlgoAPI_BuilderAlgo.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Section.hxx>
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**);
//=======================================================================
//function : APICommands
//purpose :
//=======================================================================
void BOPTest::APICommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "Partition commands";
// Commands
theCommands.Add("bapibuild", "use bapibuild r" , __FILE__, bapibuild, g);
theCommands.Add("bapibop", "use bapibop r type" , __FILE__, bapibop, g);
}
//=======================================================================
//function : bapibop
//purpose :
//=======================================================================
Standard_Integer bapibop(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<3) {
di << " use bapibop r type\n";
return 0;
}
//
char buf[128];
Standard_Boolean bRunParallel;
Standard_Integer iErr, iOp;
Standard_Real aFuzzyValue;
BRepAlgoAPI_Common aCommon;
BRepAlgoAPI_Fuse aFuse;
BRepAlgoAPI_Cut aCut;
BRepAlgoAPI_Section aSection;
BRepAlgoAPI_BooleanOperation *pBuilder;
BOPAlgo_Operation aOp;
//
pBuilder=NULL;
iOp=atoi(a[2]);
if (iOp<0 || iOp>4) {
printf(" invalid operation type\n");
return 0;
}
aOp=(BOPAlgo_Operation)iOp;
//
switch (aOp) {
case BOPAlgo_COMMON:
pBuilder=&aCommon;
break;
//
case BOPAlgo_FUSE:
pBuilder=&aFuse;
break;
//
case BOPAlgo_CUT:
case BOPAlgo_CUT21:
pBuilder=&aCut;
break;
//
case BOPAlgo_SECTION:
pBuilder=&aSection;
break;
//
default:
break;
}
//
BOPCol_ListOfShape& aLSB=BOPTest_Objects::Shapes();
BOPCol_ListOfShape& aLTB=BOPTest_Objects::Tools();
//
TopTools_ListOfShape aLS, aLT;
ConvertList(aLSB, aLS);
ConvertList(aLTB, aLT);
//
bRunParallel=BOPTest_Objects::RunParallel();
aFuzzyValue=BOPTest_Objects::FuzzyValue();
//
if (aOp!=BOPAlgo_CUT21) {
pBuilder->SetArguments(aLS);
pBuilder->SetTools(aLT);
}
else {
pBuilder->SetArguments(aLT);
pBuilder->SetTools(aLS);
}
//
pBuilder->SetRunParallel(bRunParallel);
pBuilder->SetFuzzyValue(aFuzzyValue);
//
pBuilder->Build();
iErr=pBuilder->ErrorStatus();
if (iErr) {
Sprintf(buf, " error: %d\n", iErr);
di << buf;
return 0;
}
//
const TopoDS_Shape& aR=pBuilder->Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}
//=======================================================================
//function : bapibuild
//purpose :
//=======================================================================
Standard_Integer bapibuild(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<2) {
di << " use bapibuild r\n";
return 0;
}
//
char buf[128];
Standard_Boolean bRunParallel;
Standard_Integer iErr;
Standard_Real aFuzzyValue;
BRepAlgoAPI_BuilderAlgo aBuilder;
//
BOPCol_ListOfShape& aLSB=BOPTest_Objects::Shapes();
//
TopTools_ListOfShape aLS, aLT;
ConvertList(aLSB, aLS);
//
bRunParallel=BOPTest_Objects::RunParallel();
aFuzzyValue=BOPTest_Objects::FuzzyValue();
//
aBuilder.SetArguments(aLS);
aBuilder.SetRunParallel(bRunParallel);
aBuilder.SetFuzzyValue(aFuzzyValue);
//
aBuilder.Build();
iErr=aBuilder.ErrorStatus();
if (iErr) {
Sprintf(buf, " error: %d\n", iErr);
di << buf;
return 0;
}
//
const TopoDS_Shape& aR=aBuilder.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}
//=======================================================================
//function : ConvertLists
//purpose :
//=======================================================================
void ConvertList(const BOPCol_ListOfShape& aLSB,
TopTools_ListOfShape& aLS)
{
BOPCol_ListIteratorOfListOfShape aItB;
//
aLS.Clear();
aItB.Initialize(aLSB);
for (; aItB.More(); aItB.Next()) {
const TopoDS_Shape& aS=aItB.Value();
aLS.Append(aS);
}
}

View File

@@ -17,7 +17,12 @@
#include <stdio.h>
#include <TCollection_AsciiString.hxx>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
#include <Draw_Color.hxx>
#include <Draw.hxx>
#include <NCollection_BaseAllocator.hxx>
#include <NCollection_IncAllocator.hxx>
@@ -28,26 +33,27 @@
//
#include <BRep_Builder.hxx>
#include <IntTools_FaceFace.hxx>
#include <IntTools_Curve.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPDS_DS.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Operation.hxx>
#include <BOPAlgo_BOP.hxx>
#include <BOPAlgo_MakerVolume.hxx>
#include <BOPDS_DS.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPAlgo_Section.hxx>
#include <TCollection_AsciiString.hxx>
#include <IntTools_FaceFace.hxx>
#include <IntTools_Curve.hxx>
#include <DrawTrSurf.hxx>
#include <Draw_Color.hxx>
#include <Draw.hxx>
#include <BRepAlgoAPI_BooleanOperation.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BOPAlgo_Section.hxx>
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
//
static BOPAlgo_PaveFiller* pPF=NULL;
@@ -123,9 +129,10 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
//function : bop
//purpose :
//=======================================================================
Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
Standard_Integer bop(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
char buf[32];
Standard_Boolean bRunParallel;
Standard_Integer iErr;
Standard_Real aTol;
TopoDS_Shape aS1, aS2;
@@ -133,7 +140,7 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
//
if (n < 3 || n > 4) {
di << " use bop Shape1 Shape2 [tol]\n";
return 1;
return 0;
}
//
aS1=DBRep::Get(a[1]);
@@ -141,14 +148,16 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
//
if (aS1.IsNull() || aS2.IsNull()) {
di << " null shapes are not allowed \n";
return 1;
return 0;
}
//
aTol = 0.;
aTol=BOPTest_Objects::FuzzyValue();
if (n == 4) {
aTol = Draw::Atof(a[3]);
}
//
bRunParallel=BOPTest_Objects::RunParallel();
//
aLC.Append(aS1);
aLC.Append(aS2);
//
@@ -161,6 +170,7 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
//
pPF->SetArguments(aLC);
pPF->SetFuzzyValue(aTol);
pPF->SetRunParallel(bRunParallel);
//
pPF->Perform();
iErr=pPF->ErrorStatus();
@@ -229,6 +239,7 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
}
//
char buf[64];
Standard_Boolean bRunParallel;
Standard_Integer aNb, iErr;
BOPAlgo_BOP aBOP;
//
@@ -239,6 +250,8 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
di << buf;
return 0;
}
//
bRunParallel=BOPTest_Objects::RunParallel();
//
const TopoDS_Shape& aS1=aLC.First();
const TopoDS_Shape& aS2=aLC.Last();
@@ -246,6 +259,7 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
aBOP.AddArgument(aS1);
aBOP.AddTool(aS2);
aBOP.SetOperation(aOp);
aBOP.SetRunParallel (bRunParallel);
//
aBOP.PerformWithFiller(*pPF);
iErr=aBOP.ErrorStatus();
@@ -286,6 +300,7 @@ Standard_Integer bopsection(Draw_Interpretor& di, Standard_Integer n, const char
}
//
char buf[64];
Standard_Boolean bRunParallel;
Standard_Integer aNb, iErr;
BOPAlgo_Section aBOP;
//
@@ -297,11 +312,14 @@ Standard_Integer bopsection(Draw_Interpretor& di, Standard_Integer n, const char
return 0;
}
//
bRunParallel=BOPTest_Objects::RunParallel();
//
const TopoDS_Shape& aS1=aLC.First();
const TopoDS_Shape& aS2=aLC.Last();
//
aBOP.AddArgument(aS1);
aBOP.AddArgument(aS2);
aBOP.SetRunParallel (bRunParallel);
//
aBOP.PerformWithFiller(*pPF);
iErr=aBOP.ErrorStatus();
@@ -363,7 +381,7 @@ Standard_Integer bsection(Draw_Interpretor& di,
const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n";
if (n < 4) {
di << usage;
return 1;
return 0;
}
//
TopoDS_Shape aS1 = DBRep::Get(a[2]);
@@ -371,17 +389,19 @@ Standard_Integer bsection(Draw_Interpretor& di,
//
if (aS1.IsNull() || aS2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
return 0;
}
//
Standard_Boolean bApp, bPC1, bPC2;
Standard_Integer i;
//
char buf[80];
Standard_Boolean bRunParallel, bApp, bPC1, bPC2;
Standard_Integer i, iErr;
Standard_Real aTol;
//
bApp = Standard_True;
bPC1 = Standard_True;
bPC2 = Standard_True;
aTol = 0.;
aTol = BOPTest_Objects::FuzzyValue();
bRunParallel = BOPTest_Objects::RunParallel();
//
for (i = 4; i < n; ++i) {
if (!strcmp(a[i], "-n2d")) {
@@ -402,14 +422,13 @@ Standard_Integer bsection(Draw_Interpretor& di,
}
}
//
Standard_Integer iErr;
char buf[80];
//
BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
//
aSec.Approximation(bApp);
aSec.ComputePCurveOn1(bPC1);
aSec.ComputePCurveOn2(bPC2);
aSec.SetFuzzyValue(aTol);
aSec.SetRunParallel(bRunParallel);
//
aSec.Build();
iErr=aSec.ErrorStatus();
@@ -427,7 +446,6 @@ Standard_Integer bsection(Draw_Interpretor& di,
DBRep::Set(a[1], aR);
return 0;
}
//=======================================================================
//function : bsmt
//purpose :
@@ -438,6 +456,7 @@ Standard_Integer bsmt (Draw_Interpretor& di,
const BOPAlgo_Operation aOp)
{
char buf[32];
Standard_Boolean bRunParallel;
Standard_Integer iErr;
TopoDS_Shape aS1, aS2;
BOPCol_ListOfShape aLC;
@@ -445,7 +464,7 @@ Standard_Integer bsmt (Draw_Interpretor& di,
//
if (n < 4 || n > 5) {
di << " use bx r s1 s2 [tol]\n";
return 1;
return 0;
}
//
aS1=DBRep::Get(a[2]);
@@ -453,22 +472,26 @@ Standard_Integer bsmt (Draw_Interpretor& di,
//
if (aS1.IsNull() || aS2.IsNull()) {
di << " null shapes are not allowed \n";
return 1;
return 0;
}
//
aTol = 0.;
aLC.Append(aS1);
aLC.Append(aS2);
//
aTol=BOPTest_Objects::FuzzyValue();
if (n == 5) {
aTol = Draw::Atof(a[4]);
}
//
aLC.Append(aS1);
aLC.Append(aS2);
bRunParallel = BOPTest_Objects::RunParallel();
//
Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator;
//
//---------------------------------------------------------------
BOPAlgo_PaveFiller aPF(aAL);
//
aPF.SetArguments(aLC);
aPF.SetFuzzyValue(aTol);
aPF.SetFuzzyValue(aTol);
aPF.SetRunParallel(bRunParallel);
//
aPF.Perform();
iErr=aPF.ErrorStatus();
@@ -478,36 +501,31 @@ Standard_Integer bsmt (Draw_Interpretor& di,
return 0;
}
//
BRepAlgoAPI_BooleanOperation* pBuilder=NULL;
//
if (aOp==BOPAlgo_COMMON) {
pBuilder=new BRepAlgoAPI_Common(aS1, aS2, aPF);
}
else if (aOp==BOPAlgo_FUSE) {
pBuilder=new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
}
else if (aOp==BOPAlgo_CUT) {
pBuilder=new BRepAlgoAPI_Cut (aS1, aS2, aPF);
}
else if (aOp==BOPAlgo_CUT21) {
pBuilder=new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
}
//---------------------------------------------------------------
BOPAlgo_BOP aBOP(aAL);
//
iErr = pBuilder->ErrorStatus();
if (!pBuilder->IsDone()) {
aBOP.AddArgument(aS1);
aBOP.AddTool(aS2);
aBOP.SetOperation(aOp);
aBOP.SetRunParallel(bRunParallel);
//
aBOP.PerformWithFiller(aPF);
//
iErr=aBOP.ErrorStatus();
if (iErr) {
Sprintf(buf, " ErrorStatus : %d\n", iErr);
di << buf;
return 0;
}
const TopoDS_Shape& aR=pBuilder->Shape();
const TopoDS_Shape& aR=aBOP.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}
//=======================================================================
//function : bopnews
//purpose :
@@ -579,7 +597,6 @@ Standard_Integer bopnews (Draw_Interpretor& di,
//
return 0;
}
//=======================================================================
//function : bopcurves
//purpose :
@@ -617,7 +634,8 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const TopoDS_Face& aF1=*(TopoDS_Face*)(&S1);
const TopoDS_Face& aF2=*(TopoDS_Face*)(&S2);
Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone, bMake2dCurves;
Standard_Boolean aToApproxC3d, aToApproxC2dOnS1,
aToApproxC2dOnS2, anIsDone, bMake2dCurves;
Standard_Integer i, aNbCurves;
Standard_Real anAppTol, aTolR;
TCollection_AsciiString aNm("c_");
@@ -666,8 +684,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
di << " has no 3d curve\n";
return 1;
}
else
{
else {
di << aNbCurves << " curve(s) found.\n";
}
@@ -707,7 +724,8 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
di << "(" << nameC2d2 << ") ";
di << " \n Null first 2d curve of the curve #" << i << "\n";
continue;
} else {
}
else {
TCollection_AsciiString pc1N("c2d1_"), pc1Nx;
pc1Nx = pc1N + anIndx;
Standard_CString nameC2d1 = pc1Nx.ToCString();
@@ -719,7 +737,8 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
if (aPC2.IsNull()) {
di << ") \n Null second 2d curve of the curve #" << i << "\n";
continue;
} else {
}
else {
TCollection_AsciiString pc2N("c2d2_"), pc2Nx;
pc2Nx = pc2N + anIndx;
Standard_CString nameC2d2 = pc2Nx.ToCString();
@@ -734,36 +753,6 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
return 0;
}
//=======================================================================
//function : bparallelmode
//purpose :
//=======================================================================
Standard_Integer bparallelmode(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n == 2)
{
Standard_Boolean isParallelOn = Draw::Atoi (a[1]) == 1;
if (isParallelOn == 1)
{
BOPAlgo_Algo::SetParallelMode(Standard_True);
di << "Parallel mode for boolean operations has been enabled";
}
else
{
BOPAlgo_Algo::SetParallelMode(Standard_False);
di << "Parallel mode for boolean operations has been disabled";
}
}
else
{
di << "Parallel mode state for boolean operations: "
<< (BOPAlgo_Algo::GetParallelMode()? "enabled" : "disabled");
}
return 0;
}
//=======================================================================
//function : mkvolume
//purpose :
@@ -789,9 +778,9 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
TopoDS_Shape aS;
BOPCol_ListOfShape aLS;
//
aTol = 0.;
aTol = BOPTest_Objects::FuzzyValue();
bToIntersect = Standard_True;
bRunParallel = Standard_True;
bRunParallel = BOPTest_Objects::RunParallel();
bCompounds = Standard_False;
//
for (i = 2; i < n; ++i) {
@@ -858,3 +847,31 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
//
return 0;
}
//=======================================================================
//function : bparallelmode
//purpose :
//=======================================================================
Standard_Integer bparallelmode(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n == 2)
{
Standard_Boolean isParallelOn = Draw::Atoi (a[1]) == 1;
if (isParallelOn == 1)
{
BOPAlgo_Algo::SetParallelMode(Standard_True);
di << "Parallel mode for boolean operations has been enabled";
}
else
{
BOPAlgo_Algo::SetParallelMode(Standard_False);
di << "Parallel mode for boolean operations has been disabled";
}
}
else
{
di << "Parallel mode state for boolean operations: "
<< (BOPAlgo_Algo::GetParallelMode()? "enabled" : "disabled");
}
return 0;
}

View File

@@ -64,6 +64,18 @@ is
SetBuilderDefault(myclass);
SetRunParallel(myclass;
theFlag: Boolean from Standard);
RunParallel(myclass)
returns Boolean from Standard;
SetFuzzyValue(myclass;
theValue: Real from Standard);
FuzzyValue(myclass)
returns Real from Standard;
--fields
end Objects;

View File

@@ -45,6 +45,8 @@ class BOPTest_Session {
myBuilderDefault=new BOPAlgo_Builder(pA2);
//
myBuilder=myBuilderDefault;
myRunParallel=Standard_False;
myFuzzyValue=0.;
};
//
// Clear
@@ -84,11 +86,40 @@ class BOPTest_Session {
myBuilder=myBuilderDefault;
};
//
BOPCol_ListOfShape& Shapes() {
return myShapes;
}
//
BOPCol_ListOfShape& Tools() {
return myTools;
}
//
void SetRunParallel(const Standard_Boolean bFlag) {
myRunParallel=bFlag;
};
//
Standard_Boolean RunParallel()const {
return myRunParallel;
};
//
void SetFuzzyValue(const Standard_Real aValue) {
myFuzzyValue=aValue;
};
//
Standard_Real FuzzyValue()const {
return myFuzzyValue;
};
//
protected:
//
BOPAlgo_PaveFiller* myPaveFiller;
BOPAlgo_Builder* myBuilder;
BOPAlgo_Builder* myBuilderDefault;
//
BOPCol_ListOfShape myShapes;
BOPCol_ListOfShape myTools;
Standard_Boolean myRunParallel;
Standard_Real myFuzzyValue;
};
//
//=======================================================================
@@ -120,8 +151,6 @@ void BOPTest_Objects::Init()
void BOPTest_Objects::Clear()
{
GetSession().Clear();
//
//clear objects and tools
Shapes().Clear();
Tools().Clear();
}
@@ -192,8 +221,7 @@ BOPAlgo_Section& BOPTest_Objects::Section()
//=======================================================================
BOPCol_ListOfShape& BOPTest_Objects::Shapes()
{
static BOPCol_ListOfShape s_Shapes;
return s_Shapes;
return GetSession().Shapes();
}
//=======================================================================
//function : Tools
@@ -201,8 +229,39 @@ BOPCol_ListOfShape& BOPTest_Objects::Shapes()
//=======================================================================
BOPCol_ListOfShape& BOPTest_Objects::Tools()
{
static BOPCol_ListOfShape s_Tools;
return s_Tools;
return GetSession().Tools();
}
//=======================================================================
//function : SetRunParallel
//purpose :
//=======================================================================
void BOPTest_Objects::SetRunParallel(const Standard_Boolean bFlag)
{
GetSession().SetRunParallel(bFlag);
}
//=======================================================================
//function : RunParallel
//purpose :
//=======================================================================
Standard_Boolean BOPTest_Objects::RunParallel()
{
return GetSession().RunParallel();
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
void BOPTest_Objects::SetFuzzyValue(const Standard_Real aValue)
{
GetSession().SetFuzzyValue(aValue);
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
Standard_Real BOPTest_Objects::FuzzyValue()
{
return GetSession().FuzzyValue();
}
//=======================================================================
//function : Allocator1

View File

@@ -0,0 +1,123 @@
// Created by: Peter KURNEV
// Copyright (c) 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 <BOPTest.ixx>
#include <stdio.h>
#include <string.h>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <BOPTest_Objects.hxx>
static Standard_Integer boptions (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer brunparallel (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bfuzzyvalue (Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : OptionCommands
//purpose :
//=======================================================================
void BOPTest::OptionCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "Partition commands";
// Commands
theCommands.Add("boptions", "use boptions" , __FILE__, boptions, g);
theCommands.Add("brunparallel", "use brunparallel [0/1]" , __FILE__, brunparallel, g);
theCommands.Add("bfuzzyvalue", "use bfuzzyvalue value" , __FILE__, bfuzzyvalue, g);
}
//=======================================================================
//function : boptions
//purpose :
//=======================================================================
Standard_Integer boptions(Draw_Interpretor& di,
Standard_Integer n,
const char** )
{
if (n!=1) {
di << " use boptions\n";
return 0;
}
//
char buf[128];
Standard_Boolean bRunParallel;
Standard_Real aFuzzyValue;
//
bRunParallel=BOPTest_Objects::RunParallel();
aFuzzyValue=BOPTest_Objects::FuzzyValue();
Sprintf(buf, " RunParallel: %d\n", bRunParallel);
di << buf;
Sprintf(buf, " FuzzyValue : %lf\n", aFuzzyValue);
di << buf;
//
return 0;
}
//=======================================================================
//function : bfuzzyvalue
//purpose :
//=======================================================================
Standard_Integer bfuzzyvalue(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " use bfuzzyvalue value\n";
return 0;
}
//
Standard_Real aFuzzyValue;
//
aFuzzyValue=Draw::Atof(a[1]);
if (aFuzzyValue<0.) {
di << " Wrong value.\n";
return 0;
}
//
BOPTest_Objects::SetFuzzyValue(aFuzzyValue);
//
return 0;
}
//=======================================================================
//function : brunparallel
//purpose :
//=======================================================================
Standard_Integer brunparallel(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " use brunparallel [0/1]\n";
return 0;
}
//
Standard_Integer iX;
Standard_Boolean bRunParallel;
//
iX=Draw::Atoi(a[1]);
if (iX<0 || iX>1) {
di << " Wrong value.\n";
return 0;
}
//
bRunParallel=(Standard_Boolean)(iX);
BOPTest_Objects::SetRunParallel(bRunParallel);
//
return 0;
}

View File

@@ -59,7 +59,6 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
theCommands.Add("bbop" , "use bbop r op [-s -t]" , __FILE__, bbop, g);
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
}
//=======================================================================
//function : bclear
//purpose :
@@ -105,8 +104,10 @@ Standard_Integer bfillds(Draw_Interpretor& di,
}
//
bShowTime = Standard_False;
bRunParallel = Standard_True;
aTol = 0.;
//
bRunParallel=BOPTest_Objects::RunParallel();
aTol=BOPTest_Objects::FuzzyValue();
//
for (i=1; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
@@ -207,7 +208,7 @@ Standard_Integer bbuild(Draw_Interpretor& di,
}
//
bShowTime=Standard_False;
bRunParallel=Standard_True;
bRunParallel=BOPTest_Objects::RunParallel();
for (i=2; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
@@ -282,7 +283,7 @@ Standard_Integer bbop(Draw_Interpretor& di,
aOp=(BOPAlgo_Operation)iOp;
//
bShowTime=Standard_False;
bRunParallel=Standard_True;
bRunParallel=BOPTest_Objects::RunParallel();
for (i=3; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;

View File

@@ -4,4 +4,5 @@ BOPTest_LowCommands.cxx
BOPTest_CheckCommands.cxx
BOPTest_TolerCommands.cxx
BOPTest_ObjCommands.cxx
BOPTest_Chronometer.hxx
BOPTest_APICommands.cxx
BOPTest_OptionCommands.cxx