From: dbv Date: Fri, 20 Jul 2018 17:15:58 +0000 (+0300) Subject: Issue #2561: CEA 2018-1 Cut X-Git-Tag: SHAPER_V9_1_0RC1~83 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ab78c74f12a03da4f3b402a67f0088b3f4c6a0d;p=modules%2Fshaper.git Issue #2561: CEA 2018-1 Cut Cut now allows to select any type of shape --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 9d466ae67..e111b5906 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -68,6 +68,7 @@ SET(PROJECT_SOURCES FeaturesPlugin_Rotation.cpp FeaturesPlugin_Translation.cpp FeaturesPlugin_Boolean.cpp + FeaturesPlugin_BooleanCut.cpp FeaturesPlugin_Intersection.cpp FeaturesPlugin_Partition.cpp FeaturesPlugin_Pipe.cpp @@ -272,4 +273,23 @@ ADD_UNIT_TESTS(TestExtrusion.py Test2495.py Test2514.py Test2520.py + TestBooleanCut_CompSolid_CompSolid.py + TestBooleanCut_CompSolidCompound_CompSolidCompound.py + TestBooleanCut_Edge_Edge.py + TestBooleanCut_Edge_Face.py + TestBooleanCut_EdgeCompound_EdgeCompound.py + TestBooleanCut_EdgeCompound_Solid.py + TestBooleanCut_Face_Face.py + TestBooleanCut_Face_Solid.py + TestBooleanCut_FaceCompound_FaceCompound.py + TestBooleanCut_Shell_Shell.py + TestBooleanCut_ShellCompound_ShellCompound.py + TestBooleanCut_Solid_Solid.py + TestBooleanCut_SolidCompound_SolidCompound.py + TestBooleanCut_Vertex_Vertex.py + TestBooleanCut_VertexCompound_Solid.py + TestBooleanCut_VertexCompound_VertexCompound.py + TestBooleanCut_Wire_Face.py + TestBooleanCut_Wire_Wire.py + TestBooleanCut_WireCompound_WireCompound.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp new file mode 100644 index 000000000..eebff3615 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp @@ -0,0 +1,393 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#include "FeaturesPlugin_BooleanCut.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +//================================================================================================== +FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut() +: FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT) +{ +} + +//================================================================================================== +void FeaturesPlugin_BooleanCut::execute() +{ + ListOfShape anObjects, aTools; + std::map, ListOfShape> aCompSolidsObjects; + std::map, ListOfShape> aCompoundObjects; + + // Getting objects. + AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECT_LIST_ID()); + for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { + AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex); + std::shared_ptr anObject = anObjectAttr->value(); + if(!anObject.get()) { + return; + } + ResultPtr aContext = anObjectAttr->context(); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + if (aResCompSolidPtr.get()) + { + std::shared_ptr aContextShape = aResCompSolidPtr->shape(); + GeomAPI_Shape::ShapeType aShapeType = aResCompSolidPtr->shape()->shapeType(); + std::map, ListOfShape>& aMap = + aShapeType == GeomAPI_Shape::COMPSOLID ? aCompSolidsObjects : aCompoundObjects; + + std::map, ListOfShape>::iterator + anIt = aMap.begin(); + for (; anIt != aMap.end(); anIt++) { + if (anIt->first->isEqual(aContextShape)) { + aMap[anIt->first].push_back(anObject); + break; + } + } + if (anIt == aMap.end()) { + aMap[aContextShape].push_back(anObject); + } + + } else { + anObjects.push_back(anObject); + } + } + + // Getting tools. + AttributeSelectionListPtr aToolsSelList = selectionList(TOOL_LIST_ID()); + for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) { + AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex); + GeomShapePtr aTool = aToolAttr->value(); + if(!aTool.get()) { + return; + } + aTools.push_back(aTool); + } + + int aResultIndex = 0; + + if((anObjects.empty() && aCompSolidsObjects.empty() && aCompoundObjects.empty()) + || aTools.empty()) { + std::string aFeatureError = "Error: Not enough objects for boolean operation."; + setError(aFeatureError); + return; + } + + // For solids cut each object with all tools. + for(ListOfShape::iterator anObjectsIt = anObjects.begin(); + anObjectsIt != anObjects.end(); + ++anObjectsIt) { + std::shared_ptr anObject = *anObjectsIt; + GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aCutAlgo( + new GeomAlgoAPI_Boolean(anObject, + aTools, + GeomAlgoAPI_Boolean::BOOL_CUT)); + GeomShapePtr aResShape = aCutAlgo->shape(); + + // Checking that the algorithm worked properly. + if (!aCutAlgo->isDone()) { + static const std::string aFeatureError = "Error: Boolean algorithm failed."; + setError(aFeatureError); + return; + } + if(aResShape->isNull()) { + static const std::string aShapeError = "Error: Resulting shape is Null."; + setError(aShapeError); + return; + } + if (!aCutAlgo->isValid()) { + std::string aFeatureError = "Error: Resulting shape is not valid."; + setError(aFeatureError); + return; + } + + aMakeShapeList.appendAlgo(aCutAlgo); + + GeomAPI_ShapeIterator aShapeIt(aResShape); + if (aShapeIt.more() || aResShape->shapeType() == GeomAPI_Shape::VERTEX) + { + std::shared_ptr aResultBody = + document()->createBody(data(), aResultIndex); + + loadNamingDS(aResultBody, anObject, aTools, aResShape, + aMakeShapeList, *(aCutAlgo->mapOfSubShapes()), + false); + setResult(aResultBody, aResultIndex); + aResultIndex++; + } + } + + // Compsolids handling + for (std::map, ListOfShape>::iterator + anIt = aCompSolidsObjects.begin(); + anIt != aCompSolidsObjects.end(); + ++anIt) + { + std::shared_ptr aCompSolid = anIt->first; + ListOfShape& aUsedInOperationSolids = anIt->second; + + // Collecting solids from compsolids which will not be modified in boolean operation. + ListOfShape aNotUsedSolids; + for(GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); + anExp.more(); + anExp.next()) + { + std::shared_ptr aSolidInCompSolid = anExp.current(); + ListOfShape::iterator aUsedIt = aUsedInOperationSolids.begin(); + for (; aUsedIt != aUsedInOperationSolids.end(); aUsedIt++) { + if (aSolidInCompSolid->isEqual(*aUsedIt)) { + break; + } + } + if (aUsedIt == aUsedInOperationSolids.end()) { + aNotUsedSolids.push_back(aSolidInCompSolid); + } + } + + GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aCutAlgo( + new GeomAlgoAPI_Boolean(aUsedInOperationSolids, + aTools, + GeomAlgoAPI_Boolean::BOOL_CUT)); + + // Checking that the algorithm worked properly. + if (!aCutAlgo->isDone()) { + static const std::string aFeatureError = "Error: Boolean algorithm failed."; + setError(aFeatureError); + return; + } + if (aCutAlgo->shape()->isNull()) { + static const std::string aShapeError = "Error: Resulting shape is Null."; + setError(aShapeError); + return; + } + if (!aCutAlgo->isValid()) { + std::string aFeatureError = "Error: Resulting shape is not valid."; + setError(aFeatureError); + return; + } + + aMakeShapeList.appendAlgo(aCutAlgo); + GeomAPI_DataMapOfShapeShape aMapOfShapes; + aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + GeomShapePtr aResultShape = aCutAlgo->shape(); + + // Add result to not used solids from compsolid. + if(!aNotUsedSolids.empty()) { + ListOfShape aShapesToAdd = aNotUsedSolids; + aShapesToAdd.push_back(aCutAlgo->shape()); + std::shared_ptr aFillerAlgo( + new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); + if(!aFillerAlgo->isDone()) { + std::string aFeatureError = "Error: PaveFiller algorithm failed."; + setError(aFeatureError); + return; + } + + aMakeShapeList.appendAlgo(aFillerAlgo); + aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aResultShape = aFillerAlgo->shape(); + } + + GeomAPI_ShapeIterator aShapeIt(aResultShape); + if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) + { + std::shared_ptr aResultBody = + document()->createBody(data(), aResultIndex); + + loadNamingDS(aResultBody, + aCompSolid, + aTools, + aResultShape, + aMakeShapeList, + aMapOfShapes, + false); + setResult(aResultBody, aResultIndex); + aResultIndex++; + } + } + + // Compounds handling + for (std::map, ListOfShape>::iterator + anIt = aCompoundObjects.begin(); + anIt != aCompoundObjects.end(); + ++anIt) + { + std::shared_ptr aCompound = anIt->first; + ListOfShape& aUsedInOperationShapes = anIt->second; + + // Collecting shapes from compound which will not be modified in boolean operation. + ListOfShape aNotUsedShapes; + for (GeomAPI_ShapeIterator aCompIt(aCompound); + aCompIt.more(); + aCompIt.next()) + { + std::shared_ptr aShapeInCompound = aCompIt.current(); + ListOfShape::iterator aUsedIt = aUsedInOperationShapes.begin(); + for (; aUsedIt != aUsedInOperationShapes.end(); aUsedIt++) { + if (aShapeInCompound->isEqual(*aUsedIt)) { + break; + } + } + if (aUsedIt == aUsedInOperationShapes.end()) { + aNotUsedShapes.push_back(aShapeInCompound); + } + } + + GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aCutAlgo( + new GeomAlgoAPI_Boolean(aUsedInOperationShapes, + aTools, + GeomAlgoAPI_Boolean::BOOL_CUT)); + + // Checking that the algorithm worked properly. + if (!aCutAlgo->isDone()) { + static const std::string aFeatureError = "Error: Boolean algorithm failed."; + setError(aFeatureError); + return; + } + if (aCutAlgo->shape()->isNull()) { + static const std::string aShapeError = "Error: Resulting shape is Null."; + setError(aShapeError); + return; + } + if (!aCutAlgo->isValid()) { + std::string aFeatureError = "Error: Resulting shape is not valid."; + setError(aFeatureError); + return; + } + + aMakeShapeList.appendAlgo(aCutAlgo); + GeomAPI_DataMapOfShapeShape aMapOfShapes; + aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + GeomShapePtr aResultShape = aCutAlgo->shape(); + + // Add result to not used shape from compound. + if (!aNotUsedShapes.empty()) { + ListOfShape aShapesForResult = aNotUsedShapes; + if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { + for (GeomAPI_ShapeIterator aResultIt(aResultShape); aResultIt.more(); aResultIt.next()) { + aShapesForResult.push_back(aResultIt.current()); + } + } else { + aShapesForResult.push_back(aResultShape); + } + + if (aShapesForResult.size() == 1) { + aResultShape = aShapesForResult.front(); + } else { + aResultShape = GeomAlgoAPI_CompoundBuilder::compound(aShapesForResult); + } + } + + GeomAPI_ShapeIterator aShapeIt(aResultShape); + if (aShapeIt.more() || aResultShape->shapeType() == GeomAPI_Shape::VERTEX) { + std::shared_ptr aResultBody = + document()->createBody(data(), aResultIndex); + + loadNamingDS(aResultBody, + aCompound, + aTools, + aResultShape, + aMakeShapeList, + aMapOfShapes, + false); + setResult(aResultBody, aResultIndex); + aResultIndex++; + } + } + + // remove the rest results if there were produced in the previous pass + removeResults(aResultIndex); +} + +//================================================================================================== +void FeaturesPlugin_BooleanCut::loadNamingDS(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomShapePtr theResultShape, + GeomAlgoAPI_MakeShape& theMakeShape, + GeomAPI_DataMapOfShapeShape& theMapOfShapes, + const bool theIsStoreAsGenerated) +{ + //load result + if(theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape, false); + } else { + const int aModifyVTag = 1; + const int aModifyETag = 2; + const int aModifyFTag = 3; + const int aDeletedTag = 4; + /// sub solids will be placed at labels 5, 6, etc. if result is compound of solids + const int aSubsolidsTag = 5; + + theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); + + const std::string aModVName = "Modified_Vertex"; + const std::string aModEName = "Modified_Edge"; + const std::string aModFName = "Modified_Face"; + + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, + aModifyVTag, aModVName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, + aModifyETag, aModEName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, + aModifyFTag, aModFName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + + theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, + GeomAPI_Shape::VERTEX, aDeletedTag); + theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, + GeomAPI_Shape::EDGE, aDeletedTag); + theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, + GeomAPI_Shape::FACE, aDeletedTag); + + for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) + { + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, + aModifyVTag, aModVName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, + aModifyETag, aModEName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + + theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, + aModifyFTag, aModFName, theMapOfShapes, false, + theIsStoreAsGenerated, true); + + theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, aDeletedTag); + theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, aDeletedTag); + theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); + } + } +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h index f53afa973..4ae4463eb 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h @@ -23,10 +23,13 @@ #include "FeaturesPlugin_Boolean.h" +#include +#include + /// \class FeaturesPlugin_BooleanCut /// \ingroup Plugins /// \brief Feature for applying of Boolean Cut operation. -class FeaturesPlugin_BooleanCut : public FeaturesPlugin_Boolean +class FeaturesPlugin_BooleanCut: public FeaturesPlugin_Boolean { public: @@ -44,10 +47,24 @@ public: return MY_KIND; } + /// Creates a new part document if needed. + FEATURESPLUGIN_EXPORT virtual void execute(); + public: - /// Use plugin manager for features creation. - FeaturesPlugin_BooleanCut(): FeaturesPlugin_Boolean(BOOL_CUT) {}; + /// Use plugin manager for features creation. + FeaturesPlugin_BooleanCut(); + +private: + + /// Load Naming data structure of the feature to the document + void loadNamingDS(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomShapePtr theResultShape, + GeomAlgoAPI_MakeShape& theMakeShape, + GeomAPI_DataMapOfShapeShape& theMapOfShapes, + const bool theIsStoreAsGenerated = false); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 0a85e1ab4..97c82b524 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -617,7 +617,9 @@ bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAt anAllowedTypes.insert(GeomAPI_Shape::SOLID); anAllowedTypes.insert(GeomAPI_Shape::COMPSOLID); anAllowedTypes.insert(GeomAPI_Shape::COMPOUND); - } else if (anOperationType == FeaturesPlugin_Boolean::BOOL_FILL) { + } else if (anOperationType == FeaturesPlugin_Boolean::BOOL_FILL + || anOperationType == FeaturesPlugin_Boolean::BOOL_CUT) + { anAllowedTypes.insert(GeomAPI_Shape::VERTEX); anAllowedTypes.insert(GeomAPI_Shape::EDGE); anAllowedTypes.insert(GeomAPI_Shape::WIRE); diff --git a/src/FeaturesPlugin/Test/Test2240.py b/src/FeaturesPlugin/Test/Test2240.py index 48ce24cd7..dd709a1bc 100644 --- a/src/FeaturesPlugin/Test/Test2240.py +++ b/src/FeaturesPlugin/Test/Test2240.py @@ -106,7 +106,7 @@ Group_2.result().setName("acier") Group_2.result().setColor(170, 85, 0) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY")) SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) -SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Partition_1_1_1/Modified_Edge_15_15&Partition_1_1_1/Modified_Edge_15_16")) +SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Partition_1_1_1/Modified_Edge_14_15&Partition_1_1_1/Modified_Edge_14_16")) SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py new file mode 100644 index 000000000..637dbfba8 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py @@ -0,0 +1,77 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-65.75962883650391, 1.812165175943577, 20.84344758927215) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchLine_1 = Sketch_1.addLine(-64.98081644495703, 22.64105757725738, -64.58019600110421, -18.99788637597517) +SketchLine_1.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchCircle_2 = Sketch_1.addCircle(62.53870966583226, 1.604010602289747, 23.75523331537361) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(63.75890236666707, 25.3278854890081, 63.76050419996562, -22.11978184293701) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_2.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_2.results()[1]) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(-32.47294132465983, 2.220594155120791, 24.592292084386) +SketchCircle_3.result().setColor(225, 0, 0) +SketchCircle_3.results()[1].setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-57.05151402373072, 3.041930894979393, -7.893787575150295, 1.41683366733466) +SketchLine_3.result().setColor(225, 0, 0) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchCircle_3.results()[1]) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchCircle_3.results()[1]) +SketchCircle_4 = Sketch_2.addCircle(107.0005131452338, 2.231606536656211, 32.56614591098422) +SketchCircle_4.result().setColor(225, 0, 0) +SketchCircle_4.results()[1].setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(74.45658844157124, 3.434446666454839, 139.5031967571015, 0.1995097076777023) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchCircle_4.results()[1]) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchCircle_4.results()[1]) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 20) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPSOLID", "Extrusion_1_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_1"), model.selection("COMPSOLID", "Extrusion_2_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [4]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [22]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [84]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [168]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py new file mode 100644 index 000000000..ba402dfd8 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py @@ -0,0 +1,61 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-23.21770404974615, 0.697956782029321, 35.59095357943583) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchLine_1 = Sketch_1.addLine(-23.86759161364122, 36.28297642299413, -22.5735889911581, -34.88716781357743) +SketchLine_1.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(32.08143103297851, 1.286314091165838, 40.2404383217231) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +SketchLine_2 = Sketch_2.addLine(-8.153954725266397, 0.6486549270159857, 72.23884334545456, 3.869938036363647) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchCircle_2.results()[1]) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchCircle_2.results()[1]) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 20) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], [model.selection("COMPSOLID", "Extrusion_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [11]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [42]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [84]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py new file mode 100644 index 000000000..32d12c819 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py @@ -0,0 +1,53 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-13.70458696967078, 45.46669742770666, 15.88340489230536, 45.46669742770666) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-13.21145377197118, 31.16583469441819, 14.89713849690615, 31.41240129326799) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_1.addLine(-5.074756009927738, 49.65832960815328, -4.828189411077946, 26.48106931627197) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_1.addLine(7.993273729111718, 49.41176300930348, 8.23984032796152, 26.48106931627197) +SketchLine_4.result().setColor(225, 0, 0) +model.do() +Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [6]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [6]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [12]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py new file mode 100644 index 000000000..9376fce69 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py @@ -0,0 +1,67 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-28.62948623265935, 53.77363153293705, 40.23707952134417, 53.11775947813702) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-26.66187006825925, 26.22700523133564, 40.89295157614425, 26.22700523133564) +SketchLine_2.result().setColor(225, 0, 0) +model.do() +Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 10) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_3 = Sketch_2.addLine(14.6580693841429, 60.98822413573743, -10.2650686982584, 60.98822413573743) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(-10.2650686982584, 60.98822413573743, -10.2650686982584, 18.35654057373522) +SketchLine_4.result().setColor(225, 0, 0) +SketchLine_5 = Sketch_2.addLine(-10.2650686982584, 18.35654057373522, 14.6580693841429, 18.35654057373522) +SketchLine_5.result().setColor(225, 0, 0) +SketchLine_6 = Sketch_2.addLine(14.6580693841429, 18.35654057373522, 14.6580693841429, 60.98822413573743) +SketchLine_6.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_4.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) +Extrusion_1.setNestedSketch(Sketch_2) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [4]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [8]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py new file mode 100644 index 000000000..45e866763 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py @@ -0,0 +1,48 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-25.12006861063466, 20.61578044596912, 27.54545454545454, 58.72898799313897) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-19.22984562607204, 56.30360205831907, 22.69468267581474, 22.00171526586621) +SketchLine_2.result().setColor(225, 0, 0) +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("EDGE", "Edge_1_2")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py new file mode 100644 index 000000000..4a22aa58a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py @@ -0,0 +1,65 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-30.96793587174349, 41.08817635270543, 39.4689378757515, 41.4929859719439) +SketchLine_1.result().setColor(225, 0, 0) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_2 = Sketch_2.addLine(13.96593186372747, 52.01803607214429, -9.917835671342695, 52.01803607214429) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-9.917835671342695, 52.01803607214429, -9.917835671342695, 27.32464929859719) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(-9.917835671342695, 27.32464929859719, 13.96593186372747, 27.32464929859719) +SketchLine_4.result().setColor(225, 0, 0) +SketchLine_5 = Sketch_2.addLine(13.96593186372747, 27.32464929859719, 13.96593186372747, 52.01803607214429) +SketchLine_5.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_2.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_3.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_4.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_5.result()) +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("FACE", "Face_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py new file mode 100644 index 000000000..d1dfcbd98 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py @@ -0,0 +1,61 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-49.71737993138937, 2.062011149228122, 25.20652382544127) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchCircle_2 = Sketch_1.addCircle(41.46933533447686, 0.6873370497427074, 27.03914027119833) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(-15.35052744425385, 1.145561749571189, 23.35148318113706) +SketchCircle_3.result().setColor(225, 0, 0) +SketchCircle_3.results()[1].setColor(225, 0, 0) +SketchCircle_4 = Sketch_2.addCircle(82.70955831903943, -3.436685248713552, 26.06650182177207) +SketchCircle_4.result().setColor(225, 0, 0) +SketchCircle_4.results()[1].setColor(225, 0, 0) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_1_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_2_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [8]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py new file mode 100644 index 000000000..7fd82e502 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py @@ -0,0 +1,57 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-6.063464837049752, 0.8662092624356818, 32.2304349637617) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchPoint_1.result().setColor(170, 0, 225) +SketchCircle_2 = Sketch_2.addCircle(33.45888578231592, 3.635557519489646, 33.65582143213236) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_2.results()[1]) +model.do() +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [4]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py new file mode 100644 index 000000000..319a5927f --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py @@ -0,0 +1,71 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-8.850181926352695, 1.062021831162306, 46.73432400996293) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchLine_1 = Sketch_2.addLine(64.95207814695526, 55.29739830292169, -8.272875875352462, 55.29739830292169) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_2.addLine(-8.272875875352462, 55.29739830292169, -8.272875875352462, -5.036618941767999) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-8.272875875352462, -5.036618941767999, 64.95207814695526, -5.036618941767999) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(64.95207814695526, -5.036618941767999, 64.95207814695526, 55.29739830292169) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_4.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 10) +Cut_1 = model.addCut(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) +Group_1_objects = [model.selection("VERTEX", "Cut_1_1/Modified_Edge_divided_2_v_2_1"), model.selection("FACE", "Cut_1_1"), model.selection("FACE", "Cut_1_1"), model.selection("VERTEX", "Cut_1_1/Modified_Face_divided_4_v_3_1")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +Group_2_objects = [model.selection("FACE", "Cut_1_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_divided_3_e_2_1"), model.selection("VERTEX", "Cut_1_1/Modified_Face_divided_4_v_3_1"), model.selection("FACE", "Cut_1_1")] +Group_2 = model.addGroup(Part_1_doc, Group_2_objects) +Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Cut_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [6]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py new file mode 100644 index 000000000..03369877d --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py @@ -0,0 +1,79 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-174.3348611545506, 14.32227876658794, 70.49121821473575) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchLine_1 = Sketch_1.addLine(-170.8787982705978, 84.72872358712971, -177.6798961073988, -56.0895283864863) +SketchLine_1.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +SketchCircle_2 = Sketch_1.addCircle(156.5938368884866, -3.269359348234124, 86.69415181338225) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(159.264749945663, 83.38363934242156, 152.8285624017236, -89.88170642808817) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchCircle_2.results()[1]) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchCircle_2.results()[1]) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(-63.56168377478743, 4.78844798363732, 75.55300890562218) +SketchCircle_3.result().setColor(225, 0, 0) +SketchCircle_3.results()[1].setColor(225, 0, 0) +SketchCircle_4 = Sketch_2.addCircle(322.6564034385849, -22.92418256149703, 118.030609731015) +SketchCircle_4.result().setColor(225, 0, 0) +SketchCircle_4.results()[1].setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-138.9405630492767, 9.915017403336009, 11.9830331245263, 5.907779612586542) +SketchLine_3.result().setColor(225, 0, 0) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchCircle_3.results()[1]) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchCircle_3.results()[1]) +SketchLine_4 = Sketch_2.addLine(207.6267015097382, 3.521847530670962, 440.2647819790861, -32.89885701981125) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchCircle_4.results()[1]) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchCircle_4.results()[1]) +model.do() +Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_1f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchLine_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchLine_2f")] +Shell_1 = model.addShell(Part_1_doc, Shell_1_objects) +Shell_2_objects = [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f-SketchLine_3f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f-SketchLine_3r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f-SketchLine_4f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f-SketchLine_4r")] +Shell_2 = model.addShell(Part_1_doc, Shell_2_objects) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_1_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("SHELL", "Shell_2_1"), model.selection("SHELL", "Shell_2_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [4]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [14]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [28]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py new file mode 100644 index 000000000..bb7786af6 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py @@ -0,0 +1,61 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-32.92409574173262, 1.332083115848444, 52.41665939244462) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchLine_1 = Sketch_1.addLine(-32.3899127495535, 53.7460204836366, -32.9246838934834, -51.08457627329644) +SketchLine_1.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(52.19056504290929, 1.630574981545157, 59.89949304384059) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +SketchLine_2 = Sketch_2.addLine(112.0898160449407, 1.460291967886176, -7.70480537031941, 0.9278161529026914) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchCircle_2.results()[1]) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchCircle_2.results()[1]) +model.do() +Shell_1_objects = [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f-SketchLine_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f-SketchLine_2f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_1f")] +Shell_1 = model.addShell(Part_1_doc, Shell_1_objects) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SHELL", "Shell_1_2")], [model.selection("SHELL", "Shell_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [7]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [14]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py new file mode 100644 index 000000000..90dc152e8 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py @@ -0,0 +1,61 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-64.66755707084829, 12.13132840151158, 21.07964902130243) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +SketchCircle_2 = Sketch_1.addCircle(45.61684376247555, 1.775642744728198, 22.96122819474142) +SketchCircle_2.result().setColor(225, 0, 0) +SketchCircle_2.results()[1].setColor(225, 0, 0) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_3 = Sketch_2.addCircle(-36.49725872565889, 7.160803013521951, 17.872664608039) +SketchCircle_3.result().setColor(225, 0, 0) +SketchCircle_3.results()[1].setColor(225, 0, 0) +SketchCircle_4 = Sketch_2.addCircle(78.03127953954764, -3.93858425080257, 22.76570299983515) +SketchCircle_4.result().setColor(225, 0, 0) +SketchCircle_4.results()[1].setColor(225, 0, 0) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 20, 20) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [8]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [24]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [48]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py new file mode 100644 index 000000000..456005d4d --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py @@ -0,0 +1,78 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(15.58517034068135, 30.56312625250501, -33.39679358717434, 30.56312625250501) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-33.39679358717434, 30.56312625250501, -33.39679358717434, -16.39478957915832) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_1.addLine(-33.39679358717434, -16.39478957915832, 15.58517034068135, -16.39478957915832) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_1.addLine(15.58517034068135, -16.39478957915832, 15.58517034068135, 30.56312625250501) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_5 = Sketch_2.addLine(35.01603206412826, 45.13627254509017, -8.298597194388776, 45.13627254509017) +SketchLine_5.result().setColor(225, 0, 0) +SketchLine_6 = Sketch_2.addLine(-8.298597194388776, 45.13627254509017, -8.298597194388776, 6.679358717434865) +SketchLine_6.result().setColor(225, 0, 0) +SketchLine_7 = Sketch_2.addLine(-8.298597194388776, 6.679358717434865, 35.01603206412826, 6.679358717434865) +SketchLine_7.result().setColor(225, 0, 0) +SketchLine_8 = Sketch_2.addLine(35.01603206412826, 6.679358717434865, 35.01603206412826, 45.13627254509017) +SketchLine_8.result().setColor(225, 0, 0) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()) +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()) +SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1"), model.selection("COMPOUND", "Sketch_2")], model.selection(), 100, 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [8]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [36]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [72]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py new file mode 100644 index 000000000..337eeb9fa --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py @@ -0,0 +1,72 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchPoint_1 = Sketch_1.addPoint(-61.63122212692967, 34.13774013722127) +SketchPoint_1.result().setColor(225, 0, 0) +SketchPoint_2 = Sketch_1.addPoint(-27.26436963979418, 34.59596483704974) +SketchPoint_2.result().setColor(225, 0, 0) +SketchPoint_3 = Sketch_1.addPoint(25.43147084048027, 34.59596483704974) +SketchPoint_3.result().setColor(225, 0, 0) +SketchPoint_4 = Sketch_1.addPoint(54.29962692967411, 33.67951543739281) +SketchPoint_4.result().setColor(225, 0, 0) +model.do() +Compound_1_objects = [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_3"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_4")] +Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_2.addLine(42.11715050385933, 45.75316349699826, -43.32915483490565, 45.75316349699826) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_2.addLine(-43.32915483490565, 45.75316349699826, -43.32915483490565, 20.90707471054887) +SketchLine_2.result().setColor(225, 0, 0) +SketchLine_3 = Sketch_2.addLine(-43.32915483490565, 20.90707471054887, 42.11715050385933, 20.90707471054887) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_2.addLine(42.11715050385933, 20.90707471054887, 42.11715050385933, 45.75316349699826) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_2.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_4.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 10) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [2]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py new file mode 100644 index 000000000..f56fcff01 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py @@ -0,0 +1,54 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchPoint_1 = Sketch_1.addPoint(-61.63122212692967, 34.13774013722127) +SketchPoint_1.result().setColor(225, 0, 0) +SketchPoint_2 = Sketch_1.addPoint(-27.26436963979418, 34.59596483704974) +SketchPoint_2.result().setColor(225, 0, 0) +SketchPoint_3 = Sketch_1.addPoint(25.43147084048027, 34.59596483704974) +SketchPoint_3.result().setColor(225, 0, 0) +SketchPoint_4 = Sketch_1.addPoint(54.29962692967411, 33.67951543739281) +SketchPoint_4.result().setColor(225, 0, 0) +model.do() +Compound_1_objects = [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_3"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_4")] +Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_3")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [2]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py new file mode 100644 index 000000000..0d046ff38 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py @@ -0,0 +1,60 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchPoint_1 = Sketch_1.addPoint(0, 50) +SketchPoint_1.result().setColor(225, 0, 0) +SketchPoint_2 = Sketch_1.addPoint(0, 25) +SketchPoint_2.result().setColor(225, 0, 0) +model.do() +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1")]) +Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1")]) +Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], [model.selection("VERTEX", "Vertex_2_1")]) +Cut_2 = model.addCut(Part_1_doc, [model.selection("VERTEX", "Vertex_3_1")], [model.selection("VERTEX", "Vertex_4_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.testHaveNamingSubshapes(Cut_2, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 0) +model.testNbSubResults(Cut_1, []) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, []) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, []) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, []) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, []) + +model.testNbResults(Cut_2, 1) +model.testNbSubResults(Cut_2, [0]) +model.testNbSubShapes(Cut_2, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_2, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_2, GeomAPI_Shape.EDGE, [0]) +model.testNbSubShapes(Cut_2, GeomAPI_Shape.VERTEX, [1]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py new file mode 100644 index 000000000..2f6ecf084 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py @@ -0,0 +1,71 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-64.96569468267583, 22.00171526586621, -41.05831903945112, 55.95711835334479) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-41.05831903945112, 55.95711835334479, -23.04116638078903, 21.65523156089195) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(14.72555746140652, 19.92281303602059, 33.43567753001715, 55.95711835334479) +SketchLine_3.result().setColor(225, 0, 0) +SketchLine_4 = Sketch_1.addLine(33.43567753001715, 55.95711835334479, 50.75986277873073, 22.69468267581476) +SketchLine_4.result().setColor(225, 0, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_5 = Sketch_2.addLine(-67.39108061749573, 66.6981132075472, -42.44425385934821, 35.51457975986279) +SketchLine_5.result().setColor(225, 0, 0) +SketchLine_6 = Sketch_2.addLine(-42.44425385934821, 35.51457975986279, -16.1114922813036, 69.1234991423671) +SketchLine_6.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_2.addLine(12.64665523156088, 66.6981132075472, 35.16809605488852, 36.5540308747856) +SketchLine_7.result().setColor(225, 0, 0) +SketchLine_8 = Sketch_2.addLine(35.16809605488852, 36.5540308747856, 52.49228130360206, 66.35162950257292) +SketchLine_8.result().setColor(225, 0, 0) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +model.do() +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_6")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("WIRE", "Wire_1_1"), model.selection("WIRE", "Wire_2_1")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("WIRE", "Wire_3_1"), model.selection("WIRE", "Wire_4_1")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], [model.selection("COMPOUND", "Compound_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [2]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [8]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [16]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py new file mode 100644 index 000000000..769b64fdf --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py @@ -0,0 +1,59 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-26.15951972555746, 50.06689536878219, -17.15094339622642, 14.37907375643225) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-17.15094339622642, 14.37907375643225, 26.85248713550602, 14.72555746140652) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(26.85248713550602, 14.72555746140652, 34.47512864493997, 50.41337907375645) +SketchLine_3.result().setColor(225, 0, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_2.addCircle(3.984562607204112, 58.72898799313897, 38.16357190022508) +SketchCircle_1.result().setColor(225, 0, 0) +SketchCircle_1.results()[1].setColor(225, 0, 0) +model.do() +Wire_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("FACE", "Face_1_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [6]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py new file mode 100644 index 000000000..262a79d71 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py @@ -0,0 +1,59 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-67.98180952066137, 66.89107262893774, -22.72663773945906, 26.22700523133564) +SketchLine_1.result().setColor(225, 0, 0) +SketchLine_2 = Sketch_1.addLine(-22.72663773945906, 26.22700523133564, 31.71074280894377, 25.5711331765356) +SketchLine_2.result().setColor(225, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(31.71074280894377, 25.5711331765356, 74.99829842574599, 68.85868879333785) +SketchLine_3.result().setColor(225, 0, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(-58.79960075346089, 25.5711331765356, 3.508244452542322, 60.3323520809374) +SketchLine_4.result().setColor(225, 0, 0) +SketchLine_5 = Sketch_1.addLine(3.508244452542322, 60.3323520809374, 63.1926014393454, 22.94764495733547) +SketchLine_5.result().setColor(225, 0, 0) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +model.do() +Wire_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("WIRE", "Wire_2_1")]) +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [0]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [5]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [10]) + +assert(model.checkPythonDump()) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp index 2af2e8edb..b26849dd7 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp @@ -26,6 +26,16 @@ #include #include +//================================================================================================= +GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const GeomShapePtr theObject, + const ListOfShape& theTools, + const OperationType theOperationType) +{ + ListOfShape aListWithObject; + aListWithObject.push_back(theObject); + build(aListWithObject, theTools, theOperationType); +} + //================================================================================================= GeomAlgoAPI_Boolean::GeomAlgoAPI_Boolean(const ListOfShape& theObjects, const ListOfShape& theTools, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h index ba6f8a77a..3cb2d6e92 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h @@ -39,7 +39,13 @@ public: BOOL_COMMON ///< Take common part of objects }; - public: +public: + + /// Constructor. + GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const GeomShapePtr theObject, + const ListOfShape& theTools, + const OperationType theOperationType); + /// Constructor. GEOMALGOAPI_EXPORT GeomAlgoAPI_Boolean(const ListOfShape& theObjects, diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index da79722af..dd63dcf22 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -1352,6 +1352,24 @@ void Model_AttributeSelection::updateInHistory() aValueShape = std::make_shared(); aValueShape->setImpl(new TopoDS_Shape(aNewValues.Value())); } + + // Check that list has the same type of shape selection before adding. + GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE; + if (myParent->selectionType() == "VERTEX") aListShapeType = GeomAPI_Shape::VERTEX; + else if (myParent->selectionType() == "EDGE") aListShapeType = GeomAPI_Shape::EDGE; + else if (myParent->selectionType() == "FACE") aListShapeType = GeomAPI_Shape::FACE; + + GeomAPI_Shape::ShapeType aShapeShapeType = GeomAPI_Shape::SHAPE; + if (aValueShape.get()) { + aShapeShapeType = aValueShape->shapeType(); + } else { + (*aNewCont)->shape()->shapeType(); + } + + if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) { + continue; + } + myParent->append(*aNewCont, aValueShape); } } diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 50ee39ca8..ab2c1dec6 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -58,7 +58,11 @@ //#define DEB_IMPORT 1 Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner) -: ModelAPI_BodyBuilder(theOwner) +: ModelAPI_BodyBuilder(theOwner), + myDividedIndex(1), + myVIndex(1), + myEIndex(1), + myFIndex(1) { } @@ -275,6 +279,10 @@ void Model_BodyBuilder::clean() myBuilders.clear(); // remove the old reference (if any) aLab.ForgetAttribute(TDF_Reference::GetID()); + myDividedIndex = 1; + myVIndex = 1; + myEIndex = 1; + myFIndex = 1; } Model_BodyBuilder::~Model_BodyBuilder() @@ -379,6 +387,22 @@ void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, } } +static void removeBadShapes(ListOfShape& theShapes) +{ + ListOfShape::iterator anIt = theShapes.begin(); + while (anIt != theShapes.end()) { + TopoDS_Shape aNewShape = (*anIt)->impl(); + bool aSkip = aNewShape.IsNull() + || (aNewShape.ShapeType() == TopAbs_EDGE && BRep_Tool::Degenerated(TopoDS::Edge(aNewShape))); + if (aSkip) { + ListOfShape::iterator aRemoveIt = anIt++; + theShapes.erase(aRemoveIt); + } else { + ++anIt; + } + } +} + // Keep only the shapes with minimal shape type static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRoot, const GeomShapePtr& theResultShape = GeomShapePtr()) @@ -429,6 +453,8 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( const bool theIsStoreSeparate, const bool theIsStoreAsGenerated) { + static const int THE_ANCHOR_TAG = 100000; + int anIndex = 1; int aTag = theTag; bool isBuilt = !theName.empty(); @@ -453,13 +479,17 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( std::shared_ptr aRShape(new GeomAPI_Shape()); aRShape->setImpl((new TopoDS_Shape(aRoot))); theMS->modified(aRShape, aList); - if (!theIsStoreSeparate) - keepTopLevelShapes(aList, aRoot, aResultShape); + if (!theIsStoreSeparate) { + //keepTopLevelShapes(aList, aRoot, aResultShape); + removeBadShapes(aList); + } // sort the list of images before naming GeomAlgoAPI_SortListOfShapes::sort(aList); // to trace situation where several objects are produced by one parent (#2317) - int aSameParentShapes = -1; + int aSameParentShapes = (aShapeIn.ShapeType() == TopAbs_WIRE + || aShapeIn.ShapeType() == TopAbs_SHELL + || aShapeIn.ShapeType() == TopAbs_COMPOUND) ? 0 : -1; std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { @@ -468,15 +498,16 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( std::shared_ptr aMapShape(theSubShapes.find(*anIt)); aNewShape.Orientation(aMapShape->impl().Orientation()); } - GeomShapePtr aGeomNewShape(new GeomAPI_Shape()); - aGeomNewShape->setImpl(new TopoDS_Shape(aNewShape)); - if(!aRoot.IsSame(aNewShape) && aResultShape->isSubShape(aGeomNewShape, false) && - !aResultShape->isSame(*anIt)) { // to avoid put of same shape on main label and sub - int aBuilderTag = aTag; + isBuilt = !theName.empty(); + if(!aRoot.IsSame(aNewShape) + && aResultShape->isSubShape((*anIt), false) + && !aResultShape->isSame(*anIt)) // to avoid put of same shape on main label and sub + { if (!theIsStoreSeparate) { aSameParentShapes++; - } else if (aNotInTree) { // check this new shape can not be represented as - // a sub-shape of higher level sub-shapes + } else if (aNotInTree) // check this new shape can not be represented as + // a sub-shape of higher level sub-shapes + { TopAbs_ShapeEnum aNewType = aNewShape.ShapeType(); TopAbs_ShapeEnum anAncestorType = typeOfAncestor(aNewType); if (anAncestorType != TopAbs_VERTEX) { @@ -500,25 +531,106 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( } } - static const int THE_ANCHOR_TAG = 100000; + int aFoundTag = 0; + bool isFoundSameOld = false; + bool isFoundDiffOld = false; + + // Check if new shape was already stored. + for (std::map::iterator aBuildersIt = myBuilders.begin(); + aBuildersIt != myBuilders.end(); + ++aBuildersIt) + { + TNaming_Builder* aBuilder = aBuildersIt->second; + for (TNaming_Iterator aNamingIt(aBuilder->NamedShape()); + aNamingIt.More(); + aNamingIt.Next()) + { + if (aNamingIt.NewShape().IsSame(aNewShape)) + { + aNamingIt.OldShape().IsSame(aRoot) ? isFoundSameOld = true + : isFoundDiffOld = true; + aFoundTag = aBuildersIt->first; + } + } + + if (isFoundSameOld || isFoundDiffOld) break; + } + + if (isFoundSameOld) { + // Builder already contains same old->new shapes, don't store it twice. + continue; + } + + int aBuilderTag = aSameParentShapes > 0 ? THE_ANCHOR_TAG : aTag; + int aCurShapeType = (int)((*anIt)->shapeType()); bool needSuffix = false; // suffix for the name based on the shape type - if (aSameParentShapes > 0) { // store in other label - aBuilderTag = THE_ANCHOR_TAG - aSameParentShapes * 10 - aCurShapeType; - needSuffix = true; - } else if (aCurShapeType != theKindOfShape) { + if (aCurShapeType != theKindOfShape) { // modified shape has different type => set another tag // to avoid shapes of different types on the same label - aBuilderTag = THE_ANCHOR_TAG - aCurShapeType; + aBuilderTag = THE_ANCHOR_TAG; needSuffix = true; } std::string aSuffix; if (needSuffix) { switch (aCurShapeType) { - case GeomAPI_Shape::VERTEX: aSuffix = "_v"; break; - case GeomAPI_Shape::EDGE: aSuffix = "_e"; break; - case GeomAPI_Shape::FACE: aSuffix = "_f"; break; - default: break; + case GeomAPI_Shape::VERTEX: aSuffix = "_v_" + std::to_string(myVIndex++); break; + case GeomAPI_Shape::EDGE: aSuffix = "_e_" + std::to_string(myEIndex++); break; + case GeomAPI_Shape::FACE: aSuffix = "_f_" + std::to_string(myFIndex++); break; + default: break; + } + } + + std::vector> aKeepShapes, aMoveShapes; + if (isFoundDiffOld) { + // Found same new shape with different old shape. + if (aFoundTag >= THE_ANCHOR_TAG) { + // Found on separated tag. + aBuilderTag = aFoundTag; // Store it on the same tag. + isBuilt = false; // Don't change name; + } else { + // Found on previous tag. + if (aBuilderTag < THE_ANCHOR_TAG) { + // New shape shouls not be separated. + aBuilderTag = aFoundTag; // Store it on the same tag. + isBuilt = false; // Don't change name; + } else { + // New shape should be separated from others. Move shapes from found tag to new tag. + while (myBuilders.find(aBuilderTag) != myBuilders.end()) { + ++aBuilderTag; + } + + TNaming_Builder* aFoundBuilder = myBuilders.at(aFoundTag); + Handle(TNaming_NamedShape) aFoundNamedShape = aFoundBuilder->NamedShape(); + TDF_Label aFoundLabel = aFoundNamedShape->Label(); + TNaming_Evolution anEvolution = aFoundNamedShape->Evolution(); + for (TNaming_Iterator aNamingIt(aFoundNamedShape); + aNamingIt.More(); + aNamingIt.Next()) + { + std::pair aShapesPair = + std::make_pair(aNamingIt.OldShape(), aNamingIt.NewShape()); + aNamingIt.NewShape().IsSame(aNewShape) ? aMoveShapes.push_back(aShapesPair) + : aKeepShapes.push_back(aShapesPair); + } + + aFoundNamedShape->Clear(); + for (std::vector>::iterator aKeepIt = + aKeepShapes.begin(); + aKeepIt != aKeepShapes.end(); + ++aKeepIt) + { + if (anEvolution == TNaming_GENERATED) { + aFoundBuilder->Generated(aKeepIt->first, aKeepIt->second); + } else { + aFoundBuilder->Modify(aKeepIt->first, aKeepIt->second); + } + } + } + } + } else if (aBuilderTag == THE_ANCHOR_TAG) { + while (myBuilders.find(aBuilderTag) != myBuilders.end()) { + ++aBuilderTag; } } @@ -526,40 +638,59 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes ( // Here we store shapes as generated, to avoid problem when one parent shape produce // several child shapes. In this case naming could not determine which shape to select. builder(aBuilderTag)->Generated(aRoot, aNewShape); + for (std::vector>::iterator aMoveIt = + aMoveShapes.begin(); + aMoveIt != aMoveShapes.end(); + ++aMoveIt) + { + builder(aBuilderTag)->Generated(aMoveIt->first, aMoveIt->second); + } } else if (aNotInTree) { // not in tree -> store as primitive (stored as separated) builder(aBuilderTag)->Generated(aNewShape); - } else if (aNewShape.ShapeType() > aRoot.ShapeType()) { - // if lower-level type is produced, make it as generated + } else if (aCurShapeType != theKindOfShape) { + // if different shape type is produced, make it as generated builder(aBuilderTag)->Generated(aRoot, aNewShape); } else { builder(aBuilderTag)->Modify(aRoot, aNewShape); + for (std::vector>::iterator aMoveIt = + aMoveShapes.begin(); + aMoveIt != aMoveShapes.end(); + ++aMoveIt) { + builder(aBuilderTag)->Modify(aMoveIt->first, aMoveIt->second); + } } if(isBuilt) { aStream.str(std::string()); aStream.clear(); aStream << theName; - if(theIsStoreSeparate) + if (theIsStoreSeparate && !isFoundDiffOld) aStream << "_" << anIndex++; if (aSameParentShapes > 0) { aStream.str(std::string()); aStream.clear(); - aStream << aName << "_" << aSameParentShapes << "divided"; + aStream << aName << "_" << "divided" << "_" << myDividedIndex++; } aStream << aSuffix; buildName(aBuilderTag, aStream.str()); } - if(theIsStoreSeparate) { + if(theIsStoreSeparate && !isFoundDiffOld) { aTag++; } } else if (aResultShape->isSame(*anIt)) { // keep the modification evolution on the root level (2241 - history propagation issue) - if(theIsStoreAsGenerated) { - builder(0)->Generated(aRoot, aNewShape); - } else { - builder(0)->Modify(aRoot, aNewShape); + TNaming_Builder* aBuilder = builder(0); + TDF_Label aShapeLab = aBuilder->NamedShape()->Label(); + Handle(TDF_Reference) aRef; + // Store only in case if it does not have reference. + if (!aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { + if (theIsStoreAsGenerated) { + builder(0)->Generated(aRoot, aNewShape); + } else { + builder(0)->Modify(aRoot, aNewShape); + } } } } diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 983c03a75..2c8f56321 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -153,6 +153,13 @@ private: /// builds name for the shape kept at the specified tag void buildName(const int theTag, const std::string& theName); +private: + int myDividedIndex; + int myVIndex; + int myEIndex; + int myFIndex; + +private: friend class Model_ResultBody; friend class Model_ResultCompSolid; }; diff --git a/src/ModelAPI/Test/Test1512.py b/src/ModelAPI/Test/Test1512.py index 4a3be33be..bf50090ff 100755 --- a/src/ModelAPI/Test/Test1512.py +++ b/src/ModelAPI/Test/Test1512.py @@ -154,12 +154,12 @@ def check_owner(selection, topology_type, feature): # check faces check_owner("Extrusion_1_1/Generated_Face_1", "face", aBox) -check_owner("Fuse_1_1/Modified_Face_3", "face", aBox) +check_owner("Fuse_1_1/Modified_Face_2", "face", aBox) check_owner("Cut_1_1/Modified_Face_1", "face", aHoleExt) check_owner("Fuse_1_1/Modified_Face_1", "face", aTower) # check edges without ambiguity check_owner("Fuse_1_1/Modified_Face_2&Extrusion_1_1/Generated_Face_2", "edge", aBox) -check_owner("Fuse_1_1/Modified_Face_1&Extrusion_3_1/To_Face_1_1", "edge", aTower) +check_owner("Fuse_1_1/Modified_Face_1&Extrusion_3_1/To_Face_1", "edge", aTower) # check the connected topology method: solid is not a compound of connected topology assert(aFuse.firstResult().shape().isConnectedTopology() == False) diff --git a/src/ModelAPI/Test/Test2358_2.py b/src/ModelAPI/Test/Test2358_2.py index 9429879bc..e52fec361 100644 --- a/src/ModelAPI/Test/Test2358_2.py +++ b/src/ModelAPI/Test/Test2358_2.py @@ -107,7 +107,7 @@ model.do() Sketch_3.setName("Sketch_4") Sketch_3.result().setName("Sketch_4") ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), "h", 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Fillet_1_objects = [model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_1divided_f_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&Extrusion_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_1divided_f_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_1divided_f_2&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_1divided_f_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_1divided_f_1&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_9")] +Fillet_1_objects = [model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_divided_5_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&Extrusion_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_divided_4_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_divided_4_1&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_divided_5_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_divided_5_1&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_9")] Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2) Group_1_objects = [model.selection("FACE", "Fillet_1_1/Modified_Face_3"), model.selection("FACE", "Fillet_1_1/Modified_Face_5"), model.selection("FACE", "Fillet_1_1/Modified_Face_9"), model.selection("FACE", "Fillet_1_1/Modified_Face_15")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index 7cd30c2ca..921abf09a 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -203,6 +203,8 @@ def testHaveNamingByType(theFeature, theModel, thePartDoc, theSubshapeType) : :param theFeature: feature to test. :param theSubshapeType: type of sub-shape """ + if not theFeature.results(): + return aFirstRes = theFeature.results()[0] # Get number of sub-results hasSubs = True