diff --git a/src/BOPTest/BOPTest.cdl b/src/BOPTest/BOPTest.cdl index 8121dc3bc3..de542c6942 100644 --- a/src/BOPTest/BOPTest.cdl +++ b/src/BOPTest/BOPTest.cdl @@ -41,6 +41,8 @@ is PartitionCommands (aDI:out Interpretor from Draw); APICommands (aDI:out Interpretor from Draw); OptionCommands (aDI:out Interpretor from Draw); + HistoryCommands (aDI:out Interpretor from Draw); + Factory (aDI:out Interpretor from Draw); end BOPTest; diff --git a/src/BOPTest/BOPTest.cxx b/src/BOPTest/BOPTest.cxx index b986f7bb0e..93dc10265b 100644 --- a/src/BOPTest/BOPTest.cxx +++ b/src/BOPTest/BOPTest.cxx @@ -38,8 +38,9 @@ void BOPTest::AllCommands(Draw_Interpretor& theCommands) BOPTest::TolerCommands (theCommands); BOPTest::ObjCommands (theCommands); BOPTest::PartitionCommands (theCommands); - BOPTest::APICommands (theCommands); - BOPTest::OptionCommands (theCommands); + BOPTest::APICommands (theCommands); + BOPTest::OptionCommands (theCommands); + BOPTest::HistoryCommands (theCommands); } //======================================================================= //function : Factory diff --git a/src/BOPTest/BOPTest_HistoryCommands.cxx b/src/BOPTest/BOPTest_HistoryCommands.cxx new file mode 100644 index 0000000000..131e215ee5 --- /dev/null +++ b/src/BOPTest/BOPTest_HistoryCommands.cxx @@ -0,0 +1,184 @@ +// Created by: Eugeny MALTCHIKOV +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +// +#include +#include +// +#include +// +#include +// +#include +// +#include +#include +// +#include +#include + +// +static Standard_Integer bmodified (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bgenerated (Draw_Interpretor&, Standard_Integer, const char**); +static Standard_Integer bisdeleted (Draw_Interpretor&, Standard_Integer, const char**); + +//======================================================================= +//function : HistoryCommands +//purpose : +//======================================================================= +void BOPTest::HistoryCommands(Draw_Interpretor& theCommands) +{ + static Standard_Boolean done = Standard_False; + if (done) return; + done = Standard_True; + // Chapter's name + const char* g = "BOPTest commands"; + // Commands + theCommands.Add("bmodified" , "Use: bmodified rc shape", __FILE__, bmodified , g); + theCommands.Add("bgenerated", "Use: bgenerated rc shape", __FILE__, bgenerated, g); + theCommands.Add("bisdeleted", "Use: bisdeleted shape" , __FILE__, bisdeleted, g); +} + +//======================================================================= +//function : bmodified +//purpose : +//======================================================================= +Standard_Integer bmodified(Draw_Interpretor& di, + Standard_Integer n, + const char** a) +{ + if (n < 3) { + di << "Use: bmodified rc shape\n"; + return 1; + } + // + TopoDS_Shape aS = DBRep::Get(a[2]); + if (aS.IsNull()) { + di << "Null shape\n"; + return 1; + } + // + TopAbs_ShapeEnum aType = aS.ShapeType(); + if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE || + aType==TopAbs_FACE || aType==TopAbs_SOLID)) { + di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n"; + return 1; + } + // + BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder(); + const TopTools_ListOfShape& aLS = aBuilder.Modified(aS); + // + if (aLS.IsEmpty()) { + di << "The shape has not been modified\n"; + return 0; + } + // + BRep_Builder aBB; + TopoDS_Compound aRes; + // + aBB.MakeCompound(aRes); + TopTools_ListIteratorOfListOfShape aIt(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS = aIt.Value(); + aBB.Add(aRes, aS); + } + // + DBRep::Set(a[1], aRes); + // + return 0; +} + +//======================================================================= +//function : bgenerated +//purpose : +//======================================================================= +Standard_Integer bgenerated(Draw_Interpretor& di, + Standard_Integer n, + const char** a) +{ + if (n < 3) { + di << "Use: bgenerated rc shape\n"; + return 1; + } + // + TopoDS_Shape aS = DBRep::Get(a[2]); + if (aS.IsNull()) { + di << "Null shape\n"; + return 1; + } + // + TopAbs_ShapeEnum aType = aS.ShapeType(); + if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE || + aType==TopAbs_FACE || aType==TopAbs_SOLID)) { + di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n"; + return 1; + } + // + BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder(); + const TopTools_ListOfShape& aLS = aBuilder.Generated(aS); + // + if (aLS.IsEmpty()) { + di << "No shapes were generated from the shape\n"; + return 0; + } + // + BRep_Builder aBB; + TopoDS_Compound aRes; + // + aBB.MakeCompound(aRes); + TopTools_ListIteratorOfListOfShape aIt(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS = aIt.Value(); + aBB.Add(aRes, aS); + } + // + DBRep::Set(a[1], aRes); + // + return 0; +} + +//======================================================================= +//function : bisdeleted +//purpose : +//======================================================================= +Standard_Integer bisdeleted(Draw_Interpretor& di, + Standard_Integer n, + const char** a) +{ + if (n < 2) { + di << "Use: bisdeleted shape\n"; + return 1; + } + // + TopoDS_Shape aS = DBRep::Get(a[1]); + if (aS.IsNull()) { + di << "Null shape\n"; + return 1; + } + // + TopAbs_ShapeEnum aType = aS.ShapeType(); + if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE || + aType==TopAbs_FACE || aType==TopAbs_SOLID)) { + di << "The shape must be one of the following types: VERTEX, EDGE, FACE or SOLID\n"; + return 1; + } + // + BOPAlgo_Builder& aBuilder = BOPTest_Objects::Builder(); + Standard_Boolean isDeleted = aBuilder.IsDeleted(aS); + // + di << (isDeleted ? "Deleted" : "Not deleted") << "\n"; + // + return 0; +} diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index 82bf7f7ccb..1eb182f07e 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -162,6 +162,7 @@ Standard_Integer bbuild(Draw_Interpretor& di, // BOPAlgo_PaveFiller& aPF=BOPTest_Objects::PaveFiller(); // + BOPTest_Objects::SetBuilderDefault(); BOPAlgo_Builder& aBuilder=BOPTest_Objects::Builder(); aBuilder.Clear(); // @@ -324,6 +325,8 @@ Standard_Integer bbop(Draw_Interpretor& di, return 0; } // + BOPTest_Objects::SetBuilder(pBuilder); + // DBRep::Set(a[1], aR); return 0; } diff --git a/src/BOPTest/FILES b/src/BOPTest/FILES index fad6632898..a6afe5e37f 100755 --- a/src/BOPTest/FILES +++ b/src/BOPTest/FILES @@ -6,3 +6,6 @@ BOPTest_TolerCommands.cxx BOPTest_ObjCommands.cxx BOPTest_APICommands.cxx BOPTest_OptionCommands.cxx +BOPTest_PartitionCommands.cxx +BOPTest_TolerCommands.cxx +BOPTest_HistoryCommands.cxx \ No newline at end of file diff --git a/tests/bugs/modalg_6/bug26393 b/tests/bugs/modalg_6/bug26393 new file mode 100644 index 0000000000..9c731bedb4 --- /dev/null +++ b/tests/bugs/modalg_6/bug26393 @@ -0,0 +1,102 @@ +puts "========" +puts "OCC26393" +puts "========" +puts "" +################################################################# +# Add draw commands to evaluate history of modifications of BOP +################################################################# + +restore [locate_data_file OCC26393-w.brep] w +restore [locate_data_file OCC26393-v1.brep] v0 +restore [locate_data_file OCC26393-v2.brep] v1 + +bclearobjects +bcleartools +baddobjects w +baddtools v0 v1 +bfillds +bbuild r + +set bug_info [bmodified v0m v0] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "The shape has not been modified"} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work." +} + +set bug_info [bmodified v1m v1] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "The shape has not been modified"} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work." +} + +set bug_info [bisdeleted v0] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +set bug_info [bisdeleted v1] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +explode w e + +set bug_info [bmodified w1m w_1] +if {$bug_info != ""} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work correctly." +} + +set bug_info [bisdeleted w_1] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +set bug_info [bmodified w2m w_2] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "The shape has not been modified"} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work." +} + +set bug_info [bisdeleted w_2] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +set bug_info [bmodified w3m w_3] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "The shape has not been modified"} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work." +} + +set bug_info [bisdeleted w_3] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +set bug_info [bmodified w4m w_4] +if {$bug_info != ""} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work correctly." +} + +set bug_info [bisdeleted w_4] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +} + +set bug_info [bmodified w5m w_5] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "The shape has not been modified"} { + puts "ERROR: OCC26393 is reproduced. Command bmodified does not work." +} + +set bug_info [bisdeleted w_5] +set bug_info [string trim [string range $bug_info 0 [expr {[string first "\n" $bug_info] - 1}]]] +if {$bug_info != "Not deleted"} { + puts "ERROR: OCC26393 is reproduced. Command bisdeleted does not work." +}