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

0021762: Integration of new Boolean Operation algorithm to OCCT.

Modifications:
- BRepOffset/BRepOffset_Tool.cxx, Features and Fillets algorithms have been ported on new BO algorithm.
- Old BO algorithm, that was implemented in BOP, BooleanOperations and BOPTools packages, has - been deleted.
- Porting SALOME algorithms to new BOP algorithm.
- Fixing regressions. Rebased on current master.
- Corrections in post treatment of section edges;
- Corrections in the accordance with the bug 0023293;
- Small corrections in the bopcheck and bopargcheck commands.
- NCollection maps have been replaced by NCollection indexed maps to guarantee the constant order of sub-shapes in the result of boolean operation.
- Test case feat featprism M9 has been fixed.
- Test cases chl 902 E3 H3 have been fixed (corrections in the treatment of section edges).
- Test cases caf driver B6 B7, caf named_shape F6 F7 have been modified according to the new order of sub-shapes in the result of boolean operation.
- Test cases blend buildevol G1, blend simple K4, bcommon_complex C7, feat featprism L6 have been modified as they are improvements.
- Test case boolean bsection A3 has been modified according to the new syntax of the bsection command.
- Test cases boolean bfuse_complex J1 P9 have been fixed (the function IsInternalFace has been modified to use the function GetFaceOff);
- Test case chl 902 H3 has been fixed (changes in the treatment of section edges);
- Test case boolean bsection D8 has been modified (removed TODO statement);
- Test case boolean bsection A3 has been modified (as the shapes have been changed).
- Added correction of the tolerance values of the shapes according to the bug 0023610.
- test cases:
    boolean bcommon_complex C3,
    boolean bcut_complex F2 O7,
    boolean bfuse_complex C4 C5 E4,
    boolean bsection B6 M8 M9 N4 N5 N7,
    boolean bfuse_simple ZP6,
    draft angle G8,
    feat featprism S2
have been marked as invalid according to the bug 0022033;
- New value of result has been set in the test cases :
    boolean bopsection D4
    boolean bsection R8
as it is correct.
- test case bugs modalg bug23472 has been rewritten according to the new format of bsection command.
- The classes IntTools_Context and IntTools_ShrunkRange have been replaced by BOPInt_Context and BOPInt_ShrunkRange accordingly.
- The new class BRepAlgoAPI_Check has been added according to the bug 0023648.
- Some regressions have been fixed.
- The following test cases have been marked as invalid or rewritten
    bugs modalg buc60462_2, 60531_2, 60776_1, bug472_1, bug472_2, bug472_3, bug497_3, bug62
    bugs moddata bug26_1, bug26_2,
- The test case bugs modalg buc60533 has been rewritten to use the general fuse algorithm for building the result.
- The new value of the result has been set in the test case bugs modalg 60776_2.
- The following test cases have been rewritten according to the new format of the bsection command
    bugs modlag fra62369, pro18892
    bugs moddata bug75_1, bug75_2
- Corrected BRepAlgoAPI_Check.
- Removed package BOPTColStd.
- Rewritten test cases caf named_shape F8 F9.
- Removed unnecessary comments.
- Corrected the following test scripts :
    boolean bcut_complex(012) O3 O4 O5 O6 O8
    boolean bfuse_complex(013) O5 O6 P8
    boolean bopcommon_complex(021) D8 D9
    boolean bopfuse_complex(022) H1 J6
    boolean boptuc_complex(024) D5
    bugs modalg(006) bug399 bug497_1
    feat featprism(003) C4
- Corrections in the treatment of section edges (putting paves on the curves);
- Corrections in BRepOffset_Tool;
- The following test cases have been rewritten according to the new format of the bsection command
   bugs modalg bug6502, bug6554, bug6766_1, bug6766_3
- The new value of the result has been set in the following test cases
   bugs modalg bug1255, bug1255_1
- The following test cases have been marked as invalid or rewritten
   bugs modalg bug472_2, bug472_3, bug825_2
   bugs moddata bug10603, bug152_1, bug152_2, bug3721_1, bug3721_2, bug3721_3
- The following test cases have been rewritten as improvements
   bugs modalg bug693, bug693_1, bug817_1
   bugs moddata bug3721_5, bug3721_6, bug6862_3, bug6862_4, bug6862_6
- Test cases bugs modlag buc60787_1, buc60787_2, buc60788_2, buc60788_3 have been corrected.
- Fixed some SALOME regressions (modifications in the treatment of the section edges);
- Fixed test case bugs modalg bug23100;
- Test cases bugs modalg bug21754, bug22990 have been corrected according to the new format of the bsection command.
- Test cases bugs modalg bug13116_*, bug23711 have been fixed;
- Test cases bugs modalg bug697_2, bug697_4, bug697_7, bug697_8 have been marked as invalid according to the issue 0022033;
- Test cases bugs modalg bug22109_2, bug22109_3 have been corrected;
- Test case bugs modalg bug18186 has been corrected as it is improvement;
- Test case bugs modalg bug22802 has been deleted as there is no package BOPTColStd.
This commit is contained in:
emv
2013-02-08 17:42:05 +04:00
parent a8676008f7
commit 4e57c75ee1
642 changed files with 41074 additions and 67959 deletions

View File

@@ -17,43 +17,32 @@
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
package BOPTest
---Purpose:
---Purpose:
--
uses
gp,
Draw,
TCollection,
gp,
DBRep,
TopAbs,
TopoDS,
DBRep
is
class DrawableShape;
AllCommands(DI : in out Interpretor from Draw);
---Purpose: Defines all commands.
MTestCommands(DI : in out Interpretor from Draw);
TSTCommands (DI : in out Interpretor from Draw);
EFCommands (DI : in out Interpretor from Draw);
LowCommands (DI : in out Interpretor from Draw);
BOPCommands (DI : in out Interpretor from Draw);
WSplitCommands(DI : in out Interpretor from Draw);
CurveCommands(DI : in out Interpretor from Draw);
TolerCommands(DI : in out Interpretor from Draw);
CheckCommands(DI : in out Interpretor from Draw);
TopTools,
BOPCol,
BOPDS,
BOPAlgo
is
Factory (theDI : in out Interpretor from Draw);
---Purpose: Loads all Draw commands for Geometry & Topology. Used for plugin.
end BOPTest;
class Objects;
class DrawableShape;
--
AllCommands (aDI:out Interpretor from Draw);
BOPCommands (aDI:out Interpretor from Draw);
CheckCommands (aDI:out Interpretor from Draw);
TolerCommands (aDI:out Interpretor from Draw);
LowCommands (aDI:out Interpretor from Draw);
ObjCommands (aDI:out Interpretor from Draw);
PartitionCommands (aDI:out Interpretor from Draw);
Factory (aDI:out Interpretor from Draw);
end BOPTest;

View File

@@ -18,7 +18,6 @@
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <DBRep.hxx>
#include <Draw_Interpretor.hxx>
@@ -28,6 +27,7 @@
#include <MeshTest.hxx>
//#include <CorrectTest.hxx>
#include <HLRTest.hxx>
//#include <stdio.h>
//=======================================================================
//function : AllCommands
@@ -37,40 +37,35 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
BOPTest::MTestCommands (theCommands);
BOPTest::TSTCommands(theCommands);
BOPTest::EFCommands (theCommands);
BOPTest::LowCommands(theCommands);
BOPTest::BOPCommands(theCommands);
BOPTest::WSplitCommands(theCommands);
BOPTest::CurveCommands(theCommands);
BOPTest::TolerCommands(theCommands);
BOPTest::CheckCommands(theCommands);
//
BOPTest::BOPCommands (theCommands);
BOPTest::CheckCommands (theCommands);
BOPTest::LowCommands (theCommands);
BOPTest::TolerCommands (theCommands);
BOPTest::ObjCommands (theCommands);
BOPTest::PartitionCommands (theCommands);
}
//==============================================================================
// BOPTest::Factory
//==============================================================================
void BOPTest::Factory(Draw_Interpretor& theDI)
//=======================================================================
//function : Factory
//purpose :
//=======================================================================
void BOPTest::Factory(Draw_Interpretor& theCommands)
{
static Standard_Boolean FactoryDone = Standard_False;
if (FactoryDone) return;
FactoryDone = Standard_True;
DBRep::BasicCommands(theDI);
GeomliteTest::AllCommands(theDI);
GeometryTest::AllCommands(theDI);
BRepTest::AllCommands(theDI);
MeshTest::Commands(theDI);
//CorrectTest::CorrectCommands(theDI);
HLRTest::Commands(theDI);
BOPTest::AllCommands(theDI);
#ifdef DEB
theDI << "Draw Plugin : All Geometry & Topology commands are loaded" << "\n";
#endif
DBRep::BasicCommands(theCommands);
GeomliteTest::AllCommands(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)

File diff suppressed because it is too large Load Diff

466
src/BOPTest/BOPTest_CheckCommands.cxx Executable file → Normal file
View File

@@ -1,6 +1,5 @@
// Created on: 2002-08-05
// Created by: Peter KURNEV
// Copyright (c) 2002-2012 OPEN CASCADE SAS
// Copyright (c) 2010-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
@@ -27,31 +26,26 @@
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_Checker.hxx>
// modified by NIZHNY-MKK Fri Sep 3 17:50:06 2004
#include <BOP_CheckStatus.hxx>
#include <BOP_Operation.hxx>
#include <BOP_ArgumentAnalyzer.hxx>
#include <BOP_CheckResult.hxx>
#include <BOP_ListOfCheckResult.hxx>
#include <BOP_ListIteratorOfListOfCheckResult.hxx>
#include <BOPTools_CheckResult.hxx>
#include <BOPTools_ListOfCheckResults.hxx>
#include <BOPTools_ListIteratorOfListOfCheckResults.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <DBRep.hxx>
#include <Geom_Geometry.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Draw.hxx>
#include <DrawTrSurf.hxx>
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPDS_VectorOfInterfVV.hxx>
#include <BOPDS_VectorOfInterfVE.hxx>
#include <BOPDS_VectorOfInterfEE.hxx>
#include <BOPDS_VectorOfInterfVF.hxx>
#include <BOPDS_VectorOfInterfEF.hxx>
#include <BOPDS_VectorOfInterfFF.hxx>
#include <BOPDS_DS.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPAlgo_ArgumentAnalyzer.hxx>
#include <BOPAlgo_CheckResult.hxx>
#include <BRepBuilderAPI_Copy.hxx>
static
Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );
@@ -90,136 +84,117 @@ Standard_Integer bopcheck (Draw_Interpretor& di, Standard_Integer n, const char
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
TopoDS_Shape aS1 = DBRep::Get(a[1]);
if (aS1.IsNull()) {
di << "null shapes are not allowed here!";
return 1;
}
TopoDS_Shape aS = BRepBuilderAPI_Copy(aS1).Shape();
//
BOPTools_Checker aChecker(aS);
aChecker.Perform();
Standard_Integer iErr, aTypeInt, i, ind, j;
Standard_Integer nI1, nI2;
Standard_Boolean bSelfInt, bFFInt;
char buf[256];
if (aChecker.HasFaulty()) {
const BOPTools_ListOfCheckResults& aResultList = aChecker.GetCheckResult();
// const TopoDS_Shape& aSF1=aChecker.FaultyShape1();
// const TopoDS_Shape& aSF2=aChecker.FaultyShape2();
Standard_Integer shapeit = 1;
BOPTools_ListIteratorOfListOfCheckResults anIt(aResultList);
BOPAlgo_CheckerSI aChecker;
BOPCol_ListOfShape anArgs;
anArgs.Append(aS);
aChecker.SetArguments(anArgs);
//
aChecker.Perform();
iErr = aChecker.ErrorStatus();
//
const BOPDS_PDS& theDS = aChecker.PDS();
BOPDS_VectorOfInterfVV& aVVs=theDS->InterfVV();
BOPDS_VectorOfInterfVE& aVEs=theDS->InterfVE();
BOPDS_VectorOfInterfEE& aEEs=theDS->InterfEE();
BOPDS_VectorOfInterfVF& aVFs=theDS->InterfVF();
BOPDS_VectorOfInterfEF& aEFs=theDS->InterfEF();
BOPDS_VectorOfInterfFF& aFFs=theDS->InterfFF();
//
Standard_Integer aNb[6] = {aVVs.Extent(), aVEs.Extent(), aEEs.Extent(),
aVFs.Extent(), aEFs.Extent(), aFFs.Extent()};
char type[6][5] = {"V/V:", "V/E:", "E/E:","V/F:", "E/F:", "F/F:"};
for(; anIt.More(); anIt.Next()) {
const BOPTools_CheckResult& aCheckResult = anIt.Value();
switch(aCheckResult.GetCheckStatus()) {
case BOPTools_CHKUNKNOWN: {
di << "Unknown status" << "\n";
break;
}
case BOPTools_VERTEXVERTEX: {
di << "Self-intersection near vertices" << "\n";
break;
}
case BOPTools_VERTEXEDGE: {
di << "Self-intersection near vertex and edge" << "\n";
break;
}
case BOPTools_VERTEXFACE: {
di << "Self-intersection near vertex and face" << "\n";
break;
}
case BOPTools_EDGEEDGE: {
di << "Self-intersection near edges" << "\n";
break;
}
case BOPTools_EDGEEDGECOMBLK: {
di << "Coincidance of edges" << "\n";
break;
}
case BOPTools_EDGEFACE: {
di << "Self-intersection near edge and face" << "\n";
break;
}
case BOPTools_EDGEFACECOMBLK: {
di << "Edge belong to face not topologically but geometrically" << "\n";
break;
}
case BOPTools_FACEFACE: {
di << "Self-intersection near faces" << "\n";
break;
}
case BOPTools_BADSHRANKRANGE: {
di << "Can not obtain shrunk range: too small edge" << "\n";
break;
}
case BOPTools_NULLSRANKRANGE: {
di << "Shrunk range is empty: too small edge" << "\n";
break;
}
default: {
di << "Program error" << "\n";
break;
}
}
TopTools_ListIteratorOfListOfShape anIt2(aCheckResult.GetShapes());
TCollection_AsciiString aBaseName("x");
TopoDS_Shape aSF1;
for(; anIt2.More(); anIt2.Next()) {
TopoDS_Shape aSF2 = anIt2.Value();
Standard_Boolean bPrint = Standard_False;
if(aSF1.IsNull()) {
bPrint = Standard_True;
}
else if (!aSF2.IsSame(aSF1)) {
bPrint = Standard_True;
}
if(bPrint) {
TCollection_AsciiString anumbername(shapeit);
TCollection_AsciiString aXName = aBaseName + anumbername;
//char* aname = aXName.ToCString();
Standard_CString aname=aXName.ToCString();
DBRep::Set (aname, aSF2);
//printf(aname);
di << aname << " ";
//printf(" ");
shapeit++;
}
aSF1 = aSF2;
}
//printf("\n");
di << "\n";
//
bSelfInt = Standard_False;
ind = 0;
for (aTypeInt = 0; aTypeInt < 6; ++aTypeInt) {
for (i = 0; i < aNb[aTypeInt]; ++i) {
BOPDS_Interf* aInt = (aTypeInt==0) ? (BOPDS_Interf*)(&aVVs(i)) :
((aTypeInt==1) ? (BOPDS_Interf*)(&aVEs(i)) :
((aTypeInt==2) ? (BOPDS_Interf*)(&aEEs(i)) :
((aTypeInt==3) ? (BOPDS_Interf*)(&aVFs(i)) :
((aTypeInt==4) ? (BOPDS_Interf*)(&aEFs(i)) : (BOPDS_Interf*)(&aFFs(i))))));
//
const Handle(Geom_Geometry)& aGG=aCheckResult.GetInterferenceGeometry();
if (!aGG.IsNull()) {
TCollection_AsciiString aNmx("x0");
Standard_CString name= aNmx.ToCString();
//
Handle (Geom_CartesianPoint) aGCP=
Handle (Geom_CartesianPoint)::DownCast(aGG);
//
if (!aGCP.IsNull()) {
const gp_Pnt& aP3D=aGCP->Pnt();
DrawTrSurf::Set(name, aP3D);
}
else {
DrawTrSurf::Set(name, aGG);
}
nI1 = aInt->Index1();
nI2 = aInt->Index2();
if (nI1 == nI2) {
continue;
}
//
const TopoDS_Shape& aS1 = theDS->Shape(nI1);
const TopoDS_Shape& aS2 = theDS->Shape(nI2);
//
if (aTypeInt == 5) {
bFFInt = Standard_False;
BOPDS_InterfFF& aFF = aFFs(i);
BOPDS_VectorOfPoint& aVP=aFF.ChangePoints();
Standard_Integer aNbP=aVP.Extent();
BOPDS_VectorOfCurve& aVC=aFF.ChangeCurves();
Standard_Integer aNbC=aVC.Extent();
if (!aNbP && !aNbC) {
continue;
}
for (j=0; j<aNbC; ++j) {
BOPDS_Curve& aNC=aVC(j);
BOPDS_ListOfPaveBlock& aLPBC=aNC.ChangePaveBlocks();
if (aLPBC.Extent()) {
bFFInt = Standard_True;
break;
}
}
if (!bFFInt) {
continue;
}
}
//
di << type[aTypeInt];
//
TCollection_AsciiString aBaseName("x");
TCollection_AsciiString anumbername(ind);
TCollection_AsciiString aXName = aBaseName + anumbername;
Standard_CString aname=aXName.ToCString();
DBRep::Set (aname, aS1);
++ind;
TCollection_AsciiString anumbername1(ind);
TCollection_AsciiString aXName1 = aBaseName + anumbername1;
Standard_CString aname1=aXName1.ToCString();
DBRep::Set (aname1, aS2);
++ind;
//
Sprintf(buf, "%s, %s \n", aname, aname1);
di << buf;
bSelfInt = Standard_True;
}
}
//
else {
if (iErr) {
di << "There were errors during the operation, so the list may be incomplete." << "\n";
}
if (!bSelfInt) {
di << " This shape seems to be OK." << "\n";
}
return 0;
}
static void MakeShapeForFullOutput(const TCollection_AsciiString & aBaseName,
const Standard_Integer aIndex,
const TopTools_ListOfShape & aList,
const BOPCol_ListOfShape & aList,
Standard_Integer& aCount,
Draw_Interpretor& di)
Draw_Interpretor& di)
{
TCollection_AsciiString aNum(aIndex);
TCollection_AsciiString aName = aBaseName + aNum;
@@ -229,7 +204,7 @@ static void MakeShapeForFullOutput(const TCollection_AsciiString & aBaseName,
BRep_Builder BB;
BB.MakeCompound(cmp);
TopTools_ListIteratorOfListOfShape anIt(aList);
BOPCol_ListIteratorOfListOfShape anIt(aList);
for(; anIt.More(); anIt.Next()) {
const TopoDS_Shape & aS = anIt.Value();
BB.Add(cmp, aS);
@@ -238,13 +213,12 @@ static void MakeShapeForFullOutput(const TCollection_AsciiString & aBaseName,
di << "Made faulty shape: " << name << "\n";
DBRep::Set(name, cmp);
}
Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const char** a )
{
if (n<2) {
di << "\n";
// cout << " Use >bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [+R|F|T|V|E|I|P]] [#BF]" << endl << endl;
di << " Use >bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [/R|F|T|V|E|I|P]] [#BF]" << "\n" << "\n";
di << " -<Boolean Operation>" << "\n";
di << " F (fuse)" << "\n";
@@ -255,17 +229,11 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
di << " U (unknown)" << "\n";
di << " For example: \"bopargcheck s1 s2 -F\" enables checking for Fuse operation" << "\n";
di << " default - section" << "\n" << "\n";
// cout << " +<Test Options>" << endl;
di << " /<Test Options>" << "\n";
// cout << " R (enable small edges (shrank range) test)" << endl;
di << " R (disable small edges (shrank range) test)" << "\n";
// cout << " F (enable faces verification test)" << endl;
di << " F (disable faces verification test)" << "\n";
// cout << " T (enable tangent faces searching test)" << endl;
di << " T (disable tangent faces searching test)" << "\n";
// cout << " V (test possibility to merge vertices)" << endl;
di << " V (disable test possibility to merge vertices)" << "\n";
// cout << " E (test possibility to merge edges)" << endl;
di << " E (disable test possibility to merge edges)" << "\n";
di << " I (disable self-interference test)" << "\n";
di << " P (disable shape type test)" << "\n";
@@ -280,13 +248,15 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
return 1;
}
TopoDS_Shape aS1 = DBRep::Get(a[1]);
TopoDS_Shape aS11 = DBRep::Get(a[1]);
if(aS1.IsNull()) {
if(aS11.IsNull()) {
di << "Error: null shape not allowed!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
TopoDS_Shape aS1 = BRepBuilderAPI_Copy(aS11).Shape();
Standard_Boolean isBO = Standard_False;
Standard_Integer indxBO = 0;
@@ -324,7 +294,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
}
// set & test second shape
TopoDS_Shape aS2;
TopoDS_Shape aS22, aS2;
if(isS2) {
if(indxS2 != 2) {
di << "Error: second shape should follow the first one!" << "\n";
@@ -332,8 +302,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
return 1;
}
else {
aS2 = DBRep::Get(a[2]);
if(aS2.IsNull()) {
aS22 = DBRep::Get(a[2]);
if(aS22.IsNull()) {
di << "Error: second shape is null!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
@@ -342,7 +312,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
}
// init checker
BOP_ArgumentAnalyzer aChecker;
BOPAlgo_ArgumentAnalyzer aChecker;
aChecker.SetShape1(aS1);
// set default options (always tested!) for single and couple shapes
@@ -350,27 +320,28 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
aChecker.SelfInterMode() = Standard_True;
// test & set options and operation for two shapes
if(!aS2.IsNull()) {
if(!aS22.IsNull()) {
aS2 = BRepBuilderAPI_Copy(aS22).Shape();
aChecker.SetShape2(aS2);
// set operation (default - Section)
if(isBO) {
if(a[indxBO][1] == 'F' || a[indxBO][1] == 'f') {
aChecker.OperationType() = BOP_FUSE;
aChecker.OperationType() = BOPAlgo_FUSE;
}
else if(a[indxBO][1] == 'O' || a[indxBO][1] == 'o') {
aChecker.OperationType() = BOP_COMMON;
aChecker.OperationType() = BOPAlgo_COMMON;
}
else if(a[indxBO][1] == 'C' || a[indxBO][1] == 'c') {
aChecker.OperationType() = BOP_CUT;
aChecker.OperationType() = BOPAlgo_CUT;
}
else if(a[indxBO][1] == 'T' || a[indxBO][1] == 't') {
aChecker.OperationType() = BOP_CUT21;
aChecker.OperationType() = BOPAlgo_CUT21;
}
else if(a[indxBO][1] == 'S' || a[indxBO][1] == 's') {
aChecker.OperationType() = BOP_SECTION;
aChecker.OperationType() = BOPAlgo_SECTION;
}
else if(a[indxBO][1] == 'U' || a[indxBO][1] == 'u') {
aChecker.OperationType() = BOP_UNKNOWN;
aChecker.OperationType() = BOPAlgo_UNKNOWN;
}
else {
di << "Error: invalid boolean operation type!" << "\n";
@@ -379,7 +350,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
}
}
else
aChecker.OperationType() = BOP_SECTION;
aChecker.OperationType() = BOPAlgo_SECTION;
aChecker.SmallEdgeMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_True;
@@ -393,23 +364,23 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
while(a[indxOP][ind] != 0) {
if(a[indxOP][ind] == 'R' || a[indxOP][ind] == 'r') {
//aChecker.SmallEdgeMode() = Standard_True;
aChecker.SmallEdgeMode() = Standard_False;
aChecker.SmallEdgeMode() = Standard_False;
}
else if(a[indxOP][ind] == 'F' || a[indxOP][ind] == 'f') {
//aChecker.RebuildFaceMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_False;
aChecker.RebuildFaceMode() = Standard_False;
}
else if(a[indxOP][ind] == 'T' || a[indxOP][ind] == 't') {
//aChecker.TangentMode() = Standard_True;
aChecker.TangentMode() = Standard_False;
aChecker.TangentMode() = Standard_False;
}
else if(a[indxOP][ind] == 'V' || a[indxOP][ind] == 'v') {
//aChecker.MergeVertexMode() = Standard_True;
aChecker.MergeVertexMode() = Standard_False;
aChecker.MergeVertexMode() = Standard_False;
}
else if(a[indxOP][ind] == 'E' || a[indxOP][ind] == 'e') {
//aChecker.MergeEdgeMode() = Standard_True;
aChecker.MergeEdgeMode() = Standard_False;
aChecker.MergeEdgeMode() = Standard_False;
}
else if(a[indxOP][ind] == 'I' || a[indxOP][ind] == 'i') {
aChecker.SelfInterMode() = Standard_False;
@@ -501,13 +472,14 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
di << "Faulties, that can not be treated by BOP, are detected." << "\n";
}
else {
const BOP_ListOfCheckResult& aResultList = aChecker.GetCheckResult();
BOP_ListIteratorOfListOfCheckResult anIt(aResultList);
const BOPAlgo_ListOfCheckResult& aResultList = aChecker.GetCheckResult();
BOPAlgo_ListIteratorOfListOfCheckResult anIt(aResultList);
Standard_Integer S1_BadType = 0, S1_SelfInt = 0, S1_SmalE = 0, S1_BadF = 0, S1_BadV = 0, S1_BadE = 0;
Standard_Integer S1_SelfIntAll = 0, S1_SmalEAll = 0, S1_BadFAll = 0, S1_BadVAll = 0, S1_BadEAll = 0;
Standard_Integer S2_BadType = 0, S2_SelfInt = 0, S2_SmalE = 0, S2_BadF = 0, S2_BadV = 0, S2_BadE = 0;
Standard_Integer S2_SelfIntAll = 0, S2_SmalEAll = 0, S2_BadFAll = 0, S2_BadVAll = 0, S2_BadEAll = 0;
Standard_Integer S1_OpAb = 0, S2_OpAb = 0;
Standard_Boolean hasUnknown = Standard_False;
TCollection_AsciiString aS1SIBaseName("s1si_");
@@ -522,21 +494,21 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
TCollection_AsciiString aS2BEBaseName("s2be_");
for(; anIt.More(); anIt.Next()) {
const BOP_CheckResult& aResult = anIt.Value();
const BOPAlgo_CheckResult& aResult = anIt.Value();
const TopoDS_Shape & aSS1 = aResult.GetShape1();
const TopoDS_Shape & aSS2 = aResult.GetShape2();
const TopTools_ListOfShape & aLS1 = aResult.GetFaultyShapes1();
const TopTools_ListOfShape & aLS2 = aResult.GetFaultyShapes2();
const BOPCol_ListOfShape & aLS1 = aResult.GetFaultyShapes1();
const BOPCol_ListOfShape & aLS2 = aResult.GetFaultyShapes2();
Standard_Boolean isL1 = !aLS1.IsEmpty();
Standard_Boolean isL2 = !aLS2.IsEmpty();
switch(aResult.GetCheckStatus()) {
case BOP_BadType: {
case BOPAlgo_BadType: {
if(!aSS1.IsNull()) S1_BadType++;
if(!aSS2.IsNull()) S2_BadType++;
}
break;
case BOP_SelfIntersect: {
break;
case BOPAlgo_SelfIntersect: {
if(!aSS1.IsNull()) {
S1_SelfInt++;
if(isL1)
@@ -548,8 +520,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
MakeShapeForFullOutput(aS2SIBaseName, S2_SelfInt, aLS2, S2_SelfIntAll, di);
}
}
break;
case BOP_TooSmallEdge: {
break;
case BOPAlgo_TooSmallEdge: {
if(!aSS1.IsNull()) {
S1_SmalE++;
if(isL1)
@@ -561,8 +533,8 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
MakeShapeForFullOutput(aS2SEBaseName, S2_SmalE, aLS2, S2_SmalEAll, di);
}
}
break;
case BOP_NonRecoverableFace: {
break;
case BOPAlgo_NonRecoverableFace: {
if(!aSS1.IsNull()) {
S1_BadF++;
if(isL1)
@@ -574,52 +546,57 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
MakeShapeForFullOutput(aS2BFBaseName, S2_BadF, aLS2, S2_BadFAll, di);
}
}
break;
case BOP_IncompatibilityOfVertex: {
break;
case BOPAlgo_IncompatibilityOfVertex: {
if(!aSS1.IsNull()) {
S1_BadV++;
if(isL1) {
MakeShapeForFullOutput(aS1BVBaseName, S1_BadV, aLS1, S1_BadVAll, di);
}
}
}
if(!aSS2.IsNull()) {
S2_BadV++;
if(isL2){
MakeShapeForFullOutput(aS2BVBaseName, S2_BadV, aLS2, S2_BadVAll, di);
}
}
}
}
break;
case BOP_IncompatibilityOfEdge: {
break;
case BOPAlgo_IncompatibilityOfEdge: {
if(!aSS1.IsNull()) {
S1_BadE++;
if(isL1) {
MakeShapeForFullOutput(aS1BEBaseName, S1_BadE, aLS1, S1_BadEAll, di);
}
}
}
if(!aSS2.IsNull()) {
S2_BadE++;
if(isL2) {
MakeShapeForFullOutput(aS2BEBaseName, S2_BadE, aLS2, S2_BadEAll, di);
}
}
}
}
break;
case BOP_IncompatibilityOfFace: {
break;
case BOPAlgo_IncompatibilityOfFace: {
// not yet implemented
}
break;
case BOP_CheckUnknown:
break;
case BOPAlgo_OperationAborted: {
if(!aSS1.IsNull()) S1_OpAb++;
if(!aSS2.IsNull()) S2_OpAb++;
}
break;
case BOPAlgo_CheckUnknown:
default: {
hasUnknown = Standard_True;
}
break;
break;
} // switch
}// faulties
Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE;
Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE + S1_OpAb;
FS1 += (S1_BadType != 0) ? 1 : 0;
Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE;
Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE + S2_OpAb;
FS2 += (S2_BadType != 0) ? 1 : 0;
// output for first shape
@@ -627,56 +604,62 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
if(FS1 != 0) {
di << "---------------------------------" << "\n";
Standard_CString CString1;
if (S1_BadType != 0)
CString1="YES";
else
CString1="NO";
if (S1_BadType != 0)
CString1="YES";
else
CString1="NO";
di << "Shapes are not suppotrted by BOP: " << CString1 << "\n";
Standard_CString CString2;
if (S1_SelfInt != 0)
CString2="YES";
else
CString2="NO";
if (S1_SelfInt != 0)
CString2="YES";
else
CString2="NO";
di << "Self-Intersections : " << CString2;
if(S1_SelfInt != 0)
di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")" << "\n";
else
di << "\n";
Standard_CString CString13;
if (S1_OpAb != 0)
CString13="YES";
else
CString13="NO";
di << "Check for SI has been aborted : " << CString13 << "\n";
Standard_CString CString3;
if (S1_SmalE != 0)
CString3="YES";
else
CString3="NO";
if (S1_SmalE != 0)
CString3="YES";
else
CString3="NO";
di << "Too small edges : " << CString3;
if(S1_SmalE != 0)
di << " Cases(" << S1_SmalE << ") Total shapes(" << S1_SmalEAll << ")" << "\n";
else
di << "\n";
Standard_CString CString4;
if (S1_BadF != 0)
CString4="YES";
else
CString4="NO";
if (S1_BadF != 0)
CString4="YES";
else
CString4="NO";
di << "Bad faces : " << CString4;
if(S1_BadF != 0)
di << " Cases(" << S1_BadF << ") Total shapes(" << S1_BadFAll << ")" << "\n";
else
di << "\n";
Standard_CString CString5;
if (S1_BadV != 0)
CString5="YES";
else
CString5="NO";
if (S1_BadV != 0)
CString5="YES";
else
CString5="NO";
di << "Too close vertices : " << CString5;
if(S1_BadV != 0)
di << " Cases(" << S1_BadV << ") Total shapes(" << S1_BadVAll << ")" << "\n";
else
di << "\n";
Standard_CString CString6;
if (S1_BadE != 0)
CString6="YES";
else
CString6="NO";
if (S1_BadE != 0)
CString6="YES";
else
CString6="NO";
di << "Too close edges : " << CString6;
if(S1_BadE != 0)
di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")" << "\n";
@@ -690,56 +673,63 @@ Standard_Integer bopargcheck (Draw_Interpretor& di, Standard_Integer n, const c
if(FS2 != 0) {
di << "---------------------------------" << "\n";
Standard_CString CString7;
if (S2_BadType != 0)
CString7="YES";
else
CString7="NO";
if (S2_BadType != 0)
CString7="YES";
else
CString7="NO";
di << "Shapes are not suppotrted by BOP: " << CString7 << "\n";
Standard_CString CString8;
if (S2_SelfInt != 0)
CString8="YES";
else
CString8="NO";
if (S2_SelfInt != 0)
CString8="YES";
else
CString8="NO";
di << "Self-Intersections : " << CString8;
if(S2_SelfInt != 0)
di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")" << "\n";
else
di << "\n";
Standard_CString CString14;
if (S2_OpAb != 0)
CString14="YES";
else
CString14="NO";
di << "Check for SI has been aborted : " << CString14 << "\n";
Standard_CString CString9;
if (S2_SmalE != 0)
CString9="YES";
else
CString9="NO";
if (S2_SmalE != 0)
CString9="YES";
else
CString9="NO";
di << "Too small edges : " << CString9;
if(S2_SmalE != 0)
di << " Cases(" << S2_SmalE << ") Total shapes(" << S2_SmalEAll << ")" << "\n";
else
di << "\n";
Standard_CString CString10;
if (S2_BadF != 0)
CString10="YES";
else
CString10="NO";
if (S2_BadF != 0)
CString10="YES";
else
CString10="NO";
di << "Bad faces : " << CString10;
if(S2_BadF != 0)
di << " Cases(" << S2_BadF << ") Total shapes(" << S2_BadFAll << ")" << "\n";
else
di << "\n";
Standard_CString CString11;
if (S2_BadV != 0)
CString11="YES";
else
CString11="NO";
if (S2_BadV != 0)
CString11="YES";
else
CString11="NO";
di << "Too close vertices : " << CString11;
if(S2_BadV != 0)
di << " Cases(" << S2_BadV << ") Total shapes(" << S2_BadVAll << ")" << "\n";
else
di << "\n";
Standard_CString CString12;
if (S2_BadE != 0)
CString12="YES";
else
CString12="NO";
if (S2_BadE != 0)
CString12="YES";
else
CString12="NO";
di << "Too close edges : " << CString12;
if(S2_BadE != 0)
di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")" << "\n";

View File

@@ -1,197 +0,0 @@
// Created on: 2000-03-16
// Created by: Peter KURNEV
// Copyright (c) 2000-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TCollection_AsciiString.hxx>
#include <IntTools_FaceFace.hxx>
#include <IntTools_SequenceOfCurves.hxx>
#include <IntTools_Curve.hxx>
#include <Geom_Curve.hxx>
#include <DrawTrSurf.hxx>
#include <Draw.hxx>
#include <DBRep.hxx>
#include <IntTools_Tools.hxx>
static Standard_Integer bopcurves (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer bcurtolerance (Draw_Interpretor& di, Standard_Integer n, const char** a);
//=======================================================================
//function : BOPTest::CurveCommands
//purpose :
//=======================================================================
void BOPTest::CurveCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "CCR commands";
theCommands.Add("bopcurves" , "Use bopcurves> F1 F2", __FILE__, bopcurves, g);
theCommands.Add("bcurtolerance" , " use >bcurtolerance C3Dtrim, Tol\n", __FILE__, bcurtolerance, g);
}
//=======================================================================
//function : bopcurves
//purpose :
//=======================================================================
Standard_Integer bopcurves (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<3) {
di << " Use bopcurves> F1 F2\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
TopAbs_ShapeEnum aType;
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
return 1;
}
aType=S1.ShapeType();
if (aType != TopAbs_FACE) {
di << " Type mismatch F1\n";
return 1;
}
aType=S2.ShapeType();
if (aType != TopAbs_FACE) {
di << " Type mismatch F2\n";
return 1;
}
const TopoDS_Face& aF1=TopoDS::Face(S1);
const TopoDS_Face& aF2=TopoDS::Face(S2);
Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
Standard_Boolean bToSplit;
Standard_Integer i, aNbCurves;
Standard_Real anAppTol, aTolR;
TCollection_AsciiString aNm("c_");
//
bToSplit=Standard_False;
aToApproxC3d=Standard_True;
aToApproxC2dOnS1=Standard_False;
aToApproxC2dOnS2=Standard_False;
anAppTol=0.0000001;
IntTools_FaceFace aFF;
aFF.SetParameters (aToApproxC3d,
aToApproxC2dOnS1,
aToApproxC2dOnS2,
anAppTol);
aFF.Perform (aF1, aF2);
anIsDone=aFF.IsDone();
if (!anIsDone) {
//printf(" anIsDone=%d\n", anIsDone);
di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
return 1;
}
aFF.PrepareLines3D(bToSplit);
const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
//
aTolR=aFF.TolReached3d();
di << "Tolerance Reached=" << aTolR << "\n";
aNbCurves=aSCs.Length();
if (!aNbCurves) {
di << " has no 3d curve\n";
return 1;
}
for (i=1; i<=aNbCurves; i++) {
const IntTools_Curve& anIC=aSCs(i);
Handle (Geom_Curve) aC3D=anIC.Curve();
if (aC3D.IsNull()) {
di << " has Null 3d curve# " << i << "%d\n";
continue;
}
TCollection_AsciiString anIndx(i), aNmx;
aNmx=aNm+anIndx;
Standard_CString name= aNmx.ToCString();
DrawTrSurf::Set(name, aC3D);
di << name << " ";
}
di << "\n";
return 0;
}
//=======================================================================
//function : bcurtolerance
//purpose :
//=======================================================================
Standard_Integer bcurtolerance (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if(n < 2) {
di << " use >bcurtolerance C3D [Tol=1.e-7]\n";
return 1;
}
Handle(Geom_Curve) aC3D = DrawTrSurf::GetCurve(a[1]);
if ( aC3D.IsNull()) {
di << " Null Curve is not allowed here\n";
return 1;
}
//
Standard_Real aTolMax, aTol;
aTol=1.e-7;
if (n>2) {
aTol=Draw::Atof(a[2]);
if (aTol<=0.) {
aTol=1.e-7;
}
}
//
aTolMax=IntTools_Tools::CurveTolerance(aC3D, aTol);
//printf(" aTolMax=%16.11f\n", aTolMax);
di << " aTolMax=" << aTolMax << "\n";
return 0;
}

View File

@@ -18,8 +18,8 @@
// and conditions governing the rights and limitations under the License.
#include <BOPTest_DrawableShape.ixx>
#include <stdio.h>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
@@ -57,10 +57,8 @@
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
//=======================================================================
//function : BOPTest_DrawableShape::BOPTest_DrawableShape
//function :
//purpose :
//=======================================================================
BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape,
@@ -81,7 +79,7 @@ BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape,
}
//=======================================================================
//function : BOPTest_DrawableShape::BOPTest_DrawableShape
//function :
//purpose :
//=======================================================================
BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape,

View File

@@ -1,149 +0,0 @@
// Created on: 2001-02-26
// Created by: Peter KURNEV
// Copyright (c) 2001-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <DBRep.hxx>
#include <IntTools_EdgeFace.hxx>
#include <BRep_Tool.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_CommonPrt.hxx>
//=======================================================================
//function :bedge
//purpose :
//=======================================================================
static Standard_Integer bef (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<3) {
di << " Use bef> Edge Face Discr[33] Tol[1.e-7] Deflection[0.01]\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_FACE) {
di << " Shapes must be EDGE and FACE type\n";
return 1;
}
TopoDS_Edge E=TopoDS::Edge(S1);
TopoDS_Face F=TopoDS::Face(S2);
Standard_Integer aDiscr=33;
Standard_Real aTol=.0000001, aDeflection=.01, aFrom, aTo;
if (n>=4) {
aDiscr=Draw::Atoi (a[3]);
}
if (n>=5) {
aTol=Draw::Atof (a[4]);
}
if (n>=6) {
aDeflection=Draw::Atof (a[5]);
}
di << " bef: ===Begin===\n";
di << " bef: Discretize=" << aDiscr << "%d\n";
di << " bef: Tolerance =" << aTol << "\n";
di << " bef: Deflection=" << aDeflection << "\n";
IntTools_EdgeFace aEF;
aEF.SetEdge(E);
aEF.SetFace(F);
aEF.SetTolE(aTol);
aEF.SetTolF(aTol);
aEF.SetDiscretize(aDiscr);
aEF.SetDeflection(aDeflection);
BRep_Tool::Range(E, aFrom, aTo);
aEF.SetRange (aFrom, aTo);
aEF.Perform();
//
// Results treatment
Standard_Boolean anIsDone=aEF.IsDone();
di << "\n aEF.IsDone()=" << (Standard_Integer) anIsDone << ", aEF.ErrorStatus()=" << aEF.ErrorStatus() << "\n";
if (anIsDone) {
Standard_Integer i, aNb;
Standard_Real tF, tL;
const IntTools_SequenceOfCommonPrts& aCPs=aEF.CommonParts();
aNb=aCPs.Length();
di << " aNb Common Parts=" << aNb << "\n";
for (i=1; i<=aNb; i++) {
const IntTools_CommonPrt& aCP=aCPs(i);
TopAbs_ShapeEnum aType=aCP.Type();
if (aType==TopAbs_VERTEX)
di << " aCP => Type=Vertex\n";
else if (aType==TopAbs_EDGE)
di << " aCP => Type=Edge\n";
else
di << " aCP => Type=Unknown\n";
aCP.Range1(tF, tL);
di << " Part " << i << " Edge#1 (" << tF << ", " << tL << ")\n";
}
}
di << " bef: ===End===\n";
return 0;
}
//=======================================================================
//function : EFCommands
//purpose :
//=======================================================================
void BOPTest::EFCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "Mtest commands";
theCommands.Add("bef", "Use bef> Edge Face Discr[33] Tol[1.e-7] Deflection[0.01]", __FILE__, bef, g);
}

View File

@@ -22,95 +22,30 @@
#include <stdio.h>
#include <gp_Vec2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopAbs_State.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRep_GCurve.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <TCollection_AsciiString.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <TopAbs_State.hxx>
#include <BRep_Tool.hxx>
#include <Draw.hxx>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
#include <BOPTools_Tools2D.hxx>
#include <BOPTools_Tools3D.hxx>
#include <IntTools_Tools.hxx>
#include <BOP_Refiner.hxx>
#include <TCollection_AsciiString.hxx>
#include <IntTools_Context.hxx>
#include <IntTools_FClass2d.hxx>
#include <gp_Pnt2d.hxx>
#include <OSD_Chronometer.hxx>
#include <BRepTools.hxx>
#include <BOPTColStd_CArray1OfInteger.hxx>
static
Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const TopoDS_Face& F,
Standard_Real& First,
Standard_Real& Last);
static
Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last);
static
void PrintState (Draw_Interpretor& aDI,
const TopAbs_State& aState);
const TopAbs_State& aState);
//modified by NIZNHY-PKV Thu Nov 10 12:11:15 2011f
static
void DumpArray(const BOPTColStd_CArray1OfInteger& aC,
Draw_Interpretor& aDI);
//modified by NIZNHY-PKV Thu Nov 10 12:11:18 2011t
static Standard_Integer bhaspc (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer baddve (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bisclosed (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bexplode (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bupdateedge (Draw_Interpretor& , Standard_Integer , const char**);
static Standard_Integer bremovesim (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bopsetdisp (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bfaceprepare(Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer brefine (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bclassify (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer b2dclassify (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bhole (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , const char** );
//=======================================================================
//function : LowCommands
//purpose :
@@ -122,510 +57,20 @@ static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , con
done = Standard_True;
// Chapter's name
const char* g = "CCR commands";
//
// Whether Edge has PCurve on Face
theCommands.Add("bhaspc" , "Use >bhaspc Edge Face" , __FILE__, bhaspc , g);
theCommands.Add("baddve" , "Use >addve E V1 V2 p1 p2", __FILE__, baddve , g);
theCommands.Add("bisclosed" , "Use >bisclosed Edge Face" , __FILE__, bisclosed , g);
theCommands.Add("bexplode" , "" , __FILE__, bexplode , g);
theCommands.Add("bupdateedge" , "Use bupdateedge Edge Face", __FILE__, bupdateedge , g);
theCommands.Add("bremovesim" , "Use bremovesim Face" , __FILE__, bremovesim , g);
theCommands.Add("bopsetdisp" , "Use bopsetdisp" , __FILE__, bopsetdisp , g);
theCommands.Add("bfaceprepare" , "Use bfaceprepare F1 " , __FILE__, bfaceprepare, g);
theCommands.Add("brefine" , "Use brefine Shape " , __FILE__, brefine , g);
theCommands.Add("bclassify" , "Use >bclassify Solid Point [Tolerance=1.e-7]",
__FILE__, bclassify , g);
__FILE__, bclassify , g);
theCommands.Add("b2dclassify" , "Use >bclassify Face Point2d [Tol2D=Tol(Face)] ",
__FILE__, b2dclassify , g);
theCommands.Add("bhole" , "Use bhole" , __FILE__, bhole , g);
theCommands.Add("bxhole" , "Use bxhole" , __FILE__, bxhole , g);
__FILE__, b2dclassify , g);
}
//=======================================================================
//function : brefine
//purpose :
//=======================================================================
Standard_Integer brefine (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<2) {
di << " Use >brefine Shape1\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
Standard_Boolean bIsDone;
BOP_Refiner aRefiner;
aRefiner.SetShape(aS);
aRefiner.Do();
bIsDone=aRefiner.IsDone();
if (bIsDone) {
Standard_Integer aNbRemovedVertices, aNbRemovedEdges, iFlag=0;
aNbRemovedVertices=aRefiner.NbRemovedVertices();
aNbRemovedEdges=aRefiner.NbRemovedEdges();
if (aNbRemovedVertices) {
di << " Vertices removed=" << aNbRemovedVertices << "%d\n";
iFlag++;
}
if (aNbRemovedEdges) {
di << " Edges removed=" << aNbRemovedEdges << "\n";
iFlag++;
}
// REFRESH
if (iFlag) {
TCollection_AsciiString aNm(a[1]);
Standard_CString pstr;
pstr=aNm.ToCString();
DBRep::Set(pstr, aS);
}
}
else {
di << "Not Done, err=" << aRefiner.ErrorStatus() << "\n";
}
return 0;
}
//=======================================================================
//function : bfaceprepare
//purpose :
//=======================================================================
Standard_Integer bfaceprepare(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<2) {
di << " Use bfaceprepare> F1\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
if (S1.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_FACE) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Face& aF1=TopoDS::Face(S1);
TopAbs_Orientation anOr;
anOr=aF1.Orientation();
if (anOr==TopAbs_FORWARD) {
return 0;
}
//
Standard_Real aTol;
TopoDS_Face newFace;
BRep_Builder aBB;
Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1);
Handle(Geom_Surface) aS=Handle(Geom_Surface)::DownCast(aS1->Copy());
aS->VReverse();
aTol=BRep_Tool::Tolerance(aF1);
aBB.MakeFace (newFace, aS, aTol);
TopExp_Explorer anExp(aF1, TopAbs_WIRE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Shape& newWire=anExp.Current();
aBB.Add(newFace, newWire);
}
TCollection_AsciiString aNm(a[1]), aNmNew("_r");
aNm=aNm+aNmNew;
Standard_CString an=aNm.ToCString();
di << an << "\n";
DBRep::Set(an, newFace);
return 0;
}
//=======================================================================
//function : bopsetdisp
//purpose :
//=======================================================================
Standard_Integer bopsetdisp (Draw_Interpretor& di, Standard_Integer , const char** )
{
Standard_Integer aFlag;
char* xr=getenv("MDISP");
if (xr==NULL) {
aFlag=putenv((char*)"MDISP=yes");
di << " MDISP=yes. Return code=" << aFlag << "\n";
}
else if (!strcmp (xr, "yes")) {
aFlag=putenv((char*)"MDISP=no");
di << " MDISP=no. Return code=" << aFlag << "\n";
}
else {
aFlag=putenv((char*)"MDISP=yes");
di << " MDISP=yes. Return code=" << aFlag << "\n";
}
return 0;
}
//=======================================================================
//function : bremovesim
//purpose :
//=======================================================================
Standard_Integer bremovesim (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<2) {
di << " Use bremovesim> Face\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
if (S1.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_FACE) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Face& aF=TopoDS::Face(S1);
//
Handle(IntTools_Context) aCtx=new IntTools_Context;
BOPTools_Tools3D::RemoveSims (aF, aCtx);
//
di << " Ok\n";
return 0;
}
//=======================================================================
//function : bupdateedge
//purpose :
//=======================================================================
Standard_Integer bupdateedge (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<3) {
di << " Use bupdateedge> Edge Face\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Edge& aE=TopoDS::Edge(S1);
const TopoDS_Face& aF=TopoDS::Face(S2);
Handle(Geom2d_Curve) aC2D;
Standard_Real aTol;
aTol=BRep_Tool::Tolerance(aE);
BRep_Builder BB;
BB.UpdateEdge(aE, aC2D, aF, aTol);
di << " Ok\n";
return 0;
}
//=======================================================================
//function : bisclosed
//purpose :
//=======================================================================
Standard_Integer bisclosed (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<3) {
di << " Use bisclosed> Edge Face\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Edge& aE=TopoDS::Edge(S1);
const TopoDS_Face& aF=TopoDS::Face(S2);
Standard_Boolean anIsClosed;
anIsClosed=BRep_Tool::IsClosed(aE, aF);
if (!anIsClosed) {
di << " Edge is not closed on this face\n";
}
else {
di << " Edge is closed on this face\n";
}
return 0;
}
//=======================================================================
//function : bhaspc
//purpose :
//=======================================================================
Standard_Integer bhaspc (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<3) {
di << " Use bhaspc> Edge Face [do]\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE || S2.ShapeType()!=TopAbs_FACE) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Edge& aE=TopoDS::Edge(S1);
const TopoDS_Face& aF=TopoDS::Face(S2);
Standard_Real f2D, l2D;
Handle(Geom2d_Curve) C2D=CurveOnSurface(aE, aF, f2D, l2D);
if (C2D.IsNull()) {
di << " No 2D Curves detected\n";
}
else {
di << " Ok Edge has P-Curve on this Face\n";
}
if (n==4) {
if (!strcmp(a[3], "do")) {
BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF);
}
}
return 0;
}
//=======================================================================
//function : baddve
//purpose :
//=======================================================================
Standard_Integer baddve (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<6) {
di << " Use baddve> E V1 V2 p1 p2\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
TopoDS_Shape S3 = DBRep::Get(a[3]);
if (S1.IsNull() || S2.IsNull() || S3.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE ||
S2.ShapeType()!=TopAbs_VERTEX ||
S3.ShapeType()!=TopAbs_VERTEX ) {
di << " Type mismatch\n";
return 1;
}
const TopoDS_Edge& aE=TopoDS::Edge(S1);
const TopoDS_Vertex& aV1=TopoDS::Vertex(S2);
const TopoDS_Vertex& aV2=TopoDS::Vertex(S3);
Standard_Real p1, p2;
p1=Draw::Atof(a[4]);
p2=Draw::Atof(a[5]);
TopoDS_Edge E=aE;
E.EmptyCopy();
BRep_Builder BB;
BB.Add (E, aV1);
BB.Add (E, aV2);
BB.Range(E, p1, p2);
DBRep::Set("ne", E);
return 0;
}
static Handle(Geom2d_Curve) nullPCurve;
//=======================================================================
//function : CurveOnSurface
//purpose :
//=======================================================================
Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const TopoDS_Face& F,
Standard_Real& First,
Standard_Real& Last)
{
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
TopoDS_Edge aLocalEdge = E;
if (F.Orientation() == TopAbs_REVERSED) {
aLocalEdge.Reverse();
}
return CurveOnSurface(aLocalEdge,S,l,First,Last);
}
//=======================================================================
//function : CurveOnSurface
//purpose :
//=======================================================================
Handle(Geom2d_Curve) CurveOnSurface(const TopoDS_Edge& E,
const Handle(Geom_Surface)& S,
const TopLoc_Location& L,
Standard_Real& First,
Standard_Real& Last)
{
TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
((*((Handle(BRep_TEdge)*)&E.TShape()))->ChangeCurves());
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l)) {
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
GC->Range(First,Last);
if (GC->IsCurveOnClosedSurface() && Eisreversed)
return GC->PCurve2();
else
return GC->PCurve();
}
itcr.Next();
}
return nullPCurve;
}
//=======================================================================
//function : bexplode
//purpose :
//=======================================================================
static Standard_Integer bexplode(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n <= 1) return 1;
TopoDS_Shape S = DBRep::Get(a[1]);
if (S.IsNull()) return 0;
char newname[1024];
strcpy(newname,a[1]);
char* p = newname;
while (*p != '\0') p++;
*p = '_';
p++;
Standard_Integer i = 0;
if (n == 2) {
TopoDS_Iterator itr(S);
while (itr.More()) {
i++;
Sprintf(p,"%d",i);
DBRep::Set(newname,itr.Value());
di.AppendElement(newname);
itr.Next();
}
}
else {
// explode a type
TopAbs_ShapeEnum typ;
switch (a[2][0]) {
case 'C' :
case 'c' :
if ((a[2][1] == 'd')||(a[2][1] == 'D'))
typ = TopAbs_COMPOUND;
else
typ = TopAbs_COMPSOLID;
break;
case 'S' :
case 's' :
if ((a[2][1] == 'O')||(a[2][1] == 'o'))
typ = TopAbs_SOLID;
else if ((a[2][1] == 'H')||(a[2][1] == 'h'))
typ = TopAbs_SHELL;
else
return 1;
break;
case 'F' :
case 'f' :
typ = TopAbs_FACE;
break;
case 'W' :
case 'w' :
typ = TopAbs_WIRE;
break;
case 'E' :
case 'e' :
typ = TopAbs_EDGE;
break;
case 'V' :
case 'v' :
typ = TopAbs_VERTEX;
break;
default :
return 1;
}
TopExp_Explorer ex(S,typ);
for (; ex.More(); ex.Next()) {
const TopoDS_Shape& aS = ex.Current();
i++;
Sprintf(p,"%d",i);
DBRep::Set(newname,aS);
di.AppendElement(newname);
}
}
return 0;
}
//=======================================================================
//function : bclassify
//purpose :
//=======================================================================
Standard_Integer bclassify (Draw_Interpretor& aDI,
Standard_Integer n,
const char** a)
Standard_Integer n,
const char** a)
{
char sbf[512];
@@ -674,8 +119,8 @@ Standard_Integer bclassify (Draw_Interpretor& aDI,
//purpose :
//=======================================================================
Standard_Integer b2dclassify (Draw_Interpretor& aDI,
Standard_Integer n,
const char** a)
Standard_Integer n,
const char** a)
{
char sbf[512];
@@ -719,12 +164,13 @@ Standard_Integer b2dclassify (Draw_Interpretor& aDI,
//
return 0;
}
//=======================================================================
//function : PrintState
//purpose :
//=======================================================================
void PrintState (Draw_Interpretor& aDI,
const TopAbs_State& aState)
const TopAbs_State& aState)
{
char sbf[512];
TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
@@ -732,16 +178,16 @@ void PrintState (Draw_Interpretor& aDI,
Sprintf(sbf, "The point is "); aDI<<sbf;
//
switch (aState) {
case TopAbs_IN:
case TopAbs_IN:
Sprintf(sbf, sIN.ToCString());
break;
case TopAbs_OUT:
case TopAbs_OUT:
Sprintf(sbf, sOUT.ToCString());
break;
case TopAbs_ON:
case TopAbs_ON:
Sprintf(sbf, sON.ToCString());
break;
case TopAbs_UNKNOWN:
case TopAbs_UNKNOWN:
Sprintf(sbf, sUNKNOWN.ToCString());
break;
default:
@@ -749,172 +195,8 @@ void PrintState (Draw_Interpretor& aDI,
break;
}
aDI<<sbf;
//
//
Sprintf(sbf, " shape\n");
aDI<<sbf;
}
//
//=======================================================================
//function : bhole
//purpose :
//=======================================================================
Standard_Integer bhole (Draw_Interpretor& aDI,
Standard_Integer n,
const char** a)
{
char sbf[512];
if (n!=2) {
Sprintf(sbf, " Use bhole Face\n");
aDI<<sbf;
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
Sprintf(sbf, " Null Shape is not allowed here\n");
aDI<<sbf;
return 1;
}
if (aS.ShapeType()!=TopAbs_FACE) {
Sprintf(sbf, " Shape type must be FACE\n");
aDI<<sbf;
return 1;
}
//
Standard_Boolean bIsHole;
Standard_Real aTol=1.e-7;
IntTools_FClass2d aFClass2d;
//
const TopoDS_Face& aF=TopoDS::Face(aS);
aTol=BRep_Tool::Tolerance(aF);
//
aFClass2d.Init(aF, aTol);
//
bIsHole=aFClass2d.IsHole();
printf(" bIsHole=%d\n", bIsHole);
//
return 0;
}
//
//
//=======================================================================
//class : X_Chr
//purpose :
//=======================================================================
class X_Chr {
public:
// X_Chr::X_Chr() {
X_Chr() {
Reset();
}
void Reset() {
myTime=0.;
myCnt=0;
}
void Start() {
myChronometer.Reset();
myChronometer.Start();
}
void Stop() {
Standard_Real aTime;
//
myChronometer.Stop();
myChronometer.Show(aTime);
myTime=myTime+aTime;
++myCnt;
}
void Show(const char *pComment) {
printf(" Tps: %7.2lf\tCnt: %d\tfor %s\n", myTime, myCnt, pComment);
}
protected:
Standard_Real myTime;
Standard_Integer myCnt;
OSD_Chronometer myChronometer;
};
//
//=======================================================================
//function : bxhole
//purpose :
//=======================================================================
Standard_Integer bxhole (Draw_Interpretor& aDI,
Standard_Integer n,
const char** a)
{
char sbf[512];
Standard_Integer aNbIter;
//
if (n!=3) {
Sprintf(sbf, " Use bxhole Face NbIter\n");
aDI<<sbf;
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
Sprintf(sbf, " Null Shape is not allowed here\n");
aDI<<sbf;
return 1;
}
if (aS.ShapeType()!=TopAbs_FACE) {
Sprintf(sbf, " Shape type must be FACE\n");
aDI<<sbf;
return 1;
}
//
aNbIter=Draw::Atoi(a[2]);
if (aNbIter<1) {
aNbIter=1;
}
//
Standard_Integer i;
Standard_Boolean bIsHole;
Standard_Real aTol, aUMin, aUMax, aVMin, aVMax;
gp_Pnt2d aP2DInf;
TopAbs_State aState;
X_Chr aChr;
//
aTol=1.e-7;
const TopoDS_Face& aF=TopoDS::Face(aS);
aTol=BRep_Tool::Tolerance(aF);
//
BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
aP2DInf.SetCoord(aUMin, aVMin);
//
// 1. New
aChr.Reset();
aChr.Start();
for (i=1; i<=aNbIter; ++i) {
IntTools_FClass2d aFClass2d;
//
aFClass2d.Init(aF, aTol);
//
bIsHole=aFClass2d.IsHole();
}
aChr.Stop();
aChr.Show(" new");
printf(" new bIsHole=%d\n", bIsHole);
//``````````````````````````````````````````
aChr.Reset();
aChr.Start();
for (i=1; i<=aNbIter; ++i) {
IntTools_FClass2d aFClass2d;
//
aFClass2d.Init(aF, aTol);
//
aState=aFClass2d.Perform(aP2DInf);
bIsHole=(aState==TopAbs_IN);
}
aChr.Stop();
aChr.Show(" was");
printf(" was bIsHole=%d\n", bIsHole);
//
return 0;
}

View File

@@ -1,256 +0,0 @@
// Created on: 2000-05-18
// Created by: Peter KURNEV
// Copyright (c) 2000-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <TopoDS_Shape.hxx>
#include <DBRep.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <IntTools_EdgeEdge.hxx>
#include <IntTools_SequenceOfCommonPrts.hxx>
#include <IntTools_Range.hxx>
#include <IntTools_CommonPrt.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
//function :bbedge
//purpose :
//=======================================================================
static Standard_Integer bbedge (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<7) {
di << " Use bbedge> Edge1 Edge2 f1 l1 f2 l2\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
di << " Shapes must be EDGE type\n";
return 1;
}
TopoDS_Edge E1=TopoDS::Edge(S1);
TopoDS_Edge E2=TopoDS::Edge(S2);
Standard_Integer aDiscr=30;
Standard_Real aTol=.0000001, aDeflection=.01;
Standard_Real f1, l1, f2, l2;
f1=Draw::Atof (a[3]);
l1=Draw::Atof (a[4]);
f2=Draw::Atof (a[5]);
l2=Draw::Atof (a[6]);
IntTools_Range aR1, aR2;
aR1.SetFirst(f1); aR1.SetLast(l1);
aR2.SetFirst(f2); aR2.SetLast(l2);
di << " bbedge: ===Begin===\n";
di << " bbedge: Discretize=" << aDiscr << "\n";
di << " bbedge: Tolerance =" << aTol << "\n";
di << " bbedge: Deflection=" << aDeflection << "\n";
IntTools_EdgeEdge aEE;
aEE.SetEdge1(E1);
aEE.SetEdge2(E2);
aEE.SetTolerance1(aTol);
aEE.SetTolerance2(aTol);
aEE.SetDiscretize(aDiscr);
aEE.SetDeflection(aDeflection);
aEE.SetRange1(aR1);
aEE.SetRange2(aR2);
aEE.Perform();
//
// Results treatment
Standard_Boolean anIsDone=aEE.IsDone();
di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
if (anIsDone) {
const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
Standard_Integer i,j, aNbRanges, aNbRanges2;
Standard_Real t1, t2;
aNbRanges=aSCp.Length();
for (i=1; i<=aNbRanges; i++) {
const IntTools_CommonPrt& aCommonPrt=aSCp(i);
di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
const IntTools_Range& aRange1=aCommonPrt.Range1();
aRange1.Range(t1, t2);
di << "Range 1: [" << t1 << ", " << t2 << "]\n";
const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
aNbRanges2=aSeqOfRanges2.Length();
for (j=1; j<=aNbRanges2; j++) {
const IntTools_Range& aRange2=aSeqOfRanges2(j);
aRange2.Range(t1, t2);
di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
}
}
}
di << " bedge: ===End===\n";
return 0;
}
//=======================================================================
//function :bedge
//purpose :
//=======================================================================
static Standard_Integer bedge (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<3) {
di << " Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]\n";
return 1;
}
TopoDS_Shape S1 = DBRep::Get(a[1]);
TopoDS_Shape S2 = DBRep::Get(a[2]);
if (S1.IsNull() || S2.IsNull()) {
di << " Null shapes is not allowed \n";
return 1;
}
if (S1.ShapeType()!=TopAbs_EDGE && S2.ShapeType()!=TopAbs_EDGE) {
di << " Shapes must be EDGE type\n";
return 1;
}
TopoDS_Edge E1=TopoDS::Edge(S1);
TopoDS_Edge E2=TopoDS::Edge(S2);
Standard_Integer aDiscr=30;
Standard_Real aTol=.0000001, aDeflection=.01;
Standard_Real f1, l1, f2, l2;
BRep_Tool::Range(E1, f1, l1);
BRep_Tool::Range(E2, f2, l2);
IntTools_Range aR1, aR2;
aR1.SetFirst(f1); aR1.SetLast(l1);
aR2.SetFirst(f2); aR2.SetLast(l2);
if (n>=4) {
aDiscr=Draw::Atoi (a[3]);
}
if (n>=5) {
aTol=Draw::Atof (a[4]);
}
if (n>=6) {
aDeflection=Draw::Atof (a[5]);
}
di << " bedge: ===Begin===\n";
di << " bedge: Discretize=" << aDiscr << "\n";
di << " bedge: Tolerance =" << aTol << "\n";
di << " bedge: Deflection=" << aDeflection << "\n";
IntTools_EdgeEdge aEE;
aEE.SetEdge1(E1);
aEE.SetEdge2(E2);
aEE.SetTolerance1(aTol);
aEE.SetTolerance2(aTol);
aEE.SetDiscretize(aDiscr);
aEE.SetDeflection(aDeflection);
aEE.SetRange1(aR1);
aEE.SetRange2(aR2);
aEE.Perform();
//
// Results treatment
Standard_Boolean anIsDone=aEE.IsDone();
di << "\n aEE.IsDone()=" << (Standard_Integer) anIsDone << ", aEE.ErrorStatus()=" << aEE.ErrorStatus() << "\n";
if (anIsDone) {
const IntTools_SequenceOfCommonPrts& aSCp=aEE.CommonParts ();
Standard_Integer i,j, aNbRanges, aNbRanges2;
Standard_Real t1, t2;
aNbRanges=aSCp.Length();
for (i=1; i<=aNbRanges; i++) {
const IntTools_CommonPrt& aCommonPrt=aSCp(i);
di << " CommonPrt#" << i << " , Type=" << aCommonPrt.Type() << "\n";
const IntTools_Range& aRange1=aCommonPrt.Range1();
aRange1.Range(t1, t2);
di << "Range 1: [" << t1 << ", " << t2 << "]\n";
const IntTools_SequenceOfRanges& aSeqOfRanges2=aCommonPrt.Ranges2();
aNbRanges2=aSeqOfRanges2.Length();
for (j=1; j<=aNbRanges2; j++) {
const IntTools_Range& aRange2=aSeqOfRanges2(j);
aRange2.Range(t1, t2);
di << "Range 2: [" << t1 << ", " << t2 << "] (# " << j << ")\n";
}
}
}
di << " bedge: ===End===\n";
return 0;
}
//=======================================================================
//function : MTestCommands
//purpose :
//=======================================================================
void BOPTest::MTestCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "Mtest commands";
theCommands.Add("bedge" , "Use bedge> Edge1 Edge2 Discr[30] Tol[1.e-7] Deflection[0.01]", __FILE__, bedge,g);
theCommands.Add("bbedge", "Use bbedge> Edge1 Edge2 f1 l1 f2 l2", __FILE__, bbedge,g);
}

View File

@@ -0,0 +1,156 @@
// Created by: Peter KURNEV
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <Draw_Interpretor.hxx>
#include <DBRep.hxx>
//
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shape.hxx>
//
#include <TopTools_ListOfShape.hxx>
//
#include <BOPTest_Objects.hxx>
static Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bclearobjects (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 baddcompound(Draw_Interpretor& , Standard_Integer , const char** );
//
//=======================================================================
//function :ObjCommands
//purpose :
//=======================================================================
void BOPTest::ObjCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
done = Standard_True;
// Chapter's name
const char* g = "BOP commands";
// Commands
theCommands.Add("baddobjects" , "baddobjects s1 s2 ..." , __FILE__, baddobjects, g);
theCommands.Add("bclearobjects" , "bclearobjects" , __FILE__, bclearobjects, g);
theCommands.Add("baddtools" , "baddtools s1 s2 ..." , __FILE__, baddtools, g);
theCommands.Add("bcleartools" , "bcleartools" , __FILE__, bcleartools, g);
theCommands.Add("baddcompound" , "baddcompound c" , __FILE__, baddcompound, g);
}
//=======================================================================
//function : baddcompound
//purpose :
//=======================================================================
Standard_Integer baddcompound (Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n<2) {
printf(" Use baddcompound c\n");
return 0;
}
//
TopoDS_Iterator aIt;
TopoDS_Shape aS;
//
aS=DBRep::Get(a[1]);
//
BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
aIt.Initialize(aS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aSx=aIt.Value();
aLS.Append(aSx);
}
//
return 0;
}
//
//=======================================================================
//function :baddobjects
//purpose :
//=======================================================================
Standard_Integer baddobjects (Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n<2) {
printf(" Use baddobjects s1 s2 ...\n");
return 0;
}
//
Standard_Integer i;
TopoDS_Shape aS;
//
BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
for (i = 1; i < n; ++i) {
aS=DBRep::Get(a[i]);
aLS.Append(aS);
}
//
return 0;
}
//=======================================================================
//function : bclearobjects
//purpose :
//=======================================================================
Standard_Integer bclearobjects (Draw_Interpretor& , Standard_Integer n, const char** )
{
if (n!=1) {
printf(" Use bclearobjects\n");
return 0;
}
BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
aLS.Clear();
//
return 0;
}
//=======================================================================
//function : baddtools
//purpose :
//=======================================================================
Standard_Integer baddtools (Draw_Interpretor& , Standard_Integer n, const char** a)
{
if (n<2) {
printf(" Use baddtools s1 s2 ...\n");
return 0;
}
//
Standard_Integer i;
TopoDS_Shape aS;
//
BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools();
for (i = 1; i < n; ++i) {
aS=DBRep::Get(a[i]);
aLS.Append(aS);
}
//
return 0;
}
//=======================================================================
//function : bcleartools
//purpose :
//=======================================================================
Standard_Integer bcleartools (Draw_Interpretor& , Standard_Integer n, const char** )
{
if (n!=1) {
printf(" Use bcleartools\n");
return 0;
}
BOPCol_ListOfShape& aLS=BOPTest_Objects::Tools();
aLS.Clear();
//
return 0;
}

View File

@@ -0,0 +1,68 @@
-- Created by: Peter KURNEV
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
--
-- The content of this file is subject to the Open CASCADE Technology Public
-- License Version 6.5 (the "License"). You may not use the content of this file
-- except in compliance with the License. Please obtain a copy of the License
-- at http://www.opencascade.org and read it completely before using this file.
--
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
--
-- The Original Code and all software distributed under the License is
-- distributed on an "AS IS" basis, without warranty of any kind, and the
-- Initial Developer hereby disclaims all such warranties, including without
-- limitation, any warranties of merchantability, fitness for a particular
-- purpose or non-infringement. Please see the License for the specific terms
-- and conditions governing the rights and limitations under the License.
class Objects from BOPTest
---Purpose:
uses
ListOfShape from BOPCol,
PaveFiller from BOPAlgo,
Builder from BOPAlgo,
PBuilder from BOPAlgo,
BOP from BOPAlgo,
PDS from BOPDS
--raises
is
PaveFiller(myclass)
returns PaveFiller from BOPAlgo;
---C++: return &
Init(myclass);
Clear(myclass);
PDS(myclass)
returns PDS from BOPDS;
Builder(myclass)
returns Builder from BOPAlgo;
---C++: return &
BOP(myclass)
returns BOP from BOPAlgo;
---C++: return &
Shapes(myclass)
returns ListOfShape from BOPCol;
---C++: return &
Tools(myclass)
returns ListOfShape from BOPCol;
---C++: return &
--
SetBuilder(myclass;
theBuilder:PBuilder from BOPAlgo);
SetBuilderDefault(myclass);
--fields
end Objects;

View File

@@ -0,0 +1,208 @@
// Created by: Peter KURNEV
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest_Objects.ixx>
#include <NCollection_BaseAllocator.hxx>
#include <NCollection_IncAllocator.hxx>
static Handle(NCollection_BaseAllocator)& Allocator1();
//=======================================================================
//function : BOPTest_Session
//purpose :
//=======================================================================
class BOPTest_Session {
public:
//
BOPTest_Session() {
Init();
};
//
~BOPTest_Session(){
Clear();
};
//
// Init
void Init() {
Handle(NCollection_BaseAllocator) pA1, pA2;
//
pA1=new NCollection_IncAllocator;
pA2=new NCollection_IncAllocator;
//
myPaveFiller=new BOPAlgo_PaveFiller(pA1);
myBuilderDefault=new BOPAlgo_Builder(pA2);
//
myBuilder=myBuilderDefault;
};
//
// Clear
void Clear() {
if (myPaveFiller) {
delete myPaveFiller;
myPaveFiller=NULL;
}
//
if (myBuilderDefault) {
delete myBuilderDefault;
myBuilderDefault=NULL;
}
};
//
// IsValid
Standard_Boolean IsValid() const {
return (myPaveFiller!=NULL);
}
// PaveFiller
BOPAlgo_PaveFiller& PaveFiller() {
return *myPaveFiller;
};
//
// Builder
BOPAlgo_Builder& Builder() {
return *myBuilder;
};
//
// SetBuilder
void SetBuilder(BOPAlgo_Builder* pBuilder) {
myBuilder=pBuilder;
};
//
// SetBuilderDef
void SetBuilderDefault() {
myBuilder=myBuilderDefault;
};
//
protected:
//
BOPAlgo_PaveFiller* myPaveFiller;
BOPAlgo_Builder* myBuilder;
BOPAlgo_Builder* myBuilderDefault;
};
//
//=======================================================================
//function : GetSession
//purpose :
//=======================================================================
static BOPTest_Session& GetSession()
{
static BOPTest_Session* pSession=new BOPTest_Session;
//
if (!pSession->IsValid()) {
pSession->Init();
}
return *pSession;
}
//
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BOPTest_Objects::Init()
{
GetSession().Init();
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BOPTest_Objects::Clear()
{
GetSession().Clear();
}
//=======================================================================
//function : PaveFiller
//purpose :
//=======================================================================
BOPAlgo_PaveFiller& BOPTest_Objects::PaveFiller()
{
return GetSession().PaveFiller();
}
//=======================================================================
//function : PDS
//purpose :
//=======================================================================
BOPDS_PDS BOPTest_Objects::PDS()
{
return BOPTest_Objects::PaveFiller().PDS();
}
//=======================================================================
//function : Builder
//purpose :
//=======================================================================
BOPAlgo_Builder& BOPTest_Objects::Builder()
{
return GetSession().Builder();
}
//=======================================================================
//function : SetBuilder
//purpose :
//=======================================================================
void BOPTest_Objects::SetBuilder(const BOPAlgo_PBuilder& theBuilder)
{
BOPAlgo_Builder* pB;
//
pB=(BOPAlgo_Builder*)theBuilder;
GetSession().SetBuilder(pB);
}
//=======================================================================
//function : SetBuilderDefault
//purpose :
//=======================================================================
void BOPTest_Objects::SetBuilderDefault()
{
GetSession().SetBuilderDefault();
}
//=======================================================================
//function : BOP
//purpose :
//=======================================================================
BOPAlgo_BOP& BOPTest_Objects::BOP()
{
static BOPAlgo_BOP sBOP(Allocator1());
return sBOP;
}
//=======================================================================
//function : Shapes
//purpose :
//=======================================================================
BOPCol_ListOfShape& BOPTest_Objects::Shapes()
{
static BOPCol_ListOfShape s_Shapes;
return s_Shapes;
}
//=======================================================================
//function : Tools
//purpose :
//=======================================================================
BOPCol_ListOfShape& BOPTest_Objects::Tools()
{
static BOPCol_ListOfShape s_Tools;
return s_Tools;
}
//=======================================================================
//function : Allocator1
//purpose :
//=======================================================================
Handle(NCollection_BaseAllocator)& Allocator1()
{
static Handle(NCollection_BaseAllocator) sAL1=
new NCollection_IncAllocator;
return sAL1;
}

View File

@@ -0,0 +1,255 @@
// Created by: Peter KURNEV
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <NCollection_IncAllocator.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Draw_Color.hxx>
#include <DrawTrSurf.hxx>
#include <TopoDS_Shape.hxx>
//
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_Operation.hxx>
#include <BOPAlgo_BOP.hxx>
//
#include <BOPTest_DrawableShape.hxx>
#include <BOPTest_Objects.hxx>
//
static Standard_Integer bfillds (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bbuild (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bbop (Draw_Interpretor&, Standard_Integer, const char**);
static Standard_Integer bclear (Draw_Interpretor&, Standard_Integer, const char**);
//=======================================================================
//function : PartitionCommands
//purpose :
//=======================================================================
void BOPTest::PartitionCommands(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("bfillds" , "use bfillds" , __FILE__, bfillds , g);
theCommands.Add("bbuild" , "use bbuild r" , __FILE__, bbuild, g);
theCommands.Add("bbop" , "use bbop r op" , __FILE__, bbop, g);
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
}
//=======================================================================
//function : bclear
//purpose :
//=======================================================================
Standard_Integer bclear(Draw_Interpretor& di, Standard_Integer n, const char** )
{
if (n!=1) {
di << " use bclear\n";
return 0;
}
//
BOPTest_Objects::Clear();
return 0;
}
//=======================================================================
//function : bfillds
//purpose :
//=======================================================================
Standard_Integer bfillds(Draw_Interpretor& di, Standard_Integer n, const char** )
{
if (n!=1) {
di << " Use bfillds\n";
return 0;
}
//
char buf[32];
Standard_Integer aNbS, aNbT, iErr;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_ListOfShape aLC;
BOPCol_ListOfShape& aLS=BOPTest_Objects::Shapes();
aNbS=aLS.Extent();
if (!aNbS) {
di << " no objects to process\n";
return 0;
}
//
BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
aNbT=aLT.Extent();
//
aIt.Initialize(aLS);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aLC.Append(aS);
}
//
aIt.Initialize(aLT);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aLC.Append(aS);
}
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
//
aPF.SetArguments(aLC);
//
aPF.Perform();
iErr=aPF.ErrorStatus();
if (iErr) {
Sprintf(buf, " error: %d\n", iErr);
di << buf;
return 0;
}
//
return 0;
}
//=======================================================================
//function : bbuild
//purpose :
//=======================================================================
Standard_Integer bbuild(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n!=2) {
di << " Use bbuild r\n";
return 0;
}
//
BOPDS_PDS pDS=BOPTest_Objects::PDS();
if (!pDS) {
di << " prepare PaveFiller first\n";
return 0;
}
//
char buf[32];
Standard_Integer iErr;
BOPCol_ListIteratorOfListOfShape aIt;
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
//
BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder();
aBuilder.Clear();
//
BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
aIt.Initialize(aLSObj);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBuilder.AddArgument(aS);
}
//
BOPCol_ListOfShape& aLSTool=BOPTest_Objects::Tools();
aIt.Initialize(aLSTool);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBuilder.AddArgument(aS);
}
//
aBuilder.PerformWithFiller(aPF);
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 : bbop
//purpose :
//=======================================================================
Standard_Integer bbop(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n!=3) {
di << " use bbop r op\n";
return 0;
}
//
BOPDS_PDS pDS=BOPTest_Objects::PDS();
if (!pDS) {
di << " prepare PaveFiller first\n";
return 0;
}
//
char buf[32];
Standard_Integer iErr, iOp;
BOPAlgo_Operation aOp;
BOPCol_ListIteratorOfListOfShape aIt;
//
iOp=Draw::Atoi(a[2]);
if (iOp<0 || iOp>4) {
di << " invalid operation type\n";
}
aOp=(BOPAlgo_Operation)iOp;
//
BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller();
//
BOPAlgo_BOP& aBOP=BOPTest_Objects::BOP();
aBOP.Clear();
//
BOPCol_ListOfShape& aLSObj=BOPTest_Objects::Shapes();
aIt.Initialize(aLSObj);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBOP.AddArgument(aS);
}
//
BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
aIt.Initialize(aLSTools);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
aBOP.AddTool(aS);
}
//
aBOP.SetOperation(aOp);
//
aBOP.PerformWithFiller(aPF);
iErr=aBOP.ErrorStatus();
if (iErr) {
Sprintf(buf, " error: %d\n", iErr);
di << buf;
return 0;
}
//
const TopoDS_Shape& aR=aBOP.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
//
DBRep::Set(a[1], aR);
return 0;
}

View File

@@ -1,21 +0,0 @@
// Created on: 2000-03-16
// Created by: Peter KURNEV
// Copyright (c) 2000-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>

5
src/BOPTest/BOPTest_TolerCommands.cxx Executable file → Normal file
View File

@@ -1,5 +1,4 @@
// Created on: 2000-03-16
// Created by: Peter KURNEV
// Copyright (c) 2000-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
@@ -71,8 +70,8 @@ static
//
static
void ProcessVertex(const TopoDS_Vertex&,
const TopTools_ListOfShape&,
const TopTools_ListOfShape&);
const TopTools_ListOfShape&,
const TopTools_ListOfShape&);
static
void ProcessEdge(const TopoDS_Edge&, const Standard_Real);

View File

@@ -1,228 +0,0 @@
// Created on: 2000-03-16
// Created by: Peter KURNEV
// Copyright (c) 2000-2012 OPEN CASCADE SAS
//
// The content of this file is subject to the Open CASCADE Technology Public
// License Version 6.5 (the "License"). You may not use the content of this file
// except in compliance with the License. Please obtain a copy of the License
// at http://www.opencascade.org and read it completely before using this file.
//
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
//
// The Original Code and all software distributed under the License is
// distributed on an "AS IS" basis, without warranty of any kind, and the
// Initial Developer hereby disclaims all such warranties, including without
// limitation, any warranties of merchantability, fitness for a particular
// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
#include <BOPTest.ixx>
#include <stdio.h>
#include <BOPTest_DrawableShape.hxx>
#include <DBRep.hxx>
#include <DBRep_DrawableShape.hxx>
#include <Draw.hxx>
#include <Draw_Color.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <BOP_WireSplitter.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Shell.hxx>
#include <BOP_ShellSplitter.hxx>
#include <BOPTColStd_ListOfListOfShape.hxx>
#include <BOPTColStd_ListIteratorOfListOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
static Standard_Integer bwsplit (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer bssplit (Draw_Interpretor&, Standard_Integer, const char** );
//=======================================================================
//function : WSplitCommands
//purpose :
//=======================================================================
void BOPTest::WSplitCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done)
return;
done = Standard_True;
// Chapter's name
const char* g = "CCR commands";
theCommands.Add("bwsplit" , "Use bwsplit> Face" , __FILE__, bwsplit , g);
theCommands.Add("bssplit" , "Use bssplit> Shell" , __FILE__, bssplit , g);
}
//=======================================================================
//function : bssplit
//purpose :
//=======================================================================
Standard_Integer bssplit (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " Use bssplit> Shell\n";
return 1;
}
TopoDS_Shape S = DBRep::Get(a[1]);
if (S.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
Standard_Boolean anIsDone, anIsNothingToDo ;
TopAbs_ShapeEnum aT;
aT=S.ShapeType();
if (aT!=TopAbs_SHELL) {
di << " Shape Type must be SHELL\n";
return 1;
}
const TopoDS_Shell& aSh = TopoDS::Shell(S);
BOP_ShellSplitter aShellSplitter;
aShellSplitter.SetShell(aSh);
aShellSplitter.DoWithShell ();
anIsDone=aShellSplitter.IsDone();
di << " aShellSplitter.IsDone=" << (Standard_Integer) anIsDone << "\n";
anIsNothingToDo=aShellSplitter.IsNothingToDo();
di << " IsNothingToDo=" << (Standard_Integer) anIsNothingToDo << "\n";
if (!anIsDone) {
return 0;
}
if (anIsNothingToDo) {
return 0;
}
//
Standard_Integer i=1;
BRep_Builder BB;
const BOPTColStd_ListOfListOfShape& aSSS=aShellSplitter.Shapes();
BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS);
for (; aWireIt.More(); aWireIt.Next(), ++i) {
TopoDS_Compound aCompound;
BB.MakeCompound(aCompound);
const TopTools_ListOfShape& aListEd=aWireIt.Value();
TopTools_ListIteratorOfListOfShape anIt(aListEd);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aE=anIt.Value();
BB.Add(aCompound, aE);
}
TCollection_AsciiString aName(a[1]), aDef("_"), anI(i), aRName;
aRName=aName;
aRName=aRName+aDef;
aRName=aRName+anI;
DBRep::Set (aRName.ToCString(), aCompound);
di << aRName.ToCString() << "\n";
}
return 0;
}
//=======================================================================
//function : bwsplit
//purpose :
//=======================================================================
Standard_Integer bwsplit (Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n!=2) {
di << " Use bwsplit> Face\n";
return 1;
}
TopoDS_Shape S = DBRep::Get(a[1]);
if (S.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
Standard_Boolean anIsDone, anIsNothingToDo ;
TopAbs_ShapeEnum aT;
aT=S.ShapeType();
if (aT!=TopAbs_FACE) {
di << " Shape Type must be FACE\n";
return 1;
}
const TopoDS_Face& aF = TopoDS::Face(S);
BOP_WireSplitter aWireSplitter;
aWireSplitter.SetFace(aF);
aWireSplitter.DoWithFace ();
anIsDone=aWireSplitter.IsDone();
di << " aWireSplitter.IsDone=" << (Standard_Integer) anIsDone << "\n";
anIsNothingToDo=aWireSplitter.IsNothingToDo();
di << " IsNothingToDo=" << (Standard_Integer) anIsNothingToDo << "\n";
if (!anIsDone) {
return 0;
}
if (anIsNothingToDo) {
return 0;
}
//
Standard_Integer i=1;
BRep_Builder BB;
const BOPTColStd_ListOfListOfShape& aSSS=aWireSplitter.Shapes();
BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS);
for (; aWireIt.More(); aWireIt.Next(), ++i) {
TopoDS_Compound aCompound;
BB.MakeCompound(aCompound);
const TopTools_ListOfShape& aListEd=aWireIt.Value();
TopTools_ListIteratorOfListOfShape anIt(aListEd);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Shape& aE=anIt.Value();
BB.Add(aCompound, aE);
}
TCollection_AsciiString aName(a[1]), aDef("_"), anI(i), aRName;
aRName=aName;
aRName=aRName+aDef;
aRName=aRName+anI;
DBRep::Set (aRName.ToCString(), aCompound);
di << aRName.ToCString() << "\n";
}
return 0;
}

View File

@@ -1,10 +1,6 @@
BOPTest_MTestCommands.cxx
BOPTest_TSTCommands.cxx
BOPTest_EFCommands.cxx
BOPTest_LowCommands.cxx
BOPTest_BOPCommands.cxx
BOPTest_WSplitCommands.cxx
BOPTest_CurveCommands.cxx
BOPTest_TolerCommands.cxx
BOPTest_PartitionCommands.cxx
BOPTest_LowCommands.cxx
BOPTest_CheckCommands.cxx
BOPTest_TolerCommands.cxx
BOPTest_ObjCommands.cxx