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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

45
src/BOPTest/BOPTest.cdl Executable file
View File

@@ -0,0 +1,45 @@
-- File: BOPTest.cdl
-- Created: Thu May 18 10:40:44 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
package BOPTest
---Purpose:
--
uses
Draw,
TCollection,
gp,
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);
Factory (theDI : in out Interpretor from Draw);
---Purpose: Loads all Draw commands for Geometry & Topology. Used for plugin.
end BOPTest;

61
src/BOPTest/BOPTest.cxx Executable file
View File

@@ -0,0 +1,61 @@
// File: MTest.cxx
// Created: Thu May 18 10:42:37 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
#include <DBRep.hxx>
#include <Draw_Interpretor.hxx>
#include <GeomliteTest.hxx>
#include <GeometryTest.hxx>
#include <BRepTest.hxx>
#include <MeshTest.hxx>
//#include <CorrectTest.hxx>
#include <HLRTest.hxx>
//=======================================================================
//function : AllCommands
//purpose :
//=======================================================================
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::Factory
//==============================================================================
void BOPTest::Factory(Draw_Interpretor& theDI)
{
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
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,745 @@
// File: BOPTest_CheckCommands.cxx
// Created: Mon Aug 5 11:07:19 2002
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
//
#include <TCollection_AsciiString.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#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 <DrawTrSurf.hxx>
//
static
Standard_Integer bopcheck (Draw_Interpretor&, Standard_Integer, const char** );
static
Standard_Integer bopargcheck (Draw_Interpretor&, Standard_Integer, const char** );
//
//=======================================================================
//function : CheckCommands
//purpose :
//=======================================================================
void BOPTest::CheckCommands(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("bopcheck" , "Use >bopcheck Shape", __FILE__, bopcheck, g);
theCommands.Add("bopargcheck" , "Use bopargcheck without parameters to get ", __FILE__, bopargcheck, g);
}
//=======================================================================
//function : bopcheck
//purpose :
//=======================================================================
Standard_Integer bopcheck (Draw_Interpretor& di, Standard_Integer n, const char** a )
{
if (n<2) {
di << " Use >bopcheck Shape" << "\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
//
BOPTools_Checker aChecker(aS);
aChecker.Perform();
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);
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";
//
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);
}
}
}
}
//
else {
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,
Standard_Integer& aCount,
Draw_Interpretor& di)
{
TCollection_AsciiString aNum(aIndex);
TCollection_AsciiString aName = aBaseName + aNum;
Standard_CString name = aName.ToCString();
TopoDS_Compound cmp;
BRep_Builder BB;
BB.MakeCompound(cmp);
TopTools_ListIteratorOfListOfShape anIt(aList);
for(; anIt.More(); anIt.Next()) {
const TopoDS_Shape & aS = anIt.Value();
BB.Add(cmp, aS);
aCount++;
}
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";
di << " O (common)" << "\n";
di << " C (cut)" << "\n";
di << " T (cut21)" << "\n";
di << " S (section)" << "\n";
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";
di << " For example: \"bopargcheck s1 s2 /RI\" disables small edge detection and self-intersection detection" << "\n";
di << " default - all options are enabled" << "\n" << "\n";
di << " #<Additional Test Options>" << "\n";
di << " B (stop test on first faulty found); default OFF" << "\n";
di << " F (full output for faulty shapes); default - output in a short format" << "\n" << "\n";
di << " NOTE: <Boolean Operation> and <Test Options> are used only for couple" << "\n";
di << " of argument shapes, except I and P options that are always used for" << "\n";
di << " couple of shapes as well as for single shape test." << "\n";
return 1;
}
TopoDS_Shape aS1 = DBRep::Get(a[1]);
if(aS1.IsNull()) {
di << "Error: null shape not allowed!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
Standard_Boolean isBO = Standard_False;
Standard_Integer indxBO = 0;
Standard_Boolean isOP = Standard_False;
Standard_Integer indxOP = 0;
Standard_Boolean isAD = Standard_False;
Standard_Integer indxAD = 0;
Standard_Boolean isS2 = Standard_False;
Standard_Integer indxS2 = 0;
if(n >= 3) {
Standard_Integer iIndex = 0;
for(iIndex = 2; iIndex < n; iIndex++) {
if(a[iIndex][0] == '-')
{
isBO = Standard_True;
indxBO = iIndex;
}
//else if(a[iIndex][0] == '+')
else if(a[iIndex][0] == '/')
{
isOP = Standard_True;
indxOP = iIndex;
}
else if(a[iIndex][0] == '#')
{
isAD = Standard_True;
indxAD = iIndex;
}
else {
isS2 = Standard_True;
indxS2 = iIndex;
}
}
}
// set & test second shape
TopoDS_Shape aS2;
if(isS2) {
if(indxS2 != 2) {
di << "Error: second shape should follow the first one!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
else {
aS2 = DBRep::Get(a[2]);
if(aS2.IsNull()) {
di << "Error: second shape is null!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
}
}
// init checker
BOP_ArgumentAnalyzer aChecker;
aChecker.SetShape1(aS1);
// set default options (always tested!) for single and couple shapes
aChecker.ArgumentTypeMode() = Standard_True;
aChecker.SelfInterMode() = Standard_True;
// test & set options and operation for two shapes
if(!aS2.IsNull()) {
aChecker.SetShape2(aS2);
// set operation (default - Section)
if(isBO) {
if(a[indxBO][1] == 'F' || a[indxBO][1] == 'f') {
aChecker.OperationType() = BOP_FUSE;
}
else if(a[indxBO][1] == 'O' || a[indxBO][1] == 'o') {
aChecker.OperationType() = BOP_COMMON;
}
else if(a[indxBO][1] == 'C' || a[indxBO][1] == 'c') {
aChecker.OperationType() = BOP_CUT;
}
else if(a[indxBO][1] == 'T' || a[indxBO][1] == 't') {
aChecker.OperationType() = BOP_CUT21;
}
else if(a[indxBO][1] == 'S' || a[indxBO][1] == 's') {
aChecker.OperationType() = BOP_SECTION;
}
else if(a[indxBO][1] == 'U' || a[indxBO][1] == 'u') {
aChecker.OperationType() = BOP_UNKNOWN;
}
else {
di << "Error: invalid boolean operation type!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
}
else
aChecker.OperationType() = BOP_SECTION;
aChecker.SmallEdgeMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_True;
aChecker.TangentMode() = Standard_True;
aChecker.MergeVertexMode() = Standard_True;
aChecker.MergeEdgeMode() = Standard_True;
// set options (default - all ON)
if(isOP) {
Standard_Integer ind = 1;
while(a[indxOP][ind] != 0) {
if(a[indxOP][ind] == 'R' || a[indxOP][ind] == 'r') {
//aChecker.SmallEdgeMode() = Standard_True;
aChecker.SmallEdgeMode() = Standard_False;
}
else if(a[indxOP][ind] == 'F' || a[indxOP][ind] == 'f') {
//aChecker.RebuildFaceMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_False;
}
else if(a[indxOP][ind] == 'T' || a[indxOP][ind] == 't') {
//aChecker.TangentMode() = Standard_True;
aChecker.TangentMode() = Standard_False;
}
else if(a[indxOP][ind] == 'V' || a[indxOP][ind] == 'v') {
//aChecker.MergeVertexMode() = Standard_True;
aChecker.MergeVertexMode() = Standard_False;
}
else if(a[indxOP][ind] == 'E' || a[indxOP][ind] == 'e') {
//aChecker.MergeEdgeMode() = Standard_True;
aChecker.MergeEdgeMode() = Standard_False;
}
else if(a[indxOP][ind] == 'I' || a[indxOP][ind] == 'i') {
aChecker.SelfInterMode() = Standard_False;
}
else if(a[indxOP][ind] == 'P' || a[indxOP][ind] == 'p') {
aChecker.ArgumentTypeMode() = Standard_False;
}
else {
di << "Error: invalid test option(s)!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
ind++;
}
}
else {
// default test mode (all - ON)
aChecker.SmallEdgeMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_True;
aChecker.TangentMode() = Standard_True;
aChecker.MergeVertexMode() = Standard_True;
aChecker.MergeEdgeMode() = Standard_True;
}
}
else {
// check type and self-interference mode for single shape test
// also check small edges and check faces
aChecker.SmallEdgeMode() = Standard_True;
aChecker.RebuildFaceMode() = Standard_True;
if(isOP) {
Standard_Integer ind = 1;
while(a[indxOP][ind] != 0) {
if(a[indxOP][ind] == 'R' || a[indxOP][ind] == 'r') {
}
else if(a[indxOP][ind] == 'F' || a[indxOP][ind] == 'f') {
}
else if(a[indxOP][ind] == 'T' || a[indxOP][ind] == 't') {
}
else if(a[indxOP][ind] == 'V' || a[indxOP][ind] == 'v') {
}
else if(a[indxOP][ind] == 'E' || a[indxOP][ind] == 'e') {
}
else if(a[indxOP][ind] == 'I' || a[indxOP][ind] == 'i') {
aChecker.SelfInterMode() = Standard_False;
}
else if(a[indxOP][ind] == 'P' || a[indxOP][ind] == 'p') {
aChecker.ArgumentTypeMode() = Standard_False;
}
else {
di << "Error: invalid test option(s)!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
ind++;
}
}
}
// set additional options
Standard_Boolean fullOutput = Standard_False;
if(isAD) {
Standard_Integer ind = 1;
while(a[indxAD][ind] != 0) {
if(a[indxAD][ind] == 'B' || a[indxAD][ind] == 'b') {
aChecker.StopOnFirstFaulty() = Standard_True;
}
else if(a[indxAD][ind] == 'F' || a[indxAD][ind] == 'f') {
fullOutput = Standard_True;
}
else {
di << "Error: invalid additional test option(s)!" << "\n";
di << "Type bopargcheck without arguments for more information" << "\n";
return 1;
}
ind++;
}
}
// run checker
aChecker.Perform();
// process result of checking
if(!aChecker.HasFaulty()) {
di << "Shape(s) seem(s) to be valid for BOP." << "\n";
}
else {
if(!fullOutput) {
di << "Faulties, that can not be treated by BOP, are detected." << "\n";
}
else {
const BOP_ListOfCheckResult& aResultList = aChecker.GetCheckResult();
BOP_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_Boolean hasUnknown = Standard_False;
TCollection_AsciiString aS1SIBaseName("s1si_");
TCollection_AsciiString aS1SEBaseName("s1se_");
TCollection_AsciiString aS1BFBaseName("s1bf_");
TCollection_AsciiString aS1BVBaseName("s1bv_");
TCollection_AsciiString aS1BEBaseName("s1be_");
TCollection_AsciiString aS2SIBaseName("s2si_");
TCollection_AsciiString aS2SEBaseName("s2se_");
TCollection_AsciiString aS2BFBaseName("s2bf_");
TCollection_AsciiString aS2BVBaseName("s2bv_");
TCollection_AsciiString aS2BEBaseName("s2be_");
for(; anIt.More(); anIt.Next()) {
const BOP_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();
Standard_Boolean isL1 = !aLS1.IsEmpty();
Standard_Boolean isL2 = !aLS2.IsEmpty();
switch(aResult.GetCheckStatus()) {
case BOP_BadType: {
if(!aSS1.IsNull()) S1_BadType++;
if(!aSS2.IsNull()) S2_BadType++;
}
break;
case BOP_SelfIntersect: {
if(!aSS1.IsNull()) {
S1_SelfInt++;
if(isL1)
MakeShapeForFullOutput(aS1SIBaseName, S1_SelfInt, aLS1, S1_SelfIntAll, di);
}
if(!aSS2.IsNull()) {
S2_SelfInt++;
if(isL2)
MakeShapeForFullOutput(aS2SIBaseName, S2_SelfInt, aLS2, S2_SelfIntAll, di);
}
}
break;
case BOP_TooSmallEdge: {
if(!aSS1.IsNull()) {
S1_SmalE++;
if(isL1)
MakeShapeForFullOutput(aS1SEBaseName, S1_SmalE, aLS1, S1_SmalEAll, di);
}
if(!aSS2.IsNull()) {
S2_SmalE++;
if(isL2)
MakeShapeForFullOutput(aS2SEBaseName, S2_SmalE, aLS2, S2_SmalEAll, di);
}
}
break;
case BOP_NonRecoverableFace: {
if(!aSS1.IsNull()) {
S1_BadF++;
if(isL1)
MakeShapeForFullOutput(aS1BFBaseName, S1_BadF, aLS1, S1_BadFAll, di);
}
if(!aSS2.IsNull()) {
S2_BadF++;
if(isL2)
MakeShapeForFullOutput(aS2BFBaseName, S2_BadF, aLS2, S2_BadFAll, di);
}
}
break;
case BOP_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: {
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: {
// not yet implemented
}
break;
case BOP_CheckUnknown:
default: {
hasUnknown = Standard_True;
}
break;
} // switch
}// faulties
Standard_Integer FS1 = S1_SelfInt + S1_SmalE + S1_BadF + S1_BadV + S1_BadE;
FS1 += (S1_BadType != 0) ? 1 : 0;
Standard_Integer FS2 = S2_SelfInt + S2_SmalE + S2_BadF + S2_BadV + S2_BadE;
FS2 += (S2_BadType != 0) ? 1 : 0;
// output for first shape
di << "Faulties for FIRST shape found : " << FS1 << "\n";
if(FS1 != 0) {
di << "---------------------------------" << "\n";
Standard_CString CString1;
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";
di << "Self-Intersections : " << CString2;
if(S1_SelfInt != 0)
di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")" << "\n";
else
di << "\n";
Standard_CString CString3;
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";
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";
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";
di << "Too close edges : " << CString6;
if(S1_BadE != 0)
di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")" << "\n";
else
di << "\n";
}
// output for second shape
di << "\n";
di << "Faulties for SECOND shape found : " << FS2 << "\n";
if(FS2 != 0) {
di << "---------------------------------" << "\n";
Standard_CString CString7;
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";
di << "Self-Intersections : " << CString8;
if(S2_SelfInt != 0)
di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")" << "\n";
else
di << "\n";
Standard_CString CString9;
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";
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";
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";
di << "Too close edges : " << CString12;
if(S2_BadE != 0)
di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")" << "\n";
else
di << "\n";
// warning
di << "\n";
if(hasUnknown)
di << "WARNING: The unexpected test break occurs!" << "\n";
}
} // full output
} // has faulties
return 0;
}

View File

@@ -0,0 +1,179 @@
// File: BOPTest_CurveCommands.cxx
// Created: 10:45:01 2000
// Author: Peter KURNEV
// <pkv@irinox>
#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 <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_Integer i, aNbCurves;
Standard_Real anAppTol, aTolR;
TCollection_AsciiString aNm("c_");
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();
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=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

@@ -0,0 +1,53 @@
-- File: BOPTest_DrawableShape.cdl
-- Created: Thu May 25 14:55:46 2000
-- Author: Peter KURNEV
-- <pkv@irinox>
---Copyright: Matra Datavision 2000
class DrawableShape from BOPTest inherits DrawableShape from DBRep
---Purpose:
uses
Shape from TopoDS,
Color from Draw,
Display from Draw,
Text3D from Draw,
Marker3D from Draw,
CString from Standard,
Pnt from gp
is
Create (S : Shape from TopoDS;
FreeCol : Color from Draw; -- color for free edges
ConnCol : Color from Draw; -- color for shared edges
EdgeCol : Color from Draw; -- color for other edges
IsosCol : Color from Draw; -- color for Isos
size : Real; -- size for infinite isos
nbisos : Integer; -- # of isos on each face
discret : Integer; -- # of points on curves
Text : CString from Standard;
TextColor : Color from Draw
)
returns mutable DrawableShape from BOPTest;
Create (S : Shape from TopoDS;
Text : CString from Standard;
TextColor : Color from Draw
)
returns mutable DrawableShape from BOPTest;
Pnt(me) returns Pnt from gp is private;
DrawOn(me; dis : in out Display from Draw)
is redefined;
fields
myText : Text3D from Draw;
myTextColor : Color from Draw;
end DrawableShape;

View File

@@ -0,0 +1,192 @@
// File: BOPTest_DrawableShape.cxx
// Created: Thu May 25 14:58:58 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest_DrawableShape.ixx>
#include <TopoDS.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Precision.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <Draw_Color.hxx>
#include <Draw_Segment3D.hxx>
#include <gp.hxx>
#include <TopoDS_Shape.hxx>
#include <DBRep_DrawableShape.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Draw_Circle3D.hxx>
#include <gp_Ax1.hxx>
#include <gp_Circ.hxx>
#include <Draw_Color.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
//=======================================================================
//function : BOPTest_DrawableShape::BOPTest_DrawableShape
//purpose :
//=======================================================================
BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape,
const Draw_Color& FreeCol,
const Draw_Color& ConnCol,
const Draw_Color& EdgeCol,
const Draw_Color& IsosCol,
const Standard_Real size,
const Standard_Integer nbisos,
const Standard_Integer discret,
const Standard_CString Text,
const Draw_Color& TextColor)
:
DBRep_DrawableShape(aShape,FreeCol,ConnCol,EdgeCol,IsosCol,size,nbisos,discret)
{
myText = new Draw_Text3D(Pnt(),Text,TextColor);
myTextColor = TextColor;
}
//=======================================================================
//function : BOPTest_DrawableShape::BOPTest_DrawableShape
//purpose :
//=======================================================================
BOPTest_DrawableShape::BOPTest_DrawableShape (const TopoDS_Shape& aShape,
const Standard_CString Text,
const Draw_Color& TextColor)
: DBRep_DrawableShape(
aShape,
Draw_vert,
Draw_jaune,
Draw_rouge,
Draw_bleu,
100., //size
2, //nbIsos
30 //discret
)
{
myText = new Draw_Text3D(Pnt(),Text,TextColor);
myTextColor = TextColor;
}
//=======================================================================
//function : Pnt
//purpose :
//=======================================================================
gp_Pnt BOPTest_DrawableShape::Pnt() const
{
gp_Pnt P(0,0,0);
Standard_Real u, v, u1, u2, v1, v2, p;
TopExp_Explorer ex;
TopoDS_Shape S = Shape();
TopAbs_ShapeEnum T = S.ShapeType();
Standard_Real facpar = 0.;
while ( T == TopAbs_COMPOUND ) {
TopoDS_Iterator ti(S);
if ( ti.More() ) {
S = ti.Value();
T = S.ShapeType();
}
else {
break;
}
}
// si S final = compound --> P = 0 0 0
switch (T)
{
case TopAbs_VERTEX :
P = BRep_Tool::Pnt(TopoDS::Vertex(S));
break;
case TopAbs_EDGE :
{
BRepAdaptor_Curve CU(TopoDS::Edge(S));
u1 = CU.FirstParameter();
u2 = CU.LastParameter();
if (facpar == 0.) facpar = 0.20;
p = u1 + (u2-u1)*facpar;
P = CU.Value(p);
}
break;
case TopAbs_WIRE :
{
TopTools_IndexedMapOfShape aME;
TopExp::MapShapes(S, TopAbs_EDGE, aME);
const TopoDS_Edge& anEdge=TopoDS::Edge(aME(1));
BRepAdaptor_Curve CU(anEdge);
u1 = CU.FirstParameter();
u2 = CU.LastParameter();
if (facpar == 0.) facpar = 0.40;
p = u1 + (u2-u1)*facpar;
P = CU.Value(p);
}
break;
case TopAbs_FACE :
{
BRepAdaptor_Surface SU(TopoDS::Face(S));
BRepTools::UVBounds(TopoDS::Face(S),u1,u2,v1,v2);
//
facpar = .2;
u = u1 + (u2-u1)*facpar;
v = v1 + (v2-v1)*facpar;
P = SU.Value(u,v);
}
break;
case TopAbs_SHELL :
case TopAbs_SOLID :
{
TopTools_IndexedMapOfShape aMF;
TopExp::MapShapes(S, TopAbs_FACE, aMF);
const TopoDS_Face& aF=TopoDS::Face(aMF(1));
BRepAdaptor_Surface SU(TopoDS::Face(aF));
BRepTools::UVBounds(aF,u1,u2,v1,v2);
facpar = .4;
u = u1 + (u2-u1)*facpar;
v = v1 + (v2-v1)*facpar;
P = SU.Value(u,v);
}
break;
default:
break;
}
return P;
}
//=======================================================================
//function : DrawOn
//purpose :
//=======================================================================
void BOPTest_DrawableShape::DrawOn(Draw_Display& dis) const
{
DBRep_DrawableShape::DrawOn(dis);
myText->SetPnt(Pnt());
myText->DrawOn(dis);
}

View File

@@ -0,0 +1,133 @@
// File: BOPTest_EFCommands.cxx
// Created: Mon Feb 26 10:44:30 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
#include <stdio.h>
#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=atoi (a[3]);
}
if (n>=5) {
aTol=atof (a[4]);
}
if (n>=6) {
aDeflection=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

@@ -0,0 +1,905 @@
// File: BOPTest_LowCommands.cxx
// Created: Wed Mar 28 16:46:22 2001
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
#include <stdio.h>
#include <gp_Vec2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.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 <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 <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 <Standard_Static.hxx>
#include <OSD_Chronometer.hxx>
#include <BRepTools.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);
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** );
//modified by NIZNHY-PKV Mon May 29 11:44:24 2006f
static Standard_Integer bhole (Draw_Interpretor& , Standard_Integer , const char** );
static Standard_Integer bxhole (Draw_Interpretor& , Standard_Integer , const char** );
//modified by NIZNHY-PKV Mon May 29 11:44:28 2006t
//=======================================================================
//function : LowCommands
//purpose :
//=======================================================================
void BOPTest::LowCommands(Draw_Interpretor& theCommands)
{
static Standard_Boolean done = Standard_False;
if (done) return;
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);
theCommands.Add("b2dclassify" , "Use >bclassify Face Point2d [Tol2D=Tol(Face)] ",
__FILE__, b2dclassify , g);
//modified by NIZNHY-PKV Mon May 29 11:45:33 2006f
theCommands.Add("bhole" , "Use bhole" , __FILE__, bhole , g);
theCommands.Add("bxhole" , "Use bxhole" , __FILE__, bxhole , g);
//modified by NIZNHY-PKV Mon May 29 11:45:37 2006t
}
//=======================================================================
//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);
//
IntTools_Context aCtx;
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=atof(a[4]);
p2=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)
{
char sbf[512];
if (n < 3) {
sprintf(sbf, " Use >bclassify Solid Point [Tolerance=1.e-7]\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_SOLID) {
sprintf(sbf, " Shape type must be SOLID\n");
aDI<<sbf;
return 1;
}
//
Standard_Real aTol=1.e-7;
TopAbs_State aState = TopAbs_UNKNOWN;
gp_Pnt aP(8., 9., 10.);
DrawTrSurf::GetPoint(a[2], aP);
aTol=1.e-7;
if (n==4) {
aTol=atof(a[3]);
}
//
BRepClass3d_SolidClassifier aSC(aS);
aSC.Perform(aP,aTol);
//
aState = aSC.State();
//
PrintState (aDI, aState);
//
return 0;
}
//
//=======================================================================
//function : b2dclassify
//purpose :
//=======================================================================
Standard_Integer b2dclassify (Draw_Interpretor& aDI,
Standard_Integer n,
const char** a)
{
char sbf[512];
if (n < 3) {
sprintf(sbf, " Use >bclassify Face Point2d [Tol2D=Tol(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_Real aTol;
TopAbs_State aState = TopAbs_UNKNOWN;
gp_Pnt2d aP(8., 9.);
DrawTrSurf::GetPoint2d(a[2], aP);
const TopoDS_Face& aF=TopoDS::Face(aS);
aTol=BRep_Tool::Tolerance(aF);
if (n==4) {
aTol=atof(a[3]);
}
//
BRepClass_FaceClassifier aClassifier;
aClassifier.Perform(aF, aP, aTol);
//
aState = aClassifier.State();
//
PrintState (aDI, aState);
//
return 0;
}
//=======================================================================
//function : PrintState
//purpose :
//=======================================================================
void PrintState (Draw_Interpretor& aDI,
const TopAbs_State& aState)
{
char sbf[512];
TCollection_AsciiString sIN("IN"), sOUT("OUT of"), sON("ON"), sUNKNOWN("UNKNOWN");
//
sprintf(sbf, "The point is "); aDI<<sbf;
//
switch (aState) {
case TopAbs_IN:
sprintf(sbf, sIN.ToCString());
break;
case TopAbs_OUT:
sprintf(sbf, sOUT.ToCString());
break;
case TopAbs_ON:
sprintf(sbf, sON.ToCString());
break;
case TopAbs_UNKNOWN:
sprintf(sbf, sUNKNOWN.ToCString());
break;
default:
sprintf(sbf, sUNKNOWN.ToCString());
break;
}
aDI<<sbf;
//
sprintf(sbf, " shape\n");
aDI<<sbf;
}
//
//modified by NIZNHY-PKV Mon May 29 11:40:29 2006f
//=======================================================================
//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=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;
}
//modified by NIZNHY-PKV Mon May 29 11:40:31 2006t

View File

@@ -0,0 +1,240 @@
// File: BOPTest_ProjectionCommands.cxx
// Created: Thu May 18 10:45:01 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
#include <stdio.h>
#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=atof (a[3]);
l1=atof (a[4]);
f2=atof (a[5]);
l2=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=atoi (a[3]);
}
if (n>=5) {
aTol=atof (a[4]);
}
if (n>=6) {
aDeflection=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,6 @@
// File: BOPTest_TSTCommands.cxx
// Created: 10:45:01 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>

View File

@@ -0,0 +1,558 @@
// File: BOPTest_TolerCommands.cxx
// Created: 10:45:01 2000
// Author: Peter KURNEV
// <pkv@irinox>
#include <BOPTest.ixx>
//
#include <stdio.h>
//
#include <TCollection_AsciiString.hxx>
#include <TColStd_IndexedMapOfTransient.hxx>
//
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
//
#include <DBRep.hxx>
//
#include <gp_Pnt2d.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Surface.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_ListOfCurveRepresentation.hxx>
#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
#include <BRep_CurveRepresentation.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRep_TFace.hxx>
#include <TopLoc_Location.hxx>
#include <BRepLib.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
static
Standard_Integer breducetolerance (Draw_Interpretor&, Standard_Integer, const char** );
static
Standard_Integer btolx (Draw_Interpretor&, Standard_Integer, const char** );
static
Standard_Integer bopaddpcs (Draw_Interpretor&, Standard_Integer, const char** );
//
static
void ProcessVertex(const TopoDS_Vertex&,
const TopTools_ListOfShape&,
const TopTools_ListOfShape&);
static
void ProcessEdge(const TopoDS_Edge&, const Standard_Real);
static
void ReduceVertexTolerance (const TopoDS_Shape&);
static
void ReduceFaceTolerance (const TopoDS_Shape&);
static
void ReduceEdgeTolerance (const TopoDS_Shape&, const Standard_Real);
//=======================================================================
//function : TolerCommands
//purpose :
//=======================================================================
void BOPTest::TolerCommands(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("breducetolerance" , "Use >breducetolerance Shape [maxTol=0.01]", __FILE__, breducetolerance, g);
theCommands.Add("btolx" , "Use >btolx Shape [minTol=1.e-7]", __FILE__, btolx, g);
theCommands.Add("bopaddpcs" , "Use >bopaddpcs Shape" , __FILE__, bopaddpcs, g);
}
//=======================================================================
//function : btolx
//purpose :
//=======================================================================
Standard_Integer btolx(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<2) {
di << " Use >btolx Shape [minTol=1.e-7]\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
//
Standard_Real aTolEMin=1.e-7;
if (n==3) {
aTolEMin=atof(a[2]);
}
//
// Edge Tolerances
ReduceEdgeTolerance(aS, aTolEMin);
//
// Face Tolerances
ReduceFaceTolerance(aS);
//
// Vertex Tolerances
ReduceVertexTolerance(aS);
//
BRepLib::SameParameter(aS, 1.e-7, Standard_True);
//
DBRep::Set (a[1], aS);
return 0;
}
//=======================================================================
//function : ReduceEdgeTolerance
//purpose :
//=======================================================================
void ReduceEdgeTolerance (const TopoDS_Shape& aS, const Standard_Real aTolTreshold)
{
Standard_Integer i, aNbE;
TopTools_IndexedMapOfShape aEMap;
//
TopExp::MapShapes(aS, TopAbs_EDGE, aEMap);
//
aNbE=aEMap.Extent();
for (i=1; i<=aNbE; i++) {
const TopoDS_Edge& aE= TopoDS::Edge(aEMap(i));
ProcessEdge(aE, aTolTreshold);
}
}
//=======================================================================
//function : ReduceFaceTolerance
//purpose :
//=======================================================================
void ReduceFaceTolerance (const TopoDS_Shape& aS)
{
Standard_Integer i, j, aNbF, aNbE;
Standard_Real aTolE, aTolx, aTolEMin;
TopTools_IndexedMapOfShape aFMap, aEMap;
//
aTolEMin=1.e-7;
//
TopExp::MapShapes(aS, TopAbs_FACE, aFMap);
aNbF=aFMap.Extent();
for (i=1; i<=aNbF; i++) {
aTolx=1.e6;
const TopoDS_Face& aF= TopoDS::Face(aFMap(i));
Handle(BRep_TFace)& aTF = *((Handle(BRep_TFace)*)&aF.TShape());
//
TopExp::MapShapes(aF, TopAbs_EDGE, aEMap);
aNbE=aEMap.Extent();
for (j=1; j<=aNbE; ++j) {
const TopoDS_Edge& aE= TopoDS::Edge(aEMap(j));
aTolE =BRep_Tool::Tolerance(aE);
if (aTolE<aTolx) {
aTolx=aTolE;
}
}
aTolE=(aTolx>aTolEMin) ? aTolx : aTolEMin;
aTF->Tolerance(aTolE);
}
}
//=======================================================================
//function : ReduceVertexTolerance
//purpose :
//=======================================================================
void ReduceVertexTolerance (const TopoDS_Shape& aS)
{
Standard_Integer i, aNbV;
TopTools_IndexedDataMapOfShapeListOfShape aVEMap, aVFMap;
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aVFMap);
aNbV=aVEMap.Extent();
for (i=1; i<=aNbV; i++) {
const TopoDS_Vertex& aV= TopoDS::Vertex(aVEMap.FindKey(i));
const TopTools_ListOfShape& aLE=aVEMap(i);
const TopTools_ListOfShape& aLF=aVFMap.FindFromKey(aV);
ProcessVertex(aV, aLE, aLF);
}
}
//=======================================================================
//function : ProcessEdge
//purpose :
//=======================================================================
void ProcessEdge(const TopoDS_Edge& aE, const Standard_Real aTolTreshold)
{
Standard_Integer i, aNb=23;
Standard_Real aTolE, aD2, aTolMax2, aT1, aT2, aT, dT;
gp_Pnt aPC3D, aP3D;
gp_Pnt2d aPC2D;
//TopTools_ListIteratorOfListOfShape anIt;// Wng in Gcc 3.0
BRep_ListIteratorOfListOfCurveRepresentation itcr;
//
Handle(Geom_Curve) aC3D=BRep_Tool::Curve(aE, aT1, aT2);
if (aC3D.IsNull()) {
return;
}
//
dT=(aT2-aT1)/aNb;
//
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape());
const TopLoc_Location& Eloc = aE.Location();
//
aTolMax2=-1.e6;
const BRep_ListOfCurveRepresentation& aLCR=TE->Curves();
//
itcr.Initialize(aLCR);
for (; itcr.More(); itcr.Next()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
const TopLoc_Location& loc = cr->Location();
TopLoc_Location L = (Eloc * loc);//.Predivided(aV.Location());
//
// 3D-Curve
if (cr->IsCurve3D()) {
continue;
}
//
// 2D-Curve
else if (cr->IsCurveOnSurface()) {
const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
if (aC2D.IsNull()) {
continue;
}
// Surface
const Handle(Geom_Surface)& aS=cr->Surface();
//
// 2D-point treatment
for (i=0; i<=aNb; ++i) {
aT=aT1+i*dT;
if (i==aNb) {
aT=aT2;
}
aPC3D=aC3D->Value(aT);
aPC2D=aC2D->Value(aT);
aS->D0(aPC2D.X(), aPC2D.Y(), aP3D);
aP3D.Transform(L.Transformation());
aD2=aPC3D.SquareDistance(aP3D);
if (aD2 > aTolMax2) {
aTolMax2=aD2;
}
}
} //if (cr->IsCurveOnSurface())
}//for (; itcr.More(); itcr.Next())
//#########################################################
//
if (aTolMax2<0.){
return;
}
//
aTolE =BRep_Tool::Tolerance(aE);
//
aTolMax2=sqrt(aTolMax2);
//printf(" aTolMax=%15.10lf, aTolWas=%15.10lf\n", aTolMax2, aTolE);
Standard_Real aTolSet;
aTolSet=(aTolMax2>aTolTreshold) ? aTolMax2 : aTolTreshold;
TE->Tolerance(aTolSet);
}
//=======================================================================
//function : ProcessVertex
//purpose :
//=======================================================================
void ProcessVertex(const TopoDS_Vertex& aV,
const TopTools_ListOfShape& aLE,
const TopTools_ListOfShape& aLF)
{
Standard_Real aTol, aTol2, aD2, aTolMax2, aTolE, aParam;
gp_Pnt aPC3D;
gp_Pnt2d aPC2D;
TopAbs_Orientation anOrV;
TopTools_ListIteratorOfListOfShape anIt;
TopTools_MapOfShape aProcessedEdges;
TopExp_Explorer aVExp;
BRep_ListIteratorOfListOfCurveRepresentation itcr;
//
aTolMax2=-1.e6;
//
Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &aV.TShape());
const gp_Pnt& aPV3D = TV->Pnt();
aTol =BRep_Tool::Tolerance(aV);
aTol2=aTol*aTol;
//
anIt.Initialize(aLE);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
//
if (aProcessedEdges.Contains(aE)) {
continue;
}
aProcessedEdges.Add(aE);
//
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape());
const TopLoc_Location& Eloc = aE.Location();
//
aVExp.Init(aE, TopAbs_VERTEX);
for (; aVExp.More(); aVExp.Next()) {
const TopoDS_Vertex& aVx=TopoDS::Vertex(aVExp.Current());
//
if (!aVx.IsSame(aV)) {
continue;
}
//
anOrV=aVx.Orientation();
if (!(anOrV==TopAbs_FORWARD || anOrV==TopAbs_REVERSED)) {
continue;
}
//
const BRep_ListOfCurveRepresentation& aLCR=TE->Curves();
itcr.Initialize(aLCR);
for (; itcr.More(); itcr.Next()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
const TopLoc_Location& loc = cr->Location();
TopLoc_Location L = (Eloc * loc).Predivided(aV.Location());
//
// 3D-Curve
if (cr->IsCurve3D()) {
const Handle(Geom_Curve)& aC3D = cr->Curve3D();
//
if (aC3D.IsNull()) {
continue;
}
// 3D-point treatment
aParam=BRep_Tool::Parameter(aVx, aE);
aPC3D= aC3D->Value(aParam);
aPC3D.Transform(L.Transformation());
aD2=aPV3D.SquareDistance(aPC3D);
if (aD2 > aTolMax2) {
aTolMax2=aD2;
}
//
}//if (cr->IsCurve3D())
//
// 2D-Curve
else if (cr->IsCurveOnSurface()) {
const Handle(Geom2d_Curve)& aC2D = cr->PCurve();
if (aC2D.IsNull()) {
continue;
}
// Surface
const Handle(Geom_Surface)& aS=cr->Surface();
//
// 2D-point treatment
aParam=BRep_Tool::Parameter(aVx, aE, aS, L);
aPC2D=aC2D->Value(aParam);
aS->D0(aPC2D.X(), aPC2D.Y(), aPC3D);
aPC3D.Transform(L.Transformation());
aD2=aPV3D.SquareDistance(aPC3D);
if (aD2 > aTolMax2) {
aTolMax2=aD2;
}
} //if (cr->IsCurveOnSurface())
}//for (; itcr.More(); itcr.Next())
}//for (; aVExp.More(); aVExp.Next())
}//for (; anIt.More(); anIt.Next())
//#########################################################
//
// Reducing
if (aTolMax2<0.){
return;
}
//
aTolMax2=sqrt(aTolMax2);
if (aTolMax2>aTol) {
return;
}
//
aProcessedEdges.Clear();
anIt.Initialize(aLE);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value());
if (aProcessedEdges.Contains(aE)) {
continue;
}
aProcessedEdges.Add(aE);
aTolE =BRep_Tool::Tolerance(aE);
if (aTolMax2 < aTolE) {
aTolMax2=aTolE;
}
}
//
aProcessedEdges.Clear();
anIt.Initialize(aLF);
for (; anIt.More(); anIt.Next()) {
const TopoDS_Face& aF=TopoDS::Face(anIt.Value());
if (aProcessedEdges.Contains(aF)) {
continue;
}
aProcessedEdges.Add(aF);
aTolE =BRep_Tool::Tolerance(aF);
if (aTolMax2 < aTolE) {
aTolMax2=aTolE;
}
}
//
if (aTolMax2>aTol) {
return;
}
//
// Update Tolerance
TV->Tolerance(aTolMax2);
}
//=======================================================================
//function : breducetolerance
//purpose :
//=======================================================================
Standard_Integer breducetolerance(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n<2) {
di << " Use >bupdatetolerance Shape\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
ReduceVertexTolerance(aS);
DBRep::Set (a[1], aS);
return 0;
}
//
//
static
void PreparePCurves(const TopoDS_Shape& aShape, Draw_Interpretor& di);
//=======================================================================
//function : bopaddpcs
//purpose : Some Edgesdo not contain P-Curveson Faces to which they belong to.
// These faces usually based on Geom_Plane surface.
// To prevent sophisticated treatment the Command "bopaddpcs:
// adds P-Curves for the edges .
//=======================================================================
Standard_Integer bopaddpcs(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n<2) {
di << " Use >bopaddpcs Shape\n";
return 1;
}
TopoDS_Shape aS = DBRep::Get(a[1]);
if (aS.IsNull()) {
di << " Null shape is not allowed \n";
return 1;
}
//
PreparePCurves(aS, di);
//
DBRep::Set (a[1], aS);
return 0;
}
//=======================================================================
//function : PreparePCurves
//purpose :
//=======================================================================
void PreparePCurves(const TopoDS_Shape& aShape, Draw_Interpretor& di)
{
Standard_Integer i, aNbE;
Standard_Real aTolE, aT1, aT2;
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
TopLoc_Location aLoc;
Handle(Geom_Curve) aC3D;
Handle(Geom2d_Curve) aC2D;
BRep_Builder aBB;
//
TopExp::MapShapesAndAncestors (aShape, TopAbs_EDGE, TopAbs_FACE, aEFMap);
//
aNbE=aEFMap.Extent();
for (i=1; i<=aNbE; ++i) {
const TopoDS_Edge& aE=TopoDS::Edge(aEFMap.FindKey(i));
//
if (BRep_Tool::Degenerated(aE)) {
continue;
}
//
aC3D=BRep_Tool::Curve(aE, aT1, aT2);
if (aC3D.IsNull()) {
continue;
}
aTolE=BRep_Tool::Tolerance(aE);
//
const TopTools_ListOfShape& aLF=aEFMap(i);
TopTools_ListIteratorOfListOfShape aFIt(aLF);
for (; aFIt.More(); aFIt.Next()) {
const TopoDS_Face& aF=TopoDS::Face(aFIt.Value());
//
// Map of surfaces on which the edge lays .
TColStd_IndexedMapOfTransient aSCRMap;
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&aE.TShape());
const BRep_ListOfCurveRepresentation& aLCR=TE->Curves();
BRep_ListIteratorOfListOfCurveRepresentation itcr;
itcr.Initialize(aLCR);
for (; itcr.More(); itcr.Next()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
//
if (cr->IsCurveOnSurface()) {
const Handle(Geom_Surface)& aSCR=cr->Surface();
aSCRMap.Add(aSCR);
}
//
}
//
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF, aLoc);
if (!aSCRMap.Contains(aS)) {
// try to obtain 2D curve
aC2D=BRep_Tool::CurveOnSurface(aE, aS, aLoc, aT1, aT2);
if (aC2D.IsNull()) {
di << " Warning: Can not obtain P-Curve\n";
continue;
}
else {
aBB.UpdateEdge(aE, aC2D, aF, aTolE);
}
}
}
}
}

View File

@@ -0,0 +1,213 @@
// File: BOPTest_WSplitCommands.cxx
// Created: 10:45:01 2000
// Author: Peter KURNEV
// <pkv@irinox>
#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;
}

10
src/BOPTest/FILES Executable file
View File

@@ -0,0 +1,10 @@
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_CheckCommands.cxx