From: mpv Date: Tue, 11 Dec 2018 12:59:51 +0000 (+0300) Subject: Merge commit 'refs/tags/V9_2_0^{}' X-Git-Tag: End2018~76 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d4b0a5cb916f4eccf4a0bce02e43a54c7a67cb93;hp=041408805444922d000d4200caf7fb90e3746ea8;p=modules%2Fshaper.git Merge commit 'refs/tags/V9_2_0^{}' --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 79938bc10..b5e1b3656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ SET(SKETCHER_CHANGE_RADIUS_WHEN_MOVE TRUE) ADD_SUBDIRECTORY (src/Config) ADD_SUBDIRECTORY (src/Events) +ADD_SUBDIRECTORY (src/Selector) ADD_SUBDIRECTORY (src/Model) ADD_SUBDIRECTORY (src/XAO) ADD_SUBDIRECTORY (src/GeomAPI) diff --git a/doc/gui/Introduction.rst b/doc/gui/Introduction.rst index f1163d65a..ae5c997e9 100644 --- a/doc/gui/Introduction.rst +++ b/doc/gui/Introduction.rst @@ -241,7 +241,7 @@ Each feature, result, construction, group, field, parameter can be renamed using .. centered:: Construction pop-up menu -The order of features can be changed using *Move to the end* pop-up menu command. The selected feature will be moved to the end of feature list. +The order of features can be changed using *Move to the end* pop-up menu command. It works only for Group features. The selected group will be moved to the end of features list. Folders can be used to arrange long Tree View for features. @@ -411,6 +411,7 @@ Parameters Model parametrization can be done using parameters. A parameter can be created in the active partset or part by: + - :ref:`parameter`; - :ref:`parameters`; - :ref:`parameter_expression`. diff --git a/doc/gui/tutorial.py b/doc/gui/tutorial.py index 64e0c404e..0af565892 100644 --- a/doc/gui/tutorial.py +++ b/doc/gui/tutorial.py @@ -64,9 +64,9 @@ Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Polyline_1_1")]) Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 360, 0) # Step5. Extrusion. -Wire = model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r") -To = model.selection("FACE", "Revolution_1_1/Generated_Face_6") -From = model.selection("FACE", "Revolution_1_1/Generated_Face_1") +Wire = model.selection("WIRE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_1r_wire") +To = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_2") +From = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_7") Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "PartSet/OZ"), To, 0, From, 0) @@ -74,7 +74,7 @@ Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "Pa Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Extrusion_1_1")]) # Step7. Fillet. -Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Common_1_1/Modified_Face_11")], 10) +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_3][Common_1_1/Modified_Face&Face_1_1/Edge_4]")], 10) # Step8. Box. Box_1 = model.addBox(Part_1_doc, 20, 120, 20) diff --git a/env.sh b/env.sh index f3aa50d1c..eb892afc7 100644 --- a/env.sh +++ b/env.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -export SALOME_DIR=/dn46/SALOME/series9x/current-2018-09-28 +export SALOME_DIR=/dn46/SALOME/series9x/current-2018-11-16 # Path to sources diff --git a/lcov_reports.sh b/lcov_reports.sh old mode 100644 new mode 100755 index ff376c922..9211c70ce --- a/lcov_reports.sh +++ b/lcov_reports.sh @@ -4,12 +4,12 @@ source env.sh cd ${BUILD_DIR} -lcov --capture --directory /data/mpv/build --no-external --base-directory=/data/mpv/sources --output-file coverage.info.noext -q +lcov --capture --directory ${BUILD_DIR} --no-external --base-directory ${SOURCES_DIR} --output-file coverage.info.noext -q # make a working copy of report cp -f coverage.info.noext covfile # remove all reports of GUI and external parts (for all the next kinds of reports) -for MASK in '*wrap*' 'moc_*' 'XAO_*' 'SketcherPrs_*' 'GeomAlgoImpl_*' 'ModuleBase_*' 'Primitives*' '*Widget*' '*Splitter*'; do +for MASK in '*wrap*' 'moc_*' 'XAO_*' 'SketcherPrs_*' 'GeomAlgoImpl_*' 'ModuleBase_*' '*Widget*' '*Splitter*'; do lcov -r covfile ${MASK} --output-file covfile_res -q mv -f covfile_res covfile done @@ -18,17 +18,17 @@ done # prepare API report cp -f covfile covAPI # remove plugins -for MASK in 'Build' 'Collection' 'Construction' 'Exchange' 'Features' 'GDML' 'Initialization' 'Parameters' 'PartSet' 'Sketch'; do +for MASK in 'Build' 'Collection' 'Construction' 'Exchange' 'Features' 'GDML' 'Primitives' 'Initialization' 'Parameters' 'PartSet' 'Sketch'; do lcov -r covAPI *${MASK}Plugin* --output-file covAPI_res -q mv -f covAPI_res covAPI done # remove low level API -for MASK in 'GDML' 'Geom' 'GeomAlgo' 'GeomData' 'Model'; do +for MASK in 'Geom' 'GeomAlgo' 'GeomData' 'Model'; do lcov -r covAPI *${MASK}API* --output-file covAPI_res -q mv -f covAPI_res covAPI done # remove others -for MASK in 'Config' 'Events' 'GeomData' 'GeomValidators' 'Model_' 'ModelGeomAlgo' 'SketchSolver'; do +for MASK in 'Config' 'Events' 'GeomData' 'GeomValidators' 'Model_' 'ModelGeomAlgo' 'Selector' 'SketchSolver'; do lcov -r covAPI *${MASK}* --output-file covAPI_res -q mv -f covAPI_res covAPI done @@ -39,18 +39,18 @@ genhtml covAPI --output-directory lcov_htmlAPI -q # prepare Direct report cp -f covfile covDirect # remove plugins -for MASK in 'Build' 'Collection' 'Construction' 'Exchange' 'Features' 'GDML' 'Initialization' 'Parameters' 'PartSet' 'Sketch'; do +for MASK in 'Build' 'Collection' 'Construction' 'Exchange' 'Features' 'GDML' 'Primitives' 'Initialization' 'Parameters' 'PartSet' 'Sketch'; do str=$startmask$MASK$endmask lcov -r covDirect *${MASK}Plugin* --output-file covDirect_res -q mv -f covDirect_res covDirect done # remove low level API -for MASK in 'GDML' 'Builder' 'Collection' 'Connector' 'Construction' 'Model' 'Exchange' 'Features' 'ModelHigh' 'Parameters' 'PartSet' 'Sketch' 'Build' 'GeomData'; do +for MASK in 'GDML' 'Primitives' 'Builder' 'Collection' 'Connector' 'Construction' 'Model' 'Exchange' 'Features' 'ModelHigh' 'Parameters' 'PartSet' 'Sketch' 'Build' 'GeomData'; do lcov -r covDirect *${MASK}API* --output-file covDirect_res -q mv -f covDirect_res covDirect done # remove others -for MASK in 'Config' 'Events' 'GeomValidators' 'Model_' 'ModelGeomAlgo' 'SketchSolver' 'GeomData'; do +for MASK in 'Config' 'Events' 'GeomValidators' 'Model_' 'ModelGeomAlgo' 'Selector' 'SketchSolver' 'GeomData'; do lcov -r covDirect *${MASK}* --output-file covDirect_res -q mv -f covDirect_res covDirect done @@ -60,17 +60,19 @@ genhtml covDirect --output-directory lcov_htmlDirect -q # prepare Else report cp -f covfile covElse -# remove plugins -for MASK in 'GDML'; do -str=$startmask$MASK$endmask -lcov -r covElse *${MASK}Plugin* --output-file covElse_res -q -mv -f covElse_res covElse -done # remove low level API -for MASK in 'Geom' 'GeomAlgo' 'GDML' 'Builder' 'Collection' 'Connector' 'Construction' 'Exchange' 'Features' 'ModelHigh' 'Parameters' 'PartSet' 'Sketch' 'Build'; do +for MASK in 'Geom' 'GeomAlgo' 'GDML' 'Primitives' 'Builder' 'Collection' 'Connector' 'Construction' 'Exchange' 'Features' 'ModelHigh' 'Parameters' 'PartSet' 'Sketch' 'Build'; do lcov -r covElse *${MASK}API* --output-file covElse_res -q mv -f covElse_res covElse done +# remove SketchPlugin's Ellipse feature (unsupported yet) +lcov -r covElse SketchPlugin*Ellipse* --output-file covElse_res -q +mv -f covElse_res covElse +# remove GUI related files from Config plugin +for MASK in 'DataModelReader' 'FeatureMessage' 'Translator' 'PointerMessage'; do +lcov -r covElse *Config_${MASK}* --output-file covElse_res -q +mv -f covElse_res covElse +done rm -rf lcov_htmlElse genhtml covElse --output-directory lcov_htmlElse -q diff --git a/src/BuildAPI/BuildAPI_Filling.cpp b/src/BuildAPI/BuildAPI_Filling.cpp index 8951bd8d4..22f256116 100644 --- a/src/BuildAPI/BuildAPI_Filling.cpp +++ b/src/BuildAPI/BuildAPI_Filling.cpp @@ -33,8 +33,10 @@ BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr& theF const std::list& theBaseObjects) : ModelHighAPI_Interface(theFeature) { - if(initialize()) + if (initialize()) { + setAdvancedOptions(false); setBase(theBaseObjects); + } } BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr& theFeature, @@ -48,7 +50,7 @@ BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr& theF const bool theApproximate) : ModelHighAPI_Interface(theFeature) { - if(initialize()) { + if (initialize()) { setOrientationMethod(theOrientCorrection); setMinDegree(theMinDegree); setMaxDegree(theMaxDegree); @@ -133,9 +135,9 @@ void BuildAPI_Filling::setApproximation(const bool theApproximate) execIfBaseNotEmpty(); } -void BuildAPI_Filling::setAdvancedOptions() +void BuildAPI_Filling::setAdvancedOptions(bool isEnabled) { - feature()->string(BuildPlugin_Filling::ADVANCED_OPTIONS_ID())->setValue("true"); + feature()->string(BuildPlugin_Filling::ADVANCED_OPTIONS_ID())->setValue(isEnabled ? "true" : ""); } void BuildAPI_Filling::dump(ModelHighAPI_Dumper& theDumper) const diff --git a/src/BuildAPI/BuildAPI_Filling.h b/src/BuildAPI/BuildAPI_Filling.h index 8ccab1fee..73d5df74f 100644 --- a/src/BuildAPI/BuildAPI_Filling.h +++ b/src/BuildAPI/BuildAPI_Filling.h @@ -114,7 +114,7 @@ public: private: void execIfBaseNotEmpty(); - void setAdvancedOptions(); + void setAdvancedOptions(bool isEnabled = true); }; /// Pointer on Face object. diff --git a/src/BuildPlugin/BuildPlugin_Compound.cpp b/src/BuildPlugin/BuildPlugin_Compound.cpp index 69c8551bb..6d6c0c79f 100644 --- a/src/BuildPlugin/BuildPlugin_Compound.cpp +++ b/src/BuildPlugin/BuildPlugin_Compound.cpp @@ -70,24 +70,16 @@ void BuildPlugin_Compound::execute() // Build compound. GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(anOriginalShapes); // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aCompound); - GeomShapePtr aCopyCompound = aCopyAlgo.shape(); + GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aCompound)); + GeomShapePtr aCopyCompound = aCopyAlgo->shape(); int anIndexToRemove = 0; if (aCopyCompound) { - std::shared_ptr aMapOfShapes = aCopyAlgo.mapOfSubShapes(); - ResultBodyPtr aResultBody = document()->createBody(data(), anIndexToRemove++); aResultBody->store(aCopyCompound); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX, - 1, "Modified_Vertex", *aMapOfShapes.get(), - true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::EDGE, - 100000, "Modified_Edge", *aMapOfShapes.get(), - true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aCompound, GeomAPI_Shape::FACE, - 200000, "Modified_Face", *aMapOfShapes.get(), - true, false, true); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::VERTEX); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aCopyAlgo, aCompound, GeomAPI_Shape::FACE); setResult(aResultBody); } removeResults(anIndexToRemove); diff --git a/src/BuildPlugin/BuildPlugin_Edge.cpp b/src/BuildPlugin/BuildPlugin_Edge.cpp index 253de35b5..28be282f6 100644 --- a/src/BuildPlugin/BuildPlugin_Edge.cpp +++ b/src/BuildPlugin/BuildPlugin_Edge.cpp @@ -24,6 +24,7 @@ #include #include +#include //================================================================================================= BuildPlugin_Edge::BuildPlugin_Edge() @@ -76,35 +77,18 @@ void BuildPlugin_Edge::execute() } // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aShape); + GeomMakeShapePtr aCopyAlgo(new GeomAlgoAPI_Copy(aShape)); - // Check that algo is done. - if(!aCopyAlgo.isDone()) { - setError("Error: " + getKind() + " algorithm failed."); - return; - } - - // Check if shape is not null. - if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { - setError("Error: Resulting shape is null."); - return; - } - - // Check that resulting shape is valid. - if(!aCopyAlgo.isValid()) { - setError("Error: Resulting shape is not valid."); + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) { + setError(anError); return; } // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->storeModified(aShape, aCopyAlgo.shape()); - std::shared_ptr aSubShapes = aCopyAlgo.mapOfSubShapes(); - int aModVertexTag = 1; - std::string aModVertexName = "Modified_Vertex"; - aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX, - aModVertexTag, aModVertexName, *aSubShapes.get(), - true); + aResultBody->storeModified(aShape, aCopyAlgo->shape()); + aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX); setResult(aResultBody, aResultIndex); ++aResultIndex; diff --git a/src/BuildPlugin/BuildPlugin_Face.cpp b/src/BuildPlugin/BuildPlugin_Face.cpp index 391ea4bd9..c7992999a 100644 --- a/src/BuildPlugin/BuildPlugin_Face.cpp +++ b/src/BuildPlugin/BuildPlugin_Face.cpp @@ -107,7 +107,7 @@ void BuildPlugin_Face::execute() int anEdgeIndex = 1; for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) { GeomShapePtr anEdge = anExp.current(); - aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex), anEdgeIndex); + aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex)); ++anEdgeIndex; } diff --git a/src/BuildPlugin/BuildPlugin_Filling.cpp b/src/BuildPlugin/BuildPlugin_Filling.cpp index 4aff9c942..dcf51a8b5 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.cpp +++ b/src/BuildPlugin/BuildPlugin_Filling.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -67,8 +68,8 @@ void BuildPlugin_Filling::initAttributes() data()->addAttribute(TOLERANCE_3D_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(APPROXIMATION_ID(), ModelAPI_AttributeBoolean::typeId()); - restoreDefaultParameters(); - string(ADVANCED_OPTIONS_ID())->setValue(""); + if (string(ADVANCED_OPTIONS_ID())->value().empty()) + restoreDefaultParameters(); } //================================================================================================= @@ -95,8 +96,10 @@ void BuildPlugin_Filling::execute() // get base objects list AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID()); - if (aSelectionList->size() <= 1) + if (aSelectionList->size() <= 1) { + setError("Not enough objects is selected"); return; + } // collect base shapes for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { @@ -114,7 +117,9 @@ void BuildPlugin_Filling::execute() // build result aFilling->build(aParameters.isApprox); - if (isAlgorithmFailed(aFilling)) { + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilling, getKind(), anError)) { + setError(anError); removeResults(0); return; } @@ -127,37 +132,11 @@ void BuildPlugin_Filling::execute() int anEdgeInd = 0; for(GeomAPI_ShapeExplorer anExp(aCreatedFace, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) { GeomShapePtr anEdge = anExp.current(); - aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeInd), ++anEdgeInd); + aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeInd)); } setResult(aResultBody, 0); } -bool BuildPlugin_Filling::isAlgorithmFailed( - const std::shared_ptr& theAlgorithm) -{ - if (!theAlgorithm->isDone()) { - static const std::string aFeatureError = "Error: filling algorithm failed."; - std::string anAlgoError = theAlgorithm->getError(); - if (anAlgoError.empty()) - anAlgoError = aFeatureError; - else - anAlgoError = aFeatureError + " " + anAlgoError; - setError(anAlgoError); - return true; - } - if (theAlgorithm->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape of filling is Null."; - setError(aShapeError); - return true; - } - if (!theAlgorithm->isValid()) { - std::string aFeatureError = "Error: Resulting shape of filling is not valid."; - setError(aFeatureError); - return true; - } - return false; -} - //================================================================================================= void BuildPlugin_Filling::attributeChanged(const std::string& theID) { diff --git a/src/BuildPlugin/BuildPlugin_Filling.h b/src/BuildPlugin/BuildPlugin_Filling.h index cb19f063f..aadc2292d 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.h +++ b/src/BuildPlugin/BuildPlugin_Filling.h @@ -164,9 +164,6 @@ public: BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); private: - /// Check the filling algorithm is failed - bool isAlgorithmFailed(const std::shared_ptr& theAlgorithm); - /// Convert shape to edge according to construction method std::shared_ptr toEdge(const std::shared_ptr& theShape, const std::string& theMethod); diff --git a/src/BuildPlugin/BuildPlugin_Interpolation.cpp b/src/BuildPlugin/BuildPlugin_Interpolation.cpp index 4af802725..481a51ff1 100644 --- a/src/BuildPlugin/BuildPlugin_Interpolation.cpp +++ b/src/BuildPlugin/BuildPlugin_Interpolation.cpp @@ -128,12 +128,12 @@ void BuildPlugin_Interpolation::execute() ResultBodyPtr aResultBody = document()->createBody(data()); std::set::const_iterator aContextIt = aContexts.begin(); for (; aContextIt != aContexts.end(); aContextIt++) { - aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin() ? 0 : -2); + aResultBody->storeModified(*aContextIt, anEdge, aContextIt == aContexts.begin()); } int aVertexIndex = 1; for (GeomAPI_ShapeExplorer anExp(anEdge, GeomAPI_Shape::VERTEX); anExp.more(); anExp.next()) { std::string aVertexName = "Vertex_" + std::to_string((long long)aVertexIndex); - aResultBody->generated(anExp.current(), aVertexName, aVertexIndex++); + aResultBody->generated(anExp.current(), aVertexName); } setResult(aResultBody); diff --git a/src/BuildPlugin/BuildPlugin_Polyline.cpp b/src/BuildPlugin/BuildPlugin_Polyline.cpp index 7d2369c20..da0bbfb99 100644 --- a/src/BuildPlugin/BuildPlugin_Polyline.cpp +++ b/src/BuildPlugin/BuildPlugin_Polyline.cpp @@ -92,10 +92,10 @@ void BuildPlugin_Polyline::execute() // Create wire from edges GeomShapePtr aWire = GeomAlgoAPI_WireBuilder::wire(anEdges); - if (!aWire.get()) { - setError("Error: Result polyline is empty."); - return; - } + if (!aWire.get()) { + setError("Error: Result polyline is empty."); + return; + } // Check the wire. if (GeomAlgoAPI_WireBuilder::isSelfIntersected(aWire)) { @@ -107,7 +107,7 @@ void BuildPlugin_Polyline::execute() ResultBodyPtr aResultBody = document()->createBody(data()); std::set::const_iterator aContextIt = aContexts.begin(); for (; aContextIt != aContexts.end(); aContextIt++) { - aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin() ? 0 : -2); + aResultBody->storeModified(*aContextIt, aWire, aContextIt == aContexts.begin()); } aPointsIt = aPoints.cbegin(); @@ -115,7 +115,7 @@ void BuildPlugin_Polyline::execute() for (; anExp.more() && aPointsIt != aPoints.cend(); anExp.next(), ++aPointsIt) { GeomShapePtr aPoint = *aPointsIt; GeomShapePtr anEdge = anExp.current(); - aResultBody->generated(aPoint, anEdge, "Edge", 1); + aResultBody->generated(aPoint, anEdge); } if (!isClosed) { @@ -125,8 +125,8 @@ void BuildPlugin_Polyline::execute() aResPoints.push_back(anExp.current()); } - aResultBody->generated(aResPoints.front(), "FirstVertex", 2); - aResultBody->generated(aResPoints.back(), "LastVertex", 3); + aResultBody->generated(aResPoints.front(), "FirstVertex"); + aResultBody->generated(aResPoints.back(), "LastVertex"); } setResult(aResultBody); diff --git a/src/BuildPlugin/BuildPlugin_Shell.cpp b/src/BuildPlugin/BuildPlugin_Shell.cpp index 725f8d336..bd73c2f1f 100644 --- a/src/BuildPlugin/BuildPlugin_Shell.cpp +++ b/src/BuildPlugin/BuildPlugin_Shell.cpp @@ -25,6 +25,7 @@ #include #include +#include #include //================================================================================================= @@ -56,29 +57,16 @@ void BuildPlugin_Shell::execute() } // Sew faces. - GeomAlgoAPI_Sewing aSewingAlgo(aShapes); + GeomMakeShapePtr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes)); - // Check that algo is done. - if(!aSewingAlgo.isDone()) { - setError("Error: " + getKind() + " algorithm failed."); - return; - } - - // Check if shape is not null. - if(!aSewingAlgo.shape().get() || aSewingAlgo.shape()->isNull()) { - setError("Error: Resulting shape is null."); - return; - } - - // Check that resulting shape is valid. - if(!aSewingAlgo.isValid()) { - setError("Error: Resulting shape is not valid."); + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSewingAlgo, getKind(), anError)) { + setError(anError); return; } // Store result. - GeomShapePtr aResult = aSewingAlgo.shape(); - std::shared_ptr aMapOfShapes = aSewingAlgo.mapOfSubShapes(); + GeomShapePtr aResult = aSewingAlgo->shape(); int anIndex = 0; for(GeomAPI_ShapeExplorer anExp(aResult, GeomAPI_Shape::SHELL); anExp.more(); anExp.next()) { @@ -86,23 +74,25 @@ void BuildPlugin_Shell::execute() ResultBodyPtr aResultBody = document()->createBody(data(), anIndex); aResultBody->store(aShell); for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) { - for(GeomAPI_ShapeExplorer - aFaceExp(*anIt, GeomAPI_Shape::FACE); aFaceExp.more(); aFaceExp.next()) { + for (GeomAPI_ShapeExplorer aFaceExp(*anIt, GeomAPI_Shape::FACE); + aFaceExp.more(); + aFaceExp.next()) + { GeomShapePtr aFace = aFaceExp.current(); ListOfShape aHistory; - aSewingAlgo.modified(aFace, aHistory); - for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); - aHistoryIt != aHistory.cend(); - ++aHistoryIt) { + aSewingAlgo->modified(aFace, aHistory); + for (ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); + aHistoryIt != aHistory.cend(); + ++aHistoryIt) + { GeomShapePtr aHistoryShape = *aHistoryIt; - if(aMapOfShapes->isBound(aHistoryShape)) { - aHistoryShape = aMapOfShapes->find(aHistoryShape); - } - if(aShell->isSubShape(aHistoryShape)) { - aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::EDGE, - 1, "Modified_Edge", *aMapOfShapes.get()); - aResultBody->loadAndOrientModifiedShapes(&aSewingAlgo, aFace, GeomAPI_Shape::FACE, - 2, "Modified_Face", *aMapOfShapes.get()); + if (aShell->isSubShape(aHistoryShape, false)) { + aResultBody->loadModifiedShapes(aSewingAlgo, + aFace, + GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aSewingAlgo, + aFace, + GeomAPI_Shape::FACE); break; } } diff --git a/src/BuildPlugin/BuildPlugin_Solid.cpp b/src/BuildPlugin/BuildPlugin_Solid.cpp index 0f044564e..dc0c57ed5 100644 --- a/src/BuildPlugin/BuildPlugin_Solid.cpp +++ b/src/BuildPlugin/BuildPlugin_Solid.cpp @@ -60,19 +60,18 @@ void BuildPlugin_Solid::execute() void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes, const GeomShapePtr& theResultShape, - const std::shared_ptr& theAlgorithm) + const GeomMakeShapePtr& theAlgorithm) { ResultBodyPtr aResultBody = document()->createBody(data()); aResultBody->store(theResultShape); // Store faces - std::shared_ptr aMapOfSubs = theAlgorithm->mapOfSubShapes(); - int aModifiedTag = 1; - for(ListOfShape::const_iterator anIt = theOriginalShapes.cbegin(); - anIt != theOriginalShapes.cend(); ++anIt) { + for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin(); + anIt != theOriginalShapes.cend(); + ++anIt) + { GeomShapePtr aShape = *anIt; - aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE, - aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true); + aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE); } setResult(aResultBody); } diff --git a/src/BuildPlugin/BuildPlugin_SubShapes.cpp b/src/BuildPlugin/BuildPlugin_SubShapes.cpp index 35aa48914..c919828c7 100644 --- a/src/BuildPlugin/BuildPlugin_SubShapes.cpp +++ b/src/BuildPlugin/BuildPlugin_SubShapes.cpp @@ -105,9 +105,9 @@ void BuildPlugin_SubShapes::execute() if(!aBaseShape.get()) { return; } - GeomAlgoAPI_ShapeBuilder aBuilder; - aBuilder.removeInternal(aBaseShape); - GeomShapePtr aResultShape = aBuilder.shape(); + std::shared_ptr aBuilder(new GeomAlgoAPI_ShapeBuilder()); + aBuilder->removeInternal(aBaseShape); + GeomShapePtr aResultShape = aBuilder->shape(); // Get list of shapes. ListOfShape aShapesToAdd; @@ -118,8 +118,8 @@ void BuildPlugin_SubShapes::execute() // Copy sub-shapes from list to new shape. if(!aShapesToAdd.empty()) { - aBuilder.addInternal(aResultShape, aShapesToAdd); - aResultShape = aBuilder.shape(); + aBuilder->addInternal(aResultShape, aShapesToAdd); + aResultShape = aBuilder->shape(); } // Store result. @@ -127,15 +127,15 @@ void BuildPlugin_SubShapes::execute() const int aModEdgeTag = 2; ResultBodyPtr aResultBody = document()->createBody(data()); aResultBody->storeModified(aBaseShape, aResultShape); - aResultBody->loadAndOrientModifiedShapes(&aBuilder, aBaseShape, GeomAPI_Shape::EDGE, aModEdgeTag, - "Modified_Edge", *aBuilder.mapOfSubShapes().get()); - for(ListOfShape::const_iterator - anIt = aShapesToAdd.cbegin(); anIt != aShapesToAdd.cend(); ++anIt) { + aResultBody->loadModifiedShapes(aBuilder, aBaseShape, GeomAPI_Shape::EDGE); + for (ListOfShape::const_iterator anIt = aShapesToAdd.cbegin(); + anIt != aShapesToAdd.cend(); + ++anIt) + { GeomAPI_Shape::ShapeType aShType = (*anIt)->shapeType(); - aResultBody->loadAndOrientModifiedShapes(&aBuilder, *anIt, aShType, - aShType == GeomAPI_Shape::VERTEX ? aModVertexTag : aModEdgeTag, - aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" : "Modified_Edge", - *aBuilder.mapOfSubShapes().get()); + aResultBody->loadModifiedShapes(aBuilder, + *anIt, + aShType); } setResult(aResultBody); } diff --git a/src/BuildPlugin/BuildPlugin_Validators.cpp b/src/BuildPlugin/BuildPlugin_Validators.cpp index 1dc69c0a3..3b4c4b950 100644 --- a/src/BuildPlugin/BuildPlugin_Validators.cpp +++ b/src/BuildPlugin/BuildPlugin_Validators.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -34,8 +35,7 @@ #include #include #include -#include -#include +#include #include #include @@ -292,16 +292,9 @@ bool BuildPlugin_ValidatorBaseForSolids::isValid( std::shared_ptr anAlgorithm( new GeomAlgoAPI_MakeVolume(anOriginalShapes, false)); - if (!anAlgorithm->isDone()) { - theError = "MakeVolume algorithm failed."; - return false; - } - if (anAlgorithm->shape()->isNull()) { - theError = "Resulting shape of MakeVolume is Null."; - return false; - } - if (!anAlgorithm->isValid()) { - theError = "Resulting shape of MakeVolume is not valid."; + std::string anErr; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgorithm, "MakeVolume", anErr)) { + theError = anErr; return false; } diff --git a/src/BuildPlugin/BuildPlugin_Vertex.cpp b/src/BuildPlugin/BuildPlugin_Vertex.cpp index 585682a32..a2475d870 100644 --- a/src/BuildPlugin/BuildPlugin_Vertex.cpp +++ b/src/BuildPlugin/BuildPlugin_Vertex.cpp @@ -24,6 +24,7 @@ #include #include +#include //================================================================================================= BuildPlugin_Vertex::BuildPlugin_Vertex() @@ -76,29 +77,17 @@ void BuildPlugin_Vertex::execute() } // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aShape); + std::shared_ptr aCopyAlgo(new GeomAlgoAPI_Copy(aShape)); - // Check that algo is done. - if(!aCopyAlgo.isDone()) { - setError("Error: " + getKind() + " algorithm failed."); - return; - } - - // Check if shape is not null. - if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { - setError("Error: Resulting shape is null."); - return; - } - - // Check that resulting shape is valid. - if(!aCopyAlgo.isValid()) { - setError("Error: Resulting shape is not valid."); + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) { + setError(anError); return; } // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->storeModified(aShape, aCopyAlgo.shape()); + aResultBody->storeModified(aShape, aCopyAlgo->shape()); setResult(aResultBody, aResultIndex); ++aResultIndex; } diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp index 54ae7a95b..a941765b7 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.cpp +++ b/src/BuildPlugin/BuildPlugin_Wire.cpp @@ -88,7 +88,7 @@ void BuildPlugin_Wire::execute() for(ListOfShape::const_iterator anIt = anEdges.cbegin(); anIt != anEdges.cend(); ++anIt) { std::shared_ptr anEdgeInList(new GeomAPI_Edge(*anIt)); if(anEdgeInList->isEqual(anEdgeInResult)) { - aResultBody->modified(anEdgeInList, anEdgeInResult, "Edge"); + aResultBody->modified(anEdgeInList, anEdgeInResult); break; } } diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt index d99d69f68..ac7d138a2 100644 --- a/src/BuildPlugin/CMakeLists.txt +++ b/src/BuildPlugin/CMakeLists.txt @@ -105,19 +105,28 @@ INSTALL(FILES ${XML_RESOURCES} ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XM INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Build) ADD_UNIT_TESTS(TestVertex.py + TestVertex_ErrorMsg.py TestEdge.py + TestEdge_ErrorMsg.py TestWire.py + TestWire_ErrorMsg.py TestPolyline.py TestInterpolation.py TestFace.py + TestFace_ErrorMsg.py TestShell.py TestSolid.py + TestSolid_ErrorMsg.py TestCompSolid.py TestCompound.py + TestCompound_ErrorMsg.py TestSubShapes.py + TestSubShapes_ErrorMsg.py + TestFilling.py TestFilling_ByEdges.py TestFilling_ByWires.py TestFilling_Mixed.py + TestFilling_ErrorMsg.py Test1920.py Test2398.py Test2415.py diff --git a/src/BuildPlugin/Test/Test1920.py b/src/BuildPlugin/Test/Test1920.py index 96f8eb6dc..112c28338 100644 --- a/src/BuildPlugin/Test/Test1920.py +++ b/src/BuildPlugin/Test/Test1920.py @@ -41,10 +41,10 @@ SketchLine_5 = Sketch_1.addLine(50, 50, 50, 0) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_1.result()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_5f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_5r-SketchLine_1r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OY"), 100) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Translation_1_1/Translated_Edge_1"), model.selection("EDGE", "Translation_1_1/Translated_Edge_2"), model.selection("EDGE", "Translation_1_1/Translated_Edge_3"), model.selection("EDGE", "Translation_1_1/Translated_Edge_4"), model.selection("EDGE", "Translation_1_2/Translated_Edge_1"), model.selection("EDGE", "Translation_1_2/Translated_Edge_2"), model.selection("EDGE", "Translation_1_2/Translated_Edge_3"), model.selection("EDGE", "Translation_1_2/Translated_Edge_4")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Translation_1_1/ME:Translated&Face_1_1/Edge_4"), model.selection("EDGE", "Translation_1_1/ME:Translated&Face_1_1/Edge_3"), model.selection("EDGE", "Translation_1_1/ME:Translated&Face_1_1/Edge_2"), model.selection("EDGE", "Translation_1_1/ME:Translated&Face_1_1/Edge_1"), model.selection("EDGE", "Translation_1_2/ME:Translated&Face_2_1/Edge_4"), model.selection("EDGE", "Translation_1_2/ME:Translated&Face_2_1/Edge_3"), model.selection("EDGE", "Translation_1_2/ME:Translated&Face_2_1/Edge_2"), model.selection("EDGE", "Translation_1_2/ME:Translated&Face_2_1/Edge_1")]) aGroupFeature = Group_1.feature() aSelectionList = aGroupFeature.selectionList("group_list") model.end() @@ -56,4 +56,4 @@ for index in range(0, aSelectionList.size()): assert(shape.isEdge()) assert(name) -assert(model.checkPythonDump()) \ No newline at end of file +assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/Test2398.py b/src/BuildPlugin/Test/Test2398.py index 2331d8722..12d8417f1 100644 --- a/src/BuildPlugin/Test/Test2398.py +++ b/src/BuildPlugin/Test/Test2398.py @@ -34,7 +34,7 @@ SketchCircle_1 = Sketch_1.addCircle(0, 0, 30.79356776198042) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 100, 100) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2f_wire")], model.selection(), 100, 100) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) @@ -72,7 +72,7 @@ SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_5.result(), Sk SketchConstraintMiddle_1 = Sketch_3.setMiddlePoint(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_5.result()) model.do() -Edge_1_objects = [model.selection("EDGE", "Sketch_3/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_3")] +Edge_1_objects = [model.selection("EDGE", "Sketch_3/SketchLine_2"), model.selection("EDGE", "Sketch_3/SketchLine_1"), model.selection("EDGE", "Sketch_3/SketchLine_4"), model.selection("EDGE", "Sketch_3/SketchLine_3")] Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("EDGE", "PartSet/OZ"), 135) diff --git a/src/BuildPlugin/Test/Test2415.py b/src/BuildPlugin/Test/Test2415.py index 64e30318c..8d1b283e7 100644 --- a/src/BuildPlugin/Test/Test2415.py +++ b/src/BuildPlugin/Test/Test2415.py @@ -52,10 +52,10 @@ SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 80) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 150) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchArc_1_2r")], model.selection(), 200, 0) -Compound_1_objects = [model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_4")] +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection(), 200, 0) +Compound_1_objects = [model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5")] Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects) -Compound_2_objects = [model.selection("EDGE", "Compound_1_1_2/Modified_Edge_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Compound_1_1_3/Modified_Edge_2")] +Compound_2_objects = [model.selection("EDGE", "[Compound_1_1_2/Compound_1_1_2&Sketch_1/SketchLine_4][weak_name_4]"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "[Compound_1_1_3/Compound_1_1_3&Sketch_1/SketchLine_5][weak_name_4]")] Compound_2 = model.addCompound(Part_1_doc, Compound_2_objects) model.do() diff --git a/src/BuildPlugin/Test/Test2439.py b/src/BuildPlugin/Test/Test2439.py index 3a66d3930..6d3d8fc70 100644 --- a/src/BuildPlugin/Test/Test2439.py +++ b/src/BuildPlugin/Test/Test2439.py @@ -38,8 +38,8 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 100, 0) -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f_wire")], model.selection(), 100, 0) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]")]) model.do() model.testHaveNamingSubshapes(Edge_1, model, Part_1_doc) diff --git a/src/BuildPlugin/Test/Test2454.py b/src/BuildPlugin/Test/Test2454.py index f56d1d122..7792bf2a3 100644 --- a/src/BuildPlugin/Test/Test2454.py +++ b/src/BuildPlugin/Test/Test2454.py @@ -27,11 +27,11 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_1.addCircle(0.1822176134072968, -1.34047565209109, 35.08968954114807) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 100, 0) Recover_1 = model.addRecover(Part_1_doc, Extrusion_1, [Wire_1.result()]) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Recover_1_1")]) -Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/To_Edge_1")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/To_Edge")]) Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_2_1")]) model.end() diff --git a/src/BuildPlugin/Test/TestCompSolid.py b/src/BuildPlugin/Test/TestCompSolid.py index f27cb0a8b..63fe29858 100644 --- a/src/BuildPlugin/Test/TestCompSolid.py +++ b/src/BuildPlugin/Test/TestCompSolid.py @@ -45,7 +45,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_5 = Sketch_2.addLine(20, 0, 0, 0) SketchLine_6 = Sketch_2.addLine(0, 0, 0, 20) @@ -58,7 +58,7 @@ SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()) SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_9 = SketchProjection_2.createdFeature() SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_5.startPoint(), SketchLine_9.result()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_9).startPoint(), SketchLine_5.endPoint()) @@ -75,7 +75,7 @@ SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result()) SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result()) SketchConstraintEqual_3 = Sketch_2.setEqual(SketchLine_6.result(), SketchLine_12.result()) model.do() -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r_wire")]) AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 270, 2) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7f-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), 40, 0) @@ -90,17 +90,17 @@ SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_14.endPoint() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) SketchConstraintHorizontal_7 = Sketch_3.setHorizontal(SketchLine_15.result()) SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_16.result()) -SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_5s-SketchLine_15s-SketchLine_8e-SketchLine_14e"), False) +SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_5_StartVertex"), False) SketchPoint_2 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates()) -SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_11s-SketchLine_10e"), False) +SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_10_EndVertex"), False) SketchPoint_3 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchAPI_Point(SketchPoint_3).coordinates()) -SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), False) +SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex"), False) SketchPoint_4 = SketchProjection_5.createdFeature() SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r")], model.selection(), 20, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r")], model.selection(), 20, 0) Box_1 = model.addBox(Part_1_doc, 20, 20, 20) model.do() @@ -127,12 +127,12 @@ def createCompSolidStepByStep(theSelection, theExpectedType): # ============================================================================= boundaries1 = [model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), - model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_2"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/To_Face_1"), + model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_14"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_15"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_16"), + model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Box_1_1/Front")] expectType1 = [GeomAPI_Shape.SHAPE, GeomAPI_Shape.SHAPE, @@ -153,14 +153,14 @@ model.testHaveNamingSubshapes(CompSolid_1, model, Part_1_doc) # ============================================================================= boundaries2 = [model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), - model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/To_Face_1"), + model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_10"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_15"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_16"), + model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Box_1_1/Front"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_2"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_14"), model.selection("SOLID", "Extrusion_1_1")] expectType2 = [GeomAPI_Shape.SHAPE, GeomAPI_Shape.SHAPE, diff --git a/src/BuildPlugin/Test/TestCompound.py b/src/BuildPlugin/Test/TestCompound.py index c55dda70f..58e88e206 100644 --- a/src/BuildPlugin/Test/TestCompound.py +++ b/src/BuildPlugin/Test/TestCompound.py @@ -45,9 +45,9 @@ SketchCircle_1 = Sketch_1.addCircle(51.0302184611028, -58.25492948210744, 14.676 SketchCircle_2 = Sketch_1.addCircle(57.27434431552349, -55.3477547099222, 30.40870102508203) model.do() Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "PartSet/Origin")]) -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2")]) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_5")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_2_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_6 = Sketch_2.addLine(73.69205241424749, 19.68979803478298, 29.86213888681927, 19.68979803478298) SketchLine_7 = Sketch_2.addLine(29.86213888681927, 19.68979803478298, 29.86213888681927, 46.16063196348271) @@ -62,18 +62,18 @@ SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_7.result()) SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_9.result()) model.do() -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r")]) -AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), 120, 2) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r_wire")]) +AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "Sketch_2/SketchLine_6"), 120, 2) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")]) Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 50) Box_2 = model.addBox(Part_1_doc, 10, 10, 10) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_2_1/Front"), 5, True) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_2_1"), model.selection("FACE", "Plane_1")]) -Compound_1_objects = [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), - model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), - model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"), - model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"), +Compound_1_objects = [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), + model.selection("EDGE", "Sketch_1/SketchLine_1"), + model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire"), + model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r"), model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), model.selection("WIRE", "Wire_1_1"), diff --git a/src/BuildPlugin/Test/TestCompound_ErrorMsg.py b/src/BuildPlugin/Test/TestCompound_ErrorMsg.py new file mode 100644 index 000000000..c8212712a --- /dev/null +++ b/src/BuildPlugin/Test/TestCompound_ErrorMsg.py @@ -0,0 +1,43 @@ +## Copyright (C) 2017-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Compound_1 = aPart.addFeature("Compound") +Compound_1.execute() +assert(Compound_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = Compound_1.selectionList("base_objects") +aBaseObjectsList.append("", "EDGE") +Compound_1.execute() +assert(Compound_1.error() != "") +aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestEdge_ErrorMsg.py b/src/BuildPlugin/Test/TestEdge_ErrorMsg.py new file mode 100644 index 000000000..84476cd87 --- /dev/null +++ b/src/BuildPlugin/Test/TestEdge_ErrorMsg.py @@ -0,0 +1,61 @@ +## Copyright (C) 2017-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() +aBoxResult = aBox.firstResult() +aBoxShape = aBoxResult.shape() + +aSession.startOperation() +Edge_1 = aPart.addFeature("Edge") +Edge_1.execute() +assert(Edge_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = Edge_1.selectionList("base_objects") +aBaseObjectsList.append("", "EDGE") +Edge_1.execute() +assert(Edge_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList.removeLast() +aBaseObjectsList.append("Box_1_1/Top", "FACE") +Edge_1.execute() +assert(Edge_1.error() != "") +aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestFace.py b/src/BuildPlugin/Test/TestFace.py index a64a2f913..0dfab8afc 100644 --- a/src/BuildPlugin/Test/TestFace.py +++ b/src/BuildPlugin/Test/TestFace.py @@ -107,7 +107,7 @@ aCylinderShape = aCylinderResult.shape() aSession.startOperation() aFaceFeature2 = aPart.addFeature("Face") aBaseObjectsList = aFaceFeature2.selectionList("base_objects") -aBaseObjectsList.append("Cylinder_1_1/Face_1&Cylinder_1_1/Face_2", "EDGE") +aBaseObjectsList.append("[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]", "EDGE") aSession.finishOperation() assert (len(aFaceFeature2.results()) > 0) diff --git a/src/BuildPlugin/Test/TestFace_ErrorMsg.py b/src/BuildPlugin/Test/TestFace_ErrorMsg.py new file mode 100644 index 000000000..4c3a5b9e9 --- /dev/null +++ b/src/BuildPlugin/Test/TestFace_ErrorMsg.py @@ -0,0 +1,50 @@ +## Copyright (C) 2018-20xx 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, -30, -30, -30) +SketchLine_2 = Sketch_1.addLine(-30, -30, -30, 30) +SketchLine_3 = Sketch_1.addLine(-30, 30, 30, 30) +SketchLine_4 = Sketch_1.addLine(30, 30, 30, -30) +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() + +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +assert(Face_1.feature().error() != "") +Part_1_doc.removeFeature(Face_1.feature()) + +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "PartSet/XOY")]) +assert(Face_1.feature().error() != "") +Part_1_doc.removeFeature(Face_1.feature()) + +model.end() diff --git a/src/BuildPlugin/Test/TestFilling.py b/src/BuildPlugin/Test/TestFilling.py new file mode 100644 index 000000000..3ea33ff83 --- /dev/null +++ b/src/BuildPlugin/Test/TestFilling.py @@ -0,0 +1,40 @@ +## Copyright (C) 2017-20xx 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() +Point_2 = model.addPoint(Part_1_doc, 10, 0, 0) +Point_3 = model.addPoint(Part_1_doc, 20, 10, 0) +Point_4 = model.addPoint(Part_1_doc, 0, 20, 10) +Point_5 = model.addPoint(Part_1_doc, 30, 0, 10) +Polyline_1 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], False) +Polyline_2 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_4")], False) +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1"), model.selection("EDGE", "Polyline_2_1/Generated_Edge&Point_3/Point_3")]) +Filling_2 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1"), model.selection("EDGE", "Polyline_2_1/Generated_Edge&Point_3/Point_3")], "curve_info", 5, 8, 0, 0.0001, 0.0001, True) +model.do() + +assert(Filling_1.feature().error() == "") +assert(Filling_2.feature().error() == "") + +model.end() diff --git a/src/BuildPlugin/Test/TestFilling_ByEdges.py b/src/BuildPlugin/Test/TestFilling_ByEdges.py index 08b3aea56..3b056f060 100644 --- a/src/BuildPlugin/Test/TestFilling_ByEdges.py +++ b/src/BuildPlugin/Test/TestFilling_ByEdges.py @@ -82,6 +82,7 @@ aSession.finishOperation() # Create filling aSession.startOperation() aFillingFeature = aPart.addFeature("Filling") +aFillingFeature.string("advanced_options").setValue("") aBaseObjectsList = aFillingFeature.selectionList("base_objects") aBaseObjectsList.append(aSketch1Result, anArc.lastResult().shape()) aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestFilling_ByWires.py b/src/BuildPlugin/Test/TestFilling_ByWires.py index 1529a3c09..09382bdff 100644 --- a/src/BuildPlugin/Test/TestFilling_ByWires.py +++ b/src/BuildPlugin/Test/TestFilling_ByWires.py @@ -104,6 +104,7 @@ aSession.finishOperation() # Create filling aSession.startOperation() aFillingFeature = aPart.addFeature("Filling") +aFillingFeature.string("advanced_options").setValue("") aBaseObjectsList = aFillingFeature.selectionList("base_objects") aBaseObjectsList.append(aWire1.lastResult(), None) aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestFilling_ErrorMsg.py b/src/BuildPlugin/Test/TestFilling_ErrorMsg.py new file mode 100644 index 000000000..23ed7e49c --- /dev/null +++ b/src/BuildPlugin/Test/TestFilling_ErrorMsg.py @@ -0,0 +1,92 @@ +## Copyright (C) 2017-20xx 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() +Point_2 = model.addPoint(Part_1_doc, 10, 0, 0) +Point_3 = model.addPoint(Part_1_doc, 20, 10, 0) +Point_4 = model.addPoint(Part_1_doc, 0, 20, 10) +Point_5 = model.addPoint(Part_1_doc, 30, 0, 10) +Polyline_1 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], False) +Polyline_2 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_3"), model.selection("VERTEX", "Point_4")], False) +model.do() + +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1"), model.selection("EDGE", "Polyline_2_1/Generated_Edge&Point_3/Point_3")], "curve_info", 9, 8, 0, 0.0001, 0.0001, True) +assert(Filling_1.feature().error() != "") +Part_1_doc.removeFeature(Filling_1.feature()) + +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1")]) +assert(Filling_1.feature().error() != "") +Part_1_doc.removeFeature(Filling_1.feature()) + +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +Filling_1 = model.addFilling(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")]) +assert(Filling_1.feature().error() != "") +Part_1_doc.removeFeature(Filling_1.feature()) + +model.end() + +from ModelAPI import * +aSession = ModelAPI_Session.get() + +aSession.startOperation() +aFillingFeature = featureToCompositeFeature(Part_1.feature()).addFeature("Filling") +aFillingFeature.string("advanced_options").setValue("") +aFillingFeature.execute() +assert(aFillingFeature.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = aFillingFeature.selectionList("base_objects") +aBaseObjectsList.append("Polyline_1_1/Generated_Edge&Point_1/Point_1", "EDGE") +aBaseObjectsList.append("Box_1_1/Top", "FACE") +aFillingFeature.execute() +assert(aFillingFeature.error() != "") +aSession.finishOperation() + + +model.begin() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(30, -30, -30, -30) +SketchLine_2 = Sketch_1.addLine(-30, -30, -30, 30) +SketchLine_3 = Sketch_1.addLine(-30, 30, 30, 30) +SketchLine_4 = Sketch_1.addLine(30, 30, 30, -30) +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() + +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", ""), model.selection("EDGE", "Sketch_1/SketchLine_1")], "auto_correct", 1, 1, 0, 0.0001, 0.0001, False) +assert(Filling_1.feature().error() != "") +Part_1_doc.removeFeature(Filling_1.feature()) + +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_1")], "auto_correct", 1, 1, 0, 0.0001, 0.0001, False) +assert(Filling_1.feature().error() != "") +model.end() diff --git a/src/BuildPlugin/Test/TestFilling_Mixed.py b/src/BuildPlugin/Test/TestFilling_Mixed.py index c020982ed..6d5d50976 100644 --- a/src/BuildPlugin/Test/TestFilling_Mixed.py +++ b/src/BuildPlugin/Test/TestFilling_Mixed.py @@ -89,6 +89,7 @@ aSession.finishOperation() # Create filling aSession.startOperation() aFillingFeature = aPart.addFeature("Filling") +aFillingFeature.string("advanced_options").setValue("") aBaseObjectsList = aFillingFeature.selectionList("base_objects") aBaseObjectsList.append(aSketch1Result, anArc.lastResult().shape()) aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestInterpolation.py b/src/BuildPlugin/Test/TestInterpolation.py index 656351a48..b3d868444 100644 --- a/src/BuildPlugin/Test/TestInterpolation.py +++ b/src/BuildPlugin/Test/TestInterpolation.py @@ -45,12 +45,12 @@ SketchLine_2 = Sketch_1.addLine(0, 0, 45, 45) model.do() # Get sketch points -base_name = "Sketch_1/Vertex-SketchPoint_" +base_name = "Sketch_1/SketchPoint_" p_1, p_2, p_3, p_4, p_5 = [model.selection("VERTEX", base_name + str(i + 1)) for i in range(0, 5)] # Get sketch edges -Tangent_1 = model.selection("EDGE", "Sketch_1/Edge-SketchLine_1") -Tangent_2 = model.selection("EDGE", "Sketch_1/Edge-SketchLine_2") +Tangent_1 = model.selection("EDGE", "Sketch_1/SketchLine_1") +Tangent_2 = model.selection("EDGE", "Sketch_1/SketchLine_2") # ============================================================================= # Test 1. Create curve 1-2-3-4-5, closed off, reorder off, without tangents @@ -117,14 +117,14 @@ Part_2 = model.addPart(partSet) Part_2_doc = Part_2.document() Box_1 = model.addBox(Part_2_doc, 10, 10, 10) -point_names = ("Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom", - "Box_1_1/Back&Box_1_1/Left&Box_1_1/Top", - "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top", - "Box_1_1/Front&Box_1_1/Left&Box_1_1/Bottom", - "Box_1_1/Front&Box_1_1/Right&Box_1_1/Bottom", - "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top", - "Box_1_1/Back&Box_1_1/Right&Box_1_1/Top", - "Box_1_1/Back&Box_1_1/Right&Box_1_1/Bottom") +point_names = ("[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]", + "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]", + "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]", + "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]", + "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]", + "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]", + "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]", + "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]") points = [model.selection("VERTEX", name) for name in point_names] Interpolation_8 = model.addInterpolation(Part_2_doc, points, False, False) @@ -140,8 +140,8 @@ Part_3_doc = Part_3.document() Box_1 = model.addBox(Part_3_doc, 20, 30, 40) points = [model.selection("VERTEX", name) for name in point_names] -Tangent_1 = model.selection("EDGE", "Box_1_1/Back&Box_1_1/Top") -Tangent_2 = model.selection("EDGE", "Box_1_1/Left&Box_1_1/Top") +Tangent_1 = model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]") +Tangent_2 = model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]") Interpolation_9 = model.addInterpolation(Part_3_doc, points, Tangent_1, Tangent_2, False, False) @@ -175,4 +175,4 @@ model.end() # ============================================================================= # Test 12. Check Python dump # ============================================================================= -assert(model.checkPythonDump()) +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/src/BuildPlugin/Test/TestPolyline.py b/src/BuildPlugin/Test/TestPolyline.py index ba399cc54..88da7504a 100644 --- a/src/BuildPlugin/Test/TestPolyline.py +++ b/src/BuildPlugin/Test/TestPolyline.py @@ -42,7 +42,7 @@ SketchPoint_5 = Sketch_1.addPoint(50, 0) model.do() # Get sketch points -base_name = "Sketch_1/Vertex-SketchPoint_" +base_name = "Sketch_1/SketchPoint_" p_1, p_2, p_3, p_4, p_5 = [model.selection("VERTEX", base_name + str(i + 1)) for i in range(0, 5)] # ============================================================================= @@ -100,14 +100,14 @@ Part_2 = model.addPart(partSet) Part_2_doc = Part_2.document() Box_1 = model.addBox(Part_2_doc, 10, 10, 10) -point_names = ("Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom", - "Box_1_1/Back&Box_1_1/Left&Box_1_1/Top", - "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top", - "Box_1_1/Front&Box_1_1/Left&Box_1_1/Bottom", - "Box_1_1/Front&Box_1_1/Right&Box_1_1/Bottom", - "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top", - "Box_1_1/Back&Box_1_1/Right&Box_1_1/Top", - "Box_1_1/Back&Box_1_1/Right&Box_1_1/Bottom") +point_names = ("[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]", + "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]", + "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]", + "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]", + "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]", + "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]", + "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]", + "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]") points = [model.selection("VERTEX", name) for name in point_names] Polyline_7 = model.addPolyline3D(Part_2_doc, points, False) @@ -154,4 +154,4 @@ model.end() # ============================================================================= # Test 11. Check Python dump # ============================================================================= -assert(model.checkPythonDump()) \ No newline at end of file +assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/TestSolid.py b/src/BuildPlugin/Test/TestSolid.py index f0be3f0a0..050cf7238 100644 --- a/src/BuildPlugin/Test/TestSolid.py +++ b/src/BuildPlugin/Test/TestSolid.py @@ -45,7 +45,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_5 = Sketch_2.addLine(20, 0, 0, 0) SketchLine_6 = Sketch_2.addLine(0, 0, 0, 20) @@ -58,7 +58,7 @@ SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()) SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_9 = SketchProjection_2.createdFeature() SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_5.startPoint(), SketchLine_9.result()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_9).startPoint(), SketchLine_5.endPoint()) @@ -75,7 +75,7 @@ SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result()) SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result()) SketchConstraintEqual_3 = Sketch_2.setEqual(SketchLine_6.result(), SketchLine_12.result()) model.do() -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r_wire")]) AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 270, 2) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "AngularCopy_1_1_1"), model.selection("FACE", "AngularCopy_1_1_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7f-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), 40, 0) @@ -90,17 +90,17 @@ SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_14.endPoint() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) SketchConstraintHorizontal_7 = Sketch_3.setHorizontal(SketchLine_15.result()) SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_16.result()) -SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_5s-SketchLine_15s-SketchLine_8e-SketchLine_14e"), False) +SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_5_StartVertex"), False) SketchPoint_2 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates()) -SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_11s-SketchLine_10e"), False) +SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_10_EndVertex"), False) SketchPoint_3 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchAPI_Point(SketchPoint_3).coordinates()) -SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), False) +SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex"), False) SketchPoint_4 = SketchProjection_5.createdFeature() SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r")], model.selection(), 20, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r")], model.selection(), 20, 0) Box_1 = model.addBox(Part_1_doc, 20, 20, 20) model.do() @@ -125,12 +125,12 @@ def createSolidStepByStep(theSelection, theExpected): # ============================================================================= boundaries1 = [model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), - model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_2"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/To_Face_1"), + model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_14"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_15"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_16"), + model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Box_1_1/Front")] expectSolid1 = [False, False, False, False, False, False, False, True, False] Solid_1 = createSolidStepByStep(boundaries1, expectSolid1) @@ -141,12 +141,12 @@ assert(Solid_1 is None) # ============================================================================= boundaries2 = [model.selection("FACE", "Face_1_1"), model.selection("SHELL", "Shell_1_1"), - model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16r"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_3"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_4"), - model.selection("FACE", "Extrusion_2_1/To_Face_1"), + model.selection("FACE", "Sketch_3/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_10"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_15"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_3/SketchLine_16"), + model.selection("FACE", "Extrusion_2_1/To_Face"), model.selection("FACE", "Box_1_1/Front")] expectSolid2 = [False, False, False, False, False, False, False, False, True] Solid_2 = createSolidStepByStep(boundaries2, expectSolid2) diff --git a/src/BuildPlugin/Test/TestSolid_ErrorMsg.py b/src/BuildPlugin/Test/TestSolid_ErrorMsg.py new file mode 100644 index 000000000..be0205543 --- /dev/null +++ b/src/BuildPlugin/Test/TestSolid_ErrorMsg.py @@ -0,0 +1,35 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Solid_1 = aPart.addFeature("Solid") +aSession.finishOperation() +assert(Solid_1.error() != "") diff --git a/src/BuildPlugin/Test/TestSubShapes.py b/src/BuildPlugin/Test/TestSubShapes.py index 7fc9813c7..b10358a4c 100644 --- a/src/BuildPlugin/Test/TestSubShapes.py +++ b/src/BuildPlugin/Test/TestSubShapes.py @@ -160,9 +160,9 @@ SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchPoint_1 = Sketch_1.addPoint(-490.566037735849, 50.600343053173) SketchPoint_2 = Sketch_1.addPoint(-423.670668953688, 50.600343053173) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_2_2r")]) -SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("FACE", "Face_1_1"), [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_2_2")]) +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("FACE", "Face_1_1"), [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_2")]) SubShapes_1.setBaseShape(model.selection("FACE", "Face_2_1")) model.end() diff --git a/src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py b/src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py new file mode 100644 index 000000000..4260d36da --- /dev/null +++ b/src/BuildPlugin/Test/TestSubShapes_ErrorMsg.py @@ -0,0 +1,78 @@ +## Copyright (C) 2017-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Polyline_1_objects = [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]")] +Polyline_1 = model.addPolyline3D(Part_1_doc, Polyline_1_objects, False) +model.do() + +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("WIRE", "Polyline_1_1"), [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")]) +assert(SubShapes_1.feature().error() != "") +Part_1_doc.removeFeature(SubShapes_1.feature()) + +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("WIRE", "Polyline_1_1"), [model.selection("EDGE", "Polyline_1_1/Generated_Edge&weak_name_4")]) +assert(SubShapes_1.feature().error() == "") + +model.end() + +from ModelAPI import * +aSession = ModelAPI_Session.get() + +aSession.startOperation() +SubShapes_2 = featureToCompositeFeature(Part_1.feature()).addFeature("SubShapes") +SubShapes_2.execute() +assert(SubShapes_2.error() == "") +aSession.finishOperation() + +model.begin() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(30, -30, -30, -30) +SketchLine_2 = Sketch_1.addLine(-30, -30, -30, 30) +SketchLine_3 = Sketch_1.addLine(-30, 30, 30, 30) +SketchLine_4 = Sketch_1.addLine(30, 30, 30, -30) +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() + +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine4r-SketchLine3r-SketchLine2r-SketchLine1r"), [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +assert(SubShapes_1.feature().error() != "") +Part_1_doc.removeFeature(SubShapes_1.feature()) + +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("WIRE", "Polyline_1_1"), [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +assert(SubShapes_1.feature().error() != "") +Part_1_doc.removeFeature(SubShapes_1.feature()) + +SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("WIRE", "Polyline_1_1"), [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")]) +assert(SubShapes_1.feature().error() != "") +Part_1_doc.removeFeature(SubShapes_1.feature()) + +model.end() diff --git a/src/BuildPlugin/Test/TestVertex_ErrorMsg.py b/src/BuildPlugin/Test/TestVertex_ErrorMsg.py new file mode 100644 index 000000000..0acbeba18 --- /dev/null +++ b/src/BuildPlugin/Test/TestVertex_ErrorMsg.py @@ -0,0 +1,43 @@ +## Copyright (C) 2017-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Vertex_1 = aPart.addFeature("Vertex") +Vertex_1.execute() +assert(Vertex_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = Vertex_1.selectionList("base_objects") +aBaseObjectsList.append("", "EDGE") +Vertex_1.execute() +assert(Vertex_1.error() != "") +aSession.finishOperation() diff --git a/src/BuildPlugin/Test/TestWire.py b/src/BuildPlugin/Test/TestWire.py index 25dd4ecb2..a48990443 100644 --- a/src/BuildPlugin/Test/TestWire.py +++ b/src/BuildPlugin/Test/TestWire.py @@ -111,7 +111,7 @@ 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() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) Wire_1.addContour() model.end() @@ -134,12 +134,12 @@ aBoxShape = aBoxResult.shape() aSession.startOperation() aWireFeature2 = aPart.addFeature("Wire") aBaseObjectsList = aWireFeature2.selectionList("base_objects") -aBaseObjectsList.append("Box_1_1/Front&Box_1_1/Bottom", "EDGE") -aBaseObjectsList.append("Box_1_1/Front&Box_1_1/Right", "EDGE") -aBaseObjectsList.append("Box_1_1/Right&Box_1_1/Top", "EDGE") -aBaseObjectsList.append("Box_1_1/Back&Box_1_1/Top", "EDGE") -aBaseObjectsList.append("Box_1_1/Back&Box_1_1/Left", "EDGE") -aBaseObjectsList.append("Box_1_1/Left&Box_1_1/Bottom", "EDGE") +aBaseObjectsList.append("[Box_1_1/Front][Box_1_1/Bottom]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Front][Box_1_1/Right]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Right][Box_1_1/Top]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Back][Box_1_1/Top]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Back][Box_1_1/Left]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Left][Box_1_1/Bottom]", "EDGE") aSession.finishOperation() # Test results @@ -177,4 +177,4 @@ aSession.startOperation() aPart.removeFeature(aWireFeature3) aSession.finishOperation() -assert(model.checkPythonDump()) +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/src/BuildPlugin/Test/TestWire_ErrorMsg.py b/src/BuildPlugin/Test/TestWire_ErrorMsg.py new file mode 100644 index 000000000..d09d5da95 --- /dev/null +++ b/src/BuildPlugin/Test/TestWire_ErrorMsg.py @@ -0,0 +1,88 @@ +## Copyright (C) 2017-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() +aBoxResult = aBox.firstResult() +aBoxShape = aBoxResult.shape() + +aSession.startOperation() +Wire_1 = aPart.addFeature("Wire") +Wire_1.execute() +assert(Wire_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = Wire_1.selectionList("base_objects") +aBaseObjectsList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE") +aBaseObjectsList.append("[Box_1_1/Right][Box_1_1/Top]", "EDGE") +Wire_1.execute() +assert(Wire_1.error() != "") +aSession.finishOperation() + + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +Wire_1 = model.addWire(Part_1_doc, []) +Wire_1.addContour() +Part_1_doc.removeFeature(Wire_1.feature()) + +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")]) +Wire_1.addContour() +Part_1_doc.removeFeature(Wire_1.feature()) + +Wire_1 = model.addWire(Part_1_doc, [model.selection("FACE", "Box_1_1/Top")]) +Wire_1.addContour() +Part_1_doc.removeFeature(Wire_1.feature()) + +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(26.2037104714363, 14.67693246486999, 44.63854591961698, 30.23007341140914) +SketchLine_2 = Sketch_1.addLine(44.63854591961698, 30.23007341140914, 20.93564110678636, 53.45762191102688) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +model.do() + +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Wire_1.addContour() +Part_1_doc.removeFeature(Wire_1.feature()) + +model.end() diff --git a/src/CollectionAPI/CollectionAPI_Group.cpp b/src/CollectionAPI/CollectionAPI_Group.cpp index e6660beec..19fd1a44e 100644 --- a/src/CollectionAPI/CollectionAPI_Group.cpp +++ b/src/CollectionAPI/CollectionAPI_Group.cpp @@ -64,13 +64,19 @@ void CollectionAPI_Group::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionListPtr anAttrList = aBase->selectionList(CollectionPlugin_Group::LIST_ID()); - theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList << ")" << std::endl; + theDumper << aBase << " = model.addGroup(" << aDocName << ", " << anAttrList; + if (anAttrList->isGeometricalSelection()) + theDumper <<", True"; + theDumper << ")" << std::endl; } //================================================================================================== GroupPtr addGroup(const std::shared_ptr& thePart, - const std::list& theGroupList) + const std::list& theGroupList, + const bool theShareSameTopology) { std::shared_ptr aFeature = thePart->addFeature(CollectionAPI_Group::ID()); + if (theShareSameTopology) + aFeature->selectionList(CollectionPlugin_Group::LIST_ID())->setGeometricalSelection(true); return GroupPtr(new CollectionAPI_Group(aFeature, theGroupList)); } diff --git a/src/CollectionAPI/CollectionAPI_Group.h b/src/CollectionAPI/CollectionAPI_Group.h index bb92ff1b8..fe28fc2f4 100644 --- a/src/CollectionAPI/CollectionAPI_Group.h +++ b/src/CollectionAPI/CollectionAPI_Group.h @@ -70,6 +70,7 @@ typedef std::shared_ptr GroupPtr; /// \brief Create Group feature. COLLECTIONAPI_EXPORT GroupPtr addGroup(const std::shared_ptr& thePart, - const std::list& theGroupList); + const std::list& theGroupList, + const bool theShareSameTopology = false); #endif // CollectionAPI_Group_H_ diff --git a/src/CollectionPlugin/CMakeLists.txt b/src/CollectionPlugin/CMakeLists.txt index 674ea7e08..d383ace11 100644 --- a/src/CollectionPlugin/CMakeLists.txt +++ b/src/CollectionPlugin/CMakeLists.txt @@ -109,4 +109,5 @@ ADD_UNIT_TESTS( TestGroup1799.py TestGroupMove.py TestGroupMove2.py + TestGroupShareTopology.py ) diff --git a/src/CollectionPlugin/Test/TestField.py b/src/CollectionPlugin/Test/TestField.py index 3fc6ade66..de927057b 100644 --- a/src/CollectionPlugin/Test/TestField.py +++ b/src/CollectionPlugin/Test/TestField.py @@ -73,16 +73,10 @@ aLineCEndPoint.setValue(-100., 0.) aSession.finishOperation() # Build sketch faces aSession.startOperation() -aSketchResult = aTriangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aTriangleSketchFeature.firstResult()) # Create extrusion on them anExtrusionFt = aPart.addFeature("Extrusion") -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(50) @@ -98,9 +92,9 @@ aSession.startOperation() aField = aSession.activeDocument().addFeature("Field") aSelectionListAttr = aField.selectionList("selected") aSelectionListAttr.setSelectionType("vertex") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(2) # two components aComponentNames.setValue(0, "temperatue") @@ -127,7 +121,7 @@ aSession.startOperation() aField = aSession.activeDocument().addFeature("Field") aSelectionListAttr = aField.selectionList("selected") aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") +aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") @@ -153,7 +147,7 @@ aSession.startOperation() aField = aSession.activeDocument().addFeature("Field") aSelectionListAttr = aField.selectionList("selected") aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") +aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") @@ -177,7 +171,7 @@ aSession.startOperation() aField = aSession.activeDocument().addFeature("Field") aSelectionListAttr = aField.selectionList("selected") aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") +aSelectionListAttr.append("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") diff --git a/src/CollectionPlugin/Test/TestGroup.py b/src/CollectionPlugin/Test/TestGroup.py index 0ecbd0ddc..cab94e102 100644 --- a/src/CollectionPlugin/Test/TestGroup.py +++ b/src/CollectionPlugin/Test/TestGroup.py @@ -73,21 +73,13 @@ aLineCEndPoint.setValue(-100., 0.) aSession.finishOperation() # Build sketch faces aSession.startOperation() -aSketchResult = aTriangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aTriangleSketchFeature.firstResult()) # Create extrusion on them anExtrusionFt = aPart.addFeature("Extrusion") -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(50) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove anExtrusionFt.execute() aSession.finishOperation() anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) @@ -98,12 +90,12 @@ aSession.startOperation() aGroupFeature = aSession.activeDocument().addFeature("Group") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("vertex") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]") aSession.finishOperation() #========================================================================= # Check results @@ -118,15 +110,15 @@ aSession.startOperation() aGroupFeature = aSession.activeDocument().addFeature("Group") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("edge") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1") -aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1_1") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/From_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]") +aSelectionListAttr.append("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]") aSession.finishOperation() #========================================================================= # Check results @@ -175,7 +167,7 @@ aSession.startOperation() aGroupFeature = aSession.activeDocument().addFeature("Group") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("face") -aSelectionListAttr.append("Extrusion_1_1/To_Face_1_1") +aSelectionListAttr.append("Extrusion_1_1/To_Face") aSession.finishOperation() #========================================================================= # Check results @@ -206,26 +198,17 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert(len(aCircleSketchFaces) > 0) -assert(aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert(aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(50) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove anExtrusionFt.execute() aSession.finishOperation() aCylinderBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) diff --git a/src/CollectionPlugin/Test/TestGroup1799.py b/src/CollectionPlugin/Test/TestGroup1799.py index cacc2aeac..2bf63ad69 100644 --- a/src/CollectionPlugin/Test/TestGroup1799.py +++ b/src/CollectionPlugin/Test/TestGroup1799.py @@ -114,13 +114,13 @@ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 250) SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_9.result(), SketchLine_11.result()) SketchConstraintEqual_5 = Sketch_1.setEqual(SketchLine_7.result(), SketchLine_2.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_5f-SketchLine_6f-SketchLine_9r-SketchLine_10r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchCircle_1_2r-SketchLine_7f-SketchLine_9f-SketchLine_12r"), model.selection("FACE", "Sketch_1/Face-SketchLine_4f-SketchCircle_1_2r-SketchLine_8f-SketchLine_11r-SketchLine_12f"), model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchCircle_1_2r-SketchLine_10f-SketchLine_11f")], model.selection(), 150, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/To_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_3"), model.selection("FACE", "Extrusion_1_1/To_Face_2")]) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_15"), 150, True) -Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_7"), 150, True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_10r-SketchCircle_1_2r-SketchLine_9r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_9f-SketchCircle_1_2r-SketchLine_12r-SketchLine_7f"), model.selection("FACE", "Sketch_1/Face-SketchLine_4f-SketchLine_12f-SketchCircle_1_2r-SketchLine_11r-SketchLine_8f"), model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchLine_11f-SketchCircle_1_2r-SketchLine_10f")], model.selection(), 150, 0) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1_4/To_Face"), model.selection("FACE", "Extrusion_1_1_3/To_Face"), model.selection("FACE", "Extrusion_1_1_2/To_Face")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_6"), 150, True) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_4"), 150, True) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_1"), model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("FACE", "Plane_2")]) -Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1_7/Modified_Face_2_4"), 110, True) -Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1_5/Modified_Face_3_4"), 380, True) +Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1_7/Modified_Face&Sketch_1/SketchLine_3"), 110, True) +Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Partition_1_1_5/Modified_Face&Sketch_1/SketchLine_8"), 380, True) Partition_2 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_3"), model.selection("COMPSOLID", "Partition_1_1"), model.selection("FACE", "Plane_4")]) model.do() diff --git a/src/CollectionPlugin/Test/TestGroupMove.py b/src/CollectionPlugin/Test/TestGroupMove.py index dd1e0c17f..604989e39 100644 --- a/src/CollectionPlugin/Test/TestGroupMove.py +++ b/src/CollectionPlugin/Test/TestGroupMove.py @@ -30,8 +30,8 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 20, 10, 10) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), 10, True) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Box_1_1/Left&Box_1_1/Top")]) -Group_2 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Top")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")]) +Group_2 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")]) model.do() # move groups diff --git a/src/CollectionPlugin/Test/TestGroupMove2.py b/src/CollectionPlugin/Test/TestGroupMove2.py index 0f06d1dfd..2fc004aec 100644 --- a/src/CollectionPlugin/Test/TestGroupMove2.py +++ b/src/CollectionPlugin/Test/TestGroupMove2.py @@ -28,8 +28,8 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 20) -Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Right&Box_1_1/Top"), model.selection("VERTEX", "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top"), model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom")) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Top")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]")) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")]) Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPSOLID", "Partition_1_1")) Remove_SubShapes_1.setSubShapesToKeep([model.selection("SOLID", "Partition_1_1_2")]) diff --git a/src/CollectionPlugin/Test/TestGroupShareTopology.py b/src/CollectionPlugin/Test/TestGroupShareTopology.py new file mode 100644 index 000000000..6b0b69e1d --- /dev/null +++ b/src/CollectionPlugin/Test/TestGroupShareTopology.py @@ -0,0 +1,51 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from GeomAPI import * +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 3, [model.selection("SOLID", "Box_1_1")]) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_1 = Sketch_1.addCircle(4.69238908106919, 4.989364948318125, 5.746414396356567) +ExtrusionCut_1.setNestedSketch(Sketch_1) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Box_1_1/Top&weak_name_1")]) +model.do() +# enable geometrical selection mode => 4 faces must be selected as one compound +Group_1.groupList().setGeometricalSelection(True) +model.do() +assert(Group_1.groupList().size() == 1) +assert(Group_1.groupList().value(0).value().shapeType() == GeomAPI_Shape.COMPOUND) + +# disable geometrical selection mode => 4 faces must be selected as 4 group elements +Group_1.groupList().setGeometricalSelection(False) +model.end() + +assert(Group_1.groupList().size() == 4) +assert(Group_1.groupList().value(0).value().shapeType() == GeomAPI_Shape.FACE) +assert(Group_1.groupList().value(1).value().shapeType() == GeomAPI_Shape.FACE) +assert(Group_1.groupList().value(2).value().shapeType() == GeomAPI_Shape.FACE) +assert(Group_1.groupList().value(3).value().shapeType() == GeomAPI_Shape.FACE) diff --git a/src/CollectionPlugin/doc/groupFeature.rst b/src/CollectionPlugin/doc/groupFeature.rst index 0ff1eefb3..ccb658d4d 100644 --- a/src/CollectionPlugin/doc/groupFeature.rst +++ b/src/CollectionPlugin/doc/groupFeature.rst @@ -43,10 +43,9 @@ Input fields: :align: left Solids; -- The list of selected entities of the given type. Multiple selection can be done manually in OCC 3D Viewer by mouse click with Shift button pressed or by rectangle selection. - -To delete entities from the list, select them and call pop-up menu *Delete* item. +- The list of selected entities of the given type. Multiple selection can be done manually in OCC 3D Viewer by mouse click with Shift button pressed or by rectangle selection. To delete entities from the list, select them and call pop-up menu *Delete* item. +- Control **Add elements that share the same topology** allows to add automatically all elements laying on the same topology that was selected and remove these elements if they are disappeared due to the parametrical update. They will be represented as one line in the list of selection and managed in the viewer as one object if this flag is enabled. If flag becomes disabled when such elements are already in the list, they will become divided in one line per one shape. **TUI Command**: *model.addGroup(Part_1_doc, [model.selection("EDGE", "Cone_1_1/Face_1&Cone_1_1/Face_2"), model.selection("EDGE", "Cone_1_1/Face_1")])* diff --git a/src/CollectionPlugin/doc/images/group_property_panel.png b/src/CollectionPlugin/doc/images/group_property_panel.png index 4302628d3..1ae6dea67 100644 Binary files a/src/CollectionPlugin/doc/images/group_property_panel.png and b/src/CollectionPlugin/doc/images/group_property_panel.png differ diff --git a/src/CollectionPlugin/group_widget.xml b/src/CollectionPlugin/group_widget.xml index 4696d9e79..f892893bb 100644 --- a/src/CollectionPlugin/group_widget.xml +++ b/src/CollectionPlugin/group_widget.xml @@ -29,7 +29,8 @@ email : webmaster.salome@opencascade.com + filter_points="false" + same_topology="true"> \ No newline at end of file diff --git a/src/Config/CMakeLists.txt b/src/Config/CMakeLists.txt index 05bafb324..1918d4fa4 100644 --- a/src/Config/CMakeLists.txt +++ b/src/Config/CMakeLists.txt @@ -19,6 +19,7 @@ ## INCLUDE(Common) +INCLUDE(UnitTest) INCLUDE(XMLProcessing) FIND_PACKAGE(SWIG REQUIRED) INCLUDE(${SWIG_USE_FILE}) @@ -150,3 +151,8 @@ INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) INSTALL(TARGETS _ConfigAPI DESTINATION ${SHAPER_INSTALL_SWIG}) INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG}) + + +ADD_UNIT_TESTS( + TestConfig.py +) diff --git a/src/Config/ConfigAPI.i b/src/Config/ConfigAPI.i index 2bf42f1a0..f5fb5461a 100644 --- a/src/Config/ConfigAPI.i +++ b/src/Config/ConfigAPI.i @@ -29,8 +29,16 @@ #define CONFIG_EXPORT %include "typemaps.i" +%include "std_list.i" %include "std_string.i" +%include "std_vector.i" %include "Config_ModuleReader.h" %include "Config_PropManager.h" %include "Config_Prop.h" + +// std::list -> [] +%template(ListOfString) std::list< std::string >; +%template(listOfProp) std::list< Config_Prop* >; +// std::vector -> [] +%template(VectorOfInteger) std::vector; diff --git a/src/Config/Config_AttributeMessage.cpp b/src/Config/Config_AttributeMessage.cpp index 32051337c..d8f2f23e8 100644 --- a/src/Config/Config_AttributeMessage.cpp +++ b/src/Config/Config_AttributeMessage.cpp @@ -27,6 +27,7 @@ Config_AttributeMessage::Config_AttributeMessage(const Events_ID theId, const vo myFeatureId = std::string(); // Feature unique id myIsObligatory = true; myIsConcealment = false; + myIsGeometricalSelection = false; } Config_AttributeMessage::~Config_AttributeMessage() @@ -94,3 +95,13 @@ void Config_AttributeMessage::setMainArgument(bool isMainArg) { myIsMainArgument = isMainArg; } + +bool Config_AttributeMessage::isGeometricalSelection() const +{ + return myIsGeometricalSelection; +} + +void Config_AttributeMessage::setGeometricalSelection(bool isGeometricalSelection) +{ + myIsGeometricalSelection = isGeometricalSelection; +} diff --git a/src/Config/Config_AttributeMessage.h b/src/Config/Config_AttributeMessage.h index cb4ef232c..4df9cd8b4 100644 --- a/src/Config/Config_AttributeMessage.h +++ b/src/Config/Config_AttributeMessage.h @@ -42,6 +42,7 @@ class Config_AttributeMessage : public Events_Message bool myIsObligatory; ///< Required to be set by user, else it's feature is invalid. bool myIsConcealment; ///< If true, conceals features used as input bool myIsMainArgument; ///< Mark attribute as a main argument of the feature + bool myIsGeometricalSelection; ///< If true selects geometry instead of shape; ///< a list of pairs, if the attribute is placed inside paged containers: (case, switch) std::list > myCases; @@ -69,6 +70,8 @@ public: CONFIG_EXPORT bool isConcealment() const; /// Returns true if attribute is a main argument of the feature CONFIG_EXPORT bool isMainArgument() const; + /// Returns true if attribute selects geometry instead of shape; + CONFIG_EXPORT bool isGeometricalSelection() const; /// Returns container of ids of pair of a case and switches CONFIG_EXPORT const std::list >& getCases() const; /// Sets ids of pair of a case and switches @@ -84,6 +87,8 @@ public: CONFIG_EXPORT void setObligatory(bool isObligatory); /// Set a state that the attribute is a main argument of the feature CONFIG_EXPORT void setMainArgument(bool isMainArg); + /// Set attribute's geometrical selection state + CONFIG_EXPORT void setGeometricalSelection(bool isGeometricalSelection); }; #endif // ATTRIBUTE_MESSAGE_H diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 377cb364e..ac7fdbe6c 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -89,6 +89,9 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) aMessage->setConcealment(isConcealment); bool isMainArg = isConcealment && getBooleanAttribute(theNode, ATTR_MAIN_ARG, false); aMessage->setMainArgument(isMainArg); + aMessage->setGeometricalSelection(getBooleanAttribute(theNode, + ATTR_GEOMETRICAL_SELECTION, + false)); std::list > aCases; xmlNodePtr aCaseNode = hasParentRecursive(theNode, diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index beb599b20..eb3085ce6 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -100,6 +100,8 @@ const static char* ATTR_USE_RESET = "use_reset"; const static char* ATTR_GREED = "greed"; const static char* ATTR_MODIFIED_IN_EDIT = "modified_in_edit"; const static char* ATTR_MAIN_ARG = "main_argument"; +const static char* ATTR_GEOMETRICAL_SELECTION = "geometrical_selection"; + // WDG_INFO properties const static char* INFO_WDG_TEXT = FEATURE_TEXT; diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index 4f6530dd3..e754039e3 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -24,7 +24,10 @@ std::vector stringToRGB(const std::string& theColor); int stringToInteger(const std::string& theInt); bool stringToBoolean(const std::string& theInt); -Config_Properties Config_PropManager::myProps; +Config_Properties& Config_PropManager::props() { + static Config_Properties* confProps = new Config_Properties(); + return *confProps; +} Config_Prop* Config_PropManager::registerProp(const std::string& theSection, @@ -54,7 +57,7 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection, else { aProp = new Config_Prop(theSection, theName, theTitle, theType, theDefaultValue, theMin, theMax); - myProps.push_back(aProp); + props().push_back(aProp); } return aProp; } @@ -62,7 +65,8 @@ Config_Prop* Config_PropManager::registerProp(const std::string& theSection, Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName) { Config_Properties::const_iterator aIt; - for (aIt = myProps.cbegin(); aIt != myProps.cend(); ++aIt) { + Config_Properties aProps = props(); + for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) { Config_Prop* aProp = (*aIt); if ((aProp->section() == theSection) && (aProp->name() == theName)) return aProp; @@ -74,7 +78,8 @@ Config_Properties Config_PropManager::getProperties() { Config_Properties aRes; Config_Properties::const_iterator aIt; - for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) { + Config_Properties aProps = props(); + for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) { Config_Prop* aProp = (*aIt); if (aProp->type() != Config_Prop::Disabled) aRes.push_back(aProp); @@ -87,7 +92,8 @@ std::list Config_PropManager::getSections() // Return only non disabled sections std::list aSections; Config_Properties::const_iterator aIt; - for (aIt = myProps.cbegin(); aIt != myProps.cend(); aIt++) { + Config_Properties aProps = props(); + for (aIt = aProps.cbegin(); aIt != aProps.cend(); aIt++) { const Config_Prop* aProp = (*aIt); if (aProp->type() != Config_Prop::Disabled) aSections.push_back(aProp->section()); @@ -100,7 +106,8 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio { Config_Properties aRes; Config_Properties::iterator aIt; - for (aIt = myProps.begin(); aIt != myProps.end(); aIt++) { + Config_Properties aProps = props(); + for (aIt = aProps.begin(); aIt != aProps.end(); aIt++) { Config_Prop* aProp = (*aIt); if ((aProp->section() == theSection) && (aProp->type() != Config_Prop::Disabled)) aRes.push_back(aProp); diff --git a/src/Config/Config_PropManager.h b/src/Config/Config_PropManager.h index 00dd75b73..7e03659ad 100644 --- a/src/Config/Config_PropManager.h +++ b/src/Config/Config_PropManager.h @@ -91,7 +91,7 @@ class Config_PropManager CONFIG_EXPORT static double stringToDouble(const std::string& theDouble); private: - CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties + CONFIG_EXPORT static Config_Properties& props(); ///< List of all stored properties }; #endif diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index f7af50c8f..2149feba0 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -60,6 +60,7 @@ Config_XMLReader::~Config_XMLReader() xmlFreeDoc(myXmlDoc); } +// LCOV_EXCL_START std::string Config_XMLReader::resourcesConfigFile() { std::string aValue; @@ -91,6 +92,7 @@ std::string Config_XMLReader::pluginConfigFile() } return aValue; } +// LCOV_EXCL_STOP std::string Config_XMLReader::findConfigFile(const std::string theFileName, const int theFindIndex) { @@ -115,6 +117,7 @@ std::string Config_XMLReader::findConfigFile(const std::string theFileName, cons if (!anEnv) continue; if (aSolution > 2) { // there may be several paths separated by ";" symbol +// LCOV_EXCL_START std::string anEnvPart = anEnv; size_t aPosStart = 0, aPosEnd; for(int aSubNum = 0; aSubNum < aSolution - 3; aSubNum++) { @@ -130,6 +133,7 @@ std::string Config_XMLReader::findConfigFile(const std::string theFileName, cons aPosEnd = anEnvPart.find(';', aPosStart); aFileName = anEnvPart.substr(aPosStart, aPosEnd == std::string::npos ? aPosEnd : aPosEnd - aPosStart) + FSEP; +// LCOV_EXCL_STOP } else { aFileName = std::string(anEnv) + FSEP; } @@ -189,10 +193,12 @@ void Config_XMLReader::cleanup(xmlNodePtr) // do nothing; } +// LCOV_EXCL_START bool Config_XMLReader::processChildren(xmlNodePtr aNode) { return true; } +// LCOV_EXCL_STOP xmlNodePtr Config_XMLReader::findRoot(const std::string theDocumentPath) { @@ -234,10 +240,12 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent) } } +// LCOV_EXCL_START xmlNodePtr Config_XMLReader::node(void* theNode) { return static_cast(theNode); } +// LCOV_EXCL_STOP std::string Config_XMLReader::getNodeName(xmlNodePtr theNode) { @@ -258,10 +266,12 @@ void Config_XMLReader::storeAttribute(xmlNodePtr theNode, const char* theAttribu } } +// LCOV_EXCL_START std::string Config_XMLReader::restoreAttribute(xmlNodePtr theNode, const char* theAttribute) { return restoreAttribute(getNodeName(theNode).c_str(), theAttribute); } +// LCOV_EXCL_STOP std::string Config_XMLReader::restoreAttribute(const char* theNodeName, const char* theAttribute) { @@ -290,7 +300,9 @@ bool Config_XMLReader::cleanupAttribute(const char* theNodeName, const char* the return result; } +// LCOV_EXCL_START const char* Config_XMLReader::encoding() const { return (const char*) myXmlDoc->encoding; -} \ No newline at end of file +} +// LCOV_EXCL_STOP diff --git a/src/Config/Test/TestConfig.py b/src/Config/Test/TestConfig.py new file mode 100644 index 000000000..a98d534fc --- /dev/null +++ b/src/Config/Test/TestConfig.py @@ -0,0 +1,42 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +from ConfigAPI import * + +# register boolean property +Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean) +# check property once again +Config_PropManager().registerProp("TestSection", "PropBool", "PropTitle", Config_Prop.Boolean, "true") +# check property value +assert(Config_PropManager().boolean("TestSection", "PropBool")) + +# register real property +Config_PropManager().registerProp("TestSection", "PropDouble", "PropTitle", Config_Prop.Double, "12,5") +# check property (',' should be substituted by ".") +assert(Config_PropManager().real("TestSection", "PropDouble") == 12.5) + +# register color property +Config_PropManager().registerProp("TestSection", "PropColor", "PropTitle", Config_Prop.Color, "#B00F00") +assert(len(Config_PropManager().color("TestSection", "PropColor")) == 3) + +# check sections and properties are not empty +assert(len(Config_PropManager().getSections()) > 0) +assert(len(Config_PropManager().getProperties()) > 0) diff --git a/src/ConnectorAPI/Test/TestExportToGEOM.py b/src/ConnectorAPI/Test/TestExportToGEOM.py index c5e567add..96f8ce509 100644 --- a/src/ConnectorAPI/Test/TestExportToGEOM.py +++ b/src/ConnectorAPI/Test/TestExportToGEOM.py @@ -86,8 +86,8 @@ def testSeveralExportsToGEOM(): Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Box_2 = model.addBox(Part_1_doc, 20, 20, 20) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), -10) - Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Box_2_1")]) - Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Partition_1_1_1/Modified_Face_1_2"), model.selection("FACE", "Box_2_1/Top")]) + Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Translation_1_1"), model.selection("SOLID", "Box_2_1")]) + Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"), model.selection("FACE", "Box_2_1/Top")]) model.do() model.end() diff --git a/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py b/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py index ca2b9045a..114ca9f61 100644 --- a/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py +++ b/src/ConnectorAPI/Test/TestExportToGEOMAllGroupsAndFields.py @@ -89,13 +89,13 @@ def testGroupsAndFieldsExportToGEOM(): Box_3 = model.addBox(Part_1_doc, 10, 10, 10) Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), 20) Translation_2.result().setName("Translation_2_1") - Group_1_objects = [model.selection("FACE", "Translation_1_1/Translated_Face_1"), model.selection("FACE", "Box_2_1/Top"), model.selection("FACE", "Translation_2_1/Translated_Face_1")] + Group_1_objects = [model.selection("FACE", "Translation_1_1/MF:Translated&Box_1_1/Top"), model.selection("FACE", "Box_2_1/Top"), model.selection("FACE", "Translation_2_1/MF:Translated&Box_3_1/Top")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) Group_1.result().setName("faces_top") - Group_2_objects = [model.selection("EDGE", "Partition_1_1_1/Modified_Face_1_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("EDGE", "Partition_1_1_2/Modified_Face_2_2&Partition_1_1_2/Modified_Face_2_1"), model.selection("EDGE", "Translation_2_1/Translated_Face_4&Translation_2_1/Translated_Face_2")] + Group_2_objects = [model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Left][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("EDGE", "[Partition_1_1_2/Modified_Face&Box_2_1/Left][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("EDGE", "[Translation_2_1/MF:Translated&Box_3_1/Left][Translation_2_1/MF:Translated&Box_3_1/Bottom]")] Group_2 = model.addGroup(Part_1_doc, Group_2_objects) Group_2.result().setName("edges_x") - Group_3_objects = [model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_4&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_3&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Translation_2_1/Translated_Face_6&Translation_2_1/Translated_Face_3&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Box_2_1/Front&Box_2_1/Right&Partition_1_1_2/Modified_Face_2_1"), model.selection("VERTEX", "Partition_1_1_2/Modified_Face_2_divided_1_1&Box_2_1/Right&Partition_1_1_2/Modified_Face_2_1"), model.selection("VERTEX", "Partition_1_1_1/Modified_Face_1_1&Translation_1_1/Translated_Face_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Translation_1_1/Translated_Face_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Partition_1_1_1/Modified_Face_1_3&Partition_1_1_1/Modified_Face_1_2")] + Group_3_objects = [model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Left][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Right][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Back][Translation_2_1/MF:Translated&Box_3_1/Right][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Box_2_1/Front][Box_2_1/Right][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("VERTEX", "[(Partition_1_1_2/Modified_Face&Box_2_1/Back&Box_1_1/Front)(Partition_1_1_2/Modified_Face&Box_2_1/Left)(Box_2_1/Right)(Partition_1_1_2/Modified_Face&Box_2_1/Bottom)(Box_2_1/Top)][Box_2_1/Right][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("VERTEX", "[Partition_1_1_1/Modified_Face&Box_2_1/Back&Box_1_1/Front][Translation_1_1/MF:Translated&Box_1_1/Right][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Translation_1_1/MF:Translated&Box_1_1/Right][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Partition_1_1_1/Modified_Face&Box_1_1/Left][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]")] Group_3 = model.addGroup(Part_1_doc, Group_3_objects) Group_3.result().setName("vertices_bottom") Group_4 = model.addGroup(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Translation_2_1")]) @@ -104,15 +104,15 @@ def testGroupsAndFieldsExportToGEOM(): Field_1 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], Field_1_objects) Field_1.result().setName("Field_solids") Field_1.addStep(0, 0, [[0], [1], [2], [3]]) - Field_2_objects = [model.selection("FACE", "Partition_1_1_1/Modified_Face_1_2"), model.selection("FACE", "Partition_1_1_2/Modified_Face_2_1"), model.selection("FACE", "Translation_2_1/Translated_Face_2"), model.selection("FACE", "Translation_1_1/Translated_Face_1"), model.selection("FACE", "Box_2_1/Top"), model.selection("FACE", "Translation_2_1/Translated_Face_1")] + Field_2_objects = [model.selection("FACE", "Partition_1_1_1/Modified_Face&Box_1_1/Bottom"), model.selection("FACE", "Partition_1_1_2/Modified_Face&Box_2_1/Bottom"), model.selection("FACE", "Translation_2_1/MF:Translated&Box_3_1/Bottom"), model.selection("FACE", "Translation_1_1/MF:Translated&Box_1_1/Top"), model.selection("FACE", "Box_2_1/Top"), model.selection("FACE", "Translation_2_1/MF:Translated&Box_3_1/Top")] Field_2 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], Field_2_objects) Field_2.result().setName("Field_faces") Field_2.addStep(0, 0, [[0], [1], [1], [1], [2], [2], [2]]) - Field_3_objects = [model.selection("EDGE", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_4"), model.selection("EDGE", "Translation_2_1/Translated_Face_4&Translation_2_1/Translated_Face_2"), model.selection("EDGE", "Partition_1_1_2/Modified_Face_2_2&Partition_1_1_2/Modified_Face_2_1"), model.selection("EDGE", "Partition_1_1_1/Modified_Face_1_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("EDGE", "Translation_1_1/Translated_Face_6&Partition_1_1_1/Modified_Face_1_3"), model.selection("EDGE", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_3"), model.selection("EDGE", "Translation_1_1/Translated_Face_6&Translation_1_1/Translated_Face_3"), model.selection("EDGE", "Box_2_1/Front&Box_2_1/Right"), model.selection("EDGE", "Box_2_1/Right&Box_2_1/Top"), model.selection("EDGE", "Partition_1_1_2/Modified_Face_2_divided_1_1&Box_2_1/Right"), model.selection("EDGE", "Box_2_1/Right&Partition_1_1_2/Modified_Face_2_1")] + Field_3_objects = [model.selection("EDGE", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Left]"), model.selection("EDGE", "[Translation_2_1/MF:Translated&Box_3_1/Left][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("EDGE", "[Partition_1_1_2/Modified_Face&Box_2_1/Left][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("EDGE", "[Partition_1_1_1/Modified_Face&Box_1_1/Left][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("EDGE", "[Translation_1_1/MF:Translated&Box_1_1/Back][Partition_1_1_1/Modified_Face&Box_1_1/Left]"), model.selection("EDGE", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Right]"), model.selection("EDGE", "[Translation_1_1/MF:Translated&Box_1_1/Back][Translation_1_1/MF:Translated&Box_1_1/Right]"), model.selection("EDGE", "[Box_2_1/Front][Box_2_1/Right]"), model.selection("EDGE", "[Box_2_1/Right][Box_2_1/Top]"), model.selection("EDGE", "[(Partition_1_1_2/Modified_Face&Box_2_1/Back&Box_1_1/Front)(Partition_1_1_2/Modified_Face&Box_2_1/Left)(Box_2_1/Right)(Partition_1_1_2/Modified_Face&Box_2_1/Bottom)(Box_2_1/Top)][Box_2_1/Right]"), model.selection("EDGE", "[Box_2_1/Right][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]")] Field_3 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], Field_3_objects) Field_3.result().setName("Field_edges") Field_3.addStep(0, 0, [[0], [1], [1], [1], [2], [2], [2], [2], [3], [3], [3], [3]]) - Field_4_objects = [model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Partition_1_1_1/Modified_Face_1_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Translation_1_1/Translated_Face_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("VERTEX", "Partition_1_1_1/Modified_Face_1_1&Translation_1_1/Translated_Face_3&Partition_1_1_1/Modified_Face_1_2"), model.selection("VERTEX", "Partition_1_1_2/Modified_Face_2_divided_1_1&Box_2_1/Right&Partition_1_1_2/Modified_Face_2_1"), model.selection("VERTEX", "Box_2_1/Front&Box_2_1/Right&Partition_1_1_2/Modified_Face_2_1"), model.selection("VERTEX", "Translation_2_1/Translated_Face_6&Translation_2_1/Translated_Face_3&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_3&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_4&Translation_2_1/Translated_Face_2"), model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Partition_1_1_1/Modified_Face_1_3&Translation_1_1/Translated_Face_1"), model.selection("VERTEX", "Translation_1_1/Translated_Face_6&Translation_1_1/Translated_Face_3&Translation_1_1/Translated_Face_1"), model.selection("VERTEX", "Partition_1_1_2/Modified_Face_2_divided_1_1&Partition_1_1_2/Modified_Face_2_2&Box_2_1/Top"), model.selection("VERTEX", "Partition_1_1_2/Modified_Face_2_divided_1_1&Box_2_1/Right&Box_2_1/Top"), model.selection("VERTEX", "Box_2_1/Front&Partition_1_1_2/Modified_Face_2_2&Box_2_1/Top"), model.selection("VERTEX", "Box_2_1/Front&Box_2_1/Right&Box_2_1/Top"), model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_4&Translation_2_1/Translated_Face_1"), model.selection("VERTEX", "Translation_2_1/Translated_Face_5&Translation_2_1/Translated_Face_3&Translation_2_1/Translated_Face_1")] + Field_4_objects = [model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Partition_1_1_1/Modified_Face&Box_1_1/Left][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Translation_1_1/MF:Translated&Box_1_1/Right][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("VERTEX", "[Partition_1_1_1/Modified_Face&Box_2_1/Back&Box_1_1/Front][Translation_1_1/MF:Translated&Box_1_1/Right][Partition_1_1_1/Modified_Face&Box_1_1/Bottom]"), model.selection("VERTEX", "[(Partition_1_1_2/Modified_Face&Box_2_1/Back&Box_1_1/Front)(Partition_1_1_2/Modified_Face&Box_2_1/Left)(Box_2_1/Right)(Partition_1_1_2/Modified_Face&Box_2_1/Bottom)(Box_2_1/Top)][Box_2_1/Right][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("VERTEX", "[Box_2_1/Front][Box_2_1/Right][Partition_1_1_2/Modified_Face&Box_2_1/Bottom]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Back][Translation_2_1/MF:Translated&Box_3_1/Right][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Right][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Left][Translation_2_1/MF:Translated&Box_3_1/Bottom]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Partition_1_1_1/Modified_Face&Box_1_1/Left][Translation_1_1/MF:Translated&Box_1_1/Top]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Box_1_1/Back][Translation_1_1/MF:Translated&Box_1_1/Right][Translation_1_1/MF:Translated&Box_1_1/Top]"), model.selection("VERTEX", "[(Partition_1_1_2/Modified_Face&Box_2_1/Back&Box_1_1/Front)(Partition_1_1_2/Modified_Face&Box_2_1/Left)(Box_2_1/Right)(Partition_1_1_2/Modified_Face&Box_2_1/Bottom)(Box_2_1/Top)][Partition_1_1_2/Modified_Face&Box_2_1/Left][Box_2_1/Top]"), model.selection("VERTEX", "[(Partition_1_1_2/Modified_Face&Box_2_1/Back&Box_1_1/Front)(Partition_1_1_2/Modified_Face&Box_2_1/Left)(Box_2_1/Right)(Partition_1_1_2/Modified_Face&Box_2_1/Bottom)(Box_2_1/Top)][Box_2_1/Right][Box_2_1/Top]"), model.selection("VERTEX", "[Box_2_1/Front][Partition_1_1_2/Modified_Face&Box_2_1/Left][Box_2_1/Top]"), model.selection("VERTEX", "[Box_2_1/Front][Box_2_1/Right][Box_2_1/Top]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Left][Translation_2_1/MF:Translated&Box_3_1/Top]"), model.selection("VERTEX", "[Translation_2_1/MF:Translated&Box_3_1/Front][Translation_2_1/MF:Translated&Box_3_1/Right][Translation_2_1/MF:Translated&Box_3_1/Top]")] Field_4 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], Field_4_objects) Field_4.result().setName("Field_vertices") Field_4.addStep(0, 0, [[0], [1], [1], [1], [1], [1], [1], [1], [1], [2], [2], [2], [2], [3], [3], [3], [3]]) diff --git a/src/ConstructionPlugin/CMakeLists.txt b/src/ConstructionPlugin/CMakeLists.txt index 3c5423b1f..9ddd0a2e3 100644 --- a/src/ConstructionPlugin/CMakeLists.txt +++ b/src/ConstructionPlugin/CMakeLists.txt @@ -78,6 +78,7 @@ INCLUDE_DIRECTORIES( ADD_UNIT_TESTS(TestAxisCreation.py + TestAxis_ErrorMsg.py UnitTestAxis.py TestPoint_XYZ.py TestPoint_IntersectLines.py @@ -90,4 +91,9 @@ ADD_UNIT_TESTS(TestAxisCreation.py TestPoint_GeometricalPropertyCenterOfCircle.py TestPoint_VertexSelection.py TestPointName.py - TestPlane.py) + TestPoint_ErrorMsg.py + TestPoint_FiniteValidator.py + TestPlane.py + TestPlane_ErrorMsg.py + TestPlane_FaceValidator.py +) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp index 5f4b2f8d6..857dfd739 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp @@ -33,7 +33,9 @@ #include #include #include +#include #include +#include #include #include @@ -162,16 +164,26 @@ void ConstructionPlugin_Axis::createAxisByPointAndDirection() void ConstructionPlugin_Axis::createAxisByCylindricalFace() { - std::shared_ptr aSelection = data()->selection(CYLINDRICAL_FACE())->value(); - // update arguments due to the selection value - if (aSelection && !aSelection->isNull() && aSelection->isFace()) { - std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection); - - ResultConstructionPtr aConstr = document()->createConstruction(data()); - aConstr->setInfinite(true); - aConstr->setShape(anEdge); - setResult(aConstr); - } + std::shared_ptr aSelection = data()->selection(CYLINDRICAL_FACE())->value(); + // update arguments due to the selection value + + if (!aSelection.get() || aSelection->isNull()) { + return; + } + + if (aSelection->isCompound()) { + GeomAPI_ShapeIterator anIt(aSelection); + aSelection = anIt.current(); + } + + if (aSelection->isFace()) { + std::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::cylinderAxis(aSelection); + + ResultConstructionPtr aConstr = document()->createConstruction(data()); + aConstr->setInfinite(true); + aConstr->setShape(anEdge); + setResult(aConstr); + } } void ConstructionPlugin_Axis::createAxisByDimensions() @@ -203,7 +215,36 @@ void ConstructionPlugin_Axis::createAxisByLine() if(!aLineShape.get()) { aLineShape = anEdgeSelection->context()->shape(); } - std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); + GeomEdgePtr anEdge; + if (aLineShape->isEdge()) { + anEdge = aLineShape->edge(); + } + else if (aLineShape->isCompound()) { + // create an edge which covers all edges from compounds (they are on the same line) + GeomPointPtr aFirst, aLast; + GeomXYZPtr aLineVec; + for(GeomAPI_ShapeIterator anIt(aLineShape); anIt.more(); anIt.next()) { + GeomEdgePtr aSub = anIt.current()->edge(); + if (aSub.get() && aSub->isLine()) { + if (!aLineVec.get()) { + aFirst = aSub->firstPoint(); + aLast = aSub->lastPoint(); + } else { // set aFirst and aLast by extreme points + GeomXYZPtr aFirstVec = aSub->firstPoint()->xyz()->decreased(aFirst->xyz()); + bool aSameDirection = + aSub->lastPoint()->xyz()->decreased(aSub->firstPoint()->xyz())->dot(aLineVec) > 0; + if (aLineVec->dot(aFirstVec) < -1.e-7) { // first point is changed + aFirst = aSameDirection ? aSub->firstPoint() : aSub->lastPoint(); + } else { // last point is changed + aLast = aSameDirection ? aSub->lastPoint() : aSub->firstPoint(); + } + } + aLineVec = aLast->xyz()->decreased(aFirst->xyz()); + } + } + if (aLineVec.get()) + anEdge = GeomAlgoAPI_EdgeBuilder::line(aFirst, aLast); + } ResultConstructionPtr aConstr = document()->createConstruction(data()); aConstr->setInfinite(true); @@ -219,7 +260,16 @@ void ConstructionPlugin_Axis::createAxisByPlaneAndPoint() if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); + GeomFacePtr aFace; + if (aFaceShape->isFace()) { + aFace = aFaceShape->face(); + } + else if (aFaceShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape); + aFace = anIt.current()->face(); + } + if (!aFace) + return; std::shared_ptr aPln = aFace->getPlane(); // Get point. @@ -253,7 +303,16 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes() if(!aFaceShape1.get()) { aFaceShape1 = aFaceSelection1->context()->shape(); } - std::shared_ptr aFace1(new GeomAPI_Face(aFaceShape1)); + std::shared_ptr aFace1; + if (aFaceShape1->isFace()) { + aFace1 = aFaceShape1->face(); + } + else if (aFaceShape1->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape1); + aFace1 = anIt.current()->face(); + } + if (!aFace1) + return; std::shared_ptr aPln1 = aFace1->getPlane(); std::string useOffset1 = string(USE_OFFSET1())->value(); @@ -272,7 +331,16 @@ void ConstructionPlugin_Axis::createAxisByTwoPlanes() if(!aFaceShape2.get()) { aFaceShape2 = aFaceSelection2->context()->shape(); } - std::shared_ptr aFace2(new GeomAPI_Face(aFaceShape2)); + std::shared_ptr aFace2; + if (aFaceShape2->isFace()) { + aFace2 = aFaceShape2->face(); + } + else if (aFaceShape2->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape2); + aFace2 = anIt.current()->face(); + } + if (!aFace2) + return; std::shared_ptr aPln2 = aFace2->getPlane(); std::string useOffset2 = string(USE_OFFSET2())->value(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp index ad046394a..9c3770bd4 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -231,7 +232,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByLineAndPoint() if(!aLineShape.get()) { aLineShape = anEdgeSelection->context()->shape(); } - std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); + std::shared_ptr anEdge; + if (aLineShape->isEdge()) { + anEdge = aLineShape->edge(); + } + else if (aLineShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aLineShape); + anEdge = anIt.current()->edge(); + } + if (!anEdge) + return GeomShapePtr(); // Get point. AttributeSelectionPtr aPointSelection = selection(POINT()); @@ -277,7 +287,7 @@ std::shared_ptr ConstructionPlugin_Plane::createByDistanceFromOth bool anIsReverse = boolean(REVERSE())->value(); if(anIsReverse) aDist = -aDist; GeomShapePtr aShape = aFaceAttr->value(); - if (!aShape.get()) { + if (!aShape.get() && aFaceAttr->context()) { aShape = aFaceAttr->context()->shape(); } @@ -285,7 +295,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByDistanceFromOth return aPlane; } - std::shared_ptr aFace(new GeomAPI_Face(aShape)); + std::shared_ptr aFace; + if (aShape->isFace()) { + aFace = aShape->face(); + } + else if (aShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aShape); + aFace = anIt.current()->face(); + } + if (!aFace) + return GeomShapePtr(); std::shared_ptr aPln = aFace->getPlane(); std::shared_ptr aOrig = aPln->location(); @@ -308,7 +327,14 @@ std::shared_ptr ConstructionPlugin_Plane::createByCoincidentPoint if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); + std::shared_ptr aFace; + if (aFaceShape->isFace()) { + aFace = aFaceShape->face(); + } + else if (aFaceShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape); + aFace = anIt.current()->face(); + } // Get point. AttributeSelectionPtr aPointSelection = selection(COINCIDENT_POINT()); @@ -316,7 +342,9 @@ std::shared_ptr ConstructionPlugin_Plane::createByCoincidentPoint if(!aPointShape.get()) { aPointShape = aPointSelection->context()->shape(); } - std::shared_ptr aVertex(new GeomAPI_Vertex(aPointShape)); + std::shared_ptr aVertex = aPointShape->vertex(); + if (!aVertex) + return GeomShapePtr(); std::shared_ptr anOrig = aVertex->point(); std::shared_ptr aPln = aFace->getPlane(); @@ -336,7 +364,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() if(!aFaceShape.get()) { aFaceShape = aFaceSelection->context()->shape(); } - std::shared_ptr aFace(new GeomAPI_Face(aFaceShape)); + std::shared_ptr aFace; + if (aFaceShape->isFace()) { + aFace = aFaceShape->face(); + } + else if (aFaceShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape); + aFace = anIt.current()->face(); + } + if (!aFace) + return GeomShapePtr(); aFace = makeRectangularFace(aFace, aFace->getPlane()); // Get axis. @@ -345,7 +382,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByRotation() if(!anAxisShape.get()) { anAxisShape = anAxisSelection->context()->shape(); } - std::shared_ptr anEdge(new GeomAPI_Edge(anAxisShape)); + std::shared_ptr anEdge; + if (anAxisShape->isEdge()) { + anEdge = anAxisShape->edge(); + } + else if (anAxisShape->isCompound()) { + GeomAPI_ShapeIterator anIt(anAxisShape); + anEdge = anIt.current()->edge(); + } + if (!anEdge) + return GeomShapePtr(); std::shared_ptr anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), @@ -378,7 +424,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByTwoParallelPlan if(!aFaceShape1.get()) { aFaceShape1 = aFaceSelection1->context()->shape(); } - std::shared_ptr aFace1(new GeomAPI_Face(aFaceShape1)); + std::shared_ptr aFace1; + if (aFaceShape1->isFace()) { + aFace1 = aFaceShape1->face(); + } + else if (aFaceShape1->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape1); + aFace1 = anIt.current()->face(); + } + if (!aFace1) + return GeomShapePtr(); std::shared_ptr aPln1 = aFace1->getPlane(); // Get plane 2. @@ -387,7 +442,16 @@ std::shared_ptr ConstructionPlugin_Plane::createByTwoParallelPlan if(!aFaceShape2.get()) { aFaceShape2 = aFaceSelection2->context()->shape(); } - std::shared_ptr aFace2(new GeomAPI_Face(aFaceShape2)); + std::shared_ptr aFace2; + if (aFaceShape2->isFace()) { + aFace2 = aFaceShape2->face(); + } + else if (aFaceShape2->isCompound()) { + GeomAPI_ShapeIterator anIt(aFaceShape2); + aFace2 = anIt.current()->face(); + } + if (!aFace2) + return GeomShapePtr(); std::shared_ptr aPln2 = aFace2->getPlane(); std::shared_ptr anOrig1 = aPln1->location(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index bb59c3d55..51432b609 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -36,6 +36,7 @@ #include #include #include +#include //================================================================================================== ConstructionPlugin_Point::ConstructionPlugin_Point() @@ -143,6 +144,7 @@ void ConstructionPlugin_Point::execute() removeResults(1); // for case the point type was switched from multi-results type std::shared_ptr aConstr = document()->createConstruction(data()); + aConstr->setInfinite(true); aConstr->setShape(aShape); setResult(aConstr); } @@ -270,7 +272,14 @@ std::list > if(!aLineShape.get()) { aLineShape = aLineSelection->context()->shape(); } - std::shared_ptr anEdge(new GeomAPI_Edge(aLineShape)); + GeomEdgePtr anEdge; + if (aLineShape->isEdge()) { + anEdge = aLineShape->edge(); + } + else if (aLineShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aLineShape); + anEdge = anIt.current()->edge(); + } // Get plane. AttributeSelectionPtr aPlaneSelection= selection(INTERSECTION_PLANE()); @@ -278,7 +287,14 @@ std::list > if(!aPlaneShape.get()) { aPlaneShape = aPlaneSelection->context()->shape(); } - std::shared_ptr aFace(new GeomAPI_Face(aPlaneShape)); + GeomFacePtr aFace; + if (aPlaneShape->isFace()) { + aFace = aPlaneShape->face(); + } + else if (aPlaneShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aPlaneShape); + aFace = anIt.current()->face(); + } if (!string(USE_OFFSET())->value().empty()) { double anOffset = real(OFFSET())->value(); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp index 2390b83a4..a06ef0fda 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Validators.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,7 @@ #include static std::shared_ptr getEdge(const GeomShapePtr theShape); +static std::shared_ptr getFace(const GeomShapePtr theShape); static std::shared_ptr getLin(const GeomShapePtr theShape); static std::shared_ptr getPln(const GeomShapePtr theShape); static std::shared_ptr getPnt(const GeomShapePtr theShape); @@ -114,7 +116,7 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid( AttributeSelectionPtr anAttribute2 = aFeature->selection(theArguments.front()); std::shared_ptr anEdge; - std::shared_ptr aPln; + std::shared_ptr aFace; GeomShapePtr aShape1 = anAttribute1->value(); ResultPtr aContext1 = anAttribute1->context(); @@ -137,20 +139,20 @@ bool ConstructionPlugin_ValidatorPointEdgeAndPlaneNotParallel::isValid( bool isPlaneFirst = false; anEdge = getEdge(aShape1); - aPln = getPln(aShape2); - if(!anEdge.get() || !aPln.get()) { + + aFace = getFace(aShape2); + if(!anEdge.get() || !aFace.get()) { anEdge = getEdge(aShape2); - aPln = getPln(aShape1); + aFace = getFace(aShape1); isPlaneFirst = true; } - if(!anEdge.get() || !aPln.get()) { + if(!anEdge.get() || !aFace.get()) { theError = "Wrong shape types selected."; return false; } - std::shared_ptr aPlaneFace(new GeomAPI_Face(isPlaneFirst ? aShape1 : aShape2)); - if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aPlaneFace)) { + if(GeomAlgoAPI_ShapeTools::isParallel(anEdge, aFace)) { theError = "Plane and edge are parallel."; return false; } @@ -474,25 +476,51 @@ bool ConstructionPlugin_ValidatorPointThreeNonParallelPlanes::isValid( std::shared_ptr getEdge(const GeomShapePtr theShape) { - if(!theShape->isEdge()) { - return std::shared_ptr(); - } + GeomEdgePtr anEdge; - std::shared_ptr anEdge(new GeomAPI_Edge(theShape)); + if(theShape->isEdge()) { + anEdge = theShape->edge(); + } + else if (theShape->isCompound()) { + GeomAPI_ShapeIterator anIt(theShape); + anEdge = anIt.current()->edge(); + } return anEdge; } +GeomFacePtr getFace(const GeomShapePtr theShape) +{ + GeomFacePtr aFace; + + if (theShape->isFace()) { + aFace = theShape->face(); + } + else if (theShape->isCompound()) { + GeomAPI_ShapeIterator anIt(theShape); + aFace = anIt.current()->face(); + } + + return aFace; +} + std::shared_ptr getLin(const GeomShapePtr theShape) { std::shared_ptr aLin; - if(!theShape->isEdge()) { + GeomEdgePtr anEdge; + + if (theShape->isEdge()) { + anEdge = theShape->edge(); + } + else if (theShape->isCompound()) { + GeomAPI_ShapeIterator anIt(theShape); + anEdge = anIt.current()->edge(); + } + else { return aLin; } - std::shared_ptr anEdge(new GeomAPI_Edge(theShape)); - if(!anEdge->isLine()) { return aLin; } @@ -506,13 +534,20 @@ std::shared_ptr getPln(const GeomShapePtr theShape) { std::shared_ptr aPln; - if(!theShape->isFace()) { + GeomFacePtr aFace; + + if(theShape->isFace()) { + aFace = theShape->face(); + } + else if (theShape->isCompound()) { + GeomAPI_ShapeIterator anIt(theShape); + aFace = anIt.current()->face(); + } + else { return aPln; } - std::shared_ptr aFace(new GeomAPI_Face(theShape)); - - if(!aFace->isPlanar()) { + if(!aFace || !aFace->isPlanar()) { return aPln; } diff --git a/src/ConstructionPlugin/Test/TestAxisCreation.py b/src/ConstructionPlugin/Test/TestAxisCreation.py index 642d83bde..c106b2dcb 100644 --- a/src/ConstructionPlugin/Test/TestAxisCreation.py +++ b/src/ConstructionPlugin/Test/TestAxisCreation.py @@ -107,22 +107,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(100) anExtrusionFt.real("from_size").setValue(0) @@ -145,7 +138,7 @@ anAxisFeature = aPart.addFeature("Axis") anAxisFeatureData = anAxisFeature.data() assert(anAxisFeatureData is not None) anAxisFeatureData.string("CreationMethod").setValue("AxisByCylindricalFaceCase") -anAxisFeatureData.selection("CylindricalFace").selectSubShape("face", "Extrusion_1_1/Generated_Face_1") +anAxisFeatureData.selection("CylindricalFace").selectSubShape("face", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2") anAxisFeature.execute() aSession.finishOperation() diff --git a/src/ConstructionPlugin/Test/TestAxis_ErrorMsg.py b/src/ConstructionPlugin/Test/TestAxis_ErrorMsg.py new file mode 100644 index 000000000..321512831 --- /dev/null +++ b/src/ConstructionPlugin/Test/TestAxis_ErrorMsg.py @@ -0,0 +1,120 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("Box_1_1/Front", "FACE") +aCompoundList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE") +aSession.finishOperation() + +# Create auxiliary box 2 +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound 2 +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("[Box_2_1/Left][Box_2_1/Top]", "EDGE") +aCompoundList.append("Box_2_1/Front", "FACE") +aSession.finishOperation() + + +# Axis by cylindrical face +aSession.startOperation() +Axis_1 = aPart.addFeature("Axis") +Axis_1.string("CreationMethod").setValue("AxisByCylindricalFaceCase") +Axis_1.selection("CylindricalFace").selectSubShape("COMPOUND", "Compound_2_1") +Axis_1.execute() +aSession.finishOperation() +assert(Axis_1.error() != "") + +# Axis by dimensions +aSession.startOperation() +Axis_1.string("CreationMethod").setValue("AxisByDimensionsCase") +Axis_1.real("DX").setValue(0) +Axis_1.real("DY").setValue(0) +Axis_1.real("DZ").setValue(0) +Axis_1.execute() +assert(Axis_1.error() != "") +aSession.finishOperation() + +# Axis by line +aSession.startOperation() +Axis_1.string("CreationMethod").setValue("by_line") +Axis_1.selection("line").selectSubShape("COMPOUND", "Compound_1_1") +Axis_1.execute() +assert(Axis_1.error() != "") +aSession.finishOperation() + +# Axis by plane and point +aSession.startOperation() +Axis_1.string("CreationMethod").setValue("by_plane_and_point") +Axis_1.selection("point").selectSubShape("COMPOUND", "Compound_1_1") +Axis_1.selection("plane").selectSubShape("COMPOUND", "Compound_2_1") +Axis_1.execute() +assert(Axis_1.error() != "") +aSession.finishOperation() + +# Axis by two planes +aSession.startOperation() +Axis_1.string("CreationMethod").setValue("by_two_planes") +Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_2_1") +Axis_1.selection("plane2").selectSubShape("COMPOUND", "Compound_2_1") +Axis_1.execute() +assert(Axis_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +Axis_1.selection("plane1").selectSubShape("COMPOUND", "Compound_1_1") +Axis_1.string("use_offset1").setValue("true") +Axis_1.real("offset1").setValue(10) +Axis_1.boolean("reverse_offset1").setValue(True) +Axis_1.execute() +assert(Axis_1.error() != "") +aSession.finishOperation() diff --git a/src/ConstructionPlugin/Test/TestPlane_ErrorMsg.py b/src/ConstructionPlugin/Test/TestPlane_ErrorMsg.py new file mode 100644 index 000000000..506b78b1a --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPlane_ErrorMsg.py @@ -0,0 +1,133 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("Box_1_1/Front", "FACE") +aCompoundList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE") +aSession.finishOperation() + +# Create auxiliary box 2 +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound 2 +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("[Box_2_1/Left][Box_2_1/Top]", "EDGE") +aCompoundList.append("Box_2_1/Front", "FACE") +aSession.finishOperation() + + +# Plane by line and point +aSession.startOperation() +Plane_1 = aPart.addFeature("Plane") +Plane_1.string("creation_method").setValue("by_line_and_point") +Plane_1.selection("line").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.selection("point").selectSubShape("VERTEX", "PartSet/Origin") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +# Unsupported type +aSession.startOperation() +Plane_1.string("creation_method").setValue("by_rotation") +Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.selection("axis").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +# By two parallel planes +aSession.startOperation() +Plane_1.string("creation_method").setValue("by_two_parallel_planes") +Plane_1.selection("plane1").selectSubShape("COMPOUND", "Compound_2_1") +Plane_1.selection("plane2").selectSubShape("COMPOUND", "Compound_2_1") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +Plane_1.selection("plane1").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +# By distance from other plane +aSession.startOperation() +Plane_1.string("creation_method").setValue("by_other_plane") +Plane_1.string("by_other_plane_option").setValue("by_distance_from_other") +Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_2_1") +Plane_1.real("distance").setValue(10) +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +# By coincident point +aSession.startOperation() +Plane_1.string("by_other_plane_option").setValue("by_coincident_to_point") +Plane_1.selection("coincident_point").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +# By rotation +aSession.startOperation() +Plane_1.string("by_other_plane_option").setValue("by_rotation") +Plane_1.selection("axis").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.real("angle").setValue(90) +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +Plane_1.selection("plane").selectSubShape("COMPOUND", "Compound_1_1") +Plane_1.execute() +assert(Plane_1.error() != "") +aSession.finishOperation() diff --git a/src/ConstructionPlugin/Test/TestPlane_FaceValidator.py b/src/ConstructionPlugin/Test/TestPlane_FaceValidator.py new file mode 100644 index 000000000..d2890a423 --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPlane_FaceValidator.py @@ -0,0 +1,38 @@ +## Copyright (C) 2018-20xx 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() +Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sphere_1_1/Face_1")]) + +Plane_1 = model.addPlane(Part_1_doc, model.selection("COMPOUND", (0, 0, 0)), 10, False) +assert(Plane_1.feature().error() != "") +Part_1_doc.removeFeature(Plane_1.feature()) + +Plane_1 = model.addPlane(Part_1_doc, model.selection("EDGE", "[Compound_1_1_1/Compound_1_1_1&Sphere_1_1/Face_1][weak_name_3]"), 10, False) +assert(Plane_1.feature().error() != "") +Part_1_doc.removeFeature(Plane_1.feature()) + +model.end() diff --git a/src/ConstructionPlugin/Test/TestPoint_Edge.py b/src/ConstructionPlugin/Test/TestPoint_Edge.py index 4f6c5ef88..d7f0db6fc 100644 --- a/src/ConstructionPlugin/Test/TestPoint_Edge.py +++ b/src/ConstructionPlugin/Test/TestPoint_Edge.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by coordinates. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -35,15 +34,17 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/O SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result()) model.do() -Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 50, False, False) -Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 0.4, True, False) -Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 0.4, True, True) +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), 50, False, False) +Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), 0.4, True, False) +Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), 0.4, True, True) Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 50, 10) -Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), 0.25, True, False) -Point_6 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), 0.25, True, True) +Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), 0.25, True, False) +Point_6 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), 0.25, True, True) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(35.3553390593, 35.3553390593, 0) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_ErrorMsg.py b/src/ConstructionPlugin/Test/TestPoint_ErrorMsg.py new file mode 100644 index 000000000..2d711644f --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPoint_ErrorMsg.py @@ -0,0 +1,77 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("Box_1_1/Front", "FACE") +aCompoundList.append("[Box_1_1/Left][Box_1_1/Top]", "EDGE") +aSession.finishOperation() + +# Create auxiliary box 2 +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound 2 +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompoundList = aCompound.selectionList("base_objects") +aCompoundList.append("[Box_2_1/Left][Box_2_1/Top]", "EDGE") +aCompoundList.append("Box_2_1/Front", "FACE") +aSession.finishOperation() + + +# Point by line and plane +aSession.startOperation() +Point_1 = aPart.addFeature("Point") +Point_1.string("creation_method").setValue("by_intersection") +Point_1.string("intersection_type").setValue("intersection_type_by_line_and_plane") +Point_1.selection("intersection_line").selectSubShape("COMPOUND", "Compound_1_1") +Point_1.selection("intersection_plane").selectSubShape("COMPOUND", "Compound_2_1") +Point_1.execute() +assert(Point_1.error() != "") +aSession.finishOperation() diff --git a/src/ConstructionPlugin/Test/TestPoint_FiniteValidator.py b/src/ConstructionPlugin/Test/TestPoint_FiniteValidator.py new file mode 100644 index 000000000..485b888f6 --- /dev/null +++ b/src/ConstructionPlugin/Test/TestPoint_FiniteValidator.py @@ -0,0 +1,31 @@ +## Copyright (C) 2018-20xx 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() + +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "PartSet/OZ"), 10, False, False) +assert(Point_2.feature().error() != "") + +model.end() diff --git a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py index e08fa1158..57a34b551 100644 --- a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py +++ b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfCircle.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by center of gravity. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -34,12 +33,14 @@ SketchCircle_1 = Sketch_1.addCircle(-50, 25, 25) SketchArc_1 = Sketch_1.addArc(50, 25, 25, 25, 75, 25, True) model.do() Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 100) -Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2"), True) -Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), True) -Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), True) +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchCircle_1_2"), True) +Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchArc_1_2"), True) +Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), True) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(-50, 25, 0) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py index 933252369..d9a0a5b38 100644 --- a/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py +++ b/src/ConstructionPlugin/Test/TestPoint_GeometricalPropertyCenterOfGravity.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by center of gravity. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -37,10 +36,12 @@ Box_1 = model.addBox(Part_1_doc, 50, 50, 50) Point_2 = model.addPoint(Part_1_doc, model.selection("COMPOUND", "Sketch_1")) Point_3 = model.addPoint(Part_1_doc, model.selection("SOLID", "Box_1_1")) Point_4 = model.addPoint(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) -Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "Box_1_1/Left&Box_1_1/Top")) +Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(0, 0, 25) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_IntersectLineAndPlane.py b/src/ConstructionPlugin/Test/TestPoint_IntersectLineAndPlane.py index 635ab8102..5ff71ee02 100644 --- a/src/ConstructionPlugin/Test/TestPoint_IntersectLineAndPlane.py +++ b/src/ConstructionPlugin/Test/TestPoint_IntersectLineAndPlane.py @@ -38,14 +38,14 @@ SketchArc_1 = Sketch_2.addArc(0, 0, -65.89631323066888, 61.2998850129882, -90, 0 model.do() # point by sketch face and a line -Point_1 = model.addPoint(partSet, model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")) +Point_1 = model.addPoint(partSet, model.selection("EDGE", "Sketch_2/SketchLine_1"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")) model.do() # check the point position rightPosition = GeomAPI_Vertex(-15, 0, 0) assert(rightPosition.isEqual(Point_1.results()[0].resultSubShapePair()[0].shape())) # point by sketch face and an arc, intersection outside of the face, offset is defined -Point_2 = model.addPoint(partSet, model.selection("EDGE", "Sketch_2/Edge-SketchArc_1"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), 10, True) +Point_2 = model.addPoint(partSet, model.selection("EDGE", "Sketch_2/SketchArc_1_2"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), 10, True) # check the point position rightPosition = GeomAPI_Vertex(-89.442719099991606, 0, -10) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_IntersectLines.py b/src/ConstructionPlugin/Test/TestPoint_IntersectLines.py index f3b08471a..239d4eadd 100644 --- a/src/ConstructionPlugin/Test/TestPoint_IntersectLines.py +++ b/src/ConstructionPlugin/Test/TestPoint_IntersectLines.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by lines intersection. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -35,11 +34,13 @@ SketchPoint_1 = SketchProjection_1.createdFeature() SketchLine_1 = Sketch_1.addLine(-50, 50, 50, 50) model.do() Box_1 = model.addBox(Part_1_doc, 25, 100, 100) -Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Box_1_1/Back&Box_1_1/Bottom"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) -Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom")) +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Bottom]"), model.selection("EDGE", "Sketch_1/SketchLine_1")) +Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]")) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(0, 50, 0) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py b/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py index af44576ac..0bfe96d4b 100644 --- a/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py +++ b/src/ConstructionPlugin/Test/TestPoint_ProjectOnEdge.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by coordinates. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -34,11 +33,13 @@ SketchCircle_1 = Sketch_1.addCircle(0, 0, 100) SketchPoint_1 = Sketch_1.addPoint(100, 100) model.do() Box_1 = model.addBox(Part_1_doc, 50, 50, 50) -Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")) -Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right")) +Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("EDGE", "Sketch_1/SketchCircle_1_2")) +Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]")) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(70.7106781187, 70.7106781187, 0) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_ProjectOnFace.py b/src/ConstructionPlugin/Test/TestPoint_ProjectOnFace.py index 1b5218ea7..0ed88039c 100644 --- a/src/ConstructionPlugin/Test/TestPoint_ProjectOnFace.py +++ b/src/ConstructionPlugin/Test/TestPoint_ProjectOnFace.py @@ -23,7 +23,6 @@ Test case for Construction Point feature by projection point on face. """ from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() @@ -33,11 +32,13 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchPoint_1 = Sketch_1.addPoint(50, 50) model.do() Box_1 = model.addBox(Part_1_doc, 10, 100, 100) -Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("FACE", "Box_1_1/Front")) -Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("FACE", "PartSet/XOY")) +Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("FACE", "Box_1_1/Front")) +Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("FACE", "PartSet/XOY")) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(10, 0, 50) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/Test/TestPoint_VertexSelection.py b/src/ConstructionPlugin/Test/TestPoint_VertexSelection.py index 8180742aa..de2e7b8c9 100644 --- a/src/ConstructionPlugin/Test/TestPoint_VertexSelection.py +++ b/src/ConstructionPlugin/Test/TestPoint_VertexSelection.py @@ -18,18 +18,21 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model -from GeomAPI import * model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top")) +Point_2 = model.addPoint(Part_1_doc, 10, 0, 10) model.do() model.end() +from GeomAPI import GeomAPI_Vertex + assert (len(Point_2.results()) > 0) rightPosition = GeomAPI_Vertex(10, 0, 10) assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape())) diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index 928d03022..4ccefe011 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -50,7 +50,8 @@ email : webmaster.salome@opencascade.com + shape_types="edge" + geometrical_selection="true"> @@ -59,7 +60,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> @@ -68,7 +70,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> + shape_types="face" + geometrical_selection="true"> @@ -95,7 +99,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml index f23a4f406..dfe2007b3 100644 --- a/src/ConstructionPlugin/plane_widget.xml +++ b/src/ConstructionPlugin/plane_widget.xml @@ -55,7 +55,8 @@ email : webmaster.salome@opencascade.com + shape_types="edge" + geometrical_selection="true"> @@ -79,7 +80,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> @@ -118,7 +120,8 @@ email : webmaster.salome@opencascade.com + shape_types="edge" + geometrical_selection="true"> + shape_types="face" + geometrical_selection="true"> @@ -148,7 +152,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> diff --git a/src/ConstructionPlugin/point_widget.xml b/src/ConstructionPlugin/point_widget.xml index bd7439f8a..3ccf77550 100644 --- a/src/ConstructionPlugin/point_widget.xml +++ b/src/ConstructionPlugin/point_widget.xml @@ -141,7 +141,8 @@ email : webmaster.salome@opencascade.com + shape_types="edge" + geometrical_selection="true"> @@ -149,7 +150,8 @@ email : webmaster.salome@opencascade.com + shape_types="face" + geometrical_selection="true"> diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index 91dcb6690..345b44fed 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -83,4 +83,6 @@ ADD_UNIT_TESTS(TestImport.py TestExport.py Test2290.py Test2459.py - TestExportToXAOWithGroupNotUpdated.py) + TestExportToXAOWithGroupNotUpdated.py + TestExport_FiniteValidator.py +) diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index ef70f9a66..b8b864acc 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -410,5 +410,5 @@ void ExchangePlugin_ImportFeature::loadNamingDS( int aTag(1); std::string aNameMS = "Shape"; - theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag); + theResultBody->loadFirstLevel(theGeomShape, aNameMS); } diff --git a/src/ExchangePlugin/Test/Test2459.py b/src/ExchangePlugin/Test/Test2459.py index 9cd57811e..a08d419ee 100644 --- a/src/ExchangePlugin/Test/Test2459.py +++ b/src/ExchangePlugin/Test/Test2459.py @@ -109,7 +109,7 @@ SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchArc_15.endPoint(), SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_15.startPoint(), SketchAPI_Arc(SketchArc_12).startPoint()) SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchAPI_Arc(SketchArc_6).endPoint()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchArc_1_2f-SketchArc_2_2f-SketchArc_3_2f-SketchArc_4_2r-SketchArc_5_2r-SketchCircle_1_2r-SketchArc_6_2r-SketchArc_7_2r-SketchLine_6f-SketchLine_7f-SketchArc_8_2f-SketchArc_9_2f-SketchLine_8f-SketchLine_9f-SketchArc_10_2f-SketchArc_11_2f-SketchLine_10f-SketchLine_11f-SketchArc_12_2r-SketchArc_13_2r-SketchCircle_2_2r-SketchCircle_3_2r-SketchArc_14_2f-SketchArc_15_2f")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchArc_1_2f-SketchLine_3f-SketchArc_2_2f-SketchLine_4f-SketchArc_5_2r-SketchArc_3_2f-SketchArc_6_2r-SketchLine_6f-SketchArc_8_2f-SketchLine_8f-SketchArc_10_2f-SketchLine_10f-SketchArc_12_2r-SketchArc_15_2f-SketchArc_7_2r-SketchLine_7f-SketchArc_9_2f-SketchLine_9f-SketchArc_11_2f-SketchLine_11f-SketchArc_13_2r-SketchArc_14_2f-SketchArc_4_2r-SketchCircle_1_2r-SketchCircle_2_2r-SketchCircle_3_2r")], model.selection(), 10, 0) model.do() model.end() diff --git a/src/ExchangePlugin/Test/TestExport.py b/src/ExchangePlugin/Test/TestExport.py index 8a6f1e320..468cee23e 100644 --- a/src/ExchangePlugin/Test/TestExport.py +++ b/src/ExchangePlugin/Test/TestExport.py @@ -108,16 +108,16 @@ def testExportXAO(theFile): aGroupFeature.data().setName("") aSelectionListAttr = aGroupFeature.selectionList("group_list") aSelectionListAttr.setSelectionType("face") - aSelectionListAttr.append("box1_1/Shape1") - aSelectionListAttr.append("box1_1/Shape2") + aSelectionListAttr.append("box1_1/Shape_1") + aSelectionListAttr.append("box1_1/Shape_2") aSession.finishOperation() aSession.startOperation("Create a field") aField = aSession.activeDocument().addFeature("Field") aSelectionListAttr = aField.selectionList("selected") aSelectionListAttr.setSelectionType("face") - aSelectionListAttr.append("box1_1/Shape1") - aSelectionListAttr.append("box1_1/Shape2") + aSelectionListAttr.append("box1_1/Shape_1") + aSelectionListAttr.append("box1_1/Shape_2") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(2) # two components aComponentNames.setValue(0, "temperatue") diff --git a/src/ExchangePlugin/Test/TestExportToXAOWithGroupNotUpdated.py b/src/ExchangePlugin/Test/TestExportToXAOWithGroupNotUpdated.py index 40e9e8088..d5555653e 100644 --- a/src/ExchangePlugin/Test/TestExportToXAOWithGroupNotUpdated.py +++ b/src/ExchangePlugin/Test/TestExportToXAOWithGroupNotUpdated.py @@ -39,14 +39,14 @@ SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchL SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0) # Create a group with the faces of the box -Group_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_3")] +Group_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) Group_1.setName("Group_faces") Group_1.result().setName("Group_faces") # Create a field on the box -Field_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_3")] +Field_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")] Field_1 = model.addField(Part_1_doc, 1, "DOUBLE", 1, ["Comp 1"], Field_1_objects) Field_1.addStep(0, 0, [[0], [1], [2], [3], [4], [5], [6]]) # Create a plane to split the box in two parts diff --git a/src/ExchangePlugin/Test/TestExport_FiniteValidator.py b/src/ExchangePlugin/Test/TestExport_FiniteValidator.py new file mode 100644 index 000000000..d42015ec7 --- /dev/null +++ b/src/ExchangePlugin/Test/TestExport_FiniteValidator.py @@ -0,0 +1,41 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * + +aSession = ModelAPI_Session.get() + +# Import a reference part +aSession.startOperation("Add part") +aPartFeature = aSession.moduleDocument().addFeature("Part") +aSession.finishOperation() +aPart = aSession.activeDocument() + +# Export a part +aSession.startOperation("Export part") +anExportFeature = aPart.addFeature("Export") +anExportFeature.string("file_format").setValue("BREP") +anExportFeature.string("file_path").setValue("file.brep") +anExportFeature.string("ExportType").setValue("Regular") +aSelectionListAttr = anExportFeature.selectionList("selection_list") +aSelectionListAttr.setSelectionType("solids") +aSelectionListAttr.append("PartSet/OX", "EDGE") +aSession.finishOperation() +assert(anExportFeature.error() != "") diff --git a/src/ExchangePlugin/Test/TestImport.py b/src/ExchangePlugin/Test/TestImport.py index 0d42f9207..e32246013 100644 --- a/src/ExchangePlugin/Test/TestImport.py +++ b/src/ExchangePlugin/Test/TestImport.py @@ -112,9 +112,8 @@ def testImportXAO(): aSelectionList = aFeature2.selectionList("group_list") assert aSelectionList.selectionType() == "face" assert aSelectionList.size() == 2 - assert aSelectionList.value(0).namingName("") == "mygeom_1/Shape1" - print(aSelectionList.value(1).namingName("")) - assert aSelectionList.value(1).namingName("") == "mygeom_1/Shape2" + assert aSelectionList.value(0).namingName("") == "mygeom_1/Shape_1" + assert aSelectionList.value(1).namingName("") == "mygeom_1/Shape_2" aFeature3 = aCompositeFeature.subFeature(2, False) assert aFeature3.getKind() == "Field" diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index e2ede78a6..35459c7f3 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -73,6 +73,7 @@ SET(PROJECT_SOURCES FeaturesPlugin_BooleanFuse.cpp FeaturesPlugin_BooleanCommon.cpp FeaturesPlugin_BooleanSmash.cpp + FeaturesPlugin_BooleanFill.cpp FeaturesPlugin_Intersection.cpp FeaturesPlugin_Partition.cpp FeaturesPlugin_Pipe.cpp @@ -170,24 +171,48 @@ INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) ADD_UNIT_TESTS(TestExtrusion.py TestExtrusionCut.py TestExtrusionFuse.py + TestExtrusion_ErrorMsg.py + TestExtrusion_ZeroOffsetError.py TestRevolution.py TestRevolutionCut.py TestRevolutionFuse.py TestCompositeFeaturesOnCompSolids.py TestPartition.py - TestPlacement.py + TestPartition_ErrorMsg.py + TestPlacement_Vertex_Vertex.py + TestPlacement_Edge_Vertex.py + TestPlacement_Edge_Edge.py + TestPlacement_Face_Vertex.py + TestPlacement_Face_Edge.py + TestPlacement_Face_Face.py + TestPlacement_Part_Part.py + TestPlacement_ErrorMsg.py + TestPlacement_BodyShapesValidator.py TestTranslation.py + TestTranslation_Part.py TestRotation.py - TestBoolean.py + TestRotation_ErrorMsg.py + TestMultiRotation_Part.py + TestMultiRotation_ErrorMsg.py + TestMultiTranslation_Part.py + TestMultiTranslation_ErrorMsg.py + TestSymmetry_Part.py + TestBoolean1.py + TestBoolean2.py + TestBoolean3.py TestBooleanCompSolids.py TestBooleanSmash.py TestBooleanFill.py TestBooleanFillWithPlane.py + TestBooleanFill_ErrorMsg.py TestMultiBoolean.py TestSerialBoolean.py + TestBoolean_ErrorMsg.py TestIntersection.py + TestIntersection_ErrorMsg.py TestUnion.py TestUnionFaces.py + TestUnion_ErrorMsg.py TestRemoveSubShapes.py TestRemoveSubShapes2.py TestRemoveSubShapes3.py @@ -195,6 +220,10 @@ ADD_UNIT_TESTS(TestExtrusion.py TestRemoveSubShapes5.py TestRemoveSubShapes6.py TestPipe.py + TestPipe_Edge.py + TestPipe_Wire.py + TestPipe_Compound.py + TestPipe_ErrorMsg.py TestRecover.py TestRecover1798.py TestFillEdgeVertex.py @@ -233,6 +262,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillSolidCompFace.py TestFillSolidShell.py TestFillSolidCompShell.py + TestFillCompsolidPlane.py TestPartition2Faces.py TestPartition2Solids.py TestPartition2Wires.py @@ -251,6 +281,8 @@ ADD_UNIT_TESTS(TestExtrusion.py TestMeasurementDistance.py TestMeasurementRadius.py TestMeasurementAngle.py + TestMeasurementAngle3Points.py + TestMeasurementPresentation.py TestFusionFaces.py Test1379.py Test1922.py @@ -307,9 +339,15 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCut_Wire_Face.py TestBooleanCut_Wire_Wire.py TestBooleanCut_WireCompound_WireCompound.py + TestBooleanCut_Compound_Solid.py + TestBooleanCut_ErrorMsg.py TestBooleanSmash_Face_Face.py + TestBooleanSmash_SubSolid_Solid.py + TestBooleanSmash_CompSolid_Solid.py + TestBooleanSmash_ErrorMsg.py TestBooleanFuse_SimpleMode.py TestBooleanFuse_RemoveEdges.py + TestBooleanFuse_ErrorMsg.py TestBooleanCommon_Vertex_Vertex.py TestBooleanCommon_VertexCompound_VertexCompound.py TestBooleanCommon_Edge_Edge.py @@ -317,6 +355,7 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCommon_Wire_Wire.py TestBooleanCommon_WireCompound_WireCompound.py TestBooleanCommon_Face_Face.py + TestBooleanCommon_Face_Plane.py TestBooleanCommon_FaceCompound_FaceCompound.py TestBooleanCommon_Shell_Shell.py TestBooleanCommon_ShellCompound_ShellCompound.py @@ -326,19 +365,22 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanCommon_SolidCompound_Face.py TestBooleanCommon_SolidCompound_Shell.py TestBooleanCommon_SolidCompound_SolidCompound.py + TestBooleanCommon_SubCompound_Solid.py + TestBooleanCommon_SubSolid_Solid.py TestBooleanCommon_CompSolid_Face.py TestBooleanCommon_CompSolid_Shell.py TestBooleanCommon_CompSolid_CompSolid.py TestBooleanCommon_CompSolidCompound_Face.py TestBooleanCommon_CompSolidCompound_Shell.py TestBooleanCommon_CompSolidCompound_CompSolidCompound.py + TestBooleanCommon_ErrorMsg.py Test2596.py Test2592.py Test2588.py Test1467.py - TestPartitionSubCompsolidWithCompsolid1.py - TestPartitionSubCompsolidWithCompsolid2.py - TestPartitionSubCompsolidWithCompsolid3.py + TestPartitionSubCompsolidWithCompSolid1.py + TestPartitionSubCompsolidWithCompSolid2.py + TestPartitionSubCompsolidWithCompSolid3.py TestPartitionSubCompsolidWithSolid1.py TestPartitionSubCompsolidWithSolid2.py TestPartitionSubCompsolidWithSolid3.py @@ -366,9 +408,24 @@ ADD_UNIT_TESTS(TestExtrusion.py TestBooleanFuse_ShellCompound_ShellCompound.py TestBooleanFuse_Solid_Solid.py TestBooleanFuse_SolidCompound_SolidCompound.py + TestBooleanFuse_CompSolid_Face.py TestBooleanFuse_CompSolid_CompSolid.py TestBooleanFuse_CompSolidCompound_CompSolidCompound.py + TestFillet.py + TestFillet1.py + TestFillet_ErrorMsg.py Test1816.py Test2631.py Test2650.py + Test2681.py + Test2686.py + Test2689.py + Test2693.py + Test2698.py + Test2701.py + Test2724.py + Test2692.py + Test2617.py + Test2729.py + Test2751.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp index 99afc6e8d..e9e3cbf9f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp @@ -63,683 +63,41 @@ void FeaturesPlugin_Boolean::initAttributes() ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), TOOL_LIST_ID()); } -//================================================================================================= -std::shared_ptr FeaturesPlugin_Boolean::getShape(const std::string& theAttrName) -{ - std::shared_ptr aObjRef = std::dynamic_pointer_cast< - ModelAPI_AttributeReference>(data()->attribute(theAttrName)); - if (aObjRef) { - std::shared_ptr aConstr = std::dynamic_pointer_cast< - ModelAPI_ResultBody>(aObjRef->value()); - if (aConstr) - return aConstr->shape(); - } - return std::shared_ptr(); -} - //================================================================================================= FeaturesPlugin_Boolean::OperationType FeaturesPlugin_Boolean::operationType() { return myOperationType; } -//================================================================================================= -void FeaturesPlugin_Boolean::execute() -{ - ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes; - std::map, ListOfShape> aCompSolidsObjects; - - // Getting objects. - AttributeSelectionListPtr anObjectsSelList = - selectionList(FeaturesPlugin_Boolean::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(); - ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if(aResCompSolidPtr.get() - && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { - std::shared_ptr aContextShape = aResCompSolidPtr->shape(); - std::map, ListOfShape>::iterator - anIt = aCompSolidsObjects.begin(); - for(; anIt != aCompSolidsObjects.end(); anIt++) { - if(anIt->first->isEqual(aContextShape)) { - aCompSolidsObjects[anIt->first].push_back(anObject); - break; - } - } - if(anIt == aCompSolidsObjects.end()) { - aCompSolidsObjects[aContextShape].push_back(anObject); - } - } else { - if(myOperationType != BOOL_FILL - && (anObject->shapeType() == GeomAPI_Shape::EDGE - || anObject->shapeType() == GeomAPI_Shape::FACE)) - { - anEdgesAndFaces.push_back(anObject); - } - else - { - anObjects.push_back(anObject); - } - } - } - - // Getting tools. - AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID()); - for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) { - AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex); - GeomShapePtr aTool = aToolAttr->value(); - if(!aTool.get()) { - // It could be a construction plane. - ResultPtr aContext = aToolAttr->context(); - aPlanes.push_back(aToolAttr->context()->shape()); - } - else if (myOperationType != BOOL_FILL - && (aTool->shapeType() == GeomAPI_Shape::EDGE - || aTool->shapeType() == GeomAPI_Shape::FACE)) - { - anEdgesAndFaces.push_back(aTool); - } else { - aTools.push_back(aTool); - } - } - - int aResultIndex = 0; - - switch(myOperationType) { - case BOOL_CUT: - case BOOL_COMMON: - case BOOL_FILL: { - if((anObjects.empty() && aCompSolidsObjects.empty()) - || (aTools.empty() && aPlanes.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; - ListOfShape aListWithObject; - aListWithObject.push_back(anObject); - GeomAlgoAPI_MakeShapeList aMakeShapeList; - std::shared_ptr aBoolAlgo; - GeomShapePtr aResShape; - - switch(myOperationType) { - case BOOL_CUT: { - aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject, - aTools, - GeomAlgoAPI_Boolean::BOOL_CUT)); - aResShape = aBoolAlgo->shape(); - break; - } - case BOOL_COMMON: { - aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aListWithObject, - aTools, - GeomAlgoAPI_Boolean::BOOL_COMMON)); - aResShape = aBoolAlgo->shape(); - break; - } - case BOOL_FILL: { - std::list > aBoundingPoints = - GeomAlgoAPI_ShapeTools::getBoundingBox(aListWithObject, 1.0); - - // Resize planes. - ListOfShape aToolsWithPlanes = aTools; - for(ListOfShape::const_iterator anIt = aPlanes.cbegin(); - anIt != aPlanes.cend(); - ++anIt) - { - GeomShapePtr aPlane = *anIt; - GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints); - std::shared_ptr aMkShCustom( - new GeomAlgoAPI_MakeShapeCustom); - aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); - aToolsWithPlanes.push_back(aTool); - } - - aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes)); - aResShape = aBoolAlgo->shape(); - if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) { - int aSubResultsNb = 0; - GeomAPI_ShapeIterator anIt(aResShape); - for(; anIt.more(); anIt.next()) { - ++aSubResultsNb; - } - if(aSubResultsNb == 1) { - anIt.init(aResShape); - if(anIt.more()) { - aResShape = anIt.current(); - } - } - } - break; - } - } - - // Checking that the algorithm worked properly. - if(!aBoolAlgo->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(!aBoolAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - - aMakeShapeList.appendAlgo(aBoolAlgo); - - if(GeomAlgoAPI_ShapeTools::volume(aResShape) > 1.e-27 - || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON)) - { - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - - ListOfShape aUsedTools = aTools; - if (myOperationType == BOOL_FILL) { - aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); - } - - loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, - aMakeShapeList, *(aBoolAlgo->mapOfSubShapes()), - myOperationType == BOOL_FILL); - 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 anIt = aUsedInOperationSolids.begin(); - for(; anIt != aUsedInOperationSolids.end(); anIt++) { - if(aSolidInCompSolid->isEqual(*anIt)) { - break; - } - } - if(anIt == aUsedInOperationSolids.end()) { - aNotUsedSolids.push_back(aSolidInCompSolid); - } - } - - GeomAlgoAPI_MakeShapeList aMakeShapeList; - std::shared_ptr aBoolAlgo; - - switch(myOperationType) { - case BOOL_CUT: { - aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, - aTools, - GeomAlgoAPI_Boolean::BOOL_CUT)); - break; - } - case BOOL_COMMON: { - aBoolAlgo.reset(new GeomAlgoAPI_Boolean(aUsedInOperationSolids, - aTools, - GeomAlgoAPI_Boolean::BOOL_COMMON)); - break; - } - case BOOL_FILL: { - std::list > aBoundingPoints = - GeomAlgoAPI_ShapeTools::getBoundingBox(aUsedInOperationSolids, 1.0); - - // Resize planes. - ListOfShape aToolsWithPlanes = aTools; - for(ListOfShape::const_iterator anIt = aPlanes.cbegin(); - anIt != aPlanes.cend(); - ++anIt) - { - GeomShapePtr aPlane = *anIt; - GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints); - std::shared_ptr aMkShCustom( - new GeomAlgoAPI_MakeShapeCustom); - aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); - aToolsWithPlanes.push_back(aTool); - } - - aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes)); - break; - } - } - - // Checking that the algorithm worked properly. - if(!aBoolAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if(aBoolAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if(!aBoolAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - - aMakeShapeList.appendAlgo(aBoolAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); - GeomShapePtr aResultShape = aBoolAlgo->shape(); - - // Add result to not used solids from compsolid. - if(!aNotUsedSolids.empty()) { - ListOfShape aShapesToAdd = aNotUsedSolids; - aShapesToAdd.push_back(aBoolAlgo->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(); - } - - if(GeomAlgoAPI_ShapeTools::volume(aResultShape) > 1.e-27 - || (myOperationType != BOOL_CUT && myOperationType != BOOL_COMMON)) - { - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - - ListOfShape aUsedTools = aTools; - if (myOperationType == BOOL_FILL) { - aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); - } - - loadNamingDS(aResultBody, - aCompSolid, - aUsedTools, - aResultShape, - aMakeShapeList, - aMapOfShapes, - myOperationType == BOOL_FILL); - setResult(aResultBody, aResultIndex); - aResultIndex++; - } - } - break; - } - case BOOL_FUSE: { - if((anObjects.size() + aTools.size() + - aCompSolidsObjects.size() + anEdgesAndFaces.size()) < 2) { - std::string aFeatureError = "Error: Not enough objects for boolean operation."; - setError(aFeatureError); - return; - } - - // Collecting all solids which will be fused. - ListOfShape aSolidsToFuse; - aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end()); - aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end()); - - // Collecting solids from compsolids which will not be modified - // in boolean operation and will be added to result. - ListOfShape aShapesToAdd; - for(std::map, ListOfShape>::iterator - anIt = aCompSolidsObjects.begin(); - anIt != aCompSolidsObjects.end(); anIt++) { - std::shared_ptr aCompSolid = anIt->first; - ListOfShape& aUsedInOperationSolids = anIt->second; - aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(), - aUsedInOperationSolids.end()); - - // Collect solids from compsolid which will not be modified in boolean operation. - for(GeomAPI_ShapeExplorer - anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - std::shared_ptr aSolidInCompSolid = anExp.current(); - ListOfShape::iterator anIt = aUsedInOperationSolids.begin(); - for(; anIt != aUsedInOperationSolids.end(); anIt++) { - if(aSolidInCompSolid->isEqual(*anIt)) { - break; - } - } - if(anIt == aUsedInOperationSolids.end()) { - aShapesToAdd.push_back(aSolidInCompSolid); - } - } - } - - ListOfShape anOriginalShapes = aSolidsToFuse; - anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end()); - - // Cut edges and faces(if we have any) with solids. - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; - std::shared_ptr aCuttedEdgesAndFaces; - if(!anEdgesAndFaces.empty()) { - std::shared_ptr aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces, - anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT)); - if(aCutAlgo->isDone()) { - aCuttedEdgesAndFaces = aCutAlgo->shape(); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); - } - } - anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), - anEdgesAndFaces.end()); - - // If we have compsolids then cut with not used solids all others. - if(!aShapesToAdd.empty()) { - aSolidsToFuse.clear(); - for(ListOfShape::iterator - anIt = anOriginalShapes.begin(); anIt != anOriginalShapes.end(); anIt++) { - ListOfShape aOneObjectList; - aOneObjectList.push_back(*anIt); - std::shared_ptr aCutAlgo( - new GeomAlgoAPI_Boolean(aOneObjectList, aShapesToAdd, GeomAlgoAPI_Boolean::BOOL_CUT)); - - if(GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) { - aSolidsToFuse.push_back(aCutAlgo->shape()); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); - } - } - } - - if(!aSolidsToFuse.empty()) { - anObjects.clear(); - anObjects.push_back(aSolidsToFuse.back()); - aSolidsToFuse.pop_back(); - aTools = aSolidsToFuse; - } - - // Fuse all objects and all tools. - std::shared_ptr aShape; - if(anObjects.size() == 1 && aTools.empty()) { - aShape = anObjects.front(); - } else if(anObjects.empty() && aTools.size() == 1) { - aShape = aTools.front(); - } else if((anObjects.size() + aTools.size()) > 1){ - std::shared_ptr aFuseAlgo(new GeomAlgoAPI_Boolean(anObjects, - aTools, - GeomAlgoAPI_Boolean::BOOL_FUSE)); - - // Checking that the algorithm worked properly. - if(!aFuseAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if(aFuseAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if(!aFuseAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - - aShape = aFuseAlgo->shape(); - aMakeShapeList.appendAlgo(aFuseAlgo); - aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes()); - } - - // Combine result with not used solids from compsolid and edges and faces (if we have any). - if(aCuttedEdgesAndFaces.get() && !aCuttedEdgesAndFaces->isNull()) { - aShapesToAdd.push_back(aCuttedEdgesAndFaces); - } else { - aShapesToAdd.insert(aShapesToAdd.end(), anEdgesAndFaces.begin(), anEdgesAndFaces.end()); - } - if(!aShapesToAdd.empty()) { - if(aShape.get()) { - aShapesToAdd.push_back(aShape); - } - std::shared_ptr aFillerAlgo( - new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if(!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if(aFillerAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if(!aFillerAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - - aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); - } - - std::shared_ptr aBackShape = anOriginalShapes.back(); - anOriginalShapes.pop_back(); - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aBackShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); - setResult(aResultBody, aResultIndex); - aResultIndex++; - break; - } - case BOOL_SMASH: { - if((anObjects.empty() && aCompSolidsObjects.empty()) || aTools.empty()) { - std::string aFeatureError = "Error: Not enough objects for boolean operation."; - setError(aFeatureError); - return; - } - - // List of original solids for naming. - ListOfShape anOriginalShapes; - anOriginalShapes.insert(anOriginalShapes.end(), anObjects.begin(), anObjects.end()); - anOriginalShapes.insert(anOriginalShapes.end(), aTools.begin(), aTools.end()); - - // Collecting all solids which will be smashed. - ListOfShape aShapesToSmash; - aShapesToSmash.insert(aShapesToSmash.end(), anObjects.begin(), anObjects.end()); - - // Collecting solids from compsolids which will not be modified in - // boolean operation and will be added to result. - ListOfShape aShapesToAdd; - for(std::map, ListOfShape>::iterator - anIt = aCompSolidsObjects.begin(); - anIt != aCompSolidsObjects.end(); anIt++) { - std::shared_ptr aCompSolid = anIt->first; - ListOfShape& aUsedInOperationSolids = anIt->second; - anOriginalShapes.push_back(aCompSolid); - aShapesToSmash.insert(aShapesToSmash.end(), aUsedInOperationSolids.begin(), - aUsedInOperationSolids.end()); - - // Collect solids from compsolid which will not be modified in boolean operation. - for(GeomAPI_ShapeExplorer - anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - std::shared_ptr aSolidInCompSolid = anExp.current(); - ListOfShape::iterator anIt = aUsedInOperationSolids.begin(); - for(; anIt != aUsedInOperationSolids.end(); anIt++) { - if(aSolidInCompSolid->isEqual(*anIt)) { - break; - } - } - if(anIt == aUsedInOperationSolids.end()) { - aShapesToAdd.push_back(aSolidInCompSolid); - } - } - } - - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; - if(!aShapesToAdd.empty()) { - // Cut objects with not used solids. - std::shared_ptr anObjectsCutAlgo(new GeomAlgoAPI_Boolean( - aShapesToSmash, - aShapesToAdd, - GeomAlgoAPI_Boolean::BOOL_CUT)); - - if(GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) { - aShapesToSmash.clear(); - aShapesToSmash.push_back(anObjectsCutAlgo->shape()); - aMakeShapeList.appendAlgo(anObjectsCutAlgo); - aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes()); - } - - // Cut tools with not used solids. - std::shared_ptr aToolsCutAlgo(new GeomAlgoAPI_Boolean(aTools, - aShapesToAdd, - GeomAlgoAPI_Boolean::BOOL_CUT)); - - if(GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) { - aTools.clear(); - aTools.push_back(aToolsCutAlgo->shape()); - aMakeShapeList.appendAlgo(aToolsCutAlgo); - aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes()); - } - } - - // Cut objects with tools. - std::shared_ptr aBoolAlgo(new GeomAlgoAPI_Boolean(aShapesToSmash, - aTools, - GeomAlgoAPI_Boolean::BOOL_CUT)); - - // Checking that the algorithm worked properly. - if(!aBoolAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if(aBoolAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if(!aBoolAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - aMakeShapeList.appendAlgo(aBoolAlgo); - aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); - - // Put all (cut result, tools and not used solids) to PaveFiller. - aShapesToAdd.push_back(aBoolAlgo->shape()); - aShapesToAdd.insert(aShapesToAdd.end(), aTools.begin(), aTools.end()); - - std::shared_ptr aFillerAlgo(new GeomAlgoAPI_PaveFiller(aShapesToAdd, - true)); - if(!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if(aFillerAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if(!aFillerAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - - std::shared_ptr aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); - - std::shared_ptr aFrontShape = anOriginalShapes.front(); - anOriginalShapes.pop_front(); - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aFrontShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); - setResult(aResultBody, aResultIndex); - aResultIndex++; - - break; - } - default: { - std::string anOperationError = "Error: Wrong type of operation"; - setError(anOperationError); - return; - } - } - // remove the rest results if there were produced in the previous pass - removeResults(aResultIndex); -} - //================================================================================================= void FeaturesPlugin_Boolean::loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, const ListOfShape& theTools, const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated) + const GeomMakeShapePtr& theMakeShape) { //load result if(theBaseShape->isEqual(theResultShape)) { theResultBody->store(theResultShape, false); - } else { - const int aModifyTag = 1; - const int aModifyEdgeTag = 2; - const int aModifyFaceTag = 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; + return; + } + + theResultBody->storeModified(theBaseShape, theResultShape); - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE); + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); - const std::string aModName = "Modified"; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); + for (ListOfShape::const_iterator anIter = theTools.begin(); + anIter != theTools.end(); + ++anIter) + { + GeomAPI_Shape::ShapeType aShapeType = + (*anIter)->shapeType() <= GeomAPI_Shape::FACE ? GeomAPI_Shape::FACE + : GeomAPI_Shape::EDGE; + theResultBody->loadModifiedShapes(theMakeShape, *anIter, aShapeType); - int aTag; - std::string aName; - for(ListOfShape::const_iterator - anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - if((*anIter)->shapeType() <= GeomAPI_Shape::FACE) { - aTag = aModifyFaceTag; - aName = aModFName; - } else { - aTag = aModifyEdgeTag; - aName = aModEName; - } - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, - aName == aModEName ? GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, - aTag, aName, theMapOfShapes, false, theIsStoreAsGenerated, true); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - } + theResultBody->loadDeletedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h index ce70e57bc..70aaad591 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Boolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Boolean.h @@ -59,9 +59,6 @@ public: /// \return boolean operation type. FEATURESPLUGIN_EXPORT OperationType operationType(); - /// Creates a new part document if needed. - FEATURESPLUGIN_EXPORT virtual void execute(); - /// Request for initialization of data model of the feature: adding all attributes. FEATURESPLUGIN_EXPORT virtual void initAttributes(); @@ -70,17 +67,12 @@ protected: /// Use plugin manager for features creation. FeaturesPlugin_Boolean(const OperationType theOperationType); -private: - std::shared_ptr getShape(const std::string& theAttrName); - /// Load Naming data structure of the feature to the document void loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, const ListOfShape& theTools, const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes, - const bool theIsStoreAsGenerated = false); + const GeomMakeShapePtr& theMakeShape); private: OperationType myOperationType; diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp index c8cee6318..df16a3149 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanCommon.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -34,6 +36,7 @@ #include #include #include +#include //================================================================================================== @@ -76,7 +79,8 @@ void FeaturesPlugin_BooleanCommon::execute() } ResultPtr aContext = anObjectAttr->context(); ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if (aResCompSolidPtr.get()) + if (!isSimpleMode + && aResCompSolidPtr.get()) { std::shared_ptr aContextShape = aResCompSolidPtr->shape(); GeomAPI_Shape::ShapeType aShapeType = aResCompSolidPtr->shape()->shapeType(); @@ -117,7 +121,7 @@ void FeaturesPlugin_BooleanCommon::execute() } } - if ((anObjects.empty() && aCompSolidsObjects.empty()) + if ((anObjects.empty() && aCompSolidsObjects.empty() && aCompoundObjects.empty()) || (!isSimpleMode && aTools.empty() && aPlanes.empty())) { std::string aFeatureError = "Error: Not enough objects for boolean operation."; setError(aFeatureError); @@ -125,8 +129,10 @@ void FeaturesPlugin_BooleanCommon::execute() } int aResultIndex = 0; - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; + std::string anError; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + std::vector aResultBaseAlgoList; + ListOfShape aResultShapesList; if (isSimpleMode) { @@ -138,25 +144,13 @@ void FeaturesPlugin_BooleanCommon::execute() *anObjectsIt, GeomAlgoAPI_Boolean::BOOL_COMMON)); - if (!aCommonAlgo->isDone()) { - std::string aFeatureError = "Error: An algorithm failed."; - setError(aFeatureError); - return; - } - if (aCommonAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aCommonAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aCommonAlgo->shape(); - aMakeShapeList.appendAlgo(aCommonAlgo); - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCommonAlgo); } GeomAPI_ShapeIterator aShapeIt(aShape); @@ -164,9 +158,23 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObjects.front(), anObjects, aShape, aMakeShapeList, aMapOfShapes); + GeomShapePtr aBaseShape = anObjects.front(); + anObjects.pop_front(); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + anObjects, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + aTools = anObjects; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aBaseShape; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aShape); } } else { for (ListOfShape::iterator anObjectsIt = anObjects.begin(); @@ -176,7 +184,7 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr anObject = *anObjectsIt; ListOfShape aListWithObject; aListWithObject.push_back(anObject); - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); std::shared_ptr aBoolAlgo; GeomShapePtr aResShape; @@ -193,7 +201,7 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aMkShCustom( new GeomAlgoAPI_MakeShapeCustom); aMkShCustom->addModified(aPlane, aTool); - aMakeShapeList.appendAlgo(aMkShCustom); + aMakeShapeList->appendAlgo(aMkShCustom); aToolsWithPlanes.push_back(aTool); } @@ -203,33 +211,32 @@ void FeaturesPlugin_BooleanCommon::execute() aResShape = aBoolAlgo->shape(); // Checking that the algorithm worked properly. - if (!aBoolAlgo->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 (!aBoolAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) { + setError(anError); return; } - aMakeShapeList.appendAlgo(aBoolAlgo); + aMakeShapeList->appendAlgo(aBoolAlgo); 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, *(aBoolAlgo->mapOfSubShapes())); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + anObject, + aTools, + aMakeShapeList, + aResShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = anObject; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResShape); } } @@ -267,25 +274,12 @@ void FeaturesPlugin_BooleanCommon::execute() GeomAlgoAPI_Boolean::BOOL_COMMON)); // Checking that the algorithm worked properly. - if (!aCommonAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if (aCommonAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aCommonAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) { + setError(anError); return; } aMakeShapeList->appendAlgo(aCommonAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCommonAlgo->shape(); // Add result to not used solids from compsolid. @@ -301,7 +295,6 @@ void FeaturesPlugin_BooleanCommon::execute() } aMakeShapeList->appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); aResultShape = aFillerAlgo->shape(); } @@ -311,14 +304,20 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompSolid, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompSolid, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aCompSolid; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResultShape); } } @@ -356,25 +355,12 @@ void FeaturesPlugin_BooleanCommon::execute() GeomAlgoAPI_Boolean::BOOL_COMMON)); // Checking that the algorithm worked properly. - if (!aCommonAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if (aCommonAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aCommonAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCommonAlgo, getKind(), anError)) { + setError(anError); return; } aMakeShapeList->appendAlgo(aCommonAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCommonAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCommonAlgo->shape(); // Add result to not used shape from compound. @@ -402,82 +388,30 @@ void FeaturesPlugin_BooleanCommon::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompound, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompound, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; + + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; + aRBA.resultBody = aResultBody; + aRBA.baseShape = aCompound; + aRBA.makeShape = aMakeShapeList; + aResultBaseAlgoList.push_back(aRBA); + aResultShapesList.push_back(aResultShape); } } } + // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one + // result shape has been deleted, but in another it was modified or stayed. + GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); + FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanCommon::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //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, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, 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, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, 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_BooleanCommon.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h index caf67d38e..d7dafcd67 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCommon.h @@ -91,17 +91,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanCommon(); - -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); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp index 79b959e9b..bfe0fdc2c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanCut.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -29,18 +31,11 @@ #include #include #include +#include + #include #include -//================================================================================================== -const int ModifyVTag = 1; -const int ModifyETag = 2; -const int ModifyFTag = 3; -const int DeletedTag = 4; -/// sub solids will be placed at labels 5, 6, etc. if result is compound of solids -const int SubsolidsTag = 5; - - //================================================================================================== FeaturesPlugin_BooleanCut::FeaturesPlugin_BooleanCut() : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_CUT) @@ -108,8 +103,9 @@ void FeaturesPlugin_BooleanCut::execute() return; } - std::vector aResultBaseAlgoList; + std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; + std::string anError; // For solids cut each object with all tools. for(ListOfShape::iterator anObjectsIt = anObjects.begin(); @@ -124,19 +120,8 @@ void FeaturesPlugin_BooleanCut::execute() 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); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) { + setError(anError); return; } @@ -148,13 +133,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, anObject, aTools, aResShape, - *aMakeShapeList, *(aCutAlgo->mapOfSubShapes()), - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + anObject, + aTools, + aMakeShapeList, + aResShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = anObject; aRBA.makeShape = aMakeShapeList; @@ -197,25 +184,12 @@ void FeaturesPlugin_BooleanCut::execute() 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); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) { + setError(anError); return; } aMakeShapeList->appendAlgo(aCutAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCutAlgo->shape(); // Add result to not used solids from compsolid. @@ -231,7 +205,6 @@ void FeaturesPlugin_BooleanCut::execute() } aMakeShapeList->appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); aResultShape = aFillerAlgo->shape(); } @@ -241,17 +214,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompSolid, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes, - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompSolid, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = aCompSolid; aRBA.makeShape = aMakeShapeList; @@ -294,25 +265,12 @@ void FeaturesPlugin_BooleanCut::execute() 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); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, getKind(), anError)) { + setError(anError); return; } aMakeShapeList->appendAlgo(aCutAlgo); - GeomAPI_DataMapOfShapeShape aMapOfShapes; - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); GeomShapePtr aResultShape = aCutAlgo->shape(); // Add result to not used shape from compound. @@ -338,17 +296,15 @@ void FeaturesPlugin_BooleanCut::execute() std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aCompound, - aTools, - aResultShape, - *aMakeShapeList, - aMapOfShapes, - false); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aCompound, + aTools, + aMakeShapeList, + aResultShape); setResult(aResultBody, aResultIndex); aResultIndex++; - ResultBaseAlgo aRBA; + FeaturesPlugin_Tools::ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = aCompound; aRBA.makeShape = aMakeShapeList; @@ -360,102 +316,8 @@ void FeaturesPlugin_BooleanCut::execute() // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one // result shape has been deleted, but in another it was modified or stayed. GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); - storeDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); + FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, aTools, aResultShapesCompound); // 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 { - theResultBody->storeModified(theBaseShape, theResultShape, SubsolidsTag); - - 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, - ModifyVTag, aModVName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - ModifyETag, aModEName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - ModifyFTag, aModFName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - ModifyVTag, aModVName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - ModifyETag, aModEName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - ModifyFTag, aModFName, theMapOfShapes, false, - theIsStoreAsGenerated, true); - } - } -} - -//================================================================================================== -void FeaturesPlugin_BooleanCut::storeDeletedShapes( - std::vector& theResultBaseAlgoList, - const ListOfShape& theTools, - const GeomShapePtr theResultShapesCompound) -{ - for (std::vector::iterator anIt = theResultBaseAlgoList.begin(); - anIt != theResultBaseAlgoList.end(); - ++anIt) - { - ResultBaseAlgo& aRCA = *anIt; - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::VERTEX, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::EDGE, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - aRCA.baseShape, - GeomAPI_Shape::FACE, - DeletedTag, - theResultShapesCompound); - - for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) - { - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::VERTEX, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::EDGE, - DeletedTag, - theResultShapesCompound); - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), - *anIter, - GeomAPI_Shape::FACE, - DeletedTag, - theResultShapesCompound); - } - } -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h index 11c154ced..2cc8048f8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanCut.h @@ -55,30 +55,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanCut(); -private: - - struct ResultBaseAlgo { - ResultBodyPtr resultBody; - GeomShapePtr baseShape; - std::shared_ptr makeShape; - }; - -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); - - /// Stores deleted shapes. - void storeDeletedShapes(std::vector& theResultBaseAlgoList, - const ListOfShape& theTools, - const GeomShapePtr theResultShapesCompound); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp new file mode 100644 index 000000000..d9f7faf2b --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp @@ -0,0 +1,260 @@ +// 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_BooleanFill.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +//================================================================================================= +FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill() + : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_FILL) +{ +} + +//================================================================================================= +void FeaturesPlugin_BooleanFill::execute() +{ + std::string anError; + ListOfShape anObjects, aTools, anEdgesAndFaces, aPlanes; + std::map, ListOfShape> aCompSolidsObjects; + + // Getting objects. + AttributeSelectionListPtr anObjectsSelList = + selectionList(FeaturesPlugin_Boolean::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(); + ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); + if(aResCompSolidPtr.get() + && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { + std::shared_ptr aContextShape = aResCompSolidPtr->shape(); + std::map, ListOfShape>::iterator + anIt = aCompSolidsObjects.begin(); + for(; anIt != aCompSolidsObjects.end(); anIt++) { + if(anIt->first->isEqual(aContextShape)) { + aCompSolidsObjects[anIt->first].push_back(anObject); + break; + } + } + if(anIt == aCompSolidsObjects.end()) { + aCompSolidsObjects[aContextShape].push_back(anObject); + } + } else { + anObjects.push_back(anObject); + } + } + + // Getting tools. + AttributeSelectionListPtr aToolsSelList = selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID()); + for(int aToolsIndex = 0; aToolsIndex < aToolsSelList->size(); aToolsIndex++) { + AttributeSelectionPtr aToolAttr = aToolsSelList->value(aToolsIndex); + GeomShapePtr aTool = aToolAttr->value(); + if(!aTool.get()) { + // It could be a construction plane. + ResultPtr aContext = aToolAttr->context(); + aPlanes.push_back(aToolAttr->context()->shape()); + } + else { + aTools.push_back(aTool); + } + } + + int aResultIndex = 0; + + if ((anObjects.empty() && aCompSolidsObjects.empty()) + || (aTools.empty() && aPlanes.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; + ListOfShape aListWithObject; + aListWithObject.push_back(anObject); + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + std::shared_ptr aBoolAlgo; + GeomShapePtr aResShape; + + std::list > aBoundingPoints = + GeomAlgoAPI_ShapeTools::getBoundingBox(aListWithObject, 1.0); + + // Resize planes. + ListOfShape aToolsWithPlanes = aTools; + for(ListOfShape::const_iterator anIt = aPlanes.cbegin(); + anIt != aPlanes.cend(); + ++anIt) + { + GeomShapePtr aPlane = *anIt; + GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints); + std::shared_ptr aMkShCustom( + new GeomAlgoAPI_MakeShapeCustom); + aMkShCustom->addModified(aPlane, aTool); + aMakeShapeList->appendAlgo(aMkShCustom); + aToolsWithPlanes.push_back(aTool); + } + + aBoolAlgo.reset(new GeomAlgoAPI_Partition(aListWithObject, aToolsWithPlanes)); + aResShape = aBoolAlgo->shape(); + if (aResShape.get() && aResShape->shapeType() == GeomAPI_Shape::COMPOUND) { + int aSubResultsNb = 0; + GeomAPI_ShapeIterator anIt(aResShape); + for(; anIt.more(); anIt.next()) { + ++aSubResultsNb; + } + if(aSubResultsNb == 1) { + anIt.init(aResShape); + if(anIt.more()) { + aResShape = anIt.current(); + } + } + } + + // Checking that the algorithm worked properly. + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) { + setError(anError); + return; + } + + aMakeShapeList->appendAlgo(aBoolAlgo); + + std::shared_ptr aResultBody = + document()->createBody(data(), aResultIndex); + + ListOfShape aUsedTools = aTools; + aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); + + loadNamingDS(aResultBody, anObject, aUsedTools, aResShape, aMakeShapeList); + 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 anIt = aUsedInOperationSolids.begin(); + for(; anIt != aUsedInOperationSolids.end(); anIt++) { + if(aSolidInCompSolid->isEqual(*anIt)) { + break; + } + } + if(anIt == aUsedInOperationSolids.end()) { + aNotUsedSolids.push_back(aSolidInCompSolid); + } + } + + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + std::shared_ptr aBoolAlgo; + + std::list > aBoundingPoints = + GeomAlgoAPI_ShapeTools::getBoundingBox(aUsedInOperationSolids, 1.0); + + // Resize planes. + ListOfShape aToolsWithPlanes = aTools; + for(ListOfShape::const_iterator anIt = aPlanes.cbegin(); + anIt != aPlanes.cend(); + ++anIt) + { + GeomShapePtr aPlane = *anIt; + GeomShapePtr aTool = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPlane, aBoundingPoints); + std::shared_ptr aMkShCustom( + new GeomAlgoAPI_MakeShapeCustom); + aMkShCustom->addModified(aPlane, aTool); + aMakeShapeList->appendAlgo(aMkShCustom); + aToolsWithPlanes.push_back(aTool); + } + + aBoolAlgo.reset(new GeomAlgoAPI_Partition(aUsedInOperationSolids, aToolsWithPlanes)); + + // Checking that the algorithm worked properly. + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) { + setError(anError); + return; + } + + aMakeShapeList->appendAlgo(aBoolAlgo); + GeomShapePtr aResultShape = aBoolAlgo->shape(); + + // Add result to not used solids from compsolid. + if(!aNotUsedSolids.empty()) { + ListOfShape aShapesToAdd = aNotUsedSolids; + aShapesToAdd.push_back(aBoolAlgo->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); + aResultShape = aFillerAlgo->shape(); + } + + std::shared_ptr aResultBody = + document()->createBody(data(), aResultIndex); + + ListOfShape aUsedTools = aTools; + aUsedTools.insert(aUsedTools.end(), aPlanes.begin(), aPlanes.end()); + + loadNamingDS(aResultBody, + aCompSolid, + aUsedTools, + aResultShape, + aMakeShapeList); + setResult(aResultBody, aResultIndex); + aResultIndex++; + } + + // remove the rest results if there were produced in the previous pass + removeResults(aResultIndex); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h index b4cb73b94..88b53213d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.h @@ -44,10 +44,13 @@ public: return MY_KIND; } + /// Creates a new part document if needed. + FEATURESPLUGIN_EXPORT virtual void execute(); + public: /// Use plugin manager for features creation. - FeaturesPlugin_BooleanFill(): FeaturesPlugin_Boolean(BOOL_FILL) {}; + FeaturesPlugin_BooleanFill(); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 0f1ac4f72..f6e4599f7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanFuse.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -32,6 +34,7 @@ #include #include #include +#include #include #include @@ -58,14 +61,16 @@ void FeaturesPlugin_BooleanFuse::initAttributes() //================================================================================================== void FeaturesPlugin_BooleanFuse::execute() { + std::string anError; ListOfShape anObjects, aTools, anEdgesAndFaces; - std::map, ListOfShape> aCompSolidsObjects; + std::map aCompSolidsObjects; bool isSimpleCreation = false; AttributeStringPtr aCreationMethodAttr = string(CREATION_METHOD()); if (aCreationMethodAttr.get() - && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) { + && aCreationMethodAttr->value() == CREATION_METHOD_SIMPLE()) + { isSimpleCreation = true; } @@ -74,7 +79,7 @@ void FeaturesPlugin_BooleanFuse::execute() selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID()); for (int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { AttributeSelectionPtr anObjectAttr = anObjectsSelList->value(anObjectsIndex); - std::shared_ptr anObject = anObjectAttr->value(); + GeomShapePtr anObject = anObjectAttr->value(); if (!anObject.get()) { return; } @@ -82,9 +87,10 @@ void FeaturesPlugin_BooleanFuse::execute() ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); if (!isSimpleCreation && aResCompSolidPtr.get() - && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) { - std::shared_ptr aContextShape = aResCompSolidPtr->shape(); - std::map, ListOfShape>::iterator + && aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) + { + GeomShapePtr aContextShape = aResCompSolidPtr->shape(); + std::map::iterator anIt = aCompSolidsObjects.begin(); for (; anIt != aCompSolidsObjects.end(); anIt++) { if (anIt->first->isEqual(aContextShape)) { @@ -136,10 +142,11 @@ void FeaturesPlugin_BooleanFuse::execute() // Collecting solids from compsolids which will not be modified // in boolean operation and will be added to result. ListOfShape aShapesToAdd; - for (std::map, ListOfShape>::iterator - anIt = aCompSolidsObjects.begin(); - anIt != aCompSolidsObjects.end(); anIt++) { - std::shared_ptr aCompSolid = anIt->first; + for (std::map::iterator anIt = aCompSolidsObjects.begin(); + anIt != aCompSolidsObjects.end(); + ++anIt) + { + GeomShapePtr aCompSolid = anIt->first; ListOfShape& aUsedInOperationSolids = anIt->second; aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedInOperationSolids.begin(), aUsedInOperationSolids.end()); @@ -147,7 +154,7 @@ void FeaturesPlugin_BooleanFuse::execute() // Collect solids from compsolid which will not be modified in boolean operation. for (GeomAPI_ShapeExplorer anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - std::shared_ptr aSolidInCompSolid = anExp.current(); + GeomShapePtr aSolidInCompSolid = anExp.current(); ListOfShape::iterator anIt = aUsedInOperationSolids.begin(); for (; anIt != aUsedInOperationSolids.end(); anIt++) { if (aSolidInCompSolid->isEqual(*anIt)) { @@ -164,16 +171,14 @@ void FeaturesPlugin_BooleanFuse::execute() anOriginalShapes.insert(anOriginalShapes.end(), aShapesToAdd.begin(), aShapesToAdd.end()); // Cut edges and faces(if we have any) with solids. - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; - std::shared_ptr aCuttedEdgesAndFaces; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + GeomShapePtr aCuttedEdgesAndFaces; if (!anEdgesAndFaces.empty()) { std::shared_ptr aCutAlgo(new GeomAlgoAPI_Boolean(anEdgesAndFaces, anOriginalShapes, GeomAlgoAPI_Boolean::BOOL_CUT)); if (aCutAlgo->isDone()) { aCuttedEdgesAndFaces = aCutAlgo->shape(); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } anOriginalShapes.insert(anOriginalShapes.end(), anEdgesAndFaces.begin(), @@ -191,8 +196,7 @@ void FeaturesPlugin_BooleanFuse::execute() if (GeomAlgoAPI_ShapeTools::volume(aCutAlgo->shape()) > 1.e-27) { aSolidsToFuse.push_back(aCutAlgo->shape()); - aMakeShapeList.appendAlgo(aCutAlgo); - aMapOfShapes.merge(aCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aCutAlgo); } } } @@ -205,7 +209,7 @@ void FeaturesPlugin_BooleanFuse::execute() } // Fuse all objects and all tools. - std::shared_ptr aShape; + GeomShapePtr aShape; if (anObjects.size() == 1 && aTools.empty()) { aShape = anObjects.front(); } else if (anObjects.empty() && aTools.size() == 1) { @@ -216,25 +220,13 @@ void FeaturesPlugin_BooleanFuse::execute() GeomAlgoAPI_Boolean::BOOL_FUSE)); // Checking that the algorithm worked properly. - if (!aFuseAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); - return; - } - if (aFuseAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aFuseAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFuseAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aFuseAlgo->shape(); - aMakeShapeList.appendAlgo(aFuseAlgo); - aMapOfShapes.merge(aFuseAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFuseAlgo); } // Combine result with not used solids from compsolid and edges and faces (if we have any). @@ -249,25 +241,13 @@ void FeaturesPlugin_BooleanFuse::execute() } std::shared_ptr aFillerAlgo( new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if (!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if (aFillerAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aFillerAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); } bool isRemoveEdges = false; @@ -280,101 +260,35 @@ void FeaturesPlugin_BooleanFuse::execute() std::shared_ptr aUnifyAlgo( new GeomAlgoAPI_UnifySameDomain(aShape)); - if (!aUnifyAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if (aUnifyAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aUnifyAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aUnifyAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aUnifyAlgo->shape(); - aMakeShapeList.appendAlgo(aUnifyAlgo); - aMapOfShapes.merge(aUnifyAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aUnifyAlgo); } int aResultIndex = 0; - std::shared_ptr aBackShape = anOriginalShapes.back(); + GeomShapePtr aBackShape = anOriginalShapes.back(); anOriginalShapes.pop_back(); - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aBackShape, anOriginalShapes, - aShape, aMakeShapeList, aMapOfShapes); + ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); + + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBackShape, + anOriginalShapes, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, + aBackShape, + anOriginalShapes, + aMakeShapeList, + aShape); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanFuse::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //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, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, 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, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - false, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - false, 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_BooleanFuse.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h index 950b8223f..1010871c4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.h @@ -96,15 +96,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanFuse(); - -private: - /// Load Naming data structure of the feature to the document - void loadNamingDS(std::shared_ptr theResultBody, - const std::shared_ptr theBaseShape, - const ListOfShape& theTools, - const std::shared_ptr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp index 0dbe5a348..ee6c3c785 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.cpp @@ -20,6 +20,8 @@ #include "FeaturesPlugin_BooleanSmash.h" +#include "FeaturesPlugin_Tools.h" + #include #include #include @@ -29,6 +31,8 @@ #include #include #include +#include + #include #include @@ -48,6 +52,7 @@ void FeaturesPlugin_BooleanSmash::initAttributes() //================================================================================================== void FeaturesPlugin_BooleanSmash::execute() { + std::string anError; ListOfShape anObjects, aTools; std::map, ListOfShape> aCompSolidsObjects; @@ -144,8 +149,7 @@ void FeaturesPlugin_BooleanSmash::execute() } } - GeomAlgoAPI_MakeShapeList aMakeShapeList; - GeomAPI_DataMapOfShapeShape aMapOfShapes; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); if (!aShapesToAdd.empty()) { // Cut objects with not used solids. std::shared_ptr anObjectsCutAlgo( @@ -156,8 +160,7 @@ void FeaturesPlugin_BooleanSmash::execute() if (GeomAlgoAPI_ShapeTools::volume(anObjectsCutAlgo->shape()) > 1.e-27) { aShapesToSmash.clear(); aShapesToSmash.push_back(anObjectsCutAlgo->shape()); - aMakeShapeList.appendAlgo(anObjectsCutAlgo); - aMapOfShapes.merge(anObjectsCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(anObjectsCutAlgo); } // Cut tools with not used solids. @@ -169,8 +172,7 @@ void FeaturesPlugin_BooleanSmash::execute() if (GeomAlgoAPI_ShapeTools::volume(aToolsCutAlgo->shape()) > 1.e-27) { aTools.clear(); aTools.push_back(aToolsCutAlgo->shape()); - aMakeShapeList.appendAlgo(aToolsCutAlgo); - aMapOfShapes.merge(aToolsCutAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aToolsCutAlgo); } } @@ -181,23 +183,12 @@ void FeaturesPlugin_BooleanSmash::execute() GeomAlgoAPI_Boolean::BOOL_CUT)); // Checking that the algorithm worked properly. - if (!aBoolAlgo->isDone()) { - static const std::string aFeatureError = "Error: Boolean algorithm failed."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aBoolAlgo, getKind(), anError)) { + setError(anError); return; } - if (aBoolAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aBoolAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - return; - } - aMakeShapeList.appendAlgo(aBoolAlgo); - aMapOfShapes.merge(aBoolAlgo->mapOfSubShapes()); + + aMakeShapeList->appendAlgo(aBoolAlgo); // Put all (cut result, tools and not used solids) to PaveFiller. GeomShapePtr aShape = aBoolAlgo->shape(); @@ -213,105 +204,34 @@ void FeaturesPlugin_BooleanSmash::execute() else { std::shared_ptr aFillerAlgo( new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if (!aFillerAlgo->isDone()) { - std::string aFeatureError = "Error: PaveFiller algorithm failed."; - setError(aFeatureError); - return; - } - if (aFillerAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!aFillerAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); - aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); + aMakeShapeList->appendAlgo(aFillerAlgo); } std::shared_ptr aFrontShape = anOriginalShapes.front(); anOriginalShapes.pop_front(); std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, - aFrontShape, - anOriginalShapes, - aShape, - aMakeShapeList, - aMapOfShapes); + + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aFrontShape, + anOriginalShapes, + aMakeShapeList, + aShape); setResult(aResultBody, aResultIndex); aResultIndex++; + FeaturesPlugin_Tools::loadDeletedShapes(aResultBody, + aFrontShape, + anOriginalShapes, + aMakeShapeList, + aShape); + // remove the rest results if there were produced in the previous pass removeResults(aResultIndex); } - -//================================================================================================== -void FeaturesPlugin_BooleanSmash::loadNamingDS(ResultBodyPtr theResultBody, - const GeomShapePtr theBaseShape, - const ListOfShape& theTools, - const GeomShapePtr theResultShape, - GeomAlgoAPI_MakeShape& theMakeShape, - GeomAPI_DataMapOfShapeShape& theMapOfShapes) -{ - //load result - if (theBaseShape->isEqual(theResultShape)) { - theResultBody->store(theResultShape, false); - } else if (theResultShape->isEqual(theTools.front())) { - 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, - true, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - true, true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - true, 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, - true, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyETag, aModEName, theMapOfShapes, false, - true, true); - - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, - aModifyFTag, aModFName, theMapOfShapes, false, - true, 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_BooleanSmash.h b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h index 0238d2712..8a0057c9b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanSmash.h @@ -70,17 +70,6 @@ public: /// Use plugin manager for features creation. FeaturesPlugin_BooleanSmash(); - -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); - }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp index 6f0d65f4d..6e3e8796b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include @@ -77,8 +77,6 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean() for(; aBoolObjIt != aBooleanObjects.cend() && aBoolMSIt != aBooleanMakeShapes.cend(); ++aBoolObjIt, ++aBoolMSIt) { - int aTag = 1; - ResultBodyPtr aResultBody = myFeature->document()->createBody(myFeature->data(), aResultIndex); if((*aBoolObjIt)->isEqual((*aBoolMSIt)->shape())) { @@ -86,26 +84,25 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean() } else { - aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag); - - aTag += 5000; + aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape()); // Store generation history. ListOfShape::const_iterator aGenBaseIt = aGenBaseShapes.cbegin(); ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin(); for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend(); ++aGenBaseIt, ++aGenMSIt) { - storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt, aTag); + std::shared_ptr aMSList(new GeomAlgoAPI_MakeShapeList()); + aMSList->appendAlgo(*aGenMSIt); + aMSList->appendAlgo(*aBoolMSIt); + storeGenerationHistory(aResultBody, *aGenBaseIt, aMSList); } - int aModTag = aTag; - storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag); + storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt); ResultBaseAlgo aRBA; aRBA.resultBody = aResultBody; aRBA.baseShape = *aBoolObjIt; aRBA.makeShape = *aBoolMSIt; - aRBA.delTag = aModTag; aResultBaseAlgoList.push_back(aRBA); aResultShapesList.push_back((*aBoolMSIt)->shape()); } @@ -199,9 +196,11 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools, // Collecting solids from compsolids which will not be modified in boolean operation. ListOfShape aShapesToAdd; - for(GeomAPI_ShapeExplorer - anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - GeomShapePtr aSolidInCompSolid = anExp.current(); + for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid); + aCompSolidIt.more(); + aCompSolidIt.next()) + { + GeomShapePtr aSolidInCompSolid = aCompSolidIt.current(); ListOfShape::const_iterator aUsedShapesIt = aUsedShapes.cbegin(); for(; aUsedShapesIt != aUsedShapes.cend(); ++aUsedShapesIt) { if(aSolidInCompSolid->isEqual(*aUsedShapesIt)) { @@ -282,9 +281,11 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools, aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedShapes.begin(), aUsedShapes.end()); // Collect solids from compsolid which will not be modified in boolean operation. - for(GeomAPI_ShapeExplorer - anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) { - GeomShapePtr aSolidInCompSolid = anExp.current(); + for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid); + aCompSolidIt.more(); + aCompSolidIt.next()) + { + GeomShapePtr aSolidInCompSolid = aCompSolidIt.current(); ListOfShape::iterator anIt = aUsedShapes.begin(); for(; anIt != aUsedShapes.end(); anIt++) { if(aSolidInCompSolid->isEqual(*anIt)) { @@ -380,38 +381,16 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools, void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theObject, const ListOfShape& theTools, - const std::shared_ptr theMakeShape, - int& theTag) + const std::shared_ptr theMakeShape) { - int aModTag = theTag; - int anEdgesAndFacesTag = ++aModTag; - int aDelTag = ++anEdgesAndFacesTag; - theTag = aDelTag; - - const std::string aModName = "Modfied"; - ListOfShape aTools = theTools; aTools.push_back(theObject); - std::shared_ptr aMap = theMakeShape->mapOfSubShapes(); - - int aTag; - std::string aName; for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) { - if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) { - aTag = anEdgesAndFacesTag; - aName = aModName + "_Edge"; - } - else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) { - aTag = anEdgesAndFacesTag; - aName = aModName + "_Face"; - } else { - aTag = aModTag; - aName = aModName; - } - theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt, - (*anIt)->shapeType() == GeomAPI_Shape::EDGE ? - GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true); + theResultBody->loadModifiedShapes(theMakeShape, *anIt, + (*anIt)->shapeType() == GeomAPI_Shape::EDGE ? + GeomAPI_Shape::EDGE : + GeomAPI_Shape::FACE); } } @@ -426,18 +405,16 @@ void FeaturesPlugin_CompositeBoolean::storeDeletedShapes( ++anIt) { ResultBaseAlgo& aRCA = *anIt; - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), + aRCA.resultBody->loadDeletedShapes(aRCA.makeShape, aRCA.baseShape, GeomAPI_Shape::FACE, - aRCA.delTag, theResultShapesCompound); for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(), + aRCA.resultBody->loadDeletedShapes(aRCA.makeShape, *anIter, GeomAPI_Shape::FACE, - aRCA.delTag, theResultShapesCompound); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h index 3f07d107b..237c62d9d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h @@ -55,7 +55,6 @@ protected: ResultBodyPtr resultBody; GeomShapePtr baseShape; std::shared_ptr makeShape; - int delTag; }; protected: @@ -80,15 +79,13 @@ protected: /// Stores generation history. virtual void storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag) = 0; + const GeomMakeShapePtr theMakeShape) = 0; /// Stores modification history. void storeModificationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theObject, const ListOfShape& theTools, - const std::shared_ptr theMakeShape, - int& theTag); + const std::shared_ptr theMakeShape); /// Stores deleted shapes. void storeDeletedShapes(std::vector& theResultBaseAlgoList, diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 77766fcb5..e3d5803ba 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -39,13 +39,11 @@ #include #include -static void storeSubShape(ResultBodyPtr theResultBody, +static void storeSubShape(const std::shared_ptr theMakeShape, + ResultBodyPtr theResultBody, const GeomShapePtr theShape, const GeomAPI_Shape::ShapeType theType, - const std::shared_ptr theMapOfSubShapes, - const std::string theName, - int& theShapeIndex, - int& theTag); + const std::string& theName); //================================================================================================= void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int theInitFlags) @@ -86,11 +84,12 @@ int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const std::shared_ptr FeaturesPlugin_CompositeSketch::subFeature(const int theIndex, bool forTree) { + FeaturePtr aSubFeature; if(theIndex == 0) { - return std::dynamic_pointer_cast(data()->reference(SKETCH_ID())->value()); + aSubFeature = + std::dynamic_pointer_cast(data()->reference(SKETCH_ID())->value()); } - - return std::shared_ptr(); + return aSubFeature; } //================================================================================================= @@ -110,14 +109,14 @@ int FeaturesPlugin_CompositeSketch::subFeatureId(const int theIndex) const //================================================================================================= bool FeaturesPlugin_CompositeSketch::isSub(ObjectPtr theObject) const { + bool isSubFeature = false; // Check is this feature of result FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); - if(!aFeature.get()) { - return false; + if (aFeature.get()) { + ObjectPtr aSub = data()->reference(SKETCH_ID())->value(); + isSubFeature = aSub == theObject; } - - ObjectPtr aSub = data()->reference(SKETCH_ID())->value(); - return aSub == theObject; + return isSubFeature; } //================================================================================================= @@ -237,31 +236,6 @@ void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesLis } } -//================================================================================================= -bool FeaturesPlugin_CompositeSketch::isMakeShapeValid( - const std::shared_ptr theMakeShape) -{ - // Check that algo is done. - if(!theMakeShape->isDone()) { - setError("Error: " + getKind() + " algorithm failed."); - return false; - } - - // Check if shape is not null. - if(!theMakeShape->shape().get() || theMakeShape->shape()->isNull()) { - setError("Error: Resulting shape is null."); - return false; - } - - // Check that resulting shape is valid. - if(!theMakeShape->isValid()) { - setError("Error: Resulting shape is not valid."); - return false; - } - - return true; -} - //================================================================================================= void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape, const std::shared_ptr theMakeShape, @@ -274,8 +248,7 @@ void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape aResultBody->storeGenerated(theBaseShape, theMakeShape->shape()); // Store generated edges/faces. - int aGenTag = 1; - storeGenerationHistory(aResultBody, theBaseShape, theMakeShape, aGenTag); + storeGenerationHistory(aResultBody, theBaseShape, theMakeShape); setResult(aResultBody, theIndex); } @@ -283,31 +256,17 @@ void FeaturesPlugin_CompositeSketch::storeResult(const GeomShapePtr theBaseShape //================================================================================================= void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag) + const std::shared_ptr theMakeShape) { GeomAPI_Shape::ShapeType aBaseShapeType = theBaseShape->shapeType(); GeomAPI_Shape::ShapeType aShapeTypeToExplode = GeomAPI_Shape::SHAPE; - std::string aGenName = "Generated_"; - std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); switch(aBaseShapeType) { case GeomAPI_Shape::EDGE: { aShapeTypeToExplode = GeomAPI_Shape::VERTEX; break; } case GeomAPI_Shape::WIRE: { - //std::shared_ptr aV1, aV2; - //GeomAlgoAPI_ShapeTools::findBounds(theBaseShape, aV1, aV2); - //ListOfShape aV1History, aV2History; - //theMakeShape->generated(aV1, aV1History); - //theMakeShape->generated(aV2, aV2History); - //if(!aV1History.empty()) { - // theResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", theTag++); - //} - //if(!aV2History.empty()) { - // theResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", theTag++); - //} aShapeTypeToExplode = GeomAPI_Shape::COMPOUND; break; } @@ -321,158 +280,54 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes } } + int aLateralIndex = 1; + int aBaseEdgeIndex = 1; + int aVertexIndex = 1; + int aBaseVertexIndex = 1; + if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX || aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { - theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::VERTEX, - theTag++, aGenName + "Edge", - *aMapOfSubShapes.get()); + theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX); } if(aShapeTypeToExplode == GeomAPI_Shape::EDGE || aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { - theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), - theBaseShape, GeomAPI_Shape::EDGE, - theTag++, aGenName + "Face", - *aMapOfSubShapes.get()); - } - // issue #2197: make naming of edges generated from vertices - if (aShapeTypeToExplode == GeomAPI_Shape::EDGE) { - GeomAPI_DataMapOfShapeShape aFacesFromFromEdges; - GeomAPI_ShapeExplorer anEdgeExp(theBaseShape, GeomAPI_Shape::EDGE); - for(; anEdgeExp.more(); anEdgeExp.next()) { - ListOfShape aGenerated; - theMakeShape->generated(anEdgeExp.current(), aGenerated); - ListOfShape::iterator aGenIter = aGenerated.begin(); - for(; aGenIter != aGenerated.end(); aGenIter++) { - GeomShapePtr aGen = *aGenIter; - if (aGen.get() && !aGen->isNull()) { - if ((*aGenIter)->shapeType() == GeomAPI_Shape::FACE) { // normal case - aFacesFromFromEdges.bind(aGen, anEdgeExp.current()); - } - } - } - } - - // closed revolution of 1-3 faces can not distinguish lateral and base edges - if (aFacesFromFromEdges.size() <= 3) { - bool isClosed = false; // lateral edges are closed (in full revolution) - GeomAPI_DataMapOfShapeShape anEdgesFromVertices; - GeomAPI_ShapeExplorer aVertExp(theBaseShape, GeomAPI_Shape::VERTEX); - for(; aVertExp.more(); aVertExp.next()) { - ListOfShape aGenerated; - theMakeShape->generated(aVertExp.current(), aGenerated); - ListOfShape::iterator aGenIter = aGenerated.begin(); - for(; aGenIter != aGenerated.end(); aGenIter++) { - std::shared_ptr aGenerated = *aGenIter; - if (anEdgesFromVertices.isBound(aGenerated)) // already here - continue; - std::ostringstream aStream; - aStream<<"Lateral_"<generated(aGenerated, aStream.str(), theTag++); - - anEdgesFromVertices.bind(aGenerated, aVertExp.current()); - std::shared_ptr anEdge(new GeomAPI_Edge(aGenerated)); - isClosed = isClosed || anEdge->isClosed(); - } - } - if (isClosed) { - GeomAPI_ShapeExplorer anEdgesExp(theMakeShape->shape(), GeomAPI_Shape::EDGE); - for(; anEdgesExp.more(); anEdgesExp.next()) { - if (!anEdgesFromVertices.isBound(anEdgesExp.current())) { - // found a base edge - std::ostringstream aStream; - aStream<<"Base_Edge_"<generated(anEdgesExp.current(), aStream.str(), theTag++); - // only one orientation is needed - anEdgesFromVertices.bind(anEdgesExp.current(), anEdgesExp.current()); - } - } - } else if (aFacesFromFromEdges.size() == 1) { // 2233: sphere created by the revolution: - // vertices at degenerated edges will have the same name - GeomAPI_DataMapOfShapeShape aVertices; - GeomAPI_ShapeExplorer aVertExp(theMakeShape->shape(), GeomAPI_Shape::VERTEX); - for(int anIndex = 1; aVertExp.more(); aVertExp.next()) { - if (!aVertices.isBound(aVertExp.current())) { - // found a base edge - std::ostringstream aStream; - aStream<<"Vertex_"<generated(aVertExp.current(), aStream.str(), theTag++); - // only one orientation is needed - aVertices.bind(aVertExp.current(), aVertExp.current()); - } - } - } - } else { // issue #2197, test case 4 : edges that produce fully-revolved face, - // but contain only 2 edges (on apex of revolution) - GeomAPI_ShapeExplorer anEdgeExp(theBaseShape, GeomAPI_Shape::EDGE); - for(; anEdgeExp.more(); anEdgeExp.next()) { - ListOfShape aGenerated; - theMakeShape->generated(anEdgeExp.current(), aGenerated); - ListOfShape::iterator aGenIter = aGenerated.begin(); - for(; aGenIter != aGenerated.end(); aGenIter++) { - GeomShapePtr aGen = (*aGenIter); - if (aGen.get() && !aGen->isNull()) { - GeomAPI_ShapeExplorer aFaceEdgeExp(aGen, GeomAPI_Shape::EDGE); - int aNumEdges = 0; - int aNumClosed = 0; - GeomShapePtr aNotClosedEdge; - GeomEdgePtr aDegenerateEdge; - GeomAPI_DataMapOfShapeShape alreadyIterated; - for(; aFaceEdgeExp.more(); aFaceEdgeExp.next()) { - std::shared_ptr anEdge(new GeomAPI_Edge(aFaceEdgeExp.current())); - if (anEdge->isDegenerated()) { - aDegenerateEdge = anEdge; - continue; - } - if (alreadyIterated.isBound(anEdge)) - continue; - alreadyIterated.bind(anEdge, anEdge); - aNumEdges++; - if (anEdge->isClosed()) { - aNumClosed++; - } else { - aNotClosedEdge = anEdge; - } - } - if (aNumEdges == 2 && aNumClosed == 1) { - std::ostringstream aStream; - aStream<<"Base_Edge_"<generated(aNotClosedEdge, aStream.str(), theTag++); - if (aDegenerateEdge.get()) { // export vertex of the degenerated edge (apex) #2520 - GeomAPI_ShapeExplorer anEdgeExp(aDegenerateEdge, GeomAPI_Shape::VERTEX); - if (anEdgeExp.more()) { - std::ostringstream aStream; - aStream << "Base_Vertex_" << theTag++; - theResultBody->generated(anEdgeExp.current(), aStream.str(), theTag++); - } - } - } - } - } - } - } + theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE); } - + std::list > aSweeps; // all sweeps collected std::shared_ptr aMakeSweep = std::dynamic_pointer_cast(theMakeShape); if(aMakeSweep.get()) { + aSweeps.push_back(aMakeSweep); + } else { + std::shared_ptr aMakeList = + std::dynamic_pointer_cast(theMakeShape); + if (aMakeList.get()) { + ListOfMakeShape::const_iterator anIter = aMakeList->list().cbegin(); + for(; anIter != aMakeList->list().cend(); anIter++) { + std::shared_ptr aSweep = + std::dynamic_pointer_cast(*anIter); + if (aSweep.get()) + aSweeps.push_back(aSweep); + } + } + } + std::list >::iterator aSweep = aSweeps.begin(); + for(; aSweep != aSweeps.end(); aSweep++) { // Store from shapes. - storeShapes(theResultBody, aBaseShapeType, aMapOfSubShapes, - aMakeSweep->fromShapes(), "From_", theTag); + storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->fromShapes(), "From_"); // Store to shapes. - storeShapes(theResultBody, aBaseShapeType, aMapOfSubShapes, - aMakeSweep->toShapes(), "To_", theTag); + storeShapes(theMakeShape, theResultBody, aBaseShapeType, (*aSweep)->toShapes(), "To_"); } } //================================================================================================= -void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody, - const GeomAPI_Shape::ShapeType theBaseShapeType, - const std::shared_ptr theMapOfSubShapes, - const ListOfShape& theShapes, - const std::string theName, - int& theTag) +void FeaturesPlugin_CompositeSketch::storeShapes( + const std::shared_ptr theMakeShape, + ResultBodyPtr theResultBody, + const GeomAPI_Shape::ShapeType theBaseShapeType, + const ListOfShape& theShapes, + const std::string theName) { GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE; std::string aShapeTypeStr = "Face"; @@ -501,48 +356,36 @@ void FeaturesPlugin_CompositeSketch::storeShapes(ResultBodyPtr theResultBody, } // Store shapes. - int aShapeIndex = 1; - int aFaceIndex = 1; for(ListOfShape::const_iterator anIt = theShapes.cbegin(); anIt != theShapes.cend(); ++anIt) { GeomShapePtr aShape = *anIt; if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) { std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face"); - storeSubShape(theResultBody, - aShape, - aShape->shapeType(), - theMapOfSubShapes, - aName, - aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex, - theTag); + storeSubShape(theMakeShape, theResultBody, aShape, aShape->shapeType(), aName); } else { std::string aName = theName + aShapeTypeStr; - storeSubShape(theResultBody, aShape, aShapeTypeToExplore, - theMapOfSubShapes, aName, aShapeIndex, theTag); + storeSubShape(theMakeShape, theResultBody, aShape, aShapeTypeToExplore, aName); if (theBaseShapeType == GeomAPI_Shape::WIRE) { // issue 2289: special names also for vertices aName = theName + "Vertex"; - storeSubShape(theResultBody, aShape, GeomAPI_Shape::VERTEX, - theMapOfSubShapes, aName, aShapeIndex, theTag); + storeSubShape(theMakeShape, theResultBody, aShape, GeomAPI_Shape::VERTEX, aName); } } } } -void storeSubShape(ResultBodyPtr theResultBody, - const GeomShapePtr theShape, - const GeomAPI_Shape::ShapeType theType, - const std::shared_ptr theMapOfSubShapes, - const std::string theName, - int& theShapeIndex, - int& theTag) +void storeSubShape( + const std::shared_ptr theMakeShape, + ResultBodyPtr theResultBody, + const GeomShapePtr theShape, + const GeomAPI_Shape::ShapeType theType, + const std::string& theName) { for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) { GeomShapePtr aSubShape = anExp.current(); - if(theMapOfSubShapes->isBound(aSubShape)) { - aSubShape = theMapOfSubShapes->find(aSubShape); + if (!theResultBody->generated(aSubShape, theName)) { + // store from/to shapes as primitives and then store modification of them by the boolean + theResultBody->generated(aSubShape, theName, false); + theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType); } - std::ostringstream aStr; - aStr << theName << "_" << theShapeIndex++; - theResultBody->generated(aSubShape, aStr.str(), theTag++); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h index 62d5c30f6..f714351aa 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.h @@ -83,9 +83,6 @@ protected: /// \param[in] theIsMakeShells if true make shells from faces with shared edges. void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true); - /// Checks make shape algo. - bool isMakeShapeValid(const std::shared_ptr theMakeShape); - /// Stores result of generation. void storeResult(const GeomShapePtr theBaseShape, const std::shared_ptr theMakeShape, @@ -94,16 +91,14 @@ protected: /// Stores generation history. void storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag); + const std::shared_ptr theMakeShape); - /// Used to store from and to shapes. - void storeShapes(ResultBodyPtr theResultBody, + /// Used to store from and to shapes: generated, or in common modified tag + void storeShapes(const std::shared_ptr theMakeShape, + ResultBodyPtr theResultBody, const GeomAPI_Shape::ShapeType theBaseShapeType, - const std::shared_ptr theMapOfSubShapes, const ListOfShape& theShapes, - const std::string theName, - int& theTag); + const std::string theName); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index baf8f6397..05a31bb3e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -27,10 +27,12 @@ #include #include +#include #include #include #include +#include //================================================================================================= FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion() @@ -95,16 +97,29 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, getBaseShapes(theBaseShapes); //Getting direction. - std::shared_ptr aDir; - std::shared_ptr anEdge; + static const std::string aSelectionError = "Error: The direction shape selection is bad."; AttributeSelectionPtr aSelection = selection(DIRECTION_OBJECT_ID()); - if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->value())); - } else if(aSelection->context().get() && - aSelection->context()->shape().get() && - aSelection->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->context()->shape())); + GeomShapePtr aShape = aSelection->value(); + if (!aShape.get()) { + if (aSelection->context().get()) { + aShape = aSelection->context()->shape(); + } + } + + GeomEdgePtr anEdge; + if (aShape.get()) { + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); + } } + + std::shared_ptr aDir; if(anEdge.get()) { if(anEdge->isLine()) { aDir = anEdge->line()->direction(); @@ -134,6 +149,10 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, if(!aToShape.get() && aSelection->context().get()) { aToShape = aSelection->context()->shape(); } + if (aToShape.get() && aToShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aToShape); + aToShape = anIt.current(); + } } aSelection = selection(FROM_OBJECT_ID()); if(aSelection.get()) { @@ -141,10 +160,15 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, if(!aFromShape.get() && aSelection->context().get()) { aFromShape = aSelection->context()->shape(); } + if (aFromShape.get() && aFromShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFromShape); + aFromShape = anIt.current(); + } } } // Generating result for each base shape. + std::string anError; for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) { std::shared_ptr aBaseShape = *anIter; @@ -152,7 +176,8 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes, std::shared_ptr aPrismAlgo(new GeomAlgoAPI_Prism(aBaseShape, aDir, aToShape, aToSize, aFromShape, aFromSize)); - if(!isMakeShapeValid(aPrismAlgo)) { + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPrismAlgo, getKind(), anError)) { + setError(anError); return false; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp index 88af05a75..24ae1d7bc 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.cpp @@ -38,9 +38,7 @@ bool FeaturesPlugin_ExtrusionBoolean::makeGeneration(ListOfShape& theBaseShapes, //================================================================================================= void FeaturesPlugin_ExtrusionBoolean::storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag) + const std::shared_ptr theMakeShape) { - FeaturesPlugin_Extrusion::storeGenerationHistory(theResultBody, theBaseShape, - theMakeShape, theTag); + FeaturesPlugin_Extrusion::storeGenerationHistory(theResultBody, theBaseShape, theMakeShape); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h index ed9f8f3c4..8582456f1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_ExtrusionBoolean.h @@ -44,8 +44,7 @@ protected: /// Stores generation history. void storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag); + const std::shared_ptr theMakeShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index 8b0fdab81..cf1dda3d2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -147,6 +148,7 @@ void FeaturesPlugin_Fillet::execute() GeomAlgoAPI_MakeShapeList aMakeShapeList; std::shared_ptr aFilletBuilder; int aResultIndex = 0; + std::string anError; GeomAPI_DataMapOfShapeMapOfShapes::iterator anIt = aSolidsAndSubs.begin(); for (; anIt != aSolidsAndSubs.end(); ++anIt) { @@ -158,45 +160,26 @@ void FeaturesPlugin_Fillet::execute() aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1)); else aFilletBuilder.reset(new GeomAlgoAPI_Fillet(aSolid, aFilletEdges, aRadius1, aRadius2)); - if (isFailed(aFilletBuilder)) + + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) { + setError(anError); return; + } GeomShapePtr aResult = unwrapCompound(aFilletBuilder->shape()); std::shared_ptr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aResultBody, aSolid, aFilletEdgesAndVertices, aResult, aFilletBuilder); + loadNamingDS(aResultBody, aSolid, aResult, aFilletBuilder); setResult(aResultBody, aResultIndex); aResultIndex++; } removeResults(aResultIndex); } -bool FeaturesPlugin_Fillet::isFailed( - const std::shared_ptr& theAlgorithm) -{ - if (!theAlgorithm->isDone()) { - static const std::string aFeatureError = "Error: fillet algorithm failed."; - setError(aFeatureError); - return true; - } - if (theAlgorithm->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape of fillet is Null."; - setError(aShapeError); - return true; - } - if (!theAlgorithm->isValid()) { - std::string aFeatureError = "Error: Resulting shape of fillet is not valid."; - setError(aFeatureError); - return true; - } - return false; -} - void FeaturesPlugin_Fillet::loadNamingDS( std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, - const ListOfShape& theFilletShapes, const std::shared_ptr theResultShape, const std::shared_ptr& theMakeShape) { @@ -206,32 +189,24 @@ void FeaturesPlugin_Fillet::loadNamingDS( return; } - std::shared_ptr aMapOfShapes = theMakeShape->mapOfSubShapes(); - - const int aDeletedTag = 1; - const int aModifyTag = 2; - const int aGeneratedTag = 3; - /// sub solids will be placed at labels 4, 5, etc. if result is compound of solids - const int aSubsolidsTag = 4; - - theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag); + theResultBody->storeModified(theBaseShape, theResultShape); - const std::string aModFaceName = "Modified_Face"; const std::string aFilletFaceName = "Fillet_Face"; // Store modified faces - theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::FACE, aModifyTag, aModFaceName, *aMapOfShapes); + theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); // Store new faces generated from edges and vertices - theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::EDGE, aGeneratedTag, aFilletFaceName, *aMapOfShapes); - theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes); + theResultBody->loadGeneratedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::EDGE, + aFilletFaceName); + theResultBody->loadGeneratedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::VERTEX, + aFilletFaceName); // Deleted shapes - theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::EDGE, aDeletedTag); - theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape, - GeomAPI_Shape::FACE, aDeletedTag); + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE); + theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h index d0aa71255..15472e217 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h @@ -106,13 +106,9 @@ public: FeaturesPlugin_Fillet(); private: - /// Check algorithm is finished correctly and store error otherwise - bool isFailed(const std::shared_ptr& theAlgorithm); - /// Load Naming data structure of the feature to the document void loadNamingDS(std::shared_ptr theResultBody, const std::shared_ptr theBaseShape, - const ListOfShape& theFilletShapes, const std::shared_ptr theResultShape, const std::shared_ptr& theMakeShape); }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp index b3cc312c5..22e2d8383 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_FusionFaces.cpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -60,16 +61,9 @@ void FeaturesPlugin_FusionFaces::execute() std::shared_ptr anAlgo(new GeomAlgoAPI_UnifySameDomain(aBaseShape)); // Check algo status - if (!anAlgo->isDone()) { - setError("Error: Fusion algorithm failed."); - return; - } - if (anAlgo->shape()->isNull()) { - setError("Error: Resulting shape is Null."); - return; - } - if (!anAlgo->isValid()) { - setError("Error: Resulting shape is not valid."); + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) { + setError(anError); return; } @@ -81,15 +75,8 @@ void FeaturesPlugin_FusionFaces::execute() } else { aResultBody->storeModified(aBaseShape, aResultShape); - const int aModifyEdgeTag = 1; - const int aModifyFaceTag = 2; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; - std::shared_ptr aMapOfShapes = anAlgo->mapOfSubShapes(); - aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, *aMapOfShapes.get(), true); - aResultBody->loadAndOrientModifiedShapes(anAlgo.get(), aBaseShape, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, *aMapOfShapes.get(), true); + aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(anAlgo, aBaseShape, GeomAPI_Shape::FACE); } setResult(aResultBody); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp index 7a33f2d46..93a02c79f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -68,22 +69,12 @@ void FeaturesPlugin_Intersection::execute() int aResultIndex = 0; // Create result. - GeomAlgoAPI_Intersection anIntersectionAlgo(anObjects); + GeomMakeShapePtr anIntersectionAlgo(new GeomAlgoAPI_Intersection(anObjects)); // Checking that the algorithm worked properly. - if (!anIntersectionAlgo.isDone()) { - static const std::string aFeatureError = "Error: Intersection algorithm failed."; - setError(aFeatureError); - return; - } - if (anIntersectionAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - return; - } - if (!anIntersectionAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + std::string anError; + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anIntersectionAlgo, getKind(), anError)) { + setError(anError); return; } @@ -98,66 +89,28 @@ void FeaturesPlugin_Intersection::execute() } //================================================================================================= -void FeaturesPlugin_Intersection::loadNamingDS(std::shared_ptr theResultBody, +void FeaturesPlugin_Intersection::loadNamingDS(ResultBodyPtr theResultBody, const ListOfShape& theObjects, - GeomAlgoAPI_MakeShape& theMakeShape) + const GeomMakeShapePtr& theMakeShape) { - std::shared_ptr aResultShape = theMakeShape.shape(); + std::shared_ptr aResultShape = theMakeShape->shape(); + + if(theObjects.front()->isEqual(aResultShape)) { + theResultBody->store(aResultShape, false); + return; + } + theResultBody->storeModified(theObjects.front(), aResultShape); - GeomAPI_DataMapOfShapeShape aShapesMap; // Map to store {result_shape, original_shape} - const int aShapeTypesNb = 2; - const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = - {GeomAPI_Shape::VERTEX, GeomAPI_Shape::EDGE}; + const int aShapeTypesNb = 3; + const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = {GeomAPI_Shape::VERTEX, + GeomAPI_Shape::EDGE, + GeomAPI_Shape::FACE }; for (ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { const GeomShapePtr aShape = *anIt; for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) { - for(GeomAPI_ShapeExplorer anOrigShapeExp(aShape, aShapeTypes[anIndex]); - anOrigShapeExp.more(); - anOrigShapeExp.next()) { - ListOfShape aHistory; - const GeomShapePtr aSubShape = anOrigShapeExp.current(); - theMakeShape.modified(aSubShape, aHistory); - for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); - aHistoryIt != aHistory.cend(); - ++aHistoryIt) { - aShapesMap.bind(*aHistoryIt, aSubShape); - } - } - } - } - - int aModifiedVertexIndex(1), - aGeneratedVertexIndex(1), - aModifiedEdgeIndex(1), - aGeneratedEdgeIndex(1); - int aTag = 4; - GeomAPI_DataMapOfShapeShape aStoredShapes; - for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) { - for(GeomAPI_ShapeExplorer aShapeExp(aResultShape, aShapeTypes[anIndex]); - aShapeExp.more(); - aShapeExp.next()) { - const GeomShapePtr aSubShape = aShapeExp.current(); - if(aStoredShapes.isBound(aSubShape)) { - continue; - } - if(aShapesMap.isBound(aSubShape)) { - theResultBody->modified(aShapesMap.find(aSubShape), - aSubShape, - std::string("Modified_") - + (anIndex == 0 ? "Vertex_" : "Edge_") - + std::to_string((long long)(anIndex == 0 ? aModifiedVertexIndex++ - : aModifiedEdgeIndex++)), - aTag++); - } else { - theResultBody->generated(aSubShape, - std::string("Generated_") - + (anIndex == 0 ? "Vertex_" : "Edge_") - + std::to_string((long long)(anIndex == 0 ? aGeneratedVertexIndex++ - : aGeneratedEdgeIndex++)), - aTag++); - } - aStoredShapes.bind(aSubShape, aSubShape); + theResultBody->loadModifiedShapes(theMakeShape, aShape, aShapeTypes[anIndex]); + theResultBody->loadGeneratedShapes(theMakeShape, aShape, aShapeTypes[anIndex]); } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Intersection.h b/src/FeaturesPlugin/FeaturesPlugin_Intersection.h index c4a210fc8..581c6e860 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Intersection.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Intersection.h @@ -73,7 +73,7 @@ private: /// Load Naming data structure of the feature to the document. void loadNamingDS(std::shared_ptr theResultBody, const ListOfShape& theObjects, - GeomAlgoAPI_MakeShape& theMakeShape); + const std::shared_ptr& theMakeShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp index 5deb05c69..7d04b88d6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Measurement.cpp @@ -323,6 +323,13 @@ AISObjectPtr FeaturesPlugin_Measurement::getAISObject(AISObjectPtr thePrevious) if ((aValues->size() == 0) || (aValues->value(0) <= Precision::Confusion())) return AISObjectPtr(); + if (!myScreenPlane) { + // initialize a default plane for dimension + GeomPointPtr anOrigin(new GeomAPI_Pnt(0., 0., 0.)); + GeomDirPtr aNormal(new GeomAPI_Dir(0., 0., 1.)); + myScreenPlane = GeomPlanePtr(new GeomAPI_Pln(anOrigin, aNormal)); + } + AISObjectPtr anAIS; std::string aKind = string(MEASURE_KIND())->value(); if (aKind == MEASURE_LENGTH()) @@ -342,8 +349,6 @@ AISObjectPtr FeaturesPlugin_Measurement::getAISObject(AISObjectPtr thePrevious) AISObjectPtr FeaturesPlugin_Measurement::lengthDimension(AISObjectPtr thePrevious) { AISObjectPtr aAISObj; - if (!myScreenPlane.get()) - return aAISObj; AttributeSelectionPtr aSelectedFeature = selection(EDGE_FOR_LENGTH_ID()); @@ -404,8 +409,6 @@ AISObjectPtr FeaturesPlugin_Measurement::lengthDimension(AISObjectPtr thePreviou AISObjectPtr FeaturesPlugin_Measurement::distanceDimension(AISObjectPtr thePrevious) { AISObjectPtr aAISObj; - if (!myScreenPlane.get()) - return aAISObj; AttributeSelectionPtr aFirstFeature = selection(DISTANCE_FROM_OBJECT_ID()); AttributeSelectionPtr aSecondFeature = selection(DISTANCE_TO_OBJECT_ID()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp index 5f8870f59..4206e904f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -15,6 +16,7 @@ #include #include #include +#include #include #include @@ -49,24 +51,29 @@ void FeaturesPlugin_MultiRotation::initAttributes() data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID(), ModelAPI_AttributeInteger::typeId()); - /*data()->addAttribute(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID(), +#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS + data()->addAttribute(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(FeaturesPlugin_MultiRotation::STEP_RADIAL_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FeaturesPlugin_MultiRotation::NB_COPIES_RADIAL_ID(), - ModelAPI_AttributeInteger::typeId());*/ + ModelAPI_AttributeInteger::typeId()); +#endif } //================================================================================================= void FeaturesPlugin_MultiRotation::execute() { - /*std::string useRadialDir = string(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID())->value(); +#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS + std::string useRadialDir = string(FeaturesPlugin_MultiRotation::USE_RADIAL_DIR_ID())->value(); if (useRadialDir.empty()) { performRotation1D(); } else { performRotation2D(); - }*/ + } +#else performRotation1D(); +#endif } //================================================================================================= @@ -78,6 +85,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D() AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID()); if (anObjectsSelList->size() == 0) { + setError("Error: empty selection list"); return; } for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { @@ -85,7 +93,6 @@ void FeaturesPlugin_MultiRotation::performRotation1D() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -93,21 +100,39 @@ void FeaturesPlugin_MultiRotation::performRotation1D() } //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_ANGULAR_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + if (!aShape.get()) { + setError(aSelectionError); + return; } + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); + } + + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + // Getting number of copies. int nbCopies = integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID())->value(); @@ -149,6 +174,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D() aResultIndex++; } } else { + std::string anError; ListOfShape aListOfShape; std::list > aListOfRotationAlgo; @@ -164,19 +190,8 @@ void FeaturesPlugin_MultiRotation::performRotation1D() aRotationnAlgo->build(); // Checking that the algorithm worked properly. - if (!aRotationnAlgo->isDone()) { - static const std::string aFeatureError = "Error : Multitranslation algorithm failed."; - setError(aFeatureError); - break; - } - if (aRotationnAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is null."; - setError(aShapeError); - break; - } - if (!aRotationnAlgo->isValid()) { - static const std::string aFeatureError = "Error : Resulting shape in not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationnAlgo, getKind(), anError)) { + setError(anError); break; } aListOfShape.push_back(aRotationnAlgo->shape()); @@ -198,6 +213,7 @@ void FeaturesPlugin_MultiRotation::performRotation1D() } //================================================================================================= +#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS void FeaturesPlugin_MultiRotation::performRotation2D() { // Getting objects. @@ -213,7 +229,6 @@ void FeaturesPlugin_MultiRotation::performRotation2D() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -388,34 +403,16 @@ void FeaturesPlugin_MultiRotation::loadNamingDS2( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aRotatedName; - for (std::list >::const_iterator anIt = theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) { - std::cout << "LOAD" << std::endl; - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face"); // naming of edges - aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge"); // naming of vertex - aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); - - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex"); } } @@ -425,7 +422,6 @@ void FeaturesPlugin_MultiRotation::loadNamingDS3( std::shared_ptr theResultBody, std::shared_ptr theBaseShape, int nb) { - int aTag = 6*nb+1; int anIndex = nb+1; std::string aRotatedName; @@ -438,12 +434,13 @@ void FeaturesPlugin_MultiRotation::loadNamingDS3( for(; anExp.more(); anExp.next()) { aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex); aRotatedName = aRotatedName + "_" + std::to_string((long long) numFace); - theResultBody->generated(anExp.current(), aRotatedName, aTag++); + theResultBody->generated(anExp.current(), aRotatedName); ++numFace; } ++anIndex; } } +#endif //================================================================================================= void FeaturesPlugin_MultiRotation::loadNamingDS( @@ -451,31 +448,15 @@ void FeaturesPlugin_MultiRotation::loadNamingDS( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aRotatedName; - for (std::list >::const_iterator anIt = theListOfRotationAlgo.begin(); anIt != theListOfRotationAlgo.cend(); ++anIt) { - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aRotatedName = "Rotated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::FACE, "Rotated_Face"); // naming of edges - aRotatedName = "Rotated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::EDGE, "Rotated_Edge"); // naming of vertex - aRotatedName = "Rotated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aRotatedName, *aSubShapes.get(), - false, true); - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, theBaseShape, GeomAPI_Shape::VERTEX, "Rotated_Vertex"); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h index 45af5b97c..ba5a7a196 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiRotation.h @@ -106,7 +106,8 @@ private: /// Perform the multi rotation in one direction. void performRotation1D(); - /// Perform the multi totation in two directions. +#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS + /// Perform the multi rotation in two directions. void performRotation2D(); void loadNamingDS2(std::list > theListOfTranslationAlgo, @@ -116,6 +117,7 @@ private: void loadNamingDS3(std::list > theListOfRotationAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape, int nb); +#endif void loadNamingDS(std::list > theListOfRotationAlgo, std::shared_ptr theResultBody, diff --git a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp index d23742c6d..ba1c1e8df 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_MultiTranslation.cpp @@ -21,10 +21,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -86,6 +88,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID()); if (anObjectsSelList->size() == 0) { + setError("Error: empty selection list"); return; } for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { @@ -93,7 +96,6 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -101,21 +103,39 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() } //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + if (!aShape.get()) { + setError(aSelectionError); + return; + } + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + // Getting step. double aStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value(); @@ -150,6 +170,7 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() aResultIndex++; } } else { + std::string anError; ListOfShape aListOfShape; std::list > aListOfTranslationAlgo; @@ -165,19 +186,9 @@ void FeaturesPlugin_MultiTranslation::performOneDirection() aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if (!aTranslationAlgo->isDone()) { - static const std::string aFeatureError = "Error : Multitranslation algorithm failed."; - setError(aFeatureError); - break; - } - if (aTranslationAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is null."; - setError(aShapeError); - break; - } - if (!aTranslationAlgo->isValid()) { - static const std::string aFeatureError = "Error : Resulting shape in not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed( + aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } aListOfShape.push_back(aTranslationAlgo->shape()); @@ -207,6 +218,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() AttributeSelectionListPtr anObjectsSelList = selectionList(FeaturesPlugin_MultiTranslation::OBJECTS_LIST_ID()); if (anObjectsSelList->size() == 0) { + setError("Error: empty selection list"); return; } for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) { @@ -214,7 +226,6 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -222,33 +233,71 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() } //Getting axis. - std::shared_ptr aFirstAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_MultiTranslation::AXIS_FIRST_DIR_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_FIRST_DIR_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; } - if(anEdge) { - aFirstAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); } - std::shared_ptr aSecondAxis; - anObjRef = selection(FeaturesPlugin_MultiTranslation::AXIS_SECOND_DIR_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } - if(anEdge) { - aSecondAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + + if (!anEdge.get()) + { + setError(aSelectionError); + return; } + std::shared_ptr aFirstAxis(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + + //Getting axis. + anObjRef = selection(AXIS_SECOND_DIR_ID()); + aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } + + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); + } + + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr aSecondAxis(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + // Getting step. double aFirstStep = real(FeaturesPlugin_MultiTranslation::STEP_FIRST_DIR_ID())->value(); double aSecondStep = real(FeaturesPlugin_MultiTranslation::STEP_SECOND_DIR_ID())->value(); @@ -310,6 +359,7 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() } } } else { + std::string anError; ListOfShape aListOfShape; std::list > aListOfTranslationAlgo; @@ -329,21 +379,11 @@ void FeaturesPlugin_MultiTranslation::performTwoDirection() aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if (!aTranslationAlgo->isDone()) { - static const std::string aFeatureError = "Error : Multitranslation algorithm failed."; - setError(aFeatureError); - break; - } - if (aTranslationAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is null."; - setError(aShapeError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed( + aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } - if (!aTranslationAlgo->isValid()) { - static const std::string aFeatureError = "Error : Resulting shape in not valid."; - setError(aFeatureError); - break; - } aListOfShape.push_back(aTranslationAlgo->shape()); aListOfTranslationAlgo.push_back(aTranslationAlgo); } @@ -368,32 +408,24 @@ void FeaturesPlugin_MultiTranslation::loadNamingDS( std::shared_ptr theResultBody, std::shared_ptr theBaseShape) { - int aTag = 1; - int anIndex = 1; - std::string aTranslatedName; - for (std::list >::const_iterator anIt = theListOfTranslationAlgo.begin(); anIt != theListOfTranslationAlgo.cend(); ++anIt) { - std::shared_ptr aSubShapes = (*anIt)->mapOfSubShapes(); - // naming of faces - aTranslatedName = "Translated_Face_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::FACE, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::FACE, + "Translated_Face"); // naming of edges - aTranslatedName = "Translated_Edge_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::EDGE, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::EDGE, + "Translated_Edge"); // naming of vertex - aTranslatedName = "Translated_Vertex_" + std::to_string((long long) anIndex); - theResultBody->loadAndOrientModifiedShapes((*anIt).get(), theBaseShape, GeomAPI_Shape::VERTEX, - aTag++, aTranslatedName, *aSubShapes.get(), - false, true); - - ++anIndex; + theResultBody->loadModifiedShapes(*anIt, + theBaseShape, + GeomAPI_Shape::VERTEX, + "Translated_Vertex"); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index cd4f34cd3..43ae4130c 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -66,9 +67,6 @@ static bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed, std::shared_ptr& theMakeShapeList, std::string& theError); -static bool isAlgoFailed(const std::shared_ptr& theAlgo, - std::string& theError); - //================================================================================================= FeaturesPlugin_Partition::FeaturesPlugin_Partition() @@ -125,7 +123,7 @@ void FeaturesPlugin_Partition::execute() new GeomAlgoAPI_Partition(aTargetObjects, aPlanes)); // Checking that the algorithm worked properly. - if (isAlgoFailed(aPartitionAlgo, aError)) { + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) { setError(aError); return; } @@ -143,7 +141,7 @@ void FeaturesPlugin_Partition::execute() aPartitionAlgo.reset(new GeomAlgoAPI_Partition(aTargetObjects, ListOfShape())); // Checking that the algorithm worked properly. - if (isAlgoFailed(aPartitionAlgo, aError)) { + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPartitionAlgo, getKind(), aError)) { setError(aError); return; } @@ -204,26 +202,18 @@ void FeaturesPlugin_Partition::storeResult( return; } - const int aDelTag = 1; - /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids - const int aSubTag = 2; - int aModTag = aSubTag + 10000; - const std::string aModName = "Modified"; - - aResultBody->storeModified(aBaseShape, theResultShape, aSubTag); + aResultBody->storeModified(aBaseShape, theResultShape); std::shared_ptr aMapOfSubShapes = theMakeShape->mapOfSubShapes(); theObjects.insert(theObjects.end(), thePlanes.begin(), thePlanes.end()); - int anIndex = 1; - for(ListOfShape::const_iterator anIt = theObjects.cbegin(); anIt != theObjects.cend(); ++anIt) { + for (ListOfShape::const_iterator anIt = theObjects.cbegin(); + anIt != theObjects.cend(); + ++anIt) + { GeomShapePtr aShape = *anIt; - std::string aModEdgeName = aModName + "_Edge_" + std::to_string((long long)anIndex); - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::EDGE, - aModTag, aModEdgeName, *aMapOfSubShapes.get(), false, true, true); - std::string aModFaceName = aModName + "_Face_" + std::to_string((long long)anIndex++); - aResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, - aModTag + 1, aModFaceName, *aMapOfSubShapes.get(), false, true, true); - aResultBody->loadDeletedShapes(theMakeShape.get(), aShape, GeomAPI_Shape::FACE, aDelTag); + aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE); + aResultBody->loadDeletedShapes(theMakeShape, aShape, GeomAPI_Shape::FACE); } setResult(aResultBody, theIndex); @@ -384,7 +374,7 @@ static bool cutSubs(const GeomShapePtr& theFirstArgument, // cut from current list of solids aCutAlgo.reset( new GeomAlgoAPI_Boolean(aUIt->second, theTools, GeomAlgoAPI_Boolean::BOOL_CUT)); - if (isAlgoFailed(aCutAlgo, theError)) + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCutAlgo, "", theError)) return false; theMakeShapeList->appendAlgo(aCutAlgo); @@ -419,22 +409,3 @@ bool cutUnusedSubs(CompsolidSubs& theObjects, CompsolidSubs& theNotUsed, return cutSubs(aFirstArgument, theObjects, aToolsForUsed, theMakeShapeList, theError) && cutSubs(aFirstArgument, theNotUsed, aToolsForUnused, theMakeShapeList, theError); } - -bool isAlgoFailed(const std::shared_ptr& theAlgo, std::string& theError) -{ - if (!theAlgo->isDone()) { - theError = "Error: Partition algorithm failed."; - return true; - } - if (theAlgo->shape()->isNull()) { - theError = "Error: Resulting shape is Null."; - return true; - } - if (!theAlgo->isValid()) { - theError = "Error: Resulting shape is not valid."; - return true; - } - - theError.clear(); - return false; -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index ca72a5aeb..b81823597 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -30,6 +30,8 @@ #include #include #include +#include + #include #include @@ -39,10 +41,8 @@ static void storeSubShape(ResultBodyPtr theResultBody, const GeomShapePtr theShape, const GeomAPI_Shape::ShapeType theType, - const std::shared_ptr theMapOfSubShapes, const std::string theName, - int& theShapeIndex, - int& theTag); + int& theShapeIndex); //================================================================================================== FeaturesPlugin_Pipe::FeaturesPlugin_Pipe() @@ -167,7 +167,7 @@ void FeaturesPlugin_Pipe::execute() } std::shared_ptr aPathShape = std::dynamic_pointer_cast(aPathSelection->value()); - if(!aPathShape.get()) { + if(!aPathShape.get() && aPathSelection->context().get()) { // Probaply it is a construction. aPathShape = aPathSelection->context()->shape(); } @@ -185,7 +185,7 @@ void FeaturesPlugin_Pipe::execute() return; } aBiNormal = std::dynamic_pointer_cast(aBiNormalSelection->value()); - if(!aBiNormal.get()) { + if(!aBiNormal.get() && aBiNormalSelection->context().get()) { // Probably it is a construction. aBiNormal = aBiNormalSelection->context()->shape(); } @@ -210,7 +210,7 @@ void FeaturesPlugin_Pipe::execute() return; } std::shared_ptr aLocationShape = aLocationSelection->value(); - if(!aLocationShape.get()) { + if(!aLocationShape.get() && aLocationSelection->context().get()) { // Probably it is a construction. aLocationShape = aLocationSelection->context()->shape(); } @@ -224,30 +224,22 @@ void FeaturesPlugin_Pipe::execute() // Generating result for each object. int aResultIndex = 0; + std::string anError; if(aCreationMethod == CREATION_METHOD_SIMPLE() || aCreationMethod == CREATION_METHOD_BINORMAL()) { for(ListOfShape::const_iterator anIter = aBaseShapesList.cbegin(); anIter != aBaseShapesList.cend(); anIter++) { std::shared_ptr aBaseShape = *anIter; - GeomAlgoAPI_Pipe aPipeAlgo = aCreationMethod == - CREATION_METHOD_SIMPLE() ? GeomAlgoAPI_Pipe(aBaseShape, aPathShape) : - GeomAlgoAPI_Pipe(aBaseShape, aPathShape, aBiNormal); + std::shared_ptr aPipeAlgo( + aCreationMethod == CREATION_METHOD_SIMPLE() ? new GeomAlgoAPI_Pipe(aBaseShape, + aPathShape) + : new GeomAlgoAPI_Pipe(aBaseShape, + aPathShape, + aBiNormal)); - if(!aPipeAlgo.isDone()) { - setError("Error: Pipe algorithm failed."); - aResultIndex = 0; - break; - } - - // Check if shape is valid - if(!aPipeAlgo.shape().get() || aPipeAlgo.shape()->isNull()) { - setError("Error: Resulting shape is Null."); - aResultIndex = 0; - break; - } - if(!aPipeAlgo.isValid()) { - setError("Error: Resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) { + setError(anError); aResultIndex = 0; break; } @@ -255,22 +247,12 @@ void FeaturesPlugin_Pipe::execute() storeResult(aBaseShape, aPipeAlgo, aResultIndex++); } } else if(aCreationMethod == CREATION_METHOD_LOCATIONS()) { - GeomAlgoAPI_Pipe aPipeAlgo = GeomAlgoAPI_Pipe(aBaseShapesList, aLocations, aPathShape); + std::shared_ptr aPipeAlgo(new GeomAlgoAPI_Pipe(aBaseShapesList, + aLocations, + aPathShape)); - if(!aPipeAlgo.isDone()) { - setError("Error: Pipe algorithm failed."); - removeResults(0); - return; - } - - // Check if shape is valid - if(!aPipeAlgo.shape().get() || aPipeAlgo.shape()->isNull()) { - setError("Error: Resulting shape is Null."); - removeResults(0); - return; - } - if(!aPipeAlgo.isValid()) { - setError("Error: Resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aPipeAlgo, getKind(), anError)) { + setError(anError); removeResults(0); return; } @@ -286,22 +268,19 @@ void FeaturesPlugin_Pipe::execute() //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBaseShape, - GeomAlgoAPI_Pipe& thePipeAlgo, + const std::shared_ptr thePipeAlgo, const int theResultIndex) { // Create result body. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); // Store generated shape. - aResultBody->storeGenerated(theBaseShape, thePipeAlgo.shape()); + aResultBody->storeGenerated(theBaseShape, thePipeAlgo->shape()); // Store generated edges/faces. GeomAPI_Shape::ShapeType aBaseShapeType = theBaseShape->shapeType(); GeomAPI_Shape::ShapeType aShapeTypeToExplode; - int aGenTag = 1; - std::string aGenName = "Generated_"; - std::shared_ptr aMapOfSubShapes = thePipeAlgo.mapOfSubShapes(); switch(aBaseShapeType) { case GeomAPI_Shape::VERTEX: { aShapeTypeToExplode = GeomAPI_Shape::VERTEX; @@ -312,13 +291,13 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa std::shared_ptr aV1, aV2; GeomAlgoAPI_ShapeTools::findBounds(theBaseShape, aV1, aV2); ListOfShape aV1History, aV2History; - thePipeAlgo.generated(aV1, aV1History); - thePipeAlgo.generated(aV2, aV2History); + thePipeAlgo->generated(aV1, aV1History); + thePipeAlgo->generated(aV2, aV2History); if(!aV1History.empty()) { - aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++); + aResultBody->generated(aV1, aV1History.front()); } if(!aV2History.empty()) { - aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++); + aResultBody->generated(aV2, aV2History.front()); } } case GeomAPI_Shape::FACE: @@ -333,52 +312,44 @@ void FeaturesPlugin_Pipe::storeResult(const std::shared_ptr theBa if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX || aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { - aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, theBaseShape, GeomAPI_Shape::VERTEX, - aGenTag++, aGenName + "Edge", *aMapOfSubShapes.get()); + aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::VERTEX); } if(aShapeTypeToExplode == GeomAPI_Shape::EDGE || aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) { - aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE, - aGenTag++, aGenName + "Face", *aMapOfSubShapes.get()); + aResultBody->loadGeneratedShapes(thePipeAlgo, theBaseShape, GeomAPI_Shape::EDGE); } // Store from shapes. - int aFromTag = aGenTag; - storeShapes(aResultBody, aBaseShapeType, aMapOfSubShapes, - thePipeAlgo.fromShapes(), "From_", aFromTag); + storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->fromShapes(), "From_"); // Store to shapes. - int aToTag = aFromTag; - storeShapes(aResultBody, aBaseShapeType, aMapOfSubShapes, thePipeAlgo.toShapes(), "To_", aToTag); + storeShapes(aResultBody, aBaseShapeType, thePipeAlgo->toShapes(), "To_"); setResult(aResultBody, theResultIndex); } //================================================================================================== void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, - GeomAlgoAPI_Pipe& thePipeAlgo, + const std::shared_ptr thePipeAlgo, const int theResultIndex) { // Create result body. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); // Store generated shape. - aResultBody->storeGenerated(theBaseShapes.front(), thePipeAlgo.shape()); + aResultBody->storeGenerated(theBaseShapes.front(), thePipeAlgo->shape()); // Store generated edges/faces. - int aGenTag = 1; - std::shared_ptr aMapOfSubShapes = thePipeAlgo.mapOfSubShapes(); - - for(ListOfShape::const_iterator - anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) { + for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin(); + anIter != theBaseShapes.cend(); + ++anIter) + { GeomShapePtr aBaseShape = *anIter; GeomAPI_Shape::ShapeType aBaseShapeType = aBaseShape->shapeType(); GeomAPI_Shape::ShapeType aShapeTypeToExplode; - std::string aGenName = "Generated_"; switch(aBaseShapeType) { case GeomAPI_Shape::VERTEX: { aShapeTypeToExplode = GeomAPI_Shape::VERTEX; - aGenName += "Edge"; break; } case GeomAPI_Shape::EDGE: @@ -386,31 +357,25 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, std::shared_ptr aV1, aV2; GeomAlgoAPI_ShapeTools::findBounds(aBaseShape, aV1, aV2); ListOfShape aV1History, aV2History; - thePipeAlgo.generated(aV1, aV1History); - thePipeAlgo.generated(aV2, aV2History); - aResultBody->generated(aV1, aV1History.front(), aGenName + "Edge_1", aGenTag++); - aResultBody->generated(aV2, aV2History.front(), aGenName + "Edge_2", aGenTag++); + thePipeAlgo->generated(aV1, aV1History); + thePipeAlgo->generated(aV2, aV2History); + aResultBody->generated(aV1, aV1History.front()); + aResultBody->generated(aV2, aV2History.front()); } case GeomAPI_Shape::FACE: case GeomAPI_Shape::SHELL: { aShapeTypeToExplode = GeomAPI_Shape::EDGE; - aGenName += "Face"; break; } } - aResultBody->loadAndOrientGeneratedShapes(&thePipeAlgo, aBaseShape, aShapeTypeToExplode, - aGenTag++, aGenName, *aMapOfSubShapes.get()); + aResultBody->loadGeneratedShapes(thePipeAlgo, aBaseShape, aShapeTypeToExplode); } // Store from shapes. - int aFromTag = aGenTag; - storeShapes(aResultBody, theBaseShapes.front()->shapeType(), aMapOfSubShapes, - thePipeAlgo.fromShapes(), "From", aFromTag); + storeShapes(aResultBody, theBaseShapes.front()->shapeType(), thePipeAlgo->fromShapes(), "From_"); // Store to shapes. - int aToTag = aFromTag; - storeShapes(aResultBody, theBaseShapes.back()->shapeType(), - aMapOfSubShapes, thePipeAlgo.toShapes(), "To", aToTag); + storeShapes(aResultBody, theBaseShapes.back()->shapeType(), thePipeAlgo->toShapes(), "To_"); setResult(aResultBody, theResultIndex); @@ -418,11 +383,9 @@ void FeaturesPlugin_Pipe::storeResult(const ListOfShape& theBaseShapes, //================================================================================================== void FeaturesPlugin_Pipe::storeShapes(ResultBodyPtr theResultBody, - const GeomAPI_Shape::ShapeType theBaseShapeType, - const std::shared_ptr theMapOfSubShapes, - const ListOfShape& theShapes, - const std::string theName, - int& theTag) + const GeomAPI_Shape::ShapeType theBaseShapeType, + const ListOfShape& theShapes, + const std::string theName) { GeomAPI_Shape::ShapeType aShapeTypeToExplore = GeomAPI_Shape::FACE; std::string aShapeTypeStr = "Face"; @@ -458,17 +421,13 @@ void FeaturesPlugin_Pipe::storeShapes(ResultBodyPtr theResultBody, if(aShapeTypeToExplore == GeomAPI_Shape::COMPOUND) { std::string aName = theName + (aShape->shapeType() == GeomAPI_Shape::EDGE ? "Edge" : "Face"); - storeSubShape(theResultBody, - aShape, + storeSubShape(theResultBody, aShape, aShape->shapeType(), - theMapOfSubShapes, aName, - aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex, - theTag); + aShape->shapeType() == GeomAPI_Shape::EDGE ? aShapeIndex : aFaceIndex); } else { std::string aName = theName + aShapeTypeStr; - storeSubShape(theResultBody, aShape, aShapeTypeToExplore, - theMapOfSubShapes, aName, aShapeIndex, theTag); + storeSubShape(theResultBody, aShape, aShapeTypeToExplore, aName, aShapeIndex); } } } @@ -477,18 +436,13 @@ void FeaturesPlugin_Pipe::storeShapes(ResultBodyPtr theResultBody, void storeSubShape(ResultBodyPtr theResultBody, const GeomShapePtr theShape, const GeomAPI_Shape::ShapeType theType, - const std::shared_ptr theMapOfSubShapes, const std::string theName, - int& theShapeIndex, - int& theTag) + int& theShapeIndex) { for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) { GeomShapePtr aSubShape = anExp.current(); - if(theMapOfSubShapes->isBound(aSubShape)) { - aSubShape = theMapOfSubShapes->find(aSubShape); - } std::ostringstream aStr; aStr << theName << "_" << theShapeIndex++; - theResultBody->generated(aSubShape, aStr.str(), theTag++); + theResultBody->generated(aSubShape, aStr.str()); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h index 074c8b088..2699ef56f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.h @@ -121,19 +121,17 @@ public: private: void storeResult(const std::shared_ptr theBaseShape, - GeomAlgoAPI_Pipe& thePipeAlgo, + const std::shared_ptr thePipeAlgo, const int theResultIndex = 0); void storeResult(const ListOfShape& theBaseShapes, - GeomAlgoAPI_Pipe& thePipeAlgo, + const std::shared_ptr thePipeAlgo, const int theResultIndex = 0); void storeShapes(ResultBodyPtr theResultBody, const GeomAPI_Shape::ShapeType theBaseShapeType, - const std::shared_ptr theMapOfSubShapes, const ListOfShape& theShapes, - const std::string theName, - int& theTag); + const std::string theName); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index ab932f01d..b4ae07c3d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -31,8 +31,10 @@ #include #include #include +#include #include #include +#include #include @@ -67,7 +69,6 @@ void FeaturesPlugin_Placement::execute() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -121,21 +122,8 @@ void FeaturesPlugin_Placement::execute() // Verify planarity of faces and linearity of edges std::shared_ptr aShapes[2] = {aStartShape, anEndShape}; for (int i = 0; i < 2; i++) { - if (aShapes[i]->isFace()) { - std::shared_ptr aFace(new GeomAPI_Face(aShapes[i])); - if (!aFace->isPlanar()) { - static const std::string aPlanarityError = "Error: One of selected faces is not planar."; - setError(aPlanarityError); - return; - } - } - else if (aShapes[i]->isEdge()) { - std::shared_ptr anEdge(new GeomAPI_Edge(aShapes[i])); - if (!anEdge->isLine()) { - static const std::string aLinearityError = "Error: One of selected endges is not linear."; - setError(aLinearityError); - return; - } + if (!isShapeValid(aShapes[i])) { + return; } } @@ -155,6 +143,7 @@ void FeaturesPlugin_Placement::execute() // Applying transformation to each object. int aResultIndex = 0; + std::string anError; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { @@ -167,29 +156,19 @@ void FeaturesPlugin_Placement::execute() setResult(aResultPart, aResultIndex); } else { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Transform aTransformAlgo(aBaseShape, aTrsf); + std::shared_ptr aTransformAlgo(new GeomAlgoAPI_Transform(aBaseShape, + aTrsf)); // Checking that the algorithm worked properly. - if(!aTransformAlgo.isDone()) { - static const std::string aFeatureError = "Error: Transform algorithm failed."; - setError(aFeatureError); - break; - } - if(aTransformAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aTransformAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTransformAlgo, getKind(), anError)) { + setError(anError); break; } //LoadNamingDS - std::shared_ptr aResultBody = - document()->createBody(data(), aResultIndex); - loadNamingDS(aTransformAlgo, aResultBody, aBaseShape); + ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); + aResultBody->storeModified(aBaseShape, aTransformAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aTransformAlgo, "Placed"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -199,18 +178,44 @@ void FeaturesPlugin_Placement::execute() removeResults(aResultIndex); } -//============================================================================ -void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) +//================================================================================================== +bool FeaturesPlugin_Placement::isShapeValid(GeomShapePtr theShape) { - //load result - theResultBody->storeModified(theBaseShape, theTransformAlgo.shape()); + if (theShape->isCompound()) { + GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE; + for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) { + GeomShapePtr aCurrentShape = anIt.current(); + if (aShapeType == GeomAPI_Shape::SHAPE) { + aShapeType = aCurrentShape->shapeType(); + } + else if (aShapeType != aCurrentShape->shapeType()) { + static const std::string aLinearityError = + "Error: Selected compound contains shapes with different types."; + setError(aLinearityError); + return false; + } - std::string aPlacedName = "Placed"; - std::shared_ptr aSubShapes = theTransformAlgo.mapOfSubShapes(); + if (!isShapeValid(aCurrentShape)) { + return false; + } + } + } + else if (theShape->isFace()) { + std::shared_ptr aFace(new GeomAPI_Face(theShape)); + if (!aFace->isPlanar()) { + static const std::string aPlanarityError = "Error: One of selected faces is not planar."; + setError(aPlanarityError); + return false; + } + } + else if (theShape->isEdge()) { + std::shared_ptr anEdge(new GeomAPI_Edge(theShape)); + if (!anEdge->isLine()) { + static const std::string aLinearityError = "Error: One of selected edges is not linear."; + setError(aLinearityError); + return false; + } + } - FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, - theBaseShape, 1, 2, 3, aPlacedName, - *aSubShapes.get()); + return true; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.h b/src/FeaturesPlugin/FeaturesPlugin_Placement.h index 1b8a7b6bd..4b8e94c64 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.h @@ -96,10 +96,8 @@ class FeaturesPlugin_Placement : public ModelAPI_Feature /// Use plugin manager for features creation FeaturesPlugin_Placement(); private: - /// Load Naming data structure of the feature to the document - void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); + /// Checks validity of passed shape. + bool isShapeValid(GeomShapePtr theShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp index cf16130b9..0bf95c301 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Recover.cpp @@ -31,6 +31,7 @@ #include #include #include +#include FeaturesPlugin_Recover::FeaturesPlugin_Recover() { @@ -45,6 +46,7 @@ void FeaturesPlugin_Recover::initAttributes() void FeaturesPlugin_Recover::execute() { + std::string anError; int aResultIndex = 0; AttributeRefListPtr aRecovered = reflist(RECOVERED_ENTITIES()); for(int anIndex = aRecovered->size() - 1; anIndex >= 0; anIndex--) { @@ -59,31 +61,20 @@ void FeaturesPlugin_Recover::execute() continue; // Copy shape. - GeomAlgoAPI_Copy aCopyAlgo(aShape); + std::shared_ptr aCopyAlgo(new GeomAlgoAPI_Copy(aShape)); // Check that algo is done. - if(!aCopyAlgo.isDone()) { - setError("Error: recover algorithm failed."); - return; - } - // Check if shape is not null. - if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) { - setError("Error: resulting shape is null."); - return; - } - // Check that resulting shape is valid. - if(!aCopyAlgo.isValid()) { - setError("Error: resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aCopyAlgo, getKind(), anError)) { + setError(anError); return; } // Store result. ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - aResultBody->store(aCopyAlgo.shape());//, aCopyAlgo.shape()); - std::shared_ptr aSubShapes = aCopyAlgo.mapOfSubShapes(); - // like in import: forget any history - int aTag(1); - std::string aNameMS = "Shape"; - aResultBody->loadFirstLevel(aCopyAlgo.shape(), aNameMS, aTag); + aResultBody->store(aCopyAlgo->shape());//, aCopyAlgo.shape()); + + aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::VERTEX); + aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aCopyAlgo, aShape, GeomAPI_Shape::FACE); setResult(aResultBody, aResultIndex); ++aResultIndex; diff --git a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp index e4d61f163..d2bd7e5de 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp @@ -232,7 +232,7 @@ void FeaturesPlugin_RemoveSubShapes::execute() aResultShape = anAttrSelectionInList->value(); } // deleted and copied must be jointed to one list which keeps all the history - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); // find all removed shapes std::shared_ptr aDeletedSubs(new GeomAlgoAPI_MakeShapeCustom); @@ -263,11 +263,11 @@ void FeaturesPlugin_RemoveSubShapes::execute() } } } - aMakeShapeList.appendAlgo(aDeletedSubs); + aMakeShapeList->appendAlgo(aDeletedSubs); std::shared_ptr aCopy(new GeomAlgoAPI_Copy(aResultShape)); aResultShape = aCopy->shape(); - aMakeShapeList.appendAlgo(aCopy); + aMakeShapeList->appendAlgo(aCopy); if (aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { aResultShape = GeomAlgoAPI_ShapeTools::groupSharedTopology(aResultShape); @@ -283,15 +283,22 @@ void FeaturesPlugin_RemoveSubShapes::execute() // Store result. ResultBodyPtr aResultBody = document()->createBody(data()); - aResultBody->storeModified(aBaseShape, aResultShape, 1); - std::set::iterator aTypeIter = aTypes.begin(); - for(; aTypeIter != aTypes.end(); aTypeIter++) - aResultBody->loadDeletedShapes(&aMakeShapeList, aBaseShape, *aTypeIter, 1); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::FACE, - 2, "Modified_Face", *aMakeShapeList.mapOfSubShapes().get(), true, false, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::EDGE, - 3, "Modified_Edge", *aMakeShapeList.mapOfSubShapes().get(), false, false, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, aBaseShape, GeomAPI_Shape::VERTEX, - 4, "Modified_Vertex", *aMakeShapeList.mapOfSubShapes().get()); + aResultBody->storeModified(aBaseShape, aResultShape); + for (std::set::iterator aTypeIter = aTypes.begin(); + aTypeIter != aTypes.end(); + ++aTypeIter) + { + aResultBody->loadDeletedShapes(aMakeShapeList, aBaseShape, *aTypeIter); + } + + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::FACE); + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aMakeShapeList, + aBaseShape, + GeomAPI_Shape::VERTEX); setResult(aResultBody); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp index 4a6433180..bbd7b41f3 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp @@ -27,9 +27,11 @@ #include #include +#include #include #include +#include //================================================================================================= FeaturesPlugin_Revolution::FeaturesPlugin_Revolution() @@ -92,17 +94,37 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes, // Getting base shapes. getBaseShapes(theBaseShapes); - //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; + // Getting axis. + static const std::string aSelectionError = "Error: The axis shape selection is bad."; AttributeSelectionPtr aSelection = selection(AXIS_OBJECT_ID()); - if(aSelection.get() && aSelection->value().get() && aSelection->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->value())); - } else if(aSelection->context().get() && - aSelection->context()->shape().get() && - aSelection->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(aSelection->context()->shape())); + GeomShapePtr aShape = aSelection->value(); + if (!aShape.get()) { + if (aSelection->context().get()) { + aShape = aSelection->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return false; + } + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } + else + { + setError(aSelectionError); + return false; + } + + std::shared_ptr anAxis; if(anEdge.get()) { if(anEdge->isLine()) { anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), @@ -137,6 +159,10 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes, if(!aToShape.get() && aSelection->context().get()) { aToShape = aSelection->context()->shape(); } + if (aToShape.get() && aToShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aToShape); + aToShape = anIt.current(); + } } aSelection = selection(FROM_OBJECT_ID()); if(aSelection.get()) { @@ -144,10 +170,15 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes, if(!aFromShape.get() && aSelection->context().get()) { aFromShape = aSelection->context()->shape(); } + if (aFromShape.get() && aFromShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFromShape); + aFromShape = anIt.current(); + } } } // Generating result for each base shape. + std::string anError; for(ListOfShape::const_iterator anIter = theBaseShapes.cbegin(); anIter != theBaseShapes.cend(); anIter++) { GeomShapePtr aBaseShape = *anIter; @@ -156,7 +187,8 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes, aBaseShape, anAxis, aToShape, aToAngle, aFromShape, aFromAngle)); - if(!isMakeShapeValid(aRevolAlgo)) { + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRevolAlgo, getKind(), anError)) { + setError(anError); return false; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp index 50c03fa4e..107fecc8e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.cpp @@ -38,9 +38,7 @@ bool FeaturesPlugin_RevolutionBoolean::makeGeneration(ListOfShape& theBaseShapes //================================================================================================= void FeaturesPlugin_RevolutionBoolean::storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag) + const std::shared_ptr theMakeShape) { - FeaturesPlugin_Revolution::storeGenerationHistory(theResultBody, theBaseShape, - theMakeShape, theTag); + FeaturesPlugin_Revolution::storeGenerationHistory(theResultBody, theBaseShape, theMakeShape); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h index 8aceb322b..a89288faa 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h +++ b/src/FeaturesPlugin/FeaturesPlugin_RevolutionBoolean.h @@ -44,8 +44,7 @@ protected: /// Stores generation history. void storeGenerationHistory(ResultBodyPtr theResultBody, const GeomShapePtr theBaseShape, - const std::shared_ptr theMakeShape, - int& theTag); + const std::shared_ptr theMakeShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 07d2d575c..01547d62f 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -27,9 +27,11 @@ #include #include +#include #include #include +#include #include #include @@ -99,25 +101,44 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() } //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + + if (!anEdge.get()) + { + setError(aSelectionError); + return; } + std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + // Getting angle. double anAngle = real(FeaturesPlugin_Rotation::ANGLE_ID())->value(); // Rotating each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -134,34 +155,26 @@ void FeaturesPlugin_Rotation::performTranslationByAxisAndAngle() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, anAxis, anAngle); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + anAxis, + anAngle)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Rotation algorithm failed."; - setError(aFeatureError); - break; - } - if(aRotationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aRotationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aRotationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -203,16 +216,17 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints() selection(FeaturesPlugin_Rotation::START_POINT_ID()); std::shared_ptr anEndPointRef = selection(FeaturesPlugin_Rotation::END_POINT_ID()); - if ((aCenterRef.get() != NULL) && (aStartPointRef.get() != NULL) - && (anEndPointRef.get() != NULL)) { + if ((aCenterRef.get() != NULL) && + (aStartPointRef.get() != NULL) && + (anEndPointRef.get() != NULL)) { GeomShapePtr aCenterShape = aCenterRef->value(); - if (!aCenterShape.get()) + if (!aCenterShape.get() && aCenterRef->context().get()) aCenterShape = aCenterRef->context()->shape(); GeomShapePtr aStartShape = aStartPointRef->value(); - if (!aStartShape.get()) + if (!aStartShape.get() && aStartPointRef->context().get()) aStartShape = aStartPointRef->context()->shape(); - GeomShapePtr anEndShape = anEndPointRef->value(); - if (!anEndShape.get()) + GeomShapePtr anEndShape = anEndPointRef->value(); + if (!anEndShape.get() && anEndPointRef->context().get()) anEndShape = anEndPointRef->context()->shape(); if (aStartShape && anEndShape && aCenterShape) { aCenterPoint = GeomAlgoAPI_PointBuilder::point(aCenterShape); @@ -222,6 +236,7 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints() } // Rotating each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -238,52 +253,29 @@ void FeaturesPlugin_Rotation::performTranslationByThreePoints() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Rotation aRotationAlgo(aBaseShape, aCenterPoint, aStartPoint, anEndPoint); + std::shared_ptr aRotationAlgo(new GeomAlgoAPI_Rotation(aBaseShape, + aCenterPoint, + aStartPoint, + anEndPoint)); - if (!aRotationAlgo.check()) { - setError(aRotationAlgo.getError()); + if (!aRotationAlgo->check()) { + setError(aRotationAlgo->getError()); return; } - aRotationAlgo.build(); + aRotationAlgo->build(); // Checking that the algorithm worked properly. - if(!aRotationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Rotation algorithm failed."; - setError(aFeatureError); - break; - } - if(aRotationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error : Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aRotationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aRotationAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aRotationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aRotationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aRotationAlgo, "Rotated"); setResult(aResultBody, aResultIndex); } aResultIndex++; } } - -//================================================================================================= -void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store result. - theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - - std::string aRotatedName = "Rotated"; - std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, - theBaseShape, 1, 2, 3, aRotatedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h index ce064ca21..0c8a24aee 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.h @@ -125,10 +125,6 @@ private: ///Perform the rotation using a center and two points. void performTranslationByThreePoints(); - - void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp index 4e854c22a..a2c6105c8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -90,7 +91,6 @@ void FeaturesPlugin_Scale::performScaleByFactor() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -115,39 +115,31 @@ void FeaturesPlugin_Scale::performScaleByFactor() double aScaleFactor = real(FeaturesPlugin_Scale::SCALE_FACTOR_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, aScaleFactor); + std::shared_ptr aScaleAlgo( + new GeomAlgoAPI_Scale(aBaseShape, aCenterPoint, aScaleFactor)); - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aScaleAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aScaleAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aScaleAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -172,7 +164,6 @@ void FeaturesPlugin_Scale::performScaleByDimensions() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -199,40 +190,34 @@ void FeaturesPlugin_Scale::performScaleByDimensions() double aScaleFactorZ = real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); anObjectsIt++, aContext++) { std::shared_ptr aBaseShape = *anObjectsIt; - GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint, - aScaleFactorX, aScaleFactorY, aScaleFactorZ); - - if (!aScaleAlgo.check()) { - setError(aScaleAlgo.getError()); + std::shared_ptr aScaleAlgo(new GeomAlgoAPI_Scale(aBaseShape, + aCenterPoint, + aScaleFactorX, + aScaleFactorY, + aScaleFactorZ)); + + if (!aScaleAlgo->check()) { + setError(aScaleAlgo->getError()); return; } - aScaleAlgo.build(); + aScaleAlgo->build(); // Checking that the algorithm worked properly. - if(!aScaleAlgo.isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aScaleAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aScaleAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aScaleAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aScaleAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aScaleAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, aBaseShape, aScaleAlgo, "Scaled"); setResult(aResultBody, aResultIndex); aResultIndex++; } @@ -240,19 +225,3 @@ void FeaturesPlugin_Scale::performScaleByDimensions() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store and name the result. - theResultBody->storeModified(theBaseShape, theScaleAlgo.shape()); - - // Name the faces - std::shared_ptr aSubShapes = theScaleAlgo.mapOfSubShapes(); - std::string aScaledName = "Scaled"; - FeaturesPlugin_Tools::storeModifiedShapes(theScaleAlgo, theResultBody, - theBaseShape, 1, 2, 3, aScaledName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.h b/src/FeaturesPlugin/FeaturesPlugin_Scale.h index 519dec4e4..9700331f7 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.h @@ -126,11 +126,6 @@ private: /// Perform symmetry using a central point and three dimensions void performScaleByDimensions(); - - /// Perform the naming - void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif // FEATURESPLUGIN_SCALE_H_ \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp index d50b74aa2..333820a8d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.cpp @@ -25,11 +25,13 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -101,7 +103,6 @@ bool FeaturesPlugin_Symmetry::collectSourceObjects(ListOfShape& theSourceShapes, anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if (!anObject.get()) { // may be for not-activated parts - eraseResults(); return false; } theSourceShapes.push_back(anObject); @@ -134,6 +135,7 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint() } // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -160,19 +162,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByPoint() aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo->isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aSymmetryAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aSymmetryAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) { + setError(anError); break; } @@ -195,22 +186,42 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis() return; //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis (new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + + // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -237,19 +248,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByAxis() aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo->isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aSymmetryAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aSymmetryAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) { + setError(anError); break; } @@ -271,25 +271,43 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane() if (!collectSourceObjects(anObjects, aContextes)) return; - //Getting axis. - std::shared_ptr aPlane; - std::shared_ptr aPln; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID()); - if (anObjRef && anObjRef->value() && anObjRef->value()->isFace()) { - aPln = std::shared_ptr(new GeomAPI_Face(anObjRef->value()))->getPlane(); + //Getting plane. + static const std::string aSelectionError = "Error: The plane shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(PLANE_OBJECT_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; } - else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isFace()) { - aPln = - std::shared_ptr(new GeomAPI_Face(anObjRef->context()->shape()))->getPlane(); + + GeomFacePtr aFace; + if (aShape->isFace()) + { + aFace = aShape->face(); } - if (aPln) { - aPlane = std::shared_ptr(new GeomAPI_Ax2(aPln->location(), - aPln->direction())); + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + aFace = anIt.current()->face(); } + if (!aFace.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr aPlane(new GeomAPI_Ax2(aFace->getPlane()->location(), + aFace->getPlane()->direction())); + + // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -315,19 +333,8 @@ void FeaturesPlugin_Symmetry::performSymmetryByPlane() aSymmetryAlgo->build(); // Checking that the algorithm worked properly. - if(!aSymmetryAlgo->isDone()) { - static const std::string aFeatureError = "Error: Symmetry algorithm failed."; - setError(aFeatureError); - break; - } - if(aSymmetryAlgo->shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aSymmetryAlgo->isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSymmetryAlgo, getKind(), anError)) { + setError(anError); break; } @@ -345,8 +352,8 @@ void FeaturesPlugin_Symmetry::buildResult( std::shared_ptr& theSymmetryAlgo, std::shared_ptr theBaseShape, int theResultIndex) { - GeomAlgoAPI_MakeShapeList anAlgoList; - anAlgoList.appendAlgo(theSymmetryAlgo); + std::shared_ptr anAlgoList(new GeomAlgoAPI_MakeShapeList()); + anAlgoList->appendAlgo(theSymmetryAlgo); // Compose source shape and the result of symmetry. GeomShapePtr aCompound; if (boolean(KEEP_ORIGINAL_RESULT())->value()) { @@ -354,7 +361,7 @@ void FeaturesPlugin_Symmetry::buildResult( // add a copy of a base shape otherwise selection of this base shape is bad (2592) std::shared_ptr aCopyAlgo(new GeomAlgoAPI_Copy(theBaseShape)); aShapes.push_back(aCopyAlgo->shape()); - anAlgoList.appendAlgo(aCopyAlgo); + anAlgoList->appendAlgo(aCopyAlgo); aShapes.push_back(theSymmetryAlgo->shape()); aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); @@ -364,7 +371,7 @@ void FeaturesPlugin_Symmetry::buildResult( // Store and name the result. ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex); aResultBody->storeModified(theBaseShape, aCompound); - loadNamingDS(anAlgoList, aResultBody, theBaseShape); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theBaseShape, anAlgoList, "Symmetried"); setResult(aResultBody, theResultIndex); } @@ -385,16 +392,3 @@ void FeaturesPlugin_Symmetry::buildResult(ResultPartPtr theOriginal, aResultPart->setTrsf(theOriginal, theTrsf); setResult(aResultPart, theResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Symmetry::loadNamingDS(GeomAlgoAPI_MakeShapeList& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Name the faces - std::shared_ptr aSubShapes = theAlgo.mapOfSubShapes(); - std::string aReflectedName = "Symmetried"; - FeaturesPlugin_Tools::storeModifiedShapes(theAlgo, theResultBody, - theBaseShape, 1, 2, 3, aReflectedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h index a19d143cf..d03cc141b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Symmetry.h @@ -137,11 +137,6 @@ private: /// Perform symmetry with respect to a plane. void performSymmetryByPlane(); - /// Perform the naming - void loadNamingDS(GeomAlgoAPI_MakeShapeList& theSymmetryAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); - /// Create new result on given shapes and the index of result void buildResult(std::shared_ptr& theSymmetryAlgo, std::shared_ptr theBaseShape, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 07709d1ed..efdee5801 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -24,47 +24,114 @@ #include -void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape, - const int theFaceTag, - const int theEdgeTag, - const int theVertexTag, - const std::string theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShape) +{ + if (theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape, false); + return; + } + + theResultBody->storeModified(theBaseShape, theResultShape); + + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter) + { + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const GeomMakeShapePtr& theMakeShape, + const std::string theName) { switch(theBaseShape->shapeType()) { case GeomAPI_Shape::COMPOUND: { for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next()) { - storeModifiedShapes(theAlgo, - theResultBody, - anIt.current(), - theFaceTag, - theEdgeTag, - theVertexTag, - theName, - theSubShapes); + loadModifiedShapes(theResultBody, + anIt.current(), + theMakeShape, + theName); } break; } case GeomAPI_Shape::COMPSOLID: case GeomAPI_Shape::SOLID: case GeomAPI_Shape::SHELL: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::FACE, - theFaceTag, theName + "_Face", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::FACE, + theName); } case GeomAPI_Shape::FACE: case GeomAPI_Shape::WIRE: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - theEdgeTag, theName + "_Edge", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::EDGE, + theName); } case GeomAPI_Shape::EDGE: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - theVertexTag, theName + "_Vertex", theSubShapes, false, true); + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::VERTEX, + theName); } } } + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShapesCompound) +{ + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++) + { + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::VERTEX, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::EDGE, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::FACE, + theResultShapesCompound); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes( + std::vector& theResultBaseAlgoList, + const ListOfShape& theTools, + const GeomShapePtr theResultShapesCompound) +{ + for (std::vector::iterator anIt = theResultBaseAlgoList.begin(); + anIt != theResultBaseAlgoList.end(); + ++anIt) + { + ResultBaseAlgo& aRCA = *anIt; + loadDeletedShapes(aRCA.resultBody, + aRCA.baseShape, + theTools, + aRCA.makeShape, + theResultShapesCompound); + } +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h index 02a0b5e45..22b269b04 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.h @@ -21,20 +21,42 @@ #ifndef FeaturesPlugin_Tools_H_ #define FeaturesPlugin_Tools_H_ -#include +#include +#include -class ModelAPI_ResultBody; +#include class FeaturesPlugin_Tools { public: - static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape, - const int theFaceTag, - const int theEdgeTag, - const int theVertexTag, - const std::string theName, - GeomAPI_DataMapOfShapeShape& theSubShapes); + struct ResultBaseAlgo { + ResultBodyPtr resultBody; + GeomShapePtr baseShape; + GeomMakeShapePtr makeShape; + }; + +public: + static void loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShape); + + static void loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const GeomMakeShapePtr& theMakeShape, + const std::string theName); + + /// Stores deleted shapes. + static void loadDeletedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShapesCompound); + + /// Stores deleted shapes. + static void loadDeletedShapes(std::vector& theResultBaseAlgoList, + const ListOfShape& theTools, + const GeomShapePtr theResultShapesCompound); }; #endif /* FeaturesPlugin_Tools_H_ */ diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index 0da4b6acc..e303f2b12 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -30,9 +30,11 @@ #include #include +#include #include #include +#include #include @@ -104,7 +106,6 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -112,25 +113,45 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance() } //Getting axis. - std::shared_ptr anAxis; - std::shared_ptr anEdge; - std::shared_ptr anObjRef = - selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID()); - if(anObjRef && anObjRef->value() && anObjRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->value())); - } else if (anObjRef && !anObjRef->value() && anObjRef->context() && - anObjRef->context()->shape() && anObjRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anObjRef->context()->shape())); + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + AttributeSelectionPtr anObjRef = selection(AXIS_OBJECT_ID()); + GeomShapePtr aShape = anObjRef->value(); + if (!aShape.get()) { + if (anObjRef->context().get()) { + aShape = anObjRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax1(anEdge->line()->location(), - anEdge->line()->direction())); + + GeomEdgePtr anEdge; + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); + } + + if (!anEdge.get()) + { + setError(aSelectionError); + return; } + std::shared_ptr anAxis(new GeomAPI_Ax1(anEdge->line()->location(), + anEdge->line()->direction())); + + // Getting distance. double aDistance = real(FeaturesPlugin_Translation::DISTANCE_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -147,34 +168,28 @@ void FeaturesPlugin_Translation::performTranslationByAxisAndDistance() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, anAxis, aDistance); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, anAxis, aDistance)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Translation algorithm failed."; - setError(aFeatureError); - break; - } - if(aTranslationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aTranslationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -200,7 +215,6 @@ void FeaturesPlugin_Translation::performTranslationByDimensions() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -213,6 +227,7 @@ void FeaturesPlugin_Translation::performTranslationByDimensions() double aDZ = real(FeaturesPlugin_Translation::DZ_ID())->value(); // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -229,34 +244,28 @@ void FeaturesPlugin_Translation::performTranslationByDimensions() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aDX, aDY, aDZ); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, aDX, aDY, aDZ)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Translation algorithm failed."; - setError(aFeatureError); - break; - } - if(aTranslationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aTranslationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -282,7 +291,6 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() anObjectsSelList->value(anObjectsIndex); std::shared_ptr anObject = anObjectAttr->value(); if(!anObject.get()) { // may be for not-activated parts - eraseResults(); return; } anObjects.push_back(anObject); @@ -308,6 +316,7 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() } // Moving each object. + std::string anError; int aResultIndex = 0; std::list::iterator aContext = aContextes.begin(); for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); @@ -324,34 +333,28 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() aResultPart->setTrsf(*aContext, aTrsf); setResult(aResultPart, aResultIndex); } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint); + std::shared_ptr aTranslationAlgo( + new GeomAlgoAPI_Translation(aBaseShape, aFirstPoint, aSecondPoint)); - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); + if (!aTranslationAlgo->check()) { + setError(aTranslationAlgo->getError()); return; } - aTranslationAlgo.build(); + aTranslationAlgo->build(); // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Translation algorithm failed."; - setError(aFeatureError); - break; - } - if(aTranslationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aTranslationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aTranslationAlgo, getKind(), anError)) { + setError(anError); break; } ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); + aResultBody->storeModified(aBaseShape, aTranslationAlgo->shape()); + FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, + aBaseShape, + aTranslationAlgo, + "Translated"); setResult(aResultBody, aResultIndex); } aResultIndex++; @@ -360,19 +363,3 @@ void FeaturesPlugin_Translation::performTranslationByTwoPoints() // Remove the rest results if there were produced in the previous pass. removeResults(aResultIndex); } - -//================================================================================================= -void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape) -{ - // Store result. - theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape()); - - std::string aTranslatedName = "Translated"; - std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); - - FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, - theBaseShape, 1, 2, 3, aTranslatedName, - *aSubShapes.get()); -} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.h b/src/FeaturesPlugin/FeaturesPlugin_Translation.h index 191f208ab..624d8de39 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.h @@ -149,10 +149,6 @@ private: ///Perform the translation usind two points void performTranslationByTwoPoints(); - - void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape); }; #endif diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index 775da23a3..fe7122c4a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,7 @@ void FeaturesPlugin_Union::execute() } // Fuse objects. + std::string anError; std::shared_ptr anAlgo; ListOfShape aTools; if (anObjects.front()->shapeType() == GeomAPI_Shape::SOLID) { @@ -121,23 +123,15 @@ void FeaturesPlugin_Union::execute() } // Checking that the algorithm worked properly. - GeomAlgoAPI_MakeShapeList aMakeShapeList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); GeomAPI_DataMapOfShapeShape aMapOfShapes; - if(!anAlgo->isDone()) { - setError("Error: Boolean algorithm failed."); - return; - } - if(anAlgo->shape()->isNull()) { - setError("Error: Resulting shape is Null."); - return; - } - if(!anAlgo->isValid()) { - setError("Error: Resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(anAlgo, getKind(), anError)) { + setError(anError); return; } GeomShapePtr aShape = anAlgo->shape(); - aMakeShapeList.appendAlgo(anAlgo); + aMakeShapeList->appendAlgo(anAlgo); aMapOfShapes.merge(anAlgo->mapOfSubShapes()); // Store original shapes for naming. @@ -149,44 +143,25 @@ void FeaturesPlugin_Union::execute() aShapesToAdd.push_back(aShape); std::shared_ptr aFillerAlgo( new GeomAlgoAPI_PaveFiller(aShapesToAdd, true)); - if(!aFillerAlgo->isDone()) { - setError("Error: PaveFiller algorithm failed."); - return; - } - if(aFillerAlgo->shape()->isNull()) { - setError("Error: Resulting shape is Null."); - return; - } - if(!aFillerAlgo->isValid()) { - setError("Error: Resulting shape is not valid."); + if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFillerAlgo, getKind(), anError)) { + setError(anError); return; } aShape = aFillerAlgo->shape(); - aMakeShapeList.appendAlgo(aFillerAlgo); + aMakeShapeList->appendAlgo(aFillerAlgo); aMapOfShapes.merge(aFillerAlgo->mapOfSubShapes()); } // workaround: make copy to name edges correctly // Store result and naming. - const int aModifyEdgeTag = 1; - const int aModifyFaceTag = 2; - const int aDeletedTag = 3; - /// sub solids will be placed at labels 4, 5 etc. if result is compound of solids - const int aSubsolidsTag = 4; - const std::string aModEName = "Modified_Edge"; - const std::string aModFName = "Modified_Face"; std::shared_ptr aResultBody = document()->createBody(data()); - aResultBody->storeModified(anObjects.front(), aShape, aSubsolidsTag); + aResultBody->storeModified(anObjects.front(), aShape); for(ListOfShape::const_iterator anIter = anObjects.begin(); anIter != anObjects.end(); ++anIter) { - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::EDGE, - aModifyEdgeTag, aModEName, aMapOfShapes, - false, true, true); - aResultBody->loadAndOrientModifiedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, - aModifyFaceTag, aModFName, aMapOfShapes, - false, true, true); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE); + aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE); //aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index aa78551d6..4f9b5f1f1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -411,7 +411,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute if (aContext.get()) aConstruction = std::dynamic_pointer_cast(aContext); if(aConstruction.get()) { - // Construciotn selected. Check that is is not infinite. + // Construction selected. Check that it is not infinite. if(aConstruction->isInfinite()) { theError = "Error: Infinite constructions is not allowed as base."; return false; @@ -430,7 +430,6 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute return true; } } - return false; } @@ -547,10 +546,16 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid( if(aContext.get()) { aDirShape = aContext->shape(); } + + if (aDirShape.get() && aDirShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aDirShape); + aDirShape = anIt.current(); + } } } - if(!aDirShape.get()) { + if(!aDirShape.get() || aDirShape->isNull() || + aDirShape->shapeType() != GeomAPI_Shape::EDGE) { // Check that dir can be empty. if(!isShapesCanBeEmpty(aCheckAttribute, theError)) { theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" " @@ -1163,75 +1168,44 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( return false; } - int anObjectsNb = 0, aToolsNb = 0; - //int anOperationType = 0; + int anObjectsToolsNb[2] = { 0, 0 }; std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); bool isAllInSameCompSolid = true; ResultBodyPtr aCompSolid; - AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); - if (anAttrSelList) - { - anObjectsNb = anAttrSelList->size(); - for (int anIndex = 0; anIndex < anObjectsNb; ++anIndex) - { - AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); - ResultPtr aContext = anAttr->context(); - ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if (aResCompSolidPtr.get()) - { - if (aCompSolid.get()) - { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; - } - else - { - aCompSolid = aResCompSolidPtr; - } - } - else - { - isAllInSameCompSolid = false; - break; - } - } - } - anIt++; - - - anAttrSelList = theFeature->selectionList(*anIt); - if (anAttrSelList) - { - aToolsNb = anAttrSelList->size(); - if (isAllInSameCompSolid) + for (int* anArgNbIt = anObjectsToolsNb; anIt != aLast; ++anIt, ++anArgNbIt) { + AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); + if (anAttrSelList) { - for (int anIndex = 0; anIndex < aToolsNb; ++anIndex) - { - AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); - ResultPtr aContext = anAttr->context(); - ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if (aResCompSolidPtr.get()) + *anArgNbIt = anAttrSelList->size(); + if (isAllInSameCompSolid) { + for (int anIndex = 0; anIndex < *anArgNbIt; ++anIndex) { - if (aCompSolid.get()) + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); + if (aResCompSolidPtr.get()) { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + if (aCompSolid.get()) + { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } + else + { + aCompSolid = aResCompSolidPtr; + } } else { - aCompSolid = aResCompSolidPtr; + isAllInSameCompSolid = false; + break; } } - else - { - isAllInSameCompSolid = false; - break; - } } } } - anIt++; std::shared_ptr aFeature = std::dynamic_pointer_cast(theFeature); @@ -1240,7 +1214,7 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( if (anOperationType == FeaturesPlugin_Boolean::BOOL_FUSE) { // Fuse operation - if (anObjectsNb + aToolsNb < 2) + if (anObjectsToolsNb[0] + anObjectsToolsNb[1] < 2) { theError = "Not enough arguments for Fuse operation."; return false; @@ -1253,12 +1227,12 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( } else { - if (anObjectsNb < 1) + if (anObjectsToolsNb[0] < 1) // check number of objects { theError = "Objects not selected."; return false; } - if (aToolsNb < 1) + if (anObjectsToolsNb[1] < 1) // check number of tools { theError = "Tools not selected."; return false; diff --git a/src/FeaturesPlugin/Test/Test1379.py b/src/FeaturesPlugin/Test/Test1379.py index a9d0762a9..9fdb8f1be 100644 --- a/src/FeaturesPlugin/Test/Test1379.py +++ b/src/FeaturesPlugin/Test/Test1379.py @@ -19,7 +19,6 @@ ## # -*- coding: utf-8 -*- -from SketchAPI import * from salome.shaper import model @@ -30,7 +29,7 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "OZ"), False SketchLine_1 = SketchProjection_1.createdFeature() SketchLine_1.setName("SketchLine_5") SketchLine_1.result().setName("SketchLine_5") -SketchLine_2 = Sketch_1.addLine(0.008, 0.0005000000000000006, 0.0075, -1.258295422426014e-035) +SketchLine_2 = Sketch_1.addLine(0.008, 0.0005000000000000006, 0.0075, -1.258295422426014e-35) SketchLine_2.setName("SketchLine_9") SketchLine_2.result().setName("SketchLine_9") SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "OX"), False) @@ -39,7 +38,7 @@ SketchLine_3.setName("SketchLine_10") SketchLine_3.result().setName("SketchLine_10") SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.result()) SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_12") -SketchLine_4 = Sketch_1.addLine(0.0075, -1.258295422426014e-035, 0.005, 0) +SketchLine_4 = Sketch_1.addLine(0.0075, -1.258295422426014e-35, 0.005, 0) SketchLine_4.setName("SketchLine_11") SketchLine_4.result().setName("SketchLine_11") SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_4.startPoint()) @@ -60,7 +59,7 @@ SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result()) SketchConstraintVertical_1.setName("SketchConstraintVertical_3") SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_6.result()) SketchConstraintHorizontal_1.setName("SketchConstraintHorizontal_3") -SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_3.result(), SketchLine_2.result(), 45) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_3.result(), SketchLine_2.result(), 45.00000000000001) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_5.result(), 0.02) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), 0.005) SketchConstraintLength_2.setName("SketchConstraintLength_4") @@ -95,14 +94,14 @@ SketchLine_11.setName("SketchLine_16") SketchLine_11.result().setName("SketchLine_16") SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_17") -SketchLine_12 = Sketch_1.addLine(0.008999999999999999, 0.042, -5.446629538236431e-036, 0.042) +SketchLine_12 = Sketch_1.addLine(0.008999999999999999, 0.042, -5.446629538236431e-36, 0.042) SketchLine_12.setName("SketchLine_17") SketchLine_12.result().setName("SketchLine_17") SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_18") SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_1.result()) SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_19") -SketchLine_13 = Sketch_1.addLine(-5.446629538236431e-036, 0.042, 0, 0.02) +SketchLine_13 = Sketch_1.addLine(-5.446629538236431e-36, 0.042, 0, 0.02) SketchLine_13.setName("SketchLine_18") SketchLine_13.result().setName("SketchLine_18") SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) @@ -141,16 +140,16 @@ SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_22") model.do() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_9r-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_7f-SketchLine_8f-SketchArc_1_2r-SketchLine_14f-SketchArc_2_2r-SketchLine_15f-SketchLine_16f-SketchLine_17f-SketchLine_18f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_7f-SketchLine_8f-SketchArc_1_2r-SketchLine_14f-SketchArc_2_2r-SketchLine_15f-SketchLine_16f-SketchLine_17f-SketchLine_18f-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_9r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) -SketchLine_14 = Sketch_2.addLine(-5.446629538236431e-036, 0.042, 5.172728347136208e-022, 0.03963932022500211) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Sketch_1/Vertex-SketchLine_18s-SketchLine_17e"), False) +SketchLine_14 = Sketch_2.addLine(-5.446629538236431e-36, 0.042, 5.172728347136208e-22, 0.03963932022500211) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Sketch_1/SketchLine_17_EndVertex"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchPoint_1.result()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_18"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/Sketch_1/SketchLine_18"), False) SketchLine_15 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.result()) -SketchArc_3 = Sketch_2.addArc(0.02, 0.062, 5.172728347136208e-022, 0.03963932022500211, 0.02, 0.032, False) +SketchArc_3 = Sketch_2.addArc(0.02, 0.062, 5.172728347136208e-22, 0.03963932022500211, 0.02, 0.032, False) SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchArc_3.startPoint()) SketchLine_16 = Sketch_2.addLine(0.02, 0.032, 0.02, 0.042) SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchArc_3.endPoint(), SketchLine_16.startPoint()) @@ -166,9 +165,9 @@ SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX" SketchLine_18 = SketchProjection_5.createdFeature() SketchConstraintDistance_7 = Sketch_2.setDistance(SketchLine_18.result(), SketchArc_3.center(), 0.062, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchArc_1_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 0.008999999999999999, 0.008999999999999999) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 0.008999999999999999, 0.008999999999999999) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) -Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_13")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_7")) RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 10, 28, [model.selection("SOLID", "Fuse_1_1")]) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_19 = Sketch_3.addLine(0.029, 0.042, 0.029, 0.03267384683690003) @@ -183,7 +182,7 @@ SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_19.result()) SketchLine_21 = Sketch_3.addLine(0.008999999999999999, 0.042, 0.029, 0.042) SketchLine_21.setName("SketchLine_9") SketchLine_21.result().setName("SketchLine_9") -SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_22 = SketchProjection_6.createdFeature() SketchLine_22.setName("SketchLine_10") SketchLine_22.result().setName("SketchLine_10") @@ -195,9 +194,11 @@ SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_21.startPoint SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_11") SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_21.result()) SketchConstraintAngle_2 = Sketch_3.setAngle(SketchLine_20.result(), SketchLine_21.result(), 25) -SketchProjection_7 = Sketch_3.addProjection(model.selection("VERTEX", "PartSet/Sketch_1/Vertex-SketchLine_17s-SketchLine_16e"), False) +SketchProjection_7 = Sketch_3.addProjection(model.selection("VERTEX", "PartSet/Sketch_1/SketchLine_16_EndVertex"), False) +SketchPoint_2 = SketchProjection_7.createdFeature() SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_21.result(), 0.02) RevolutionCut_1.setNestedSketch(Sketch_3) +model.do() model.end() # check that result was created diff --git a/src/FeaturesPlugin/Test/Test1467.py b/src/FeaturesPlugin/Test/Test1467.py index 9347af3ff..70dac9592 100644 --- a/src/FeaturesPlugin/Test/Test1467.py +++ b/src/FeaturesPlugin/Test/Test1467.py @@ -18,15 +18,14 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model -# Create document model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() - -# Create base and path for pipe Point_2 = model.addPoint(Part_1_doc, 5, 20, 0) Point_3 = model.addPoint(Part_1_doc, 0, 40, 30) Point_4 = model.addPoint(Part_1_doc, 10, 50, 70) @@ -59,7 +58,7 @@ SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_2.results()[1], Sketch SketchConstraintRigid_1 = Sketch_1.setFixed(SketchArc_1.startPoint()) SketchConstraintRigid_2 = Sketch_1.setFixed(SketchLine_2.endPoint()) model.do() -Wire_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2")] +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_2_2"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchArc_1_2")] Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_4 = Sketch_2.addLine(9.525599451781, 2.539525405208, -21.231656152164, 2.539525405208) @@ -87,18 +86,11 @@ SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_5.result()) SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_6.result()) SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_7.result()) model.do() - -# Create pipe on the entire path (big pipe) Pipe_1 = model.addPipe(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("WIRE", "Wire_1_1")) - -# Create pipe on the fisrt segment of the path (small pipe) -Pipe_2 = model.addPipe(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2")) - -# Cut big pipe from the small pipe +Pipe_2 = model.addPipe(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_1/SketchArc_2_2")) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Pipe_2_1")], [model.selection("SOLID", "Pipe_1_1")]) model.do() +model.end() # Check that the small pipe is a part of the big one assert(len(Cut_1.results()) == 0) - -model.end() diff --git a/src/FeaturesPlugin/Test/Test1816.py b/src/FeaturesPlugin/Test/Test1816.py index 3fe9e47ee..f06b0e7d8 100644 --- a/src/FeaturesPlugin/Test/Test1816.py +++ b/src/FeaturesPlugin/Test/Test1816.py @@ -60,28 +60,28 @@ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "Lgz") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), "Lgx") SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "Ray") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchArc_1_2f-SketchLine_4r-SketchLine_6r")], model.selection(), 0, "Lgy") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_4r-SketchArc_1_2f-SketchLine_3r-SketchLine_1r")], model.selection(), 0, "Lgy") +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")) SketchLine_7 = Sketch_2.addLine(0, -75, 0, 0) -SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_1e"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False) SketchPoint_2 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchPoint_2.result()) -SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]"), False) SketchPoint_3 = SketchProjection_5.createdFeature() SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchPoint_3.result()) SketchLine_8 = Sketch_2.addLine(0, 0, 60, 0) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) -SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/From_Face]"), False) SketchPoint_4 = SketchProjection_6.createdFeature() SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchPoint_4.result()) SketchLine_9 = Sketch_2.addLine(60, 0, 59.99999999999999, -62.5) SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) -SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/From_Face]"), False) SketchLine_10 = SketchProjection_7.createdFeature() SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.result()) SketchLine_11 = Sketch_2.addLine(0, -75, 47.49999999999999, -75) SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchLine_11.startPoint()) -SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1"), False) +SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]"), False) SketchLine_12 = SketchProjection_8.createdFeature() SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.result()) SketchArc_2 = Sketch_2.addArc(47.49999999999999, -62.5, 59.99999999999999, -62.5, 47.49999999999999, -75, True) @@ -91,8 +91,9 @@ SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchConstraintTangent_3 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_11.result()) SketchConstraintTangent_4 = Sketch_2.setTangent(SketchLine_9.result(), SketchArc_2.results()[1]) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_11f-SketchArc_2_2f")], model.selection(), 0, "Lgx") +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchArc_2_2f-SketchLine_9r-SketchLine_8r-SketchLine_7r")], model.selection(), 0, "Lgx") Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) +model.do() model.end() assert(len(Common_1.results()) == 1) diff --git a/src/FeaturesPlugin/Test/Test1915.py b/src/FeaturesPlugin/Test/Test1915.py index 3d4de21bf..388ccab83 100644 --- a/src/FeaturesPlugin/Test/Test1915.py +++ b/src/FeaturesPlugin/Test/Test1915.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -33,7 +35,8 @@ Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_2 = Sketch_2.addCircle(-111.0503834053735, -148.4878232655183, 89.21253106334201) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1"), model.selection("COMPOUND", "Sketch_2")], model.selection(), 10, 0) -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2_2"), model.selection("SOLID", "Extrusion_1_2_1")], [model.selection("SOLID", "Extrusion_1_1")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2_2"), model.selection("SOLID", "Extrusion_1_2_1")], [model.selection("SOLID", "Extrusion_1_1")]) +model.do() model.end() assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test1922.py b/src/FeaturesPlugin/Test/Test1922.py index 8b1fc660b..124446498 100644 --- a/src/FeaturesPlugin/Test/Test1922.py +++ b/src/FeaturesPlugin/Test/Test1922.py @@ -18,7 +18,8 @@ ## email : webmaster.salome@opencascade.com ## -from ModelAPI import * +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -90,45 +91,47 @@ SketchPoint_11 = Sketch_1.addPoint(-342.6051560379917, -180.9380775505472) SketchPoint_11.setName("SketchPoint_13") SketchPoint_11.result().setName("SketchPoint_13") SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchPoint_11.coordinates(), SketchLine_5.result()) -SketchPoint_12 = Sketch_1.addPoint(-584.124830393487, -180.9380775505472) +SketchPoint_12 = Sketch_1.addPoint(-584.1248303934869, -180.9380775505472) SketchPoint_12.setName("SketchPoint_14") SketchPoint_12.result().setName("SketchPoint_14") SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchPoint_12.coordinates(), SketchLine_5.result()) model.do() -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_6s-SketchLine_5e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_7"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s-SketchLine_4e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_11"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_10"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_8"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_9"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_13"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_6e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_14"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_6"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_4"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_5")]) -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2"), model.selection("VERTEX", "Vertex_1_3"), model.selection("VERTEX", "Vertex_1_4"), model.selection("VERTEX", "Vertex_1_5"), model.selection("VERTEX", "Vertex_1_6"), model.selection("VERTEX", "Vertex_1_7"), model.selection("VERTEX", "Vertex_1_8"), model.selection("VERTEX", "Vertex_1_9"), model.selection("VERTEX", "Vertex_1_10"), model.selection("VERTEX", "Vertex_1_11"), model.selection("VERTEX", "Vertex_1_12"), model.selection("VERTEX", "Vertex_1_13"), model.selection("VERTEX", "Vertex_1_14"), model.selection("VERTEX", "Vertex_1_15"), model.selection("VERTEX", "Vertex_1_16"), model.selection("VERTEX", "Vertex_1_17"), model.selection("VERTEX", "Vertex_1_18")], model.selection("EDGE", "PartSet/OZ"), 100, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_1_12/To_Vertex_1"), model.selection("VERTEX", "Extrusion_1_13/To_Vertex_1"), model.selection("VERTEX", "Extrusion_1_3/To_Vertex_1")) +Vertex_1_objects = [model.selection("VERTEX", "Sketch_1/SketchLine_5_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchPoint_7"), model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchPoint_11"), model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchPoint_10"), model.selection("VERTEX", "Sketch_1/SketchPoint_8"), model.selection("VERTEX", "Sketch_1/SketchPoint_9"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchPoint_13"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchPoint_14"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/SketchPoint_6"), model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_4"), model.selection("VERTEX", "Sketch_1/SketchPoint_5")] +Vertex_1 = model.addVertex(Part_1_doc, Vertex_1_objects) +Extrusion_1_objects = [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2"), model.selection("VERTEX", "Vertex_1_3"), model.selection("VERTEX", "Vertex_1_4"), model.selection("VERTEX", "Vertex_1_5"), model.selection("VERTEX", "Vertex_1_6"), model.selection("VERTEX", "Vertex_1_7"), model.selection("VERTEX", "Vertex_1_8"), model.selection("VERTEX", "Vertex_1_9"), model.selection("VERTEX", "Vertex_1_10"), model.selection("VERTEX", "Vertex_1_11"), model.selection("VERTEX", "Vertex_1_12"), model.selection("VERTEX", "Vertex_1_13"), model.selection("VERTEX", "Vertex_1_14"), model.selection("VERTEX", "Vertex_1_15"), model.selection("VERTEX", "Vertex_1_16"), model.selection("VERTEX", "Vertex_1_17"), model.selection("VERTEX", "Vertex_1_18")] +Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection("EDGE", "PartSet/OZ"), 100, 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_1_12/To_Vertex"), model.selection("VERTEX", "Extrusion_1_13/To_Vertex"), model.selection("VERTEX", "Extrusion_1_3/To_Vertex")) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_7 = Sketch_2.addLine(-717.0963364993213, -45.06817090071282, -717.0963364993213, -180.9380775505473) -SketchPoint_13 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_12/To_Vertex_1")) +SketchPoint_13 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_12/To_Vertex")) SketchPoint_13.setName("SketchPoint_15") SketchPoint_13.result().setName("SketchPoint_15") SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchPoint_13.result()) -SketchPoint_14 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/To_Vertex_1")) +SketchPoint_14 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/To_Vertex")) SketchPoint_14.setName("SketchPoint_16") SketchPoint_14.result().setName("SketchPoint_16") SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchPoint_14.result()) SketchLine_8 = Sketch_2.addLine(-717.0963364993213, -180.9380775505473, -102.0809741405142, -180.9380775505473) SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) -SketchPoint_15 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_3/To_Vertex_1")) +SketchPoint_15 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_3/To_Vertex")) SketchPoint_15.setName("SketchPoint_17") SketchPoint_15.result().setName("SketchPoint_17") SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchPoint_15.result()) SketchLine_9 = Sketch_2.addLine(-102.0809741405142, -180.9380775505473, -102.0809741405142, 193.0685819822336) SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) -SketchPoint_16 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_10/To_Vertex_1")) +SketchPoint_16 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_10/To_Vertex")) SketchPoint_16.setName("SketchPoint_18") SketchPoint_16.result().setName("SketchPoint_18") SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchPoint_16.result()) SketchLine_10 = Sketch_2.addLine(-102.0809741405142, 193.0685819822336, -254.8675173043772, 193.0685819822336) SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) -SketchPoint_17 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_5/To_Vertex_1")) +SketchPoint_17 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_5/To_Vertex")) SketchPoint_17.setName("SketchPoint_19") SketchPoint_17.result().setName("SketchPoint_19") SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchPoint_17.result()) SketchLine_11 = Sketch_2.addLine(-254.8675173043772, 193.0685819822336, -254.8675173043772, -45.06817090071281) SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) -SketchPoint_18 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_9/To_Vertex_1")) +SketchPoint_18 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_9/To_Vertex")) SketchPoint_18.setName("SketchPoint_20") SketchPoint_18.result().setName("SketchPoint_20") SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchPoint_18.result()) @@ -136,18 +139,18 @@ SketchLine_12 = Sketch_2.addLine(-254.8675173043772, -45.06817090071281, -717.09 SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchLine_12.endPoint()) SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchPoint_13.coordinates(), SketchLine_12.endPoint()) -SketchLine_13 = Sketch_2.addLine(-599.2405881202537, -45.06817090071282, -584.124830393487, -180.9380775505472) +SketchLine_13 = Sketch_2.addLine(-599.2405881202537, -45.06817090071282, -584.1248303934869, -180.9380775505472) SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchLine_13.startPoint(), SketchLine_12.result()) -SketchPoint_19 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_13/To_Vertex_1")) +SketchPoint_19 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_13/To_Vertex")) SketchPoint_19.setName("SketchPoint_21") SketchPoint_19.result().setName("SketchPoint_21") SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchPoint_19.result()) SketchLine_14 = Sketch_2.addLine(-356.1736770691994, -45.06817090071282, -342.6051560379917, -180.9380775505472) -SketchPoint_20 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_15/To_Vertex_1")) +SketchPoint_20 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_15/To_Vertex")) SketchPoint_20.setName("SketchPoint_22") SketchPoint_20.result().setName("SketchPoint_22") SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchPoint_20.result()) -SketchPoint_21 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_11/To_Vertex_1")) +SketchPoint_21 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_11/To_Vertex")) SketchPoint_21.setName("SketchPoint_23") SketchPoint_21.result().setName("SketchPoint_23") SketchConstraintCoincidence_35 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_21.result()) @@ -157,12 +160,17 @@ SketchConstraintCoincidence_37 = Sketch_2.setCoincident(SketchPoint_18.coordinat SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchLine_12.startPoint(), SketchLine_15.startPoint()) SketchConstraintCoincidence_39 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_9.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_7f-SketchLine_8f-SketchLine_12f-SketchLine_13r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_8f-SketchLine_12f-SketchLine_13f-SketchLine_14r")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_8f-SketchLine_9f-SketchLine_12f-SketchLine_14f-SketchLine_15r")]) -Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_15f")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1"), model.selection("EDGE", "Extrusion_1_2"), model.selection("EDGE", "Extrusion_1_3"), model.selection("EDGE", "Extrusion_1_4"), model.selection("EDGE", "Extrusion_1_5"), model.selection("EDGE", "Extrusion_1_6"), model.selection("EDGE", "Extrusion_1_7"), model.selection("EDGE", "Extrusion_1_8"), model.selection("EDGE", "Extrusion_1_9"), model.selection("EDGE", "Extrusion_1_10"), model.selection("EDGE", "Extrusion_1_11"), model.selection("EDGE", "Extrusion_1_12"), model.selection("EDGE", "Extrusion_1_13"), model.selection("EDGE", "Extrusion_1_14"), model.selection("EDGE", "Extrusion_1_15"), model.selection("EDGE", "Extrusion_1_16"), model.selection("EDGE", "Extrusion_1_17"), model.selection("EDGE", "Extrusion_1_18"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_4_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_7r-SketchLine_8f-SketchLine_13r-SketchLine_12f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_8f-SketchLine_14r-SketchLine_12f-SketchLine_13f_wire")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_8f-SketchLine_9f-SketchLine_15r-SketchLine_12f-SketchLine_14f_wire")]) +Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_15f_wire")]) +Partition_1_objects = [model.selection("EDGE", "Extrusion_1_1"), model.selection("EDGE", "Extrusion_1_2"), model.selection("EDGE", "Extrusion_1_3"), model.selection("EDGE", "Extrusion_1_4"), model.selection("EDGE", "Extrusion_1_5"), model.selection("EDGE", "Extrusion_1_6"), model.selection("EDGE", "Extrusion_1_7"), model.selection("EDGE", "Extrusion_1_8"), model.selection("EDGE", "Extrusion_1_9"), model.selection("EDGE", "Extrusion_1_10"), model.selection("EDGE", "Extrusion_1_11"), model.selection("EDGE", "Extrusion_1_12"), model.selection("EDGE", "Extrusion_1_13"), model.selection("EDGE", "Extrusion_1_14"), model.selection("EDGE", "Extrusion_1_15"), model.selection("EDGE", "Extrusion_1_16"), model.selection("EDGE", "Extrusion_1_17"), model.selection("EDGE", "Extrusion_1_18"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_4_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +model.do() model.end() + +from ModelAPI import * + PartitionFeature = Partition_1.feature() assert(len(PartitionFeature.results()) == 1) PartitionResult = modelAPI_ResultBody(PartitionFeature.firstResult()) diff --git a/src/FeaturesPlugin/Test/Test1942.py b/src/FeaturesPlugin/Test/Test1942.py index b4ffe9143..ada970bc5 100644 --- a/src/FeaturesPlugin/Test/Test1942.py +++ b/src/FeaturesPlugin/Test/Test1942.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -29,25 +31,25 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() model.addParameter(Part_1_doc, "a", "100") Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/Plane_4")) -SketchLine_1 = Sketch_1.addLine(-5.023684372475525, -46.5755143466786, -14.75825153820805, -43.01597925234075) +SketchLine_1 = Sketch_1.addLine(-5.024014514861164, -46.57477619916804, -15.03025649976126, -42.91660461599292) SketchLine_1.setName("SketchLine_9") SketchLine_1.result().setName("SketchLine_9") -SketchLine_2 = Sketch_1.addLine(-33.96152175760117, -20.26294727816075, -38.72043789437247, 5.632510332222703) +SketchLine_2 = Sketch_1.addLine(-34.15308715195452, -20.5925185611531, -39.51293324824182, 6.356619200673476) SketchLine_2.setName("SketchLine_10") SketchLine_2.result().setName("SketchLine_10") -SketchLine_3 = Sketch_1.addLine(-5.023684372475525, -46.5755143466786, -30.86227207373359, -37.12739424591874) +SketchLine_3 = Sketch_1.addLine(-5.024014514861164, -46.57477619916804, -30.86442523156243, -37.12780736470863) SketchLine_3.setName("SketchLine_1") SketchLine_3.result().setName("SketchLine_1") SketchLine_3.setAuxiliary(True) -SketchLine_4 = Sketch_1.addLine(-30.86227207373359, -37.12739424591874, -38.72043789437247, 5.632510332222703) +SketchLine_4 = Sketch_1.addLine(-30.86442523156243, -37.12780736470863, -39.51293324824182, 6.356619200673476) SketchLine_4.setName("SketchLine_2") SketchLine_4.result().setName("SketchLine_2") SketchLine_4.setAuxiliary(True) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) -SketchLine_5 = Sketch_1.addLine(-20.37351638704503, 39.82660556161157, 5.515492360623621, 50.89855436380311) +SketchLine_5 = Sketch_1.addLine(-21.88471935002519, 39.79243387785534, 5.516674902531107, 51.5099134867221) SketchLine_5.setName("SketchLine_4") SketchLine_5.result().setName("SketchLine_4") -SketchLine_6 = Sketch_1.addLine(5.515492360623621, 50.89855436380311, 32.11790618078412, 35.7788047045564) +SketchLine_6 = Sketch_1.addLine(5.516674902531107, 51.5099134867221, 32.11790618078412, 35.7788047045564) SketchLine_6.setName("SketchLine_5") SketchLine_6.result().setName("SketchLine_5") SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) @@ -57,19 +59,19 @@ SketchLine_7.setName("SketchLine_6") SketchLine_7.result().setName("SketchLine_6") SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_5") -SketchLine_8 = Sketch_1.addLine(51.23593736581751, -10.42185420425237, 33.52439630860805, -30.08966199583723) +SketchLine_8 = Sketch_1.addLine(51.23593736581751, -10.42185420425237, 33.52471395405271, -30.09043472300023) SketchLine_8.setName("SketchLine_7") SketchLine_8.result().setName("SketchLine_7") SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6") -SketchLine_9 = Sketch_1.addLine(33.52439630860805, -30.08966199583723, -5.023684372475525, -46.5755143466786) +SketchLine_9 = Sketch_1.addLine(33.52471395405271, -30.09043472300023, -5.024014514861164, -46.57477619916804) SketchLine_9.setName("SketchLine_8") SketchLine_9.result().setName("SketchLine_8") SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7") SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_9.endPoint()) SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_8") -SketchArc_1 = Sketch_1.addArc(-4.455634849643539, -14.84052735945157, -33.96152175760117, -20.26294727816075, -14.75825153820805, -43.01597925234075, False) +SketchArc_1 = Sketch_1.addArc(-4.72938863253667, -14.74051331180418, -34.15308715195452, -20.5925185611531, -15.03025649976126, -42.91660461599292, False) SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_9") SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint()) @@ -85,7 +87,7 @@ SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_13") SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_4.result()) SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14") SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 30) -SketchArc_2 = Sketch_1.addArc(-8.152231059872202, 11.25015706261054, -38.72043789437247, 5.632510332222703, -20.37351638704503, 39.82660556161157, True) +SketchArc_2 = Sketch_1.addArc(-10.08923472882396, 12.20862445002239, -39.51293324824182, 6.356619200673476, -21.88471935002519, 39.79243387785534, True) SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 30) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint()) SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15") @@ -175,14 +177,18 @@ SketchConstraintParallel_2 = Sketch_2.setParallel(SketchLine_10.result(), Sketch SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchPoint_7.coordinates()) SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_34") model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_9r-SketchLine_10r-SketchLine_4r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchArc_1_2f-SketchArc_2_2f-SketchArc_4_2r-SketchArc_3_2r")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_12"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchArc_2_2f-SketchLine_10r-SketchArc_1_2f-SketchLine_9r-SketchArc_3_2r-SketchArc_4_2r")], model.selection("EDGE", "Sketch_2/SketchLine_12"), 360, 0) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/Plane_4"), model.selection("SOLID", "Revolution_1_1")]) Recover_1 = model.addRecover(Part_1_doc, Partition_1, [Revolution_1.result()]) Plane_5 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/Axis_4"), model.selection("VERTEX", "PartSet/Point_2"), True) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_2_2"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Recover_1_1"), model.selection("FACE", "Face_1_1")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_2_1"), model.selection("VERTEX", "Intersection_1_1/Generated_Vertex_2"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_6_1"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_4_1"), model.selection("VERTEX", "Intersection_1_1/Generated_Vertex_3"), model.selection("VERTEX", "Intersection_1_1/Generated_Vertex_1"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_1_1"), model.selection("VERTEX", "Intersection_1_1/Generated_Vertex_4"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_3_1"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_7_1"), model.selection("VERTEX", "Intersection_1_1/Modified_Vertex_5_1")]) -Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Intersection_1_1_7"), model.selection("EDGE", "Intersection_1_1_6"), model.selection("EDGE", "Intersection_1_1_3"), model.selection("EDGE", "Intersection_1_1_11"), model.selection("EDGE", "Intersection_1_1_5"), model.selection("EDGE", "Intersection_1_1_1"), model.selection("EDGE", "Intersection_1_1_4"), model.selection("EDGE", "Intersection_1_1_2"), model.selection("EDGE", "Intersection_1_1_10"), model.selection("EDGE", "Intersection_1_1_9"), model.selection("EDGE", "Intersection_1_1_8")]) +Group_1_objects = [model.selection("VERTEX", "[Intersection_1_1_3/Intersection_1_1_3&Face_1_1/Edge_3][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_9/Intersection_1_1_9&Face_1_1/Edge_7][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_7/Intersection_1_1_7&Face_1_1/Edge_5][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_2/Intersection_1_1_2&Face_1_1/Edge_2][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_6/Intersection_1_1_6&Face_1_1/Edge_4][weak_name_2]"), model.selection("VERTEX", "[Intersection_1_1_10/Intersection_1_1_10&Face_1_1/Edge_8][weak_name_1]"), model.selection("VERTEX", "[Intersection_1_1_8/Intersection_1_1_8&Face_1_1/Edge_6][weak_name_1]")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +Group_2_objects = [model.selection("EDGE", "Intersection_1_1_7"), model.selection("EDGE", "Intersection_1_1_6"), model.selection("EDGE", "Intersection_1_1_3"), model.selection("EDGE", "Intersection_1_1_11"), model.selection("EDGE", "Intersection_1_1_5"), model.selection("EDGE", "Intersection_1_1_1"), model.selection("EDGE", "Intersection_1_1_4"), model.selection("EDGE", "Intersection_1_1_2"), model.selection("EDGE", "Intersection_1_1_10"), model.selection("EDGE", "Intersection_1_1_9"), model.selection("EDGE", "Intersection_1_1_8")] +Group_2 = model.addGroup(Part_1_doc, Group_2_objects) +model.do() model.end() aGroupFeature = Group_1.feature() diff --git a/src/FeaturesPlugin/Test/Test2023.py b/src/FeaturesPlugin/Test/Test2023.py index cfde51a81..0c9156338 100644 --- a/src/FeaturesPlugin/Test/Test2023.py +++ b/src/FeaturesPlugin/Test/Test2023.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -38,8 +40,8 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 100, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 100, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) SketchLine_5 = Sketch_2.addLine(99.48542024013722, 69.46826758147516, -34.30531732418524, 69.46826758147516) SketchLine_6 = Sketch_2.addLine(-34.30531732418524, 69.46826758147516, -34.30531732418524, -62.60720411663805) SketchLine_7 = Sketch_2.addLine(-34.30531732418524, -62.60720411663805, 99.48542024013722, -62.60720411663805) @@ -53,9 +55,10 @@ 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_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 10, 110) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 10, 110) Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "Intersection_1_1")], model.selection("EDGE", "PartSet/OZ"), 45) +model.do() model.end() assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2038.py b/src/FeaturesPlugin/Test/Test2038.py index 8a98df7e9..8cc936b8e 100644 --- a/src/FeaturesPlugin/Test/Test2038.py +++ b/src/FeaturesPlugin/Test/Test2038.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -37,14 +39,14 @@ SketchLine_5 = Sketch_1.addLine(-379.073756432247, 108.9193825042881, -360.20583 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_5.endPoint()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_5r")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_5r")], model.selection(), 100, 0) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_5f")], model.selection(), 100, 0) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OX"), 50) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Translation_1_1"), model.selection("SOLID", "Extrusion_2_1")]) Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], model.selection("EDGE", "PartSet/OZ"), 50) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Translation_2_1/Translated_Face_24"), model.selection("FACE", "Translation_2_1/Translated_Face_13"), model.selection("FACE", "Translation_2_1/Translated_Face_16"), model.selection("FACE", "Translation_2_1/Translated_Face_12"), model.selection("FACE", "Translation_2_1/Translated_Face_9"), model.selection("FACE", "Translation_2_1/Translated_Face_10"), model.selection("FACE", "Translation_2_1/Translated_Face_11"), model.selection("FACE", "Translation_2_1/Translated_Face_25"), model.selection("FACE", "Translation_2_1/Translated_Face_20"), model.selection("FACE", "Translation_2_1/Translated_Face_19"), model.selection("FACE", "Translation_2_1/Translated_Face_18"), model.selection("FACE", "Translation_2_1/Translated_Face_27"), model.selection("FACE", "Translation_2_1/Translated_Face_17"), model.selection("FACE", "Translation_2_1/Translated_Face_31"), model.selection("FACE", "Translation_2_1/Translated_Face_32"), model.selection("FACE", "Translation_2_1/Translated_Face_30"), model.selection("FACE", "Translation_2_1/Translated_Face_28"), model.selection("FACE", "Translation_2_1/Translated_Face_29"), model.selection("FACE", "Translation_2_1/Translated_Face_8"), model.selection("FACE", "Translation_2_1/Translated_Face_22"), model.selection("FACE", "Translation_2_1/Translated_Face_7"), model.selection("FACE", "Translation_2_1/Translated_Face_6"), model.selection("FACE", "Translation_2_1/Translated_Face_5"), model.selection("FACE", "Translation_2_1/Translated_Face_3"), model.selection("FACE", "Translation_2_1/Translated_Face_1"), model.selection("FACE", "Translation_2_1/Translated_Face_2"), model.selection("FACE", "Translation_2_1/Translated_Face_21"), model.selection("FACE", "Translation_2_1/Translated_Face_4"), model.selection("FACE", "Translation_2_1/Translated_Face_25"), model.selection("FACE", "Translation_2_1/Translated_Face_27"), model.selection("FACE", "Translation_2_1/Translated_Face_21"), model.selection("FACE", "Translation_2_1/Translated_Face_22"), model.selection("FACE", "Translation_2_1/Translated_Face_26"), model.selection("FACE", "Translation_2_1/Translated_Face_23"), model.selection("FACE", "Translation_2_1/Translated_Face_30"), model.selection("FACE", "Translation_2_1/Translated_Face_23"), model.selection("FACE", "Translation_2_1/Translated_Face_14"), model.selection("FACE", "Translation_2_1/Translated_Face_15")]) -#Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Translation_2_1_6/Translated_Face_1"), model.selection("FACE", "Translation_2_1_5/Translated_Face_1"), model.selection("FACE", "Translation_2_1_5/Translated_Face_4"), model.selection("FACE", "Translation_2_1_4/Translated_Face_4"), model.selection("FACE", "Translation_2_1_5/Translated_Face_3"), model.selection("FACE", "Translation_2_1_5/Translated_Face_2"), model.selection("FACE", "Translation_2_1_5/Translated_Face_5"), model.selection("FACE", "Translation_2_1_7/Translated_Face_5"), model.selection("FACE", "Translation_2_1_6/Translated_Face_5"), model.selection("FACE", "Translation_2_1_4/Translated_Face_1"), model.selection("FACE", "Translation_2_1_2/Translated_Face_2"), model.selection("FACE", "Translation_2_1_5/Translated_Face_5"), model.selection("FACE", "Translation_2_1_2/Translated_Face_1"), model.selection("FACE", "Translation_2_1_4/Translated_Face_5"), model.selection("FACE", "Translation_2_1_2/Translated_Face_3"), model.selection("FACE", "Translation_2_1_3/Translated_Face_5"), model.selection("FACE", "Translation_2_1_1/Translated_Face_3"), model.selection("FACE", "Translation_2_1_4/Translated_Face_2"), model.selection("FACE", "Translation_2_1_2/Translated_Face_3"), model.selection("FACE", "Translation_2_1_1/Translated_Face_4"), model.selection("FACE", "Translation_2_1_1/Translated_Face_1"), model.selection("FACE", "Translation_2_1_1/Translated_Face_2"), model.selection("FACE", "Translation_2_1_3/Translated_Face_4"), model.selection("FACE", "Translation_2_1_4/Translated_Face_3"), model.selection("FACE", "Translation_2_1_3/Translated_Face_5"), model.selection("FACE", "Translation_2_1_3/Translated_Face_2"), model.selection("FACE", "Translation_2_1_3/Translated_Face_3"), model.selection("FACE", "Translation_2_1_3/Translated_Face_1"), model.selection("FACE", "Translation_2_1_7/Translated_Face_3"), model.selection("FACE", "Translation_2_1_7/Translated_Face_5"), model.selection("FACE", "Translation_2_1_7/Translated_Face_4"), model.selection("FACE", "Translation_2_1_7/Translated_Face_1"), model.selection("FACE", "Translation_2_1_7/Translated_Face_2"), model.selection("FACE", "Translation_2_1_6/Translated_Face_4"), model.selection("FACE", "Translation_2_1_4/Translated_Face_5"), model.selection("FACE", "Translation_2_1_6/Translated_Face_5"), model.selection("FACE", "Translation_2_1_6/Translated_Face_2"), model.selection("FACE", "Translation_2_1_6/Translated_Face_3")]) - +Group_1_objects = [model.selection("FACE", "Translation_2_1_3/MF:Translated&Sketch_1/SketchLine_4"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Extrusion_1_1/To_Face"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Extrusion_1_1/From_Face"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Extrusion_2_1/From_Face"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Extrusion_2_1/To_Face"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Sketch_1/SketchLine_4"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Sketch_1/SketchLine_5"), model.selection("FACE", "Translation_2_1_2/MF:Translated&Extrusion_2_1/To_Face&Extrusion_1_1/To_Face"), model.selection("FACE", "Translation_2_1_3/MF:Translated&Sketch_1/SketchLine_1"), model.selection("FACE", "Translation_2_1_3/MF:Translated&Extrusion_1_1/From_Face"), model.selection("FACE", "Translation_2_1_3/MF:Translated&Extrusion_1_1/To_Face"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Sketch_1/SketchLine_1"), model.selection("FACE", "Translation_2_1_3/MF:Translated&Sketch_1/SketchLine_5"), model.selection("FACE", "Translation_2_1_1/MF:Translated&Extrusion_1_1/From_Face"), model.selection("FACE", "Translation_2_1_1/MF:Translated&Sketch_1/SketchLine_1"), model.selection("FACE", "Translation_2_1_1/MF:Translated&Sketch_1/SketchLine_2"), model.selection("FACE", "(Translation_2_1_2/MF:Translated&Sketch_1/SketchLine_1)(Translation_2_1_2/MF:Translated&Extrusion_2_1/From_Face&Extrusion_1_1/From_Face)(Translation_2_1_2/MF:Translated&Extrusion_2_1/To_Face&Extrusion_1_1/To_Face)(Translation_2_1_2/MF:Translated&Sketch_1/SketchLine_2)"), model.selection("FACE", "Translation_2_1_1/MF:Translated&Extrusion_1_1/To_Face"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Sketch_1/SketchLine_3"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Sketch_1/SketchLine_3"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Extrusion_2_1/From_Face"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Extrusion_2_1/To_Face"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Sketch_1/SketchLine_5"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Extrusion_2_1/From_Face"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Extrusion_2_1/To_Face"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Sketch_1/SketchLine_4"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Sketch_1/SketchLine_2"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Sketch_1/SketchLine_3"), model.selection("FACE", "Translation_2_1_2/MF:Translated&Extrusion_2_1/To_Face&Extrusion_1_1/To_Face"), model.selection("FACE", "Translation_2_1_5/MF:Translated&Sketch_1/SketchLine_1"), model.selection("FACE", "Translation_2_1_6/MF:Translated&Sketch_1/SketchLine_2"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Sketch_1/SketchLine_3"), model.selection("FACE", "Translation_2_1_2/MF:Translated&Extrusion_2_1/From_Face&Extrusion_1_1/From_Face"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Sketch_1/SketchLine_5"), model.selection("FACE", "Translation_2_1_1/MF:Translated&Sketch_1/SketchLine_2"), model.selection("FACE", "Translation_2_1_7/MF:Translated&Sketch_1/SketchLine_5"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Sketch_1/SketchLine_2"), model.selection("FACE", "Translation_2_1_4/MF:Translated&Sketch_1/SketchLine_5")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() groupFeature = Group_1.feature() diff --git a/src/FeaturesPlugin/Test/Test2046.py b/src/FeaturesPlugin/Test/Test2046.py index 72c1b77f1..bb3cb3670 100644 --- a/src/FeaturesPlugin/Test/Test2046.py +++ b/src/FeaturesPlugin/Test/Test2046.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -31,9 +33,11 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), model.do() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_3")]) +Wire_1_objects = [model.selection("EDGE", "PartSet/Sketch_1/SketchLine_1"), model.selection("EDGE", "PartSet/Sketch_1/SketchLine_2"), model.selection("EDGE", "PartSet/Sketch_1/SketchLine_3")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 100, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1")]) +Group_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_3")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2172.py b/src/FeaturesPlugin/Test/Test2172.py index 993dceb2e..8d9af6b57 100644 --- a/src/FeaturesPlugin/Test/Test2172.py +++ b/src/FeaturesPlugin/Test/Test2172.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -36,7 +38,7 @@ SketchLine_5 = Sketch_1.addLine(551.916977573864, -398.3514326277755, -18.083022 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchLine_6 = Sketch_1.addLine(-18.08302242613596, -398.3514326277755, -18.08302242613596, -98.35143262777552) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) -SketchArc_1 = Sketch_1.addArc(0, -7.626897158721915e-023, -85.62958302127123, 51.64856737222455, -18.08302242613596, -98.35143262777552, False) +SketchArc_1 = Sketch_1.addArc(0, -7.626897158721915e-23, -85.62958302127123, 51.64856737222455, -18.08302242613596, -98.35143262777552, False) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchArc_1.endPoint()) SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint()) SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result()) @@ -50,8 +52,8 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_5.result(), 570) SketchConstraintAngle_1 = Sketch_1.setAngleBackward(SketchLine_5.result(), SketchLine_4.result(), 139.9999999999999) SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_2.result(), 124.9999999999987) SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_6.result(), 300) -SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.startPoint(), SketchLine_2.result(), 350) -SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchLine_5.result(), 300) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.startPoint(), SketchLine_2.result(), 350, False) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchLine_5.result(), 300, False) SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_1.center(), SketchPoint_1.coordinates()) SketchCircle_1 = Sketch_1.addCircle(623.3624504738834, 247.4315530304268, 75) @@ -68,13 +70,15 @@ SketchPoint_2 = Sketch_1.addPoint(557.3438493481349, 211.8430112592427) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_8.startPoint()) SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_7.result(), SketchLine_8.result()) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchCircle_2.results()[1]) -SketchConstraintDistance_3 = Sketch_1.setDistance(SketchCircle_2.center(), SketchLine_6.endPoint(), 325) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchCircle_2.center(), SketchLine_6.endPoint(), 325, False) SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchCircle_1.results()[1]) -SketchConstraintDistance_4 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.endPoint(), 325) +SketchConstraintDistance_4 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.endPoint(), 325, False) model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_8f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchLine_7r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Lateral_2"), model.selection("EDGE", "Revolution_1_1/Lateral_4"), model.selection("EDGE", "Revolution_1_1/Base_Edge_6"), model.selection("EDGE", "Revolution_1_1/Base_Edge_8"), model.selection("EDGE", "Revolution_2_1/Base_Edge_8"), model.selection("EDGE", "Revolution_2_1/Lateral_2"), model.selection("EDGE", "Revolution_2_1/Lateral_4"), model.selection("EDGE", "Revolution_2_1/Base_Edge_10"), model.selection("EDGE", "Revolution_2_1/Base_Edge_12"), model.selection("EDGE", "Revolution_2_1/Lateral_6")]) +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_2_2f-SketchLine_7r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][weak_name_2]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][weak_name_1]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][weak_name_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][weak_name_3]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1][weak_name_3]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1][Revolution_2_1/Generated_Face&Sketch_1/SketchLine_7]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1][Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2][weak_name_3]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchLine_7][weak_name_3]"), model.selection("EDGE", "[Revolution_2_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2][Revolution_2_1/Generated_Face&Sketch_1/SketchLine_7]")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2194.py b/src/FeaturesPlugin/Test/Test2194.py index d42a091f4..f7d815d23 100644 --- a/src/FeaturesPlugin/Test/Test2194.py +++ b/src/FeaturesPlugin/Test/Test2194.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,14 +29,15 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchCircle_1 = Sketch_1.addCircle(-79.57211859899775, 93.0358363165245, 69.46562387481423) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) SketchCircle_2 = Sketch_2.addCircle(-111.8968837135755, 98.96901887198163, 6.57145775571253) SketchCircle_3 = Sketch_2.addCircle(-41.97827733564338, 89.35676702647821, 6.102067916018811) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")], model.selection(), 10, 0) -Boolean_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_2_2/To_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_2/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Smash_1_1_1/Modified_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_2/From_Face_1"), model.selection("FACE", "Extrusion_2_1/Generated_Face_1"), model.selection("FACE", "Extrusion_2_1/From_Face_1"), model.selection("FACE", "Extrusion_2_1/To_Face_1")]) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")], model.selection(), 10, 0) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) +Group_1_objects = [model.selection("FACE", "Extrusion_2_2/To_Face"), model.selection("FACE", "Extrusion_2_2/From_Face"), model.selection("FACE", "Extrusion_2_2/Generated_Face&Sketch_2/SketchCircle_3_2"), model.selection("FACE", "Extrusion_2_1/From_Face"), model.selection("FACE", "(Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2)(Extrusion_2_1/From_Face)(Extrusion_2_2/From_Face)"), model.selection("FACE", "Extrusion_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_2_2/From_Face"), model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchCircle_2_2"), model.selection("FACE", "Extrusion_2_1/From_Face"), model.selection("FACE", "Extrusion_2_1/To_Face")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2197_1.py b/src/FeaturesPlugin/Test/Test2197_1.py index 4375edb71..b013f7602 100644 --- a/src/FeaturesPlugin/Test/Test2197_1.py +++ b/src/FeaturesPlugin/Test/Test2197_1.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -25,12 +27,15 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) -SketchCircle_1 = Sketch_1.addCircle(-150, 79, -50, 79) -SketchCircle_2 = Sketch_1.addCircle(-155, 278, -10, 278) +SketchCircle_1 = Sketch_1.addCircle(-155, 278, 145) +SketchCircle_2 = Sketch_1.addCircle(-150, 79, 100) +model.do() +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_2_2f-SketchCircle_2_2f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][weak_name_1]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2][weak_name_1]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1][weak_name_1]")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +Group_2_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_2][Revolution_1_1/Generated_Face&Sketch_1/SketchCircle_2_2&weak_name_1]")] +Group_2 = model.addGroup(Part_1_doc, Group_2_objects) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_2_2f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Base_Edge_8"), model.selection("EDGE", "Revolution_1_1/Base_Edge_10"), model.selection("EDGE", "Revolution_1_1/Base_Edge_12")]) -Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Lateral_2"), model.selection("EDGE", "Revolution_1_1/Lateral_4"), model.selection("EDGE", "Revolution_1_1/Lateral_6")]) model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2197_2.py b/src/FeaturesPlugin/Test/Test2197_2.py index cedd7f88f..8c57780a0 100644 --- a/src/FeaturesPlugin/Test/Test2197_2.py +++ b/src/FeaturesPlugin/Test/Test2197_2.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,11 +29,12 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchCircle_1 = Sketch_1.addCircle(-150, 80, 100) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Base_Edge_4")]) -Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Lateral_2")]) -Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Revolution_1_1/Lateral_2&Revolution_1_1/Base_Edge_4")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_1][weak_name_1]")]) +Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_1][weak_name_2]")]) +Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_1]")]) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2197_3.py b/src/FeaturesPlugin/Test/Test2197_3.py index dc6122bb3..cf01ec2dc 100644 --- a/src/FeaturesPlugin/Test/Test2197_3.py +++ b/src/FeaturesPlugin/Test/Test2197_3.py @@ -19,6 +19,7 @@ ## # revolution of 3-edges contour (4th is used as axis of rotation) is checking for naming of edges + from salome.shaper import model model.begin() @@ -35,8 +36,10 @@ SketchLine_4 = Sketch_1.addLine(138, 234, 138, 47) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Lateral_4"), model.selection("EDGE", "Revolution_1_1/Base_Edge_10"), model.selection("EDGE", "Revolution_1_1/Lateral_6"), model.selection("EDGE", "Revolution_1_1/Base_Edge_12"), model.selection("EDGE", "Revolution_1_1/Base_Edge_14")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection("EDGE", "Sketch_1/SketchLine_4"), 360, 0) +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][weak_name_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][weak_name_3]")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2197_4.py b/src/FeaturesPlugin/Test/Test2197_4.py index 23bb4ff7b..cdcd04e6e 100644 --- a/src/FeaturesPlugin/Test/Test2197_4.py +++ b/src/FeaturesPlugin/Test/Test2197_4.py @@ -51,8 +51,10 @@ SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6") SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.endPoint()) SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7") model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5r-SketchLine_6r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4&Revolution_1_1/Generated_Face_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_3&Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "Revolution_1_1/Base_Edge_6"), model.selection("EDGE", "Revolution_1_1/Base_Edge_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "Revolution_1_1/Generated_Face_3")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5r-SketchLine_3f-SketchLine_4f")], model.selection("EDGE", "Sketch_1/SketchLine_4"), 360, 0) +Group_1_objects = [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][weak_name_3]"), model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][weak_name_3]"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])"), model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3])")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2215.py b/src/FeaturesPlugin/Test/Test2215.py index 6c2b3f92d..f43d3273b 100644 --- a/src/FeaturesPlugin/Test/Test2215.py +++ b/src/FeaturesPlugin/Test/Test2215.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,8 +43,8 @@ SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchL SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1"), 25, True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face"), 25, True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_5 = Sketch_2.addLine(84.67753244325934, -72.65003691291119, -28.95543815719345, -72.65003691291119) SketchLine_6 = Sketch_2.addLine(-28.95543815719345, -72.65003691291119, -28.95543815719345, 10.01640181835304) @@ -57,7 +59,8 @@ SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_8.result()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_7")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_6"), model.selection("EDGE", "Sketch_2/SketchLine_8"), model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_7")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_1_1")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("FACE", "Face_1_1")]) Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) @@ -77,7 +80,7 @@ SketchConstraintParallel_3 = Sketch_3.setParallel(SketchLine_9.result(), SketchL SketchConstraintParallel_4 = Sketch_3.setParallel(SketchLine_10.result(), SketchLine_12.result()) SketchConstraintPerpendicular_2 = Sketch_3.setPerpendicular(SketchLine_9.result(), SketchLine_12.result()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_9r-SketchLine_10r-SketchLine_11r-SketchLine_12r")], model.selection(), 50, 0) -Boolean_1 = model.addCut(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r")], model.selection(), 50, 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2222.py b/src/FeaturesPlugin/Test/Test2222.py index ccbab14c6..3143406a9 100644 --- a/src/FeaturesPlugin/Test/Test2222.py +++ b/src/FeaturesPlugin/Test/Test2222.py @@ -40,10 +40,12 @@ 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() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 1, False) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Plane_1")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Partition_1_1_2/Modified_Edge_1_1")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Partition_1_1_2/Modified_Edge&Face_1_1/Edge_4")]) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2231.py b/src/FeaturesPlugin/Test/Test2231.py index f51ba4f89..f306093b7 100644 --- a/src/FeaturesPlugin/Test/Test2231.py +++ b/src/FeaturesPlugin/Test/Test2231.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -72,7 +74,8 @@ SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_12.result()) SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_13.result()) SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_14.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_5f-SketchLine_6f-SketchLine_7f"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r"), model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_14f")], model.selection(), 10, 0) +Extrusion_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_5f-SketchLine_6f-SketchLine_7f"), model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r"), model.selection("FACE", "Sketch_1/Face-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_14f")] +Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection(), 10, 0) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("COMPSOLID", "Extrusion_1_2")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2233.py b/src/FeaturesPlugin/Test/Test2233.py index c4015977d..1b67c6987 100644 --- a/src/FeaturesPlugin/Test/Test2233.py +++ b/src/FeaturesPlugin/Test/Test2233.py @@ -18,7 +18,7 @@ ## email : webmaster.salome@opencascade.com ## -# check that revolution that produces a sphere has correctly named 2 vertices with different names +# -*- coding: utf-8 -*- from salome.shaper import model @@ -37,8 +37,9 @@ SketchLine_2 = Sketch_1.addLine(0, 50, 0, -50) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 360, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Revolution_1_1/Vertex_6"), model.selection("VERTEX", "Revolution_1_1/Vertex_8")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 360, 0) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_1]"), model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][weak_name_2]")]) +model.do() model.end() # check that resulting group selection is valid and names are different diff --git a/src/FeaturesPlugin/Test/Test2240.py b/src/FeaturesPlugin/Test/Test2240.py index dd709a1bc..a0b739e7e 100644 --- a/src/FeaturesPlugin/Test/Test2240.py +++ b/src/FeaturesPlugin/Test/Test2240.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -52,20 +54,20 @@ SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result()) -SketchArc_1 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 81.26217508737108, 0, 0, 81.26217508737108, False) +SketchArc_1 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 81.26217508737108, 0, 0, 81.26217508737108, False) SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_1.center()) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint()) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint()) SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.endPoint()) SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result()) -SketchArc_2 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 76.26217508737108, 0, 0, 76.26217508737108, False) +SketchArc_2 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 76.26217508737108, 0, 0, 76.26217508737108, False) SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_2.center()) SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_23") SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_9.result(), SketchArc_2.startPoint()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_24") SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_10.result(), SketchArc_2.endPoint()) SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_25") -SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5, False) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), "2*length_assemblage") SketchConstraintLength_1.setName("SketchConstraintLength_2") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), "length_assemblage") @@ -93,27 +95,35 @@ SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552 SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645) SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")]) -Face_4 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_9f-SketchArc_1_2f-SketchLine_10r-SketchArc_2_2r_wire")]) +Face_3_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2")] +Face_3 = model.addFace(Part_1_doc, Face_3_objects) +Face_4_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")] +Face_4 = model.addFace(Part_1_doc, Face_4_objects) +Partition_1_objects = [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +Group_1_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) Group_1.result().setName("eau") Group_1.result().setColor(0, 170, 255) Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")]) Group_2.result().setName("acier") Group_2.result().setColor(170, 85, 0) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY")) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) -SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Partition_1_1_1/Modified_Edge_14_15&Partition_1_1_1/Modified_Edge_14_16")) +SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "[Partition_1_1_1/Modified_Edge&Face_4_1/Edge_7&Face_1_1/Edge_7][Partition_1_1_1/Modified_Edge&Face_4_1/Edge_6&Face_1_1/Edge_6]")) SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19") SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0) SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20") SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_22") SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result()) @@ -125,21 +135,23 @@ SketchConstraintLength_3.setName("SketchConstraintLength_1") SketchConstraintEqual_5 = Sketch_3.setEqual(SketchLine_13.result(), SketchLine_14.result()) SketchConstraintEqual_5.setName("SketchConstraintEqual_1") model.do() -Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) -MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) -Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_6s-SketchLine_5e")) -MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) -Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e")) -MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4) -Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "LinearCopy_3_1/Translated_Edge_1_4&LinearCopy_3_1/Translated_Edge_1_1")) -MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3) -Recover_4 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_10s")) -MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 2) -Partition_2 = model.addPartition(Part_1_doc, [model.selection("COMPOUND", "Partition_1_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")]) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")]) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) +Recover_1 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_5_EndVertex")) +LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) +Recover_2 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex")) +LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4) +Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e")) +LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3) +Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")) +LinearCopy_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 2) +Partition_2_objects = [model.selection("COMPOUND", "Partition_1_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")] +Partition_2 = model.addPartition(Part_1_doc, Partition_2_objects) +model.do() model.end() # check that partition constructed correctly diff --git a/src/FeaturesPlugin/Test/Test2246.py b/src/FeaturesPlugin/Test/Test2246.py index c178e45ab..ad02faa1e 100644 --- a/src/FeaturesPlugin/Test/Test2246.py +++ b/src/FeaturesPlugin/Test/Test2246.py @@ -37,9 +37,10 @@ SketchLine_2 = Sketch_1.addLine(0, -62, 0, 62) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 360, 0) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], model.selection("EDGE", "PartSet/OY"), 150) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Translation_1_1/Translated_Vertex_1"), model.selection("VERTEX", "Translation_1_1/Translated_Vertex_2")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_1]"), model.selection("VERTEX", "[Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2][weak_name_2]")]) +model.do() model.end() # check that resulting group selection is valid, names exist and different diff --git a/src/FeaturesPlugin/Test/Test2248.py b/src/FeaturesPlugin/Test/Test2248.py index 20e48f5b9..c3dbdf15d 100644 --- a/src/FeaturesPlugin/Test/Test2248.py +++ b/src/FeaturesPlugin/Test/Test2248.py @@ -48,7 +48,9 @@ SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_3.result(), SketchArc SketchCircle_1 = Sketch_1.addCircle(-13.45056286489504, 169.4770920976776, 150.6703210346195) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_2"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_2"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_2"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_2"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_10&Extrusion_1_1/To_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_10&Extrusion_1_1/From_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_10"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/Generated_Face_10"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/To_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/From_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_9"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/From_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/To_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_7"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/From_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/To_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_11&Extrusion_1_1/Generated_Face_5"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_11&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_11&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_11&Extrusion_1_1/Generated_Face_10"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_10&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_10&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_10&Extrusion_1_1/Generated_Face_9"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&Extrusion_1_1/Generated_Face_8"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/Generated_Face_7")]) +Group_1_objects = [model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1_2/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1_4/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_4/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1][Extrusion_1_1_1/Generated_Face&Sketch_1/SketchArc_1_2]")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2251.py b/src/FeaturesPlugin/Test/Test2251.py index c2694960e..d13c620cb 100644 --- a/src/FeaturesPlugin/Test/Test2251.py +++ b/src/FeaturesPlugin/Test/Test2251.py @@ -56,7 +56,9 @@ SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_3.results()[1], Sketch SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_4.endPoint()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/Generated_Face_19"), model.selection("FACE", "Extrusion_1_1/Generated_Face_18"), model.selection("FACE", "Extrusion_1_1/Generated_Face_16"), model.selection("FACE", "Extrusion_1_1/Generated_Face_15"), model.selection("FACE", "Extrusion_1_1/Generated_Face_15"), model.selection("FACE", "Extrusion_1_1/Generated_Face_5"), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("FACE", "Extrusion_1_1/From_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/To_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_19"), model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("FACE", "Extrusion_1_1/From_Face_4"), model.selection("FACE", "Extrusion_1_1/To_Face_4"), model.selection("FACE", "Extrusion_1_1/Generated_Face_8"), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_9"), model.selection("FACE", "Extrusion_1_1/From_Face_6"), model.selection("FACE", "Extrusion_1_1/Generated_Face_13"), model.selection("FACE", "Extrusion_1_1/To_Face_6"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), model.selection("FACE", "Extrusion_1_1/To_Face_5"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/From_Face_5"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_8"), model.selection("FACE", "Extrusion_1_1/Generated_Face_9"), model.selection("FACE", "Extrusion_1_1/Generated_Face_13"), model.selection("FACE", "Extrusion_1_1/Generated_Face_7"), model.selection("FACE", "Extrusion_1_1/Generated_Face_14"), model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), model.selection("FACE", "Extrusion_1_1/Generated_Face_18"), model.selection("FACE", "Extrusion_1_1/From_Face_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face_11"), model.selection("FACE", "Extrusion_1_1/Generated_Face_6"), model.selection("FACE", "Extrusion_1_1/To_Face_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face_10"), model.selection("FACE", "Extrusion_1_1/Generated_Face_6"), model.selection("FACE", "Extrusion_1_1/To_Face_7"), model.selection("FACE", "Extrusion_1_1/From_Face_7"), model.selection("FACE", "Extrusion_1_1/Generated_Face_17"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/To_Face_1")]) +Group_1_objects = [model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_1"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_3/From_Face"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_3/To_Face"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_1&weak_name_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_4/From_Face"), model.selection("FACE", "Extrusion_1_1_4/To_Face"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchLine_2"), model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_1_1_6/From_Face"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_6/To_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_5/To_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_1"), model.selection("FACE", "Extrusion_1_1_5/From_Face"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchCircle_1_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_3_2"), model.selection("FACE", "Extrusion_1_1_4/Generated_Face&Sketch_1/SketchArc_4_2"), model.selection("FACE", "Extrusion_1_1_5/Generated_Face&Sketch_1/SketchArc_4_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_2/From_Face"), model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_2/To_Face"), model.selection("FACE", "Extrusion_1_1_7/Generated_Face&Sketch_1/SketchCircle_2_2"), model.selection("FACE", "Extrusion_1_1_6/Generated_Face&Sketch_1/SketchArc_2_2&weak_name_2"), model.selection("FACE", "Extrusion_1_1_7/To_Face"), model.selection("FACE", "Extrusion_1_1_7/From_Face"), model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchCircle_1_2&weak_name_1"), model.selection("FACE", "Extrusion_1_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1_1/To_Face")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/FeaturesPlugin/Test/Test2255.py b/src/FeaturesPlugin/Test/Test2255.py index 92193a3a5..4c9921d13 100644 --- a/src/FeaturesPlugin/Test/Test2255.py +++ b/src/FeaturesPlugin/Test/Test2255.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -42,12 +44,13 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchCircle_1 = Sketch_1.addCircle(0, 0, 24.97092001270093) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.center()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_1")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_1_1")]) Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_2_1")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], model.selection(), 50, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ")) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_5 = Sketch_2.addLine(49.62901186301215, 25.3130971701971, 39.15939470736273, 25.3130971701971) SketchLine_6 = Sketch_2.addLine(39.15939470736273, 25.3130971701971, 39.15939470736273, 38.96586914453801) SketchLine_7 = Sketch_2.addLine(39.15939470736273, 38.96586914453801, 49.62901186301215, 38.96586914453801) @@ -61,7 +64,7 @@ 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() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")], model.selection(), 50, 50, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 50, 50, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2289.py b/src/FeaturesPlugin/Test/Test2289.py index 90675d37e..8540d2dbe 100644 --- a/src/FeaturesPlugin/Test/Test2289.py +++ b/src/FeaturesPlugin/Test/Test2289.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -45,7 +47,8 @@ SketchConstraintAngle_1 = Sketch_1.setAngleBackward(SketchLine_2.result(), Sketc SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_3.result()) SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_5")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 10, 0) model.do() diff --git a/src/FeaturesPlugin/Test/Test2304.py b/src/FeaturesPlugin/Test/Test2304.py index cd9c8d689..5726b506b 100644 --- a/src/FeaturesPlugin/Test/Test2304.py +++ b/src/FeaturesPlugin/Test/Test2304.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -51,7 +53,8 @@ SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_8.result()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 100, 100) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("FACE", "Face_1_1")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2304_2.py b/src/FeaturesPlugin/Test/Test2304_2.py index 0558504b8..cbdc10602 100644 --- a/src/FeaturesPlugin/Test/Test2304_2.py +++ b/src/FeaturesPlugin/Test/Test2304_2.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -131,11 +133,11 @@ SketchConstraintAngle_2 = Sketch_1.setAngleComplementary(SketchLine_6.result(), SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_5.startPoint(), SketchLine_12.endPoint(), 8.1, False) SketchConstraintAngle_3 = Sketch_1.setAngle(SketchLine_3.result(), SketchLine_12.result(), 45) model.do() -Edge_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")] +Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")] Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) Face_1_objects = [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4")] Face_1 = model.addFace(Part_1_doc, Face_1_objects) -Edge_2_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_16"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_15"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_13"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_14"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_9")] +Edge_2_objects = [model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_16"), model.selection("EDGE", "Sketch_1/SketchCircle_3_2"), model.selection("EDGE", "Sketch_1/SketchLine_15"), model.selection("EDGE", "Sketch_1/SketchCircle_2_2"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_13"), model.selection("EDGE", "Sketch_1/SketchLine_14"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_9")] Edge_2 = model.addEdge(Part_1_doc, Edge_2_objects) Partition_1_objects = [model.selection("FACE", "Face_1_1"), model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2"), model.selection("EDGE", "Edge_2_3"), model.selection("EDGE", "Edge_2_4"), model.selection("EDGE", "Edge_2_5"), model.selection("EDGE", "Edge_2_6"), model.selection("EDGE", "Edge_2_7"), model.selection("EDGE", "Edge_2_8"), model.selection("EDGE", "Edge_2_9"), model.selection("EDGE", "Edge_2_10"), model.selection("EDGE", "Edge_2_11")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) diff --git a/src/FeaturesPlugin/Test/Test2375.py b/src/FeaturesPlugin/Test/Test2375.py index 1fbbd14c5..b468d2fce 100644 --- a/src/FeaturesPlugin/Test/Test2375.py +++ b/src/FeaturesPlugin/Test/Test2375.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -56,9 +58,9 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_5.result(), 2) SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_3.result(), 1.5) SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_8.result(), 4) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r-SketchLine_8f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1__cc"), False) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8f-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1")) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1]__cc"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchCircle_1 = Sketch_2.addCircle(0, 0, 4.75) SketchCircle_1.setAuxiliary(True) @@ -67,7 +69,7 @@ SketchCircle_2 = Sketch_2.addCircle(4.113620667976081, 2.375000000000003, 1.1) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center()) SketchCircle_3 = Sketch_2.addCircle(-4.113620667974014, 2.375000000003604, 1.1) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_3.center()) -SketchCircle_4 = Sketch_2.addCircle(4.163806340121522e-012, -4.75000000000001, 1.1) +SketchCircle_4 = Sketch_2.addCircle(4.163806340121522e-12, -4.75000000000001, 1.1) SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_4.center()) SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1]) SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_3.results()[1], SketchCircle_4.results()[1]) @@ -79,12 +81,12 @@ SketchLine_10 = Sketch_2.addLine(-4.113620667974014, 2.375000000003604, 0, 0) SketchLine_10.setAuxiliary(True) SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchLine_10.startPoint()) SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_10.endPoint()) -SketchLine_11 = Sketch_2.addLine(4.163806340121522e-012, -4.75000000000001, 0, 0) +SketchLine_11 = Sketch_2.addLine(4.163806340121522e-12, -4.75000000000001, 0, 0) SketchLine_11.setAuxiliary(True) SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchCircle_4.center(), SketchLine_11.startPoint()) SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_11.endPoint()) SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_2.results()[1], 1.1) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_12 = SketchProjection_4.createdFeature() SketchConstraintAngle_1 = Sketch_2.setAngleBackward(SketchLine_9.result(), SketchLine_12.result(), 30.00000000000006) SketchConstraintAngle_2 = Sketch_2.setAngle(SketchLine_9.result(), SketchLine_10.result(), 119.9999999999498) @@ -173,49 +175,43 @@ SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_16.center(), Sket SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_19).startPoint(), SketchCircle_17.center(), 5.2, True) model.do() ExtrusionCut_1_objects_1 = [model.selection("FACE", "Sketch_2/Face-SketchCircle_9_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_10_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_7_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_17_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_16_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")] -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) -ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_12_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_6_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_8_2f")] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Face-SketchCircle_11_2f-SketchCircle_9_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_12_2f-SketchCircle_10_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_6_2f-SketchCircle_5_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_8_2f-SketchCircle_7_2r_wire")] ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_1_1")]) Axis_4 = model.addAxis(Part_1_doc, 0, -1, -10) -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f")], model.selection("EDGE", "Axis_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -ExtrusionCut_3.result().setDeflection(1e-005) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f")], model.selection("EDGE", "Axis_1"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionCut_3.result().setDeflection(1e-05) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_21 = Sketch_3.addLine(3.5, 2.508501119175777, 3.5, 4.934853156880259) SketchLine_22 = Sketch_3.addLine(3.5, 4.934853156880259, 6.2, 4.934853156880259) SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) SketchLine_23 = Sketch_3.addLine(6.2, 4.934853156880259, 6.2, 3.008501119175777) SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) -SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), False) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_3"), False) SketchLine_24 = SketchProjection_6.createdFeature() SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_24.result()) SketchLine_25 = Sketch_3.addLine(6.2, 3.008501119175777, 3.5, 2.508501119175777) SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_25.startPoint()) SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_25.endPoint()) -SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), False) +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_5"), False) SketchLine_26 = SketchProjection_7.createdFeature() SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_26.result()) SketchConstraintCoincidence_55 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_26.result()) SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_22.result()) SketchConstraintCoincidence_56 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.result()) -SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_27 = SketchProjection_8.createdFeature() SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_25.result(), SketchLine_27.result()) -SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_28 = SketchProjection_9.createdFeature() SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_21.startPoint(), SketchLine_28.result(), 0.5, True) model.do() Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0) Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_3_1")], [model.selection("SOLID", "Common_1_1"), model.selection("SOLID", "Common_1_2")]) -# skip 3 vertices, limitation -Group_1_objects = [model.selection("VERTEX", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Cut_1_1/Modified_Face_1"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5095"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("VERTEX", "ExtrusionCut_3_1/Lateral_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("VERTEX", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5108"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5082"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5069"), model.selection("VERTEX", "ExtrusionCut_1_1/Lateral_5043"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5024"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5006"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5015"), model.selection("VERTEX", "Extrusion_1_1/Lateral_4"), model.selection("VERTEX", "Extrusion_1_2/Lateral_4"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5033"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5031"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5022"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5004"), model.selection("VERTEX", "ExtrusionCut_2_1/Vertex_5013"), model.selection("VERTEX", "Common_1_2/Modified_Face_2&Common_1_2/Modified_Face_1"), model.selection("VERTEX", "Common_1_1/Modified_Face_2&Common_1_1/Modified_Face_1")] -Group_1 = model.addGroup(Part_1_doc, Group_1_objects) -# skip 3 edges, limitation -Group_2_objects = [model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5011"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "Common_1_2/Modified_Face_2&Common_1_2/Modified_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&Common_1_2/Modified_Face_2"), model.selection("EDGE", "Common_1_2/Modified_Edge_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_4&ExtrusionCut_2_1/Modfied_9"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_9&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5002"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Common_1_1/Modified_Edge_1"), model.selection("EDGE", "Common_1_1/Modified_Face_2&Common_1_1/Modified_Face_1"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&Common_1_1/Modified_Face_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4&ExtrusionCut_3_1/Modfied_2"), model.selection("EDGE", "Revolution_1_1/Generated_Face_5&Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_4"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_3&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_6&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "Revolution_1_1/Generated_Face_4"), model.selection("EDGE", "Cut_1_1/Modified_Face_1&ExtrusionCut_2_1/Generated_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_6"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "Revolution_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5029"), model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_8&Cut_1_1/Modified_Face_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Lateral_5020")] -Group_2 = model.addGroup(Part_1_doc, Group_2_objects) -Group_3_objects = [model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_8"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_3"), model.selection("FACE", "Common_1_2/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_4"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_9"), model.selection("FACE", "Common_1_1/Modified_Face_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Cut_1_1/Modified_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_2"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_7"), model.selection("FACE", "Common_1_1/Modified_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "Common_1_2/Modified_Face_2"), model.selection("FACE", "Revolution_1_1/Generated_Face_2"), model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_5"), model.selection("FACE", "ExtrusionCut_2_1/Generated_Face_1"), model.selection("FACE", "ExtrusionCut_2_1/Modfied_6"), model.selection("FACE", "ExtrusionCut_1_1/Modfied_8")] -Group_3 = model.addGroup(Part_1_doc, Group_3_objects) +model.do() +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) model.end() assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2377.py b/src/FeaturesPlugin/Test/Test2377.py index 36e38d9d5..5f794351f 100644 --- a/src/FeaturesPlugin/Test/Test2377.py +++ b/src/FeaturesPlugin/Test/Test2377.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -32,11 +34,11 @@ SketchLine_3 = Sketch_1.addLine(46.08233276157804, -21.30874785591767, -1.039451 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")) SketchCircle_1 = Sketch_2.addCircle(-10.74792845018279, -51.46099937127247, 20.55678647017868) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection("EDGE", "PartSet/OX"), model.selection("FACE", "PartSet/YOZ"), 0, model.selection(), 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")], model.selection("EDGE", "PartSet/OX"), model.selection("FACE", "PartSet/YOZ"), 0, model.selection(), 0) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2394.py b/src/FeaturesPlugin/Test/Test2394.py index 13639bba7..cc0cde106 100644 --- a/src/FeaturesPlugin/Test/Test2394.py +++ b/src/FeaturesPlugin/Test/Test2394.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- - -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -20,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from GeomAPI import * from SketchAPI import * @@ -29,7 +29,6 @@ model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() - model.addParameter(Part_1_doc, "R", "58") model.addParameter(Part_1_doc, "cote_cube", "R/2") model.addParameter(Part_1_doc, "theta", "54") @@ -41,7 +40,6 @@ model.addParameter(Part_1_doc, "z", "R*cos(phi/180*pi)") model.addParameter(Part_1_doc, "haut_ext_tuyau", "5") model.addParameter(Part_1_doc, "haut_int_tuyau", "14") Param_Diam = model.addParameter(Part_1_doc, "diam_tuyau", "10") - Revolution_1 = model.addRevolution(Part_1_doc, [], model.selection("EDGE", "PartSet/OZ"), 90, 0) Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) @@ -60,9 +58,8 @@ SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), "R") Revolution_1.setNestedSketch(Sketch_1) - Extrusion_1 = model.addExtrusion(Part_1_doc, [], model.selection(), 0, "cote_cube") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_2")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3")) SketchLine_4 = Sketch_2.addLine(29, 0, 0, 0) SketchLine_5 = Sketch_2.addLine(0, 0, 0, 29) SketchLine_6 = Sketch_2.addLine(0, 29, 29, 29) @@ -77,25 +74,22 @@ SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_6.result()) SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_7.result()) SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_6.result(), "cote_cube") SketchConstraintEqual_1 = Sketch_2.setEqual(SketchLine_6.result(), SketchLine_7.result()) -SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Revolution_1_1/To_Face_1"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][Revolution_1_1/To_Face]"), False) SketchLine_8 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_8.result()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Revolution_1_1/From_Face_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][Revolution_1_1/From_Face]"), False) SketchLine_9 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchLine_9.result()) Extrusion_1.setNestedSketch(Sketch_2) - Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) - Point_2 = model.addPoint(Part_1_doc, "x", "y", "-z") -Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Fill_1_1_2/Modified_Face_3&Fill_1_1_2/Modified_Face_2&Fill_1_1_2/Modified_Face_1")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "[Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_5&Revolution_1_1/To_Face][Fill_1_1_2/Modified_Face&Sketch_2/SketchLine_4&Revolution_1_1/From_Face][Fill_1_1_2/Modified_Face&Extrusion_1_1/To_Face&Sketch_1/SketchLine_3]")) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Point_1"), True) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), "haut_ext_tuyau", True) Plane_5.result().setName("Plane_2 arrivee tuyau") -Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1"), 45) -Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1"), 45) -Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_4"), "90+45") - +Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/From_Face]"), 45) +Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/From_Face]"), 45) +Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7]"), "90+45") Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_1_1_1")], [model.selection("FACE", "Plane_5")]) Fill_3 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_2_1_2")], [model.selection("FACE", "Plane_3")]) Fill_4 = model.addFill(Part_1_doc, [model.selection("SOLID", "Fill_3_1_2")], [model.selection("FACE", "Plane_4")]) @@ -105,11 +99,8 @@ Fill_4.result().subResult(1).setColor(0, 204, 204) Fill_4.result().subResult(2).setColor(51, 51, 102) Fill_4.result().subResult(3).setColor(102, 204, 102) Fill_4.result().subResult(4).setColor(204, 204, 0) - Union_1 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Fill_4_1_4"), model.selection("SOLID", "Fill_4_1_2")]) - Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("FACE", "Plane_2 arrivee tuyau")) - Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2 arrivee tuyau")) SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Point_2"), False) SketchPoint_2 = SketchProjection_5.createdFeature() @@ -147,15 +138,13 @@ SketchConstraintEqual_3 = Sketch_3.setEqual(SketchLine_14.result(), SketchLine_1 SketchConstraintEqual_4 = Sketch_3.setEqual(SketchLine_17.result(), SketchLine_16.result()) SketchConstraintLength_3 = Sketch_3.setLength(SketchLine_10.result(), "diam_tuyau") model.do() - -Extrusion_2_objects = [model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_11f-SketchLine_14r-SketchLine_16r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_10f-SketchLine_14f-SketchLine_17r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_13f-SketchLine_15r-SketchLine_17f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_12f-SketchLine_15f-SketchLine_16f")] +Extrusion_2_objects = [model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_14r-SketchLine_11f-SketchLine_16r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchCircle_1_2f-SketchLine_17r-SketchLine_10f-SketchLine_14f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_15r-SketchLine_13f-SketchLine_17f"), model.selection("FACE", "Sketch_3/Face-SketchCircle_1_2f-SketchLine_16f-SketchLine_12f-SketchLine_15f")] Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), 10, 0) -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_13r")], model.selection(), "haut_int_tuyau", 0) - -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_3")) -SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/To_Face_4"), False) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_10r")], model.selection(), "haut_int_tuyau", 0) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1_3/To_Face")) +SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), False) SketchPoint_3 = SketchProjection_6.createdFeature() -SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_3"), False) +SketchProjection_7 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), False) SketchPoint_4 = SketchProjection_7.createdFeature() SketchArc_2 = Sketch_4.addArc(0, 0, -7.071067811865476, -7.071067811865472, 7.071067811865476, 7.071067811865472, True) SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchPoint_3.result(), SketchArc_2.startPoint()) @@ -163,48 +152,102 @@ SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchPoint_4.result(), SketchLine_18 = Sketch_4.addLine(7.071067811865476, 7.071067811865472, -7.071067811865476, -7.071067811865472) SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchLine_18.startPoint()) SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_18.endPoint()) -SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_2_1/Generated_Face_13&Extrusion_2_1/Generated_Face_12&Extrusion_2_1/To_Face_1"), False) +SketchProjection_8 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), False) SketchPoint_5 = SketchProjection_8.createdFeature() SketchConstraintCoincidence_30 = Sketch_4.setCoincident(SketchArc_2.endPoint(), SketchAPI_Point(SketchPoint_5).coordinates()) model.do() - -Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_2_2f-SketchLine_18r")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_18"), 0, 180) - +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_2_2f-SketchLine_18r")], model.selection("EDGE", "Sketch_4/SketchLine_18"), 0, 180) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) Cut_1.result().setName("demi-sphere") - -Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_10&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/From_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_10&Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_10&Extrusion_2_1/To_Face_4")) -Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_12&Extrusion_2_1/Generated_Face_11&Extrusion_2_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_13&Extrusion_2_1/Generated_Face_12&Extrusion_2_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_13&Extrusion_2_1/Generated_Face_12&Extrusion_2_1/From_Face_1")) -Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_3"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_3"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_7&Extrusion_2_1/From_Face_3")) -Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_1&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/To_Face_4"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_4&Extrusion_2_1/From_Face_4")) - +Plane_9 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/From_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_16][Extrusion_2_1_1/To_Face]")) +Plane_10 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_11][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_1/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_1/Generated_Face&Sketch_3/SketchLine_14][Extrusion_2_1_1/From_Face]")) +Plane_11 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_10][Extrusion_2_1_2/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_2/Generated_Face&Sketch_3/SketchCircle_1_2&weak_name_1][Extrusion_2_1_2/Generated_Face&Sketch_3/SketchLine_17][Extrusion_2_1_2/From_Face]")) +Plane_12 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_13][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1_3/Generated_Face&Sketch_3/SketchCircle_1_2][Extrusion_2_1_3/Generated_Face&Sketch_3/SketchLine_15][Extrusion_2_1_3/From_Face]")) Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_3.result()]) - -Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape4"), model.selection("EDGE", "Recover_1_1/Shape4&Recover_1_1/Shape6"), "90+45") -Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape1"), model.selection("EDGE", "Recover_1_1/Shape1&Recover_1_1/Shape6"), "90+45") -Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape2"), model.selection("EDGE", "Recover_1_1/Shape2&Recover_1_1/Shape6"), "90+45") -Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Shape6"), model.selection("EDGE", "Recover_1_1/Shape3&Recover_1_1/Shape6"), 45) - +Plane_13 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_10"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_10][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45") +Plane_14 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_13"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_13][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45") +Plane_15 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Sketch_3/SketchLine_12"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_12][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), "90+45") +Plane_16 = model.addPlane(Part_1_doc, model.selection("FACE", "Recover_1_1/Modified_Face&Extrusion_3_1/To_Face"), model.selection("EDGE", "[Recover_1_1/Modified_Face&Sketch_3/SketchLine_11][Recover_1_1/Modified_Face&Extrusion_3_1/To_Face]"), 45) Fill_5_objects_2 = [model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_7"), model.selection("FACE", "Plane_8"), model.selection("FACE", "Plane_9"), model.selection("FACE", "Plane_10"), model.selection("FACE", "Plane_11"), model.selection("FACE", "Plane_12"), model.selection("FACE", "Plane_13")] Fill_5 = model.addFill(Part_1_doc, [model.selection("SOLID", "demi-sphere")], Fill_5_objects_2) - +Fill_5.result().subResult(0).setName("Fill_5_1_1") +Fill_5.result().subResult(1).setName("Fill_5_1_2") +Fill_5.result().subResult(2).setName("Fill_5_1_3") +Fill_5.result().subResult(3).setName("Fill_5_1_4") +Fill_5.result().subResult(4).setName("Fill_5_1_5") +Fill_5.result().subResult(5).setName("Fill_5_1_6") +Fill_5.result().subResult(6).setName("Fill_5_1_7") +Fill_5.result().subResult(7).setName("Fill_5_1_8") +Fill_5.result().subResult(8).setName("Fill_5_1_9") +Fill_5.result().subResult(9).setName("Fill_5_1_10") +Fill_5.result().subResult(10).setName("Fill_5_1_11") +Fill_5.result().subResult(11).setName("Fill_5_1_12") +Fill_5.result().subResult(12).setName("Fill_5_1_13") +Fill_5.result().subResult(13).setName("Fill_5_1_14") +Fill_5.result().subResult(14).setName("Fill_5_1_15") +Fill_5.result().subResult(15).setName("Fill_5_1_16") Union_2_objects = [model.selection("SOLID", "Fill_5_1_14"), model.selection("SOLID", "Fill_5_1_15"), model.selection("SOLID", "Fill_5_1_16")] Union_2 = model.addUnion(Part_1_doc, Union_2_objects) -Union_3_objects = [model.selection("SOLID", "Fill_5_1_8/Fill_5_1_8"), model.selection("SOLID", "Fill_5_1_4/Fill_5_1_4"), model.selection("SOLID", "Fill_5_1_9/Fill_5_1_9"), model.selection("SOLID", "Fill_5_1_11/Fill_5_1_11")] +Union_2.result().subResult(0).setName("Union_2_1_1") +Union_2.result().subResult(1).setName("Union_2_1_2") +Union_2.result().subResult(2).setName("Union_2_1_3") +Union_2.result().subResult(3).setName("Union_2_1_4") +Union_2.result().subResult(4).setName("Union_2_1_5") +Union_2.result().subResult(5).setName("Union_2_1_6") +Union_2.result().subResult(6).setName("Union_2_1_7") +Union_2.result().subResult(7).setName("Union_2_1_8") +Union_2.result().subResult(8).setName("Union_2_1_9") +Union_2.result().subResult(9).setName("Union_2_1_10") +Union_2.result().subResult(10).setName("Union_2_1_11") +Union_2.result().subResult(11).setName("Union_2_1_12") +Union_2.result().subResult(12).setName("Union_2_1_13") +Union_2.result().subResult(13).setName("Union_2_1_14") +Union_3_objects = [model.selection("SOLID", "Union_2_1_8"), model.selection("SOLID", "Union_2_1_4"), model.selection("SOLID", "Union_2_1_9"), model.selection("SOLID", "Union_2_1_11")] Union_3 = model.addUnion(Part_1_doc, Union_3_objects) -Union_4_objects = [model.selection("SOLID", "Fill_5_1_6/Fill_5_1_6"), model.selection("SOLID", "Fill_5_1_10/Fill_5_1_10"), model.selection("SOLID", "Fill_5_1_13/Fill_5_1_13")] +Union_3.result().subResult(0).setName("Union_3_1_1") +Union_3.result().subResult(1).setName("Union_3_1_2") +Union_3.result().subResult(2).setName("Union_3_1_3") +Union_3.result().subResult(3).setName("Union_3_1_4") +Union_3.result().subResult(4).setName("Union_3_1_5") +Union_3.result().subResult(5).setName("Union_3_1_6") +Union_3.result().subResult(6).setName("Union_3_1_7") +Union_3.result().subResult(7).setName("Union_3_1_8") +Union_3.result().subResult(8).setName("Union_3_1_9") +Union_3.result().subResult(9).setName("Union_3_1_10") +Union_3.result().subResult(10).setName("Union_3_1_11") +Union_4_objects = [model.selection("SOLID", "Union_3_1_5"), model.selection("SOLID", "Union_3_1_7"), model.selection("SOLID", "Union_3_1_9")] Union_4 = model.addUnion(Part_1_doc, Union_4_objects) -Union_5_objects = [model.selection("SOLID", "Fill_5_1_2/Fill_5_1_2"), model.selection("SOLID", "Fill_5_1_1/Fill_5_1_1"), model.selection("SOLID", "Fill_5_1_3/Fill_5_1_3")] +Union_4.result().subResult(0).setName("Union_4_1_1") +Union_4.result().subResult(1).setName("Union_4_1_2") +Union_4.result().subResult(2).setName("Union_4_1_3") +Union_4.result().subResult(3).setName("Union_4_1_4") +Union_4.result().subResult(4).setName("Union_4_1_5") +Union_4.result().subResult(5).setName("Union_4_1_6") +Union_4.result().subResult(6).setName("Union_4_1_7") +Union_4.result().subResult(7).setName("Union_4_1_8") +Union_4.result().subResult(8).setName("Union_4_1_9") +Union_5_objects = [model.selection("SOLID", "Union_4_1_2"), model.selection("SOLID", "Union_4_1_1"), model.selection("SOLID", "Union_4_1_3")] Union_5 = model.addUnion(Part_1_doc, Union_5_objects) -Union_6_objects = [model.selection("SOLID", "Fill_5_1_5/Fill_5_1_5"), model.selection("SOLID", "Fill_5_1_7/Fill_5_1_7"), model.selection("SOLID", "Fill_5_1_12/Fill_5_1_12")] +Union_5.result().subResult(0).setName("Union_5_1_1") +Union_5.result().subResult(1).setName("Union_5_1_2") +Union_5.result().subResult(2).setName("Union_5_1_3") +Union_5.result().subResult(3).setName("Union_5_1_4") +Union_5.result().subResult(4).setName("Union_5_1_5") +Union_5.result().subResult(5).setName("Union_5_1_6") +Union_5.result().subResult(6).setName("Union_5_1_7") +Union_6_objects = [model.selection("SOLID", "Union_5_1_1"), model.selection("SOLID", "Union_5_1_2"), model.selection("SOLID", "Union_5_1_3")] Union_6 = model.addUnion(Part_1_doc, Union_6_objects) Union_6.result().setColor(0, 0, 204) +Union_6.result().subResult(0).setName("Union_6_1_1") Union_6.result().subResult(0).setColor(204, 102, 102) +Union_6.result().subResult(1).setName("Union_6_1_2") Union_6.result().subResult(1).setColor(127, 254, 127) +Union_6.result().subResult(2).setName("Union_6_1_3") Union_6.result().subResult(2).setColor(102, 51, 102) +Union_6.result().subResult(3).setName("Union_6_1_4") Union_6.result().subResult(3).setColor(76, 76, 153) +Union_6.result().subResult(4).setName("Union_6_1_5") Union_6.result().subResult(4).setColor(0, 0, 254) - Partition_1_objects = [model.selection("SOLID", "Recover_1_1"), model.selection("COMPSOLID", "Union_1_1"), model.selection("COMPSOLID", "Extrusion_2_1"), model.selection("COMPSOLID", "demi-sphere")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) Partition_1.result().setColor(102, 0, 0) @@ -227,7 +270,6 @@ Partition_1.result().subResult(15).setColor(254, 127, 254) Partition_1.result().subResult(16).setColor(153, 153, 0) Partition_1.result().subResult(17).setColor(153, 153, 0) Partition_1.result().subResult(18).setColor(204, 0, 204) - Folder_1 = model.addFolder(Part_1_doc, Revolution_1, Union_1) Folder_2 = model.addFolder(Part_1_doc, Point_3, Union_6) model.do() @@ -255,4 +297,5 @@ model.testResultsVolumes(Partition_1, [103221.354557478349306620657444]) model.end() +# too long #assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2395.py b/src/FeaturesPlugin/Test/Test2395.py index 5364304ea..e352bbfd4 100644 --- a/src/FeaturesPlugin/Test/Test2395.py +++ b/src/FeaturesPlugin/Test/Test2395.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -43,11 +45,11 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_5 = Sketch_2.addLine(0, 0, -37.87650574447493, 64.03712943185892) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchProjection_1-SketchPoint_1-SketchLine_2s-SketchLine_1e"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchPoint_2.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")], model.selection("EDGE", "Sketch_2/SketchLine_5"), 100, 0) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2419_1.py b/src/FeaturesPlugin/Test/Test2419_1.py index e1366fd36..8bb2a8a46 100644 --- a/src/FeaturesPlugin/Test/Test2419_1.py +++ b/src/FeaturesPlugin/Test/Test2419_1.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -52,13 +54,13 @@ SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result()) -SketchArc_1 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 81.26217508737108, 0, 0, 81.26217508737108, False) +SketchArc_1 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 81.26217508737108, 0, 0, 81.26217508737108, False) SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_1.center()) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint()) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint()) SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.endPoint()) SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result()) -SketchArc_2 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 76.26217508737108, 0, 0, 76.26217508737108, False) +SketchArc_2 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 76.26217508737108, 0, 0, 76.26217508737108, False) SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_2.center()) SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_23") SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_9.result(), SketchArc_2.startPoint()) @@ -79,15 +81,18 @@ SketchConstraintEqual_3.setName("SketchConstraintEqual_4") SketchConstraintEqual_4 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_1.result()) SketchConstraintEqual_4.setName("SketchConstraintEqual_5") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_11 = Sketch_2.addLine(40, 0, 30, 0) SketchLine_12 = Sketch_2.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_2.addLine(30, 10, 40, 10) SketchLine_14 = Sketch_2.addLine(40, 10, 40, 0) SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19") SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20") SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_26") SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_11.result()) @@ -101,23 +106,22 @@ SketchConstraintEqual_5.setName("SketchConstraintEqual_1") model.do() Sketch_2.setName("Sketch_3") Sketch_2.result().setName("Sketch_3") -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")]) Face_2.setName("Face_5") Face_2.result().setName("Face_5_1") -LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), 10, 2) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/SketchLine_9"), 10, 2) LinearCopy_1.result().setName("LinearCopy") -LinearCopy_1.result().subResult(0).setName("LinearCopy_1_1_1") -LinearCopy_1.result().subResult(1).setName("LinearCopy_1_1_2") -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("COMPOUND", "LinearCopy")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("COMPOUND", "LinearCopy")]) +model.do() model.end() from GeomAPI import GeomAPI_Shape -model.testNbResults(Boolean_1, 1) -model.testNbSubResults(Boolean_1, [3]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [0]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [3]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [20]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [40]) +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [3]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [20]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [40]) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2419_2.py b/src/FeaturesPlugin/Test/Test2419_2.py index 4f591ed01..b9fdb3b30 100644 --- a/src/FeaturesPlugin/Test/Test2419_2.py +++ b/src/FeaturesPlugin/Test/Test2419_2.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -93,11 +95,11 @@ SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552 SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645) SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")]) -Face_3_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")] +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_9f-SketchArc_1_2f-SketchLine_10r-SketchArc_2_2r_wire")]) +Face_3_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2")] Face_3 = model.addFace(Part_1_doc, Face_3_objects) -Face_4_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")] +Face_4_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")] Face_4 = model.addFace(Part_1_doc, Face_4_objects) Group_1_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) @@ -108,15 +110,19 @@ Group_2.result().setName("acier") Group_2.result().setColor(170, 85, 0) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) -SketchProjection_1 = Sketch_3.addProjection(model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), False) +SketchProjection_1 = Sketch_3.addProjection(model.selection("VERTEX", "[Face_4_1/Edge_6][Face_4_1/Edge_7]"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19") SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0) SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20") SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_22") SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result()) @@ -128,33 +134,33 @@ SketchConstraintLength_3.setName("SketchConstraintLength_1") SketchConstraintEqual_5 = Sketch_3.setEqual(SketchLine_13.result(), SketchLine_14.result()) SketchConstraintEqual_5.setName("SketchConstraintEqual_1") model.do() -Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) -LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")]) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) Recover_1 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchProjection_1-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_6s-SketchLine_5e")) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_5_EndVertex")) LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) Recover_2 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchProjection_1-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e")) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex")) LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4) Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "LinearCopy_3_1/Translated_Edge_1_4&LinearCopy_3_1/Translated_Edge_1_1")) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e")) LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3) Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_10s")) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")) LinearCopy_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 2) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Boolean_1_objects_2 = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")] -Boolean_1 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Partition_1_1")], Boolean_1_objects_2) +Fill_1_objects_2 = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")] +Fill_1 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Partition_1_1")], Fill_1_objects_2) model.do() model.end() from GeomAPI import GeomAPI_Shape -model.testNbResults(Boolean_1, 1) -model.testNbSubResults(Boolean_1, [60]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [0]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [60]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [273]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [546]) +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [60]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [60]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [273]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [546]) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2419_3.py b/src/FeaturesPlugin/Test/Test2419_3.py index dd6e4c4e9..9d2144f63 100644 --- a/src/FeaturesPlugin/Test/Test2419_3.py +++ b/src/FeaturesPlugin/Test/Test2419_3.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -93,11 +95,11 @@ SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552 SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645) SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")]) -Face_3_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")] +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_9f-SketchArc_1_2f-SketchLine_10r-SketchArc_2_2r_wire")]) +Face_3_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2")] Face_3 = model.addFace(Part_1_doc, Face_3_objects) -Face_4_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")] +Face_4_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")] Face_4 = model.addFace(Part_1_doc, Face_4_objects) Group_1_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) @@ -108,15 +110,19 @@ Group_2.result().setName("acier") Group_2.result().setColor(170, 85, 0) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) -SketchProjection_1 = Sketch_3.addProjection(model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), False) +SketchProjection_1 = Sketch_3.addProjection(model.selection("VERTEX", "[Face_4_1/Edge_6][Face_4_1/Edge_7]"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19") SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0) SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20") SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_22") SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result()) @@ -128,33 +134,33 @@ SketchConstraintLength_3.setName("SketchConstraintLength_1") SketchConstraintEqual_5 = Sketch_3.setEqual(SketchLine_13.result(), SketchLine_14.result()) SketchConstraintEqual_5.setName("SketchConstraintEqual_1") model.do() -Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) -LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")]) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "Sketch_1/SketchLine_9"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) Recover_1 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchProjection_1-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_6s-SketchLine_5e")) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_5_EndVertex")) LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4, model.selection("EDGE", "PartSet/OY"), "length_assemblage", 2) Recover_2 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/Vertex-SketchProjection_1-SketchPoint_1-SketchLine_12s-SketchLine_11e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e")) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Sketch_3/SketchLine_11_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex")) LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 4) Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "LinearCopy_3_1/Translated_Edge_1_4&LinearCopy_3_1/Translated_Edge_1_1")) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_4]e")) LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 3) Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) -Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_9s-SketchLine_7e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_10s")) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_7_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")) LinearCopy_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "length_assemblage", 2) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Boolean_1_objects_2 = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")] -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], Boolean_1_objects_2) +Fill_1_objects_2 = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("FACE", "Face_4_1"), model.selection("COMPOUND", "LinearCopy_1_1"), model.selection("COMPOUND", "LinearCopy_2_1"), model.selection("COMPOUND", "LinearCopy_3_1"), model.selection("COMPOUND", "LinearCopy_4_1"), model.selection("COMPOUND", "LinearCopy_5_1")] +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], Fill_1_objects_2) model.do() model.end() from GeomAPI import GeomAPI_Shape -model.testNbResults(Boolean_1, 1) -model.testNbSubResults(Boolean_1, [0]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [0]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [60]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [273]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [546]) +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [0]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [60]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [273]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [546]) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2465.py b/src/FeaturesPlugin/Test/Test2465.py index d23abdd5e..313f436ad 100644 --- a/src/FeaturesPlugin/Test/Test2465.py +++ b/src/FeaturesPlugin/Test/Test2465.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -26,7 +28,8 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Ellipsoid_1 = model.addEllipsoid(Part_1_doc, 10, 20, 40) Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 15, 3) -LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Ellipsoid_1_1")], model.selection("EDGE", "Ellipsoid_1_1/Face_1"), 10, 2) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Ellipsoid_1_1")], model.selection("EDGE", "[Ellipsoid_1_1/Face_1][weak_name_3]"), 10, 2) +model.do() model.end() # check that for the linear copy direction the elliptical edge is invalid diff --git a/src/FeaturesPlugin/Test/Test2495.py b/src/FeaturesPlugin/Test/Test2495.py index 8154bd4bd..f7c74d590 100644 --- a/src/FeaturesPlugin/Test/Test2495.py +++ b/src/FeaturesPlugin/Test/Test2495.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -36,7 +36,7 @@ SketchLine_1 = Sketch_1.addLine(153.5, 27.7, -153.5, 27.7) SketchLine_2 = Sketch_1.addLine(-153.5, 27.7, -153.5, 16.19999999999975) SketchLine_3 = Sketch_1.addLine(-151.5000000000398, -24.69999999999951, 151.5000000000377, -24.69999999999977) SketchLine_4 = Sketch_1.addLine(153.5000000000001, -22.70000000003736, 153.5, -15.80000000000003) -SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.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()) @@ -44,20 +44,20 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 307) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 11.50000000000025) SketchPoint_1 = Sketch_1.addPoint(0, 27.7) -SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()) -SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_5") +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()) +SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_5") SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_5 = SketchProjection_1.createdFeature() -SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_5.result()) -SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6") +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_5.result()) +SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_6") SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchLine_1.result(), SketchPoint_1.coordinates()) SketchPoint_2 = Sketch_1.addPoint(153.5, 0) -SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_4.result()) -SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7") +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_4.result()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_7") SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) SketchLine_6 = SketchProjection_2.createdFeature() -SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_6.result()) -SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_8") +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_6.result()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_8") SketchLine_7 = Sketch_1.addLine(-108.1499999999999, 23.04999999999991, -109.8500000000001, 23.04999999999991) SketchLine_8 = Sketch_1.addLine(-109.8500000000001, 19.75000000000008, -108.1499999999999, 19.75000000000008) SketchLine_8.setName("SketchLine_9") @@ -65,15 +65,15 @@ SketchLine_8.result().setName("SketchLine_9") SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_7.result()) SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_8.result()) SketchArc_1 = Sketch_1.addArc(-109.8500000000001, 21.39999999999999, -109.8500000000001, 19.75000000000008, -109.8500000000001, 23.04999999999991, True) -SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchArc_1.startPoint()) -SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_9") +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_9") SketchArc_2 = Sketch_1.addArc(-108.1499999999999, 21.39999999999999, -108.1499999999999, 19.75000000000008, -108.1499999999999, 23.04999999999991, False) -SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchArc_2.startPoint()) -SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_10") -SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_7.startPoint()) -SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_11") -SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_7.endPoint()) -SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_12") +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_10") +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_11") +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_7.endPoint()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_12") SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_7.result()) SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_8.result(), SketchArc_2.results()[1]) SketchConstraintTangent_3 = Sketch_1.setTangent(SketchLine_8.result(), SketchArc_1.results()[1]) @@ -82,24 +82,24 @@ SketchLine_9 = Sketch_1.addLine(-111.5, 21.39999999999998, -106.5, 21.4000000000 SketchLine_9.setName("SketchLine_10") SketchLine_9.result().setName("SketchLine_10") SketchLine_9.setAuxiliary(True) -SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_9.startPoint(), SketchArc_1.results()[1]) -SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_13") -SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_2.results()[1]) -SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14") -SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_9.result()) -SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15") -SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_9.result()) -SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_16") +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.startPoint(), SketchArc_1.results()[1]) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_13") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_2.results()[1]) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_14") +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_9.result()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_15") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_9.result()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_16") SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_9.result(), 5) SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.startPoint(), SketchLine_7.result(), 3.3, True) SketchPoint_3 = Sketch_1.addPoint(0, 21.40000000000294) -SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_5.result()) -SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_17") -SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_9.result()) -SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_18") +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_5.result()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_17") +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_9.result()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_18") SketchPoint_4 = Sketch_1.addPoint(-109, 21.4) -SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_9.result()) -SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_19") +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_9.result()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_19") SketchConstraintMiddle_2 = Sketch_1.setMiddlePoint(SketchPoint_4.coordinates(), SketchLine_9.result()) SketchConstraintMiddle_2.setName("SketchConstraintMiddle_3") SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchPoint_4.coordinates(), SketchPoint_3.coordinates(), 109) @@ -122,8 +122,8 @@ SketchArc_4.result().setName("SketchArc_5") SketchArc_4.results()[1].setName("SketchArc_5_2") SketchConstraintDistance_2 = Sketch_1.setDistance(SketchPoint_4.coordinates(), SketchLine_6.result(), 21.4, True) SketchPoint_5 = Sketch_1.addPoint(0, -21) -SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchLine_5.result()) -SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20") +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchPoint_5.coordinates(), SketchLine_5.result()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_20") SketchConstraintDistance_3 = Sketch_1.setDistance(SketchPoint_5.coordinates(), SketchLine_6.result(), 21, True) SketchMultiTranslation_2_objects = [SketchArc_1.results()[1], SketchLine_7.result(), SketchLine_8.result(), SketchArc_2.results()[1], SketchLine_10.result(), SketchArc_5.results()[1], SketchLine_12.result(), SketchArc_3.results()[1], SketchArc_4.results()[1], SketchLine_13.result(), SketchLine_11.result(), SketchArc_6.results()[1]] SketchMultiTranslation_2 = Sketch_1.addTranslation(SketchMultiTranslation_2_objects, SketchPoint_3.coordinates(), SketchPoint_5.coordinates(), 2) @@ -160,49 +160,49 @@ SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_20.result(), 37) SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_21.result(), 8) SketchArc_13 = Sketch_1.addArc(-146.43, 15.7, -145.43, 15.69999999999999, -146.43, 14.7, False) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_13.results()[1], 1) -SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_20.endPoint(), SketchArc_13.startPoint()) -SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_31") -SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_13.endPoint(), SketchLine_21.startPoint()) -SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_29") -SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_13.center(), SketchLine_20.result()) -SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_30") -SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_13.center(), SketchLine_21.result()) -SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_32") +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_20.endPoint(), SketchArc_13.startPoint()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_31") +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_13.endPoint(), SketchLine_21.startPoint()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_29") +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_13.center(), SketchLine_20.result()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_30") +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_13.center(), SketchLine_21.result()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_32") SketchArc_14 = Sketch_1.addArc(-146.43, 5.699999999999998, -146.43, 6.699999999999998, -145.43, 5.7, False) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_13.results()[1], SketchArc_14.results()[1]) -SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchArc_14.startPoint(), SketchLine_21.endPoint()) -SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_35") -SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchArc_14.endPoint(), SketchLine_22.startPoint()) -SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_34") -SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchArc_14.center(), SketchLine_22.result()) -SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_33") -SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchArc_14.center(), SketchLine_21.result()) -SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_36") +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_14.startPoint(), SketchLine_21.endPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_35") +SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchArc_14.endPoint(), SketchLine_22.startPoint()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_34") +SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchArc_14.center(), SketchLine_22.result()) +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_33") +SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchArc_14.center(), SketchLine_21.result()) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_36") SketchArc_15 = Sketch_1.addArc(-107.43, 15.69999999999999, -107.43, 14.69999999999999, -108.43, 15.69999999999999, False) SketchConstraintEqual_2 = Sketch_1.setEqual(SketchArc_15.results()[1], SketchArc_13.results()[1]) -SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchArc_15.endPoint(), SketchLine_20.startPoint()) -SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_39") -SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchArc_15.startPoint(), SketchLine_23.endPoint()) -SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_37") -SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchArc_15.center(), SketchLine_20.result()) -SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_38") -SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchArc_15.center(), SketchLine_23.result()) -SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_40") +SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchArc_15.endPoint(), SketchLine_20.startPoint()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_39") +SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchArc_15.startPoint(), SketchLine_23.endPoint()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_37") +SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchArc_15.center(), SketchLine_20.result()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_38") +SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchArc_15.center(), SketchLine_23.result()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_40") SketchArc_16 = Sketch_1.addArc(-107.43, 5.7, -108.43, 5.7, -107.43, 6.7, False) SketchConstraintEqual_3 = Sketch_1.setEqual(SketchArc_15.results()[1], SketchArc_16.results()[1]) -SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchArc_16.startPoint(), SketchLine_22.endPoint()) -SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_43") -SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchArc_16.endPoint(), SketchLine_23.startPoint()) -SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_42") -SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchArc_16.center(), SketchLine_22.result()) -SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_41") -SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchArc_16.center(), SketchLine_23.result()) -SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_44") +SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchArc_16.startPoint(), SketchLine_22.endPoint()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_43") +SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchArc_16.endPoint(), SketchLine_23.startPoint()) +SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_42") +SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchArc_16.center(), SketchLine_22.result()) +SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_41") +SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchArc_16.center(), SketchLine_23.result()) +SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_44") SketchConstraintDistance_4 = Sketch_1.setDistance(SketchArc_15.center(), SketchLine_5.result(), 107.43, True) SketchConstraintDistance_5 = Sketch_1.setDistance(SketchArc_16.center(), SketchLine_6.result(), 5.7, True) SketchPoint_6 = Sketch_1.addPoint(-95.65000000000001, 15.7) -SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchLine_20.result()) -SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_45") +SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchPoint_6.coordinates(), SketchLine_20.result()) +SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_45") SketchConstraintDistance_6 = Sketch_1.setDistance(SketchArc_15.center(), SketchPoint_6.coordinates(), "5.89*2", True) SketchMultiTranslation_3_objects = [SketchLine_23.result(), SketchArc_13.results()[1], SketchLine_21.result(), SketchArc_14.results()[1], SketchArc_16.results()[1], SketchLine_22.result(), SketchLine_20.result(), SketchArc_15.results()[1]] SketchMultiTranslation_3 = Sketch_1.addTranslation(SketchMultiTranslation_3_objects, SketchArc_13.center(), SketchPoint_6.coordinates(), 6) @@ -293,8 +293,8 @@ SketchLine_25.result().setName("SketchLine_29") SketchLine_24.setName("SketchLine_25") SketchLine_24.result().setName("SketchLine_25") SketchPoint_7 = Sketch_1.addPoint(-107.43, -5.3) -SketchConstraintCoincidence_36 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchLine_23.result()) -SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_46") +SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchPoint_7.coordinates(), SketchLine_23.result()) +SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_46") SketchConstraintDistance_7 = Sketch_1.setDistance(SketchPoint_7.coordinates(), SketchLine_6.result(), 5.3, True) SketchMultiTranslation_4_objects = [SketchLine_20.result(), SketchArc_21.results()[1], SketchLine_22.result(), SketchArc_16.results()[1], SketchLine_41.result(), SketchLine_37.result(), SketchLine_38.result(), SketchArc_33.results()[1], SketchLine_43.result(), SketchLine_24.result(), SketchLine_42.result(), SketchArc_13.results()[1], SketchArc_31.results()[1], SketchLine_36.result(), SketchLine_28.result(), SketchArc_19.results()[1], SketchLine_21.result(), SketchArc_36.results()[1], SketchArc_14.results()[1], SketchArc_24.results()[1], SketchLine_31.result(), SketchArc_32.results()[1], SketchArc_20.results()[1], SketchLine_27.result(), SketchLine_34.result(), SketchArc_30.results()[1], SketchLine_39.result(), SketchArc_25.results()[1], SketchArc_34.results()[1], SketchArc_18.results()[1], SketchLine_40.result(), SketchLine_35.result(), SketchArc_35.results()[1], SketchArc_28.results()[1], SketchLine_32.result(), SketchArc_22.results()[1], SketchArc_26.results()[1], SketchLine_26.result(), SketchLine_30.result(), SketchArc_15.results()[1], SketchLine_33.result(), SketchLine_29.result(), SketchLine_23.result(), SketchLine_25.result(), SketchArc_29.results()[1], SketchArc_23.results()[1], SketchArc_27.results()[1], SketchArc_17.results()[1]] SketchMultiTranslation_4 = Sketch_1.addTranslation(SketchMultiTranslation_4_objects, SketchArc_15.center(), SketchPoint_7.coordinates(), 2) @@ -360,17 +360,17 @@ SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_68.result()) SketchConstraintHorizontal_8 = Sketch_1.setHorizontal(SketchLine_70.result()) SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_69.result()) SketchArc_61 = Sketch_1.addArc(-152.2999999999999, 14.70000000000002, -150.7999999999999, 14.70000000000003, -152.2999999999999, 16.20000000000002, False) -SketchConstraintCoincidence_37 = Sketch_1.setCoincident(SketchArc_61.startPoint(), SketchLine_69.startPoint()) -SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_47") -SketchConstraintCoincidence_38 = Sketch_1.setCoincident(SketchArc_61.endPoint(), SketchLine_68.endPoint()) -SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_50") +SketchConstraintCoincidence_36 = Sketch_1.setCoincident(SketchArc_61.startPoint(), SketchLine_69.startPoint()) +SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_47") +SketchConstraintCoincidence_37 = Sketch_1.setCoincident(SketchArc_61.endPoint(), SketchLine_68.endPoint()) +SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_50") SketchConstraintTangent_5 = Sketch_1.setTangent(SketchArc_61.results()[1], SketchLine_69.result()) SketchConstraintTangent_6 = Sketch_1.setTangent(SketchArc_61.results()[1], SketchLine_68.result()) SketchArc_62 = Sketch_1.addArc(-152.2999999999999, 9.699999999999999, -152.2999999999999, 8.199999999999999, -150.7999999999999, 9.699999999999999, False) -SketchConstraintCoincidence_39 = Sketch_1.setCoincident(SketchArc_62.startPoint(), SketchLine_70.startPoint()) -SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_48") -SketchConstraintCoincidence_40 = Sketch_1.setCoincident(SketchArc_62.endPoint(), SketchLine_69.endPoint()) -SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_51") +SketchConstraintCoincidence_38 = Sketch_1.setCoincident(SketchArc_62.startPoint(), SketchLine_70.startPoint()) +SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_48") +SketchConstraintCoincidence_39 = Sketch_1.setCoincident(SketchArc_62.endPoint(), SketchLine_69.endPoint()) +SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_51") SketchConstraintTangent_7 = Sketch_1.setTangent(SketchArc_62.results()[1], SketchLine_69.result()) SketchConstraintTangent_8 = Sketch_1.setTangent(SketchArc_62.results()[1], SketchLine_70.result()) SketchConstraintDistance_8 = Sketch_1.setDistance(SketchLine_70.startPoint(), SketchLine_68.result(), 8, True) @@ -379,8 +379,8 @@ SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_61.results()[1], 1.5) SketchConstraintEqual_4 = Sketch_1.setEqual(SketchArc_61.results()[1], SketchArc_62.results()[1]) SketchConstraintDistance_10 = Sketch_1.setDistance(SketchLine_70.endPoint(), SketchLine_6.result(), 8.199999999999999, True) SketchPoint_8 = Sketch_1.addPoint(-153.5, -7.799999999999999) -SketchConstraintCoincidence_41 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_2.result()) -SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_53") +SketchConstraintCoincidence_40 = Sketch_1.setCoincident(SketchPoint_8.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_53") SketchConstraintDistance_11 = Sketch_1.setDistance(SketchPoint_8.coordinates(), SketchLine_6.result(), 7.8, True) SketchMultiTranslation_5_objects = [SketchLine_68.result(), SketchArc_61.results()[1], SketchLine_69.result(), SketchArc_62.results()[1], SketchLine_70.result()] SketchMultiTranslation_5 = Sketch_1.addTranslation(SketchMultiTranslation_5_objects, SketchLine_68.startPoint(), SketchPoint_8.coordinates(), 2) @@ -410,23 +410,24 @@ SketchLine_80 = Sketch_1.addLine(-153.4999999999999, 8.199999999999999, -153.5, SketchLine_80.setName("SketchLine_81") SketchLine_80.result().setName("SketchLine_81") SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_2.result(), SketchLine_80.result()) -SketchConstraintCoincidence_42 = Sketch_1.setCoincident(SketchLine_70.endPoint(), SketchLine_80.startPoint()) -SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_54") -SketchConstraintCoincidence_43 = Sketch_1.setCoincident(SketchLine_68.startPoint(), SketchLine_2.endPoint()) -SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_55") +SketchConstraintCoincidence_41 = Sketch_1.setCoincident(SketchLine_70.endPoint(), SketchLine_80.startPoint()) +SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_54") +SketchConstraintCoincidence_42 = Sketch_1.setCoincident(SketchLine_68.startPoint(), SketchLine_2.endPoint()) +SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_55") SketchLine_81 = Sketch_1.addLine(-153.4999999999999, -15.79999999999969, -153.5, -22.70000000003739) SketchLine_81.setName("SketchLine_82") SketchLine_81.result().setName("SketchLine_82") SketchConstraintCollinear_2 = Sketch_1.setCollinear(SketchLine_80.result(), SketchLine_81.result()) -SketchConstraintCoincidence_44 = Sketch_1.setCoincident(SketchLine_81.startPoint(), SketchLine_73.result()) -SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_49") -SketchConstraintCoincidence_45 = Sketch_1.setCoincident(SketchLine_80.endPoint(), SketchPoint_8.result()) -SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_52") +SketchConstraintCoincidence_43 = Sketch_1.setCoincident(SketchLine_81.startPoint(), SketchLine_73.result()) +SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_49") +SketchConstraintCoincidence_44 = Sketch_1.setCoincident(SketchLine_80.endPoint(), SketchPoint_8.result()) +SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_52") SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_80.result()) SketchLine_82 = Sketch_1.addLine(153.5, 16.19999999999975, 153.5, 27.7) SketchLine_82.setName("SketchLine_83") SketchLine_82.result().setName("SketchLine_83") -SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_82.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_45 = Sketch_1.setCoincident(SketchLine_82.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_56") SketchConstraintCollinear_3 = Sketch_1.setCollinear(SketchLine_4.result(), SketchLine_82.result()) SketchConstraintCoincidence_46 = Sketch_1.setCoincident(SketchLine_82.startPoint(), SketchLine_74.result()) SketchConstraintCoincidence_46.setName("SketchConstraintCoincidence_56") @@ -443,7 +444,7 @@ SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_59") SketchLine_84 = Sketch_1.addLine(-153.5, -22.70000000003739, -151.5000000000398, -24.69999999999951) SketchLine_84.setName("SketchLine_85") SketchLine_84.result().setName("SketchLine_85") -SketchConstraintAngle_1 = Sketch_1.setAngleComplementary(SketchLine_84.result(), SketchLine_3.result(), 45) +SketchConstraintAngle_1 = Sketch_1.setAngleComplementary(SketchLine_84.result(), SketchLine_3.result(), 45.0000000000272) SketchConstraintCoincidence_50 = Sketch_1.setCoincident(SketchLine_84.startPoint(), SketchLine_81.endPoint()) SketchConstraintCoincidence_50.setName("SketchConstraintCoincidence_62") SketchConstraintCoincidence_51 = Sketch_1.setCoincident(SketchLine_84.endPoint(), SketchLine_3.startPoint()) @@ -459,14 +460,14 @@ SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_61") SketchConstraintCoincidence_53 = Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_85.result()) SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_63") model.do() -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4e-SketchLine_80e")) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex")) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_83e"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), False) SketchPoint_9 = SketchProjection_3.createdFeature() SketchArc_69 = Sketch_2.addArc(27.70000001097709, 0.85, 27.7, 0, 28.55000001097708, 0.85, False) SketchConstraintCoincidence_54 = Sketch_2.setCoincident(SketchPoint_9.result(), SketchArc_69.startPoint()) SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_64") -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_83"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_83"), False) SketchLine_86 = SketchProjection_4.createdFeature() SketchLine_86.setName("SketchLine_87") SketchLine_86.result().setName("SketchLine_87") @@ -489,13 +490,13 @@ SketchConstraintCoincidence_57.setName("SketchConstraintCoincidence_67") SketchConstraintVertical_7 = Sketch_2.setVertical(SketchLine_88.result()) SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_88.result(), 10) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchArc_69_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_89")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchArc_69_2"), model.selection("EDGE", "Sketch_2/SketchLine_89")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2")], model.selection("EDGE", "PartSet/OX"), 0, 307) -Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3e-SketchLine_86e")) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex")) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) -SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3e-SketchLine_86e"), False) +SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"), False) SketchPoint_10 = SketchProjection_5.createdFeature() -SketchArc_70 = Sketch_3.addArc(-24.69999999999951, 1.85, -24.69999999999928, -3.648414406296559e-014, -26.54999999999951, 1.85, True) +SketchArc_70 = Sketch_3.addArc(-24.69999999999951, 1.85, -24.69999999999928, -3.648414406296559e-14, -26.54999999999951, 1.85, True) SketchConstraintCoincidence_58 = Sketch_3.setCoincident(SketchPoint_10.result(), SketchArc_70.startPoint()) SketchConstraintCoincidence_58.setName("SketchConstraintCoincidence_68") SketchLine_89 = Sketch_3.addLine(-26.54999999999951, 1.85, -24.69999999999951, 1.85) @@ -525,18 +526,18 @@ SketchConstraintVertical_9 = Sketch_3.setVertical(SketchLine_91.result()) SketchConstraintRadius_4 = Sketch_3.setRadius(SketchArc_70.results()[1], "rext_2-ep/2") SketchConstraintLength_7 = Sketch_3.setLength(SketchLine_91.result(), 10) model.do() -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_92"), model.selection("EDGE", "Sketch_3/Edge-SketchArc_70_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_92"), model.selection("EDGE", "Sketch_3/SketchArc_70_2")]) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2")], model.selection("EDGE", "PartSet/OX"), 0, 299) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Extrusion_2_2"), model.selection("FACE", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OX"), -2) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_7r-SketchLine_9r-SketchArc_1_2r-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11r-SketchLine_12r-SketchArc_4_2r-SketchArc_5_2r-SketchLine_13r-SketchLine_14r-SketchArc_6_2r-SketchArc_7_2r-SketchLine_15r-SketchLine_16r-SketchArc_8_2r-SketchLine_17r-SketchArc_9_2r-SketchLine_18r-SketchArc_10_2r-SketchArc_11_2r-SketchLine_19r-SketchLine_20r-SketchArc_12_2r-SketchLine_21r-SketchLine_22r-SketchLine_23r-SketchLine_24r-SketchArc_13_2r-SketchArc_14_2r-SketchArc_15_2r-SketchArc_16_2r-SketchLine_25r-SketchArc_17_2r-SketchLine_26r-SketchArc_18_2r-SketchArc_19_2r-SketchLine_27r-SketchLine_28r-SketchArc_20_2r-SketchLine_29r-SketchLine_30r-SketchLine_31r-SketchLine_32r-SketchArc_21_2r-SketchArc_22_2r-SketchArc_23_2r-SketchArc_24_2r-SketchLine_33r-SketchLine_34r-SketchLine_35r-SketchLine_36r-SketchArc_25_2r-SketchArc_26_2r-SketchArc_27_2r-SketchArc_28_2r-SketchArc_29_2r-SketchArc_30_2r-SketchArc_31_2r-SketchArc_32_2r-SketchLine_37r-SketchLine_38r-SketchLine_39r-SketchLine_40r-SketchLine_41r-SketchLine_42r-SketchLine_43r-SketchLine_44r-SketchArc_33_2r-SketchArc_34_2r-SketchArc_35_2r-SketchArc_36_2r-SketchLine_45r-SketchArc_37_2r-SketchLine_46r-SketchArc_38_2r-SketchLine_47r-SketchLine_48r-SketchLine_49r-SketchArc_39_2r-SketchLine_50r-SketchLine_51r-SketchLine_52r-SketchArc_40_2r-SketchArc_41_2r-SketchLine_53r-SketchLine_54r-SketchArc_42_2r-SketchLine_55r-SketchArc_43_2r-SketchArc_44_2r-SketchArc_45_2r-SketchLine_56r-SketchArc_46_2r-SketchArc_47_2r-SketchLine_57r-SketchLine_58r-SketchArc_48_2r-SketchLine_59r-SketchArc_49_2r-SketchArc_50_2r-SketchArc_51_2r-SketchLine_60r-SketchLine_61r-SketchArc_52_2r-SketchArc_53_2r-SketchLine_62r-SketchArc_54_2r-SketchArc_55_2r-SketchLine_63r-SketchLine_64r-SketchArc_56_2r-SketchLine_65r-SketchLine_66r-SketchLine_67r-SketchLine_68r-SketchArc_57_2r-SketchArc_58_2r-SketchArc_59_2r-SketchArc_60_2r-SketchLine_69f-SketchLine_70f-SketchLine_71f-SketchArc_61_2r-SketchArc_62_2r-SketchLine_72f-SketchArc_63_2r-SketchLine_73f-SketchArc_64_2r-SketchLine_74f-SketchLine_75r-SketchArc_65_2r-SketchLine_76r-SketchArc_66_2r-SketchLine_77r-SketchLine_78r-SketchArc_67_2r-SketchLine_79r-SketchArc_68_2r-SketchLine_80r-SketchLine_81f-SketchLine_82f-SketchLine_83f-SketchLine_84f-SketchLine_85f-SketchLine_86r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_69f-SketchArc_61_2r-SketchLine_70f-SketchArc_62_2r-SketchLine_71f-SketchLine_81f-SketchLine_72f-SketchArc_63_2r-SketchLine_73f-SketchArc_64_2r-SketchLine_74f-SketchLine_82f-SketchLine_85f-SketchLine_3f-SketchLine_86r-SketchLine_4f-SketchLine_80r-SketchArc_68_2r-SketchLine_79r-SketchArc_67_2r-SketchLine_78r-SketchLine_84f-SketchLine_77r-SketchArc_66_2r-SketchLine_76r-SketchArc_65_2r-SketchLine_75r-SketchLine_83f-SketchLine_15r-SketchArc_8_2r-SketchLine_16r-SketchArc_7_2r-SketchArc_2_2r-SketchLine_9r-SketchArc_1_2r-SketchLine_7r-SketchLine_11r-SketchArc_4_2r-SketchLine_12r-SketchArc_3_2r-SketchArc_32_2r-SketchLine_40r-SketchArc_28_2r-SketchLine_36r-SketchArc_24_2r-SketchLine_44r-SketchArc_36_2r-SketchLine_32r-SketchLine_50r-SketchArc_43_2r-SketchLine_54r-SketchArc_41_2r-SketchLine_49r-SketchArc_55_2r-SketchLine_65r-SketchArc_37_2r-SketchLine_13r-SketchArc_6_2r-SketchLine_14r-SketchArc_5_2r-SketchArc_9_2r-SketchLine_18r-SketchArc_10_2r-SketchLine_17r-SketchLine_20r-SketchArc_12_2r-SketchLine_19r-SketchArc_11_2r-SketchArc_29_2r-SketchLine_37r-SketchArc_25_2r-SketchLine_33r-SketchArc_21_2r-SketchLine_41r-SketchArc_33_2r-SketchLine_29r-SketchArc_30_2r-SketchLine_38r-SketchArc_26_2r-SketchLine_34r-SketchArc_22_2r-SketchLine_42r-SketchArc_34_2r-SketchLine_30r-SketchLine_68r-SketchArc_53_2r-SketchLine_61r-SketchArc_58_2r-SketchLine_64r-SketchArc_51_2r-SketchLine_60r-SketchArc_39_2r-SketchArc_50_2r-SketchLine_63r-SketchArc_57_2r-SketchLine_53r-SketchArc_45_2r-SketchLine_56r-SketchArc_42_2r-SketchLine_47r-SketchArc_49_2r-SketchLine_62r-SketchArc_47_2r-SketchLine_52r-SketchArc_52_2r-SketchLine_57r-SketchArc_48_2r-SketchLine_48r-SketchArc_31_2r-SketchLine_39r-SketchArc_27_2r-SketchLine_35r-SketchArc_23_2r-SketchLine_43r-SketchArc_35_2r-SketchLine_31r-SketchArc_59_2r-SketchLine_58r-SketchArc_54_2r-SketchLine_66r-SketchArc_60_2r-SketchLine_59r-SketchArc_46_2r-SketchLine_51r-SketchArc_19_2r-SketchLine_27r-SketchArc_18_2r-SketchLine_26r-SketchArc_17_2r-SketchLine_28r-SketchArc_20_2r-SketchLine_25r-SketchArc_56_2r-SketchLine_67r-SketchArc_38_2r-SketchLine_46r-SketchArc_44_2r-SketchLine_55r-SketchArc_40_2r-SketchLine_45r-SketchArc_15_2r-SketchLine_24r-SketchArc_16_2r-SketchLine_23r-SketchArc_14_2r-SketchLine_22r-SketchArc_13_2r-SketchLine_21r")]) Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Translation_1_2")) SketchCircle_1 = Sketch_4.addCircle(96.50000000003769, 5.5, 1.65) -SketchProjection_6 = Sketch_4.addProjection(model.selection("EDGE", "Translation_1_2/Translated_Edge_1"), False) +SketchProjection_6 = Sketch_4.addProjection(model.selection("EDGE", "Translation_1_2/ME:Translated&Extrusion_2_1/To_Edge"), False) SketchLine_92 = SketchProjection_6.createdFeature() SketchLine_92.setName("SketchLine_93") SketchLine_92.result().setName("SketchLine_93") SketchConstraintDistance_14 = Sketch_4.setDistance(SketchCircle_1.center(), SketchLine_92.result(), 53, True) -SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_2/To_Edge_1"), False) +SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_2/To_Edge"), False) SketchLine_93 = SketchProjection_7.createdFeature() SketchLine_93.setName("SketchLine_94") SketchLine_93.result().setName("SketchLine_94") @@ -560,11 +561,11 @@ SketchConstraintLength_8 = Sketch_4.setLength(SketchLine_95.result(), 67) SketchMultiTranslation_6 = Sketch_4.addTranslation([SketchCircle_1.results()[1]], SketchLine_95.endPoint(), SketchLine_95.startPoint(), 4) [SketchCircle_2, SketchCircle_3, SketchCircle_4] = SketchMultiTranslation_6.translated() model.do() -Face_2_objects = [model.selection("EDGE", "Sketch_4/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_4/Edge-SketchCircle_3_2"), model.selection("WIRE", "Sketch_4/Wire-SketchCircle_2_2f"), model.selection("EDGE", "Sketch_4/Edge-SketchCircle_1_2")] +Face_2_objects = [model.selection("EDGE", "Sketch_4/SketchCircle_4_2"), model.selection("EDGE", "Sketch_4/SketchCircle_3_2"), model.selection("WIRE", "[Sketch_4/SketchCircle_2_2]"), model.selection("EDGE", "Sketch_4/SketchCircle_1_2")] Face_2 = model.addFace(Part_1_doc, Face_2_objects) Partition_1_objects = [model.selection("FACE", "Extrusion_1_1"), model.selection("FACE", "Extrusion_1_2"), model.selection("FACE", "Translation_1_1"), model.selection("FACE", "Translation_1_2"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_2_2"), model.selection("FACE", "Face_2_3"), model.selection("FACE", "Face_2_4")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Remove_SubShapes_1_objects_2 = [model.selection("FACE", "Face_2_1/Face_2_1"), model.selection("FACE", "Face_2_2/Face_2_2"), model.selection("FACE", "Face_2_3/Face_2_3"), model.selection("FACE", "Face_2_4/Face_2_4")] +Remove_SubShapes_1_objects_2 = [model.selection("FACE", "Partition_1_1_5"), model.selection("FACE", "Partition_1_1_6"), model.selection("FACE", "Partition_1_1_7"), model.selection("FACE", "Partition_1_1_8")] Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "Partition_1_1")) Remove_SubShapes_1.setSubShapesToRemove(Remove_SubShapes_1_objects_2) model.do() diff --git a/src/FeaturesPlugin/Test/Test2514.py b/src/FeaturesPlugin/Test/Test2514.py index d8ea46b65..5d15a2555 100644 --- a/src/FeaturesPlugin/Test/Test2514.py +++ b/src/FeaturesPlugin/Test/Test2514.py @@ -88,14 +88,14 @@ SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_16") SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_3.result()) SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_17") model.do() -Edge_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_9")] +Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_9")] Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) Revolution_1_objects = [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4"), model.selection("EDGE", "Edge_1_5"), model.selection("EDGE", "Edge_1_6"), model.selection("EDGE", "Edge_1_7")] Revolution_1 = model.addRevolution(Part_1_doc, Revolution_1_objects, model.selection("EDGE", "PartSet/OZ"), 360, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2e"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex"), False) SketchPoint_1 = SketchProjection_3.createdFeature() -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_9 = SketchProjection_4.createdFeature() SketchLine_9.setName("SketchLine_11") SketchLine_9.result().setName("SketchLine_11") @@ -122,197 +122,198 @@ SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_10.startPoint(), SketchLine_13.endPoint()) SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_22") SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_12.result()) -SketchPoint_2 = Sketch_2.addPoint(-5.903605550615992e-026, -5) -SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_12.result()) -SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_24") +SketchPoint_2 = Sketch_2.addPoint(-5.903605550615992e-26, -5) +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_12.result()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_24") SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchPoint_2.coordinates(), SketchLine_12.result()) -SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) -SketchLine_15 = SketchProjection_6.createdFeature() -SketchLine_15.setName("SketchLine_16") -SketchLine_15.result().setName("SketchLine_16") -SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_15.result()) -SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_25") +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_14 = SketchProjection_5.createdFeature() +SketchLine_14.setName("SketchLine_16") +SketchLine_14.result().setName("SketchLine_16") +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_14.result()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_25") SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_11.endPoint(), SketchLine_10.result(), 2, True) SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_10.result(), 3) SketchConstraintMiddle_2 = Sketch_2.setMiddlePoint(SketchAPI_Line(SketchLine_9).endPoint(), SketchLine_10.result()) SketchConstraintLength_5 = Sketch_2.setLength(SketchLine_12.result(), 2) model.do() -Edge_2_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchLine_12"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_13"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_14"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_10")] +Edge_2_objects = [model.selection("EDGE", "Sketch_2/SketchLine_12"), model.selection("EDGE", "Sketch_2/SketchLine_13"), model.selection("EDGE", "Sketch_2/SketchLine_14"), model.selection("EDGE", "Sketch_2/SketchLine_10")] Edge_2 = model.addEdge(Part_1_doc, Edge_2_objects) Extrusion_1_objects = [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2"), model.selection("EDGE", "Edge_2_3"), model.selection("EDGE", "Edge_2_4")] Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection("EDGE", "PartSet/OY"), 3, 3) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_6")) -SketchLine_16 = Sketch_3.addLine(-15, 0, -10, 2.951677693621839e-024) -SketchLine_16.setName("SketchLine_17") -SketchLine_16.result().setName("SketchLine_17") -SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Revolution_1_6/Generated_Edge_1"), False) -SketchCircle_1 = SketchProjection_7.createdFeature() -SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_16.startPoint(), SketchCircle_1.results()[1]) -SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") -SketchLine_17 = Sketch_3.addLine(-10, 2.951677693621839e-024, -10, -3) -SketchLine_17.setName("SketchLine_18") -SketchLine_17.result().setName("SketchLine_18") +SketchLine_15 = Sketch_3.addLine(-15, 0, -10, 2.951677693621839e-24) +SketchLine_15.setName("SketchLine_17") +SketchLine_15.result().setName("SketchLine_17") +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Revolution_1_6/Generated_Edge&Sketch_1/SketchLine_2_StartVertex"), False) +SketchCircle_1 = SketchProjection_6.createdFeature() +SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_15.startPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_26") +SketchLine_16 = Sketch_3.addLine(-10, 2.951677693621839e-24, -10, -3) +SketchLine_16.setName("SketchLine_18") +SketchLine_16.result().setName("SketchLine_18") +SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_27") +SketchLine_17 = Sketch_3.addLine(-10, -3, -14.69693845669907, -3) +SketchLine_17.setName("SketchLine_19") +SketchLine_17.result().setName("SketchLine_19") SketchConstraintCoincidence_24 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint()) -SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_27") -SketchLine_18 = Sketch_3.addLine(-10, -3, -14.69693845669907, -3) -SketchLine_18.setName("SketchLine_19") -SketchLine_18.result().setName("SketchLine_19") -SketchConstraintCoincidence_25 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint()) -SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_28") -SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchCircle_1.results()[1]) -SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_29") -SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_17.result()) -SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_16.result(), SketchAPI_Circle(SketchCircle_1).center()) -SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_30") -SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_16.result(), SketchLine_18.result()) -SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_16.result(), 5) -SketchConstraintLength_7 = Sketch_3.setLength(SketchLine_17.result(), 3) -SketchConstraintMirror_1 = Sketch_3.addMirror(SketchLine_16.result(), [SketchLine_17.result(), SketchLine_18.result()]) -[SketchLine_19, SketchLine_20] = SketchConstraintMirror_1.mirrored() -SketchLine_20.setName("SketchLine_21") -SketchLine_20.result().setName("SketchLine_21") -SketchLine_19.setName("SketchLine_20") -SketchLine_19.result().setName("SketchLine_20") -SketchLine_21 = Sketch_3.addLine(-1.5, -2, 2, -2) -SketchLine_21.setName("SketchLine_22") -SketchLine_21.result().setName("SketchLine_22") -SketchLine_22 = Sketch_3.addLine(2, -2, 2, 2) -SketchLine_22.setName("SketchLine_23") -SketchLine_22.result().setName("SketchLine_23") +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_28") +SketchConstraintCoincidence_25 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_29") +SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_16.result()) +SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_15.result(), SketchAPI_Circle(SketchCircle_1).center()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_30") +SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_15.result(), SketchLine_17.result()) +SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_15.result(), 5) +SketchConstraintLength_7 = Sketch_3.setLength(SketchLine_16.result(), 3) +SketchConstraintMirror_1 = Sketch_3.addMirror(SketchLine_15.result(), [SketchLine_16.result(), SketchLine_17.result()]) +[SketchLine_18, SketchLine_19] = SketchConstraintMirror_1.mirrored() +SketchLine_19.setName("SketchLine_21") +SketchLine_19.result().setName("SketchLine_21") +SketchLine_18.setName("SketchLine_20") +SketchLine_18.result().setName("SketchLine_20") +SketchLine_20 = Sketch_3.addLine(-1.5, -2, 2, -2) +SketchLine_20.setName("SketchLine_22") +SketchLine_20.result().setName("SketchLine_22") +SketchLine_21 = Sketch_3.addLine(2, -2, 2, 2) +SketchLine_21.setName("SketchLine_23") +SketchLine_21.result().setName("SketchLine_23") +SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_31") +SketchLine_22 = Sketch_3.addLine(2, 2, -1.5, 2) +SketchLine_22.setName("SketchLine_24") +SketchLine_22.result().setName("SketchLine_24") SketchConstraintCoincidence_28 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) -SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_31") -SketchLine_23 = Sketch_3.addLine(2, 2, -1.5, 2) -SketchLine_23.setName("SketchLine_24") -SketchLine_23.result().setName("SketchLine_24") -SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) -SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_32") -SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) -SketchLine_24 = SketchProjection_8.createdFeature() -SketchLine_24.setName("SketchLine_25") -SketchLine_24.result().setName("SketchLine_25") -SketchConstraintCoincidence_30 = Sketch_3.setCoincident(SketchLine_16.startPoint(), SketchLine_24.result()) -SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_33") -SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_23.result()) -SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_21.result()) -SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_22.result()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_32") +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_23 = SketchProjection_7.createdFeature() +SketchLine_23.setName("SketchLine_25") +SketchLine_23.result().setName("SketchLine_25") +SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchLine_15.startPoint(), SketchLine_23.result()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_33") +SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_22.result()) +SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_20.result()) +SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_21.result()) SketchArc_2 = Sketch_3.addArc(0, 0, -1.5, -2, -1.5, 2, True) -SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchAPI_Circle(SketchCircle_1).center(), SketchArc_2.center()) -SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_34") -SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchArc_2.startPoint(), SketchLine_21.startPoint()) -SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_35") -SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchArc_2.endPoint(), SketchLine_23.endPoint()) -SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_36") +SketchConstraintCoincidence_30 = Sketch_3.setCoincident(SketchAPI_Circle(SketchCircle_1).center(), SketchArc_2.center()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_34") +SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchArc_2.startPoint(), SketchLine_20.startPoint()) +SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_35") +SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchArc_2.endPoint(), SketchLine_22.endPoint()) +SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_36") SketchPoint_3 = Sketch_3.addPoint(2, 0) -SketchConstraintCoincidence_34 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_22.result()) -SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_37") -SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_24.result()) -SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_38") -SketchConstraintMiddle_3 = Sketch_3.setMiddlePoint(SketchPoint_3.coordinates(), SketchLine_22.result()) -SketchLine_25 = Sketch_3.addLine(-1.5, -2, -1.5, 2) -SketchLine_25.setName("SketchLine_26") -SketchLine_25.result().setName("SketchLine_26") -SketchLine_25.setAuxiliary(True) -SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_25.startPoint()) -SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_39") -SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_25.endPoint()) -SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_40") -SketchProjection_9 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_12s-SketchLine_10e"), False) -SketchPoint_4 = SketchProjection_9.createdFeature() -SketchConstraintCoincidence_38 = Sketch_3.setCoincident(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_25.result()) -SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_41") -SketchConstraintLength_8 = Sketch_3.setLength(SketchLine_25.result(), 4) -SketchProjection_10 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_10s-SketchLine_14e"), False) -SketchPoint_5 = SketchProjection_10.createdFeature() -SketchConstraintDistance_3 = Sketch_3.setDistance(SketchAPI_Point(SketchPoint_5).coordinates(), SketchLine_22.result(), 0.5, True) -SketchLine_26 = Sketch_3.addLine(-7.5, -7.382311001750988e-022, -7.5, -3) -SketchLine_26.setName("SketchLine_27") -SketchLine_26.result().setName("SketchLine_27") -SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_26.result()) -SketchConstraintCoincidence_39 = Sketch_3.setCoincident(SketchLine_26.startPoint(), SketchLine_16.result()) -SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_42") -SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchLine_26.endPoint(), SketchLine_18.result()) -SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_43") -SketchLine_27 = Sketch_3.addLine(-7.5, -7.382311001750988e-022, -2.500000000000019, -5.187200122832181e-016) -SketchLine_27.setName("SketchLine_28") -SketchLine_27.result().setName("SketchLine_28") -SketchConstraintCoincidence_41 = Sketch_3.setCoincident(SketchLine_26.startPoint(), SketchLine_27.startPoint()) -SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_44") -SketchConstraintCoincidence_42 = Sketch_3.setCoincident(SketchLine_27.endPoint(), SketchArc_2.results()[1]) -SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_45") -SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_27.result()) -SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_17.startPoint(), SketchLine_26.result(), 2.5, True) -SketchLine_28 = Sketch_3.addLine(2, 0, 11, 0) -SketchLine_28.setName("SketchLine_29") -SketchLine_28.result().setName("SketchLine_29") -SketchConstraintCoincidence_43 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_28.startPoint()) -SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_46") -SketchConstraintCoincidence_44 = Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchLine_24.result()) -SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_47") -SketchLine_29 = Sketch_3.addLine(15, 0, 14, 0) -SketchLine_29.setName("SketchLine_30") -SketchLine_29.result().setName("SketchLine_30") -SketchProjection_11 = Sketch_3.addProjection(model.selection("VERTEX", "Revolution_1_6/Generated_Edge_1"), False) -SketchPoint_6 = SketchProjection_11.createdFeature() -SketchConstraintCoincidence_45 = Sketch_3.setCoincident(SketchLine_29.startPoint(), SketchPoint_6.result()) -SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_48") -SketchConstraintCoincidence_46 = Sketch_3.setCoincident(SketchLine_29.endPoint(), SketchLine_24.result()) -SketchConstraintCoincidence_46.setName("SketchConstraintCoincidence_49") -SketchConstraintDistance_5 = Sketch_3.setDistance(SketchLine_28.endPoint(), SketchLine_29.endPoint(), 3, True) -SketchConstraintLength_9 = Sketch_3.setLength(SketchLine_29.result(), 1) -SketchLine_30 = Sketch_3.addLine(11, 0, 11, -2.000000000000004) -SketchLine_30.setName("SketchLine_31") -SketchLine_30.result().setName("SketchLine_31") -SketchConstraintCoincidence_47 = Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchLine_30.startPoint()) -SketchConstraintCoincidence_47.setName("SketchConstraintCoincidence_50") -SketchLine_31 = Sketch_3.addLine(9.500000000000002, 2.627360613063856e-019, 9.5, -2.000000000000004) -SketchLine_31.setName("SketchLine_32") -SketchLine_31.result().setName("SketchLine_32") -SketchConstraintCoincidence_48 = Sketch_3.setCoincident(SketchLine_31.startPoint(), SketchLine_28.result()) -SketchConstraintCoincidence_48.setName("SketchConstraintCoincidence_51") -SketchLine_32 = Sketch_3.addLine(8, -1.882265929199326e-020, 8, -2.000000000000004) -SketchLine_32.setName("SketchLine_33") -SketchLine_32.result().setName("SketchLine_33") -SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_32.startPoint(), SketchLine_28.result()) -SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_52") -SketchLine_33 = Sketch_3.addLine(5, -3.396138881322731e-022, 5, -2.000000000000004) -SketchLine_33.setName("SketchLine_34") -SketchLine_33.result().setName("SketchLine_34") -SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchLine_33.startPoint(), SketchLine_28.result()) -SketchConstraintCoincidence_50.setName("SketchConstraintCoincidence_53") -SketchLine_34 = Sketch_3.addLine(5, -2.000000000000004, 11, -2.000000000000004) -SketchLine_34.setName("SketchLine_35") -SketchLine_34.result().setName("SketchLine_35") -SketchLine_34.setAuxiliary(True) -SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_33.endPoint(), SketchLine_34.startPoint()) -SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_54") -SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_30.endPoint(), SketchLine_34.endPoint()) -SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_55") -SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_33.result()) -SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_32.result()) -SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_31.result()) -#SketchConstraintVertical_9 = Sketch_3.setVertical(SketchLine_30.result()) -SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_34.result()) -SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_32.endPoint(), SketchLine_34.result()) -SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_56") -SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_31.endPoint(), SketchLine_34.result()) -SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_57") -SketchConstraintDistance_6 = Sketch_3.setDistance(SketchLine_21.endPoint(), SketchLine_33.result(), 3, True) -SketchConstraintDistance_7 = Sketch_3.setDistance(SketchLine_33.endPoint(), SketchLine_32.result(), 3, True) -SketchConstraintDistance_8 = Sketch_3.setDistance(SketchLine_32.endPoint(), SketchLine_31.result(), 1.5, True) -SketchConstraintDistance_9 = Sketch_3.setDistance(SketchLine_31.endPoint(), SketchLine_30.result(), 1.5, True) -SketchConstraintCoincidence_55 = Sketch_3.setCoincident(SketchLine_33.endPoint(), SketchLine_21.result()) -SketchConstraintCoincidence_55.setName("SketchConstraintCoincidence_58") -SketchConstraintMirror_2_objects = [SketchLine_33.result(), SketchLine_32.result(), SketchLine_31.result(), SketchLine_30.result()] -SketchConstraintMirror_2 = Sketch_3.addMirror(SketchLine_24.result(), SketchConstraintMirror_2_objects) -[SketchLine_35, SketchLine_36, SketchLine_37, SketchLine_38] = SketchConstraintMirror_2.mirrored() -SketchLine_38.setName("SketchLine_39") -SketchLine_38.result().setName("SketchLine_39") -SketchLine_37.setName("SketchLine_38") -SketchLine_37.result().setName("SketchLine_38") -SketchLine_36.setName("SketchLine_37") -SketchLine_36.result().setName("SketchLine_37") -SketchLine_35.setName("SketchLine_36") -SketchLine_35.result().setName("SketchLine_36") +SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_21.result()) +SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_37") +SketchConstraintCoincidence_34 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_23.result()) +SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_38") +SketchConstraintMiddle_3 = Sketch_3.setMiddlePoint(SketchPoint_3.coordinates(), SketchLine_21.result()) +SketchLine_24 = Sketch_3.addLine(-1.5, -2, -1.5, 2) +SketchLine_24.setName("SketchLine_26") +SketchLine_24.result().setName("SketchLine_26") +SketchLine_24.setAuxiliary(True) +SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_24.startPoint()) +SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_39") +SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.endPoint()) +SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_40") +SketchProjection_8 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_10_EndVertex"), False) +SketchPoint_4 = SketchProjection_8.createdFeature() +SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_24.result()) +SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_41") +SketchConstraintLength_8 = Sketch_3.setLength(SketchLine_24.result(), 4) +SketchProjection_9 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_2/SketchLine_10_StartVertex"), False) +SketchPoint_5 = SketchProjection_9.createdFeature() +SketchConstraintDistance_3 = Sketch_3.setDistance(SketchAPI_Point(SketchPoint_5).coordinates(), SketchLine_21.result(), 0.5, True) +SketchLine_25 = Sketch_3.addLine(-7.5, -7.382311001750988e-22, -7.5, -3) +SketchLine_25.setName("SketchLine_27") +SketchLine_25.result().setName("SketchLine_27") +SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_25.result()) +SketchConstraintCoincidence_38 = Sketch_3.setCoincident(SketchLine_25.startPoint(), SketchLine_15.result()) +SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_42") +SketchConstraintCoincidence_39 = Sketch_3.setCoincident(SketchLine_25.endPoint(), SketchLine_17.result()) +SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_43") +SketchLine_26 = Sketch_3.addLine(-7.5, -7.382311001750988e-22, -2.500000000000019, -5.187200122832181e-16) +SketchLine_26.setName("SketchLine_28") +SketchLine_26.result().setName("SketchLine_28") +SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchLine_25.startPoint(), SketchLine_26.startPoint()) +SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_44") +SketchConstraintCoincidence_41 = Sketch_3.setCoincident(SketchLine_26.endPoint(), SketchArc_2.results()[1]) +SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_45") +SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_26.result()) +SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_16.startPoint(), SketchLine_25.result(), 2.5, True) +SketchLine_27 = Sketch_3.addLine(2, 0, 11, 0) +SketchLine_27.setName("SketchLine_29") +SketchLine_27.result().setName("SketchLine_29") +SketchConstraintCoincidence_42 = Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_27.startPoint()) +SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_46") +SketchConstraintCoincidence_43 = Sketch_3.setCoincident(SketchLine_27.endPoint(), SketchLine_23.result()) +SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_47") +SketchLine_28 = Sketch_3.addLine(15, 0, 14, 0) +SketchLine_28.setName("SketchLine_30") +SketchLine_28.result().setName("SketchLine_30") +SketchProjection_10 = Sketch_3.addProjection(model.selection("VERTEX", "[Revolution_1_6/Revolution_1_6&Sketch_1/SketchLine_2]"), False) +SketchPoint_6 = SketchProjection_10.createdFeature() +SketchConstraintCoincidence_44 = Sketch_3.setCoincident(SketchLine_28.startPoint(), SketchPoint_6.result()) +SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_48") +SketchConstraintCoincidence_45 = Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchLine_23.result()) +SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_49") +SketchConstraintDistance_5 = Sketch_3.setDistance(SketchLine_27.endPoint(), SketchLine_28.endPoint(), 3, True) +SketchConstraintLength_9 = Sketch_3.setLength(SketchLine_28.result(), 1) +SketchLine_29 = Sketch_3.addLine(11, 0, 11, -2.000000000000004) +SketchLine_29.setName("SketchLine_31") +SketchLine_29.result().setName("SketchLine_31") +SketchConstraintCoincidence_46 = Sketch_3.setCoincident(SketchLine_27.endPoint(), SketchLine_29.startPoint()) +SketchConstraintCoincidence_46.setName("SketchConstraintCoincidence_50") +SketchLine_30 = Sketch_3.addLine(9.500000000000002, 2.627360613063856e-19, 9.5, -2.000000000000004) +SketchLine_30.setName("SketchLine_32") +SketchLine_30.result().setName("SketchLine_32") +SketchConstraintCoincidence_47 = Sketch_3.setCoincident(SketchLine_30.startPoint(), SketchLine_27.result()) +SketchConstraintCoincidence_47.setName("SketchConstraintCoincidence_51") +SketchLine_31 = Sketch_3.addLine(8, -1.882265929199326e-20, 8, -2.000000000000004) +SketchLine_31.setName("SketchLine_33") +SketchLine_31.result().setName("SketchLine_33") +SketchConstraintCoincidence_48 = Sketch_3.setCoincident(SketchLine_31.startPoint(), SketchLine_27.result()) +SketchConstraintCoincidence_48.setName("SketchConstraintCoincidence_52") +SketchLine_32 = Sketch_3.addLine(5, -3.396138881322731e-22, 5, -2.000000000000004) +SketchLine_32.setName("SketchLine_34") +SketchLine_32.result().setName("SketchLine_34") +SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_32.startPoint(), SketchLine_27.result()) +SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_53") +SketchLine_33 = Sketch_3.addLine(5, -2.000000000000004, 11, -2.000000000000004) +SketchLine_33.setName("SketchLine_35") +SketchLine_33.result().setName("SketchLine_35") +SketchLine_33.setAuxiliary(True) +SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchLine_32.endPoint(), SketchLine_33.startPoint()) +SketchConstraintCoincidence_50.setName("SketchConstraintCoincidence_54") +SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_29.endPoint(), SketchLine_33.endPoint()) +SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_55") +SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_32.result()) +SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_31.result()) +SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_30.result()) +SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_33.result()) +SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_31.endPoint(), SketchLine_33.result()) +SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_56") +SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_30.endPoint(), SketchLine_33.result()) +SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_57") +SketchConstraintDistance_6 = Sketch_3.setDistance(SketchLine_20.endPoint(), SketchLine_32.result(), 3, True) +SketchConstraintDistance_7 = Sketch_3.setDistance(SketchLine_32.endPoint(), SketchLine_31.result(), 3, True) +SketchConstraintDistance_8 = Sketch_3.setDistance(SketchLine_31.endPoint(), SketchLine_30.result(), 1.5, True) +SketchConstraintDistance_9 = Sketch_3.setDistance(SketchLine_30.endPoint(), SketchLine_29.result(), 1.5, True) +SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_32.endPoint(), SketchLine_20.result()) +SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_58") +SketchConstraintMirror_2_objects = [SketchLine_32.result(), SketchLine_31.result(), SketchLine_30.result(), SketchLine_29.result()] +SketchConstraintMirror_2 = Sketch_3.addMirror(SketchLine_23.result(), SketchConstraintMirror_2_objects) +[SketchLine_34, SketchLine_35, SketchLine_36, SketchLine_37] = SketchConstraintMirror_2.mirrored() +SketchLine_37.setName("SketchLine_39") +SketchLine_37.result().setName("SketchLine_39") +SketchLine_36.setName("SketchLine_38") +SketchLine_36.result().setName("SketchLine_38") +SketchLine_35.setName("SketchLine_37") +SketchLine_35.result().setName("SketchLine_37") +SketchLine_34.setName("SketchLine_36") +SketchLine_34.result().setName("SketchLine_36") +model.do() +model.do() model.end() assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2520.py b/src/FeaturesPlugin/Test/Test2520.py index 206998deb..d12325da3 100644 --- a/src/FeaturesPlugin/Test/Test2520.py +++ b/src/FeaturesPlugin/Test/Test2520.py @@ -29,7 +29,7 @@ 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(7.823413936076148e-032, 6, 18, 6) +SketchLine_1 = Sketch_1.addLine(7.823413936076148e-32, 6, 18, 6) SketchLine_2 = Sketch_1.addLine(18, 6, 18, 10) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) SketchLine_3 = Sketch_1.addLine(18, 10, 63, 10) @@ -46,11 +46,11 @@ SketchLine_8 = Sketch_1.addLine(70, 18, 70, 6.999999999999999) SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchLine_9 = Sketch_1.addLine(70, 6.999999999999999, 38, 6.999999999999999) SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) -SketchLine_10 = Sketch_1.addLine(38, 6.999999999999999, 34, 1.232595164407831e-032) +SketchLine_10 = Sketch_1.addLine(38, 6.999999999999999, 34, 1.232595164407831e-32) SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) -SketchLine_11 = Sketch_1.addLine(34, 1.232595164407831e-032, 7.823413936076148e-032, 1.232595164407831e-032) +SketchLine_11 = Sketch_1.addLine(34, 1.232595164407831e-32, 7.823413936076148e-32, 1.232595164407831e-32) SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) -SketchLine_12 = Sketch_1.addLine(7.823413936076148e-032, 1.232595164407831e-032, 7.823413936076148e-032, 6) +SketchLine_12 = Sketch_1.addLine(7.823413936076148e-32, 1.232595164407831e-32, 7.823413936076148e-32, 6) SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_12.endPoint()) SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_11.result()) @@ -84,7 +84,7 @@ SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_13.startPoint SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_13.result()) SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_8.result()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r-SketchLine_11r-SketchLine_12r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_13"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "Sketch_1/SketchLine_13"), 360, 0) model.do() # check that naming of the revolution is correct model.testHaveNamingSubshapes(Revolution_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/Test2545.py b/src/FeaturesPlugin/Test/Test2545.py index dcc1b884c..1400e32c9 100644 --- a/src/FeaturesPlugin/Test/Test2545.py +++ b/src/FeaturesPlugin/Test/Test2545.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model import math @@ -30,7 +32,7 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchArc_1 = Sketch_1.addArc(-47.73523320343703, -72.31551328948351, 43.26553250145439, -30.85636904935887, -50.76060275488791, 27.63871192924931, False) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "R") model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")]) model.do() radius = model.measureRadius(Part_1_doc, model.selection("EDGE", "Edge_1_1")) diff --git a/src/FeaturesPlugin/Test/Test2588.py b/src/FeaturesPlugin/Test/Test2588.py index b0a4da97f..29eed9c90 100644 --- a/src/FeaturesPlugin/Test/Test2588.py +++ b/src/FeaturesPlugin/Test/Test2588.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -33,10 +35,11 @@ SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_1).coordinates()) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 2) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0) -Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], model.selection("VERTEX", "Sketch_1/Edge-SketchCircle_1_2__cc"), True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], model.selection("VERTEX", "Sketch_1/SketchCircle_1_2__cc"), True) LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "all-in-Symmetry_1")], model.selection("EDGE", "PartSet/OY"), 5, 3) AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-LinearCopy_1")], model.selection("EDGE", "PartSet/OZ"), 45, 8) +model.do() model.end() from GeomAPI import GeomAPI_Shape diff --git a/src/FeaturesPlugin/Test/Test2592.py b/src/FeaturesPlugin/Test/Test2592.py index d102679c5..ba27bbd56 100644 --- a/src/FeaturesPlugin/Test/Test2592.py +++ b/src/FeaturesPlugin/Test/Test2592.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -25,8 +27,9 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom"), True) +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), True) Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1_1")], model.selection("EDGE", "PartSet/OX"), True) +model.do() model.end() # check python dump failed before the bug fix: selection in symmetry 2 changed to the whole symmetry 1 compound diff --git a/src/FeaturesPlugin/Test/Test2596.py b/src/FeaturesPlugin/Test/Test2596.py index 529861ae1..c01c2e3c3 100644 --- a/src/FeaturesPlugin/Test/Test2596.py +++ b/src/FeaturesPlugin/Test/Test2596.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,7 +43,7 @@ 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() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_2/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_1_2")]) model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/Test2617.py b/src/FeaturesPlugin/Test/Test2617.py new file mode 100644 index 000000000..0e50b6d42 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2617.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 5, 10) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cone_1_1")], model.selection("EDGE", "PartSet/OX"), 5) +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OZ"), True) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Symmetry_1_1_2"), model.selection("SOLID", "Symmetry_1_1_1")]) +model.do() +model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Common_1, 1) +model.testNbSubResults(Common_1, [0]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [8]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [16]) +model.testResultsVolumes(Common_1, [461.055845803990962394891539589]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2631.py b/src/FeaturesPlugin/Test/Test2631.py index a254a0723..f3e679e31 100644 --- a/src/FeaturesPlugin/Test/Test2631.py +++ b/src/FeaturesPlugin/Test/Test2631.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -33,18 +35,18 @@ SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_3 = Sketch_2.addLine(31.90519577166173, 58.11303515552675, 60.012153951459, 58.11303515552675) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_4 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchLine_4.result()) SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_4).endPoint(), SketchLine_3.endPoint()) SketchLine_5 = Sketch_2.addLine(60.012153951459, 58.11303515552675, 60.012153951459, 33.0446670492211) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_5.startPoint()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_6 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_5")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_5")]) Cut_1 = model.addCut(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2")], [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2")]) model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/Test2650.py b/src/FeaturesPlugin/Test/Test2650.py index 8d7c256e6..53f6606e5 100644 --- a/src/FeaturesPlugin/Test/Test2650.py +++ b/src/FeaturesPlugin/Test/Test2650.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -37,7 +39,7 @@ SketchLine_5 = Sketch_2.addLine(64.54729867171925, -32.684941224703, 20.69511709 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_5.endPoint()) model.do() -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_6 = Sketch_3.addLine(18.78449167586506, 11.40320166178118, 18.60732592394469, -15.47067574876233) SketchLine_7 = Sketch_3.addLine(18.60732592394469, -15.47067574876233, 57.06415928764967, -9.455161348995592) @@ -48,7 +50,7 @@ SketchLine_9 = Sketch_3.addLine(56.5687276408287, 11.2362868340608, 18.784491675 SketchConstraintCoincidence_7 = Sketch_3.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_8 = Sketch_3.setCoincident(SketchLine_6.startPoint(), SketchLine_9.endPoint()) model.do() -Pipe_1 = model.addPipe(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r"), model.selection("FACE", "Sketch_3/Face-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")]) +Pipe_1 = model.addPipe(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r"), model.selection("FACE", "Sketch_3/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_9f")], model.selection("EDGE", "Sketch_1/SketchLine_1"), [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/Test2681.py b/src/FeaturesPlugin/Test/Test2681.py new file mode 100644 index 000000000..5a74bc03a --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2681.py @@ -0,0 +1,52 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +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.99434204882063, 26.80840312072785, -30.86519895695055, 26.80840312072785) +SketchLine_2 = Sketch_1.addLine(-30.86519895695055, 26.80840312072785, -30.86519895695055, -19.3714637805129) +SketchLine_3 = Sketch_1.addLine(-30.86519895695055, -19.3714637805129, 30.99434204882063, -19.3714637805129) +SketchLine_4 = Sketch_1.addLine(30.99434204882063, -19.3714637805129, 30.99434204882063, 26.80840312072785) +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()) +SketchArc_1 = Sketch_1.addArc(-7.617093567666898, 26.80840312072785, -19.24336125977736, 26.80840312072785, 4.009174124443563, 26.80840312072785, False) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.center()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.endPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0) +model.do() +model.testHaveNamingSubshapes(Extrusion_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2686.py b/src/FeaturesPlugin/Test/Test2686.py new file mode 100644 index 000000000..5367546dc --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2686.py @@ -0,0 +1,216 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from GeomAPI import GeomAPI_Pnt +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "angle", "27.5") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(0, 4, 6.2, 4) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) +SketchLine_3 = Sketch_1.addLine(6.2, 4, 6.2, 2.5) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(6.2, 2.5, 3.5, 2) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(3.5, 2, 3.5, 0) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_6 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result()) +SketchLine_7 = Sketch_1.addLine(3.5, 0, 0, 0) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_7.endPoint()) +SketchLine_8 = Sketch_1.addLine(0, 4, 0, 0) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchLine_8.endPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), 3.5) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 6.2) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 1.5) +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 4) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_5.result(), 2) +model.do() +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", GeomAPI_Pnt(3.1, 0, 2))], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", GeomAPI_Pnt(0, 0, 4))) +SketchCircle_1 = Sketch_2.addCircle(4.027018127601872, 2.325000000002457, 1.1) +SketchCircle_2 = Sketch_2.addCircle(-4.027018127597639, 2.325000000000002, 1.1) +SketchCircle_3 = Sketch_2.addCircle(7.188370358619843e-12, -4.650000000090492, 1.1) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", GeomAPI_Pnt(0, 0, 4)), False) +SketchPoint_1 = SketchProjection_3.createdFeature() +SketchCircle_4 = Sketch_2.addCircle(0, 0, 4.65) +SketchCircle_4.setAuxiliary(True) +SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_4.center()) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_9 = SketchProjection_4.createdFeature() +SketchLine_10 = Sketch_2.addLine(0, 0, 4.027018127601872, 2.325000000002457) +SketchLine_10.setAuxiliary(True) +SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchLine_10.endPoint()) +SketchLine_11 = Sketch_2.addLine(0, 0, -4.027018127597639, 2.325000000000002) +SketchLine_11.setAuxiliary(True) +SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_11.endPoint()) +SketchLine_12 = Sketch_2.addLine(0, 0, 7.188370358619843e-12, -4.650000000090492) +SketchLine_12.setAuxiliary(True) +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchLine_12.endPoint()) +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchCircle_4.results()[1]) +SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchCircle_4.results()[1]) +SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchCircle_4.results()[1]) +SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_4.results()[1], 4.65) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], 1.1) +SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1]) +SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1]) +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(3.1, 0, 4)), False) +SketchLine_13 = SketchProjection_5.createdFeature() +SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_13.result(), SketchLine_10.result(), 30) +SketchConstraintAngle_2 = Sketch_2.setAngle(SketchLine_10.result(), SketchLine_11.result(), 120) +SketchConstraintAngle_3 = Sketch_2.setAngle(SketchLine_11.result(), SketchLine_12.result(), 120) +SketchCircle_5 = Sketch_2.addCircle(4.645574230355638, 0.2028301512488116, 0.8) +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_5.center()) +SketchCircle_6 = Sketch_2.addCircle(4.645574230355638, 0.2028301512488116, 0.65) +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchCircle_6.center()) +SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_6.results()[1], 0.65) +SketchConstraintRadius_4 = Sketch_2.setRadius(SketchCircle_5.results()[1], 0.8) +SketchLine_14 = Sketch_2.addLine(0, 0, 4.645574230355638, 0.2028301512488116) +SketchLine_14.setAuxiliary(True) +SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchCircle_5.center(), SketchLine_14.endPoint()) +SketchConstraintAngle_4 = Sketch_2.setAngle(SketchLine_14.result(), SketchLine_10.result(), "angle") +SketchCircle_7 = Sketch_2.addCircle(2.498443178812738, 3.921770223029927, 0.65) +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_7.center()) +SketchCircle_8 = Sketch_2.addCircle(2.498443178812738, 3.921770223029927, 0.8) +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchCircle_4.results()[1], SketchCircle_8.center()) +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchCircle_8.center()) +SketchConstraintEqual_3 = Sketch_2.setEqual(SketchCircle_6.results()[1], SketchCircle_7.results()[1]) +SketchConstraintEqual_4 = Sketch_2.setEqual(SketchCircle_8.results()[1], SketchCircle_5.results()[1]) +SketchLine_15 = Sketch_2.addLine(0, 0, 2.498443178812738, 3.921770223029927) +SketchLine_15.setAuxiliary(True) +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchCircle_7.center(), SketchLine_15.endPoint()) +SketchConstraintAngle_5 = Sketch_2.setAngle(SketchLine_10.result(), SketchLine_15.result(), "angle") +SketchMultiRotation_1 = Sketch_2.addRotation([SketchCircle_8.results()[1], SketchCircle_5.results()[1]], SketchCircle_4.center(), 360, 3, True) +[SketchCircle_9, SketchCircle_10, SketchCircle_11, SketchCircle_12] = SketchMultiRotation_1.rotated() +SketchCircle_12.setName("SketchCircle_13") +SketchCircle_12.result().setName("SketchCircle_13") +SketchCircle_12.results()[1].setName("SketchCircle_13_2") +SketchCircle_11.setName("SketchCircle_12") +SketchCircle_11.result().setName("SketchCircle_12") +SketchCircle_11.results()[1].setName("SketchCircle_12_2") +SketchMultiRotation_2 = Sketch_2.addRotation([SketchCircle_6.results()[1], SketchCircle_7.results()[1]], SketchAPI_Line(SketchLine_9).startPoint(), 120, 2) +[SketchCircle_13, SketchCircle_14] = SketchMultiRotation_2.rotated() +SketchCircle_14.setName("SketchCircle_17") +SketchCircle_14.result().setName("SketchCircle_17") +SketchCircle_14.results()[1].setName("SketchCircle_17_2") +SketchCircle_13.setName("SketchCircle_14") +SketchCircle_13.result().setName("SketchCircle_14") +SketchCircle_13.results()[1].setName("SketchCircle_14_2") +SketchCircle_15 = Sketch_2.addCircle(0, 5, 0.45) +SketchCircle_15.setName("SketchCircle_15") +SketchCircle_15.result().setName("SketchCircle_15") +SketchCircle_15.results()[1].setName("SketchCircle_15_2") +SketchLine_16 = Sketch_2.addLine(0, 0, 0, 5) +SketchLine_16.setAuxiliary(True) +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_16.startPoint()) +SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchCircle_15.center(), SketchLine_16.endPoint()) +SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_16.result(), 5) +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_17 = SketchProjection_6.createdFeature() +SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchCircle_15.center(), SketchLine_17.result()) +SketchConstraintRadius_5 = Sketch_2.setRadius(SketchCircle_15.results()[1], 0.45) +SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(-6.2, 7.59281015471359e-16, 4)), False) +SketchCircle_16 = SketchProjection_7.createdFeature() +SketchCircle_16.setName("SketchCircle_16") +SketchCircle_16.result().setName("SketchCircle_16") +SketchCircle_16.results()[1].setName("SketchCircle_16_2") +SketchCircle_17 = Sketch_2.addCircle(4.259590630302756, -2.982597469025441, 0.5) +SketchCircle_17.setName("SketchCircle_18") +SketchCircle_17.result().setName("SketchCircle_18") +SketchCircle_17.results()[1].setName("SketchCircle_18_2") +SketchCircle_18 = Sketch_2.addCircle(3.276608177155966, -2.294305745404186, 0.3) +SketchCircle_18.setName("SketchCircle_19") +SketchCircle_18.result().setName("SketchCircle_19") +SketchCircle_18.results()[1].setName("SketchCircle_19_2") +SketchLine_18 = Sketch_2.addLine(0, 0, 4.259590630302756, -2.982597469025441) +SketchLine_18.setAuxiliary(True) +SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchCircle_17.center(), SketchLine_18.endPoint()) +SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchCircle_18.center(), SketchLine_18.result()) +SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", GeomAPI_Pnt(3.1, 0, 4)), False) +SketchLine_19 = SketchProjection_8.createdFeature() +SketchConstraintAngle_6 = Sketch_2.setAngleBackward(SketchLine_19.result(), SketchLine_18.result(), 35) +SketchConstraintRadius_6 = Sketch_2.setRadius(SketchCircle_17.results()[1], 0.5) +SketchConstraintRadius_7 = Sketch_2.setRadius(SketchCircle_18.results()[1], 0.3) +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchCircle_4.center(), SketchCircle_18.center(), 4, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_4.center(), SketchLine_18.endPoint(), 5.2, True) +model.do() +ExtrusionCut_1_objects_1 = [model.selection("WIRE", GeomAPI_Pnt(2.927018127601872, 2.325000000002457, 4)), model.selection("WIRE", GeomAPI_Pnt(1.848443178812738, 3.921770223029927, 4)), model.selection("WIRE", GeomAPI_Pnt(3.995574230355639, 0.2028301512488117, 4)), model.selection("WIRE_2", GeomAPI_Pnt(-3.148443178812729, 3.921770223029919, 4)), model.selection("WIRE", GeomAPI_Pnt(-5.127018127597639, 2.325000000000002, 4)), model.selection("WIRE_2", GeomAPI_Pnt(-5.29557423035565, 0.2028301512488154, 4)), model.selection("FACE", GeomAPI_Pnt(7.188472039842964e-12, -4.650000000090492, 4)), model.selection("FACE", GeomAPI_Pnt(4.259590630302756, -2.982597469025441, 4)), model.selection("FACE", GeomAPI_Pnt(3.276608177155966, -2.294305745404186, 4))] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", GeomAPI_Pnt(0, 0, 0)), 0, model.selection(), 0, [model.selection("SOLID", GeomAPI_Pnt(-7.561538823095622e-16, 6.008767139946657e-17, 2.62684985301323))]) +ExtrusionCut_2_objects_1 = [model.selection("WIRE", GeomAPI_Pnt(-5.44557423035565, 0.2028301512488154, 4)), model.selection("WIRE", GeomAPI_Pnt(-3.298443178812729, 3.921770223029919, 4)), model.selection("WIRE", GeomAPI_Pnt(1.698443178812738, 3.921770223029927, 4)), model.selection("WIRE", GeomAPI_Pnt(3.845574230355639, 0.2028301512488117, 4))] +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", GeomAPI_Pnt(0.06663461012735418, 0.05143712897449785, 2.675990079155852))]) +Axis_4 = model.addAxis(Part_1_doc, 0, -1, -10) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", GeomAPI_Pnt(-0.45, 5, 4))], model.selection("EDGE", GeomAPI_Pnt(0, -0.5, -5)), 10, 10, [model.selection("SOLID", GeomAPI_Pnt(0.06614791498027658, 0.06612435067467369, 2.67762623401837))]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", GeomAPI_Pnt(-2.14713105154291, -4.124600374278729, 4)), model.selection("FACE", GeomAPI_Pnt(2.14713105154291, -4.124600374278742, 4))], model.selection(), model.selection("FACE", GeomAPI_Pnt(0, 0, 0)), 0, model.selection(), 0) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_20 = Sketch_3.addLine(3.5, 2.508501119175777, 3.5, 4) +SketchLine_21 = Sketch_3.addLine(3.5, 4, 6.2, 4) +SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +SketchLine_22 = Sketch_3.addLine(6.2, 4, 6.2, 3.008501119175777) +SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) +SketchLine_23 = Sketch_3.addLine(6.2, 3.008501119175777, 3.5, 2.508501119175777) +SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) +SketchConstraintCoincidence_38 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_20.startPoint()) +SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_20.result()) +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE_9", GeomAPI_Pnt(3.5, 0, 1)), False) +SketchLine_24 = SketchProjection_9.createdFeature() +SketchConstraintCoincidence_39 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_24.result()) +SketchProjection_10 = Sketch_3.addProjection(model.selection("EDGE_3", GeomAPI_Pnt(4.85, 0, 2.25)), False) +SketchLine_25 = SketchProjection_10.createdFeature() +SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_23.result(), SketchLine_25.result()) +SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_22.result()) +SketchProjection_11 = Sketch_3.addProjection(model.selection("EDGE_9", GeomAPI_Pnt(6.2, 0, 3.25)), False) +SketchLine_26 = SketchProjection_11.createdFeature() +SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchLine_23.startPoint(), SketchLine_26.result()) +SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_21.result()) +SketchConstraintDistance_3 = Sketch_3.setDistance(SketchLine_20.startPoint(), SketchLine_25.result(), 0.5, True) +SketchProjection_12 = Sketch_3.addProjection(model.selection("EDGE_5", GeomAPI_Pnt(3.1, 0, 4)), False) +SketchLine_27 = SketchProjection_12.createdFeature() +SketchConstraintCoincidence_41 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_27.result()) +model.do() +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", GeomAPI_Pnt(4.850000000000001, 0, 3.254250559587889))], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", GeomAPI_Pnt(-2.14713105154291, -4.124600374278729, 2)), model.selection("SOLID", GeomAPI_Pnt(2.14713105154291, -4.124600374278742, 2))], [model.selection("SOLID", GeomAPI_Pnt(-1.278142456973851e-15, 2.734224632526547e-16, 3.386836255166113))]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", GeomAPI_Pnt(0.06552679693747457, 0.1115566065149892, 2.681859907222054))], [model.selection("SOLID", GeomAPI_Pnt(-2.134018078943279, -4.099410579753945, 3.358593616213623)), model.selection("SOLID", GeomAPI_Pnt(2.134018071503405, -4.099410583757958, 3.358593616233432))]) +model.do() +model.testHaveNamingSubshapes(Cut_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2689.py b/src/FeaturesPlugin/Test/Test2689.py new file mode 100644 index 000000000..76986e724 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2689.py @@ -0,0 +1,100 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +model.addParameter(partSet, "hh", "20") +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-14.44396674123619, 36.663, -34.44396674123619, 36.663) +SketchLine_2 = Sketch_1.addLine(-34.44396674123619, 36.663, -34.44396674123619, 14.29964516129033) +SketchLine_3 = Sketch_1.addLine(-34.44396674123619, 14.29964516129033, -14.44396674123619, 14.29964516129033) +SketchLine_4 = Sketch_1.addLine(-14.44396674123619, 14.29964516129033, -14.44396674123619, 36.663) +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()) +SketchLine_5 = Sketch_1.addLine(34.94274193548387, 39.45841935483872, 18.60029032258063, 39.45841935483872) +SketchLine_6 = Sketch_1.addLine(18.60029032258063, 39.45841935483872, 18.60029032258063, 13.00945161290323) +SketchLine_7 = Sketch_1.addLine(18.60029032258063, 13.00945161290323, 34.94274193548387, 13.00945161290323) +SketchLine_8 = Sketch_1.addLine(34.94274193548387, 13.00945161290323, 34.94274193548387, 39.45841935483872) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_6.result()) +SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_8.result()) +SketchLine_9 = Sketch_1.addLine(-7.633645161290328, -5.05325806451613, -33.00745161290323, -5.05325806451613) +SketchLine_10 = Sketch_1.addLine(-33.00745161290323, -5.05325806451613, -33.00745161290323, -31.71725806451613) +SketchLine_11 = Sketch_1.addLine(-33.00745161290323, -31.71725806451613, -7.633645161290328, -31.71725806451613) +SketchLine_12 = Sketch_1.addLine(-7.633645161290328, -31.71725806451613, -7.633645161290328, -5.05325806451613) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_9.result()) +SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_10.result()) +SketchConstraintHorizontal_6 = Sketch_1.setHorizontal(SketchLine_11.result()) +SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_12.result()) +SketchLine_13 = Sketch_1.addLine(36.44796774193549, -7.848677419354839, 19.46041935483872, -7.848677419354839) +SketchLine_14 = Sketch_1.addLine(19.46041935483872, -7.848677419354839, 19.46041935483872, -34.29764516129033) +SketchLine_15 = Sketch_1.addLine(19.46041935483872, -34.29764516129033, 36.44796774193549, -34.29764516129033) +SketchLine_16 = Sketch_1.addLine(36.44796774193549, -34.29764516129033, 36.44796774193549, -7.848677419354839) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_13.result()) +SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_14.result()) +SketchConstraintHorizontal_8 = Sketch_1.setHorizontal(SketchLine_15.result()) +SketchConstraintVertical_8 = Sketch_1.setVertical(SketchLine_16.result()) +SketchCircle_1 = Sketch_1.addCircle(-24.6211935483871, 23.331, 4.515677419354841) +SketchCircle_2 = Sketch_1.addCircle(27.20158064516131, 20.96564516129033, 4.091267733479863) +SketchCircle_3 = Sketch_1.addCircle(-16.23493548387097, -18.60029032258065, 7.50151366286372) +SketchCircle_4 = Sketch_1.addCircle(27.84667741935485, -22.90093548387097, 5.414373911476542) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "hh") +model.do() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "hh", "15") +model.addParameter(Part_1_doc, "hh_1", "26") +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchCircle_1_2r")], model.selection(), "hh", 0) +Extrusion_2_objects = [model.selection("WIRE", "PartSet/Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchCircle_1_2r_wire"), model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchCircle_2_2r"), model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchLine_16f-SketchCircle_4_2r"), model.selection("FACE", "PartSet/Sketch_1/Face-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_12f-SketchCircle_3_2r")] +Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), 10, "hh_1") +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_4"), model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OX"), 40) +Fuse_1_objects_1 = [model.selection("SOLID", "Translation_1_2"), model.selection("SOLID", "Translation_1_1"), model.selection("SOLID", "Extrusion_2_1")] +Fuse_1 = model.addFuse(Part_1_doc, Fuse_1_objects_1) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_3")], model.selection("EDGE", "PartSet/OX"), 30) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_2_2"), model.selection("SOLID", "Translation_2_1")]) +model.do() +model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) +model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2692.py b/src/FeaturesPlugin/Test/Test2692.py new file mode 100644 index 000000000..d7dff2aba --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2692.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OY"), 20, 3) +ExtrusionCut_1_objects_2 = [model.selection("SOLID", "LinearCopy_1_1_2"), model.selection("SOLID", "LinearCopy_1_1_1"), model.selection("SOLID", "LinearCopy_1_1_3")] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 10, ExtrusionCut_1_objects_2) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "LinearCopy_1_1_2/MF:Translated_Face&Box_1_1/Top")) +SketchCircle_1 = Sketch_1.addCircle(4.871972805908816, 24.69028692663239, 2.754280056405151) +SketchCircle_2 = Sketch_1.addCircle(4.956613458332676, 4.459837610261877, 1.82794741094275) +SketchCircle_3 = Sketch_1.addCircle(4.842959508111481, 44.32940059836771, 3.136980464700132) +ExtrusionCut_1.setNestedSketch(Sketch_1) +model.do() +model.testHaveNamingSubshapes(ExtrusionCut_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(ExtrusionCut_1, 1) +model.testNbSubResults(ExtrusionCut_1, [3]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.FACE, [21]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [90]) +model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [180]) +model.testResultsVolumes(ExtrusionCut_1, [2347.550996571865198347950354218]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2693.py b/src/FeaturesPlugin/Test/Test2693.py new file mode 100644 index 000000000..1f96da5f7 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2693.py @@ -0,0 +1,156 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +model.addParameter(partSet, "hh", "20") +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(-17.23654191510748, 16.36770059625795, -4.760492650097712, 19.4251823602345) +SketchLine_2 = Sketch_1.addLine(20, 2.414080216212369e-15, 20, -31) +SketchLine_3 = Sketch_1.addLine(2.928932188134523, -38.07106781186548, -8.677669529663685, -26.46446609406726) +SketchLine_4 = Sketch_1.addLine(-12.21320343559642, -25, -20.00000000000047, -25) +SketchArc_1 = Sketch_1.addArc(10, -31, 20, -31, 2.928932188134523, -38.07106781186548, True) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2") +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_2.result(), SketchArc_1.results()[1]) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3") +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_3.result(), SketchArc_1.results()[1]) +SketchArc_2 = Sketch_1.addArc(-12.21320343559642, -30, -8.677669529663685, -26.46446609406726, -12.21320343559642, -25, False) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_3.endPoint()) +SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4") +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5") +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_4.result()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_3.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchArc_3 = Sketch_1.addArc(5.671735138196638e-24, 3.298692290329323e-23, -4.760492650097712, 19.4251823602345, 20, 2.414080216212369e-15, True) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_3.startPoint()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6") +SketchConstraintTangent_5 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_3.results()[1]) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7") +SketchConstraintTangent_6 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_2.result()) +SketchArc_4 = Sketch_1.addArc(-12, -5, -22.35294117647118, -24.41176470588231, -17.23654191510748, 16.36770059625795, True) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_9") +SketchConstraintTangent_7 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_1.result()) +SketchConstraintTangent_7.setName("SketchConstraintTangent_8") +SketchCircle_1 = Sketch_1.addCircle(-22, -5, 7.5) +SketchCircle_2 = Sketch_1.addCircle(5.671735138196638e-24, 3.298692290329323e-23, 10) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_3.center(), SketchCircle_2.center()) +SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_10") +SketchCircle_3 = Sketch_1.addCircle(7, -25, 7.5) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 10) +SketchConstraintRadius_1.setName("SketchConstraintRadius_2") +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_4.result(), SketchLine_3.result(), 134.9999999999999) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 5) +SketchConstraintRadius_2.setName("SketchConstraintRadius_3") +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_4.results()[1], 22) +SketchConstraintRadius_3.setName("SketchConstraintRadius_4") +SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_3.results()[1], 20) +SketchConstraintRadius_4.setName("SketchConstraintRadius_5") +SketchPoint_1 = Sketch_1.addPoint(-20.00000000000047, -25) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_4.endPoint()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_12") +SketchArc_5 = Sketch_1.addArc(-20.00000000000047, -20, -20.00000000000047, -25, -22.35294117647118, -24.41176470588231, True) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchArc_5.startPoint()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11") +SketchConstraintTangent_8 = Sketch_1.setTangent(SketchLine_4.result(), SketchArc_5.results()[1]) +SketchConstraintTangent_8.setName("SketchConstraintTangent_9") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchArc_5.endPoint()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_13") +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchArc_4.center(), SketchCircle_2.center(), 12) +SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchCircle_1.center(), SketchArc_3.center(), 22) +SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchArc_3.center(), SketchArc_4.center(), 5) +SketchLine_5 = Sketch_1.addLine(-22, -5, -12, -5) +SketchLine_5.setAuxiliary(True) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_4.center(), SketchLine_5.endPoint()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15") +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result()) +SketchConstraintRadius_5 = Sketch_1.setRadius(SketchCircle_1.results()[1], 7.5) +SketchConstraintRadius_5.setName("SketchConstraintRadius_6") +SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchCircle_2.center(), SketchCircle_3.center(), 7) +SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchCircle_2.center(), SketchCircle_3.center(), 25) +SketchConstraintDistanceVertical_3 = Sketch_1.setVerticalDistance(SketchArc_3.center(), SketchArc_1.center(), 31) +SketchConstraintRadius_6 = Sketch_1.setRadius(SketchCircle_3.results()[1], 7.5) +SketchConstraintRadius_6.setName("SketchConstraintRadius_7") +SketchConstraintRadius_7 = Sketch_1.setRadius(SketchCircle_2.results()[1], 10) +SketchConstraintRadius_7.setName("SketchConstraintRadius_8") +SketchConstraintRadius_8 = Sketch_1.setRadius(SketchArc_5.results()[1], 5) +SketchConstraintRadius_8.setName("SketchConstraintRadius_9") +SketchConstraintTangent_9 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_5.results()[1]) +SketchConstraintTangent_9.setName("SketchConstraintTangent_10") +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_2 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_3.center(), SketchAPI_Point(SketchPoint_2).coordinates()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_16") +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_5.startPoint(), SketchLine_4.result(), 20, True) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_4_2f-SketchArc_5_2f-SketchLine_4r-SketchArc_2_2r-SketchLine_3r-SketchArc_1_2f-SketchLine_2r-SketchArc_3_2f-SketchLine_1r-SketchCircle_1_2r-SketchCircle_2_2r-SketchCircle_3_2r")], model.selection(), 6.5, 0) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 100, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2")) +SketchLine_6 = Sketch_2.addLine(12.25, 6.5, -12.25, 6.5) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) +SketchLine_7 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.result()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_17") +SketchLine_8 = Sketch_2.addLine(-12.25, 6.5, -12.25, 4.5) +SketchLine_9 = Sketch_2.addLine(-12.25, 4.5, 12.25, 4.5) +SketchLine_10 = Sketch_2.addLine(12.25, 4.5, 12.25, 6.5) +SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_18") +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_19") +SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20") +SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_21") +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_6.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_8.result()) +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_9.result()) +SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_10.result()) +SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_9.result(), 24.5) +SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_8.result(), 2) +SketchPoint_3 = Sketch_2.addPoint(2.442490654175344e-15, 6.499999999999999) +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_6.result()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_22") +SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchPoint_3.coordinates(), SketchLine_6.result()) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2]"), False) +SketchLine_11 = SketchProjection_3.createdFeature() +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_11.result()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_23") +ExtrusionCut_1.setNestedSketch(Sketch_2) +model.do() +model.testHaveNamingSubshapes(ExtrusionCut_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2698.py b/src/FeaturesPlugin/Test/Test2698.py new file mode 100644 index 000000000..44b5dea52 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2698.py @@ -0,0 +1,351 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +model.addParameter(partSet, "hh", "20") +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(0, -3.45, 0, -6.45) +SketchLine_2 = Sketch_1.addLine(0, -6.45, 7.781999999999999, -6.45) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(7.781999999999999, -6.45, 7.781999999999999, -3.45) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(7.781999999999999, -3.45, 6.537999941088452, -3.45) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(6.537999941088452, -3.45, 6.537999999999999, -2.4) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(6.537999999999999, -2.4, 6.375999999999999, -2.25) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_1.addLine(6.375999999999999, -2.25, 6.375999999999999, 9.025) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchLine_8 = Sketch_1.addLine(6.375999999999999, 9.025, 6.537999999999998, 9.186999999999999) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchLine_9 = Sketch_1.addLine(6.537999999999998, 9.186999999999999, 6.537999999999998, 10.256) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchLine_10 = Sketch_1.addLine(6.537999999999998, 10.256, 6.187999999999998, 10.256) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchLine_11 = Sketch_1.addLine(6.187999999999998, 10.256, 4.9175, 10.94235984621995) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_12 = SketchProjection_1.createdFeature() +SketchArc_1 = Sketch_1.addArc(0, 2.425, 0, 12.26, 4.9175, 10.94235984621995, True) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_12.result(), SketchArc_1.center()) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_12.result(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchArc_1.endPoint()) +SketchLine_13 = Sketch_1.addLine(0, 12.26, 0, 12.096) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_13.startPoint()) +SketchLine_14 = Sketch_1.addLine(0, -3.45, 6.187999958006518, -3.45) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_14.startPoint()) +SketchLine_15 = Sketch_1.addLine(6.187999958006518, -3.45, 6.188, 9.025) +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) +SketchLine_16 = Sketch_1.addLine(6.188, 9.025, 6.082, 9.532) +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_14.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_2.result()) +SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_10.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_9.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_7.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_15.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_14.result()) +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_12.result()) +SketchConstraintVertical_6 = Sketch_1.setVertical(SketchLine_1.result()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_14.endPoint(), SketchLine_5.result(), 0.35, True) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_6.endPoint(), SketchLine_15.result(), 0.188, True) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 3) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_17 = SketchProjection_2.createdFeature() +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_17.result(), 3.45, True) +SketchConstraintDistance_4 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_15.result(), 6.188, True) +SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_17.result(), 9.025, True) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_12.result()) +SketchLine_18 = Sketch_1.addLine(6.188, 9.025, 6.375999999999999, 9.025) +SketchLine_18.setAuxiliary(True) +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_18.endPoint()) +SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_18.result()) +SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_10.startPoint(), SketchLine_17.result(), 10.256, True) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_10.result(), 0.35) +SketchConstraintAngle_1 = Sketch_1.setAngleComplementary(SketchLine_18.result(), SketchLine_8.result(), 45) +SketchConstraintDistance_7 = Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_17.result(), 9.186999999999999, True) +SketchConstraintDistance_8 = Sketch_1.setDistance(SketchLine_16.endPoint(), SketchLine_15.result(), 0.106, True) +SketchConstraintDistance_9 = Sketch_1.setDistance(SketchLine_16.endPoint(), SketchLine_17.result(), 9.532, True) +SketchArc_2 = Sketch_1.addArc(4.793786120242238, 9.263, 6.082, 9.532, 5.676067550792405, 10.23944020672409, False) +SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchArc_2.startPoint()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_2.results()[1], 1.316) +SketchConstraintDistance_10 = Sketch_1.setDistance(SketchArc_2.center(), SketchLine_17.result(), 9.263, True) +SketchLine_19 = Sketch_1.addLine(4.793786120242238, 9.263, 6.082, 9.532) +SketchLine_19.setAuxiliary(True) +SketchConstraintCoincidence_24 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_19.startPoint()) +SketchConstraintCoincidence_25 = Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_19.endPoint()) +SketchLine_20 = Sketch_1.addLine(4.793786120242238, 9.263, 5.676067550792405, 10.23944020672409) +SketchLine_20.setAuxiliary(True) +SketchConstraintCoincidence_26 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_20.startPoint()) +SketchConstraintCoincidence_27 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_20.endPoint()) +SketchLine_21 = Sketch_1.addLine(4.793786120242238, 9.263, 4.79378612024245, 10.72808112087842) +SketchLine_21.setAuxiliary(True) +SketchConstraintCoincidence_28 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_21.startPoint()) +SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_21.result()) +SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_20.result(), SketchLine_21.result(), 42.09999999999906) +SketchLine_22 = Sketch_1.addLine(5.676067550792282, 10.23944020672395, 5.404900443923878, 10.43809443685872) +SketchConstraintCoincidence_29 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_22.startPoint()) +SketchLine_23 = Sketch_1.addLine(5.404900443923878, 10.43809443685872, 5.12663857042824, 10.62933672216996) +SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) +SketchLine_24 = Sketch_1.addLine(5.12663857042824, 10.62933672216996, 4.835500000000001, 10.80033167999931) +SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint()) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_13.result(), "0.082*2") +SketchArc_3 = Sketch_1.addArc(0, 2.425, 0, 12.096, 4.835500000000001, 10.80033167999931, True) +SketchConstraintCoincidence_32 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_3.center()) +SketchConstraintCoincidence_33 = Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchArc_3.startPoint()) +SketchConstraintCoincidence_34 = Sketch_1.setCoincident(SketchLine_24.endPoint(), SketchArc_3.endPoint()) +SketchConstraintDistance_11 = Sketch_1.setDistance(SketchArc_1.center(), SketchLine_17.result(), 2.425, True) +SketchLine_25 = Sketch_1.addLine(0, 2.425, 4.9175, 10.94235984621995) +SketchLine_25.setName("SketchLine_26") +SketchLine_25.result().setName("SketchLine_26") +SketchLine_25.setAuxiliary(True) +SketchConstraintCoincidence_35 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_25.startPoint()) +SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_37") +SketchConstraintCoincidence_36 = Sketch_1.setCoincident(SketchLine_25.endPoint(), SketchLine_11.result()) +SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_38") +SketchConstraintCoincidence_37 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_25.result()) +SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_39") +SketchLine_26 = Sketch_1.addLine(0, 2.425, 5.220090907696442, 10.77889172431985) +SketchLine_26.setName("SketchLine_27") +SketchLine_26.result().setName("SketchLine_27") +SketchLine_26.setAuxiliary(True) +SketchConstraintCoincidence_38 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_26.startPoint()) +SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_40") +SketchConstraintCoincidence_39 = Sketch_1.setCoincident(SketchLine_26.endPoint(), SketchLine_11.result()) +SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_41") +SketchConstraintCoincidence_40 = Sketch_1.setCoincident(SketchLine_24.startPoint(), SketchLine_26.result()) +SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_42") +SketchLine_27 = Sketch_1.addLine(0, 2.425, 5.524022094217663, 10.61469954608912) +SketchLine_27.setName("SketchLine_28") +SketchLine_27.result().setName("SketchLine_28") +SketchLine_27.setAuxiliary(True) +SketchConstraintCoincidence_41 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_27.startPoint()) +SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_43") +SketchConstraintCoincidence_42 = Sketch_1.setCoincident(SketchLine_27.endPoint(), SketchLine_11.result()) +SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_44") +SketchConstraintCoincidence_43 = Sketch_1.setCoincident(SketchLine_27.result(), SketchLine_23.startPoint()) +SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_45") +SketchConstraintCoincidence_44 = Sketch_1.setCoincident(SketchLine_25.endPoint(), SketchArc_1.endPoint()) +SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_46") +SketchConstraintAngle_3 = Sketch_1.setAngle(SketchLine_25.result(), SketchLine_12.result(), 30.00000000000003) +SketchConstraintAngle_4 = Sketch_1.setAngle(SketchLine_26.result(), SketchLine_12.result(), 32.00000000000001) +SketchConstraintAngle_5 = Sketch_1.setAngle(SketchLine_27.result(), SketchLine_12.result(), 33.99999999999999) +SketchConstraintDistance_12 = Sketch_1.setDistance(SketchLine_23.endPoint(), SketchLine_11.result(), "0.088*2", True) +SketchConstraintDistance_13 = Sketch_1.setDistance(SketchLine_22.endPoint(), SketchLine_11.result(), "0.106*2", True) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_1.results()[1], 9.835000000000001) +SketchLine_28 = Sketch_1.addLine(7.031999999999999, -4.05, 5.531999999999999, -4.05) +SketchLine_28.setName("SketchLine_29") +SketchLine_28.result().setName("SketchLine_29") +SketchLine_29 = Sketch_1.addLine(5.531999999999999, -4.05, 5.531999999999999, -5.85) +SketchLine_29.setName("SketchLine_30") +SketchLine_29.result().setName("SketchLine_30") +SketchLine_30 = Sketch_1.addLine(5.531999999999999, -5.85, 7.031999999999999, -5.85) +SketchLine_30.setName("SketchLine_31") +SketchLine_30.result().setName("SketchLine_31") +SketchLine_31 = Sketch_1.addLine(7.031999999999999, -5.85, 7.031999999999999, -4.05) +SketchLine_31.setName("SketchLine_32") +SketchLine_31.result().setName("SketchLine_32") +SketchConstraintCoincidence_45 = Sketch_1.setCoincident(SketchLine_31.endPoint(), SketchLine_28.startPoint()) +SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_47") +SketchConstraintCoincidence_46 = Sketch_1.setCoincident(SketchLine_28.endPoint(), SketchLine_29.startPoint()) +SketchConstraintCoincidence_46.setName("SketchConstraintCoincidence_48") +SketchConstraintCoincidence_47 = Sketch_1.setCoincident(SketchLine_29.endPoint(), SketchLine_30.startPoint()) +SketchConstraintCoincidence_47.setName("SketchConstraintCoincidence_49") +SketchConstraintCoincidence_48 = Sketch_1.setCoincident(SketchLine_30.endPoint(), SketchLine_31.startPoint()) +SketchConstraintCoincidence_48.setName("SketchConstraintCoincidence_50") +SketchConstraintHorizontal_6 = Sketch_1.setHorizontal(SketchLine_28.result()) +SketchConstraintVertical_8 = Sketch_1.setVertical(SketchLine_29.result()) +SketchConstraintHorizontal_7 = Sketch_1.setHorizontal(SketchLine_30.result()) +SketchConstraintVertical_9 = Sketch_1.setVertical(SketchLine_31.result()) +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_30.result(), 1.5) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_29.result(), 1.8) +SketchConstraintDistance_14 = Sketch_1.setDistance(SketchLine_29.startPoint(), SketchLine_14.result(), 0.6, True) +SketchLine_32 = Sketch_1.addLine(6.281999999999999, 9.025000000000009, 6.281999999999999, -4.049999999999998) +SketchLine_32.setName("SketchLine_33") +SketchLine_32.result().setName("SketchLine_33") +SketchLine_32.setAuxiliary(True) +SketchConstraintCoincidence_49 = Sketch_1.setCoincident(SketchLine_32.startPoint(), SketchLine_18.result()) +SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_51") +SketchConstraintCoincidence_50 = Sketch_1.setCoincident(SketchLine_32.endPoint(), SketchLine_28.result()) +SketchConstraintCoincidence_50.setName("SketchConstraintCoincidence_52") +SketchConstraintVertical_10 = Sketch_1.setVertical(SketchLine_32.result()) +SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchLine_32.endPoint(), SketchLine_28.result()) +SketchConstraintMiddle_2 = Sketch_1.setMiddlePoint(SketchLine_32.startPoint(), SketchLine_18.result()) +SketchConstraintDistance_15 = Sketch_1.setDistance(SketchLine_32.endPoint(), SketchLine_3.result(), 1.5, True) +SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_6.endPoint(), SketchLine_5.endPoint(), 0.15) +SketchConstraintDistance_16 = Sketch_1.setDistance(SketchLine_6.endPoint(), SketchLine_17.result(), 2.25, True) +SketchConstraintCoincidence_51 = Sketch_1.setCoincident(SketchLine_21.result(), SketchLine_21.endPoint()) +SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_53") +SketchConstraintCoincidence_52 = Sketch_1.setCoincident(SketchLine_25.result(), SketchLine_21.endPoint()) +SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_54") +model.do() +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchArc_1_2f-SketchLine_13f-SketchArc_3_2r-SketchLine_24r-SketchLine_23r-SketchLine_22r-SketchArc_2_2r-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_32r-SketchLine_31r-SketchLine_30r-SketchLine_29r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_33 = Sketch_2.addLine(0, 2.425, 3.282538500974061, 11.74164236673401) +SketchLine_33.setName("SketchLine_34") +SketchLine_33.result().setName("SketchLine_34") +SketchLine_33.setAuxiliary(True) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_28_StartVertex"), False) +SketchPoint_1 = SketchProjection_3.createdFeature() +SketchConstraintCoincidence_53 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchPoint_1.result()) +SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_55") +SketchPoint_2 = Sketch_2.addPoint(3.241, 11.6237460014939) +SketchConstraintCoincidence_54 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_33.result()) +SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_56") +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_34 = SketchProjection_4.createdFeature() +SketchLine_34.setName("SketchLine_36") +SketchLine_34.result().setName("SketchLine_36") +SketchConstraintDistance_17 = Sketch_2.setDistance(SketchPoint_2.coordinates(), SketchLine_34.result(), 3.241, True) +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_13"), False) +SketchLine_35 = SketchProjection_5.createdFeature() +SketchLine_35.setName("SketchLine_37") +SketchLine_35.result().setName("SketchLine_37") +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_28"), False) +SketchLine_36 = SketchProjection_6.createdFeature() +SketchLine_36.setName("SketchLine_38") +SketchLine_36.result().setName("SketchLine_38") +SketchArc_4 = Sketch_2.addArc(0, 2.425, 0, 12.178, 5.453808387550194, 10.51060344512932, True) +SketchArc_4.setAuxiliary(True) +SketchConstraintCoincidence_55 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchArc_4.center()) +SketchConstraintCoincidence_55.setName("SketchConstraintCoincidence_58") +SketchConstraintCoincidence_56 = Sketch_2.setCoincident(SketchLine_35.result(), SketchArc_4.startPoint()) +SketchConstraintCoincidence_56.setName("SketchConstraintCoincidence_59") +SketchConstraintCoincidence_57 = Sketch_2.setCoincident(SketchLine_36.result(), SketchArc_4.endPoint()) +SketchConstraintCoincidence_57.setName("SketchConstraintCoincidence_60") +SketchConstraintMiddle_3 = Sketch_2.setMiddlePoint(SketchLine_35.result(), SketchArc_4.startPoint()) +SketchConstraintCoincidence_58 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchArc_4.results()[1]) +SketchConstraintCoincidence_58.setName("SketchConstraintCoincidence_61") +SketchArc_5 = Sketch_2.addArc(0, 2.425, 3.28253850097406, 11.74164236673401, 4.139817701932777, 11.39365616437401, True) +SketchConstraintCoincidence_59 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchArc_5.center()) +SketchConstraintCoincidence_59.setName("SketchConstraintCoincidence_62") +SketchConstraintCoincidence_60 = Sketch_2.setCoincident(SketchLine_33.result(), SketchArc_5.startPoint()) +SketchConstraintCoincidence_60.setName("SketchConstraintCoincidence_63") +SketchLine_37 = Sketch_2.addLine(4.139817701932777, 11.39365616437401, 4.459277785066624, 11.1909606795611) +SketchLine_37.setName("SketchLine_39") +SketchLine_37.result().setName("SketchLine_39") +SketchConstraintCoincidence_61 = Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchLine_37.startPoint()) +SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_64") +SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchArc_1_2"), False) +SketchArc_6 = SketchProjection_7.createdFeature() +SketchConstraintCoincidence_62 = Sketch_2.setCoincident(SketchLine_37.endPoint(), SketchArc_6.results()[1]) +SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_65") +SketchLine_38 = Sketch_2.addLine(4.459277785066624, 11.1909606795611, 4.390495384356073, 11.041947909785) +SketchLine_38.setName("SketchLine_40") +SketchLine_38.result().setName("SketchLine_40") +SketchConstraintCoincidence_63 = Sketch_2.setCoincident(SketchLine_37.endPoint(), SketchLine_38.startPoint()) +SketchConstraintCoincidence_63.setName("SketchConstraintCoincidence_66") +SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchArc_3_2"), False) +SketchArc_7 = SketchProjection_8.createdFeature() +SketchConstraintCoincidence_64 = Sketch_2.setCoincident(SketchLine_38.endPoint(), SketchArc_7.results()[1]) +SketchConstraintCoincidence_64.setName("SketchConstraintCoincidence_67") +SketchLine_39 = Sketch_2.addLine(4.390495384356073, 11.041947909785, 4.035044020470619, 11.16667053559354) +SketchLine_39.setName("SketchLine_41") +SketchLine_39.result().setName("SketchLine_41") +SketchConstraintCoincidence_65 = Sketch_2.setCoincident(SketchLine_38.endPoint(), SketchLine_39.startPoint()) +SketchConstraintCoincidence_65.setName("SketchConstraintCoincidence_68") +SketchArc_8 = Sketch_2.addArc(0, 2.425, 3.199461499025941, 11.5058496362538, 4.035044020470619, 11.16667053559354, True) +SketchConstraintCoincidence_66 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchArc_8.center()) +SketchConstraintCoincidence_66.setName("SketchConstraintCoincidence_69") +SketchConstraintCoincidence_67 = Sketch_2.setCoincident(SketchLine_33.result(), SketchArc_8.startPoint()) +SketchConstraintCoincidence_67.setName("SketchConstraintCoincidence_70") +SketchConstraintCoincidence_68 = Sketch_2.setCoincident(SketchArc_8.endPoint(), SketchLine_39.endPoint()) +SketchConstraintCoincidence_68.setName("SketchConstraintCoincidence_71") +SketchLine_40 = Sketch_2.addLine(0, 2.425, 4.139817701932777, 11.39365616437401) +SketchLine_40.setName("SketchLine_42") +SketchLine_40.result().setName("SketchLine_42") +SketchLine_40.setAuxiliary(True) +SketchConstraintCoincidence_69 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchLine_40.startPoint()) +SketchConstraintCoincidence_69.setName("SketchConstraintCoincidence_72") +SketchConstraintCoincidence_70 = Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchLine_40.endPoint()) +SketchConstraintCoincidence_70.setName("SketchConstraintCoincidence_73") +SketchConstraintCoincidence_71 = Sketch_2.setCoincident(SketchArc_8.endPoint(), SketchLine_40.result()) +SketchConstraintCoincidence_71.setName("SketchConstraintCoincidence_74") +SketchConstraintParallel_1 = Sketch_2.setParallel(SketchLine_38.result(), SketchLine_40.result()) +SketchLine_41 = Sketch_2.addLine(0, 2.425, 3.9115060144283, 11.49555702253678) +SketchLine_41.setName("SketchLine_43") +SketchLine_41.result().setName("SketchLine_43") +SketchLine_41.setAuxiliary(True) +SketchConstraintCoincidence_72 = Sketch_2.setCoincident(SketchLine_33.startPoint(), SketchLine_41.startPoint()) +SketchConstraintCoincidence_72.setName("SketchConstraintCoincidence_75") +SketchConstraintCoincidence_73 = Sketch_2.setCoincident(SketchLine_41.endPoint(), SketchArc_5.results()[1]) +SketchConstraintCoincidence_73.setName("SketchConstraintCoincidence_76") +SketchPoint_3 = Sketch_2.addPoint(3.812510620258724, 11.26599240868436) +SketchConstraintCoincidence_74 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_41.result()) +SketchConstraintCoincidence_74.setName("SketchConstraintCoincidence_77") +SketchConstraintCoincidence_75 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchArc_8.results()[1]) +SketchConstraintCoincidence_75.setName("SketchConstraintCoincidence_78") +SketchLine_42 = Sketch_2.addLine(3.812510620258724, 11.26599240868436, 3.9115060144283, 11.49555702253678) +SketchLine_42.setName("SketchLine_44") +SketchLine_42.result().setName("SketchLine_44") +SketchConstraintCoincidence_76 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_42.startPoint()) +SketchConstraintCoincidence_76.setName("SketchConstraintCoincidence_79") +SketchConstraintCoincidence_77 = Sketch_2.setCoincident(SketchLine_41.endPoint(), SketchLine_42.endPoint()) +SketchConstraintCoincidence_77.setName("SketchConstraintCoincidence_80") +SketchPoint_4 = Sketch_2.addPoint(3.862008317343517, 11.38077471561057) +SketchConstraintCoincidence_78 = Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchLine_42.result()) +SketchConstraintCoincidence_78.setName("SketchConstraintCoincidence_81") +SketchConstraintMiddle_4 = Sketch_2.setMiddlePoint(SketchPoint_4.coordinates(), SketchLine_42.result()) +SketchConstraintCoincidence_79 = Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchArc_4.results()[1]) +SketchConstraintCoincidence_79.setName("SketchConstraintCoincidence_82") +SketchConstraintDistance_18 = Sketch_2.setDistance(SketchLine_42.endPoint(), SketchLine_40.result(), 0.25, True) +SketchConstraintDistance_19 = Sketch_2.setDistance(SketchArc_5.endPoint(), SketchLine_38.result(), 0.375, True) +SketchConstraintDistance_20 = Sketch_2.setDistance(SketchArc_5.startPoint(), SketchLine_42.result(), "1.35/2", True) +SketchConstraintDistance_21 = Sketch_2.setDistance(SketchArc_8.startPoint(), SketchArc_5.startPoint(), 0.25, True) +SketchConstraintCoincidence_80 = Sketch_2.setCoincident(SketchLine_33.endPoint(), SketchArc_5.startPoint()) +SketchConstraintCoincidence_80.setName("SketchConstraintCoincidence_83") +SketchLine_43 = Sketch_2.addLine(3.199461499025942, 11.5058496362538, 3.28253850097406, 11.74164236673401) +SketchLine_43.setName("SketchLine_45") +SketchLine_43.result().setName("SketchLine_45") +SketchConstraintCoincidence_81 = Sketch_2.setCoincident(SketchArc_8.startPoint(), SketchLine_43.startPoint()) +SketchConstraintCoincidence_81.setName("SketchConstraintCoincidence_84") +SketchConstraintCoincidence_82 = Sketch_2.setCoincident(SketchLine_33.endPoint(), SketchLine_43.endPoint()) +SketchConstraintCoincidence_82.setName("SketchConstraintCoincidence_85") +model.do() +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_5_2f-SketchLine_45r-SketchArc_8_2r-SketchLine_44f")], model.selection("EDGE", "Sketch_2/SketchLine_34"), 360, 0) +Revolution_2.result().setName("Cut_tool") +Revolution_3 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchArc_5_2f-SketchLine_44r-SketchArc_8_2r-SketchLine_41r-SketchLine_40r-SketchLine_39r_wire")], model.selection("EDGE", "Sketch_2/SketchLine_34"), 360, 0) +Revolution_3.result().setName("Fuse_tool") +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Cut_tool"), model.selection("SOLID", "Fuse_tool")], model.selection("EDGE", "PartSet/OZ"), True) +Symmetry_1.result().subResult(0).setName("Symmetry_1_1_1") +Symmetry_1.result().subResult(1).setName("Symmetry_1_1_2") +Symmetry_1.results()[1].subResult(0).setName("Symmetry_1_2_1") +Symmetry_1.results()[1].subResult(1).setName("Symmetry_1_2_2") +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("COMPOUND", "Cut_tool")]) +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cut_1_1"), model.selection("COMPOUND", "Fuse_tool")], True) +model.do() +model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2701.py b/src/FeaturesPlugin/Test/Test2701.py new file mode 100644 index 000000000..97de48178 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2701.py @@ -0,0 +1,118 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "a", "10") +model.addParameter(Part_1_doc, "b", "8") +model.addParameter(Part_1_doc, "c", "2*a") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-48.37423594569039, -43.07420401522882, -48.37423594569039, -8.074204015228814) +SketchLine_2 = Sketch_1.addLine(-40.38893648559045, -0.07421752185518632, -2.793802518897851e-22, 0) +SketchLine_3 = Sketch_1.addLine(-2.793802518897851e-22, 0, 37.58770483143633, -13.68080573302675) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2") +SketchLine_4 = Sketch_1.addLine(37.58770483143633, -13.68080573302675, 19.91003530177265, -31.35847526269043) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3") +SketchLine_5 = Sketch_1.addLine(-8.374235945690391, -43.07420401522882, -48.37423594569039, -43.07420401522882) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint()) +SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_5") +SketchArc_1 = Sketch_1.addArc(-40.37423594569039, -8.074204015228817, -40.38893648559045, -0.07421752185518632, -48.37423594569039, -8.074204015228814, False) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6") +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7") +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result()) +SketchArc_2 = Sketch_1.addArc(-8.374235945690213, -3.074204015227884, -8.374235945690391, -43.07420401522882, 19.91003530177265, -31.35847526269043, False) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_8") +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_4.endPoint()) +SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_9") +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_4.result()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_5.result()) +SketchLine_6 = Sketch_1.addLine(-2.793802518897851e-22, 0, 0, 35) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_10") +SketchLine_7 = Sketch_1.addLine(30.00000000001173, 65.00000000001097, 42.00000000001173, 65.00000000001097) +SketchLine_8 = Sketch_1.addLine(65.00000000000007, 42, 65.00000000000007, 30) +SketchLine_9 = Sketch_1.addLine(35.00000000000009, 0, -2.793802518897851e-22, 0) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_9.endPoint()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_14") +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_7.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_9.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_8.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result()) +SketchArc_3 = Sketch_1.addArc(30.00000000000873, 35.00000000000306, 30.00000000001173, 65.00000000001097, 0, 35, False) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_15") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_6.endPoint()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_16") +SketchConstraintTangent_5 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_6.result()) +SketchConstraintTangent_6 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_7.result()) +SketchArc_4 = Sketch_1.addArc(42.00000000000008, 41.99999999999999, 65.00000000000007, 42, 42.00000000001173, 65.00000000001097, False) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_17") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_7.endPoint()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_18") +SketchConstraintTangent_7 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_7.result()) +SketchConstraintTangent_8 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_8.result()) +SketchArc_5 = Sketch_1.addArc(35.00000000000006, 30.00000000000001, 35.00000000000009, 0, 65.00000000000007, 30, False) +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_5.startPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_19") +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_5.endPoint(), SketchLine_8.endPoint()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_20") +SketchConstraintTangent_9 = Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_8.result()) +SketchConstraintTangent_10 = Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_9.result()) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_21") +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_5.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_1.result()) +SketchConstraintAngle_1 = Sketch_1.setAngleBackward(SketchLine_4.result(), SketchLine_3.result(), 65.00000000000011) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), "2*c") +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 25) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_5.result(), "4*a") +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_1.result(), 35) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 8) +SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_3.result(), SketchLine_9.result(), 20.00000000000001) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 40) +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_6.result(), 35) +SketchConstraintLength_6 = Sketch_1.setLength(SketchLine_7.result(), 12) +SketchConstraintLength_7 = Sketch_1.setLength(SketchLine_8.result(), 12) +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_3.results()[1], 30) +SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_5.results()[1], 30) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), 10, 0) +model.do() +model.testHaveNamingSubshapes(Extrusion_1, model, Part_1_doc) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2724.py b/src/FeaturesPlugin/Test/Test2724.py new file mode 100644 index 000000000..16cd2c330 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2724.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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +model.addParameter(partSet, "b", "80") +model.addParameter(partSet, "a", "100") +model.addParameter(partSet, "c", "b-a") +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-60, -20, -60.00000000000001, 80) +SketchLine_2 = Sketch_1.addLine(-60.00000000000001, 80, 0, 0) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(0, 0, 0, -100) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(0, -100, -60, -20) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result()) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result()) +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_3.startPoint(), "a", True) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.endPoint(), SketchLine_2.endPoint(), 60) +SketchConstraintMirror_1_objects = [SketchLine_4.result(), SketchLine_1.result(), SketchLine_2.result()] +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_3.result(), SketchConstraintMirror_1_objects) +[SketchLine_5, SketchLine_6, SketchLine_7] = SketchConstraintMirror_1.mirrored() +SketchMultiTranslation_1_objects = [SketchLine_1.result(), SketchLine_4.result(), SketchLine_3.result(), SketchLine_5.result(), SketchLine_6.result()] +SketchMultiTranslation_1 = Sketch_1.addTranslation(SketchMultiTranslation_1_objects, SketchLine_2.endPoint(), SketchLine_4.startPoint(), 4) +[SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_5, SketchLine_17, SketchLine_18, SketchLine_19, SketchLine_6, SketchLine_20, SketchLine_21, SketchLine_22] = SketchMultiTranslation_1.translated() +model.do() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1_objects = [model.selection("FACE", (-30, -10, 0)), model.selection("FACE", (30, -110, 0)), model.selection("FACE", (-30, -210, 0)), model.selection("FACE", (30, -310, 0))] +Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection(), "c", 0) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", (30, -310, -9.999999999999998))], model.selection("EDGE", (-30, -360, 0)), "-c") +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", (-30.00000000000001, -10, -10))], model.selection("FACE", (5, 10, 5)), model.selection("FACE", (-30, 40, -10)), True, True) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", (-30.00000000000001, -210, -10)), model.selection("SOLID", (18, -293.9999999999999, -9.999999999999998))]) +model.do() +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_WEAK)) +model.end() diff --git a/src/FeaturesPlugin/Test/Test2729.py b/src/FeaturesPlugin/Test/Test2729.py new file mode 100644 index 000000000..2819f1868 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2729.py @@ -0,0 +1,254 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "B", "46") +model.addParameter(Part_1_doc, "B1", "36") +model.addParameter(Part_1_doc, "B2", "25.5") +model.addParameter(Part_1_doc, "B3", "10") +model.addParameter(Part_1_doc, "D", "4.2") +model.addParameter(Part_1_doc, "D1", "4") +model.addParameter(Part_1_doc, "D2", "0") +model.addParameter(Part_1_doc, "H", "95") +model.addParameter(Part_1_doc, "H1", "86") +model.addParameter(Part_1_doc, "H2", "4.7") +model.addParameter(Part_1_doc, "H4", "86") +model.addParameter(Part_1_doc, "H5", "71") +model.addParameter(Part_1_doc, "H6", "40") +model.addParameter(Part_1_doc, "H7", "26.75") +model.addParameter(Part_1_doc, "H8", "51.5") +model.addParameter(Part_1_doc, "H9", "15") +model.addParameter(Part_1_doc, "H10", "1.5") +model.addParameter(Part_1_doc, "L1", "23") +model.addParameter(Part_1_doc, "L2", "30") +model.addParameter(Part_1_doc, "L3", "4") +model.addParameter(Part_1_doc, "L4", "2.3") +model.addParameter(Part_1_doc, "L5", "6.5") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(29.99999999999995, 0, -16.00000000000005, 0) +SketchLine_2 = Sketch_1.addLine(-16.00000000000005, 0, -16.00000000000005, 4.7) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(-16.00000000000005, 4.7, 1.946471204593173e-17, 4.7) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(1.946471204593173e-17, 4.7, 4.235164736271502e-22, 95) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(4.235164736271502e-22, 95, 7, 95) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(7, 95, 7, 80) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_1.addLine(7, 80, 9, 80) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchLine_8 = Sketch_1.addLine(9, 80, 9, 8.999999999999996) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchLine_9 = Sketch_1.addLine(9, 8.999999999999996, 17, 9.000000000000002) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchLine_10 = Sketch_1.addLine(17, 9.000000000000002, 17, 4.7) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchLine_11 = Sketch_1.addLine(17, 4.7, 30, 4.7) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchLine_12 = Sketch_1.addLine(30, 4.7, 29.99999999999995, 0) +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_12.endPoint()) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_13 = SketchProjection_1.createdFeature() +SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_13.result(), SketchLine_1.result()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_14 = SketchProjection_2.createdFeature() +SketchConstraintCollinear_2 = Sketch_1.setCollinear(SketchLine_4.result(), SketchLine_14.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_6.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_8.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_10.result()) +SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_12.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_9.result()) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_11.result()) +SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_5.result()) +SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_7.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), "H2") +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), "B") +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_3.endPoint(), SketchLine_1.startPoint(), "L2") +SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchLine_11.endPoint(), "L1") +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 2) +SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_6.startPoint(), SketchLine_1.startPoint(), "H") +SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_8.startPoint(), SketchLine_9.endPoint(), "H5") +SketchConstraintDistanceVertical_3 = Sketch_1.setVerticalDistance(SketchLine_6.startPoint(), SketchLine_9.endPoint(), "H1") +SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_12.result(), "H2") +SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_11.result(), "L5*2") +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), "B/2", "B/2") +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, "L5", [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8")) +SketchLine_15 = Sketch_2.addLine(-8.985867605559861e-16, 8.999999999999996, 1.535230276239474e-15, 80) +SketchLine_15.setAuxiliary(True) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]"), False) +SketchLine_16 = SketchProjection_3.createdFeature() +SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_16.result(), SketchLine_15.endPoint()) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8]"), False) +SketchLine_17 = SketchProjection_4.createdFeature() +SketchConstraintMiddle_2 = Sketch_2.setMiddlePoint(SketchLine_15.startPoint(), SketchLine_17.result()) +SketchLine_18 = Sketch_2.addLine(-4.999999999999998, 13.00000000000012, -4.999999999999999, 94.99999999999999) +SketchLine_19 = Sketch_2.addLine(-4.999999999999999, 94.99999999999999, -13.00000000000988, 95.00000000000222) +SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) +SketchLine_20 = Sketch_2.addLine(-13.00000000000988, 95.00000000000222, -13, 78.5) +SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint()) +SketchLine_21 = Sketch_2.addLine(-13, 78.5, -23.00000000000001, 78.5) +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +SketchLine_22 = Sketch_2.addLine(-23.00000000000001, 78.5, -23.00000000000001, 72.5) +SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) +SketchLine_23 = Sketch_2.addLine(-23.00000000000001, 72.5, -15, 72.5) +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) +SketchLine_24 = Sketch_2.addLine(-13, 70.5, -13, 23) +SketchLine_25 = Sketch_2.addLine(-15, 21, -22.99999999999999, 21) +SketchLine_26 = Sketch_2.addLine(-22.99999999999999, 21, -22.99999999999999, 15) +SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_25.endPoint(), SketchLine_26.startPoint()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20") +SketchLine_27 = Sketch_2.addLine(-22.99999999999999, 15, -13, 15) +SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_26.endPoint(), SketchLine_27.startPoint()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_21") +SketchLine_28 = Sketch_2.addLine(-13, 15, -13.00000000000024, 13.00000000000012) +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_27.endPoint(), SketchLine_28.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_22") +SketchArc_1 = Sketch_2.addArc(-9.000000000000117, 13.00000000000012, -4.999999999999998, 13.00000000000012, -13.00000000000024, 13.00000000000012, True) +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_18.startPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_23") +SketchConstraintTangent_1 = Sketch_2.setTangent(SketchLine_18.result(), SketchArc_1.results()[1]) +SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_28.endPoint(), SketchArc_1.endPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_24") +SketchConstraintTangent_2 = Sketch_2.setTangent(SketchLine_28.result(), SketchArc_1.results()[1]) +SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_18.result()) +SketchConstraintVertical_7 = Sketch_2.setVertical(SketchLine_28.result()) +SketchConstraintCollinear_3 = Sketch_2.setCollinear(SketchLine_28.result(), SketchLine_24.result()) +SketchConstraintCollinear_4 = Sketch_2.setCollinear(SketchLine_20.result(), SketchLine_24.result()) +SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_27.result()) +SketchConstraintHorizontal_7 = Sketch_2.setHorizontal(SketchLine_25.result()) +SketchConstraintHorizontal_8 = Sketch_2.setHorizontal(SketchLine_23.result()) +SketchConstraintHorizontal_9 = Sketch_2.setHorizontal(SketchLine_21.result()) +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/To_Face]"), False) +SketchLine_29 = SketchProjection_5.createdFeature() +SketchConstraintCollinear_5 = Sketch_2.setCollinear(SketchLine_22.result(), SketchLine_29.result()) +SketchConstraintCollinear_5.setName("SketchConstraintCollinear_7") +SketchConstraintCollinear_6 = Sketch_2.setCollinear(SketchLine_26.result(), SketchLine_29.result()) +SketchConstraintCollinear_6.setName("SketchConstraintCollinear_8") +SketchConstraintTangent_3 = Sketch_2.setTangent(SketchArc_1.results()[1], SketchLine_17.result()) +SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_22.result(), 6) +SketchConstraintLength_7 = Sketch_2.setLength(SketchLine_26.result(), 6) +SketchConstraintDistanceHorizontal_3 = Sketch_2.setHorizontalDistance(SketchLine_18.endPoint(), SketchLine_15.endPoint(), "B3/2") +SketchConstraintLength_8 = Sketch_2.setLength(SketchLine_19.result(), 8) +SketchConstraintLength_8.setName("SketchConstraintLength_9") +SketchArc_2 = Sketch_2.addArc(-15, 70.5, -13, 70.5, -15, 72.5, False) +SketchPoint_1 = Sketch_2.addPoint(-13, 72.5) +SketchPoint_1.setAuxiliary(True) +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchLine_23.result()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_25") +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchLine_24.result()) +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_26") +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_24.startPoint()) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_27") +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_23.endPoint()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_28") +SketchConstraintTangent_4 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_23.result()) +SketchConstraintTangent_5 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_24.result()) +SketchArc_3 = Sketch_2.addArc(-15, 23, -15, 21, -13, 23, False) +SketchPoint_2 = Sketch_2.addPoint(-13, 21) +SketchPoint_2.setAuxiliary(True) +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchPoint_2.coordinates(), "H8", False) +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_25.result()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_29") +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_24.result()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_30") +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchArc_3.startPoint(), SketchLine_25.startPoint()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_31") +SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchArc_3.endPoint(), SketchLine_24.endPoint()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_32") +SketchConstraintTangent_6 = Sketch_2.setTangent(SketchArc_3.results()[1], SketchLine_25.result()) +SketchConstraintTangent_7 = Sketch_2.setTangent(SketchArc_3.results()[1], SketchLine_24.result()) +SketchConstraintRadius_1 = Sketch_2.setRadius(SketchArc_3.results()[1], 2) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_2.results()[1], 2) +SketchLine_30 = Sketch_2.addLine(13.00000000000001, 78.49999999999866, 23, 78.49999999999866) +SketchLine_30.setName("SketchLine_32") +SketchLine_30.result().setName("SketchLine_32") +SketchLine_31 = Sketch_2.addLine(23, 78.49999999999866, 23, 72.49999999999866) +SketchLine_31.setName("SketchLine_33") +SketchLine_31.result().setName("SketchLine_33") +SketchLine_32 = Sketch_2.addLine(23, 72.49999999999866, 14.99999999999993, 72.5) +SketchLine_32.setName("SketchLine_34") +SketchLine_32.result().setName("SketchLine_34") +SketchArc_4 = Sketch_2.addArc(14.99999999999997, 70.5, 12.99999999999997, 70.50000000000004, 14.99999999999993, 72.5, True) +SketchLine_33 = Sketch_2.addLine(12.99999999999997, 70.50000000000004, 12.99999999999995, 22.99999999999997) +SketchLine_33.setName("SketchLine_35") +SketchLine_33.result().setName("SketchLine_35") +SketchArc_5 = Sketch_2.addArc(14.99999999999996, 23.00000000000001, 14.99999999999992, 21, 12.99999999999995, 22.99999999999997, True) +SketchLine_34 = Sketch_2.addLine(14.99999999999992, 21, 23, 20.99999999999866) +SketchLine_34.setName("SketchLine_36") +SketchLine_34.result().setName("SketchLine_36") +SketchLine_35 = Sketch_2.addLine(23, 20.99999999999866, 23, 14.99999999999866) +SketchLine_35.setName("SketchLine_37") +SketchLine_35.result().setName("SketchLine_37") +SketchLine_36 = Sketch_2.addLine(23, 14.99999999999866, 13.00000000000001, 14.99999999999866) +SketchLine_36.setName("SketchLine_38") +SketchLine_36.result().setName("SketchLine_38") +SketchLine_37 = Sketch_2.addLine(13.00000000000001, 14.99999999999866, 13.00000000000024, 13.00000000000011) +SketchLine_37.setName("SketchLine_39") +SketchLine_37.result().setName("SketchLine_39") +SketchArc_6 = Sketch_2.addArc(9.000000000000117, 13.00000000000012, 4.999999999999996, 13.00000000000012, 13.00000000000024, 13.00000000000011, False) +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5]"), True) +SketchLine_38 = SketchProjection_6.createdFeature() +SketchLine_38.setName("SketchLine_41") +SketchLine_38.result().setName("SketchLine_41") +SketchConstraintCollinear_7 = Sketch_2.setCollinear(SketchLine_19.result(), SketchLine_38.result()) +SketchConstraintCollinear_7.setName("SketchConstraintCollinear_9") +SketchConstraintDistanceVertical_4 = Sketch_2.setVerticalDistance(SketchAPI_Line(SketchLine_29).startPoint(), SketchLine_22.startPoint(), "H10") +SketchConstraintMirror_1_objects = [SketchLine_18.result(), SketchLine_20.result(), SketchLine_19.result()] +SketchConstraintMirror_1 = Sketch_2.addMirror(SketchLine_15.result(), SketchConstraintMirror_1_objects) +[SketchLine_39, SketchLine_40, SketchLine_41] = SketchConstraintMirror_1.mirrored() +SketchLine_41.setName("SketchLine_43") +SketchLine_41.result().setName("SketchLine_43") +SketchLine_40.setName("SketchLine_42") +SketchLine_40.result().setName("SketchLine_42") +SketchLine_39.setName("SketchLine_40") +SketchLine_39.result().setName("SketchLine_40") +ExtrusionCut_1.setNestedSketch(Sketch_2) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 20, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_8&weak_name_1")) +SketchCircle_1 = Sketch_3.addCircle(-19.86097902097902, 65.28094405594405, 2.5) +SketchCircle_2 = Sketch_3.addCircle(-18.51902097902098, 27.57192307692308, 2) +SketchCircle_3 = Sketch_3.addCircle(-19.0558041958042, 85.54451048951049, 3) +SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_2.results()[1], 2) +SketchConstraintRadius_4 = Sketch_3.setRadius(SketchCircle_1.results()[1], 2.5) +SketchConstraintRadius_5 = Sketch_3.setRadius(SketchCircle_3.results()[1], 3) +ExtrusionCut_2.setNestedSketch(Sketch_3) +model.end() + +# check that radius constraint is valid +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(SketchConstraintRadius_3.feature())) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test2751.py b/src/FeaturesPlugin/Test/Test2751.py new file mode 100644 index 000000000..ef00edc94 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test2751.py @@ -0,0 +1,93 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "r", "20") +model.addParameter(Part_1_doc, "l", "40") +model.addParameter(Part_1_doc, "r2", "3") +model.addParameter(Part_1_doc, "a", "10") +model.addParameter(Part_1_doc, "h", "5") +model.addParameter(Part_1_doc, "n", "2") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_1 = SketchProjection_2.createdFeature() +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_2 = SketchProjection_3.createdFeature() +SketchArc_1 = Sketch_1.addArc(0, 0, 20, 0, 0, 20, False) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint()) +SketchArc_2 = Sketch_1.addArc(0, 0, 60, 0, 0, 60, False) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchArc_2.center()) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint()) +SketchLine_3 = Sketch_1.addLine(0, 20, 0, 60) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_3.endPoint()) +SketchLine_4 = Sketch_1.addLine(20, 0, 60, 0) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_4.endPoint()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), "l") +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "r") +model.do() +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", (30, 30, 0))]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE_2", (30, 30, 0))) +SketchCircle_1 = Sketch_2.addCircle(24.6201938253052, 4.341204441673258, 3) +SketchLine_5 = Sketch_2.addLine(24.6201938253052, 4.341204441673258, 54.16442641567144, 9.550649771681169) +SketchLine_5.setAuxiliary(True) +SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchLine_5.startPoint()) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], "r2") +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_6 = SketchProjection_4.createdFeature() +SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", (20, 0, 0)), False) +SketchPoint_2 = SketchProjection_5.createdFeature() +SketchMultiTranslation_1 = Sketch_2.addTranslation([SketchCircle_1.results()[1]], SketchCircle_1.center(), SketchLine_5.endPoint(), "n") +[SketchCircle_2] = SketchMultiTranslation_1.translated() +SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_5.result(), "(l-2*h)/(n-1)") +SketchLine_7 = Sketch_2.addLine(0, 0, 24.6201938253052, 4.341204441673258) +SketchLine_7.setAuxiliary(True) +SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_6).startPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchLine_7.endPoint()) +SketchConstraintCollinear_1 = Sketch_2.setCollinear(SketchLine_5.result(), SketchLine_7.result()) +SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_6.result(), SketchLine_7.result(), "a") +SketchPoint_3 = Sketch_2.addPoint(19.69615506024416, 3.472963553338606) +SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchLine_7.result()) +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", (14.14213562373095, 14.14213562373095, 0)), False) +SketchArc_3 = SketchProjection_6.createdFeature() +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchArc_3.results()[1]) +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchPoint_3.coordinates(), SketchLine_7.endPoint(), "h", True) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_2")], model.selection(), 10, 0) +AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], model.selection("EDGE", "PartSet/OZ"), "(90-2*a)/(n-1)", "n") +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", (30, 30, 0))], [model.selection("COMPOUND", (29.25281542867235, 29.25281542867235, 5))]) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBoolean.py b/src/FeaturesPlugin/Test/TestBoolean.py deleted file mode 100644 index 84c893e42..000000000 --- a/src/FeaturesPlugin/Test/TestBoolean.py +++ /dev/null @@ -1,172 +0,0 @@ -## 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 -## - -""" - TestBoolean.py - Unit test of FeaturesPlugin_Boolean class - - class FeaturesPlugin_Boolean - static const std::string MY_ID("Boolean"); - static const std::string MY_OBJECT_ID("main_object"); - static const std::string MY_TOOL_ID("tool_object"); - static const std::string MY_TYPE_ID("bool_type"); - - data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId()); - data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId()); - data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId()); -""" -#========================================================================= -# Initialization of the test -#========================================================================= -from ModelAPI import * -from GeomDataAPI import * -from GeomAlgoAPI import * -from GeomAPI import * - -__updated__ = "2014-12-16" - -aSession = ModelAPI_Session.get() -# Create a part for extrusions & boolean -aSession.startOperation() -aPartFeature = aSession.moduleDocument().addFeature("Part") -aSession.finishOperation() -aPart = aSession.activeDocument() -#========================================================================= -# Create a sketch with circle to extrude -#========================================================================= -aSession.startOperation() -aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")) -origin.setValue(0, 0, 0) -dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) -dirx.setValue(1, 0, 0) -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) -norm.setValue(0, 0, 1) -aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") -anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) -aCircleRadius = aSketchCircle.real("circle_radius") -anCircleCentr.setValue(10., 10.) -aCircleRadius.setValue(50.) -aSession.finishOperation() -#========================================================================= -# Create a sketch with triangle to extrude -#========================================================================= -aSession.startOperation() -aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) -origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")) -origin.setValue(0, 0, 0) -dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")) -dirx.setValue(1, 0, 0) -norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")) -norm.setValue(0, 0, 1) -aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine") -aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine") -aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine") -aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint")) -aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint")) -aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint")) -aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint")) -aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint")) -aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint")) -aLineAStartPoint.setValue(25., 25.) -aLineAEndPoint.setValue(100., 25.) -aLineBStartPoint.setValue(100., 25.) -aLineBEndPoint.setValue(60., 75.) -aLineCStartPoint.setValue(60., 75.) -aLineCEndPoint.setValue(25., 25.) -aSession.finishOperation() -#========================================================================= -# Make extrusion on circle (cylinder) and triangle (prism) -#========================================================================= -# Build shape from sketcher results -aSession.startOperation() -extrudedObjects = [] -for eachSketchFeature in [aCircleSketchFeature, aTriangleSketchFeature]: - # Build sketch faces - aSketchResult = eachSketchFeature.firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(eachSketchFeature.attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(eachSketchFeature.attribute("DirX")).dir() - norm = geomDataAPI_Dir(eachSketchFeature.attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) - # Create extrusion on them - anExtrusionFt = aPart.addFeature("Extrusion") - anExtrusionFt.selectionList("base").append( - aSketchResult, aSketchFaces[0]) - anExtrusionFt.string("CreationMethod").setValue("BySizes") - anExtrusionFt.real("from_size").setValue(0) - anExtrusionFt.real("to_size").setValue(50) - anExtrusionFt.real("to_offset").setValue(0) #TODO: remove - anExtrusionFt.real("from_offset").setValue(0) #TODO: remove - anExtrusionFt.execute() - extrudedObjects.append(modelAPI_ResultBody(anExtrusionFt.firstResult())) -aSession.finishOperation() -#========================================================================= -# Create a pacman as boolean cut of the prism from the cylinder -#========================================================================= -aSession.startOperation() -aBooleanFt = aPart.addFeature("Cut") -aBooleanFt.selectionList("main_objects").append(extrudedObjects[0], extrudedObjects[0].shape()) -aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], extrudedObjects[1].shape()) -aBooleanFt.execute() -aSession.finishOperation() - -assert (len(aBooleanFt.results()) > 0) -aBooleanResult = modelAPI_ResultBody(aBooleanFt.firstResult()) -assert (aBooleanResult is not None) -#========================================================================= -# End of test -#========================================================================= - -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(-353.344768439108, 0.857632933105, 175.14200032067) -model.do() -Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchCircle_2 = Sketch_2.addCircle(-126.929674099485, -2.572898799314, 176.971885556791) -model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 10, 0) -Boolean_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) -model.end() -assert(len(Boolean_1.results()) > 0) - -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(-353.344768439108, 0.857632933105, 175.14200032067) -model.do() -Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchCircle_2 = Sketch_2.addCircle(-126.929674099485, -2.572898799314, 176.971885556791) -model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), 10, 0) -Boolean_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) -model.end() -assert(len(Boolean_1.results()) > 0) - -assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBoolean1.py b/src/FeaturesPlugin/Test/TestBoolean1.py new file mode 100644 index 000000000..371c30b7d --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBoolean1.py @@ -0,0 +1,134 @@ +## 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 +## + +""" + TestBoolean.py + Unit test of FeaturesPlugin_Boolean class + + class FeaturesPlugin_Boolean + static const std::string MY_ID("Boolean"); + static const std::string MY_OBJECT_ID("main_object"); + static const std::string MY_TOOL_ID("tool_object"); + static const std::string MY_TYPE_ID("bool_type"); + + data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::typeId()); + data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::typeId()); + data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::typeId()); +""" +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +# Create a part for extrusions & boolean +aSession.startOperation() +aPartFeature = aSession.moduleDocument().addFeature("Part") +aSession.finishOperation() +aPart = aSession.activeDocument() +#========================================================================= +# Create a sketch with circle to extrude +#========================================================================= +aSession.startOperation() +aCircleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") +anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) +aCircleRadius = aSketchCircle.real("circle_radius") +anCircleCentr.setValue(10., 10.) +aCircleRadius.setValue(50.) +aSession.finishOperation() +#========================================================================= +# Create a sketch with triangle to extrude +#========================================================================= +aSession.startOperation() +aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine") +aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine") +aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine") +aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint")) +aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint")) +aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint")) +aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint")) +aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint")) +aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint")) +aLineAStartPoint.setValue(25., 25.) +aLineAEndPoint.setValue(100., 25.) +aLineBStartPoint.setValue(100., 25.) +aLineBEndPoint.setValue(60., 75.) +aLineCStartPoint.setValue(60., 75.) +aLineCEndPoint.setValue(25., 25.) +aSession.finishOperation() +#========================================================================= +# Make extrusion on circle (cylinder) and triangle (prism) +#========================================================================= +# Build shape from sketcher results +aSession.startOperation() +extrudedObjects = [] +for eachSketchFeature in [aCircleSketchFeature, aTriangleSketchFeature]: + # Build sketch faces + aSketchResult = modelAPI_ResultConstruction(eachSketchFeature.firstResult()) + # Create extrusion on them + anExtrusionFt = aPart.addFeature("Extrusion") + anExtrusionFt.selectionList("base").append( + aSketchResult, aSketchResult.face(0)) + anExtrusionFt.string("CreationMethod").setValue("BySizes") + anExtrusionFt.real("from_size").setValue(0) + anExtrusionFt.real("to_size").setValue(50) + anExtrusionFt.real("to_offset").setValue(0) #TODO: remove + anExtrusionFt.real("from_offset").setValue(0) #TODO: remove + anExtrusionFt.execute() + extrudedObjects.append(modelAPI_ResultBody(anExtrusionFt.firstResult())) +aSession.finishOperation() +#========================================================================= +# Create a pacman as boolean cut of the prism from the cylinder +#========================================================================= +aSession.startOperation() +aBooleanFt = aPart.addFeature("Cut") +aBooleanFt.selectionList("main_objects").append(extrudedObjects[0], extrudedObjects[0].shape()) +aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], extrudedObjects[1].shape()) +aBooleanFt.execute() +aSession.finishOperation() + +assert (len(aBooleanFt.results()) > 0) +aBooleanResult = modelAPI_ResultBody(aBooleanFt.firstResult()) +assert (aBooleanResult is not None) +#========================================================================= +# End of test +#========================================================================= + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBoolean2.py b/src/FeaturesPlugin/Test/TestBoolean2.py new file mode 100644 index 000000000..dc68688d7 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBoolean2.py @@ -0,0 +1,41 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +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(-353.344768439108, 0.857632933105, 175.14200032067) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(-126.929674099485, -2.572898799314, 176.971885556791) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 10, 0) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) +model.do() +model.end() +assert(len(Common_1.results()) > 0) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBoolean3.py b/src/FeaturesPlugin/Test/TestBoolean3.py new file mode 100644 index 000000000..9c027bbc6 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBoolean3.py @@ -0,0 +1,41 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +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(-353.344768439108, 0.857632933105, 175.14200032067) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(-126.929674099485, -2.572898799314, 176.971885556791) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 10, 0) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) +model.do() +model.end() +assert(len(Smash_1.results()) > 0) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_CompSolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_CompSolidCompound.py index c74354f89..11a62f645 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_CompSolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_CompSolidCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Face.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Face.py index 4ed9772d1..7fa5c0af2 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -71,7 +73,7 @@ SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_13.result()) SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_14.result()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 10) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_14f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12f-SketchLine_13f-SketchLine_14f")]) Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPSOLID", "Extrusion_1_2")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("COMPOUND", "Compound_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Shell.py index 474ee4f0d..fba6de97f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolidCompound_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -75,7 +77,7 @@ SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_15.endPoint() model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 10) Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1"), model.selection("COMPSOLID", "Extrusion_1_2")]) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_13f-SketchLine_14f-SketchLine_15f"), model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_15r")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_15f-SketchLine_13f-SketchLine_14f"), model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12f-SketchLine_13f-SketchLine_15r")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("COMPOUND", "Compound_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_CompSolid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_CompSolid.py index 30e2a876b..a6ac0b278 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_CompSolid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_CompSolid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Face.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Face.py index 8799458b1..317b8b9ac 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -56,7 +58,7 @@ SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_9.result()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 10) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_9f")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("COMPSOLID", "Extrusion_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Shell.py index f43929d82..f2d4c518d 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_CompSolid_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -42,9 +44,9 @@ SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint() SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result()) model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchLine_6 = Sketch_2.addLine(26.29086071781277, 6.827405438264643, 9.220324256871813, 6.827405438264643) -SketchLine_7 = Sketch_2.addLine(9.220324256871813, 6.827405438264643, 9.220324256871813, -3.640935176083419) -SketchLine_8 = Sketch_2.addLine(9.220324256871813, -3.640935176083419, 26.29086071781277, -3.640935176083419) +SketchLine_6 = Sketch_2.addLine(26.29086071781277, 6.827405438264643, 9.220324256871812, 6.827405438264643) +SketchLine_7 = Sketch_2.addLine(9.220324256871812, 6.827405438264643, 9.220324256871812, -3.640935176083419) +SketchLine_8 = Sketch_2.addLine(9.220324256871812, -3.640935176083419, 26.29086071781277, -3.640935176083419) SketchLine_9 = Sketch_2.addLine(26.29086071781277, -3.640935176083419, 26.29086071781277, 6.827405438264643) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_6.startPoint()) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) @@ -59,7 +61,7 @@ SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_10.startPoint SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_8.result()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 10) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_10r"), model.selection("FACE", "Sketch_2/Face-SketchLine_6f-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_10r"), model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_10f-SketchLine_8f-SketchLine_9f")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("COMPSOLID", "Extrusion_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_EdgeCompound_EdgeCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_EdgeCompound_EdgeCompound.py index ad29cd18d..ac4c913fd 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_EdgeCompound_EdgeCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_EdgeCompound_EdgeCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -34,8 +36,8 @@ SketchLine_4 = Sketch_1.addLine(31.27467463593981, 24.52070441885453, 55.1316738 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.startPoint(), SketchLine_3.result()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_3.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3")]) Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_2_2")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_2_1")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Edge_Edge.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Edge_Edge.py index 69b8e39f8..edee7c4f8 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Edge_Edge.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Edge_Edge.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,7 @@ SketchLine_2 = Sketch_1.addLine(-81.47249047471176, -8.020952206935315, 40.54932 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_1.result()) SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.endPoint()) 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")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_1")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py new file mode 100644 index 000000000..1c1143fbd --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_ErrorMsg.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Box_1_1")]) +assert(Common_1.feature().error() != "") +Part_1_doc.removeFeature(Common_1.feature()) + +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Box_1_1")], []) +assert(Common_1.feature().error() != "") +Part_1_doc.removeFeature(Common_1.feature()) + +model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Common_1 = Part_1_doc.addFeature("Common") +Common_1.execute() +assert(Common_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_FaceCompound_FaceCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_FaceCompound_FaceCompound.py index 23195447d..f0dd9175f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_FaceCompound_FaceCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_FaceCompound_FaceCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -76,8 +78,8 @@ SketchConstraintVertical_7 = Sketch_2.setVertical(SketchLine_14.result()) SketchConstraintHorizontal_8 = Sketch_2.setHorizontal(SketchLine_15.result()) SketchConstraintVertical_8 = Sketch_2.setVertical(SketchLine_16.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_12f"), model.selection("FACE", "Sketch_2/Face-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchLine_16f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10f-SketchLine_11f-SketchLine_12f"), model.selection("FACE", "Sketch_2/Face-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchLine_16f")]) 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")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Face.py index 0c2edd99d..9a6edb525 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -52,7 +54,7 @@ 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() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f-SketchLine_8f")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_1_2")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py new file mode 100644 index 000000000..6b86e5dba --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Face_Plane.py @@ -0,0 +1,51 @@ +## Copyright (C) 2018-20xx 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(32.87583448774056, -21.97399556638079, -28.86536213173501, -21.97399556638079) +SketchLine_2 = Sketch_1.addLine(-28.86536213173501, -21.97399556638079, -28.86536213173501, 32.11012709159006) +SketchLine_3 = Sketch_1.addLine(-28.86536213173501, 32.11012709159006, 32.87583448774056, 32.11012709159006) +SketchLine_4 = Sketch_1.addLine(32.87583448774056, 32.11012709159006, 32.87583448774056, -21.97399556638079) +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() +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 0, False) +Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_1")]) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Common_1, 0) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_ShellCompound_ShellCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_ShellCompound_ShellCompound.py index 8cb5b9078..6e6060d4c 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_ShellCompound_ShellCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_ShellCompound_ShellCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -88,9 +90,9 @@ SketchLine_20 = Sketch_2.addLine(62.43123950606181, 3.491482965931855, 86.073169 SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_20.startPoint(), SketchLine_17.result()) SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_19.result()) model.do() -Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_9r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_9f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_10f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_7f-SketchLine_8f-SketchLine_10r")] +Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_9r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_9f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_10f"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_10r-SketchLine_7f-SketchLine_8f")] Shell_1 = model.addShell(Part_1_doc, Shell_1_objects) -Shell_2_objects = [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_12f-SketchLine_14f-SketchLine_15f"), model.selection("FACE", "Sketch_2/Face-SketchLine_12f-SketchLine_13f-SketchLine_14f-SketchLine_15r"), model.selection("FACE", "Sketch_2/Face-SketchLine_16f-SketchLine_17f-SketchLine_19f-SketchLine_20f"), model.selection("FACE", "Sketch_2/Face-SketchLine_17f-SketchLine_18f-SketchLine_19f-SketchLine_20r")] +Shell_2_objects = [model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12f-SketchLine_15f-SketchLine_14f"), model.selection("FACE", "Sketch_2/Face-SketchLine_12f-SketchLine_13f-SketchLine_14f-SketchLine_15r"), model.selection("FACE", "Sketch_2/Face-SketchLine_16f-SketchLine_17f-SketchLine_20f-SketchLine_19f"), model.selection("FACE", "Sketch_2/Face-SketchLine_17f-SketchLine_18f-SketchLine_19f-SketchLine_20r")] 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")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Shell_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Shell_Shell.py index 5930b955e..e552c0000 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Shell_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Shell_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -58,8 +60,8 @@ SketchLine_10 = Sketch_2.addLine(-61.96570844393754, -12.80210420841683, -27.699 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_10.startPoint(), SketchLine_7.result()) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_9.result()) model.do() -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f")]) -Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10f"), model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7r-SketchLine_9r-SketchLine_10r")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_5f-SketchLine_3f-SketchLine_4f")]) +Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_10f-SketchLine_9r-SketchLine_8r-SketchLine_7r"), model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10r-SketchLine_7r-SketchLine_6r")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_2_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Face.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Face.py index 29b3e9109..38b7a13cb 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -65,8 +67,8 @@ SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_10.result()) SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_11.result()) SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9f-SketchLine_10f-SketchLine_11f-SketchLine_12f")]) -Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10f-SketchLine_11f-SketchLine_12f")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("COMPOUND", "Compound_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Shell.py index 7435166fd..6335dcd9d 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -68,7 +70,7 @@ SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_13.endPoint() SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_15.endPoint()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 10) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10r-SketchLine_14r-SketchLine_15f"), model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_15r")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_14r-SketchLine_15f-SketchLine_10r-SketchLine_9r"), model.selection("FACE", "Sketch_2/Face-SketchLine_15r-SketchLine_13r-SketchLine_12r-SketchLine_11r")]) Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("COMPOUND", "Compound_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_SolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_SolidCompound.py index 37bf47049..eb65219ec 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_SolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SolidCompound_SolidCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Face.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Face.py index 36cee473d..ce3da4b77 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,7 +29,7 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_1.addCircle(-19.01903137581643, 2.528314065029049, 44.55011038017909) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")]) Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10) Common_1 = model.addCommon(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Sphere_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Shell.py index c9364c2bc..b5ca6b4fb 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,7 +43,7 @@ SketchLine_5 = Sketch_1.addLine(4.250501002003999, 22.87174348697394, 4.25050100 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_1.result()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result()) model.do() -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_5f-SketchLine_3f-SketchLine_4f")]) Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10) Common_1 = model.addCommon(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SOLID", "Sphere_1_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Solid.py index cd4fd2ade..9cda92d25 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Solid_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py new file mode 100644 index 000000000..69d741673 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SubCompound_Solid.py @@ -0,0 +1,52 @@ +## Copyright (C) 2018-20xx 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(3.367708126821666, -16.14093028927689, 18.51144913400999) +SketchCircle_2 = Sketch_1.addCircle(37.37680688568888, 37.3768068856889, 21.5270932014419) +SketchCircle_3 = Sketch_1.addCircle(-3.554756249974806, 10.65828989222541, 8.503732568675463) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Compound_1_objects = [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3")] +Compound_1 = model.addCompound(Part_1_doc, Compound_1_objects) +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1"), model.selection("SOLID", "Compound_1_1_3")], [model.selection("SOLID", "Box_1_1")]) +model.do() + +model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Common_1, 1) +model.testNbSubResults(Common_1, [3]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [14]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [48]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [96]) +model.testResultsVolumes(Common_1, [15007.623169576811051229014992714]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py new file mode 100644 index 000000000..42be4686c --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_SubSolid_Solid.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5, True) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")]) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 3, 3, 3) +Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Partition_1_1_2")], [model.selection("SOLID", "Translation_1_1")]) +model.do() + +model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Common_1, 1) +model.testNbSubResults(Common_1, [2]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [13]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [56]) +model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [112]) +model.testResultsVolumes(Common_1, [745]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_VertexCompound_VertexCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_VertexCompound_VertexCompound.py index e3389a117..99b823f5c 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_VertexCompound_VertexCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_VertexCompound_VertexCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -29,8 +31,8 @@ SketchPoint_1 = Sketch_1.addPoint(-28.13426853707415, 23.27655310621242) SketchPoint_2 = Sketch_1.addPoint(10.32264529058116, 23.27655310621242) SketchPoint_3 = Sketch_1.addPoint(47.56513026052106, 23.27655310621242) model.do() -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")]) -Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_3")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_2")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/SketchPoint_3")]) Compound_1 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Vertex_2_1"), model.selection("VERTEX", "Vertex_2_2")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Vertex_Vertex.py index c89dda3f3..8e18283a2 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Vertex_Vertex.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Vertex_Vertex.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,16 +30,16 @@ Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchPoint_1 = Sketch_1.addPoint(15.05904629113425, 12.50050543761873) SketchPoint_2 = Sketch_1.addPoint(47.25352258215165, 31.63008715695855) model.do() -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_2")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2")]) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchPoint_3 = Sketch_2.addPoint(15.05904629113425, 12.50050543761873) -SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchPoint_1"), False) SketchPoint_4 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchPoint_4.result()) model.do() -Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/Vertex-SketchPoint_3-SketchProjection_1-SketchPoint_4")]) -Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/SketchPoint_3")]) +Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")]) Common_2 = model.addCommon(Part_1_doc, [model.selection("VERTEX", "Vertex_2_1"), model.selection("VERTEX", "Vertex_3_1")]) model.testHaveNamingSubshapes(Common_2, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_WireCompound_WireCompound.py b/src/FeaturesPlugin/Test/TestBooleanCommon_WireCompound_WireCompound.py index 5d06579a2..ed878934a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_WireCompound_WireCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_WireCompound_WireCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -36,30 +38,30 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_5 = Sketch_2.addLine(-75.23467769579756, 14.76574658950986, -60.62456998069012, -7.998839850308684) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_6 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_6.result()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_6).endPoint(), SketchLine_5.endPoint()) SketchLine_7 = Sketch_2.addLine(-60.62456998069012, -7.998839850308684, -47.51524103341781, 13.8500417284785) SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_8 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.result()) SketchLine_9 = Sketch_2.addLine(35.74952364371219, 12.81217486039606, 47.60078384600371, -9.954719738742909) -SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_3"), False) SketchLine_10 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_9.startPoint(), SketchLine_10.result()) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_10).endPoint(), SketchLine_9.endPoint()) SketchLine_11 = Sketch_2.addLine(47.60078384600371, -9.954719738742909, 64.13719888777418, 18.68151118724985) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_11.startPoint()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_12 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.result()) 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_7")]) -Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_11")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_7")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_2/SketchLine_11")]) 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")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCommon_Wire_Wire.py b/src/FeaturesPlugin/Test/TestBooleanCommon_Wire_Wire.py index 0e802ce83..3ead1bf48 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCommon_Wire_Wire.py +++ b/src/FeaturesPlugin/Test/TestBooleanCommon_Wire_Wire.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -33,18 +35,18 @@ SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_3 = Sketch_2.addLine(-15.313984501828, -1.226571041729713, -1.296213364851965, -18.43019925529121) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_4 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.startPoint(), SketchLine_4.result()) SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_4).endPoint(), SketchLine_3.endPoint()) SketchLine_5 = Sketch_2.addLine(-1.296213364851965, -18.43019925529121, 20.70651786493702, 7.831125115747244) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_5.startPoint()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_6 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result()) 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_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_5")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_5")]) Common_1 = model.addCommon(Part_1_doc, [model.selection("WIRE", "Wire_1_1"), model.selection("WIRE", "Wire_2_1")]) model.testHaveNamingSubshapes(Common_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py index 638f27955..1ab01779a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py +++ b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py @@ -93,14 +93,7 @@ aSession.startOperation() extrudedObjects = [] for eachSketchFeature in [aCircleSketchFeature, aTriangleSketchFeature]: # Build sketch faces - aSketchResult = eachSketchFeature.firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(eachSketchFeature.attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(eachSketchFeature.attribute("DirX")).dir() - norm = geomDataAPI_Dir(eachSketchFeature.attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) + aSketchResult = modelAPI_ResultConstruction(eachSketchFeature.firstResult()) # Create extrusion on them anExtrusionFt = aPart.addFeature("Extrusion") anExtrusionFt.selectionList("base").append( diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py index 3df97a612..82f6ceff0 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolidCompound_CompSolidCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -47,7 +49,7 @@ 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")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_2"), model.selection("COMPSOLID", "Extrusion_2_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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py index 5d20e521f..5328ea5bd 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_CompSolid_CompSolid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -32,7 +34,7 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_2 = Sketch_2.addCircle(32.08143103297851, 1.286314091165838, 40.2404383217231) -SketchLine_2 = Sketch_2.addLine(-8.153954725266397, 0.6486549270159857, 72.23884334545456, 3.869938036363647) +SketchLine_2 = Sketch_2.addLine(-8.153954725266397, 0.6486549270159857, 72.23884334545455, 3.869938036363647) 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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py new file mode 100644 index 000000000..6e858996a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Compound_Solid.py @@ -0,0 +1,45 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), 20) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Translation_1_1")]) +Box_3 = model.addBox(Part_1_doc, 20, 6, 20) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], -5, 2, -5) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Compound_1_1_1")], [model.selection("SOLID", "Translation_2_1")]) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Cut_1, 1) +model.testNbSubResults(Cut_1, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.FACE, [18]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [72]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [144]) +model.testResultsVolumes(Cut_1, [1400]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py index 45674c700..1e361757b 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_EdgeCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,8 +32,8 @@ SketchLine_2 = Sketch_1.addLine(-13.21145377197118, 31.16583469441819, 14.897138 SketchLine_3 = Sketch_1.addLine(-5.074756009927738, 49.65832960815328, -4.828189411077946, 26.48106931627197) SketchLine_4 = Sketch_1.addLine(7.993273729111718, 49.41176300930348, 8.23984032796152, 26.48106931627197) 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")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py index 9d51ddc1c..0ae1a159f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_EdgeCompound_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,7 +30,7 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(-28.62948623265935, 53.77363153293705, 40.23707952134417, 53.11775947813702) SketchLine_2 = Sketch_1.addLine(-26.66187006825925, 26.22700523133564, 40.89295157614425, 26.22700523133564) 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_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/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) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py index ccd2c2c30..b7d16f2e6 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Edge.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,7 +30,7 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(-25.12006861063466, 20.61578044596912, 27.54545454545454, 58.72898799313897) SketchLine_2 = Sketch_1.addLine(-19.22984562607204, 56.30360205831907, 22.69468267581474, 22.00171526586621) 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")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py index 5e8d25fe1..91d9df2a4 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Edge_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,8 +43,8 @@ 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")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f_wire")]) 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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py new file mode 100644 index 000000000..254980392 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanCut_ErrorMsg.py @@ -0,0 +1,36 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Cut_1 = aPart.addFeature("Cut") +Cut_1.execute() +assert(Cut_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py index d3c727e67..daf6e38d3 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_FaceCompound_FaceCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -32,8 +34,8 @@ Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_3 = Sketch_2.addCircle(-15.35052744425385, 1.145561749571189, 23.35148318113706) SketchCircle_4 = Sketch_2.addCircle(82.70955831903943, -3.436685248713552, 26.06650182177207) 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")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2"), model.selection("EDGE", "Sketch_1/SketchCircle_2_2")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/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")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py index f314c44d5..6cdfcddc7 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -25,9 +27,9 @@ 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 = Sketch_1.addCircle(-6.063464837049752, 0.8662092624356817, 32.2304349637617) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py index bd0752f91..07c2e15c7 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Face_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,7 +29,7 @@ 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) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/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_2 = Sketch_2.addLine(-8.272875875352462, 55.29739830292169, -8.272875875352462, -5.036618941767999) @@ -42,11 +44,11 @@ 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) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_1r-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_objects = [model.selection("VERTEX", "Cut_1_1/Generated_Vertex&Sketch_2/SketchLine_3&Face_1_1/Edge_1"), model.selection("FACE", "Cut_1_1"), model.selection("FACE", "Cut_1_1"), model.selection("VERTEX", "Cut_1_1/Generated_Vertex&Face_1_1/Face_1_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_objects = [model.selection("FACE", "Cut_1_1"), model.selection("EDGE", "Cut_1_1/Generated_Edge&Sketch_2/SketchLine_3&Face_1_1/Face_1_1"), model.selection("VERTEX", "Cut_1_1/Generated_Vertex&Face_1_1/Face_1_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) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py index 9bed1636b..d7ecbef44 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_ShellCompound_ShellCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -44,9 +46,9 @@ SketchLine_4 = Sketch_2.addLine(207.6267015097382, 3.521847530670962, 440.264781 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_objects = [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_1_2r-SketchLine_1f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchLine_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-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_objects = [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2r-SketchLine_3f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2r-SketchCircle_3_2r-SketchLine_3r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f-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")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py b/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py index 0757d3a9b..e09a76193 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Shell_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -36,7 +38,7 @@ SketchLine_2 = Sketch_2.addLine(112.0898160449407, 1.460291967886176, -7.7048053 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_objects = [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r-SketchCircle_2_2r-SketchLine_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r-SketchLine_2f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_1_2r-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) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py index 987532453..f8803c16b 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_SolidCompound_SolidCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -34,8 +36,8 @@ SketchCircle_4 = Sketch_2.addCircle(78.03127953954764, -3.93858425080257, 22.765 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")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_2"), model.selection("SOLID", "Extrusion_2_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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py index 602d704bf..36fc87b1a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Solid_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py index 681a33893..4cfcc864c 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,7 @@ SketchPoint_2 = Sketch_1.addPoint(-27.26436963979418, 34.59596483704974) SketchPoint_3 = Sketch_1.addPoint(25.43147084048027, 34.59596483704974) SketchPoint_4 = Sketch_1.addPoint(54.29962692967411, 33.67951543739281) 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_objects = [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/SketchPoint_3"), model.selection("VERTEX", "Sketch_1/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) @@ -46,7 +48,7 @@ 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) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_1r-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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py index 702fa1e9c..314fb4efa 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_VertexCompound_VertexCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,9 +32,9 @@ SketchPoint_2 = Sketch_1.addPoint(-27.26436963979418, 34.59596483704974) SketchPoint_3 = Sketch_1.addPoint(25.43147084048027, 34.59596483704974) SketchPoint_4 = Sketch_1.addPoint(54.29962692967411, 33.67951543739281) 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_objects = [model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/SketchPoint_3"), model.selection("VERTEX", "Sketch_1/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")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py index cc53f7725..5015061a4 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Vertex_Vertex.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,13 +30,12 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchPoint_1 = Sketch_1.addPoint(0, 50) SketchPoint_2 = Sketch_1.addPoint(0, 25) 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")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")]) +Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_1")]) +Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py b/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py index baf9bc921..8b37dcefc 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_WireCompound_WireCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -33,17 +35,17 @@ SketchLine_4 = Sketch_1.addLine(33.43567753001715, 55.95711835334479, 50.7598627 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_6 = Sketch_2.addLine(-42.44425385934821, 35.51457975986279, -16.1114922813036, 69.1234991423671) +SketchLine_5 = Sketch_2.addLine(-67.39108061749573, 66.69811320754719, -42.44425385934821, 35.51457975986279) +SketchLine_6 = Sketch_2.addLine(-42.44425385934821, 35.51457975986279, -16.1114922813036, 69.12349914236709) 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 = Sketch_2.addLine(12.64665523156088, 66.69811320754719, 35.16809605488852, 36.5540308747856) SketchLine_8 = Sketch_2.addLine(35.16809605488852, 36.5540308747856, 52.49228130360206, 66.35162950257292) 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")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_6")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/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")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py index 9739b75fa..6a9f8d678 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -34,9 +36,9 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_2.addCircle(3.984562607204112, 58.72898799313897, 38.16357190022508) 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_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/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")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py index 0944b7ea5..3b608b1a8 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py +++ b/src/FeaturesPlugin/Test/TestBooleanCut_Wire_Wire.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -34,9 +36,9 @@ SketchLine_4 = Sketch_1.addLine(-58.79960075346089, 25.5711331765356, 3.50824445 SketchLine_5 = Sketch_1.addLine(3.508244452542322, 60.3323520809374, 63.1926014393454, 22.94764495733547) 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_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/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")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/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() diff --git a/src/FeaturesPlugin/Test/TestBooleanFill.py b/src/FeaturesPlugin/Test/TestBooleanFill.py index 449508b03..c181b3744 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFill.py +++ b/src/FeaturesPlugin/Test/TestBooleanFill.py @@ -18,50 +18,25 @@ ## email : webmaster.salome@opencascade.com ## -""" -Test case for Boolean Fill feature. Written on High API. -""" -from ModelAPI import * -from GeomAPI import * +# -*- coding: utf-8 -*- from salome.shaper import model -# Get session -aSession = ModelAPI_Session.get() - -# Create a part -aDocument = aSession.activeDocument() -aSession.startOperation() -model.addPart(aDocument) -aDocument = aSession.activeDocument() -aSession.finishOperation() - -# Create a sketch with circle to extrude -aSession.startOperation() -anOrigin = GeomAPI_Pnt(0, 0, 0) -aDirX = GeomAPI_Dir(1, 0, 0) -aNorm = GeomAPI_Dir(0, 0, 1) -aCircleSketch = model.addSketch(aDocument, GeomAPI_Ax3(anOrigin, aDirX, aNorm)) -aCircleSketch.addCircle(0, 0, 50) -aSession.finishOperation() - -# Create a sketch with triangle to extrude -aSession.startOperation() -aTriangleSketch = model.addSketch(aDocument, GeomAPI_Ax3(anOrigin, aDirX, aNorm)) -aTriangleSketch.addLine(25, 25, 100, 25) -aTriangleSketch.addLine(100, 25, 60, 75) -aTriangleSketch.addLine(60, 75, 25, 25) -aSession.finishOperation() - -# Make extrusion on circle (cylinder) and triangle (prism) -aSession.startOperation() -anExtrusion = model.addExtrusion(aDocument, aCircleSketch.results() + aTriangleSketch.results(), 100) -aSession.finishOperation() - -# Fill prism with cylinder -aSession.startOperation() -aBoolean = model.addFill(aDocument, [anExtrusion.results()[0]], [anExtrusion.results()[1]]) -assert (len(aBoolean.results()) > 0) -aSession.finishOperation() - +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(0, 0, 50) +model.do() +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_2.addLine(25, 25, 100, 25) +SketchLine_2 = Sketch_2.addLine(100, 25, 60, 75) +SketchLine_3 = Sketch_2.addLine(60, 75, 25, 25) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1"), model.selection("COMPOUND", "Sketch_2")], model.selection(), 100, 0) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_1_2")]) +model.do() +model.end() +assert (len(Fill_1.results()) > 0) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanFillWithPlane.py b/src/FeaturesPlugin/Test/TestBooleanFillWithPlane.py index eeb224064..ed575a9b7 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFillWithPlane.py +++ b/src/FeaturesPlugin/Test/TestBooleanFillWithPlane.py @@ -18,6 +18,10 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + +from GeomAPI import GeomAPI_Pnt + from salome.shaper import model model.begin() @@ -50,22 +54,20 @@ SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_6.result()) SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_8.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("FACE", "PartSet/YOZ")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", GeomAPI_Pnt(17.35551764280096, -11.01190794150899, 0))], model.selection(), 100, 0) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", GeomAPI_Pnt(-0.3180832609141306, -28.0220443670531, 50.00000000000001))], [model.selection("FACE", "PartSet/YOZ")]) model.do() - -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) - +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() from GeomAPI import GeomAPI_Shape -model.testNbResults(Boolean_1, 1) -model.testNbSubResults(Boolean_1, [4]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [4]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [30]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [132]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [264]) -model.testResultsVolumes(Boolean_1, [11003613.329450136050581932067871094]) +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [4]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [4]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [30]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [132]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [264]) +model.testResultsVolumes(Fill_1, [11003613.329450136050581932067871094]) assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py new file mode 100644 index 000000000..612fdf486 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanFill_ErrorMsg.py @@ -0,0 +1,36 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +aSession.startOperation() +Fill_1 = aPart.addFeature("Fill") +Fill_1.execute() +assert(Fill_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolidCompound_CompSolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolidCompound_CompSolidCompound.py index ca8aae00d..5267db93a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolidCompound_CompSolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolidCompound_CompSolidCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -74,8 +76,8 @@ SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_17.endPoint() model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 50, -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")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_2"), model.selection("COMPSOLID", "Extrusion_1_1")]) +Compound_2 = model.addCompound(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_2"), model.selection("COMPSOLID", "Extrusion_2_1")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")], True) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_CompSolid.py b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_CompSolid.py index a5d5577e0..5140319a5 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_CompSolid.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_CompSolid.py @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py new file mode 100644 index 000000000..90d0037bb --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_CompSolid_Face.py @@ -0,0 +1,66 @@ +## Copyright (C) 2018-20xx 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 +from GeomAPI import GeomAPI_Shape + +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")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(52.27216563767099, 0, 18.66006927176168) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center()) +SketchCircle_2 = Sketch_1.addCircle(79.68333887668101, 0, 24.16077154338278) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_2 = Sketch_2.addLine(73.13136007081269, -14.25937060400964, 2.118687665902372, -14.25937060400964) +SketchLine_3 = Sketch_2.addLine(2.118687665902372, -14.25937060400964, 2.118687665902372, 26.70061277610758) +SketchLine_4 = Sketch_2.addLine(2.118687665902372, 26.70061277610758, 73.13136007081269, 26.70061277610758) +SketchLine_5 = Sketch_2.addLine(73.13136007081269, 26.70061277610758, 73.13136007081269, -14.25937060400964) +SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_6 = 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() +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r")]) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], [model.selection("FACE", "Face_1_1")]) + +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [2]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [4]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [16]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [32]) +model.testResultsVolumes(Fuse_1, [785.398163397447774514148477465]) + +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Extrusion_1_1_1")], [model.selection("FACE", "Fuse_1_1_1")]) +assert(Fuse_2.feature().error() != "") + +model.end() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_EdgeCompound_EdgeCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_EdgeCompound_EdgeCompound.py index 14a1cb140..904b8dd34 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_EdgeCompound_EdgeCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_EdgeCompound_EdgeCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -32,7 +34,7 @@ Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_3 = Sketch_2.addLine(-70.53968253968257, 29.92592592592593, -31.52910052910054, -5.343915343915344) SketchLine_4 = Sketch_2.addLine(14.96296296296294, 26.18518518518519, 50.23280423280426, -8.015873015873021) model.do() -Edge_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4")] +Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4")] Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Edge_Edge.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Edge_Edge.py index 3a3a78be3..faecb17e3 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Edge_Edge.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Edge_Edge.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,7 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_2 = Sketch_2.addLine(-24.04761904761907, 40.07936507936508, 39.54497354497357, -14.96296296296296) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_2/SketchLine_2")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_1")]) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py new file mode 100644 index 000000000..1801cab5a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_ErrorMsg.py @@ -0,0 +1,52 @@ +## Copyright (C) 2018-20xx 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() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1"), model.selection("FACE", "PartSet/XOZ")]) + +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")]) +assert(Fuse_1.feature().error() != "") +Part_1_doc.removeFeature(Fuse_1.feature()) + +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_2")]) +assert(Fuse_1.feature().error() != "") +Part_1_doc.removeFeature(Fuse_1.feature()) + +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")], [model.selection("SOLID", "Partition_1_1_2")]) +assert(Fuse_1.feature().error() != "") +Part_1_doc.removeFeature(Fuse_1.feature()) +model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Fuse_1 = Part_1_doc.addFeature("Fuse") +Fuse_1.execute() +assert(Fuse_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_FaceCompound_FaceCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_FaceCompound_FaceCompound.py index d9cebddfd..33a3ff96f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_FaceCompound_FaceCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_FaceCompound_FaceCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -32,9 +34,9 @@ Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_3 = Sketch_2.addCircle(-36.12101408450705, -7.148950704225357, 25.24032590912034) SketchCircle_4 = Sketch_2.addCircle(51.92395774647893, -12.41659859154929, 31.3630728131964) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")]) Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2r")]) Face_4 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")]) Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_4_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py index a7f012ab2..c9b803e50 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Face_Face.py @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -31,8 +32,8 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_2 = Sketch_2.addCircle(22.86792452830187, 26.50600343053173, 30.90704565816075) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")], True) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_RemoveEdges.py b/src/FeaturesPlugin/Test/TestBooleanFuse_RemoveEdges.py index 6065be805..b1ab2c6ae 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_RemoveEdges.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_RemoveEdges.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_ShellCompound_ShellCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_ShellCompound_ShellCompound.py index df924e429..79d4d308d 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_ShellCompound_ShellCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_ShellCompound_ShellCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -72,7 +74,7 @@ SketchLine_20 = Sketch_2.addLine(31.63598289786226, 11.9441976247031, 52.2962166 SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_16.startPoint(), SketchLine_20.startPoint()) SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchLine_20.endPoint()) model.do() -Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_4r-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchLine_3r-SketchLine_5f"), model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_9r-SketchLine_10r"), model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_8r-SketchLine_10f"), model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12r-SketchLine_15f"), model.selection("FACE", "Sketch_2/Face-SketchLine_13r-SketchLine_14r-SketchLine_15r"), model.selection("FACE", "Sketch_2/Face-SketchLine_16r-SketchLine_17r-SketchLine_20f"), model.selection("FACE", "Sketch_2/Face-SketchLine_18r-SketchLine_19r-SketchLine_20r")] +Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_5r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r"), model.selection("FACE", "Sketch_1/Face-SketchLine_9r-SketchLine_10r-SketchLine_6r"), model.selection("FACE", "Sketch_1/Face-SketchLine_10f-SketchLine_8r-SketchLine_7r"), model.selection("FACE", "Sketch_2/Face-SketchLine_15f-SketchLine_12r-SketchLine_11r"), model.selection("FACE", "Sketch_2/Face-SketchLine_15r-SketchLine_14r-SketchLine_13r"), model.selection("FACE", "Sketch_2/Face-SketchLine_20f-SketchLine_17r-SketchLine_16r"), model.selection("FACE", "Sketch_2/Face-SketchLine_20r-SketchLine_19r-SketchLine_18r")] Shell_1 = model.addShell(Part_1_doc, Shell_1_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_1_3"), model.selection("SHELL", "Shell_1_4")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Shell_Shell.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Shell_Shell.py index 495756723..b612327c6 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Shell_Shell.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Shell_Shell.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -50,7 +52,7 @@ SketchLine_10 = Sketch_2.addLine(-84.57783182897859, 11.29856532066509, -60.6894 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_6.startPoint(), SketchLine_10.startPoint()) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_10.endPoint()) model.do() -Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_4r-SketchLine_5r"), model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchLine_3r-SketchLine_5f"), model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7r-SketchLine_10f"), model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_9r-SketchLine_10r")] +Shell_1_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_5r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r"), model.selection("FACE", "Sketch_2/Face-SketchLine_10f-SketchLine_7r-SketchLine_6r"), model.selection("FACE", "Sketch_2/Face-SketchLine_10r-SketchLine_9r-SketchLine_8r")] Shell_1 = model.addShell(Part_1_doc, Shell_1_objects) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SHELL", "Shell_1_1"), model.selection("SHELL", "Shell_1_2")], True) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_SimpleMode.py b/src/FeaturesPlugin/Test/TestBooleanFuse_SimpleMode.py index e985d2876..7f7dba73e 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_SimpleMode.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_SimpleMode.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_SolidCompound_SolidCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_SolidCompound_SolidCompound.py index 3cd98f2ef..c5fdfc25a 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_SolidCompound_SolidCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_SolidCompound_SolidCompound.py @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -79,7 +80,7 @@ SketchConstraintHorizontal_8 = Sketch_2.setHorizontal(SketchLine_15.result()) SketchConstraintVertical_8 = Sketch_2.setVertical(SketchLine_16.result()) model.do() Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), 40, -20) -Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Solid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Solid_Solid.py index 809ff19f6..51f95d569 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Solid_Solid.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Solid_Solid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -38,7 +40,7 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 50, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 50, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_5 = Sketch_2.addLine(-38.01624011480907, 11.11021000825241, -18.03083750064881, 11.11021000825241) SketchLine_6 = Sketch_2.addLine(-18.03083750064881, 11.11021000825241, -18.03083750064881, 22.05701811772883) @@ -53,7 +55,7 @@ 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_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 30, -20) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f-SketchLine_8f_wire")], model.selection(), 30, -20) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_VertexCompound_VertexCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_VertexCompound_VertexCompound.py index 3a497f317..23e9bf54c 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_VertexCompound_VertexCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_VertexCompound_VertexCompound.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,7 @@ SketchPoint_2 = Sketch_1.addPoint(18.16931216931219, 17.1005291005291) SketchPoint_3 = Sketch_1.addPoint(-19.77248677248678, -16.03174603174603) SketchPoint_4 = Sketch_1.addPoint(21.37566137566138, -16.03174603174603) model.do() -Vertex_1_objects = [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_3"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_4"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")] +Vertex_1_objects = [model.selection("VERTEX", "Sketch_1/SketchPoint_3"), model.selection("VERTEX", "Sketch_1/SketchPoint_1"), model.selection("VERTEX", "Sketch_1/SketchPoint_4"), model.selection("VERTEX", "Sketch_1/SketchPoint_2")] Vertex_1 = model.addVertex(Part_1_doc, Vertex_1_objects) Compound_1 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2")]) Compound_2 = model.addCompound(Part_1_doc, [model.selection("VERTEX", "Vertex_1_3"), model.selection("VERTEX", "Vertex_1_4")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Vertex_Vertex.py index 70ce3aad8..c246d7f39 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Vertex_Vertex.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Vertex_Vertex.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,7 +30,7 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchPoint_1 = Sketch_1.addPoint(-6.078627161807992, -0.4501231771005025) SketchPoint_2 = Sketch_1.addPoint(7.482208269631659, 3.929326826374309) model.do() -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchPoint_2"), model.selection("VERTEX", "Sketch_1/SketchPoint_1")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_1_2")]) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_WireCompound_WireCompound.py b/src/FeaturesPlugin/Test/TestBooleanFuse_WireCompound_WireCompound.py index b7473f690..3a27c8a0c 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_WireCompound_WireCompound.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_WireCompound_WireCompound.py @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -41,10 +42,10 @@ SketchLine_7 = Sketch_2.addLine(13.49417304964538, 51.08508368794326, 35.9844614 SketchLine_8 = Sketch_2.addLine(35.98446146572105, 27.95221560283687, 53.3341125295508, 47.87218534278959) 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")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_6")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/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")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1"), model.selection("COMPOUND", "Compound_2_1")]) diff --git a/src/FeaturesPlugin/Test/TestBooleanFuse_Wire_Wire.py b/src/FeaturesPlugin/Test/TestBooleanFuse_Wire_Wire.py index 0cb778f8e..c4261102f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanFuse_Wire_Wire.py +++ b/src/FeaturesPlugin/Test/TestBooleanFuse_Wire_Wire.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -34,8 +36,8 @@ SketchLine_3 = Sketch_2.addLine(-23.92129524945932, 7.630068312327553, -4.124361 SketchLine_4 = Sketch_2.addLine(-4.124361249906777, 34.02598031173091, 14.43526437467373, 6.392759937355498) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.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_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4")]) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("WIRE", "Wire_1_1"), model.selection("WIRE", "Wire_2_1")]) model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash.py b/src/FeaturesPlugin/Test/TestBooleanSmash.py index 4be9090f0..7cce18735 100644 --- a/src/FeaturesPlugin/Test/TestBooleanSmash.py +++ b/src/FeaturesPlugin/Test/TestBooleanSmash.py @@ -84,18 +84,11 @@ aSession.startOperation() extrudedObjects = [] for eachSketchFeature in [aCircleSketchFeature, aTriangleSketchFeature]: # Build sketch faces - aSketchResult = eachSketchFeature.firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(eachSketchFeature.attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(eachSketchFeature.attribute("DirX")).dir() - norm = geomDataAPI_Dir(eachSketchFeature.attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) + aSketchResult = modelAPI_ResultConstruction(eachSketchFeature.firstResult()) # Create extrusion on them anExtrusionFt = aPart.addFeature("Extrusion") anExtrusionFt.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(50) diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py new file mode 100644 index 000000000..4819afe11 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_CompSolid_Solid.py @@ -0,0 +1,44 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(-0.820365148699405, 7.40718257641344, 6.028904154999336) +SketchCircle_2 = Sketch_1.addCircle(10.62009910116713, 13.94078752172051, 10.99163472554975) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("SOLID", "Box_1_1")]) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Smash_1, 1) +model.testNbSubResults(Smash_1, [4]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [4]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [28]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [120]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [240]) +model.testResultsVolumes(Smash_1, [4980.404017506245509139262139797]) diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py new file mode 100644 index 000000000..519b542e2 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_ErrorMsg.py @@ -0,0 +1,71 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) + +Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")], [model.selection("SOLID", "Cylinder_1_1")]) +assert(Smash_1.feature().error() != "") +Part_1_doc.removeFeature(Smash_1.feature()) + +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Cylinder_1_1/Face_1")]) + +Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("SOLID", "Cylinder_1_1")]) +assert(Smash_1.feature().error() != "") +Part_1_doc.removeFeature(Smash_1.feature()) + +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], [model.selection("FACE", "Face_1_1")]) +assert(Smash_1.feature().error() != "") +Part_1_doc.removeFeature(Smash_1.feature()) + +Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(5, -6, 7) +SketchCircle_2 = Sketch_1.addCircle(14, 0, 8) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) + +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1")], [model.selection("SOLID", "Extrusion_1_1_2")]) +assert(Smash_1.feature().error() != "") +Part_1_doc.removeFeature(Smash_1.feature()) + +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Extrusion_1_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1_1/To_Face")]) + +Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Face_2_1")], [model.selection("FACE", "Face_2_2")]) +assert(Smash_1.feature().error() != "") +Part_1_doc.removeFeature(Smash_1.feature()) + +model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Smash_1 = Part_1_doc.addFeature("Smash") +Smash_1.execute() +assert(Smash_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_Face_Face.py b/src/FeaturesPlugin/Test/TestBooleanSmash_Face_Face.py index 06198375b..56c4b9a9f 100644 --- a/src/FeaturesPlugin/Test/TestBooleanSmash_Face_Face.py +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_Face_Face.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,7 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_2 = Sketch_2.addCircle(12.30017152658664, 14.37907375643225, 29.61574408620473) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")]) Smash_1 = model.addSmash(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_1_2")]) model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc) model.do() diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py b/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py new file mode 100644 index 000000000..9f2ee792f --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBooleanSmash_SubSolid_Solid.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5, True) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1")]) +Box_2 = model.addBox(Part_1_doc, 10, 10, 10) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], 3, 3, 3) +Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Partition_1_1_2")], [model.selection("SOLID", "Translation_1_1")]) +model.do() + +model.testHaveNamingSubshapes(Smash_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Smash_1, 1) +model.testNbSubResults(Smash_1, [3]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.SOLID, [3]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.FACE, [28]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.EDGE, [130]) +model.testNbSubShapes(Smash_1, GeomAPI_Shape.VERTEX, [260]) +model.testResultsVolumes(Smash_1, [1657]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestBoolean_ErrorMsg.py b/src/FeaturesPlugin/Test/TestBoolean_ErrorMsg.py new file mode 100644 index 000000000..17c34dafb --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBoolean_ErrorMsg.py @@ -0,0 +1,42 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/YOZ"), model.selection("SOLID", "Cylinder_1_1")]) + +Cut_1 = model.addCut(Part_1_doc, [], []) +assert(Cut_1.feature().error() != "") +Part_1_doc.removeFeature(Cut_1.feature()) + +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")], []) +assert(Cut_1.feature().error() != "") +Part_1_doc.removeFeature(Cut_1.feature()) + +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Partition_1_1_1")], [model.selection("SOLID", "Partition_1_1_2")]) +assert(Cut_1.feature().error() != "") +Part_1_doc.removeFeature(Cut_1.feature()) +model.end() diff --git a/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py b/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py index 47caabb1d..1df2653bc 100644 --- a/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py +++ b/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py @@ -64,16 +64,8 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") diff --git a/src/FeaturesPlugin/Test/TestExtrusion.py b/src/FeaturesPlugin/Test/TestExtrusion.py index 5e44cac12..158c60feb 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion.py +++ b/src/FeaturesPlugin/Test/TestExtrusion.py @@ -85,24 +85,16 @@ aSession.finishOperation() #========================================================================= # Make extrusion on circle #========================================================================= -# Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +# Build face from sketcher results +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -147,8 +139,7 @@ aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("ByPlanesAndOffsets") anExtrusionFt.real("to_size").setValue(0) #TODO: remove anExtrusionFt.real("from_size").setValue(0) #TODO: remove @@ -213,20 +204,13 @@ aLineEEndPoint.setValue(0., -50.) aSession.finishOperation() # Extrude clamp -aClampSketchResult = aClampSketchFeature.firstResult() -aClampSketchEdges = modelAPI_ResultConstruction(aClampSketchResult).shape() -origin = geomDataAPI_Point(aClampSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aClampSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aClampSketchFeature.attribute("Norm")).dir() -aClampSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aClampSketchEdges, aClampSketchFaces) +aClampSketchResult = modelAPI_ResultConstruction(aClampSketchFeature.firstResult()) aSession.startOperation() aClampExtrusionFt = aPart.addFeature("Extrusion") assert (aClampExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 aClampExtrusionFt.selectionList("base").append( - aClampSketchResult, aClampSketchFaces[0]) + aClampSketchResult, aClampSketchResult.face(0)) aClampExtrusionFt.string("CreationMethod").setValue("BySizes") aClampExtrusionFt.real("to_size").setValue(70) aClampExtrusionFt.real("from_size").setValue(0) @@ -245,14 +229,13 @@ aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 -anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("ByPlanesAndOffsets") anExtrusionFt.real("to_size").setValue(0) #TODO: remove anExtrusionFt.real("from_size").setValue(0) #TODO: remove -anExtrusionFt.selection("to_object").selectSubShape("face", "Extrusion_3_1/Generated_Face_3") +anExtrusionFt.selection("to_object").selectSubShape("face", "Extrusion_3_1/Generated_Face&Sketch_2/SketchLine_3") anExtrusionFt.real("to_offset").setValue(0) -anExtrusionFt.selection("from_object").selectSubShape("face", "Extrusion_3_1/Generated_Face_4") +anExtrusionFt.selection("from_object").selectSubShape("face", "Extrusion_3_1/Generated_Face&Sketch_2/SketchLine_4") anExtrusionFt.real("from_offset").setValue(0) anExtrusionFt.execute() aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut.py b/src/FeaturesPlugin/Test/TestExtrusionCut.py index af4c49179..05a81bef3 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut.py @@ -62,23 +62,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -108,7 +100,7 @@ dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1") +aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face") aSession.startOperation() aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse.py b/src/FeaturesPlugin/Test/TestExtrusionFuse.py index a8c6cb8c3..0ad73b99b 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionFuse.py +++ b/src/FeaturesPlugin/Test/TestExtrusionFuse.py @@ -62,23 +62,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -108,7 +100,7 @@ dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1") +aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face") aSession.startOperation() aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ErrorMsg.py b/src/FeaturesPlugin/Test/TestExtrusion_ErrorMsg.py new file mode 100644 index 000000000..00819d0ef --- /dev/null +++ b/src/FeaturesPlugin/Test/TestExtrusion_ErrorMsg.py @@ -0,0 +1,53 @@ +## Copyright (C) 2018-20xx 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() +Point_2 = model.addPoint(Part_1_doc, 0, 0, 0) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")]) + +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection(), 10, 0) +assert(Extrusion_1.feature().error() != "") +Part_1_doc.removeFeature(Extrusion_1.feature()) + +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(20, 20, 10) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection("EDGE", "PartSet/OX"), 10, 0) +assert(Extrusion_1.feature().error() != "") +Part_1_doc.removeFeature(Extrusion_1.feature()) + +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OX"), 10, 0) +assert(Extrusion_1.feature().error() != "") +Part_1_doc.removeFeature(Extrusion_1.feature()) + +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchArc_1 = Sketch_2.addArc(25, 10, 40, 10, 25, 25, False) +model.do() + +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "Sketch_2/SketchArc_1_2"), 10, 0) +assert(Extrusion_1.feature().error() != "") +Part_1_doc.removeFeature(Extrusion_1.feature()) + +model.end() diff --git a/src/FeaturesPlugin/Test/TestExtrusion_ZeroOffsetError.py b/src/FeaturesPlugin/Test/TestExtrusion_ZeroOffsetError.py new file mode 100644 index 000000000..858f14709 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestExtrusion_ZeroOffsetError.py @@ -0,0 +1,50 @@ +## Copyright (C) 2018-20xx 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(9.631110499908317, -35.9437937189679, 36.19447160731126) +model.do() + +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, -10) +assert(Extrusion_1.feature().error() != "") + +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(114.4867836253828, -21.50233830122853, 11.10986684682035) +SketchCircle_3 = Sketch_2.addCircle(113.4180342136906, 1.426992627069481, 10.29495051811322) +model.do() +Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")]) + +Plane_1 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 10, False) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) +SketchCircle_4 = Sketch_3.addCircle(91.42492988686666, -20.30106607931821, 6.749165188215104) +SketchCircle_5 = Sketch_3.addCircle(88.32466240656791, 2.196618803039243, 8.273170230715275) +model.do() +Compound_2 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_4_2r"), model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2f")]) + +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), model.selection("COMPOUND", "Compound_1_1"), 0, model.selection("COMPOUND", "Compound_2_1"), 0) +assert(Extrusion_2.feature().error() == "") + +model.end() diff --git a/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py b/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py index 832475bb2..e53cbae56 100644 --- a/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py +++ b/src/FeaturesPlugin/Test/TestFillCompFaceSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -50,13 +51,13 @@ SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True) -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Fill_1_1")], [model.selection("SOLID", "Box_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) +Fill_2 = model.addFill(Part_1_doc, [model.selection("COMPOUND", "Fill_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() -model.checkResult(Boolean_2, model, 1, [6], [0], [6], [22], [44]) -model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc) +model.checkResult(Fill_2, model, 1, [6], [0], [6], [22], [44]) +model.testHaveNamingSubshapes(Fill_2, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py b/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py new file mode 100644 index 000000000..555810909 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestFillCompsolidPlane.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(11.92861402549826, 0, 16.05621803603458) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_1.center()) +SketchCircle_2 = Sketch_1.addCircle(37.8779560884558, 0, 17.74637067763095) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.result(), SketchCircle_2.center()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("FACE", "PartSet/XOZ")]) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Fill_1, 1) +model.testNbSubResults(Fill_1, [5]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.FACE, [25]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.EDGE, [90]) +model.testNbSubShapes(Fill_1, GeomAPI_Shape.VERTEX, [180]) +model.testResultsVolumes(Fill_1, [16831.622023411000554915517568588]) diff --git a/src/FeaturesPlugin/Test/TestFillEdgeEdge.py b/src/FeaturesPlugin/Test/TestFillEdgeEdge.py index 0c92a1422..452a91aa1 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeEdge.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeEdge.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -30,18 +31,18 @@ SketchLine_1 = Sketch_1.addLine(-43.24383164005806, 13.92597968069667, 63.179970 model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_2 = Sketch_2.addLine(-21.12944291883177, 24.09981691608177, 39.13933236574746, 51.82677414066782) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_3 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_3.result()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_3.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_2")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("EDGE", "Edge_2_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_2")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("EDGE", "Edge_2_1")]) model.do() -model.checkResult(Boolean_1,model,1,[3],[0],[0],[3],[6]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[3],[0],[0],[3],[6]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeEdgeIntersected.py b/src/FeaturesPlugin/Test/TestFillEdgeEdgeIntersected.py index 5b5ee1cc4..9e4c8dca7 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeEdgeIntersected.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeEdgeIntersected.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -31,13 +32,13 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchLine_2 = Sketch_2.addLine(-42.46271611030479, 53.71965718432511, 14.83075791001449, -51.73354862119014) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_2")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("EDGE", "Edge_2_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_2")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("EDGE", "Edge_2_1")]) model.do() -model.checkResult(Boolean_1,model,1,[2],[0],[0],[2],[4]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[2],[0],[0],[2],[4]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeFace.py b/src/FeaturesPlugin/Test/TestFillEdgeFace.py index 49a082413..fda6db633 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeFace.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -35,16 +36,17 @@ SketchLine_4 = Sketch_1.addLine(13.30716777939044, -81.12733381712628, -65.15998 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchLine_5 = Sketch_2.addLine(-53.77011318694006, -47.84888937635935, 60.89888292381829, 36.13719175945) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_5")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("FACE", "Face_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_5")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("FACE", "Face_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [3], [0], [0], [3], [6]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [3], [0], [0], [3], [6]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeShell.py b/src/FeaturesPlugin/Test/TestFillEdgeShell.py index cd7be482d..c0b99730a 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeShell.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -40,19 +41,19 @@ SketchArc_2 = Sketch_1.addArc(38.14157263904823, 16.22495851193372, 56.770542089 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_2.results()[1]) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchArc_2_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 70, 0) Shell_1 = model.addShell(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")]) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 30, False) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_3 = Sketch_2.addLine(-64.49168769733997, 17.16789081864163, 146.7677170722727, 22.9901626941168) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_3")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SHELL", "Shell_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_3")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SHELL", "Shell_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [3], [0], [0], [3], [6]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [3], [0], [0], [3], [6]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeSolid.py b/src/FeaturesPlugin/Test/TestFillEdgeSolid.py index 943d4e5a7..9cc4c12e7 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeSolid.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -28,19 +29,19 @@ Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) SketchLine_1 = Sketch_1.addLine(4, 10, 7, 0) -SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "Box_1_1/Front&Box_1_1/Top"), False) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), False) SketchLine_2 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) -SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), False) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), False) SketchLine_3 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SOLID", "Box_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [0], [1], [2]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [0], [1], [2]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeSolidIntersected.py b/src/FeaturesPlugin/Test/TestFillEdgeSolidIntersected.py index 5756635e1..630317d66 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeSolidIntersected.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeSolidIntersected.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -36,12 +37,12 @@ SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_1.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 20) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SOLID", "Cone_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("SOLID", "Cone_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [3], [0], [0], [3], [6]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [3], [0], [0], [3], [6]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeVertex.py b/src/FeaturesPlugin/Test/TestFillEdgeVertex.py index 33ba672dc..ce2e768f0 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeVertex.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeVertex.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -27,7 +28,7 @@ model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -Point_1 = model.addPoint(Part_1_doc, 10, 10, 0) +Point_2 = model.addPoint(Part_1_doc, 10, 10, 0) Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")]) Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(-27.61369370623992, 41.69872643310781, 64.30052615729069, -35.76145957046036) @@ -35,12 +36,11 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Point_1") SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchAPI_Point(SketchPoint_1).coordinates()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) model.do() - -model.checkResult(Boolean_1,model,1,[2],[0],[0],[2],[4]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[2],[0],[0],[2],[4]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillEdgeWire.py b/src/FeaturesPlugin/Test/TestFillEdgeWire.py index ead4aeb88..d4ee8813f 100644 --- a/src/FeaturesPlugin/Test/TestFillEdgeWire.py +++ b/src/FeaturesPlugin/Test/TestFillEdgeWire.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -38,13 +39,14 @@ SketchLine_5 = Sketch_2.addLine(55.26415094339622, -34.15529753265602, -40.60522 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_2.startPoint()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("WIRE", "Wire_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], [model.selection("WIRE", "Wire_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [3], [0], [0], [3], [6]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [3], [0], [0], [3], [6]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceEdge.py b/src/FeaturesPlugin/Test/TestFillFaceEdge.py index 5bcc0602a..a16030c88 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceEdge.py +++ b/src/FeaturesPlugin/Test/TestFillFaceEdge.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -35,16 +36,17 @@ SketchLine_4 = Sketch_1.addLine(13.30716777939044, -81.12733381712628, -65.15998 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchLine_5 = Sketch_2.addLine(-53.77011318694006, -47.84888937635935, 60.89888292381829, 36.13719175945) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_5")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_5")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[2],[0],[2],[8],[16]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[2],[0],[2],[8],[16]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceEdgeInside.py b/src/FeaturesPlugin/Test/TestFillFaceEdgeInside.py index 44bd6384a..e28c492c6 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceEdgeInside.py +++ b/src/FeaturesPlugin/Test/TestFillFaceEdgeInside.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -35,19 +36,20 @@ SketchLine_3 = Sketch_1.addLine(-34.74165457184325, -28.87808417997097, -49.4005 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_3.endPoint()) model.do() -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_1r-SketchLine_2r-SketchLine_3r")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchLine_4 = Sketch_2.addLine(-17.59187701681758, -17.53169787967194, -23.97073271029336, 4.338664497959301) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_2"), False) SketchLine_5 = SketchProjection_1.createdFeature() SketchConstraintPerpendicular_1 = Sketch_2.setPerpendicular(SketchLine_4.result(), SketchLine_5.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_4")]) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_4")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchLine_1")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[1],[5],[10]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[1],[5],[10]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceEdgePerpendicular.py b/src/FeaturesPlugin/Test/TestFillFaceEdgePerpendicular.py index 2d5182fd2..e088a9137 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceEdgePerpendicular.py +++ b/src/FeaturesPlugin/Test/TestFillFaceEdgePerpendicular.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -42,13 +43,14 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_7 = Sketch_2.addLine(24.33758278426026, -52.48127186534471, 29.40566289183227, 59.45054433956496) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_7")]) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_7")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_2")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[1],[6],[13]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[1],[6],[13]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceFace.py b/src/FeaturesPlugin/Test/TestFillFaceFace.py index d7ce14972..ac67d7600 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceFace.py +++ b/src/FeaturesPlugin/Test/TestFillFaceFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,9 +18,9 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model -from SketchAPI import * model.begin() partSet = model.moduleDocument() @@ -42,26 +42,26 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "R") model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_4 = Sketch_2.addLine(31.79164821526215, 49.99496405877289, 8.200436015051352, 0) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_1e"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False) SketchPoint_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchPoint_1.result()) SketchLine_5 = Sketch_2.addLine(8.200436015051352, 0, 27.24680168984479, -49.85269382803262) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_1"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchArc_1"), False) SketchPoint_2 = SketchProjection_3.createdFeature() -SketchArc_2 = Sketch_2.addArc(31.08202242513997, 1.147024884467139e-021, 27.24680168984479, -49.85269382803262, 31.79164821526215, 49.99496405877289, False) +SketchArc_2 = Sketch_2.addArc(31.08202242513997, 1.147024884467139e-21, 27.24680168984479, -49.85269382803262, 31.79164821526215, 49.99496405877289, False) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchArc_2.center()) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchArc_2.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_4.startPoint()) SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_2.results()[1], "R") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchArc_1_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_4f-SketchLine_5f-SketchArc_2_2f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_2_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchArc_1_2f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_4r-SketchLine_5f-SketchArc_2_2f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Face_2_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [2], [0], [2], [6], [12]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [2], [0], [2], [6], [12]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceShell.py b/src/FeaturesPlugin/Test/TestFillFaceShell.py index 068e4aebe..da44bcf24 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceShell.py +++ b/src/FeaturesPlugin/Test/TestFillFaceShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -97,15 +98,15 @@ SketchLine_15.result().setName("SketchLine_16") SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_15.startPoint()) SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_8.startPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_5f-SketchLine_6r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_3f-SketchLine_4f-SketchLine_6f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_6f_wire")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_3_1")], [model.selection("SHELL", "Shell_1_1")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_15r-SketchLine_14r-SketchLine_13r-SketchLine_16f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_3_1")], [model.selection("SHELL", "Shell_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [3], [0], [3], [14], [28]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [3], [0], [3], [14], [28]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceSolid.py b/src/FeaturesPlugin/Test/TestFillFaceSolid.py index a99fa556f..f7e144562 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceSolid.py +++ b/src/FeaturesPlugin/Test/TestFillFaceSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -49,12 +50,12 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), 5) SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("SOLID", "Box_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [4], [0], [4], [15], [30]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [4], [0], [4], [15], [30]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceVertex.py b/src/FeaturesPlugin/Test/TestFillFaceVertex.py index 21b11a3d1..23a1a71db 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceVertex.py +++ b/src/FeaturesPlugin/Test/TestFillFaceVertex.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -40,13 +41,14 @@ 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() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_2")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[1],[4],[9]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[1],[4],[9]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillFaceWire.py b/src/FeaturesPlugin/Test/TestFillFaceWire.py index b38a7a3de..6daa0c42e 100644 --- a/src/FeaturesPlugin/Test/TestFillFaceWire.py +++ b/src/FeaturesPlugin/Test/TestFillFaceWire.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -45,19 +46,19 @@ SketchLine_5 = Sketch_2.addLine(-18.23994072168525, 7.835320880296757, 13.893416 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchLine_6 = Sketch_2.addLine(13.89341696052619, 27.33089138697832, 39.39985877388298, 9.747860956493145) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) -SketchLine_7 = Sketch_2.addLine(39.39985877388298, 9.747860956493145, 38.20105433548567, 71.93732104572752) +SketchLine_7 = Sketch_2.addLine(39.39985877388298, 9.747860956493145, 38.20105433548567, 71.93732104572751) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) -SketchLine_8 = Sketch_2.addLine(38.20105433548567, 71.93732104572752, -42.38833891077762, 73.71572760627062) +SketchLine_8 = Sketch_2.addLine(38.20105433548567, 71.93732104572751, -42.38833891077762, 73.71572760627062) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchLine_8.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchArc_1_2f")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("WIRE", "Wire_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchArc_1_2f_wire")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_4r-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("WIRE", "Wire_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [5], [0], [5], [21], [42]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [5], [0], [5], [21], [42]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellConstrPlane.py b/src/FeaturesPlugin/Test/TestFillShellConstrPlane.py index a0bd627ba..a1e1043fd 100644 --- a/src/FeaturesPlugin/Test/TestFillShellConstrPlane.py +++ b/src/FeaturesPlugin/Test/TestFillShellConstrPlane.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -40,14 +41,14 @@ SketchArc_2 = Sketch_1.addArc(38.14157263904823, 16.22495851193372, 56.770542089 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_2.results()[1]) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchArc_2_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 70, 0) Shell_1 = model.addShell(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("FACE", "PartSet/XOZ")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("FACE", "PartSet/XOZ")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[3],[12],[24]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[3],[12],[24]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellEdge.py b/src/FeaturesPlugin/Test/TestFillShellEdge.py index 20f0ed60f..a81a80960 100644 --- a/src/FeaturesPlugin/Test/TestFillShellEdge.py +++ b/src/FeaturesPlugin/Test/TestFillShellEdge.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -40,19 +41,19 @@ SketchArc_2 = Sketch_1.addArc(38.14157263904823, 16.22495851193372, 56.770542089 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_2.results()[1]) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchArc_2_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 70, 0) Shell_1 = model.addShell(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")]) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 30, False) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_3 = Sketch_2.addLine(-64.49168769733997, 17.16789081864163, 146.7677170722727, 22.9901626941168) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_3")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_3")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[2],[8],[18]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[2],[8],[18]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellFace.py b/src/FeaturesPlugin/Test/TestFillShellFace.py index 0a7242dfc..6e1cd569d 100644 --- a/src/FeaturesPlugin/Test/TestFillShellFace.py +++ b/src/FeaturesPlugin/Test/TestFillShellFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -73,7 +74,9 @@ SketchLine_10 = Sketch_2.addLine(64.99999999999999, 12.18920647716607, 50, 12.18 SketchLine_10.setName("SketchLine_12") SketchLine_10.result().setName("SketchLine_12") SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10") SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_7.result()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11") SketchConstraintDistance_4 = Sketch_2.setDistance(SketchLine_8.endPoint(), SketchLine_7.result(), "L", True) SketchConstraintDistance_5 = Sketch_2.setDistance(SketchLine_9.endPoint(), SketchLine_7.result(), "L/2", True) SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_10.result()) @@ -86,20 +89,22 @@ SketchLine_12.setName("SketchLine_14") SketchLine_12.result().setName("SketchLine_14") SketchLine_11.setName("SketchLine_13") SketchLine_11.result().setName("SketchLine_13") -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"), False) SketchPoint_2 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_9.result()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12") SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_8.startPoint(), SketchLine_7.result()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_13") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_5f-SketchLine_6r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_3f-SketchLine_4f-SketchLine_6f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_6f_wire")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_13r-SketchLine_14r-SketchLine_15r")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("FACE", "Face_3_1")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_15r-SketchLine_14r-SketchLine_13r_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("FACE", "Face_3_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [4], [13], [26]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [4], [13], [26]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellShell.py b/src/FeaturesPlugin/Test/TestFillShellShell.py index 1363f2e95..e5a81e896 100644 --- a/src/FeaturesPlugin/Test/TestFillShellShell.py +++ b/src/FeaturesPlugin/Test/TestFillShellShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -33,10 +34,10 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(-10, 32.04672553984553, 15.61552812808831, 47.66225366793383) SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_2 = SketchProjection_1.createdFeature() -SketchLine_3 = Sketch_1.addLine(15.61552812808831, 47.66225366793383, -4.988916520257207e-021, 73.27778179602213) +SketchLine_3 = Sketch_1.addLine(15.61552812808831, 47.66225366793383, -4.988916520257207e-21, 73.27778179602213) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_2.result()) -SketchLine_4 = Sketch_1.addLine(-4.988916520257207e-021, 73.27778179602213, -25.61552812810082, 57.66225366792627) +SketchLine_4 = Sketch_1.addLine(-4.988916520257207e-21, 73.27778179602213, -25.61552812810082, 57.66225366792627) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) SketchLine_5 = Sketch_1.addLine(-25.61552812810082, 57.66225366792627, -10, 32.04672553984553) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) @@ -64,7 +65,7 @@ SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchLine_10.endPoint()) SketchLine_11 = Sketch_2.addLine(50, 15.56025031353752, 73.27778179602213, 0) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_7.startPoint(), SketchLine_11.startPoint()) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_3e"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_3_EndVertex"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) SketchLine_12 = Sketch_2.addLine(73.27778179602213, 0, 50, -15.54016280334104) @@ -73,17 +74,17 @@ SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_9).startPoint(), SketchLine_7.result(), "D", True) SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_7.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_5f-SketchLine_6r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_3f-SketchLine_4f-SketchLine_6f")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_7r-SketchLine_8r-SketchLine_10r")]) -Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_7f-SketchLine_11r-SketchLine_12r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_6f_wire")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_10r-SketchLine_8r-SketchLine_7r_wire")]) +Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_7r-SketchLine_12r-SketchLine_11r_wire")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_4_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("SHELL", "Shell_2_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("SHELL", "Shell_2_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [4], [15], [30]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [4], [15], [30]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellSolid.py b/src/FeaturesPlugin/Test/TestFillShellSolid.py index 1b78fe4c1..15deb078a 100644 --- a/src/FeaturesPlugin/Test/TestFillShellSolid.py +++ b/src/FeaturesPlugin/Test/TestFillShellSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -50,14 +51,14 @@ SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift", True) -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("SOLID", "Box_1_1")]) +Fill_2 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() -model.checkResult(Boolean_2, model, 1, [0], [0], [6], [22], [44]) -model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc) +model.checkResult(Fill_2, model, 1, [0], [0], [6], [22], [44]) +model.testHaveNamingSubshapes(Fill_2, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellVertex.py b/src/FeaturesPlugin/Test/TestFillShellVertex.py index 2fb840f5c..0303d771e 100644 --- a/src/FeaturesPlugin/Test/TestFillShellVertex.py +++ b/src/FeaturesPlugin/Test/TestFillShellVertex.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -36,16 +37,16 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/O SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_2_2")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchArc_2_2")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 50, 0) Shell_1 = model.addShell(Part_1_doc, [model.selection("SHELL", "Extrusion_1_1")]) Point_2 = model.addPoint(Part_1_doc, 0, 0, 10) Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[2],[9],[18]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[2],[9],[18]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillShellWire.py b/src/FeaturesPlugin/Test/TestFillShellWire.py index 1dc51bd3d..9c3362ba5 100644 --- a/src/FeaturesPlugin/Test/TestFillShellWire.py +++ b/src/FeaturesPlugin/Test/TestFillShellWire.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -71,15 +72,16 @@ SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/O SketchPoint_1 = SketchProjection_2.createdFeature() SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_9.result(), "L", True) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_5f-SketchLine_6r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_3f-SketchLine_4f-SketchLine_6f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_6f_wire")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_10")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("WIRE", "Wire_1_1")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/SketchLine_8"), model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_2/SketchLine_10")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], [model.selection("WIRE", "Wire_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [8], [30], [60]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [8], [30], [60]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolid2ConstructionPlanes.py b/src/FeaturesPlugin/Test/TestFillSolid2ConstructionPlanes.py index 981f18b9b..18507904d 100644 --- a/src/FeaturesPlugin/Test/TestFillSolid2ConstructionPlanes.py +++ b/src/FeaturesPlugin/Test/TestFillSolid2ConstructionPlanes.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -26,11 +27,11 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 5, 10) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Cone_1_1")], [model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Cone_1_1")], [model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")]) model.do() -model.checkResult(Boolean_1,model,1,[4],[4],[20],[72],[144]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[4],[4],[20],[72],[144]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolidCompFace.py b/src/FeaturesPlugin/Test/TestFillSolidCompFace.py index d486e1856..cbc2df764 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidCompFace.py +++ b/src/FeaturesPlugin/Test/TestFillSolidCompFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -34,14 +35,14 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchArc_1 = Sketch_1.addArc(0, 0, 11.4564392373896, -5, 0, -12.5, True) +SketchArc_1 = Sketch_1.addArc(0, 0, 15.49193338482974, -4, 0, -16, True) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result()) -SketchLine_2 = Sketch_1.addLine(11.4564392373896, -5, 0, 5) +SketchLine_2 = Sketch_1.addLine(15.49193338482974, -4, 0, 12) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) -SketchLine_3 = Sketch_1.addLine(0, 5, 0, -12.5) +SketchLine_3 = Sketch_1.addLine(0, 12, 0, -16) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result()) @@ -50,13 +51,13 @@ SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Fill_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) +Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Fill_1_1")]) model.do() -model.checkResult(Boolean_2, model, 1, [2], [2], [14], [60], [120]) -model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc) +model.checkResult(Fill_2, model, 1, [2], [2], [14], [60], [120]) +model.testHaveNamingSubshapes(Fill_2, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolidCompShell.py b/src/FeaturesPlugin/Test/TestFillSolidCompShell.py index d6de9e4cf..ed2dc543f 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidCompShell.py +++ b/src/FeaturesPlugin/Test/TestFillSolidCompShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -34,14 +35,14 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchArc_1 = Sketch_1.addArc(0, 0, 11.4564392373896, -5, 0, -12.5, True) +SketchArc_1 = Sketch_1.addArc(0, 0, 15.49193338482974, -4, 0, -16, True) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result()) -SketchLine_2 = Sketch_1.addLine(11.4564392373896, -5, 0, 5) +SketchLine_2 = Sketch_1.addLine(15.49193338482974, -4, 0, 12) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) -SketchLine_3 = Sketch_1.addLine(0, 5, 0, -12.5) +SketchLine_3 = Sketch_1.addLine(0, 12, 0, -16) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result()) @@ -50,15 +51,15 @@ SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) -MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), 1, 3) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "LinearCopy_1_1")]) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OZ"), 1, 3) +Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "LinearCopy_1_1")]) model.do() -model.checkResult(Boolean_2, model, 1, [4], [4], [30], [132], [264]) -model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc) +model.checkResult(Fill_2, model, 1, [4], [4], [30], [132], [264]) +model.testHaveNamingSubshapes(Fill_2, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolidEdge.py b/src/FeaturesPlugin/Test/TestFillSolidEdge.py index 25190b5fd..813b114f8 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidEdge.py +++ b/src/FeaturesPlugin/Test/TestFillSolidEdge.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -28,19 +29,19 @@ Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Front")) SketchLine_1 = Sketch_1.addLine(4, 10, 7, 0) -SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "Box_1_1/Front&Box_1_1/Top"), False) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), False) SketchLine_2 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) -SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), False) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Bottom]"), False) SketchLine_3 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [1], [7], [30], [60]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [1], [7], [30], [60]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolidFace.py b/src/FeaturesPlugin/Test/TestFillSolidFace.py index 54e07fa92..b6ac81d72 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidFace.py +++ b/src/FeaturesPlugin/Test/TestFillSolidFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -34,14 +35,14 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchArc_1 = Sketch_1.addArc(0, 0, 11.4564392373896, -5, 0, -12.5, True) +SketchArc_1 = Sketch_1.addArc(0, 0, 15.49193338482974, -4, 0, -16, True) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result()) -SketchLine_2 = Sketch_1.addLine(11.4564392373896, -5, 0, 5) +SketchLine_2 = Sketch_1.addLine(15.49193338482974, -4, 0, 12) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) -SketchLine_3 = Sketch_1.addLine(0, 5, 0, -12.5) +SketchLine_3 = Sketch_1.addLine(0, 12, 0, -16) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result()) @@ -49,12 +50,12 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), "Shift/3") SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("FACE", "Face_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("FACE", "Face_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [2], [2], [12], [48], [96]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [2], [2], [12], [48], [96]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillSolidShell.py b/src/FeaturesPlugin/Test/TestFillSolidShell.py index 174e8db41..283100fc9 100644 --- a/src/FeaturesPlugin/Test/TestFillSolidShell.py +++ b/src/FeaturesPlugin/Test/TestFillSolidShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -34,14 +35,14 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchArc_1 = Sketch_1.addArc(0, 0, 11.4564392373896, -5, 0, -12.5, True) +SketchArc_1 = Sketch_1.addArc(0, 0, 15.49193338482974, -4, 0, -16, True) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result()) -SketchLine_2 = Sketch_1.addLine(11.4564392373896, -5, 0, 5) +SketchLine_2 = Sketch_1.addLine(15.49193338482974, -4, 0, 12) SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint()) -SketchLine_3 = Sketch_1.addLine(0, 5, 0, -12.5) +SketchLine_3 = Sketch_1.addLine(0, 12, 0, -16) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.endPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_1.result()) @@ -50,14 +51,14 @@ SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), "Shift/3", True) -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("FACE", "Face_1_1")], [model.selection("FACE", "Plane_2")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Fill_1_1_2"), model.selection("FACE", "Fill_1_1_1")]) -Boolean_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SHELL", "Shell_1_1")]) +Fill_2 = model.addFill(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SHELL", "Shell_1_1")]) model.do() -model.checkResult(Boolean_2, model, 1, [2], [2], [14], [60], [120]) -model.testHaveNamingSubshapes(Boolean_2, model, Part_1_doc) +model.checkResult(Fill_2, model, 1, [2], [2], [14], [60], [120]) +model.testHaveNamingSubshapes(Fill_2, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireEdge.py b/src/FeaturesPlugin/Test/TestFillWireEdge.py index eeda3945e..4305d7df3 100644 --- a/src/FeaturesPlugin/Test/TestFillWireEdge.py +++ b/src/FeaturesPlugin/Test/TestFillWireEdge.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -38,13 +39,14 @@ SketchLine_5 = Sketch_2.addLine(55.26415094339622, -34.15529753265602, -40.60522 SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_2.startPoint()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("EDGE", "Edge_1_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("EDGE", "Edge_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[0],[6],[12]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[0],[6],[12]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireFace.py b/src/FeaturesPlugin/Test/TestFillWireFace.py index e63cac9f5..2a4ee39fa 100644 --- a/src/FeaturesPlugin/Test/TestFillWireFace.py +++ b/src/FeaturesPlugin/Test/TestFillWireFace.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -41,7 +42,7 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "R") model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_4 = Sketch_2.addLine(29.74624907439609, 30.07487215963349, 31.08202242513997, 0) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_1"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchArc_1"), False) SketchPoint_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchPoint_1.result()) SketchLine_5 = Sketch_2.addLine(31.08202242513997, 0, 45.45797599933665, 0) @@ -57,13 +58,13 @@ SketchLine_9 = Sketch_2.addLine(70.40999925541598, 30.039147749218, 29.746249074 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_4.startPoint(), SketchLine_9.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchArc_1_2f")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchLine_8f-SketchLine_9f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("FACE", "Face_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchArc_1_2f_wire")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_4r-SketchLine_5f-SketchLine_7f-SketchLine_8f-SketchLine_9f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("FACE", "Face_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [0], [6], [12]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [0], [6], [12]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireShell.py b/src/FeaturesPlugin/Test/TestFillWireShell.py index d5b99ecdc..840818c89 100644 --- a/src/FeaturesPlugin/Test/TestFillWireShell.py +++ b/src/FeaturesPlugin/Test/TestFillWireShell.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -97,15 +98,15 @@ SketchLine_15.result().setName("SketchLine_16") SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_15.startPoint()) SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_8.startPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_5f-SketchLine_6r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_3f-SketchLine_4f-SketchLine_6f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_6r-SketchLine_5f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3f-SketchLine_4f-SketchLine_6f_wire")]) Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_13r-SketchLine_14r-SketchLine_15r-SketchLine_16f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("SHELL", "Shell_1_1")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_15r-SketchLine_14r-SketchLine_13r-SketchLine_16f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("SHELL", "Shell_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [0], [10], [20]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [0], [10], [20]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireSolid.py b/src/FeaturesPlugin/Test/TestFillWireSolid.py index d0fd12e4e..35dd3401a 100644 --- a/src/FeaturesPlugin/Test/TestFillWireSolid.py +++ b/src/FeaturesPlugin/Test/TestFillWireSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -49,12 +50,12 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "L+Shift SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_2.startPoint(), 5) SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_1).startPoint(), SketchLine_3.startPoint(), "Shift", True) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchLine_2f-SketchLine_3f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("SOLID", "Box_1_1")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_2f-SketchLine_3f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("SOLID", "Box_1_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [0], [9], [18]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [0], [9], [18]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireVertex.py b/src/FeaturesPlugin/Test/TestFillWireVertex.py index 01c3c349a..677cd5b94 100644 --- a/src/FeaturesPlugin/Test/TestFillWireVertex.py +++ b/src/FeaturesPlugin/Test/TestFillWireVertex.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from SketchAPI import * @@ -40,12 +41,13 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result()) SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) 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"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("VERTEX", "Vertex_1_1")]) model.do() -model.checkResult(Boolean_1,model,1,[0],[0],[0],[4],[8]) -model.testHaveNamingSubshapes(Boolean_1,model,Part_1_doc) +model.checkResult(Fill_1,model,1,[0],[0],[0],[4],[8]) +model.testHaveNamingSubshapes(Fill_1,model,Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillWireWire.py b/src/FeaturesPlugin/Test/TestFillWireWire.py index 9540742cf..b7e49aa20 100644 --- a/src/FeaturesPlugin/Test/TestFillWireWire.py +++ b/src/FeaturesPlugin/Test/TestFillWireWire.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -41,26 +42,26 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "R") model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_4 = Sketch_2.addLine(31.79164821526215, 49.99496405877289, 8.200436015051352, 0) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_1e"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False) SketchPoint_1 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchPoint_1.result()) SketchLine_5 = Sketch_2.addLine(8.200436015051352, 0, 27.24680168984479, -49.85269382803262) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_1"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchArc_1"), False) SketchPoint_2 = SketchProjection_3.createdFeature() -SketchArc_2 = Sketch_2.addArc(31.08202242513997, 1.147024884467139e-021, 27.24680168984479, -49.85269382803262, 31.79164821526215, 49.99496405877289, False) +SketchArc_2 = Sketch_2.addArc(31.08202242513997, 1.147024884467139e-21, 27.24680168984479, -49.85269382803262, 31.79164821526215, 49.99496405877289, False) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchArc_2.center()) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchArc_2.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_4.startPoint()) SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_2.results()[1], "R") model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchArc_1_2f")]) -Wire_2 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_4f-SketchLine_5f-SketchArc_2_2f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("WIRE", "Wire_2_1")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchArc_1_2f_wire")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_4r-SketchLine_5f-SketchArc_2_2f_wire")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], [model.selection("WIRE", "Wire_2_1")]) model.do() -model.checkResult(Boolean_1, model, 1, [0], [0], [0], [4], [8]) -model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) +model.checkResult(Fill_1, model, 1, [0], [0], [0], [4], [8]) +model.testHaveNamingSubshapes(Fill_1, model, Part_1_doc) model.end() diff --git a/src/FeaturesPlugin/Test/TestFillet.py b/src/FeaturesPlugin/Test/TestFillet.py index a641328bf..05d41e7c5 100644 --- a/src/FeaturesPlugin/Test/TestFillet.py +++ b/src/FeaturesPlugin/Test/TestFillet.py @@ -52,7 +52,7 @@ aSession.finishOperation() aSession.startOperation() aPoint = aPart.addFeature("Point") aPoint.string("creation_method").setValue("by_xyz") -geomDataAPI_Point(aFeature.attribute("point3d")).setValue(20, 5, 0) +geomDataAPI_Point(aPoint.attribute("point3d")).setValue(20, 5, 0) aSession.finishOperation() aSession.startOperation() @@ -71,7 +71,7 @@ aSession.startOperation() aFillet1 = aPart.addFeature("Fillet") aFillet1.string("creation_method").setValue("fixed_radius") anObjects = aFillet1.selectionList("main_objects") -anObjects.append("Box_1_1/Left&Box_1_1/Top", "edge") +anObjects.append("[Box_1_1/Left][Box_1_1/Top]", "edge") aFillet1.real("radius1").setValue(3) aSession.finishOperation() assert(aFillet1.error() == ""), "FAILED: Fillet reports error \"{}\"".format(aFillet1.error()) @@ -94,7 +94,7 @@ aFillet2 = aPart.addFeature("Fillet") aFillet2.string("creation_method").setValue("fixed_radius") anObjects = aFillet2.selectionList("main_objects") anObjects.append("Cylinder_1_1/Face_2", "face") -anObjects.append("_Box_1_1/Right", "face") +anObjects.append("Box_1_1/Right", "face") aFillet2.real("radius1").setValue(2) aSession.finishOperation() assert(aFillet2.error() != ""), "FAILED: Fillet does not report error" diff --git a/src/FeaturesPlugin/Test/TestFillet1.py b/src/FeaturesPlugin/Test/TestFillet1.py new file mode 100644 index 000000000..9c5bf9366 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestFillet1.py @@ -0,0 +1,50 @@ +## Copyright (C) 2018-20xx 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 +from GeomAPI import GeomAPI_Shape + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "all-in-Box_1")], 2) +assert(Fillet_1.feature().error() == "") + +model.testNbResults(Fillet_1, 1) +model.testNbSubResults(Fillet_1, [0]) +model.testNbSubShapes(Fillet_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fillet_1, GeomAPI_Shape.FACE, [26]) +model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [104]) +model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [208]) +model.testResultsVolumes(Fillet_1, [907.704992710141368661425076425]) + +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchCircle_1 = Sketch_1.addCircle(20, -15, 5) +SketchCircle_2 = Sketch_1.addCircle(30, 10, 3) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) + +Fillet_2 = model.addFillet(Part_1_doc, [model.selection("EDGE", "all-in-Extrusion_1")], 2) +assert(Fillet_2.feature().error() != "") + +model.end() diff --git a/src/FeaturesPlugin/Test/TestFillet_ErrorMsg.py b/src/FeaturesPlugin/Test/TestFillet_ErrorMsg.py new file mode 100644 index 000000000..92dfacdba --- /dev/null +++ b/src/FeaturesPlugin/Test/TestFillet_ErrorMsg.py @@ -0,0 +1,52 @@ +## Copyright (C) 2018-20xx 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(-30, 5, 15) +SketchLine_1 = Sketch_1.addLine(60, -30, 15, -30) +SketchLine_2 = Sketch_1.addLine(15, -30, 15, 15) +SketchLine_3 = Sketch_1.addLine(15, 15, 60, 15) +SketchLine_4 = Sketch_1.addLine(60, 15, 60, -30) +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() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) + +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")], 2) +assert(Fillet_1.feature().error() != "") +Part_1_doc.removeFeature(Fillet_1.feature()) + +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_2/To_Face")], 2) +assert(Fillet_1.feature().error() != "") +Part_1_doc.removeFeature(Fillet_1.feature()) + +model.end() diff --git a/src/FeaturesPlugin/Test/TestFusionFaces.py b/src/FeaturesPlugin/Test/TestFusionFaces.py index 810d548db..84c6a3c45 100644 --- a/src/FeaturesPlugin/Test/TestFusionFaces.py +++ b/src/FeaturesPlugin/Test/TestFusionFaces.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model # Create document @@ -33,7 +35,7 @@ Box_1 = model.addBox(Part_1_doc, 10, 10, 10) Box_2 = model.addBox(Part_1_doc, 10, 10, 10) Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("EDGE", "PartSet/OX"), 10) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Translation_1_1/Translated_Face_1")]) +Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Box_1_1/Top"), model.selection("FACE", "Translation_1_1/MF:Translated&Box_2_1/Top")]) model.do() model.checkResult(Shell_1, model, 1, [0], [0], [2], [8], [16]) diff --git a/src/FeaturesPlugin/Test/TestIntersection.py b/src/FeaturesPlugin/Test/TestIntersection.py index ea47ba331..df49fea30 100644 --- a/src/FeaturesPlugin/Test/TestIntersection.py +++ b/src/FeaturesPlugin/Test/TestIntersection.py @@ -62,23 +62,15 @@ aSession.finishOperation() # Make extrusion on circle 1 #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -116,23 +108,15 @@ aSession.finishOperation() # Make extrusion on circle 2 #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) diff --git a/src/FeaturesPlugin/Test/TestIntersection_ErrorMsg.py b/src/FeaturesPlugin/Test/TestIntersection_ErrorMsg.py new file mode 100644 index 000000000..74b8b2500 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestIntersection_ErrorMsg.py @@ -0,0 +1,35 @@ +## Copyright (C) 2018-20xx 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(10, -20, 15) +model.do() + +Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) +assert(Intersection_1.feature().error() != "") +Part_1_doc.removeFeature(Intersection_1.feature()) + +model.end() diff --git a/src/FeaturesPlugin/Test/TestMeasurementAngle.py b/src/FeaturesPlugin/Test/TestMeasurementAngle.py index bec25e1c2..ec0b9d444 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementAngle.py +++ b/src/FeaturesPlugin/Test/TestMeasurementAngle.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -28,9 +30,9 @@ model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -ParamR = model.addParameter(Part_1_doc, "R", "50") -ParamL = model.addParameter(Part_1_doc, "L", "40") -ParamH = model.addParameter(Part_1_doc, "H", "20") +model.addParameter(Part_1_doc, "R", "50") +model.addParameter(Part_1_doc, "L", "40") +model.addParameter(Part_1_doc, "H", "20") Point_2 = model.addPoint(Part_1_doc, 0, 100, 100) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OX"), model.selection("VERTEX", "Point_1"), False) Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) @@ -59,8 +61,8 @@ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), "H") SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "L/2") SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "H/2") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) SketchLine_7 = Sketch_2.addLine(119.1454520140253, 130.0744845530344, 10, 0) SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) SketchLine_8 = SketchProjection_3.createdFeature() @@ -72,14 +74,14 @@ model.do() TOLERANCE = 1.e-6 # reference data -REF_DATA = [("Sketch_1/Edge-SketchLine_3", "Sketch_1/Edge-SketchLine_6", [90]), - ("Extrusion_1_1/Generated_Face_5", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", [45]), - ("Sketch_1/Edge-SketchCircle_1_2", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", [0]), - ("Sketch_1/Edge-SketchLine_3", "Sketch_1/Edge-SketchCircle_1_2", []), - ("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", []), - ("Sketch_2/Edge-SketchLine_7", "Extrusion_1_1/To_Face_1&Extrusion_1_1/Generated_Face_4", [130]), - ("Sketch_2/Edge-SketchLine_7", "Extrusion_1_1/To_Face_1&Extrusion_1_1/Generated_Face_1", [40]), - ("Sketch_2/Edge-SketchLine_7", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", [121.21205374, 84.80231126]) +REF_DATA = [("Sketch_1/SketchLine_3", "Sketch_1/SketchLine_6", [90]), + ("([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]", [45]), + ("Sketch_1/SketchCircle_1_2", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]", [0]), + ("Sketch_1/SketchLine_3", "Sketch_1/SketchCircle_1_2", []), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]", []), + ("Sketch_2/SketchLine_7", "[Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]", [130]), + ("Sketch_2/SketchLine_7", "[Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]", [40]), + ("Sketch_2/SketchLine_7", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]", [121.21205374, 84.80231126]) ] for ref in REF_DATA: @@ -89,7 +91,7 @@ for ref in REF_DATA: assert(math.fabs(a - r) < TOLERANCE), "Angle {} differs from expected value {}".format(a, r) # select incorrect data -angle = model.measureAngle(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_7")) +angle = model.measureAngle(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("EDGE", "Sketch_2/SketchLine_7")) assert(angle.size() == 0) model.end() diff --git a/src/FeaturesPlugin/Test/TestMeasurementAngle3Points.py b/src/FeaturesPlugin/Test/TestMeasurementAngle3Points.py index c3f7fcc8e..1e4fc4034 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementAngle3Points.py +++ b/src/FeaturesPlugin/Test/TestMeasurementAngle3Points.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -55,43 +57,43 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/O SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), 100, 0) model.do() TOLERANCE = 1.e-6 # reference data -REF_DATA = [("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1", +REF_DATA = [("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]", 120), - ("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]", 120), - ("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]", 60), - ("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", - "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]", 120), - ("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]", 104.9068234), - ("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]", 90), - ("Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1", - "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]", 52.91916441), - ("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1", - "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", - "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1", + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]", + "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]", 0) ] @@ -100,7 +102,7 @@ for ref in REF_DATA: assert(math.fabs(angle - ref[3]) < TOLERANCE), "Angle {} differs from expected value {}".format(angle, ref[3]) # select incorrect data -angle = model.measureAngle(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("VERTEX", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1"), model.selection("VERTEX", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1")) +angle = model.measureAngle(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]")) assert(angle == -1.0) angle = model.measureAngle(Part_1_doc, model.selection("VERTEX", ""), model.selection("VERTEX", ""), model.selection("VERTEX", "")) diff --git a/src/FeaturesPlugin/Test/TestMeasurementDistance.py b/src/FeaturesPlugin/Test/TestMeasurementDistance.py index c2b7d0a6a..a5a4444aa 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementDistance.py +++ b/src/FeaturesPlugin/Test/TestMeasurementDistance.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model import math @@ -26,9 +28,9 @@ model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -ParamR = model.addParameter(Part_1_doc, "R", "50") -ParamL = model.addParameter(Part_1_doc, "L", "40") -ParamH = model.addParameter(Part_1_doc, "H", "20") +model.addParameter(Part_1_doc, "R", "50") +model.addParameter(Part_1_doc, "L", "40") +model.addParameter(Part_1_doc, "H", "20") Point_2 = model.addPoint(Part_1_doc, 0, 100, 100) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OX"), model.selection("VERTEX", "Point_1"), False) Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) @@ -57,7 +59,7 @@ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), "H") SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "L/2") SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "H/2") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchArc_1 = Sketch_2.addArc(100, 48.41229182762603, 87.5, 0, 87.5, 96.82458365525073, False) SketchArc_2 = Sketch_2.addArc(0, 48.41229182762603, 87.5, 0, 87.5, 96.82458365525073, False) @@ -87,34 +89,34 @@ TOLERANCE = 1.e-6 # reference data REF_DATA = [(model.selection("VERTEX", "PartSet/Origin"), - model.selection("VERTEX", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1"), + model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), 122.4744871), - (model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1"), - model.selection("VERTEX", "Sketch_2/Vertex-SketchArc_1-SketchLine_7e"), + (model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), + model.selection("VERTEX", "Sketch_2/SketchArc_1"), 36.94403089), - (model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1"), - model.selection("EDGE", "Extrusion_1_1/Generated_Face_5"), + (model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), + model.selection("EDGE", "([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])"), 0), - (model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1"), - model.selection("EDGE", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/To_Face_1"), + (model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), + model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2][Extrusion_2_1/To_Face]"), 16.00781059), - (model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_2"), + (model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2"), 8.412291828), - (model.selection("VERTEX", "Sketch_1/Vertex-SketchCircle_1"), + (model.selection("VERTEX", "Sketch_1/SketchCircle_1_2__cc"), model.selection("FACE", "Plane_1"), 35.35533906), - (model.selection("FACE", "Extrusion_2_2/From_Face_1"), - model.selection("FACE", "Extrusion_2_2/To_Face_1"), + (model.selection("FACE", "Extrusion_2_2/From_Face"), + model.selection("FACE", "Extrusion_2_2/To_Face"), 100), - (model.selection("FACE", "Extrusion_1_1/Generated_Face_5"), - model.selection("FACE", "Extrusion_2_1/Generated_Face_2"), + (model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"), + model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_1_2"), 0), - (model.selection("FACE", "Extrusion_1_1/Generated_Face_5"), - model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), + (model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"), + model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5"), 27.63932023), (model.selection("SOLID", "Extrusion_1_1"), - model.selection("FACE", "Extrusion_2_1/To_Face_1"), + model.selection("FACE", "Extrusion_2_1/To_Face"), 12.5), (model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), diff --git a/src/FeaturesPlugin/Test/TestMeasurementLength.py b/src/FeaturesPlugin/Test/TestMeasurementLength.py index f557f8fde..c85fb4a2b 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementLength.py +++ b/src/FeaturesPlugin/Test/TestMeasurementLength.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model import math @@ -57,20 +59,20 @@ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), "H") SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "L/2") SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "H/2") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) model.do() TOLERANCE = 1.e-6 # reference data -REF_DATA = [("Extrusion_1_1/From_Face_1&Extrusion_1_1/Generated_Face_1", ParamH.value()), - ("Extrusion_1_1/From_Face_1&Extrusion_1_1/Generated_Face_4", ParamL.value()), - ("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1", ParamR.value() * 2.0 * math.pi), - ("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1", 381.981436664), - ("Extrusion_1_1/Generated_Face_5", 60), - ("Sketch_1/Edge-SketchLine_3", ParamL.value()), - ("Sketch_1/Edge-SketchLine_4", ParamH.value()), - ("Sketch_1/Edge-SketchCircle_1_2", ParamR.value() * 2.0 * math.pi) +REF_DATA = [("[Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]", ParamH.value()), + ("[Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]", ParamL.value()), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]", ParamR.value() * 2.0 * math.pi), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]", 381.981436664), + ("([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face])([Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face])", 60), + ("Sketch_1/SketchLine_3", ParamL.value()), + ("Sketch_1/SketchLine_4", ParamH.value()), + ("Sketch_1/SketchCircle_1_2", ParamR.value() * 2.0 * math.pi) ] for ref in REF_DATA: @@ -78,7 +80,7 @@ for ref in REF_DATA: assert(math.fabs(length - ref[1]) < TOLERANCE), "Length {} differs from expected value {}".format(length, ref[1]) # select incorrect data -length = model.measureLength(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_5")) +length = model.measureLength(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2")) assert(length == -1) model.end() diff --git a/src/FeaturesPlugin/Test/TestMeasurementPresentation.py b/src/FeaturesPlugin/Test/TestMeasurementPresentation.py new file mode 100644 index 000000000..97d2f80ef --- /dev/null +++ b/src/FeaturesPlugin/Test/TestMeasurementPresentation.py @@ -0,0 +1,98 @@ +## Copyright (C) 2018-20xx 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 + +from ConfigAPI import * +Config_PropManager().registerProp("Visualization", "dimension_value_size", "Dimension value size", Config_Prop.IntSpin, "16") +Config_PropManager().registerProp("Visualization", "dimension_arrow_size", "Dimension arrow size", Config_Prop.IntSpin, "16") +Config_PropManager().registerProp("Visualization", "dimension_font", "Dimension font", Config_Prop.String, "Times-bold") +Config_PropManager().registerProp("Visualization", "sketch_dimension_color", "Dimension color", Config_Prop.Color, "64,128,225") + +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.79157881408318, 17.46869043106789, -28.20135254460625, -14.21916935022164) +SketchLine_2 = Sketch_1.addLine(-28.20135254460625, -14.21916935022164, 5.332188506333114, -12.56026625936245) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchArc_1 = Sketch_1.addArc(-8.886980843888518, -0.1184930779185158, 5.332188506333114, -12.56026625936245, -15.79157881408318, 17.46869043106789, False) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_1.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.endPoint()) +model.do() +model.end() + +from ModelAPI import * + +aSession = ModelAPI_Session.get() +aSession.startOperation() +aMeasurement = Part_1_doc.addFeature("Measurement") +aMeasurement.string("MeasureKind").setValue("Length") +aMeasurement.selection("edge_for_length").selectSubShape("EDGE", "Sketch_1/SketchLine_1") +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) +aSession.finishOperation() + +aSession.startOperation() +aMeasurement = Part_1_doc.addFeature("Measurement") +aMeasurement.string("MeasureKind").setValue("Distance") +aMeasurement.selection("distance_from").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex") +aMeasurement.selection("distance_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2") +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) +aSession.finishOperation() + +aSession.startOperation() +aMeasurement = Part_1_doc.addFeature("Measurement") +aMeasurement.string("MeasureKind").setValue("Radius") +aMeasurement.selection("circular").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2") +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) +aSession.finishOperation() + +aSession.startOperation() +aMeasurement = Part_1_doc.addFeature("Measurement") +aMeasurement.string("MeasureKind").setValue("Angle") +aMeasurement.selection("angle_from").selectSubShape("EDGE", "Sketch_1/SketchLine_1") +aMeasurement.selection("angle_to").selectSubShape("EDGE", "Sketch_1/SketchLine_2") +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) +aSession.finishOperation() + +aSession.startOperation() +aMeasurement = Part_1_doc.addFeature("Measurement") +aMeasurement.string("MeasureKind").setValue("AngleBy3Points") +aMeasurement.selection("angle_point_1").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_StartVertex") +aMeasurement.selection("angle_point_2").selectSubShape("VERTEX", "Sketch_1/SketchLine_1_EndVertex") +aMeasurement.selection("angle_point_3").selectSubShape("VERTEX", "Sketch_1/SketchLine_2_EndVertex") +anAIS = featureToPresentation(aMeasurement).getAISObject(None) +assert(anAIS is not None) +anAIS = featureToPresentation(aMeasurement).getAISObject(anAIS) +assert(anAIS is not None) +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestMeasurementRadius.py b/src/FeaturesPlugin/Test/TestMeasurementRadius.py index a39927d46..c000dde79 100644 --- a/src/FeaturesPlugin/Test/TestMeasurementRadius.py +++ b/src/FeaturesPlugin/Test/TestMeasurementRadius.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model import math @@ -57,15 +59,15 @@ SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), "H") SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "L/2") SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), "H/2") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), model.selection("FACE", "Plane_1"), 0, model.selection(), 10) model.do() TOLERANCE = 1.e-6 # reference data -REF_DATA = [(model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2"), ParamR.value()), - (model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/From_Face_1"), ParamR.value()), - (model.selection("FACE", "Extrusion_1_1/Generated_Face_5"), ParamR.value()) +REF_DATA = [(model.selection("EDGE", "Sketch_1/SketchCircle_1_2"), ParamR.value()), + (model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/From_Face]"), ParamR.value()), + (model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2"), ParamR.value()) ] for ref in REF_DATA: @@ -73,7 +75,7 @@ for ref in REF_DATA: assert(math.fabs(radius - ref[1]) < TOLERANCE), "Radius {} differs from expected value {}".format(radius, ref[1]) # select incorrect data -radius = model.measureRadius(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +radius = model.measureRadius(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) assert(radius == -1) model.end() diff --git a/src/FeaturesPlugin/Test/TestMultiBoolean.py b/src/FeaturesPlugin/Test/TestMultiBoolean.py index c65d2c4bc..1471c32d6 100644 --- a/src/FeaturesPlugin/Test/TestMultiBoolean.py +++ b/src/FeaturesPlugin/Test/TestMultiBoolean.py @@ -96,30 +96,17 @@ aSession.startOperation() anExtrusions = [] for i in range(0, N * N): - aSketchResult = aSketchFeatures[i].firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir() - norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) - + aSketchResult = modelAPI_ResultConstruction(aSketchFeatures[i].firstResult()) anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") anExtrusionFt.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(10) anExtrusionFt.real("to_offset").setValue(0) #TODO: remove anExtrusionFt.real("from_offset").setValue(0) #TODO: remove - # v1.0.2 from master - # anExtrusionFt.selection("extrusion_face").setValue( - # aSketchResult, aSketchFaces[0]) - # anExtrusionFt.real("extrusion_size").setValue(10) - # anExtrusionFt.boolean("extrusion_reverse").setValue(False) anExtrusions.append(anExtrusionFt) aSession.finishOperation() @@ -162,28 +149,16 @@ aSession.startOperation() #========================================================================= # Build a big box extrusion #========================================================================= -aSketchResult = aQuadrangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aQuadrangleSketchFeature.firstResult()) # Create extrusion on them aBox = aPart.addFeature("Extrusion") aBox.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) aBox.string("CreationMethod").setValue("BySizes") aBox.real("from_size").setValue(0) aBox.real("to_size").setValue(10) aBox.real("to_offset").setValue(0) #TODO: remove aBox.real("from_offset").setValue(0) #TODO: remove -# v 1.0.2 from master -# aBox.selection("extrusion_face").setValue( -# aSketchResult, aSketchFaces[0]) -# aBox.real("extrusion_size").setValue(10) -# aBox.boolean("extrusion_reverse").setValue(False) aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py b/src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py new file mode 100644 index 000000000..4675f04e6 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestMultiRotation_ErrorMsg.py @@ -0,0 +1,72 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompound.selectionList("base_objects").append("Box_1_1", "SOLID") +aSession.finishOperation() + + +aSession.startOperation() +anAngularCopy1 = aPart.addFeature("AngularCopy") +anAngularCopy1.execute() +assert(anAngularCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +anAngularCopy1.selectionList("main_objects").append("Compound_1_1", "COMPOUND") +anAngularCopy1.execute() +assert(anAngularCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +anAngularCopy1.selection("axis_angular").selectSubShape("COMPOUND", "Compound_1_1") +anAngularCopy1.execute() +assert(anAngularCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +anAngularCopy1.selection("axis_angular").selectSubShape("EDGE", "PartSet/OX") +anAngularCopy1.integer("nb_angular").setValue(0) +anAngularCopy1.execute() +assert(anAngularCopy1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestMultiRotation_Part.py b/src/FeaturesPlugin/Test/TestMultiRotation_Part.py new file mode 100644 index 000000000..11938ae85 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestMultiRotation_Part.py @@ -0,0 +1,40 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +AngularCopy_1 = model.addMultiRotation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OZ"), 2) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(AngularCopy_1, 2) +model.testNbSubResults(AngularCopy_1, [0, 0]) +model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.SOLID, [1, 1]) +model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.FACE, [6, 6]) +model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.EDGE, [24, 24]) +model.testNbSubShapes(AngularCopy_1, GeomAPI_Shape.VERTEX, [48, 48]) +model.testResultsVolumes(AngularCopy_1, [1000, 1000]) diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py b/src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py new file mode 100644 index 000000000..f5bbd13bc --- /dev/null +++ b/src/FeaturesPlugin/Test/TestMultiTranslation_ErrorMsg.py @@ -0,0 +1,114 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create auxiliary box +aSession.startOperation() +aBox = aPart.addFeature("Box") +aBox.string("CreationMethod").setValue("BoxByDimensions") +aBox.real("dx").setValue(50) +aBox.real("dy").setValue(50) +aBox.real("dz").setValue(50) +aSession.finishOperation() + +# Create auxiliary compound +aSession.startOperation() +aCompound = aPart.addFeature("Compound") +aCompound.selectionList("base_objects").append("Box_1_1", "SOLID") +aSession.finishOperation() + + +aSession.startOperation() +aLinearCopy1 = aPart.addFeature("LinearCopy") +aLinearCopy1.execute() +assert(aLinearCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy1.selectionList("main_objects").append("Compound_1_1", "COMPOUND") +aLinearCopy1.execute() +assert(aLinearCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy1.selection("axis_first_dir").selectSubShape("COMPOUND", "Compound_1_1") +aLinearCopy1.execute() +assert(aLinearCopy1.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy1.selection("axis_first_dir").selectSubShape("EDGE", "PartSet/OX") +aLinearCopy1.integer("nb_first_dir").setValue(2) +aLinearCopy1.execute() +assert(aLinearCopy1.error() != "") +aSession.finishOperation() + + +aSession.startOperation() +aLinearCopy2 = aPart.addFeature("LinearCopy") +aLinearCopy2.string("use_second_dir").setValue("true") +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy2.selectionList("main_objects").append("Compound_1_1", "COMPOUND") +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy2.selection("axis_first_dir").selectSubShape("COMPOUND", "Compound_1_1") +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy2.selection("axis_first_dir").selectSubShape("EDGE", "PartSet/OX") +aLinearCopy2.selection("axis_second_dir").selectSubShape("COMPOUND", "Compound_1_1") +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy2.selection("axis_second_dir").selectSubShape("EDGE", "PartSet/OY") +aLinearCopy2.integer("nb_first_dir").setValue(0) +aLinearCopy2.integer("nb_second_dir").setValue(0) +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aLinearCopy2.integer("nb_first_dir").setValue(2) +aLinearCopy2.integer("nb_second_dir").setValue(2) +aLinearCopy2.execute() +assert(aLinearCopy2.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestMultiTranslation_Part.py b/src/FeaturesPlugin/Test/TestMultiTranslation_Part.py new file mode 100644 index 000000000..634aa47d3 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestMultiTranslation_Part.py @@ -0,0 +1,49 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +LinearCopy_1 = model.addMultiTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OZ"), 20, 2) +LinearCopy_2 = model.addMultiTranslation(partSet, [model.selection("COMPOUND", "LinearCopy_1/")], model.selection("EDGE", "OX"), 20, 2, model.selection("EDGE", "OY"), 20, 2) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(LinearCopy_1, 2) +model.testNbSubResults(LinearCopy_1, [0, 0]) +model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.SOLID, [1, 1]) +model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.FACE, [6, 6]) +model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.EDGE, [24, 24]) +model.testNbSubShapes(LinearCopy_1, GeomAPI_Shape.VERTEX, [48, 48]) +model.testResultsVolumes(LinearCopy_1, [1000, 1000]) + +model.testNbResults(LinearCopy_2, 4) +model.testNbSubResults(LinearCopy_2, [0, 0, 0, 0]) +model.testNbSubShapes(LinearCopy_2, GeomAPI_Shape.SOLID, [1, 1, 1, 1]) +model.testNbSubShapes(LinearCopy_2, GeomAPI_Shape.FACE, [6, 6, 6, 6]) +model.testNbSubShapes(LinearCopy_2, GeomAPI_Shape.EDGE, [24, 24, 24, 24]) +model.testNbSubShapes(LinearCopy_2, GeomAPI_Shape.VERTEX, [48, 48, 48, 48]) +model.testResultsVolumes(LinearCopy_2, [1000, 1000, 1000, 1000]) diff --git a/src/FeaturesPlugin/Test/TestPartition.py b/src/FeaturesPlugin/Test/TestPartition.py index 6380b0094..9e3812237 100644 --- a/src/FeaturesPlugin/Test/TestPartition.py +++ b/src/FeaturesPlugin/Test/TestPartition.py @@ -64,23 +64,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) diff --git a/src/FeaturesPlugin/Test/TestPartition2Faces.py b/src/FeaturesPlugin/Test/TestPartition2Faces.py index dc64bef78..ceee550fd 100644 --- a/src/FeaturesPlugin/Test/TestPartition2Faces.py +++ b/src/FeaturesPlugin/Test/TestPartition2Faces.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -42,8 +43,9 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_2.addCircle(64.38749999999999, 45.44999999999999, 41.86298795836804) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_2")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchCircle_1_2")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartition2Solids.py b/src/FeaturesPlugin/Test/TestPartition2Solids.py index fac8630ee..d86d22d28 100644 --- a/src/FeaturesPlugin/Test/TestPartition2Solids.py +++ b/src/FeaturesPlugin/Test/TestPartition2Solids.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,16 +18,14 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model -from GeomAPI import GeomAPI_Shape model.begin() -#Create part partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -#Create Sketch_1 - closed polyline from 5 segments Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_1 = Sketch_1.addLine(-43.90694444444443, 28.05555555555554, 19.21805555555554, 72.66388888888889) SketchLine_2 = Sketch_1.addLine(19.21805555555554, 72.66388888888889, 82.06249999999999, -36.19166666666666) @@ -40,10 +38,8 @@ SketchLine_5 = Sketch_1.addLine(-45.87083333333333, -45.44999999999999, -43.9069 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint()) model.do() -#Create Extrusion_1 on Sketch_1 -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r")], model.selection(), 100, 0) -#Create Sketch_2 from 5 segments -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 100, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")) SketchLine_6 = Sketch_2.addLine(74.07000206783135, -18.10965884648514, 62.37497281453477, -31.70853007124862) SketchLine_7 = Sketch_2.addLine(62.37497281453477, -31.70853007124862, 37.35304976096997, -31.43655264675337) SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) @@ -55,9 +51,7 @@ SketchLine_10 = Sketch_2.addLine(69.44638585141178, 6.640286782584385, 74.070002 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_6.startPoint(), SketchLine_10.endPoint()) model.do() -#Create Extrusion_2 on Sketch_2 -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r")], model.selection(), 10, 160) -#Create Partition on objects Extrusion_1 and Extrusion_2 +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r")], model.selection(), 10, 160) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartition2Wires.py b/src/FeaturesPlugin/Test/TestPartition2Wires.py index 01eb2c1e5..6de248887 100644 --- a/src/FeaturesPlugin/Test/TestPartition2Wires.py +++ b/src/FeaturesPlugin/Test/TestPartition2Wires.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -49,8 +50,10 @@ SketchLine_9 = Sketch_2.addLine(30.30743587791019, -67.62202818906478, 1.8947624 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_9.endPoint()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_1_2")]) -Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_6")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/SketchLine_8"), model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_2/SketchArc_1_2")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Wire_2_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_6")] +Wire_2 = model.addWire(Part_1_doc, Wire_2_objects) Partition_1 = model.addPartition(Part_1_doc, [model.selection("WIRE", "Wire_2_1"), model.selection("WIRE", "Wire_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionBox4Planes.py b/src/FeaturesPlugin/Test/TestPartitionBox4Planes.py index 7e2313a7f..a733842c5 100644 --- a/src/FeaturesPlugin/Test/TestPartitionBox4Planes.py +++ b/src/FeaturesPlugin/Test/TestPartitionBox4Planes.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -30,7 +31,8 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 100 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), 100, False) Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 100, False) Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 50, False) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"), model.selection("FACE", "Plane_3"), model.selection("FACE", "Plane_4"), model.selection("SOLID", "Box_1_1")]) +Partition_1_objects = [model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"), model.selection("FACE", "Plane_3"), model.selection("FACE", "Plane_4"), model.selection("SOLID", "Box_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() model.checkResult(Partition_1,model,1,[8],[8],[48],[192],[384]) diff --git a/src/FeaturesPlugin/Test/TestPartitionEdgeSolid.py b/src/FeaturesPlugin/Test/TestPartitionEdgeSolid.py index c12eec4b3..26886c988 100644 --- a/src/FeaturesPlugin/Test/TestPartitionEdgeSolid.py +++ b/src/FeaturesPlugin/Test/TestPartitionEdgeSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -26,12 +27,12 @@ partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 5, 10) -Point_1 = model.addPoint(Part_1_doc, 4, 5, 11) +Point_2 = model.addPoint(Part_1_doc, 4, 5, 11) Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OX"), model.selection("VERTEX", "Point_1"), False) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_1 = Sketch_1.addLine(1.156555510724249, 12.03812858614785, 0.5812800089239156, -4.87167684997945) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Cone_1_1"), model.selection("EDGE", "Edge_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionFace2Solid.py b/src/FeaturesPlugin/Test/TestPartitionFace2Solid.py index 7750c0148..b1c837f27 100644 --- a/src/FeaturesPlugin/Test/TestPartitionFace2Solid.py +++ b/src/FeaturesPlugin/Test/TestPartitionFace2Solid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,10 +18,12 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- -from salome.shaper import model from SketchAPI import * +from salome.shaper import model + model.begin() partSet = model.moduleDocument() Part_1 = model.addPart(partSet) @@ -48,8 +50,7 @@ SketchConstraintMirror_2 = Sketch_1.addMirror(SketchLine_1.result(), SketchConst [SketchArc_5, SketchArc_6, SketchArc_7, SketchArc_8] = SketchConstraintMirror_2.mirrored() model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 12, 12) - -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) SketchLine_3 = Sketch_2.addLine(7.498934040825037, 4.111344571723496, -7.530337532973568, 4.111344571723496) SketchLine_4 = Sketch_2.addLine(-7.530337532973568, 4.111344571723496, -7.530337532973568, -4.489390918751097) SketchLine_5 = Sketch_2.addLine(-7.530337532973568, -4.489390918751097, 7.498934040825037, -4.489390918751097) @@ -64,8 +65,7 @@ SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_5.result()) SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_6.result()) SketchCircle_1 = Sketch_2.addCircle(-0.133117930244568, 0.08984026389066591, 1.099112071963378) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchCircle_1_2r")], model.selection(), model.selection(), 5, model.selection(), 10) - +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_3r-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchCircle_1_2r")], model.selection(), model.selection(), 5, model.selection(), 10) Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_7 = Sketch_3.addLine(21.55890075100801, 30.21822825485694, -17.43219636481839, 31.63011070278906) SketchLine_8 = Sketch_3.addLine(-17.43219636481839, 31.63011070278906, -12.33809712604348, -45.93749869468675) @@ -76,9 +76,10 @@ SketchLine_10 = Sketch_3.addLine(30.10255255530162, -25.9120009302625, 21.558900 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_7.startPoint(), SketchLine_10.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_10")]) - -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_1_1")]) +Face_1_objects = [model.selection("EDGE", "Sketch_3/SketchLine_7"), model.selection("EDGE", "Sketch_3/SketchLine_8"), model.selection("EDGE", "Sketch_3/SketchLine_9"), model.selection("EDGE", "Sketch_3/SketchLine_10")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Partition_1_objects = [model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() model.checkResult(Partition_1,model,1,[2],[4],[42],[198],[396]) diff --git a/src/FeaturesPlugin/Test/TestPartitionFaceWire.py b/src/FeaturesPlugin/Test/TestPartitionFaceWire.py index 3a6a56b86..29ec0085a 100644 --- a/src/FeaturesPlugin/Test/TestPartitionFaceWire.py +++ b/src/FeaturesPlugin/Test/TestPartitionFaceWire.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -52,8 +53,10 @@ SketchLine_9 = Sketch_2.addLine(-36.0335881148175, -7.328477046301525, -31.39978 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_9.endPoint()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")]) -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Face_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_2/SketchArc_2_2"), model.selection("EDGE", "Sketch_2/SketchLine_6"), model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/SketchLine_8")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("WIRE", "Wire_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionInclinedFaceSolid.py b/src/FeaturesPlugin/Test/TestPartitionInclinedFaceSolid.py index c7113bbc2..25fba0007 100644 --- a/src/FeaturesPlugin/Test/TestPartitionInclinedFaceSolid.py +++ b/src/FeaturesPlugin/Test/TestPartitionInclinedFaceSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -30,7 +31,7 @@ SketchCircle_1 = Sketch_1.addCircle(-18.11540697674418, -21.53002906976744, 69.9 SketchCircle_2 = Sketch_1.addCircle(-18.11540697674418, -21.53002906976744, 31.60961705559024) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_2_2r")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_2_2r")], model.selection(), 100, 0) Point_2 = model.addPoint(Part_1_doc, 100, 40, 80) Point_3 = model.addPoint(Part_1_doc, 100, -40, 80) Point_4 = model.addPoint(Part_1_doc, 20, 40, -80) @@ -45,7 +46,8 @@ SketchLine_4 = Sketch_2.addLine(-102.5665996005733, 115.6113578178721, 98.506500 SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3")]) +Face_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_4"), model.selection("EDGE", "Sketch_2/SketchLine_1"), model.selection("EDGE", "Sketch_2/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("FACE", "Face_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid1.py index 689fdb07e..73cb83f81 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid1.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid2.py index 48e09d554..02afc6c25 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid2.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,7 +42,8 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), mo Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), model.selection("FACE", "Box_1_1/Front")) Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Partition_2 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_3")]) +Partition_2_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_3")] +Partition_2 = model.addPartition(Part_1_doc, Partition_2_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid3.py index c6673117d..6508e2171 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithCompSolid3.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,7 +42,8 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), mo Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), model.selection("FACE", "Box_1_1/Front")) Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Partition_2 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Partition_1_1_3")]) +Partition_2_objects = [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Partition_1_1_3")] +Partition_2 = model.addPartition(Part_1_doc, Partition_2_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py index 086680d49..9ba9d1360 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace1.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,8 +42,8 @@ SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace2.py index 3ed42aa9c..4fdfc8e39 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace2.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,8 +42,8 @@ SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "Face_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py index 93b708ca6..1a3a6c59c 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace3.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,8 +42,8 @@ SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "Face_1_1")]) model.do() diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py index c2e0b8045..a11e6bba5 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace4.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,9 +42,10 @@ SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "Face_1_1")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "Face_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py index d1bc8fa05..8bacb70a9 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithFace5.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -40,9 +42,10 @@ SketchLine_1 = Sketch_2.addLine(58.22303949051827, 32.8176179844255, 7.898114670 SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_1.startPoint()) SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_1"), 90, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_2")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_1_1_3")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "Sketch_2/SketchLine_1"), 90, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_2/SketchArc_1_2")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Extrusion_1_1_3")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py index 3e12bd028..68efb9325 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane1.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py index f64b01b7e..0d8668bd1 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane2.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py index befdd8803..c44f1b6dd 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane3.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane4.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane4.py index a4e738ff3..e403909da 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane4.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane4.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -34,7 +36,8 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "PartSet/XOZ")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("FACE", "PartSet/XOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py index 11f2e34c6..e2f6f34d2 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithPlane5.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -34,7 +36,8 @@ SketchCircle_2 = Sketch_1.addCircle(55, 30, 40) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radius") model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "PartSet/XOZ")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("FACE", "PartSet/XOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py index 02f669053..c7adbf2c9 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid1.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py index d132dd368..5097340fe 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid2.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -36,7 +38,8 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid3.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid3.py index 736e688e0..670121b51 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid3.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid3.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -36,7 +38,8 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Box_1_1")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Extrusion_1_1_3"), model.selection("SOLID", "Box_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py index fef86e870..718d72037 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid4.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -36,7 +38,8 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1_2"), model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py index df68837af..61627dbed 100644 --- a/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py +++ b/src/FeaturesPlugin/Test/TestPartitionSubCompsolidWithSolid5.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -36,7 +38,8 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_2.results()[1], "Radi model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "ExtrusionMax", "ExtrusionMin") Box_1 = model.addBox(Part_1_doc, 50, 100, "BoxHeight") -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")]) +Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_1_1_1"), model.selection("SOLID", "Extrusion_1_1_2")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() # check partition diff --git a/src/FeaturesPlugin/Test/TestPartitionWireFaceSolid.py b/src/FeaturesPlugin/Test/TestPartitionWireFaceSolid.py index 9573c9cc7..1c3cb4576 100644 --- a/src/FeaturesPlugin/Test/TestPartitionWireFaceSolid.py +++ b/src/FeaturesPlugin/Test/TestPartitionWireFaceSolid.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -37,7 +38,8 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) SketchCircle_1 = Sketch_1.addCircle(14.49765103937751, 9.678507230150521, 3.831444106492329) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchCircle_1_2")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchLine_5 = Sketch_2.addLine(-15.11211565655763, 11.99814589971457, -14.79635576556081, -11.77064279967296) SketchLine_6 = Sketch_2.addLine(-14.79635576556081, -11.77064279967296, -3.043616368139293, -11.46189011940212) @@ -48,8 +50,10 @@ SketchLine_8 = Sketch_2.addLine(-3.922197168000547, 15.83568871823551, -15.11211 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint()) model.do() -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_7")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Torus_1_1"), model.selection("WIRE", "Wire_1_1")]) +Wire_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_8"), model.selection("EDGE", "Sketch_2/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_6"), model.selection("EDGE", "Sketch_2/SketchLine_7")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Partition_1_objects = [model.selection("FACE", "Face_1_1"), model.selection("SOLID", "Torus_1_1"), model.selection("WIRE", "Wire_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() model.checkResult(Partition_1,model,1,[3],[1],[4],[22],[46]) diff --git a/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py b/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py new file mode 100644 index 000000000..9addcbe6a --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPartition_ErrorMsg.py @@ -0,0 +1,58 @@ +## Copyright (C) 2018-20xx 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(60, -30, 15, -30) +SketchLine_2 = Sketch_1.addLine(15, -30, 15, 15) +SketchLine_3 = Sketch_1.addLine(15, 15, 60, 15) +SketchLine_4 = Sketch_1.addLine(60, 15, 60, -30) +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() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) + +Partition_1 = model.addPartition(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +assert(Partition_1.feature().error() != "") +Part_1_doc.removeFeature(Partition_1.feature()) + +model.end() + + +from ModelAPI import * +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +Partition_1 = Part_1_doc.addFeature("Partition") +Partition_1.execute() +assert(Partition_1.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestPipe_Compound.py b/src/FeaturesPlugin/Test/TestPipe_Compound.py new file mode 100644 index 000000000..192c40087 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPipe_Compound.py @@ -0,0 +1,44 @@ +## Copyright (C) 2018-20xx 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(50, 15, 100, 20) +SketchLine_2 = Sketch_1.addLine(30, 10, 50, 0) +SketchArc_1 = Sketch_1.addArc(30, 40, 60, 40, 30, 70, False) +model.do() +Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]) +model.do() +Pipe_1 = model.addPipe(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection("EDGE", "Sketch_1/SketchArc_1_2")) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Pipe_1, 1) +model.testNbSubResults(Pipe_1, [2]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [2]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [8]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [16]) diff --git a/src/FeaturesPlugin/Test/TestPipe_Edge.py b/src/FeaturesPlugin/Test/TestPipe_Edge.py new file mode 100644 index 000000000..9e17782f9 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPipe_Edge.py @@ -0,0 +1,54 @@ +## Copyright (C) 2018-20xx 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")) +SketchArc_1 = Sketch_1.addArc(23.47558064206828, 28.1849874113521, 68.07028657666974, 20.97621888383109, 20.24058919303746, 73.24260576165612, False) +SketchLine_1 = Sketch_1.addLine(67.41776169413798, 4.173199186912264, 102.8479480835664, 10.72004206910377) +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Pipe_1 = model.addPipe(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "Sketch_1/SketchArc_1_2")) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Pipe_2 = model.addPipe(Part_1_doc, [model.selection("EDGE", "Edge_2_1")], model.selection("EDGE", "PartSet/OY"), model.selection("EDGE", "PartSet/OZ")) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Pipe_1, 1) +model.testNbSubResults(Pipe_1, [0]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [8]) +model.testResultsVolumes(Pipe_1, [3693.366575752712378744035959244]) + +model.testNbResults(Pipe_2, 1) +model.testNbSubResults(Pipe_2, [0]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.VERTEX, [8]) +model.testResultsVolumes(Pipe_2, [3543.018638942841789685189723969]) diff --git a/src/FeaturesPlugin/Test/TestPipe_ErrorMsg.py b/src/FeaturesPlugin/Test/TestPipe_ErrorMsg.py new file mode 100644 index 000000000..ea10665ab --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPipe_ErrorMsg.py @@ -0,0 +1,89 @@ +## Copyright (C) 2018-20xx 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 ModelAPI import * +from GeomDataAPI import * + +# Get document +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create a sketch with circle for pipe profile +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) + +# Create circle +aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle") +anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center")) +aCircleRadius = aSketchCircleFeature.real("circle_radius") +anCircleCentr.setValue(0, 0) +aCircleRadius.setValue(10) +aSession.finishOperation() + +aSketchResult = aSketchFeature.firstResult() +aSketchShape = aSketchResult.shape() + +aSession.startOperation() +aPipeFeature = aPart.addFeature("Pipe") +aPipeFeature.string("creation_method").setValue("WrongCreationMethod") +aPipeFeature.execute() +assert(aPipeFeature.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aBaseObjectsList = aPipeFeature.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, None) +aPipeFeature.execute() +assert(aPipeFeature.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aPathObjectSelection = aPipeFeature.selection("path_object") +aPathObjectSelection.selectSubShape("EDGE", "PartSet/OZ") +aPipeFeature.execute() +assert(aPipeFeature.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aPipeFeature.string("creation_method").setValue("binormal") +aPipeFeature.execute() +assert(aPipeFeature.error() != "") +aSession.finishOperation() + +aSession.startOperation() +aPipeFeature.string("creation_method").setValue("locations") +aBaseObjectsList = aPipeFeature.selectionList("locations_objects") +aBaseObjectsList.append(None, None) +aPipeFeature.execute() +assert(aPipeFeature.error() != "") +aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestPipe_Wire.py b/src/FeaturesPlugin/Test/TestPipe_Wire.py new file mode 100644 index 000000000..34786b0bf --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPipe_Wire.py @@ -0,0 +1,69 @@ +## Copyright (C) 2018-20xx 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, -20, -20, -20) +SketchLine_2 = Sketch_1.addLine(-20, -20, -20, 15) +SketchLine_3 = Sketch_1.addLine(-20, 15, 25, 15) +SketchLine_4 = Sketch_1.addLine(25, 15, 25, -20) +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()) +SketchLine_5 = Sketch_1.addLine(75, 25, 95, 25) +SketchLine_6 = Sketch_1.addLine(95, 25, 95, 45) +SketchLine_7 = Sketch_1.addLine(95, 45, 75, 45) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +model.do() +Pipe_1 = model.addPipe(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")], model.selection("EDGE", "PartSet/OZ")) +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_7")] +Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) +Pipe_2 = model.addPipe(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), []) +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Pipe_1, 1) +model.testNbSubResults(Pipe_1, [0]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.FACE, [6]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.EDGE, [24]) +model.testNbSubShapes(Pipe_1, GeomAPI_Shape.VERTEX, [48]) +model.testResultsVolumes(Pipe_1, [157500]) + +model.testNbResults(Pipe_2, 1) +model.testNbSubResults(Pipe_2, [0]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.EDGE, [12]) +model.testNbSubShapes(Pipe_2, GeomAPI_Shape.VERTEX, [24]) +model.testResultsVolumes(Pipe_2, [6000]) diff --git a/src/FeaturesPlugin/Test/TestPlacement.py b/src/FeaturesPlugin/Test/TestPlacement.py deleted file mode 100644 index 0ad0b903c..000000000 --- a/src/FeaturesPlugin/Test/TestPlacement.py +++ /dev/null @@ -1,242 +0,0 @@ -## 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 -## - -#========================================================================= -# Initialization of the test -#========================================================================= -from ModelAPI import * -from GeomDataAPI import * -from GeomAlgoAPI import * -from GeomAPI import * -import math - -__updated__ = "2014-12-16" - -aSession = ModelAPI_Session.get() -aDocument = aSession.moduleDocument() - -aSession.startOperation() -aPartFeature = aDocument.addFeature("Part") -aSession.finishOperation() -assert (len(aPartFeature.results()) == 1) -aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) -aPart = aPartResult.partDoc() - -#========================================================================= -# Create a sketch to extrude -#========================================================================= -aSession.startOperation() -aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) -origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) -origin.setValue(0, 0, 0) -dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) -dirx.setValue(1, 0, 0) -norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) -norm.setValue(0, 0, 1) -aLineA1 = aSketchFeature.addFeature("SketchLine") -aLineB1 = aSketchFeature.addFeature("SketchLine") -aLineC1 = aSketchFeature.addFeature("SketchLine") -aLineD1 = aSketchFeature.addFeature("SketchLine") -aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) -aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) -aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) -aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) -aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) -aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) -aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) -aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) -aLineA1StartPoint.setValue(-100, 0) -aLineA1EndPoint.setValue(-50, 0) -aLineB1StartPoint.setValue(-50, 0) -aLineB1EndPoint.setValue(-50, 50) -aLineC1StartPoint.setValue(-50, 50) -aLineC1EndPoint.setValue(-100, 50) -aLineD1StartPoint.setValue(-100, 50) -aLineD1EndPoint.setValue(-100, 0) -aLineA2 = aSketchFeature.addFeature("SketchLine") -aLineB2 = aSketchFeature.addFeature("SketchLine") -aLineC2 = aSketchFeature.addFeature("SketchLine") -aLineD2 = aSketchFeature.addFeature("SketchLine") -aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) -aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) -aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) -aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) -aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) -aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) -aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) -aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) -aLineA2StartPoint.setValue(100, 0) -aLineA2EndPoint.setValue(50, 0) -aLineB2StartPoint.setValue(50, 0) -aLineB2EndPoint.setValue(50, 50) -aLineC2StartPoint.setValue(50, 50) -aLineC2EndPoint.setValue(100, 50) -aLineD2StartPoint.setValue(100, 50) -aLineD2EndPoint.setValue(100, 0) -aSession.finishOperation() - -#========================================================================= -# Make extrusion -#========================================================================= -aSketchResult = aSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces) -assert (len(aSketchFaces) > 0) -assert (aSketchFaces[0] is not None) -assert (aSketchFaces[1] is not None) - -aSession.startOperation() -anExtrusionFt = aPart.addFeature("Extrusion") -assert (anExtrusionFt.getKind() == "Extrusion") -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[1]) -anExtrusionFt.string("CreationMethod").setValue("BySizes") -anExtrusionFt.real("to_size").setValue(50) -anExtrusionFt.real("from_size").setValue(0) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove -anExtrusionFt.execute() -aSession.finishOperation() -assert (anExtrusionFt.real("to_size").value() == 50.0) - -# Check extrusion results -assert (len(anExtrusionFt.results()) > 0) -anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) -assert (anExtrusionResult is not None) - -#========================================================================= -# Test placement by face - face -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("face", "Extrusion_1_2/Generated_Face_3") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) -aSession.undo() - -#========================================================================= -# Test placement by face - edge -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) -aSession.undo() - -#========================================================================= -# Test placement by face - vertex -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) -aSession.undo() - -#========================================================================= -# Test placement by edge - edge -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/To_Face_1_1&Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) -aSession.undo() - -#========================================================================= -# Test placement by edge - vertex -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "Extrusion_1_1/To_Face_1_1&Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) -aSession.undo() - -#========================================================================= -# Test placement by vertex - vertex -#========================================================================= -aSession.startOperation() -aPlacementFt = aPart.addFeature("Placement") -aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) -aPlacementFt.selection("placement_start_shape").selectSubShape("vertex", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1_1&Extrusion_1_1/Generated_Face_1") -aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "Extrusion_1_2/To_Face_1_1&Extrusion_1_2/Generated_Face_3&Extrusion_1_2/Generated_Face_2") -aPlacementFt.boolean("placement_reverse_direction").setValue(False) -aPlacementFt.boolean("placement_centering").setValue(True) -aPlacementFt.execute() -aSession.finishOperation() - -# Check placement results -assert (len(aPlacementFt.results()) > 0) -aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) -assert (aPlacementResult is not None) - -from salome.shaper import model -assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_BodyShapesValidator.py b/src/FeaturesPlugin/Test/TestPlacement_BodyShapesValidator.py new file mode 100644 index 000000000..dc3e58cba --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_BodyShapesValidator.py @@ -0,0 +1,38 @@ +## Copyright (C) 2018-20xx 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() +model.do() + +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Box_1 = model.addBox(Part_2_doc, 10, 10, 10) +model.do() + +Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("COMPOUND", "all-in-Part_1"), model.selection("FACE", "Part_2/Box_1_1/Top"), False, False) +assert(Placement_1.feature().error() != "") +Part_1_doc.removeFeature(Placement_1.feature()) + +model.end() diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py new file mode 100644 index 000000000..ac1cb7352 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Edge.py @@ -0,0 +1,140 @@ +## 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 +## + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +import math + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +assert (len(aPartFeature.results()) == 1) +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +#========================================================================= +# Create a sketch to extrude +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aLineA1 = aSketchFeature.addFeature("SketchLine") +aLineB1 = aSketchFeature.addFeature("SketchLine") +aLineC1 = aSketchFeature.addFeature("SketchLine") +aLineD1 = aSketchFeature.addFeature("SketchLine") +aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) +aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) +aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) +aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) +aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) +aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) +aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) +aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) +aLineA1StartPoint.setValue(-100, 0) +aLineA1EndPoint.setValue(-50, 0) +aLineB1StartPoint.setValue(-50, 0) +aLineB1EndPoint.setValue(-50, 50) +aLineC1StartPoint.setValue(-50, 50) +aLineC1EndPoint.setValue(-100, 50) +aLineD1StartPoint.setValue(-100, 50) +aLineD1EndPoint.setValue(-100, 0) +aLineA2 = aSketchFeature.addFeature("SketchLine") +aLineB2 = aSketchFeature.addFeature("SketchLine") +aLineC2 = aSketchFeature.addFeature("SketchLine") +aLineD2 = aSketchFeature.addFeature("SketchLine") +aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) +aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) +aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) +aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) +aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) +aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) +aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) +aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) +aLineA2StartPoint.setValue(100, 0) +aLineA2EndPoint.setValue(50, 0) +aLineB2StartPoint.setValue(50, 0) +aLineB2EndPoint.setValue(50, 50) +aLineC2StartPoint.setValue(50, 50) +aLineC2EndPoint.setValue(100, 50) +aLineD2StartPoint.setValue(100, 50) +aLineD2EndPoint.setValue(100, 0) +aSession.finishOperation() + +#========================================================================= +# Make extrusion +#========================================================================= +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) +assert (aSketchResult.facesNum() > 1) + +aSession.startOperation() +anExtrusionFt = aPart.addFeature("Extrusion") +assert (anExtrusionFt.getKind() == "Extrusion") +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1)) +anExtrusionFt.string("CreationMethod").setValue("BySizes") +anExtrusionFt.real("to_size").setValue(50) +anExtrusionFt.real("from_size").setValue(0) +anExtrusionFt.real("to_offset").setValue(0) #TODO: remove +anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.execute() +aSession.finishOperation() +assert (anExtrusionFt.real("to_size").value() == 50.0) + +# Check extrusion results +assert (len(anExtrusionFt.results()) > 0) +anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) +assert (anExtrusionResult is not None) + +#========================================================================= +# Test placement by edge - edge +#========================================================================= +aSession.startOperation() +aPlacementFt = aPart.addFeature("Placement") +aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) +aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]") +aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/To_Face]") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() + +# Check placement results +assert (len(aPlacementFt.results()) > 0) +aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) +assert (aPlacementResult is not None) +aSession.finishOperation() + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py new file mode 100644 index 000000000..40502f8b0 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Edge_Vertex.py @@ -0,0 +1,140 @@ +## 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 +## + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +import math + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +assert (len(aPartFeature.results()) == 1) +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +#========================================================================= +# Create a sketch to extrude +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aLineA1 = aSketchFeature.addFeature("SketchLine") +aLineB1 = aSketchFeature.addFeature("SketchLine") +aLineC1 = aSketchFeature.addFeature("SketchLine") +aLineD1 = aSketchFeature.addFeature("SketchLine") +aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) +aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) +aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) +aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) +aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) +aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) +aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) +aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) +aLineA1StartPoint.setValue(-100, 0) +aLineA1EndPoint.setValue(-50, 0) +aLineB1StartPoint.setValue(-50, 0) +aLineB1EndPoint.setValue(-50, 50) +aLineC1StartPoint.setValue(-50, 50) +aLineC1EndPoint.setValue(-100, 50) +aLineD1StartPoint.setValue(-100, 50) +aLineD1EndPoint.setValue(-100, 0) +aLineA2 = aSketchFeature.addFeature("SketchLine") +aLineB2 = aSketchFeature.addFeature("SketchLine") +aLineC2 = aSketchFeature.addFeature("SketchLine") +aLineD2 = aSketchFeature.addFeature("SketchLine") +aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) +aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) +aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) +aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) +aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) +aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) +aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) +aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) +aLineA2StartPoint.setValue(100, 0) +aLineA2EndPoint.setValue(50, 0) +aLineB2StartPoint.setValue(50, 0) +aLineB2EndPoint.setValue(50, 50) +aLineC2StartPoint.setValue(50, 50) +aLineC2EndPoint.setValue(100, 50) +aLineD2StartPoint.setValue(100, 50) +aLineD2EndPoint.setValue(100, 0) +aSession.finishOperation() + +#========================================================================= +# Make extrusion +#========================================================================= +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) +assert (aSketchResult.facesNum() > 1) + +aSession.startOperation() +anExtrusionFt = aPart.addFeature("Extrusion") +assert (anExtrusionFt.getKind() == "Extrusion") +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1)) +anExtrusionFt.string("CreationMethod").setValue("BySizes") +anExtrusionFt.real("to_size").setValue(50) +anExtrusionFt.real("from_size").setValue(0) +anExtrusionFt.real("to_offset").setValue(0) #TODO: remove +anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.execute() +aSession.finishOperation() +assert (anExtrusionFt.real("to_size").value() == 50.0) + +# Check extrusion results +assert (len(anExtrusionFt.results()) > 0) +anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) +assert (anExtrusionResult is not None) + +#========================================================================= +# Test placement by edge - vertex +#========================================================================= +aSession.startOperation() +aPlacementFt = aPart.addFeature("Placement") +aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) +aPlacementFt.selection("placement_start_shape").selectSubShape("edge", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]") +aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() + +# Check placement results +assert (len(aPlacementFt.results()) > 0) +aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) +assert (aPlacementResult is not None) +aSession.finishOperation() + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_ErrorMsg.py b/src/FeaturesPlugin/Test/TestPlacement_ErrorMsg.py new file mode 100644 index 000000000..4a3707741 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_ErrorMsg.py @@ -0,0 +1,88 @@ +## Copyright (C) 2018-20xx 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(-16.57843122838298, -30.87163595652513, 16.88033171559421) +SketchCircle_2 = Sketch_1.addCircle(29.74848722752363, 33.32178840955915, 9.026354269133289) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +model.do() +model.end() + +from ModelAPI import * +aSession = ModelAPI_Session.get() + +aShapeToMove = Extrusion_1.feature().results()[1] + +# Verify Placement errors on low-level +aSession.startOperation() +aPlacementFt = featureToCompositeFeature(Part_1.feature()).addFeature("Placement") +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() != "") + +aSession.startOperation() +aPlacementFt.selectionList("placement_objects_list").append(aShapeToMove, aShapeToMove.shape()) +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() != "") + +aSession.startOperation() +aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face") +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() != "") + +aSession.startOperation() +aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2") +aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face") +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() != "") + +aSession.startOperation() +aPlacementFt.selection("placement_start_shape").selectSubShape("EDGE", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchCircle_2_2][Extrusion_1_2/To_Face]") +aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face") +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() != "") + +# Create correct Placement +aSession.startOperation() +aPlacementFt.selection("placement_start_shape").selectSubShape("FACE", "Extrusion_1_2/To_Face") +aPlacementFt.selection("placement_end_shape").selectSubShape("FACE", "Extrusion_1_1/To_Face") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() +assert(aPlacementFt.error() == "") + + +model.begin() +Placement_2 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Placement_1_1")], model.selection("COMPOUND", "Sketch_1"), model.selection("FACE", "Extrusion_1_1/To_Face"), False, False) +assert(Placement_2.feature().error() != "") +Part_1_doc.removeFeature(Placement_2.feature()) +model.end() diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py new file mode 100644 index 000000000..b723c3cc2 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Edge.py @@ -0,0 +1,140 @@ +## 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 +## + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +import math + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +assert (len(aPartFeature.results()) == 1) +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +#========================================================================= +# Create a sketch to extrude +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aLineA1 = aSketchFeature.addFeature("SketchLine") +aLineB1 = aSketchFeature.addFeature("SketchLine") +aLineC1 = aSketchFeature.addFeature("SketchLine") +aLineD1 = aSketchFeature.addFeature("SketchLine") +aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) +aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) +aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) +aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) +aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) +aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) +aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) +aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) +aLineA1StartPoint.setValue(-100, 0) +aLineA1EndPoint.setValue(-50, 0) +aLineB1StartPoint.setValue(-50, 0) +aLineB1EndPoint.setValue(-50, 50) +aLineC1StartPoint.setValue(-50, 50) +aLineC1EndPoint.setValue(-100, 50) +aLineD1StartPoint.setValue(-100, 50) +aLineD1EndPoint.setValue(-100, 0) +aLineA2 = aSketchFeature.addFeature("SketchLine") +aLineB2 = aSketchFeature.addFeature("SketchLine") +aLineC2 = aSketchFeature.addFeature("SketchLine") +aLineD2 = aSketchFeature.addFeature("SketchLine") +aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) +aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) +aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) +aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) +aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) +aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) +aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) +aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) +aLineA2StartPoint.setValue(100, 0) +aLineA2EndPoint.setValue(50, 0) +aLineB2StartPoint.setValue(50, 0) +aLineB2EndPoint.setValue(50, 50) +aLineC2StartPoint.setValue(50, 50) +aLineC2EndPoint.setValue(100, 50) +aLineD2StartPoint.setValue(100, 50) +aLineD2EndPoint.setValue(100, 0) +aSession.finishOperation() + +#========================================================================= +# Make extrusion +#========================================================================= +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) +assert (aSketchResult.facesNum() > 1) + +aSession.startOperation() +anExtrusionFt = aPart.addFeature("Extrusion") +assert (anExtrusionFt.getKind() == "Extrusion") +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1)) +anExtrusionFt.string("CreationMethod").setValue("BySizes") +anExtrusionFt.real("to_size").setValue(50) +anExtrusionFt.real("from_size").setValue(0) +anExtrusionFt.real("to_offset").setValue(0) #TODO: remove +anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.execute() +aSession.finishOperation() +assert (anExtrusionFt.real("to_size").value() == 50.0) + +# Check extrusion results +assert (len(anExtrusionFt.results()) > 0) +anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) +assert (anExtrusionResult is not None) + +#========================================================================= +# Test placement by face - edge +#========================================================================= +aSession.startOperation() +aPlacementFt = aPart.addFeature("Placement") +aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) +aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4") +aPlacementFt.selection("placement_end_shape").selectSubShape("edge", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/To_Face]") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() + +# Check placement results +assert (len(aPlacementFt.results()) > 0) +aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) +assert (aPlacementResult is not None) +aSession.finishOperation() + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py new file mode 100644 index 000000000..ffb334e32 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Face.py @@ -0,0 +1,140 @@ +## 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 +## + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +import math + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +assert (len(aPartFeature.results()) == 1) +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +#========================================================================= +# Create a sketch to extrude +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aLineA1 = aSketchFeature.addFeature("SketchLine") +aLineB1 = aSketchFeature.addFeature("SketchLine") +aLineC1 = aSketchFeature.addFeature("SketchLine") +aLineD1 = aSketchFeature.addFeature("SketchLine") +aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) +aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) +aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) +aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) +aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) +aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) +aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) +aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) +aLineA1StartPoint.setValue(-100, 0) +aLineA1EndPoint.setValue(-50, 0) +aLineB1StartPoint.setValue(-50, 0) +aLineB1EndPoint.setValue(-50, 50) +aLineC1StartPoint.setValue(-50, 50) +aLineC1EndPoint.setValue(-100, 50) +aLineD1StartPoint.setValue(-100, 50) +aLineD1EndPoint.setValue(-100, 0) +aLineA2 = aSketchFeature.addFeature("SketchLine") +aLineB2 = aSketchFeature.addFeature("SketchLine") +aLineC2 = aSketchFeature.addFeature("SketchLine") +aLineD2 = aSketchFeature.addFeature("SketchLine") +aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) +aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) +aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) +aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) +aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) +aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) +aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) +aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) +aLineA2StartPoint.setValue(100, 0) +aLineA2EndPoint.setValue(50, 0) +aLineB2StartPoint.setValue(50, 0) +aLineB2EndPoint.setValue(50, 50) +aLineC2StartPoint.setValue(50, 50) +aLineC2EndPoint.setValue(100, 50) +aLineD2StartPoint.setValue(100, 50) +aLineD2EndPoint.setValue(100, 0) +aSession.finishOperation() + +#========================================================================= +# Make extrusion +#========================================================================= +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) +assert (aSketchResult.facesNum() > 1) + +aSession.startOperation() +anExtrusionFt = aPart.addFeature("Extrusion") +assert (anExtrusionFt.getKind() == "Extrusion") +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1)) +anExtrusionFt.string("CreationMethod").setValue("BySizes") +anExtrusionFt.real("to_size").setValue(50) +anExtrusionFt.real("from_size").setValue(0) +anExtrusionFt.real("to_offset").setValue(0) #TODO: remove +anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.execute() +aSession.finishOperation() +assert (anExtrusionFt.real("to_size").value() == 50.0) + +# Check extrusion results +assert (len(anExtrusionFt.results()) > 0) +anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) +assert (anExtrusionResult is not None) + +#========================================================================= +# Test placement by face - face +#========================================================================= +aSession.startOperation() +aPlacementFt = aPart.addFeature("Placement") +aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) +aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4") +aPlacementFt.selection("placement_end_shape").selectSubShape("face", "Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() + +# Check placement results +assert (len(aPlacementFt.results()) > 0) +aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) +assert (aPlacementResult is not None) +aSession.finishOperation() + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py new file mode 100644 index 000000000..2eed9a251 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Face_Vertex.py @@ -0,0 +1,140 @@ +## 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 +## + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +import math + +__updated__ = "2014-12-16" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +assert (len(aPartFeature.results()) == 1) +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +#========================================================================= +# Create a sketch to extrude +#========================================================================= +aSession.startOperation() +aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) +origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) +origin.setValue(0, 0, 0) +dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) +dirx.setValue(1, 0, 0) +norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) +norm.setValue(0, 0, 1) +aLineA1 = aSketchFeature.addFeature("SketchLine") +aLineB1 = aSketchFeature.addFeature("SketchLine") +aLineC1 = aSketchFeature.addFeature("SketchLine") +aLineD1 = aSketchFeature.addFeature("SketchLine") +aLineA1StartPoint = geomDataAPI_Point2D(aLineA1.attribute("StartPoint")) +aLineA1EndPoint = geomDataAPI_Point2D(aLineA1.attribute("EndPoint")) +aLineB1StartPoint = geomDataAPI_Point2D(aLineB1.attribute("StartPoint")) +aLineB1EndPoint = geomDataAPI_Point2D(aLineB1.attribute("EndPoint")) +aLineC1StartPoint = geomDataAPI_Point2D(aLineC1.attribute("StartPoint")) +aLineC1EndPoint = geomDataAPI_Point2D(aLineC1.attribute("EndPoint")) +aLineD1StartPoint = geomDataAPI_Point2D(aLineD1.attribute("StartPoint")) +aLineD1EndPoint = geomDataAPI_Point2D(aLineD1.attribute("EndPoint")) +aLineA1StartPoint.setValue(-100, 0) +aLineA1EndPoint.setValue(-50, 0) +aLineB1StartPoint.setValue(-50, 0) +aLineB1EndPoint.setValue(-50, 50) +aLineC1StartPoint.setValue(-50, 50) +aLineC1EndPoint.setValue(-100, 50) +aLineD1StartPoint.setValue(-100, 50) +aLineD1EndPoint.setValue(-100, 0) +aLineA2 = aSketchFeature.addFeature("SketchLine") +aLineB2 = aSketchFeature.addFeature("SketchLine") +aLineC2 = aSketchFeature.addFeature("SketchLine") +aLineD2 = aSketchFeature.addFeature("SketchLine") +aLineA2StartPoint = geomDataAPI_Point2D(aLineA2.attribute("StartPoint")) +aLineA2EndPoint = geomDataAPI_Point2D(aLineA2.attribute("EndPoint")) +aLineB2StartPoint = geomDataAPI_Point2D(aLineB2.attribute("StartPoint")) +aLineB2EndPoint = geomDataAPI_Point2D(aLineB2.attribute("EndPoint")) +aLineC2StartPoint = geomDataAPI_Point2D(aLineC2.attribute("StartPoint")) +aLineC2EndPoint = geomDataAPI_Point2D(aLineC2.attribute("EndPoint")) +aLineD2StartPoint = geomDataAPI_Point2D(aLineD2.attribute("StartPoint")) +aLineD2EndPoint = geomDataAPI_Point2D(aLineD2.attribute("EndPoint")) +aLineA2StartPoint.setValue(100, 0) +aLineA2EndPoint.setValue(50, 0) +aLineB2StartPoint.setValue(50, 0) +aLineB2EndPoint.setValue(50, 50) +aLineC2StartPoint.setValue(50, 50) +aLineC2EndPoint.setValue(100, 50) +aLineD2StartPoint.setValue(100, 50) +aLineD2EndPoint.setValue(100, 0) +aSession.finishOperation() + +#========================================================================= +# Make extrusion +#========================================================================= +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) +assert (aSketchResult.facesNum() > 1) + +aSession.startOperation() +anExtrusionFt = aPart.addFeature("Extrusion") +assert (anExtrusionFt.getKind() == "Extrusion") +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(1)) +anExtrusionFt.string("CreationMethod").setValue("BySizes") +anExtrusionFt.real("to_size").setValue(50) +anExtrusionFt.real("from_size").setValue(0) +anExtrusionFt.real("to_offset").setValue(0) #TODO: remove +anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.execute() +aSession.finishOperation() +assert (anExtrusionFt.real("to_size").value() == 50.0) + +# Check extrusion results +assert (len(anExtrusionFt.results()) > 0) +anExtrusionResult = modelAPI_ResultBody(anExtrusionFt.firstResult()) +assert (anExtrusionResult is not None) + +#========================================================================= +# Test placement by face - vertex +#========================================================================= +aSession.startOperation() +aPlacementFt = aPart.addFeature("Placement") +aPlacementFt.selectionList("placement_objects_list").append(anExtrusionResult, anExtrusionResult.shape()) +aPlacementFt.selection("placement_start_shape").selectSubShape("face", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4") +aPlacementFt.selection("placement_end_shape").selectSubShape("vertex", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]") +aPlacementFt.boolean("placement_reverse_direction").setValue(False) +aPlacementFt.boolean("placement_centering").setValue(True) +aPlacementFt.execute() +aSession.finishOperation() + +# Check placement results +assert (len(aPlacementFt.results()) > 0) +aPlacementResult = modelAPI_ResultBody(aPlacementFt.firstResult()) +assert (aPlacementResult is not None) +aSession.finishOperation() + +from salome.shaper import model +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Part_Part.py b/src/FeaturesPlugin/Test/TestPlacement_Part_Part.py new file mode 100644 index 000000000..6f6d28f11 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Part_Part.py @@ -0,0 +1,44 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() +Cylinder_1 = model.addCylinder(Part_2_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +model.do() +Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("FACE", "Part_2/Cylinder_1_1/Face_2"), model.selection("FACE", "Part_1/Box_1_1/Front"), False, True) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Placement_1, 1) +model.testNbSubResults(Placement_1, [0]) +model.testNbSubShapes(Placement_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Placement_1, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Placement_1, GeomAPI_Shape.EDGE, [6]) +model.testNbSubShapes(Placement_1, GeomAPI_Shape.VERTEX, [12]) +model.testResultsVolumes(Placement_1, [785.398163397448342948337085545]) diff --git a/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py b/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py new file mode 100644 index 000000000..568564ad5 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestPlacement_Vertex_Vertex.py @@ -0,0 +1,42 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +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(-100, 0, -50, 0) +SketchLine_2 = Sketch_1.addLine(-50, 0, -50, 50) +SketchLine_3 = Sketch_1.addLine(-50, 50, -100, 50) +SketchLine_4 = Sketch_1.addLine(-100, 50, -100, 0) +SketchLine_5 = Sketch_1.addLine(100, 0, 50, 0) +SketchLine_6 = Sketch_1.addLine(50, 0, 50, 50) +SketchLine_7 = Sketch_1.addLine(50, 50, 100, 50) +SketchLine_8 = Sketch_1.addLine(100, 50, 100, 0) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 50, 0) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]"), model.selection("VERTEX", "[Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_2/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_2/To_Face]"), False, True) +model.do() +model.end() diff --git a/src/FeaturesPlugin/Test/TestRecover1798.py b/src/FeaturesPlugin/Test/TestRecover1798.py index 1adcbd13e..40085922c 100644 --- a/src/FeaturesPlugin/Test/TestRecover1798.py +++ b/src/FeaturesPlugin/Test/TestRecover1798.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -54,7 +56,7 @@ SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_11 = Sketch_1.addLine(-70, 0, -90, 0) SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_9.result()) -SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_10.result(), 70) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_10.result(), 70, False) SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_10.result()) SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_2.result()) SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_4.result()) @@ -66,10 +68,10 @@ SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_3.result()) SketchConstraintHorizontal_3.setName("SketchConstraintHorizontal_4") SketchConstraintHorizontal_4 = Sketch_1.setHorizontal(SketchLine_7.result()) SketchConstraintHorizontal_4.setName("SketchConstraintHorizontal_5") -SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_9.startPoint(), SketchLine_1.result(), 80) -SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_5.endPoint(), SketchLine_1.result(), 90) -SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_1.result(), 85) -SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_2.endPoint(), SketchLine_1.result(), 90) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_9.startPoint(), SketchLine_1.result(), 80, False) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_5.endPoint(), SketchLine_1.result(), 90, False) +SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_1.result(), 85, False) +SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_2.endPoint(), SketchLine_1.result(), 90, False) SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_2.startPoint()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_10.result(), 190) SketchConstraintLength_1.setName("SketchConstraintLength_3") @@ -92,40 +94,44 @@ SketchConstraintHorizontal_5.setName("SketchConstraintHorizontal_8") SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_13.result(), SketchLine_4.endPoint()) SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_17") model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r-SketchLine_11r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 180, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Revolution_1_1/From_Face_1"), 120, True) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r")], model.selection("EDGE", "Sketch_1/SketchLine_1"), 180, 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Revolution_1_1/From_Face"), 120, True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_14 = SketchProjection_1.createdFeature() -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX")) +SketchLine_14.setName("SketchLine_14") +SketchLine_14.result().setName("SketchLine_14") +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) SketchLine_15 = SketchProjection_2.createdFeature() -SketchLine_16 = Sketch_2.addLine(-15.00002401644285, 44.20204102886705, 14.99999932366307, 44.20204102886705) +SketchLine_15.setName("SketchLine_15") +SketchLine_15.result().setName("SketchLine_15") +SketchLine_16 = Sketch_2.addLine(-15, 44.202041028867, 15, 44.20204102886701) SketchLine_16.setName("SketchLine_24") SketchLine_16.result().setName("SketchLine_24") -SketchLine_17 = Sketch_2.addLine(-25, 88.20203643108667, -25, 54.20202402898175) +SketchLine_17 = Sketch_2.addLine(-25, 88.20204102886699, -25, 54.202041028867) SketchLine_17.setName("SketchLine_28") SketchLine_17.result().setName("SketchLine_28") -SketchLine_18 = Sketch_2.addLine(25, 54.2020551101737, 25, 88.20204066628929) +SketchLine_18 = Sketch_2.addLine(25, 54.20204102886701, 25, 88.202041028867) SketchLine_18.setName("SketchLine_26") SketchLine_18.result().setName("SketchLine_26") -SketchLine_19 = Sketch_2.addLine(14.99999814471567, 98.20204102886706, -15.00002220451297, 98.20204102886706) +SketchLine_19 = Sketch_2.addLine(15, 98.202041028867, -15.00000000000001, 98.20204102886699) SketchLine_19.setName("SketchLine_27") SketchLine_19.result().setName("SketchLine_27") -SketchLine_21 = Sketch_2.addLine(25, 98.20204102886706, -25, 98.20204102886706) -SketchLine_21.setName("SketchLine_15") -SketchLine_21.result().setName("SketchLine_15") -SketchLine_21.setAuxiliary(True) -SketchLine_20 = Sketch_2.addLine(25, 44.20204102886705, 25, 98.20204102886706) -SketchLine_20.setName("SketchLine_18") -SketchLine_20.result().setName("SketchLine_18") +SketchLine_20 = Sketch_2.addLine(25, 98.20204102886706, -25, 98.20204102886706) +SketchLine_20.setName("SketchLine_15") +SketchLine_20.result().setName("SketchLine_15") SketchLine_20.setAuxiliary(True) -SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +SketchLine_21 = Sketch_2.addLine(25, 44.20204102886705, 25, 98.20204102886706) +SketchLine_21.setName("SketchLine_18") +SketchLine_21.result().setName("SketchLine_18") +SketchLine_21.setAuxiliary(True) +SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_20.startPoint()) SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_13") SketchLine_22 = Sketch_2.addLine(-25, 98.20204102886706, -25, 44.20204102886705) SketchLine_22.setName("SketchLine_16") SketchLine_22.result().setName("SketchLine_16") SketchLine_22.setAuxiliary(True) -SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) +SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_22.startPoint()) SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_14") SketchLine_23 = Sketch_2.addLine(-25, 44.20204102886705, 25, 44.20204102886705) SketchLine_23.setName("SketchLine_17") @@ -133,27 +139,31 @@ SketchLine_23.result().setName("SketchLine_17") SketchLine_23.setAuxiliary(True) SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_15") -SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_23.endPoint(), SketchLine_20.startPoint()) +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_23.endPoint(), SketchLine_21.startPoint()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_16") -SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_21.result()) +SketchConstraintHorizontal_6 = Sketch_2.setHorizontal(SketchLine_20.result()) +SketchConstraintHorizontal_6.setName("SketchConstraintHorizontal_6") SketchConstraintVertical_7 = Sketch_2.setVertical(SketchLine_22.result()) SketchConstraintHorizontal_7 = Sketch_2.setHorizontal(SketchLine_23.result()) -SketchConstraintVertical_8 = Sketch_2.setVertical(SketchLine_20.result()) -SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_21.result(), "l_percage") +SketchConstraintHorizontal_7.setName("SketchConstraintHorizontal_7") +SketchConstraintVertical_8 = Sketch_2.setVertical(SketchLine_21.result()) +SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_20.result(), "l_percage") SketchConstraintLength_6.setName("SketchConstraintLength_8") -SketchConstraintLength_7 = Sketch_2.setLength(SketchLine_20.result(), 54) +SketchConstraintLength_7 = Sketch_2.setLength(SketchLine_21.result(), 54) SketchConstraintLength_7.setName("SketchConstraintLength_9") -SketchConstraintDistance_6 = Sketch_2.setDistance(SketchLine_14.result(), SketchLine_22.startPoint(), "l_percage/2") -SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_19")) +SketchConstraintDistance_6 = Sketch_2.setDistance(SketchLine_14.result(), SketchLine_22.startPoint(), "l_percage/2", False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_19"), False) SketchLine_24 = SketchProjection_3.createdFeature() -SketchConstraintDistance_7 = Sketch_2.setDistance(SketchLine_24.result(), SketchLine_21.startPoint(), 20) -SketchArc_1 = Sketch_2.addArc(-15, 54.20204102886705, -25, 54.20202402898175, -15.00002401644285, 44.20204102886705, False) -SketchLine_25 = Sketch_2.addLine(-25, 98.20204102886706, -25, 54.20202402898175) +SketchLine_24.setName("SketchLine_25") +SketchLine_24.result().setName("SketchLine_25") +SketchConstraintDistance_7 = Sketch_2.setDistance(SketchLine_24.result(), SketchLine_20.startPoint(), 20, False) +SketchArc_1 = Sketch_2.addArc(-15, 54.202041028867, -25, 54.202041028867, -15, 44.202041028867, False) +SketchLine_25 = Sketch_2.addLine(-25, 98.20204102886706, -25, 54.202041028867) SketchLine_25.setName("SketchLine_22") SketchLine_25.result().setName("SketchLine_22") SketchLine_25.setAuxiliary(True) SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchLine_25.endPoint()) -SketchLine_26 = Sketch_2.addLine(-15.00002401644285, 44.20204102886705, 25, 44.20204102886705) +SketchLine_26 = Sketch_2.addLine(-15, 44.202041028867, 25, 44.20204102886705) SketchLine_26.setName("SketchLine_21") SketchLine_26.result().setName("SketchLine_21") SketchLine_26.setAuxiliary(True) @@ -164,33 +174,33 @@ SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_23.endPoint() SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_22.startPoint(), SketchLine_25.startPoint()) SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_26.startPoint(), SketchLine_23.result()) SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_25.endPoint(), SketchLine_22.result()) -SketchArc_2 = Sketch_2.addArc(15, 54.20204102886705, 14.99999932366307, 44.20204102886705, 25, 54.2020551101737, False) +SketchArc_2 = Sketch_2.addArc(15, 54.20204102886701, 15, 44.20204102886701, 25, 54.20204102886701, False) SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_16.endPoint()) -SketchLine_27 = Sketch_2.addLine(25, 54.2020551101737, 25, 98.20204102886706) +SketchLine_27 = Sketch_2.addLine(25, 54.20204102886701, 25, 98.20204102886706) SketchLine_27.setName("SketchLine_23") SketchLine_27.result().setName("SketchLine_23") SketchLine_27.setAuxiliary(True) SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_27.startPoint()) SketchConstraintTangent_3 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_27.result()) SketchConstraintTangent_4 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_16.result()) -SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_27.endPoint()) +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_27.endPoint()) SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_26.startPoint(), SketchLine_16.startPoint()) -SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_27.startPoint(), SketchLine_20.result()) +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_27.startPoint(), SketchLine_21.result()) SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchLine_26.result()) -SketchArc_3 = Sketch_2.addArc(15, 88.20204102886704, 25, 88.20204066628929, 14.99999814471567, 98.20204102886706, False) +SketchArc_3 = Sketch_2.addArc(15, 88.202041028867, 25, 88.202041028867, 15, 98.202041028867, False) SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchArc_3.startPoint(), SketchLine_18.endPoint()) -SketchLine_28 = Sketch_2.addLine(14.99999814471567, 98.20204102886706, -25, 98.20204102886706) +SketchLine_28 = Sketch_2.addLine(15, 98.202041028867, -25, 98.20204102886706) SketchLine_28.setName("SketchLine_25") SketchLine_28.result().setName("SketchLine_25") SketchLine_28.setAuxiliary(True) SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchArc_3.endPoint(), SketchLine_28.startPoint()) SketchConstraintTangent_5 = Sketch_2.setTangent(SketchArc_3.results()[1], SketchLine_28.result()) SketchConstraintTangent_6 = Sketch_2.setTangent(SketchArc_3.results()[1], SketchLine_18.result()) -SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchLine_21.endPoint(), SketchLine_28.endPoint()) +SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchLine_20.endPoint(), SketchLine_28.endPoint()) SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchLine_27.startPoint(), SketchLine_18.startPoint()) -SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchLine_28.startPoint(), SketchLine_21.result()) +SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchLine_28.startPoint(), SketchLine_20.result()) SketchConstraintCoincidence_35 = Sketch_2.setCoincident(SketchLine_18.endPoint(), SketchLine_27.result()) -SketchArc_4 = Sketch_2.addArc(-15, 88.20204102886706, -15.00002220451297, 98.20204102886706, -25, 88.20203643108667, False) +SketchArc_4 = Sketch_2.addArc(-15, 88.20204102886699, -15.00000000000001, 98.20204102886699, -25, 88.20204102886699, False) SketchConstraintCoincidence_36 = Sketch_2.setCoincident(SketchArc_4.startPoint(), SketchLine_19.endPoint()) SketchConstraintCoincidence_37 = Sketch_2.setCoincident(SketchArc_4.endPoint(), SketchLine_17.startPoint()) SketchConstraintTangent_7 = Sketch_2.setTangent(SketchArc_4.results()[1], SketchLine_19.result()) @@ -204,9 +214,9 @@ SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_4.results()[1], 10) SketchConstraintRadius_3 = Sketch_2.setRadius(SketchArc_2.results()[1], 10) SketchConstraintRadius_4 = Sketch_2.setRadius(SketchArc_1.results()[1], 10) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_24f-SketchLine_28f-SketchLine_26f-SketchLine_27f-SketchArc_1_2f-SketchArc_2_2f-SketchArc_3_2f-SketchArc_4_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/To_Face_1"), -30, model.selection(), 0) -Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "Extrusion_1_1/From_Face_1&Extrusion_1_1/Generated_Face_8"), "inclinaison") -Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "PartSet/OZ"), "angle1") +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_24f-SketchArc_2_2f-SketchLine_26f-SketchArc_3_2f-SketchLine_27f-SketchArc_4_2f-SketchLine_28f-SketchArc_1_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/To_Face"), -30, model.selection(), 0) +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_24][Extrusion_1_1/From_Face]"), "inclinaison") +Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_1_1")], model.selection("EDGE", "PartSet/OZ"), "angle1") Recover_1 = model.addRecover(Part_1_doc, Rotation_2, [Rotation_1.result()]) Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1")], model.selection("EDGE", "PartSet/OZ"), "angle2") Rotation_3.setName("Rotation_4") @@ -219,8 +229,10 @@ Recover_3 = model.addRecover(Part_1_doc, Rotation_2, [Rotation_1.result()]) Rotation_5 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_3_1")], model.selection("EDGE", "PartSet/OZ"), "-angle1") Rotation_5.setName("Rotation_6") Rotation_5.result().setName("Rotation_6_1") -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Rotation_4_1"), model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Rotation_6_1"), model.selection("SOLID", "Rotation_5_1")]) +Cut_1_objects_2 = [model.selection("SOLID", "Rotation_4_1"), model.selection("SOLID", "Rotation_2_1"), model.selection("SOLID", "Rotation_6_1"), model.selection("SOLID", "Rotation_5_1")] +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], Cut_1_objects_2) +model.do() model.end() -assert(Boolean_1.result().shapeType() == 'SOLID') +assert(Cut_1.result().shapeType() == 'SOLID') assert(Part_1_doc.size("Bodies") == 1) diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes3.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes3.py index c7f7d6384..a7531b72b 100644 --- a/src/FeaturesPlugin/Test/TestRemoveSubShapes3.py +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes3.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -36,7 +38,7 @@ Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_ Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Translation_1_1"), model.selection("FACE", "Face_1_1")]) Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("SHELL", "Shell_1_1")) -Remove_SubShapes_1.setSubShapesToRemove([model.selection("FACE", "Shell_1_1/Modified_Face_2")]) +Remove_SubShapes_1.setSubShapesToRemove([model.selection("FACE", "Shell_1_1/Modified_Face&Face_2_1/Face_2_1")]) model.do() model.checkResult(Remove_SubShapes_1, model, 1, [0], [0], [1], [4], [8]) diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes4.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes4.py index e594d3371..5d203c268 100644 --- a/src/FeaturesPlugin/Test/TestRemoveSubShapes4.py +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes4.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -47,7 +49,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 20) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 2, 2) Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes5.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes5.py index ff3c8d804..8d24febe2 100644 --- a/src/FeaturesPlugin/Test/TestRemoveSubShapes5.py +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes5.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -47,7 +49,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 20) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 2, 2) Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes6.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes6.py index ff61445e5..806869411 100644 --- a/src/FeaturesPlugin/Test/TestRemoveSubShapes6.py +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes6.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from GeomAPI import * @@ -47,7 +49,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 20) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")]) LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 2, 2) Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) diff --git a/src/FeaturesPlugin/Test/TestRevolution.py b/src/FeaturesPlugin/Test/TestRevolution.py index bfe1a37bb..dfd45ccb4 100644 --- a/src/FeaturesPlugin/Test/TestRevolution.py +++ b/src/FeaturesPlugin/Test/TestRevolution.py @@ -86,16 +86,8 @@ aCircleRadius.setValue(30.) aSession.finishOperation() # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) #========================================================================= # Create a sketch line to revol @@ -130,7 +122,7 @@ aRevolFt = aPart.addFeature("Revolution") assert (aRevolFt.getKind() == "Revolution") # selection type FACE=4 aRevolFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) aRevolFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge) aRevolFt.string("CreationMethod").setValue("ByAngles") aRevolFt.real("from_angle").setValue(10) @@ -184,7 +176,7 @@ aRevolFt = aPart.addFeature("Revolution") assert (aRevolFt.getKind() == "Revolution") # selection type FACE=4 aRevolFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) aRevolFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge) aRevolFt.string("CreationMethod").setValue("ByPlanesAndOffsets") aRevolFt.real("from_angle").setValue(0) #TODO: remove @@ -210,7 +202,7 @@ aRevolFt = aPart.addFeature("Revolution") assert (aRevolFt.getKind() == "Revolution") # selection type FACE=4 aRevolFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) aRevolFt.selection("axis_object").setValue(aLineSketchResult, aLineEdge) aRevolFt.string("CreationMethod").setValue("ByPlanesAndOffsets") aRevolFt.real("from_angle").setValue(0) #TODO: remove diff --git a/src/FeaturesPlugin/Test/TestRevolutionCut.py b/src/FeaturesPlugin/Test/TestRevolutionCut.py index 21bb4644b..03a3ade72 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionCut.py +++ b/src/FeaturesPlugin/Test/TestRevolutionCut.py @@ -62,23 +62,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -104,7 +96,7 @@ dirx = geomDataAPI_Dir(aLineSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aLineSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace_1") +aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace") aSketchLine = aLineSketchFeature.addFeature("SketchLine") aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint")) @@ -134,7 +126,7 @@ dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1") +aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face") aSession.startOperation() aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) diff --git a/src/FeaturesPlugin/Test/TestRevolutionFuse.py b/src/FeaturesPlugin/Test/TestRevolutionFuse.py index 659cde9b8..ee8e77c2f 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionFuse.py +++ b/src/FeaturesPlugin/Test/TestRevolutionFuse.py @@ -90,23 +90,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -132,7 +124,7 @@ dirx = geomDataAPI_Dir(aLineSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aLineSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace_1") +aLineSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/TopFace") aSketchLine = aLineSketchFeature.addFeature("SketchLine") aLineStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint")) @@ -162,7 +154,7 @@ dirx = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")) dirx.setValue(1, 0, 0) norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) -aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1") +aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face") aSession.startOperation() aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle") anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) diff --git a/src/FeaturesPlugin/Test/TestRotation.py b/src/FeaturesPlugin/Test/TestRotation.py index 5e192e24a..62229e654 100644 --- a/src/FeaturesPlugin/Test/TestRotation.py +++ b/src/FeaturesPlugin/Test/TestRotation.py @@ -75,23 +75,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) diff --git a/src/FeaturesPlugin/Test/TestRotation_ErrorMsg.py b/src/FeaturesPlugin/Test/TestRotation_ErrorMsg.py new file mode 100644 index 000000000..0e903e586 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestRotation_ErrorMsg.py @@ -0,0 +1,80 @@ +## Copyright (C) 2018-20xx 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() +Box_1 =model.addBox(Part_1_doc, 10, 10, 10) +model.end() + +from ModelAPI import * +aSession = ModelAPI_Session.get() + +aShapeToMove = Box_1.feature().lastResult() + +# Verify Rotation errors on low-level +aSession.startOperation() +aRotation = featureToCompositeFeature(Part_1.feature()).addFeature("Rotation") +aRotation.string("CreationMethod").setValue("ByAxisAndAngle") +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.selectionList("main_objects").append(aShapeToMove, aShapeToMove.shape()) +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.selectionList("main_objects").append(None, None) +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.string("CreationMethod").setValue("ByThreePoints") +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.selectionList("main_objects").removeLast() +aRotation.selectionList("main_objects").removeLast() +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.selectionList("main_objects").append(aShapeToMove, aShapeToMove.shape()) +aRotation.string("CreationMethod").setValue("ByAxisAndAngle") +aRotation.selection("axis_object").selectSubShape("FACE", "Box_1_1/Back") +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") + +aSession.startOperation() +aRotation.selection("axis_object").selectSubShape("COMPOUND", "Box_1_1/Back") +aRotation.execute() +aSession.finishOperation() +assert(aRotation.error() != "") diff --git a/src/FeaturesPlugin/Test/TestSerialBoolean.py b/src/FeaturesPlugin/Test/TestSerialBoolean.py index ddbde4793..2012454bc 100644 --- a/src/FeaturesPlugin/Test/TestSerialBoolean.py +++ b/src/FeaturesPlugin/Test/TestSerialBoolean.py @@ -96,30 +96,17 @@ aSession.startOperation() anExtrusions = [] for i in range(0, N * N): - aSketchResult = aSketchFeatures[i].firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir() - norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) - + aSketchResult = modelAPI_ResultConstruction(aSketchFeatures[i].firstResult()) anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") anExtrusionFt.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(10) anExtrusionFt.real("to_offset").setValue(0) #TODO: remove anExtrusionFt.real("from_offset").setValue(0) #TODO: remove - # v1.0.2 from master - # anExtrusionFt.selection("extrusion_face").setValue( - # aSketchResult, aSketchFaces[0]) - # anExtrusionFt.real("extrusion_size").setValue(10) - # anExtrusionFt.boolean("extrusion_reverse").setValue(False) anExtrusions.append(anExtrusionFt) aSession.finishOperation() @@ -162,28 +149,16 @@ aSession.startOperation() #========================================================================= # Build a big box extrusion #========================================================================= -aSketchResult = aQuadrangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aQuadrangleSketchFeature.firstResult()) # Create extrusion on them aBox = aPart.addFeature("Extrusion") aBox.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) aBox.string("CreationMethod").setValue("BySizes") aBox.real("from_size").setValue(0) aBox.real("to_size").setValue(10) aBox.real("to_offset").setValue(0) #TODO: remove aBox.real("from_offset").setValue(0) #TODO: remove -# v 1.0.2 from master -# aBox.selection("extrusion_face").setValue( -# aSketchResult, aSketchFaces[0]) -# aBox.real("extrusion_size").setValue(10) -# aBox.boolean("extrusion_reverse").setValue(False) aSession.finishOperation() diff --git a/src/FeaturesPlugin/Test/TestSymmetry_Part.py b/src/FeaturesPlugin/Test/TestSymmetry_Part.py new file mode 100644 index 000000000..c0db1e382 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestSymmetry_Part.py @@ -0,0 +1,42 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +Symmetry_1 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("VERTEX", "Part_1/[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), False) +Symmetry_2 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Symmetry_1/")], model.selection("EDGE", "Symmetry_1/[Box_1_1/Back][Box_1_1/Left]"), False) +Symmetry_3 = model.addSymmetry(partSet, [model.selection("COMPOUND", "Symmetry_2/")], model.selection("FACE", "Symmetry_2/Box_1_1/Bottom"), True) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Symmetry_3, 2) +model.testNbSubResults(Symmetry_3, [0, 0]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.SOLID, [1, 1]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.FACE, [6, 6]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.EDGE, [24, 24]) +model.testNbSubShapes(Symmetry_3, GeomAPI_Shape.VERTEX, [48, 48]) +model.testResultsVolumes(Symmetry_3, [-1000, 1000]) diff --git a/src/FeaturesPlugin/Test/TestTranslation.py b/src/FeaturesPlugin/Test/TestTranslation.py index 0ebe4e300..3309d0ddf 100644 --- a/src/FeaturesPlugin/Test/TestTranslation.py +++ b/src/FeaturesPlugin/Test/TestTranslation.py @@ -75,23 +75,15 @@ aSession.finishOperation() # Make extrusion on circle #========================================================================= # Build shape from sketcher results -aCircleSketchResult = aCircleSketchFeature.firstResult() -aCircleSketchEdges = modelAPI_ResultConstruction(aCircleSketchResult).shape() -origin = geomDataAPI_Point(aCircleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aCircleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm")).dir() -aCircleSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aCircleSketchEdges, aCircleSketchFaces) -assert (len(aCircleSketchFaces) > 0) -assert (aCircleSketchFaces[0] is not None) +aCircleSketchResult = modelAPI_ResultConstruction(aCircleSketchFeature.firstResult()) +assert (aCircleSketchResult.facesNum() > 0) # Create extrusion aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") # selection type FACE=4 anExtrusionFt.selectionList("base").append( - aCircleSketchResult, aCircleSketchFaces[0]) + aCircleSketchResult, aCircleSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) diff --git a/src/FeaturesPlugin/Test/TestTranslation_Part.py b/src/FeaturesPlugin/Test/TestTranslation_Part.py new file mode 100644 index 000000000..f50e57578 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestTranslation_Part.py @@ -0,0 +1,42 @@ +## Copyright (C) 2018-20xx 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() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +Translation_1 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_1/")], model.selection("EDGE", "OX"), 10) +Translation_2 = model.addTranslation(partSet, [model.selection("COMPOUND", "Translation_1/")], 0, 10, 0) +Translation_3 = model.addTranslation(partSet, [model.selection("COMPOUND", "Translation_2/")], model.selection("VERTEX", "Translation_2/[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "Translation_2/[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]")) +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Translation_1, 1) +model.testNbSubResults(Translation_1, [0]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.FACE, [6]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.EDGE, [24]) +model.testNbSubShapes(Translation_1, GeomAPI_Shape.VERTEX, [48]) +model.testResultsVolumes(Translation_1, [1000]) diff --git a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py index 80665ef41..aff0c7b96 100644 --- a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py +++ b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -36,7 +37,7 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")]) Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OY"), 200, 0) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "Revolution_1_1")]) Union_1 = model.addUnion(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2")]) diff --git a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py index 2519dd469..52d67d340 100644 --- a/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py +++ b/src/FeaturesPlugin/Test/TestUnion4CurvedFaces_2.py @@ -1,3 +1,8 @@ +## 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, @@ -13,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,10 +37,12 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchArc_1_2")]) Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OY"), 360, 0) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/XOY"), model.selection("FACE", "Revolution_1_1")]) -Union_1 = model.addUnion(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")]) +Partition_1_objects = [model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/XOY"), model.selection("FACE", "Revolution_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +Union_1_objects = [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")] +Union_1 = model.addUnion(Part_1_doc, Union_1_objects) model.testHaveNamingSubshapes(Union_1,model,Part_1_doc) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/TestUnion4Faces.py b/src/FeaturesPlugin/Test/TestUnion4Faces.py index f5adc70c8..87b1617a8 100644 --- a/src/FeaturesPlugin/Test/TestUnion4Faces.py +++ b/src/FeaturesPlugin/Test/TestUnion4Faces.py @@ -1,4 +1,4 @@ -## Copyright (C) 2017 CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,7 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- from salome.shaper import model @@ -37,9 +38,9 @@ SketchLine_5 = Sketch_1.addLine(31.85610465116278, -38.16860465116279, -44.48110 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.startPoint()) model.do() -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchLine_6 = Sketch_2.addLine(31.85610465116278, -38.16860465116279, -40.43276493886778, -56.03425756438362) -SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s-SketchLine_4e"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.startPoint(), SketchPoint_1.result()) SketchLine_7 = Sketch_2.addLine(-40.43276493886778, -56.03425756438362, -115.5003601973775, -26.06900348999911) @@ -48,14 +49,18 @@ SketchLine_8 = Sketch_2.addLine(-115.5003601973775, -26.06900348999911, -106.232 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchLine_9 = Sketch_2.addLine(-106.2327558444751, 34.47934494896344, -44.48110465116279, 12.33139534883721) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_5e"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchPoint_2.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_6"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_8")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "PartSet/YOZ")]) -Union_1 = model.addUnion(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Face_2_objects = [model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_2/SketchLine_6"), model.selection("EDGE", "Sketch_2/SketchLine_7"), model.selection("EDGE", "Sketch_2/SketchLine_8")] +Face_2 = model.addFace(Part_1_doc, Face_2_objects) +Partition_1_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "PartSet/YOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +Union_1_objects = [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_3"), model.selection("FACE", "Partition_1_1_4")] +Union_1 = model.addUnion(Part_1_doc, Union_1_objects) model.do() model.checkResult(Union_1,model,1,[2],[0],[2],[13],[26]) diff --git a/src/FeaturesPlugin/Test/TestUnionFaces.py b/src/FeaturesPlugin/Test/TestUnionFaces.py index ae80df8af..886da1df4 100644 --- a/src/FeaturesPlugin/Test/TestUnionFaces.py +++ b/src/FeaturesPlugin/Test/TestUnionFaces.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,8 +29,9 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_1.addCircle(-5.197255574614073, 0.1732418524871273, 67.586529314451) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) +Partition_1_objects = [model.selection("FACE", "Face_1_1"), model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) Union_1 = model.addUnion(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("FACE", "Partition_1_1_2")]) model.do() model.end() diff --git a/src/FeaturesPlugin/Test/TestUnionOfUnion.py b/src/FeaturesPlugin/Test/TestUnionOfUnion.py index a681118ea..ba8e4c177 100644 --- a/src/FeaturesPlugin/Test/TestUnionOfUnion.py +++ b/src/FeaturesPlugin/Test/TestUnionOfUnion.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -30,7 +32,8 @@ Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Front"), 5 Partition_1_objects = [model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"), model.selection("SOLID", "Box_1_1")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) Union_1 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Partition_1_1_3"), model.selection("SOLID", "Partition_1_1_1")]) -Union_2 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Partition_1_1_4/Partition_1_1_4"), model.selection("SOLID", "Partition_1_1_2/Partition_1_1_2")]) +Union_2 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Union_1_1_2"), model.selection("SOLID", "Union_1_1_1")]) +model.do() model.end() from GeomAPI import GeomAPI_Shape diff --git a/src/FeaturesPlugin/Test/TestUnion_ErrorMsg.py b/src/FeaturesPlugin/Test/TestUnion_ErrorMsg.py new file mode 100644 index 000000000..5f5710a49 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestUnion_ErrorMsg.py @@ -0,0 +1,37 @@ +## Copyright (C) 2018-20xx 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.standardPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(0, -30, 15) +SketchCircle_2 = Sketch_1.addCircle(10, -25, 10) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) + +Union_1 = model.addUnion(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_1"), model.selection("COMPOUND", "Sketch_1")]) +assert(Union_1.feature().error() != "") +Part_1_doc.removeFeature(Union_1.feature()) + +model.end() diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 910a623e3..6e14b846e 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -41,6 +41,7 @@ email : webmaster.salome@opencascade.com @@ -74,6 +75,7 @@ email : webmaster.salome@opencascade.com @@ -90,6 +92,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index b176ddc18..c8bc95a8e 100755 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com @@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com @@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index e65b6b4af..0891b5589 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com @@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com @@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/multirotation_widget.xml b/src/FeaturesPlugin/multirotation_widget.xml index e0357b1f4..78cba48ea 100644 --- a/src/FeaturesPlugin/multirotation_widget.xml +++ b/src/FeaturesPlugin/multirotation_widget.xml @@ -15,7 +15,8 @@ label="Axis" tooltip="Select an edge for the axis of rotation" shape_types="edge" - default=""> + default="" + geometrical_selection="true"> diff --git a/src/FeaturesPlugin/multitranslation_widget.xml b/src/FeaturesPlugin/multitranslation_widget.xml index b6137c34e..4eed46173 100644 --- a/src/FeaturesPlugin/multitranslation_widget.xml +++ b/src/FeaturesPlugin/multitranslation_widget.xml @@ -34,7 +34,8 @@ email : webmaster.salome@opencascade.com + default="" + geometrical_selection="true"> + default="" + geometrical_selection="true"> + shape_types="face edge vertex" + geometrical_selection="true"> + shape_types="face edge vertex" + geometrical_selection="true"> diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index 3d71c3d84..3bc2c6683 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -41,6 +41,7 @@ email : webmaster.salome@opencascade.com @@ -74,6 +75,7 @@ email : webmaster.salome@opencascade.com @@ -90,6 +92,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml index 12f2f247f..297fc706f 100644 --- a/src/FeaturesPlugin/revolutioncut_widget.xml +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com @@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com @@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml index 6d1bb8394..5e358ee66 100644 --- a/src/FeaturesPlugin/revolutionfuse_widget.xml +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -43,6 +43,7 @@ email : webmaster.salome@opencascade.com @@ -76,6 +77,7 @@ email : webmaster.salome@opencascade.com @@ -91,6 +93,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/FeaturesPlugin/rotation_widget.xml b/src/FeaturesPlugin/rotation_widget.xml index c07bd8ba8..418998210 100755 --- a/src/FeaturesPlugin/rotation_widget.xml +++ b/src/FeaturesPlugin/rotation_widget.xml @@ -37,7 +37,8 @@ email : webmaster.salome@opencascade.com + default="" + geometrical_selection="true"> + default="" + geometrical_selection="true"> diff --git a/src/FeaturesPlugin/translation_widget.xml b/src/FeaturesPlugin/translation_widget.xml index 28bb25115..3e5ef8260 100644 --- a/src/FeaturesPlugin/translation_widget.xml +++ b/src/FeaturesPlugin/translation_widget.xml @@ -37,7 +37,8 @@ email : webmaster.salome@opencascade.com + default="" + geometrical_selection="true"> prepareNamingFaces(); // Insert to faces - int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theConeSegmentAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultConeSegment->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultConeSegment->generated((*it).second, (*it).first); } } diff --git a/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp b/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp index 55e2d1445..c7b4c5aeb 100644 --- a/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp +++ b/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp @@ -113,23 +113,26 @@ void GDMLPlugin_Ellipsoid::loadNamingDS(std::shared_ptr t // Insert to faces // Naming for faces and edges - int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theEllipsoidAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultEllipsoid->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it!=listOfFaces.end(); + ++it) + { + theResultEllipsoid->generated((*it).second, (*it).first); } // Naming vertices GeomAPI_DataMapOfShapeShape aVertices; - GeomAPI_ShapeExplorer aVertExp(theEllipsoidAlgo->shape(), GeomAPI_Shape::VERTEX); - for(int anIndex = 1; aVertExp.more(); aVertExp.next()) { + int anIndex = 1; + for (GeomAPI_ShapeExplorer aVertExp(theEllipsoidAlgo->shape(), GeomAPI_Shape::VERTEX); + aVertExp.more(); + aVertExp.next()) + { if (!aVertices.isBound(aVertExp.current())) { std::ostringstream aStream; aStream<<"Vertex_"<generated(aVertExp.current(), aStream.str(), num++); + theResultEllipsoid->generated(aVertExp.current(), aStream.str()); aVertices.bind(aVertExp.current(), aVertExp.current()); } } diff --git a/src/GeomAPI/GeomAPI_Edge.h b/src/GeomAPI/GeomAPI_Edge.h index a375b100e..e2851f71b 100644 --- a/src/GeomAPI/GeomAPI_Edge.h +++ b/src/GeomAPI/GeomAPI_Edge.h @@ -123,7 +123,7 @@ public: virtual std::shared_ptr middlePoint() const; }; -//! Pointer on attribute object +//! Pointer on object typedef std::shared_ptr GeomEdgePtr; #endif diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.cpp b/src/GeomAPI/GeomAPI_PlanarEdges.cpp index fa4686de7..dbc6e498a 100644 --- a/src/GeomAPI/GeomAPI_PlanarEdges.cpp +++ b/src/GeomAPI/GeomAPI_PlanarEdges.cpp @@ -122,6 +122,8 @@ bool GeomAPI_PlanarEdges::isEqual(const std::shared_ptr theShape) return false; TopoDS_Shape& aMyShape = const_cast(impl()); TopoDS_Shape aTheShape = theShape->impl(); + if (aMyShape.ShapeType() != aTheShape.ShapeType()) // to don't confuse by the face of same edges + return false; TopExp_Explorer aMyExp(aMyShape, TopAbs_EDGE); TopExp_Explorer aTheExp(aTheShape, TopAbs_EDGE); for (; aMyExp.More() && aTheExp.More(); aMyExp.Next(), aTheExp.Next()) { diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.h b/src/GeomAPI/GeomAPI_PlanarEdges.h index ef1cea8be..0fc2a9f0a 100644 --- a/src/GeomAPI/GeomAPI_PlanarEdges.h +++ b/src/GeomAPI/GeomAPI_PlanarEdges.h @@ -35,7 +35,7 @@ * \ingroup DataModel * \brief Interface to the set of edges located in one plane * - * Normally this interface corresponds to theedges of the sketch + * Normally this interface corresponds to the edges of the sketch */ class GeomAPI_PlanarEdges : public GeomAPI_Shape { diff --git a/src/GeomAPI/GeomAPI_Pln.cpp b/src/GeomAPI/GeomAPI_Pln.cpp index 60e417c7c..9ccd1a950 100644 --- a/src/GeomAPI/GeomAPI_Pln.cpp +++ b/src/GeomAPI/GeomAPI_Pln.cpp @@ -120,6 +120,13 @@ double GeomAPI_Pln::distance(const std::shared_ptr thePlane) const return aMyPln.Distance(anOtherPln); } +double GeomAPI_Pln::distance(const std::shared_ptr thePoint) const +{ + const gp_Pln& aMyPln = impl(); + const gp_Pnt& aPnt = thePoint->impl(); + return aMyPln.Distance(aPnt); +} + void GeomAPI_Pln::translate(const std::shared_ptr theDir, double theDist) { gp_Vec aVec(theDir->impl()); diff --git a/src/GeomAPI/GeomAPI_Pln.h b/src/GeomAPI/GeomAPI_Pln.h index 863a72f61..af1d1fe7c 100644 --- a/src/GeomAPI/GeomAPI_Pln.h +++ b/src/GeomAPI/GeomAPI_Pln.h @@ -82,6 +82,10 @@ class GeomAPI_Pln : public GeomAPI_Interface GEOMAPI_EXPORT double distance(const std::shared_ptr thePlane) const; + /// \return distance from a point to this plane. + GEOMAPI_EXPORT + double distance(const std::shared_ptr thePoint) const; + /// Translates the plane along direction theDir on distance theDist GEOMAPI_EXPORT void translate(const std::shared_ptr theDir, const double theDist); diff --git a/src/GeomAPI/GeomAPI_Tools.cpp b/src/GeomAPI/GeomAPI_Tools.cpp index 082595768..c15700df1 100644 --- a/src/GeomAPI/GeomAPI_Tools.cpp +++ b/src/GeomAPI/GeomAPI_Tools.cpp @@ -28,6 +28,9 @@ //================================================================================================== GeomShapePtr GeomAPI_Tools::getTypedShape(const GeomShapePtr& theShape) { + if (!theShape.get()) + return GeomShapePtr(); + GeomShapePtr aTypedShape = theShape; GeomAPI_Shape::ShapeType aType = theShape->shapeType(); diff --git a/src/GeomAPI/GeomAPI_XYZ.h b/src/GeomAPI/GeomAPI_XYZ.h index 020d819c1..bcedbf74d 100644 --- a/src/GeomAPI/GeomAPI_XYZ.h +++ b/src/GeomAPI/GeomAPI_XYZ.h @@ -81,5 +81,8 @@ class GeomAPI_XYZ : public GeomAPI_Interface GEOMAPI_EXPORT double squareModulus() const; }; +//! Pointer on object +typedef std::shared_ptr GeomXYZPtr; + #endif diff --git a/src/GeomAPI/Test/Test2675.py b/src/GeomAPI/Test/Test2675.py index d1c6fae9c..2af1a04a9 100644 --- a/src/GeomAPI/Test/Test2675.py +++ b/src/GeomAPI/Test/Test2675.py @@ -77,8 +77,8 @@ SketchConstraintDistance_3 = Sketch_1.setDistance(SketchCircle_2.center(), Sketc SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchCircle_1.results()[1]) SketchConstraintDistance_4 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.endPoint(), 325) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchLine_7r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_1")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_2_2f-SketchLine_7r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7")]) from GeomAPI import * diff --git a/src/GeomAPI/Test/TestBox.py b/src/GeomAPI/Test/TestBox.py index a8412a4cd..32948b25a 100644 --- a/src/GeomAPI/Test/TestBox.py +++ b/src/GeomAPI/Test/TestBox.py @@ -91,7 +91,7 @@ ParamHeight = model.addParameter(Part_1_doc, "Height", "25") ParamAngle = model.addParameter(Part_1_doc, "Angle", "30") Box_1 = model.addBox(Part_1_doc, "BoxSize", "BoxSize", "BoxSize") Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) -SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top"), False) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchLine_1 = Sketch_1.addLine(30, 10, 10, 10) SketchLine_2 = Sketch_1.addLine(10, 10, 10, 20) @@ -109,7 +109,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "Width") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), "Depth") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), "Height", 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), "Height", 0) model.do() # Test 1. Check boxes @@ -119,13 +119,13 @@ aCornerPara = GeomAPI.GeomAPI_Pnt(ParamSize.value(), ParamSize.value(), ParamSiz checkBox(Extrusion_1, aCornerPara, ParamWidth.value(), ParamDepth.value(), ParamHeight.value()) # Test 2. Rotate box to keep it still axes-aligned -Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1"), 90) +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]"), 90) aCornerPara.setX(aCornerPara.x() + ParamWidth.value() - ParamDepth.value()) aCornerPara.setY(aCornerPara.y() - ParamWidth.value()) checkBox(Rotation_1, aCornerPara, ParamDepth.value(), ParamWidth.value(), ParamHeight.value()) # Test 3. Rotate boxes -Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom"), model.selection("VERTEX", "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]"), model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]")) Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Axis_1"), "Angle") Rotation_3 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Rotation_1_1")], model.selection("EDGE", "Axis_1"), "Angle") @@ -155,11 +155,11 @@ aCornerPara1 = GeomAPI.GeomAPI_Pnt(aCornerPara1.x() * (aCosAngle + (1 - aCosAngl checkRotatedBox(Rotation_3, aCornerPara, aCornerPara1) # Test 4. Compose a non-closed shell of the box faces and check it is not a box -Shell_objects = ["Rotation_3_1/Rotated_Face_1", "Rotation_3_1/Rotated_Face_2", "Rotation_3_1/Rotated_Face_3", "Rotation_3_1/Rotated_Face_4"] +Shell_objects = ["Rotation_3_1/MF:Rotated&Extrusion_1_1/To_Face", "Rotation_3_1/MF:Rotated&Extrusion_1_1/From_Face", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_1", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_2"] checkShellNotBox(Part_1_doc, Shell_objects) # Test 5. Compose a shell of all box faces -Shell_objects = ["Rotation_3_1/Rotated_Face_1", "Rotation_3_1/Rotated_Face_2", "Rotation_3_1/Rotated_Face_3", "Rotation_3_1/Rotated_Face_4", "Rotation_3_1/Rotated_Face_5", "Rotation_3_1/Rotated_Face_6"] +Shell_objects = ["Rotation_3_1/MF:Rotated&Extrusion_1_1/To_Face", "Rotation_3_1/MF:Rotated&Extrusion_1_1/From_Face", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_1", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_2", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_3", "Rotation_3_1/MF:Rotated&Sketch_1/SketchLine_4"] checkShellRotatedBox(Part_1_doc, Shell_objects, aCornerPara, aCornerPara1) model.end() diff --git a/src/GeomAPI/Test/TestCone.py b/src/GeomAPI/Test/TestCone.py index 2c74a1955..7c92fb34d 100644 --- a/src/GeomAPI/Test/TestCone.py +++ b/src/GeomAPI/Test/TestCone.py @@ -153,10 +153,10 @@ anApex = GeomAPI.GeomAPI_Pnt(0, 0, ParamR1.value() / math.tan(aSemiAngle)) anAxis = GeomAPI.GeomAPI_Dir(0, 0, 1) checkConeAll(Part_1_doc, Cone_1, "Cone_1_1/Face_1", anApex, anAxis, aSemiAngle, ParamR2.value(), ParamR1.value(), ParamH.value()) checkCircleFace(Part_1_doc, "Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) -checkCircleEdge(Part_1_doc, "Cone_1_1/Face_1&Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) +checkCircleEdge(Part_1_doc, "[Cone_1_1/Face_1][Cone_1_1/Face_2]", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) checkCircleFace(Part_1_doc, "Cone_1_1/Face_3", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) -checkCircleEdge(Part_1_doc, "Cone_1_1/Face_1&Cone_1_1/Face_3", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) -checkSegment(Part_1_doc, "Cone_1_1/Face_1", GeomAPI.GeomAPI_Pnt(ParamR1.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) +checkCircleEdge(Part_1_doc, "[Cone_1_1/Face_1][Cone_1_1/Face_3]", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) +checkSegment(Part_1_doc, "[Cone_1_1/Face_1][weak_name_3]", GeomAPI.GeomAPI_Pnt(ParamR1.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) # Test 2. Update cone radii ParamR1.setValue(0) @@ -165,8 +165,8 @@ aSemiAngle = semiAngle(ParamR1.value(), ParamR2.value(), ParamH.value()) anApex.setZ(0) checkConeAll(Part_1_doc, Cone_1, "Cone_1_1/Face_1", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) checkCircleFace(Part_1_doc, "Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) -checkCircleEdge(Part_1_doc, "Cone_1_1/Face_1&Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) -checkSegment(Part_1_doc, "Cone_1_1/Face_1", GeomAPI.GeomAPI_Pnt(0, 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) +checkCircleEdge(Part_1_doc, "[Cone_1_1/Face_1][Cone_1_1/Face_2]", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) +checkSegment(Part_1_doc, "[Cone_1_1/Face_1][weak_name_3]", GeomAPI.GeomAPI_Pnt(0, 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) checkVertex(Part_1_doc, "Cone_1_1/Vertex_2", GeomAPI.GeomAPI_Pnt(0, 0, 0)) ParamR2.setValue(50) @@ -176,20 +176,20 @@ aSemiAngle = semiAngle(ParamR1.value(), ParamR2.value(), ParamH.value()) anApex.setZ(-ParamR1.value() / math.tan(aSemiAngle)) checkConeAll(Part_1_doc, Cone_1, "Cone_1_1/Face_1", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) checkCircleFace(Part_1_doc, "Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) -checkCircleEdge(Part_1_doc, "Cone_1_1/Face_1&Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) +checkCircleEdge(Part_1_doc, "[Cone_1_1/Face_1][Cone_1_1/Face_2]", GeomAPI.GeomAPI_Pnt(0, 0, ParamH.value()), ParamR2.value()) checkCircleFace(Part_1_doc, "Cone_1_1/Face_3", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) -checkCircleEdge(Part_1_doc, "Cone_1_1/Face_1&Cone_1_1/Face_3", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) -checkSegment(Part_1_doc, "Cone_1_1/Face_1", GeomAPI.GeomAPI_Pnt(ParamR1.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) +checkCircleEdge(Part_1_doc, "[Cone_1_1/Face_1][Cone_1_1/Face_3]", GeomAPI.GeomAPI_Pnt(0, 0, 0), ParamR1.value()) +checkSegment(Part_1_doc, "[Cone_1_1/Face_1][weak_name_3]", GeomAPI.GeomAPI_Pnt(ParamR1.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value(), 0, ParamH.value())) # Test 3. Translate cone Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Cone_1_1")], model.selection("EDGE", "PartSet/OX"), "Shift") anApex.setX(anApex.x() + ParamShift.value()) -checkConeAll(Part_1_doc, Translation_1, "Translation_1_1/Translated_Face_3", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) -checkCircleFace(Part_1_doc, "Translation_1_1/Translated_Face_2", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, ParamH.value()), ParamR2.value()) -checkCircleEdge(Part_1_doc, "Translation_1_1/Translated_Face_3&Translation_1_1/Translated_Face_2", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, ParamH.value()), ParamR2.value()) -checkCircleFace(Part_1_doc, "Translation_1_1/Translated_Face_1", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, 0), ParamR1.value()) -checkCircleEdge(Part_1_doc, "Translation_1_1/Translated_Face_3&Translation_1_1/Translated_Face_1", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, 0), ParamR1.value()) -checkSegment(Part_1_doc, "Translation_1_1/Translated_Face_3", GeomAPI.GeomAPI_Pnt(ParamR1.value() + ParamShift.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value() + ParamShift.value(), 0, ParamH.value())) +checkConeAll(Part_1_doc, Translation_1, "Translation_1_1/MF:Translated&Cone_1_1/Face_1", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) +checkCircleFace(Part_1_doc, "Translation_1_1/MF:Translated&Cone_1_1/Face_2", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, ParamH.value()), ParamR2.value()) +checkCircleEdge(Part_1_doc, "[Translation_1_1/MF:Translated&Cone_1_1/Face_1][Translation_1_1/MF:Translated&Cone_1_1/Face_2]", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, ParamH.value()), ParamR2.value()) +checkCircleFace(Part_1_doc, "Translation_1_1/MF:Translated&Cone_1_1/Face_3", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, 0), ParamR1.value()) +checkCircleEdge(Part_1_doc, "[Translation_1_1/MF:Translated&Cone_1_1/Face_1][Translation_1_1/MF:Translated&Cone_1_1/Face_3]", GeomAPI.GeomAPI_Pnt(ParamShift.value(), 0, 0), ParamR1.value()) +checkSegment(Part_1_doc, "[Translation_1_1/MF:Translated&Cone_1_1/Face_1][weak_name_3]", GeomAPI.GeomAPI_Pnt(ParamR1.value() + ParamShift.value(), 0, 0), GeomAPI.GeomAPI_Pnt(ParamR2.value() + ParamShift.value(), 0, ParamH.value())) # Test 4. Rotate cone Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OY"), "Angle") @@ -198,24 +198,24 @@ anAxis = GeomAPI.GeomAPI_Dir(math.sin(anAngle), 0, math.cos(anAngle)) x, z = anApex.x(), anApex.z() anApex.setX(x * math.cos(anAngle) + z * math.sin(anAngle)) anApex.setZ(-x * math.sin(anAngle) + z * math.cos(anAngle)) -checkConeAll(Part_1_doc, Rotation_1, "Rotation_1_1/Rotated_Face_3", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) +checkConeAll(Part_1_doc, Rotation_1, "Rotation_1_1/MF:Rotated&Cone_1_1/Face_1", anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) aCenter = GeomAPI.GeomAPI_Pnt(ParamShift.value() * math.cos(anAngle) + ParamH.value() * math.sin(anAngle), 0, -ParamShift.value() * math.sin(anAngle) + ParamH.value() * math.cos(anAngle)) -checkCircleFace(Part_1_doc, "Rotation_1_1/Rotated_Face_2", aCenter, ParamR2.value()) -checkCircleEdge(Part_1_doc, "Rotation_1_1/Rotated_Face_3&Rotation_1_1/Rotated_Face_2", aCenter, ParamR2.value()) +checkCircleFace(Part_1_doc, "Rotation_1_1/MF:Rotated&Cone_1_1/Face_2", aCenter, ParamR2.value()) +checkCircleEdge(Part_1_doc, "[Rotation_1_1/MF:Rotated&Cone_1_1/Face_1][Rotation_1_1/MF:Rotated&Cone_1_1/Face_2]", aCenter, ParamR2.value()) aCenter = GeomAPI.GeomAPI_Pnt(ParamShift.value() * math.cos(anAngle), 0, -ParamShift.value() * math.sin(anAngle)) -checkCircleFace(Part_1_doc, "Rotation_1_1/Rotated_Face_1", aCenter, ParamR1.value()) -checkCircleEdge(Part_1_doc, "Rotation_1_1/Rotated_Face_3&Rotation_1_1/Rotated_Face_1", aCenter, ParamR1.value()) +checkCircleFace(Part_1_doc, "Rotation_1_1/MF:Rotated&Cone_1_1/Face_3", aCenter, ParamR1.value()) +checkCircleEdge(Part_1_doc, "[Rotation_1_1/MF:Rotated&Cone_1_1/Face_1][Rotation_1_1/MF:Rotated&Cone_1_1/Face_3]", aCenter, ParamR1.value()) # Test 5. Split cone by plane and check conical shell and elliptic face Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 20, False) Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Rotation_1_1"), model.selection("FACE", "Plane_1")]) -checkConeShell(Part_1_doc, ["Partition_1_1_1/Modified_Face_2_2", "Partition_1_1_2/Modified_Face_2_2"], anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) +checkConeShell(Part_1_doc, ["Partition_1_1_1/Modified_Face&Cone_1_1/Face_1", "Partition_1_1_2/Modified_Face&Cone_1_1/Face_1"], anApex, anAxis, aSemiAngle, ParamR1.value(), ParamR2.value(), ParamH.value()) aFirstFocus = GeomAPI.GeomAPI_Pnt(20, 0, 31.062397266842858) aSecondFocus = GeomAPI.GeomAPI_Pnt(20, 0, -1.0935246846933797) aMajorRadius = 27.91915871311068 aMinorRadius = 22.824955511666207 -checkEllipseFace(Part_1_doc, "Partition_1_1_2/Modified_Face_2_1", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius) -checkEllipseEdge(Part_1_doc, "Partition_1_1_1/Modified_Face_1_divided_1_e_1", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius) +checkEllipseFace(Part_1_doc, "_weak_name_1_Partition_1_1_2", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius) +checkEllipseEdge(Part_1_doc, "Partition_1_1_1/Generated_Edge&Cone_1_1/Face_1", aFirstFocus, aSecondFocus, aMajorRadius, aMinorRadius) model.end() diff --git a/src/GeomAPI/Test/TestCylinder.py b/src/GeomAPI/Test/TestCylinder.py index 726b837fa..c423f72e1 100644 --- a/src/GeomAPI/Test/TestCylinder.py +++ b/src/GeomAPI/Test/TestCylinder.py @@ -76,7 +76,7 @@ ParamR = model.addParameter(Part_1_doc, "R", "10") ParamAngle = model.addParameter(Part_1_doc, "Angle", "30") Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "2*R", "H") Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_2")) -SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2__cc"), False) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]__cc"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchCircle_1 = Sketch_1.addCircle(0, 0, 10) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) @@ -98,14 +98,14 @@ SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_3.result()) SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_1.result(), "R/2") SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_2.result(), "H") -SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]"), False) [SketchPoint_2, SketchPoint_3] = SketchIntersectionPoint_1.intersectionPoints() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_1.result()) SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) SketchLine_5 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_2.endPoint(), SketchLine_5.result()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection("EDGE", "PartSet/OZ"), 270, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 270, 0) model.do() # Test 1. Check cylinders @@ -114,10 +114,10 @@ aLoc2 = GeomAPI.GeomAPI_Pnt(0, 0, 2 * ParamH.value()) aLoc3 = GeomAPI.GeomAPI_Pnt(0, 0, 3 * ParamH.value()) anAxis = GeomAPI.GeomAPI_Dir(0, 0, 1) checkCylinderAll(Part_1_doc, Cylinder_1, "Cylinder_1_1/Face_1", aLoc1, anAxis, 2 * ParamR.value(), ParamH.value()) -checkCylinderAll(Part_1_doc, Extrusion_1, "Extrusion_1_1/Generated_Face_1", aLoc2, anAxis, ParamR.value(), ParamH.value()) +checkCylinderAll(Part_1_doc, Extrusion_1, "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2", aLoc2, anAxis, ParamR.value(), ParamH.value()) checkNonCylinder(Revolution_1) -checkCylinderShell(Part_1_doc, ["Revolution_1_1/Generated_Face_4"], aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) -checkCylinderFace(Part_1_doc, "Revolution_1_1/Generated_Face_4", aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) +checkCylinderShell(Part_1_doc, ["Revolution_1_1/Generated_Face&Sketch_2/SketchLine_4"], aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) +checkCylinderFace(Part_1_doc, "Revolution_1_1/Generated_Face&Sketch_2/SketchLine_4", aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) # Test 2. Rotate cylinders Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), "Angle") @@ -131,11 +131,11 @@ anAxis = GeomAPI.GeomAPI_Dir(0, anAxis.y() * aCosAngle - anAxis.z() * aSinAngle, aLoc1 = GeomAPI.GeomAPI_Pnt(0, aLoc1.y() * aCosAngle - aLoc1.z() * aSinAngle, aLoc1.y() * aSinAngle + aLoc1.z() * aCosAngle) aLoc2 = GeomAPI.GeomAPI_Pnt(0, aLoc2.y() * aCosAngle - aLoc2.z() * aSinAngle, aLoc2.y() * aSinAngle + aLoc2.z() * aCosAngle) aLoc3 = GeomAPI.GeomAPI_Pnt(0, aLoc3.y() * aCosAngle - aLoc3.z() * aSinAngle, aLoc3.y() * aSinAngle + aLoc3.z() * aCosAngle) -checkCylinderAll(Part_1_doc, Rotation_1, "Rotation_1_1/Rotated_Face_3", aLoc1, anAxis, 2 * ParamR.value(), ParamH.value()) -checkCylinderAll(Part_1_doc, Rotation_2, "Rotation_2_1/Rotated_Face_3", aLoc2, anAxis, ParamR.value(), ParamH.value()) +checkCylinderAll(Part_1_doc, Rotation_1, "Rotation_1_1/MF:Rotated&Cylinder_1_1/Face_1", aLoc1, anAxis, 2 * ParamR.value(), ParamH.value()) +checkCylinderAll(Part_1_doc, Rotation_2, "Rotation_2_1/MF:Rotated&Sketch_1/SketchCircle_1_2", aLoc2, anAxis, ParamR.value(), ParamH.value()) checkNonCylinder(Rotation_3) -checkCylinderShell(Part_1_doc, ["Rotation_3_1/Rotated_Face_5"], aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) -checkCylinderFace(Part_1_doc, "Rotation_3_1/Rotated_Face_5", aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) +checkCylinderShell(Part_1_doc, ["Rotation_3_1/MF:Rotated&Sketch_2/SketchLine_4"], aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) +checkCylinderFace(Part_1_doc, "Rotation_3_1/MF:Rotated&Sketch_2/SketchLine_4", aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) # Test 3. Split cylinder and compose a shell Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "2.2*H", False) @@ -143,7 +143,9 @@ Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), "H" Partition_1_objects = [model.selection("SOLID", "Rotation_3_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Shell_1_objects = ["Partition_1_1_1/Modified_Face_3_5", "Partition_1_1_4/Modified_Face_3_3", "Partition_1_1_2/Modified_Face_1_divided_2_1"] +Shell_1_objects = ["Partition_1_1_1/Modified_Face&Sketch_2/SketchLine_4", + "Partition_1_1_4/Modified_Face&Sketch_2/SketchLine_4", + "(Partition_1_1_2/Modified_Face&Revolution_1_1/To_Face)(Partition_1_1_2/Modified_Face&Sketch_2/SketchLine_1)"] checkCylinderShell(Part_1_doc, Shell_1_objects, aLoc3, anAxis, 0.5 * ParamR.value(), ParamH.value()) model.end() diff --git a/src/GeomAPI/Test/TestPolygon.py b/src/GeomAPI/Test/TestPolygon.py index c05c38864..7f6600626 100644 --- a/src/GeomAPI/Test/TestPolygon.py +++ b/src/GeomAPI/Test/TestPolygon.py @@ -88,15 +88,15 @@ model.do() # Test 1. Check face/wire of box is a rectangle checkRectangleFace(Part_1_doc, "Box_1_1/Top") -Wire_edges = ["Box_1_1/Left&Box_1_1/Top", "Box_1_1/Front&Box_1_1/Top", "Box_1_1/Right&Box_1_1/Top", "Box_1_1/Back&Box_1_1/Top"] +Wire_edges = ["[Box_1_1/Left][Box_1_1/Top]", "[Box_1_1/Front][Box_1_1/Top]", "[Box_1_1/Right][Box_1_1/Top]", "[Box_1_1/Back][Box_1_1/Top]"] checkRectangleWire(Part_1_doc, Wire_edges) # Test 2. Build a polygon from edges -Wire_edges = ["Box_1_1/Left&Box_1_1/Bottom", "Box_1_1/Front&Box_1_1/Left", "Box_1_1/Left&Box_1_1/Top", "Box_1_1/Back&Box_1_1/Top", "Box_1_1/Right&Box_1_1/Top"] +Wire_edges = ["[Box_1_1/Left][Box_1_1/Bottom]", "[Box_1_1/Front][Box_1_1/Left]", "[Box_1_1/Left][Box_1_1/Top]", "[Box_1_1/Back][Box_1_1/Top]", "[Box_1_1/Right][Box_1_1/Top]"] checkPolygonWire(Part_1_doc, Wire_edges) # Test 3. Build a polygon from vertices -Poly_vertices = ["Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom", "Box_1_1/Front&Box_1_1/Left&Box_1_1/Bottom", "Box_1_1/Front&Box_1_1/Right&Box_1_1/Bottom", "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top", "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top", "Box_1_1/Back&Box_1_1/Right&Box_1_1/Top"] +Poly_vertices = ["[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"] checkPolyline(Part_1_doc, Poly_vertices) model.end() diff --git a/src/GeomAPI/Test/TestSphere.py b/src/GeomAPI/Test/TestSphere.py index 961ed55e1..1990fbc20 100644 --- a/src/GeomAPI/Test/TestSphere.py +++ b/src/GeomAPI/Test/TestSphere.py @@ -68,7 +68,9 @@ def checkSphereAll(theDocument, theFeature, theFaceName, theCenter, theRadius): checkSphereShell(theDocument, theFaceName, theCenter, theRadius) checkSphereFace(theDocument, theFaceName, theCenter, theRadius) - checkArc(theDocument, theFaceName, theCenter, theRadius) + + anArcName = "[" + theFaceName + "][weak_name_3]" + checkArc(theDocument, anArcName, theCenter, theRadius) model.begin() @@ -93,32 +95,32 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "R") model.do() # Test 1. Compose sphere -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_1f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), "Aperture", 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_1f")], model.selection("EDGE", "Sketch_1/SketchLine_1"), "Aperture", 0) aCenter = GeomAPI.GeomAPI_Pnt(0, 0, 0) -checkSphereAll(Part_1_doc, Revolution_1, "Revolution_1_1/Generated_Face_2", aCenter, ParamR.value()) +checkSphereAll(Part_1_doc, Revolution_1, "Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) # Test 2. Translate sphere Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], model.selection("EDGE", "PartSet/OX"), "Shift") aCenter.setX(aCenter.x() + ParamShift.value()) -checkSphereAll(Part_1_doc, Translation_1, "Translation_1_1/Translated_Face_1", aCenter, ParamR.value()) +checkSphereAll(Part_1_doc, Translation_1, "Translation_1_1/MF:Translated&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) # Test 3. Rotate sphere Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("EDGE", "PartSet/OY"), "Angle") anAngle = ParamAngle.value() * math.pi / 180.0 aCenter.setX(ParamShift.value() * math.cos(anAngle)) aCenter.setZ(-ParamShift.value() * math.sin(anAngle)) -checkSphereAll(Part_1_doc, Rotation_1, "Rotation_1_1/Rotated_Face_1", aCenter, ParamR.value()) +checkSphereAll(Part_1_doc, Rotation_1, "Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) # Test 4. Check result by changing parameters ParamR.setValue(100) model.do() -checkSphereAll(Part_1_doc, Rotation_1, "Rotation_1_1/Rotated_Face_1", aCenter, ParamR.value()) +checkSphereAll(Part_1_doc, Rotation_1, "Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) ParamAperture.setValue(270) model.do() -checkSphereFace(Part_1_doc, "Rotation_1_1/Rotated_Face_3", aCenter, ParamR.value()) -checkSphereShell(Part_1_doc, "Rotation_1_1/Rotated_Face_3", aCenter, ParamR.value()) -checkArc(Part_1_doc, "Rotation_1_1/Rotated_Face_3&Rotation_1_1/Rotated_Face_1", aCenter, ParamR.value()) -checkArc(Part_1_doc, "Rotation_1_1/Rotated_Face_3&Rotation_1_1/Rotated_Face_2", aCenter, ParamR.value()) +checkSphereFace(Part_1_doc, "Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) +checkSphereShell(Part_1_doc, "Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2", aCenter, ParamR.value()) +checkArc(Part_1_doc, "[Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2][Rotation_1_1/MF:Rotated&Revolution_1_1/From_Face]", aCenter, ParamR.value()) +checkArc(Part_1_doc, "[Rotation_1_1/MF:Rotated&Sketch_1/SketchArc_1_2][Rotation_1_1/MF:Rotated&Revolution_1_1/To_Face]", aCenter, ParamR.value()) model.end() diff --git a/src/GeomAPI/Test/TestTorus.py b/src/GeomAPI/Test/TestTorus.py index 25c7f3edc..a710df35b 100644 --- a/src/GeomAPI/Test/TestTorus.py +++ b/src/GeomAPI/Test/TestTorus.py @@ -84,12 +84,15 @@ aCosAngle = math.cos(anAngle) aSinAngle = math.sin(anAngle) aCenter = GeomAPI.GeomAPI_Pnt(0, aCenter.y() * aCosAngle - aCenter.z() * aSinAngle, aCenter.y() * aSinAngle + aCenter.z() * aCosAngle) anAxis = GeomAPI.GeomAPI_Dir(0, anAxis.y() * aCosAngle - anAxis.z() * aSinAngle, anAxis.y() * aSinAngle + anAxis.z() * aCosAngle) -checkTorusAll(Part_1_doc, Rotation_1, "Rotation_1_1/Rotated_Face_1", aCenter, anAxis, ParamRMax.value(), ParamRMin.value()) +checkTorusAll(Part_1_doc, Rotation_1, "Rotation_1_1/MF:Rotated&Torus_1_1/Face_1", aCenter, anAxis, ParamRMax.value(), ParamRMin.value()) # Test 3. Split torus and compose a shell Partition_1_objects = [model.selection("SOLID", "Rotation_1_1"), model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ"), model.selection("FACE", "PartSet/XOY")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) -Shell_1_objects = ["Partition_1_1_6/Modified_Face_4_4", "Partition_1_1_7/Modified_Face_4_3", "Partition_1_1_7/Modified_Face_1_divided_2_1", "Partition_1_1_5/Modified_Face_4_4"] +Shell_1_objects = ["Partition_1_1_6/Modified_Face&Torus_1_1/Face_1", + "Partition_1_1_7/Modified_Face&Torus_1_1/Face_1&weak_name_2", + "Partition_1_1_7/Modified_Face&Torus_1_1/Face_1&weak_name_1", + "Partition_1_1_5/Modified_Face&Torus_1_1/Face_1"] checkTorusShell(Part_1_doc, Shell_1_objects, aCenter, anAxis, ParamRMax.value(), ParamRMin.value()) model.end() diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp index 5793dbf0b..49b7fe423 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp @@ -27,10 +27,15 @@ //================================================================================================== GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects) + : myFiller(0) { build(theObjects); } +GeomAlgoAPI_Intersection::~GeomAlgoAPI_Intersection() { + if (myFiller) + delete (BOPAlgo_PaveFiller*)myFiller; +} //================================================================================================== void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) { @@ -53,21 +58,22 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) } } - BOPAlgo_PaveFiller aDSFiller; - aDSFiller.SetArguments(anObjects); + BOPAlgo_PaveFiller* aDSFiller = new BOPAlgo_PaveFiller; + myFiller = aDSFiller; + aDSFiller->SetArguments(anObjects); - aDSFiller.SetRunParallel(false); - aDSFiller.SetNonDestructive(false); - aDSFiller.SetGlue(BOPAlgo_GlueOff); + aDSFiller->SetRunParallel(false); + aDSFiller->SetNonDestructive(false); + aDSFiller->SetGlue(BOPAlgo_GlueOff); // optimization for the issue #2399 BOPAlgo_SectionAttribute theSecAttr(Standard_True, Standard_True, Standard_True); - aDSFiller.SetSectionAttribute(theSecAttr); + aDSFiller->SetSectionAttribute(theSecAttr); - aDSFiller.Perform(); - if (aDSFiller.HasErrors()) { + aDSFiller->Perform(); + if (aDSFiller->HasErrors()) { return; } @@ -75,7 +81,7 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) anOperation->SetRunParallel(false); anOperation->SetCheckInverted(true); - anOperation->PerformWithFiller(aDSFiller); + anOperation->PerformWithFiller(*aDSFiller); // it references a filler fields, so keep the filler if(anOperation->HasErrors()) { return; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h index 2ea3e0c14..bd0511769 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h @@ -31,15 +31,20 @@ /// \brief Performs the intersection operations. class GeomAlgoAPI_Intersection : public GeomAlgoAPI_MakeShape { + void* myFiller; ///< store filler to avoid memory leaks public: /// \brief Constructor. /// \param[in] theObjects list of objects. /// \param[in] theTools list of tools. GEOMALGOAPI_EXPORT GeomAlgoAPI_Intersection(const ListOfShape& theObjects); + /// Destructor to erase the filler + GEOMALGOAPI_EXPORT virtual ~GeomAlgoAPI_Intersection(); + private: /// Builds resulting shape. void build(const ListOfShape& theObjects); + }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp index 6ed3adf8e..ded490e1f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp @@ -21,6 +21,7 @@ #include "GeomAlgoAPI_MakeShape.h" #include +#include #include #include #include @@ -31,7 +32,9 @@ #include #include #include +#include #include +#include // new shape -> old shapes -> index in the old shape typedef NCollection_DataMap > HistoryMap; -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() : myBuilderType(Unknown), myDone(false) @@ -49,32 +52,34 @@ GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() myHist = 0; } -GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() { +//================================================================================================== +GeomAlgoAPI_MakeShape::~GeomAlgoAPI_MakeShape() +{ if (myHist) { delete (HistoryMap*)myHist; } } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::isDone() const { return myDone; } -//================================================================================================= -const std::shared_ptr GeomAlgoAPI_MakeShape::shape() const +//================================================================================================== +const GeomShapePtr GeomAlgoAPI_MakeShape::shape() const { return myShape; } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::isValid() const { BRepCheck_Analyzer aChecker(myShape->impl()); return (aChecker.IsValid() == Standard_True); } -//================================================================================================= +//================================================================================================== bool GeomAlgoAPI_MakeShape::hasVolume() const { bool hasVolume = false; @@ -88,88 +93,86 @@ bool GeomAlgoAPI_MakeShape::hasVolume() const return hasVolume; } -//================================================================================================= +//================================================================================================== std::shared_ptr GeomAlgoAPI_MakeShape::mapOfSubShapes() const { return myMap; } -//================================================================================================= -void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShape::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { TopTools_ListOfShape aList; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); - aList = aMakeShape->Generated(theShape->impl()); + aList = aMakeShape->Generated(theOldShape->impl()); } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - aList = aBOPBuilder->Generated(theShape->impl()); + aList = aBOPBuilder->Generated(theOldShape->impl()); } for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) { - if(anIt.Value().IsNull()) { - continue; - } - std::shared_ptr aShape(new GeomAPI_Shape()); + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } -//================================================================================================= -void GeomAlgoAPI_MakeShape::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShape::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { TopTools_ListOfShape aList; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); try { - aList = aMakeShape->Modified(theShape->impl()); + aList = aMakeShape->Modified(theOldShape->impl()); } catch(Standard_NoSuchObject) { } } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - aList = aBOPBuilder->Modified(theShape->impl()); + aList = aBOPBuilder->Modified(theOldShape->impl()); } for(TopTools_ListIteratorOfListOfShape anIt(aList); anIt.More(); anIt.Next()) { - if(anIt.Value().IsNull()) { - continue; - } - std::shared_ptr aShape(new GeomAPI_Shape()); + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } -//================================================================================================= -bool GeomAlgoAPI_MakeShape::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isDeleted(const GeomShapePtr theOldShape) { bool isDeleted = false; if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) { BRepBuilderAPI_MakeShape* aMakeShape = implPtr(); - isDeleted = aMakeShape->IsDeleted(theShape->impl()) == Standard_True; + isDeleted = aMakeShape->IsDeleted(theOldShape->impl()) == Standard_True; } else if(myBuilderType == OCCT_BOPAlgo_Builder) { BOPAlgo_Builder* aBOPBuilder = implPtr(); - isDeleted = aBOPBuilder->IsDeleted(theShape->impl()) == Standard_True; + isDeleted = aBOPBuilder->IsDeleted(theOldShape->impl()) == Standard_True; } return isDeleted; } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::setBuilderType(const BuilderType theBuilderType) { myBuilderType = theBuilderType; } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::setDone(const bool theFlag) { myDone = theFlag; } -//================================================================================================= -void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theShape) +//================================================================================================== +void GeomAlgoAPI_MakeShape::setShape(const GeomShapePtr theShape) { if(myShape.get() && myShape->isEqual(theShape)) { return; @@ -187,17 +190,17 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theSha const TopoDS_Shape& aTopoDSShape = myShape->impl(); for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } @@ -208,8 +211,30 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theSha } } -//================================================================================================= -void GeomAlgoAPI_MakeShape::initialize() { +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isValidForHistory(const GeomShapePtr theShape) +{ + if (!theShape.get()) return false; + + const TopoDS_Shape& aShape_ = theShape->impl(); + if (aShape_.IsNull()) return false; + + if (aShape_.ShapeType() == TopAbs_EDGE) { + TopoDS_Edge anEdge_ = TopoDS::Edge(aShape_); + if (BRep_Tool::Degenerated(anEdge_)) return false; + } + + return true; +} + +//================================================================================================== +void GeomAlgoAPI_MakeShape::fixOrientation(GeomShapePtr& theShape) { + if (myMap->isBound(theShape)) theShape = myMap->find(theShape); +} + +//================================================================================================== +void GeomAlgoAPI_MakeShape::initialize() +{ switch (myBuilderType) { case OCCT_BRepBuilderAPI_MakeShape: { myDone = implPtr()->IsDone() == Standard_True; @@ -233,7 +258,7 @@ void GeomAlgoAPI_MakeShape::initialize() { const TopoDS_Shape& aTopoDSShape = myShape->impl(); for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_FACE); anExp.More(); anExp.Next()) { - std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + GeomShapePtr aCurrentShape(new GeomAPI_Shape()); aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); myMap->bind(aCurrentShape, aCurrentShape); } @@ -241,21 +266,21 @@ void GeomAlgoAPI_MakeShape::initialize() { } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShape::prepareNamingFaces() { long long index = 1; GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); for(GeomAPI_ShapeExplorer anExp(shape(), GeomAPI_Shape::FACE); anExp.more(); anExp.next()) { - std::shared_ptr aFace = anExp.current(); + GeomShapePtr aFace = anExp.current(); myCreatedFaces["Face_" + std::to_string(index++)] = aFace; } } -//================================================================================================= -bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){ - +//================================================================================================== +bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage) +{ // isValid() is called from this method if (!isValid()) { myError = theMessage + " :: resulting shape is not valid."; @@ -278,8 +303,9 @@ bool GeomAlgoAPI_MakeShape::checkValid(std::string theMessage){ return true ; } -bool GeomAlgoAPI_MakeShape::newShapesCollected( - std::shared_ptr theWholeOld, const int theShapeType) +//================================================================================================== +bool GeomAlgoAPI_MakeShape::isNewShapesCollected(GeomShapePtr theWholeOld, + const int theShapeType) { if (!myHist) return false; @@ -290,7 +316,7 @@ bool GeomAlgoAPI_MakeShape::newShapesCollected( } void GeomAlgoAPI_MakeShape::collectNewShapes( - std::shared_ptr theWholeOld, const int theShapeType) + GeomShapePtr theWholeOld, const int theShapeType) { if (!myHist) myHist = new HistoryMap; @@ -339,9 +365,10 @@ static void addAllSubs(const TopoDS_Shape& theNewShape, } } -std::shared_ptr GeomAlgoAPI_MakeShape::oldShapesForNew( - std::shared_ptr theWholeOld, - std::shared_ptr theNewShape, const int theShapeType) +//================================================================================================== +GeomShapePtr GeomAlgoAPI_MakeShape::oldShapesForNew(GeomShapePtr theWholeOld, + GeomShapePtr theNewShape, + const int theShapeType) { GeomShapePtr aResult(new GeomAPI_Shape); TopoDS_Compound aResComp; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index eb2396c96..c5c586855 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -52,7 +52,8 @@ public: /// \brief Constructor by builder and builder type. /// \param[in] theBuilder pointer to the builder. /// \param[in] theBuilderType builder type. - template explicit GeomAlgoAPI_MakeShape(T* theBuilder, + template explicit GeomAlgoAPI_MakeShape( + T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) : GeomAPI_Interface(theBuilder), myBuilderType(theBuilderType) @@ -63,7 +64,8 @@ public: /// \brief Initializes internals. /// \param[in] theBuilder pointer to the builder. /// \param[in] theBuilderType builder type. - template void initialize(T* theBuilder, + template void initialize( + T* theBuilder, const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) { setImpl(theBuilder); @@ -75,7 +77,7 @@ public: GEOMALGOAPI_EXPORT bool isDone() const; /// \return a shape built by the shape construction algorithm. - GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const; /// \return true if resulting shape is valid. GEOMALGOAPI_EXPORT bool isValid() const; @@ -87,34 +89,35 @@ public: GEOMALGOAPI_EXPORT std::shared_ptr mapOfSubShapes() const; /// \return the list of shapes generated from the shape \a theShape. - /// \param[in] theShape base shape. - /// \param[out] theHistory generated shapes. - GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, - ListOfShape& theHistory); + /// \param[in] theOldShape base shape. + /// \param[out] theNewShapes shapes generated from \a theShape. Does not cleared! + GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return the list of shapes modified from the shape \a theShape. - /// \param[in] theShape base shape. - /// \param[out] theHistory modified shapes. Does not cleared! - GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, - ListOfShape& theHistory); + /// \param[in] theOldShape base shape. + /// \param[out] theNewShapes shapes modified from \a theShape. Does not cleared! + GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return true if theShape was deleted. - /// \param[in] theShape base shape. - GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); + /// \param[in] theOldShape base shape. + GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theOldShape); /// \return true if the data were correct. GEOMALGOAPI_EXPORT virtual bool check() { return true; }; + /// \brief Prepare the naming of faces. + GEOMALGOAPI_EXPORT virtual void prepareNamingFaces(); + /// \return the list of created faces. - GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr > getCreatedFaces() - {return myCreatedFaces;} + GEOMALGOAPI_EXPORT std::map< std::string, GeomShapePtr > getCreatedFaces() { + return myCreatedFaces; + } /// \return the error. GEOMALGOAPI_EXPORT std::string getError() { return myError; } - /// \brief Prepare the naming of faces. - GEOMALGOAPI_EXPORT virtual void prepareNamingFaces(); - /// \brief Check the validity of the produced shape. GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage); @@ -122,24 +125,27 @@ public: /// \param theWholeOld the whole old shape /// \param theShapeType type of the sub-shapes that is used for optimization /// \returns true if optimization containers are already filled - GEOMALGOAPI_EXPORT bool newShapesCollected( - std::shared_ptr theWholeOld, const int theShapeType); + GEOMALGOAPI_EXPORT bool isNewShapesCollected(GeomShapePtr theWholeOld, + const int theShapeType); /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes. /// \param theWholeOld the whole old shape /// \param theShapeType type of the sub-shapes that is used for optimization /// \returns true if optimization containers are already filled - GEOMALGOAPI_EXPORT void collectNewShapes( - std::shared_ptr theWholeOld, const int theShapeType); + GEOMALGOAPI_EXPORT void collectNewShapes(GeomShapePtr theWholeOld, + const int theShapeType); /// Optimization of access the new shapes by old shapes for the limited set of needed new shapes. /// \param theWholeOld the whole old shape /// \param theNewShape the whole new shape /// \param theShapeType type of the old sub-shapes /// \returns compound of all old shapes that were used for creation of the given new - GEOMALGOAPI_EXPORT std::shared_ptr oldShapesForNew( - std::shared_ptr theWholeOld, - std::shared_ptr theNewShape, const int theShapeType); + GEOMALGOAPI_EXPORT GeomShapePtr oldShapesForNew(GeomShapePtr theWholeOld, + GeomShapePtr theNewShape, + const int theShapeType); + + /// Replaces \a theShape with shape from \a myMap. + GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr& theShape); protected: /// \brief Sets builder type. @@ -152,7 +158,10 @@ protected: /// \brief Sets result shape. /// \param[in] theShape new shape. - void setShape(const std::shared_ptr theShape); + void setShape(const GeomShapePtr theShape); + + /// \return true if passed shape is valid for history. + bool isValidForHistory(const GeomShapePtr theShape); protected: /// Data map to keep correct orientation of sub-shapes. @@ -160,7 +169,7 @@ protected: /// Error occurred during the execution of an algorithm. std::string myError; /// Map of created faces with their name for naming. - std::map< std::string, std::shared_ptr > myCreatedFaces; + std::map< std::string, GeomShapePtr > myCreatedFaces; private: /// \brief Initializes internals. @@ -169,13 +178,14 @@ private: private: GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder. bool myDone; ///< Builder status. - std::shared_ptr myShape; ///< Resulting shape. + GeomShapePtr myShape; ///< Resulting shape. /// map that is used to keep the optimization structure for access to the history /// kind of sub-shapes -> whole old shape -> new shape -> list of old shapes that create this new void* myHist; }; -typedef std::list > ListOfMakeShape; +typedef std::shared_ptr GeomMakeShapePtr; +typedef std::list ListOfMakeShape; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp index 01bf7a88a..01bf7c865 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.cpp @@ -20,58 +20,63 @@ #include -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeCustom::GeomAlgoAPI_MakeShapeCustom() -{} +{ +} -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::setResult(const std::shared_ptr theShape) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::setResult(const GeomShapePtr theShape) { setShape(theShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addModified(const std::shared_ptr theBase, - const std::shared_ptr theResult) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addModified(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape) { - return myModified.add(theBase, theResult); + if (!isValidForHistory(theNewShape)) return false; + GeomShapePtr aNewShape = theNewShape; + return myModified.add(theOldShape, aNewShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const std::shared_ptr theBase, - const std::shared_ptr theResult) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addGenerated(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape) { - return myGenerated.add(theBase, theResult); + if (!isValidForHistory(theNewShape)) return false; + GeomShapePtr aNewShape = theNewShape; + return myGenerated.add(theOldShape, aNewShape); } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::addDeleted(const GeomShapePtr theOldShape) { - return myDeleted.bind(theShape, theShape); + return myDeleted.bind(theOldShape, theOldShape); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { ListOfShape aGenerated; - if(myGenerated.find(theShape, aGenerated)) { - theHistory.insert(theHistory.end(), aGenerated.begin(), aGenerated.end()); + if(myGenerated.find(theOldShape, aGenerated)) { + theNewShapes.insert(theNewShapes.end(), aGenerated.begin(), aGenerated.end()); } } -//================================================================================================= -void GeomAlgoAPI_MakeShapeCustom::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeCustom::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { ListOfShape aModified; - if(myModified.find(theShape, aModified)) { - theHistory.insert(theHistory.end(), aModified.begin(), aModified.end()); + if(myModified.find(theOldShape, aModified)) { + theNewShapes.insert(theNewShapes.end(), aModified.begin(), aModified.end()); } } -//================================================================================================= -bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeCustom::isDeleted(const GeomShapePtr theOldShape) { - return myDeleted.isBound(theShape); -} \ No newline at end of file + return myDeleted.isBound(theOldShape); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h index 77bfac0e2..6fca968ea 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeCustom.h @@ -37,29 +37,29 @@ public: GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShapeCustom(); /// Sets result shape. - GEOMALGOAPI_EXPORT void setResult(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT void setResult(const GeomShapePtr theShape); /// Adds modified shape. - GEOMALGOAPI_EXPORT bool addModified(const std::shared_ptr theBase, - const std::shared_ptr theResult); + GEOMALGOAPI_EXPORT bool addModified(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape); /// Adds generated shape. - GEOMALGOAPI_EXPORT bool addGenerated(const std::shared_ptr theBase, - const std::shared_ptr theResult); + GEOMALGOAPI_EXPORT bool addGenerated(const GeomShapePtr theOldShape, + const GeomShapePtr theNewShape); /// Adds deleted shape. - GEOMALGOAPI_EXPORT bool addDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT bool addDeleted(const GeomShapePtr theOldShape); /// \return the list of shapes generated from the shape theShape - GEOMALGOAPI_EXPORT void generated(const std::shared_ptr theShape, - ListOfShape& theHistory); + GEOMALGOAPI_EXPORT void generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes); /// \return the list of shapes modified from the shape theShape - GEOMALGOAPI_EXPORT void modified(const std::shared_ptr theShape, - ListOfShape& theHistory); + GEOMALGOAPI_EXPORT void modified(const GeomShapePtr theShape, + ListOfShape& theNewShapes); /// \return whether the shape is deleted - GEOMALGOAPI_EXPORT bool isDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT bool isDeleted(const GeomShapePtr theOldShape); private: GeomAPI_DataMapOfShapeMapOfShapes myGenerated; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp index 1c615ced3..646894a1f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.cpp @@ -25,19 +25,19 @@ #include #include -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList() : GeomAlgoAPI_MakeShape() {} -//================================================================================================= +//================================================================================================== GeomAlgoAPI_MakeShapeList::GeomAlgoAPI_MakeShapeList(const ListOfMakeShape& theMakeShapeList) : GeomAlgoAPI_MakeShape() { init(theMakeShapeList); } -//================================================================================================= +//================================================================================================== void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) { if(myMap.get()) { @@ -54,9 +54,15 @@ void GeomAlgoAPI_MakeShapeList::init(const ListOfMakeShape& theMakeShapeList) } } -//================================================================================================= +const ListOfMakeShape& GeomAlgoAPI_MakeShapeList::list() const +{ + return myListOfMakeShape; +} + + +//================================================================================================== void GeomAlgoAPI_MakeShapeList::appendAlgo( - const std::shared_ptr theMakeShape) + const GeomMakeShapePtr theMakeShape) { myListOfMakeShape.push_back(theMakeShape); if(!myMap.get()) { @@ -65,38 +71,41 @@ void GeomAlgoAPI_MakeShapeList::appendAlgo( myMap->merge(theMakeShape->mapOfSubShapes()); } -//================================================================================================= -const std::shared_ptr GeomAlgoAPI_MakeShapeList::shape() const +//================================================================================================== +const GeomShapePtr GeomAlgoAPI_MakeShapeList::shape() const { - std::shared_ptr aShape = GeomAlgoAPI_MakeShape::shape(); + GeomShapePtr aShape = GeomAlgoAPI_MakeShape::shape(); if(aShape.get() && !aShape->impl().IsNull()) { return aShape; } else if(!myListOfMakeShape.empty()) { return myListOfMakeShape.back()->shape(); } - return std::shared_ptr(); + return GeomShapePtr(); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::generated(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::generated(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Generated, theHistory); + result(theOldShape, GeomAlgoAPI_MakeShapeList::Generated, theNewShapes); } -//================================================================================================= -void GeomAlgoAPI_MakeShapeList::modified(const std::shared_ptr theShape, - ListOfShape& theHistory) +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::modified(const GeomShapePtr theOldShape, + ListOfShape& theNewShapes) { - result(theShape, GeomAlgoAPI_MakeShapeList::Modified, theHistory); + result(theOldShape, GeomAlgoAPI_MakeShapeList::Modified, theNewShapes); } -bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr theShape) +//================================================================================================== +bool GeomAlgoAPI_MakeShapeList::isDeleted(const GeomShapePtr theOldShape) { - for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; - if(aMakeShape->isDeleted(theShape)) { + for (ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; + if(aMakeShape->isDeleted(theOldShape)) { return true; } } @@ -104,9 +113,10 @@ bool GeomAlgoAPI_MakeShapeList::isDeleted(const std::shared_ptr t return false; } -void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theShape, +//================================================================================================== +void GeomAlgoAPI_MakeShapeList::result(const GeomShapePtr theOldShape, OperationType theOperationType, - ListOfShape& theHistory) + ListOfShape& theNewShapes) { if(myListOfMakeShape.empty()) { return; @@ -115,24 +125,30 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS NCollection_Map anAlgoShapes; NCollection_Map aResultShapesMap; NCollection_List aResultShapesList; - anAlgoShapes.Add(theShape->impl()); - aResultShapesMap.Add(theShape->impl()); - aResultShapesList.Append(theShape->impl()); + anAlgoShapes.Add(theOldShape->impl()); + aResultShapesMap.Add(theOldShape->impl()); + aResultShapesList.Append(theOldShape->impl()); for(ListOfMakeShape::iterator aBuilderIt = myListOfMakeShape.begin(); - aBuilderIt != myListOfMakeShape.end(); aBuilderIt++) { - std::shared_ptr aMakeShape = *aBuilderIt; + aBuilderIt != myListOfMakeShape.end(); + ++aBuilderIt) + { + GeomMakeShapePtr aMakeShape = *aBuilderIt; NCollection_Map aTempShapes; - for(NCollection_Map::Iterator - aShapeIt(anAlgoShapes); aShapeIt.More(); aShapeIt.Next()) { + for (NCollection_Map::Iterator aShapeIt(anAlgoShapes); + aShapeIt.More(); + aShapeIt.Next()) + { bool hasResults = false; bool anArgumentIsInResult = false; - std::shared_ptr aShape(new GeomAPI_Shape); + GeomShapePtr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); ListOfShape aGeneratedShapes; aMakeShape->generated(aShape, aGeneratedShapes); - for (ListOfShape::const_iterator - anIt = aGeneratedShapes.cbegin(); anIt != aGeneratedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aGeneratedShapes.cbegin(); + anIt != aGeneratedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); if (anItShape.IsSame(aShapeIt.Value())) { anArgumentIsInResult = true; @@ -146,8 +162,10 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS } ListOfShape aModifiedShapes; aMakeShape->modified(aShape, aModifiedShapes); - for(ListOfShape::const_iterator - anIt = aModifiedShapes.cbegin(); anIt != aModifiedShapes.cend(); anIt++) { + for (ListOfShape::const_iterator anIt = aModifiedShapes.cbegin(); + anIt != aModifiedShapes.cend(); + ++anIt) + { const TopoDS_Shape& anItShape = (*anIt)->impl(); if (anItShape.IsSame(aShapeIt.Value())) { anArgumentIsInResult = true; @@ -175,10 +193,14 @@ void GeomAlgoAPI_MakeShapeList::result(const std::shared_ptr theS anAlgoShapes.Unite(aTempShapes); } - for(NCollection_List::Iterator - aShapeIt(aResultShapesList); aShapeIt.More(); aShapeIt.Next()) { - std::shared_ptr aShape(new GeomAPI_Shape()); + for (NCollection_List::Iterator aShapeIt(aResultShapesList); + aShapeIt.More(); + aShapeIt.Next()) + { + GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(aShapeIt.Value())); - theHistory.push_back(aShape); + if (!isValidForHistory(aShape)) continue; + fixOrientation(aShape); + theNewShapes.push_back(aShape); } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h index e79826e89..b41712e14 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShapeList.h @@ -49,26 +49,29 @@ public: /// \param[in] theMakeShapeList list of algorithms. GEOMALGOAPI_EXPORT void init(const ListOfMakeShape& theMakeShapeList); + /// \return the list reference + GEOMALGOAPI_EXPORT const ListOfMakeShape& list() const; + /// \brief Adds algo to the end of list. /// \param[in] theMakeShape algo to be added. - GEOMALGOAPI_EXPORT void appendAlgo(const std::shared_ptr theMakeShape); + GEOMALGOAPI_EXPORT void appendAlgo(const GeomMakeShapePtr theMakeShape); /// \return a shape built by the shape construction algorithms - GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + GEOMALGOAPI_EXPORT virtual const GeomShapePtr shape() const; /// \return the list of shapes generated from the shape \a theShape - GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, + GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theShape, ListOfShape& theHistory); /// \return the list of shapes modified from the shape \a theShape - GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, + GEOMALGOAPI_EXPORT virtual void modified(const GeomShapePtr theShape, ListOfShape& theHistory); /// \return whether the shape is deleted - GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); + GEOMALGOAPI_EXPORT virtual bool isDeleted(const GeomShapePtr theShape); private: - void result(const std::shared_ptr theShape, + void result(const GeomShapePtr theShape, OperationType theOperationType, ListOfShape& theHistory); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp index 419854e01..210a8c4b0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp @@ -323,6 +323,8 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(aPipeBuilder->FirstShape())); aToShape->setImpl(new TopoDS_Shape(aPipeBuilder->LastShape())); + fixOrientation(aFromShape); + fixOrientation(aToShape); this->addFromShape(aFromShape); this->addToShape(aToShape); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp index 3e3ed5d4e..c07cda2db 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp @@ -21,6 +21,7 @@ #include "GeomAlgoAPI_Placement.h" #include +#include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #include #include @@ -70,29 +72,48 @@ void GeomAlgoAPI_Placement::build(const std::shared_ptr& theSourc GProp_GProps aProps; static const double aPropEps = 1.e-4; + GeomShapePtr aShape; + bool isCompound = false; for (int i = 0; i < aNbObjects; i++) { - if (aShapes[i]->isFace()) { - std::shared_ptr aFace(new GeomAPI_Face(aShapes[i])); + aShape = aShapes[i]; + isCompound = false; + if (aShapes[i]->isCompound()) { + isCompound = true; + GeomAPI_ShapeIterator anIt(aShapes[i]); + aShape = anIt.current(); + + GeomPointPtr aPnt = GeomAlgoAPI_ShapeTools::centreOfMass(aShapes[i]); + aSrcDstPoints[i].SetCoord(aPnt->x(), aPnt->y(), aPnt->z()); + } + + if (aShape->isFace()) { + std::shared_ptr aFace(new GeomAPI_Face(aShape)); std::shared_ptr aPlane = aFace->getPlane(); std::shared_ptr aDir = aPlane->direction(); aSrcDstNormals[i].SetCoord(aDir->x(), aDir->y(), aDir->z()); - BRepGProp::SurfaceProperties(aFace->impl(), aProps, aPropEps); - gp_Pnt aLoc = aProps.CentreOfMass(); - aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z()); + if (!isCompound) { + BRepGProp::SurfaceProperties(aFace->impl(), aProps, aPropEps); + gp_Pnt aLoc = aProps.CentreOfMass(); + aSrcDstPoints[i].SetCoord(aLoc.X(), aLoc.Y(), aLoc.Z()); + } } - else if (aShapes[i]->isEdge()) { - std::shared_ptr anEdge(new GeomAPI_Edge(aShapes[i])); + else if (aShape->isEdge()) { + std::shared_ptr anEdge(new GeomAPI_Edge(aShape)); std::shared_ptr aLine = anEdge->line(); std::shared_ptr aDir = aLine->direction(); - std::shared_ptr aFirstPnt = anEdge->firstPoint(); - std::shared_ptr aLastPnt = anEdge->lastPoint(); - std::shared_ptr aLoc = aFirstPnt->xyz()->added(aLastPnt->xyz())->multiplied(0.5); - aSrcDstPoints[i].SetCoord(aLoc->x(), aLoc->y(), aLoc->z()); aSrcDstDirections[i].SetCoord(aDir->x(), aDir->y(), aDir->z()); + + if (!isCompound) { + std::shared_ptr aFirstPnt = anEdge->firstPoint(); + std::shared_ptr aLastPnt = anEdge->lastPoint(); + std::shared_ptr aLoc = aFirstPnt->xyz()->added(aLastPnt->xyz()) + ->multiplied(0.5); + aSrcDstPoints[i].SetCoord(aLoc->x(), aLoc->y(), aLoc->z()); + } } - else if (aShapes[i]->isVertex()) { - std::shared_ptr aVertex(new GeomAPI_Vertex(aShapes[i])); + else if (aShape->isVertex()) { + std::shared_ptr aVertex(new GeomAPI_Vertex(aShape)); std::shared_ptr aPnt = aVertex->point(); aSrcDstPoints[i].SetCoord(aPnt->x(), aPnt->y(), aPnt->z()); } else // something goes wrong diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 2576423e7..3a0e7eee8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -411,6 +411,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) { GeomShapePtr aGeomSh(new GeomAPI_Shape()); aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aGeomSh); this->addToShape(aGeomSh); } } @@ -436,6 +437,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) { GeomShapePtr aGeomSh(new GeomAPI_Shape()); aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aGeomSh); this->addFromShape(aGeomSh); } } @@ -483,6 +485,8 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(thePrismBuilder->FirstShape(aShape))); aToShape->setImpl(new TopoDS_Shape(thePrismBuilder->LastShape(aShape))); + thePrismAlgo->fixOrientation(aFromShape); + thePrismAlgo->fixOrientation(aToShape); thePrismAlgo->addFromShape(aFromShape); thePrismAlgo->addToShape(aToShape); } @@ -504,11 +508,13 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, if(anIntTools.IsValidPointForFace(aPnt, theToFace, Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, theFromFace, Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addFromShape(aGeomSh); } } else if(theType == TopAbs_EDGE) { @@ -517,12 +523,14 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addToShape(aGeomSh); } anEdgeCheck.Init(anEdge, theFromFace); anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addFromShape(aGeomSh); } } else { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp index 770580963..8c2f62448 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp @@ -418,6 +418,7 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr& theBaseSh for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) { GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aShape); isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape); } } @@ -482,6 +483,7 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr& theBaseSh for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) { GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aShape); isFromFaceSet ? this->addToShape(aShape) : this->addFromShape(aShape); } } @@ -612,6 +614,8 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(theRevolBuilder->FirstShape(aShape))); aToShape->setImpl(new TopoDS_Shape(theRevolBuilder->LastShape(aShape))); + theRevolutionAlgo->fixOrientation(aFromShape); + theRevolutionAlgo->fixOrientation(aToShape); theRevolutionAlgo->addFromShape(aFromShape); theRevolutionAlgo->addToShape(aToShape); } @@ -633,11 +637,13 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theToFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theFromFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } } else if(theType == TopAbs_EDGE) { @@ -646,12 +652,14 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } anEdgeCheck.Init(anEdge, TopoDS::Face(theFromFace)); anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } } else { @@ -660,10 +668,12 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(theToFace)); if(aFaceSurface == aFromSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } if(aFaceSurface == aToSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } } @@ -686,12 +696,14 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theRotatedBoundingFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theModifiedBaseShape), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } @@ -701,6 +713,7 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } @@ -708,6 +721,7 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } @@ -718,11 +732,13 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(TopoDS::Face(theModifiedBaseShape)); if(aFaceSurface == aBoundingSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } if(aFaceSurface == aBaseSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index a47c77c7f..a9390272b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -234,14 +234,14 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::combineShapes( } } - // Map subshapes and shapes. + // Map sub-shapes and shapes. TopTools_IndexedDataMapOfShapeListOfShape aMapSA; TopExp::MapShapesAndAncestors(aShapesComp, aTS, aTA, aMapSA); if(aMapSA.IsEmpty()) { return aResult; } - // Get all shapes with common subshapes and free shapes. + // Get all shapes with common sub-shapes and free shapes. NCollection_Map aFreeShapes; NCollection_Vector> aShapesWithCommonSubshapes; for(TopTools_IndexedDataMapOfShapeListOfShape::Iterator @@ -299,7 +299,7 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::combineShapes( } } - // Combine shapes with common subshapes. + // Combine shapes with common sub-shapes. for(NCollection_Vector>::Iterator anIter(aShapesWithCommonSubshapes); anIter.More(); anIter.Next()) { TopoDS_Shell aShell; @@ -444,7 +444,7 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology( aKeysIt.Next()) { const TopTools_ListOfShape& anOtherConnected = aVertexShapesMap(aKeysIt.Value()); if (!anOtherConnected.Contains(aConnected)) { - // Other connected group does not containt shape from our connected group + // Other connected group does not contain shape from our connected group continue; } // Other is connected to our, so add them to our connected diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp index 5a893f50b..e642cc59f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp @@ -19,6 +19,7 @@ // #include "GeomAlgoAPI_Tools.h" +#include "GeomAlgoAPI_MakeShape.h" #include @@ -58,3 +59,32 @@ std::string File_Tools::name(const std::string& theFileName) OSD_Path aPath(aFileName); return aPath.Name().ToCString(); } + +bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm, + const std::string& theFeature, + std::string& theError) +{ + theError.clear(); + if (!theAlgorithm->isDone()) { + theError = "Error: " + (theFeature.empty() ? "The" : theFeature) + " algorithm failed."; + std::string anAlgoError = theAlgorithm->getError(); + if (!anAlgoError.empty()) + theError += " " + anAlgoError; + return true; + } + if (!theAlgorithm->shape() || theAlgorithm->shape()->isNull()) { + theError = "Error: Resulting shape"; + if (!theFeature.empty()) + theError += "of " + theFeature; + theError += " is Null."; + return true; + } + if (!theAlgorithm->isValid()) { + theError = "Error: Resulting shape"; + if (!theFeature.empty()) + theError += "of " + theFeature; + theError += " is not valid."; + return true; + } + return false; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h index f17efdc3b..bb0c28f2b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h @@ -23,8 +23,11 @@ #include +#include #include +class GeomAlgoAPI_MakeShape; + namespace GeomAlgoAPI_Tools { /** \class Localizer @@ -56,6 +59,24 @@ public: GEOMALGOAPI_EXPORT static std::string name(const std::string& theFileName); }; +/** \class AlgoError + * \ingroup DataAlgo + * \brief Verify error in MakeShape algorithm. + */ +class AlgoError { +public: + /** \brief Verify MakeShape algorithm for failures + * \param[in] theAlgorithm object to verify the failure + * \param[in] theFeature kind of the feature, the algorithm belongs to + * \param[out] theError error string (empty if the feature succeed) + * \return \c true if succeed + */ + GEOMALGOAPI_EXPORT static bool isAlgorithmFailed( + const std::shared_ptr& theAlgorithm, + const std::string& theFeature, + std::string& theError); +}; + } // GeomAlgoAPI_Tools #endif /* GEOMALGOAPI_TOOLS_H_ */ diff --git a/src/GeomValidators/CMakeLists.txt b/src/GeomValidators/CMakeLists.txt index 85527474e..fcca1b51c 100644 --- a/src/GeomValidators/CMakeLists.txt +++ b/src/GeomValidators/CMakeLists.txt @@ -28,7 +28,6 @@ SET(PROJECT_HEADERS GeomValidators_Face.h GeomValidators_FeatureKind.h GeomValidators_Finite.h - GeomValidators_PartitionArguments.h GeomValidators_Plugin.h GeomValidators_Positive.h GeomValidators_ShapeType.h @@ -48,7 +47,6 @@ SET(PROJECT_SOURCES GeomValidators_Face.cpp GeomValidators_FeatureKind.cpp GeomValidators_Finite.cpp - GeomValidators_PartitionArguments.cpp GeomValidators_Plugin.cpp GeomValidators_Positive.cpp GeomValidators_ShapeType.cpp diff --git a/src/GeomValidators/GeomValidators_DifferentShapes.cpp b/src/GeomValidators/GeomValidators_DifferentShapes.cpp index 69a981be6..e030c284e 100644 --- a/src/GeomValidators/GeomValidators_DifferentShapes.cpp +++ b/src/GeomValidators/GeomValidators_DifferentShapes.cpp @@ -171,5 +171,7 @@ bool GeomValidators_DifferentShapes::isAttrShapesEqual(const AttributePtr& theAt } GeomShapePtr aOtherTypedShape = GeomAPI_Tools::getTypedShape(anOtherShape); + if (!aTypedShape.get()) + return !aTypedShape.get() && !aOtherTypedShape.get(); return aTypedShape->isEqual(aOtherTypedShape); -} \ No newline at end of file +} diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index 945f9bc34..18cc1b1e6 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -24,6 +24,7 @@ #include "ModelAPI_AttributeSelection.h" #include +#include #include @@ -46,6 +47,40 @@ GeomAbs_SurfaceType faceType(const std::string& theType) return GeomAbs_Plane; } +bool isValidFace(const GeomShapePtr theShape, + const GeomAbs_SurfaceType theFaceType, + Events_InfoMessage& theError) +{ + GeomFacePtr aGeomFace = theShape->face(); + + if (!aGeomFace.get()) { + theError = "The shape is not a face."; + return false; + } + + bool aValid = true; + + switch (theFaceType) { + case GeomAbs_Plane: { + aValid = aGeomFace->isPlanar(); + if (!aValid) theError = "The shape is not a plane."; + break; + } + case GeomAbs_Cylinder: { + aValid = aGeomFace->isCylindrical(); + if (!aValid) theError = "The shape is not a cylinder."; + break; + } + default: { + aValid = false; + theError = "The shape is not an available face."; + break; + } + } + + return aValid; +} + bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, const std::list& theArguments, Events_InfoMessage& theError) const @@ -73,42 +108,21 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, // it is necessary to check whether the shape is face in order to set in selection a value // with any type and check the type in this validator // It is realized to select any object in OB and filter it in this validator (sketch plane) - if (!aGeomShape->isFace()) { - aValid = false; - theError = "The shape is not a face."; + GeomAbs_SurfaceType aFaceType = GeomAbs_Plane; + if (theArguments.size() == 1) + aFaceType = faceType(theArguments.front()); + if (aGeomShape->isFace()) { + aValid = isValidFace(aGeomShape, aFaceType, theError); } - else { - std::shared_ptr aGeomFace(new GeomAPI_Face(aGeomShape)); - if (!aGeomFace.get()) { - aValid = false; - theError = "The shape is not a face."; - } - else { - GeomAbs_SurfaceType aFaceType = GeomAbs_Plane; - if (theArguments.size() == 1) - aFaceType = faceType(theArguments.front()); - - switch (aFaceType) { - case GeomAbs_Plane: { - aValid = aGeomFace->isPlanar(); - if (!aValid) - theError = "The shape is not a plane."; - } - break; - case GeomAbs_Cylinder:{ - aValid = aGeomFace->isCylindrical(); - if (!aValid) - theError = "The shape is not a cylinder."; - } - break; - default: { - aValid = false; - theError = "The shape is not an available face."; - break; - } - } + else if (aSelectionAttr->isGeometricalSelection() && aGeomShape->isCompound()) { + for (GeomAPI_ShapeIterator anIt(aGeomShape); anIt.more() && aValid; anIt.next()) { + aValid = isValidFace(anIt.current(), aFaceType, theError); } } + else { + aValid = false; + theError = "The shape is not a face."; + } } return aValid; } diff --git a/src/GeomValidators/GeomValidators_PartitionArguments.cpp b/src/GeomValidators/GeomValidators_PartitionArguments.cpp deleted file mode 100644 index 0231edafa..000000000 --- a/src/GeomValidators/GeomValidators_PartitionArguments.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// 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 - -#include - -#include -#include - -//================================================================================================= -bool GeomValidators_PartitionArguments::isValid(const std::shared_ptr& theFeature, - const std::list& theArguments, - Events_InfoMessage& theError) const -{ - if(theArguments.size() != 3) { - theError = "Wrong number of arguments (expected 3)."; - return false; - } - - int anObjectsNb = 0, aToolsNb = 0; - bool isCombine = true; - - std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); - - std::shared_ptr anAttrSelList = theFeature->selectionList(*anIt); - if(anAttrSelList) { - anObjectsNb = anAttrSelList->size(); - } - anIt++; - - anAttrSelList = theFeature->selectionList(*anIt); - if(anAttrSelList) { - aToolsNb = anAttrSelList->size(); - } - anIt++; - - std::shared_ptr anAttrBool = theFeature->boolean(*anIt); - if(anAttrBool) { - isCombine = anAttrBool->value(); - } - - if((anObjectsNb > 0 && aToolsNb > 0) || - (isCombine && anObjectsNb != 0 && (anObjectsNb + aToolsNb > 1))) { - return true; - } - - theError = "Not enough arguments"; - return false; -} - -//================================================================================================= -bool GeomValidators_PartitionArguments::isNotObligatory(std::string theFeature, - std::string theAttribute) -{ - if(theAttribute == "tool_objects") { - return true; - } - - return false; -} diff --git a/src/GeomValidators/GeomValidators_PartitionArguments.h b/src/GeomValidators/GeomValidators_PartitionArguments.h deleted file mode 100644 index 8a8f072dc..000000000 --- a/src/GeomValidators/GeomValidators_PartitionArguments.h +++ /dev/null @@ -1,50 +0,0 @@ -// 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 -// - -#ifndef GeomValidators_PartitionArguments_H -#define GeomValidators_PartitionArguments_H - -#include -#include -#include - -/** \class GeomValidators_PartitionArguments - * \ingroup Validators - * \brief Validates that partition operation have enough arguments. - */ -class GeomValidators_PartitionArguments : public ModelAPI_FeatureValidator -{ -public: - /** \brief Returns true if feature and/or attributes are valid. - * \param[in] theFeature the validated feature. - * \param[in] theArguments the arguments in the configuration file for this validator. - * \param[out] theError error message. - * \returns true if feature is valid. - */ - GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr& theFeature, - const std::list& theArguments, - Events_InfoMessage& theError) const; - - /// \return true if the attribute in feature is not obligatory for the feature execution. - GEOMVALIDATORS_EXPORT virtual - bool isNotObligatory(std::string theFeature, std::string theAttribute); -}; - -#endif diff --git a/src/GeomValidators/GeomValidators_Plugin.cpp b/src/GeomValidators/GeomValidators_Plugin.cpp index 733fc17bf..6f8129df5 100644 --- a/src/GeomValidators/GeomValidators_Plugin.cpp +++ b/src/GeomValidators/GeomValidators_Plugin.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -54,8 +53,6 @@ GeomValidators_Plugin::GeomValidators_Plugin() new GeomValidators_DifferentShapes); aFactory->registerValidator("GeomValidators_Face", new GeomValidators_Face); aFactory->registerValidator("GeomValidators_Finite", new GeomValidators_Finite); - aFactory->registerValidator("GeomValidators_PartitionArguments", - new GeomValidators_PartitionArguments); aFactory->registerValidator("GeomValidators_ShapeType", new GeomValidators_ShapeType); aFactory->registerValidator("GeomValidators_ZeroOffset", new GeomValidators_ZeroOffset); aFactory->registerValidator("GeomValidators_FeatureKind", new GeomValidators_FeatureKind); diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index afb7dd0c9..a7638e7be 100755 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -22,6 +22,7 @@ #include "GeomValidators_Tools.h" #include +#include #include #include @@ -130,18 +131,27 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute std::dynamic_pointer_cast(theAttribute); GeomShapePtr aShape = anAttr->value(); if (aShape.get()) - aValid = isValidShape(aShape, theShapeType, theError); + aValid = isValidShape(aShape, theShapeType, anAttr->isGeometricalSelection(), theError); else { if (anAttr->context().get()) - aValid = isValidObject(anAttr->context(), theShapeType, theError); + aValid = isValidObject(anAttr->context(), + theShapeType, + anAttr->isGeometricalSelection(), + theError); else - aValid = isValidObject(anAttr->contextFeature(), theShapeType, theError); + aValid = isValidObject(anAttr->contextFeature(), + theShapeType, + anAttr->isGeometricalSelection(), + theError); } } else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); if (anAttr->isObject()) { - aValid = isValidObject(anAttr->object(), theShapeType, theError); + aValid = isValidObject(anAttr->object(), + theShapeType, + false, + theError); } else if (theShapeType == Vertex) { AttributePtr aRefAttr = anAttr->attr(); @@ -162,7 +172,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute else if (anAttributeType == ModelAPI_AttributeReference::typeId()) { AttributeReferencePtr anAttr = std::dynamic_pointer_cast(theAttribute); - aValid = isValidObject(anAttr->value(), theShapeType, theError); + aValid = isValidObject(anAttr->value(), theShapeType, false, theError); } else if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aListAttr = @@ -190,6 +200,7 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, const TypeOfShape theShapeType, + const bool theIsGeometricalSelection, Events_InfoMessage& theError) const { bool aValid = true; @@ -214,7 +225,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, aValid = false; theError = "The result is empty"; } else { - aValid = isValidShape(aResult->shape(), theShapeType, theError); + aValid = isValidShape(aResult->shape(), theShapeType, theIsGeometricalSelection, theError); } } else { FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); @@ -231,6 +242,7 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape, const TypeOfShape theShapeType, + const bool theIsGeometricalSelection, Events_InfoMessage& theError) const { bool aValid = true; @@ -247,9 +259,21 @@ bool GeomValidators_ShapeType::isValidShape(const GeomShapePtr theShape, case Edge: aValid = theShape->isEdge(); break; - case Line: - aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isLine(); + case Line: { + if (theIsGeometricalSelection && theShape->isCompound()) { + aValid = true; + for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) { + if (!anIt.current()->isEdge() || !GeomAPI_Curve(anIt.current()).isLine()) { + aValid = false; + break; + } + } + } + else { + aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isLine(); + } break; + } case Circle: aValid = theShape->isEdge() && GeomAPI_Curve(theShape).isCircle(); break; diff --git a/src/GeomValidators/GeomValidators_ShapeType.h b/src/GeomValidators/GeomValidators_ShapeType.h index daf9fda38..0606cd411 100644 --- a/src/GeomValidators/GeomValidators_ShapeType.h +++ b/src/GeomValidators/GeomValidators_ShapeType.h @@ -83,6 +83,7 @@ protected: /// \param[out] theError error message. bool isValidObject(const ObjectPtr& theObject, const TypeOfShape theShapeType, + const bool theIsGeometricalSelection, Events_InfoMessage& theError) const; /// Returns true if the attibute's object type satisfies the argument value @@ -91,6 +92,7 @@ protected: /// \param[out] theError error message. bool isValidShape(const GeomShapePtr theShape, const TypeOfShape theShapeType, + const bool theIsGeometricalSelection, Events_InfoMessage& theError) const; }; diff --git a/src/GeomValidators/GeomValidators_ZeroOffset.cpp b/src/GeomValidators/GeomValidators_ZeroOffset.cpp index 4a919d0c4..d6181783f 100644 --- a/src/GeomValidators/GeomValidators_ZeroOffset.cpp +++ b/src/GeomValidators/GeomValidators_ZeroOffset.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -131,6 +132,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aToShape.get() == NULL && anAttrSel->context().get() != NULL) { aToShape = anAttrSel->context()->shape(); } + if (aToShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aToShape); + aToShape = anIt.current(); + } } anIt++; @@ -146,6 +151,10 @@ bool GeomValidators_ZeroOffset::isValid(const std::shared_ptr& if(aFromShape.get() == NULL && anAttrSel->context().get() != NULL) { aFromShape = anAttrSel->context()->shape(); } + if (aFromShape->isCompound()) { + GeomAPI_ShapeIterator anIt(aFromShape); + aFromShape = anIt.current(); + } } anIt++; diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 33ec73c00..a5138d2fa 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -55,7 +55,6 @@ SET(PROJECT_HEADERS Model_ResultParameter.h Model_FeatureValidator.h Model_AttributeValidator.h - Model_SelectionNaming.h ) SET(PROJECT_SOURCES @@ -92,13 +91,13 @@ SET(PROJECT_SOURCES Model_ResultParameter.cpp Model_FeatureValidator.cpp Model_AttributeValidator.cpp - Model_SelectionNaming.cpp ) SET(PROJECT_LIBRARIES ModelAPI Events Config + Selector GeomData GeomAPI GeomAlgoAPI @@ -109,6 +108,7 @@ SET(PROJECT_INCLUDES ../ModelAPI ../Events ../Config + ../Selector ../GeomData ../GeomDataAPI ../GeomAlgoAPI diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 4d77a91f7..e6564b60a 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -44,6 +44,12 @@ void Model_AttributeRefList::append(ObjectPtr theObject) myExtDocRef->Append(anEntry); } else return; // something is wrong + if (myHashUsed) { + myHashObjects.insert(theObject); + myHashIndex[myRef->Extent() - 1] = theObject; + myHashIndexNoEmpty[int(myHashIndexNoEmpty.size())] = theObject; + } + // do it before the transaction finish to make just created/removed objects know dependencies // and reference from composite feature is removed automatically ADD_BACK_REF(theObject); @@ -52,6 +58,7 @@ void Model_AttributeRefList::append(ObjectPtr theObject) void Model_AttributeRefList::remove(ObjectPtr theObject) { + eraseHash(); if (theObject.get() != NULL) { if (owner()->document() == theObject->document()) { std::shared_ptr aData; @@ -79,7 +86,7 @@ void Model_AttributeRefList::remove(ObjectPtr theObject) if (anExtIter.Value() == anIdString.str().c_str()) { TDataStd_ListIteratorOfListOfExtendedString anExtIter2 = anExtIter; anExtIter2.Next(); - if (anExtIter2.Value() == anEntry) { // fully maches, so, remove(don't copy) + if (anExtIter2.Value() == anEntry) { // fully matches, so, remove(don't copy) aFound = true; continue; } @@ -124,6 +131,7 @@ void Model_AttributeRefList::clear() REMOVE_BACK_REF((*anOldIter)); } myExtDocRef->Clear(); + eraseHash(); owner()->data()->sendAttributeUpdated(this); } @@ -131,6 +139,10 @@ int Model_AttributeRefList::size(const bool theWithEmpty) const { if (theWithEmpty) return myRef->Extent(); + + if (myHashUsed) + return int(myHashIndexNoEmpty.size()); + int aResult = 0; const TDF_LabelList& aList = myRef->List(); for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { @@ -177,15 +189,11 @@ ObjectPtr Model_AttributeRefList::iteratedObject(TDF_ListIteratorOfLabelList& th std::list Model_AttributeRefList::list() { + createHash(); std::list aResult; - std::shared_ptr aDoc = std::dynamic_pointer_cast( - owner()->document()); - if (aDoc) { - const TDF_LabelList& aList = myRef->List(); - TDataStd_ListIteratorOfListOfExtendedString anExtIter(myExtDocRef->List()); - for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { - aResult.push_back(iteratedObject(aLIter, anExtIter, aDoc)); - } + std::map::iterator aHashIter = myHashIndex.begin(); + for(; aHashIter != myHashIndex.end(); aHashIter++) { + aResult.push_back(aHashIter->second); } return aResult; } @@ -195,65 +203,24 @@ bool Model_AttributeRefList::isInList(const ObjectPtr& theObj) if(!theObj.get()) { return false; } - if (theObj->document() == owner()->document()) { // this document object - std::shared_ptr aDoc = std::dynamic_pointer_cast( - owner()->document()); - if (aDoc) { - std::shared_ptr aData = std::dynamic_pointer_cast(theObj->data()); - if (aData.get() && aData->isValid()) { - TDF_Label anObjLab = aData->label().Father(); - const TDF_LabelList& aList = myRef->List(); - for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { - if (aLIter.Value().IsEqual(anObjLab)) { - return true; - } - } - } - } - } else { // external document object - // create new lists because for the current moment remove one of the duplicated elements - // from the list is buggy - std::ostringstream anIdString; // string with document Id - anIdString<document()->id(); - std::shared_ptr aData = std::dynamic_pointer_cast(theObj->data()); - TCollection_AsciiString anEntry; - TDF_Tool::Entry(aData->label().Father(), anEntry); - bool aFound = false; - TDataStd_ListIteratorOfListOfExtendedString anExtIter(myExtDocRef->List()); - for (; anExtIter.More(); anExtIter.Next()) { - if (anExtIter.Value() == anIdString.str().c_str()) { - anExtIter.Next(); - if (anExtIter.Value() == anEntry) { // fully maches - return true; - } - } else { - anExtIter.Next(); - } - } - } - return false; + createHash(); + return myHashObjects.count(theObj) != 0; } -ObjectPtr Model_AttributeRefList::object(const int theIndex, const bool theWithEmpty) const +ObjectPtr Model_AttributeRefList::object(const int theIndex, const bool theWithEmpty) { - std::shared_ptr aDoc = - std::dynamic_pointer_cast(owner()->document()); - if (aDoc) { - int anIndex = -1; - TDataStd_ListIteratorOfListOfExtendedString anExtIter(myExtDocRef->List()); - for (TDF_ListIteratorOfLabelList aLIter(myRef->List()); aLIter.More(); aLIter.Next()) { - if (theWithEmpty || (!aLIter.Value().IsNull() && !aLIter.Value().IsRoot())) - anIndex++; - if (anIndex == theIndex) { - return iteratedObject(aLIter, anExtIter, aDoc); - } - if (aLIter.Value() == myRef->Label()) { - anExtIter.Next(); - anExtIter.Next(); - } - } + createHash(); + std::map::iterator aFind; + if (theWithEmpty) { + aFind = myHashIndex.find(theIndex); + if (aFind == myHashIndex.end()) + return ObjectPtr(); + } else { + aFind = myHashIndexNoEmpty.find(theIndex); + if (aFind == myHashIndexNoEmpty.end()) + return ObjectPtr(); } - return ObjectPtr(); + return aFind->second; } void Model_AttributeRefList::substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) @@ -273,6 +240,7 @@ void Model_AttributeRefList::substitute(const ObjectPtr& theCurrent, const Objec aNewLab = aCurrentLab.Root(); // root means null object } // do the substitution + eraseHash(); ADD_BACK_REF(theNew); if (myRef->InsertAfter(aNewLab, aCurrentLab)) { myRef->Remove(aCurrentLab); @@ -295,6 +263,7 @@ void Model_AttributeRefList::exchange(const ObjectPtr& theObject1, const ObjectP std::shared_ptr aData2 = std::dynamic_pointer_cast(theObject2->data()); if (aData2.get() && aData2->isValid()) { + eraseHash(); TDF_Label aLab2 = aData2->label().Father(); // do the substitution: use the temporary label, as usually in exchange TDF_Label aTmpLab = aLab1.Root(); @@ -321,6 +290,7 @@ void Model_AttributeRefList::removeLast() if (aDoc && !myRef->IsEmpty()) { ObjectPtr anObj = aDoc->objects()->object(myRef->Last()); if (anObj.get()) { + eraseHash(); myRef->Remove(myRef->Last()); REMOVE_BACK_REF(anObj); owner()->data()->sendAttributeUpdated(this); @@ -333,7 +303,7 @@ void Model_AttributeRefList::remove(const std::set& theIndices) std::shared_ptr aDoc = std::dynamic_pointer_cast( owner()->document()); if (aDoc && !myRef->IsEmpty()) { - // collet labels that will be removed + // collect labels that will be removed TDF_LabelList aLabelsToRemove; TDF_ListIteratorOfLabelList aLabIter(myRef->List()); for(int aCurrent = 0; aLabIter.More(); aLabIter.Next(), aCurrent++) { @@ -349,6 +319,7 @@ void Model_AttributeRefList::remove(const std::set& theIndices) } } if (!aLabelsToRemove.IsEmpty()) { + eraseHash(); owner()->data()->sendAttributeUpdated(this); } } @@ -369,4 +340,37 @@ void Model_AttributeRefList::reinit() if (!myLab.FindAttribute(TDataStd_ExtStringList::GetID(), myExtDocRef)) { myExtDocRef = TDataStd_ExtStringList::Set(myLab); } + eraseHash(); +} + +void Model_AttributeRefList::createHash() +{ + if (myHashUsed) + return; + eraseHash(); + std::shared_ptr aDoc = std::dynamic_pointer_cast( + owner()->document()); + if (aDoc) { + const TDF_LabelList& aList = myRef->List(); + TDataStd_ListIteratorOfListOfExtendedString anExtIter(myExtDocRef->List()); + for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { + ObjectPtr anObj = iteratedObject(aLIter, anExtIter, aDoc); + myHashIndex[int(myHashIndex.size())] = anObj; + if (anObj.get()) { + myHashIndexNoEmpty[int(myHashIndexNoEmpty.size())] = anObj; + myHashObjects.insert(anObj); + } + } + if (!myHashObjects.empty()) // on open document with multi-rotation referenced have no results + myHashUsed = true; + } +} + + +void Model_AttributeRefList::eraseHash() +{ + myHashObjects.clear(); + myHashIndex.clear(); + myHashIndexNoEmpty.clear(); + myHashUsed = false; } diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 1964c7d58..da674ff49 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -37,11 +37,16 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList { TDF_Label myLab; ///< the main label of this attribute + Handle_TDataStd_ReferenceList myRef; ///< references to the features labels /// pairs of doc ID and entries if reference is to external object, appends some in this list if /// something in myRef is empty Handle_TDataStd_ExtStringList myExtDocRef; - public: + bool myHashUsed; ///< true if the hash stored is valid + std::set myHashObjects; ///< hashed information: objects existing in the list + std::map myHashIndex; ///< index to object in the list + std::map myHashIndexNoEmpty; ///< index to not empty object in the list +public: /// Appends the feature to the end of a list MODEL_EXPORT virtual void append(ObjectPtr theObject); @@ -64,7 +69,7 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList /// Returns the list of features ///\param theIndex zero-based index in the list ///\param theWithEmpty if it is false, counts the not-empty referenced objects only - MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const; + MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true); /// Substitutes the feature by another one. Does nothing if such object is not found. /// Does not support the external documents objects yet. @@ -94,6 +99,10 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter, TDataStd_ListIteratorOfListOfExtendedString& theExtIter, std::shared_ptr theDoc) const; + /// Creates the hash-objects containers (does nothing if hash is already correct) + void createHash(); + /// Erases the hashed objects caused by complicated modifications in the list + void eraseHash(); friend class Model_Data; }; diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 7b1259db3..1db965d23 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -23,7 +23,6 @@ #include "Model_Events.h" #include "Model_Data.h" #include "Model_Document.h" -#include "Model_SelectionNaming.h" #include #include #include @@ -40,15 +39,18 @@ #include #include #include +#include #include +#include #include #include +#include -#include #include #include #include #include +#include #include #include #include @@ -59,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -88,10 +91,6 @@ Standard_GUID kCIRCLE_CENTER("d0d0e0f1-217a-4b95-8fbb-0c4132f23718"); Standard_GUID kELLIPSE_CENTER1("f70df04c-3168-4dc9-87a4-f1f840c1275d"); // identifier of the selection of the second focus point of ellipse on edge Standard_GUID kELLIPSE_CENTER2("1395ae73-8e02-4cf8-b204-06ff35873a32"); -// identifier of the weak naming index -Standard_GUID kWEAK_NAMING("9dcdd9be-a3a9-46eb-9b16-1c957ab20142"); -// identifier of the weak naming sub-shape type -Standard_GUID kWEAK_NAMING_SHAPETYPE("6b9cc709-e320-4a1f-9c42-df5622369ea7"); // prefix for the whole feature context identification const static std::string kWHOLE_FEATURE = "all-in-"; @@ -131,15 +130,13 @@ bool Model_AttributeSelection::setValue(const ObjectPtr& theContext, myRef.setValue(theContext); } - // do noth use naming if selected shape is result shape itself, but not sub-shape + // do not use naming if selected shape is result shape itself, but not sub-shape TDF_Label aSelLab = selectionLabel(); aSelLab.ForgetAttribute(kSIMPLE_REF_ID); aSelLab.ForgetAttribute(kINVALID_SELECTION); aSelLab.ForgetAttribute(kCIRCLE_CENTER); aSelLab.ForgetAttribute(kELLIPSE_CENTER1); aSelLab.ForgetAttribute(kELLIPSE_CENTER2); - aSelLab.ForgetAttribute(kWEAK_NAMING); - aSelLab.ForgetAttribute(kWEAK_NAMING_SHAPETYPE); bool isDegeneratedEdge = false; // do not use the degenerated edge as a shape, a null context and shape is used in the case @@ -157,34 +154,30 @@ bool Model_AttributeSelection::setValue(const ObjectPtr& theContext, owner()->data()->blockSendAttributeUpdated(false); return false; } - if (theContext->groupName() == ModelAPI_ResultBody::group()) { - ResultBodyPtr aContextBody = std::dynamic_pointer_cast(theContext); + bool isSelectBody = theContext->groupName() == ModelAPI_ResultBody::group(); + if (!isSelectBody) { + ResultConstructionPtr aContextConstruction = + std::dynamic_pointer_cast(theContext); + isSelectBody = aContextConstruction.get() && !aContextConstruction->isInfinite(); + } + if (isSelectBody) { + ResultPtr aContextResult = std::dynamic_pointer_cast(theContext); + GeomShapePtr aContextShape = aContextResult->shape(); // do not select the whole shape for body:it is already must be in the data framework // equal and null selected objects mean the same: object is equal to context, - if (aContextBody->shape().get() && - (aContextBody->shape()->isEqual(theSubShape) || !theSubShape.get())) { + if (aContextShape.get() && (aContextShape->isEqual(theSubShape) || !theSubShape.get())) { aSelLab.ForgetAllAttributes(true); TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID); } else { - selectBody(aContextBody, theSubShape); + selectBody(aContextResult, theSubShape); } } else if (theContext->groupName() == ModelAPI_ResultConstruction::group()) { - ResultConstructionPtr aContextConstruction = - std::dynamic_pointer_cast(theContext); aSelLab.ForgetAllAttributes(true); // to remove old selection data std::shared_ptr aConstruction = std::dynamic_pointer_cast(theContext); std::shared_ptr aSubShape; - if (theSubShape.get() && !aContextConstruction->shape()->isEqual(theSubShape)) + if (theSubShape.get() && !aConstruction->shape()->isEqual(theSubShape)) aSubShape = theSubShape; // the whole context - if (aConstruction->isInfinite()) { - // For correct naming selection, put the shape into the naming structure. - // It seems sub-shapes are not needed: only this shape is (and can be ) selected. - TNaming_Builder aBuilder(aSelLab); - aBuilder.Generated(aContextConstruction->shape()->impl()); - } - int anIndex = aConstruction->select(theSubShape, owner()->document()); - TDataStd_Integer::Set(aSelLab, anIndex); } else if (theContext->groupName() == ModelAPI_ResultPart::group()) { aSelLab.ForgetAllAttributes(true); TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID); @@ -339,8 +332,8 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp if (myRef.isInitialized()) { if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape ResultPtr aContext = context(); - if (!aContext.get()) - return aResult; // empty result + if (!aContext.get() || aContext->groupName() == ModelAPI_ResultConstruction::group()) + return aResult; // empty result, for whole construction selection also return aContext->shape(); } if (aSelLab.IsAttribute(kPART_REF_ID)) { @@ -389,30 +382,10 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp } return GeomAlgoAPI_CompoundBuilder::compound(allShapes); } - } - - if (aSelLab.IsAttribute(kWEAK_NAMING)) { // a weak naming is used - Handle(TDataStd_Integer) aWeakId; - aSelLab.FindAttribute(kWEAK_NAMING, aWeakId); - // get the context shape - GeomShapePtr aContextShape; - ResultBodyPtr aBody = std::dynamic_pointer_cast(context()); - if (aBody.get()) { - aContextShape = aBody->shape(); - } else { - ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); - if (aResult) { - aContextShape = aResult->shape(); - } + } else { + if (contextFeature().get()) { + return aResult; // for the whole sketch feature selected return null => all faces } - if (!aContextShape.get()) - return GeomShapePtr(); - Handle(TDataStd_Integer) aWeakShapeType; - aSelLab.FindAttribute(kWEAK_NAMING_SHAPETYPE, aWeakShapeType); - GeomAlgoAPI_NExplode aNExplode( - aContextShape, GeomAPI_Shape::ShapeType(aWeakShapeType->Get())); - GeomShapePtr aValue = aNExplode.shape(aWeakId->Get()); - return aValue; } Handle(TNaming_NamedShape) aSelection; @@ -421,12 +394,7 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp aResult = std::shared_ptr(new GeomAPI_Shape); aResult->setImpl(new TopoDS_Shape(aSelShape)); } else if (aConstr) { // simple construction element: just shape of this construction element - Handle(TDataStd_Integer) anIndex; - if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) { - if (anIndex->Get() == 0) // it is just reference to construction, nothing is in value - return aResult; - return aConstr->shape(anIndex->Get(), owner()->document()); - } + aResult = aConstr->shape(); } } return aResult; @@ -454,11 +422,7 @@ bool Model_AttributeSelection::isInitialized() std::shared_ptr aConstr = std::dynamic_pointer_cast(context()); if (aConstr.get()) { - Handle(TDataStd_Integer) anIndex; - if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) { - // for the whole shape it may return null, so, if index exists, returns true return true; - } } // for the whole feature, a feature object FeaturePtr aFeat = contextFeature(); @@ -471,7 +435,8 @@ bool Model_AttributeSelection::isInitialized() } Model_AttributeSelection::Model_AttributeSelection(TDF_Label& theLabel) - : myRef(theLabel) +: myRef(theLabel), + myIsGeometricalSelection(false) { myIsInitialized = myRef.isInitialized(); myParent = NULL; @@ -481,6 +446,13 @@ void Model_AttributeSelection::setID(const std::string theID) { myRef.setID(theID); ModelAPI_AttributeSelection::setID(theID); + FeaturePtr aFeature = std::dynamic_pointer_cast(owner()); + if (myParent) { + myIsGeometricalSelection = true;//myParent->isGeometricalSelection(); + } else { + myIsGeometricalSelection = + ModelAPI_Session::get()->validators()->isGeometricalSelection(aFeature->getKind(), id()); + } } ResultPtr Model_AttributeSelection::context() @@ -502,7 +474,7 @@ ResultPtr Model_AttributeSelection::context() if(aPart.get() && aPart->data() == aResult->data()) { ResultPtr aPartResult = std::dynamic_pointer_cast(aPart); FeaturePtr anOwnerFeature = std::dynamic_pointer_cast(owner()); - // check that this result is not this-feature result (it is forbidden t oselect itself) + // check that this result is not this-feature result (it is forbidden to select itself) if(anOwnerFeature.get() && anOwnerFeature->firstResult() != aPartResult) { return aPartResult; } @@ -538,69 +510,6 @@ void Model_AttributeSelection::setObject(const std::shared_ptr& myRef.setObject(theObject); } -TDF_LabelMap& Model_AttributeSelection::scope() -{ - if (myScope.IsEmpty()) { // create a new scope if not yet done - // gets all features with named shapes that are before this feature label (before in history) - DocumentPtr aMyDoc = owner()->document(); - std::list > allFeatures = aMyDoc->allFeatures(); - std::list >::iterator aFIter = allFeatures.begin(); - bool aMePassed = false; - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(owner()); - FeaturePtr aFeature = std::dynamic_pointer_cast(owner()); - CompositeFeaturePtr aCompositeOwner, aCompositeOwnerOwner; - if (aFeature.get()) { - aCompositeOwner = ModelAPI_Tools::compositeOwner(aFeature); - if (aCompositeOwner.get()) { - aCompositeOwnerOwner = ModelAPI_Tools::compositeOwner(aCompositeOwner); - } - } - // for group Scope is not limitet: this is always up to date objects - // this causes problem in galeries.py - //bool isGroup = aFeature.get() && aFeature->getKind() == "Group"; - for(; aFIter != allFeatures.end(); aFIter++) { - if (*aFIter == owner()) { // the left features are created later (except subs of composite) - aMePassed = true; - continue; - } - //if (isGroup) aMePassed = false; - bool isInScope = !aMePassed; - if (!isInScope && aComposite.get()) { - // try to add sub-elements of composite if this is composite - if (aComposite->isSub(*aFIter)) - isInScope = true; - } - // remove the composite-owner of this feature (sketch in extrusion-cut) - if (isInScope && (aCompositeOwner == *aFIter || aCompositeOwnerOwner == *aFIter)) - isInScope = false; - - if (isInScope && aFIter->get() && (*aFIter)->data()->isValid()) { - TDF_Label aFeatureLab = std::dynamic_pointer_cast( - (*aFIter)->data())->label().Father(); - TDF_ChildIDIterator aNSIter(aFeatureLab, TNaming_NamedShape::GetID(), true); - for(; aNSIter.More(); aNSIter.Next()) { - Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value()); - if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) { - myScope.Add(aNS->Label()); - } - } - } - } - // also add all naming labels created for external constructions - std::shared_ptr aDoc = std::dynamic_pointer_cast(aMyDoc); - TDF_Label anExtDocLab = aDoc->extConstructionsLabel(); - TDF_ChildIDIterator aNSIter(anExtDocLab, TNaming_NamedShape::GetID(), true); - for(; aNSIter.More(); aNSIter.Next()) { - Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value()); - if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) { - myScope.Add(aNS->Label()); - } - } - } - return myScope; -} - /// Sets the invalid flag if flag is false, or removes it if "true" /// Returns theFlag static bool setInvalidIfFalse(TDF_Label& theLab, const bool theFlag) { @@ -642,6 +551,7 @@ bool Model_AttributeSelection::update() { FeaturePtr aContextFeature = contextFeature(); if (aContextFeature.get()) { + owner()->data()->sendAttributeUpdated(this); // send updated if "update" called in any way return true; } TDF_Label aSelLab = selectionLabel(); @@ -663,46 +573,25 @@ bool Model_AttributeSelection::update() } if (aContext->groupName() == ModelAPI_ResultBody::group()) { - if (aSelLab.IsAttribute(kWEAK_NAMING)) { // a weak naming is used - Handle(TDataStd_Integer) aWeakId; - aSelLab.FindAttribute(kWEAK_NAMING, aWeakId); - // get the context shape - GeomShapePtr aContextShape; - ResultBodyPtr aBody = std::dynamic_pointer_cast(aContext); - if (aBody.get()) { - aContextShape = aBody->shape(); - } else { - ResultPtr aResult = std::dynamic_pointer_cast(myRef.value()); - if (aResult) { - aContextShape = aResult->shape(); - } - } - if (!setInvalidIfFalse(aSelLab, aContextShape.get() != NULL)) // context shape not found - return false; - Handle(TDataStd_Integer) aWeakShapeType; - aSelLab.FindAttribute(kWEAK_NAMING_SHAPETYPE, aWeakShapeType); - GeomAlgoAPI_NExplode aNExplode( - aContextShape, GeomAPI_Shape::ShapeType(aWeakShapeType->Get())); - GeomShapePtr aValue = aNExplode.shape(aWeakId->Get()); - return setInvalidIfFalse(aSelLab, aValue.get() != NULL); - } - // body: just a named shape, use selection mechanism from OCCT - TNaming_Selector aSelector(aSelLab); + // body: just a named shape, use topological selection mechanism + bool aResult = false; TopoDS_Shape anOldShape; - if (!aSelector.NamedShape().IsNull()) { - anOldShape = aSelector.NamedShape()->Get(); - } - bool aResult = aSelector.Solve(scope()) == Standard_True; - // must be before sending of updated attribute (1556) - aResult = setInvalidIfFalse(aSelLab, aResult); + Handle(TNaming_NamedShape) aNS; + if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + anOldShape = aNS->Get(); + + TopoDS_Shape aContextShape = aContext->shape()->impl(); + Selector_Selector aSelector(aSelLab, baseDocumentLab()); + aResult = aSelector.restore(aContextShape); + setInvalidIfFalse(aSelLab, aResult); + TopoDS_Shape aNewShape; - if (!aSelector.NamedShape().IsNull()) { - aNewShape = aSelector.NamedShape()->Get(); - } - if (anOldShape.IsNull() || aNewShape.IsNull() || - !anOldShape.IsEqual(aSelector.NamedShape()->Get())) { - // shape type shoud not not changed: if shape becomes compound of such shapes, then split - if (myParent && !anOldShape.IsNull() && !aNewShape.IsNull() && + if (aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + aNewShape = aNS->Get(); + + if (anOldShape.IsNull() || aNewShape.IsNull() || !anOldShape.IsEqual(aNewShape)) { + // shape type should not be changed: if shape becomes compound of such shapes, then split + if (!myIsGeometricalSelection && myParent && !anOldShape.IsNull() && !aNewShape.IsNull() && anOldShape.ShapeType() != aNewShape.ShapeType() && (aNewShape.ShapeType() == TopAbs_COMPOUND || aNewShape.ShapeType() == TopAbs_COMPSOLID)) { @@ -714,22 +603,21 @@ bool Model_AttributeSelection::update() } if (aContext->groupName() == ModelAPI_ResultConstruction::group()) { - Handle(TDataStd_Integer) anIndex; - if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) { - std::shared_ptr aConstructionContext = - std::dynamic_pointer_cast(aContext); - bool aModified = true; - bool aValid = aConstructionContext->update(anIndex->Get(), owner()->document(), aModified); - setInvalidIfFalse(aSelLab, aValid); - if (aConstructionContext->isInfinite()) { - // Update the selected shape. - TNaming_Builder aBuilder(aSelLab); - aBuilder.Generated(aConstructionContext->shape()->impl()); - } - if (aModified) - owner()->data()->sendAttributeUpdated(this); - return aValid; + bool aResult = true; + std::shared_ptr aConstructionContext = + std::dynamic_pointer_cast(aContext); + if (!aConstructionContext->isInfinite()) { + TopoDS_Shape aContextShape = aContext->shape()->impl(); + Selector_Selector aSelector(aSelLab, baseDocumentLab()); + TopoDS_Shape anOldShape = aSelector.value(); + aResult = aSelector.restore(aContextShape); + setInvalidIfFalse(aSelLab, aResult); + if (aResult && !anOldShape.IsEqual(aSelector.value())) + owner()->data()->sendAttributeUpdated(this); // send updated if shape is changed + } else { + owner()->data()->sendAttributeUpdated(this); // send updated if "update" called in any way } + return aResult; } return setInvalidIfFalse(aSelLab, false); // unknown case } @@ -738,10 +626,9 @@ void Model_AttributeSelection::selectBody( const ResultPtr& theContext, const std::shared_ptr& theSubShape) { // perform the selection - TNaming_Selector aSel(selectionLabel()); TopoDS_Shape aContext; - ResultBodyPtr aBody = std::dynamic_pointer_cast(theContext);//myRef.value() + ResultPtr aBody = std::dynamic_pointer_cast(theContext); if (aBody) { aContext = aBody->shape()->impl(); } else { @@ -755,116 +642,25 @@ void Model_AttributeSelection::selectBody( } } - // with "recover" feature the selected context may be not up to date (issue 1710) - Handle(TNaming_NamedShape) aResult; - TDF_Label aSelLab = selectionLabel(); - TopoDS_Shape aNewContext = aContext; - bool isUpdated = true; - while(!aNewContext.IsNull() && isUpdated) { - // searching for the very last shape that was produced from this one - isUpdated = false; - if (!TNaming_Tool::HasLabel(aSelLab, aNewContext)) - // to avoid crash of TNaming_SameShapeIterator if pure shape does not exists - break; - for(TNaming_SameShapeIterator anIter(aNewContext, aSelLab); anIter.More(); anIter.Next()) { - TDF_Label aNSLab = anIter.Label(); - if (!scope().Contains(aNSLab)) - continue; - Handle(TNaming_NamedShape) aNS; - if (aNSLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - for(TNaming_Iterator aShapesIter(aNS); aShapesIter.More(); aShapesIter.Next()) { - if (aShapesIter.Evolution() == TNaming_SELECTED) - continue; // don't use the selection evolution - if (!aShapesIter.OldShape().IsNull() && aShapesIter.OldShape().IsSame(aNewContext)) { - // found the original shape - aNewContext = aShapesIter.NewShape(); // go to the newer shape - isUpdated = true; - break; - } - } - } - } - } - if (aNewContext.IsNull()) { // a context is already deleted - setInvalidIfFalse(aSelLab, false); - Events_InfoMessage("Model_AttributeSelection", "Failed to select shape already deleted").send(); - return; - } - - TopoDS_Shape aNewSub = theSubShape ? theSubShape->impl() : aContext; - if (!aNewSub.IsEqual(aContext)) { // searching for subshape in the new context - bool isFound = false; - TopExp_Explorer anExp(aNewContext, aNewSub.ShapeType()); - for(; anExp.More(); anExp.Next()) { - if (anExp.Current().IsSame(aNewSub)) { - isFound = true; - break; - } - } - if (!isFound) { // sub-shape is not found in the up-to-date instance of the context shape - // if context is sub-result of compound/compsolid, selection of sub-shape better propagate to - // the main result (which is may be modified); the case is in 1799 - ResultBodyPtr aMain = ModelAPI_Tools::bodyOwner(theContext); - while(ModelAPI_Tools::bodyOwner(aMain).get()) - aMain = ModelAPI_Tools::bodyOwner(theContext); - if (aMain.get()) { - selectBody(aMain, theSubShape); - return; - } - setInvalidIfFalse(aSelLab, false); - Events_InfoMessage("Model_AttributeSelection", - "Failed to select sub-shape already modified").send(); - return; - } - } - - /// fix for issue 411: result modified shapes must not participate in this selection mechanism if (!aContext.IsNull()) { - FeaturePtr aFeatureOwner = std::dynamic_pointer_cast(owner()); - bool aEraseResults = false; - if (aFeatureOwner.get()) { - aEraseResults = !aFeatureOwner->results().empty(); - if (aEraseResults) // erase results without flash deleted and redisplay: do it after Select - aFeatureOwner->removeResults(0, false, false); - } + TDF_Label aSelLab = selectionLabel(); + TopoDS_Shape aNewSub = theSubShape->impl(); + bool aSelectorOk = true; + Selector_Selector aSelector(aSelLab, baseDocumentLab()); try { - aSel.Select(aNewSub, aNewContext); + aSelectorOk = aSelector.select(aContext, aNewSub, myIsGeometricalSelection); + if (aSelectorOk) { + aSelectorOk = aSelector.store(aContext); + } } catch(...) { aSelectorOk = false; } - // face may become divided after the model update, so, new labels may be added to the scope - myScope.Clear(); - - // check that selection is correct, otherwise use weak naming solution - TDF_Label aSelLab = selectionLabel(); - aSelLab.ForgetAttribute(kWEAK_NAMING); - Handle(TNaming_NamedShape) aSelectorShape; - if (aSelectorOk && aSelLab.FindAttribute(TNaming_NamedShape::GetID(), aSelectorShape)) - { - TopoDS_Shape aShape = aSelectorShape->Get(); - if (aShape.IsNull() || aShape.ShapeType() != aNewSub.ShapeType()) - aSelectorOk = false; - } - if (!aSelectorOk) { // weak naming identifier instead - GeomShapePtr aContextShape(new GeomAPI_Shape); - aContextShape->setImpl(new TopoDS_Shape(aNewContext)); - GeomShapePtr aValueShape(new GeomAPI_Shape); - aValueShape->setImpl(new TopoDS_Shape(aNewSub)); - - GeomAlgoAPI_NExplode aNExplode(aContextShape, aValueShape->shapeType()); - int anId = aNExplode.index(aValueShape); - if (anId) { - TDataStd_Integer::Set(aSelLab, kWEAK_NAMING, anId); - TDataStd_Integer::Set(aSelLab, kWEAK_NAMING_SHAPETYPE, int(aValueShape->shapeType())); - } - } - - if (aEraseResults) { // flash after Select : in Groups it makes selection with shift working - static Events_Loop* aLoop = Events_Loop::loop(); - static const Events_ID kDeletedEvent = aLoop->eventByName(EVENT_OBJECT_DELETED); - aLoop->flush(kDeletedEvent); + if (aSelectorOk) { + TopoDS_Shape aShape = aSelector.value(); + aSelectorOk = !aShape.IsNull() && aShape.ShapeType() == aNewSub.ShapeType(); } + setInvalidIfFalse(aSelLab, aSelectorOk); } } @@ -947,16 +743,34 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa } TDF_Label aSelLab = selectionLabel(); - Handle(TDataStd_Integer) aWeakId; - if (aSelLab.FindAttribute(kWEAK_NAMING, aWeakId)) { // a weak naming is used - std::ostringstream aNameStream; - aNameStream<data()->name()<<"/weak_name_"<Get(); - return aNameStream.str(); + if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // whole context, no value + return contextName(aCont); + } + + // if it is in result of another part + if (aCont->groupName() == ModelAPI_ResultPart::group()) { + ResultPartPtr aPart = std::dynamic_pointer_cast(aCont); + int anIndex; + GeomShapePtr aValue = value(); + if (aValue.get()) + return aPart->data()->name() + "/" + aPart->nameInPart(aValue, anIndex); + else + return aPart->data()->name(); + } + + + // whole infinitive construction + if (aCont->groupName() == ModelAPI_ResultConstruction::group()) { + ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aCont); + if (aConstr->isInfinite()) { + return contextName(aCont); + } } - Model_SelectionNaming aSelNaming(aSelLab); - std::string aResult = aSelNaming.namingName( - aCont, aSubSh, theDefaultName, owner()->document() != aCont->document()); + Selector_Selector aSelector(aSelLab, baseDocumentLab()); + std::string aResult; + if (aCont->shape().get() && aSelector.restore(aCont->shape()->impl())) + aResult = aSelector.name(this); if (aCenterType != NOT_CENTER) { aResult += centersMap()[aCenterType]; } @@ -989,172 +803,116 @@ void Model_AttributeSelection::selectSubShape( CenterType aCenterType = theType[0] == 'v' || theType[0] == 'V' ? // only for vertex-type centerTypeByName(aSubShapeName) : NOT_CENTER; std::string aType = aCenterType == NOT_CENTER ? theType : "EDGE"; // search for edge now + static const GeomShapePtr anEmptyShape; // first iteration is selection by name without center prefix, second - in case of problem, // try with initial name - for(int aUseCenter = 1; aUseCenter >= 0; aUseCenter--) { + for(int aUseCenter = 1; aUseCenter >= 0; aUseCenter--) { if (aUseCenter == 0 && aCenterType != NOT_CENTER) { aSubShapeName = theSubShapeName; aCenterType = NOT_CENTER; aType = theType; } else if (aUseCenter != 1) continue; + TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(GeomAPI_Shape::shapeTypeByStr(aType)); + std::shared_ptr aDoc = + std::dynamic_pointer_cast(owner()->document()); // check this is Part-name: 2 delimiters in the name std::size_t aPartEnd = aSubShapeName.find('/'); - if (aPartEnd != std::string::npos && aPartEnd != aSubShapeName.rfind('/')) { + if (aPartEnd != std::string::npos) { std::string aPartName = aSubShapeName.substr(0, aPartEnd); - ObjectPtr aFound = owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName); - if (aFound.get()) { // found such part, so asking it for the name - ResultPartPtr aPart = std::dynamic_pointer_cast(aFound); - std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1); - int anIndex; - std::shared_ptr aSelected = aPart->shapeInPart(aNameInPart, aType, anIndex); - if (aSelected.get()) { - if (aCenterType != NOT_CENTER) { - if (!aSelected->isEdge()) - continue; - std::shared_ptr aSelectedEdge(new GeomAPI_Edge(aSelected)); - setValueCenter(aPart, aSelectedEdge, aCenterType); - } else - setValue(aPart, aSelected); - TDataStd_Integer::Set(selectionLabel(), anIndex); - return; + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); + if (aPartName == aRootDoc->kind()) { + aDoc = std::dynamic_pointer_cast(aRootDoc); + aSubShapeName = aSubShapeName.substr(aPartEnd + 1); + } else { + ObjectPtr aFound = + owner()->document()->objectByName(ModelAPI_ResultPart::group(), aPartName); + if (aFound.get()) { // found such part, so asking it for the name + ResultPartPtr aPart = std::dynamic_pointer_cast(aFound); + std::string aNameInPart = aSubShapeName.substr(aPartEnd + 1); + if (aNameInPart.empty()) { // whole part + setValue(aPart, anEmptyShape); + return; + } + int anIndex; + std::shared_ptr aSelected = + aPart->shapeInPart(aNameInPart, aType, anIndex); + if (aSelected.get()) { + if (aCenterType != NOT_CENTER) { + if (!aSelected->isEdge()) + continue; + std::shared_ptr aSelectedEdge(new GeomAPI_Edge(aSelected)); + setValueCenter(aPart, aSelectedEdge, aCenterType); + } else + setValue(aPart, aSelected); + TDataStd_Integer::Set(selectionLabel(), anIndex); + return; + } } } } - std::shared_ptr aDoc = - std::dynamic_pointer_cast(owner()->document()); // check this is a whole feature context if (aSubShapeName.size() > kWHOLE_FEATURE.size() && aSubShapeName.substr(0, kWHOLE_FEATURE.size()) == kWHOLE_FEATURE) { std::string aFeatureName = aSubShapeName.substr(kWHOLE_FEATURE.size()); ObjectPtr anObj = aDoc->objectByName(ModelAPI_Feature::group(), aFeatureName); if (anObj.get()) { - static const GeomShapePtr anEmptyShape; setValue(anObj, anEmptyShape); return; } } - Model_SelectionNaming aSelNaming(selectionLabel()); - std::shared_ptr aShapeToBeSelected; - ResultPtr aCont; - if (aSelNaming.selectSubShape(aType, aSubShapeName, aDoc, aShapeToBeSelected, aCont)) { - // try to find the last context to find the up to date shape - if (aCont->shape().get() && !aCont->shape()->isNull() && - aCont->groupName() == ModelAPI_ResultBody::group() && aDoc == owner()->document()) { - const TopoDS_Shape aConShape = aCont->shape()->impl(); - if (!aConShape.IsNull()) { - Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aConShape, selectionLabel()); - if (!aNS.IsNull()) { - aNS = TNaming_Tool::CurrentNamedShape(aNS); - if (!aNS.IsNull() && scope().Contains(aNS->Label())) { // scope check is for 2228 - TDF_Label aLab = aNS->Label(); - if (aLab.Depth() % 2 == 0) - aLab = aLab.Father(); - ObjectPtr anObj = aDoc->objects()->object(aLab); - while(!anObj.get() && aLab.Depth() > 5) { - aLab = aLab.Father().Father(); - anObj = aDoc->objects()->object(aLab); - } - - if (anObj.get()) { - ResultPtr aRes = std::dynamic_pointer_cast(anObj); - if (aRes) - aCont = aRes; - } - } - } - } - } - // if compsolid is context, try to take sub-solid as context: like in GUI and scripts - if (aCont.get() && aShapeToBeSelected.get()) { - ResultBodyPtr aComp = std::dynamic_pointer_cast(aCont); - if (aComp && aComp->numberOfSubs()) { - std::list allSubs; - ModelAPI_Tools::allSubs(aComp, allSubs); - std::list::iterator aS = allSubs.begin(); - for(; aS != allSubs.end(); aS++) { - ResultBodyPtr aSub = std::dynamic_pointer_cast(*aS); - if (aSub && aSub->numberOfSubs() == 0 && aSub->shape().get() && - aSub->shape()->isSubShape(aShapeToBeSelected)) { - aCont = aSub; - break; - } - } - } + // the whole result selection check + if (aSubShapeName.find('/') == std::string::npos) { + ObjectPtr aRes = aDoc->objectByName(ModelAPI_ResultConstruction::group(), aSubShapeName); + if (!aRes.get()) + aRes = aDoc->objectByName(ModelAPI_ResultBody::group(), aSubShapeName); + if (aRes.get()) { + setValue(aRes, anEmptyShape); + return; } - // try to find the latest active result that must be used instead of the selected - // to set the active context (like in GUI selection), not concealed one - bool aFindNewContext = true; - while(aFindNewContext && aCont.get()) { - aFindNewContext = false; - // take references to all results: root one, any sub - ResultBodyPtr aCompContext = ModelAPI_Tools::bodyOwner(aCont, true); - std::list allRes; - if (aCompContext.get()) { - ModelAPI_Tools::allSubs(aCompContext, allRes); - allRes.push_back(aCompContext); - } else { - allRes.push_back(aCont); - } - for(std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { - ResultPtr aResCont = *aSub; - ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont); - // only lower and higher level subs are counted - if (aResBody.get() && aResBody->numberOfSubs() > 0 && aResBody != aCompContext) - continue; - const std::set& aRefs = aResCont->data()->refsToMe(); - std::set::const_iterator aRef = aRefs.begin(); - for(; !aFindNewContext && aRef != aRefs.end(); aRef++) { - if (!aRef->get() || !(*aRef)->owner().get()) - continue; - // concealed attribute only - FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aRef)->owner()); - if (!ModelAPI_Session::get()->validators()->isConcealed( - aRefFeat->getKind(), (*aRef)->id())) + } + + Selector_Selector aSelector(selectionLabel(), baseDocumentLab()); + myRestoreDocument = aDoc; + TDF_Label aContextLabel = aSelector.restoreByName( + aSubShapeName, aShapeType, this, myIsGeometricalSelection); + myRestoreDocument.reset(); + if (!aContextLabel.IsNull()) { + ResultPtr aContext = aDoc->resultByLab(aContextLabel); // any label for document access + if (aContext.get() && aContext->shape().get()) { + TopoDS_Shape aContextShape = aContext->shape()->impl(); + if (aSelector.solve(aContextShape)) { + TopoDS_Shape aSelectorShape = aSelector.value(); + GeomShapePtr aShapeToBeSelected(new GeomAPI_Shape); + aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelectorShape)); + // make the context result the latest existing + aContext = newestContext(aContext, aShapeToBeSelected); + if (myIsGeometricalSelection || aCenterType == NOT_CENTER) { + // store the currently generated name + selectionLabel().ForgetAllAttributes(true); + bool aToUnblock = false; + aToUnblock = !owner()->data()->blockSendAttributeUpdated(true); + myRef.setValue(aContext); + aSelector.store(aContextShape); + owner()->data()->sendAttributeUpdated(this); + if (aToUnblock) + owner()->data()->blockSendAttributeUpdated(false); + return; + } else { // re-select center of circle/arc by context and value + if (!aShapeToBeSelected->isEdge()) continue; - // search the feature result that contains sub-shape selected - std::list > aResults; - - // take all sub-results or one result - std::list aRefFeatResults; - ModelAPI_Tools::allResults(aRefFeat, aRefFeatResults); - std::list::iterator aRefResIter = aRefFeatResults.begin(); - for(; aRefResIter != aRefFeatResults.end(); aRefResIter++) { - ResultBodyPtr aBody = std::dynamic_pointer_cast(*aRefResIter); - if (aBody.get() && aBody->numberOfSubs() == 0) // add only lower level subs - aResults.push_back(aBody); - } - std::list >::iterator aResIter = aResults.begin(); - for(; aResIter != aResults.end(); aResIter++) { - if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled()) - continue; - GeomShapePtr aShape = (*aResIter)->shape(); - GeomShapePtr aSelectedShape = - aShapeToBeSelected.get() ? aShapeToBeSelected : aCont->shape(); - if (aShape.get() && aShape->isSubShape(aSelectedShape, false)) { - aCont = *aResIter; // found new context (produced from this) with same subshape - aFindNewContext = true; // continue searching futher - break; - } - } + std::shared_ptr aSelectedEdge(new GeomAPI_Edge(aShapeToBeSelected)); + setValueCenter(aContext, aSelectedEdge, aCenterType); } + return; } } - - if (aCenterType != NOT_CENTER) { - if (!aShapeToBeSelected->isEdge()) - continue; - std::shared_ptr aSelectedEdge(new GeomAPI_Edge(aShapeToBeSelected)); - setValueCenter(aCont, aSelectedEdge, aCenterType); - } else - setValue(aCont, aShapeToBeSelected); - return; } } - + // invalid TDF_Label aSelLab = selectionLabel(); setInvalidIfFalse(aSelLab, false); reset(); @@ -1249,24 +1007,15 @@ void Model_AttributeSelection::selectSubShape(const std::string& theType, const std::string& theContextName, const int theIndex) { // selection of context by name - //std::string aNamingContextName = theContextName + "/"; - //selectSubShape(theType, aNamingContextName); - std::shared_ptr aDoc = - std::dynamic_pointer_cast(owner()->document()); - if (aDoc.get()) { - bool aUnique = true; - std::string aContextName = theContextName; - std::string anEmptySub = ""; - ResultPtr aContext = aDoc->findByName(aContextName, anEmptySub, aUnique); - //ResultPtr aContext = context(); - if (aContext.get()) { - GeomShapePtr aContShape = aContext->shape(); - if (aContShape.get()) { - GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType)); - GeomShapePtr aValue = aNExp.shape(theIndex); - if (aValue.get()) - setValue(aContext, aValue); - } + selectSubShape(theType, theContextName); + ResultPtr aContext = context(); + if (aContext.get()) { + GeomShapePtr aContShape = aContext->shape(); + if (aContShape.get()) { + GeomAlgoAPI_NExplode aNExp(aContShape, GeomAPI_Shape::shapeTypeByStr(theType)); + GeomShapePtr aValue = aNExp.shape(theIndex); + if (aValue.get()) + setValue(aContext, aValue); } } } @@ -1365,16 +1114,9 @@ void Model_AttributeSelection::computeValues( { bool aWasWholeContext = theValShape.IsNull(); if (aWasWholeContext) { - //theShapes.Append(theValShape); - //return; theValShape = theOldContext->shape()->impl(); } - //TopoDS_Shape anOldContShape = theOldContext->shape()->impl(); TopoDS_Shape aNewContShape = theNewContext->shape()->impl(); - //if (anOldContShape.IsSame(theValShape)) { // full context shape substituted by new full context - //theShapes.Append(aNewContShape); - //return; - //} // if a new value is unchanged in the new context, do nothing: value is correct TopExp_Explorer aSubExp(aNewContShape, theValShape.ShapeType()); for(; aSubExp.More(); aSubExp.Next()) { @@ -1408,9 +1150,9 @@ void Model_AttributeSelection::computeValues( for(; aNewContIter != aNewToIterate.end(); aNewContIter++) { std::shared_ptr aNewData = std::dynamic_pointer_cast((*aNewContIter)->data()); - TDF_Label aNewLab = aNewData->label(); + TDF_Label aNewLab = aNewData->shapeLab(); // searching for produced sub-shape fully on some label - TDF_ChildIDIterator aNSIter(aNewLab, TNaming_NamedShape::GetID(), Standard_True); + TDF_ChildIDIterator aNSIter(aNewLab, TNaming_NamedShape::GetID()); for(; aNSIter.More(); aNSIter.Next()) { Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value()); for(TNaming_Iterator aPairIter(aNS); aPairIter.More(); aPairIter.Next()) { @@ -1441,7 +1183,7 @@ void Model_AttributeSelection::computeValues( } } if (aToFindPart == 2 && !aNewToOld.IsEmpty()) { - // map of sub-shapes -> number of occurences of these shapes in containers + // map of sub-shapes -> number of occurrences of these shapes in containers NCollection_DataMap aSubs; TopTools_DataMapOfShapeShape::Iterator aContIter(aNewToOld); for(; aContIter.More(); aContIter.Next()) { @@ -1502,33 +1244,31 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr if (!aModifierFeat.get()) continue; FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); - if (aModifierFeat == aThisFeature || theDoc->objects()->isLater(aModifierFeat, aThisFeature)) + if (aModifierFeat == aThisFeature || !theDoc->isLaterByDep(aThisFeature, aModifierFeat)) continue; // the modifier feature is later than this, so, should not be used FeaturePtr aCurrentModifierFeat = theDoc->feature(theContext); if (aCurrentModifierFeat == aModifierFeat || - theDoc->objects()->isLater(aCurrentModifierFeat, aModifierFeat)) + !theDoc->isLaterByDep(aModifierFeat, aCurrentModifierFeat)) continue; // the current modifier is later than the found, so, useless Handle(TNaming_NamedShape) aNewNS; aModifIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNewNS); if (aNewNS->Evolution() == TNaming_MODIFY || aNewNS->Evolution() == TNaming_GENERATED) { aResults.insert(aModifierObj); - //TNaming_Iterator aPairIter(aNewNS); - //aResContShapes.Append(aPairIter.NewShape()); aResContShapes.Append(aModifierObj->shape()->impl()); } else if (aNewNS->Evolution() == TNaming_DELETE) { // a shape was deleted => result is empty aResults.insert(ResultPtr()); - } else { // not-precessed modification => don't support it + } else { // not-processed modification => don't support it continue; } } } if (aResults.empty()) return false; // no modifications found, must stay the same - // iterate all results to find futher modifications + // iterate all results to find further modifications std::set::iterator aResIter = aResults.begin(); for(; aResIter != aResults.end(); aResIter++) { if (aResIter->get() != NULL) { - // compute new values by two contextes: the old and the new + // compute new values by two contexts: the old and the new TopTools_ListOfShape aValShapes; computeValues(theContext, *aResIter, theValShape, aValShapes); @@ -1543,7 +1283,7 @@ bool Model_AttributeSelection::searchNewContext(std::shared_ptr if (searchNewContext(theDoc, aNewContShape, *aResIter, aNewValSh, theAccessLabel, aNewRes, aNewUpdatedVal)) { - // appeand new results instead of the current ones + // append new results instead of the current ones std::list::iterator aNewIter = aNewRes.begin(); TopTools_ListIteratorOfListOfShape aNewUpdVal(aNewUpdatedVal); for(; aNewIter != aNewRes.end(); aNewIter++, aNewUpdVal.Next()) { @@ -1572,7 +1312,7 @@ void Model_AttributeSelection::updateInHistory() std::shared_ptr aContData = std::dynamic_pointer_cast(aContext->data()); if (!aContData.get() || !aContData->isValid()) return; - TDF_Label aContLab = aContData->label(); // named shape where the selected context is located + TDF_Label aContLab = aContData->shapeLab(); // named shape where the selected context is located Handle(TNaming_NamedShape) aContNS; if (!aContLab.FindAttribute(TNaming_NamedShape::GetID(), aContNS)) { bool aFoundNewContext = true; @@ -1589,13 +1329,14 @@ void Model_AttributeSelection::updateInHistory() // to avoid detection of part changes by local selection only AttributeSelectionPtr aSel = std::dynamic_pointer_cast(*aRef); - if (aSel.get() && !aSel->value()->isSame(aSel->context()->shape())) + if (aSel.get() && aSel->value().get() && + !aSel->value()->isSame(aSel->context()->shape())) continue; FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aRef)->owner()); if (aRefFeat.get() && aRefFeat != owner()) { FeaturePtr aThisFeature = std::dynamic_pointer_cast(owner()); - if (aDoc->objects()->isLater(aThisFeature, aRefFeat)) { // found better feature + if (!aDoc->isLaterByDep(aRefFeat, aThisFeature)) { // found better feature aFoundNewContext = true; aNewContext = aRefFeat->firstResult(); } @@ -1632,63 +1373,436 @@ void Model_AttributeSelection::updateInHistory() TopTools_ListOfShape aValShapes; if (searchNewContext(aDoc, aNewCShape, aContext, aValShape, aContLab, aNewContexts, aValShapes)) { - // update scope to reset to a new one - myScope.Clear(); + GeomAPI_Shape::ShapeType aListShapeType = GeomAPI_Shape::SHAPE; + if (myParent) { + 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; + } std::list::iterator aNewCont = aNewContexts.begin(); TopTools_ListIteratorOfListOfShape aNewValues(aValShapes); - if (aNewCont == aNewContexts.end()) { // all results were deleted + bool aFirst = true; // first is set to this, next are appended to parent + for(; aNewCont != aNewContexts.end(); aNewCont++, aNewValues.Next()) { + + GeomShapePtr aValueShape; + if (!aNewValues.Value().IsNull()) { + 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 aShapeShapeType = GeomAPI_Shape::SHAPE; + if (aValueShape.get()) { + aShapeShapeType = aValueShape->shapeType(); + } else { + aShapeShapeType = (*aNewCont)->shape()->shapeType(); + } + if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) { + continue; + } + if (aFirst) { + setValue(*aNewCont, aValueShape); + aFirst = false; + } else if (myParent) { + myParent->append(*aNewCont, aValueShape); + } + } + if (aFirst) { // nothing was added, all results were deleted ResultPtr anEmptyContext; std::shared_ptr anEmptyShape; setValue(anEmptyContext, anEmptyShape); // nullify the selection return; } + } +} + +void Model_AttributeSelection::setParent(Model_AttributeSelectionList* theParent) +{ + myParent = theParent; +} - GeomShapePtr aValueShape; - if (!aNewValues.Value().IsNull()) { - aValueShape = std::make_shared(); - aValueShape->setImpl(new TopoDS_Shape(aNewValues.Value())); +std::string Model_AttributeSelection::contextName(const TDF_Label theSelectionLab) +{ + std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : + std::dynamic_pointer_cast(owner()->document()); + FeaturePtr aFeatureOwner = aDoc->featureByLab(theSelectionLab); + bool aBaseDocumnetUsed = false; + if (!aFeatureOwner.get()) { // use module document + aDoc = std::dynamic_pointer_cast(ModelAPI_Session::get()->moduleDocument()); + aFeatureOwner = aDoc->featureByLab(theSelectionLab); + aBaseDocumnetUsed = true; + } + if (aFeatureOwner.get()) { + // if it is sub-element of the sketch, the context name is the name of the sketch + // searching also for result - real context + ResultPtr aResult; + FeaturePtr aComposite = ModelAPI_Tools::compositeOwner(aFeatureOwner); + if (aComposite.get() && aComposite->results().size() == 1 && + aComposite->firstResult()->groupName() == ModelAPI_ResultConstruction::group()) { + aFeatureOwner = aComposite; + aResult = aFeatureOwner->firstResult(); + } else { + aResult = aDoc->resultByLab(theSelectionLab); } - setValue(*aNewCont, aValueShape); - // if there are more than one result, put them by "append" into "parent" list - if (myParent) { - for(aNewCont++, aNewValues.Next(); aNewCont != aNewContexts.end(); - aNewCont++, aNewValues.Next()) { - GeomShapePtr aValueShape; - if (!aNewValues.Value().IsNull()) { - aValueShape = std::make_shared(); - aValueShape->setImpl(new TopoDS_Shape(aNewValues.Value())); + if (aResult.get()) { + // this is to avoid duplicated names of results problem + std::string aContextName = aResult->data()->name(); + // myLab corresponds to the current time + TDF_Label aCurrentLab = selectionLabel(); + while(aCurrentLab.Depth() > 3) + aCurrentLab = aCurrentLab.Father(); + + int aNumInHistoryNames = + aDoc->numberOfNameInHistory(aResult, aCurrentLab); + while(aNumInHistoryNames > 1) { // add "_" before name the needed number of times + aContextName = "_" + aContextName; + aNumInHistoryNames--; + } + if (aBaseDocumnetUsed) + aContextName = aDoc->kind() + "/" + aContextName; + return aContextName; + } + } + return ""; // invalid case +} + +/// This method restores by the context and value name the context label and +/// sub-label where the value is. Returns true if it is valid. +bool Model_AttributeSelection::restoreContext(std::string theName, + TDF_Label& theContext, TDF_Label& theValue) +{ + static const GeomShapePtr anEmptyShape; // to store context only + std::string aName = theName; + std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : + std::dynamic_pointer_cast(owner()->document()); + + // remove the sub-value part if exists + std::string aSubShapeName = aName; + std::string::size_type n = aName.find('/'); + if (n != std::string::npos) { + aName = aName.substr(0, n); + } + + if (aName.empty()) return false; + bool anUniqueContext = false; + ResultPtr aCont = aDoc->findByName(aName, aSubShapeName, anUniqueContext); + if (!aCont.get() || !aCont->shape().get() || aCont->shape()->isNull()) { + // name in PartSet? + aDoc = std::dynamic_pointer_cast( + ModelAPI_Session::get()->moduleDocument()); + if (theName.find(aDoc->kind()) == 0) { // remove the document identifier from name if exists + aSubShapeName = theName.substr(aDoc->kind().size() + 1); + aName = aSubShapeName; + std::string::size_type n = aName.find('/'); + if (n != std::string::npos) { + aName = aName.substr(0, n); + } + } + aCont = aDoc->findByName(aName, aSubShapeName, anUniqueContext); + if (!aCont.get() || !aCont->shape().get() || aCont->shape()->isNull()) + return false; + } + + // searching the sub-shape + static const ResultPtr anEmpty; + theValue = aDoc->findNamingName(aSubShapeName, anUniqueContext ? aCont : anEmpty); + + // sketch sub-component shape and name is located in separated feature label, try the sub-name + if (theValue.IsNull() && aCont->groupName() == ModelAPI_ResultConstruction::group()) { + std::string::size_type aSlash = aSubShapeName.rfind('/'); + if (aSlash != std::string::npos) { + std::string aCompName = aSubShapeName.substr(aSlash + 1); + CompositeFeaturePtr aComposite = + std::dynamic_pointer_cast(aDoc->feature(aCont)); + if (aComposite.get() && aComposite->numberOfSubs()) { + const int aSubNum = aComposite->numberOfSubs(); + for (int a = 0; a < aSubNum && theValue.IsNull(); a++) { + FeaturePtr aSub = aComposite->subFeature(a); + const std::list >& aResults = aSub->results(); + std::list >::const_iterator aRes = aResults.cbegin(); + for (; aRes != aResults.cend() && theValue.IsNull(); aRes++) { + if ((*aRes)->data()->name() == aCompName) { + theValue = std::dynamic_pointer_cast((*aRes)->data())->shapeLab(); + break; + } else { // any sub-label because the sketch line may be renamed, but not sub-vertices + TDF_Label aLab = std::dynamic_pointer_cast((*aRes)->data())->shapeLab(); + TDF_ChildIDIterator aSubNames(aLab, TDataStd_Name::GetID()); + for(; aSubNames.More(); aSubNames.Next()) { + if (Handle(TDataStd_Name)::DownCast(aSubNames.Value())->Get(). + IsEqual(aCompName.c_str())) { + theValue = aSubNames.Value()->Label(); + break; + } + } + } + } } + } + } + } + + if (aCont.get()) { + theContext = std::dynamic_pointer_cast(aCont->data())->label(); + } + return true; +} + +TDF_Label Model_AttributeSelection::newestContext(const TDF_Label theCurrentContext) { + std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : + std::dynamic_pointer_cast(owner()->document()); + ResultPtr aContext = aDoc->resultByLab(theCurrentContext); + if (aContext.get()) { + aContext = newestContext(aContext, GeomShapePtr(), true); + if (aContext.get()) + return std::dynamic_pointer_cast(aContext->data())->label(); + } + return theCurrentContext; // nothing is changed +} + +bool Model_AttributeSelection::isLater( + const TDF_Label theResult1, const TDF_Label theResult2) const +{ + std::shared_ptr aDoc = myRestoreDocument.get() ? myRestoreDocument : + std::dynamic_pointer_cast(owner()->document()); + FeaturePtr aFeat1 = aDoc->featureByLab(theResult1); + if (!aFeat1.get()) + return false; + FeaturePtr aFeat2 = aDoc->featureByLab(theResult2); + if (!aFeat2.get()) + return false; + return aDoc->isLaterByDep(aFeat1, aFeat2); +} - // 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(); +ResultPtr Model_AttributeSelection::newestContext( + const ResultPtr theCurrent, const GeomShapePtr theValue, const bool theAnyValue) +{ + ResultPtr aResult = theCurrent; + GeomShapePtr aSelectedShape = theValue.get() ? theValue : theCurrent->shape(); + std::shared_ptr aDoc = + std::dynamic_pointer_cast(owner()->document()); + bool aFindNewContext = true; + while (aFindNewContext && aResult.get()) { + aFindNewContext = false; + // try to find the last context to find the up to date shape + TopoDS_Shape aConShape = aResult->shape()->impl(); + if (TNaming_Tool::HasLabel(selectionLabel(), aConShape)) { + Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aConShape, selectionLabel()); + if (!aNS.IsNull()) { + aNS = TNaming_Tool::CurrentNamedShape(aNS); + if (!aNS.IsNull() + && isLater(selectionLabel(), aNS->Label()) + && isLater(aNS->Label(), + std::dynamic_pointer_cast(aResult->data())->label())) + { + TDF_Label aLab = aNS->Label(); + ResultPtr aRes = aDoc->resultByLab(aLab); + if (aRes.get()) { + if (theAnyValue || aRes->shape()->isSubShape(aSelectedShape)) { + aResult = aRes; + aFindNewContext = true; + continue; + } + } } + } + } + if (theAnyValue) { // only for neighbors for now + // try to find modification of sub-shapes: the best number of matches + std::map aMatches; // result -> number of matches of shapes to find the best + TDF_Label aResLab = std::dynamic_pointer_cast(aResult->data())->shapeLab(); + TDF_ChildIDIterator aModifIter(aResLab, TNaming_NamedShape::GetID()); + for(; aModifIter.More(); aModifIter.Next()) { + Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aModifIter.Value()); + if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED) { + for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) { + TNaming_NewShapeIterator aNewIter(aNSIter.NewShape(), aNS->Label()); + for(; aNewIter.More(); aNewIter.Next()) { + TDF_Label aLab = aNewIter.Label(); + if (isLater(aLab, aNS->Label()) && isLater(selectionLabel(), aLab)) { + ResultPtr aRes = aDoc->resultByLab(aLab); + if (aRes.get()) { + if (aMatches.find(aRes) == aMatches.end()) + aMatches[aRes] = 0; + aMatches[aRes]++; // found result, add matches + } + } + } + } + } + } + // searching for the best result-candidate + int aBest = 0; + ResultPtr aBestResult; + std::map::iterator aMatchIter = aMatches.begin(); + for(; aMatchIter != aMatches.end(); aMatchIter++) { + if (aMatchIter->second > aBest) { + aBest = aMatchIter->second; + aBestResult = aMatchIter->first; + } + } + if (aBestResult.get()) { + aResult = aBestResult; + aFindNewContext = true; + continue; + } + } + - if (aListShapeType != GeomAPI_Shape::SHAPE && aListShapeType != aShapeShapeType) { + // TestFillWireVertex.py - sketch constructions for wire may participate too + //if (aResult->groupName() == ModelAPI_ResultBody::group()) { + // try to search newer context by the concealment references + // take references to all results: root one, any sub + std::list allRes; + ResultPtr aCompContext; + ResultBodyPtr aCompBody = ModelAPI_Tools::bodyOwner(aResult, true); + if (aCompBody.get()) { + ModelAPI_Tools::allSubs(aCompBody, allRes); + allRes.push_back(aCompBody); + aCompContext = aCompBody; + } + if (allRes.empty()) + allRes.push_back(aResult); + + for (std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { + ResultPtr aResCont = *aSub; + ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont); + if (aResBody.get() && aResBody->numberOfSubs() > 0 && aResBody != aCompContext) + continue; // only lower and higher level subs are counted + const std::set& aRefs = aResCont->data()->refsToMe(); + std::set::const_iterator aRef = aRefs.begin(); + for (; !aFindNewContext && aRef != aRefs.end(); aRef++) { + if (!aRef->get() || !(*aRef)->owner().get()) + continue; + // concealed attribute only + FeaturePtr aRefFeat = std::dynamic_pointer_cast((*aRef)->owner()); + if (!ModelAPI_Session::get()->validators()->isConcealed( + aRefFeat->getKind(), (*aRef)->id())) continue; + // search the feature result that contains sub-shape selected + std::list > aResults; + + // take all sub-results or one result + std::list aRefFeatResults; + ModelAPI_Tools::allResults(aRefFeat, aRefFeatResults); + std::list::iterator aRefResIter = aRefFeatResults.begin(); + for (; aRefResIter != aRefFeatResults.end(); aRefResIter++) { + ResultBodyPtr aBody = std::dynamic_pointer_cast(*aRefResIter); + if (aBody.get() && aBody->numberOfSubs() == 0) // add only lower level subs + aResults.push_back(aBody); } + std::list >::iterator aResIter = aResults.begin(); - myParent->append(*aNewCont, aValueShape); + if (theAnyValue) { // searching the best sub-result by maximum number of references to orig + int aReferencesCount = 0; + ResultPtr aBestResult; + for (; aResIter != aResults.end(); aResIter++) { + if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled()) + continue; + TDF_Label aCandidateLab = + std::dynamic_pointer_cast((*aResIter)->data())->shapeLab(); + Handle(TDF_Reference) aRef; + if (aCandidateLab.FindAttribute(TDF_Reference::GetID(), aRef)) { + TDF_Label aRefLab = aRef->Get(); + ResultPtr aRefRes = aDoc->resultByLab(aRefLab); + if (aRefRes.get() && aRefRes->shape().get() && + aRefRes->shape()->isEqual(aResult->shape())) {// it directly references to result + aResult = *aResIter; // found new context (produced from this) with same subshape + aFindNewContext = true; // continue searching further + break; + } + } else { + if (!aBestResult.get()) + aBestResult = *aResIter; + } + } + if (aBestResult.get() && !aFindNewContext) { // the first good result for now + aResult = aBestResult; // found new context + aFindNewContext = true; + } + } else { // searching by sub-shape + for (; aResIter != aResults.end(); aResIter++) { + if (!aResIter->get() || !(*aResIter)->data()->isValid() || (*aResIter)->isDisabled()) + continue; + GeomShapePtr aShape = (*aResIter)->shape(); + if (aShape.get() && (theAnyValue || aShape->isSubShape(aSelectedShape, false))) { + aResult = *aResIter; // found new context (produced from this) with same subshape + aFindNewContext = true; // continue searching further + break; + } + } + } + } + } + } + // if compsolid is context, try to take sub-solid as context: like in GUI and scripts + ResultBodyPtr aComp = std::dynamic_pointer_cast(aResult); + if (aComp && aComp->numberOfSubs()) { + std::list allSubs; + ModelAPI_Tools::allSubs(aComp, allSubs); + std::list::iterator aS = allSubs.begin(); + for (; aS != allSubs.end(); aS++) { + ResultBodyPtr aSub = std::dynamic_pointer_cast(*aS); + if (aSub && aSub->numberOfSubs() == 0 && aSub->shape().get() && + (theAnyValue || aSub->shape()->isSubShape(aSelectedShape))) { + aResult = aSub; + break; } } } + // in case sketch line was selected for wire, but wire was concealed and not such line anymore, + // so, actually, the sketch element was selected (which is never concealed) + if (aResult != theCurrent && aResult->isConcealed()) + aResult = theCurrent; + return aResult; } -void Model_AttributeSelection::setParent(Model_AttributeSelectionList* theParent) +void Model_AttributeSelection::combineGeometrical() { - myParent = theParent; + if (myTmpContext.get() || myTmpSubShape.get()) + return; + TDF_Label aSelLab = selectionLabel(); + if (aSelLab.IsAttribute(kINVALID_SELECTION) || !myRef.isInitialized()) + return; + + if (aSelLab.IsAttribute(kCIRCLE_CENTER) || aSelLab.IsAttribute(kELLIPSE_CENTER1) || + aSelLab.IsAttribute(kELLIPSE_CENTER2) || aSelLab.IsAttribute(kSIMPLE_REF_ID)) + return; + + if (aSelLab.IsAttribute(kPART_REF_ID)) { + ResultPartPtr aPart = std::dynamic_pointer_cast(context()); + if (!aPart.get() || !aPart->isActivated()) + return; // postponed naming needed + Handle(TDataStd_Integer) anIndex; + if (aSelLab.FindAttribute(TDataStd_Integer::GetID(), anIndex)) { + if (anIndex->Get()) { // special selection attribute was created, use it + std::string aNewName; + aPart->combineGeometrical(anIndex->Get(), aNewName); + TDataStd_Name::Set(aSelLab, aNewName.c_str()); + } + } + return; + } + + std::shared_ptr aConstr = + std::dynamic_pointer_cast(context()); + if (aConstr.get()) + return; + FeaturePtr aFeature = contextFeature(); + if (aFeature.get()) + return; + + Selector_Selector aSelector(aSelLab, baseDocumentLab()); + TopoDS_Shape aContextShape = context()->shape()->impl(); + if (aSelector.restore(aContextShape)) { + aSelector.combineGeometrical(aContextShape); + } } -bool Model_AttributeSelection::isWeakNaming() +TDF_Label Model_AttributeSelection::baseDocumentLab() { - return selectionLabel().IsAttribute(kWEAK_NAMING); + if (ModelAPI_Session::get()->moduleDocument() != owner()->document()) + return std::dynamic_pointer_cast + (ModelAPI_Session::get()->moduleDocument())->extConstructionsLabel(); + static TDF_Label anEmpty; + return anEmpty; } diff --git a/src/Model/Model_AttributeSelection.h b/src/Model/Model_AttributeSelection.h index 66f628ebb..9512a3a73 100644 --- a/src/Model/Model_AttributeSelection.h +++ b/src/Model/Model_AttributeSelection.h @@ -24,6 +24,7 @@ #include "Model.h" #include "Model_AttributeReference.h" #include +#include #include #include #include @@ -35,24 +36,29 @@ class Model_Document; * \ingroup DataModel * \brief Attribute that contains reference to the sub-shape of some result, the selected shape. */ -class Model_AttributeSelection : public ModelAPI_AttributeSelection +class Model_AttributeSelection : public ModelAPI_AttributeSelection, + public Selector_NameGenerator { - Model_AttributeReference myRef; ///< The reference functionality reusage - TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving + Model_AttributeReference myRef; ///< The reference functionality re-usage /// temporarily storages to avoid keeping in the data structure if not needed ResultPtr myTmpContext; /// temporarily storages to avoid keeping in the data structure if not needed std::shared_ptr myTmpSubShape; /// temporarily storages to avoid keeping in the data structure if not needed CenterType myTmpCenterType; - /// Reference to the partent attribute, if any (to split selection compounds in issue 1799) + /// Reference to the parent attribute, if any (to split selection compounds in issue 1799) Model_AttributeSelectionList* myParent; + + std::shared_ptr myRestoreDocument; // current document to restore by name + /// If true attribute selects geometry instead of shape. + bool myIsGeometricalSelection; + public: /// Defines the result and its selected sub-shape /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, do not store and name the added in the data framework - /// (used to remove immideately, without the following updates) + /// (used to remove immediately, without the following updates) /// \returns true if attribute was updated MODEL_EXPORT virtual bool setValue( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, @@ -86,7 +92,7 @@ public: /// Sets the feature object MODEL_EXPORT virtual void setObject(const std::shared_ptr& theObject); - /// Updates the underlied selection due to the changes in the referenced objects + /// Updates the selection due to the changes in the referenced objects /// \returns false if update is failed MODEL_EXPORT virtual bool update(); @@ -104,7 +110,7 @@ public: /// NOTE: This method is opposite to Id() method. MODEL_EXPORT virtual void setId(int theID); - /// Selects (i.e. creates Naming data structure) of sub-shape specifed by textual name + /// Selects (i.e. creates Naming data structure) of sub-shape specified by textual name MODEL_EXPORT virtual void selectSubShape(const std::string& theType, const std::string& theSubShapeName); @@ -118,16 +124,34 @@ public: /// Returns true if attribute was initialized by some value MODEL_EXPORT virtual bool isInitialized(); - /// Returns true if recomute of selection become impossible + /// Returns true if recompute of selection become impossible MODEL_EXPORT virtual bool isInvalid(); /// Updates the arguments of selection if something was affected by creation /// or reorder of features upper in the history line (issue #1757) MODEL_EXPORT virtual void updateInHistory(); - /// Returns true if the name was stored using weak naming principle - MODEL_EXPORT virtual bool isWeakNaming(); + // Implementation of the name generator method from the Selector package + // This method returns the context name by the label of the sub-selected shape + MODEL_EXPORT virtual std::string contextName(const TDF_Label theSelectionLab) override; + + /// This method restores by the context and value name the context label and + /// sub-label where the value is. Returns true if it is valid. + MODEL_EXPORT virtual bool restoreContext(std::string theName, + TDF_Label& theContext, TDF_Label& theValue) override; + + /// Returns the label of the newest context presented by the current one + MODEL_EXPORT virtual TDF_Label newestContext(const TDF_Label theCurrentContext) override; + /// Returns true if the first result is newer than the second one in the tree of features + MODEL_EXPORT virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2) + const override; + + /// Returns the name by context. Adds the part name if the context is located in other document + MODEL_EXPORT virtual std::string contextName(const ResultPtr& theContext) const; + + /// Makes the current local selection becomes all sub-shapes with same base geometry. + MODEL_EXPORT virtual void combineGeometrical(); protected: /// Objects are created for features automatically @@ -139,9 +163,6 @@ protected: /// Returns theType type of the center, or NOT_CENTER if it is not. std::shared_ptr internalValue(CenterType& theType); - - /// Performs the selection for the body result (TNaming Selection) - /// Performs the selection for the body result (TNaming selection) virtual void selectBody( const ResultPtr& theContext, const std::shared_ptr& theSubShape); @@ -150,7 +171,7 @@ protected: /// \param theContext the result - owner of the selection /// \param theSubShape selected shape /// \param theUpdate flag that shows that it must be just update, theShape is null - /// \returns true if eveything is selected correctly + /// \returns true if everything is selected correctly virtual bool selectPart( const ResultPtr& theContext, const std::shared_ptr& theSubShape, const bool theUpdate = false); @@ -159,15 +180,9 @@ protected: /// Note: there must be no attributes stored at the same label because Selector clears this lab TDF_Label selectionLabel(); - /// Returns the prepared map of valid labels for naming selection solving (creates if not exists) - TDF_LabelMap& scope(); - /// Sets the ID of the attribute in Data (called from Data): here it is used for myRef ID setting MODEL_EXPORT virtual void setID(const std::string theID); - /// Returns the name by context. Adds the part name if the context is located in other document - std::string contextName(const ResultPtr& theContext) const; - /// Sets the parent attribute void setParent(Model_AttributeSelectionList* theParent); @@ -179,11 +194,24 @@ protected: ResultPtr theContext, TopoDS_Shape theValShape, TDF_Label theAccessLabel, std::list& theResults, TopTools_ListOfShape& theValShapes); + /// Searches for the newest context, modification of the current, that contains theValue + ResultPtr newestContext(const ResultPtr theCurrent, + const std::shared_ptr theValue, const bool theAnyValue = false); + /// computes theShapes list - shapes that were generated/modified/deleted the theValShape /// during creation from new to old context void computeValues(ResultPtr theOldContext, ResultPtr theNewContext, TopoDS_Shape theValShape, TopTools_ListOfShape& theShapes); + /// Returns true if is geometrical selection. + virtual bool isGeometricalSelection() const { + return myIsGeometricalSelection; + }; + + /// Returns the module document label if this selection attribute is not in this document. + /// Returns null label otherwise. + TDF_Label baseDocumentLab(); + friend class Model_Data; friend class Model_AttributeSelectionList; }; diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 9fb412407..617007a5e 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -26,11 +26,13 @@ #include #include +#include #include #include #include #include +#include #include #include #include @@ -41,6 +43,10 @@ #include #include +/// GUID for UAttribute that indicates the list has "To add all elements that share the same +/// topology" flag enabled +static const Standard_GUID kIS_GEOMETRICAL_SELECTION("f16987b6-e6c8-435c-99fa-03a7e0b06e83"); + void Model_AttributeSelectionList::append( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) @@ -231,7 +237,7 @@ void Model_AttributeSelectionList::remove(const std::set& theIndices) { int anOldSize = mySize->Get(); int aRemoved = 0; - // iterate one by one and shifting the removed indicies + // iterate one by one and shifting the removed indices for(int aCurrent = 0; aCurrent < anOldSize; aCurrent++) { if (theIndices.find(aCurrent) == theIndices.end()) { // not removed if (aRemoved) { // but must be shifted to the removed position @@ -263,6 +269,19 @@ int Model_AttributeSelectionList::size() return mySize->Get(); } +// returns true if theShape is same with theInList or is contained in it (a compound) +static bool isIn(GeomShapePtr theInList, GeomShapePtr theShape) { + if (theShape->isSame(theInList)) + return true; + if (theInList.get() && theInList->shapeType() == GeomAPI_Shape::COMPOUND) { + for(GeomAPI_ShapeIterator anIter(theInList); anIter.more(); anIter.next()) { + if (!anIter.current()->isNull() && anIter.current()->isSame(theShape)) + return true; + } + } + return false; +} + bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily) @@ -281,7 +300,7 @@ bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext, return true; } else { // we need to call here isSame instead of isEqual to do not check shapes orientation - if (theSubShape->isSame(*aShapes)) + if (isIn(*aShapes, theSubShape)) return true; } } @@ -301,7 +320,7 @@ bool Model_AttributeSelectionList::isInList(const ObjectPtr& theContext, } } else { // we need to call here isSame instead of isEqual to do not check shapes orientation - if (theSubShape->isSame(aValue)) // shapes are equal + if (isIn(aValue, theSubShape)) // shapes are equal return true; } } @@ -328,15 +347,15 @@ std::shared_ptr } TDF_Label aLabel = mySize->Label().FindChild(theIndex + 1); // create a new attribute each time, by demand - // supporting of old attributes is too slow (synch each time) and buggy on redo - // (if attribute is deleted and created, the abort updates attriute and makes the Attr invalid) + // supporting of old attributes is too slow (sync each time) and buggy on redo + // (if attribute is deleted and created, the abort updates attribute and makes the Attr invalid) std::shared_ptr aNewAttr = std::shared_ptr(new Model_AttributeSelection(aLabel)); - aNewAttr->setID(id()); if (owner()) { aNewAttr->setObject(owner()); aNewAttr->setParent(this); } + aNewAttr->setID(id()); return aNewAttr; } @@ -371,8 +390,8 @@ bool Model_AttributeSelectionList::isInitialized() } Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) +: myLab(theLabel) { - myLab = theLabel; reinit(); } @@ -402,3 +421,59 @@ void Model_AttributeSelectionList::cashValues(const bool theEnabled) } } } + +bool Model_AttributeSelectionList::isGeometricalSelection() const +{ + return myLab.IsAttribute(kIS_GEOMETRICAL_SELECTION); +} + +void Model_AttributeSelectionList::setGeometricalSelection(const bool theIsGeometricalSelection) +{ + if (isGeometricalSelection() == theIsGeometricalSelection) + return; // nothing to do + if (theIsGeometricalSelection) // store the state + TDataStd_UAttribute::Set(myLab, kIS_GEOMETRICAL_SELECTION); + else + myLab.ForgetAttribute(kIS_GEOMETRICAL_SELECTION); + std::set anIndiciesToRemove; // Update list according to the flag + if (theIsGeometricalSelection) { // all objects with same geometry must be combined into single + std::list anAttributes; // collect attributes with geometrical compounds + for(int anIndex = 0; anIndex < size(); anIndex++) { + AttributeSelectionPtr anAttr = value(anIndex); + if (!anAttr.get() || !anAttr->context().get()) + continue; + anAttr->combineGeometrical(); + if (!anAttr->value().get() || anAttr->value()->shapeType() != GeomAPI_Shape::COMPOUND) + continue; + // check it is equal to some other attribute already presented in the list + std::list::iterator anAttrIter = anAttributes.begin(); + for(; anAttrIter != anAttributes.end(); anAttrIter++) { + if (anAttr->context() == (*anAttrIter)->context() && + anAttr->namingName() == (*anAttrIter)->namingName()) { + anIndiciesToRemove.insert(anIndex); + break; + } + } + if (anAttrIter == anAttributes.end()) // not removed, so, add to the compare-list + anAttributes.push_back(anAttr); + } + } else { // all objects with same geometry must be divided into separated sub-attributes + int anInitialSize = size(); + for(int anIndex = 0; anIndex < anInitialSize; anIndex++) { + AttributeSelectionPtr anAttr = value(anIndex); + if (!anAttr.get() || !anAttr->context().get()) + continue; + GeomShapePtr aValue = anAttr->value(); + if (!aValue.get() || aValue->shapeType() != GeomAPI_Shape::COMPOUND) + continue; + for(GeomAPI_ShapeIterator anIter(aValue); anIter.more(); anIter.next()) { + append(anAttr->context(), anIter.current()); + } + anIndiciesToRemove.insert(anIndex); + } + } + remove(anIndiciesToRemove); + myIsCashed = false; + myCash.clear(); // empty list as indicator that cash is not used + owner()->data()->sendAttributeUpdated(this); +} diff --git a/src/Model/Model_AttributeSelectionList.h b/src/Model/Model_AttributeSelectionList.h index 7e0736fe8..d84ca1ff4 100644 --- a/src/Model/Model_AttributeSelectionList.h +++ b/src/Model/Model_AttributeSelectionList.h @@ -50,7 +50,7 @@ public: /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, do not store and name the added in the data framework - /// (used to remove immideately, without the following updates) + /// (used to remove immediately, without the following updates) MODEL_EXPORT virtual void append( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily = false); @@ -77,14 +77,14 @@ public: /// \param theIndices a list of indices of elements to be removed MODEL_EXPORT virtual void remove(const std::set& theIndices); - /// Returns the number ofselection attributes in the list + /// Returns the number of selection attributes in the list MODEL_EXPORT virtual int size(); /// Returns true if the object with the shape are in list /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, it checks also the temporary added item - /// \returns true if the pair is found in the attirbute + /// \returns true if the pair is found in the attribute MODEL_EXPORT virtual bool isInList( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily = false); @@ -111,6 +111,11 @@ public: /// during non-modification operations with this attribute) MODEL_EXPORT virtual void cashValues(const bool theEnabled); + MODEL_EXPORT virtual void setGeometricalSelection(const bool theIsGeometricalSelection) override; + + /// Returns true if is geometrical selection. + MODEL_EXPORT virtual bool isGeometricalSelection() const override; + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeSelectionList(TDF_Label& theLabel); diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 8428157d3..fee31e5c4 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -22,17 +22,21 @@ #include #include +#include #include #include #include #include +#include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -49,98 +53,79 @@ #include #include #include +#include #include #include #include // DEB //#include -//#include //#define DEB_IMPORT 1 -Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner) -: ModelAPI_BodyBuilder(theOwner), - myDividedIndex(1), - myVIndex(1), - myEIndex(1), - myFIndex(1) -{ +/// reference to the shape in external document: sting list attribute identifier +static const Standard_GUID kEXTERNAL_SHAPE_REF("9aa5dd14-6d34-4a8d-8786-05842fd7bbbd"); + +static const int INVALID_TAG = -1; +static const int GENERATED_VERTICES_TAG = 1; +static const int GENERATED_EDGES_TAG = 2; +static const int GENERATED_FACES_TAG = 3; +static const int MODIFIED_VERTICES_TAG = 4; +static const int MODIFIED_EDGES_TAG = 5; +static const int MODIFIED_FACES_TAG = 6; +static const int DELETED_TAG = 7; +static const int PRIMITIVES_START_TAG = 11; + +static int getGenerationTag(const TopoDS_Shape& theShape) { + TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); + switch (aShapeType) { + case TopAbs_VERTEX: return GENERATED_VERTICES_TAG; + case TopAbs_EDGE: return GENERATED_EDGES_TAG; + case TopAbs_FACE: return GENERATED_FACES_TAG; + } + + return INVALID_TAG; } -// Converts evolution of naming shape to selection evelution and back to avoid -// naming support on the disabled results. Deeply in the labels tree, recursively. -static void evolutionToSelectionRec(TDF_Label theLab, const bool theFlag) { - std::list > aShapePairs; // to store old and new shapes - Handle(TNaming_NamedShape) aName; - int anEvolution = -1; - if (theLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TNaming_Evolution aNSEvol = aName->Evolution(); - if ((aNSEvol == TNaming_SELECTED && theFlag) || - (aNSEvol != TNaming_SELECTED && !theFlag)) { // nothing to do, it is already correct - return; - } - anEvolution = (int)(aNSEvol); - if (!theFlag) { - Handle(TDataStd_Integer) anAttrEvol; - if (theLab.FindAttribute(TDataStd_Integer::GetID(), anAttrEvol)) { - anEvolution = anAttrEvol->Get(); - } - } else { - TDataStd_Integer::Set(theLab, anEvolution); - } +static int getModificationTag(const TopoDS_Shape& theShape) { + TopAbs_ShapeEnum aShapeType = theShape.ShapeType(); + switch (aShapeType) { + case TopAbs_VERTEX: return MODIFIED_VERTICES_TAG; + case TopAbs_EDGE: return MODIFIED_EDGES_TAG; + case TopAbs_FACE: return MODIFIED_FACES_TAG; + } - for(TNaming_Iterator anIter(aName); anIter.More(); anIter.Next()) { - // iterator goes in reversed order relatively to the Builder, to, make the list reversed - aShapePairs.push_front(std::pair - (anIter.OldShape(), anIter.NewShape())); - } + return INVALID_TAG; +} - // create new - TNaming_Builder aBuilder(theLab); - TNaming_Evolution anEvol = (TNaming_Evolution)(anEvolution); - std::list >::iterator aPairsIter = aShapePairs.begin(); - for(; aPairsIter != aShapePairs.end(); aPairsIter++) { - if (theFlag) { // disabled => make selection - if (anEvolution == TNaming_DELETE) // issue 2274 : don't put too many same null shapes - aBuilder.Select(aPairsIter->first, aPairsIter->first); - else if (anEvolution == TNaming_PRIMITIVE) - aBuilder.Select(aPairsIter->second, aPairsIter->second); - else - aBuilder.Select(aPairsIter->second, aPairsIter->first); - } else if (anEvol == TNaming_GENERATED) { - aBuilder.Generated(aPairsIter->first, aPairsIter->second); - } else if (anEvol == TNaming_MODIFY) { - aBuilder.Modify(aPairsIter->first, aPairsIter->second); - } else if (anEvol == TNaming_DELETE) { - aBuilder.Delete(aPairsIter->first); - } else if (anEvol == TNaming_PRIMITIVE) { - aBuilder.Generated(aPairsIter->second); - } else if (anEvol == TNaming_SELECTED) { - aBuilder.Select(aPairsIter->second, aPairsIter->first); - } +static bool isAlreadyStored(const TNaming_Builder* theBuilder, + const TopoDS_Shape& theOldShape, + const TopoDS_Shape& theNewShape) +{ + for (TNaming_Iterator aNamingIt(theBuilder->NamedShape()); + aNamingIt.More(); + aNamingIt.Next()) + { + if (aNamingIt.NewShape().IsSame(theNewShape) + && aNamingIt.OldShape().IsSame(theOldShape)) + { + return true; } } - // recursive call for all sub-labels - TDF_ChildIterator anIter(theLab, Standard_False); - for(; anIter.More(); anIter.Next()) { - evolutionToSelectionRec(anIter.Value(), theFlag); - } + + return false; } -void Model_BodyBuilder::evolutionToSelection(const bool theFlag) +Model_BodyBuilder::Model_BodyBuilder(ModelAPI_Object* theOwner) +: ModelAPI_BodyBuilder(theOwner), + myFreePrimitiveTag(PRIMITIVES_START_TAG) { - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - if (!aData || !aData->isValid()) // unknown case - return; - TDF_Label& aShapeLab = aData->shapeLab(); - evolutionToSelectionRec(aShapeLab, theFlag); } -void Model_BodyBuilder::store(const std::shared_ptr& theShape, +void Model_BodyBuilder::store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); // clean builders clean(); // store the new shape as primitive @@ -153,7 +138,8 @@ void Model_BodyBuilder::store(const std::shared_ptr& theShape, if(!theIsStoreSameShapes) { Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aShape, aShapeLab); - if(!aNS.IsNull() && !aNS->IsEmpty()) { + // the last condition is for the issue 2751 : existing shape may be found in compound-NS + if(!aNS.IsNull() && !aNS->IsEmpty() && aNS->Get().IsSame(aShape)) { // This shape is already in document, store reference instead of shape; const TDF_Label aFoundLabel = aNS->Label(); TDF_Reference::Set(aShapeLab, aFoundLabel); @@ -179,12 +165,12 @@ void Model_BodyBuilder::store(const std::shared_ptr& theShape, } } -void Model_BodyBuilder::storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) +void Model_BodyBuilder::storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); + TDF_Label aShapeLab = aData->shapeLab(); // clean builders clean(); // store the new shape as primitive @@ -225,15 +211,14 @@ TNaming_Builder* Model_BodyBuilder::builder(const int theTag) return aFind->second; } -void Model_BodyBuilder::storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag) +void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored) { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); // clean builders - if (theDecomposeSolidsTag != -2) - clean(); + if (theIsCleanStored) clean(); // store the new shape as primitive TNaming_Builder* aBuilder = builder(0); if (!theOldShape || !theNewShape) @@ -259,21 +244,6 @@ void Model_BodyBuilder::storeModified(const std::shared_ptr& theO } } -void Model_BodyBuilder::storeWithoutNaming(const std::shared_ptr& theShape) -{ - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - if (aData) { - clean(); - if (!theShape.get()) - return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) - return; // null shape inside - TNaming_Builder aBuilder(aData->shapeLab()); - aBuilder.Select(aShape, aShape); - } -} - void Model_BodyBuilder::clean() { TDF_Label aLab = std::dynamic_pointer_cast(data())->shapeLab(); @@ -281,20 +251,20 @@ void Model_BodyBuilder::clean() return; std::map::iterator aBuilder = myBuilders.begin(); for(; aBuilder != myBuilders.end(); aBuilder++) { + Handle(TNaming_NamedShape) aNS = aBuilder->second->NamedShape(); delete aBuilder->second; - // clear also shapes on cleaned sub-labels (#2241) - Handle(TNaming_NamedShape) aNS; - if (aLab.FindChild(aBuilder->first).FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - aNS->Clear(); - } + if (!aNS.IsNull() && !aNS->Label().IsNull()) + aNS->Label().ForgetAttribute(TNaming_NamedShape::GetID()); } myBuilders.clear(); + myPrimitivesNamesIndexMap.clear(); // remove the old reference (if any) aLab.ForgetAttribute(TDF_Reference::GetID()); - myDividedIndex = 1; - myVIndex = 1; - myEIndex = 1; - myFIndex = 1; + myFreePrimitiveTag = PRIMITIVES_START_TAG; + TDF_ChildIDIterator anEntriesIter(aLab, kEXTERNAL_SHAPE_REF, true); + for(; anEntriesIter.More(); anEntriesIter.Next()) { + anEntriesIter.Value()->Label().ForgetAttribute(kEXTERNAL_SHAPE_REF); + } } Model_BodyBuilder::~Model_BodyBuilder() @@ -304,111 +274,130 @@ Model_BodyBuilder::~Model_BodyBuilder() void Model_BodyBuilder::buildName(const int theTag, const std::string& theName) { - std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); - //aDoc->addNamingName(builder(theTag)->NamedShape()->Label(), theName); - TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), theName.c_str()); + std::string aName = theName; + std::string aPrefix = ""; + switch (theTag) { + case GENERATED_VERTICES_TAG: aPrefix = aName.empty() ? "Generated_Vertex" : "GV:"; break; + case GENERATED_EDGES_TAG: aPrefix = aName.empty() ? "Generated_Edge" : "GE:"; break; + case GENERATED_FACES_TAG: aPrefix = aName.empty() ? "Generated_Face" : "GF:"; break; + case MODIFIED_VERTICES_TAG: aPrefix = aName.empty() ? "Modified_Vertex" : "MV:"; break; + case MODIFIED_EDGES_TAG: aPrefix = aName.empty() ? "Modified_Edge" : "ME:"; break; + case MODIFIED_FACES_TAG: aPrefix = aName.empty() ? "Modified_Face" : "MF:"; break; + } + aName.insert(0, aPrefix); + + TDataStd_Name::Set(builder(theTag)->NamedShape()->Label(), aName.c_str()); } -void Model_BodyBuilder::generated( - const std::shared_ptr& theNewShape, const std::string& theName, const int theTag) +bool Model_BodyBuilder::generated(const GeomShapePtr& theNewShape, + const std::string& theName, + const bool theCheckIsInResult) { + GeomShapePtr aResultShape = shape(); + if (theCheckIsInResult) { + bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(theNewShape, false); + if (aNewShapeIsNotInResultShape) { + return false; + } + } + TopoDS_Shape aShape = theNewShape->impl(); - builder(theTag)->Generated(aShape); - if(!theName.empty()) - buildName(theTag, theName); + builder(myFreePrimitiveTag)->Generated(aShape); + if (!theName.empty()) { + std::string aName = theName; + if (myPrimitivesNamesIndexMap.find(theName) != myPrimitivesNamesIndexMap.end()) { + IndexTags& anIndexTags = myPrimitivesNamesIndexMap.find(theName)->second; + aName += "_" + std::to_string(++(anIndexTags.index)); + anIndexTags.tags.push_back(myFreePrimitiveTag); + if (anIndexTags.index == 2) { + buildName(anIndexTags.tags.front(), theName + "_1"); + } + } + else { + IndexTags anIndexTags; + anIndexTags.index = 1; + anIndexTags.tags.push_back(myFreePrimitiveTag); + myPrimitivesNamesIndexMap[theName] = anIndexTags; + } + + buildName(myFreePrimitiveTag, aName); + } + ++myFreePrimitiveTag; + return true; } -void Model_BodyBuilder::generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, const int theTag) +void Model_BodyBuilder::generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Generated(anOldShape, aNewShape); - if(!theName.empty()) - buildName(theTag, theName); - TopAbs_ShapeEnum aGenShapeType = aNewShape.ShapeType(); - if(aGenShapeType == TopAbs_WIRE || aGenShapeType == TopAbs_SHELL) { - TopAbs_ShapeEnum anExplodeShapeType = aGenShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE; - const TDF_Label aLabel = builder(theTag)->NamedShape()->Label(); - int aTag = 1; - std::shared_ptr aDoc = std::dynamic_pointer_cast(document()); - for(TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) { - TDF_Label aChildLabel = aLabel.FindChild(aTag); - TNaming_Builder aBuilder(aChildLabel); - aBuilder.Generated(anOldShape, anExp.Current()); - TCollection_AsciiString aChildName = TCollection_AsciiString((theName + "_").c_str()) + aTag; - //aDoc->addNamingName(aChildLabel, aChildName.ToCString()); - TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); - aTag++; - } + TopAbs_ShapeEnum aNewShapeType = aNewShape.ShapeType(); + int aTag; + if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) { + // TODO: This is a workaround. New shape should be only vertex, edge or face. + TopAbs_ShapeEnum aShapeTypeToExplore = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE; + aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG; + for (TopExp_Explorer anExp(aNewShape, aShapeTypeToExplore); anExp.More(); anExp.Next()) { + builder(aTag)->Generated(anOldShape, anExp.Current()); + } + buildName(aTag, theName); + } else { + aTag = getGenerationTag(aNewShape); + if (aTag == INVALID_TAG) return; + builder(aTag)->Generated(anOldShape, aNewShape); + buildName(aTag, theName); } } - -void Model_BodyBuilder::modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, const int theTag) +void Model_BodyBuilder::modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { TopoDS_Shape anOldShape = theOldShape->impl(); TopoDS_Shape aNewShape = theNewShape->impl(); - builder(theTag)->Modify(anOldShape, aNewShape); - if(!theName.empty()) - buildName(theTag, theName); -} - -void Model_BodyBuilder::deleted(const std::shared_ptr& theOldShape, - const int theTag) -{ - TopoDS_Shape aShape = theOldShape->impl(); - builder(theTag)->Delete(aShape); + int aTag = getModificationTag(aNewShape); + if (aTag == INVALID_TAG) return; + builder(aTag)->Modify(anOldShape, aNewShape); + buildName(aTag, theName); } -void Model_BodyBuilder::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes) +void Model_BodyBuilder::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude) { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - TopExp_Explorer ShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); + TopTools_MapOfShape anAlreadyProcessedShapes; GeomShapePtr aResultShape = shape(); - for (; ShapeExplorer.More(); ShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = ShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - std::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - if (!theMS->isDeleted(aRShape) - || aResultShape->isSubShape(aRShape, false) - || (theShapes.get() && theShapes->isSubShape(aRShape, false))) { + for (GeomAPI_ShapeExplorer anExp(theOldShape, theShapeTypeToExplore); + anExp.more(); + anExp.next()) + { + GeomShapePtr anOldSubShape = anExp.current(); + const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl(); + if (!anAlreadyProcessedShapes.Add(anOldSubShape_) + || !theAlgo->isDeleted(anOldSubShape) + || aResultShape->isSubShape(anOldSubShape, false) + || (theShapesToExclude.get() && theShapesToExclude->isSubShape(anOldSubShape, false))) + { continue; } - ListOfShape aHist; - if (BRepTools_History::IsSupportedType(aRoot)) // to avoid crash in #2572 - theMS->modified(aRShape, aHist); - if (aHist.size() == 0 || (aHist.size() == 1 && aHist.front()->isSame(aRShape))) - builder(theTag)->Delete(aRoot); - } -} + ListOfShape aNewShapes; + if (BRepTools_History::IsSupportedType(anOldSubShape_)) { // to avoid crash in #2572 + theAlgo->modified(anOldSubShape, aNewShapes); + } -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; + if (aNewShapes.size() == 0 + || (aNewShapes.size() == 1 && aNewShapes.front()->isSame(anOldSubShape))) { + builder(DELETED_TAG)->Delete(anOldSubShape_); } } } // Keep only the shapes with minimal shape type -static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRoot, - const GeomShapePtr& theResultShape = GeomShapePtr()) +static void keepTopLevelShapes(ListOfShape& theShapes, + const TopoDS_Shape& theRoot, + const GeomShapePtr& theResultShape = GeomShapePtr()) { GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE; ListOfShape::iterator anIt = theShapes.begin(); @@ -437,348 +426,223 @@ static void keepTopLevelShapes(ListOfShape& theShapes, const TopoDS_Shape& theRo } } -// returns an ancestor shape-type thaty used for naming-definition of the sub-type -TopAbs_ShapeEnum typeOfAncestor(const TopAbs_ShapeEnum theSubType) { - if (theSubType == TopAbs_VERTEX) - return TopAbs_EDGE; - if (theSubType == TopAbs_EDGE) - return TopAbs_FACE; - return TopAbs_VERTEX; // bad case +/// Checks that shape is presented in the tree with not-selection evolution +/// In theOriginalLabel it returns label where NS of old sub-shape is stored +static bool isShapeInTree(const TDF_Label& theAccess1, const TDF_Label& theAccess2, + TopoDS_Shape theShape, TDF_Label& theOriginalLabel) +{ + bool aResult = TNaming_Tool::HasLabel(theAccess1, theShape); + if (aResult) { //check evolution and a label of this shape + for(TNaming_SameShapeIterator aShapes(theShape, theAccess1); aShapes.More(); aShapes.Next()) + { + static Handle(TNaming_NamedShape) aNS; + if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aNS->Evolution() != TNaming_SELECTED) { + theOriginalLabel = aNS->Label(); + return true; + } + } + } + } + if (!theAccess2.IsNull()) { + static const TDF_Label anEmpty; + return isShapeInTree(theAccess2, anEmpty, theShape, theOriginalLabel); + } + return false; } -void Model_BodyBuilder::loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated) +/// Stores entry to the external label in the entries list at this label +static void storeExternalReference(const TDF_Label& theExternal, const TDF_Label theThis) { - static const int THE_ANCHOR_TAG = 100000; + // store information about the external document reference to restore old shape on open + if (!theExternal.IsNull() && !theExternal.Root().IsEqual(theThis.Root())) { + Handle(TDataStd_ExtStringList) anEntries; + if (!theThis.FindAttribute(kEXTERNAL_SHAPE_REF, anEntries)) { + anEntries = TDataStd_ExtStringList::Set(theThis, kEXTERNAL_SHAPE_REF); + } + TCollection_AsciiString anEntry; + TDF_Tool::Entry(theExternal, anEntry); + // check it already contains this entry + TDataStd_ListOfExtendedString::Iterator anIter(anEntries->List()); + for(; anIter.More(); anIter.Next()) + if (anIter.Value() == anEntry) + break; + if (!anIter.More()) { + anEntries->Append(anEntry); + } + } +} - int anIndex = 1; - int aTag = theTag; - bool isBuilt = !theName.empty(); - std::string aName = theName; - std::ostringstream aStream; +void Model_BodyBuilder::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) +{ GeomShapePtr aResultShape = shape(); - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - - TopoDS_Shape aShapeToIterate; - if (theMS->newShapesCollected(theShapeIn, theKindOfShape)) { + GeomShapePtr aShapeToExplore = theOldShape; + if (theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) { // use optimized set of old shapes for this - GeomShapePtr aCompound = theMS->oldShapesForNew(theShapeIn, aResultShape, theKindOfShape); - if (aCompound.get()) - aShapeToIterate = aCompound->impl(); - } else { - aShapeToIterate = aShapeIn; + GeomShapePtr aCompound = theAlgo->oldShapesForNew(theOldShape, + aResultShape, + theShapeTypeToExplore); + if (aCompound.get()) aShapeToExplore = aCompound; } - TopExp_Explorer aShapeExplorer (aShapeToIterate, (TopAbs_ShapeEnum)theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - - bool aNotInTree = - TNaming_Tool::NamedShape(aRoot, aData->shapeLab()).IsNull(); - if (aNotInTree && !theIsStoreSeparate) { - // there is no sense to write history if old shape does not exist in the document - continue; // but if it is stored separately, it will be builded as a primitive + TopTools_MapOfShape anAlreadyProcessedShapes; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + for (GeomAPI_ShapeExplorer anOldShapeExp(aShapeToExplore, theShapeTypeToExplore); + anOldShapeExp.more(); + anOldShapeExp.next()) + { + GeomShapePtr anOldSubShape = anOldShapeExp.current(); + const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl(); + + // There is no sense to write history if shape already processed + // or old shape does not exist in the document. + bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_); + TDF_Label anAccess2 = std::dynamic_pointer_cast( + ModelAPI_Session::get()->moduleDocument())->generalLabel(); + TDF_Label anOriginalLabel; + bool anOldSubShapeNotInTree = + !isShapeInTree(aData->shapeLab(), anAccess2, anOldSubShape_, anOriginalLabel); + if (anOldSubShapeAlreadyProcessed || anOldSubShapeNotInTree) { + continue; } - ListOfShape aList; - std::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->modified(aRShape, aList); - if (!theIsStoreSeparate) { - //keepTopLevelShapes(aList, aRoot, aResultShape); - removeBadShapes(aList); - } - // sort the list of images before naming - GeomAlgoAPI_SortListOfShapes::sort(aList); + // Get new shapes. + ListOfShape aNewShapes; + theAlgo->modified(anOldSubShape, aNewShapes); - // to trace situation where several objects are produced by one parent (#2317) - 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++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - std::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); - } - 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 + for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin(); + aNewShapesIt != aNewShapes.cend(); + ++aNewShapesIt) + { + GeomShapePtr aNewShape = *aNewShapesIt; + const TopoDS_Shape& aNewShape_ = aNewShape->impl(); + bool isGenerated = anOldSubShape_.ShapeType() != aNewShape_.ShapeType(); + + bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape); + bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false); + if (aNewShapeIsSameAsOldShape + || aNewShapeIsNotInResultShape) { - if (!theIsStoreSeparate) { - aSameParentShapes++; - } 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) { - bool aFound = false; - TopoDS_Shape aResultTShape = aResultShape->impl(); - TopExp_Explorer anAncestorExp(aResultTShape, anAncestorType); - for(; anAncestorExp.More() && !aFound; anAncestorExp.Next()) { - if (aResultTShape.IsSame(anAncestorExp.Current())) - continue; - TopExp_Explorer aSubExp(anAncestorExp.Current(), aNewType); - for(; aSubExp.More(); aSubExp.Next()) { - if (aNewShape.IsSame(aSubExp.Current())) { - aFound = true; - break; - } - } - } - if (aFound) { - continue; // not need to store this shape in the BRep structure - } - } - } - - 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; - } + continue; + } - if (isFoundSameOld) { - // Builder already contains same old->new shapes, don't store it twice. + TNaming_Builder* aBuilder; + if (aResultShape->isSame(aNewShape)) { + // keep the modification evolution on the root level (2241 - history propagation issue) + aBuilder = builder(0); + TDF_Label aShapeLab = aBuilder->NamedShape()->Label(); + Handle(TDF_Reference) aRef; + if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) { + // Store only in case if it does not have reference. 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 (aCurShapeType != theKindOfShape) { - // modified shape has different type => set another tag - // to avoid shapes of different types on the same label - aBuilderTag = THE_ANCHOR_TAG; - needSuffix = true; - } - std::string aSuffix; - if (needSuffix) { - switch (aCurShapeType) { - 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; - } - } + // Check if new shape was already stored. + if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue; - if(theIsStoreAsGenerated) { - // 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 (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 (!aBuilder->NamedShape().IsNull() && + ((isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) + || (!isGenerated && aBuilder->NamedShape()->Evolution() != TNaming_MODIFY))) + { + myBuilders.erase(0); // clear old builder to avoid different evolutions crash + aBuilder = builder(0); } - if(isBuilt) { - aStream.str(std::string()); - aStream.clear(); - aStream << theName; - if (theIsStoreSeparate && !isFoundDiffOld) - aStream << "_" << anIndex++; + } else { + int aTag = isGenerated ? getGenerationTag(aNewShape_) + : getModificationTag(aNewShape_); + aBuilder = builder(aTag); - if (aSameParentShapes > 0) { - aStream.str(std::string()); - aStream.clear(); - aStream << aName << "_" << "divided" << "_" << myDividedIndex++; - } + // Check if new shape was already stored. + if (isAlreadyStored(aBuilder, anOldSubShape_, aNewShape_)) continue; - aStream << aSuffix; - buildName(aBuilderTag, aStream.str()); - } - if(theIsStoreSeparate && !isFoundDiffOld) { - aTag++; - } - } else if (aResultShape->isSame(*anIt)) { - // keep the modification evolution on the root level (2241 - history propagation issue) - 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) { - TNaming_Builder* aBuilder = builder(0); - if (!aBuilder->NamedShape().IsNull() && - aBuilder->NamedShape()->Evolution() != TNaming_GENERATED) { - myBuilders.erase(0); // clear old builder to avoid different evolutions crash - } - builder(0)->Generated(aRoot, aNewShape); - } else { - TNaming_Builder* aBuilder = builder(0); - if (!aBuilder->NamedShape().IsNull() && - aBuilder->NamedShape()->Evolution() != TNaming_MODIFY) { - myBuilders.erase(0); // clear old builder to avoid different evolutions crash - } - builder(0)->Modify(aRoot, aNewShape); - } - } + buildName(aTag, theName); } + + isGenerated ? aBuilder->Generated(anOldSubShape_, aNewShape_) + : aBuilder->Modify(anOldSubShape_, aNewShape_); + // store information about the external document reference to restore old shape on open + storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label()); } } } -void Model_BodyBuilder::loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) +void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - TopoDS_Shape aShapeIn = theShapeIn->impl(); - TopTools_MapOfShape aView; - bool isBuilt = !theName.empty(); - TopExp_Explorer aShapeExplorer (aShapeIn, (TopAbs_ShapeEnum)theKindOfShape); - for (; aShapeExplorer.More(); aShapeExplorer.Next ()) { - const TopoDS_Shape& aRoot = aShapeExplorer.Current (); - if (!aView.Add(aRoot)) continue; - //if (TNaming_Tool::NamedShape(aRoot, builder(theTag)->NamedShape()->Label()).IsNull()) - // continue; // there is no sense to write history if old shape does not exist in the document - ListOfShape aList; - std::shared_ptr aRShape(new GeomAPI_Shape()); - aRShape->setImpl((new TopoDS_Shape(aRoot))); - theMS->generated(aRShape, aList); - keepTopLevelShapes(aList, aRoot); - std::list >::const_iterator - anIt = aList.begin(), aLast = aList.end(); - for (; anIt != aLast; anIt++) { - TopoDS_Shape aNewShape = (*anIt)->impl(); - if (theSubShapes.isBound(*anIt)) { - std::shared_ptr aMapShape(theSubShapes.find(*anIt)); - aNewShape.Orientation(aMapShape->impl().Orientation()); - } - if (!aRoot.IsSame (aNewShape)) { - builder(theTag)->Generated(aRoot,aNewShape); - if(isBuilt) - buildName(theTag, theName); + GeomShapePtr aResultShape = shape(); + TopTools_MapOfShape anAlreadyProcessedShapes; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + for (GeomAPI_ShapeExplorer anOldShapeExp(theOldShape, theShapeTypeToExplore); + anOldShapeExp.more(); + anOldShapeExp.next()) + { + GeomShapePtr anOldSubShape = anOldShapeExp.current(); + const TopoDS_Shape& anOldSubShape_ = anOldSubShape->impl(); + + // There is no sense to write history if shape already processed + // or old shape does not exist in the document. + bool anOldSubShapeAlreadyProcessed = !anAlreadyProcessedShapes.Add(anOldSubShape_); + TDF_Label anAccess2 = std::dynamic_pointer_cast( + ModelAPI_Session::get()->moduleDocument())->generalLabel(); + TDF_Label anOriginalLabel; + bool anOldSubShapeNotInTree = + !isShapeInTree(aData->shapeLab(), anAccess2, anOldSubShape_, anOriginalLabel); + if (anOldSubShapeAlreadyProcessed || anOldSubShapeNotInTree) { + continue; + } + + // Get new shapes. + ListOfShape aNewShapes; + theAlgo->generated(anOldSubShape, aNewShapes); + + keepTopLevelShapes(aNewShapes, anOldSubShape_); + + for (ListOfShape::const_iterator aNewShapesIt = aNewShapes.cbegin(); + aNewShapesIt != aNewShapes.cend(); + ++aNewShapesIt) + { + GeomShapePtr aNewShape = *aNewShapesIt; + const TopoDS_Shape& aNewShape_ = aNewShape->impl(); + + bool aNewShapeIsSameAsOldShape = anOldSubShape->isSame(aNewShape); + bool aNewShapeIsNotInResultShape = !aResultShape->isSubShape(aNewShape, false); + if (aNewShapeIsSameAsOldShape + || aNewShapeIsNotInResultShape) + { + continue; } - TopAbs_ShapeEnum aGenShapeType = aNewShape.ShapeType(); - if(aGenShapeType == TopAbs_WIRE || aGenShapeType == TopAbs_SHELL) { - TopAbs_ShapeEnum anExplodeShapeType = - aGenShapeType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE; - const TDF_Label aLabel = builder(theTag)->NamedShape()->Label(); - int aTag = 1; - std::shared_ptr aDoc = - std::dynamic_pointer_cast(document()); - for(TopExp_Explorer anExp(aNewShape, anExplodeShapeType); anExp.More(); anExp.Next()) { - TDF_Label aChildLabel = aLabel.FindChild(aTag); - TNaming_Builder aBuilder(aChildLabel); - aBuilder.Generated(aRoot, anExp.Current()); - TCollection_AsciiString aChildName = - TCollection_AsciiString((theName + "_").c_str()) + aTag; - TDataStd_Name::Set(aChildLabel, aChildName.ToCString()); - aTag++; + + TopAbs_ShapeEnum aNewShapeType = aNewShape_.ShapeType(); + if (aNewShapeType == TopAbs_WIRE || aNewShapeType == TopAbs_SHELL) { + // TODO: This is a workaround. New shape should be only edge or face. + TopAbs_ShapeEnum aShapeTypeToExplore = aNewShapeType == TopAbs_WIRE ? TopAbs_EDGE + : TopAbs_FACE; + int aTag = TopAbs_WIRE ? GENERATED_EDGES_TAG : GENERATED_FACES_TAG; + for (TopExp_Explorer anExp(aNewShape_, aShapeTypeToExplore); anExp.More(); anExp.Next()) { + builder(aTag)->Generated(anOldSubShape_, anExp.Current()); + // store information about the external document reference to restore old shape on open + storeExternalReference(anOriginalLabel, builder(aTag)->NamedShape()->Label()); } + buildName(aTag, theName); + } + else { + int aTag = getGenerationTag(aNewShape_); + if (aTag == INVALID_TAG) return; + builder(aTag)->Generated(anOldSubShape_, aNewShape_); + buildName(aTag, theName); + // store information about the external document reference to restore old shape on open + storeExternalReference(anOriginalLabel, builder(aTag)->NamedShape()->Label()); } } } } +// LCOV_EXCL_START //======================================================================= int getDangleShapes(const TopoDS_Shape& theShapeIn, const TopAbs_ShapeEnum theGeneratedFrom, @@ -811,10 +675,11 @@ void loadGeneratedDangleShapes( for (; itr.More(); itr.Next()) theBuilder->Generated(itr.Key(), itr.Value()); } +// LCOV_EXCL_STOP //======================================================================= -void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void Model_BodyBuilder::loadNextLevels(GeomShapePtr theShape, + const std::string& theName) { if(theShape->isNull()) return; TopoDS_Shape aShape = theShape->impl(); @@ -822,11 +687,11 @@ void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, if (aShape.ShapeType() == TopAbs_SOLID) { TopExp_Explorer expl(aShape, TopAbs_FACE); for (; expl.More(); expl.Next()) { - builder(theTag)->Generated(expl.Current()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(expl.Current()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } } else if (aShape.ShapeType() == TopAbs_SHELL || aShape.ShapeType() == TopAbs_FACE) { @@ -836,11 +701,11 @@ void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, if (Faces.Extent() > 1 || (aShape.ShapeType() == TopAbs_SHELL && Faces.Extent() == 1)) { TopExp_Explorer expl(aShape, TopAbs_FACE); for (; expl.More(); expl.Next()) { - builder(theTag)->Generated(expl.Current()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(expl.Current()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } } TopTools_IndexedDataMapOfShapeListOfShape anEdgeAndNeighbourFaces; @@ -851,21 +716,21 @@ void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, if (aLL.Extent() < 2) { if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeAndNeighbourFaces.FindKey(i)))) continue; - builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i)); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i)); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } else { TopTools_ListIteratorOfListOfShape anIter(aLL); const TopoDS_Face& aFace = TopoDS::Face(anIter.Value()); anIter.Next(); if(aFace.IsEqual(anIter.Value())) { - builder(theTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i)); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(anEdgeAndNeighbourFaces.FindKey(i)); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } } } @@ -873,40 +738,40 @@ void Model_BodyBuilder::loadNextLevels(std::shared_ptr theShape, TopTools_IndexedMapOfShape Edges; BRepTools::Map3DEdges(aShape, Edges); if (Edges.Extent() == 1) { - builder(theTag++)->Generated(Edges.FindKey(1)); + builder(myFreePrimitiveTag++)->Generated(Edges.FindKey(1)); TopExp_Explorer expl(aShape, TopAbs_VERTEX); for (; expl.More(); expl.Next()) { - builder(theTag)->Generated(expl.Current()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(expl.Current()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } } else { TopExp_Explorer expl(aShape, TopAbs_EDGE); for (; expl.More(); expl.Next()) { - builder(theTag)->Generated(expl.Current()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(expl.Current()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } // and load generated vertices. TopTools_DataMapOfShapeShape generated; if (getDangleShapes(aShape, TopAbs_EDGE, generated)) { - TNaming_Builder* pBuilder = builder(theTag++); + TNaming_Builder* pBuilder = builder(myFreePrimitiveTag++); loadGeneratedDangleShapes(aShape, TopAbs_EDGE, pBuilder); } } } else if (aShape.ShapeType() == TopAbs_EDGE) { TopExp_Explorer expl(aShape, TopAbs_VERTEX); for (; expl.More(); expl.Next()) { - builder(theTag)->Generated(expl.Current()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(expl.Current()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; } } } @@ -969,8 +834,7 @@ int findAmbiguities(const TopoDS_Shape& theShapeIn, } //======================================================================= -void Model_BodyBuilder::loadFirstLevel( - std::shared_ptr theShape, const std::string& theName, int& theTag) +void Model_BodyBuilder::loadFirstLevel(GeomShapePtr theShape, const std::string& theName) { if(theShape->isNull()) return; TopoDS_Shape aShape = theShape->impl(); @@ -978,158 +842,41 @@ void Model_BodyBuilder::loadFirstLevel( if (aShape.ShapeType() == TopAbs_COMPOUND || aShape.ShapeType() == TopAbs_COMPSOLID) { TopoDS_Iterator itr(aShape); for (; itr.More(); itr.Next()) { - builder(theTag)->Generated(itr.Value()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - if(!theName.empty()) buildName(theTag, aName); - theTag++; + builder(myFreePrimitiveTag)->Generated(itr.Value()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); + ++myFreePrimitiveTag; if (itr.Value().ShapeType() == TopAbs_COMPOUND || itr.Value().ShapeType() == TopAbs_COMPSOLID) { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(itr.Value())); - loadFirstLevel(itrShape, theName, theTag); + loadFirstLevel(itrShape, theName); } else { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(itr.Value())); - loadNextLevels(itrShape, theName, theTag); + loadNextLevels(itrShape, theName); } } } else { - std::shared_ptr itrShape(new GeomAPI_Shape()); + GeomShapePtr itrShape(new GeomAPI_Shape()); itrShape->setImpl(new TopoDS_Shape(aShape)); - loadNextLevels(itrShape, theName, theTag); + loadNextLevels(itrShape, theName); } TopTools_ListOfShape aList; if(findAmbiguities(aShape, aList)) { TopTools_ListIteratorOfListOfShape it(aList); - for (; it.More(); it.Next(),theTag++) { - builder(theTag)->Generated(it.Value()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - } - } -} - -//======================================================================= -void Model_BodyBuilder::loadDisconnectedEdges( - std::shared_ptr theShape, const std::string& theName, int& theTag) -{ - if(theShape->isNull()) return; - TopoDS_Shape aShape = theShape->impl(); - TopTools_DataMapOfShapeListOfShape edgeNaborFaces; - TopTools_ListOfShape empty; - TopExp_Explorer explF(aShape, TopAbs_FACE); - for (; explF.More(); explF.Next()) { - const TopoDS_Shape& aFace = explF.Current(); - TopExp_Explorer explV(aFace, TopAbs_EDGE); - for (; explV.More(); explV.Next()) { - const TopoDS_Shape& anEdge = explV.Current(); - if (!edgeNaborFaces.IsBound(anEdge)) edgeNaborFaces.Bind(anEdge, empty); - Standard_Boolean faceIsNew = Standard_True; - TopTools_ListIteratorOfListOfShape itrF(edgeNaborFaces.Find(anEdge)); - for (; itrF.More(); itrF.Next()) { - if (itrF.Value().IsSame(aFace)) { - faceIsNew = Standard_False; - break; - } - } - if (faceIsNew) - edgeNaborFaces.ChangeFind(anEdge).Append(aFace); - } - } - - TopTools_MapOfShape anEdgesToDelete; - TopExp_Explorer anEx(aShape,TopAbs_EDGE); - std::string aName; - for(;anEx.More();anEx.Next()) { - Standard_Boolean aC0 = Standard_False; - TopoDS_Shape anEdge1 = anEx.Current(); - if (edgeNaborFaces.IsBound(anEdge1)) { - const TopTools_ListOfShape& aList1 = edgeNaborFaces.Find(anEdge1); - if (aList1.Extent()<2) continue; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(edgeNaborFaces); - for (; itr.More(); itr.Next()) { - TopoDS_Shape anEdge2 = itr.Key(); - if(anEdgesToDelete.Contains(anEdge2)) continue; - if (anEdge1.IsSame(anEdge2)) continue; - const TopTools_ListOfShape& aList2 = itr.Value(); - // compare lists of the neighbour faces of edge1 and edge2 - if (aList1.Extent() == aList2.Extent()) { - Standard_Integer aMatches = 0; - for(TopTools_ListIteratorOfListOfShape aLIter1(aList1);aLIter1.More();aLIter1.Next()) - for(TopTools_ListIteratorOfListOfShape aLIter2(aList2);aLIter2.More();aLIter2.Next()) - if (aLIter1.Value().IsSame(aLIter2.Value())) aMatches++; - if (aMatches == aList1.Extent()) { - aC0=Standard_True; - builder(theTag)->Generated(anEdge2); - anEdgesToDelete.Add(anEdge2); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; - } - } - } - TopTools_MapIteratorOfMapOfShape itDelete(anEdgesToDelete); - for(;itDelete.More();itDelete.Next()) - edgeNaborFaces.UnBind(itDelete.Key()); - edgeNaborFaces.UnBind(anEdge1); - } - if (aC0) { - builder(theTag)->Generated(anEdge1); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; - } - } -} - -void Model_BodyBuilder::loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag) -{ - if(theShape->isNull()) return; - TopoDS_Shape aShape = theShape->impl(); - TopTools_DataMapOfShapeListOfShape vertexNaborEdges; - TopTools_ListOfShape empty; - TopExp_Explorer explF(aShape, TopAbs_EDGE); - for (; explF.More(); explF.Next()) { - const TopoDS_Shape& anEdge = explF.Current(); - TopExp_Explorer explV(anEdge, TopAbs_VERTEX); - for (; explV.More(); explV.Next()) { - const TopoDS_Shape& aVertex = explV.Current(); - if (!vertexNaborEdges.IsBound(aVertex)) vertexNaborEdges.Bind(aVertex, empty); - Standard_Boolean faceIsNew = Standard_True; - TopTools_ListIteratorOfListOfShape itrF(vertexNaborEdges.Find(aVertex)); - for (; itrF.More(); itrF.Next()) { - if (itrF.Value().IsSame(anEdge)) { - faceIsNew = Standard_False; - break; - } - } - if (faceIsNew) { - vertexNaborEdges.ChangeFind(aVertex).Append(anEdge); - } - } - } - std::string aName; - TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itr(vertexNaborEdges); - for (; itr.More(); itr.Next()) { - const TopTools_ListOfShape& naborEdges = itr.Value(); - if (naborEdges.Extent() < 2) { - builder(theTag)->Generated(itr.Key()); - TCollection_AsciiString aStr(theTag); - aName = theName + aStr.ToCString(); - buildName(theTag, aName); - theTag++; + for (; it.More(); it.Next(), ++myFreePrimitiveTag) { + builder(myFreePrimitiveTag)->Generated(it.Value()); + TCollection_AsciiString aStr(myFreePrimitiveTag - PRIMITIVES_START_TAG + 1); + aName = theName + "_" + aStr.ToCString(); + buildName(myFreePrimitiveTag, aName); } } } -std::shared_ptr Model_BodyBuilder::shape() +GeomShapePtr Model_BodyBuilder::shape() { std::shared_ptr aData = std::dynamic_pointer_cast(data()); if (aData && aData->isValid()) { @@ -1142,36 +889,11 @@ std::shared_ptr Model_BodyBuilder::shape() if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { TopoDS_Shape aShape = aName->Get(); if (!aShape.IsNull()) { - std::shared_ptr aRes(new GeomAPI_Shape); + GeomShapePtr aRes(new GeomAPI_Shape); aRes->setImpl(new TopoDS_Shape(aShape)); return aRes; } } } - return std::shared_ptr(); -} - -bool Model_BodyBuilder::isLatestEqual(const std::shared_ptr& theShape) -{ - if (theShape.get()) { - TopoDS_Shape aShape = theShape->impl(); - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - if (aData) { - TDF_Label& aShapeLab = aData->shapeLab(); - Handle(TNaming_NamedShape) aName; - if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aLatest = TNaming_Tool::CurrentShape(aName); - if (aLatest.IsNull()) - return false; - if (aLatest.IsEqual(aShape)) - return true; - // check sub-shapes for comp-solids: - for (TopExp_Explorer anExp(aShape, aLatest.ShapeType()); anExp.More(); anExp.Next()) { - if (aLatest.IsEqual(anExp.Current())) - return true; - } - } - } - } - return false; + return GeomShapePtr(); } diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index d34fb0b17..0689a0f52 100755 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -41,101 +41,73 @@ class Model_BodyBuilder : public ModelAPI_BodyBuilder std::map myBuilders; public: /// Stores the shape (called by the execution method). - MODEL_EXPORT virtual void store(const std::shared_ptr& theShape, + MODEL_EXPORT virtual void store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes = true); /// Stores the generated shape (called by the execution method). - MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape); + MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape); /// Stores the modified shape (called by the execution method). /// \param theOldShape shape that produces result /// \param theNewShape resulting shape /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case /// theNewShape is compound of solids, if zero it is not used - MODEL_EXPORT virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag = 0); - - /// Stores the shape without naming support - /// \param theShape shape to store - MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr& theShape); + MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true) override; /// Returns the shape-result produced by this feature - MODEL_EXPORT virtual std::shared_ptr shape(); + MODEL_EXPORT virtual GeomShapePtr shape(); /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - MODEL_EXPORT virtual void generated(const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); + /// Returns true if it is stored correctly (the final shape contains this new sub-shape) + MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult = true) override; /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - MODEL_EXPORT virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); + MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") override; /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - MODEL_EXPORT virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); - - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - MODEL_EXPORT virtual void deleted(const std::shared_ptr& theOldShape, - const int theTag = 1); + MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") override; /// load deleted shapes - MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()); + MODEL_EXPORT + virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override; + /// load and orient modified shapes - MODEL_EXPORT virtual void loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, - const bool theIsStoreAsGenerated = false); - /// load and orient generated shapes - MODEL_EXPORT virtual void loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes); + MODEL_EXPORT + virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") override; + + /// load and orient generated shapes + MODEL_EXPORT + virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") override; /// Loads shapes of the first level (to be used during shape import) - MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag); - - /// Loads disconnected edges - MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag); - - /// Loads disconnected vetexes - MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag); + MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName) override; /// Removes the stored builders MODEL_EXPORT virtual ~Model_BodyBuilder(); - /// Converts evolution of sub-shapes stored in naming structure to selection - /// (theFlag = true) and back (theFlag = false) - MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag); - - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); - protected: /// Default constructor accessible only by Model_Objects Model_BodyBuilder(ModelAPI_Object* theOwner); @@ -148,17 +120,21 @@ protected: private: /// Loads shapes of the next level (to be used during shape import) - void loadNextLevels(std::shared_ptr theShape, - const std::string& theName, int& theTag); + void loadNextLevels(GeomShapePtr theShape, + const std::string& theName); /// 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; + struct IndexTags { + int index; + std::vector tags; + }; + +private: + int myFreePrimitiveTag; + std::map myPrimitivesNamesIndexMap; private: friend class Model_ResultBody; diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index d7d14ad8c..bfc463057 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -111,7 +111,7 @@ void Model_Data::setLabel(TDF_Label theLab) std::string Model_Data::name() { Handle(TDataStd_Name) aName; - if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) { + if (shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { #ifdef DEBUG_NAMES myObject->myName = TCollection_AsciiString(aName->Get()).ToCString(); #endif @@ -125,8 +125,8 @@ void Model_Data::setName(const std::string& theName) bool isModified = false; std::string anOldName = name(); Handle(TDataStd_Name) aName; - if (!myLab.FindAttribute(TDataStd_Name::GetID(), aName)) { - TDataStd_Name::Set(myLab, theName.c_str()); + if (!shapeLab().FindAttribute(TDataStd_Name::GetID(), aName)) { + TDataStd_Name::Set(shapeLab(), theName.c_str()); isModified = true; } else { isModified = !aName->Get().IsEqual(theName.c_str()); @@ -143,7 +143,7 @@ void Model_Data::setName(const std::string& theName) } if (isUserDefined) { // name is user-defined, thus special attribute is set - TDataStd_UAttribute::Set(myLab, kUSER_DEFINED_NAME); + TDataStd_UAttribute::Set(shapeLab(), kUSER_DEFINED_NAME); } } } @@ -151,7 +151,7 @@ void Model_Data::setName(const std::string& theName) ModelAPI_ObjectRenamedMessage::send(myObject, anOldName, theName, this); if (isModified && myObject && myObject->document()) { std::dynamic_pointer_cast(myObject->document())-> - changeNamingName(anOldName, theName, myLab); + changeNamingName(anOldName, theName, shapeLab()); } #ifdef DEBUG_NAMES myObject->myName = theName; @@ -160,7 +160,7 @@ void Model_Data::setName(const std::string& theName) bool Model_Data::hasUserDefinedName() const { - return myLab.IsAttribute(kUSER_DEFINED_NAME); + return shapeLab().IsAttribute(kUSER_DEFINED_NAME); } AttributePtr Model_Data::addAttribute(const std::string& theID, const std::string theAttrType) @@ -346,10 +346,10 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) } } else { // trim: need to redisplay - if (myObject) { + /*if (myObject) { static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); - } + }*/ } } diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index 598193cb8..2ed26625f 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -172,9 +172,9 @@ class Model_Data : public ModelAPI_Data MODEL_EXPORT virtual bool isValid(); /// Returns the label where the shape must be stored (used in ResultBody) - TDF_Label& shapeLab() + TDF_Label shapeLab() const { - return myLab; + return myLab.IsNull() ? myLab : myLab.Father().FindChild(2); } /// Initializes object by the attributes: must be called just after the object is created diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 7acdecde2..99a624ae0 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -51,13 +52,18 @@ #include #include #include +#include #include +#include #include #include #include #include #include #include +#include +#include +#include #include #include @@ -85,13 +91,16 @@ static const int TAG_GENERAL = 1; // general properties tag // general sub-labels /// where the reference to the current feature label is located (or no attribute if null feature) static const int TAG_CURRENT_FEATURE = 1; ///< reference to the current feature -/// integer, index of the transaction + GUID for auto recomutation blocking +/// integer, index of the transaction + GUID for auto recomputation blocking static const int TAG_CURRENT_TRANSACTION = 2; static const int TAG_SELECTION_FEATURE = 3; ///< integer, tag of the selection feature label static const int TAG_NODES_STATE = 4; ///< array, tag of the Object Browser nodes states ///< naming structures constructions selected from other document static const int TAG_EXTERNAL_CONSTRUCTIONS = 5; +/// reference to the shape in external document: sting list attribute identifier +static const Standard_GUID kEXTERNAL_SHAPE_REF("9aa5dd14-6d34-4a8d-8786-05842fd7bbbd"); + Model_Document::Model_Document(const int theID, const std::string theKind) : myID(theID), myKind(theKind), myIsActive(false), myIsSetCurrentFeature(false), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format @@ -136,6 +145,82 @@ bool Model_Document::isRoot() const return this == Model_Session::get()->moduleDocument().get(); } +/// Makes all modification and generation naming shapes that have old shapes corresponding to +/// shapes in a root document be equal to this root document +static void updateShapesFromRoot(const TDF_Label theThisAccess, const TDF_Label theRootAccess) +{ + TopTools_DataMapOfShapeShape aCurrentToRoot; // shapes that must be updated: from this to root + TDF_ChildIDIterator aThisIter(theThisAccess.Root(), kEXTERNAL_SHAPE_REF, true); + for(; aThisIter.More(); aThisIter.Next()) { + aCurrentToRoot.Clear(); + Handle(TNaming_NamedShape) aNS; + if (!aThisIter.Value()->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) + continue; + if (aNS->Evolution() != TNaming_GENERATED && aNS->Evolution() != TNaming_MODIFY) + continue; + for (TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) { + const TopoDS_Shape& anOld = aNSIter.OldShape(); + if (anOld.IsNull()) + continue; + TNaming_OldShapeIterator aNewIter(anOld, theThisAccess); + for (; aNewIter.More(); aNewIter.Next()) { + TNaming_Evolution anEvolution = aNewIter.NamedShape()->Evolution(); + if (anEvolution != TNaming_SELECTED && anEvolution != TNaming_DELETE) + break; + } + if (aNewIter.More()) + continue; + GeomShapePtr anOldShape(new GeomAPI_Shape), aRootShape(new GeomAPI_Shape); + anOldShape->setImpl(new TopoDS_Shape(anOld)); + anOldShape = GeomAPI_Tools::getTypedShape(anOldShape); + + // search the same shape in the root document + Handle(TDataStd_ExtStringList) anEntries = + Handle(TDataStd_ExtStringList)::DownCast(aThisIter.Value()); + TDataStd_ListOfExtendedString::Iterator anIter(anEntries->List()); + for (; anIter.More(); anIter.Next()) { + TDF_Label aRootLab; + TDF_Tool::Label(theRootAccess.Data(), anIter.Value(), aRootLab); + if (aRootLab.IsNull()) + continue; + Handle(TNaming_NamedShape) aRootNS; + if (!aRootLab.FindAttribute(TNaming_NamedShape::GetID(), aRootNS)) + continue; + TNaming_Iterator aRootShapes(aRootNS); + for (; aRootShapes.More(); aRootShapes.Next()) { + if (aRootShapes.NewShape().IsNull()) + continue; + aRootShape->setImpl(new TopoDS_Shape(aRootShapes.NewShape())); + aRootShape = GeomAPI_Tools::getTypedShape(aRootShape); + if (!anOldShape->isEqual(aRootShape)) // special checking by geometry + continue; + // found a good corresponded shape + if (!anOld.IsEqual(aRootShapes.NewShape())) + aCurrentToRoot.Bind(anOld, aRootShapes.NewShape()); + } + } + } + if (!aCurrentToRoot.IsEmpty()) { // update the whole named shape content + TopTools_ListOfShape anOld, aNew; + TNaming_Evolution anEvol = aNS->Evolution(); + for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) { + anOld.Prepend(aCurrentToRoot.IsBound(aNSIter.OldShape()) ? + aCurrentToRoot.Find(aNSIter.OldShape()) : aNSIter.OldShape()); + aNew.Prepend(aNSIter.NewShape()); + } + TNaming_Builder aBuilder(aNS->Label()); + TopTools_ListOfShape::Iterator anOldIter(anOld), aNewIter(aNew); + for(; anOldIter.More(); anOldIter.Next(), aNewIter.Next()) { + if (anEvol == TNaming_GENERATED) { + aBuilder.Generated(anOldIter.Value(), aNewIter.Value()); + } else if (anEvol == TNaming_MODIFY) { + aBuilder.Modify(anOldIter.Value(), aNewIter.Value()); + } + } + } + } +} + bool Model_Document::load(const char* theDirName, const char* theFileName, DocumentPtr theThis) { Handle(Model_Application) anApp = Model_Application::getApplication(); @@ -220,12 +305,12 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum aSession->setCheckTransactions(false); if (myObjs) delete myObjs; - myObjs = new Model_Objects(myDoc->Main()); // synchronisation is inside + myObjs = new Model_Objects(myDoc->Main()); // synchronization is inside myObjs->setOwner(theThis); // update the current features status setCurrentFeature(currentFeature(false), false); aSession->setCheckTransactions(true); - aSession->setActiveDocument(Model_Session::get()->moduleDocument(), false); + aSession->setActiveDocument(aSession->moduleDocument(), false); // this is done in Part result "activate", so no needed here. Causes not-blue active part. // aSession->setActiveDocument(anApp->getDocument(myID), true); @@ -239,8 +324,11 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum anApp->setLoadByDemand(aPart->data()->name(), aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->docId()); } - - } else { // open failed, but new documnet was created to work with it: inform the model + if (!isRoot()) { + updateShapesFromRoot(myDoc->Main(), + std::dynamic_pointer_cast(aSession->moduleDocument())->generalLabel()); + } + } else { // open failed, but new document was created to work with it: inform the model aSession->setActiveDocument(Model_Session::get()->moduleDocument(), false); } return !isError; @@ -369,10 +457,10 @@ void Model_Document::close(const bool theForever) aSub->close(theForever); } - // close for thid document needs no transaction in this document + // close for this document needs no transaction in this document std::static_pointer_cast(Model_Session::get())->setCheckTransactions(false); - // close all only if it is really asked, otherwise it can be undoed/redoed + // close all only if it is really asked, otherwise it can be undone/redone if (theForever) { // flush everything to avoid messages with bad objects delete myObjs; @@ -425,7 +513,7 @@ void Model_Document::compactNested() aSumOfTransaction += myTransactions.rbegin()->myOCAFNum; myTransactions.pop_back(); } - // the latest transaction is the start of lower-level operation which startes the nested + // the latest transaction is the start of lower-level operation which starts the nested myTransactions.rbegin()->myOCAFNum += aSumOfTransaction; myNestedNum.pop_back(); } @@ -521,7 +609,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) return false; } -/// Returns true if the last transaction is actually empty: modification to te same values +/// Returns true if the last transaction is actually empty: modification to the same values /// were performed only static bool isEmptyTransaction(const Handle(TDocStd_Document)& theDoc) { Handle(TDF_Delta) aDelta; @@ -568,7 +656,7 @@ bool Model_Document::finishOperation() // do it before flashes to enable and recompute nesting features correctly if (myNestedNum.empty() || (isNestedClosed && myNestedNum.size() == 1)) { // if all nested operations are closed, make current the higher level objects (to perform - // it in the python scripts correctly): sketch become current after creation ofsub-elements + // it in the python scripts correctly): sketch become current after creation of sub-elements FeaturePtr aCurrent = currentFeature(false); CompositeFeaturePtr aMain, aNext = ModelAPI_Tools::compositeOwner(aCurrent); while(aNext.get()) { @@ -627,7 +715,7 @@ bool Model_Document::finishOperation() // transaction may be empty if this document was created during this transaction (create part) if (!myTransactions.empty() && myDoc->CommitCommand()) { - // if commit is successfull, just increment counters + // if commit is successful, just increment counters if (isEmptyTransaction(myDoc)) { // erase this transaction myDoc->Undo(); myDoc->ClearRedos(); @@ -647,7 +735,7 @@ bool Model_Document::finishOperation() // nothing inside in all documents, so remove this transaction from the transactions list undoInternal(true, false); } - // on finish clear redos in any case (issue 446) and for all subs (issue 408) + // on finish clear redo in any case (issue 446) and for all subs (issue 408) myDoc->ClearRedos(); myRedos.clear(); for (aSubIter = aSubs.begin(); aSubIter != aSubs.end(); aSubIter++) { @@ -683,7 +771,7 @@ static void modifiedLabels(const Handle(TDocStd_Document)& theDoc, TDF_LabelList if (anAttr.Value()->Attribute()->ID() == TNaming_NamedShape::GetID()) { anExcludedInt.Add(anAttr.Value()->Label()); // named shape evolution is changed in history update => skip them, - // they are not the features arguents + // they are not the features arguments continue; } if (anAttr.Value()->Attribute()->ID() == TDataStd_Integer::GetID()) { @@ -755,7 +843,7 @@ bool Model_Document::isOperation() const bool Model_Document::isModified() { - // is modified if at least one operation was commited and not undoed + // is modified if at least one operation was committed and not undone return myTransactions.size() != myTransactionSave || isOperation(); } @@ -768,7 +856,7 @@ bool Model_Document::canUndo() (myNestedNum.empty() || *myNestedNum.rbegin() - aCurrentNum > 0) && myTransactions.size() - aCurrentNum > 0 /* for omitting the first useless transaction */) return true; - // check other subs contains operation that can be undoed + // check other subs contains operation that can be undone const std::set aSubs = subDocuments(); std::set::iterator aSubIter = aSubs.begin(); for (; aSubIter != aSubs.end(); aSubIter++) { @@ -826,7 +914,7 @@ bool Model_Document::canRedo() { if (!myRedos.empty()) return true; - // check other subs contains operation that can be redoed + // check other subs contains operation that can be redone const std::set aSubs = subDocuments(); std::set::iterator aSubIter = aSubs.begin(); for (; aSubIter != aSubs.end(); aSubIter++) { @@ -952,6 +1040,22 @@ void Model_Document::refsToFeature(FeaturePtr theFeature, void Model_Document::removeFeature(FeaturePtr theFeature) { myObjs->removeFeature(theFeature); + // fix for #2723: send signal that part is updated + if (!isRoot()) { + std::shared_ptr aRoot = + std::dynamic_pointer_cast(ModelAPI_Session::get()->moduleDocument()); + std::list allParts; + aRoot->objects()->allResults(ModelAPI_ResultPart::group(), allParts); + std::list::iterator aParts = allParts.begin(); + for(; aParts != allParts.end(); aParts++) { + ResultPartPtr aPart = std::dynamic_pointer_cast(*aParts); + if (aPart->partDoc().get() == this) { + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(aRoot->feature(aPart), anEvent); + break; + } + } + } } // recursive function to check if theSub is a child of theMain composite feature @@ -979,8 +1083,9 @@ void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis) FeaturePtr anAfterThisSub = theAfterThis; if (aCompositeAfter.get()) { FeaturePtr aSub = aCompositeAfter; + int anIndex = kUNDEFINED_FEATURE_INDEX; do { - FeaturePtr aNext = myObjs->nextFeature(aSub); + FeaturePtr aNext = myObjs->nextFeature(aSub, anIndex); if (!isSub(aCompositeAfter, aNext)) { anAfterThisSub = aSub; break; @@ -1000,12 +1105,14 @@ void Model_Document::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis) void Model_Document::updateHistory(const std::shared_ptr theObject) { - myObjs->updateHistory(theObject); + if (myObjs) + myObjs->updateHistory(theObject); } void Model_Document::updateHistory(const std::string theGroup) { - myObjs->updateHistory(theGroup); + if (myObjs) + myObjs->updateHistory(theGroup); } const std::set Model_Document::subDocuments() const @@ -1074,8 +1181,9 @@ std::shared_ptr Model_Document::currentFeature(const bool theV TDF_Label aLab = aRef->Get(); FeaturePtr aResult = myObjs->feature(aLab); if (theVisible) { // get nearest visible (in history) going up + int anIndex = kUNDEFINED_FEATURE_INDEX; while(aResult.get() && !aResult->isInHistory()) { - aResult = myObjs->nextFeature(aResult, true); + aResult = myObjs->nextFeature(aResult, anIndex, true); } } return aResult; @@ -1111,9 +1219,10 @@ void Model_Document::setCurrentFeature( if (theVisible && !theCurrent.get()) { // needed to avoid disabling of PartSet initial constructions + int anIndex = kUNDEFINED_FEATURE_INDEX; FeaturePtr aNext = - theCurrent.get() ? myObjs->nextFeature(theCurrent) : myObjs->firstFeature(); - for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent)) { + theCurrent.get() ? myObjs->nextFeature(theCurrent, anIndex, false) : myObjs->firstFeature(); + for (; aNext.get(); aNext = myObjs->nextFeature(theCurrent, anIndex, false)) { if (aNext->isInHistory()) { break; // next in history is not needed } else { // next not in history is good for making current @@ -1140,14 +1249,15 @@ void Model_Document::setCurrentFeature( aRefLab.ForgetAttribute(TDF_Reference::GetID()); } // make all features after this feature disabled in reversed order - // (to remove results without deps) + // (to remove results without dependencies) static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); bool aPassed = false; // flag that the current object is already passed in cycle FeaturePtr anIter = myObjs->lastFeature(); bool aWasChanged = false; bool isCurrentParameter = theCurrent.get() && theCurrent->getKind() == "Parameter"; - for(; anIter.get(); anIter = myObjs->nextFeature(anIter, true)) { + int anIndex = kUNDEFINED_FEATURE_INDEX; + for(; anIter.get(); anIter = myObjs->nextFeature(anIter, anIndex, true)) { // check this before passed become enabled: the current feature is enabled! if (anIter == theCurrent) aPassed = true; @@ -1167,7 +1277,7 @@ void Model_Document::setCurrentFeature( //if (!isCurrentParameter) aDisabledFlag = false; } else if (isCurrentParameter) { - // if paramater is active, all other features become enabled (issue 1307) + // if parameter is active, all other features become enabled (issue 1307) aDisabledFlag = false; } @@ -1182,7 +1292,7 @@ void Model_Document::setCurrentFeature( ModelAPI_EventCreator::get()->sendUpdated(anIter, aRedispEvent /*, false*/); aWasChanged = true; } - // update for everyone the concealment flag immideately: on edit feature in the midle of history + // update for everyone concealment flag immediately: on edit feature in the middle of history if (aWasChanged) { std::list aResults; ModelAPI_Tools::allResults(anIter, aResults); @@ -1191,7 +1301,7 @@ void Model_Document::setCurrentFeature( if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled()) std::dynamic_pointer_cast((*aRes)->data())->updateConcealmentFlag(); } - // update the concealment status for disply in isConcealed of ResultBody + // update the concealment status for display in isConcealed of ResultBody for(aRes = aResults.begin(); aRes != aResults.end(); aRes++) { if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled()) (*aRes)->isConcealed(); @@ -1209,12 +1319,13 @@ void Model_Document::setCurrentFeatureUp() // problems if it is true: here and in "setCurrentFeature" FeaturePtr aCurrent = currentFeature(false); if (aCurrent.get()) { // if not, do nothing because null is the upper - FeaturePtr aPrev = myObjs->nextFeature(aCurrent, true); + int anIndex = kUNDEFINED_FEATURE_INDEX; + FeaturePtr aPrev = myObjs->nextFeature(aCurrent, anIndex, true); // make the higher level composite as current (sketch becomes disabled if line is enabled) if (aPrev.get()) { FeaturePtr aComp = ModelAPI_Tools::compositeOwner(aPrev); // without cycle (issue 1555): otherwise extrusion fuse - // will be enabled and displayed whaen inside sketch + // will be enabled and displayed when inside sketch if (aComp.get()) aPrev = aComp; } @@ -1334,7 +1445,6 @@ Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); } -// searches in this document feature that contains this label FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) { TDF_Label aCurrentLab = theLab; while(aCurrentLab.Depth() > 3) @@ -1342,12 +1452,26 @@ FeaturePtr Model_Document::featureByLab(const TDF_Label& theLab) { return myObjs->feature(aCurrentLab); } +ResultPtr Model_Document::resultByLab(const TDF_Label& theLab) +{ + TDF_Label aCurrentLab = theLab; + while(aCurrentLab.Depth() > 3) { + ObjectPtr aResultObj = myObjs->object(aCurrentLab); + if (aResultObj.get()) { + return std::dynamic_pointer_cast(aResultObj); // this may be null if feature + } + aCurrentLab = aCurrentLab.Father(); + } + return ResultPtr(); // not found +} + + void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName) { std::map >::iterator aFind = myNamingNames.find(theName); if (aFind != myNamingNames.end()) { // to avoid duplicate-labels - // to keep correct order inspite of history line management + // to keep correct order in spite of history line management std::list::iterator anAddAfterThis = aFind->second.end(); FeaturePtr anAddedFeature = featureByLab(theLabel); std::list::iterator aLabIter = aFind->second.begin(); @@ -1391,6 +1515,17 @@ void Model_Document::changeNamingName(const std::string theOldName, } else { // remove from the list aFind->second.erase(aLabIter); } + // check the sketch vertex name located under renamed sketch line + TDF_ChildIDIterator aChild(theLabel, TDataStd_Name::GetID()); + for(; aChild.More(); aChild.Next()) { + Handle(TDataStd_Name) aSubName = Handle(TDataStd_Name)::DownCast(aChild.Value()); + std::string aName = TCollection_AsciiString(aSubName->Get()).ToCString(); + if (aName.find(theOldName) == 0) { // started from parent name + std::string aNewSubName = theNewName + aName.substr(theNewName.size()); + changeNamingName(aName, aNewSubName, aSubName->Label()); + aSubName->Set(aNewSubName.c_str()); + } + } return; } } @@ -1409,7 +1544,7 @@ TDF_Label Model_Document::findNamingName(std::string theName, ResultPtr theConte return *aLabIter; } } - return *(aFind->second.rbegin()); // no more variannts, so, return the last + return *(aFind->second.rbegin()); // no more variants, so, return the last } // not found exact name, try to find by sub-components std::string::size_type aSlash = theName.rfind('/'); @@ -1480,12 +1615,24 @@ bool Model_Document::isLaterByDep(FeaturePtr theThis, FeaturePtr theOther) { if (!aRefFeat.get()) { // take feature of the result aRefFeat = feature(std::dynamic_pointer_cast(aRefObj)); } - if (aRefFeat.get() && aRefFeat == theThis) { - return false; // other references to this, so this later than other + if (aRefFeat.get()) { + if (aRefFeat == theThis) + return false; // other references to this, so other later than this + //if (std::dynamic_pointer_cast(aRefFeat)) { + // if (!isLaterByDep(theThis, aRefFeat)) // nested composites: recursion + // return false; + //} } } } } + FeaturePtr aThisOwner = ModelAPI_Tools::compositeOwner(theThis); + if (aThisOwner.get()) { + if (aThisOwner == theOther) + return true; // composite owner is later that its sub + if (!isLaterByDep(aThisOwner, theOther)) + return false; + } return myObjs->isLater(theThis, theOther); } @@ -1536,7 +1683,7 @@ ResultPtr Model_Document::findByName( std::string aName = theName; ResultPtr aRes = myObjs->findByName(aName); theUniqueContext = !(aRes.get() && myNamingNames.find(aName) != myNamingNames.end()); - while(!aRes.get() && aName[0] == '_') { // this may be thecontext with the history index + while(!aRes.get() && aName[0] == '_') { // this may be theContext with the history index aNumInHistory++; aName = aName.substr(1); aRes = myObjs->findByName(aName); @@ -1648,17 +1795,17 @@ void Model_Document::synchronizeTransactions() Model_Document* aRoot = std::dynamic_pointer_cast(ModelAPI_Session::get()->moduleDocument()).get(); if (aRoot == this) - return; // don't need to synchronise root with root + return; // don't need to synchronize root with root std::shared_ptr aSession = std::dynamic_pointer_cast(Model_Session::get()); - while(myRedos.size() > aRoot->myRedos.size()) { // remove redos in this + while(myRedos.size() > aRoot->myRedos.size()) { // remove redo in this aSession->setCheckTransactions(false); redo(); aSession->setCheckTransactions(true); } /* this case can not be reproduced in any known case for the current moment, so, just comment - while(myRedos.size() < aRoot->myRedos.size()) { // add more redos in this + while(myRedos.size() < aRoot->myRedos.size()) { // add more redo in this undoInternal(false, true); }*/ } @@ -1778,11 +1925,11 @@ std::shared_ptr Model_Document::producedByFeature( if (!aBodyData.get() || !aBodyData->isValid()) return FeaturePtr(); - TopoDS_Shape anOldShape; // old shape in the pair oldshape->theShape in the named shape + TopoDS_Shape anOldShape; // old shape in the pair old shape->theShape in the named shape TopoDS_Shape aShapeContainer; // old shape of the shape that contains aShape as sub-element Handle(TNaming_NamedShape) aCandidatInThis, aCandidatContainer; - TDF_Label aBodyLab = aBodyData->label(); - // use childs and this label (the lowest priority) + TDF_Label aBodyLab = aBodyData->shapeLab(); + // use child and this label (the lowest priority) TDF_ChildIDIterator aNSIter(aBodyLab, TNaming_NamedShape::GetID(), Standard_True); bool aUseThis = !aNSIter.More(); while(anOldShape.IsNull() && (aNSIter.More() || aUseThis)) { diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 0842d3d32..f4c6233d1 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -38,8 +38,8 @@ class ModelAPI_AttributeSelectionList; /**\class Model_Document * \ingroup DataModel * \brief Document for internal data structure of any object storage. - * Document contains all data that must be stored/retrived in the file. - * Also it provides acces to this data: open/save, transactions management etc. + * Document contains all data that must be stored/retrieved in the file. + * Also it provides access to this data: open/save, transactions management etc. */ class Model_Document : public ModelAPI_Document { @@ -66,11 +66,11 @@ class Model_Document : public ModelAPI_Document const char* theDirName, const char* theFileName, std::list& theResults); //! Removes document data - //! \param theForever if it is false, document is just hiden + //! \param theForever if it is false, document is just hidden //! (to keep possibility make it back on Undo/Redo) MODEL_EXPORT virtual void close(const bool theForever = false); - //! Starts a new operation (opens a tansaction) + //! Starts a new operation (opens a transaction) MODEL_EXPORT virtual void startOperation(); //! Finishes the previously started operation (closes the transaction) //! \returns true if transaction in this document is not empty and really was performed @@ -82,11 +82,11 @@ class Model_Document : public ModelAPI_Document //! Returns true if document was modified (since creation/opening) MODEL_EXPORT virtual bool isModified(); - //! Returns True if there are available Undos + //! Returns True if there are available Undo-s MODEL_EXPORT virtual bool canUndo(); //! Undoes last operation MODEL_EXPORT virtual void undo(); - //! Returns True if there are available Redos + //! Returns True if there are available Redo-s MODEL_EXPORT virtual bool canRedo(); //! Redoes last operation MODEL_EXPORT virtual void redo(); @@ -176,15 +176,15 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual std::shared_ptr internalFeature(const int theIndex); //! Performs synchronization of transactions with the module document: //! If some document is not active (by undo of activation) but in memory, - //! on activation the transactions must be synchronised because all redos performed - //! wihtout this participation + //! on activation the transactions must be synchronized because all redo-s performed + //! without this participation MODEL_EXPORT virtual void synchronizeTransactions(); //! Returns feature by the id of the feature (produced by the Data "featureId" method) MODEL_EXPORT virtual std::shared_ptr featureById(const int theId); - /// Creates a construction cresults + /// Creates construction results MODEL_EXPORT virtual std::shared_ptr createConstruction( const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body results @@ -229,7 +229,7 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual std::shared_ptr findFolderBelow( const std::list >& theFeatures); //! Search a folder containing the given feature. - //! Addtionally calculates a zero-based index of the feature in this folder. + //! Additionally calculates a zero-based index of the feature in this folder. //! \param theFeature feature to search //! \param theIndexInFolder zero-based index in the folder or -1 if the feature is top-level. //! \return the folder containing the feature or empty pointer if the feature is top-level. @@ -238,7 +238,7 @@ class Model_Document : public ModelAPI_Document int& theIndexInFolder); //! Add a list of features to the folder. The correctness of the adding is not performed //! (such checks have been done in corresponding find.. method). - //! \return \c true if the movement is successfull + //! \return \c true if the movement is successful MODEL_EXPORT virtual bool moveToFolder( const std::list >& theFeatures, const std::shared_ptr& theFolder); @@ -252,7 +252,7 @@ class Model_Document : public ModelAPI_Document const std::list >& theFeatures, const bool theBefore = true); - ///! Returns true if parametric updater need to execute feature on recomputartion + ///! Returns true if parametric updater need to execute feature on recomputation ///! On abort, undo or redo it is not necessary: results in document are updated automatically bool executeFeatures() {return myExecuteFeatures;} @@ -321,22 +321,22 @@ class Model_Document : public ModelAPI_Document } //! performs compactification of all nested operations into one - //! \returns true if resulting transaction is not empty and can be undoed + //! \returns true if resulting transaction is not empty and can be undone void compactNested(); //! Returns all loaded sub documents const std::set subDocuments() const; - //! The implementation of undo: with or without recoursive calls in the sub-documents + //! The implementation of undo: with or without recursive calls in the sub-documents void undoInternal(const bool theWithSubs, const bool theSynchronize); //! Stores the Id of the current operation (normally is called for the root document) void operationId(const std::string& theId); - //! Returns the list of Ids of the operations that can be undoed (called for the root document) + //! Returns the list of Ids of the operations that can be undone (called for the root document) std::list undoList() const; - //! Returns the list of Ids of the operations that can be redoed (called for the root document) + //! Returns the list of Ids of the operations that can be redone (called for the root document) std::list redoList() const; //! Internally makes document know that feature was removed or added in history after creation @@ -366,25 +366,27 @@ class Model_Document : public ModelAPI_Document /// Normally is called outside of the transaction, just before "save". virtual void storeNodesState(const std::list& theStates); - /// Returns the stored nodes states. Normally it is calles just after "open". + /// Returns the stored nodes states. Normally it is called just after "open". /// Appends the values to theStates list. virtual void restoreNodesState(std::list& theStates) const; - /// Label that constains structures for selection of constructions of another document + /// Label that contains structures for selection of constructions of another document TDF_Label extConstructionsLabel() const; /// searches in this document feature that contains this label FeaturePtr featureByLab(const TDF_Label& theLab); + /// searches in this document result that contains this label + ResultPtr resultByLab(const TDF_Label& theLab); - /// returns true if theThis is later in the features trre and dependencies than theOther + /// returns true if theThis is later in the features tree and dependencies than theOther bool isLaterByDep(FeaturePtr theThis, FeaturePtr theOther); /// appends the latest transaction to the previous one (used for AutoUpdate enabling transaction) void appendTransactionToPrevious(); - /// Sets the automatic recomutation flag: true means enabled + /// Sets the automatic recomputation flag: true means enabled void setAutoRecomutationState(const bool theState); - /// Returns the current automatic recomutation flag: true means enabled + /// Returns the current automatic recomputation flag: true means enabled bool autoRecomutationState() const; friend class Model_Application; @@ -399,6 +401,7 @@ class Model_Document : public ModelAPI_Document friend class Model_ResultBody; friend class Model_ResultConstruction; friend class Model_SelectionNaming; + friend class Model_BodyBuilder; friend class DFBrowser; private: @@ -410,7 +413,7 @@ class Model_Document : public ModelAPI_Document //! counter value of transaction on the last "save" call, used for "IsModified" method int myTransactionSave; - //! number of nested transactions performed (list becasue may be nested inside of nested) + //! number of nested transactions performed (list because may be nested inside of nested) //! the list is empty if not nested transaction is performed std::list myNestedNum; diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 6fc21e71e..d7ecf7187 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -41,13 +41,14 @@ #include #include #include -#include #include #include #include #include #include +int kUNDEFINED_FEATURE_INDEX = -1; + static const std::string& groupNameFoldering(const std::string& theGroupID, const bool theAllowFolder) { @@ -149,7 +150,7 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced, TDF_ } else { // extend array by one more element Handle(TDataStd_HLabelArray1) aNewArray = new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1); - int aPassedPrev = 0; // prev feature is found and passed + int aPassedPrev = 0; // previous feature is found and passed if (thePrevLab.IsNull()) { // null means that inserted feature must be the first aNewArray->SetValue(aRefs->Lower(), theReferenced); aPassedPrev = 1; @@ -310,7 +311,7 @@ void Model_Objects::removeFeature(FeaturePtr theFeature) for(; aRefIter != aRefs.end(); aRefIter++) { std::shared_ptr aComposite = std::dynamic_pointer_cast(*aRefIter); - if (aComposite.get() && aComposite->isSub(theFeature)) { + if (aComposite.get() && aComposite->data()->isValid() && aComposite->isSub(theFeature)) { aComposite->removeFeature(theFeature); } } @@ -383,7 +384,7 @@ void Model_Objects::moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis) Handle(TDataStd_HLabelArray1) aNewArray = new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper()); - int aPassedMovedFrom = 0; // the prev feature location is found and passed + int aPassedMovedFrom = 0; // the previous feature location is found and passed int aPassedMovedTo = 0; // the feature is added and this location is passed if (!theAfterThis.get()) { // null means that inserted feature must be the first aNewArray->SetValue(aRefs->Lower(), aMovedLab); @@ -628,15 +629,17 @@ std::shared_ptr Model_Objects::objectByName( createHistory(theGroupID); if (theGroupID == ModelAPI_Feature::group()) { // searching among features (in history or not) std::list > allObjs = allFeatures(); - std::list >::iterator anObjIter = allObjs.begin(); - for(; anObjIter != allObjs.end(); anObjIter++) { + // from the end to find the latest result with such name + std::list >::reverse_iterator anObjIter = allObjs.rbegin(); + for(; anObjIter != allObjs.rend(); anObjIter++) { if ((*anObjIter)->data()->name() == theName) return *anObjIter; } } else { // searching among results (concealed or not) std::list > allObjs = allFeatures(); - std::list >::iterator anObjIter = allObjs.begin(); - for(; anObjIter != allObjs.end(); anObjIter++) { + // from the end to find the latest result with such name + std::list >::reverse_iterator anObjIter = allObjs.rbegin(); + for(; anObjIter != allObjs.rend(); anObjIter++) { std::list allRes; ModelAPI_Tools::allResults(*anObjIter, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { @@ -740,31 +743,17 @@ void Model_Objects::setUniqueName(FeaturePtr theFeature) // first count all features of such kind to start with index = count + 1 int aNumObjects = -1; // this feature is already in this map NCollection_DataMap::Iterator aFIter(myFeatures); + std::set allNames; for (; aFIter.More(); aFIter.Next()) { if (aFIter.Value()->getKind() == theFeature->getKind()) aNumObjects++; + allNames.insert(aFIter.Value()->data()->name()); } // generate candidate name aName = composeName(theFeature->getKind(), aNumObjects + 1); // check this is unique, if not, increase index by 1 - for (aFIter.Initialize(myFeatures); aFIter.More();) { - FeaturePtr aFeature = aFIter.Value(); - bool isSameName = aFeature->data()->name() == aName; - if (!isSameName) { // check also results to avoid same results names (actual for Parts) - const std::list >& aResults = aFeature->results(); - std::list >::const_iterator aRIter = aResults.begin(); - for (; aRIter != aResults.cend(); aRIter++) { - isSameName = (*aRIter)->data()->name() == aName; - } - } - - if (isSameName) { - aNumObjects++; - aName = composeName(theFeature->getKind(), aNumObjects + 1); - // reinitialize iterator to make sure a new name is unique - aFIter.Initialize(myFeatures); - } else - aFIter.Next(); + for(aNumObjects++; allNames.find(aName) != allNames.end(); aNumObjects++) { + aName = composeName(theFeature->getKind(), aNumObjects + 1); } theFeature->data()->setName(aName); } @@ -865,7 +854,7 @@ void Model_Objects::synchronizeFeatures( ObjectPtr aFeature = isFolder ? ObjectPtr(new ModelAPI_Folder) : ObjectPtr(aSession->createFeature(aFeatureID, anOwner)); if (!aFeature.get()) { - // somethig is wrong, most probably, the opened document has invalid structure + // something is wrong, most probably, the opened document has invalid structure Events_InfoMessage("Model_Objects", "Invalid type of object in the document").send(); aLabIter.Value()->Label().ForgetAllAttributes(); continue; @@ -966,7 +955,7 @@ void Model_Objects::synchronizeFeatures( } // update results of the features (after features created because // they may be connected, like sketch and sub elements) - // After synchronisation of back references because sketch + // After synchronization of back references because sketch // must be set in sub-elements before "execute" by updateResults std::set aProcessed; // composites must be updated after their subs (issue 360) TDF_ChildIDIterator aLabIter2(featuresLabel(), TDataStd_Comment::GetID()); @@ -1005,14 +994,14 @@ void Model_Objects::synchronizeFeatures( anOwner->setExecuteFeatures(true); } -/// synchronises back references for the given object basing on the collected data +/// synchronizes back references for the given object basing on the collected data void Model_Objects::synchronizeBackRefsForObject(const std::set& theNewRefs, ObjectPtr theObject) { if (!theObject.get() || !theObject->data()->isValid()) return; // invalid std::shared_ptr aData = std::dynamic_pointer_cast(theObject->data()); - // iterate new list to compare with curent + // iterate new list to compare with current std::set::iterator aNewIter = theNewRefs.begin(); for(; aNewIter != theNewRefs.end(); aNewIter++) { if (aData->refsToMe().find(*aNewIter) == aData->refsToMe().end()) { @@ -1114,9 +1103,9 @@ static void collectReferences(std::shared_ptr theData, void Model_Objects::synchronizeBackRefs() { // collect all back references in the separated container: to update everything at once, - // without additional Concealment switchin on and off: only the final modification + // without additional Concealment switching on and off: only the final modification - // referenced (slave) objects to referencing attirbutes + // referenced (slave) objects to referencing attributes std::map > allRefs; NCollection_DataMap::Iterator aFeatures(myFeatures); for(; aFeatures.More(); aFeatures.Next()) { @@ -1157,7 +1146,7 @@ void Model_Objects::synchronizeBackRefs() FeaturePtr aFeature = aFeatures.Value(); std::list aResults; ModelAPI_Tools::allResults(aFeature, aResults); - // update the concealment status for disply in isConcealed of ResultBody + // update the concealment status for display in isConcealed of ResultBody std::list::iterator aRIter = aResults.begin(); for(; aRIter != aResults.cend(); aRIter++) { (*aRIter)->isConcealed(); @@ -1370,7 +1359,8 @@ std::shared_ptr Model_Objects::createFolder( std::shared_ptr aPrevData = std::dynamic_pointer_cast(theBeforeThis->data()); if (aPrevData.get()) { - aPrevFeatureLab = nextLabel(aPrevData->label().Father(), true); + int anIndex = kUNDEFINED_FEATURE_INDEX; + aPrevFeatureLab = nextLabel(aPrevData->label().Father(), anIndex, true); } } else { // find the label of the last feature Handle(TDataStd_ReferenceArray) aRefs; @@ -1489,7 +1479,7 @@ std::shared_ptr Model_Objects::findFolder( if (!aLastFeatureInFolder.IsNull()) { if (IsEqual(aCurLabel, aLastFeatureInFolder)) - aLastFeatureInFolder.Nullify(); // the last feature in the folder is achived + aLastFeatureInFolder.Nullify(); // the last feature in the folder is achieved continue; } @@ -1796,7 +1786,7 @@ std::shared_ptr Model_Objects::feature( const std::shared_ptr& theResult) { std::shared_ptr aData = std::dynamic_pointer_cast(theResult->data()); - if (aData.get()) { + if (aData.get() && aData->isValid()) { TDF_Label aFeatureLab = aData->label().Father().Father().Father(); FeaturePtr aFeature = feature(aFeatureLab); while(!aFeature.get() && aFeatureLab.Depth() > 1) { // this may be sub-result of result @@ -1840,8 +1830,6 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t } } - // for not persistent is will be done by parametric updater automatically - //if (!theFeature->isPersistentResult()) return; // check the existing results and remove them if there is nothing on the label std::list::const_iterator aResIter = theFeature->results().cbegin(); while(aResIter != theFeature->results().cend()) { @@ -1875,16 +1863,20 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) { aNewBody = createBody(theFeature->data(), aResIndex); } else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) { - std::shared_ptr aNewP = createPart(theFeature->data(), aResIndex); - theFeature->setResult(aNewP, aResIndex); - if (!aNewP->partDoc().get()) - // create the part result: it is better to restore the previous result if it is possible - theFeature->execute(); + if (aResIndex <= theFeature->results().size()) { // to avoid crash if previous execute + // for index = 0 erases result + std::shared_ptr aNewP = createPart(theFeature->data(), aResIndex); + theFeature->setResult(aNewP, aResIndex); + if (!aNewP->partDoc().get()) + // create the part result: it is better to restore the previous result if possible + theFeature->execute(); + } } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) { - theFeature->execute(); // construction shapes are needed for sketch solver - if (!theFeature->results().empty()) // to fix #2640 : update sketch, but not naming - std::dynamic_pointer_cast(theFeature->firstResult()) - ->facesNum(false); + ResultConstructionPtr aConstr = createConstruction(theFeature->data(), aResIndex); + if (!aConstr->updateShape()) + theFeature->execute(); // not stored shape in the data structure, execute to have it + else + theFeature->setResult(aConstr, aResIndex); // result is ready without execution } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) { aNewBody = createGroup(theFeature->data(), aResIndex); } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) { @@ -1904,9 +1896,16 @@ void Model_Objects::updateResults(FeaturePtr theFeature, std::set& t if (aResSize > 0) { // check there exist a body that must be updated std::list::const_iterator aRes = theFeature->results().cbegin(); for (; aResSize && aRes != theFeature->results().cend(); aRes++, aResSize++) { - if ((*aRes)->data()->isValid() && (*aRes)->groupName() == ModelAPI_ResultBody::group()) { - ResultBodyPtr aBody = std::dynamic_pointer_cast(*aRes); - aBody->updateSubs(aBody->shape(), false); + if ((*aRes)->data()->isValid()) { + if ((*aRes)->groupName() == ModelAPI_ResultBody::group()) { + ResultBodyPtr aBody = std::dynamic_pointer_cast(*aRes); + aBody->updateSubs(aBody->shape(), false); + } else if ((*aRes)->groupName() == ModelAPI_ResultConstruction::group()) { + // update the cashed myShape presented in construction + ResultConstructionPtr aConstr = + std::dynamic_pointer_cast(*aRes); + aConstr->updateShape(); + } } } } @@ -1939,32 +1938,35 @@ ResultPtr Model_Objects::findByName(const std::string theName) return aResult; } -TDF_Label Model_Objects::nextLabel(TDF_Label theCurrent, const bool theReverse) +TDF_Label Model_Objects::nextLabel(TDF_Label theCurrent, int& theIndex, const bool theReverse) { Handle(TDataStd_ReferenceArray) aRefs; if (featuresLabel().FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { - for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { // iterate all existing features + int aStart = theIndex == kUNDEFINED_FEATURE_INDEX ? aRefs->Lower() : theIndex; + for(int a = aStart; a <= aRefs->Upper(); a++) { // iterate all existing features TDF_Label aCurLab = aRefs->Value(a); if (aCurLab.IsEqual(theCurrent)) { a += theReverse ? -1 : 1; - if (a >= aRefs->Lower() && a <= aRefs->Upper()) + if (a >= aRefs->Lower() && a <= aRefs->Upper()) { + theIndex = a; return aRefs->Value(a); - break; // finish iiteration: it's last feature + } + break; // finish iteration: it's last feature } } } return TDF_Label(); } -FeaturePtr Model_Objects::nextFeature(FeaturePtr theCurrent, const bool theReverse) +FeaturePtr Model_Objects::nextFeature(FeaturePtr theCurrent, int& theIndex, const bool theReverse) { std::shared_ptr aData = std::static_pointer_cast(theCurrent->data()); if (aData.get() && aData->isValid()) { TDF_Label aFeatureLabel = aData->label().Father(); do { - TDF_Label aNextLabel = nextLabel(aFeatureLabel, theReverse); + TDF_Label aNextLabel = nextLabel(aFeatureLabel, theIndex, theReverse); if (aNextLabel.IsNull()) - break; // last or something is wrong + break; // the last or something is wrong FeaturePtr aFound = feature(aNextLabel); if (aFound) return aFound; // the feature is found diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index 0991cf210..26e6e6d19 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -40,6 +40,8 @@ static Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper); static Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2); +extern int kUNDEFINED_FEATURE_INDEX; + /**\class Model_Objects * \ingroup DataModel * \brief Manager of objects of the document. Normally one this class corresponds to @@ -49,7 +51,7 @@ static Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLa class Model_Objects { public: - //! Registers the fieature in the data structure + //! Registers the feature in the data structure //! \param theFeature feature that must be added to the data structure //! \param theAfterThis the feature will be added after this feature; //! if it is null, the added feature will be the first @@ -167,7 +169,7 @@ class Model_Objects const std::list >& theFeatures, const bool theBelow); //! Search a folder containing the given feature. - //! Addtionally calculates a zero-based index of the feature in this folder. + //! Additionally calculates a zero-based index of the feature in this folder. //! \param theFeature feature to search //! \param theIndexInFolder zero-based index in the folder or -1 if the feature is top-level. //! \return the folder containing the feature or empty pointer if the feature is top-level. @@ -176,7 +178,7 @@ class Model_Objects int& theIndexInFolder); //! Add a list of features to the folder. The correctness of the adding is not performed //! (such checks have been done in corresponding find.. method). - //! \return \c true if the movement is successfull + //! \return \c true if the movement is successful bool moveToFolder(const std::list >& theFeatures, const std::shared_ptr& theFolder); //! Remove features from the folder @@ -194,7 +196,7 @@ class Model_Objects //! Returns the owner of this manager DocumentPtr owner() {return myDoc;} - //! Deletes all managed features wit hemmitting of corresponded signal + //! Deletes all managed features with emitting of corresponded signal ~Model_Objects(); protected: @@ -206,15 +208,15 @@ class Model_Objects //! feature type + "_" + index void setUniqueName(FeaturePtr theFeature); - //! Initializes the foldet with an unique name ("Folder_" + index) + //! Initializes the folder with an unique name ("Folder_" + index) void setUniqueName(FolderPtr theFolder); //! Synchronizes myFeatures list with the updated document - //! \param theUpdated list of labels that are marked as modified, so featrues must be also + //! \param theUpdated list of labels that are marked as modified, so features must be also //! \param theUpdateReferences causes the update of back-references //! \param theExecuteFeatures requires re-execute modified persistent features //! (not needed on undo/redo/abort/open) - //! \param theOpen - on open nothing must be reexecuted, except not persistent results + //! \param theOpen - on open nothing must be re-executed, except not persistent results //! \param theFlush makes flush all events in the end of all modifications of this method void synchronizeFeatures(const TDF_LabelList& theUpdated, const bool theUpdateReferences, const bool theOpen, const bool theExecuteFeatures, const bool theFlush); @@ -255,8 +257,9 @@ class Model_Objects /// Returns the next (from the history point of view) feature, any: invisible or disabled /// \param theCurrent previous to the resulting feature - /// \param theReverse if it is true, iterates in reverced order (next becomes previous) - FeaturePtr nextFeature(FeaturePtr theCurrent, const bool theReverse = false); + /// \param theReverse if it is true, iterates in reversed order (next becomes previous) + /// \param theIndex may be used for optimization: index of theCurrent in references array + FeaturePtr nextFeature(FeaturePtr theCurrent, int& theIndex, const bool theReverse = false); /// Returns to the first (from the history point of view) feature, any: invisible or disabled FeaturePtr firstFeature(); /// Returns to the last (from the history point of view) feature, any: invisible or disabled @@ -266,8 +269,8 @@ class Model_Objects /// Returns the next or previous label /// \param theCurrent given label - /// \param theReverse if it is true, iterates in reverced order (next becomes previous) - TDF_Label nextLabel(TDF_Label theCurrent, const bool theReverse = false); + /// \param theReverse if it is true, iterates in reversed order (next becomes previous) + TDF_Label nextLabel(TDF_Label theCurrent, int& theIndex, const bool theReverse = false); /// Returns the result group identifier of the given feature (for this at least one result must /// be created before) @@ -281,14 +284,14 @@ class Model_Objects //! history. Not very fast method, for calling once, not in big cycles. std::list > allObjects(); - //! synchronises back references for the given object basing on the collected data + //! synchronizes back references for the given object basing on the collected data void synchronizeBackRefsForObject( const std::set>& theNewRefs, ObjectPtr theObject); /// Just removes all features without touching the document data (to be able undo) virtual void eraseAllFeatures(); - // Check whether the pre-image of the result had user-defined name. + // Check whether the predefined-image of the result had user-defined name. // If yes, return this name. bool hasCustomName(DataPtr theFeatureData, ResultPtr theResult, @@ -301,7 +304,7 @@ class Model_Objects private: TDF_Label myMain; ///< main label of the data storage - DocumentPtr myDoc; ///< doc,ument, owner of this objects manager: needed for events creation + DocumentPtr myDoc; ///< document, owner of this objects manager: needed for events creation /// All managed features (not only in history of OB) /// For optimization mapped by labels @@ -311,7 +314,7 @@ class Model_Objects NCollection_DataMap myFolders; /// Map from group id to the array that contains all objects located in history. - /// Each array is updated by demand from scratch, by browing all the features in the history. + /// Each array is updated by demand from scratch, by browsing all the features in the history. std::map > myHistory; friend class Model_Document; diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index eaee3ac1e..c226ac762 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -52,17 +52,53 @@ Model_ResultBody::~Model_ResultBody() delete myBuilder; } -void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated, - const bool theSplitInSubs) +bool Model_ResultBody::generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult) { - if (theSplitInSubs && mySubs.size()) { // consists of subs + bool aResult = false; + if (mySubs.size()) { // consists of subs + for (std::vector::const_iterator aSubIter = mySubs.cbegin(); + aSubIter != mySubs.cend(); + ++aSubIter) + { + const ResultBodyPtr& aSub = *aSubIter; + if (aSub->generated(theNewShape, theName, theCheckIsInResult)) + aResult = true; + } + } else { // do for this directly + if (myBuilder->generated(theNewShape, theName, theCheckIsInResult)) + aResult = true; + } + return aResult; +} + +void Model_ResultBody::loadGeneratedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) +{ + if (mySubs.size()) { // consists of subs + for (std::vector::const_iterator aSubIter = mySubs.cbegin(); + aSubIter != mySubs.cend(); + ++aSubIter) + { + const ResultBodyPtr& aSub = *aSubIter; + aSub->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); + } + } else { // do for this directly + myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); + } +} + +void Model_ResultBody::loadModifiedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) +{ + if (/*theSplitInSubs &&*/ mySubs.size()) { // consists of subs // optimization of getting of new shapes for specific sub-result - if (!theMS->newShapesCollected(theShapeIn, theKindOfShape)) - theMS->collectNewShapes(theShapeIn, theKindOfShape); + if (!theAlgo->isNewShapesCollected(theOldShape, theShapeTypeToExplore)) + theAlgo->collectNewShapes(theOldShape, theShapeTypeToExplore); std::vector::const_iterator aSubIter = mySubs.cbegin(); for(; aSubIter != mySubs.cend(); aSubIter++) { // check that sub-shape was also created as modification of ShapeIn @@ -84,14 +120,10 @@ void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, } } }*/ - (*aSubIter)->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated, theSplitInSubs); + (*aSubIter)->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } } else { // do for this directly - myBuilder->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated); + myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } } @@ -129,7 +161,6 @@ bool Model_ResultBody::setDisabled(std::shared_ptr theThis, con { bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag); if (aChanged) { // state is changed, so modifications are needed - myBuilder->evolutionToSelection(theFlag); updateSubs(shape(), false); // to set disabled/enabled } return aChanged; @@ -213,6 +244,7 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); if (!aDataLab.IsNull()) { TDataStd_UAttribute::Set(aDataLab, kUpdateConnectedTopology); + isConnectedTopology(); // to store this flag in transaction, #2630 } } // iterate all sub-solids of compsolid to make sub-results synchronized with them @@ -277,20 +309,6 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS } } -bool Model_ResultBody::isLatestEqual(const std::shared_ptr& theShape) -{ - if (myBuilder->isLatestEqual(theShape)) - return true; - // also check that it is asked for sub-elements - std::vector::const_iterator aSubIter = mySubs.cbegin(); - for(; aSubIter != mySubs.cend(); aSubIter++) { - if (aSubIter->get() && (*aSubIter)->isLatestEqual(theShape)) { - return true; - } - } - return false; -} - bool Model_ResultBody::isConnectedTopology() { TDF_Label aDataLab = std::dynamic_pointer_cast(data())->label(); diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 6047bc059..721ad71f3 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -33,7 +33,7 @@ * Provides a shape that may be displayed in the viewer. * May provide really huge results, so, working with this kind * of result must be optimized. -* Also provides a conainer of sub-body result in case it is compound or compsolid. +* Also provides a container of sub-body result in case it is compound or compsolid. */ class Model_ResultBody : public ModelAPI_ResultBody { @@ -49,12 +49,24 @@ public: /// Removes the stored builders MODEL_EXPORT virtual ~Model_ResultBody(); - /// load and orient modified shapes for sub-objects - MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false, - const bool theSplitInSubs = false); + /// Records the subshape newShape which was generated during a topological construction. + /// As an example, consider the case of a face generated in construction of a box. + MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult = true) override; + + /// load generated shapes + MODEL_EXPORT + virtual void loadGeneratedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") override; + + /// load modified shapes for sub-objects + MODEL_EXPORT + virtual void loadModifiedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") override; /// Returns the number of sub-elements @@ -64,11 +76,11 @@ public: MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex, bool forTree = false) const; - /// Returns true if feature or reuslt belong to this composite feature as subs + /// Returns true if feature or result belong to this composite feature as subs /// Returns theIndex - zero based index of sub if found MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const; - /// Returns the parameters of color definition in the resources config manager + /// Returns the parameters of color definition in the resources configuration manager MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault); @@ -83,10 +95,6 @@ public: /// Sets all subs as concealed in the data tree (referenced by other objects) MODEL_EXPORT virtual void setIsConcealed(const bool theValue); - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); - /// Returns true is the topology is connected. MODEL_EXPORT virtual bool isConnectedTopology(); @@ -98,7 +106,7 @@ protected: void updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged = true); - // Checks the state of children and partents to send events of creation/erase when needed + // Checks the state of children and parents to send events of creation/erase when needed void updateConcealment(); friend class Model_Objects; diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 1d0c715c7..272cb7338 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -22,37 +22,38 @@ #include #include -#include +#include +#include #include -#include +#include #include #include -#include #include +#include +#include -#include -#include +#include #include #include -#include #include #include #include -#include -#include -#include #include #include -#include #include #include +#include #include -#include -#include +#include +#include + +#include -// identifier that it is full result selected, but in external document (for internal index is 0) -Standard_GUID kFULL_RESULT_ID("ee87e529-da6f-46af-be25-5e0fefde52f7"); +// identifier of the infinite result +Standard_GUID kIS_INFINITE("dea8cc5a-53f2-49c1-94e8-a947bed20a9f"); +// identifier of the result not in history +Standard_GUID kIS_IN_HISTORY("a9aec01c-805e-44d1-b5d2-a63f06522f8a"); void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault) @@ -65,13 +66,10 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str void Model_ResultConstruction::setShape(std::shared_ptr theShape) { if (myShape != theShape) { + storeShape(theShape); if (!theShape.get() || !theShape->isEqual(myShape)) { - static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); - if (theShape.get()) { - myFacesUpToDate = false; - myFaces.clear(); - } + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); } myShape = theShape; } @@ -82,803 +80,387 @@ std::shared_ptr Model_ResultConstruction::shape() return myShape; } -Model_ResultConstruction::Model_ResultConstruction() -{ - myIsInHistory = true; - myIsInfinite = false; - myFacesUpToDate = false; -} - -void Model_ResultConstruction::setIsInHistory(const bool isInHistory) +static std::string shortName( + std::shared_ptr& theConstr) { - myIsInHistory = isInHistory; + std::string aName = theConstr->data()->name(); + // remove "-", "/" and "&" command-symbols + aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end()); + aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end()); + aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end()); + // remove the last 's', 'e', 'f' and 'r' symbols: + // they are used as markers of start/end/forward/reversed indicators + static const std::string aSyms("sefr"); + std::string::iterator aSuffix = aName.end() - 1; + while(aSyms.find(*aSuffix) != std::string::npos) { + --aSuffix; + } + aName.erase(aSuffix + 1, aName.end()); + return aName; } -int Model_ResultConstruction::facesNum(const bool theUpdateNaming) +bool Model_ResultConstruction::updateShape() { - if (!myFacesUpToDate) { - std::shared_ptr aWirePtr = - std::dynamic_pointer_cast(myShape); - if (aWirePtr.get()) { - std::list > aFaces; - GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), - aWirePtr->norm(), aWirePtr, aFaces); - std::list >::iterator aFIter = aFaces.begin(); - for(; aFIter != aFaces.end(); aFIter++) { - std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); - if (aFace.get() && !aFace->isNull()) - myFaces.push_back(aFace); - } - } - myFacesUpToDate = true; - - // update all the faces and sub-elements in the naming structure - if (theUpdateNaming) { - DocumentPtr anEmptyExt; - bool aNotExt = false; - TDF_Label aDataLab = startLabel(anEmptyExt, aNotExt); - TDF_ChildIterator aSubsIter(aDataLab, Standard_False); - for(; aSubsIter.More(); aSubsIter.Next()) { - const TDF_Label aLab = aSubsIter.Value(); - if (aLab.Tag() == 1) // skip the root shape label - continue; - Handle(TNaming_NamedShape) aNS; - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - update(aLab.Tag() - 1, anEmptyExt, aNotExt); + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData && aData->isValid()) { + TDF_Label aShapeLab = aData->shapeLab(); + Handle(TNaming_NamedShape) aNS; + if (aShapeLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TopoDS_Shape aShape = aNS->Get(); + if (!aShape.IsNull()) { + if (aShape.ShapeType() == TopAbs_COMPOUND) { + // restore the sketch planar edges object + std::shared_ptr aBigWire(new GeomAPI_PlanarEdges); + aBigWire->setImpl(new TopoDS_Shape(aShape)); + FeaturePtr aSketch = + document()->feature(std::dynamic_pointer_cast(data()->owner())); + std::shared_ptr anOrigin = + std::dynamic_pointer_cast(aSketch->data()->attribute("Origin")); + std::shared_ptr aDirX = + std::dynamic_pointer_cast(aSketch->data()->attribute("DirX")); + std::shared_ptr aNorm = + std::dynamic_pointer_cast(aSketch->data()->attribute("Norm")); + if (anOrigin.get() && aDirX.get() && aNorm.get()) { + aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir()); + myShape = aBigWire; + return true; + } } + // just restore shape + GeomShapePtr aGShape(new GeomAPI_Shape); + aGShape->setImpl(new TopoDS_Shape(aShape)); + myShape = GeomAPI_Tools::getTypedShape(aGShape); // restore the sketch sub-components + return true; } } } - return int(myFaces.size()); + return false; } -std::shared_ptr Model_ResultConstruction::face(const int theIndex) +Model_ResultConstruction::Model_ResultConstruction() { - return myFaces[theIndex]; } -bool Model_ResultConstruction::isInfinite() +bool Model_ResultConstruction::isInHistory() { - return myIsInfinite; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + return !aData->label().IsAttribute(kIS_IN_HISTORY); // by default no attribute, but in history + } + return true; // unknown case } -void Model_ResultConstruction::setInfinite(const bool theInfinite) +void Model_ResultConstruction::setIsInHistory(const bool isInHistory) { - myIsInfinite = theInfinite; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + if (!isInHistory) + TDataStd_UAttribute::Set(aData->label(), kIS_IN_HISTORY); + else + aData->label().ForgetAttribute(kIS_IN_HISTORY); + } } -void Model_ResultConstruction::setIsConcealed(const bool theValue) +bool Model_ResultConstruction::isInfinite() { - // do nothing: the construction element is never concealed + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + return aData->label().IsAttribute(kIS_INFINITE); + } + return false; // unknown case } -static const int kSTART_VERTEX_DELTA = 1000000; - -static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape, std::string theFullName, - const int theID, std::shared_ptr theDoc, - bool theSelectionMode) +void Model_ResultConstruction::setInfinite(const bool theInfinite) { - TDF_Label aLab = theID == 0 ? theMainLabel : theMainLabel.FindChild(theID); - TNaming_Builder aBuilder(aLab); - // wire never happens as sub, it must be generated to be found - // by SelectionNaming TNaming_Tool::NamedShape - if (theSelectionMode && theShape.ShapeType() != TopAbs_WIRE) - aBuilder.Select(theShape, theShape); - else - aBuilder.Generated(theShape); - - theDoc->addNamingName(aLab, theFullName); - TDataStd_Name::Set(aLab, theFullName.c_str()); + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + if (theInfinite) + TDataStd_UAttribute::Set(aData->label(), kIS_INFINITE); + else + aData->label().ForgetAttribute(kIS_INFINITE); + } } -#include - -// generates a full-name for sub-element of the composite feature (sketch) -std::string fullName(CompositeFeaturePtr theComposite, const TopoDS_Shape& theSubShape, - Handle(TDataStd_IntPackedMap) theRefs = Handle(TDataStd_IntPackedMap)()) +int Model_ResultConstruction::facesNum(const bool theUpdateNaming) { - TopAbs_ShapeEnum aShapeType = theSubShape.ShapeType(); - gp_Pnt aVertexPos; - NCollection_Map allExactEdges; - NCollection_DataMap allEdges; - NCollection_DataMap allCurves; - /// map from edges from theSubShape to the found corresponded indices of the sub-components - NCollection_DataMap, TopTools_OrientedShapeMapHasher> - anEdgesCorrespondence; - if (aShapeType == TopAbs_VERTEX) { // compare positions - aVertexPos = BRep_Tool::Pnt(TopoDS::Vertex(theSubShape)); - } else { - for(TopExp_Explorer anEdgeExp(theSubShape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExp.Current()); - allExactEdges.Add(anEdge); - allEdges.Bind(anEdge, anEdge); - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - allCurves.Bind(aCurve, anEdge); - anEdgesCorrespondence.Bind(anEdge, NCollection_List()); - } - } - std::map anOrientations; //map from edges IDs to orientations of these edges in face - std::map aSubNames; //map from edges IDs to names of edges - TColStd_PackedMapOfInteger aRefs; // indixes of sub-elements in composite - - - const int aSubNum = theComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - FeaturePtr aSub = theComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes = aResults.cbegin(); - // there may be many shapes (circle and center): register if at least one is in selection - for(; aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (!aConstr->shape()) { - continue; - } - if (aShapeType == TopAbs_VERTEX) { - if (aConstr->shape()->isVertex()) { // compare vertices positions - const TopoDS_Shape& aVertex = aConstr->shape()->impl(); - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVertex)); - if (aPnt.IsEqual(aVertexPos, Precision::Confusion())) { - aRefs.Add(theComposite->subFeatureId(a)); - aSubNames[theComposite->subFeatureId(a)] = Model_SelectionNaming::shortName(aConstr); - } - } else { // get first or last vertex of the edge: last is stored with additional delta - const TopoDS_Shape& anEdge = aConstr->shape()->impl(); - int aDelta = kSTART_VERTEX_DELTA; - for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) { - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVExp.Current())); - if (aPnt.IsEqual(aVertexPos, Precision::Confusion())) { - aRefs.Add(aDelta + theComposite->subFeatureId(a)); - aSubNames[aDelta + theComposite->subFeatureId(a)] = - Model_SelectionNaming::shortName(aConstr, aDelta / kSTART_VERTEX_DELTA); - break; - } - aDelta += kSTART_VERTEX_DELTA; - } - } - } else { - if (aConstr->shape()->isEdge()) { - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (anEdge.IsNull()) - continue; - if (allEdges.IsBound(anEdge)) { - anEdgesCorrespondence.ChangeFind(allEdges.Find(anEdge)).Append(a); - } else { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (allCurves.IsBound(aCurve)) { - anEdgesCorrespondence.ChangeFind(allCurves.Find(aCurve)).Append(a); - } - } - } - } - } - } - - if (aShapeType != TopAbs_VERTEX) { // get best candidates from the correspondances - NCollection_DataMap, TopTools_OrientedShapeMapHasher> - ::Iterator aCorIter(anEdgesCorrespondence); - for(; aCorIter.More(); aCorIter.Next()) { - TopoDS_Edge anOrig = aCorIter.Key(); - NCollection_List::Iterator aCandidate(aCorIter.Value()); - int aBestScore = 0; - int aBestIndex = -1; - ResultConstructionPtr aBestConstr; - for(; aCandidate.More(); aCandidate.Next()) { - FeaturePtr aSub = theComposite->subFeature(aCandidate.Value()); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes = aResults.cbegin(); - // there may be many shapes (circle and center): register if at least one is in selection - for(; aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (!aConstr->shape() || !aConstr->shape()->isEdge()) - continue; - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (anEdge.IsNull()) - continue; - // detect score of the candidate - int aScore = 0; - if (anEdge.IsEqual(anOrig)) - aScore = 10; - else if (anEdge.IsSame(anOrig)) - aScore = 9; - else { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) anOrigCurve = BRep_Tool::Curve(anOrig, aFirst, aLast); - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (anOrigCurve == aCurve) { - if (Model_EdgesHasher::IsEqual(anEdge, anOrig)) { - aScore = 8; - } else { - aScore = 6; - } - } else { - if (Model_EdgesHasher::IsEqual(anEdge, anOrig)) { - aScore = 7; - } else if (Model_CurvesHasher::IsEqual(aCurve, anOrigCurve)) { - aScore = 5; - } - } - } - if (aScore > aBestScore) { - aBestIndex = aCandidate.Value(); - aBestScore = aScore; - aBestConstr = aConstr; - } - } - } - if (aBestIndex >= 0) { - int anID = theComposite->subFeatureId(aBestIndex); - aRefs.Add(anID); - aSubNames[anID] = Model_SelectionNaming::shortName(aBestConstr); - if (aShapeType != TopAbs_EDGE) { // face needs the sub-edges on sub-labels - // add edges to sub-label to support naming for edges selection - int anOrient = Model_SelectionNaming::edgeOrientation(theSubShape, anOrig); - anOrientations[anID] = anOrient; - } - } - } - } - std::stringstream aName; - // #1839 : do not store name of the feature in the tree, since this name could be changed - if (theSubShape.ShapeType() != TopAbs_COMPOUND) { // compound means the whole construction result - if (theSubShape.ShapeType() == TopAbs_FACE) aName<<"Face"; - else if (theSubShape.ShapeType() == TopAbs_WIRE) aName<<"Wire"; - else if (theSubShape.ShapeType() == TopAbs_EDGE) aName<<"Edge"; - else if (theSubShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex"; - - // make a composite name from all sub-elements indexes: "1_2_3_4" - TColStd_MapIteratorOfPackedMapOfInteger aRef(aRefs); - for(; aRef.More(); aRef.Next()) { - aName<<"-"< aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + TDF_Label aShapeLab = aData->shapeLab(); + TDF_ChildIDIterator anOldIter(aShapeLab, TDataStd_IntPackedMap::GetID()); + for (; anOldIter.More(); anOldIter.Next()) { + aResult++; } } - if (!theRefs.IsNull()) { - Handle(TColStd_HPackedMapOfInteger) aMap = new TColStd_HPackedMapOfInteger(aRefs); - theRefs->ChangeMap(aMap); - } - return aName.str(); + return aResult; } -// stores shape and name on sub-label of the main stored shape -static void saveSubName(CompositeFeaturePtr theComposite, - TDF_Label& theLab, const bool isSelectionMode, TopoDS_Shape aSub, - std::shared_ptr theDoc, std::string theFullName) +std::shared_ptr Model_ResultConstruction::face(const int theIndex) { - // trying to store the edge of composite result, not sketch sub as it is - if (aSub.ShapeType() == TopAbs_EDGE) { - ResultPtr aRes = theComposite->firstResult(); - ResultConstructionPtr aConstr = std::dynamic_pointer_cast(aRes); - if (aConstr.get()) { - Standard_Real aSubFirst, aSubLast; - TopoDS_Edge aSubEdge = TopoDS::Edge(aSub); - Handle(Geom_Curve) aSubCurve = BRep_Tool::Curve(aSubEdge, aSubFirst, aSubLast); - for(int aFaceIndex = 0; aFaceIndex < aConstr->facesNum(); aFaceIndex++) { - GeomShapePtr aGFace = aConstr->face(aFaceIndex); - TopoDS_Shape aFace = aGFace->impl(); - for(TopExp_Explorer anExp(aFace, TopAbs_EDGE); anExp.More(); anExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anExp.Current()); - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (Model_CurvesHasher::IsEqual(aCurve, aSubCurve) && - ((fabs(aFirst - aSubFirst) < 1.e-9 && fabs(aLast - aSubLast) < 1.e-9)) || - (fabs(aFirst - aSubLast) < 1.e-9 && fabs(aLast - aSubFirst) < 1.e-9)) { - aSub = anEdge; - break; - } - } + std::shared_ptr aResult; + int anIndex = 0; + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData.get() && aData->isValid()) { + TDF_Label aShapeLab = aData->shapeLab(); + TDF_ChildIDIterator anOldIter(aShapeLab, TDataStd_IntPackedMap::GetID()); + for (; anOldIter.More(); anOldIter.Next()) { + if (anIndex == theIndex) { + Handle(TNaming_NamedShape) aNS; + anOldIter.Value()->Label().FindAttribute(TNaming_NamedShape::GetID(), aNS); + aResult.reset(new GeomAPI_Face); + aResult->setImpl(new TopoDS_Shape(aNS->Get())); + break; } + anIndex++; } } - - TNaming_Builder aBuilder(theLab); - if (isSelectionMode) - aBuilder.Select(aSub, aSub); - else - aBuilder.Generated(aSub); - theDoc->addNamingName(theLab, theFullName.c_str()); - TDataStd_Name::Set(theLab, theFullName.c_str()); + return aResult; } - -TDF_Label Model_ResultConstruction::startLabel( - const std::shared_ptr theExtDoc, bool& theExternal) +void Model_ResultConstruction::setIsConcealed(const bool theValue) { - theExternal = theExtDoc.get() && theExtDoc != document(); - if (theExternal) { // external document is used - std::shared_ptr aDoc = std::dynamic_pointer_cast(theExtDoc); - return aDoc->extConstructionsLabel(); - } - std::shared_ptr aData = std::dynamic_pointer_cast(data()); - return aData->label(); + // do nothing: the construction element is never concealed } -int Model_ResultConstruction::select(const std::shared_ptr& theSubShape, - const std::shared_ptr theExtDoc, const int theIndex) +void Model_ResultConstruction::storeShape(std::shared_ptr theShape) { - int anIndex; // resulting index of the sub-label - TopoDS_Shape aSubShape; - if (theSubShape.get()) { - aSubShape = theSubShape->impl(); - } else if (shape().get()) { - aSubShape = shape()->impl(); - } - // if external document requires this selection, put the naming structures to this doc - // to support the naming mechanism in this document correctly - bool anExternal; - TDF_Label aDataLab = startLabel(theExtDoc, anExternal); - if (theIndex == -1) { - anIndex = anExternal ? 2 : 1; // for the external doc don't mind about the main shape - - if (theSubShape.get() || anExternal) { // searching for already selected sub (or whole for ext) - // iterate all the already presented shapes to see the same - TDF_ChildIterator aSubsIter(aDataLab, Standard_False); - for(; aSubsIter.More(); aSubsIter.Next()) { - const TDF_Label aLab = aSubsIter.Value(); - if (aLab.Tag() == 1) // skip the root shape label - continue; - Handle(TNaming_NamedShape) aNS; - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - if (aNS->Get().IsSame(aSubShape)) { - return aLab.Tag() - 1; // found exactly the needed shape, nothing else to do - } - } - anIndex = aLab.Tag(); // searching for the latest index - } - anIndex = (anIndex == 1) ? 2 : (anIndex + 1); // next after 1-root, or next after all + std::shared_ptr aData = std::dynamic_pointer_cast(data()); + if (aData && aData->isValid()) { + std::string aMyName = data()->name(); + TDF_Label aShapeLab = aData->shapeLab(); + if (!theShape.get() || theShape->isNull()) { + aShapeLab.ForgetAllAttributes(); + TDataStd_Name::Set(aShapeLab, aMyName.c_str()); // restore name forgotten + return; } - } else { - anIndex = theIndex + 1; - } - - // set the naming structure at index - TDF_Label aLab = aDataLab.FindChild(anIndex, Standard_True); - - // if the subshape is part of a result face, select the whole face (#1997) - bool isSelectionMode = false; // and other don't set shapes - all the naming is in face label - if (!aSubShape.IsNull() && aSubShape.ShapeType() > TopAbs_FACE) { - // but before check that sub-vertex correctly detected as intersection of sketch edges (#2389) - int anEdgesNum = 2; - if (aSubShape.ShapeType() == TopAbs_VERTEX) { - anEdgesNum = 0; + std::shared_ptr aMyDoc = + std::dynamic_pointer_cast(document()); + const TopoDS_Shape& aShape = theShape->impl(); + if (isInfinite() || aShape.ShapeType() == TopAbs_VERTEX) { + aShapeLab.ForgetAllAttributes(); // clear all previously stored + TNaming_Builder aBuilder(aShapeLab); + aBuilder.Generated(aShape); + TDataStd_Name::Set(aShapeLab, aMyName.c_str()); + aMyDoc->addNamingName(aShapeLab, aMyName); + } else if (aShape.ShapeType() == TopAbs_EDGE) { // store sub-vertices on sub-labels + aShapeLab.ForgetAllAttributes(); // clear all previously stored + TNaming_Builder aBuilder(aShapeLab); + aBuilder.Generated(aShape); + + TopExp_Explorer anExp(aShape, TopAbs_VERTEX); + for(int anIndex = 1; anExp.More(); anExp.Next(), anIndex++) { + TDF_Label aSubLab = aShapeLab.FindChild(anIndex); + TNaming_Builder aBuilder(aSubLab); + aBuilder.Generated(anExp.Current()); + std::string aVertexName = aMyName + "_" + (anIndex == 1 ? "StartVertex" : "EndVertex"); + TDataStd_Name::Set(aSubLab, aVertexName.c_str()); + aMyDoc->addNamingName(aSubLab, aVertexName); + } + TDataStd_Name::Set(aShapeLab, aMyName.c_str()); + aMyDoc->addNamingName(aShapeLab, aMyName); + } else { // this is probably sketch, so, work with it as with composite + std::shared_ptr aWirePtr = + std::dynamic_pointer_cast(theShape); + if (!aWirePtr.get()) + return; // unknown case ResultPtr aThisPtr = std::dynamic_pointer_cast(data()->owner()); - FeaturePtr aThisFeature = document()->feature(aThisPtr); + FeaturePtr aThisFeature = aMyDoc->feature(aThisPtr); CompositeFeaturePtr aComposite = std::dynamic_pointer_cast(aThisFeature); - if (aComposite.get()) { - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - int aSubID = aComposite->subFeatureId(a); - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes; - for(aRes = aResults.cbegin(); aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (aConstr->shape() && aConstr->shape()->isEdge()) { - TopoDS_Shape aResShape = aConstr->shape()->impl(); - for(TopExp_Explorer anExp(aResShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) { - if (aSubShape.IsSame(anExp.Current())) { - anEdgesNum++; - break; - } - } - } - } - } - } - } - if (anEdgesNum > 1) { - for(int aFaceIndex = 0; aFaceIndex < facesNum(); aFaceIndex++) { - TopExp_Explorer anExp(face(aFaceIndex)->impl(), aSubShape.ShapeType()); - for(; anExp.More(); anExp.Next()) { - if (aSubShape.IsSame(anExp.Current())) { // this is the case: select the whole face - // here just store the face index (to update face if update of edge is needed) - TNaming_Builder aBuilder(aLab); - aBuilder.Select(aSubShape, aSubShape); - int aFaceSelID = select(face(aFaceIndex), theExtDoc, -1); - TDF_Reference::Set(aLab, aLab.Father().FindChild(aFaceSelID)); - isSelectionMode = true; - break; + if (!aComposite || aComposite->numberOfSubs() == 0) + return; // unknown case + // collect indices of curves of current composite + NCollection_DataMap aCurvesIndices; + NCollection_DataMap anEdgeIndices; + std::map aComponentsNames; // names of components that lay on index + const int aSubNum = aComposite->numberOfSubs(); + for (int a = 0; a < aSubNum; a++) { + FeaturePtr aSub = aComposite->subFeature(a); + const std::list >& aResults = aSub->results(); + std::list >::const_iterator aRes = aResults.cbegin(); + for (; aRes != aResults.cend(); aRes++) { + ResultConstructionPtr aConstr = + std::dynamic_pointer_cast(*aRes); + if (aConstr->shape() && aConstr->shape()->isEdge()) { + TopoDS_Edge anEdge = TopoDS::Edge(aConstr->shape()->impl()); + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); + aCurvesIndices.Bind(aCurve, a); + anEdgeIndices.Bind(a, anEdge); + aComponentsNames[a] = shortName(aConstr); } } } - } - } - - // external full result is not identified by index == 0, so, add here the ID - if (!theSubShape.get()) { - TDataStd_UAttribute::Set(aLab, kFULL_RESULT_ID); - // empty NS - TNaming_Builder aBuilder(aLab); - // store all sub-faces naming since faces may be used for extrusion, where all edges are needed - Handle(TDataStd_IntPackedMap) anIndices = TDataStd_IntPackedMap::Set(aLab); - std::list aFacesIndexes; - for(int a = 0; a < facesNum(); a++) { - anIndices->Add(select(face(a), theExtDoc, -1)); - } - return anIndex - 1; - } - - { // this to have erased Builder after the shape was generated (NS on this label may be changed) - TNaming_Builder aBuilder(aLab); - if (aSubShape.IsNull()) { - return anIndex - 1; // just keep empty named shape - } - // wire never happens as sub, it must be generated to be found - // by SelectionNaming TNaming_Tool::NamedShape - if (isSelectionMode && aSubShape.ShapeType() != TopAbs_WIRE) { - aBuilder.Select(aSubShape, aSubShape); - } else { - aBuilder.Generated(aSubShape); - } - } - - if (anIndex == 1 && isInfinite()) { // infinitive results has no sub-selection - return anIndex - 1; - } - ResultPtr aThisPtr = std::dynamic_pointer_cast(data()->owner()); - FeaturePtr aThisFeature = document()->feature(aThisPtr); - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aThisFeature); - if (!aComposite || aComposite->numberOfSubs() == 0) { - // saving of context is enough: result construction contains exactly the needed shape - return anIndex - 1; - } - - // identify the results of sub-object of the composite by edges - // save type of the selected shape in integer attribute - TopAbs_ShapeEnum aShapeType = aSubShape.ShapeType(); - TDataStd_Integer::Set(aLab, (int)aShapeType); - gp_Pnt aVertexPos; - // curves of the sketch sub-elements are used, so, edges are not equal - TColStd_MapOfTransient allCurves; - if (aShapeType == TopAbs_VERTEX) { // compare positions - aVertexPos = BRep_Tool::Pnt(TopoDS::Vertex(aSubShape)); - } else { - for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExp.Current()); - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - allCurves.Add(aCurve); - } - } - std::shared_ptr aMyDoc = - std::dynamic_pointer_cast(document()); - // iterate and store the result ids of sub-elements and sub-elements to sub-labels - Handle(TDataStd_IntPackedMap) aRefs = TDataStd_IntPackedMap::Set(aLab); - const int aSubNum = aComposite->numberOfSubs(); - // subs are placed on unique labels because of #2248: sketch curve may produce several edges, - // but #2401 - on stable labels - NCollection_Map aUsedIDMap; // already used lab tags for placement of shapes - for(int a = 0; a < aSubNum; a++) { - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes = aResults.cbegin(); - // there may be many shapes (circle and center): register if at least one is in selection - for(; aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (!aConstr->shape()) { - continue; - } - if (aShapeType != TopAbs_VERTEX) { - if (aConstr->shape()->isEdge()) { - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (!anEdge.IsNull()) { + std::list > aFaces; + GeomAlgoAPI_SketchBuilder::createFaces(aWirePtr->origin(), aWirePtr->dirX(), + aWirePtr->norm(), aWirePtr, aFaces); + // order is important to store faces in the same order if sketch is created from scratch + NCollection_IndexedDataMap aNewIndices; // edges indices + std::list >::iterator aFIter = aFaces.begin(); + for (; aFIter != aFaces.end(); aFIter++) { + std::shared_ptr aFace(new GeomAPI_Face(*aFIter)); + // put them to a label, trying to keep the same faces on the same labels + if (aFace.get() && !aFace->isNull()) { + TopoDS_Face aTopoFace = TopoDS::Face(aFace->impl()); + aNewIndices.Add(aTopoFace, TColStd_ListOfInteger()); + // keep new indices of sub-elements used in this face + for (TopExp_Explorer anEdges(aTopoFace, TopAbs_EDGE); anEdges.More(); anEdges.Next()) { + TopoDS_Edge anEdge = TopoDS::Edge(anEdges.Current()); Standard_Real aFirst, aLast; Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (allCurves.Contains(aCurve)) { - int anID = aComposite->subFeatureId(a); - if (aShapeType != TopAbs_EDGE) { // face needs the sub-edges on sub-labels - // add edges to sub-label to support naming for edges selection - TopExp_Explorer anEdgeExp(aSubShape, TopAbs_EDGE); - for(; anEdgeExp.More(); anEdgeExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExp.Current()); - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aFaceCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (Model_CurvesHasher::IsEqual(aFaceCurve, aCurve)) { - while(aUsedIDMap.Contains(anID)) - anID += 100000; - aUsedIDMap.Add(anID); - TDF_Label aSubLab = aLab.FindChild(anID); - std::string aFullNameSub = fullName(aComposite, anEdge); - saveSubName(aComposite, aSubLab, isSelectionMode, anEdge, aMyDoc, aFullNameSub); - - int anOrient = Model_SelectionNaming::edgeOrientation(aSubShape, anEdge); - if (anOrient != 0) { - // store the orientation of edge relatively to face if needed - TDataStd_Integer::Set(aSubLab, anOrient); - } - } - } - } else { // put vertices of the selected edge to sub-labels - // add edges to sub-label to support naming for edges selection - for(TopExp_Explorer anEdgeExp(aSubShape, TopAbs_VERTEX); - anEdgeExp.More(); anEdgeExp.Next()) { - TopoDS_Vertex aV = TopoDS::Vertex(anEdgeExp.Current()); - while(aUsedIDMap.Contains(anID)) - anID += 100000; - aUsedIDMap.Add(anID); - TDF_Label aSubLab = aLab.FindChild(anID); - std::string aFullNameSub = fullName(aComposite, aV); - saveSubName(aComposite, aSubLab, isSelectionMode, aV, aMyDoc, aFullNameSub); - } - } + if (aCurvesIndices.IsBound(aCurve)) { + int anIndex = aCurvesIndices.Find(aCurve); + if ((aFirst > aLast) != (anEdge.Orientation() == TopAbs_REVERSED)) + anIndex = -anIndex; + aNewIndices.ChangeFromKey(aTopoFace).Append(anIndex); } } } } - } - } - std::string aFullName = fullName(aComposite, aSubShape, aRefs); - // store the selected as primitive - registerSubShape(aLab, aSubShape, aFullName, 0, aMyDoc, isSelectionMode); - return anIndex - 1; -} - -std::shared_ptr Model_ResultConstruction::shape(const int theIndex, - const std::shared_ptr theExtDoc) -{ - std::shared_ptr aResult; - if (theIndex == 0) - return aResult; // the whole shape, so, NULL - - bool isExt; - TDF_Label aLab = startLabel(theExtDoc, isExt).FindChild(theIndex + 1); - if (!aLab.IsNull()) { // index is not bad - Handle(TNaming_NamedShape) aSelection; - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aSelection)) { - TopoDS_Shape aSelShape = aSelection->Get(); - if (aSelShape.IsNull()) - return aResult; // shape equal to context => null - aResult = std::shared_ptr(new GeomAPI_Shape); - aResult->setImpl(new TopoDS_Shape(aSelShape)); - } - } - - return aResult; -} - -bool Model_ResultConstruction::update(const int theIndex, - const std::shared_ptr theExtDoc, bool& theModified) -{ - theModified = false; - bool anExt; - TDF_Label aLab = startLabel(theExtDoc, anExt).FindChild(theIndex + 1, Standard_True); - if (theIndex == 0 || aLab.IsAttribute(kFULL_RESULT_ID)) { // full for external same as index == 0 - // it is just reference to construction, not sub-shape - // if there is a sketch, the sketch-naming must be updated - if (!isInfinite()) { - // update all faces named by the whole result - bool aRes = true; - Handle(TDataStd_IntPackedMap) anIndices; - if (aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), anIndices)) { - NCollection_Map aFaces; // collect faces, updated in the tree - TColStd_MapIteratorOfPackedMapOfInteger anIndexIter(anIndices->GetMap()); - Handle(TColStd_HPackedMapOfInteger) aNewPackedMap = - new TColStd_HPackedMapOfInteger; // with only faces that are ok - // iterate to find existing faces, updated - for(; anIndexIter.More(); anIndexIter.Next()) { - if (update(anIndexIter.Key(), theExtDoc, theModified)) { - GeomShapePtr aFace = shape(anIndexIter.Key(), theExtDoc); - if (!aFaces.Contains(aFace->impl())) { - aNewPackedMap->ChangeMap().Add(anIndexIter.Key()); - aFaces.Add(aFace->impl()); + NCollection_DataMap aFacesOrder; // faces -> tag where they must be set + NCollection_List anUnorderedFaces; // faces that may be located at any index + // searching for the best new candidate to old location + NCollection_IndexedDataMap::Iterator + aNewIter(aNewIndices); + for (; aNewIter.More(); aNewIter.Next()) { + double aBestFound = 0, aBestNotFound = 1.e+100; + int aBestTag = 0; + const TColStd_ListOfInteger& aNewInd = aNewIter.Value(); + // old faces indices where they where located + TDF_ChildIDIterator anOldIter(aShapeLab, TDataStd_IntPackedMap::GetID()); + for (; anOldIter.More(); anOldIter.Next()) { + int aTag = anOldIter.Value()->Label().Tag(); + if (aFacesOrder.IsBound(aTag)) + continue; // already found a best candidate + Handle(TDataStd_IntPackedMap) anOldIndices = + Handle(TDataStd_IntPackedMap)::DownCast(anOldIter.Value()); + double aFound = 0, aNotFound = 0; + TColStd_ListOfInteger::Iterator aNewIndIter(aNewInd); + for (; aNewIndIter.More(); aNewIndIter.Next()) { + if (anOldIndices->Contains(aNewIndIter.Value())) { + aFound += 1.; + } + else if (anOldIndices->Contains(-aNewIndIter.Value())) { // different orientation + aFound += 0.001; + } + else { + aNotFound += 1.; } } - } - // then iterate all existing faces to find new faces - int aCurrentFacesNum = facesNum(); - for(int a = 0; a < aCurrentFacesNum; a++) { - GeomShapePtr aFace = face(a); - if (!aFaces.Contains(aFace->impl())) { - // add this one - int aNewFaceIndex = select(aFace, theExtDoc, -1); - if (aNewFaceIndex > 0) { - aNewPackedMap->ChangeMap().Add(aNewFaceIndex); + if (aNotFound < aBestNotFound) { + if (aFound > aBestFound) { + aBestNotFound = aNotFound; + aBestFound = aFound; + aBestTag = aTag; } } } - anIndices->ChangeMap(aNewPackedMap); - } - return aRes; - } else { - // check is this modified or not - std::shared_ptr aNewShape = shape(); - TopoDS_Shape anOldSh; - Handle(TNaming_NamedShape) aNS; - if (aLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - anOldSh = aNS->Get(); - } - if (aNewShape.get()) { - if (anOldSh.IsNull()) - theModified = true; - else { - std::shared_ptr anOldShape(new GeomAPI_Shape); - anOldShape->setImpl(new TopoDS_Shape(anOldSh)); - theModified = !anOldShape->isEqual(aNewShape); + if (aBestTag != 0) { // found an appropriate face + aFacesOrder.Bind(aBestTag, aNewIter.Key()); + } else { + anUnorderedFaces.Append(aNewIter.Key()); } } - else if (!anOldSh.IsNull()) { - theModified = true; - } - - // For correct naming selection, put the shape into the naming structure. - // It seems sub-shapes are not needed: only this shape is (and can be ) selected. - TNaming_Builder aBuilder(aLab); - aBuilder.Generated(aNewShape->impl()); - } - return shape() && !shape()->isNull(); - } - // construction: identification by the results indexes, recompute faces and - // take the face that more close by the indexes - ResultPtr aThisPtr = std::dynamic_pointer_cast(data()->owner()); - FeaturePtr aContextFeature = document()->feature(aThisPtr); + aShapeLab.ForgetAllAttributes(); // clear all previously stored + TDataStd_Name::Set(aShapeLab, aMyName.c_str()); // restore name forgotten + TNaming_Builder aBuilder(aShapeLab); // store the compound to get it ready on open of document + aBuilder.Generated(aShape); + aMyDoc->addNamingName(aShapeLab, aMyName); + // set new faces to the labels + int aCurrentTag = 1; + NCollection_List::Iterator anUnordered(anUnorderedFaces); + for(int aCurrentTag = 1; !aFacesOrder.IsEmpty() || anUnordered.More(); aCurrentTag++) { + TopoDS_Face aFaceToPut; + if (aFacesOrder.IsBound(aCurrentTag)) { + aFaceToPut = aFacesOrder.Find(aCurrentTag); + aFacesOrder.UnBind(aCurrentTag); + } else if (anUnordered.More()){ + aFaceToPut = anUnordered.Value(); + anUnordered.Next(); + } - // sketch sub-element - if (std::dynamic_pointer_cast(aContextFeature).get()) - { - // update the referenced object if it is sub - Handle(TDF_Reference) aRef; - if (aLab.FindAttribute(TDF_Reference::GetID(), aRef)) { - int aFaceIndex = aRef->Get().Tag(); - // don't check selection since face may disappear, but the shape stays correct - Model_ResultConstruction::update(aFaceIndex, theExtDoc, theModified); - } - // getting a type of selected shape - Handle(TDataStd_Integer) aTypeAttr; - if (!aLab.FindAttribute(TDataStd_Integer::GetID(), aTypeAttr)) { - return false; - } - TopAbs_ShapeEnum aShapeType = (TopAbs_ShapeEnum)(aTypeAttr->Get()); - // selected indexes will be needed in each "if" - Handle(TDataStd_IntPackedMap) aSubIds; - std::shared_ptr aNewSelected; - bool aNoIndexes = - !aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), aSubIds) || aSubIds->Extent() == 0; - // for now working only with composite features - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aContextFeature); - if (!aComposite.get() || aComposite->numberOfSubs() == 0) { - return false; - } + if (!aFaceToPut.IsNull()) { + TopTools_MapOfShape aFaceEdges; + for(TopExp_Explorer anEdges(aFaceToPut, TopAbs_EDGE); anEdges.More(); anEdges.Next()) { + aFaceEdges.Add(anEdges.Current()); + } - if (aShapeType == TopAbs_FACE || aShapeType == TopAbs_WIRE) { - // compound is for the whole sketch selection - // If this is a wire with plane defined then it is a sketch-like object - if (!facesNum()) // no faces, update can not work correctly - return false; - // if there is no edges indexes, any face can be used: take the first - std::shared_ptr aNewSelected; - if (aNoIndexes) { - aNewSelected = face(0); - } else { // searching for most looks-like initial face by the indexes - // prepare edges of the current result for the fast searching - // curves and orientations of edges - NCollection_DataMap allCurves; - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - int aSubID = aComposite->subFeatureId(a); - if (aSubIds->Contains(aSubID)) { - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes; - for(aRes = aResults.cbegin(); aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (aConstr->shape() && aConstr->shape()->isEdge()) { - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (!anEdge.IsNull()) { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - // searching for orientation information - int anOrient = 0; - Handle(TDataStd_Integer) anInt; - if (aLab.FindChild(aSubID).FindAttribute(TDataStd_Integer::GetID(), anInt)) { - anOrient = anInt->Get(); - } - allCurves.Bind(aCurve, anOrient); - } + TDF_Label aLab = aShapeLab.FindChild(aCurrentTag); + TNaming_Builder aFaceBuilder(aLab); + aFaceBuilder.Generated(aFaceToPut); + // store also indices of the new face edges + Handle(TDataStd_IntPackedMap) aNewMap = TDataStd_IntPackedMap::Set(aLab); + const TColStd_ListOfInteger& aNewInd = aNewIndices.FindFromKey(aFaceToPut); + std::stringstream aName; + aName<<"Face"; + TopExp_Explorer aPutEdges(aFaceToPut, TopAbs_EDGE); + TNaming_Builder *anEdgesBuilder = 0, *aVerticesBuilder = 0; + for(TColStd_ListOfInteger::Iterator anIter(aNewInd); anIter.More(); anIter.Next()) { + int anIndex = anIter.Value(); + int aModIndex = anIndex > 0 ? anIndex : -anIndex; + aNewMap->Add(anIndex); + aName<<"-"< 0) + aName<<"f"; + else + aName<<"r"; + // collect all edges of the face which are modified in sub-label of the face + if (anEdgeIndices.IsBound(aModIndex) && + !aFaceEdges.Contains(anEdgeIndices.Find(aModIndex))) { + if (!anEdgesBuilder) { + TDF_Label anEdgesLabel = aLab.FindChild(1); + anEdgesBuilder = new TNaming_Builder(anEdgesLabel); + std::ostringstream aSubName; + // tag is needed for Test1922 to distinguish sub-edges of different faces + aSubName<<"SubEdge_"<Modify(anEdgeIndices.Find(aModIndex), aPutEdges.Current()); } - } - } - aNewSelected = Model_SelectionNaming::findAppropriateFace( - aThisPtr, allCurves, aShapeType == TopAbs_WIRE); - } - if (aNewSelected) { // store this new selection - select(aNewSelected, theExtDoc, theIndex); - theModified = true; - return true; - } else { - // if the selection is not found, put the empty shape: - // it's better to have disappeared shape, than the old, the lost one - TNaming_Builder anEmptyBuilder(aLab); - return false; - } - } else if (aShapeType == TopAbs_EDGE) { - // just reselect the edge by the id - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - // if aSubIds take any, the first appropriate - if (aSubIds->IsEmpty() || aSubIds->Contains(aComposite->subFeatureId(a))) { - // found the appropriate feature - FeaturePtr aFeature = aComposite->subFeature(a); - std::list >::const_iterator aResIter = - aFeature->results().cbegin(); - for(;aResIter != aFeature->results().cend(); aResIter++) { - ResultConstructionPtr aRes = - std::dynamic_pointer_cast(*aResIter); - if (aRes && aRes->shape() && aRes->shape()->isEdge()) { // found! - select(aRes->shape(), theExtDoc, theIndex); - theModified = true; - return true; - } - } - } - } - } else if (aShapeType == TopAbs_VERTEX) { - // just reselect the vertex by the id of edge - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - // if aSubIds take any, the first appropriate - int aFeatureID = aComposite->subFeatureId(a); - if (aSubIds->IsEmpty() || aSubIds->Contains(aFeatureID) || - aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA) || - aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) { - // searching for deltas - int aVertexNum = 0; - if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1; - else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2; - // found the feature with appropriate edge - FeaturePtr aFeature = aComposite->subFeature(a); - std::list >::const_iterator aResIter = - aFeature->results().cbegin(); - for(;aResIter != aFeature->results().cend(); aResIter++) { - ResultConstructionPtr aRes = - std::dynamic_pointer_cast(*aResIter); - if (aRes && aRes->shape()) { - if (aRes->shape()->isVertex() && aVertexNum == 0) { // found! - select(aRes->shape(), theExtDoc, theIndex); - theModified = true; - return true; - } else if (aRes->shape()->isEdge() && aVertexNum > 0) { - const TopoDS_Shape& anEdge = aRes->shape()->impl(); - int aVIndex = 1; - for(TopExp_Explorer aVExp(anEdge, TopAbs_VERTEX); aVExp.More(); aVExp.Next()) { - if (aVIndex == aVertexNum) { // found! - std::shared_ptr aVertex(new GeomAPI_Shape); - aVertex->setImpl(new TopoDS_Shape(aVExp.Current())); - select(aVertex, theExtDoc, theIndex); - theModified = true; - return true; - } - aVIndex++; + // put also modified vertices, otherwise vertex of original edge has no history + if (anEdgeIndices.IsBound(aModIndex)) { + TopExp_Explorer aVExpOld(anEdgeIndices.Find(aModIndex), TopAbs_VERTEX); + TopExp_Explorer aVExpNew(aPutEdges.Current(), TopAbs_VERTEX); + for(; aVExpNew.More() && aVExpOld.More(); aVExpNew.Next(), aVExpOld.Next()) { + if (!aVExpOld.Current().IsSame(aVExpNew.Current())) { + if (!aVerticesBuilder) { + TDF_Label aVertLabel = aLab.FindChild(2); + aVerticesBuilder = new TNaming_Builder(aVertLabel); + std::ostringstream aSubName; + // tag is needed for Test1922 to distinguish sub-edges of different faces + aSubName<<"SubVertex_"<Modify(aVExpOld.Current(), aVExpNew.Current()); + } } } + aPutEdges.Next(); + } + if (anEdgesBuilder) + delete anEdgesBuilder; + if (aVerticesBuilder) + delete aVerticesBuilder; + TDataStd_Name::Set(aLab, TCollection_ExtendedString(aName.str().c_str())); + aMyDoc->addNamingName(aLab, aName.str()); + // put also wires to sub-labels to correctly select them instead of collection by edges + int aWireTag = 3; // first tag is for SubEdge-s, second - for vertices + for(TopExp_Explorer aWires(aFaceToPut, TopAbs_WIRE); aWires.More(); aWires.Next()) { + TDF_Label aWireLab = aLab.FindChild(aWireTag); + TNaming_Builder aWireBuilder(aWireLab); + aWireBuilder.Generated(aWires.Current()); + std::ostringstream aWireName; + aWireName< 3) + aWireName<<"_"<addNamingName(aWireLab, aWireName.str()); + aWireTag++; + } } } } - } else { // simple construction element: the selected is that needed - select(shape(), theExtDoc, theIndex); - theModified = true; - return true; } - return false; // unknown case } diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h index b5ea41cd9..3ba48777f 100644 --- a/src/Model/Model_ResultConstruction.h +++ b/src/Model/Model_ResultConstruction.h @@ -39,22 +39,13 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction { std::shared_ptr myOwner; ///< owner of this result std::shared_ptr myShape; ///< shape of this result created "on the fly" - bool myFacesUpToDate; ///< is true if faces in myuFaces are computed and up to date - /// stores the up to date faces if they exist - std::vector > myFaces; - bool myIsInHistory; - bool myIsInfinite; public: /// Retuns the parameters of color definition in the resources config manager MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName, std::string& theDefault); /// By default object is displayed in the object browser. - MODEL_EXPORT virtual bool isInHistory() - { - return myIsInHistory; - } - + MODEL_EXPORT virtual bool isInHistory(); /// Sets the result MODEL_EXPORT virtual void setShape(std::shared_ptr theShape); /// Returns the shape-result produced by this feature @@ -76,39 +67,16 @@ class Model_ResultConstruction : public ModelAPI_ResultConstruction /// The construction element is never concealed MODEL_EXPORT virtual void setIsConcealed(const bool theValue); - // methods related to selection of sub-shapes in construction, used by SelectionAttribute - - /// Selects theSubShape in the construction. Returns an index of the selected sub-shape. - /// Puts the selected shape with a needed BRepNaming sub-structure to the data tree of result. - /// If theSubShape is null, it selects the whole construction and returns zero index. - /// If theIndex is not -1, it re-selects over the existing data (used for update selection). - /// If theExtDoc is document where this selection is needed, if it differs from this, - /// naming structures will be located there. - int select(const std::shared_ptr& theSubShape, - const std::shared_ptr theExtDoc, const int theIndex = -1); - - /// Returns already selected shape by the given index. Zero index means the whole construction, - /// so, the returned shape in this case is null. - /// If theExtDoc is document where this selection is needed, if it differs from this, - /// naming structures will be located there. - std::shared_ptr shape(const int theIndex, - const std::shared_ptr theExtDoc); - - /// Updates the existing selection by the index. - /// Returns false if update is failed. Returns theModified true if the selection was updated. - /// If theExtDoc is document where this selection is needed, if it differs from this, - /// naming structures will be updated there. - bool update(const int theIndex, const std::shared_ptr theExtDoc, - bool& theModified); + /// Updates the shape taking the current value from the data structure, returns true + /// if update has been correctly done + MODEL_EXPORT virtual bool updateShape(); protected: /// Makes a body on the given feature Model_ResultConstruction(); - /// Searchies for the working label selection/update will start from - /// Returns true if this is label of the external document. - /// theExtDoc is document where this selection is required - TDF_Label startLabel(const std::shared_ptr theExtDoc, bool& theExternal); + /// Stores shape in the data structure to allow identification it by the naming + void storeShape(std::shared_ptr theShape); friend class Model_Objects; }; diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 255f5e380..dbad51c7b 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -169,6 +169,8 @@ std::shared_ptr Model_ResultPart::shape() { std::shared_ptr aResult(new GeomAPI_Shape); if (myShape.IsNull()) { // shape is not produced yet, create it + SessionPtr aMgr = ModelAPI_Session::get(); + bool aToSendUpdate = aMgr->isOperation(); // inside of operation may send an update evnet if (myTrsf.get()) { // get shape of the base result and apply the transformation ResultPtr anOrigResult = baseRef(); std::shared_ptr anOrigShape = anOrigResult->shape(); @@ -180,6 +182,10 @@ std::shared_ptr Model_ResultPart::shape() aResult->setImpl(new TopoDS_Shape(aShape)); } } + if (!myShape.IsNull() && aToSendUpdate) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + } return aResult; } else { DocumentPtr aDoc = Model_ResultPart::partDoc(); @@ -205,9 +211,14 @@ std::shared_ptr Model_ResultPart::shape() } } } + if (!myShape.IsNull() && aToSendUpdate) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + } } - if (!myShape.IsNull()) + if (!myShape.IsNull()) { aResult->setImpl(new TopoDS_Shape(myShape)); + } return aResult; } @@ -312,6 +323,24 @@ gp_Trsf Model_ResultPart::sumTrsf() { return aResult; } +bool Model_ResultPart::combineGeometrical(const int theIndex, std::string& theNewName) +{ + std::shared_ptr aDoc = std::dynamic_pointer_cast(partDoc()); + if (aDoc.get()) { + AttributeSelectionListPtr aSelAttr = aDoc->selectionInPartFeature(); + AttributeSelectionPtr aThisAttr = aSelAttr->value(theIndex - 1); + if (aThisAttr.get()) { + aThisAttr->combineGeometrical(); + if (aThisAttr->value().get()) { + int anIndex; + theNewName = nameInPart(aThisAttr->value(), anIndex); + return true; + } + } + } + return false; // something is wrong +} + std::shared_ptr Model_ResultPart::shapeInPart( const std::string& theName, const std::string& theType, int& theIndex) { diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h index b6a130511..d632ae187 100644 --- a/src/Model/Model_ResultPart.h +++ b/src/Model/Model_ResultPart.h @@ -79,6 +79,8 @@ class Model_ResultPart : public ModelAPI_ResultPart /// Returns the shape by the name in the part MODEL_EXPORT virtual std::shared_ptr shapeInPart( const std::string& theName, const std::string& theType, int& theIndex); + /// Updates the selection inside of the part as a geometrical selection + MODEL_EXPORT virtual bool combineGeometrical(const int theIndex, std::string& theNewName); /// Updates the shape-result of the part (called on Part feature execution) MODEL_EXPORT virtual void updateShape(); /// Applies the additional transformation of the part diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp deleted file mode 100644 index 802b13cfc..000000000 --- a/src/Model/Model_SelectionNaming.cpp +++ /dev/null @@ -1,1218 +0,0 @@ -// 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 "Model_SelectionNaming.h" -#include "Model_Document.h" -#include "Model_Objects.h" -#include "Model_Data.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DEB_NAMING -#include -#endif - -Model_SelectionNaming::Model_SelectionNaming(TDF_Label theSelectionLab) -{ - myLab = theSelectionLab; -} - -// searches named shape by the shape in the given document (identified by the label) -// tries to find s shape nearest to the context-label -static Handle(TNaming_NamedShape) shapeToNS(const TDF_Label theLabAccess, - const TopoDS_Shape& theShape, const TDF_Label& theContextLab) -{ - Handle(TNaming_NamedShape) aResult; - if (!TNaming_Tool::HasLabel(theLabAccess, theShape)) // no shape in the document - return aResult; - int aContextLabDepth = theContextLab.IsNull() ? 100 : theContextLab.Depth(); - TNaming_SameShapeIterator aNSIter(theShape, theLabAccess); - for(; aNSIter.More(); aNSIter.Next()) { - TDF_Label aLabel = aNSIter.Label(); - Handle(TNaming_NamedShape) aNS; - if (aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - if (aNS->Evolution() != TNaming_SELECTED && aNS->Evolution() != TNaming_DELETE) { - // check this is new shape in this named shape - bool aIsNew = false; - for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) - if (!aNSIter.NewShape().IsNull() && aNSIter.NewShape().IsSame(theShape)) - aIsNew = true; - if (!aIsNew) - continue; - // check this is the context-shape - while(aLabel.Depth() > aContextLabDepth) - aLabel = aLabel.Father(); - if (aLabel.IsEqual(theContextLab)) - return aNS; - if (aResult.IsNull()) // take the first, otherwise it will get shapes from results, etc - aResult = aNS; // keep some result anyway - if there are no context labels return any - } - } - } - return aResult; -} - -std::string Model_SelectionNaming::getShapeName( - std::shared_ptr theDoc, const TopoDS_Shape& theShape, - ResultPtr& theContext, const bool theAnotherDoc, const bool theWholeContext) -{ - std::string aName; - // add the result name to the name of the shape - // (it was in BodyBuilder, but did not work on Result rename) - bool isNeedContextName = theContext->shape().get() != NULL; - // check if the subShape is already in DF - std::shared_ptr aData = - std::dynamic_pointer_cast(theContext->data()); - TDF_Label aContextDataLab(aData.get() && aData->isValid() ? aData->label() : TDF_Label()); - Handle(TNaming_NamedShape) aNS = shapeToNS(myLab, theShape, aContextDataLab); - Handle(TDataStd_Name) anAttr; - if(!aNS.IsNull() && !aNS->IsEmpty()) { // in the document - if(aNS->Label().FindAttribute(TDataStd_Name::GetID(), anAttr)) { - if (isNeedContextName && aData && aContextDataLab.IsEqual(aNS->Label())) { - // do nothing because this context name will be added later in this method - } else { - aName = TCollection_AsciiString(anAttr->Get()).ToCString(); - // indexes are added to sub-shapes not primitives - // (primitives must not be located at the same label) - if(!aName.empty() && aNS->Evolution() != TNaming_PRIMITIVE && isNeedContextName) { - const TDF_Label& aLabel = aNS->Label(); - static const std::string aPostFix("_"); - TNaming_Iterator anItL(aNS); - for(int i = 1; anItL.More(); anItL.Next(), i++) { - // in #1766 IsEqual produced no index of the face - if(anItL.NewShape().IsSame(theShape)) { - aName += aPostFix; - aName += TCollection_AsciiString (i).ToCString(); - break; - } - } - } - // if a shape is under another context, use this name, not theContext - std::shared_ptr aContextData = - std::dynamic_pointer_cast(theContext->data()); - // for constructions the naming is in arguments and has no evolution, so, apply this only - // for bodies - if (isNeedContextName && theContext->groupName() == ModelAPI_ResultBody::group() && - !aNS->Label().IsDescendant(aContextData->label())) { - isNeedContextName = false; - TDF_Label aNSDataLab = aNS->Label(); - if (aNSDataLab.Depth() % 2 == 0) - aNSDataLab = aNSDataLab.Father(); - ObjectPtr aNewContext = theDoc->objects()->object(aNSDataLab); - while(!aNewContext.get() && aNSDataLab.Depth() > 5) { - aNSDataLab = aNSDataLab.Father().Father(); - aNewContext = theDoc->objects()->object(aNSDataLab); - } - if (aNewContext.get()) { - // this is to avoid duplicated names of results problem - std::string aContextName = aNewContext->data()->name(); - // myLab corresponds to the current time - TDF_Label aCurrentLab = myLab; - while(aCurrentLab.Depth() > 3) - aCurrentLab = aCurrentLab.Father(); - - int aNumInHistoryNames = - theDoc->numberOfNameInHistory(aNewContext, aCurrentLab); - while(aNumInHistoryNames > 1) { // add "_" before name the needed number of times - aContextName = "_" + aContextName; - aNumInHistoryNames--; - } - - aName = aContextName + "/" + aName; - } - } - } - } - } - - // Name is empty and this is full context, it just add the whole context name that must be added - bool isEmptyName = aName.empty(); - if (isNeedContextName && (!isEmptyName || theWholeContext)) { - aName = theContext->data()->name() + (isEmptyName ? "" : ("/" + aName)); - if (theAnotherDoc) - aName = theContext->document()->kind() + "/" + aName; // PartSet - } - return aName; -} - -bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfShape& theSMap) -{ - // a trivial case: F1 & F2, aNumber = 1, i.e. intersection gives 1 edge. - TopoDS_Compound aCmp; - BRep_Builder BB; - BB.MakeCompound(aCmp); - TopTools_ListIteratorOfListOfShape it(theAncestors); - for(;it.More();it.Next()) { - if (theSMap.Contains(it.Value())) - continue; - BB.Add(aCmp, it.Value()); - theSMap.Add(it.Value()); - } - int aNumber(0); - TopTools_IndexedDataMapOfShapeListOfShape aMap2; - TopExp::MapShapesAndAncestors(aCmp, TopAbs_EDGE, TopAbs_FACE, aMap2); - for (int i = 1; i <= aMap2.Extent(); i++) { - const TopoDS_Shape& aKey = aMap2.FindKey(i); - const TopTools_ListOfShape& anAncestors = aMap2.FindFromIndex(i); - if(anAncestors.Extent() > 1) aNumber++; - } - if(aNumber > 1) return false; - return true; -} - -const TopoDS_Shape findCommonShape( - const TopAbs_ShapeEnum theType, const TopTools_ListOfShape& theList) -{ - if(theList.Extent() < 1) { - return TopoDS_Shape(); - } else if (theList.Extent() == 1) { // check that sub-shape is bounded by this alone shape - TopTools_MapOfShape aSubsInShape; - TopExp_Explorer anExp(theList.First(), theType); - for(; anExp.More(); anExp.Next()) { - if (aSubsInShape.Contains(anExp.Current())) { // found duplicate - return anExp.Current(); - } - aSubsInShape.Add(anExp.Current()); - } - } - - // Store in maps sub-shapes from each face. - std::vector aVec; - for(TopTools_ListIteratorOfListOfShape anIt(theList); anIt.More(); anIt.Next()) { - const TopoDS_Shape aFace = anIt.Value(); - TopTools_MapOfShape aMap; - for(TopExp_Explorer anExp(aFace, theType); anExp.More(); anExp.Next()) { - const TopoDS_Shape& aSubShape = anExp.Current(); - aMap.Add(anExp.Current()); - } - aVec.push_back(aMap); - } - - // Find sub-shape shared between all faces. - TopoDS_Shape aSharedShape; - for(TopTools_MapIteratorOfMapOfShape anIt(aVec[0]); anIt.More(); anIt.Next()) { - const TopoDS_Shape& aSubShape = anIt.Value(); - int aSharedNb = 1; - for(int anIndex = 1; anIndex < aVec.size(); ++anIndex) { - if(aVec[anIndex].Contains(aSubShape)) { - ++aSharedNb; - } - } - if(aSharedNb == theList.Extent()) { - if(aSharedShape.IsNull()) { - aSharedShape = aSubShape; - } else { - // More than one shape shared between all faces, return null shape in this case. - return TopoDS_Shape(); - } - } - } - - return aSharedShape; -} - -// searches theType shape that contains theConnectionType sub-shapes in each shape from the List, -// so, implements the neighbours searching -/* -const TopoDS_Shape findCommonShapeByNB(const TopAbs_ShapeEnum theType, - const TopAbs_ShapeEnum theConnectionType, const TopTools_ListOfShape& theList) -{ -TopTools_MapOfShape aCheckedShapes; // already checked shapes of type theType - TopoDS_Shape aResult; // theType result shape - for(TopTools_ListIteratorOfListOfShape anIt(theList); anIt.More(); anIt.Next()) { // iterate all - for(TopExp_Explorer anExp(anIt.ChangeValue(), theType); anExp.More(); anExp.Next()) { - if (aCheckedShapes.Contains(anExp.Current())) - continue; // already checked - aCheckedShapes.Add(anExp.Current()); - TopTools_MapOfShape aConnectors; // all connectors of the checked theType shape - for(TopExp_Explorer aCExp(anExp.Current(), theConnectionType); aCExp.More(); aCExp.Next()) { - aConnectors.Add(aCExp.Current()); - } - // check that all shapes from the List contain the connector sub-shapes - bool aFound = true; - for(TopTools_ListIteratorOfListOfShape anIt2(theList); anIt2.More() && aFound; anIt2.Next()) { - if (anIt2.Value().IsSame(anIt.Value())) - continue; - aFound = false; - for(TopExp_Explorer anE(anIt2.ChangeValue(), theConnectionType); anE.More(); anE.Next()) { - if (aConnectors.Contains(anE.Current())) { - aFound = true; - break; - } - } - } - if (aFound) { - if (!aResult.IsNull()) // more than one result - return TopoDS_Shape(); - aResult = anExp.Current(); - } - } - } - return aResult; -}*/ - -std::string Model_SelectionNaming::vertexNameByEdges(TopoDS_Shape theContext, TopoDS_Shape theSub, - std::shared_ptr theDoc, ResultPtr& theContextRes, const bool theAnotherDoc) -{ - std::string aResult; - TopTools_IndexedDataMapOfShapeListOfShape aMap; - TopExp::MapShapesAndAncestors(theContext, TopAbs_VERTEX, TopAbs_EDGE, aMap); - const TopTools_ListOfShape& aList22 = aMap.FindFromKey(theSub); - if(aList22.Extent() >= 2) { // regular solution - TopTools_MapOfShape aFMap; - TopTools_ListOfShape aListE; - TopTools_ListIteratorOfListOfShape itl2(aList22); - for (int i = 1;itl2.More();itl2.Next(),i++) { - if(aFMap.Add(itl2.Value())) - aListE.Append(itl2.Value()); - } - TopTools_ListIteratorOfListOfShape itl(aListE); - for (int i = 1;itl.More();itl.Next(),i++) { - const TopoDS_Shape& anEdge = itl.Value(); - std::string anEdgeName = getShapeName(theDoc, anEdge, theContextRes, theAnotherDoc, false); - if (anEdgeName.empty()) { // edge is not in DS - aResult.clear(); - return aResult; - } - if(i == 1) - aResult = anEdgeName; - else - aResult += "&" + anEdgeName; - } - } - return aResult; -} - -std::string Model_SelectionNaming::namingName(ResultPtr& theContext, - std::shared_ptr theSubSh, const std::string& theDefaultName, - const bool theAnotherDoc) -{ - std::string aName("Undefined name"); - if(!theContext.get() - || !theContext->shape().get() - || theContext->shape()->isNull()) { - return !theDefaultName.empty() ? theDefaultName : aName; - } - - // if it is in result of another part - std::shared_ptr aDoc = - std::dynamic_pointer_cast(theContext->document()); - if (theContext->groupName() == ModelAPI_ResultPart::group()) { - ResultPartPtr aPart = std::dynamic_pointer_cast(theContext); - int anIndex; - if (theSubSh.get()) - return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex); - else - return aPart->data()->name(); - } - - if (!theSubSh.get() || theSubSh->isNull()) { // no subshape, so just the whole feature name - // but if it is in another Part, add this part name - std::string aPartName; - if (theAnotherDoc) - aPartName = theContext->document()->kind() + "/"; // PartSet - return aPartName + theContext->data()->name(); - } - TopoDS_Shape aSubShape = theSubSh->impl(); - TopoDS_Shape aContext = theContext->shape()->impl(); -#ifdef DEB_NAMING - if(aSubShape.ShapeType() == TopAbs_COMPOUND) { - BRepTools::Write(aSubShape, "Selection.brep"); - BRepTools::Write(aContext, "Context.brep"); - } -#endif - aName = getShapeName(aDoc, aSubShape, theContext, theAnotherDoc, - theContext->shape()->isEqual(theSubSh)); - - if(aName.empty() ) { // not in the document! - TopAbs_ShapeEnum aType = aSubShape.ShapeType(); - switch (aType) { - case TopAbs_FACE: - // the Face should be in DF. If it is not the case, it is an error ==> to be debugged - break; - case TopAbs_EDGE: - { - // name structure: F1 & F2 [& F3 & F4], - // where F1 & F2 the faces which gives the Edge in trivial case - // if it is not atrivial case we use localization by neighbours. F3 & F4 - neighbour faces - if (BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) { - aName = "Degenerated_Edge"; - break; - } - TopTools_IndexedDataMapOfShapeListOfShape aMap; - TopExp::MapShapesAndAncestors(aContext, TopAbs_EDGE, TopAbs_FACE, aMap); - TopTools_IndexedMapOfShape aSMap; // map for ancestors of the sub-shape - bool isTrivialCase(true); - if(aMap.Contains(aSubShape)) { - const TopTools_ListOfShape& anAncestors = aMap.FindFromKey(aSubShape); - // check that it is not a trivial case (F1 & F2: aNumber = 1) - isTrivialCase = isTrivial(anAncestors, aSMap); - if (!isTrivialCase) { // another try: check that common shape can be processed anyway - isTrivialCase = !findCommonShape(TopAbs_EDGE, anAncestors).IsNull(); - } - } else - break; - TopTools_MapOfShape aNbs; - if(!isTrivialCase) { // find Neighbors - TNaming_Localizer aLocalizer; - TopTools_MapOfShape aMap3; - aLocalizer.FindNeighbourg(aContext, aSubShape, aMap3); - //int n = aMap3.Extent(); - TopTools_MapIteratorOfMapOfShape it(aMap3); - for(;it.More();it.Next()) { - const TopoDS_Shape& aNbShape = it.Key(); // neighbor edge - //TopAbs_ShapeEnum aType = aNbShape.ShapeType(); - const TopTools_ListOfShape& aList = aMap.FindFromKey(aNbShape); - TopTools_ListIteratorOfListOfShape it2(aList); - for(;it2.More();it2.Next()) { - if(aSMap.Contains(it2.Value())) continue; // skip this Face - aNbs.Add(it2.Value()); - } - } - } // else a trivial case - - // build name of the sub-shape Edge - // iterate faces of the context to get stable order, not map-order - TopTools_MapOfShape aStoredFaces; // to avoid duplicates - for(TopExp_Explorer aContExp(aContext, TopAbs_FACE); aContExp.More(); aContExp.Next()) { - const TopoDS_Shape& aFace = aContExp.Current(); - if (aStoredFaces.Contains(aFace) || !(aSMap.Contains(aFace) || aNbs.Contains(aFace))) - continue; - aStoredFaces.Add(aFace); - std::string aFaceName = getShapeName(aDoc, aFace, theContext, theAnotherDoc, false); - if(aName.empty()) - aName = aFaceName; - else - aName += "&" + aFaceName; - } - } - break; - - case TopAbs_VERTEX: - // name structure (Monifold Topology): - // 1) F1 | F2 | F3 - intersection of 3 faces defines a vertex - trivial case. - // 2) F1 | F2 | F3 [|F4 [|Fn]] - redundant definition, - // but it should be kept as is to obtain safe recomputation - // 2) F1 | F2 - intersection of 2 faces definses a vertex - applicable for case - // when 1 faces is cylindrical, conical, spherical or revolution and etc. - // 3) E1 | E2 | E3 - intersection of 3 edges defines a vertex - when we have case of a shell - // or compound of 2 open faces. - // 4) E1 | E2 - intesection of 2 edges defines a vertex - when we have a case of - // two independent edges (wire or compound) - // implemented 2 first cases - { - TopTools_IndexedDataMapOfShapeListOfShape aMap; - TopExp::MapShapesAndAncestors(aContext, TopAbs_VERTEX, TopAbs_FACE, aMap); - TopTools_ListOfShape aList; - TopTools_MapOfShape aFMap; - // simetimes when group is moved in history, naming may be badly updated, so - // avoid crash in FindFromKey (issue 1842) - if (aMap.Contains(aSubShape)) { - const TopTools_ListOfShape& aList2 = aMap.FindFromKey(aSubShape); - // fix is below - TopTools_ListIteratorOfListOfShape itl2(aList2); - for (int i = 1;itl2.More();itl2.Next(),i++) { - if(aFMap.Add(itl2.Value())) - aList.Append(itl2.Value()); - } - } else - break; - int n = aList.Extent(); - bool isByFaces = n >= 3; - if (isByFaces) { // check that by faces vertex is identified uniquly (2317) - TopoDS_Shape aVertex = findCommonShape(TopAbs_VERTEX, aList); - isByFaces = !aVertex.IsNull() && aVertex.ShapeType() == TopAbs_VERTEX; - } - - if(!isByFaces) { // open topology case or Compound case => via edges - aName = vertexNameByEdges(aContext, aSubShape, aDoc, theContext, theAnotherDoc); - isByFaces = aName.empty(); - if (isByFaces) { // try to find a vertex in sketch faces - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(theContext); - if (aConstr.get() && aConstr->facesNum()) { - for(int aFace = aConstr->facesNum() - 1; isByFaces && aFace >= 0; aFace--) { - std::shared_ptr aGFace = aConstr->face(aFace); - aName = vertexNameByEdges(aGFace->impl(), aSubShape, - aDoc, theContext, theAnotherDoc); - isByFaces = aName.empty(); - } - } - } - } - - if (isByFaces) { - TopTools_ListIteratorOfListOfShape itl(aList); - for (int i = 1;itl.More();itl.Next(),i++) { - const TopoDS_Shape& aFace = itl.Value(); - std::string aFaceName = getShapeName(aDoc, aFace, theContext, theAnotherDoc, false); - if(i == 1) - aName = aFaceName; - else - aName += "&" + aFaceName; - } - } - } - break; - } - } - return aName; -} - -TopAbs_ShapeEnum translateType (const std::string& theType) -{ - // map from the textual shape types to OCCT enumeration - static std::map aShapeTypes; - - if(aShapeTypes.size() == 0) { - aShapeTypes["compound"] = TopAbs_COMPOUND; - aShapeTypes["compounds"] = TopAbs_COMPOUND; - aShapeTypes["compsolid"] = TopAbs_COMPSOLID; - aShapeTypes["compsolids"] = TopAbs_COMPSOLID; - aShapeTypes["solid"] = TopAbs_SOLID; - aShapeTypes["solids"] = TopAbs_SOLID; - aShapeTypes["shell"] = TopAbs_SHELL; - aShapeTypes["shells"] = TopAbs_SHELL; - aShapeTypes["face"] = TopAbs_FACE; - aShapeTypes["faces"] = TopAbs_FACE; - aShapeTypes["wire"] = TopAbs_WIRE; - aShapeTypes["wires"] = TopAbs_WIRE; - aShapeTypes["edge"] = TopAbs_EDGE; - aShapeTypes["edges"] = TopAbs_EDGE; - aShapeTypes["vertex"] = TopAbs_VERTEX; - aShapeTypes["vertices"] = TopAbs_VERTEX; - aShapeTypes["COMPOUND"] = TopAbs_COMPOUND; - aShapeTypes["COMPOUNDS"] = TopAbs_COMPOUND; - aShapeTypes["COMPSOLID"] = TopAbs_COMPSOLID; - aShapeTypes["COMPSOLIDS"] = TopAbs_COMPSOLID; - aShapeTypes["SOLID"] = TopAbs_SOLID; - aShapeTypes["SOLIDS"] = TopAbs_SOLID; - aShapeTypes["SHELL"] = TopAbs_SHELL; - aShapeTypes["SHELLS"] = TopAbs_SHELL; - aShapeTypes["FACE"] = TopAbs_FACE; - aShapeTypes["FACES"] = TopAbs_FACE; - aShapeTypes["WIRE"] = TopAbs_WIRE; - aShapeTypes["WIRES"] = TopAbs_WIRE; - aShapeTypes["EDGE"] = TopAbs_EDGE; - aShapeTypes["EDGES"] = TopAbs_EDGE; - aShapeTypes["VERTEX"] = TopAbs_VERTEX; - aShapeTypes["VERTICES"] = TopAbs_VERTEX; - } - if (aShapeTypes.find(theType) != aShapeTypes.end()) - return aShapeTypes[theType]; - Events_InfoMessage("Model_SelectionNaming", - "Shape type defined in XML is not implemented!").send(); - return TopAbs_SHAPE; -} - -const TopoDS_Shape getShapeFromNS( - const std::string& theSubShapeName, Handle(TNaming_NamedShape) theNS) -{ - TopoDS_Shape aSelection; - std::string::size_type n = theSubShapeName.rfind('/'); - if (n == std::string::npos) n = -1; - std::string aSubString = theSubShapeName.substr(n + 1); - n = aSubString.rfind('_'); - int indx = 1; - if (n != std::string::npos) {// for primitives this is a first - // if we have here the same name as theSubShapeName, there is no index in compound, it is whole - Handle(TDataStd_Name) aName; - if (!theNS->Label().FindAttribute(TDataStd_Name::GetID(), aName) || - aName->Get() != aSubString.c_str()) { - aSubString = aSubString.substr(n+1); - indx = atoi(aSubString.c_str()); - } - } - - TNaming_Iterator anItL(theNS); - for(int i = 1; anItL.More(); anItL.Next(), i++) { - if (i == indx) { - return anItL.NewShape(); - } - } - return aSelection; -} - -const TopoDS_Shape findFaceByName( - const std::string& theSubShapeName, std::shared_ptr theDoc, - const ResultPtr theDetectedContext, bool theContextIsUnique) -{ - TopoDS_Shape aFace; - std::string aSubString = theSubShapeName; - - static const ResultPtr anEmpty; - TDF_Label aLabel = theDoc->findNamingName(aSubString, - theContextIsUnique ? theDetectedContext : anEmpty); - if (aLabel.IsNull()) { // try to remove additional artificial suffix - std::string::size_type n = aSubString.rfind('_'); - if (n != std::string::npos) { - aSubString = aSubString.substr(0, n); - aLabel = theDoc->findNamingName(aSubString, - theContextIsUnique ? theDetectedContext : anEmpty); - } - } - if(aLabel.IsNull()) return aFace; - Handle(TNaming_NamedShape) aNS; - if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - aFace = getShapeFromNS(theSubShapeName, aNS); - } - return aFace; -} - -size_t ParseName(const std::string& theSubShapeName, std::list& theList) -{ - std::string aName = theSubShapeName; - std::string aLastName = aName; - size_t n1(0), n2(0); // n1 - start position, n2 - position of the delimiter - while ((n2 = aName.find('&', n1)) != std::string::npos) { - const std::string aName1 = aName.substr(n1, n2 - n1); //name of face - theList.push_back(aName1); - n1 = n2 + 1; - aLastName = aName.substr(n1); - } - if(!aLastName.empty()) - theList.push_back(aLastName); - return theList.size(); -} - -std::string getContextName(const std::string& theSubShapeName) -{ - std::string aName; - std::string::size_type n = theSubShapeName.find('/'); - if (n == std::string::npos) return theSubShapeName; - aName = theSubShapeName.substr(0, n); - return aName; -} - -/// Parses naming name of sketch sub-elements: takes indices and orientation -/// (if theOriented = true) from this name. Map theIDs constains indices -> -/// orientations and start/end vertices: negative is reversed, 2 - start, 3 - end -bool parseSubIndices(CompositeFeaturePtr theComp, //< to iterate names - const std::string& theName, const char* theShapeType, - std::map& theIDs, const bool theOriented = false) -{ - // collect all IDs in the name - std::map aNames; // short name of sub -> ID of sub of theComp - const int aSubNum = theComp->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - FeaturePtr aSub = theComp->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes = aResults.cbegin(); - // there may be many shapes (circle and center) - for(; aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (aConstr.get()) { - aNames[Model_SelectionNaming::shortName(aConstr)] = theComp->subFeatureId(a); - } - } - } - - size_t aPrevPos = theName.find("/") + 1, aLastNamePos; - bool isShape = false; // anyway the first world must be 'Vertex' - do { - aLastNamePos = theName.find('-', aPrevPos); - std::string anID = theName.substr(aPrevPos, aLastNamePos - aPrevPos); - if (!isShape) { - if (anID != theShapeType) - return false; - isShape = true; - } else { - int anOrientation = 1; // default - if (theOriented) { // here must be a symbol in the end of digit 'f' or 'r' - std::string::iterator aSymbol = anID.end() - 1; - if (*aSymbol == 'r') anOrientation = -1; - anID.erase(aSymbol); // remove last symbol - } - // check start/end symbols - std::string::iterator aBack = anID.end() - 1; - if (*aBack == 's') { - anOrientation *= 2; - anID.erase(aBack); // remove last symbol - } else if (*aBack == 'e') { - anOrientation *= 3; - anID.erase(aBack); // remove last symbol - } - - if (aNames.find(anID) != aNames.end()) { - theIDs[aNames[anID]] = anOrientation; - } - } - aPrevPos = aLastNamePos + 1; - } while (aLastNamePos != std::string::npos); - return true; -} - -/// produces theEdge orientation relatively to theContext face -int Model_SelectionNaming::edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge) -{ - if (theContext.ShapeType() != TopAbs_FACE && theContext.ShapeType() != TopAbs_WIRE) - return 0; - if (theEdge.Orientation() == TopAbs_FORWARD) - return 1; - if (theEdge.Orientation() == TopAbs_REVERSED) - return -1; - return 0; // unknown -} - -int Model_CurvesHasher::HashCode(const Handle(Geom_Curve)& theCurve, const Standard_Integer Upper) -{ - double aFirstParam = theCurve->FirstParameter(); - if (aFirstParam < -1.e+100 || aFirstParam > 1.e+100) - aFirstParam = 0; - double aLastParam = theCurve->LastParameter(); - if (aLastParam < -1.e+100 || aLastParam > 1.e+100) - aLastParam = 2; - else aLastParam = (aLastParam + aFirstParam) / 2.; // to avoid in periodic same first and last - - gp_XYZ aCoordSum = theCurve->Value(aFirstParam).XYZ() + theCurve->Value(aLastParam).XYZ(); - return ::HashCode(aCoordSum.X() + aCoordSum.Y() / 123. + aCoordSum.Z() / 123456., Upper); -} -bool Model_CurvesHasher::IsEqual(const Handle(Geom_Curve)& theC1, const Handle(Geom_Curve)& theC2) -{ - if (theC1->DynamicType() != theC2->DynamicType()) - return false; - double aFirstParam1 = theC1->FirstParameter(); - if (aFirstParam1 < -1.e+100 || aFirstParam1 > 1.e+100) - aFirstParam1 = 0; - double aFirstParam2 = theC2->FirstParameter(); - if (aFirstParam2 < -1.e+100 || aFirstParam2 > 1.e+100) - aFirstParam2 = 0; - if (fabs(aFirstParam1 - aFirstParam2) > 1.e-9) - return false; - - double aLastParam1 = theC1->LastParameter(); - if (aLastParam1 < -1.e+100 || aLastParam1 > 1.e+100) - aLastParam1 = 2.; - else aLastParam1 = (aLastParam1 + aFirstParam1) / 2.; // to avoid in periodic same first and last - double aLastParam2 = theC2->LastParameter(); - if (aLastParam2 < -1.e+100 || aLastParam2 > 1.e+100) - aLastParam2 = 2.; - else aLastParam2 = (aLastParam2 + aFirstParam2) / 2.; // to avoid in periodic same first and last - - if (fabs(aLastParam1 - aLastParam2) > 1.e-9) - return false; - - return theC1->Value(aFirstParam1).IsEqual(theC2->Value(aFirstParam2), Precision::Confusion()) && - theC1->Value(aLastParam1).IsEqual(theC2->Value(aLastParam2), Precision::Confusion()); -} - -int Model_EdgesHasher::HashCode(const TopoDS_Edge& theEdge, const Standard_Integer Upper) -{ - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast); - return Model_CurvesHasher::HashCode(aCurve, Upper); -} - -bool Model_EdgesHasher::IsEqual(const TopoDS_Edge& theE1, const TopoDS_Edge& theE2) -{ - GeomEdgePtr aSh1(new GeomAPI_Edge); - aSh1->setImpl(new TopoDS_Shape(theE1)); - GeomEdgePtr aSh2(new GeomAPI_Edge); - aSh2->setImpl(new TopoDS_Shape(theE2)); - return aSh1->isEqual(aSh2); -} - -std::shared_ptr Model_SelectionNaming::findAppropriateFace( - std::shared_ptr& theConstr, - NCollection_DataMap& theCurves, const bool theIsWire) -{ - int aBestFound = 0; // best number of found edges (not percentage: issue 1019) - int aBestNotFound = 1000000; // best number of not found edges (must be minimum) - int aBestOrient = 0; // for the equal "BestFound" additional parameter is orientation - std::shared_ptr aResult; - ResultConstructionPtr aConstructionContext = - std::dynamic_pointer_cast(theConstr); - if (!aConstructionContext.get()) - return aResult; - for(int aFaceIndex = 0; aFaceIndex < aConstructionContext->facesNum(); aFaceIndex++) { - int aFound = 0, aNotFound = 0, aSameOrientation = 0; - TopoDS_Face aFace = - TopoDS::Face(aConstructionContext->face(aFaceIndex)->impl()); - std::list aFacesWires; // faces or wires to iterate - if (theIsWire) { - for(TopExp_Explorer aWires(aFace, TopAbs_WIRE); aWires.More(); aWires.Next()) { - aFacesWires.push_back(aWires.Current()); - } - } else { - aFacesWires.push_back(aFace); - } - std::list::iterator aFW = aFacesWires.begin(); - for(; aFW != aFacesWires.end(); aFW++) { - TopExp_Explorer anEdgesExp(*aFW, TopAbs_EDGE); - TColStd_MapOfTransient alreadyProcessed; // to avoid counting edges with same curves (841) - for(; anEdgesExp.More(); anEdgesExp.Next()) { - TopoDS_Edge anEdge = TopoDS::Edge(anEdgesExp.Current()); - if (!anEdge.IsNull()) { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - if (alreadyProcessed.Contains(aCurve)) - continue; - alreadyProcessed.Add(aCurve); - if (theCurves.IsBound(aCurve)) { - aFound++; - int anOrient = theCurves.Find(aCurve); - if (anOrient != 0) { // extra comparision score is orientation - if (edgeOrientation(aFace, anEdge) == anOrient) - aSameOrientation++; - } - } else { - aNotFound++; - } - } - } - if (theIsWire && aFound + aNotFound != 0) { - if (aBestNotFound > aNotFound || (aBestNotFound == aNotFound && aFound > aBestFound) || - (aBestNotFound == aNotFound && aFound == aBestFound && aSameOrientation > aBestOrient)) { - aBestFound = aFound; - aBestOrient = aSameOrientation; - aBestNotFound = aNotFound; - std::shared_ptr aWire(new GeomAPI_Wire); - aWire->setImpl(new TopoDS_Shape(*aFW)); - aResult = aWire; - } - aFound = 0; - aNotFound = 0; - aSameOrientation = 0; - } - } - if (!theIsWire) { - if (aFound + aNotFound != 0) { - if (aBestNotFound > aNotFound || (aBestNotFound == aNotFound && aFound > aBestFound) || - (aBestNotFound == aNotFound && aFound == aBestFound && aSameOrientation > aBestOrient)) { - aBestFound = aFound; - aBestOrient = aSameOrientation; - aBestNotFound = aNotFound; - aResult = aConstructionContext->face(aFaceIndex); - } - } - } - } - return aResult; -} - -std::string Model_SelectionNaming::shortName( - std::shared_ptr& theConstr, const int theEdgeVertexPos) -{ - std::string aName = theConstr->data()->name(); - // remove "-", "/" and "&" command-symbols - aName.erase(std::remove(aName.begin(), aName.end(), '-'), aName.end()); - aName.erase(std::remove(aName.begin(), aName.end(), '/'), aName.end()); - aName.erase(std::remove(aName.begin(), aName.end(), '&'), aName.end()); - // remove the last 's', 'e', 'f' and 'r' symbols: - // they are used as markers of start/end/forward/rewersed indicators - static const std::string aSyms("sefr"); - std::string::iterator aSuffix = aName.end() - 1; - while(aSyms.find(*aSuffix) != std::string::npos) { - --aSuffix; - } - aName.erase(aSuffix + 1, aName.end()); - - if (theEdgeVertexPos == 1) { - aName += "s"; // start - } else if (theEdgeVertexPos == 2) { - aName += "e"; // end - } - return aName; -} - -// type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT -bool Model_SelectionNaming::selectSubShape(const std::string& theType, - const std::string& theSubShapeName, std::shared_ptr theDoc, - std::shared_ptr& theShapeToBeSelected, std::shared_ptr& theCont) -{ - if(theSubShapeName.empty() || theType.empty()) return false; - TopAbs_ShapeEnum aType = translateType(theType); - - // check that it was selected in another document - size_t aSlash = theSubShapeName.find("/"); - std::string aSubShapeName = theSubShapeName; - std::shared_ptr aDoc = theDoc; - if (aSlash != std::string::npos) { - std::string aDocName = theSubShapeName.substr(0, aSlash); - ResultPartPtr aFoundPart; - DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); - if (aDocName == aRootDoc->kind()) { - aDoc = std::dynamic_pointer_cast(aRootDoc); - } else { - for (int a = aRootDoc->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { - ResultPartPtr aPart = std::dynamic_pointer_cast( - aRootDoc->object(ModelAPI_ResultPart::group(), a)); - if (aPart.get() && aPart->isActivated() && aPart->data()->name() == aDocName) { - aDoc = std::dynamic_pointer_cast(aPart->partDoc()); - aFoundPart = aPart; - break; - } - } - } - if (aDoc != theDoc) { - // so, the first word is the document name => reduce the string for the next manips - aSubShapeName = theSubShapeName.substr(aSlash + 1); - if (aSubShapeName.empty() && aFoundPart.get()) { // the whole Part result - theCont = aFoundPart; - return true; - } - } - } - - std::string aContName = getContextName(aSubShapeName); - if(aContName.empty()) return false; - bool anUniqueContext = false; - ResultPtr aCont = aDoc->findByName(aContName, aSubShapeName, anUniqueContext); - // possible this is body where postfix is added to distinguish several shapes on the same label - int aSubShapeId = -1; // -1 means sub shape not found - // for result body the name wihtout "_" has higher priority than with it: it is always added - if ((!aCont.get()/* || (aCont->groupName() == ModelAPI_ResultBody::group())*/) && - aContName == aSubShapeName) { - size_t aPostIndex = aContName.rfind('_'); - if (aPostIndex != std::string::npos) { - std::string anEmpty, aSubContName = aContName.substr(0, aPostIndex); - ResultPtr aSubCont = aDoc->findByName(aSubContName, anEmpty, anUniqueContext); - if (aSubCont.get()) { - try { - std::string aNum = aContName.substr(aPostIndex + 1); - aSubShapeId = std::stoi(aNum); - } catch (std::invalid_argument&) { - aSubShapeId = -1; - } - if (aSubShapeId > 0) { - aContName = aSubContName; - aCont = aSubCont; - } - } - } - } - - - static const ResultPtr anEmpty; - TopoDS_Shape aSelection; - switch (aType) - { - case TopAbs_FACE: - case TopAbs_WIRE: - { - aSelection = findFaceByName(aSubShapeName, aDoc, aCont, anUniqueContext); - } - break; - case TopAbs_EDGE: - { - const TDF_Label& aLabel = - aDoc->findNamingName(aSubShapeName, anUniqueContext ? aCont : anEmpty); - if(!aLabel.IsNull()) { - Handle(TNaming_NamedShape) aNS; - if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - aSelection = getShapeFromNS(aSubShapeName, aNS); - } - } - } - break; - case TopAbs_VERTEX: - { - const TDF_Label& aLabel = - aDoc->findNamingName(aSubShapeName, anUniqueContext ? aCont : anEmpty); - if(!aLabel.IsNull()) { - Handle(TNaming_NamedShape) aNS; - if(aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { - aSelection = getShapeFromNS(aSubShapeName, aNS); - } - } - } - break; - case TopAbs_COMPOUND: - case TopAbs_COMPSOLID: - case TopAbs_SOLID: - case TopAbs_SHELL: - default: {//TopAbs_SHAPE - /// case when the whole sketch is selected, so, - /// selection type is compound, but there is no value - if (aCont.get() && aCont->shape().get()) { - if (aCont->shape()->impl().ShapeType() == aType) { - theCont = aCont; - return true; - } else if (aSubShapeId > 0) { // try to find sub-shape by the index - TopExp_Explorer anExp(aCont->shape()->impl(), aType); - for(; aSubShapeId > 1 && anExp.More(); aSubShapeId--) { - anExp.Next(); - } - if (anExp.More()) { - std::shared_ptr aShapeToBeSelected(new GeomAPI_Shape()); - aShapeToBeSelected->setImpl(new TopoDS_Shape(anExp.Current())); - theShapeToBeSelected = aShapeToBeSelected; - theCont = aCont; - return true; - } - } - } - return false; - } - } - if (!aSelection.IsNull() && - aSelection.ShapeType() != aType && aSelection.ShapeType() != TopAbs_COMPOUND) - aSelection.Nullify(); // to avoid selection of face instead of edge that is described by face - // another try to find edge or vertex by faces - std::list aListofNames; - size_t aN = aSelection.IsNull() ? ParseName(aSubShapeName, aListofNames) : 0; - if ((aSelection.IsNull() && (aType == TopAbs_EDGE || aType == TopAbs_VERTEX)) || - (!aSelection.IsNull() && aSelection.ShapeType() != aType)) { // edge by one face as example - if(aN >= 1) { - TopTools_ListOfShape aList; - std::list::iterator it = aListofNames.begin(); - for(; it != aListofNames.end(); it++) { - ResultPtr aFaceContext = aCont; - if (it != aListofNames.begin()) { // there may be other context for different sub-faces - std::string aContName = getContextName(*it); - if(!aContName.empty()) { - aFaceContext = aDoc->findByName(aContName, *it, anUniqueContext); - } - } - TopoDS_Shape aFace = findFaceByName(*it, aDoc, aFaceContext, anUniqueContext); - if (aFace.IsNull() && aFaceContext.get() && - aFaceContext->groupName() == ModelAPI_ResultConstruction::group() ) { - // search the construction sub-elements for the intersection if they are in the tree - size_t aSlash = it->find("/"); - if (aSlash != std::string::npos) { - std::string aSubShapeName = it->substr(aSlash + 1); - aFace = findFaceByName(aSubShapeName, aDoc, aFaceContext, true); - } - } - if(!aFace.IsNull()) - aList.Append(aFace); - } - aSelection = findCommonShape(aType, aList); - //if (aSelection.IsNull() && aType == TopAbs_EDGE) { // try to find selection by neighbours - // aSelection = findCommonShapeByNB(aType, TopAbs_VERTEX, aList); - //} - } - } - // in case of construction, there is no registered names for all sub-elements, - // even for the main element; so, trying to find them by name (without "&" intersections) - if (aSelection.IsNull() && aN < 2) { - size_t aConstrNamePos = aSubShapeName.find("/"); - bool isFullName = aConstrNamePos == std::string::npos; - std::string anEmpty, aContrName = aContName; - ResultPtr aConstr = aDoc->findByName(aContrName, anEmpty, anUniqueContext); - if (aConstr.get() && aConstr->groupName() == ModelAPI_ResultConstruction::group()) { - theCont = aConstr; - if (isFullName) { - // For the full construction selection shape must be empty. - //theShapeToBeSelected = aConstr->shape(); - return true; - } - // for sketch sub-elements selected - CompositeFeaturePtr aComposite = - std::dynamic_pointer_cast(aDoc->feature(aConstr)); - if (aComposite.get()) { - if (aType == TopAbs_VERTEX || aType == TopAbs_EDGE) { - // collect all IDs in the name - bool isVertexByEdge = false; - std::map anIDs; - if (!parseSubIndices(aComposite, aSubShapeName, - aType == TopAbs_EDGE ? "Edge" : "Vertex", anIDs)) { - // there is a case when vertex is identified by one circle-edge (2253) - if (aType == TopAbs_VERTEX && - parseSubIndices(aComposite, aSubShapeName, "Edge", anIDs)) - isVertexByEdge = true; - else - return false; - } - - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - int aCompID = aComposite->subFeatureId(a); - if (anIDs.find(aCompID) != anIDs.end()) { // found the vertex/edge shape - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRIt = aResults.cbegin(); - // there may be many shapes (circle and center) - for(; aRIt != aResults.cend(); aRIt++) { - ResultConstructionPtr aRes = - std::dynamic_pointer_cast(*aRIt); - if (aRes) { - int anOrientation = abs(anIDs[aCompID]); - TopoDS_Shape aShape = aRes->shape()->impl(); - if (anOrientation == 1) { - if (!isVertexByEdge && aType == aShape.ShapeType()) { - theShapeToBeSelected = aRes->shape(); - return true; - } else if (isVertexByEdge && aType != aShape.ShapeType()) { - // check that there is only one vertex produces by and circular edge - TopoDS_Shape aShape = aRes->shape()->impl(); - TopExp_Explorer anExp(aShape, TopAbs_VERTEX); - if (anExp.More()) - aShape = anExp.Current(); - anExp.Next(); - if (!anExp.More() || anExp.Current().IsSame(aShape)) { - std::shared_ptr aShapeToBeSelected(new GeomAPI_Shape()); - aShapeToBeSelected->setImpl(new TopoDS_Shape(aShape)); - theShapeToBeSelected = aShapeToBeSelected; - return true; - } - } - } else { // take first or second vertex of the edge - TopoDS_Shape aShape = aRes->shape()->impl(); - if (aShape.ShapeType() == TopAbs_VERTEX) continue; - TopExp_Explorer anExp(aShape, aType); - for(; anExp.More() && anOrientation != 2; anOrientation--) - anExp.Next(); - if (anExp.More()) { - std::shared_ptr aShapeToBeSelected(new GeomAPI_Shape()); - aShapeToBeSelected->setImpl(new TopoDS_Shape(anExp.Current())); - theShapeToBeSelected = aShapeToBeSelected; - return true; - } - } - } - } - } - } - // sketch faces is identified by format "Sketch_1/Face-2f-8f-11r" - } else if (aType == TopAbs_FACE || aType == TopAbs_WIRE) { - std::map anIDs; - if (!parseSubIndices(aComposite, aSubShapeName, - aType == TopAbs_FACE ? "Face" : "Wire", anIDs, true)) - return false; - - // curves and orientations of edges - NCollection_DataMap allCurves; - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - int aSubID = aComposite->subFeatureId(a); - if (anIDs.find(aSubID) != anIDs.end()) { - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes; - for(aRes = aResults.cbegin(); aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (aConstr->shape() && aConstr->shape()->isEdge()) { - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (!anEdge.IsNull()) { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - allCurves.Bind(aCurve, anIDs[aSubID] > 0 ? 1 : -1); - } - } - } - } - } - std::shared_ptr aFoundFW = - findAppropriateFace(aConstr, allCurves, aType == TopAbs_WIRE); - if (aFoundFW.get()) { - theShapeToBeSelected = aFoundFW; - return true; - } - } else if (aType == TopAbs_WIRE) { - // sketch faces is identified by format "Sketch_1/Face-2f-8f-11r" - std::map anIDs; - if (!parseSubIndices(aComposite, aSubShapeName, "Wire", anIDs)) - return false; - - // curves and orientations of edges - NCollection_DataMap allCurves; - const int aSubNum = aComposite->numberOfSubs(); - for(int a = 0; a < aSubNum; a++) { - int aSubID = aComposite->subFeatureId(a); - if (anIDs.find(aSubID) != anIDs.end()) { - FeaturePtr aSub = aComposite->subFeature(a); - const std::list >& aResults = aSub->results(); - std::list >::const_iterator aRes; - for(aRes = aResults.cbegin(); aRes != aResults.cend(); aRes++) { - ResultConstructionPtr aConstr = - std::dynamic_pointer_cast(*aRes); - if (aConstr->shape() && aConstr->shape()->isEdge()) { - const TopoDS_Shape& aResShape = aConstr->shape()->impl(); - TopoDS_Edge anEdge = TopoDS::Edge(aResShape); - if (!anEdge.IsNull()) { - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast); - allCurves.Bind(aCurve, anIDs[aSubID] > 0 ? 1 : -1); - } - } - } - } - } - std::shared_ptr aFoundFW = - findAppropriateFace(aConstr, allCurves, aType == TopAbs_WIRE); - if (aFoundFW.get()) { - theShapeToBeSelected = aFoundFW; - return true; - } - } - } - } - } else if (aSelection.IsNull() && aN >= 2 && aType == TopAbs_VERTEX) { - // support of shape name as intersection separated by "&" - static std::string anEdgeType = "edge"; // for now it works only with su-edges - std::list::iterator aSubNames = aListofNames.begin(); - TopTools_ListOfShape aSubsList; - for(; aSubNames != aListofNames.end(); aSubNames++) { - std::string aSubName = *aSubNames; - std::shared_ptr aSubShapeFound; - std::shared_ptr aContextFound; - if (selectSubShape(anEdgeType, aSubName, theDoc, aSubShapeFound, aContextFound)) { - if (aSubShapeFound.get()) - aSubsList.Append(aSubShapeFound->impl()); - } - } - aSelection = findCommonShape(TopAbs_VERTEX, aSubsList); - } - if (!aSelection.IsNull()) { - // Select it (must be after N=0 checking, - // since for simple constructions the shape must be null) - std::shared_ptr aShapeToBeSelected(new GeomAPI_Shape()); - aShapeToBeSelected->setImpl(new TopoDS_Shape(aSelection)); - theShapeToBeSelected = aShapeToBeSelected; - theCont = aCont; - return true; - } - - return false; -} diff --git a/src/Model/Model_SelectionNaming.h b/src/Model/Model_SelectionNaming.h deleted file mode 100644 index 3494369df..000000000 --- a/src/Model/Model_SelectionNaming.h +++ /dev/null @@ -1,115 +0,0 @@ -// 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 -// - -#ifndef Model_SelectionNaming_H_ -#define Model_SelectionNaming_H_ - -#include -#include -#include -#include -#include -#include -#include -#include - -// class to compare curves in the same way as in GeomAPI_Edge -class Model_CurvesHasher -{ -public: - DEFINE_STANDARD_ALLOC - /// standard hash code - static int HashCode (const Handle(Geom_Curve)& theCurve, const Standard_Integer Upper); - /// comapre curves by parameters and points on them - static bool IsEqual (const Handle(Geom_Curve)& theC1, const Handle(Geom_Curve)& theC2); -}; - -// class to compare edges in the same way as in GeomAPI_Edge -class Model_EdgesHasher -{ -public: - DEFINE_STANDARD_ALLOC - /// standard hash code - static int HashCode (const TopoDS_Edge& theEdge, const Standard_Integer Upper); - /// comapre curves by parameters and points on them - static bool IsEqual (const TopoDS_Edge& theE1, const TopoDS_Edge& theE2); -}; - - -/**\class Model_SelectionNaming - * \ingroup DataModel - * \brief The set of methods that allow to generate a string-name for the selection attribute. - */ -class Model_SelectionNaming -{ - TDF_Label myLab; ///< Selection label of the selection attribute -public: - /// Constructor for the selection attribute by the selection label - Model_SelectionNaming(TDF_Label theSelectionLab); - - /// Produces the string-name for the selected shape - std::string namingName(ResultPtr& theContext, std::shared_ptr theSubSh, - const std::string& theDefaultName, const bool theAnotherDoc); - - /// Makes a selection by the string-name - /// \param theType string of the type of the shape - /// \param theSubShapeName string-identifier of the selected shape - /// \param theDoc document where the selected shape is searched - /// \param theShapeToBeSelected resulting selected shape - /// \param theCont the selection context of the resulting selected shape - bool selectSubShape(const std::string& theType, const std::string& theSubShapeName, - std::shared_ptr theDoc, std::shared_ptr& theShapeToBeSelected, - std::shared_ptr& theCont); - - /// Searches the face more appropriate to the given curves - /// (with higher level of matched parameters) - /// \param theConstr construction result that contains one or several faces - /// \param theCurves map from the face edges curves to orientation - /// (-1 reversed, 0 unknown, 1 forward) - /// \param theIsWire for wire algorithm isquite the same, - /// but if in face several wires, it returns the needed wire - /// \returns faces fron this construction if found - static std::shared_ptr findAppropriateFace( - std::shared_ptr& theConstr, - NCollection_DataMap& theCurves, - const bool theIsWire); - - /// Returns orientation of the edge in the context shape - static int edgeOrientation(const TopoDS_Shape& theContext, TopoDS_Edge& theEdge); - - /// Returns the name of sketch sub-element, shortened by exclusion of some symbols and with added - /// the vertex position (if needed) - /// \param theConstr result with name - basis for the name - /// \param theEdgeVertexPos position of the vertex on edge: 1 - first , 2 - second - /// \returns the generated name - static std::string shortName(std::shared_ptr& theConstr, - const int theEdgeVertexPos = 0); - -protected: - /// Gets the stored name from the document - std::string getShapeName(std::shared_ptr theDoc, const TopoDS_Shape& theShape, - ResultPtr& theContext, const bool theAnotherDoc, const bool theWholeContext); - - /// Tries to find the name of the context sub-shape as combination of edges in context - std::string vertexNameByEdges(TopoDS_Shape theContext, TopoDS_Shape theSub, - std::shared_ptr theDoc, ResultPtr& theContextRes, const bool theAnotherDoc); -}; - -#endif diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index a22db3780..3d3724794 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -55,7 +55,7 @@ static Model_Session* myImpl = new Model_Session(); -// t oredirect all calls to the root document +// to redirect all calls to the root document #define ROOT_DOC std::dynamic_pointer_cast(moduleDocument()) bool Model_Session::load(const char* theFileName) @@ -114,7 +114,7 @@ void Model_Session::abortOperation() myOperationAttachedToNext = false; } setCheckTransactions(true); - // here the update mechanism may work after abort, so, supress the warnings about + // here the update mechanism may work after abort, so, suppress the warnings about // modifications outside of the transactions bool aWasCheck = myCheckTransactions; myCheckTransactions = false; @@ -294,7 +294,7 @@ void Model_Session::setActiveDocument( std::shared_ptr aPrevious = myCurrentDoc; myCurrentDoc = theDoc; if (theDoc.get() && theSendSignal) { - // this must be before the synchronisation call because features in PartSet lower than this + // this must be before the synchronization call because features in PartSet lower than this // part feature must be disabled and don't recomputed anymore (issue 1156, // translation feature is failed on activation of Part 2) if (isOperation()) { // do it only in transaction, not on opening of document @@ -306,7 +306,7 @@ void Model_Session::setActiveDocument( } } } - // syncronize the document: it may be just opened or opened but removed before + // synchronize the document: it may be just opened or opened but removed before std::shared_ptr aDoc = std::dynamic_pointer_cast(theDoc); if (aDoc.get()) { bool aWasChecked = myCheckTransactions; @@ -320,7 +320,7 @@ void Model_Session::setActiveDocument( new Events_Message(Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED))); Events_Loop::loop()->send(aMsg); } - // make the current state correct and synchronised in the module and sub-documents + // make the current state correct and synchronized in the module and sub-documents if (isOperation()) { // do it only in transaction, not on opening of document if (myCurrentDoc == moduleDocument()) { // make the current feature the latest in root, in previous root current become also last @@ -475,6 +475,10 @@ void Model_Session::processEvent(const std::shared_ptr& theMessa if (!aCases.empty()) { validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(), aCases); } + if (aMsgAttr->isGeometricalSelection()) { + validators()->registerGeometricalSelection(aMsgAttr->featureId(), + aMsgAttr->attributeId()); + } } } // plugins information was started to load, so, it will be loaded @@ -615,7 +619,7 @@ void Model_Session::blockAutoUpdate(const bool theBlock) } if (!isOperation) { finishOperation(); - // append this transaction to the previous one: ne don't need this separated operation in list + // append this transaction to the previous one: don't need this separated operation in list ROOT_DOC->appendTransactionToPrevious(); } } diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 60b2c7206..5e2ccff5f 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -76,10 +77,6 @@ Model_Update::Model_Update() aLoop->registerListener(this, kReorderEvent); static const Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION); aLoop->registerListener(this, kUpdatedSel); - static const Events_ID kAutomaticOff = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE); - aLoop->registerListener(this, kAutomaticOff); - static const Events_ID kAutomaticOn = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE); - aLoop->registerListener(this, kAutomaticOn); // Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true"; myIsParamUpdated = false; @@ -198,7 +195,7 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { } } } - // proccess also results + // process also results std::list allResults; // list of this feature and results ModelAPI_Tools::allResults(theFeature, allResults); std::list::iterator aRes = allResults.begin(); @@ -240,8 +237,6 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag static const Events_ID kReorderEvent = aLoop->eventByName(EVENT_ORDER_UPDATED); static const Events_ID kRedisplayEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); static const Events_ID kUpdatedSel = aLoop->eventByName(EVENT_UPDATE_SELECTION); - static const Events_ID kAutomaticOff = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE); - static const Events_ID kAutomaticOn = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE); #ifdef DEB_UPDATE std::cout<<"****** Event "<eventID().eventText()<& theMessag if (!myUpdateBlocked) { // process all modified features, even if preview is blocked bool aPreviewBlockedState = myIsPreviewBlocked; // to update the selected arguments myIsPreviewBlocked = false; - // iterate everything and add efatures in state "MustBeUpdated" into modified + // iterate everything and add features in state "MustBeUpdated" into modified std::list > allDocs = ModelAPI_Session::get()->allOpenedDocuments(); std::list >::iterator aDoc = allDocs.begin(); @@ -331,7 +326,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) { myIsParamUpdated = true; } - // on undo/redo, abort do not update persisten features + // on undo/redo, abort do not update persistent features FeaturePtr anUpdated = std::dynamic_pointer_cast(*anObjIter); if (anUpdated.get()) { if (addModified(anUpdated, FeaturePtr())) @@ -395,7 +390,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag } myIsFinish = false; } - // processed features must be only on finish, so clear anyway (to avoid reimport on load) + // processed features must be only on finish, so clear anyway (to avoid re-import on load) myProcessOnFinish.clear(); // #2156: current must be sketch, left after the macro execution @@ -409,7 +404,8 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag } if (anActiveDoc.get() && aCurrent.get() && aCurrent->data()->isValid()) { - if (anActiveDoc->currentFeature(false) != aCurrent) + if (anActiveDoc->currentFeature(false) != aCurrent && + ModelAPI_Tools::compositeOwner(anActiveDoc->currentFeature(false)) == aCurrent) anActiveDoc->setCurrentFeature(aCurrent, false); // #2156 make the current feature back } @@ -483,7 +479,7 @@ void Model_Update::processFeatures(const bool theFlushRedisplay) } } -// collects all the feautres this feature depends on: reasons +// collects all the features this feature depends on: reasons static void allReasons(FeaturePtr theFeature, std::set& theReasons) { std::list > > > aDeps; theFeature->data()->referencesToObjects(aDeps); @@ -690,7 +686,7 @@ bool Model_Update::processFeature(FeaturePtr theFeature) theFeature->data()->execState(ModelAPI_StateDone); // this checking must be after the composite feature sub-elements processing: - // composite feature status may depend on it's subelements + // composite feature status may depend on it's sub-elements if ((theFeature->data()->execState() == ModelAPI_StateInvalidArgument || isReferencedInvalid) && theFeature->getKind() != "Part") { // don't disable Part because it will make disabled all the features @@ -713,7 +709,8 @@ bool Model_Update::processFeature(FeaturePtr theFeature) aDoExecute = true; } else if (theFeature->results().size()) { // execute only not-results features aDoExecute = !(theFeature->firstResult()->groupName() == ModelAPI_ResultBody::group() || - theFeature->firstResult()->groupName() == ModelAPI_ResultPart::group()); + theFeature->firstResult()->groupName() == ModelAPI_ResultPart::group() || + theFeature->getKind() == "Sketch"); } else { aDoExecute = aState != ModelAPI_StateInvalidArgument; } diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index 41fa0f701..5bf41b289 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -377,3 +377,27 @@ bool Model_ValidatorsFactory::isMainArgument(std::string theFeature, std::string std::map::iterator aFound = myMainArgument.find(theFeature); return aFound != myMainArgument.end() && aFound->second == theAttribute; } + +void Model_ValidatorsFactory::registerGeometricalSelection(std::string theFeature, + std::string theAttribute) +{ + std::map >::iterator aFind = + myGeometricalSelection.find(theFeature); + if (aFind == myGeometricalSelection.end()) { + std::set aNewSet; + aNewSet.insert(theAttribute); + myGeometricalSelection[theFeature] = aNewSet; + } + else { + aFind->second.insert(theAttribute); + } +} + +bool Model_ValidatorsFactory::isGeometricalSelection(std::string theFeature, + std::string theAttribute) +{ + std::map >::iterator aFind = + myGeometricalSelection.find(theFeature); + return aFind != myGeometricalSelection.end() + && aFind->second.find(theAttribute) != aFind->second.end(); +} diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index 939cdf213..7dcf2ff98 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -58,6 +58,7 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory std::map > > > myCases; /// Stores main attribute for each feature std::map myMainArgument; + std::map > myGeometricalSelection; public: /// Registers the instance of the validator by the ID @@ -123,6 +124,12 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory /// Returns true is the attribute is a main argument of the feature virtual bool isMainArgument(std::string theFeature, std::string theAttribute); + /// Register the selection attribute as geometrical selection + virtual void registerGeometricalSelection(std::string theFeature, std::string theAttribute); + + /// Returns true if the attribute is a geometrical selection + virtual bool isGeometricalSelection(std::string theFeature, std::string theAttribute); + protected: /// Adds the defualt validators that are usefull for all features. diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 14148d046..22b949c54 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -166,6 +166,7 @@ ADD_UNIT_TESTS(TestConstants.py TestResults.py TestIntArray.py Test1512.py + Test1562.py TestDoubleArray.py Test1757.py Test1998.py @@ -210,6 +211,7 @@ ADD_UNIT_TESTS(TestConstants.py Test2607.py TestBlockRecalculation.py TestSelectionScope.py + TestSelectorShell.py TestWeakNaming2125.py TestWeakNaming2222.py TestWeakNaming2245.py @@ -223,4 +225,12 @@ ADD_UNIT_TESTS(TestConstants.py TestWeakNaming2445.py TestWeakNaming2446.py TestWeakNaming2452.py + Test2685.py + TestGeomNamingPlacement.py + TestGeomNamingRevolution.py + TestGeomNamingEdgeByFilter.py + TestGeomNamingSketchPlane.py + TestGeomNamingBoxWithFillet.py + TestContainerSelector.py + TestSaveOpen.py ) diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index e5113a5c2..db3acb539 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -207,3 +207,6 @@ template std::shared_ptr shared_ptr_cast(std::shared_ptr // Geometry casts %template(shapeToEdge) shared_ptr_cast; + +template std::shared_ptr shared_ptr_cast(std::shared_ptr theObject); +%template(featureToPresentation) shared_ptr_cast; diff --git a/src/ModelAPI/ModelAPI_AttributeRefList.h b/src/ModelAPI/ModelAPI_AttributeRefList.h index 78d8ba769..27b2427b9 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefList.h +++ b/src/ModelAPI/ModelAPI_AttributeRefList.h @@ -64,7 +64,7 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute /// Returns the referenced object by the zero-based index ///\param theIndex zero-based index in the list ///\param theWithEmpty if it is false, counts the not-empty referenced objects only - virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const = 0; + virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) = 0; /// Substitutes the object by another one. Does nothing if such object is not found. virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0; diff --git a/src/ModelAPI/ModelAPI_AttributeSelection.h b/src/ModelAPI/ModelAPI_AttributeSelection.h index 212e83be9..d2dec5bc4 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelection.h +++ b/src/ModelAPI/ModelAPI_AttributeSelection.h @@ -47,7 +47,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, do not store and name the added in the data framework - /// (used to remove immideately, without the following updates) + /// (used to remove immediately, without the following updates) /// \returns true if attribute was updated virtual bool setValue( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, @@ -78,7 +78,7 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Returns the context of the selection : result or feature virtual std::shared_ptr contextObject() = 0; - /// Updates the underlied selection due to the changes in the referenced objects + /// Updates the selection due to the changes in the referenced objects /// \returns false if update is failed virtual bool update() = 0; @@ -115,12 +115,17 @@ class ModelAPI_AttributeSelection : public ModelAPI_Attribute /// Returns true if recompute of selection become impossible virtual bool isInvalid() = 0; - /// Returns true if the name was stored using weak naming principle - MODELAPI_EXPORT virtual bool isWeakNaming() = 0; + /// Returns true if is geometrical selection. + virtual bool isGeometricalSelection() const = 0; /// To virtually destroy the fields of successors MODELAPI_EXPORT virtual ~ModelAPI_AttributeSelection(); + /// Returns the name by context. Adds the part name if the context is located in other document + MODELAPI_EXPORT virtual std::string contextName(const ResultPtr& theContext) const = 0; + + /// Makes the current local selection becomes all sub-shapes with same base geometry. + MODELAPI_EXPORT virtual void combineGeometrical() = 0; protected: /// Objects are created for features automatically diff --git a/src/ModelAPI/ModelAPI_AttributeSelectionList.h b/src/ModelAPI/ModelAPI_AttributeSelectionList.h index fe432944a..7bdd59a6b 100644 --- a/src/ModelAPI/ModelAPI_AttributeSelectionList.h +++ b/src/ModelAPI/ModelAPI_AttributeSelectionList.h @@ -74,7 +74,7 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute /// \param theContext object where the sub-shape was selected /// \param theSubShape selected sub-shape (if null, the whole context is selected) /// \param theTemporarily if it is true, it checks also the temporary added item - /// \returns true if the pair is found in the attirbute + /// \returns true if the pair is found in the attribute virtual bool isInList( const ObjectPtr& theContext, const std::shared_ptr& theSubShape, const bool theTemporarily = false) = 0; @@ -98,6 +98,11 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute /// during non-modification operations with this attribute) virtual void cashValues(const bool theEnabled) = 0; + virtual void setGeometricalSelection(const bool theIsGeometricalSelection) = 0; + + /// Returns true if is geometrical selection. + virtual bool isGeometricalSelection() const = 0; + /// Returns the type of this class of attributes static std::string typeId() { diff --git a/src/ModelAPI/ModelAPI_BodyBuilder.h b/src/ModelAPI/ModelAPI_BodyBuilder.h index 8da3d2158..6523241df 100755 --- a/src/ModelAPI/ModelAPI_BodyBuilder.h +++ b/src/ModelAPI/ModelAPI_BodyBuilder.h @@ -42,92 +42,61 @@ public: MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {}; /// Stores the shape (called by the execution method). - virtual void store(const std::shared_ptr& theShape, + virtual void store(const GeomShapePtr& theShape, const bool theIsStoreSameShapes = true) = 0; /// Stores the generated shape (called by the execution method). - virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) = 0; + virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) = 0; /// Stores the modified shape (called by the execution method). - virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag = 0) = 0; - - /// Stores the shape without naming support - virtual void storeWithoutNaming(const std::shared_ptr& theShape) = 0; + virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true) = 0; /// Returns the shape-result produced by this feature - virtual std::shared_ptr shape() = 0; + virtual GeomShapePtr shape() = 0; /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - virtual void generated( - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1) = 0; + /// Returns true if it is stored correctly (the final shape contains this new sub-shape) + virtual bool generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult = true) = 0; /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1) = 0; + virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") = 0; /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1) = 0; - - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - virtual void deleted( - const std::shared_ptr& theOldShape, const int theTag = 1) = 0; + virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = "") = 0; /// load deleted shapes - virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()) = 0; + virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0; + /// load and orient modified shapes - virtual void loadAndOrientModifiedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, - const bool theIsStoreAsGenerated = false) = 0; + virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") = 0; + /// load and orient generated shapes - virtual void loadAndOrientGeneratedShapes ( - GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const std::string& theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) = 0; + virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = "") = 0; /// load shapes of the first level (to be used during shape import) - virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag) = 0; - - /// load disconnected edges - virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag) = 0; - - /// load disconnected vetexes - virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName,int& theTag) = 0; - - /// Converts evolution of sub-shapes stored in naming structure to selection - /// (theFlag = true) and back (theFlag = false) - virtual void evolutionToSelection(const bool theFlag) = 0; - - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - virtual bool isLatestEqual(const std::shared_ptr& theShape) = 0; + virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName) = 0; protected: /// Returns the data manager of this object: attributes @@ -137,7 +106,7 @@ protected: MODELAPI_EXPORT virtual std::shared_ptr document() const; protected: - /// Deafult constructor accessible only from Model_Object + /// Default constructor accessible only from Model_Object MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner); ModelAPI_Object* myOwner; ///< the owner object this builder belongs to diff --git a/src/ModelAPI/ModelAPI_CompositeFeature.cpp b/src/ModelAPI/ModelAPI_CompositeFeature.cpp index 8fc0c819a..b9227b043 100644 --- a/src/ModelAPI/ModelAPI_CompositeFeature.cpp +++ b/src/ModelAPI/ModelAPI_CompositeFeature.cpp @@ -25,12 +25,6 @@ ModelAPI_CompositeFeature::~ModelAPI_CompositeFeature() } -void ModelAPI_CompositeFeature::exchangeIDs( - std::shared_ptr theFeature1, std::shared_ptr theFeature2) -{ - // by default nothing is in the implementation -} - void ModelAPI_CompositeFeature::erase() { // erase all sub-features diff --git a/src/ModelAPI/ModelAPI_CompositeFeature.h b/src/ModelAPI/ModelAPI_CompositeFeature.h index 1011b350b..29276b544 100644 --- a/src/ModelAPI/ModelAPI_CompositeFeature.h +++ b/src/ModelAPI/ModelAPI_CompositeFeature.h @@ -55,10 +55,6 @@ public: /// structures of the owner (the remove from the document will be done outside just after) virtual void removeFeature(std::shared_ptr theFeature) = 0; - /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769) - MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr theFeature1, - std::shared_ptr theFeature2); - /// in addition removes all subs MODELAPI_EXPORT virtual void erase(); }; diff --git a/src/ModelAPI/ModelAPI_Expression.cpp b/src/ModelAPI/ModelAPI_Expression.cpp index c0ffdf16d..3bba79c8c 100644 --- a/src/ModelAPI/ModelAPI_Expression.cpp +++ b/src/ModelAPI/ModelAPI_Expression.cpp @@ -54,14 +54,18 @@ bool ModelAPI_Expression::isVariable(const std::string& theString) { if (theString.empty()) return false; - std::string::const_iterator it = theString.begin(); - if (!(isalpha(*it) || (*it) == '_') || it == theString.end()) - return false; - it++; - for ( ; it != theString.end(); ++it ) { - if(!(isalnum(*it) || (*it) == '_')) { + try { + std::string::const_iterator it = theString.begin(); + if (!(isalpha(*it) || (*it) == '_') || it == theString.end()) return false; + it++; + for ( ; it != theString.end(); ++it ) { + if(!(isalnum(*it) || (*it) == '_')) { + return false; + } } + } catch(...) { + return false; } return true; } diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 236ee3dff..5f1e3c989 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -91,7 +91,7 @@ void ModelAPI_Feature::setResult(const std::shared_ptr& theResu void ModelAPI_Feature::removeResult(const std::shared_ptr& theResult) { theResult->setDisabled(theResult, true); - // flush visualisation changes + // flush visualization changes static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); aLoop->flush(aRedispEvent); @@ -138,7 +138,7 @@ void ModelAPI_Feature::removeResults( } } if (!aGroup.empty() && theFlush) { - // flush visualisation changes + // flush visualization changes static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); aLoop->flush(aRedispEvent); @@ -173,8 +173,10 @@ void ModelAPI_Feature::erase() while (!myResults.empty()) { // remove one by one with messages std::shared_ptr aRes = *(myResults.begin()); aRes->setDisabled(aRes, true); // to avoid activation of the Part result - if (!myResults.empty()) // disabling result may erase the list (on undo of Part, issue 665) + if (!myResults.empty()) {// disabling result may erase the list (on undo of Part, issue 665) myResults.erase(myResults.begin()); + aRes->erase(); + } } ModelAPI_Object::erase(); } diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h index 1f09fb2be..64a2d432e 100644 --- a/src/ModelAPI/ModelAPI_Object.h +++ b/src/ModelAPI/ModelAPI_Object.h @@ -30,7 +30,7 @@ class ModelAPI_Data; class ModelAPI_Document; -// sometimes it is usefull for debug to see name of each object (bad for memory and performance) +// sometimes it is useful for debug to see name of each object (bad for memory and performance) //#define DEBUG_NAMES /**\class ModelAPI_Object @@ -115,6 +115,7 @@ class ModelAPI_Object: public ModelAPI_Entity MODELAPI_EXPORT virtual void erase(); friend class Model_Objects; + friend class ModelAPI_Feature; friend class Model_Document; }; diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index 588d138bf..e0f0f8c87 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -35,9 +35,9 @@ void ModelAPI_Result::initAttributes() { // append the color attribute. It is empty, the attribute will be filled by a request DataPtr aData = data(); - aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId()); - aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId()); - aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId()); + aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::typeId())->setIsArgument(false); + aData->addAttribute(DEFLECTION_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); + aData->addAttribute(TRANSPARENCY_ID(), ModelAPI_AttributeDouble::typeId())->setIsArgument(false); } bool ModelAPI_Result::setDisabled(std::shared_ptr theThis, const bool theFlag) diff --git a/src/ModelAPI/ModelAPI_ResultBody.cpp b/src/ModelAPI/ModelAPI_ResultBody.cpp index 0ee6696c2..22284d1ee 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.cpp +++ b/src/ModelAPI/ModelAPI_ResultBody.cpp @@ -39,8 +39,8 @@ std::string ModelAPI_ResultBody::groupName() return group(); } -void ModelAPI_ResultBody::store(const std::shared_ptr& theShape, - const bool theIsStoreSameShapes) +void ModelAPI_ResultBody::store(const GeomShapePtr& theShape, + const bool theIsStoreSameShapes) { myBuilder->store(theShape, theIsStoreSameShapes); myConnect = ConnectionNotComputed; @@ -53,8 +53,8 @@ void ModelAPI_ResultBody::store(const std::shared_ptr& theShape, updateSubs(theShape); } -void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape) +void ModelAPI_ResultBody::storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape) { myBuilder->storeGenerated(theFromShape, theToShape); myConnect = ConnectionNotComputed; @@ -67,11 +67,11 @@ void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr& t updateSubs(theToShape); } -void ModelAPI_ResultBody::storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, - const int theDecomposeSolidsTag) +void ModelAPI_ResultBody::storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored) { - myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag); + myBuilder->storeModified(theOldShape, theNewShape, theIsCleanStored); myConnect = ConnectionNotComputed; static Events_Loop* aLoop = Events_Loop::loop(); @@ -82,94 +82,60 @@ void ModelAPI_ResultBody::storeModified(const std::shared_ptr& th updateSubs(theNewShape); } -void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr& theShape) -{ - myBuilder->storeWithoutNaming(theShape); - myConnect = ConnectionNotComputed; - - static Events_Loop* aLoop = Events_Loop::loop(); - static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - aECreator->sendUpdated(data()->owner(), aRedispEvent); -} - -std::shared_ptr ModelAPI_ResultBody::shape() +GeomShapePtr ModelAPI_ResultBody::shape() { return myBuilder->shape(); } -void ModelAPI_ResultBody::generated(const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag) +bool ModelAPI_ResultBody::generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult) { - myBuilder->generated(theNewShape, theName, theTag); + return myBuilder->generated(theNewShape, theName, theCheckIsInResult); } -void ModelAPI_ResultBody::generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag) +void ModelAPI_ResultBody::generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { - myBuilder->generated(theOldShape, theNewShape, theName, theTag); + myBuilder->generated(theOldShape, theNewShape, theName); } -void ModelAPI_ResultBody::modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag) +void ModelAPI_ResultBody::modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName) { - myBuilder->modified(theOldShape, theNewShape, theName, theTag); + myBuilder->modified(theOldShape, theNewShape, theName); } -void ModelAPI_ResultBody::deleted( - const std::shared_ptr& theOldShape, const int theTag) -{ - myBuilder->deleted(theOldShape, theTag); -} - -void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes) -{ - myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag, theShapes); -} - -void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate, - const bool theIsStoreAsGenerated, - const bool /*theSplitInSubs*/) -{ - myBuilder->loadAndOrientModifiedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate, - theIsStoreAsGenerated); -} - -void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, - const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes) +void ModelAPI_ResultBody::loadDeletedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude) { - myBuilder->loadAndOrientGeneratedShapes( - theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes); + myBuilder->loadDeletedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theShapesToExclude); } -void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadModifiedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - myBuilder->loadFirstLevel(theShape, theName, theTag); + myBuilder->loadModifiedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } -void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName) { - myBuilder->loadDisconnectedEdges(theShape, theName, theTag); + myBuilder->loadGeneratedShapes(theAlgo, theOldShape, theShapeTypeToExplore, theName); } -void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag) +void ModelAPI_ResultBody::loadFirstLevel(GeomShapePtr theShape, + const std::string& theName) { - myBuilder->loadDisconnectedVertexes(theShape, theName, theTag); + myBuilder->loadFirstLevel(theShape, theName); } bool ModelAPI_ResultBody::isConnectedTopology() diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index b934744c6..1ad95f5d1 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -36,12 +36,12 @@ class GeomAlgoAPI_MakeShape; * Provides a shape that may be displayed in the viewer. * May provide really huge results, so, working with this kind * of result must be optimized. -* Also provides a conainer of sub-body result in case it is compound or compsolid. +* Also provides a container of sub-body result in case it is compound or compsolid. */ class ModelAPI_ResultBody : public ModelAPI_Result { public: - /// Iternal enumeration for storage the information of connected topology flag + /// Internal enumeration for storage the information of connected topology flag enum ConnectedTopologyFlag { ConnectionNotComputed, ///< not yet computed IsConnected, ///< the topology is connected @@ -87,7 +87,7 @@ public: MODELAPI_EXPORT virtual std::shared_ptr subResult( const int theIndex, bool forTree = false) const = 0; - /// Returns true if feature or reuslt belong to this composite feature as subs + /// Returns true if feature or result belong to this composite feature as subs /// Returns theIndex - zero based index of sub if found MODELAPI_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0; @@ -95,81 +95,64 @@ public: /// param[in] theShape shape to store. /// param[in] theIsStoreSameShapes if false stores reference to the same shape /// if it is already in document. - MODELAPI_EXPORT virtual void store(const std::shared_ptr& theShape, - const bool theIsStoreSameShapes = true); + MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape, + const bool theIsStoreSameShapes = true); /// Stores the generated shape (called by the execution method). - MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr& theFromShape, - const std::shared_ptr& theToShape); + MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape, + const GeomShapePtr& theToShape); /// Stores the modified shape (called by the execution method). - MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const int theDecomposeSolidsTag = 0); - - /// Stores the shape without naming support - MODELAPI_EXPORT virtual void storeWithoutNaming( - const std::shared_ptr& theShape); + MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const bool theIsCleanStored = true); /// Returns the shape-result produced by this feature - MODELAPI_EXPORT virtual std::shared_ptr shape(); + MODELAPI_EXPORT virtual GeomShapePtr shape(); /// Records the subshape newShape which was generated during a topological construction. /// As an example, consider the case of a face generated in construction of a box. - MODELAPI_EXPORT virtual void generated(const std::shared_ptr& theNewShape, - const std::string& theName, const int theTag = 1); + /// Returns true if it is stored correctly (the final shape contains this new sub-shape) + MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape, + const std::string& theName, const bool theCheckIsInResult = true); /// Records the shape newShape which was generated from the shape oldShape during a topological /// construction. As an example, consider the case of a face generated from an edge in /// construction of a prism. - MODELAPI_EXPORT virtual void generated(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1); + MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = ""); /// Records the shape newShape which is a modification of the shape oldShape. /// As an example, consider the case of a face split or merged in a Boolean operation. - MODELAPI_EXPORT virtual void modified(const std::shared_ptr& theOldShape, - const std::shared_ptr& theNewShape, const std::string& theName, - const int theTag = 1); - - /// Records the shape oldShape which was deleted from the current label. - /// As an example, consider the case of a face removed by a Boolean operation. - MODELAPI_EXPORT virtual void deleted( - const std::shared_ptr& theOldShape, const int theTag = 1); + MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape, + const GeomShapePtr& theNewShape, + const std::string& theName = ""); /// load deleted shapes - MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, - const int theKindOfShape, - const int theTag, - const GeomShapePtr theShapes = GeomShapePtr()); + MODELAPI_EXPORT + virtual void loadDeletedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const GeomShapePtr& theShapesToExclude = GeomShapePtr()); /// load and orient modified shapes - MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, const int theTag, - const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes, - const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false, - const bool theSplitInSubs = false); + MODELAPI_EXPORT + virtual void loadModifiedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = ""); /// load and orient generated shapes - MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS, - std::shared_ptr theShapeIn, const int theKindOfShape, - const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes); + MODELAPI_EXPORT + virtual void loadGeneratedShapes(const std::shared_ptr& theAlgo, + const GeomShapePtr& theOldShape, + const GeomAPI_Shape::ShapeType theShapeTypeToExplore, + const std::string& theName = ""); /// load shapes of the first level (to be used during shape import) - MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr theShape, - const std::string& theName, int& theTag); - - /// load disconnected edges - MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr theShape, - const std::string& theName, int& theTag); - - /// load disconnected vetexes - MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr theShape, - const std::string& theName, int& theTag); - - /// Returns true if the latest modification of this body in the naming history - // is equal to the given shape - MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape) = 0; + MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, + const std::string& theName); /// Returns true is the topology is connected. MODELAPI_EXPORT virtual bool isConnectedTopology() = 0; @@ -179,7 +162,7 @@ public: MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); /// Updates the sub-bodies if shape of this object is compsolid or compound - MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr& theThisShape, + MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape, const bool theShapeChanged = true) = 0; protected: diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h index ff637277d..225102be5 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.h +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -63,6 +63,10 @@ class ModelAPI_ResultConstruction : public ModelAPI_Result /// Sets the result virtual void setShape(std::shared_ptr theShape) = 0; + /// Updates the shape taking the current value from the data structure, returns true + /// if update has been correctly done + virtual bool updateShape() = 0; + /// Sets the flag that it must be displayed in history (default is true) virtual void setIsInHistory(const bool isInHistory) = 0; diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index bd8a697f8..db0baf99c 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -63,7 +63,7 @@ class ModelAPI_ResultPart : public ModelAPI_Result /// Returns the part-document of this result virtual std::shared_ptr partDoc() = 0; - /// Returns the original part result: for transfomration features results this is + /// Returns the original part result: for transformation features results this is /// the original Part feature result virtual std::shared_ptr original() = 0; @@ -87,6 +87,9 @@ class ModelAPI_ResultPart : public ModelAPI_Result virtual std::shared_ptr shapeInPart( const std::string& theName, const std::string& theType, int& theIndex) = 0; + /// Updates the selection inside of the part as a geometrical selection + virtual bool combineGeometrical(const int theIndex, std::string& theNewName) = 0; + /// Returns the shape selected in the selection index virtual std::shared_ptr selectionValue(const int theIndex) = 0; diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index a2c8af67a..e40e05536 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -128,6 +128,12 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory /// Returns true if the attribute must be checked (the case is selected) virtual bool isCase(FeaturePtr theFeature, std::string theAttribute) = 0; + /// Register the selection attribute as geometrical selection + virtual void registerGeometricalSelection(std::string theFeature, std::string theAttribute) = 0; + + /// Returns true if the attribute is a geometrical selection + virtual bool isGeometricalSelection(std::string theFeature, std::string theAttribute) = 0; + protected: /// Get instance from Session ModelAPI_ValidatorsFactory() diff --git a/src/ModelAPI/Test/Test1064.py b/src/ModelAPI/Test/Test1064.py index bd2599e08..39cd4f49b 100644 --- a/src/ModelAPI/Test/Test1064.py +++ b/src/ModelAPI/Test/Test1064.py @@ -71,14 +71,10 @@ aPart = aSession.activeDocument() #========================================================================= # Make extrusion on triangle #========================================================================= -aSketchResult = aSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin.pnt(), dirx.dir(), norm.dir(), aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aSketchFeature.firstResult()) aSession.startOperation() anExtrusionFt = aPart.addFeature("Extrusion") -anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) +anExtrusionFt.selectionList("base").append(aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(0) @@ -93,7 +89,7 @@ aSession.setActiveDocument(aPartSet) aPlane = aPartSet.addFeature("Plane") aPlane.string("creation_method").setValue("by_other_plane") aPlane.string("by_other_plane_option").setValue("by_distance_from_other") -aPlane.selection("plane").selectSubShape("face", "Part_1/Extrusion_1_1/Generated_Face_2") +aPlane.selection("plane").selectSubShape("face", "Part_1/_weak_name_5_Extrusion_1_1") aPlane.real("distance").setValue(0.001) aPlane.boolean("reverse").setValue(False) aSession.finishOperation() diff --git a/src/ModelAPI/Test/Test1512.py b/src/ModelAPI/Test/Test1512.py index 5a8182c2c..8494772c8 100755 --- a/src/ModelAPI/Test/Test1512.py +++ b/src/ModelAPI/Test/Test1512.py @@ -155,13 +155,13 @@ def check_owner(selection, topology_type, feature): aSession.abortOperation() # check faces -check_owner("Extrusion_1_1/Generated_Face_1", "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_owner("Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4", "face", aBox) +check_owner("Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face", "face", aBox) +check_owner("Cut_1_1/Modified_Face&Sketch_2/SketchCircle_1_2", "face", aHoleExt) +check_owner("Fuse_1_1/Modified_Face&Sketch_3/SketchCircle_2_2", "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", "edge", aTower) +check_owner("[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]", "edge", aBox) +check_owner("[Fuse_1_1/Modified_Face&Sketch_3/SketchCircle_2_2][Extrusion_3_1/To_Face]", "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/Test1562.py b/src/ModelAPI/Test/Test1562.py new file mode 100644 index 000000000..b49bcf0d0 --- /dev/null +++ b/src/ModelAPI/Test/Test1562.py @@ -0,0 +1,82 @@ +## 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() +lenParam = model.addParameter(Part_1_doc, "len", "45") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(63.23267137124048, -31.30105453337777, -32.56343706523536, -31.30105453337777) +SketchLine_2 = Sketch_1.addLine(-32.56343706523536, -31.30105453337777, -32.56343706523536, -163.6364723017416) +SketchLine_3 = Sketch_1.addLine(-32.56343706523536, -163.6364723017416, 63.23267137124048, -163.6364723017416) +SketchLine_4 = Sketch_1.addLine(63.23267137124048, -163.6364723017416, 63.23267137124048, -31.30105453337777) +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() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 50, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")) +SketchLine_5 = Sketch_2.addLine(43.23267137124047, 69.97394590606471, -1.767328628759523, 69.97394590606471) +SketchLine_6 = Sketch_2.addLine(-1.767328628759523, 69.97394590606471, -1.767328628759523, 20.8583125692591) +SketchLine_7 = Sketch_2.addLine(-1.767328628759523, 20.8583125692591, 43.23267137124047, 20.8583125692591) +SketchLine_8 = Sketch_2.addLine(43.23267137124047, 20.8583125692591, 43.23267137124047, 69.97394590606471) +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()) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4]"), False) +SketchLine_9 = SketchProjection_1.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchLine_9.result(), SketchLine_7.endPoint(), 20, True) +SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_7.result(), "len") +model.do() +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"), 0, model.selection("FACE", "ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_8"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_8")) +SketchCircle_1 = Sketch_3.addCircle(-89.76476373103716, -34.76230113958862, 5.223553090716001) +ExtrusionCut_2.setNestedSketch(Sketch_3) +model.do() +# on increase of parameter selected part of extrusion is increased and selected face is removed (U becomes L) +# so, check that selection is still correct and cut from not existing part produces correct shape anyway +lenParam.setValue(100) +model.do() + +# check the result validity +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(ExtrusionCut_2.feature())) + +# set the value back to avoid changed the name text in selection of "to_object" in check python dump +lenParam.setValue(45) + +model.end() + +assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test1757.py b/src/ModelAPI/Test/Test1757.py index 8418bdc89..6f725da2c 100644 --- a/src/ModelAPI/Test/Test1757.py +++ b/src/ModelAPI/Test/Test1757.py @@ -54,13 +54,13 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 300, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 300, 0) #========================================================================= # Cut another rectangle to make a groove #========================================================================= -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/To_Face_1"), 0, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1")) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/To_Face"), 0, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face")) SketchLine_5 = Sketch_2.addLine(-47.794137712106, -188.943752610533, 90.842718875892, -188.943752610533) SketchLine_6 = Sketch_2.addLine(90.842718875892, -188.943752610533, 90.842718875892, -51.567231082425) SketchLine_7 = Sketch_2.addLine(90.842718875892, -51.567231082425, -47.794137712106, -51.567231082425) @@ -79,8 +79,8 @@ model.do() #========================================================================= # Make a cylindrical hole using one of the produced faces #========================================================================= -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_3")) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4)")) SketchCircle_1 = Sketch_3.addCircle(143.412751420315, -228.52745656314, 32.158435160764) ExtrusionCut_2.setNestedSketch(Sketch_3) @@ -92,8 +92,8 @@ Part_1.document().setCurrentFeature(ExtrusionCut_1.feature(), True) #========================================================================= # Modify the cylindrical hole base face by another groove in the history before the hole is created #========================================================================= -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), -50, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2")) SketchLine_9 = Sketch_4.addLine(-176.701443076057, -151.212050129331, -91.83965287802501, -151.212050129331) SketchLine_10 = Sketch_4.addLine(-91.83965287802501, -151.212050129331, -91.83965287802501, -84.473709256573) SketchLine_11 = Sketch_4.addLine(-91.83965287802501, -84.473709256573, -176.701443076057, -84.473709256573) @@ -125,6 +125,6 @@ import ModelAPI assert(ModelAPI.ModelAPI_Session.get().validators().validate(Sketch_4.feature())) assert(ModelAPI.ModelAPI_Session.get().validators().validate(ExtrusionCut_2.feature())) -assert(Sketch_3.feature().selection("External").namingName() == "ExtrusionCut_3_1/Modfied_5") +assert(Sketch_3.feature().selection("External").namingName() == "(ExtrusionCut_3_1/Modified_Face&Sketch_2/SketchLine_6)(ExtrusionCut_3_1/Modified_Face&Sketch_1/SketchLine_4)(ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face)") assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test1995.py b/src/ModelAPI/Test/Test1995.py index 123cab3cb..cb931c2d5 100644 --- a/src/ModelAPI/Test/Test1995.py +++ b/src/ModelAPI/Test/Test1995.py @@ -42,9 +42,9 @@ 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() -Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e")) -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 50, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_2")) +Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f"), model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 50, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")) SketchCircle_1 = Sketch_2.addCircle(12.88847795756506, 28.93359954982685, 11.55225986344597) model.do() diff --git a/src/ModelAPI/Test/Test1998.py b/src/ModelAPI/Test/Test1998.py index 743598add..ac0ff8c4b 100644 --- a/src/ModelAPI/Test/Test1998.py +++ b/src/ModelAPI/Test/Test1998.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -27,8 +29,9 @@ Part_1_doc = Part_1.document() Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_1 = Sketch_1.addLine(-106.3464837049742, -78.0445969125214, -108.0617495711835, 165.5231560891939) model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")]) +model.do() model.end() assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test2170.py b/src/ModelAPI/Test/Test2170.py index daf3d3473..f0133e287 100644 --- a/src/ModelAPI/Test/Test2170.py +++ b/src/ModelAPI/Test/Test2170.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -47,7 +49,7 @@ SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint() SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6") SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 200) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 200) -SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-032, 0, 500, 0, False) +SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-32, 0, 500, 0, False) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.center()) SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7") SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint()) @@ -63,10 +65,11 @@ SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12") model.do() Sketch_1.setName("toto") Sketch_1.result().setName("tutu") -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "tutu/Face-SketchLine_1f-SketchLine_3f-SketchArc_1_2f-SketchArc_2_2f")], model.selection(), 10, 0) -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/Edge-SketchLine_2")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "tutu/Face-SketchLine_1r-SketchArc_2_2f-SketchLine_3f-SketchArc_1_2f")], model.selection(), 10, 0) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/SketchLine_2")]) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0) -Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Extrusion_2_1/Generated_Edge_2&Extrusion_2_1/To_Edge_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Edge_1&Extrusion_2_1/To_Edge_1")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_StartVertex]e[Extrusion_2_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_EndVertex]e[Extrusion_2_1/To_Edge]e")]) +model.do() model.end() # check that resulting group selection is valid diff --git a/src/ModelAPI/Test/Test2228.py b/src/ModelAPI/Test/Test2228.py index 1da5212a8..3540fa055 100644 --- a/src/ModelAPI/Test/Test2228.py +++ b/src/ModelAPI/Test/Test2228.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -31,16 +33,16 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchPoint_1.coordinates model.do() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2r-SketchCircle_2_2f")], model.selection(), 5, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r")], model.selection(), 5, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchCircle_3 = Sketch_2.addCircle(-0.01730125245914903, 1.175069067120482, 0.2787321880802174) SketchCircle_4 = Sketch_2.addCircle(-0.01730125245914903, 1.175069067120482, 0.3197841740766353) SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchCircle_4.center()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r-SketchCircle_2_2f")], model.selection(), 0, 3) -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face_1"), 0, model.selection(), 0) -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOZ")) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r")], model.selection(), 0, 3) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face"), 0, model.selection(), 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], [model.selection("SOLID", "Extrusion_3_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_1 = Sketch_3.addLine(-3.362323990279312, -0.5188129046480872, 0.8318943090987101, -0.5188129046480872) SketchLine_2 = Sketch_3.addLine(0.8318943090987101, -0.5188129046480872, 0.8318943090987101, 7.155729512171993) SketchLine_3 = Sketch_3.addLine(0.8318943090987101, 7.155729512171993, -3.362323990279312, 7.155729512171993) @@ -54,15 +56,16 @@ SketchConstraintVertical_1 = Sketch_3.setVertical(SketchLine_2.result()) SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_3.result()) SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_4.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_1")]) -Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_2_2f")], model.selection(), model.selection("FACE", "Extrusion_2_1/From_Face_1"), 0, model.selection(), 0) -Boolean_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_4_1")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Cut_1_1"), model.selection("SOLID", "Cut_2_1"), model.selection("FACE", "Face_1_1")]) -Remove_SubShapes_1_objects = [model.selection("SOLID", "Partition_1_1_1_1"), model.selection("SOLID", "Partition_1_1_1_2"), model.selection("SOLID", "Partition_1_1_1_3"), model.selection("SOLID", "Partition_1_1_1_4")] +Face_1_objects = [model.selection("EDGE", "Sketch_2/SketchLine_2"), model.selection("EDGE", "Sketch_2/SketchLine_3"), model.selection("EDGE", "Sketch_2/SketchLine_4"), model.selection("EDGE", "Sketch_2/SketchLine_1")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_2_2f-SketchCircle_1_2r_wire")], model.selection(), model.selection("FACE", "Extrusion_2_1/From_Face"), 0, model.selection(), 0) +Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_4_1")]) +Partition_1_objects = [model.selection("SOLID", "Cut_1_1"), model.selection("SOLID", "Cut_2_1"), model.selection("FACE", "Face_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +Remove_SubShapes_1_objects_1 = [model.selection("SOLID", "Partition_1_1_1_1"), model.selection("SOLID", "Partition_1_1_1_2"), model.selection("SOLID", "Partition_1_1_1_3"), model.selection("SOLID", "Partition_1_1_1_4")] Remove_SubShapes_1 = model.addRemoveSubShapes(Part_1_doc, model.selection("COMPOUND", "Partition_1_1")) -Remove_SubShapes_1.setSubShapesToKeep(Remove_SubShapes_1_objects) - - +Remove_SubShapes_1.setSubShapesToKeep(Remove_SubShapes_1_objects_1) +model.do() model.end() # check that remove sub-shapes contains correct selection diff --git a/src/ModelAPI/Test/Test2241.py b/src/ModelAPI/Test/Test2241.py index 10747cdea..521adb37f 100644 --- a/src/ModelAPI/Test/Test2241.py +++ b/src/ModelAPI/Test/Test2241.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -52,20 +54,20 @@ SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_4.result()) SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_6.result()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result()) -SketchArc_1 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 81.26217508737108, 0, 0, 81.26217508737108, False) +SketchArc_1 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 81.26217508737108, 0, 0, 81.26217508737108, False) SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_1.center()) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchArc_1.startPoint()) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_1.endPoint()) SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_1.endPoint()) SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_7.result()) -SketchArc_2 = Sketch_1.addArc(4.151438510550382e-034, -3.089278765476956e-034, 76.26217508737108, 0, 0, 76.26217508737108, False) +SketchArc_2 = Sketch_1.addArc(4.151438510550382e-34, -3.089278765476956e-34, 76.26217508737108, 0, 0, 76.26217508737108, False) SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchArc_2.center()) SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_23") SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchLine_9.result(), SketchArc_2.startPoint()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_24") SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_10.result(), SketchArc_2.endPoint()) SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_25") -SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.endPoint(), SketchArc_2.endPoint(), 5, False) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), "2*l") SketchConstraintLength_1.setName("SketchConstraintLength_2") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_6.result(), "l") @@ -93,20 +95,26 @@ SketchCircle_10 = Sketch_2.addCircle(49.58498153094326, 15.18789884296047, 2.552 SketchCircle_11 = Sketch_2.addCircle(66.22695092615982, 10.77677442495125, 4.536925074373645) SketchCircle_12 = Sketch_2.addCircle(50.98852111849166, 6.165144351577979, 3.547307159201085) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_9f-SketchLine_10r-SketchArc_1_2f-SketchArc_2_2r")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2")]) -Face_4 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/Edge-SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchLine_10r-SketchArc_2_2f")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/XOY")) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_9f-SketchArc_1_2f-SketchLine_10r-SketchArc_2_2r_wire")]) +Face_3_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2")] +Face_3 = model.addFace(Part_1_doc, Face_3_objects) +Face_4_objects = [model.selection("EDGE", "Sketch_2/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_2/SketchCircle_5_2"), model.selection("EDGE", "Sketch_2/SketchCircle_7_2"), model.selection("EDGE", "Sketch_2/SketchCircle_6_2"), model.selection("EDGE", "Sketch_2/SketchCircle_9_2"), model.selection("EDGE", "Sketch_2/SketchCircle_8_2"), model.selection("EDGE", "Sketch_2/SketchCircle_10_2"), model.selection("EDGE", "Sketch_2/SketchCircle_12_2"), model.selection("EDGE", "Sketch_2/SketchCircle_11_2"), model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_9f-SketchArc_2_2f-SketchLine_10r_wire")] +Face_4 = model.addFace(Part_1_doc, Face_4_objects) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_11 = Sketch_3.addLine(40, 0, 30, 0) -SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "Face_1_1/Edge_6&Face_1_1/Edge_7")) +SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "[Face_1_1/Edge_6]e[Face_1_1/Edge_7]e")) SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_1.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_19") SketchLine_12 = Sketch_3.addLine(30, 0, 30, 10) SketchLine_13 = Sketch_3.addLine(30, 10, 40, 10) SketchLine_14 = Sketch_3.addLine(40, 10, 40, 0) SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_20") SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_21") SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_22") SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_26") SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_11.result()) @@ -118,24 +126,26 @@ SketchConstraintEqual_5.setName("SketchConstraintEqual_6") SketchConstraintLength_3 = Sketch_3.setLength(SketchLine_13.result(), "l") SketchConstraintLength_3.setName("SketchConstraintLength_4") model.do() -Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")]) -MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) -Recover_1 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), model.selection("VERTEX", "Face_4_1/Edge_4&Face_4_1/Edge_5")) -MultiTranslation_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) -Recover_2 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), model.selection("VERTEX", "Face_4_1/Edge_2&Face_4_1/Edge_3")) -MultiTranslation_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "l", 4) -Recover_3 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), model.selection("VERTEX", "LinearCopy_3_1/Translated_Edge_1_4&LinearCopy_3_1/Translated_Edge_1_3")) -MultiTranslation_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "l", 3) -Recover_4 = model.addRecover(Part_1_doc, MultiTranslation_1, [Face_5.result()]) -Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "Face_4_1/Edge_6&Face_4_1/Edge_7"), model.selection("VERTEX", "Face_4_1/Edge_1&Face_4_1/Edge_9")) -MultiTranslation_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "l", 2) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_1_1_8"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_1_1_5")]) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r_wire")]) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) +Recover_1 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_4]e[Face_4_1/Edge_5]e")) +LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_1_1")], model.selection("EDGE", "PartSet/OX"), "l", 4, model.selection("EDGE", "PartSet/OY"), "l", 2) +Recover_2 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_2_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_2]e[Face_4_1/Edge_3]e")) +LinearCopy_3 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_2_1")], model.selection("EDGE", "PartSet/OX"), "l", 4) +Recover_3 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_3 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_3_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_1]e[LinearCopy_3_1_1/ME:Translated_Edge&Face_5_1/Edge_2]e")) +LinearCopy_4 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_3_1")], model.selection("EDGE", "PartSet/OX"), "l", 3) +Recover_4 = model.addRecover(Part_1_doc, LinearCopy_1, [Face_5.result()]) +Translation_4 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_4_1")], model.selection("VERTEX", "[Face_4_1/Edge_6]e[Face_4_1/Edge_7]e"), model.selection("VERTEX", "[Face_4_1/Edge_1]e[Face_4_1/Edge_9]e")) +LinearCopy_5 = model.addMultiTranslation(Part_1_doc, [model.selection("FACE", "Translation_4_1")], model.selection("EDGE", "PartSet/OX"), "l", 2) +Group_1_objects = [model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_1_1_8"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_1_1_5")] +Group_1 = model.addGroup(Part_1_doc, Group_1_objects) Group_1.setName("Group_3") Group_1.result().setName("assemblages") -Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")]) +Group_2_objects = [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_12")] +Group_2 = model.addGroup(Part_1_doc, Group_2_objects) Group_2.setName("Group_1") Group_2.result().setName("eau") Group_2.result().setColor(0, 170, 255) @@ -143,8 +153,11 @@ Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_4_1")]) Group_3.setName("Group_2") Group_3.result().setName("acier") Group_3.result().setColor(170, 85, 0) -Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_5"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_1_1_8")]) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_4_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("SHELL", "Shell_1_1")]) +Shell_1_objects = [model.selection("FACE", "LinearCopy_1_1_1"), model.selection("FACE", "LinearCopy_1_1_2"), model.selection("FACE", "LinearCopy_1_1_3"), model.selection("FACE", "LinearCopy_1_1_4"), model.selection("FACE", "LinearCopy_1_1_5"), model.selection("FACE", "LinearCopy_1_1_6"), model.selection("FACE", "LinearCopy_1_1_7"), model.selection("FACE", "LinearCopy_2_1_4"), model.selection("FACE", "LinearCopy_2_1_5"), model.selection("FACE", "LinearCopy_2_1_6"), model.selection("FACE", "LinearCopy_2_1_7"), model.selection("FACE", "LinearCopy_2_1_8"), model.selection("FACE", "LinearCopy_2_1_1"), model.selection("FACE", "LinearCopy_2_1_2"), model.selection("FACE", "LinearCopy_2_1_3"), model.selection("FACE", "LinearCopy_3_1_4"), model.selection("FACE", "LinearCopy_3_1_3"), model.selection("FACE", "LinearCopy_3_1_2"), model.selection("FACE", "LinearCopy_3_1_1"), model.selection("FACE", "LinearCopy_4_1_1"), model.selection("FACE", "LinearCopy_4_1_2"), model.selection("FACE", "LinearCopy_4_1_3"), model.selection("FACE", "LinearCopy_5_1_1"), model.selection("FACE", "LinearCopy_5_1_2"), model.selection("FACE", "LinearCopy_1_1_8")] +Shell_1 = model.addShell(Part_1_doc, Shell_1_objects) +Partition_1_objects = [model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_3_2"), model.selection("FACE", "Face_4_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_5"), model.selection("FACE", "Face_3_3"), model.selection("FACE", "Face_3_4"), model.selection("FACE", "Face_3_7"), model.selection("FACE", "Face_3_6"), model.selection("FACE", "Face_3_8"), model.selection("FACE", "Face_3_9"), model.selection("FACE", "Face_3_10"), model.selection("FACE", "Face_3_11"), model.selection("FACE", "Face_3_12"), model.selection("SHELL", "Shell_1_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +model.do() model.end() # move groups diff --git a/src/ModelAPI/Test/Test2252.py b/src/ModelAPI/Test/Test2252.py index 3b4306e64..2b971addd 100644 --- a/src/ModelAPI/Test/Test2252.py +++ b/src/ModelAPI/Test/Test2252.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from ModelAPI import * from GeomAlgoAPI import * @@ -44,7 +46,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 60) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 90, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 90, 0) model.do() aSession = ModelAPI_Session.get() aSession.setActiveDocument(partSet, False) diff --git a/src/ModelAPI/Test/Test2276.py b/src/ModelAPI/Test/Test2276.py index 8697b5d15..68e41a29d 100644 --- a/src/ModelAPI/Test/Test2276.py +++ b/src/ModelAPI/Test/Test2276.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -25,14 +27,16 @@ 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(-9.954190485756755, -75.16051465706819, 60.31858435553394) +SketchCircle_1 = Sketch_1.addCircle(-9.954190485756754, -75.16051465706819, 60.31858435553394) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1__cc"), False) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]__cc"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchCircle_2 = Sketch_2.addCircle(-9.954190485756755, -75.16051465706819, 33.11263086848982) +SketchCircle_2 = Sketch_2.addCircle(-9.954190485756754, -75.16051465706819, 33.11263086848982) SketchConstraintCoincidence_1 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_2.center()) +model.do() +model.do() model.end() assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test2358_1.py b/src/ModelAPI/Test/Test2358_1.py index 27427d75f..46cea4b88 100644 --- a/src/ModelAPI/Test/Test2358_1.py +++ b/src/ModelAPI/Test/Test2358_1.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,12 +43,12 @@ SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchL SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchCircle_1 = Sketch_2.addCircle(26.06240015364781, 18.07716886601709, 12.23427461205297) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face_1"), 0, model.selection(), 0) -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face"), 0, model.selection(), 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) model.do() Folder_1 = model.addFolder(Part_1_doc, Sketch_1, Extrusion_1) @@ -57,13 +59,13 @@ Folder_2.setName("Cylinder") from GeomAPI import GeomAPI_Shape # check result shape -model.testNbResults(Boolean_1, 1) -model.testNbSubResults(Boolean_1, [0]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.FACE, [7]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.EDGE, [30]) -model.testNbSubShapes(Boolean_1, GeomAPI_Shape.VERTEX, [60]) -model.testResultsVolumes(Boolean_1, [101488.717162133529200218617916107]) +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, [7]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.EDGE, [30]) +model.testNbSubShapes(Cut_1, GeomAPI_Shape.VERTEX, [60]) +model.testResultsVolumes(Cut_1, [101488.717162133529200218617916107]) model.end() diff --git a/src/ModelAPI/Test/Test2358_2.py b/src/ModelAPI/Test/Test2358_2.py index e52fec361..110d934e8 100644 --- a/src/ModelAPI/Test/Test2358_2.py +++ b/src/ModelAPI/Test/Test2358_2.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -42,7 +44,7 @@ SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchL SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_5 = Sketch_2.addLine(10, 21.9014765990379, 0, 21.9014765990379) SketchLine_5.setName("SketchLine_9") @@ -74,7 +76,7 @@ SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_8.result(), 10) model.do() Sketch_2.setName("Sketch_3") Sketch_2.result().setName("Sketch_3") -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_9r-SketchLine_11r-SketchLine_12r-SketchLine_13r")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_9r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_10 = Sketch_3.addLine(29.60939424565112, 0, 19.60939424565112, 0) SketchLine_10.setName("SketchLine_14") @@ -107,12 +109,12 @@ 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_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_objects = [model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_16&weak_name_2]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_18&weak_name_2]")] 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_objects = [model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_1"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_4"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_2"), model.selection("FACE", "Fillet_1_1/Modified_Face&Sketch_1/SketchLine_4&weak_name_3")] Group_1 = model.addGroup(Part_1_doc, Group_1_objects) -Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Fillet_1_1/Fillet_Face_13&Fillet_1_1/Modified_Face_4"), model.selection("EDGE", "Fillet_1_1/Modified_Face_11&Fillet_1_1/Fillet_Face_13")]) -Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Fillet_1_1/Modified_Face_12&ExtrusionCut_1_1/Generated_Face_4&Fillet_1_1/Modified_Face_11"), model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Face_4&Fillet_1_1/Modified_Face_11&Fillet_1_1/Modified_Face_6")]) +Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)][Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][(Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3)(Fillet_1_1/Modified_Face&Extrusion_1_1/To_Face)]")]) +Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Fillet_1_1/Modified_Face&Sketch_3/SketchLine_9][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/Modified_Face&Sketch_1/SketchLine_3][Fillet_1_1/Modified_Face&Sketch_3/SketchLine_12]")]) model.do() Folder_1 = model.addFolder(Part_1_doc, Sketch_3, ExtrusionCut_2) diff --git a/src/ModelAPI/Test/Test2389.py b/src/ModelAPI/Test/Test2389.py index 89121b8a7..8d0211717 100644 --- a/src/ModelAPI/Test/Test2389.py +++ b/src/ModelAPI/Test/Test2389.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -31,7 +33,7 @@ model.addParameter(Part_1_doc, "Drill2_InnerRadius", "0.5") model.addParameter(Part_1_doc, "Drill2_DepthMin", "6.5") model.addParameter(Part_1_doc, "Drill2_DepthMax", "7.5") Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchLine_1 = Sketch_1.addLine(64., 0, 0, 0) +SketchLine_1 = Sketch_1.addLine(64, 0, 0, 0) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result()) @@ -50,7 +52,7 @@ SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 36) SketchLine_5 = Sketch_1.addLine(22, 36, 22, 0) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_3.result()) -SketchLine_6 = Sketch_1.addLine(32., 36., 32., 0) +SketchLine_6 = Sketch_1.addLine(32, 36, 32, 0) SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_3.result()) SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_1.result()) SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_1.result()) @@ -60,8 +62,10 @@ SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine SketchConstraintDistanceHorizontal_3 = Sketch_1.setHorizontalDistance(SketchLine_6.startPoint(), SketchLine_3.endPoint(), "Width/2") model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s"), True) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_5_StartVertex"), True) SketchPoint_2 = SketchProjection_2.createdFeature() +model.do() +model.do() model.end() assert(SketchProjection_2.external().namingName() != "") diff --git a/src/ModelAPI/Test/Test2391.py b/src/ModelAPI/Test/Test2391.py index 20d2655e0..caea5a405 100644 --- a/src/ModelAPI/Test/Test2391.py +++ b/src/ModelAPI/Test/Test2391.py @@ -18,7 +18,10 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * + from salome.shaper import model model.begin() @@ -167,7 +170,7 @@ SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], Sketch SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_6.result()) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], "Fillet1") SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_7.endPoint(), SketchLine_35.result(), "D1_in/2", True) -SketchConstraintAngle_4 = Sketch_1.setAngleComplementary(SketchLine_23.result(), SketchLine_22.result(), 44.99999999999992) +SketchConstraintAngle_4 = Sketch_1.setAngleComplementary(SketchLine_23.result(), SketchLine_22.result(), 44.99999999999991) SketchConstraintCollinear_4 = Sketch_1.setCollinear(SketchLine_14.result(), SketchLine_9.result()) SketchConstraintDistanceHorizontal_4 = Sketch_1.setHorizontalDistance(SketchLine_34.startPoint(), SketchLine_23.startPoint(), "Width/32*11") SketchConstraintDistanceHorizontal_5 = Sketch_1.setHorizontalDistance(SketchLine_23.startPoint(), SketchLine_22.startPoint(), "Chamfer") @@ -195,19 +198,19 @@ SketchConstraintDistanceHorizontal_14 = Sketch_1.setHorizontalDistance(SketchLin SketchConstraintDistance_11 = Sketch_1.setDistance(SketchLine_23.startPoint(), SketchLine_35.result(), "(D4_out+D2_in)/2", True) model.do() Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OX"), 360, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OY"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), True) +Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OY"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchPoint_2"), False) SketchPoint_3 = SketchProjection_3.createdFeature() -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Revolution_1_1/Generated_Face_28"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8])"), False) SketchLine_36 = SketchProjection_4.createdFeature() SketchCircle_1 = Sketch_2.addCircle(14.5, 0, 2.25) SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchPoint_3.result(), SketchCircle_1.center()) SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_1.results()[1], "Drill1_Radius") model.do() ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "PartSet/XOZ"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) -Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_14&Revolution_1_1/Generated_Face_15")], "Fillet1") -Fillet_2_objects = [model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "Revolution_1_1/Generated_Face_6"), model.selection("FACE", "Revolution_1_1/Generated_Face_8"), model.selection("FACE", "Revolution_1_1/Generated_Face_10")] +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20]")], "Fillet1") +Fillet_2_objects = [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_31"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_29"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_27"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25")] Fillet_2 = model.addFillet(Part_1_doc, Fillet_2_objects, "Fillet2") model.do() diff --git a/src/ModelAPI/Test/Test2396.py b/src/ModelAPI/Test/Test2396.py index a3ef0be37..cead3dfb7 100644 --- a/src/ModelAPI/Test/Test2396.py +++ b/src/ModelAPI/Test/Test2396.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,9 +18,10 @@ ## email : webmaster.salome@opencascade.com ## -from GeomAPI import * +# -*- coding: utf-8 -*- from salome.shaper import model +from GeomAPI import GeomAPI_Shape model.begin() partSet = model.moduleDocument() @@ -40,26 +41,9 @@ 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() - -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 100, 0) Extrusion_1.result().setName("Cube") - -Edge_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), - model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), - model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), - model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), - model.selection("EDGE", "Cube/Generated_Face_2&Cube/Generated_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_2&Cube/From_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_2&Cube/To_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_3&Cube/Generated_Face_2"), - model.selection("EDGE", "Cube/Generated_Face_1&Cube/From_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_3&Cube/To_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_3&Cube/From_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_1&Cube/To_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_4&Cube/Generated_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_4&Cube/From_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_4&Cube/To_Face_1"), - model.selection("EDGE", "Cube/Generated_Face_4&Cube/Generated_Face_3")] +Edge_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_2][Cube/Generated_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_2][Cube/From_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_2][Cube/To_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_3][Cube/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_1][Cube/From_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_3][Cube/To_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_3][Cube/From_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_1][Cube/To_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_4][Cube/Generated_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_4][Cube/From_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_4][Cube/To_Face]"), model.selection("EDGE", "[Cube/Generated_Face&Sketch_1/SketchLine_4][Cube/Generated_Face&Sketch_1/SketchLine_3]")] Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) # check all the names of Edge_1 results are different names = set() @@ -70,7 +54,7 @@ assert(len(names) == len(Edge_1.results())), "Some edges have equal name" Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_2.addCircle(200, 0, 50) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection("EDGE", "Cube"), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")], model.selection("EDGE", "Cube"), 10, 0) model.do() # check Extrusion_2 model.testNbResults(Extrusion_2, 1) diff --git a/src/ModelAPI/Test/Test2401.py b/src/ModelAPI/Test/Test2401.py index abf10ad1e..80869d143 100644 --- a/src/ModelAPI/Test/Test2401.py +++ b/src/ModelAPI/Test/Test2401.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -51,8 +53,8 @@ SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_1. SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 3) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_7.result(), 8) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r")], model.selection(), 5, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), 5, True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection(), 5, 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5"), 5, True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_8 = Sketch_2.addLine(7.560741003605092, 9.43062705614625, -1.095841663628257, 9.43062705614625) SketchLine_9 = Sketch_2.addLine(-1.095841663628257, 9.43062705614625, -1.095841663628257, -5.449377136847041) @@ -67,8 +69,8 @@ SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_9.result()) SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_10.result()) SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_11.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f")]) -Boolean_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("FACE", "Face_1_1")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f-SketchLine_11f")]) +Fill_1 = model.addFill(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("FACE", "Face_1_1")]) model.do() # now add an additional edge to the first sketch as it is described in the issue @@ -76,10 +78,10 @@ SketchLine_8 = Sketch_1.addLine(0, 3, 8, 3) SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_8.endPoint()) model.do() -Part_1_doc.setCurrentFeature(Boolean_1.feature(), True) +Part_1_doc.setCurrentFeature(Fill_1.feature(), True) model.end() # check that the plane is located as previously -model.testNbSubResults(Boolean_1, [2]) -model.testResultsVolumes(Boolean_1, [120]) +model.testNbSubResults(Fill_1, [2]) +model.testResultsVolumes(Fill_1, [120]) assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test2413.py b/src/ModelAPI/Test/Test2413.py index cb70bf684..0ef8930c2 100644 --- a/src/ModelAPI/Test/Test2413.py +++ b/src/ModelAPI/Test/Test2413.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -47,9 +49,9 @@ SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8") SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 50) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_3f")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchArc_1_2f-SketchLine_1r")], model.selection(), 100, 0) model.do() -Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3")] +Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")] Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects) # check that resulting build-solid feature is invalid: only one not-closed face is used from ModelAPI import * @@ -58,7 +60,7 @@ assert(aFactory.validate(Solid_1.feature()) == False) ModelAPI_Session.get().abortOperation() # another try: to make a solid with a face inside model.begin() -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"), 70, True) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"), 70, True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_5 = Sketch_2.addLine(14.9039069695087, 8.923908092675951, 26.86805702948195, 11.13714035991706) SketchLine_6 = Sketch_2.addLine(26.86805702948195, 11.13714035991706, 18.50962242738747, 32.13572332177004) @@ -70,11 +72,10 @@ SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10") SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint()) SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f")]) -Solid_2_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Face_1_1")] -Solid_2 = model.addSolid(Part_1_doc, Solid_2_objects) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f")]) +Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Face_1_1")] +Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects) +model.do() model.end() -assert(aFactory.validate(Solid_2.feature()) == False) - assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/Test2496.py b/src/ModelAPI/Test/Test2496.py index 9fefd0831..d17dc6161 100644 --- a/src/ModelAPI/Test/Test2496.py +++ b/src/ModelAPI/Test/Test2496.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -38,13 +40,13 @@ 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() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")]) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchCircle_1 = Sketch_2.addCircle(0, -10, 25) model.do() -Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")]) Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_1_1")]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Face_2_1/Face_2_1"), model.selection("FACE", "Partition_1_1_1")]) +Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Partition_1_1_1"), model.selection("COMPOUND", "Partition_1_1")]) model.do() assert(Group_1.feature().error() == "") diff --git a/src/ModelAPI/Test/Test2510.py b/src/ModelAPI/Test/Test2510.py index 09838dd7a..9c0ece97a 100644 --- a/src/ModelAPI/Test/Test2510.py +++ b/src/ModelAPI/Test/Test2510.py @@ -1,4 +1,4 @@ -## Copyright (C) 2018-20xx CEA/DEN, EDF R&D +## 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 @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -65,7 +67,7 @@ SketchLine_7.result().setName("SketchLine_8") SketchLine_7.setAuxiliary(True) SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_7.startPoint()) SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_7.endPoint()) -SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_7.result(), SketchLine_3.result(), 93.56999999999999) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_7.result(), SketchLine_3.result(), 93.56999999998719) SketchArc_2 = Sketch_1.addArc(2.349985665002739, 1.087256027998574, 2.499428733897898, 3.48259875277915, 3.77688682869805, 3.017010693505298, True) SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint()) SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_2.results()[1]) @@ -79,14 +81,14 @@ SketchLine_8.setName("SketchLine_9") SketchLine_8.result().setName("SketchLine_9") SketchLine_8.setAuxiliary(True) SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_8.endPoint()) -SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_8.result(), SketchLine_7.result(), 32.91) +SketchConstraintAngle_2 = Sketch_1.setAngle(SketchLine_8.result(), SketchLine_7.result(), 32.91000000001281) SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchArc_2.center()) SketchLine_9 = Sketch_1.addLine(1.546759218272496, 0.000964964207000808, 4.166514953924199, 2.685528408329715) SketchLine_9.setName("SketchLine_10") SketchLine_9.result().setName("SketchLine_10") SketchLine_9.setAuxiliary(True) SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_9.endPoint()) -SketchConstraintAngle_3 = Sketch_1.setAngle(SketchLine_9.result(), SketchLine_8.result(), 7.82) +SketchConstraintAngle_3 = Sketch_1.setAngle(SketchLine_9.result(), SketchLine_8.result(), 7.820000000000003) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_9.startPoint(), SketchArc_3.center()) SketchLine_10 = Sketch_1.addLine(4.166514953924199, 2.685528408329715, 4.411514953924289, 2.446442922550623) SketchLine_10.setName("SketchLine_11") @@ -109,7 +111,7 @@ SketchLine_12.result().setName("SketchLine_13") SketchLine_12.setAuxiliary(True) SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_4.center(), SketchLine_12.startPoint()) SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_12.endPoint()) -SketchConstraintAngle_4 = Sketch_1.setAngleBackward(SketchLine_11.result(), SketchLine_12.result(), 8.018000000000001) +SketchConstraintAngle_4 = Sketch_1.setAngleBackward(SketchLine_11.result(), SketchLine_12.result(), 8.018000000993595) SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_4.results()[1], 1.32) SketchArc_5 = Sketch_1.addArc(1.545335047953034, 0, 4.534275383417573, 2.308616054576027, 3.791202568545627, -3.03637143583555, True) SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchArc_5.startPoint()) @@ -154,6 +156,18 @@ SketchLine_17.result().setName("SketchLine_18") SketchArc_11.setName("SketchArc_14") SketchArc_11.result().setName("SketchArc_14") SketchArc_11.results()[1].setName("SketchArc_14_2") +SketchArc_10.setName("SketchArc_10") +SketchArc_10.result().setName("SketchArc_10") +SketchArc_10.results()[1].setName("SketchArc_10_2") +SketchArc_9.setName("SketchArc_9") +SketchArc_9.result().setName("SketchArc_9") +SketchArc_9.results()[1].setName("SketchArc_9_2") +SketchLine_16.setName("SketchLine_16") +SketchLine_16.result().setName("SketchLine_16") +SketchLine_15.setName("SketchLine_15") +SketchLine_15.result().setName("SketchLine_15") +SketchLine_14.setName("SketchLine_14") +SketchLine_14.result().setName("SketchLine_14") SketchConstraintCoincidence_30 = Sketch_1.setCoincident(SketchArc_7.endPoint(), SketchArc_8.startPoint()) SketchConstraintTangent_9 = Sketch_1.setTangent(SketchArc_7.results()[1], SketchArc_8.results()[1]) SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchLine_5.result(), SketchArc_8.endPoint()) @@ -190,13 +204,13 @@ SketchArc_15.setName("SketchArc_18") SketchArc_15.result().setName("SketchArc_18") SketchArc_15.results()[1].setName("SketchArc_18_2") SketchConstraintCoincidence_42 = Sketch_1.setCoincident(SketchArc_14.endPoint(), SketchArc_15.startPoint()) -SketchConstraintTangent_12 = Sketch_1.setTangent(SketchArc_14.results()[1], SketchArc_15.results()[1]) +SketchConstraintTangent_11 = Sketch_1.setTangent(SketchArc_14.results()[1], SketchArc_15.results()[1]) SketchArc_16 = Sketch_1.addArc(1.552616124088898, 0, 3.904833906055851, 3.190047534283911, 5.51611606287941, 0, True) SketchArc_16.setName("SketchArc_19") SketchArc_16.result().setName("SketchArc_19") SketchArc_16.results()[1].setName("SketchArc_19_2") SketchConstraintCoincidence_43 = Sketch_1.setCoincident(SketchArc_15.endPoint(), SketchArc_16.startPoint()) -SketchConstraintTangent_13 = Sketch_1.setTangent(SketchArc_15.results()[1], SketchArc_16.results()[1]) +SketchConstraintTangent_12 = Sketch_1.setTangent(SketchArc_15.results()[1], SketchArc_16.results()[1]) SketchConstraintCoincidence_44 = Sketch_1.setCoincident(SketchLine_5.result(), SketchArc_16.endPoint()) SketchConstraintCoincidence_45 = Sketch_1.setCoincident(SketchArc_14.endPoint(), SketchLine_13.result()) SketchConstraintCoincidence_46 = Sketch_1.setCoincident(SketchArc_14.center(), SketchArc_6.center()) @@ -214,7 +228,7 @@ SketchConstraintCoincidence_50 = Sketch_1.setCoincident(SketchLine_20.endPoint() SketchConstraintCoincidence_51 = Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchLine_3.result()) SketchConstraintVertical_5 = Sketch_1.setVertical(SketchLine_20.result()) SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_21.endPoint(), SketchLine_20.result(), 0.03, True) -SketchConstraintAngle_5 = Sketch_1.setAngle(SketchLine_20.result(), SketchLine_21.result(), 170) +SketchConstraintAngle_5 = Sketch_1.setAngle(SketchLine_20.result(), SketchLine_21.result(), 169.9999999984344) SketchConstraintDistance_7 = Sketch_1.setDistance(SketchLine_21.endPoint(), SketchLine_19.result(), 0.045, True) SketchArc_17 = Sketch_1.addArc(2.429999974807022, 2.369762445224826, 1.08, 2.370000000000011, 2.429999974807022, 3.719762440932702, True) SketchArc_17.setName("SketchArc_23") @@ -250,6 +264,15 @@ SketchArc_23.result().setName("SketchArc_26") SketchArc_23.results()[1].setName("SketchArc_26_2") SketchLine_23.setName("SketchLine_24") SketchLine_23.result().setName("SketchLine_24") +SketchArc_22.setName("SketchArc_22") +SketchArc_22.result().setName("SketchArc_22") +SketchArc_22.results()[1].setName("SketchArc_22_2") +SketchArc_21.setName("SketchArc_21") +SketchArc_21.result().setName("SketchArc_21") +SketchArc_21.results()[1].setName("SketchArc_21_2") +SketchArc_20.setName("SketchArc_20") +SketchArc_20.result().setName("SketchArc_20") +SketchArc_20.results()[1].setName("SketchArc_20_2") SketchLine_22.setName("SketchLine_21") SketchLine_22.result().setName("SketchLine_21") SketchConstraintCoincidence_58 = Sketch_1.setCoincident(SketchArc_18.endPoint(), SketchArc_19.startPoint()) @@ -293,7 +316,7 @@ SketchLine_31.result().setName("SketchLine_32") SketchLine_31.setAuxiliary(True) SketchConstraintCoincidence_75 = Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_31.startPoint()) SketchConstraintCoincidence_76 = Sketch_1.setCoincident(SketchLine_31.endPoint(), SketchArc_1.results()[1]) -SketchConstraintAngle_6 = Sketch_1.setAngle(SketchLine_31.result(), SketchLine_3.result(), 59.94) +SketchConstraintAngle_6 = Sketch_1.setAngle(SketchLine_31.result(), SketchLine_3.result(), 59.93999999988066) SketchLine_32 = Sketch_1.addLine(1.871489087529827, 3.334796428456965, 1.871489087529827, 3.598813126524882) SketchLine_32.setName("SketchLine_33") SketchLine_32.result().setName("SketchLine_33") @@ -308,14 +331,14 @@ SketchConstraintCoincidence_80 = Sketch_1.setCoincident(SketchLine_33.endPoint() SketchConstraintCoincidence_81 = Sketch_1.setCoincident(SketchLine_33.startPoint(), SketchLine_32.result()) SketchConstraintVertical_7 = Sketch_1.setVertical(SketchLine_33.result()) model.do() -Extrusion_1_objects = [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2f-SketchArc_1_2r-SketchLine_5f-SketchArc_11_2f-SketchLine_14r-SketchLine_15f-SketchLine_16r-SketchArc_9_2f-SketchArc_15_2r-SketchLine_33f-SketchLine_34r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2r-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_12_2f-SketchArc_13_2f-SketchArc_10_2f-SketchArc_14_2f-SketchArc_16_2r-SketchLine_29f-SketchLine_30r"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_20f-SketchArc_17_2r-SketchLine_21r-SketchArc_20_2r-SketchLine_22r-SketchLine_23r-SketchArc_23_2f-SketchLine_24f-SketchArc_27_2f-SketchLine_25f-SketchLine_33f-SketchLine_34r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_18_2r-SketchArc_19_2r-SketchArc_21_2r-SketchArc_22_2r-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_28_2f-SketchLine_28f-SketchLine_31f"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_17_2r-SketchArc_23_2f-SketchLine_28r-SketchLine_33r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2r-SketchArc_11_2f-SketchLine_29r-SketchLine_33r"), model.selection("FACE", "Sketch_1/Face-SketchArc_9_2f-SketchArc_15_2r-SketchLine_30f-SketchLine_34f"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_20_2r-SketchArc_27_2f-SketchLine_31r-SketchLine_34f")] +Extrusion_1_objects = [model.selection("WIRE", "Sketch_1/Face-SketchLine_5f-SketchArc_1_2r-SketchLine_33f-SketchArc_11_2f-SketchLine_2f-SketchLine_14r-SketchArc_9_2f-SketchLine_34r-SketchArc_15_2r-SketchLine_16r-SketchLine_15f-SketchLine_1r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_16_2r-SketchLine_30r-SketchArc_10_2f-SketchArc_14_2f-SketchArc_13_2f-SketchArc_12_2f-SketchLine_29f-SketchArc_1_2r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchLine_20f-SketchArc_17_2r-SketchLine_33f-SketchArc_23_2f-SketchLine_23r-SketchLine_22r-SketchLine_24f-SketchLine_25f-SketchArc_27_2f-SketchLine_34r-SketchArc_20_2r-SketchLine_21r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchArc_19_2r-SketchArc_22_2r-SketchArc_21_2r-SketchLine_31f-SketchArc_28_2f-SketchArc_26_2f-SketchArc_25_2f-SketchArc_24_2f-SketchLine_28f-SketchArc_18_2r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchLine_28r-SketchArc_23_2f-SketchLine_33r-SketchArc_17_2r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchLine_29r-SketchArc_11_2f-SketchLine_33r-SketchArc_1_2r_wire"), model.selection("FACE", "Sketch_1/Face-SketchArc_9_2f-SketchLine_30f-SketchArc_15_2r-SketchLine_34f"), model.selection("WIRE", "Sketch_1/Face-SketchLine_34f-SketchArc_27_2f-SketchLine_31r-SketchArc_20_2r_wire")] Extrusion_1 = model.addExtrusion(Part_1_doc, Extrusion_1_objects, model.selection(), 0.1785, 0.1785) -Extrusion_2_objects = [model.selection("WIRE", "Sketch_1/Wire-SketchArc_12_2r-SketchArc_13_2r-SketchArc_10_2r-SketchArc_14_2r-SketchArc_18_2f-SketchArc_19_2f-SketchArc_21_2f-SketchArc_22_2f-SketchLine_26f-SketchLine_27r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2r-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_12_2f-SketchArc_13_2f-SketchArc_10_2f-SketchArc_14_2f-SketchArc_16_2r-SketchLine_29f-SketchLine_30r"), model.selection("FACE", "Sketch_1/Face-SketchArc_18_2r-SketchArc_19_2r-SketchArc_21_2r-SketchArc_22_2r-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_28_2f-SketchLine_28f-SketchLine_31f")] -Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), model.selection("FACE", "Extrusion_1_2/From_Face_2"), -0.05, model.selection("FACE", "Extrusion_1_2/From_Face_2"), 0) -Extrusion_3_objects = [model.selection("FACE", "Sketch_1/Face-SketchArc_12_2r-SketchArc_13_2r-SketchArc_10_2r-SketchArc_14_2r-SketchArc_18_2f-SketchArc_19_2f-SketchArc_21_2f-SketchArc_22_2f-SketchLine_26f-SketchLine_27r"), model.selection("FACE", "Sketch_1/Face-SketchArc_18_2r-SketchArc_19_2r-SketchArc_21_2r-SketchArc_22_2r-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_28_2f-SketchLine_28f-SketchLine_31f"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2r-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_12_2f-SketchArc_13_2f-SketchArc_10_2f-SketchArc_14_2f-SketchArc_16_2r-SketchLine_29f-SketchLine_30r")] -Extrusion_3 = model.addExtrusion(Part_1_doc, Extrusion_3_objects, model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face_1"), 0.05, model.selection("FACE", "Extrusion_1_2/To_Face_1"), 0) -Extrusion_4_objects = [model.selection("FACE", "Sketch_1/Face-SketchArc_17_2r-SketchArc_23_2f-SketchLine_28r-SketchLine_33r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2r-SketchArc_11_2f-SketchLine_29r-SketchLine_33r"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_11_2r-SketchArc_17_2f-SketchLine_27f-SketchLine_33r"), model.selection("FACE", "Sketch_1/Face-SketchArc_20_2r-SketchArc_27_2f-SketchLine_31r-SketchLine_34f"), model.selection("FACE", "Sketch_1/Face-SketchArc_9_2r-SketchArc_20_2f-SketchLine_26r-SketchLine_34f"), model.selection("WIRE", "Sketch_1/Wire-SketchArc_9_2f-SketchArc_15_2r-SketchLine_30f-SketchLine_34f")] -Extrusion_4 = model.addExtrusion(Part_1_doc, Extrusion_4_objects, model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face_2"), 0.15, model.selection("FACE", "Extrusion_1_1/To_Face_2"), 0) +Extrusion_2_objects = [model.selection("WIRE", "Sketch_1/Face-SketchArc_13_2r-SketchArc_14_2r-SketchArc_10_2r-SketchLine_26f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_19_2f-SketchArc_18_2f-SketchLine_27r-SketchArc_12_2r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_16_2r-SketchLine_30r-SketchArc_10_2f-SketchArc_14_2f-SketchArc_13_2f-SketchArc_12_2f-SketchLine_29f-SketchArc_1_2r_wire"), model.selection("FACE", "Sketch_1/Face-SketchArc_19_2r-SketchArc_22_2r-SketchArc_21_2r-SketchLine_31f-SketchArc_28_2f-SketchArc_26_2f-SketchArc_25_2f-SketchArc_24_2f-SketchLine_28f-SketchArc_18_2r")] +Extrusion_2 = model.addExtrusion(Part_1_doc, Extrusion_2_objects, model.selection(), model.selection("FACE", "Extrusion_1_2_2/From_Face"), -0.05, model.selection("FACE", "Extrusion_1_2_2/From_Face"), 0) +Extrusion_3_objects = [model.selection("FACE", "Sketch_1/Face-SketchArc_13_2r-SketchArc_14_2r-SketchArc_10_2r-SketchLine_26f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_19_2f-SketchArc_18_2f-SketchLine_27r-SketchArc_12_2r"), model.selection("FACE", "Sketch_1/Face-SketchArc_19_2r-SketchArc_22_2r-SketchArc_21_2r-SketchLine_31f-SketchArc_28_2f-SketchArc_26_2f-SketchArc_25_2f-SketchArc_24_2f-SketchLine_28f-SketchArc_18_2r"), model.selection("WIRE", "Sketch_1/Face-SketchArc_2_2r-SketchArc_3_2r-SketchLine_11f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_16_2r-SketchLine_30r-SketchArc_10_2f-SketchArc_14_2f-SketchArc_13_2f-SketchArc_12_2f-SketchLine_29f-SketchArc_1_2r_wire")] +Extrusion_3 = model.addExtrusion(Part_1_doc, Extrusion_3_objects, model.selection(), model.selection("FACE", "Extrusion_1_1_1/To_Face"), 0.05, model.selection("FACE", "Extrusion_1_2_1/To_Face"), 0) +Extrusion_4_objects = [model.selection("FACE", "Sketch_1/Face-SketchLine_28r-SketchArc_23_2f-SketchLine_33r-SketchArc_17_2r"), model.selection("WIRE", "Sketch_1/Face-SketchLine_29r-SketchArc_11_2f-SketchLine_33r-SketchArc_1_2r_wire"), model.selection("WIRE", "Sketch_1/Face-SketchLine_27f-SketchArc_17_2f-SketchLine_33r-SketchArc_11_2r_wire"), model.selection("FACE", "Sketch_1/Face-SketchLine_34f-SketchArc_27_2f-SketchLine_31r-SketchArc_20_2r"), model.selection("FACE", "Sketch_1/Face-SketchLine_34f-SketchArc_20_2f-SketchLine_26r-SketchArc_9_2r"), model.selection("WIRE", "Sketch_1/Face-SketchArc_9_2f-SketchLine_30f-SketchArc_15_2r-SketchLine_34f_wire")] +Extrusion_4 = model.addExtrusion(Part_1_doc, Extrusion_4_objects, model.selection(), model.selection("FACE", "Extrusion_1_1_2/To_Face"), 0.15, model.selection("FACE", "Extrusion_1_1_2/To_Face"), 0) Extrusion_4.setName("Extrusion_6") Extrusion_4.result().setName("Extrusion_6_1") Extrusion_4.result().subResult(0).setName("Extrusion_6_1_1") @@ -325,8 +348,8 @@ Extrusion_4.results()[1].setName("Extrusion_6_2") Extrusion_4.results()[1].subResult(0).setName("Extrusion_6_2_1") Extrusion_4.results()[1].subResult(1).setName("Extrusion_6_2_2") Extrusion_4.results()[1].subResult(2).setName("Extrusion_6_2_3") -Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "Extrusion_3_1/To_Face_3&Extrusion_3_1/Generated_Face_10&Extrusion_3_1/Generated_Face_11"), model.selection("VERTEX", "Extrusion_6_1/To_Face_1&Extrusion_6_1/Generated_Face_9&Extrusion_6_1/Generated_Face_8")) -Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Extrusion_6_1/Generated_Face_3&Extrusion_6_1/To_Face_3&Extrusion_6_1/Generated_Face_4"), False) +Axis_4 = model.addAxis(Part_1_doc, model.selection("VERTEX", "[Extrusion_3_1_3/To_Face][Extrusion_3_1_3/Generated_Face&Sketch_1/SketchLine_28][Extrusion_3_1_3/Generated_Face&Sketch_1/SketchArc_24_2]"), model.selection("VERTEX", "[Extrusion_6_1_1/To_Face][Extrusion_6_1_1/Generated_Face&Sketch_1/SketchArc_23_2][Extrusion_6_1_1/Generated_Face&Sketch_1/SketchLine_33]")) +Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "[Extrusion_6_1_3/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_6_1_3/To_Face][Extrusion_6_1_3/Generated_Face&Sketch_1/SketchLine_33]"), False) Partition_1_objects = [model.selection("COMPSOLID", "Extrusion_6_1"), model.selection("FACE", "Plane_1"), model.selection("COMPSOLID", "Extrusion_6_2")] Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() diff --git a/src/ModelAPI/Test/Test2685.py b/src/ModelAPI/Test/Test2685.py new file mode 100644 index 000000000..f851694d7 --- /dev/null +++ b/src/ModelAPI/Test/Test2685.py @@ -0,0 +1,66 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +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(22, 5, 10) +SketchCircle_2 = Sketch_1.addCircle(0, 0, 7.5) +SketchCircle_3 = Sketch_1.addCircle(29, -20, 7.5) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin", 1), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchAPI_Point(SketchPoint_1).coordinates()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_1 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_1.result(), 22, True) +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_2 = SketchProjection_3.createdFeature() +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchCircle_1.center(), SketchLine_2.result(), 5, True) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_2.results()[1], 7.5) +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchCircle_3.results()[1], 7.5) +SketchLine_3 = Sketch_1.addLine(22, 5, 22, 41.96787958115183) +SketchLine_3.setAuxiliary(True) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_3.startPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchCircle_3.center(), SketchLine_3.result(), 7, True) +SketchConstraintDistance_4 = Sketch_1.setDistance(SketchCircle_3.center(), SketchLine_2.result(), 20, True) +SketchArc_1 = Sketch_1.addArc(22, 5, 19.39053135678072, 27.42761377547613, 44.57891020979248, 5, True) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchArc_1.center()) +SketchLine_4 = Sketch_1.addLine(22, 5, 85.59353403141361, 5) +SketchLine_4.setAuxiliary(True) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_4.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_4.result()) +SketchLine_5 = Sketch_1.addLine(44.57891020979248, 5, 44.57891020979248, -20) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_5.startPoint()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_5.result(), 25) +model.end() + +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_WEAK)) diff --git a/src/ModelAPI/Test/TestContainerSelector.py b/src/ModelAPI/Test/TestContainerSelector.py new file mode 100644 index 000000000..3f5b59221 --- /dev/null +++ b/src/ModelAPI/Test/TestContainerSelector.py @@ -0,0 +1,36 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +# a wire selection: container of intersections (edges are intesection of faces) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "[[Box_1_1/Left][Box_1_1/Bottom]][[Box_1_1/Front][Box_1_1/Left]][[Box_1_1/Left][Box_1_1/Top]][[Box_1_1/Back][Box_1_1/Left]]")]) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/TestCustomName_BooleanCut.py b/src/ModelAPI/Test/TestCustomName_BooleanCut.py index 5eb24bc40..0d368254f 100644 --- a/src/ModelAPI/Test/TestCustomName_BooleanCut.py +++ b/src/ModelAPI/Test/TestCustomName_BooleanCut.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -45,9 +47,9 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 70) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 50) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 10, 0) Extrusion_1.result().setName("box") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")) SketchLine_5 = Sketch_2.addLine(10, 55, 50, 55) SketchLine_6 = Sketch_2.addLine(50, 55, 50, -5) SketchLine_7 = Sketch_2.addLine(50, -5, 10, -5) @@ -67,12 +69,12 @@ SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchLine SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_8.result(), 60) SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_7.result(), 40) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")], model.selection(), 15, 5) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 15, 5) Extrusion_2.result().setName("tool") -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "box")], [model.selection("SOLID", "tool")]) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "box")], [model.selection("SOLID", "tool")]) model.do() -assert(Boolean_1.result().name() == Extrusion_1.result().name()), "Boolean CUT name '{}' != '{}'".format(Boolean_1.result().name(), Extrusion_1.result().name()) +assert(Cut_1.result().name() == Extrusion_1.result().name()), "Boolean CUT name '{}' != '{}'".format(Cut_1.result().name(), Extrusion_1.result().name()) model.end() diff --git a/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py b/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py index 8e1e7944f..b15ec73dc 100644 --- a/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py +++ b/src/ModelAPI/Test/TestCustomName_CommonCompSolid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -28,30 +30,30 @@ Box_1 = model.addBox(Part_1_doc, 100, 100, 10) Box_1.result().setName("plate") Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "plate/Front"), 50, True) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "plate/Left"), 50, True) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "plate"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")]) -#Partition_1.result().setName("plate") +Partition_1_objects = [model.selection("SOLID", "plate"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) Partition_1.result().subResult(0).setName("Partition_1_1_1") Partition_1.result().subResult(1).setName("top_left") Partition_1.result().subResult(2).setName("bottom_right") Partition_1.result().subResult(3).setName("Partition_1_1_4") -Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Partition_1_1_1/Modified_Face_3_3")) -SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "Partition_1_1_1/Modified_Face_3_3&top_left/Modified_Face_3_1&bottom_right/Modified_Face_3_2"), False) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Partition_1_1_1/Modified_Face&_plate/Top")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Partition_1_1_1/Modified_Face&_plate/Top][Partition_1_1_1/Modified_Face&Plane_2/Plane_2][Partition_1_1_1/Modified_Face&Plane_1/Plane_1]"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchCircle_1 = Sketch_1.addCircle(50, 50, 40) SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 40) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection(), 10, model.selection("FACE", "Partition_1_1_1/Modified_Face_3_4"), 10) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection(), 10, model.selection("FACE", "Partition_1_1_1/Modified_Face&_plate/Bottom"), 10) Extrusion_1.result().setName("cylinder") -Boolean_1 = model.addCommon(Part_1_doc, [model.selection("COMPSOLID", "plate")], [model.selection("SOLID", "cylinder")]) +Common_1 = model.addCommon(Part_1_doc, [model.selection("COMPSOLID", "plate")], [model.selection("SOLID", "cylinder")]) model.do() # check the name of result is kept -CommonResult = Boolean_1.result() +CommonResult = Common_1.result() CommonResultName = CommonResult.name() assert(CommonResultName == Partition_1.result().name()), "Name of Boolean COMMON result '{}' != '{}'".format(CommonResultName, Partition_1.result().name()) # check sub-result names are lost -BooleanName = Boolean_1.name() + "_1" +BooleanName = Common_1.name() + "_1" for i in range(0, CommonResult.numberOfSubs()): refName = BooleanName + '_' + str(i + 1) subResult = CommonResult.subResult(i) diff --git a/src/ModelAPI/Test/TestCustomName_CutCompSolid.py b/src/ModelAPI/Test/TestCustomName_CutCompSolid.py index 7da2b0e44..13760a4f4 100644 --- a/src/ModelAPI/Test/TestCustomName_CutCompSolid.py +++ b/src/ModelAPI/Test/TestCustomName_CutCompSolid.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -26,7 +28,6 @@ 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(80, 0, 0, 0) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) @@ -58,27 +59,26 @@ SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchLine_6.e model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0) Extrusion_1.result().setName("compsolid") - -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "compsolid/Generated_Face_5")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_5")) SketchCircle_1 = Sketch_2.addCircle(65, -30, 10) SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_1.results()[1], 10) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "compsolid/Generated_Face_5&compsolid/Generated_Face_4&compsolid/To_Face_3"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1_3/To_Face]"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintDistanceVertical_3 = Sketch_2.setVerticalDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchCircle_1.center(), 20) SketchConstraintDistanceHorizontal_2 = Sketch_2.setHorizontalDistance(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), 15) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection(), 10, model.selection("FACE", "compsolid/Generated_Face_1"), 10) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")], model.selection(), model.selection(), 10, model.selection("FACE", "Extrusion_1_1_4/Generated_Face&Sketch_1/SketchLine_3"), 10) Extrusion_2.result().setName("cyl") +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3")], [model.selection("SOLID", "cyl")]) -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_3")], [model.selection("SOLID", "cyl")]) model.do() # check the name of Extrusion_1 is kept -CutResult = Boolean_1.result() +CutResult = Cut_1.result() CutResultName = CutResult.name() assert(CutResultName == Extrusion_1.result().name()), "Name of Boolean CUT result '{}' != '{}'".format(CutResultName, Extrusion_1.result().name()) # check sub-result names are lost -BooleanName = Boolean_1.name() + "_1" +BooleanName = Cut_1.name() + "_1" for i in range(0, CutResult.numberOfSubs()): refName = BooleanName + '_' + str(i + 1) subResult = CutResult.subResult(i) diff --git a/src/ModelAPI/Test/TestCustomName_CutGroup.py b/src/ModelAPI/Test/TestCustomName_CutGroup.py index ca2ac6c92..850b6f0f8 100644 --- a/src/ModelAPI/Test/TestCustomName_CutGroup.py +++ b/src/ModelAPI/Test/TestCustomName_CutGroup.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -61,17 +63,17 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_7.result(), 35) SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_5.endPoint(), SketchLine_2.startPoint(), 30) SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_5.endPoint(), SketchLine_2.startPoint(), 15) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 10, 0) Extrusion_1.result().setName("box") -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r")], model.selection(), 20, 20) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 20, 20) Extrusion_2.result().setName("prism") Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0) Extrusion_3.result().setName("cylinder") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "box/From_Face_1")) -SketchLine_8 = Sketch_2.addLine(45, 30, 25, 30) -SketchLine_9 = Sketch_2.addLine(25, 30, 25, -100) -SketchLine_10 = Sketch_2.addLine(25, -100, 45, -100) -SketchLine_11 = Sketch_2.addLine(45, -100, 45, 30) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "box/From_Face")) +SketchLine_8 = Sketch_2.addLine(45, -10, 25, -10) +SketchLine_9 = Sketch_2.addLine(25, -10, 25, -140) +SketchLine_10 = Sketch_2.addLine(25, -140, 45, -140) +SketchLine_11 = Sketch_2.addLine(45, -140, 45, -10) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) @@ -82,21 +84,22 @@ SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_10.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_11.result()) SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_10.result(), 20) SketchConstraintLength_5 = Sketch_2.setLength(SketchLine_9.result(), 130) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "box/Generated_Face_3&box/Generated_Face_2&box/From_Face_1"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[box/Generated_Face&Sketch_1/SketchLine_3][box/Generated_Face&Sketch_1/SketchLine_2][box/From_Face]"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchLine_8.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), 30) SketchConstraintDistanceHorizontal_3 = Sketch_2.setHorizontalDistance(SketchLine_8.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates(), 25) model.do() -Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchLine_11f")], model.selection(), 5, 15) +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f-SketchLine_11f")], model.selection(), 5, 15) Extrusion_4.result().setName("cut_tool") -Boolean_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "box"), model.selection("SOLID", "prism"), model.selection("SOLID", "cylinder")], [model.selection("SOLID", "cut_tool")]) +Cut_1_objects_1 = [model.selection("SOLID", "box"), model.selection("SOLID", "prism"), model.selection("SOLID", "cylinder")] +Cut_1 = model.addCut(Part_1_doc, Cut_1_objects_1, [model.selection("SOLID", "cut_tool")]) model.do() Extrusions = [Extrusion_1, Extrusion_2, Extrusion_3] -BooleanResults = Boolean_1.results() +BooleanResults = Cut_1.results() for i in range(len(BooleanResults)): assert(BooleanResults[i].name() == Extrusions[i].result().name()), "Name of result {} of Boolean CUT '{}' != '{}'".format(i, BooleanResults[i].name(), Extrusions[i].result().name()) - BooleanName = Boolean_1.name() + "_" + str(i + 1) + BooleanName = Cut_1.name() + "_" + str(i + 1) for sub in range(0, BooleanResults[i].numberOfSubs()): refName = BooleanName + '_' + str(sub + 1) subResult = BooleanResults[i].subResult(sub) diff --git a/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py b/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py index e1fa838ce..c9babd78e 100644 --- a/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py +++ b/src/ModelAPI/Test/TestCustomName_ExtrudeFace.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -38,7 +40,8 @@ SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result()) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result()) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_3")] +Face_1 = model.addFace(Part_1_doc, Face_1_objects) Face_1.result().setName("triangle") Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "triangle")], model.selection(), 10, 0) model.do() diff --git a/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py b/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py index 9d083212a..bb15cbb73 100644 --- a/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py +++ b/src/ModelAPI/Test/TestCustomName_ExtrusionCut.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -43,15 +45,15 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 50) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 20, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 20, 0) Extrusion_1.result().setName("plate") ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 0, 10, [model.selection("SOLID", "plate")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "plate/To_Face_1")) -SketchCircle_1 = Sketch_2.addCircle(30, 35, 10) -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "plate/Generated_Face_4&plate/To_Face_1"), False) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "plate/To_Face")) +SketchCircle_1 = Sketch_2.addCircle(30.00000000000001, 15, 10) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "[plate/Generated_Face&Sketch_1/SketchLine_4][plate/To_Face]"), False) SketchLine_5 = SketchProjection_2.createdFeature() SketchConstraintDistance_1 = Sketch_2.setDistance(SketchCircle_1.center(), SketchLine_5.result(), 20, True) -SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "plate/Generated_Face_1&plate/To_Face_1"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "[plate/Generated_Face&Sketch_1/SketchLine_1][plate/To_Face]"), False) SketchLine_6 = SketchProjection_3.createdFeature() SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_1.center(), SketchLine_6.result(), 15, True) SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_1.results()[1], 10) diff --git a/src/ModelAPI/Test/TestCustomName_ExtrusionCutFace.py b/src/ModelAPI/Test/TestCustomName_ExtrusionCutFace.py index b20f90afb..1b22fcb45 100644 --- a/src/ModelAPI/Test/TestCustomName_ExtrusionCutFace.py +++ b/src/ModelAPI/Test/TestCustomName_ExtrusionCutFace.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -29,7 +31,7 @@ Box_1.result().setName("box") Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "box/Front")) SketchCircle_1 = Sketch_1.addCircle(7, 6, 2) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Face_1.result().setName("circle") ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "circle")], model.selection(), 0, 3, [model.selection("SOLID", "box")]) model.do() diff --git a/src/ModelAPI/Test/TestCustomName_MultiTranslation.py b/src/ModelAPI/Test/TestCustomName_MultiTranslation.py index 6e008eee7..a7e817cde 100644 --- a/src/ModelAPI/Test/TestCustomName_MultiTranslation.py +++ b/src/ModelAPI/Test/TestCustomName_MultiTranslation.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model from ModelAPI import * @@ -29,15 +31,15 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) Cylinder_1.result().setName("cylinder") -MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "cylinder/Face_1"), 10, NB_COPIES) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "([cylinder/Face_1][cylinder/Face_2])([cylinder/Face_1][cylinder/Face_3])"), 10, NB_COPIES) model.do() -TransResult = MultiTranslation_1.result() +TransResult = LinearCopy_1.result() TransResultName = TransResult.name() assert(TransResultName == Cylinder_1.result().name()), "MultiTranslation name '{}' != '{}'".format(TransResultName, Cylinder_1.result().name()) # check sub-result names assert(NB_COPIES == TransResult.numberOfSubs()), "Number of results {} is not equal to reference {}".format(TransResult.numberOfSubs(), NB_COPIES) -MultiTranslationName = MultiTranslation_1.name() + "_1" +MultiTranslationName = LinearCopy_1.name() + "_1" for i in range(0, NB_COPIES): refName = MultiTranslationName + '_' + str(i + 1) subResult = TransResult.subResult(i) diff --git a/src/ModelAPI/Test/TestCustomName_Placement.py b/src/ModelAPI/Test/TestCustomName_Placement.py index ad2043f7f..808123790 100644 --- a/src/ModelAPI/Test/TestCustomName_Placement.py +++ b/src/ModelAPI/Test/TestCustomName_Placement.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -33,7 +35,7 @@ SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_2.result(), SketchLine_3.result()) -SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_3.result(), 30) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_3.result(), 30.00000000000014) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 60) SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_4 = SketchProjection_1.createdFeature() @@ -42,11 +44,11 @@ SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_4.result(), SketchConst [SketchLine_5, SketchLine_6, SketchLine_7] = SketchConstraintMirror_1.mirrored() SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_4.result(), 30, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 20, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f")], model.selection(), 20, 0) Extrusion_1.result().setName("prism") -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_7r-SketchLine_5r")], model.selection("EDGE", "Sketch_1/SketchLine_6"), 360, 0) Revolution_1.result().setName("spinner") -Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "spinner")], model.selection("VERTEX", "spinner/Lateral_6&spinner/Base_Edge_10"), model.selection("FACE", "prism/Generated_Face_2"), False, True) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "spinner")], model.selection("VERTEX", "[spinner/Generated_Face&Sketch_1/SketchLine_7][spinner/Generated_Face&Sketch_1/SketchLine_5]"), model.selection("FACE", "prism/Generated_Face&Sketch_1/SketchLine_2"), False, True) model.do() assert(Placement_1.result().name() == Revolution_1.result().name()), "Placement name '{}' != '{}'".format(Placement_1.result().name(), Revolution_1.result().name()) diff --git a/src/ModelAPI/Test/TestCustomName_RotateGroup.py b/src/ModelAPI/Test/TestCustomName_RotateGroup.py index cb3678672..949be3feb 100644 --- a/src/ModelAPI/Test/TestCustomName_RotateGroup.py +++ b/src/ModelAPI/Test/TestCustomName_RotateGroup.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -41,7 +43,7 @@ SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint()) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5) SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_1.endPoint(), 8, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_2_2f")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchArc_2_2f")], model.selection(), 10, 0) Extrusion_1.result().setName("prism") Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "prism"), model.selection("SOLID", "cylinder")], model.selection("EDGE", "PartSet/OX"), 30) model.do() diff --git a/src/ModelAPI/Test/TestCustomName_Translation.py b/src/ModelAPI/Test/TestCustomName_Translation.py index bad08c5e7..3a8cb09d7 100644 --- a/src/ModelAPI/Test/TestCustomName_Translation.py +++ b/src/ModelAPI/Test/TestCustomName_Translation.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from salome.shaper import model model.begin() @@ -26,7 +28,7 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) Cylinder_1.result().setName("cylinder") -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "cylinder/Face_1"), 20) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "cylinder")], model.selection("EDGE", "([cylinder/Face_1][cylinder/Face_2])([cylinder/Face_1][cylinder/Face_3])"), 20) model.do() assert(Translation_1.result().name() == Cylinder_1.result().name()), "Translation name '{}' != '{}'".format(Translation_1.result().name(), Cylinder_1.result().name()) diff --git a/src/ModelAPI/Test/TestFeatureSelection_2.py b/src/ModelAPI/Test/TestFeatureSelection_2.py index 3e8b58b4e..f4c21551e 100644 --- a/src/ModelAPI/Test/TestFeatureSelection_2.py +++ b/src/ModelAPI/Test/TestFeatureSelection_2.py @@ -50,7 +50,7 @@ SketchLine_2 = SketchProjection_2.createdFeature() SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_2.result(), SketchCircle_4.center(), 5, True) SketchConstraintDistanceHorizontal_1 = Sketch_2.setHorizontalDistance(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_4.center(), 25) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) Cut_1 = model.addCut(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], [model.selection("COMPOUND", "all-in-Revolution_1")]) model.do() diff --git a/src/ModelAPI/Test/TestFolder_CustomName.py b/src/ModelAPI/Test/TestFolder_CustomName.py index 3806afedd..81386cd03 100644 --- a/src/ModelAPI/Test/TestFolder_CustomName.py +++ b/src/ModelAPI/Test/TestFolder_CustomName.py @@ -18,7 +18,7 @@ ## email : webmaster.salome@opencascade.com ## -__updated__ = "2018-01-16" +# -*- coding: utf-8 -*- from salome.shaper import model @@ -43,8 +43,8 @@ SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchL SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result()) SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0) -Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1")], 2) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0) +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]")], 2) model.do() Folder_1 = model.addFolder(Part_1_doc, Sketch_1, Extrusion_1) diff --git a/src/ModelAPI/Test/TestGeomNamingBoxWithFillet.py b/src/ModelAPI/Test/TestGeomNamingBoxWithFillet.py new file mode 100644 index 000000000..515732d8e --- /dev/null +++ b/src/ModelAPI/Test/TestGeomNamingBoxWithFillet.py @@ -0,0 +1,91 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +param_p = model.addParameter(Part_1_doc, "p", "5") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(0, 0, 0, 30.0000000000845) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_2 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result()) +SketchLine_3 = Sketch_1.addLine(0, 30.0000000000845, 30.00000000002328, 30.00000000002326) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(30.00000000002328, 30.00000000002326, 29.99999999996195, 0) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_5 = SketchProjection_3.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.result()) +SketchLine_6 = Sketch_1.addLine(29.99999999996195, 0, 0, 0) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 30) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 30) +SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_4.result(), SketchLine_3.result()) +SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_4.result(), SketchLine_1.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection(), 30, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_4r-SketchLine_3r-SketchLine_1r")) +SketchLine_7 = Sketch_2.addLine(20, 7, 10, 7) +SketchLine_8 = Sketch_2.addLine(10, 7, 10, 0) +SketchLine_9 = Sketch_2.addLine(10, 0, 20, 0) +SketchLine_10 = Sketch_2.addLine(20, 0, 20, 7) +SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_7.startPoint()) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_7.result()) +SketchConstraintVertical_1 = Sketch_2.setVertical(SketchLine_8.result()) +SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_9.result()) +SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_10.result()) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_6"), False) +SketchLine_11 = SketchProjection_4.createdFeature() +SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_11.result()) +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_11).endPoint(), SketchLine_8.endPoint(), 10, True) +SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_9.result(), 10) +SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_8.result(), 7) +model.do() +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_7r-SketchLine_8f-SketchLine_9f-SketchLine_10f_wire")], model.selection(), "p", 0, [model.selection("SOLID", "Extrusion_1_1")]) +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_6][Extrusion_1_1/To_Face]")], 3) +model.do() +# increase the extrusion-cut heigh to make face of a box divided into two +param_p.setValue(30); +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Fillet_1.feature())) +model.do() +# set the value back and check again +param_p.setValue(5); +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Fillet_1.feature())) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/TestGeomNamingEdgeByFilter.py b/src/ModelAPI/Test/TestGeomNamingEdgeByFilter.py new file mode 100644 index 000000000..a97c9cd77 --- /dev/null +++ b/src/ModelAPI/Test/TestGeomNamingEdgeByFilter.py @@ -0,0 +1,50 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 15, 15, 15) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), 5, True) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Bottom"), 10, True) +Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), 5, True) +Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Back"), 10, True) +Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), 5, True) +Plane_9 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Left"), 10, True) +Partition_1_objects = [model.selection("SOLID", "Box_1_1"), model.selection("FACE", "Plane_1"), model.selection("FACE", "Plane_2"), model.selection("FACE", "Plane_5"), model.selection("FACE", "Plane_6"), model.selection("FACE", "Plane_3"), model.selection("FACE", "Plane_4")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) +Box_2 = model.addBox(Part_1_doc, 2, 2, 10) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("FACE", "Box_2_1/Bottom"), model.selection("FACE", "_weak_name_4_Partition_1_1_14"), False, True) +model.do() +# update the selection of the placement +Placement_1.setEndShape(model.selection("EDGE", "Partition_1_1_5/Generated_Edge&Plane_3/Plane_3&Plane_2/Plane_2")) +model.end() + +# check that placement is valid +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Placement_1.feature())) + +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/src/ModelAPI/Test/TestGeomNamingPlacement.py b/src/ModelAPI/Test/TestGeomNamingPlacement.py new file mode 100644 index 000000000..254bf50ad --- /dev/null +++ b/src/ModelAPI/Test/TestGeomNamingPlacement.py @@ -0,0 +1,89 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +param = model.addParameter(Part_1_doc, "p", "60") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) +SketchLine_1 = Sketch_1.addLine(30, 30, -20, 30) +SketchLine_2 = Sketch_1.addLine(-20, 30, -20, -20) +SketchLine_3 = Sketch_1.addLine(-20, -20, 30, -20) +SketchLine_4 = Sketch_1.addLine(30, -20, 30, 30) +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()) +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_1.startPoint(), SketchLine_2.startPoint(), 50) +SketchConstraintDistanceVertical_1 = Sketch_1.setVerticalDistance(SketchLine_4.endPoint(), SketchLine_3.endPoint(), 50) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintDistanceHorizontal_2 = Sketch_1.setHorizontalDistance(SketchLine_2.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates(), 20) +SketchConstraintDistanceVertical_2 = Sketch_1.setVerticalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.endPoint(), 20) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchLine_5 = Sketch_2.addLine(19.58333333333334, 17.27351642784226, -0.4166666666666646, 17.27351642784226) +SketchLine_6 = Sketch_2.addLine(-0.4166666666666646, 17.27351642784226, -0.4166666666794808, -42.72648357216971) +SketchLine_7 = Sketch_2.addLine(-0.4166666666794808, -42.72648357216971, 19.58333333332052, -42.72648357216971) +SketchLine_8 = Sketch_2.addLine(19.58333333332052, -42.72648357216971, 19.58333333333334, 17.27351642784226) +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()) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_7.startPoint(), 30, True) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), False) +SketchPoint_3 = SketchProjection_3.createdFeature() +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_7.endPoint(), 25, True) +SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_7.result(), 20) +SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_8.result(), "p") +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), -5, -2) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) +Box_1 = model.addBox(Part_1_doc, 50, 50, 30) +Placement_1 = model.addPlacement(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("FACE", "Box_1_1/Left"), model.selection("FACE", "Cut_1_1/Modified_Face&Extrusion_1_1/To_Face"), False, True) +model.do() +# change parameter to split extrusion top face to two +param.setValue(100) +model.end() + +# check that placement is valid +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Placement_1.feature())) + +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/src/ModelAPI/Test/TestGeomNamingRevolution.py b/src/ModelAPI/Test/TestGeomNamingRevolution.py new file mode 100644 index 000000000..7f2e9357a --- /dev/null +++ b/src/ModelAPI/Test/TestGeomNamingRevolution.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 +## + +# -*- coding: utf-8 -*- + +from SketchAPI import * + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +param = model.addParameter(Part_1_doc, "p", "10") +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) +SketchLine_1 = Sketch_1.addLine(6.82842712474619, 7.171572875253809, 2.82842712474619, 7.171572875253809) +SketchLine_2 = Sketch_1.addLine(2.82842712474619, 7.171572875253809, 2.82842712474619, 3.171572875253809) +SketchLine_3 = Sketch_1.addLine(2.82842712474619, 3.171572875253809, 6.82842712474619, 3.171572875253809) +SketchLine_4 = Sketch_1.addLine(6.82842712474619, 3.171572875253809, 6.82842712474619, 7.171572875253809) +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()) +SketchCircle_1 = Sketch_1.addCircle(4.440892098500626e-16, 0, 1) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 4) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 4) +SketchLine_5 = Sketch_1.addLine(0, 10, 10, 0) +SketchLine_5.setAuxiliary(True) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchPoint_1.result()) +SketchProjection_2 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]"), False) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchPoint_2.result()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.result(), SketchLine_2.startPoint()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_5.startPoint(), 4, True) +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), False) +SketchLine_6 = SketchProjection_3.createdFeature() +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.result(), SketchCircle_1.center()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 1) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_6).endPoint(), SketchCircle_1.center(), "p", True) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 1, 1) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("SOLID", "Extrusion_1_1")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f_wire")], model.selection("EDGE", "[Cut_1_1/Modified_Face&Box_1_1/Left][Cut_1_1/Modified_Face&Box_1_1/Top]"), 45, 0) +model.do() +# relocate circle to split the edge - axis of revolution +param.setValue(5) +model.end() + +# check that revolution is valid +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Revolution_1.feature())) + +assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/src/ModelAPI/Test/TestGeomNamingSketchPlane.py b/src/ModelAPI/Test/TestGeomNamingSketchPlane.py new file mode 100644 index 000000000..57cb642a6 --- /dev/null +++ b/src/ModelAPI/Test/TestGeomNamingSketchPlane.py @@ -0,0 +1,107 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +lenParam = model.addParameter(Part_1_doc, "len", "500") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-302.4220649391276, 58.25973730731688, -52.42206493912754, 58.25973730731688) +SketchLine_2 = Sketch_1.addLine(-52.42206493912754, 58.25973730731688, -52.42206493912754, -61.38418346467283) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(-52.42206493912754, -61.38418346467283, 147.5779350608725, -61.38418346467283) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(147.5779350608725, -61.38418346467283, 147.5779350608725, 58.25973730731685) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(147.5779350608725, 58.25973730731685, 297.5779350608724, 58.25973730731685) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(297.5779350608724, 58.25973730731685, 297.5779350608724, -192.2459441196271) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchLine_7 = Sketch_1.addLine(297.5779350608724, -192.2459441196271, -302.4220649391276, -192.2459441196271) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchLine_8 = Sketch_1.addLine(-302.4220649391276, -192.2459441196271, -302.4220649391276, 58.25973730731688) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.endPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_7.result()) +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_8.result()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_4.result()) +SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_6.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), 600) +SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_1.result()) +SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 250) +SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 200) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 600, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")) +SketchLine_9 = Sketch_2.addLine(236.9930310780426, -200, -144.601680073095, -200) +SketchLine_10 = Sketch_2.addLine(-144.601680073095, -200, -144.601680073095, -500) +SketchLine_11 = Sketch_2.addLine(-144.601680073095, -500, 236.9930310780426, -500) +SketchLine_12 = Sketch_2.addLine(236.9930310780426, -500, 236.9930310780426, -200) +SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) +SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_9.result()) +SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_10.result()) +SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result()) +SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result()) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) +SketchLine_13 = SketchProjection_1.createdFeature() +SketchConstraintDistance_1 = Sketch_2.setDistance(SketchLine_13.result(), SketchLine_9.endPoint(), 200, True) +SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_10.endPoint(), SketchLine_13.result(), "len", True) +model.do() +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1")) +SketchCircle_1 = Sketch_3.addCircle(27.57793506087247, -80, 42.03963933117138) +SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1]"), False) +SketchProjection_2.setName("SketchProjection_3") +SketchProjection_2.result().setName("SketchProjection_3") +SketchLine_14 = SketchProjection_2.createdFeature() +SketchLine_14.setName("SketchLine_15") +SketchLine_14.result().setName("SketchLine_15") +SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_14.result(), SketchCircle_1.center(), 80, True) +SketchConstraintDistance_4.setName("SketchConstraintDistance_4") +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/From_Face)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_9)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1]"), False) +SketchProjection_3.setName("SketchProjection_4") +SketchProjection_3.result().setName("SketchProjection_4") +SketchLine_15 = SketchProjection_3.createdFeature() +SketchLine_15.setName("SketchLine_16") +SketchLine_15.result().setName("SketchLine_16") +SketchConstraintDistance_3 = Sketch_3.setDistance(SketchLine_15.result(), SketchCircle_1.center(), 80, True) +SketchConstraintDistance_3.setName("SketchConstraintDistance_3") +model.do() +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchCircle_1_2r_wire")], model.selection(), model.selection(), 0, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_7"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +model.do() +# update the sketch 2 to make split of a size of a box +lenParam.setValue(700) +model.end() + +# check that sketch_3 and extrusion are updated well +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(ExtrusionCut_2.feature())) diff --git a/src/ModelAPI/Test/TestSaveOpen.py b/src/ModelAPI/Test/TestSaveOpen.py new file mode 100644 index 000000000..5bc57a292 --- /dev/null +++ b/src/ModelAPI/Test/TestSaveOpen.py @@ -0,0 +1,50 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from ModelAPI import * + +model.begin() +partSet = model.moduleDocument() +Point_2 = model.addPoint(partSet, 1, 2, 3) +Point_name = Point_2.name() +model.end() + +# check save document in a current folder +aSession = ModelAPI_Session.get() +aFiles = StringList() +aSession.save(".", aFiles) +assert(len(aFiles) == 1) + +# check open of the same document +assert(aSession.load(".") == False) # error because this document is already opened + +# close the current document +aSession.closeAll() + +# open again: it must be correct now +assert(aSession.load(".")) + +# check the created point is opened +partSet = model.moduleDocument() +assert(partSet.size("Features") == 1) +assert(partSet.object("Features", 0).data().name() == Point_name) diff --git a/src/ModelAPI/Test/TestSelectionScope.py b/src/ModelAPI/Test/TestSelectionScope.py index 62e1e96de..f8a754dc8 100644 --- a/src/ModelAPI/Test/TestSelectionScope.py +++ b/src/ModelAPI/Test/TestSelectionScope.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from GeomAPI import * from salome.shaper import model @@ -41,7 +43,7 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0) ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 5, 5, [model.selection("SOLID", "Extrusion_1_1")]) Sketch_2_origin = GeomAPI_Pnt(0, -10, 0) Sketch_2_norm = GeomAPI_Dir(0, -1, 0) @@ -60,20 +62,20 @@ SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_6.result()) SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_7.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_8.result()) SketchConstraintLength_1 = Sketch_2.setLength(SketchLine_8.result(), "len") -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]"), False) SketchLine_9 = SketchProjection_1.createdFeature() SketchConstraintDistance_1 = Sketch_2.setDistance(SketchLine_5.startPoint(), SketchLine_9.result(), 20, True) ExtrusionCut_1.setNestedSketch(Sketch_2) -Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_1"), model.selection("EDGE", "PartSet/OZ"), 5, 10) -Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_2&Extrusion_1_1/Generated_Face_3&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4]"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "PartSet/OZ"), 5, 10) model.do() # make sketch_2 cut the whole top face of the initial extrusion, so, one of the cylinder becomes invalid lenParam.setValue(100) Part_1_doc.setCurrentFeature(Cylinder_2.feature(), True) model.do() # update selection of cylinder base points -model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_3&Extrusion_1_1/Generated_Face_3&ExtrusionCut_1_1/Modfied_1").fillAttribute(Cylinder_1.basePoint()) -model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_divided_1_1&Extrusion_1_1/Generated_Face_1").fillAttribute(Cylinder_2.basePoint()) +model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)]").fillAttribute(Cylinder_1.basePoint()) +model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face&weak_name_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4]").fillAttribute(Cylinder_2.basePoint()) model.end() # check that both cylinders are valid and have correct results diff --git a/src/ModelAPI/Test/TestSelectorShell.py b/src/ModelAPI/Test/TestSelectorShell.py new file mode 100644 index 000000000..3038845d7 --- /dev/null +++ b/src/ModelAPI/Test/TestSelectorShell.py @@ -0,0 +1,44 @@ +## 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 +## + +# -*- coding: utf-8 -*- + +from salome.shaper import model +from GeomAPI import * + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +model.do() +# select a shell of a box : this test checks selection of a shell +aBoxResult = Box_1.feature().results()[0] +aShell = GeomAPI_ShapeExplorer(aBoxResult.shape(), GeomAPI_Shape.SHELL) +aGroup = Part_1_doc.addFeature("Group") +aGroup.selectionList("group_list").append(aBoxResult, aShell.current()) +model.end() + +# check that the resulting group is correct +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(aGroup)) + +assert(model.checkPythonDump()) diff --git a/src/ModelAPI/Test/TestWeakNaming2125.py b/src/ModelAPI/Test/TestWeakNaming2125.py index e9ec85ba5..dadd65fa3 100644 --- a/src/ModelAPI/Test/TestWeakNaming2125.py +++ b/src/ModelAPI/Test/TestWeakNaming2125.py @@ -34,9 +34,9 @@ SketchCircle_2 = Sketch_1.addCircle(0, 0, 103.3027146966417) SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchCircle_2.center()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_2_2r")], model.selection(), 410, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchCircle_3 = Sketch_2.addCircle(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1")) -SketchCircle_4 = Sketch_2.addCircle(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchCircle_3 = Sketch_2.addCircle(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_2_2][Extrusion_1_1/To_Face]")) +SketchCircle_4 = Sketch_2.addCircle(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_1_2][Extrusion_1_1/To_Face]")) SketchArc_1 = Sketch_2.addArc(-76.31943784014528, 69.61892179185162, 22.73963059863011, 100.7688447087372, -98.26117835861398, -31.87776170424145, False) SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchCircle_3.results()[1], SketchArc_1.startPoint()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchCircle_3.results()[1], SketchArc_1.endPoint()) @@ -48,13 +48,15 @@ SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchArc_1.startPoint(), SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchArc_1.results()[1], SketchArc_2.endPoint()) model.do() ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2f-SketchArc_2_2r")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_2_2r"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_1")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face")) SketchLine_1 = Sketch_3.addLine(72.49453964599654, -117.643151959956, 76.08424302289386, 111.5797586569786) SketchArc_3 = Sketch_3.addArc(23.82028040531734, -147.9761102212422, 72.49453964599654, -117.643151959956, 29.20403695178628, -205.0750334594096, False) SketchConstraintCoincidence_9 = Sketch_3.setCoincident(SketchLine_1.startPoint(), SketchArc_3.startPoint()) -SketchProjection_1 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1", 13), False) +SketchProjection_1 = Sketch_3.addProjection(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchCircle_1_2&weak_name_2]"), False) SketchArc_4 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1]) +model.do() +model.do() model.end() from ModelAPI import * diff --git a/src/ModelAPI/Test/TestWeakNaming2222.py b/src/ModelAPI/Test/TestWeakNaming2222.py index 1aa708b3f..9d76f132e 100644 --- a/src/ModelAPI/Test/TestWeakNaming2222.py +++ b/src/ModelAPI/Test/TestWeakNaming2222.py @@ -61,15 +61,15 @@ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "ep_base") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 3.65) SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 4.65) SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_4.result(), 1.65) -SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_7.startPoint(), SketchLine_3.result(), "ep_base") +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_7.startPoint(), SketchLine_3.result(), "ep_base", False) SketchLine_9 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX")) -SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_9.result(), "0.275+ep_voiles/2") +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_9.result(), "0.275+ep_voiles/2", False) SketchLine_10 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OY")) -SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_10.result(), "0.325+ep_voiles/2") +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_10.result(), "0.325+ep_voiles/2", False) SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_5.result(), SketchLine_1.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 0, 0.3) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 0, 0.3) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face")) SketchLine_11 = Sketch_2.addLine(2.26, -2.31, 1.64, -2.31) SketchLine_12 = Sketch_2.addLine(1.64, -2.31, 1.64, -1.69) SketchLine_13 = Sketch_2.addLine(1.64, -1.69, 2.26, -1.69) @@ -86,21 +86,21 @@ SketchPoint_1 = Sketch_2.addPoint(1.925, -1.875) SketchConstraintLength_5 = Sketch_2.setLength(SketchLine_11.result(), 0.62) SketchConstraintLength_5.setName("SketchConstraintLength_10") SketchConstraintEqual_2 = Sketch_2.setEqual(SketchLine_11.result(), SketchLine_12.result()) -SketchConstraintDistance_4 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_13.result(), "0.11+ep_poteau/2") +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_13.result(), "0.11+ep_poteau/2", False) SketchConstraintDistance_4.setName("SketchConstraintDistance_6") -SketchConstraintDistance_5 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_12.result(), "0.21+ep_poteau/2") +SketchConstraintDistance_5 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_12.result(), "0.21+ep_poteau/2", False) SketchConstraintDistance_5.setName("SketchConstraintDistance_7") -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) SketchLine_15 = SketchProjection_1.createdFeature() -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY")) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) SketchLine_16 = SketchProjection_2.createdFeature() -SketchConstraintDistance_6 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_15.result(), "1.75+ep_poteau/2+ep_voiles/2") +SketchConstraintDistance_6 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_15.result(), "1.75+ep_poteau/2+ep_voiles/2", False) SketchConstraintDistance_6.setName("SketchConstraintDistance_8") -SketchConstraintDistance_7 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_16.result(), "1.8+ep_poteau/2+ep_voiles/2") +SketchConstraintDistance_7 = Sketch_2.setDistance(SketchPoint_1.coordinates(), SketchLine_16.result(), "1.8+ep_poteau/2+ep_voiles/2", False) SketchConstraintDistance_7.setName("SketchConstraintDistance_9") model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11r-SketchLine_12r-SketchLine_13r-SketchLine_14r")], model.selection(), 0, 0.02) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_14r-SketchLine_13r-SketchLine_12r-SketchLine_11r")], model.selection(), 0, 0.02) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")) SketchLine_17 = Sketch_3.addLine(0, 2.950000000000001, 0, 1.700000000000001) SketchLine_17.setName("SketchLine_15") SketchLine_17.result().setName("SketchLine_15") @@ -120,24 +120,22 @@ SketchLine_20.result().setName("SketchLine_18") SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OX")) SketchLine_21.setName("SketchLine_19") SketchLine_21.result().setName("SketchLine_19") -#SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_21.result()) -#SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_20.endPoint(), SketchLine_21.result()) SketchLine_22 = Sketch_3.addLine(2.525000000000001, 0, 3.975000000000001, 0) SketchLine_22.setName("SketchLine_20") SketchLine_22.result().setName("SketchLine_20") -SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_22.startPoint(), SketchLine_21.result()) -SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_21.result()) +SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_22.startPoint(), SketchLine_21.result()) +SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_21.result()) SketchLine_23 = Sketch_3.addLine(3.975000000000001, 0, 3.975000000000001, 0.95) SketchLine_23.setName("SketchLine_21") SketchLine_23.result().setName("SketchLine_21") -SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) -SketchLine_24 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1")) +SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) +SketchLine_24 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/To_Face]")) SketchLine_24.setName("SketchLine_22") SketchLine_24.result().setName("SketchLine_22") SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_17.result(), 1.25) SketchConstraintLength_6.setName("SketchConstraintLength_5") -SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchLine_18.startPoint()) -SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_19.endPoint()) +SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchLine_18.startPoint()) +SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_20.startPoint(), SketchLine_19.endPoint()) SketchConstraintLength_7 = Sketch_3.setLength(SketchLine_19.result(), "1.25-ep_voiles/2") SketchConstraintLength_7.setName("SketchConstraintLength_6") SketchConstraintLength_8 = Sketch_3.setLength(SketchLine_20.result(), "1-ep_voiles/2") @@ -145,99 +143,108 @@ SketchConstraintLength_8.setName("SketchConstraintLength_7") SketchConstraintLength_9 = Sketch_3.setLength(SketchLine_22.result(), "1.5-ep_voiles/2") SketchConstraintLength_9.setName("SketchConstraintLength_8") SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_23.result()) -SketchLine_25 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")) +SketchLine_25 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/SketchLine_4")) SketchLine_25.setName("SketchLine_23") SketchLine_25.result().setName("SketchLine_23") -SketchConstraintDistance_8 = Sketch_3.setDistance(SketchLine_22.endPoint(), SketchLine_25.result(), "0.25+ep_voiles/2") +SketchConstraintDistance_8 = Sketch_3.setDistance(SketchLine_22.endPoint(), SketchLine_25.result(), "0.25+ep_voiles/2", False) SketchConstraintDistance_8.setName("SketchConstraintDistance_5") SketchConstraintLength_10 = Sketch_3.setLength(SketchLine_23.result(), "1-ep_voiles/2") SketchConstraintLength_10.setName("SketchConstraintLength_9") -SketchLine_26 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/To_Face_1")) +SketchLine_26 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]")) SketchLine_26.setName("SketchLine_35") SketchLine_26.result().setName("SketchLine_35") -SketchConstraintDistance_9 = Sketch_3.setDistance(SketchLine_17.startPoint(), SketchLine_26.result(), 0.375) +SketchConstraintDistance_9 = Sketch_3.setDistance(SketchLine_17.startPoint(), SketchLine_26.result(), 0.375, False) SketchConstraintDistance_9.setName("SketchConstraintDistance_12") model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_15"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_17"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_18"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_20"), model.selection("EDGE", "Sketch_3/Edge-SketchLine_21")]) -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4"), model.selection("EDGE", "Edge_1_5")], model.selection("EDGE", "PartSet/OZ"), "h_ouverture", 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_3_1/Generated_Edge_2&Extrusion_3_1/To_Edge_1"), model.selection("VERTEX", "Extrusion_3_3/Generated_Edge_2&Extrusion_3_3/To_Edge_1"), model.selection("VERTEX", "Extrusion_3_4/Generated_Edge_1&Extrusion_3_4/To_Edge_1")) +Edge_1_objects = [model.selection("EDGE", "Sketch_3/SketchLine_15"), model.selection("EDGE", "Sketch_3/SketchLine_17"), model.selection("EDGE", "Sketch_3/SketchLine_18"), model.selection("EDGE", "Sketch_3/SketchLine_20"), model.selection("EDGE", "Sketch_3/SketchLine_21")] +Edge_1 = model.addEdge(Part_1_doc, Edge_1_objects) +Extrusion_3_objects = [model.selection("EDGE", "Edge_1_1"), model.selection("EDGE", "Edge_1_2"), model.selection("EDGE", "Edge_1_3"), model.selection("EDGE", "Edge_1_4"), model.selection("EDGE", "Edge_1_5")] +Extrusion_3 = model.addExtrusion(Part_1_doc, Extrusion_3_objects, model.selection("EDGE", "PartSet/OZ"), "h_ouverture", 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_3_1/Generated_Edge&Sketch_3/SketchLine_15_StartVertex]e[Extrusion_3_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_3_3/Generated_Edge&Sketch_3/SketchLine_18_StartVertex]e[Extrusion_3_3/To_Edge]e"), model.selection("VERTEX", "[Extrusion_3_4/Generated_Edge&Sketch_3/SketchLine_20_EndVertex]e[Extrusion_3_4/To_Edge]e")) Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_27 = Sketch_4.addLine(0, 2.950000000000001, 0, 0) SketchLine_27.setName("SketchLine_26") SketchLine_27.result().setName("SketchLine_26") -SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "Extrusion_3_1/Generated_Edge_2&Extrusion_3_1/To_Edge_1")) -SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchLine_27.startPoint(), SketchPoint_2.result()) -SketchPoint_3 = Sketch_4.addPoint(model.selection("VERTEX", "Extrusion_3_3/Generated_Edge_2&Extrusion_3_3/To_Edge_1")) -SketchConstraintCoincidence_25 = Sketch_4.setCoincident(SketchLine_27.endPoint(), SketchPoint_3.result()) +SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "[Extrusion_3_1/Generated_Edge&Sketch_3/SketchLine_15_StartVertex]e[Extrusion_3_1/To_Edge]e")) +SketchConstraintCoincidence_22 = Sketch_4.setCoincident(SketchLine_27.startPoint(), SketchPoint_2.result()) +SketchPoint_3 = Sketch_4.addPoint(model.selection("VERTEX", "[Extrusion_3_3/Generated_Edge&Sketch_3/SketchLine_18_StartVertex]e[Extrusion_3_3/To_Edge]e")) +SketchConstraintCoincidence_23 = Sketch_4.setCoincident(SketchLine_27.endPoint(), SketchPoint_3.result()) SketchLine_28 = Sketch_4.addLine(0, 0, 3.975000000000001, 0) SketchLine_28.setName("SketchLine_27") SketchLine_28.result().setName("SketchLine_27") -SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchLine_27.endPoint(), SketchLine_28.startPoint()) -SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "Extrusion_3_4/Generated_Edge_1&Extrusion_3_4/To_Edge_1")) -SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchLine_28.endPoint(), SketchPoint_4.result()) +SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchLine_27.endPoint(), SketchLine_28.startPoint()) +SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "[Extrusion_3_4/Generated_Edge&Sketch_3/SketchLine_20_EndVertex]e[Extrusion_3_4/To_Edge]e")) +SketchConstraintCoincidence_25 = Sketch_4.setCoincident(SketchLine_28.endPoint(), SketchPoint_4.result()) SketchLine_29 = Sketch_4.addLine(3.975000000000001, 0, 3.975000000000001, 0.95) SketchLine_29.setName("SketchLine_28") SketchLine_29.result().setName("SketchLine_28") -SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchLine_28.endPoint(), SketchLine_29.startPoint()) -SketchPoint_5 = Sketch_4.addPoint(model.selection("VERTEX", "Extrusion_3_5/Generated_Edge_1&Extrusion_3_5/To_Edge_1")) -SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchLine_29.endPoint(), SketchPoint_5.result()) +SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchLine_28.endPoint(), SketchLine_29.startPoint()) +SketchPoint_5 = Sketch_4.addPoint(model.selection("VERTEX", "[Extrusion_3_5/Generated_Edge&Sketch_3/SketchLine_21_EndVertex]e[Extrusion_3_5/To_Edge]e")) +SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchLine_29.endPoint(), SketchPoint_5.result()) model.do() -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_26"), model.selection("EDGE", "Sketch_4/Edge-SketchLine_27"), model.selection("EDGE", "Sketch_4/Edge-SketchLine_28")]) -Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2"), model.selection("EDGE", "Edge_2_3")], model.selection("EDGE", "PartSet/OZ"), "h_apres_ouverture-ep_dalles/2", 0) -Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "Extrusion_4_1/Generated_Edge_2&Extrusion_4_1/To_Edge_1"), model.selection("VERTEX", "Extrusion_4_1/Generated_Edge_1&Extrusion_4_1/To_Edge_1"), model.selection("VERTEX", "Extrusion_4_2/Generated_Edge_1&Extrusion_4_2/To_Edge_1")) +Edge_2_objects = [model.selection("EDGE", "Sketch_4/SketchLine_26"), model.selection("EDGE", "Sketch_4/SketchLine_27"), model.selection("EDGE", "Sketch_4/SketchLine_28")] +Edge_2 = model.addEdge(Part_1_doc, Edge_2_objects) +Extrusion_4_objects = [model.selection("EDGE", "Edge_2_1"), model.selection("EDGE", "Edge_2_2"), model.selection("EDGE", "Edge_2_3")] +Extrusion_4 = model.addExtrusion(Part_1_doc, Extrusion_4_objects, model.selection("EDGE", "PartSet/OZ"), "h_apres_ouverture-ep_dalles/2", 0) +Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[Extrusion_4_1/Generated_Edge&Sketch_4/SketchLine_26_StartVertex]e[Extrusion_4_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_4_1/Generated_Edge&Sketch_4/SketchLine_26_EndVertex]e[Extrusion_4_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_4_2/Generated_Edge&Sketch_4/SketchLine_27_EndVertex]e[Extrusion_4_2/To_Edge]e")) Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) SketchLine_30 = Sketch_5.addLine(0, 2.950000000000001, 0, 0) SketchLine_30.setName("SketchLine_29") SketchLine_30.result().setName("SketchLine_29") -SketchPoint_6 = Sketch_5.addPoint(model.selection("VERTEX", "Extrusion_4_1/Generated_Edge_2&Extrusion_4_1/To_Edge_1")) -SketchConstraintCoincidence_30 = Sketch_5.setCoincident(SketchLine_30.startPoint(), SketchPoint_6.result()) -SketchPoint_7 = Sketch_5.addPoint(model.selection("VERTEX", "Extrusion_4_1/Generated_Edge_1&Extrusion_4_1/To_Edge_1")) -SketchConstraintCoincidence_31 = Sketch_5.setCoincident(SketchLine_30.endPoint(), SketchPoint_7.result()) +SketchPoint_6 = Sketch_5.addPoint(model.selection("VERTEX", "[Extrusion_4_1/Generated_Edge&Sketch_4/SketchLine_26_StartVertex]e[Extrusion_4_1/To_Edge]e")) +SketchConstraintCoincidence_28 = Sketch_5.setCoincident(SketchLine_30.startPoint(), SketchPoint_6.result()) +SketchPoint_7 = Sketch_5.addPoint(model.selection("VERTEX", "[Extrusion_4_1/Generated_Edge&Sketch_4/SketchLine_26_EndVertex]e[Extrusion_4_1/To_Edge]e")) +SketchConstraintCoincidence_29 = Sketch_5.setCoincident(SketchLine_30.endPoint(), SketchPoint_7.result()) SketchLine_31 = Sketch_5.addLine(0, 0, 3.975000000000001, 0) SketchLine_31.setName("SketchLine_30") SketchLine_31.result().setName("SketchLine_30") -SketchConstraintCoincidence_32 = Sketch_5.setCoincident(SketchLine_30.endPoint(), SketchLine_31.startPoint()) -SketchPoint_8 = Sketch_5.addPoint(model.selection("VERTEX", "Extrusion_4_2/Generated_Edge_1&Extrusion_4_2/To_Edge_1")) -SketchConstraintCoincidence_33 = Sketch_5.setCoincident(SketchLine_31.endPoint(), SketchPoint_8.result()) +SketchConstraintCoincidence_30 = Sketch_5.setCoincident(SketchLine_30.endPoint(), SketchLine_31.startPoint()) +SketchPoint_8 = Sketch_5.addPoint(model.selection("VERTEX", "[Extrusion_4_2/Generated_Edge&Sketch_4/SketchLine_27_EndVertex]e[Extrusion_4_2/To_Edge]e")) +SketchConstraintCoincidence_31 = Sketch_5.setCoincident(SketchLine_31.endPoint(), SketchPoint_8.result()) SketchLine_32 = Sketch_5.addLine(3.975000000000001, 0, 3.975000000000001, 0.95) SketchLine_32.setName("SketchLine_31") SketchLine_32.result().setName("SketchLine_31") -SketchConstraintCoincidence_34 = Sketch_5.setCoincident(SketchLine_31.endPoint(), SketchLine_32.startPoint()) -SketchPoint_9 = Sketch_5.addPoint(model.selection("VERTEX", "Extrusion_4_3/Generated_Edge_1&Extrusion_4_3/To_Edge_1")) -SketchConstraintCoincidence_35 = Sketch_5.setCoincident(SketchLine_32.endPoint(), SketchPoint_9.result()) +SketchConstraintCoincidence_32 = Sketch_5.setCoincident(SketchLine_31.endPoint(), SketchLine_32.startPoint()) +SketchPoint_9 = Sketch_5.addPoint(model.selection("VERTEX", "[Extrusion_4_3/Generated_Edge&Sketch_4/SketchLine_28_EndVertex]e[Extrusion_4_3/To_Edge]e")) +SketchConstraintCoincidence_33 = Sketch_5.setCoincident(SketchLine_32.endPoint(), SketchPoint_9.result()) SketchLine_33 = Sketch_5.addLine(3.975000000000001, 0.95, 0, 2.950000000000001) SketchLine_33.setName("SketchLine_32") SketchLine_33.result().setName("SketchLine_32") -SketchConstraintCoincidence_36 = Sketch_5.setCoincident(SketchLine_32.endPoint(), SketchLine_33.startPoint()) -SketchConstraintCoincidence_37 = Sketch_5.setCoincident(SketchLine_30.startPoint(), SketchLine_33.endPoint()) -SketchConstraintCoincidence_38 = Sketch_5.setCoincident(SketchPoint_6.coordinates(), SketchLine_33.endPoint()) +SketchConstraintCoincidence_34 = Sketch_5.setCoincident(SketchLine_32.endPoint(), SketchLine_33.startPoint()) +SketchConstraintCoincidence_35 = Sketch_5.setCoincident(SketchLine_30.startPoint(), SketchLine_33.endPoint()) +SketchConstraintCoincidence_36 = Sketch_5.setCoincident(SketchPoint_6.coordinates(), SketchLine_33.endPoint()) SketchLine_34 = Sketch_5.addLine(1.85, 2.019182389937107, 1.85, 0) SketchLine_34.setName("SketchLine_33") SketchLine_34.result().setName("SketchLine_33") -SketchConstraintCoincidence_39 = Sketch_5.setCoincident(SketchLine_34.startPoint(), SketchLine_33.result()) +SketchConstraintCoincidence_37 = Sketch_5.setCoincident(SketchLine_34.startPoint(), SketchLine_33.result()) SketchLine_35 = Sketch_5.addLine(2.075000000000001, 1.905974842767296, 2.075000000000001, 0) SketchLine_35.setName("SketchLine_34") SketchLine_35.result().setName("SketchLine_34") -SketchConstraintCoincidence_40 = Sketch_5.setCoincident(SketchLine_35.startPoint(), SketchLine_33.result()) -SketchConstraintCoincidence_41 = Sketch_5.setCoincident(SketchLine_35.endPoint(), SketchLine_31.result()) -SketchConstraintCoincidence_42 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_31.result()) +SketchConstraintCoincidence_38 = Sketch_5.setCoincident(SketchLine_35.startPoint(), SketchLine_33.result()) +SketchConstraintCoincidence_39 = Sketch_5.setCoincident(SketchLine_35.endPoint(), SketchLine_31.result()) +SketchConstraintCoincidence_40 = Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_31.result()) SketchConstraintVertical_8 = Sketch_5.setVertical(SketchLine_34.result()) SketchConstraintVertical_9 = Sketch_5.setVertical(SketchLine_35.result()) -SketchConstraintDistance_10 = Sketch_5.setDistance(SketchLine_34.startPoint(), SketchLine_30.result(), "1.8+ep_voiles/2") -SketchConstraintDistance_11 = Sketch_5.setDistance(SketchLine_35.startPoint(), SketchLine_32.result(), "1.85+ep_voiles/2") +SketchConstraintDistance_10 = Sketch_5.setDistance(SketchLine_34.startPoint(), SketchLine_30.result(), "1.8+ep_voiles/2", False) +SketchConstraintDistance_10.setName("SketchConstraintDistance_10") +SketchConstraintDistance_11 = Sketch_5.setDistance(SketchLine_35.startPoint(), SketchLine_32.result(), "1.85+ep_voiles/2", False) +SketchConstraintDistance_11.setName("SketchConstraintDistance_11") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_29f-SketchLine_30f-SketchLine_32f-SketchLine_33r")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_30f-SketchLine_31f-SketchLine_32f-SketchLine_34f")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_30f-SketchLine_32f-SketchLine_33f-SketchLine_34r")]) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Extrusion_4_3"), model.selection("FACE", "Extrusion_3_3"), model.selection("FACE", "Extrusion_4_2"), model.selection("FACE", "Extrusion_3_5"), model.selection("FACE", "Extrusion_3_4"), model.selection("FACE", "Extrusion_3_2"), model.selection("FACE", "Extrusion_4_1"), model.selection("FACE", "Extrusion_3_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), "h_ouverture+h_apres_ouverture-ep_dalles/2") +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_29r-SketchLine_30f-SketchLine_33r-SketchLine_32f_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_30f-SketchLine_31f-SketchLine_32f-SketchLine_34f_wire")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_30f-SketchLine_34r-SketchLine_32f-SketchLine_33f_wire")]) +Translation_1_objects = [model.selection("FACE", "Extrusion_4_3"), model.selection("FACE", "Extrusion_3_3"), model.selection("FACE", "Extrusion_4_2"), model.selection("FACE", "Extrusion_3_5"), model.selection("FACE", "Extrusion_3_4"), model.selection("FACE", "Extrusion_3_2"), model.selection("FACE", "Extrusion_4_1"), model.selection("FACE", "Extrusion_3_1"), model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_3_1"), model.selection("FACE", "Face_2_1")] +Translation_1 = model.addTranslation(Part_1_doc, Translation_1_objects, model.selection("EDGE", "PartSet/OZ"), "h_ouverture+h_apres_ouverture-ep_dalles/2") Recover_1_objects = [Face_2.result(), Face_3.result(), Face_1.result(), Extrusion_3.result(), Extrusion_4.result(), Extrusion_3.results()[1], Extrusion_3.results()[3], Extrusion_3.results()[4], Extrusion_4.results()[1], Extrusion_3.results()[2], Extrusion_4.results()[2]] Recover_1 = model.addRecover(Part_1_doc, Translation_1, Recover_1_objects) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Recover_1_2"), model.selection("FACE", "Recover_1_5"), model.selection("FACE", "Recover_1_3"), model.selection("FACE", "Recover_1_4"), model.selection("FACE", "Recover_1_1"), model.selection("FACE", "Recover_1_6"), model.selection("FACE", "Recover_1_8"), model.selection("FACE", "Recover_1_7"), model.selection("FACE", "Recover_1_11"), model.selection("FACE", "Recover_1_10"), model.selection("FACE", "Recover_1_9")], model.selection("EDGE", "PartSet/OZ"), "2*(h_ouverture+h_apres_ouverture-ep_dalles/2)") +Translation_2_objects = [model.selection("FACE", "Recover_1_2"), model.selection("FACE", "Recover_1_5"), model.selection("FACE", "Recover_1_3"), model.selection("FACE", "Recover_1_4"), model.selection("FACE", "Recover_1_1"), model.selection("FACE", "Recover_1_6"), model.selection("FACE", "Recover_1_8"), model.selection("FACE", "Recover_1_7"), model.selection("FACE", "Recover_1_11"), model.selection("FACE", "Recover_1_10"), model.selection("FACE", "Recover_1_9")] +Translation_2 = model.addTranslation(Part_1_doc, Translation_2_objects, model.selection("EDGE", "PartSet/OZ"), "2*(h_ouverture+h_apres_ouverture-ep_dalles/2)") Recover_2_objects = [Recover_1.results()[8], Recover_1.results()[9], Recover_1.results()[10], Recover_1.results()[6], Recover_1.results()[7], Recover_1.results()[5], Recover_1.result(), Recover_1.results()[3], Recover_1.results()[2], Recover_1.results()[4], Recover_1.results()[1]] Recover_2 = model.addRecover(Part_1_doc, Translation_2, Recover_2_objects) -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/Vertex-SketchPoint_1")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/SketchPoint_1")]) Extrusion_5 = model.addExtrusion(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), model.selection("FACE", "Translation_2_11"), 0, model.selection(), 0) -Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("FACE", "Translation_1_1"), model.selection("FACE", "Translation_1_2"), model.selection("FACE", "Translation_1_3"), model.selection("FACE", "Translation_1_4"), model.selection("FACE", "Translation_1_5"), model.selection("FACE", "Translation_1_6"), model.selection("FACE", "Translation_1_7"), model.selection("FACE", "Translation_1_8"), model.selection("FACE", "Translation_1_9"), model.selection("FACE", "Translation_1_10"), model.selection("FACE", "Translation_1_11"), model.selection("FACE", "Translation_2_1"), model.selection("FACE", "Translation_2_2"), model.selection("FACE", "Translation_2_3"), model.selection("FACE", "Translation_2_4"), model.selection("FACE", "Translation_2_5"), model.selection("FACE", "Translation_2_6"), model.selection("FACE", "Translation_2_7"), model.selection("FACE", "Translation_2_8"), model.selection("FACE", "Translation_2_9"), model.selection("FACE", "Translation_2_10"), model.selection("FACE", "Translation_2_11"), model.selection("FACE", "Recover_2_1"), model.selection("FACE", "Recover_2_2"), model.selection("FACE", "Recover_2_3"), model.selection("FACE", "Recover_2_4"), model.selection("FACE", "Recover_2_5"), model.selection("FACE", "Recover_2_6"), model.selection("FACE", "Recover_2_7"), model.selection("FACE", "Recover_2_8"), model.selection("FACE", "Recover_2_9"), model.selection("FACE", "Recover_2_10"), model.selection("FACE", "Recover_2_11"), model.selection("EDGE", "Extrusion_5_1")]) +Partition_1_objects = [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("FACE", "Translation_1_1"), model.selection("FACE", "Translation_1_2"), model.selection("FACE", "Translation_1_3"), model.selection("FACE", "Translation_1_4"), model.selection("FACE", "Translation_1_5"), model.selection("FACE", "Translation_1_6"), model.selection("FACE", "Translation_1_7"), model.selection("FACE", "Translation_1_8"), model.selection("FACE", "Translation_1_9"), model.selection("FACE", "Translation_1_10"), model.selection("FACE", "Translation_1_11"), model.selection("FACE", "Translation_2_1"), model.selection("FACE", "Translation_2_2"), model.selection("FACE", "Translation_2_3"), model.selection("FACE", "Translation_2_4"), model.selection("FACE", "Translation_2_5"), model.selection("FACE", "Translation_2_6"), model.selection("FACE", "Translation_2_7"), model.selection("FACE", "Translation_2_8"), model.selection("FACE", "Translation_2_9"), model.selection("FACE", "Translation_2_10"), model.selection("FACE", "Translation_2_11"), model.selection("FACE", "Recover_2_1"), model.selection("FACE", "Recover_2_2"), model.selection("FACE", "Recover_2_3"), model.selection("FACE", "Recover_2_4"), model.selection("FACE", "Recover_2_5"), model.selection("FACE", "Recover_2_6"), model.selection("FACE", "Recover_2_7"), model.selection("FACE", "Recover_2_8"), model.selection("FACE", "Recover_2_9"), model.selection("FACE", "Recover_2_10"), model.selection("FACE", "Recover_2_11"), model.selection("EDGE", "Extrusion_5_1")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects) model.do() model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc) model.end() diff --git a/src/ModelAPI/Test/TestWeakNaming2291.py b/src/ModelAPI/Test/TestWeakNaming2291.py index 10c00199a..c075e912d 100644 --- a/src/ModelAPI/Test/TestWeakNaming2291.py +++ b/src/ModelAPI/Test/TestWeakNaming2291.py @@ -40,8 +40,8 @@ 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() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")) SketchLine_5 = Sketch_2.addLine(-3.660618520812283, -7.666051414039341, -9.927240775274454, -7.666051414039341) SketchLine_6 = Sketch_2.addLine(-9.927240775274454, -7.666051414039341, -9.927240775274454, 7.885614342469023) SketchLine_7 = Sketch_2.addLine(-9.927240775274454, 7.885614342469023, -3.660618520812283, 7.885614342469023) @@ -55,7 +55,7 @@ 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_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r")], model.selection(), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r")], model.selection(), 10, 0) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) model.do() model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) diff --git a/src/ModelAPI/Test/TestWeakNaming2375.py b/src/ModelAPI/Test/TestWeakNaming2375.py index 0113da48a..bd4f577e6 100644 --- a/src/ModelAPI/Test/TestWeakNaming2375.py +++ b/src/ModelAPI/Test/TestWeakNaming2375.py @@ -18,6 +18,8 @@ ## email : webmaster.salome@opencascade.com ## +# -*- coding: utf-8 -*- + from SketchAPI import * from salome.shaper import model @@ -56,9 +58,9 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_5.result(), 2) SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_3.result(), 1.5) SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_8.result(), 4) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r-SketchLine_8f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1__cc"), False) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8f-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1")) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1]__cc"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchCircle_1 = Sketch_2.addCircle(0, 0, 4.75) SketchCircle_1.setAuxiliary(True) @@ -67,7 +69,7 @@ SketchCircle_2 = Sketch_2.addCircle(4.113620667976081, 2.375000000000003, 1.1) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center()) SketchCircle_3 = Sketch_2.addCircle(-4.113620667974014, 2.375000000003604, 1.1) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_3.center()) -SketchCircle_4 = Sketch_2.addCircle(4.163806340121522e-012, -4.75000000000001, 1.1) +SketchCircle_4 = Sketch_2.addCircle(4.163806340121522e-12, -4.75000000000001, 1.1) SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchCircle_1.results()[1], SketchCircle_4.center()) SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_2.results()[1], SketchCircle_3.results()[1]) SketchConstraintEqual_2 = Sketch_2.setEqual(SketchCircle_3.results()[1], SketchCircle_4.results()[1]) @@ -79,12 +81,12 @@ SketchLine_10 = Sketch_2.addLine(-4.113620667974014, 2.375000000003604, 0, 0) SketchLine_10.setAuxiliary(True) SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchCircle_3.center(), SketchLine_10.startPoint()) SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_10.endPoint()) -SketchLine_11 = Sketch_2.addLine(4.163806340121522e-012, -4.75000000000001, 0, 0) +SketchLine_11 = Sketch_2.addLine(4.163806340121522e-12, -4.75000000000001, 0, 0) SketchLine_11.setAuxiliary(True) SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchCircle_4.center(), SketchLine_11.startPoint()) SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_11.endPoint()) SketchConstraintRadius_1 = Sketch_2.setRadius(SketchCircle_2.results()[1], 1.1) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_12 = SketchProjection_4.createdFeature() SketchConstraintAngle_1 = Sketch_2.setAngleBackward(SketchLine_9.result(), SketchLine_12.result(), 30.00000000000006) SketchConstraintAngle_2 = Sketch_2.setAngle(SketchLine_9.result(), SketchLine_10.result(), 119.9999999999498) @@ -173,39 +175,39 @@ SketchConstraintDistance_2 = Sketch_2.setDistance(SketchCircle_16.center(), Sket SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_19).startPoint(), SketchCircle_17.center(), 5.2, True) model.do() ExtrusionCut_1_objects_1 = [model.selection("FACE", "Sketch_2/Face-SketchCircle_9_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_10_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_7_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_17_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_16_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")] -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) -ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_12_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_6_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_8_2f")] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Face-SketchCircle_11_2f-SketchCircle_9_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_12_2f-SketchCircle_10_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_6_2f-SketchCircle_5_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_8_2f-SketchCircle_7_2r_wire")] ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_1_1")]) Axis_4 = model.addAxis(Part_1_doc, 0, -1, -10) -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f")], model.selection("EDGE", "Axis_1"), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -ExtrusionCut_3.result().setDeflection(1e-005) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f")], model.selection("EDGE", "Axis_1"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionCut_3.result().setDeflection(1e-05) Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_21 = Sketch_3.addLine(3.5, 2.508501119175777, 3.5, 4.934853156880259) SketchLine_22 = Sketch_3.addLine(3.5, 4.934853156880259, 6.2, 4.934853156880259) SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) SketchLine_23 = Sketch_3.addLine(6.2, 4.934853156880259, 6.2, 3.008501119175777) SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint()) -SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), False) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_3"), False) SketchLine_24 = SketchProjection_6.createdFeature() SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_24.result()) SketchLine_25 = Sketch_3.addLine(6.2, 3.008501119175777, 3.5, 2.508501119175777) SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_23.endPoint(), SketchLine_25.startPoint()) SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_25.endPoint()) -SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), False) +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_5"), False) SketchLine_26 = SketchProjection_7.createdFeature() SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_26.result()) SketchConstraintCoincidence_55 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_26.result()) SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_22.result()) SketchConstraintCoincidence_56 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.result()) -SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_27 = SketchProjection_8.createdFeature() SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_25.result(), SketchLine_27.result()) -SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), False) +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_4"), False) SketchLine_28 = SketchProjection_9.createdFeature() SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_21.startPoint(), SketchLine_28.result(), 0.5, True) model.do() Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_13_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_14_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0) Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_3_1")], [model.selection("SOLID", "Common_1_1"), model.selection("SOLID", "Common_1_2")]) model.do() diff --git a/src/ModelAPI/Test/TestWeakNaming2437.py b/src/ModelAPI/Test/TestWeakNaming2437.py index 6656fbe9d..288989030 100644 --- a/src/ModelAPI/Test/TestWeakNaming2437.py +++ b/src/ModelAPI/Test/TestWeakNaming2437.py @@ -178,9 +178,9 @@ SketchLine_22 = SketchProjection_4.createdFeature() SketchConstraintDistance_9 = Sketch_2.setDistance(SketchLine_19.startPoint(), SketchLine_22.result(), "(TL/2-3)-20", True) SketchConstraintDistance_10 = Sketch_2.setDistance(SketchLine_19.endPoint(), SketchLine_22.result(), "(TL/2-3)-20", True) model.do() -Wire_1_objects = [model.selection("EDGE", "Sketch_1/Edge-SketchLine_11"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_10"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_4_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_12"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_14"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_13"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_15"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_5_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_16"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_1_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_5"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_3_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")] +Wire_1_objects = [model.selection("EDGE", "Sketch_1/SketchLine_11"), model.selection("EDGE", "Sketch_1/SketchLine_10"), model.selection("EDGE", "Sketch_1/SketchArc_4_2"), model.selection("EDGE", "Sketch_1/SketchLine_12"), model.selection("EDGE", "Sketch_1/SketchLine_14"), model.selection("EDGE", "Sketch_1/SketchLine_13"), model.selection("EDGE", "Sketch_1/SketchLine_15"), model.selection("EDGE", "Sketch_1/SketchArc_5_2"), model.selection("EDGE", "Sketch_1/SketchLine_16"), model.selection("EDGE", "Sketch_1/SketchLine_9"), model.selection("EDGE", "Sketch_1/SketchArc_1_2"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchArc_3_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchLine_1")] Wire_1 = model.addWire(Part_1_doc, Wire_1_objects) -Wire_2_objects = [model.selection("EDGE", "Sketch_2/Edge-SketchLine_17"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_7_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_20"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_19"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_18"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_6_2")] +Wire_2_objects = [model.selection("EDGE", "Sketch_2/SketchLine_17"), model.selection("EDGE", "Sketch_2/SketchArc_7_2"), model.selection("EDGE", "Sketch_2/SketchLine_20"), model.selection("EDGE", "Sketch_2/SketchLine_19"), model.selection("EDGE", "Sketch_2/SketchLine_18"), model.selection("EDGE", "Sketch_2/SketchArc_6_2")] Wire_2 = model.addWire(Part_1_doc, Wire_2_objects) Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_1_1")]) Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_2_1")]) diff --git a/src/ModelAPI/Test/TestWeakNaming2452.py b/src/ModelAPI/Test/TestWeakNaming2452.py index 21caaa1da..83613dda4 100644 --- a/src/ModelAPI/Test/TestWeakNaming2452.py +++ b/src/ModelAPI/Test/TestWeakNaming2452.py @@ -87,9 +87,9 @@ SketchConstraintHorizontal_10 = Sketch_1.setHorizontal(SketchLine_19.result()) SketchConstraintVertical_10 = Sketch_1.setVertical(SketchLine_20.result()) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 100) -Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "Extrusion_1_1/Generated_Face_24&Extrusion_1_1/To_Face_2"), 200) +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_1_1")], model.selection("EDGE", "[Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_20][Extrusion_1_1_2/To_Face]"), 200) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 50) -Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_1")], model.selection("EDGE", "Extrusion_2_1/Generated_Face_24&Extrusion_2_1/To_Face_2"), 150) +Translation_2 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Extrusion_2_1")], model.selection("EDGE", "[Extrusion_2_1_2/Generated_Face&Sketch_1/SketchLine_20][Extrusion_2_1_2/To_Face]"), 150) Boolean_1 = model.addCut(Part_1_doc, [model.selection("COMPSOLID", "Translation_1_1")], [model.selection("COMPSOLID", "Translation_2_1")]) model.do() model.testHaveNamingSubshapes(Boolean_1, model, Part_1_doc) diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 07260dcf2..ca344ce98 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1067,6 +1068,13 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( isDumpByGeom = aSelectedFeature && aSelectedFeature->isInHistory(); } + if (theAttrSelect->isGeometricalSelection() && aShape->shapeType() == GeomAPI_Shape::COMPOUND + && theAttrSelect->context().get() && !aShape->isEqual(theAttrSelect->context()->shape()) + && theAttrSelect->context()->groupName() != ModelAPI_ResultPart::group()) { + GeomAPI_ShapeIterator anIt(aShape); + aShape = anIt.current(); + } + myDumpBuffer << "\"" << aShape->shapeTypeStr(); bool aStandardDump = true; if (isDumpByGeom) { @@ -1096,13 +1104,13 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( << aMiddlePoint->y() << ", " << aMiddlePoint->z() << ")"; aStandardDump = false; - } else if (theAttrSelect->isWeakNaming() || - (myWeakNamingSelection && aShape.get() && theAttrSelect->context().get() && - aShape != theAttrSelect->context()->shape())) { // weak naming for local selection only + } else if (myWeakNamingSelection && aShape.get() && theAttrSelect->context().get() && + aShape != theAttrSelect->context()->shape()) { // weak naming for local selection only GeomAlgoAPI_NExplode aNExplode(theAttrSelect->context()->shape(), aShape->shapeType()); int anIndex = aNExplode.index(aShape); if (anIndex != 0) { // found a week-naming index, so, export it - myDumpBuffer<<"\", \""<context()->data()->name()<<"\", "<contextName(theAttrSelect->context())<<"\", "< >& theStore, const bool theCompare) // if false => store @@ -390,7 +390,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, } } // store the model features information: iterate all features - int anObjectsCount = 0; // stores the number of compared features for this document to compate + int anObjectsCount = 0; // stores the number of compared features for this document to compare std::set aProcessed; // processed features names (that are in the current document) // process all objects (features and folders) @@ -422,7 +422,7 @@ std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc, ModelAPI_Tools::allResults(aFeature, allResults); std::list::iterator aRes = allResults.begin(); for(; aRes != allResults.end(); aRes++) { - // recoursively store features of sub-documents + // recursively store features of sub-documents if ((*aRes)->groupName() == ModelAPI_ResultPart::group()) { DocumentPtr aDoc = std::dynamic_pointer_cast(*aRes)->partDoc(); if (aDoc.get()) { @@ -511,21 +511,32 @@ static bool checkDump(SessionPtr theSession, return true; } -bool checkPythonDump() +bool checkPythonDump(const checkDumpType theCheckType) { static const std::string anErrorByNaming("checkPythonDump by naming"); static const std::string anErrorByGeometry("checkPythonDump by geometry"); + static const std::string anErrorByWeak("checkPythonDump by weak naming"); static char aFileForNamingDump[] = "./check_dump_byname.py"; static char aFileForGeometryDump[] = "./check_dump_bygeom.py"; + static char aFileForWeakDump[] = "./check_dump_weak.py"; SessionPtr aSession = ModelAPI_Session::get(); - // dump with the selection by names - if (!dumpToPython(aSession, aFileForNamingDump, "topological_naming", anErrorByNaming)) - return false; - // dump with the selection by geometry - if (!dumpToPython(aSession, aFileForGeometryDump, "geometric_selection", anErrorByGeometry)) - return false; + if (theCheckType & CHECK_NAMING) { + // dump with the selection by names + if (!dumpToPython(aSession, aFileForNamingDump, "topological_naming", anErrorByNaming)) + return false; + } + if (theCheckType & CHECK_GEOMETRICAL) { + // dump with the selection by geometry + if (!dumpToPython(aSession, aFileForGeometryDump, "geometric_selection", anErrorByGeometry)) + return false; + } + if (theCheckType & CHECK_WEAK) { + // dump with the selection by weak naming + if (!dumpToPython(aSession, aFileForWeakDump, "weak_naming", anErrorByWeak)) + return false; + } // map from document name to feature name to feature data std::map > aStore; @@ -537,10 +548,18 @@ bool checkPythonDump() return false; } - // check dump with the selection by names - bool isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming); - // check dump with the selection by geometry - isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry); + bool isOk = true; + if (theCheckType & CHECK_NAMING) { + // check dump with the selection by names + isOk = checkDump(aSession, aFileForNamingDump, aStore, anErrorByNaming); + } + if (theCheckType & CHECK_GEOMETRICAL) { + // check dump with the selection by geometry + isOk = isOk && checkDump(aSession, aFileForGeometryDump, aStore, anErrorByGeometry); + } + if (theCheckType & CHECK_WEAK) { + isOk = isOk && checkDump(aSession, aFileForWeakDump, aStore, anErrorByWeak); + } return isOk; } diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.h b/src/ModelHighAPI/ModelHighAPI_Tools.h index aa5286d84..8da24a0e5 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.h +++ b/src/ModelHighAPI/ModelHighAPI_Tools.h @@ -168,11 +168,19 @@ ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTy MODELHIGHAPI_EXPORT std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType); +/// Enumeration to manage the check python dump modes. +enum checkDumpType { + CHECK_NAMING = 1, ///< check topological naming only + CHECK_GEOMETRICAL = 2, ///< check geometrical naming only + CHECK_NAMING_AND_GEOMETRICAL = 3, ///< default option, check topological and geometrical dumps + CHECK_WEAK = 4, ///< check weak naming only +}; + /// Performs the high level API dump, then closes all and executes the script: /// model must be recreated fully, with all attributes /// \returns true if check is well done MODELHIGHAPI_EXPORT -bool checkPythonDump(); +bool checkPythonDump(const checkDumpType theCheckType = CHECK_NAMING_AND_GEOMETRICAL); //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- diff --git a/src/ModelHighAPI/Test/Test2488.py b/src/ModelHighAPI/Test/Test2488.py index d89e4c754..59b7b443d 100644 --- a/src/ModelHighAPI/Test/Test2488.py +++ b/src/ModelHighAPI/Test/Test2488.py @@ -55,9 +55,9 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_1.result(), 6.2) SketchConstraintLength_4 = Sketch_1.setLength(SketchLine_8.result(), 4) SketchConstraintLength_5 = Sketch_1.setLength(SketchLine_5.result(), 2) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_7r-SketchLine_8f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1__cc"), False) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8f-SketchLine_7r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1")) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_3][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1]__cc"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchCircle_1 = Sketch_2.addCircle(0, 0, 4.75) SketchCircle_1.setAuxiliary(True) @@ -73,7 +73,7 @@ SketchLine_9 = Sketch_2.addLine(0, 0, 4.113620667973598, 2.375000000005359) SketchLine_9.setAuxiliary(True) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_9.startPoint()) SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchCircle_2.center(), SketchLine_9.endPoint()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False) SketchLine_10 = SketchProjection_4.createdFeature() SketchConstraintAngle_1 = Sketch_2.setAngleBackward(SketchLine_9.result(), SketchLine_10.result(), 30) SketchMultiRotation_1 = Sketch_2.addRotation([SketchCircle_2.results()[1]], SketchCircle_1.center(), 120, 3) @@ -173,9 +173,9 @@ SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY" SketchLine_15 = SketchProjection_5.createdFeature() SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_15.result()) model.do() -ExtrusionCut_1_objects_1 = [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_3_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_9_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_6_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_18_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_17_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_14_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")] -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) -ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_10_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_8_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_7_2f")] +ExtrusionCut_1_objects_1 = [model.selection("WIRE", "Sketch_2/Face-SketchCircle_3_2f_wire"), model.selection("FACE", "Sketch_2/Face-SketchCircle_9_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_6_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_18_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_17_2f"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_14_2f_wire"), model.selection("FACE", "Sketch_2/Face-SketchCircle_15_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")] +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_2_objects_1 = [model.selection("WIRE", "Sketch_2/Face-SketchCircle_11_2f-SketchCircle_15_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_10_2f-SketchCircle_14_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_8_2f-SketchCircle_9_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_7_2f-SketchCircle_6_2r_wire")] ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_1_1")]) model.do() model.end() diff --git a/src/ModelHighAPI/Test/TestDeflectionDump.py b/src/ModelHighAPI/Test/TestDeflectionDump.py index aebb48e50..b52f97bc8 100644 --- a/src/ModelHighAPI/Test/TestDeflectionDump.py +++ b/src/ModelHighAPI/Test/TestDeflectionDump.py @@ -28,7 +28,7 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_1 = Sketch_1.addCircle(-325.90051457976, -18.010291595197, 258.003584159371) model.do() Sketch_1.result().setDeflection(5e-006) -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) Extrusion_1.result().setDeflection(0.5) model.end() diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index b54f6e4ee..cde321d1e 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -34,24 +34,19 @@ void ModuleBase_ISelection::appendSelected(const QList { // collect the objects from the viewer QObjectPtrList anExistedObjects; - QList::const_iterator aPrsIt = theValuesTo.begin(), - aPrsLast = theValuesTo.end(); - for (; aPrsIt != aPrsLast; aPrsIt++) { - if ((*aPrsIt)->owner() && (*aPrsIt)->object()) - anExistedObjects.push_back((*aPrsIt)->object()); + foreach(ModuleBase_ViewerPrsPtr aPrs, theValuesTo) { + if (aPrs->owner() && aPrs->object()) + anExistedObjects.append(aPrs->object()); } - - QList::const_iterator anIt = theValues.begin(), - aLast = theValues.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr anObject = (*anIt)->object(); + ObjectPtr anObject; + foreach(ModuleBase_ViewerPrsPtr aPrs, theValues) { + anObject = aPrs->object(); if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) { theValuesTo.append(std::shared_ptr( new ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL))); } } - } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_ITreeNode.h b/src/ModuleBase/ModuleBase_ITreeNode.h index cef49758a..33b8d8a64 100644 --- a/src/ModuleBase/ModuleBase_ITreeNode.h +++ b/src/ModuleBase/ModuleBase_ITreeNode.h @@ -185,9 +185,14 @@ protected: int aIdx; int aCount = 0; int aSize = myChildren.size(); + int aMaxCount = aSize * aSize; int aShift = 0; while (i < aSize) { aCount++; + // To avoid unlimited cycling + if (aCount > aMaxCount) + break; + aNode = myChildren.at(i); aObject = aNode->object(); if (aObject.get()) { @@ -202,9 +207,6 @@ protected: else aShift++; i++; - // To avoid unlimited cycling - if (aCount > aSize * aSize) - break; } } } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index d81556ac1..afe020112 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -159,11 +160,17 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen aMainLay->addWidget(myListView->getControl(), 2, 0, 1, -1); aMainLay->setRowStretch(2, 1); - //aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)??? - //aMainLay->setRowMinimumHeight(3, 20); - //this->setLayout(aMainLay); connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged())); + bool aSameTop = theData->getBooleanAttribute("same_topology", false); + if (aSameTop) { + myGeomCheck = new QCheckBox(tr("Add elements that share the same topology"), this); + aMainLay->addWidget(myGeomCheck); + connect(myGeomCheck, SIGNAL(toggled(bool)), SLOT(onSameTopology(bool))); + } + else + myGeomCheck = 0; + myIsNeutralPointClear = theData->getBooleanAttribute("clear_in_neutral_point", true); if (myShapeTypes.size() > 1 || myIsUseChoice) { if (defaultValues.contains(myFeatureId + attributeID())) { @@ -240,9 +247,9 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() return false; AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); std::string aType = anAttribute->attributeType(); if (aType == ModelAPI_AttributeSelectionList::typeId()) { - AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); // Restore shape type std::string aSelectionType = aSelectionListAttr->selectionType().c_str(); if (!aSelectionType.empty()) { @@ -251,6 +258,8 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() myIsFirst = false; } } + if (myGeomCheck) + myGeomCheck->setChecked(aSelectionListAttr->isGeometricalSelection()); updateSelectionList(); return true; } @@ -1040,4 +1049,15 @@ void ModuleBase_WidgetMultiSelector::onListActivated() { //focusTo(); emitFocusInWidget(); -} \ No newline at end of file +} + +void ModuleBase_WidgetMultiSelector::onSameTopology(bool theOn) +{ + AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); + std::string aType = anAttribute->attributeType(); + if (aType == ModelAPI_AttributeSelectionList::typeId()) { + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + aSelectionListAttr->setGeometricalSelection(theOn); + updateObject(myFeature); + } +} diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 1a40c1303..4c2898107 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -37,6 +37,7 @@ #include class QWidget; +class QCheckBox; //class QComboBox; class ModuleBase_ListView; class ModuleBase_IWorkshop; @@ -132,6 +133,8 @@ protected slots: void onListActivated(); + void onSameTopology(bool theOn); + protected: /// Returns true if the event is processed. The default implementation is empty, returns false. virtual bool processDelete(); @@ -247,6 +250,8 @@ protected: bool myIsFirst; std::string myDefMode; + + QCheckBox* myGeomCheck; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ diff --git a/src/ModuleBase/ModuleBase_WidgetPointInput.cpp b/src/ModuleBase/ModuleBase_WidgetPointInput.cpp index 7d8596556..11b96c37c 100644 --- a/src/ModuleBase/ModuleBase_WidgetPointInput.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPointInput.cpp @@ -219,16 +219,19 @@ QIntList ModuleBase_WidgetPointInput::shapeTypes() const //******************************************************************** bool ModuleBase_WidgetPointInput -::setSelectionCustom(const std::shared_ptr& thePrs) +::setSelection(QList>& theValues, + const bool theToValidate) { - GeomShapePtr aShape = thePrs->shape(); - if (aShape->isVertex()) { - GeomVertexPtr aVertex(new GeomAPI_Vertex(aShape)); - GeomPointPtr aPnt = aVertex->point(); - myXSpin->setValue(aPnt->x()); - myYSpin->setValue(aPnt->y()); - myZSpin->setValue(aPnt->z()); - return true; + if (theValues.size() == 1) { + GeomShapePtr aShape = theValues.first()->shape(); + if (aShape.get() && aShape->isVertex()) { + GeomVertexPtr aVertex(new GeomAPI_Vertex(aShape)); + GeomPointPtr aPnt = aVertex->point(); + myXSpin->setValue(aPnt->x()); + myYSpin->setValue(aPnt->y()); + myZSpin->setValue(aPnt->z()); + return true; + } } return false; } diff --git a/src/ModuleBase/ModuleBase_WidgetPointInput.h b/src/ModuleBase/ModuleBase_WidgetPointInput.h index bae10d61a..802649211 100644 --- a/src/ModuleBase/ModuleBase_WidgetPointInput.h +++ b/src/ModuleBase/ModuleBase_WidgetPointInput.h @@ -61,7 +61,8 @@ public: /// Fills the attribute with the value of the selected owner /// \param thePrs a selected owner - virtual bool setSelectionCustom(const std::shared_ptr& thePrs); + virtual bool setSelection(QList>& theValues, + const bool theToValidate); protected: /// Retunrs a list of possible shape types diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 6fbd9b174..16b47680e 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -130,7 +130,8 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr& std::dynamic_pointer_cast(anAttr); aSelectAttr->setValue(myPresentedObject, GeomShapePtr(), true); GeomShapePtr aShape = aSelectAttr->value(); - if (!aShape.get() && aSelectAttr->contextFeature()->firstResult().get()) { + if (!aShape.get() && aSelectAttr->contextFeature().get() && + aSelectAttr->contextFeature()->firstResult().get()) { aShape = aSelectAttr->contextFeature()->firstResult()->shape(); } if (aShape.get()) { diff --git a/src/ParametersAPI/ParametersAPI_Parameter.cpp b/src/ParametersAPI/ParametersAPI_Parameter.cpp index dac7f0aa3..419f778f1 100644 --- a/src/ParametersAPI/ParametersAPI_Parameter.cpp +++ b/src/ParametersAPI/ParametersAPI_Parameter.cpp @@ -23,6 +23,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------- ParametersAPI_Parameter::ParametersAPI_Parameter( const std::shared_ptr & theFeature) @@ -92,3 +93,14 @@ ParameterPtr addParameter(const std::shared_ptr & thePart, std::shared_ptr aFeature = thePart->addFeature(ParametersAPI_Parameter::ID()); return ParameterPtr(new ParametersAPI_Parameter(aFeature, theName, theExpression, theComment)); } + +//-------------------------------------------------------------------------------------- +void removeParameter(const std::shared_ptr & thePart, + const ParameterPtr & theParameter) +{ + FeaturePtr aParam = theParameter->feature(); + if (aParam) { + ModelAPI_ReplaceParameterMessage::send(aParam, 0); + thePart->removeFeature(aParam); + } +} diff --git a/src/ParametersAPI/ParametersAPI_Parameter.h b/src/ParametersAPI/ParametersAPI_Parameter.h index 7abc34850..6d444d9f6 100644 --- a/src/ParametersAPI/ParametersAPI_Parameter.h +++ b/src/ParametersAPI/ParametersAPI_Parameter.h @@ -83,6 +83,13 @@ ParameterPtr addParameter(const std::shared_ptr & thePart, const std::string & theExpression, const std::string & theComment = std::string()); +/**\ingroup CPPHighAPI + * \brief Remove Parameter feature and substitute it by the value in referred features + */ +PARAMETERSAPI_EXPORT +void removeParameter(const std::shared_ptr & thePart, + const ParameterPtr & theParameter); + //-------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------- #endif /* SRC_PARAMETERSAPI_PARAMETERSAPI_PARAMETER_H_ */ diff --git a/src/ParametersPlugin/CMakeLists.txt b/src/ParametersPlugin/CMakeLists.txt index 8cc950e41..8cbc233f3 100644 --- a/src/ParametersPlugin/CMakeLists.txt +++ b/src/ParametersPlugin/CMakeLists.txt @@ -116,6 +116,9 @@ INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES}) ADD_UNIT_TESTS(TestParameterCreation.py TestParameterRename.py TestParameterChangeValue.py + TestParameterDelete.py + TestParameterErrorMsg.py + TestParametersMgr.py Test1806.py Test2392.py Test2474.py diff --git a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp index cc2990833..cd5328a34 100644 --- a/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp +++ b/src/ParametersPlugin/ParametersPlugin_EvalListener.cpp @@ -48,7 +48,7 @@ //------------------------------------------------------------------------------ // Tools -std::string toStdString(double theValue) +static std::string toStdString(double theValue) { std::ostringstream sstream; sstream << theValue; @@ -59,7 +59,7 @@ std::string toStdString(double theValue) return sstream.str() + aPnt; } -std::set toSet(const std::list& theContainer) +static std::set toSet(const std::list& theContainer) { return std::set(theContainer.begin(), theContainer.end()); } diff --git a/src/ParametersPlugin/ParametersPlugin_Validators.cpp b/src/ParametersPlugin/ParametersPlugin_Validators.cpp index aaa647d9d..dc0c766e6 100644 --- a/src/ParametersPlugin/ParametersPlugin_Validators.cpp +++ b/src/ParametersPlugin/ParametersPlugin_Validators.cpp @@ -100,8 +100,6 @@ bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttrib Events_InfoMessage& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); - ResultParameterPtr aParam = - std::dynamic_pointer_cast(aFeature->firstResult()); AttributeStringPtr aStrAttr = std::dynamic_pointer_cast(theAttribute); @@ -116,11 +114,6 @@ bool ParametersPlugin_ExpressionValidator::isValid(const AttributePtr& theAttrib return false; } - if (!aParam.get()) { - theError = "Result is empty."; - return false; - } - theError = aFeature->string(ParametersPlugin_Parameter::EXPRESSION_ERROR_ID())->value(); return theError.empty(); } diff --git a/src/ParametersPlugin/Test/TestParameterDelete.py b/src/ParametersPlugin/Test/TestParameterDelete.py new file mode 100644 index 000000000..c1db59d6d --- /dev/null +++ b/src/ParametersPlugin/Test/TestParameterDelete.py @@ -0,0 +1,53 @@ +## Copyright (C) 2018-20xx 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 +from ModelAPI import * +import math + +def assertLineLength(theLine, theLength): + dx = theLine.startPoint().x() - theLine.endPoint().x() + dy = theLine.startPoint().y() - theLine.endPoint().y() + assert(math.fabs(dx**2 + dy**2 - theLength**2) < 1.e-8), "Line length {} is not equal to expected {}".format(math.sqrt(dx**2 + dy**2), theLength) + + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +ParamLen = model.addParameter(Part_1_doc, "Len", "100") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(0, -30, 100, -30) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "Len") +model.do() + +aLength = ParamLen.value() +assertLineLength(SketchLine_1, aLength) + +# delete parameter +model.removeParameter(Part_1_doc, ParamLen) +model.do() + +# move line and check the constraint is still here +SketchLine_1.startPoint().setValue(SketchLine_1.startPoint().x() + 10., SketchLine_1.startPoint().y()) +model.do() +assertLineLength(SketchLine_1, aLength) + +model.end() diff --git a/src/ParametersPlugin/Test/TestParameterErrorMsg.py b/src/ParametersPlugin/Test/TestParameterErrorMsg.py new file mode 100644 index 000000000..1030c77cf --- /dev/null +++ b/src/ParametersPlugin/Test/TestParameterErrorMsg.py @@ -0,0 +1,37 @@ +## Copyright (C) 2018-20xx 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() +# check error on empty name +Param1 = model.addParameter(partSet, "", "100") +assert(Param1.feature().error() != "") +# check error on empty value +Param2 = model.addParameter(partSet, "L", "") +assert(Param2.feature().error() != "") +# check error if name is not variable +Param3 = model.addParameter(partSet, "100", "100") +assert(Param3.feature().error() != "") +# check error on wrong value expression +Param4 = model.addParameter(partSet, "N", "+-.so&@") +assert(Param4.feature().error() != "") +model.end() diff --git a/src/ParametersPlugin/Test/TestParameterRename.py b/src/ParametersPlugin/Test/TestParameterRename.py index 703ee35d1..8129eb0ba 100644 --- a/src/ParametersPlugin/Test/TestParameterRename.py +++ b/src/ParametersPlugin/Test/TestParameterRename.py @@ -63,7 +63,11 @@ __updated__ = "2015-04-27" class TestParameterRename(unittest.TestCase): def setUp(self): self.aSession = ModelAPI_Session.get() - self.aDocument = self.aSession.moduleDocument() + model.begin() + partSet = self.aSession.moduleDocument() + Part = model.addPart(partSet) + model.end() + self.aDocument = Part.document() self.createParameters() self.createFeature() @@ -73,8 +77,8 @@ class TestParameterRename(unittest.TestCase): pass def createParameters(self): - ltNames = ["x1", "y1", "x2"] - ltExpressions = ["150.", "200.", "x1 + y1 + 100.0"] + ltNames = ["x1", "y1", "x2", "n", "px"] + ltExpressions = ["150.", "200.", "x1 + y1 + 100.0", "5", "50"] self.dtParams = {} for name, expr in zip(ltNames, ltExpressions): self.aSession.startOperation() @@ -123,8 +127,7 @@ class TestParameterRename(unittest.TestCase): anEndPoint = geomDataAPI_Point2D(anOY.attribute("EndPoint")) aStartPoint.setValue(0., 0.) anEndPoint.setValue(0., 100.) - anOYRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OY")) - anOY.selection("External").setValue(anOYRes, anOYRes.shape()) + anOY.selection("External").selectSubShape("EDGE", "PartSet/OY") anOY.execute() refattrB.setObject(modelAPI_ResultConstruction(anOY.firstResult())) valueX = aDistanceConstraint1.real("ConstraintValue") @@ -140,8 +143,7 @@ class TestParameterRename(unittest.TestCase): anEndPoint = geomDataAPI_Point2D(anOX.attribute("EndPoint")) aStartPoint.setValue(0., 0.) anEndPoint.setValue(100., 0.) - anOXRes = modelAPI_Result(self.aDocument.objectByName("Construction", "OX")) - anOX.selection("External").setValue(anOXRes, anOXRes.shape()) + anOX.selection("External").selectSubShape("EDGE", "PartSet/OX") anOX.execute() refattrB.setObject(modelAPI_ResultConstruction(anOX.firstResult())) valueY = aDistanceConstraint2.real("ConstraintValue") @@ -164,6 +166,41 @@ class TestParameterRename(unittest.TestCase): self.assertEqual(self.anCircleCentr.y(), 170.) self.assertEqual(aRadiusAttr.value(), 150.) + # add a line and rotate it around origin + self.aSession.startOperation() + aSketchLine = aSketchFeature.addFeature("SketchLine") + aStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint")) + aEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint")) + aStartPoint.setText("px", "0") + aEndPoint.setValue(0., 0.) + self.aSession.finishOperation() + self.aSession.startOperation() + aEndPoint.move(100., 0.) + self.aSession.finishOperation() + + self.aSession.startOperation() + aMultiRotation = aSketchFeature.addFeature("SketchMultiRotation") + aMultiRotation.reflist("MultiRotationList").append(aSketchLine.lastResult()) + aMultiRotation.refattr("MultiRotationCenter").setAttr(anCircleCentr) + aMultiRotation.real("MultiRotationAngle").setValue(60.0) + aMultiRotation.string("AngleType").setValue("SingleAngle") + aMultiRotation.boolean("MultiRotationReversed").setValue(False) + aMultiRotation.integer("MultiRotationObjects").setText("n") + self.aSession.finishOperation() + + self.aMultiRotCopies = aMultiRotation.integer("MultiRotationObjects") + + # create 3D point + self.aSession.startOperation() + aPoint3D = self.aDocument.addFeature("Point") + aPoint3D.string("creation_method").setValue("by_xyz") + aCoords = geomDataAPI_Point(aPoint3D.attribute("point3d")) + aCoords.setText("px", "0", "0") + self.aSession.finishOperation() + + self.aPoint2D = aStartPoint + self.aPoint3D = aCoords + def test_rename(self): # Rename aParam = self.dtParams["x1"] @@ -188,6 +225,44 @@ class TestParameterRename(unittest.TestCase): self.assertEqual(self.anCircleCentr.y(), 170.) self.assertEqual(self.aRadiusAttr.value(), 150.) + def test_rename_integer(self): + # rename integer parameter + aParam = self.dtParams["n"] + aResultAttr = modelAPI_ResultParameter(aParam.firstResult()) + self.aSession.startOperation() + aResultAttr.data().setName("m") + self.aSession.finishOperation() + + # Check rename in the parameter + self.assertEqual(aParam.name(), "m") + self.assertEqual(aParam.string("variable").value(), "m") + self.assertEqual(aResultAttr.data().name(), "m") + + # Check rename in feature + self.assertEqual(self.aMultiRotCopies.text(), "m") + # Check corresponding value + self.assertEqual(self.aMultiRotCopies.value(), 5) + + def test_rename_point(self): + # rename parameter in point coordinates + aParam = self.dtParams["px"] + aResultAttr = modelAPI_ResultParameter(aParam.firstResult()) + self.aSession.startOperation() + aResultAttr.data().setName("p") + self.aSession.finishOperation() + + # Check rename in the parameter + self.assertEqual(aParam.name(), "p") + self.assertEqual(aParam.string("variable").value(), "p") + self.assertEqual(aResultAttr.data().name(), "p") + + # Check rename in feature + self.assertEqual(self.aPoint2D.textX(), "p") + self.assertEqual(self.aPoint3D.textX(), "p") + # Check corresponding value + self.assertEqual(self.aPoint2D.x(), 50.) + self.assertEqual(self.aPoint3D.x(), 50.) + def test_rename_not_unique(self): # Rename to not unique name aParam = self.dtParams["x1"] @@ -230,6 +305,7 @@ class TestParameterRename(unittest.TestCase): self.assertEqual(self.anCircleCentr.y(), 170.) self.assertEqual(self.aRadiusAttr.value(), 150.) + if __name__ == "__main__": test_program = unittest.main(exit=False) assert test_program.result.wasSuccessful(), "Test failed" diff --git a/src/ParametersPlugin/Test/TestParametersMgr.py b/src/ParametersPlugin/Test/TestParametersMgr.py new file mode 100644 index 000000000..847727169 --- /dev/null +++ b/src/ParametersPlugin/Test/TestParametersMgr.py @@ -0,0 +1,42 @@ +## Copyright (C) 2018-20xx 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 +## + +""" + TestParametersMgr.py + + class ParametersPlugin_ParametersMgr +""" + +#========================================================================= +# Initialization of the test +#========================================================================= +from ModelAPI import * + +__updated__ = "2018-12-05" + +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +aSession.startOperation() +aKind = "ParametersMgr" +aParamMgr = aDocument.addFeature(aKind) +assert(aParamMgr is not None) +assert(aParamMgr.getKind() == aKind) +aSession.finishOperation() diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index 640af398a..a7480b35a 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -161,8 +161,21 @@ void PartSet_OverconstraintListener::processEvent( std::set aModifiedObjects; PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); CompositeFeaturePtr aSketch = aModule->sketchMgr()->activeSketch(); + + // check the sketch in the message and the active sketch are the same + std::shared_ptr anErrorMsg = + std::dynamic_pointer_cast(theMessage); + if (aSketch && anErrorMsg && !anErrorMsg->objects().empty()) { + ObjectPtr anObject = *anErrorMsg->objects().begin(); + CompositeFeaturePtr aSketchFromMsg = + std::dynamic_pointer_cast(anObject); + if (!aSketchFromMsg || aSketchFromMsg != aSketch) + aSketch = CompositeFeaturePtr(); + } + if (aSketch.get()) { - for (int i = 0; i < aSketch->numberOfSubs(); i++) { + int aNumberOfSubs = aSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = aSketch->subFeature(i); aModifiedObjects.insert(aFeature); // is necessary to redisplay presentations std::list aResults = aFeature->results(); diff --git a/src/PartSet/PartSet_PreviewPlanes.cpp b/src/PartSet/PartSet_PreviewPlanes.cpp index 7585f21be..961c35ccb 100755 --- a/src/PartSet/PartSet_PreviewPlanes.cpp +++ b/src/PartSet/PartSet_PreviewPlanes.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -49,7 +50,9 @@ bool PartSet_PreviewPlanes::hasVisualizedBodies(ModuleBase_IWorkshop* theWorksho foreach (ObjectPtr anObj, aDisplayed) { ResultPtr aResult = std::dynamic_pointer_cast(anObj); // result constructions should not be taken as a body - if (aResult.get() != NULL && aResult->groupName() == ModelAPI_ResultBody::group()) { + if (aResult.get() != NULL && + ((aResult->groupName() == ModelAPI_ResultBody::group()) || + ((aResult->groupName() == ModelAPI_ResultPart::group()))) ) { GeomShapePtr aShape = aResult->shape(); if (aShape.get()) { // vertices, edges should not be taken as a body diff --git a/src/PartSet/PartSet_PreviewSketchPlane.cpp b/src/PartSet/PartSet_PreviewSketchPlane.cpp index 56f6c33f6..808de929f 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.cpp +++ b/src/PartSet/PartSet_PreviewSketchPlane.cpp @@ -143,7 +143,8 @@ bool PartSet_PreviewSketchPlane::getDefaultSizeOfView( return false; Bnd_Box aBox; - for (int aSubFeatureId = 0; aSubFeatureId < theSketch->numberOfSubs(); aSubFeatureId++) { + int aNumberOfSubs = theSketch->numberOfSubs(); + for (int aSubFeatureId = 0; aSubFeatureId < aNumberOfSubs; aSubFeatureId++) { FeaturePtr aFeature = theSketch->subFeature(aSubFeatureId); if (!aFeature.get()) continue; diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp index b600306b9..c1f7bd1f0 100755 --- a/src/PartSet/PartSet_ResultSketchPrs.cpp +++ b/src/PartSet/PartSet_ResultSketchPrs.cpp @@ -285,7 +285,8 @@ void PartSet_ResultSketchPrs::fillShapes(TopoDS_Shape& theResultShape, CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast (aResultFeature); std::list anAuxiliaryResults; - for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) { + int aNumberOfSubs = aSketchFeature->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = aSketchFeature->subFeature(i); if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) { std::list aResults = aFeature->results(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index a67aa0f36..84a0ab0c0 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -197,6 +197,7 @@ PartSet_SketcherMgr::PartSet_SketcherMgr(PartSet_Module* theModule) PartSet_SketcherMgr::~PartSet_SketcherMgr() { + delete mySketchPlane; } void PartSet_SketcherMgr::onEnterViewPort() @@ -970,7 +971,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) // Remove invalid sketch entities std::set anInvalidFeatures; ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators(); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); if (aFeature.get()) { if (!aFactory->validate(aFeature)) @@ -1011,7 +1013,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) QStringList anInfo; Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); #ifdef DEBUG_SKETCHER_ENTITIES anInfo.append(ModuleBase_Tools::objectInfo(aFeature)); @@ -1081,7 +1084,8 @@ void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation) } else { // Hide all sketcher sub-Objects - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aFeature = myCurrentSketch->subFeature(i); std::list aResults = aFeature->results(); std::list::const_iterator aIt; @@ -1479,7 +1483,7 @@ bool PartSet_SketcherMgr::isObjectOfSketch(const ObjectPtr& theObject) const FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject); if (anObjectFeature.get()) { int aSize = myCurrentSketch->numberOfSubs(); - for (int i = 0; i < myCurrentSketch->numberOfSubs() && !isFoundObject; i++) { + for (int i = 0; i < aSize && !isFoundObject; i++) { FeaturePtr aCurrentFeature = myCurrentSketch->subFeature(i); isFoundObject = myCurrentSketch->subFeature(i) == anObjectFeature; } @@ -1900,7 +1904,8 @@ void PartSet_SketcherMgr::updateBySketchParameters( if (aPrevState != theState) { ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) { + int aNumberOfSubs = myCurrentSketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aSubFeature = myCurrentSketch->subFeature(i); bool aProcessed = false; bool aConstraintDisplayed = canDisplayConstraint(aSubFeature, theType, aProcessed); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 16a0d0faa..0d91654e5 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -664,7 +664,8 @@ void PartSet_Tools::sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite return; static Events_Loop* aLoop = Events_Loop::loop(); - for (int i = 0; i < theComposite->numberOfSubs(); i++) { + int aNumberOfSubs = theComposite->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { FeaturePtr aSubFeature = theComposite->subFeature(i); static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); aECreator->sendUpdated(aSubFeature, theEventId); @@ -756,6 +757,9 @@ ResultPtr PartSet_Tools::createFixedByExternalCenter( void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, int& theFirst, int& theLast) { + theFirst = -1; + theLast = -1; + DocumentPtr aDoc = theFolder->document(); FolderPtr aFolder = std::dynamic_pointer_cast(theFolder); if (!aFolder.get()) @@ -763,18 +767,19 @@ void PartSet_Tools::getFirstAndLastIndexInFolder(const ObjectPtr& theFolder, AttributeReferencePtr aFirstFeatAttr = aFolder->data()->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); + if (!aFirstFeatAttr.get()) + return; FeaturePtr aFirstFeatureInFolder = ModelAPI_Feature::feature(aFirstFeatAttr->value()); - if (!aFirstFeatureInFolder.get()) { - theFirst = -1; + if (!aFirstFeatureInFolder.get()) return; - } + AttributeReferencePtr aLastFeatAttr = aFolder->data()->reference(ModelAPI_Folder::LAST_FEATURE_ID()); + if (!aLastFeatAttr.get()) + return; FeaturePtr aLastFeatureInFolder = ModelAPI_Feature::feature(aLastFeatAttr->value()); - if (!aLastFeatureInFolder.get()) { - theLast = -1; + if (!aLastFeatureInFolder.get()) return; - } theFirst = aDoc->index(aFirstFeatureInFolder); theLast = aDoc->index(aLastFeatureInFolder); diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index e8acf5f61..b8434fbff 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -270,6 +270,7 @@ void PartSet_ObjectNode::update() else { aNode = new PartSet_ObjectNode(aBody, this); myChildren.append(aNode); + aNode->update(); } } else if (aFieldRes.get()) { @@ -482,7 +483,9 @@ ModuleBase_ITreeNode* PartSet_FolderNode::createNode(const ObjectPtr& theObj) //ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast(theObj); //if (aCompRes.get()) // return new PartSet_CompsolidNode(theObj, this); - return new PartSet_ObjectNode(theObj, this); + ModuleBase_ITreeNode* aNode = new PartSet_ObjectNode(theObj, this); + aNode->update(); + return aNode; } void PartSet_FolderNode::update() @@ -813,7 +816,9 @@ ModuleBase_ITreeNode* PartSet_RootNode::createNode(const ObjectPtr& theObj) if (aFeature->getKind() == PartSetPlugin_Part::ID()) return new PartSet_PartRootNode(theObj, this); - return new PartSet_ObjectNode(theObj, this); + PartSet_ObjectNode* aNode = new PartSet_ObjectNode(theObj, this); + aNode->update(); + return aNode; } ////////////////////////////////////////////////////////////////////////////////// @@ -859,11 +864,19 @@ void PartSet_PartRootNode::update() bool aHasFields = myFieldsFolder->childrenCount() > 0; bool aHasGroups = myGroupsFolder->childrenCount() > 0; - if (aHasFields && (!myChildren.contains(myFieldsFolder))) { - myChildren.insert(3, myFieldsFolder); + if (aHasFields) { + if (!myChildren.contains(myFieldsFolder)) { + myChildren.insert(3, myFieldsFolder); + } + } else if (myChildren.contains(myFieldsFolder)) { + myChildren.removeAll(myFieldsFolder); } - if (aHasGroups && (!myChildren.contains(myGroupsFolder))) { - myChildren.insert(aHasFields ? 4 : 3, myGroupsFolder); + if (aHasGroups) { + if (!myChildren.contains(myGroupsFolder)) { + myChildren.insert(aHasFields ? 4 : 3, myGroupsFolder); + } + } else if (myChildren.contains(myGroupsFolder)) { + myChildren.removeAll(myGroupsFolder); } // Update features content @@ -947,7 +960,7 @@ QVariant PartSet_PartRootNode::data(int theColumn, int theRole) const Qt::ItemFlags PartSet_PartRootNode::flags(int theColumn) const { if (myObject->isDisabled()) - return (theColumn == 2) ? Qt::ItemIsSelectable : aDefaultFlag; + return (theColumn == 2) ? Qt::ItemIsSelectable : aNullFlag; SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aActiveDoc = aSession->activeDocument(); @@ -960,7 +973,9 @@ ModuleBase_ITreeNode* PartSet_PartRootNode::createNode(const ObjectPtr& theObj) { if (theObj->groupName() == ModelAPI_Folder::group()) return new PartSet_ObjectFolderNode(theObj, this); - return new PartSet_ObjectNode(theObj, this); + PartSet_ObjectNode* aNode = new PartSet_ObjectNode(theObj, this); + aNode->update(); + return aNode; } int PartSet_PartRootNode::numberOfFolders() const @@ -1066,11 +1081,13 @@ void PartSet_ObjectFolderNode::update() if (aObj != myChildren.at(i)->object()) { aNode = new PartSet_ObjectNode(aObj, this); myChildren.insert(i, aNode); + aNode->update(); } } else { aNode = new PartSet_ObjectNode(aObj, this); myChildren.append(aNode); + aNode->update(); } } } @@ -1098,11 +1115,13 @@ QTreeNodesList PartSet_ObjectFolderNode::objectCreated(const QObjectPtrList& the aNode = new PartSet_ObjectNode(aObj, this); myChildren.insert(i, aNode); aResult.append(aNode); + aNode->update(); } } else { aNode = new PartSet_ObjectNode(aObj, this); myChildren.append(aNode); aResult.append(aNode); + aNode->update(); } } return aResult; @@ -1141,6 +1160,7 @@ QTreeNodesList PartSet_ObjectFolderNode::objectsDeleted(const DocumentPtr& theDo } else { myChildren.removeAll(aNode); + aResult.removeAll(aNode); delete aNode; aRemoved = true; continue; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 8714eb98d..14c7fbe57 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -465,10 +465,11 @@ bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_View else { aSelAttr->setValue(aFeature, GeomShapePtr()); GeomShapePtr aShape = aSelAttr->value(); - if (!aShape.get() && aSelAttr->contextFeature()->firstResult().get()) { + if (!aShape.get() && aSelAttr->contextFeature().get() && + aSelAttr->contextFeature()->firstResult().get()) { aShape = aSelAttr->contextFeature()->firstResult()->shape(); } - if (aShape.get()) { + if (aShape.get() && aShape->isPlanar()) { const TopoDS_Shape& aTDShape = aShape->impl(); setSketchPlane(aTDShape); isOwnerSet = true; diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index efb568425..6d08828f0 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -163,10 +163,11 @@ void PrimitivesPlugin_Box::loadNamingDS(std::shared_ptr theBoxA int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theBoxAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultBox->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultBox->generated((*it).second, (*it).first); } } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp index 2c2916586..3f94a85d5 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -82,21 +83,43 @@ void PrimitivesPlugin_Cone::execute() } // Getting axis. - std::shared_ptr anAxis; + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + std::shared_ptr anEdgeRef = selection(AXIS_ID()); + GeomShapePtr aShape = anEdgeRef->value(); + if (!aShape.get()) { + if (anEdgeRef->context().get()) { + aShape = anEdgeRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } std::shared_ptr anEdge; - std::shared_ptr anEdgeRef = - selection(PrimitivesPlugin_Cone::AXIS_ID()); - if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); - } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && - anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, - anEdge->line()->direction())); + else + { + setError(aSelectionError); + return; } + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); + // Getting base radius, top radius and height double aBaseRadius = real(PrimitivesPlugin_Cone::BASE_RADIUS_ID())->value(); double aTopRadius = real(PrimitivesPlugin_Cone::TOP_RADIUS_ID())->value(); @@ -145,26 +168,27 @@ void PrimitivesPlugin_Cone::loadNamingDS(std::shared_ptr theCo theConeAlgo->prepareNamingFaces(); // Insert to faces - int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theConeAlgo->getCreatedFaces(); int nbFaces = 0; for (std::map< std::string, std::shared_ptr >::iterator it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultCone->generated(aFace, (*it).first, num++); + theResultCone->generated((*it).second, (*it).first); nbFaces++; } if (nbFaces == 2) { // Naming vertices GeomAPI_DataMapOfShapeShape aVertices; - GeomAPI_ShapeExplorer aVertExp(theConeAlgo->shape(), GeomAPI_Shape::VERTEX); - for(int anIndex = 1; aVertExp.more(); aVertExp.next()) { + int anIndex = 1; + for (GeomAPI_ShapeExplorer aVertExp(theConeAlgo->shape(), GeomAPI_Shape::VERTEX); + aVertExp.more(); + aVertExp.next()) + { if (!aVertices.isBound(aVertExp.current())) { std::ostringstream aStream; aStream<<"Vertex_"<generated(aVertExp.current(), aStream.str(), num++); + theResultCone->generated(aVertExp.current(), aStream.str()); aVertices.bind(aVertExp.current(), aVertExp.current()); } } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp index c3d5b8223..268c983f1 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -112,21 +113,44 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle) } // Getting axis. - std::shared_ptr anAxis; + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + std::shared_ptr anEdgeRef = selection(AXIS_ID()); + GeomShapePtr aShape = anEdgeRef->value(); + if (!aShape.get()) { + if (anEdgeRef->context().get()) { + aShape = anEdgeRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } std::shared_ptr anEdge; - std::shared_ptr anEdgeRef = - selection(PrimitivesPlugin_Cylinder::AXIS_ID()); - if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); - } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && - anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, - anEdge->line()->direction())); + else + { + setError(aSelectionError); + return; } + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); + + // Getting radius and height double aRadius = real(PrimitivesPlugin_Cylinder::RADIUS_ID())->value(); double aHeight = real(PrimitivesPlugin_Cylinder::HEIGHT_ID())->value(); @@ -184,12 +208,12 @@ void PrimitivesPlugin_Cylinder::loadNamingDS(std::shared_ptrprepareNamingFaces(); // Insert to faces - int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theCylinderAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultCylinder->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultCylinder->generated((*it).second, (*it).first); } } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp index c01d2b2fb..df9fe3220 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp @@ -106,23 +106,26 @@ void PrimitivesPlugin_Sphere::loadNamingDS(std::shared_ptr t // Insert to faces // Naming for faces and edges - int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theSphereAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultSphere->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultSphere->generated((*it).second, (*it).first); } // Naming vertices GeomAPI_DataMapOfShapeShape aVertices; - GeomAPI_ShapeExplorer aVertExp(theSphereAlgo->shape(), GeomAPI_Shape::VERTEX); - for(int anIndex = 1; aVertExp.more(); aVertExp.next()) { + int anIndex = 1; + for (GeomAPI_ShapeExplorer aVertExp(theSphereAlgo->shape(), GeomAPI_Shape::VERTEX); + aVertExp.more(); + aVertExp.next()) + { if (!aVertices.isBound(aVertExp.current())) { std::ostringstream aStream; aStream<<"Vertex_"<generated(aVertExp.current(), aStream.str(), num++); + theResultSphere->generated(aVertExp.current(), aStream.str()); aVertices.bind(aVertExp.current(), aVertExp.current()); } } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp index a086def17..0c000a8fe 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -80,21 +81,43 @@ void PrimitivesPlugin_Torus::execute() } // Getting axis. - std::shared_ptr anAxis; + static const std::string aSelectionError = "Error: The axis shape selection is bad."; + std::shared_ptr anEdgeRef = selection(AXIS_ID()); + GeomShapePtr aShape = anEdgeRef->value(); + if (!aShape.get()) { + if (anEdgeRef->context().get()) { + aShape = anEdgeRef->context()->shape(); + } + } + if (!aShape.get()) { + setError(aSelectionError); + return; + } std::shared_ptr anEdge; - std::shared_ptr anEdgeRef = - selection(PrimitivesPlugin_Torus::AXIS_ID()); - if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->value())); - } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() && - anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) { - anEdge = std::shared_ptr(new GeomAPI_Edge(anEdgeRef->context()->shape())); + if (aShape->isEdge()) + { + anEdge = aShape->edge(); + } + else if (aShape->isCompound()) + { + GeomAPI_ShapeIterator anIt(aShape); + anEdge = anIt.current()->edge(); } - if(anEdge) { - anAxis = std::shared_ptr(new GeomAPI_Ax2(aBasePoint, - anEdge->line()->direction())); + else + { + setError(aSelectionError); + return; } + if (!anEdge.get()) + { + setError(aSelectionError); + return; + } + + std::shared_ptr anAxis(new GeomAPI_Ax2(aBasePoint, + anEdge->line()->direction())); + // Getting radius and ring radius double aRadius = real(PrimitivesPlugin_Torus::RADIUS_ID())->value(); double aRingRadius = real(PrimitivesPlugin_Torus::RING_RADIUS_ID())->value(); @@ -145,20 +168,24 @@ void PrimitivesPlugin_Torus::loadNamingDS(std::shared_ptr the int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = theTorusAlgo->getCreatedFaces(); - for (std::map< std::string, std::shared_ptr >::iterator - it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { - std::shared_ptr aFace = (*it).second; - theResultTorus->generated(aFace, (*it).first, num++); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultTorus->generated((*it).second, (*it).first); } // Naming of edges GeomAPI_DataMapOfShapeShape anEdges; - GeomAPI_ShapeExplorer anEdgeExp(theTorusAlgo->shape(), GeomAPI_Shape::EDGE); - for(int anIndex = 1; anEdgeExp.more(); anEdgeExp.next()) { + int anIndex = 1; + for (GeomAPI_ShapeExplorer anEdgeExp(theTorusAlgo->shape(), GeomAPI_Shape::EDGE); + anEdgeExp.more(); + anEdgeExp.next()) + { if (!anEdges.isBound(anEdgeExp.current())) { std::ostringstream aStream; aStream<<"Edge_"<generated(anEdgeExp.current(), aStream.str(), num++); + theResultTorus->generated(anEdgeExp.current(), aStream.str()); anEdges.bind(anEdgeExp.current(), anEdgeExp.current()); } } diff --git a/src/PrimitivesPlugin/cone_widget.xml b/src/PrimitivesPlugin/cone_widget.xml index 4f1acd5e4..710134ca0 100644 --- a/src/PrimitivesPlugin/cone_widget.xml +++ b/src/PrimitivesPlugin/cone_widget.xml @@ -16,6 +16,7 @@ label="axis" default="" shape_types="edge" + geometrical_selection="true" icon="icons/Primitives/axis.png" tooltip="Select the axis of the cone"> diff --git a/src/PrimitivesPlugin/cylinder_widget.xml b/src/PrimitivesPlugin/cylinder_widget.xml index 373bafb5f..2474f8bad 100644 --- a/src/PrimitivesPlugin/cylinder_widget.xml +++ b/src/PrimitivesPlugin/cylinder_widget.xml @@ -37,6 +37,7 @@ email : webmaster.salome@opencascade.com @@ -75,6 +76,7 @@ email : webmaster.salome@opencascade.com diff --git a/src/PrimitivesPlugin/torus_widget.xml b/src/PrimitivesPlugin/torus_widget.xml index 44d0ce688..30f6489e4 100644 --- a/src/PrimitivesPlugin/torus_widget.xml +++ b/src/PrimitivesPlugin/torus_widget.xml @@ -16,6 +16,7 @@ label="axis" default="" shape_types="edge" + geometrical_selection="true" icon="icons/Primitives/axis.png" tooltip="Select the axis of the torus"> diff --git a/src/PythonAPI/examples/MakeBrick1.py b/src/PythonAPI/examples/MakeBrick1.py index 831c91fbd..f39fb3f06 100644 --- a/src/PythonAPI/examples/MakeBrick1.py +++ b/src/PythonAPI/examples/MakeBrick1.py @@ -69,9 +69,9 @@ model.do() # Creating a cylinder on a face of the box -thisface = "Extrusion_1_1/Generated_Face_2" -thisxmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1" -thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1" +thisface = "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2" +thisxmax = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]" +thiszmax = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]" mystand = model.addSketch(mypart, thisface) diff --git a/src/PythonAPI/examples/MakeBrick2.py b/src/PythonAPI/examples/MakeBrick2.py index 2172b850c..38466f94b 100644 --- a/src/PythonAPI/examples/MakeBrick2.py +++ b/src/PythonAPI/examples/MakeBrick2.py @@ -67,9 +67,9 @@ model.do() # Creating a cylinder on a face of the box -thisface = "Extrusion_1_1/Generated_Face_2" -thisxmin = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1" -thiszmax = "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1_1" +thisface = "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2" +thisxmin = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]" +thiszmax = "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]" mystand = model.addSketch(mypart, thisface) circle = mystand.addCircle(0, 25, 5) diff --git a/src/PythonAPI/examples/Platine.py b/src/PythonAPI/examples/Platine.py index 25e45babf..795571074 100644 --- a/src/PythonAPI/examples/Platine.py +++ b/src/PythonAPI/examples/Platine.py @@ -78,7 +78,7 @@ def vertical_body(): def bottom_body(): # Create XOY sketch - sketch = model.addSketch(part, "Extrusion_1_1/Generated_Face_5") + sketch = model.addSketch(part, "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4") # Create base polygon points = [(0, 0), (0, L), (P, L), (P, 16 + 16), (P - 20, 16 + 16), (P - 20, 16), (P, 16), (P, 0)] @@ -111,7 +111,7 @@ def bottom_body(): sketch.setCoincident(arc.endPoint(), h1.startPoint()) # Binding - left_e = sketch.addLine("Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1_1") + left_e = sketch.addLine("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]") sketch.setCoincident(left_e.startPoint(), left.endPoint()) sketch.setCoincident(left_e.endPoint(), left.startPoint()) @@ -132,7 +132,7 @@ def bottom_body(): def body_3(): # Create XOZ sketch - sketch = model.addSketch(part, "Boolean_1_1/Modified_Face_3") + sketch = model.addSketch(part, "Boolean_1_1/Modified_Face&Sketch_1/SketchLine_3") # Create base polygon H, L, l, r = 28, 40, 8, 12 @@ -170,7 +170,7 @@ def body_3(): sketch.setRadius(arc, r) # Binding - bottom_e = sketch.addLine("Boolean_1_1/Modified_Face_7&Extrusion_2_1/To_Face_1") + bottom_e = sketch.addLine("[Boolean_1_1/Modified_Face&Sketch_2/SketchLine_6][Extrusion_2_1/To_Face]") sketch.setCoincident(bottom_e, bottom.startPoint()) sketch.setCoincident(bottom_e.startPoint(), bottom.endPoint()) @@ -183,7 +183,7 @@ def body_3(): def body_4(): # Create XOZ 2nd sketch - sketch = model.addSketch(part, "Boolean_2_1/Modified_Face_4") + sketch = model.addSketch(part, "Boolean_2_1/Modified_Face&Sketch_2/SketchLine_6") # Create base polygon points = [(0, 0), (0, 1), (1, 0)] @@ -192,11 +192,11 @@ def body_4(): left, diagonal, bottom = model.addPolygon(sketch, *geom_points) # Binding - bottom_e = sketch.addLine("Boolean_2_1/Modified_Face_2&Boolean_2_1/Modified_Face_4") + bottom_e = sketch.addLine("[Boolean_2_1/Modified_Face&Extrusion_2_1/To_Face][Boolean_2_1/Modified_Face&Sketch_2/SketchLine_6]") sketch.setCoincident(bottom_e.endPoint(), bottom.startPoint()) sketch.setCoincident(bottom_e.startPoint(), left.startPoint()) - left_e = sketch.addLine("Boolean_2_1/Modified_Face_5&Extrusion_3_1/Generated_Face_2") + left_e = sketch.addLine("[Boolean_2_1/Modified_Face&Extrusion_3_1/From_Face][Extrusion_3_1/Generated_Face&Sketch_3/SketchLine_18]") sketch.setCoincident(left_e.startPoint(), left.endPoint()) model.do() #!!! diff --git a/src/PythonAPI/model/parameter/__init__.py b/src/PythonAPI/model/parameter/__init__.py index fb276792d..12020f850 100644 --- a/src/PythonAPI/model/parameter/__init__.py +++ b/src/PythonAPI/model/parameter/__init__.py @@ -1,4 +1,4 @@ """Package for Parameter plugin for the Parametric Geometry API of the Modeler. """ -from ParametersAPI import addParameter \ No newline at end of file +from ParametersAPI import addParameter, removeParameter \ No newline at end of file diff --git a/src/PythonAPI/model/tests/tests.py b/src/PythonAPI/model/tests/tests.py index 92ff8a609..f888453dd 100644 --- a/src/PythonAPI/model/tests/tests.py +++ b/src/PythonAPI/model/tests/tests.py @@ -130,7 +130,7 @@ def testResultsVolumes(theFeature, theExpectedResultsVolumes, theNbSignificantDi aResultVolumeStr = "{:0.27f}".format(aResultVolume).lstrip("0").lstrip(".").lstrip("0") anExpectedResultVolume = theExpectedResultsVolumes[anIndex] anExpectedResultVolumeStr = "{:0.27f}".format(anExpectedResultVolume).lstrip("0").lstrip(".").lstrip("0") - assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * anExpectedResultVolume, "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits) + assert math.fabs(aResultVolume - anExpectedResultVolume) < aTolerance * math.fabs(anExpectedResultVolume), "Volume of result[{}]: {:0.27f}. Expected: {:0.27f}. The first {} significant digits not equal.".format(anIndex, aResultVolume, anExpectedResultVolume, theNbSignificantDigits) def testHaveNamingFaces(theFeature, theModel, thePartDoc) : """ Tests if all faces of result have a name @@ -263,6 +263,7 @@ def testHaveNamingSubshapes(theFeature, theModel, thePartDoc) : """ Tests if all vertices/edges/faces of result have a unique name :param theFeature: feature to test. """ + assert(len(theFeature.results()) > 0) testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.VERTEX) testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.EDGE) testHaveNamingByType(theFeature, theModel, thePartDoc, GeomAPI_Shape.FACE) diff --git a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp index 304dc616c..a799ef044 100644 --- a/src/SHAPERGUI/SHAPERGUI_DataModel.cpp +++ b/src/SHAPERGUI/SHAPERGUI_DataModel.cpp @@ -78,20 +78,7 @@ bool SHAPERGUI_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStr QString aCurrentFile = SUIT_Tools::addSlash(aTmpDir) + aFileName; XGUI_Workshop* aWorkShop = myModule->workshop(); aWorkShop->openFile(aCurrentFile); - //QString aNewFile = SUIT_Tools::addSlash(aNewTmpDir) + aFileName; - //if (!QFile::copy(aCurrentFile, aNewFile)) - // isDone = false; } - //if (isDone) { - // myTmpDirectory = aNewTmpDir; - //} - //else { - // removeDirectory(aNewTmpDir); - // myTmpDirectory = ""; - //} - - //SessionPtr aMgr = ModelAPI_Session::get(); - //aMgr->load(qPrintable(aNewTmpDir)); myModule->setIsOpened(true); return true; @@ -113,7 +100,6 @@ bool SHAPERGUI_DataModel::save(QStringList& theFiles) bool isMultiFile = aResMgr ? aResMgr->booleanValue("Study", "multi_file", false) : false; std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), isMultiFile); - //std::string aTmpDir = aStudy->GetTmpDir("", false);//true ); QString aTmp = QString(aTmpDir.c_str()); theFiles.append(aTmp); @@ -122,21 +108,13 @@ bool SHAPERGUI_DataModel::save(QStringList& theFiles) aMgr->blockAutoUpdate(false); //aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames); - aWorkShop->setCurrentDataFile(aTmp + "shaper.opp"); + aWorkShop->setCurrentDataFile(aTmp + "shaper.shaper"); aWorkShop->onSave(); QString aName = aWorkShop->currentDataFile(); - std::string aa = aName.toStdString(); aName.replace(QChar('\\'), QChar('/')); int aN = aName.lastIndexOf('/'); theFiles.append(aName.right(aName.length() - aN - 1)); - //std::list::iterator aIt; - //for (aIt = aFileNames.begin(); aIt != aFileNames.end(); ++aIt) { - // QString aName((*aIt).c_str()); - // aName.replace(QChar('\\'), QChar('/')); - // int aN = aName.lastIndexOf('/'); - // theFiles.append(aName.right(aName.length() - aN - 1)); - //} return true; } @@ -149,8 +127,6 @@ bool SHAPERGUI_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QS bool SHAPERGUI_DataModel::close() { myModule->workshop()->closeDocument(); - //removeDirectory(myTmpDirectory); - //myTmpDirectory = ""; return LightApp_DataModel::close(); } diff --git a/src/Selector/CMakeLists.txt b/src/Selector/CMakeLists.txt new file mode 100644 index 000000000..cfc38feca --- /dev/null +++ b/src/Selector/CMakeLists.txt @@ -0,0 +1,66 @@ +## 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(Common) + +SET(PROJECT_HEADERS + Selector.h + Selector_Selector.h + Selector_Algo.h + Selector_Primitive.h + Selector_AlgoWithSubs.h + Selector_Intersect.h + Selector_Container.h + Selector_Modify.h + Selector_FilterByNeighbors.h + Selector_WeakName.h + Selector_NameGenerator.h + Selector_NExplode.h +) + +SET(PROJECT_SOURCES + Selector_Selector.cpp + Selector_Algo.cpp + Selector_Primitive.cpp + Selector_AlgoWithSubs.cpp + Selector_Intersect.cpp + Selector_Container.cpp + Selector_Modify.cpp + Selector_FilterByNeighbors.cpp + Selector_WeakName.cpp + Selector_NameGenerator.cpp + Selector_NExplode.cpp +) + +SET(PROJECT_LIBRARIES + ${OpenCASCADE_ApplicationFramework_LIBRARIES} +) +SET(PROJECT_INCLUDES + ${OpenCASCADE_INCLUDE_DIR} +) + + +ADD_DEFINITIONS(-DSELECTOR_EXPORTS ${OpenCASCADE_DEFINITIONS}) +ADD_LIBRARY(Selector SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) +TARGET_LINK_LIBRARIES(Selector ${PROJECT_LIBRARIES}) + +INCLUDE_DIRECTORIES(${PROJECT_INCLUDES}) + +INSTALL(TARGETS Selector DESTINATION ${SHAPER_INSTALL_BIN}) diff --git a/src/Selector/Selector.h b/src/Selector/Selector.h new file mode 100644 index 000000000..293da865c --- /dev/null +++ b/src/Selector/Selector.h @@ -0,0 +1,38 @@ +// 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 +// + +#ifndef SELECTOR_H +#define SELECTOR_H + +#if defined SELECTOR_EXPORTS +#if defined WIN32 +#define SELECTOR_EXPORT __declspec( dllexport ) +#else +#define SELECTOR_EXPORT +#endif +#else +#if defined WIN32 +#define SELECTOR_EXPORT __declspec( dllimport ) +#else +#define SELECTOR_EXPORT +#endif +#endif + +#endif diff --git a/src/Selector/Selector_Algo.cpp b/src/Selector/Selector_Algo.cpp new file mode 100644 index 000000000..ee31d00bd --- /dev/null +++ b/src/Selector/Selector_Algo.cpp @@ -0,0 +1,495 @@ +// 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/// type of the selection, integer keeps the Selector_Type value +static const Standard_GUID kSEL_TYPE("db174d59-c2e3-4a90-955e-55544df090d6"); +// geometrical naming indicator +static const Standard_GUID kGEOMETRICAL_NAMING("a5322d02-50fb-43ed-9255-75c7b93f6657"); + + +// reference attribute that contains the reference to labels where the "from" or "base" shapes +// of selection are located +static const Standard_GUID kBASE_ARRAY("7c515b1a-9549-493d-9946-a4933a22f45f"); +// if the base array contains reference to the root label, this means that it refers to an +// external document and this list contains a tag in the document +static const Standard_GUID kBASE_LIST("7c515b1a-9549-493d-9946-a4933a22f45a"); + +Selector_Algo::Selector_Algo() +{ + myGeometricalNaming = false; // default values + myAlwaysGeometricalNaming = false; +} + +#define SET_ALGO_FLAGS(algo) \ + algo->myLab = theAccess; \ + algo->myBaseDocumentLab = theBaseDocument; \ + algo->myGeometricalNaming = theGeometricalNaming; \ + algo->myUseNeighbors = theUseNeighbors; \ + algo->myUseIntersections = theUseIntersections; \ + algo->myAlwaysGeometricalNaming = theAlwaysGeometricalNaming; + +Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue, + const TDF_Label theAccess, const TDF_Label theBaseDocument, + const bool theGeometricalNaming, const bool theUseNeighbors, const bool theUseIntersections, + const bool theAlwaysGeometricalNaming) +{ + Selector_Algo* aResult = NULL; + if (theValue.IsNull() || theContext.IsNull()) + return aResult; + + // check the value shape can be named as it is, or it is needed to construct it from the + // higher level shapes (like a box vertex by faces that form this vertex) + bool aIsFound = TNaming_Tool::HasLabel(theAccess, theValue); + if (aIsFound) { // additional check for selection and delete evolution only: also could not use + aIsFound = false; + for(TNaming_SameShapeIterator aShapes(theValue, theAccess); aShapes.More(); aShapes.Next()) + { + Handle(TNaming_NamedShape) aNS; + if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED || + aNS->Evolution() == TNaming_PRIMITIVE) { + aIsFound = true; + break; + } + } + } + } + // searching in the base document + if (!aIsFound && !theBaseDocument.IsNull() && TNaming_Tool::HasLabel(theBaseDocument, theValue)) + { + TNaming_SameShapeIterator aShapes(theValue, theBaseDocument); + for(; aShapes.More(); aShapes.Next()) + { + Handle(TNaming_NamedShape) aNS; + if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED || + aNS->Evolution() == TNaming_PRIMITIVE) { + aIsFound = true; + break; + } + } + } + } + if (!aIsFound) { + TopAbs_ShapeEnum aSelectionType = theValue.ShapeType(); + if (aSelectionType == TopAbs_COMPOUND || aSelectionType == TopAbs_COMPSOLID || + aSelectionType == TopAbs_SHELL || aSelectionType == TopAbs_WIRE) + { + Selector_Container* aContainer = new Selector_Container; + SET_ALGO_FLAGS(aContainer); + if (aContainer->select(theContext, theValue)) + return aContainer; + delete aContainer; + return NULL; + } + + Selector_Intersect* anIntersect = new Selector_Intersect; + SET_ALGO_FLAGS(anIntersect); + bool aGoodIntersector = anIntersect->select(theContext, theValue); + // weak intersector is bad for not use neighbors and has lower priority than neighbors + if (aGoodIntersector && anIntersect->myWeakIndex == -1) { + return anIntersect; + } + if (!theUseNeighbors) { + delete anIntersect; + return NULL; + } + // searching by neighbors + Selector_FilterByNeighbors* aNBs = new Selector_FilterByNeighbors; + SET_ALGO_FLAGS(aNBs); + if (aNBs->select(theContext, theValue)) { + delete anIntersect; + return aNBs; + } + delete aNBs; + if (aGoodIntersector) { // if neighbors are bad, use intersector with weak index + return anIntersect; + } + delete anIntersect; + + // pure weak naming: there is no sense to use pure weak naming for neighbors selection + if (theUseNeighbors) { + Selector_WeakName* aWeak = new Selector_WeakName; + SET_ALGO_FLAGS(aWeak); + if (aWeak->select(theContext, theValue)) { + return aWeak; + } + delete aWeak; + } + return NULL; // not found value in the tree, not found context shape in the tree also + } + // searching for the base shapes of the value + Handle(TNaming_NamedShape) aPrimitiveNS; + NCollection_List aModifList; + for(int aUseExternal = 0; aUseExternal < 2; aUseExternal++) { + TDF_Label aLab = aUseExternal == 0 ? theAccess : theBaseDocument; + if (aLab.IsNull() || !TNaming_Tool::HasLabel(aLab, theValue)) + continue; + for(TNaming_SameShapeIterator aShapes(theValue, aLab); aShapes.More(); aShapes.Next()) + { + Handle(TNaming_NamedShape) aNS; + if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_PRIMITIVE) { // the value shape is declared as PRIMITIVE + aPrimitiveNS = aNS; + break; + } else if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + // check this is a new shape + TNaming_Iterator aNSIter(aNS); + for(; aNSIter.More(); aNSIter.Next()) + if (aNSIter.NewShape().IsSame(theValue)) + break; + if (aNSIter.More()) // new was found + aModifList.Append(aNS); + } + } + } + } + + if (!aPrimitiveNS.IsNull()) { + Selector_Primitive* aPrimitive = new Selector_Primitive; + SET_ALGO_FLAGS(aPrimitive); + aPrimitive->select(aPrimitiveNS->Label()); + return aPrimitive; + } else { + Selector_Modify* aModify = new Selector_Modify; + SET_ALGO_FLAGS(aModify); + bool aGoodModify = aModify->select(aModifList, theContext, theValue); + // weak intersector is bad for not use neighbors and has lower priority than neighbors + if (aGoodModify && aModify->myWeakIndex == -1) { + return aModify; + } + if (!theUseNeighbors) { + delete aModify; + return NULL; + } + // searching by neighbors + Selector_FilterByNeighbors* aNBs = new Selector_FilterByNeighbors; + SET_ALGO_FLAGS(aNBs); + if (aNBs->select(theContext, theValue)) { + delete aModify; + return aNBs; + } + delete aNBs; + + if (aGoodModify) { // if neighbors are bad, use modify algo with weak index + return aModify; + } + delete aModify; + } + + return NULL; // invalid case +} + +Selector_Algo* Selector_Algo::relesectWithAllGeometry( + Selector_Algo* theOldAlgo, const TopoDS_Shape theContext) +{ + return select(theContext, theOldAlgo->value(), + theOldAlgo->myLab, theOldAlgo->myBaseDocumentLab, true, true, true, true); +} + +void Selector_Algo::storeBaseArray(const TDF_LabelList& theRef, const TDF_Label& theLast) +{ + Handle(TDataStd_ReferenceArray) anArray = + TDataStd_ReferenceArray::Set(myLab, kBASE_ARRAY, 0, theRef.Extent()); + Handle(TDataStd_ExtStringList) anEntries; // entries of references to external document + const TDF_Label aThisDocRoot = myLab.Root(); + TDF_LabelList::Iterator aBIter(theRef); + for(int anIndex = 0; true; aBIter.Next(), anIndex++) { + const TDF_Label& aLab = aBIter.More() ? aBIter.Value() : theLast; + // check this is a label of this document + if (aLab.Root().IsEqual(aThisDocRoot)) { + anArray->SetValue(anIndex, aLab); + } else { // store reference to external document as an entry-string + if (anEntries.IsNull()) { + anEntries = TDataStd_ExtStringList::Set(myLab, kBASE_LIST); + } + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aLab, anEntry); + anEntries->Append(anEntry); + anArray->SetValue(anIndex, aThisDocRoot); // stored root means it is external reference + } + if (!aBIter.More()) + break; + } +} + +bool Selector_Algo::restoreBaseArray(TDF_LabelList& theRef, TDF_Label& theLast) +{ + const TDF_Label aThisDocRoot = myLab.Root(); + Handle(TDataStd_ExtStringList) anEntries; // entries of references to external document + TDataStd_ListOfExtendedString::Iterator anIter; + Handle(TDataStd_ReferenceArray) anArray; + if (myLab.FindAttribute(kBASE_ARRAY, anArray)) { + int anUpper = anArray->Upper(); + for(int anIndex = anArray->Lower(); anIndex <= anUpper; anIndex++) { + TDF_Label aLab = anArray->Value(anIndex); + if (aLab.IsEqual(aThisDocRoot)) { // external document reference + if (myBaseDocumentLab.IsNull()) + return false; + if (anEntries.IsNull()) { + if (!myLab.FindAttribute(kBASE_LIST, anEntries)) + return false; + anIter.Initialize(anEntries->List()); + } + if (!anIter.More()) + return false; + TDF_Tool::Label(myBaseDocumentLab.Data(), anIter.Value(), aLab); + anIter.Next(); + } + if (anIndex == anUpper) { + theLast = aLab; + } else { + theRef.Append(aLab); + } + } + return true; + } + return false; +} + +void Selector_Algo::store(const TopoDS_Shape theShape) +{ + TNaming_Builder aBuilder(myLab); + aBuilder.Select(theShape, theShape); +} + +bool Selector_Algo::sameGeometry(const TopoDS_Shape theShape1, const TopoDS_Shape theShape2) { + if (!theShape1.IsNull() && !theShape2.IsNull() && theShape1.ShapeType() == theShape2.ShapeType()) + { + if (theShape1.ShapeType() == TopAbs_FACE) { // check surfaces + TopLoc_Location aLoc1, aLoc2; + TopoDS_Face aFace1 = TopoDS::Face(theShape1); + Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(aFace1, aLoc1); + TopoDS_Face aFace2 = TopoDS::Face(theShape2); + Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(aFace2, aLoc2); + return aSurf1 == aSurf2 && aLoc1.IsEqual(aLoc2); + } else if (theShape1.ShapeType() == TopAbs_EDGE) { // check curves + TopLoc_Location aLoc1, aLoc2; + Standard_Real aFirst, aLast; + TopoDS_Edge anEdge1 = TopoDS::Edge(theShape1); + Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(anEdge1, aLoc1, aFirst, aLast); + TopoDS_Edge anEdge2 = TopoDS::Edge(theShape2); + Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(anEdge2, aLoc2, aFirst, aLast); + return aCurve1 == aCurve2 && aLoc1.IsEqual(aLoc2); + } + } + return false; +} + +TopoDS_Shape Selector_Algo::value() +{ + Handle(TNaming_NamedShape) aNS; + if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + return aNS->Get(); + return TopoDS_Shape(); // empty, error shape +} + +Selector_Algo* Selector_Algo::restoreByLab(TDF_Label theLab, TDF_Label theBaseDocLab) +{ + Handle(TDataStd_Integer) aTypeAttr; + if (!theLab.FindAttribute(kSEL_TYPE, aTypeAttr)) + return NULL; + Selector_Type aType = Selector_Type(aTypeAttr->Get()); + Selector_Algo* aResult = NULL; + switch (aType) { + case SELTYPE_CONTAINER: { + aResult = new Selector_Container; + break; + } + case SELTYPE_INTERSECT: { + aResult = new Selector_Intersect; + break; + } + case SELTYPE_MODIFICATION: { + aResult = new Selector_Modify; + break; + } + case SELTYPE_PRIMITIVE: { + aResult = new Selector_Primitive; + break; + } + case SELTYPE_FILTER_BY_NEIGHBOR: { + aResult = new Selector_FilterByNeighbors; + break; + } + case SELTYPE_WEAK_NAMING: { + aResult = new Selector_WeakName; + break; + } + default: { // unknown case + } + } + if (aResult) { + aResult->myLab = theLab; + aResult->myBaseDocumentLab = theBaseDocLab; + aResult->myGeometricalNaming = theLab.IsAttribute(kGEOMETRICAL_NAMING); + if (!aResult->restore()) { + delete aResult; + aResult = NULL; + } + } + return aResult; +} + +Selector_Algo* Selector_Algo::restoreByName(TDF_Label theLab, TDF_Label theBaseDocLab, + std::string theName, const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming, + Selector_NameGenerator* theNameGenerator, TDF_Label& theContextLab) +{ + Selector_Algo* aResult = NULL; + if (theName[0] == '[') { // intersection or container + switch(theShapeType) { + case TopAbs_COMPOUND: + case TopAbs_COMPSOLID: + case TopAbs_SHELL: + case TopAbs_WIRE: + aResult = new Selector_Container; + break; + case TopAbs_VERTEX: + case TopAbs_EDGE: + case TopAbs_FACE: + aResult = new Selector_Intersect; + break; + default:; + } + } else if (theName[0] == '(') { // filter by neighbors + aResult = new Selector_FilterByNeighbors; + } else if (theName.find(pureWeakNameID()) == 0) { // weak naming identifier + aResult = new Selector_WeakName; + } else if (theName.find('&') != std::string::npos) { // modification + aResult = new Selector_Modify; + } else { // primitive + aResult = new Selector_Primitive; + } + if (aResult) { + aResult->myLab = theLab; + aResult->myBaseDocumentLab = theBaseDocLab; + aResult->myGeometricalNaming = theGeomNaming; + theContextLab = aResult->restoreByName(theName, theShapeType, theNameGenerator); + if (theContextLab.IsNull()) { + delete aResult; + aResult = NULL; + } + } + return aResult; +} + +void Selector_Algo::storeType(const Selector_Type theType) +{ + myLab.ForgetAllAttributes(true); + TDataStd_Integer::Set(myLab, kSEL_TYPE, (int)(theType)); + if (myGeometricalNaming) + TDataStd_UAttribute::Set(myLab, kGEOMETRICAL_NAMING); +} + +/// Returns true if theSub is in theContext shape +static bool isInContext(const TopoDS_Shape& theContext, const TopoDS_Shape& theSub) { + for(TopExp_Explorer anExp(theContext, theSub.ShapeType()); anExp.More(); anExp.Next()) { + if (anExp.Current().IsSame(theSub)) + return true; + } + return false; +} + +bool Selector_Algo::findNewVersion(const TopoDS_Shape& theContext, TopoDS_Shape& theResult) const +{ + if (theResult.IsNull()) + return false; + if (!TNaming_Tool::HasLabel(myLab, theResult)) { + if (theResult.ShapeType() == TopAbs_COMPOUND) { // do it for all elements of compound + BRep_Builder aBuilder; + TopoDS_Compound aResultingCompound; + aBuilder.MakeCompound(aResultingCompound); + bool aWasChanged = false; + for (TopoDS_Iterator anIter(theResult); anIter.More(); anIter.Next()) { + TopoDS_Shape aSub = anIter.Value(); + if (findNewVersion(theContext, aSub)) + aWasChanged = true; + aBuilder.Add(aResultingCompound, aSub); + } + if (aWasChanged) + theResult = aResultingCompound; + return aWasChanged; + } + } else { + // check theResult is in theContext + if (isInContext(theContext, theResult)) + return false; + // searching the next modifications of the result shape in document + TopTools_MapOfShape aResultShapes; + for(TNaming_NewShapeIterator aBaseIter(theResult, myLab); aBaseIter.More(); aBaseIter.Next()) + { + TNaming_Evolution anEvolution = aBaseIter.NamedShape()->Evolution(); + if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + TopoDS_Shape aNextModification = aBaseIter.Shape(); + if (aNextModification.IsNull()) + continue; + if (isInContext(theContext, aNextModification)) + aResultShapes.Add(aNextModification); + else if (findNewVersion(theContext, aNextModification)) + aResultShapes.Add(aNextModification); + } + } + if (aResultShapes.IsEmpty()) + return false; + if (aResultShapes.Size() == 1) { + theResult = TopTools_MapIteratorOfMapOfShape(aResultShapes).Value(); + } else { // make a compound of all results + BRep_Builder aBuilder; + TopoDS_Compound aResultingCompound; + aBuilder.MakeCompound(aResultingCompound); + for(TopTools_MapIteratorOfMapOfShape anIter(aResultShapes); anIter.More(); anIter.Next()) + aBuilder.Add(aResultingCompound, anIter.Value()); + theResult = aResultingCompound; + } + return true; + } + return false; +} diff --git a/src/Selector/Selector_Algo.h b/src/Selector/Selector_Algo.h new file mode 100644 index 000000000..1492c4658 --- /dev/null +++ b/src/Selector/Selector_Algo.h @@ -0,0 +1,172 @@ +// 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 +// + +#ifndef Selector_Algo_H_ +#define Selector_Algo_H_ + +#include "Selector.h" + +#include +#include +#include +#include + +class Selector_NameGenerator; + +/**\class Selector_Selector + * \ingroup DataModel + * \brief Base class for all kinds of selection algorithms. + */ +class Selector_Algo +{ + TopAbs_ShapeEnum myShapeType; ///< type of this shape + + TDF_Label myLab; ///< label where this also may be located + TDF_Label myBaseDocumentLab; ///< an access-label of the document that may contain initial shapes + bool myGeometricalNaming; ///< flag that indicates that geometrical naming selection is enabled + bool myAlwaysGeometricalNaming; ///< to enable geometrical naming from beginning, at select + bool myUseNeighbors; ///< to use neighbors algorithms + bool myUseIntersections; ///< to use intersections algorithms + +public: + /// Type of a selector algorithm: on this type depends what is stored in this label and how to + /// restore it on update. + enum Selector_Type { + SELTYPE_CONTAINER, ///< just a container of sub-elements, keeps the shape type of container + SELTYPE_INTERSECT, ///< sub-shape is intersection of higher level objects + SELTYPE_PRIMITIVE, ///< sub-shape found as a primitive on some label + SELTYPE_MODIFICATION, ///< modification of base shapes to the final label + SELTYPE_FILTER_BY_NEIGHBOR, ///< identification by neighbor shapes in context + SELTYPE_WEAK_NAMING, ///< pure weak naming by weak index in context + }; + + /// Initializes the algorithm + SELECTOR_EXPORT Selector_Algo(); + + /// Initializes the selector structure on the label. + /// Stores the name data to restore after modification. + /// \param theContext whole shape that contains the selected sub-shape + /// \param theValue selected subshape + /// \param theGeometricalNaming treats selection with equal surfaces as one + /// \param theUseNeighbors enables searching algorithm by neighbors + /// \param theUseIntersections enables searching algorithm by intersection of higher level shapes + SELECTOR_EXPORT static Selector_Algo* select( + const TopoDS_Shape theContext, const TopoDS_Shape theValue, + const TDF_Label theAccess, const TDF_Label theBaseDocument, + const bool theGeometricalNaming = false, + const bool theUseNeighbors = true, const bool theUseIntersections = true, + const bool theAlwaysGeometricalNaming = false); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() = 0; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() = 0; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) = 0; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) = 0; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) = 0; + /// Returns the current sub-shape value (null if can not resolve) + SELECTOR_EXPORT TopoDS_Shape value(); + /// Restores sub-algorithm of a given type by the storage-label + SELECTOR_EXPORT static Selector_Algo* restoreByLab(TDF_Label theLab, TDF_Label theBaseDocLab); + /// Restores the selected sub-algorithm by the naming name. + /// Returns not empty label of the context. + SELECTOR_EXPORT static Selector_Algo* restoreByName( + TDF_Label theLab, TDF_Label theBaseDocLab, std::string theName, + const TopAbs_ShapeEnum theShapeType, const bool theGeomNaming, + Selector_NameGenerator* theNameGenerator, TDF_Label& theContextLab); + + /// Returns true if the given shapes are based on the same geometry + static bool sameGeometry(const TopoDS_Shape theShape1, const TopoDS_Shape theShape2); + + /// Creates a new selection algorithm for selection of all topology based on the same geometry + SELECTOR_EXPORT static Selector_Algo* relesectWithAllGeometry( + Selector_Algo* theOldAlgo, const TopoDS_Shape theContext); + /// Sets geometrical naming flag to true + void setGeometricalNaming() + {myGeometricalNaming = true;} + +protected: + /// Returns label where this algorithm is attached to, or just an access label to the document + const TDF_Label& label() const + {return myLab;} + /// Stores the array of references to theLab: references to elements of ref-list, then the last + void storeBaseArray(const TDF_LabelList& theRef, const TDF_Label& theLast); + /// Restores references to the labels: references to elements of ref-list, then the last + bool restoreBaseArray(TDF_LabelList& theRef, TDF_Label& theLast); + /// Stores result of selection at the given label + void store(const TopoDS_Shape theShape); + /// Returns an access-label of the document that may contain initial shapes + const TDF_Label& baseDocument() const + {return myBaseDocumentLab;} + /// Returns the geometrical naming flag + bool geometricalNaming() const + {return myGeometricalNaming;} + /// Returns always geometrical naming flag + bool alwaysGeometricalNaming() const + {return myAlwaysGeometricalNaming;} + /// Returns use neighbors flag + bool useNeighbors() const + {return myUseNeighbors;} + /// Returns use intersections flag + bool useIntersections() const + {return myUseIntersections;} + /// Returns GUID for the weak index (integer attribute) of the sub-shape + static const Standard_GUID& weakID() + { + static const Standard_GUID kWEAK_INDEX("e9373a61-cabc-4ee8-aabf-aea47c62ed87"); + return kWEAK_INDEX; + } + /// Returns GUID for the type of the shape, stored in case it is intersection or container + static const Standard_GUID& shapeTypeID() + { + static const Standard_GUID kSHAPE_TYPE("864b3267-cb9d-4107-bf58-c3ce1775b171"); + return kSHAPE_TYPE; + } + /// string identifier of the weak name in modification or intersection types of algorithm + static const std::string& weakNameID() + { + static const std::string kWEAK_NAME_IDENTIFIER = "weak_name_"; + return kWEAK_NAME_IDENTIFIER; + } + /// string identifier of the pure weak name + static const std::string& pureWeakNameID() + { + static const std::string kPURE_WEAK_NAME_IDENTIFIER = "_weak_name_"; + return kPURE_WEAK_NAME_IDENTIFIER; + } + /// Stores the type of an algorithm in the data tree (in myLab) + void storeType(const Selector_Type theType); + + /// Searches the newer version of the shape in the document if the base shape does not + /// belong to context. Returns it in theResult (if any). Returns true is theResult is changed. + bool findNewVersion(const TopoDS_Shape& theContext, TopoDS_Shape& theResult) const; +}; + +#endif diff --git a/src/Selector/Selector_AlgoWithSubs.cpp b/src/Selector/Selector_AlgoWithSubs.cpp new file mode 100644 index 000000000..c25014b5c --- /dev/null +++ b/src/Selector/Selector_AlgoWithSubs.cpp @@ -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 +// + +#include + +Selector_AlgoWithSubs::Selector_AlgoWithSubs() : Selector_Algo() +{} + +void Selector_AlgoWithSubs::clearSubAlgos() +{ + std::list::iterator anAlgo = mySubSelList.begin(); + for(; anAlgo != mySubSelList.end(); anAlgo++) { + delete *anAlgo; + } + mySubSelList.clear(); +} + +Selector_AlgoWithSubs::~Selector_AlgoWithSubs() +{ + clearSubAlgos(); +} + +TDF_Label Selector_AlgoWithSubs::newSubLabel() +{ + return label().FindChild(int(mySubSelList.size() + 1)); +} + +bool Selector_AlgoWithSubs::append(Selector_Algo* theAlgo, const bool theEraseIfNull) +{ + if (theAlgo) { + mySubSelList.push_back(theAlgo); + return true; + } + if (theEraseIfNull) + clearSubAlgos(); + return false; +} + +std::list& Selector_AlgoWithSubs::list() +{ + return mySubSelList; +} diff --git a/src/Selector/Selector_AlgoWithSubs.h b/src/Selector/Selector_AlgoWithSubs.h new file mode 100644 index 000000000..994953caf --- /dev/null +++ b/src/Selector/Selector_AlgoWithSubs.h @@ -0,0 +1,51 @@ +// 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 +// + +#ifndef Selector_AlgoWithSubs_H_ +#define Selector_AlgoWithSubs_H_ + +#include "Selector_Algo.h" + +#include + +/**\class Selector_AlgoWithSubs + * \ingroup DataModel + * \brief Kind of selection algorithm: generic algorithm that contains sub-algorithms inside. + * It is base for Container, Intersection and FilterByNeighbours algorithms. + */ +class Selector_AlgoWithSubs: public Selector_Algo +{ + std::list mySubSelList; ///< list of sub-algorithms +public: + /// Initializes selector + Selector_AlgoWithSubs(); + /// Destructor + virtual ~Selector_AlgoWithSubs(); + /// Erases the sub-algorithms stored + void clearSubAlgos(); + /// Returns the next label for a new sub-selector created + TDF_Label newSubLabel(); + /// Appends a new algorithm to the list, erases list if it is null (failed) + bool append(Selector_Algo* theAlgo, const bool theEraseIfNull = true); + /// Returns the stored list of sub-algorithms. + std::list& list(); +}; + +#endif diff --git a/src/Selector/Selector_Container.cpp b/src/Selector/Selector_Container.cpp new file mode 100644 index 000000000..6ef129ae5 --- /dev/null +++ b/src/Selector/Selector_Container.cpp @@ -0,0 +1,192 @@ +// 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 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Selector_Container::Selector_Container() : Selector_AlgoWithSubs() +{} + +bool Selector_Container::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue) +{ + myShapeType = theValue.ShapeType(); + + // iterate all sub-shapes and select them on sublabels + for(TopoDS_Iterator aSubIter(theValue); aSubIter.More(); aSubIter.Next()) { + Selector_Algo* aSubAlgo = Selector_Algo::select(theContext, aSubIter.Value(), + newSubLabel(), baseDocument(), + false, useNeighbors(), useIntersections()); //for subs no geometrical naming allowed + if (!append(aSubAlgo)) + return false; + } + return true; +} + +void Selector_Container::store() +{ + storeType(Selector_Algo::SELTYPE_CONTAINER); + // store all sub-selectors + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + (*aSubSel)->store(); + } + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); +} + +bool Selector_Container::restore() +{ + Handle(TDataStd_Integer) aShapeTypeAttr; + if (!label().FindAttribute(shapeTypeID(), aShapeTypeAttr)) + return false; + myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get()); + // restore sub-selectors + bool aSubResult = true; + for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) { + Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument()); + if (!append(aSubSel, false)) { + break; // some empty label left in the end + } + } + return true; +} + +TDF_Label Selector_Container::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + myShapeType = theShapeType; + TDF_Label aContext; + for(size_t aStart = 0; aStart != std::string::npos; aStart = theName.find('[', aStart + 1)) { + size_t anEndPos = theName.find(']', aStart + 1); + if (anEndPos != std::string::npos) { + // there could be sub-intersections, so, [[...]] case; searching for other open-bracket + size_t aNextStart = theName.find('[', aStart + 1); + while(aNextStart != std::string::npos && aNextStart < anEndPos) { + anEndPos = theName.find(']', anEndPos + 1); + if (anEndPos == std::string::npos) { + return TDF_Label(); // invalid parentheses + } + aNextStart = theName.find('[', aNextStart + 1); + } + if (anEndPos == std::string::npos) + return TDF_Label(); // invalid parentheses + std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; + switch (myShapeType) { + case TopAbs_COMPSOLID: aSubShapeType = TopAbs_SOLID; break; + case TopAbs_WIRE: aSubShapeType = TopAbs_EDGE; break; + default:; + } + TDF_Label aSubContext; + Selector_Algo* aSubSel = + Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, aSubShapeType, + geometricalNaming(), theNameGenerator, aSubContext); + if (!append(aSubSel)) + return TDF_Label(); + + if (aSubContext.IsNull()) { + delete aSubSel; + clearSubAlgos(); + return TDF_Label(); + } + if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) { + if (!theNameGenerator->isLater(aContext, aSubContext)) + aContext = aSubContext; + } else { + aContext = aSubContext; + } + } else + return TDF_Label(); // invalid parentheses + aStart = anEndPos; // for recursive parenthesis set start on the current end + } + return aContext; +} + +bool Selector_Container::solve(const TopoDS_Shape& theContext) +{ + TopoDS_Shape aResult; + + TopoDS_Builder aBuilder; + switch(myShapeType) { + case TopAbs_COMPOUND: { + TopoDS_Compound aComp; + aBuilder.MakeCompound(aComp); + aResult = aComp; + break; + } + case TopAbs_COMPSOLID: { + TopoDS_CompSolid aComp; + aBuilder.MakeCompSolid(aComp); + aResult = aComp; + break; + } + case TopAbs_SHELL: { + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + aResult = aShell; + break; + } + case TopAbs_WIRE: { + TopoDS_Wire aWire; + aBuilder.MakeWire(aWire); + aResult = aWire; + break; + } + } + TopoDS_ListOfShape aSubSelectorShapes; + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + if (!(*aSubSel)->solve(theContext)) { + return false; + } + aBuilder.Add(aResult, (*aSubSel)->value()); + } + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } + return false; +} + +std::string Selector_Container::name(Selector_NameGenerator* theNameGenerator) +{ + std::string aResult; + // add names of sub-components one by one in "[]" + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + aResult += '['; + aResult += (*aSubSel)->name(theNameGenerator); + aResult += ']'; + } + return aResult; +} diff --git a/src/Selector/Selector_Container.h b/src/Selector/Selector_Container.h new file mode 100644 index 000000000..668b651b3 --- /dev/null +++ b/src/Selector/Selector_Container.h @@ -0,0 +1,64 @@ +// 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 +// + +#ifndef Selector_Container_H_ +#define Selector_Container_H_ + +#include "Selector_AlgoWithSubs.h" + +#include + +/**\class Selector_Container + * \ingroup DataModel + * \brief Kind of selection algorithm: selected shape is a container of sub-shapes that must + * be named one by one. + */ +class Selector_Container: public Selector_AlgoWithSubs +{ + TopAbs_ShapeEnum myShapeType; ///< type of this container +public: + /// Initializes the selection of this kind + SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; +private: + /// Initializes selector + Selector_Container(); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/Selector/Selector_FilterByNeighbors.cpp b/src/Selector/Selector_FilterByNeighbors.cpp new file mode 100644 index 000000000..09e0ab314 --- /dev/null +++ b/src/Selector/Selector_FilterByNeighbors.cpp @@ -0,0 +1,369 @@ +// 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 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// array of the neighbor levels +static const Standard_GUID kLEVELS_ARRAY("ee4c4b45-e859-4e86-aa4f-6eac68e0ca1f"); + +Selector_FilterByNeighbors::Selector_FilterByNeighbors() : Selector_AlgoWithSubs() +{} + +/// Searches neighbor of theLevel of neighborhood to theValue in theContex +static void findNeighbors(const TopoDS_Shape theContext, const TopoDS_Shape theValue, + const int theLevel, TopTools_MapOfShape& theResult) +{ + TopAbs_ShapeEnum aConnectorType = TopAbs_VERTEX; // type of the connector sub-shapes + if (theValue.ShapeType() == TopAbs_FACE) + aConnectorType = TopAbs_EDGE; + TopTools_MapOfShape aNBConnectors; // connector shapes that already belong to neighbors + for(TopExp_Explorer aValExp(theValue, aConnectorType); aValExp.More(); aValExp.Next()) { + aNBConnectors.Add(aValExp.Current()); + } + + TopTools_MapOfShape alreadyProcessed; + alreadyProcessed.Add(theValue); + + for(int aLevel = 1; aLevel <= theLevel; aLevel++) { + TopoDS_ListOfShape aGoodCandidates; + TopExp_Explorer aCandidate(theContext, theValue.ShapeType()); + for(; aCandidate.More(); aCandidate.Next()) { + if (alreadyProcessed.Contains(aCandidate.Current())) + continue; + TopExp_Explorer aCandConnector(aCandidate.Current(), aConnectorType); + for(; aCandConnector.More(); aCandConnector.Next()) { + if (aNBConnectors.Contains(aCandConnector.Current())) // candidate is neighbor + break; + } + if (aCandConnector.More()) { + if (aLevel == theLevel) { // add a NB into result: it is connected to other neighbors + theResult.Add(aCandidate.Current()); + } else { // add to the NB of the current level + aGoodCandidates.Append(aCandidate.Current()); + } + } + } + if (aLevel != theLevel) { // good candidates are added to neighbor of this level by connectors + for(TopoDS_ListOfShape::Iterator aGood(aGoodCandidates); aGood.More(); aGood.Next()) { + TopExp_Explorer aGoodConnector(aGood.Value(), aConnectorType); + for(; aGoodConnector.More(); aGoodConnector.Next()) { + aNBConnectors.Add(aGoodConnector.Current()); + } + alreadyProcessed.Add(aGood.Value()); + } + } + } +} + +/// Searches the neighbor shape by neighbors defined in theNB in theContext shape +static const TopoDS_Shape findNeighbor(const TopoDS_Shape theContext, + const std::list >& theNB, const bool theGeometrical) +{ + // searching for neighbors with minimum level + int aMinLevel = 0; + std::list >::const_iterator aNBIter = theNB.cbegin(); + for(; aNBIter != theNB.cend(); aNBIter++) { + if (aMinLevel == 0 || aNBIter->second < aMinLevel) { + aMinLevel = aNBIter->second; + } + } + // collect all neighbors which are neighbors of sub-shapes with minimum level + bool aFirst = true; + TopoDS_ListOfShape aMatches; + for(aNBIter = theNB.cbegin(); aNBIter != theNB.cend(); aNBIter++) { + if (aNBIter->second == aMinLevel) { + TopTools_MapOfShape aThisNBs; + findNeighbors(theContext, aNBIter->first, aMinLevel, aThisNBs); + // aMatches must contain common part of all NBs lists + for(TopTools_MapOfShape::Iterator aThisNB(aThisNBs); aThisNB.More(); aThisNB.Next()) { + if (aFirst) { + aMatches.Append(aThisNB.Value()); + } else { + // remove all in aMatches which are not in this NBs + for(TopoDS_ListOfShape::Iterator aMatch(aMatches); aMatch.More(); ) { + if (aThisNBs.Contains(aMatch.Value())) { + aMatch.Next(); + } else { + aMatches.Remove(aMatch); + } + } + } + } + aFirst = false; + } + } + if (aMatches.IsEmpty()) + return TopoDS_Shape(); // not found any candidate + if (aMatches.Extent() == 1) + return aMatches.First(); // already found good candidate + TopoDS_Compound aResultCompound; // in case of geometrical name and many candidates + // iterate all matches to find by other (higher level) neighbors the best candidate + TopoDS_Shape aGoodCandidate; + TopTools_MapOfShape aGoodCandidates; // already added good candidates to the map + for(TopoDS_ListOfShape::Iterator aCandidate(aMatches); aCandidate.More(); aCandidate.Next()) { + bool aValidCadidate = true; + for(int aLevel = aMinLevel + 1; true; aLevel++) { + bool aFooundHigherLevel = false; + TopoDS_ListOfShape aLevelNBs; + for(aNBIter = theNB.cbegin(); aNBIter != theNB.cend(); aNBIter++) { + if (aNBIter->second == aLevel) + aLevelNBs.Append(aNBIter->first); + else if (aNBIter->second >= aLevel) + aFooundHigherLevel = true; + } + if (!aFooundHigherLevel && aLevelNBs.IsEmpty()) { // iterated all, so, good candidate + if (aGoodCandidate.IsNull()) { + aGoodCandidate = aCandidate.Value(); + } else { // another good candidate + if (theGeometrical && Selector_Algo::sameGeometry(aGoodCandidate, aCandidate.Value())) { + if (!aGoodCandidates.Add(aCandidate.Value())) + break; + static TopoDS_Builder aBuilder; + if (aResultCompound.IsNull()) { + aBuilder.MakeCompound(aResultCompound); + aBuilder.Add(aResultCompound, aGoodCandidate); + } + aBuilder.Add(aResultCompound, aCandidate.Value()); + } else + return TopoDS_Shape(); + } + } + if (!aLevelNBs.IsEmpty()) { + TopTools_MapOfShape aNBsOfCandidate; + findNeighbors(theContext, aCandidate.Value(), aLevel, aNBsOfCandidate); + // check all stored neighbors are in the map of real neighbors + for(TopoDS_ListOfShape::Iterator aLevIter(aLevelNBs); aLevIter.More(); aLevIter.Next()) { + if (!aNBsOfCandidate.Contains(aLevIter.Value())) { + aValidCadidate = false; + break; + } + } + } + if (!aValidCadidate) // candidate is not valid, break the checking + break; + } + } + if (!aResultCompound.IsNull()) + return aResultCompound; + return aGoodCandidate; +} + +bool Selector_FilterByNeighbors::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue) +{ + myShapeType = theValue.ShapeType(); + // searching by neighbors + std::list > aNBs; /// neighbor sub-shape -> level of neighborhood + for(int aLevel = 1; true; aLevel++) { + TopTools_MapOfShape aNewNB; + findNeighbors(theContext, theValue, aLevel, aNewNB); + if (aNewNB.Extent() == 0) { // there are no neighbors of the given level, stop iteration + break; + } + // iterate by the order in theContext to keep same naming names + TopExp_Explorer anOrder(theContext, theValue.ShapeType()); + TopTools_MapOfShape alreadyProcessed; + for (; anOrder.More(); anOrder.Next()) { + if (alreadyProcessed.Add(anOrder.Current()) && aNewNB.Contains(anOrder.Current())) { + TopoDS_Shape aNewNBShape = anOrder.Current(); + // check which can be named correctly, without "by neighbors" type + Selector_Algo* aSubAlgo = Selector_Algo::select(theContext, aNewNBShape, + newSubLabel(), baseDocument(), geometricalNaming(), false, useIntersections()); + if (aSubAlgo) { + // add to list of good NBs + aNBs.push_back(std::pair(aNewNBShape, aLevel)); + } + delete aSubAlgo; // don't keep this sub-algo until all subs and whole validity are checked + } + } + TopoDS_Shape aResult = findNeighbor(theContext, aNBs, geometricalNaming()); + if (!aResult.IsNull() && aResult.IsSame(theValue)) { + std::list >::iterator aNBIter = aNBs.begin(); + for(; aNBIter != aNBs.end(); aNBIter++) { + Selector_Algo* aSubAlgo = Selector_Algo::select(theContext, aNBIter->first, + newSubLabel(), baseDocument(), geometricalNaming(), false, useIntersections()); + if (append(aSubAlgo)) { + myNBLevel.push_back(aNBIter->second); + } else { + delete aSubAlgo; + } + } + return true; + } + } + return false; +} + +void Selector_FilterByNeighbors::store() +{ + storeType(Selector_Algo::SELTYPE_FILTER_BY_NEIGHBOR); + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); + // store numbers of levels corresponded to the neighbors in sub-selectors + Handle(TDataStd_IntegerArray) anArray = + TDataStd_IntegerArray::Set(label(), kLEVELS_ARRAY, 0, int(myNBLevel.size()) - 1); + std::list::iterator aLevel = myNBLevel.begin(); + for(int anIndex = 0; aLevel != myNBLevel.end(); aLevel++, anIndex++) { + anArray->SetValue(anIndex, Abs(*aLevel)); + } + // store all sub-selectors + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + (*aSubSel)->store(); + } +} + +bool Selector_FilterByNeighbors::restore() +{ + Handle(TDataStd_Integer) aShapeTypeAttr; + if (!label().FindAttribute(shapeTypeID(), aShapeTypeAttr)) + return false; + myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get()); + // restore levels indices + Handle(TDataStd_IntegerArray) anArray; + if (!label().FindAttribute(kLEVELS_ARRAY, anArray)) + return false; + for(int anIndex = 0; anIndex <= anArray->Upper(); anIndex++) { + myNBLevel.push_back(anArray->Value(anIndex)); + } + // restore sub-selectors + bool aSubResult = true; + for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) { + Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument()); + if (!append(aSubSel, false)) { + if (!aSub.Value().HasAttribute()) + break; // some empty label left in the end + // some selector fails, try to use rest selectors, myNBLevel becomes negative: unused + if (myNBLevel.size() > list().size()) { + std::list::iterator aListIter = myNBLevel.begin(); + for(int a = 0; a < list().size(); a++) + aListIter++; + *aListIter = -*aListIter; + list().push_back(NULL); + } + } + } + return myNBLevel.size() == list().size() && !myNBLevel.empty(); +} + +TDF_Label Selector_FilterByNeighbors::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + myShapeType = theShapeType; + TDF_Label aContext; + for (size_t aStart = 0; aStart != std::string::npos; + aStart = theName.find('(', aStart + 1)) { + size_t anEndPos = theName.find(')', aStart + 1); + if (anEndPos != std::string::npos) { + std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + TDF_Label aSubContext; + Selector_Algo* aSubSel = + Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, myShapeType, + geometricalNaming(), theNameGenerator, aSubContext); + if (!append(aSubSel)) + return TDF_Label(); + + if (aSubContext.IsNull()) { + delete aSubSel; + clearSubAlgos(); + return TDF_Label(); + } + if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) { + if (!theNameGenerator->isLater(aContext, aSubContext)) + aContext = aSubContext; + } else { + aContext = aSubContext; + } + if (!aContext.IsNull()) // for filters by neighbor the latest context shape is vital + aContext = theNameGenerator->newestContext(aContext); + + // searching for the level index + std::string aLevel; + for (anEndPos++; anEndPos != std::string::npos && + theName[anEndPos] != '(' && theName[anEndPos] != 0; + anEndPos++) { + aLevel += theName[anEndPos]; + } + if (aLevel.empty()) + myNBLevel.push_back(1); // by default it is 1 + else { + int aNum = atoi(aLevel.c_str()); + if (aNum > 0) + myNBLevel.push_back(aNum); + else + return TDF_Label(); // invalid number + } + } else + return TDF_Label(); // invalid parentheses + } + return aContext; +} + +bool Selector_FilterByNeighbors::solve(const TopoDS_Shape& theContext) +{ + TopoDS_Shape aResult; + + std::list > aNBs; /// neighbor sub-shape -> level of neighborhood + std::list::iterator aLevel = myNBLevel.begin(); + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++, aLevel++) { + if (*aLevel < 0) + continue; // skip because sub-selector is not good + if ((*aSubSel)->solve(theContext)) { + aNBs.push_back(std::pair((*aSubSel)->value(), *aLevel)); + } + } + if (!aNBs.empty()) { + aResult = findNeighbor(theContext, aNBs, geometricalNaming()); + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } + } + return false; +} + +std::string Selector_FilterByNeighbors::name(Selector_NameGenerator* theNameGenerator) +{ + // (nb1)level_if_more_than_1(nb2)level_if_more_than_1(nb3)level_if_more_than_1 + std::string aResult; + std::list::iterator aLevel = myNBLevel.begin(); + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++, aLevel++) { + if (!*aSubSel) + continue; + aResult += "(" + (*aSubSel)->name(theNameGenerator) + ")"; + if (*aLevel > 1) { + std::ostringstream aLevelStr; + aLevelStr<<*aLevel; + aResult += aLevelStr.str(); + } + } + return aResult; +} diff --git a/src/Selector/Selector_FilterByNeighbors.h b/src/Selector/Selector_FilterByNeighbors.h new file mode 100644 index 000000000..721e4a923 --- /dev/null +++ b/src/Selector/Selector_FilterByNeighbors.h @@ -0,0 +1,66 @@ +// 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 +// + +#ifndef Selector_FilterByNeighbors_H_ +#define Selector_FilterByNeighbors_H_ + +#include "Selector_AlgoWithSubs.h" + +#include + +/**\class Selector_FilterByNeighbors + * \ingroup DataModel + * \brief Kind of selection algorithm: selected shape is identified by neighbor faces of + * the same type. Or neighbors of neighbors are considered, etc. + * be named one by one. + */ +class Selector_FilterByNeighbors: public Selector_AlgoWithSubs +{ + TopAbs_ShapeEnum myShapeType; ///< type of this shape + std::list myNBLevel; ///< list of integers corresponding to subs neighborhood level +public: + /// Initializes the selection of this kind + SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; +private: + /// Initializes selector + Selector_FilterByNeighbors(); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/Selector/Selector_Intersect.cpp b/src/Selector/Selector_Intersect.cpp new file mode 100644 index 000000000..5d9ab36b4 --- /dev/null +++ b/src/Selector/Selector_Intersect.cpp @@ -0,0 +1,308 @@ +// 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 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Selector_Intersect::Selector_Intersect() : Selector_AlgoWithSubs() +{ + myWeakIndex = -1; // no index by default +} + +// returns the sub-shapes of theSubType which belong to all theShapes (so, common or intersection) +static void commonShapes(const TopoDS_ListOfShape& theShapes, TopAbs_ShapeEnum theSubType, + TopoDS_ListOfShape& theResults) +{ + TopoDS_ListOfShape::iterator aSubSel = theShapes.begin(); + for(; aSubSel != theShapes.end(); aSubSel++) { + TopTools_MapOfShape aCurrentMap; + for(TopExp_Explorer anExp(*aSubSel, theSubType); anExp.More(); anExp.Next()) { + if (aCurrentMap.Add(anExp.Current()) && aSubSel == theShapes.begin()) + theResults.Append(anExp.Current()); + } + if (aSubSel != theShapes.begin()) { // remove from common shapes not in aCurrentMap + for(TopoDS_ListOfShape::Iterator aComIter(theResults); aComIter.More(); ) { + if (aCurrentMap.Contains(aComIter.Value())) + aComIter.Next(); + else + theResults.Remove(aComIter); + } + } + } +} + +bool Selector_Intersect::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue) +{ + if (!useIntersections()) + return false; + myShapeType = theValue.ShapeType(); + TopAbs_ShapeEnum aSelectionType = myShapeType; + // try to find the shape of the higher level type in the context shape + bool aFacesTried = false; // for identification of vertices, faces are tried, then edges + TopoDS_ListOfShape aLastCommon; // store not good commons, but which may be used for weak naming + TopoDS_ListOfShape aLastIntersectors; + while(aSelectionType != TopAbs_FACE || !aFacesTried) { + if (aSelectionType == TopAbs_FACE) { + if (theValue.ShapeType() != TopAbs_VERTEX) + break; + aFacesTried = true; + aSelectionType = TopAbs_EDGE; + } else + aSelectionType = TopAbs_FACE; + TopTools_MapOfShape anIntersectors; // shapes of aSelectionType that contain theValue + TopoDS_ListOfShape anIntList; // same as anIntersectors + for(TopExp_Explorer aSelExp(theContext, aSelectionType); aSelExp.More(); aSelExp.Next()) { + if (aSelectionType == TopAbs_EDGE && + BRep_Tool::Degenerated(TopoDS::Edge(aSelExp.Current()))) + continue; + TopExp_Explorer aSubExp(aSelExp.Current(), theValue.ShapeType()); + for(; aSubExp.More(); aSubExp.Next()) { + if (aSubExp.Current().IsSame(theValue)) { + if (anIntersectors.Add(aSelExp.Current())) + anIntList.Append(aSelExp.Current()); + break; + } + } + } + // check that solution is only one + TopoDS_ListOfShape aCommon; + commonShapes(anIntList, theValue.ShapeType(), aCommon); + if (aCommon.Extent() == 1 && aCommon.First().IsSame(theValue)) { + // name the intersectors + TopoDS_ListOfShape::Iterator anInt(anIntList); + for (; anInt.More(); anInt.Next()) { + Selector_Algo* aSubAlgo = Selector_Algo::select(theContext, anInt.Value(), + newSubLabel(), baseDocument(), geometricalNaming(), useNeighbors(), false); + if (!append(aSubAlgo)) + break; // if some selector is failed, stop and search another solution + } + if (!anInt.More()) { // all intersectors were correctly named + return true; + } + } else if (aCommon.Extent() > 1 && aLastCommon.IsEmpty()) { + aLastCommon = aCommon; + aLastIntersectors = anIntList; + } + } + if (aLastCommon.Extent() > 1) { + if (alwaysGeometricalNaming()) { + TopoDS_ListOfShape::Iterator aCommonIter(aLastCommon); + TopoDS_Shape aFirst = aCommonIter.Value(); + for(aCommonIter.Next(); aCommonIter.More(); aCommonIter.Next()) { + if (!sameGeometry(aFirst, aCommonIter.Value())) + break; + } + if (!aCommonIter.More()) { // all geometry is same, result is a compound + return true; + } + } + // weak naming to distinguish commons coming from intersection + Selector_NExplode aNexp(aLastCommon); + myWeakIndex = aNexp.index(theValue); + if (myWeakIndex != -1) { + // name the intersectors + TopoDS_ListOfShape::Iterator anInt(aLastIntersectors); + for (; anInt.More(); anInt.Next()) { + Selector_Algo* aSubAlgo = Selector_Algo::select(theContext, anInt.Value(), + newSubLabel(), baseDocument(), geometricalNaming(), useNeighbors(), false); + if (!append(aSubAlgo)) + break; // if some selector is failed, stop and search another solution + } + if (!anInt.More()) { // all intersectors were correctly named + return true; + } + } + } + return false; // solution does not found +} + +void Selector_Intersect::store() +{ + storeType(Selector_Algo::SELTYPE_INTERSECT); + // store all sub-selectors + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + (*aSubSel)->store(); + } + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); + if (myWeakIndex != -1) { + TDataStd_Integer::Set(label(), weakID(), myWeakIndex); + } +} + +bool Selector_Intersect::restore() +{ + Handle(TDataStd_Integer) aShapeTypeAttr; + if (!label().FindAttribute(shapeTypeID(), aShapeTypeAttr)) + return false; + myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get()); + // restore sub-selectors + bool aSubResult = true; + for(TDF_ChildIterator aSub(label(), false); aSub.More(); aSub.Next()) { + Selector_Algo* aSubSel = restoreByLab(aSub.Value(), baseDocument()); + if (!append(aSubSel, false)) { + break; // some empty label left in the end + } + } + Handle(TDataStd_Integer) aWeakInt; + if (label().FindAttribute(weakID(), aWeakInt)) { + myWeakIndex = aWeakInt->Get(); + } + return true; +} + +TDF_Label Selector_Intersect::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + myShapeType = theShapeType; + TDF_Label aContext; + for(size_t aStart = 0; aStart != std::string::npos; aStart = theName.find('[', aStart + 1)) { + size_t anEndPos = theName.find(']', aStart + 1); + if (anEndPos != std::string::npos) { + std::string aSubStr = theName.substr(aStart + 1, anEndPos - aStart - 1); + if (aSubStr.find(weakNameID()) == 0) { // weak name identifier + std::string aWeakIndex = aSubStr.substr(weakNameID().size()); + myWeakIndex = atoi(aWeakIndex.c_str()); + continue; + } + TopAbs_ShapeEnum aSubShapeType = TopAbs_FACE; + if (anEndPos != std::string::npos && anEndPos + 1 < theName.size()) { + char aShapeChar = theName[anEndPos + 1]; + if (theName[anEndPos + 1] != '[') { + switch(aShapeChar) { + case 'e': aSubShapeType = TopAbs_EDGE; break; + case 'v': aSubShapeType = TopAbs_VERTEX; break; + default:; + } + } + } + TDF_Label aSubContext; + Selector_Algo* aSubSel = + Selector_Algo::restoreByName(newSubLabel(), baseDocument(), aSubStr, aSubShapeType, + geometricalNaming(), theNameGenerator, aSubContext); + if (!append(aSubSel)) + return TDF_Label(); + + if (aSubContext.IsNull()) { + delete aSubSel; + clearSubAlgos(); + return TDF_Label(); + } + if (!aContext.IsNull() && !aContext.IsEqual(aSubContext)) { + if (!theNameGenerator->isLater(aContext, aSubContext)) + aContext = aSubContext; + } else { + aContext = aSubContext; + } + } else + return TDF_Label(); // invalid parentheses + } + return aContext; +} + +bool Selector_Intersect::solve(const TopoDS_Shape& theContext) +{ + TopoDS_Shape aResult; + TopoDS_ListOfShape aSubSelectorShapes; + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + if (!(*aSubSel)->solve(theContext)) { + return false; + } + aSubSelectorShapes.Append((*aSubSel)->value()); + } + TopoDS_ListOfShape aCommon; // common sub shapes in each sub-selector (a result) + commonShapes(aSubSelectorShapes, myShapeType, aCommon); + if (aCommon.Extent() != 1) { + if (myWeakIndex != -1) { + Selector_NExplode aNexp(aCommon); + aResult = aNexp.shape(myWeakIndex); + } else if (geometricalNaming() && aCommon.Extent() > 1) { + // check results are on the same geometry, create compound + TopoDS_ListOfShape::Iterator aCommonIter(aCommon); + TopoDS_Shape aFirst = aCommonIter.Value(); + for(aCommonIter.Next(); aCommonIter.More(); aCommonIter.Next()) { + if (!sameGeometry(aFirst, aCommonIter.Value())) + break; + } + if (!aCommonIter.More()) { // all geometry is same, create a result compound + TopoDS_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + for(aCommonIter.Initialize(aCommon); aCommonIter.More(); aCommonIter.Next()) { + aBuilder.Add(aCompound, aCommonIter.Value()); + } + aResult = aCompound; + } + } else { + return false; + } + } else { + aResult = aCommon.First(); + } + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } + return false; +} + +std::string Selector_Intersect::name(Selector_NameGenerator* theNameGenerator) +{ + std::string aResult; + // add names of sub-components one by one in "[]" +optionally [weak_name_1] + std::list::const_iterator aSubSel = list().cbegin(); + for(; aSubSel != list().cend(); aSubSel++) { + aResult += '['; + aResult += (*aSubSel)->name(theNameGenerator); + aResult += ']'; + TopoDS_Shape aSubVal = (*aSubSel)->value(); + if (!aSubVal.IsNull()) { + TopAbs_ShapeEnum aSubType = aSubVal.ShapeType(); + if (aSubType != TopAbs_FACE) { // in case the sub shape type must be stored + switch(aSubType) { + case TopAbs_EDGE: aResult += "e"; break; + case TopAbs_VERTEX: aResult += "v"; break; + default:; + } + } + } + } + if (myWeakIndex != -1) { + std::ostringstream aWeakStr; + aWeakStr<<"["< +// + +#ifndef Selector_Intersect_H_ +#define Selector_Intersect_H_ + +#include "Selector_AlgoWithSubs.h" + +#include + +/**\class Selector_Intersect + * \ingroup DataModel + * \brief Kind of selection algorithm: sub-shape is intersection of higher level objects. + */ +class Selector_Intersect: public Selector_AlgoWithSubs +{ + TopAbs_ShapeEnum myShapeType; ///< type of this shape + int myWeakIndex; ///< weak index in case intersection produces several shapes +public: + /// Initializes the selection of this kind + SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; +private: + /// Initializes selector + Selector_Intersect(); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/Selector/Selector_Modify.cpp b/src/Selector/Selector_Modify.cpp new file mode 100644 index 000000000..d7d5d47f4 --- /dev/null +++ b/src/Selector/Selector_Modify.cpp @@ -0,0 +1,339 @@ +// 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 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Selector_Modify::Selector_Modify() : Selector_Algo() +{ + myWeakIndex = -1; // no index by default +} + +// adds to theResult all labels that contain initial shapes for theValue located in theFinal +static void findBases(TDF_Label theAccess, Handle(TNaming_NamedShape) theFinal, + const TopoDS_Shape& theValue, + bool aMustBeAtFinal, const TDF_Label& theAdditionalDocument, TDF_LabelList& theResult) +{ + bool aFoundAnyShape = false; + TNaming_SameShapeIterator aLabIter(theValue, theAccess); + for(; aLabIter.More(); aLabIter.Next()) { + Handle(TNaming_NamedShape) aNS; + if (aLabIter.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + if (aMustBeAtFinal && aNS != theFinal) + continue; // looking for old at the same final label only + TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_PRIMITIVE) { + // check that this is not in the results already + const TDF_Label aResult = aNS->Label(); + TDF_LabelList::Iterator aResIter(theResult); + for(; aResIter.More(); aResIter.Next()) { + if (aResIter.Value().IsEqual(aResult)) + break; + } + if (!aResIter.More()) // not found, so add this new + theResult.Append(aResult); + aFoundAnyShape = true; + } + if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + for(TNaming_Iterator aThisIter(aNS); aThisIter.More(); aThisIter.Next()) { + if (aThisIter.NewShape().IsSame(theValue)) { + // continue recursively, null NS means that any NS are ok + findBases(theAccess, theFinal, aThisIter.OldShape(), + false, theAdditionalDocument, theResult); + aFoundAnyShape = true; + } + } + } + } + } + if (!aFoundAnyShape && !theAdditionalDocument.IsNull()) { // try to find in additional document + static TDF_Label anEmpty; + if (TNaming_Tool::HasLabel(theAdditionalDocument, theValue)) + findBases(theAdditionalDocument, Handle(TNaming_NamedShape)(), theValue, + false, anEmpty, theResult); + } +} + +/// Returns in theResults all shapes with history started in theBase and ended in theFinal +static void findFinals(const TDF_Label& anAccess, const TopoDS_Shape& theBase, + const TDF_Label& theFinal, + const TDF_Label& theAdditionalDoc, TopTools_MapOfShape& theResults) +{ + if (TNaming_Tool::HasLabel(anAccess, theBase)) { + for(TNaming_NewShapeIterator aBaseIter(theBase, anAccess); aBaseIter.More(); aBaseIter.Next()) + { + TNaming_Evolution anEvolution = aBaseIter.NamedShape()->Evolution(); + if (anEvolution == TNaming_GENERATED || anEvolution == TNaming_MODIFY) { + if (aBaseIter.NamedShape()->Label().IsEqual(theFinal)) { + theResults.Add(aBaseIter.Shape()); + } else { + findFinals(anAccess, aBaseIter.Shape(), theFinal, theAdditionalDoc, theResults); + } + } + } + } + if (!theAdditionalDoc.IsNull()) { // search additionally by the additional access label + static TDF_Label anEmpty; + findFinals(theAdditionalDoc, theBase, theFinal, anEmpty, theResults); + } +} + +void Selector_Modify::findModificationResult(TopoDS_ListOfShape& theCommon) { + for(TDF_LabelList::Iterator aBase(myBases); aBase.More(); aBase.Next()) { + TDF_Label anAdditionalDoc; // this document if base is started in extra document + if (aBase.Value().Root() != label().Root()) { + anAdditionalDoc = label(); + } + TopTools_MapOfShape aFinals; + for(TNaming_Iterator aBaseShape(aBase.Value()); aBaseShape.More(); aBaseShape.Next()) { + findFinals(aBase.Value(), aBaseShape.NewShape(), myFinal, anAdditionalDoc, aFinals); + } + if (!aFinals.IsEmpty()) { + if (theCommon.IsEmpty()) { // just copy all to common + for(TopTools_MapOfShape::Iterator aFinal(aFinals); aFinal.More(); aFinal.Next()) { + theCommon.Append(aFinal.Key()); + } + } else { // keep only shapes presented in both lists + for(TopoDS_ListOfShape::Iterator aCommon(theCommon); aCommon.More(); ) { + if (aFinals.Contains(aCommon.Value())) { + aCommon.Next(); + } else { // common is not found, remove it + theCommon.Remove(aCommon); + } + } + } + } + } +} + +bool Selector_Modify::select(NCollection_List& theModifList, + const TopoDS_Shape theContext, const TopoDS_Shape theValue) +{ + if (theModifList.Extent() > 1) { // searching for the best modification result: by context + Handle(TNaming_NamedShape) aCandidate; + NCollection_List::Iterator aModIter(theModifList); + for (; !theModifList.IsEmpty() && aModIter.More(); aModIter.Next()) { + aCandidate = aModIter.Value(); + TDF_Label aFatherLab = aCandidate->Label().Father(); + Handle(TNaming_NamedShape) aFatherNS; + if (aFatherLab.FindAttribute(TNaming_NamedShape::GetID(), aFatherNS)) { + for (TNaming_Iterator anIter(aFatherNS); anIter.More(); anIter.Next()) { + if (theContext.IsSame(anIter.NewShape())) { // found the best modification + theModifList.Clear(); + break; + } + } + } + } + // take the best candidate, or the last in the iteration + theModifList.Clear(); + theModifList.Append(aCandidate); + } + + if (!theModifList.IsEmpty()) { + // searching for all the base shapes of this modification + findBases(label(), theModifList.First(), theValue, true, baseDocument(), myBases); + if (!myBases.IsEmpty()) { + myFinal = theModifList.First()->Label(); + TopoDS_ListOfShape aCommon; + findModificationResult(aCommon); + // trying to search by neighbors + if (aCommon.Extent() > 1) { // more complicated selection + if (alwaysGeometricalNaming()) { + TopoDS_ListOfShape::Iterator aCommonIter(aCommon); + TopoDS_Shape aFirst = aCommonIter.Value(); + for (aCommonIter.Next(); aCommonIter.More(); aCommonIter.Next()) { + if (!sameGeometry(aFirst, aCommonIter.Value())) + break; + } + if (!aCommonIter.More()) { // all geometry is same, result is a compound + return true; + } + } + } else if (aCommon.Extent() == 1) { + return true; // simple modification + } + // weak naming between the common results + Selector_NExplode aNexp(aCommon); + myWeakIndex = aNexp.index(theValue); + return myWeakIndex != -1; + } + // weak naming case + TopoDS_ListOfShape aCommon; + myFinal = theModifList.First()->Label(); + Handle(TNaming_NamedShape) aNS; + if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { + const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); + if (!aNewShape.IsNull()) + aCommon.Append(aNewShape); + } + } + Selector_NExplode aNexp(aCommon); + myWeakIndex = aNexp.index(theValue); + return myWeakIndex != -1; + } + return false; +} + +void Selector_Modify::store() +{ + storeType(Selector_Algo::SELTYPE_MODIFICATION); + storeBaseArray(myBases, myFinal); + if (myWeakIndex != -1) { + TDataStd_Integer::Set(label(), weakID(), myWeakIndex); + } +} + +bool Selector_Modify::restore() +{ + if (restoreBaseArray(myBases, myFinal)) { + Handle(TDataStd_Integer) aWeakInt; + if (label().FindAttribute(weakID(), aWeakInt)) { + myWeakIndex = aWeakInt->Get(); + } + return true; + } + return false; +} + +TDF_Label Selector_Modify::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + TDF_Label aContext; + for(size_t anEnd, aStart = 0; aStart != std::string::npos; aStart = anEnd) { + if (aStart != 0) + aStart++; + anEnd = theName.find('&', aStart); + std::string aSubStr = + theName.substr(aStart, anEnd == std::string::npos ? anEnd : anEnd - aStart); + if (aSubStr.find(weakNameID()) == 0) { // weak name identifier + std::string aWeakIndex = aSubStr.substr(weakNameID().size()); + myWeakIndex = atoi(aWeakIndex.c_str()); + continue; + } + TDF_Label aSubContext, aValue; + if (!theNameGenerator->restoreContext(aSubStr, aSubContext, aValue)) + return TDF_Label(); // can not restore + if(aSubContext.IsNull() || aValue.IsNull()) + return TDF_Label(); // can not restore + if (myFinal.IsNull()) { + myFinal = aValue; + aContext = aSubContext; + } else + myBases.Append(aValue); + } + return aContext; +} + +bool Selector_Modify::solve(const TopoDS_Shape& theContext) +{ + TopoDS_Shape aResult; + if (myBases.IsEmpty() && myWeakIndex > 0) { // weak name by the final shapes index + TopoDS_ListOfShape aCommon; + Handle(TNaming_NamedShape) aNS; + if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + for(TNaming_Iterator aFinalIter(aNS); aFinalIter.More(); aFinalIter.Next()) { + const TopoDS_Shape& aNewShape = aFinalIter.NewShape(); + if (!aNewShape.IsNull()) + aCommon.Append(aNewShape); + } + } + Selector_NExplode aNexp(aCommon); + aResult = aNexp.shape(myWeakIndex); + } else { // standard case + TopoDS_ListOfShape aFinalsCommon; // final shapes presented in all results from bases + findModificationResult(aFinalsCommon); + if (aFinalsCommon.Extent() == 1) { // result is valid: found only one shape + aResult = aFinalsCommon.First(); + findNewVersion(theContext, aResult); + } else if (aFinalsCommon.Extent() > 1 && myWeakIndex > 0) { + Selector_NExplode aNExp(aFinalsCommon); + aResult = aNExp.shape(myWeakIndex); + findNewVersion(theContext, aResult); + } else if (aFinalsCommon.Extent() > 1 && geometricalNaming()) {// if same geometry - compound + TopoDS_ListOfShape::Iterator aCommonIter(aFinalsCommon); + TopoDS_Shape aFirst = aCommonIter.Value(); + for(aCommonIter.Next(); aCommonIter.More(); aCommonIter.Next()) { + if (!sameGeometry(aFirst, aCommonIter.Value())) + break; + } + if (!aCommonIter.More()) { // all geometry is same, create a result compound + TopoDS_Builder aBuilder; + TopoDS_Compound aCompound; + aBuilder.MakeCompound(aCompound); + for(aCommonIter.Initialize(aFinalsCommon); aCommonIter.More(); aCommonIter.Next()) { + TopoDS_Shape aSub = aCommonIter.Value(); + findNewVersion(theContext, aSub); + aBuilder.Add(aCompound, aSub); + } + aResult = aCompound; + } + + } + } + + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } + return false; +} + +std::string Selector_Modify::name(Selector_NameGenerator* theNameGenerator) +{ + // final&base1&base2 +optionally: [weak_name_1] + std::string aResult; + Handle(TDataStd_Name) aName; + if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName)) + return ""; + aResult += theNameGenerator->contextName(myFinal) + "/" + + std::string(TCollection_AsciiString(aName->Get()).ToCString()); + for(TDF_LabelList::iterator aBase = myBases.begin(); aBase != myBases.end(); aBase++) { + if (!aBase->FindAttribute(TDataStd_Name::GetID(), aName)) + return ""; + aResult += "&"; + aResult += theNameGenerator->contextName(*aBase) + "/" + + std::string(TCollection_AsciiString(aName->Get()).ToCString()); + } + if (myWeakIndex != -1) { + std::ostringstream aWeakStr; + aWeakStr<<"&"< +// + +#ifndef Selector_Modify_H_ +#define Selector_Modify_H_ + +#include "Selector_Algo.h" + +#include + +#include + +/**\class Selector_Modify + * \ingroup DataModel + * \brief Kind of selection algorithm: sub-shape is modification of primitive at some + * final stage. + */ +class Selector_Modify: public Selector_Algo +{ + TDF_Label myFinal; ///< final label of the primitive or generation, where the value is + TDF_LabelList myBases; ///< initial labels that contain shapes that produce the modification + int myWeakIndex; ///< weak index in case modification produces several shapes +public: + /// Initializes the selection of this kind by list of named shapes where the modification results + /// are presented and the selected value. + SELECTOR_EXPORT bool select(NCollection_List& theModifList, + const TopoDS_Shape theContext, const TopoDS_Shape theValue); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; + +private: + /// Initializes selector + Selector_Modify(); + /// Searches the final shapes presented in all results from bases basing on modification fields + void findModificationResult(TopoDS_ListOfShape& theCommon); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/Selector/Selector_NExplode.cpp b/src/Selector/Selector_NExplode.cpp new file mode 100644 index 000000000..5657a171f --- /dev/null +++ b/src/Selector/Selector_NExplode.cpp @@ -0,0 +1,196 @@ +// Copyright (C) 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 "Selector_NExplode.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static std::pair ShapeToDouble (const TopoDS_Shape& S) +{ + // Computing of CentreOfMass + gp_Pnt GPoint; + double Len; + + if (S.ShapeType() == TopAbs_VERTEX) { + GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S)); + Len = (double)S.Orientation(); + } + else { + GProp_GProps GPr; + if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) { + BRepGProp::LinearProperties(S, GPr); + } + else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) { + BRepGProp::SurfaceProperties(S, GPr); + } + else { + BRepGProp::VolumeProperties(S, GPr); + } + GPoint = GPr.CentreOfMass(); + Len = GPr.Mass(); + } + + double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9; + return std::make_pair(dMidXYZ, Len); +} + +/*! +* \brief Sort shapes in the list by their coordinates. +*/ +struct CompareShapes : public std::binary_function +{ + typedef NCollection_DataMap > DataMapOfShapeDouble; + + CompareShapes(DataMapOfShapeDouble* theCashMap) : myMap(theCashMap) {} + + bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs); + + DataMapOfShapeDouble* myMap; +}; + +bool CompareShapes::operator() (const TopoDS_Shape& theShape1, + const TopoDS_Shape& theShape2) +{ + if (!myMap->IsBound(theShape1)) { + myMap->Bind(theShape1, ShapeToDouble(theShape1)); + } + + if (!myMap->IsBound(theShape2)) { + myMap->Bind(theShape2, ShapeToDouble(theShape2)); + } + + std::pair val1 = myMap->Find(theShape1); + std::pair val2 = myMap->Find(theShape2); + + double tol = Precision::Confusion(); + bool exchange = Standard_False; + + double dMidXYZ = val1.first - val2.first; + if (dMidXYZ >= tol) { + exchange = Standard_True; + } + else if (Abs(dMidXYZ) < tol) { + double dLength = val1.second - val2.second; + if (dLength >= tol) { + exchange = Standard_True; + } + else if (Abs(dLength) < tol && theShape1.ShapeType() <= TopAbs_FACE) { + // equal values possible on shapes such as two halves of a sphere and + // a membrane inside the sphere +// LCOV_EXCL_START + // this part of code is taken from GEOM module, but can not reproduce in SHAPER + Bnd_Box box1,box2; + BRepBndLib::Add(theShape1, box1); + if (!box1.IsVoid()) { + BRepBndLib::Add(theShape2, box2); + Standard_Real dSquareExtent = box1.SquareExtent() - box2.SquareExtent(); + if (dSquareExtent >= tol) { + exchange = Standard_True; + } + else if (Abs(dSquareExtent) < tol) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, val1, val2; + box1.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val1 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + box2.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + val2 = (aXmin+aXmax)*999.0 + (aYmin+aYmax)*99.0 + (aZmin+aZmax)*0.9; + if ((val1 - val2) >= tol) { + exchange = Standard_True; + } + } + } +// LCOV_EXCL_STOP + } else // compare addresses if shapes are geometrically equal + return theShape1.TShape().get() > theShape2.TShape().get(); + } + + //return val1 < val2; + return !exchange; +} + +Selector_NExplode::Selector_NExplode(const TopoDS_ListOfShape& theShapes) +{ + std::vector aShapesVec; + + for(TopoDS_ListOfShape::Iterator anIter(theShapes); anIter.More(); anIter.Next()) { + aShapesVec.push_back(anIter.Value()); + } + + CompareShapes::DataMapOfShapeDouble aCash; + CompareShapes shComp(&aCash); + std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); + + std::vector::const_iterator anIter = aShapesVec.begin(); + for (; anIter != aShapesVec.end(); ++anIter) { + mySorted.Append(*anIter); + } +} + +Selector_NExplode::Selector_NExplode(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType) +{ + std::vector aShapesVec; + TopTools_MapOfShape anAdded; // to avoid same shapes duplication + for(TopExp_Explorer anExp(theShape, theType); anExp.More(); anExp.Next()) { + if (anAdded.Add(anExp.Current())) + aShapesVec.push_back(anExp.Current()); + } + + CompareShapes::DataMapOfShapeDouble aCash; + CompareShapes shComp(&aCash); + std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp); + + std::vector::const_iterator anIter = aShapesVec.begin(); + for (; anIter != aShapesVec.end(); ++anIter) { + mySorted.Append(*anIter); + } +} + + +int Selector_NExplode::index(const TopoDS_Shape& theSubShape) +{ + TopoDS_ListOfShape::Iterator anIter(mySorted); + for(int anIndex = 1; anIter.More(); anIter.Next(), anIndex++) { + if (anIter.Value().IsSame(theSubShape)) + return anIndex; + } + return -1; // not found +} + +TopoDS_Shape Selector_NExplode::shape(const int theIndex) +{ + TopoDS_ListOfShape::Iterator anIter(mySorted); + for(int anIndex = 1; anIter.More(); anIter.Next(), anIndex++) { + if (anIndex == theIndex) + return anIter.Value(); + } + return TopoDS_Shape(); // not found +} diff --git a/src/Selector/Selector_NExplode.h b/src/Selector/Selector_NExplode.h new file mode 100644 index 000000000..cb23b4d24 --- /dev/null +++ b/src/Selector/Selector_NExplode.h @@ -0,0 +1,51 @@ +// Copyright (C) 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 +// + +#ifndef Selector_NExplode_H_ +#define Selector_NExplode_H_ + +#include "Selector.h" + +#include +#include + +/// \class Selector_NExplode +/// \ingroup DataModel +/// \brief Sort shapes by their centers of mass, using formula X*999 + Y*99 + Z*0.9. +/// Algorithm is copied from GEOM module, which uses nexplode Draw command from OCCT. +/// Used for getting index of sub0shape in WeakNaming algorithm. +class Selector_NExplode +{ + public: + /// \brief Initializes the sorted list of shapes by the shapes list. + SELECTOR_EXPORT Selector_NExplode(const TopoDS_ListOfShape& theShapes); + /// \brief Initializes the sorted list of shapes by the context shape and type of sub-shapes. + SELECTOR_EXPORT Selector_NExplode(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType); + + /// Returns an index (started from one) of sub-shape in the sorted list. Returns 0 if not found. + SELECTOR_EXPORT int index(const TopoDS_Shape& theSubShape); + /// Returns a shape by an index (started from one). Returns null if not found. + SELECTOR_EXPORT TopoDS_Shape shape(const int theIndex); + +protected: + TopoDS_ListOfShape mySorted; ///< keep the ordered list of shapes +}; + +#endif diff --git a/src/Selector/Selector_NameGenerator.cpp b/src/Selector/Selector_NameGenerator.cpp new file mode 100644 index 000000000..0c4ed036b --- /dev/null +++ b/src/Selector/Selector_NameGenerator.cpp @@ -0,0 +1 @@ +#include diff --git a/src/Selector/Selector_NameGenerator.h b/src/Selector/Selector_NameGenerator.h new file mode 100644 index 000000000..6ac0f4ce4 --- /dev/null +++ b/src/Selector/Selector_NameGenerator.h @@ -0,0 +1,55 @@ +// 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 +// + +#ifndef Selector_NameGenerator_H_ +#define Selector_NameGenerator_H_ + +#include "Selector.h" + +#include + +/**\class Selector_NameGenerator + * \ingroup DataModel + * \brief An interface for generation of the naming name basing on the current selection and + * document information. This requires higher-level data access, so, the caller of "name" method + * of Selector must implement this helper-class abstract methods. + */ +class Selector_NameGenerator +{ +public: + /// empty constructor, nothing to add + Selector_NameGenerator() {}; + + /// This method returns the context name by the label of the sub-selected shape + virtual std::string contextName(const TDF_Label theSelectionLab) = 0; + + /// This method restores by the context and value name the context label and + /// sub-label where the value is. Returns true if it is valid. + virtual bool restoreContext(std::string theName, + TDF_Label& theContext, TDF_Label& theValue) = 0; + + /// Returns true if the first result is older than the second one in the tree of features + virtual bool isLater(const TDF_Label theResult1, const TDF_Label theResult2) const = 0; + + /// Returns the label of the newest context presented by the current one + virtual TDF_Label newestContext(const TDF_Label theCurrentContext) = 0; +}; + +#endif diff --git a/src/Selector/Selector_Primitive.cpp b/src/Selector/Selector_Primitive.cpp new file mode 100644 index 000000000..a2d141066 --- /dev/null +++ b/src/Selector/Selector_Primitive.cpp @@ -0,0 +1,85 @@ +// 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 + +#include + +#include +#include + + +Selector_Primitive::Selector_Primitive() : Selector_Algo() +{ +} + +void Selector_Primitive::select(const TDF_Label theFinalLabel) +{ + myFinal = theFinalLabel; +} + +void Selector_Primitive::store() +{ + storeType(Selector_Algo::SELTYPE_PRIMITIVE); + static const TDF_LabelList anEmptyRefList; + storeBaseArray(anEmptyRefList, myFinal); +} + +bool Selector_Primitive::restore() +{ + static TDF_LabelList anEmptyRefList; + return restoreBaseArray(anEmptyRefList, myFinal); +} + +TDF_Label Selector_Primitive::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + TDF_Label aContext; + if (theNameGenerator->restoreContext(theName, aContext, myFinal)) { + if (myFinal.IsNull()) + aContext.Nullify(); + } + return aContext; +} + +bool Selector_Primitive::solve(const TopoDS_Shape& theContext) +{ + Handle(TNaming_NamedShape) aNS; + if (myFinal.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TopoDS_Shape aResult = aNS->Get(); + // if shape was modified and not exists in the context anymore, check evolution of this shape + // issue 2254 and similar (document CEA parametric first issue description) + findNewVersion(theContext, aResult); + Selector_Algo::store(aResult); + return true; + } + return false; +} + +std::string Selector_Primitive::name(Selector_NameGenerator* theNameGenerator) +{ + Handle(TDataStd_Name) aName; + if (!myFinal.FindAttribute(TDataStd_Name::GetID(), aName)) + return ""; + std::string aResult = theNameGenerator->contextName(myFinal); + if (!aResult.empty()) + aResult += "/" + std::string(TCollection_AsciiString(aName->Get()).ToCString()); + return aResult; +} diff --git a/src/Selector/Selector_Primitive.h b/src/Selector/Selector_Primitive.h new file mode 100644 index 000000000..ea8b23a89 --- /dev/null +++ b/src/Selector/Selector_Primitive.h @@ -0,0 +1,62 @@ +// 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 +// + +#ifndef Selector_Primitive_H_ +#define Selector_Primitive_H_ + +#include "Selector_Algo.h" + +/**\class Selector_Primitive + * \ingroup DataModel + * \brief Kind of selection algorithm: exact referencing to alone shape in the data structure. + */ +class Selector_Primitive: public Selector_Algo +{ + TDF_Label myFinal; ///< final label of the where the value is +public: + /// Initializes the selection of this kind + /// \param theLabel the final label with the primitive shape + SELECTOR_EXPORT void select(const TDF_Label theFinalLabel); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; +private: + /// Initializes selector + Selector_Primitive(); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/Selector/Selector_Selector.cpp b/src/Selector/Selector_Selector.cpp new file mode 100644 index 000000000..4ed6caebc --- /dev/null +++ b/src/Selector/Selector_Selector.cpp @@ -0,0 +1,112 @@ + // 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 + +#include +#include + +#include +#include +#include +#include +#include + +Selector_Selector::Selector_Selector(TDF_Label theLab, TDF_Label theBaseDocLab) : + myLab(theLab), myBaseDocumentLab(theBaseDocLab), myAlgo(NULL) +{} + +Selector_Selector::~Selector_Selector() +{ + if (myAlgo) + delete myAlgo; +} + +bool Selector_Selector::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue, + const bool theGeometricalNaming) +{ + if (theValue.IsNull() || theContext.IsNull()) + return false; + + myAlgo = Selector_Algo::select(theContext, theValue, myLab, myBaseDocumentLab, + theGeometricalNaming, true, true); + + return myAlgo != NULL; +} + +bool Selector_Selector::store(const TopoDS_Shape theContext) +{ + myAlgo->store(); + return myAlgo->solve(theContext); // to update the selection shape on the label +} + +bool Selector_Selector::restore(const TopoDS_Shape theContext) +{ + myAlgo = Selector_Algo::restoreByLab(myLab, myBaseDocumentLab); + if (myAlgo) { + return myAlgo->solve(theContext); // to update the selection shape on the label + } + return false; +} + +TopoDS_Shape Selector_Selector::value() +{ + Handle(TNaming_NamedShape) aNS; + if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aNS)) + return aNS->Get(); + return TopoDS_Shape(); // empty, error shape +} + +std::string Selector_Selector::name(Selector_NameGenerator* theNameGenerator) { + return myAlgo->name(theNameGenerator); +} + +TDF_Label Selector_Selector::restoreByName( + std::string theName, const TopAbs_ShapeEnum theShapeType, + Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming) +{ + TDF_Label aResult; + myAlgo = Selector_Algo::restoreByName(myLab, myBaseDocumentLab, theName, theShapeType, + theGeometricalNaming, theNameGenerator, aResult); + if (myAlgo) { + return aResult; + } + return TDF_Label(); +} + +void Selector_Selector::combineGeometrical(const TopoDS_Shape theContext) +{ + TopoDS_Shape aValue = value(); + if (aValue.IsNull() || aValue.ShapeType() == TopAbs_COMPOUND) + return; + + Selector_Algo* aNewAlgo = Selector_Algo::relesectWithAllGeometry(myAlgo, theContext); + if (aNewAlgo) { + aNewAlgo->store(); + aNewAlgo->solve(theContext); + delete myAlgo; + myAlgo = aNewAlgo; + } +} + +bool Selector_Selector::solve(const TopoDS_Shape theContext) +{ + return myAlgo->solve(theContext); +} diff --git a/src/Selector/Selector_Selector.h b/src/Selector/Selector_Selector.h new file mode 100644 index 000000000..d3e5b8a3b --- /dev/null +++ b/src/Selector/Selector_Selector.h @@ -0,0 +1,86 @@ +// 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 +// + +#ifndef Selector_Selector_H_ +#define Selector_Selector_H_ + +#include "Selector.h" + +#include +#include + +class Selector_NameGenerator; +class Selector_Algo; + +/**\class Selector_Selector + * \ingroup DataModel + * \brief Main object for selection of the sub-shapes in the parametrically updated + * shapes using topological naming mechanism. + */ +class Selector_Selector +{ + TDF_Label myLab; ///< main label where selector is performed + TDF_Label myBaseDocumentLab; ///< an access-label to the document that may contain initial shapes + Selector_Algo* myAlgo; ///< root algorithm of the selector + +public: + /// Initializes selector on the label + SELECTOR_EXPORT Selector_Selector(TDF_Label theLab, TDF_Label theBaseDocLab = TDF_Label()); + + /// Destructor + SELECTOR_EXPORT ~Selector_Selector(); + + /// Initializes the selector structure on the label. + /// Stores the name data to restore after modification. + /// \param theContext whole shape that contains the selected sub-shape + /// \param theValue selected subshape + /// \param theGeometricalNaming treats selection with equal surfaces as one + /// \param theUseNeighbors enables searching algorithm by neighbors + /// \param theUseIntersections enables searching algorithm by intersection of higher level shapes + SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue, + const bool theGeometricalNaming = false); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT bool store(const TopoDS_Shape theContext); + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT bool restore(const TopoDS_Shape theContext); + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT TDF_Label restoreByName( + std::string theName, const TopAbs_ShapeEnum theShapeType, + Selector_NameGenerator* theNameGenerator, const bool theGeometricalNaming = false); + + /// Returns the current sub-shape value (null if can not resolve) + SELECTOR_EXPORT TopoDS_Shape value(); + + /// Returns the naming name of the selection + SELECTOR_EXPORT std::string name(Selector_NameGenerator* theNameGenerator); + + /// Makes the current local selection becomes all sub-shapes with same base geometry. + SELECTOR_EXPORT void combineGeometrical(const TopoDS_Shape theContext); + + /// Stores the selected shape in he tree and returns true if shape found correctly + SELECTOR_EXPORT bool solve(const TopoDS_Shape theContext); +}; + +#endif diff --git a/src/Selector/Selector_WeakName.cpp b/src/Selector/Selector_WeakName.cpp new file mode 100644 index 000000000..6ede1c385 --- /dev/null +++ b/src/Selector/Selector_WeakName.cpp @@ -0,0 +1,139 @@ +// 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 + +#include +#include + +#include +#include +#include +#include + +Selector_WeakName::Selector_WeakName() : Selector_Algo() +{ +} + +bool Selector_WeakName::select(const TopoDS_Shape theContext, const TopoDS_Shape theValue) +{ + myShapeType = theValue.ShapeType(); + Selector_NExplode aNexp(theContext, myShapeType); + myWeakIndex = aNexp.index(theValue); + if (myWeakIndex != -1) { + // searching for context shape label to store in myFinal + if (TNaming_Tool::HasLabel(label(), theContext)) { + for(TNaming_SameShapeIterator aShapes(theContext, label()); aShapes.More(); aShapes.Next()) + { + Handle(TNaming_NamedShape) aNS; + if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_PRIMITIVE || anEvolution == TNaming_GENERATED || + anEvolution == TNaming_MODIFY) { + // check this is a new shape + for(TNaming_Iterator aNSIter(aNS); aNSIter.More(); aNSIter.Next()) { + if (aNSIter.NewShape().IsSame(theContext)) { + myContext = aNS->Label(); + break; + } + } + } + } + } + } + return true; + } + return false; +} + +void Selector_WeakName::store() +{ + static const TDF_LabelList anEmptyRefList; + storeType(Selector_Algo::SELTYPE_WEAK_NAMING); + storeBaseArray(anEmptyRefList, myContext); + TDataStd_Integer::Set(label(), weakID(), myWeakIndex); + TDataStd_Integer::Set(label(), shapeTypeID(), (int)myShapeType); +} + +bool Selector_WeakName::restore() +{ + Handle(TDataStd_Integer) aWeakInt; + if (!label().FindAttribute(weakID(), aWeakInt)) + return false; + myWeakIndex = aWeakInt->Get(); + Handle(TDataStd_Integer) aShapeTypeAttr; + if (!label().FindAttribute(shapeTypeID(), aShapeTypeAttr)) + return false; + myShapeType = TopAbs_ShapeEnum(aShapeTypeAttr->Get()); + static TDF_LabelList anEmptyRefList; + return restoreBaseArray(anEmptyRefList, myContext); +} + +TDF_Label Selector_WeakName::restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) +{ + std::string aWeakIndex = theName.substr(pureWeakNameID().size()); + std::size_t aContextPosition = aWeakIndex.find("_"); + myWeakIndex = atoi(aWeakIndex.c_str()); + myShapeType = theShapeType; + TDF_Label aContext; + if (aContextPosition != std::string::npos) { // context is also defined + std::string aContextName = aWeakIndex.substr(aContextPosition + 1); + if (theNameGenerator->restoreContext(aContextName, aContext, myContext)) { + if (myContext.IsNull()) + aContext.Nullify(); + } + } + return aContext; +} + +bool Selector_WeakName::solve(const TopoDS_Shape& theContext) +{ + + TopoDS_Shape aContext; + if (myContext.IsNull()) { + aContext = theContext; + } else { + Handle(TNaming_NamedShape) aNS; + if (myContext.FindAttribute(TNaming_NamedShape::GetID(), aNS)) { + aContext = aNS->Get(); + } + } + if (!aContext.IsNull()) { + Selector_NExplode aNexp(aContext, myShapeType); + TopoDS_Shape aResult = aNexp.shape(myWeakIndex); + if (!aResult.IsNull()) { + Selector_Algo::store(aResult); + return true; + } + } + return false; +} + +std::string Selector_WeakName::name(Selector_NameGenerator* theNameGenerator) +{ + // _weak_naming_1_Context + std::ostringstream aWeakStr; + aWeakStr<contextName(myContext); + return aResult; +} diff --git a/src/Selector/Selector_WeakName.h b/src/Selector/Selector_WeakName.h new file mode 100644 index 000000000..7f1016a8b --- /dev/null +++ b/src/Selector/Selector_WeakName.h @@ -0,0 +1,64 @@ +// 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 +// + +#ifndef Selector_WeakName_H_ +#define Selector_WeakName_H_ + +#include "Selector_Algo.h" + +/**\class Selector_WeakName + * \ingroup DataModel + * \brief Kind of selection algorithm: if other algorithms fail, this stores the geometrical + * index of the selected shape. Pure weak naming approach. + */ +class Selector_WeakName: public Selector_Algo +{ + TopAbs_ShapeEnum myShapeType; ///< type of this shape + int myWeakIndex; ///< weak index in case modification produces several shapes + TDF_Label myContext; ///< context shape label +public: + /// Initializes the selection of this kind + SELECTOR_EXPORT bool select(const TopoDS_Shape theContext, const TopoDS_Shape theValue); + + /// Stores the name to the label and sub-labels tree + SELECTOR_EXPORT virtual void store() override; + + /// Restores the selected shape by the topological naming kept in the data structure + /// Returns true if it can restore structure correctly + SELECTOR_EXPORT virtual bool restore() override; + + /// Restores the selected shape by the topological name string. + /// Returns not empty label of the context. + SELECTOR_EXPORT virtual TDF_Label restoreByName(std::string theName, + const TopAbs_ShapeEnum theShapeType, Selector_NameGenerator* theNameGenerator) override; + + /// Updates the current shape by the stored topological name + SELECTOR_EXPORT virtual bool solve(const TopoDS_Shape& theContext) override; + + /// Returns the naming name of the selection + SELECTOR_EXPORT virtual std::string name(Selector_NameGenerator* theNameGenerator) override; +private: + /// Initializes selector + Selector_WeakName(); + + friend class Selector_Algo; +}; + +#endif diff --git a/src/SketchAPI/SketchAPI_Constraint.cpp b/src/SketchAPI/SketchAPI_Constraint.cpp index 82b5dfab4..d9edb13de 100644 --- a/src/SketchAPI/SketchAPI_Constraint.cpp +++ b/src/SketchAPI/SketchAPI_Constraint.cpp @@ -66,6 +66,31 @@ bool SketchAPI_Constraint::initialize() return true; } +void SketchAPI_Constraint::setEntityA(const ModelHighAPI_RefAttr& theEntity) +{ + fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_A())); +} + +void SketchAPI_Constraint::setEntityB(const ModelHighAPI_RefAttr& theEntity) +{ + fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_B())); +} + +void SketchAPI_Constraint::setEntityC(const ModelHighAPI_RefAttr& theEntity) +{ + fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_C())); +} + +void SketchAPI_Constraint::setEntityD(const ModelHighAPI_RefAttr& theEntity) +{ + fillAttribute(theEntity, feature()->refattr(SketchPlugin_Constraint::ENTITY_D())); +} + +void SketchAPI_Constraint::setValue(const ModelHighAPI_Double& theValue) +{ + fillAttribute(theValue, feature()->real(SketchPlugin_Constraint::VALUE())); +} + static const std::string& constraintTypeToSetter(const std::string& theType) { if (theType == SketchPlugin_ConstraintCoincidence::ID()) { diff --git a/src/SketchAPI/SketchAPI_Constraint.h b/src/SketchAPI/SketchAPI_Constraint.h index 2ad165065..958bbdae3 100644 --- a/src/SketchAPI/SketchAPI_Constraint.h +++ b/src/SketchAPI/SketchAPI_Constraint.h @@ -29,6 +29,8 @@ #include +class ModelHighAPI_Double; + /**\class SketchAPI_Constraint * \ingroup CPPHighAPI * \brief Interface for Constraint feature @@ -54,6 +56,13 @@ public: SKETCHAPI_EXPORT bool initialize(); + SKETCHAPI_EXPORT void setEntityA(const ModelHighAPI_RefAttr& theEntity); + SKETCHAPI_EXPORT void setEntityB(const ModelHighAPI_RefAttr& theEntity); + SKETCHAPI_EXPORT void setEntityC(const ModelHighAPI_RefAttr& theEntity); + SKETCHAPI_EXPORT void setEntityD(const ModelHighAPI_RefAttr& theEntity); + + SKETCHAPI_EXPORT void setValue(const ModelHighAPI_Double& theValue); + /// Dump wrapped feature SKETCHAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index bf4ffcb76..4d399b188 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -66,6 +66,7 @@ SET(PROJECT_HEADERS SketchPlugin_Tools.h SketchPlugin_Trim.h SketchPlugin_Validators.h + SketchPlugin_SketchDrawer.h ) SET(PROJECT_SOURCES @@ -73,7 +74,6 @@ SET(PROJECT_SOURCES SketchPlugin_Circle.cpp SketchPlugin_Constraint.cpp SketchPlugin_ConstraintAngle.cpp - SketchPlugin_ConstraintBase.cpp SketchPlugin_ConstraintCoincidence.cpp SketchPlugin_ConstraintCollinear.cpp SketchPlugin_ConstraintDistance.cpp @@ -111,6 +111,7 @@ SET(PROJECT_SOURCES SketchPlugin_Tools.cpp SketchPlugin_Trim.cpp SketchPlugin_Validators.cpp + SketchPlugin_SketchDrawer.cpp ) SET(PROJECT_LIBRARIES @@ -153,123 +154,135 @@ INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Sketch) INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}) -ADD_UNIT_TESTS(TestSketchPointLine.py - TestCreateArcByCenterStartEnd.py - TestCreateArcByThreePoints.py - TestCreateArcByTangentEdge.py - TestCreateArcChangeType.py - TestCreateCircleByCenterAndPassed.py - TestCreateCircleByThreePoints.py - TestCreateCircleChangeType.py - TestConstraintCoincidence.py - TestConstraintCollinear.py - TestConstraintLength.py - TestConstraintDistance.py - TestConstraintDistanceHorizontal.py - TestConstraintDistanceVertical.py - TestConstraintDistanceBehavior.py - TestConstraintParallel.py - TestConstraintPerpendicular.py - TestConstraintRadius.py - TestConstraintFixed.py - TestConstraintHorizontal.py - TestConstraintHorizontalValidator.py - TestConstraintVertical.py - TestConstraintEqual.py - TestConstraintTangent.py - TestConstraintAngle.py - TestConstraintMiddlePoint.py - TestEdgesOrder.py - TestMirror.py - TestMultiTranslation.py - TestMultiRotation.py - TestMultiRotationWithParameter.py - TestMultiRotation01.py - TestMultiRotation02.py - TestMultiRotation03.py - TestMultiRotation04.py - TestMultiRotation05.py - TestFillet.py - TestFilletAfterFolder.py - TestFilletInteracting.py - TestRectangle.py - TestProjection.py - TestProjectionIntoResult.py - TestSplit.py - TestHighload.py - TestSnowflake.py - TestArcBehavior.py - TestRemoveSketch.py - Test1061.py - Test1673.py - Test1924.py - Test1966.py - Test1967.py - Test2062.py - Test2095.py - Test2115.py - TestTrimArc01.py - TestTrimArc02.py - TestTrimArc03.py - TestTrimArc04.py - TestTrimArc05.py - TestTrimArc06.py - TestTrimArc07.py - TestTrimCircle01.py - TestTrimCircle02.py - TestTrimCircle03.py - TestTrimCircle04.py - TestTrimCircle05.py - TestTrimCircleAndArc01.py - TestTrimLine01.py - TestTrimLine02.py - Test2229.py - Test2239.py - TestDistanceDump.py - TestDistanceSignedVsUnsigned01.py - TestDistanceSignedVsUnsigned02.py - TestDistanceSignedVsUnsigned03.py - TestDistanceSignedVsUnsigned04.py - TestDistanceSignedVsUnsigned05.py - TestSignedDistancePointPoint.py - TestSignedDistancePointLine.py - TestIntersectionWithLine.py - TestIntersectionWithCircle.py - TestIntersectionWithSpline.py - TestIntersectionChangeEdge.py - Test2273.py - Test2280.py - Test2287.py - Test2341.py - Test2390.py - Test2393.py - Test2425.py - Test2440.py - Test2157.py - Test2157_2.py - Test2481.py - Test1963.py - Test2034_1.py - Test2034_2.py - Test2034_3.py - Test2134.py - TestDegeneratedGeometry.py - Test2119.py - Test2224.py - Test2427.py - Test1577.py - Test1578.py - Test2654.py - Test1779.py - Test2711.py +ADD_UNIT_TESTS( + Test1061.py + Test1577.py + Test1578.py + Test1673.py + Test1779.py + Test1924.py + Test1963.py + Test1966.py + Test1967.py + Test2034_1.py + Test2034_2.py + Test2034_3.py + Test2062.py + Test2095.py + Test2115.py + Test2119.py + Test2134.py + Test2157.py + Test2157_2.py + Test2224.py + Test2229.py + Test2239.py + Test2273.py + Test2280.py + Test2287.py + Test2341.py + Test2390.py + Test2393.py + Test2425.py + Test2427.py + Test2440.py + Test2481.py + Test2654.py + Test2711.py + Test2741.py + Test2810.py + TestArcBehavior.py + TestConstraintAngle.py + TestConstraintCoincidence.py + TestConstraintCollinear.py + TestConstraintDistance.py + TestConstraintDistanceBehavior.py + TestConstraintDistanceHorizontal.py + TestConstraintDistanceVertical.py + TestConstraintEqual.py + TestConstraintFixed.py + TestConstraintHorizontal.py + TestConstraintHorizontalValidator.py + TestConstraintLength.py + TestConstraintMiddlePoint.py + TestConstraintParallel.py + TestConstraintPerpendicular.py + TestConstraintRadius.py + TestConstraintRadiusFailure.py + TestConstraintTangent.py + TestConstraintVertical.py + TestCreateArcByCenterStartEnd.py + TestCreateArcByTangentEdge.py + TestCreateArcByThreePoints.py + TestCreateArcChangeType.py + TestCreateCircleByCenterAndPassed.py + TestCreateCircleByThreePoints.py + TestCreateCircleChangeType.py + TestDegeneratedGeometry.py + TestDistanceDump.py + TestDistanceSignedVsUnsigned01.py + TestDistanceSignedVsUnsigned02.py + TestDistanceSignedVsUnsigned03.py + TestDistanceSignedVsUnsigned04.py + TestDistanceSignedVsUnsigned05.py + TestEdgesOrder.py + TestFillet.py + TestFilletAfterFolder.py + TestFilletInteracting.py + TestHighload.py + TestIntersectionChangeEdge.py + TestIntersectionWithCircle.py + TestIntersectionWithLine.py + TestIntersectionWithSpline.py + TestMirror.py + TestMultiRotation.py + TestMultiRotation01.py + TestMultiRotation02.py + TestMultiRotation03.py + TestMultiRotation04.py + TestMultiRotation05.py + TestMultiRotationWithParameter.py + TestMultiTranslation.py + TestPresentation.py + TestProjection.py + TestProjectionIntoResult.py + TestProjectionUpdate.py + TestRectangle.py + TestRemoveSketch.py + TestSignedDistancePointLine.py + TestSignedDistancePointPoint.py + TestSketchDrawer.py + TestSketchPointLine.py + TestSnowflake.py + TestSplit.py + TestSplitLine.py + TestSplitPreview.py + TestTrimArc01.py + TestTrimArc02.py + TestTrimArc03.py + TestTrimArc04.py + TestTrimArc05.py + TestTrimArc06.py + TestTrimArc07.py + TestTrimArc08.py + TestTrimCircle01.py + TestTrimCircle02.py + TestTrimCircle03.py + TestTrimCircle04.py + TestTrimCircle05.py + TestTrimCircleAndArc01.py + TestTrimLine01.py + TestTrimLine02.py + TestTrimLine03.py + TestTrimPreview.py ) if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) ADD_UNIT_TESTS( - TestMovePoint.py - TestMoveLine.py - TestMoveCircle.py - TestMoveArc.py - TestMovementComplex.py + TestMoveArc.py + TestMoveCircle.py + TestMoveLine.py + TestMovementComplex.py + TestMovePoint.py ) endif() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp b/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp deleted file mode 100644 index 0a499442b..000000000 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// 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 "SketchPlugin_ConstraintBase.h" - -AISObjectPtr SketchPlugin_ConstraintBase::getAISObject(AISObjectPtr thePrevious) -{ - return thePrevious; -} - -const void SketchPlugin_ConstraintBase::addSub(const FeaturePtr& theFeature) -{ - -} diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.h b/src/SketchPlugin/SketchPlugin_ConstraintBase.h index 9c65757d6..a43599607 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintBase.h @@ -57,15 +57,7 @@ class SketchPlugin_ConstraintBase : public SketchPlugin_Constraint, public GeomA public GeomAPI_ICustomPrs { public: - /// Returns the AIS preview - SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); - - /** \brief Adds sub-feature of the higher level feature (sub-element of the sketch) - * \param theFeature sub-feature - */ - SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature); - - /// Customize presentation of the feature + /// Customize presentation of the feature virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theDefaultPrs) { diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp index ac7b9961b..2c3bddf16 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -56,51 +56,6 @@ AISObjectPtr SketchPlugin_ConstraintCoincidence::getAISObject(AISObjectPtr thePr return anAIS; } -FeaturePtr SketchPlugin_ConstraintCoincidence::findCoincidenceFeature(const FeaturePtr& theFeature1, - const FeaturePtr& theFeature2) -{ - FeaturePtr aResultFeature; - - std::list anAttrList; - if (theFeature1->getKind() == SketchPlugin_Circle::ID() || - theFeature2->getKind() == SketchPlugin_Circle::ID()) - return aResultFeature; - - if (theFeature2->getKind() == SketchPlugin_Line::ID()) { - anAttrList.push_back(theFeature2->attribute(SketchPlugin_Line::START_ID())); - anAttrList.push_back(theFeature2->attribute(SketchPlugin_Line::END_ID())); - } else if (theFeature2->getKind() == SketchPlugin_Arc::ID()) { - anAttrList.push_back(theFeature2->attribute(SketchPlugin_Arc::START_ID())); - anAttrList.push_back(theFeature2->attribute(SketchPlugin_Arc::END_ID())); - } - - const std::set& aRefsList = theFeature1->data()->refsToMe(); - std::set::const_iterator aRefIt = aRefsList.begin(); - for (; aRefIt != aRefsList.end() && !aResultFeature.get(); ++aRefIt) { - FeaturePtr aConstrFeature = std::dynamic_pointer_cast((*aRefIt)->owner()); - if (aConstrFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID()) - continue; - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*aRefIt); - AttributePtr anAttr = aRefAttr->attr(); - if (anAttr->id() == SketchPlugin_Arc::CENTER_ID()) - continue; - - anAttr = aConstrFeature->attribute(SketchPlugin_Constraint::ENTITY_A()); - if (anAttr == *aRefIt) - anAttr = aConstrFeature->attribute(SketchPlugin_Constraint::ENTITY_B()); - - aRefAttr = std::dynamic_pointer_cast(anAttr); - if (!aRefAttr) - continue; - anAttr = aRefAttr->attr(); - for (std::list::const_iterator anIt = anAttrList.begin(); - anIt != anAttrList.end() && !aResultFeature.get(); ++anIt) - if (*anIt == anAttr) - aResultFeature = aConstrFeature; - } - return aResultFeature; -} - AttributePoint2DPtr SketchPlugin_ConstraintCoincidence::getPoint(const FeaturePtr& theFeature) { AttributePoint2DPtr aPoint = ModelGeomAlgo_Point2D::getPointOfRefAttr(theFeature.get(), diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index db5f5e3ca..5e2ba1668 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -60,12 +60,6 @@ class SketchPlugin_ConstraintCoincidence : public SketchPlugin_ConstraintBase /// \brief Request for initialization of data model of the feature: adding all attributes SKETCHPLUGIN_EXPORT virtual void initAttributes(); - /// Returns coincident feature if there is a coincidence built on the given features - /// \param theFeature1 the first feature - /// \param theFeature2 the second feature - static FeaturePtr findCoincidenceFeature(const FeaturePtr& theFeature1, - const FeaturePtr& theFeature2); - /// Creates a constraint on two points /// \param theSketch a sketch feature /// \param thePoint1 the first point diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index a98238307..20a98e327 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -65,9 +65,6 @@ class SketchPlugin_Feature : public ModelAPI_Feature return true; } - /// Construction result is allways recomuted on the fly - SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;} - /// Returns true is sketch element is under the rigid constraint SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;} diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index 3373df8c6..852d006e5 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -104,6 +104,10 @@ void SketchPlugin_Fillet::execute() // create feature for fillet arc FeaturePtr aFilletArc = createFilletArc(); + if (!aFilletArc) { + setError("Error: unable to create a fillet arc."); + return; + } // collect features referred to the edges participating in fillet AttributePoint2DPtr aFilletPoints[2]; @@ -308,6 +312,10 @@ FeaturePtr SketchPlugin_Fillet::createFilletArc() if (!myBaseFeatures[0] || !myBaseFeatures[1]) calculateFilletParameters(); + // fix for issue #2810 (sometimes, myCenterXY is NULL, fillet should report an error) + if (!myCenterXY) + return FeaturePtr(); + // Create arc feature. FeaturePtr aFilletArc = sketch()->addFeature(SketchPlugin_Arc::ID()); diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 23cbe2666..f04cf47d7 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -92,6 +92,7 @@ void SketchPlugin_Line::execute() } } +// LCOV_EXCL_START std::string SketchPlugin_Line::processEvent(const std::shared_ptr& theMessage) { std::string aFilledAttributeName; @@ -113,6 +114,7 @@ std::string SketchPlugin_Line::processEvent(const std::shared_ptr& thePoint) { diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index d51c6608f..11444e0ef 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -77,7 +77,7 @@ class SketchPlugin_Line : public SketchPlugin_SketchEntity, SKETCHPLUGIN_EXPORT virtual void execute(); /// Apply information of the message to current object. It fills start attribute of - /// the currrent feature by last attribute of the message feature, build coincidence + /// the current feature by last attribute of the message feature, build coincidence /// if message has selected object virtual std::string processEvent(const std::shared_ptr& theMessage); @@ -92,7 +92,7 @@ class SketchPlugin_Line : public SketchPlugin_SketchEntity, SketchPlugin_Line(); private: - /// Calculates the lenght of the line and fill the lenght attribute with the value + /// Calculates the length of the line and fill the length attribute with the value void updateLenghtValue(); protected: diff --git a/src/SketchPlugin/SketchPlugin_MacroArc.cpp b/src/SketchPlugin/SketchPlugin_MacroArc.cpp index b6a09bde6..f50e22554 100644 --- a/src/SketchPlugin/SketchPlugin_MacroArc.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroArc.cpp @@ -373,6 +373,7 @@ void SketchPlugin_MacroArc::execute() Events_Loop::loop()->send(aMessage); } +// LCOV_EXCL_START std::string SketchPlugin_MacroArc::processEvent(const std::shared_ptr& theMessage) { std::string aFilledAttributeName; @@ -450,6 +451,7 @@ std::string SketchPlugin_MacroArc::processEvent(const std::shared_ptr()) + return; bool aWasBlocked = data()->blockSendAttributeUpdated(true); // check the end point is referred to another feature diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp index 3b8049b57..5a3c14cb9 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp @@ -119,6 +119,7 @@ void SketchPlugin_MacroCircle::execute() Events_Loop::loop()->send(aMessage); } +// LCOV_EXCL_START std::string SketchPlugin_MacroCircle::processEvent( const std::shared_ptr& theMessage) { @@ -180,6 +181,7 @@ std::string SketchPlugin_MacroCircle::processEvent( } return aFilledAttributeName; } +// LCOV_EXCL_STOP void SketchPlugin_MacroCircle::constraintsForCircleByCenterAndPassed(FeaturePtr theCircleFeature) { diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 6a47d8539..d3a8a43e2 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -244,11 +245,14 @@ FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new SketchPlugin_Ellipse); } else if (theFeatureID == SketchPlugin_MacroEllipse::ID()) { return FeaturePtr(new SketchPlugin_MacroEllipse); + } else if (theFeatureID == SketchPlugin_SketchDrawer::ID()) { + return FeaturePtr(new SketchPlugin_SketchDrawer); } // feature of such kind is not found return FeaturePtr(); } +// LCOV_EXCL_START void SketchPlugin_Plugin::processEvent(const std::shared_ptr& theMessage) { const Events_ID kRequestEvent = @@ -318,3 +322,4 @@ std::shared_ptr SketchPlugin_Plugin } return aMsg; } +// LCOV_EXCL_STOP diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 252ecf181..d2f727f71 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -67,7 +67,7 @@ bool SketchPlugin_Point::isFixed() { } void SketchPlugin_Point::attributeChanged(const std::string& theID) { - // the second condition for unability to move external point anywhere + // the second condition for inability to move external point anywhere if (theID == EXTERNAL_ID() || isFixed()) { std::shared_ptr aSelection = data()->selection(EXTERNAL_ID())->value(); if (!aSelection) { diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index d23ad07d0..92fb4fcc5 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -255,38 +256,46 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { std::shared_ptr aSelection = aSelAttr->value(); if (!aSelection.get()) aSelection = aSelAttr->context()->shape(); // update the sketch plane - std::shared_ptr aFace(new GeomAPI_Face(aSelection)); - std::shared_ptr aPlane = aFace->getPlane(); - if (aPlane) { - double anA, aB, aC, aD; - aPlane->coefficients(anA, aB, aC, aD); - - // calculate attributes of the sketch - std::shared_ptr aNormDir(new GeomAPI_Dir(anA, aB, aC)); - std::shared_ptr aCoords = aNormDir->xyz(); - std::shared_ptr aZero(new GeomAPI_XYZ(0, 0, 0)); - aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero)); - std::shared_ptr anOrigPnt(new GeomAPI_Pnt(aCoords)); - // X axis is preferable to be dirX on the sketch - // here can not be very small value to avoid very close to X normal axis (issue 595) - static const double tol = 0.1; - bool isX = fabs(anA) - 1.0 < tol && fabs(aB) < tol && fabs(aC) < tol; - std::shared_ptr aTempDir( - isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); - std::shared_ptr aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir))); - std::shared_ptr aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir))); - - // update position of the sketch - std::shared_ptr anOrigin = std::dynamic_pointer_cast - (data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - anOrigin->setValue(anOrigPnt); - std::shared_ptr aNormal = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::NORM_ID())); - aNormal->setValue(aNormDir); - std::shared_ptr aDirX = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - aDirX->setValue(aXDir); - std::shared_ptr aDir = aPlane->direction(); + std::shared_ptr aFace; + if (aSelection->isFace()) { + aFace = aSelection->face(); + } else if (aSelection->isCompound()) { + GeomAPI_ShapeIterator anIt(aSelection); + aFace = anIt.current()->face(); + } + if (aFace.get()) { + std::shared_ptr aPlane = aFace->getPlane(); + if (aPlane.get()) { + double anA, aB, aC, aD; + aPlane->coefficients(anA, aB, aC, aD); + + // calculate attributes of the sketch + std::shared_ptr aNormDir(new GeomAPI_Dir(anA, aB, aC)); + std::shared_ptr aCoords = aNormDir->xyz(); + std::shared_ptr aZero(new GeomAPI_XYZ(0, 0, 0)); + aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero)); + std::shared_ptr anOrigPnt(new GeomAPI_Pnt(aCoords)); + // X axis is preferable to be dirX on the sketch + // here can not be very small value to avoid very close to X normal axis (issue 595) + static const double tol = 0.1; + bool isX = fabs(anA) - 1.0 < tol && fabs(aB) < tol && fabs(aC) < tol; + std::shared_ptr aTempDir( + isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); + std::shared_ptr aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir))); + std::shared_ptr aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir))); + + // update position of the sketch + std::shared_ptr anOrigin = std::dynamic_pointer_cast + (data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + anOrigin->setValue(anOrigPnt); + std::shared_ptr aNormal = std::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); + aNormal->setValue(aNormDir); + std::shared_ptr aDirX = std::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::DIRX_ID())); + aDirX->setValue(aXDir); + std::shared_ptr aDir = aPlane->direction(); + } } } } else if (theID == NORM_ID() || theID == DIRX_ID() || theID == ORIGIN_ID()) { @@ -361,9 +370,3 @@ std::shared_ptr SketchPlugin_Sketch::plane(SketchPlugin_Sketch* the return std::shared_ptr(new GeomAPI_Ax3(anOrigin->pnt(), aDirX->dir(), aNorm->dir())); } - -void SketchPlugin_Sketch::exchangeIDs( - std::shared_ptr theFeature1, std::shared_ptr theFeature2) -{ - reflist(SketchPlugin_Sketch::FEATURES_ID())->exchange(theFeature1, theFeature2); -} diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 3e7328e77..310001a81 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -204,16 +204,8 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICu /// Returns true if feature or reuslt belong to this composite feature as subs SKETCHPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const; - /// Construction result is allways recomuted on the fly - SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;} - SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); - /// Exchanges IDs of two given features: needed for fillet feature better naming (issue 769) - SKETCHPLUGIN_EXPORT virtual void exchangeIDs(std::shared_ptr theFeature1, - std::shared_ptr theFeature2); - - /// \brief Create a result for the point in the attribute if the attribute is initialized /// \param theFeature a source feature /// \param theSketch a sketch intance diff --git a/src/SketchPlugin/SketchPlugin_SketchDrawer.cpp b/src/SketchPlugin/SketchPlugin_SketchDrawer.cpp new file mode 100644 index 000000000..fd4deeddb --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_SketchDrawer.cpp @@ -0,0 +1,217 @@ +// 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 "SketchPlugin_SketchDrawer.h" + +#include "SketchPlugin_Arc.h" +#include "SketchPlugin_Line.h" +#include "SketchPlugin_Circle.h" +#include "SketchPlugin_Point.h" +#include "SketchPlugin_Sketch.h" +#include "SketchPlugin_ConstraintDistance.h" +#include "SketchPlugin_ConstraintCoincidence.h" +#include "SketchPlugin_ConstraintLength.h" +#include "SketchPlugin_ConstraintRadius.h" +#include "SketchPlugin_ConstraintVertical.h" +#include "SketchPlugin_ConstraintHorizontal.h" +#include "SketchPlugin_ConstraintDistanceVertical.h" +#include "SketchPlugin_ConstraintDistanceHorizontal.h" +#include "SketchPlugin_Tools.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +static const double kTOL = 1.e-6; + +SketchPlugin_SketchDrawer::SketchPlugin_SketchDrawer() : ModelAPI_Feature() +{} + +void SketchPlugin_SketchDrawer::initAttributes() +{ + data()->addAttribute(BASE_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(PLANE_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(ADD_DIMENSIONS_ID(), ModelAPI_AttributeBoolean::typeId()); +} + +// sets a point attribute of the feature by 3D point on the sketch +static void setPoint(FeaturePtr theFeature, const std::string& theAttrID, + std::shared_ptr theSketch, GeomPointPtr thePoint, + std::list >& aPoints) +{ + GeomPnt2dPtr aPnt2D = theSketch->to2D(thePoint); + std::dynamic_pointer_cast( + theFeature->attribute(theAttrID))->setValue(aPnt2D); + aPoints.push_back(std::pair(aPnt2D, theAttrID)); +} + +void SketchPlugin_SketchDrawer::execute() +{ + GeomShapePtr aBase = selection(BASE_ID())->value(); + if (!aBase.get() && selection(BASE_ID())->context().get()) + aBase = selection(BASE_ID())->context()->shape(); + if (!aBase.get()) { + setError("Error: a base shape can not be obtained"); + return; // invalid case + } + + ObjectPtr aPlaneContext = selection(PLANE_ID())->contextObject(); + GeomShapePtr aPlaneShape = selection(PLANE_ID())->value(); + if (!aPlaneShape.get() && aPlaneContext.get()) + aPlaneShape = selection(PLANE_ID())->context()->shape(); + if (!aPlaneShape.get() || aPlaneShape->shapeType() != GeomAPI_Shape::FACE) { + setError("Error: a sketch plane can not be obtained"); + return; // invalid case + } + GeomFacePtr aPlaneFace(new GeomAPI_Face(aPlaneShape)); + GeomPlanePtr aPlane = aPlaneFace->getPlane(); + + // create and initialize sketch + DocumentPtr aMyDoc = document(); + std::shared_ptr aSketch = + std::dynamic_pointer_cast(aMyDoc->addFeature(SketchPlugin_Sketch::ID())); + // by selection of plane + aSketch->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())-> + setValue(selection(PLANE_ID())->context(), aPlaneShape); + // remove reference, but keep the sketch position + aSketch->selection(SketchPlugin_SketchEntity::EXTERNAL_ID())-> + setValue(ResultPtr(), GeomShapePtr()); + + bool addDimensions = boolean(ADD_DIMENSIONS_ID())->value(); + // iterate all edges of the base to find all edges that belong to this plane + GeomAPI_DataMapOfShapeShape alreadyProcessed; + std::list aCreatedPoints;// points to check and set coincidence + for(GeomAPI_ShapeExplorer anEdges(aBase, GeomAPI_Shape::EDGE); anEdges.more(); anEdges.next()) { + if (!alreadyProcessed.bind(anEdges.current(), anEdges.current())) + continue; // skip duplicated edges + GeomEdgePtr anEdge(new GeomAPI_Edge(anEdges.current())); + if (anEdge->isDegenerated()) + continue; // skip degenerated edges + GeomPointPtr aStart = anEdge->firstPoint(); + GeomPointPtr anEnd = anEdge->lastPoint(); + if (aPlane->distance(aStart) >= kTOL || aPlane->distance(anEnd) >= kTOL) + continue; // skip edges not in plane + + FeaturePtr anItem; + std::list > aPoints; // created point to attribute ID + if (anEdge->isLine()) { // line is already in the plane: create by two points + anItem = aSketch->addFeature(SketchPlugin_Line::ID()); + setPoint(anItem, SketchPlugin_Line::START_ID(), aSketch, aStart, aPoints); + setPoint(anItem, SketchPlugin_Line::END_ID(), aSketch, anEnd, aPoints); + anItem->execute(); // for constraints setting on result + // add a vertical or horizontal constraints + bool isHorVertConstr = true; + if (fabs(aPoints.front().first->x() - aPoints.back().first->x()) < kTOL) { + FeaturePtr aVert = aSketch->addFeature(SketchPlugin_ConstraintVertical::ID()); + aVert->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(anItem->firstResult()); + } else if (fabs(aPoints.front().first->y() - aPoints.back().first->y()) < kTOL) { + FeaturePtr aHor = aSketch->addFeature(SketchPlugin_ConstraintHorizontal::ID()); + aHor->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(anItem->firstResult()); + } else { + isHorVertConstr = false; + } + if (addDimensions) { + if (isHorVertConstr) { // only length constraint is enough + FeaturePtr aLen = aSketch->addFeature(SketchPlugin_ConstraintLength::ID()); + aLen->refattr(SketchPlugin_ConstraintLength::ENTITY_A()) + ->setObject(anItem->firstResult()); + aLen->real(SketchPlugin_ConstraintLength::VALUE())->setValue(anEdge->length()); + } else { // set horizontal and vertical distance constraints + FeaturePtr aVDist = aSketch->addFeature(SketchPlugin_ConstraintDistanceVertical::ID()); + aVDist->refattr(SketchPlugin_Constraint::ENTITY_A()) + ->setAttr(anItem->attribute(SketchPlugin_Line::START_ID())); + aVDist->refattr(SketchPlugin_Constraint::ENTITY_B()) + ->setAttr(anItem->attribute(SketchPlugin_Line::END_ID())); + aVDist->real(SketchPlugin_ConstraintDistanceVertical::VALUE()) + ->setValue(aPoints.back().first->y() - aPoints.front().first->y()); + FeaturePtr aHDist = aSketch->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID()); + aHDist->refattr(SketchPlugin_Constraint::ENTITY_A()) + ->setAttr(anItem->attribute(SketchPlugin_Line::START_ID())); + aHDist->refattr(SketchPlugin_Constraint::ENTITY_B()) + ->setAttr(anItem->attribute(SketchPlugin_Line::END_ID())); + aHDist->real(SketchPlugin_ConstraintDistanceVertical::VALUE()) + ->setValue(aPoints.back().first->x() - aPoints.front().first->x()); + } + } + } else if (anEdge->isArc()) { // check also center + GeomPointPtr aCenter = anEdge->circle()->center(); + if (aPlane->distance(aCenter) >= kTOL) + continue; + // create arc by 3 points + anItem = aSketch->addFeature(SketchPlugin_Arc::ID()); + setPoint(anItem, SketchPlugin_Arc::CENTER_ID(), aSketch, aCenter, aPoints); + setPoint(anItem, SketchPlugin_Arc::START_ID(), aSketch, aStart, aPoints); + setPoint(anItem, SketchPlugin_Arc::END_ID(), aSketch, anEnd, aPoints); + anItem->execute(); // for constraints setting on result + // set radius constraint + if (addDimensions) { + FeaturePtr aRad = aSketch->addFeature(SketchPlugin_ConstraintRadius::ID()); + aRad->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(anItem->lastResult()); + } + } else if (anEdge->isCircle()) { // check also center and middle (at value 2.) + GeomPointPtr aCenter = anEdge->circle()->center(); + if (aPlane->distance(aCenter) >= kTOL || aPlane->distance(anEdge->middlePoint()) >= kTOL) + continue; + // circle by center and radius + anItem = aSketch->addFeature(SketchPlugin_Circle::ID()); + setPoint(anItem, SketchPlugin_Circle::CENTER_ID(), aSketch, aCenter, aPoints); + anItem->real(SketchPlugin_Circle::RADIUS_ID())->setValue(anEdge->circle()->radius()); + anItem->execute(); // for constraints setting on result + // set radius constraint + if (addDimensions) { + FeaturePtr aRad = aSketch->addFeature(SketchPlugin_ConstraintRadius::ID()); + aRad->refattr(SketchPlugin_Constraint::ENTITY_A())->setObject(anItem->lastResult()); + } + } else { + continue; // other types of edges are not supported, only lines, circles and arcs + } + // check some resulting points are coincident to existing + std::list >::iterator aPIter = aPoints.begin(); + for(; aPIter != aPoints.end(); aPIter++) { + AttributePoint2DPtr aPointAttr = + std::dynamic_pointer_cast(anItem->attribute(aPIter->second)); + std::list::iterator aCoincIter = aCreatedPoints.begin(); + for(; aCoincIter != aCreatedPoints.end(); aCoincIter++) { + double aDX = (*aCoincIter)->x() - aPIter->first->x(); + if (fabs(aDX) >= kTOL) + continue; + double aDY = (*aCoincIter)->y() - aPIter->first->y(); + if (fabs(aDY) >= kTOL) + continue; + // create a coincidence constraint + FeaturePtr aCoinc = aSketch->addFeature(SketchPlugin_ConstraintCoincidence::ID()); + aCoinc->refattr(SketchPlugin_Constraint::ENTITY_A())->setAttr(aPointAttr); + aCoinc->refattr(SketchPlugin_Constraint::ENTITY_B())->setAttr(*aCoincIter); + break; // only one coincidence per point + } + aCreatedPoints.push_back(aPointAttr); + } + } + aMyDoc->setCurrentFeature(aSketch, false); +} diff --git a/src/SketchPlugin/SketchPlugin_SketchDrawer.h b/src/SketchPlugin/SketchPlugin_SketchDrawer.h new file mode 100644 index 000000000..62c1ed163 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_SketchDrawer.h @@ -0,0 +1,85 @@ +// 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 +// + +#ifndef SketchPlugin_SketchDrawer_H_ +#define SketchPlugin_SketchDrawer_H_ + +#include "SketchPlugin.h" +#include + +/// \class SketchPlugin_SketchDrawer +/// \ingroup Plugins +/// \brief Feature for creation of a sketch on selected base object and plane. It tries +/// to make sketch elements equal to edges and vertices of the objects that belong to +/// the selected plane. +class SketchPlugin_SketchDrawer: public ModelAPI_Feature +{ + public: + /// A constructor + SketchPlugin_SketchDrawer(); + + /// Feature kind. + inline static const std::string& ID() + { + static const std::string MY_FEATURE_ID("SketchDrawer"); + return MY_FEATURE_ID; + } + + /// Attribute name of the base shape selected. + inline static const std::string& BASE_ID() + { + static const std::string ID("base_shape"); + return ID; + } + /// Attribute name of the plane selected. + inline static const std::string& PLANE_ID() + { + static const std::string ID("plane"); + return ID; + } + /// Attribute name of the add-dimensions flag. + inline static const std::string& ADD_DIMENSIONS_ID() + { + static const std::string ID("add_dimensions"); + return ID; + } + + /// \return the kind of a feature. + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_SketchDrawer::ID(); + return MY_KIND; + } + + /// Creates a new sketch. + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes. + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// Reimplemented from ModelAPI_Feature::isMacro(). Means that feature is removed on apply. + /// \returns true + SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;} + + /// No preview is generated until it is applied. + SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;} +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index baa37b9d8..4e984c0a1 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -112,6 +112,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC return false; } +// LCOV_EXCL_START /// Customize presentation of the feature virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theDefaultPrs) @@ -192,6 +193,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC } return isCustomized; } +// LCOV_EXCL_STOP protected: /// initializes mySketch diff --git a/src/SketchPlugin/SketchPlugin_Split.cpp b/src/SketchPlugin/SketchPlugin_Split.cpp index d9e0cc252..c90b10cc0 100644 --- a/src/SketchPlugin/SketchPlugin_Split.cpp +++ b/src/SketchPlugin/SketchPlugin_Split.cpp @@ -421,6 +421,7 @@ void SketchPlugin_Split::execute() #endif } +// LCOV_EXCL_START std::string SketchPlugin_Split::processEvent(const std::shared_ptr& theMessage) { #ifdef DEBUG_SPLIT @@ -484,6 +485,7 @@ std::string SketchPlugin_Split::processEvent(const std::shared_ptr SketchPlugin_Split::getPointOfRefAttr( - const AttributePtr& theAttribute) -{ - AttributePoint2DPtr aPointAttribute; - - if (theAttribute->attributeType() == ModelAPI_AttributeRefAttr::typeId()) { - AttributeRefAttrPtr aRefAttr = - std::dynamic_pointer_cast(theAttribute); - if (aRefAttr.get() && aRefAttr->isInitialized()) { - AttributePtr anAttribute = aRefAttr->attr(); - if (anAttribute.get() && anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) - aPointAttribute = std::dynamic_pointer_cast(anAttribute); - } - } - return aPointAttribute; -} - void SketchPlugin_Split::getFeaturePoints(const FeaturePtr& theFeature, AttributePoint2DPtr& theStartPointAttr, AttributePoint2DPtr& theEndPointAttr) @@ -1566,6 +1551,7 @@ std::shared_ptr SketchPlugin_Split::getFeatureResult( return aResult; } +#ifdef _DEBUG std::set > SketchPlugin_Split::getEdgeAttributes( const std::shared_ptr& theFeature) { @@ -1585,6 +1571,7 @@ std::set > SketchPlugin_Split::getEdgeAttrib return anAttributes; } +#endif std::shared_ptr SketchPlugin_Split::getPointAttribute (const bool isFirstAttribute) diff --git a/src/SketchPlugin/SketchPlugin_Split.h b/src/SketchPlugin/SketchPlugin_Split.h index 363db3645..a52428b79 100644 --- a/src/SketchPlugin/SketchPlugin_Split.h +++ b/src/SketchPlugin/SketchPlugin_Split.h @@ -149,11 +149,6 @@ private: std::shared_ptr& theStartPointAttr, std::shared_ptr& theEndPointAttr); - /// Returns cast of attribute to geometrical point if the attribute is a ref attr attribute - /// \param theAttribute an attribute - /// \param geom point 2D or NULL - std::shared_ptr getPointOfRefAttr(const AttributePtr& theAttribute); - /// Obtains those constraints of the feature that should be modified. output maps contain /// point of coincidence and attribute id to be modified after split /// \param theFeaturesToDelete [out] constrains that will be deleted after split diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index 387f3a8b4..5346feda8 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -478,6 +478,7 @@ void SketchPlugin_Trim::execute() #endif } +// LCOV_EXCL_START std::string SketchPlugin_Trim::processEvent(const std::shared_ptr& theMessage) { #ifdef DEBUG_TRIM_METHODS @@ -529,6 +530,7 @@ std::string SketchPlugin_Trim::processEvent(const std::shared_ptr& theFurtherCoincidences, @@ -1197,20 +1199,6 @@ void SketchPlugin_Trim::fillAttribute(const AttributePtr& theModifiedAttribute, if (aModifiedAttribute.get() && aSourceAttribute.get()) aModifiedAttribute->setValue(aSourceAttribute->value()); } - else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { - AttributeRefAttrPtr aRefAttributeToFill = std::dynamic_pointer_cast( - theModifiedAttribute); - AttributeRefAttrPtr aSourceRefAttr = std::dynamic_pointer_cast( - theSourceAttribute); - if (!aSourceRefAttr.get()) - aRefAttributeToFill->setAttr(theSourceAttribute); - else { - if (aSourceRefAttr->isObject()) - aRefAttributeToFill->setObject(aSourceRefAttr->object()); - else - aRefAttributeToFill->setAttr(aSourceRefAttr->attr()); - } - } } FeaturePtr SketchPlugin_Trim::createLineFeature(const FeaturePtr& theBaseFeature, diff --git a/src/SketchPlugin/Test/Test2034_3.py b/src/SketchPlugin/Test/Test2034_3.py index 632db037c..99f21766c 100644 --- a/src/SketchPlugin/Test/Test2034_3.py +++ b/src/SketchPlugin/Test/Test2034_3.py @@ -48,14 +48,14 @@ SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_4.result(), SketchLine_1. SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_5.result(), 10) model.do() Sketch_2 = model.addSketch(partSet, model.defaultPlane("XOZ")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s-SketchLine_4e"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex"), False) SketchPoint_1 = SketchProjection_3.createdFeature() SketchArc_1 = Sketch_2.addArc(0, 5, -5, 0, 5, 0, False) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchArc_1.startPoint()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_5e"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), False) SketchPoint_2 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchAPI_Point(SketchPoint_2).coordinates()) -SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_4s-SketchLine_1e"), False) +SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False) SketchPoint_3 = SketchProjection_5.createdFeature() model.do() diff --git a/src/SketchPlugin/Test/Test2119.py b/src/SketchPlugin/Test/Test2119.py index 1c949e8cb..e9f70c2c6 100644 --- a/src/SketchPlugin/Test/Test2119.py +++ b/src/SketchPlugin/Test/Test2119.py @@ -86,24 +86,24 @@ SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 10) SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.coordinates()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchArc_1_2r-SketchArc_2_2r")], model.selection(), "b/2", "b/2") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), False) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchArc_2_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchArc_1_2r-SketchLine_10f")], model.selection(), "b/2", "b/2") +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]"), False) SketchPoint_2 = SketchProjection_1.createdFeature() SketchCircle_1 = Sketch_2.addCircle(-15, 35, 25) SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchCircle_1.center(), SketchPoint_2.result()) SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_1.results()[1], "50/2") model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_4")) -SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_4"), False) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f_wire")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&ExtrusionCut_1_1/From_Face")) +SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Vertex&ExtrusionCut_1_1/From_Face"), False) SketchPoint_3 = SketchProjection_2.createdFeature() -SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_4"), False) +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_2"), False) SketchLine_11 = SketchProjection_3.createdFeature() SketchArc_3 = Sketch_3.addArc(-15, 35, -15, 46.0103340429751, -17.02045759563166, 24.17663606626138, True) SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchPoint_3.result(), SketchArc_3.center()) SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_11.result(), SketchArc_3.startPoint()) -SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_1_1/Modfied_4"), False) +SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_1"), False) SketchArc_4 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1]) SketchLine_12 = Sketch_3.addLine(-15, 46.0103340429751, -15, 35) diff --git a/src/SketchPlugin/Test/Test2280.py b/src/SketchPlugin/Test/Test2280.py index d96bf8aac..980d684ee 100644 --- a/src/SketchPlugin/Test/Test2280.py +++ b/src/SketchPlugin/Test/Test2280.py @@ -32,7 +32,7 @@ Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_2")) -SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), True) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "[Cylinder_1_1/Face_1][Cylinder_1_1/Face_2]"), True) SketchCircle_1 = SketchProjection_1.createdFeature() SketchCircle_2 = Sketch_1.addCircle(0.0, 10.0, 8.0) model.do() diff --git a/src/SketchPlugin/Test/Test2287.py b/src/SketchPlugin/Test/Test2287.py index 1049f7d1c..f812ec934 100644 --- a/src/SketchPlugin/Test/Test2287.py +++ b/src/SketchPlugin/Test/Test2287.py @@ -28,13 +28,13 @@ Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchLine_1 = Sketch_1.addLine(-20, -62, 81, 60) model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), True) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), True) SketchLine_2 = SketchProjection_1.createdFeature() model.do() -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchProjection_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchProjection_1")]) model.end() # before bug fix it was "Sketch_2" -assert(Edge_1.baseObjects().value(0).namingName() == "Sketch_2/Edge-SketchProjection_1") +assert(Edge_1.baseObjects().value(0).namingName() == "Sketch_2/SketchProjection_1") assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/Test2341.py b/src/SketchPlugin/Test/Test2341.py index a62144360..337a82cb9 100644 --- a/src/SketchPlugin/Test/Test2341.py +++ b/src/SketchPlugin/Test/Test2341.py @@ -112,13 +112,13 @@ SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_3.endPoint(), Sketch SketchConstraintLength_6 = Sketch_1.setLength(SketchLine_9.result(), 20) SketchConstraintLength_6.setName("SketchConstraintLength_8") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6r-SketchLine_7r-SketchLine_8f-SketchArc_1_2f-SketchArc_2_2f-SketchArc_3_2r-SketchLine_11f-SketchLine_12r")], model.selection(), 3.5, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_2_2f-SketchLine_11f-SketchArc_3_2r-SketchLine_12r-SketchLine_7r-SketchLine_6r-SketchLine_8f-SketchArc_1_2f")], model.selection(), 3.5, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6")) SketchLine_14 = Sketch_2.addLine(6, 0, -6, 0) -SketchProjection_8 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_7s-SketchLine_6e"), False) +SketchProjection_8 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_6_EndVertex"), False) SketchPoint_7 = SketchProjection_8.createdFeature() SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchPoint_7.result()) -SketchProjection_9 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_6s-SketchLine_8s"), False) +SketchProjection_9 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_6_StartVertex"), False) SketchPoint_8 = SketchProjection_9.createdFeature() SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_8.result()) SketchLine_15 = Sketch_2.addLine(-6, 0, -6, -3.5) @@ -126,14 +126,14 @@ SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_14.endPoint() SketchLine_16 = Sketch_2.addLine(-6, -3.5, -6, -10.5) SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) SketchLine_17 = Sketch_2.addLine(5.978225648847096, 0.08643259872215214, 6, -3.5) -SketchProjection_10 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), False) +SketchProjection_10 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/To_Face]"), False) SketchPoint_9 = SketchProjection_10.createdFeature() SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchPoint_9.result()) SketchLine_18 = Sketch_2.addLine(6, -3.5, 6, -10.5) SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint()) SketchConstraintLength_7 = Sketch_2.setLength(SketchLine_18.result(), 7) SketchConstraintLength_7.setName("SketchConstraintLength_9") -SketchProjection_11 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), False) +SketchProjection_11 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/To_Face]"), False) SketchPoint_10 = SketchProjection_11.createdFeature() SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_10).coordinates(), SketchLine_15.endPoint()) SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_18.result()) diff --git a/src/SketchPlugin/Test/Test2390.py b/src/SketchPlugin/Test/Test2390.py index 1739cbe66..d0f4b6f67 100644 --- a/src/SketchPlugin/Test/Test2390.py +++ b/src/SketchPlugin/Test/Test2390.py @@ -93,11 +93,11 @@ SketchConstraintVertical_15 = Sketch_4.setVertical(SketchLine_52.result()) SketchConstraintVertical_16 = Sketch_4.setVertical(SketchLine_55.result()) SketchConstraintVertical_17 = Sketch_4.setVertical(SketchLine_58.result()) SketchConstraintHorizontal_11 = Sketch_4.setHorizontal(SketchLine_56.result()) -SketchProjection_13 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5e"), False) +SketchProjection_13 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_5_EndVertex"), False) SketchPoint_4 = SketchProjection_13.createdFeature() SketchConstraintDistanceHorizontal_17 = Sketch_4.setHorizontalDistance(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_52.endPoint(), "Drill2_Loc") SketchConstraintLength_3 = Sketch_4.setLength(SketchLine_54.result(), "Drill2_InnerRadius") -SketchProjection_14 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), False) +SketchProjection_14 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_3"), False) SketchLine_59 = SketchProjection_14.createdFeature() SketchConstraintAngle_6 = Sketch_4.setAngle(SketchLine_57.result(), SketchLine_56.result(), 45) SketchConstraintLength_4 = Sketch_4.setLength(SketchLine_56.result(), "Drill2_Radius") @@ -111,7 +111,7 @@ SketchConstraintDistance_14 = Sketch_4.setDistance(SketchLine_57.endPoint(), Ske SketchConstraintTangent_3 = Sketch_4.setTangent(SketchLine_58.result(), SketchArc_2.results()[1]) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_9r-SketchLine_10r-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchArc_1_2f")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_7"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchArc_1_2f-SketchLine_10r-SketchLine_9r-SketchLine_7r")], model.selection("EDGE", "Sketch_2/SketchLine_7"), 360, 0) model.do() from GeomAPI import GeomAPI_Shape @@ -157,4 +157,4 @@ model.testResultsVolumes(Revolution_1, [41.691543241529835484016075497], SIGNIFI model.end() # TODO: uncomment following line when issue #2389 is fixed -#assert(model.checkPythonDump()) \ No newline at end of file +#assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/Test2393.py b/src/SketchPlugin/Test/Test2393.py index 0fc461049..09a224557 100644 --- a/src/SketchPlugin/Test/Test2393.py +++ b/src/SketchPlugin/Test/Test2393.py @@ -38,7 +38,7 @@ Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_1_1/Top"), 10, Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) SketchPoint_1 = SketchProjection_1.createdFeature() -SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "Box_1_1/Front&Box_1_1/Top"), True) +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]"), True) SketchLine_1 = SketchProjection_2.createdFeature() SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_1).coordinates(), 90, 3) [SketchLine_1, SketchLine_2, SketchLine_3] = SketchMultiRotation_1.rotated() @@ -54,4 +54,4 @@ model.checkSketch(Sketch_1, 0) model.end() -assert(model.checkPythonDump()) \ No newline at end of file +assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/Test2440.py b/src/SketchPlugin/Test/Test2440.py index eb4077a58..0197e4ab8 100644 --- a/src/SketchPlugin/Test/Test2440.py +++ b/src/SketchPlugin/Test/Test2440.py @@ -44,7 +44,7 @@ Import_1.result().setName("profile_top_1") Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_1 = Sketch_1.addLine(-0.5, 0, -0.1, 0.5) -SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "profile_top_1/Shape2"), False) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "profile_top_1/Shape_2"), False) SketchPoint_1 = SketchProjection_1.createdFeature() model.do() diff --git a/src/SketchPlugin/Test/Test2654.py b/src/SketchPlugin/Test/Test2654.py index 066d5e292..f78931992 100644 --- a/src/SketchPlugin/Test/Test2654.py +++ b/src/SketchPlugin/Test/Test2654.py @@ -113,13 +113,13 @@ SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_1.startPoint( SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_23") SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_11.result(), SketchArc_2.startPoint(), 7.37, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_10r-SketchArc_1_2r-SketchArc_2_2f-SketchArc_3_2f")], model.selection(), "h", 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1"), False) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_3_2f-SketchLine_10r-SketchArc_1_2r-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchArc_2_2f")], model.selection(), "h", 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7")) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/From_Face]"), False) SketchPoint_2 = SketchProjection_3.createdFeature() -SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]"), False) SketchPoint_3 = SketchProjection_4.createdFeature() -SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), False) +SketchProjection_5 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/To_Face]"), False) SketchPoint_4 = SketchProjection_5.createdFeature() SketchLine_13 = Sketch_2.addLine(6.005577592461473, 0, -5.994422407538528, 0) SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_13.startPoint()) @@ -129,7 +129,7 @@ SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_26") SketchLine_14 = Sketch_2.addLine(-5.994422407538528, 0, -5.994422407538528, -3.5) SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_27") -SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), False) +SketchProjection_6 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/To_Face]"), False) SketchPoint_5 = SketchProjection_6.createdFeature() SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_28") @@ -161,7 +161,7 @@ SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_17.result()) SketchConstraintLength_6 = Sketch_2.setLength(SketchLine_17.result(), 7) SketchConstraintEqual_2 = Sketch_2.setEqual(SketchLine_17.result(), SketchLine_15.result()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchLine_16r-SketchLine_17r-SketchArc_5_2f")], model.selection(), "h", 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_13f-SketchLine_14f-SketchLine_15f-SketchArc_5_2f-SketchLine_17r-SketchLine_16r")], model.selection(), "h", 0) model.do() diff --git a/src/SketchPlugin/Test/Test2741.py b/src/SketchPlugin/Test/Test2741.py new file mode 100644 index 000000000..549f5af67 --- /dev/null +++ b/src/SketchPlugin/Test/Test2741.py @@ -0,0 +1,44 @@ +## Copyright (C) 2018-20xx 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 +## + +""" + Test2741.py + Test case for issue #2741 "Undo of distance argument change produces crash" +""" + +from salome.shaper import model +from SketchAPI import * + +model.begin() +partSet = model.moduleDocument() +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-34.48932587013569, -5.994823429605995, -23.03828378136105, 27.99739301876914) +SketchLine_2 = Sketch_1.addLine(-23.03828378136105, 27.99739301876914, -14.34307552407934, -3.849202930145424) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_2.result(), 20, True) +model.do() + +# Change point-line distance constraint to point-point distance +SketchAPI_Constraint(SketchConstraintDistance_1).setEntityB(SketchLine_2.endPoint()) +model.do() +model.end() + +# Check no crash on undo distance changing +model.undo() diff --git a/src/SketchPlugin/Test/Test2810.py b/src/SketchPlugin/Test/Test2810.py new file mode 100644 index 000000000..413153337 --- /dev/null +++ b/src/SketchPlugin/Test/Test2810.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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 +## + +""" + Test2810.py + Test case for issue #2810 "crash creating arc fillet" +""" + +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")) +SketchArc_1 = Sketch_1.addArc(10, 10, 11, 10, 10, 11, False) +SketchLine_1 = Sketch_1.addLine(12, 10, 12, 9) +model.do() + +Sketch_1.setFixed(SketchArc_1.results()[1]) +Sketch_1.setFixed(SketchLine_1.result()) + +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.startPoint()) +model.do() + +SketchFillet = Sketch_1.setFillet(SketchArc_1.startPoint()) +model.do() + +assert(Sketch_1.feature().error() != "") + +model.end() diff --git a/src/SketchPlugin/Test/TestConstraintDistance.py b/src/SketchPlugin/Test/TestConstraintDistance.py index 46ce2e4d1..a36c17835 100644 --- a/src/SketchPlugin/Test/TestConstraintDistance.py +++ b/src/SketchPlugin/Test/TestConstraintDistance.py @@ -171,6 +171,25 @@ assert (refattrB.isInitialized()) assert (aDistance.isInitialized()) assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist) assert (model.dof(aSketchFeature) == 5) + +#========================================================================= +# Swap point and line in the distance +#========================================================================= +aSession.startOperation() +refattrA.setAttr(aSketchPointCoords) +refattrB.setObject(aLineResult) +aSession.finishOperation() +assert (model.dof(aSketchFeature) == 5) +# set flyout point then abort operation, after that check the Distance is correct +aSession.startOperation() +aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt")) +aFlyoutPoint.setValue(100.0, 100.0) +aSession.abortOperation() +assert (refattrA.isInitialized()) +assert (refattrB.isInitialized()) +assert (aDistance.isInitialized()) +assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist) +assert (model.dof(aSketchFeature) == 5) #========================================================================= # Change distance value #========================================================================= diff --git a/src/SketchPlugin/Test/TestConstraintEqual.py b/src/SketchPlugin/Test/TestConstraintEqual.py index cd5bf4b68..1251e564e 100644 --- a/src/SketchPlugin/Test/TestConstraintEqual.py +++ b/src/SketchPlugin/Test/TestConstraintEqual.py @@ -147,7 +147,7 @@ anExtCircleCenter = geomDataAPI_Point2D(anExtCircle.attribute("circle_center")) anExtCircleRadius = anExtCircle.real("circle_radius") anExtCircleCenter.setValue(-50., 50.) anExtCircleRadius.setValue(10.) -anExtCircle.selection("External").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2") +anExtCircle.selection("External").selectSubShape("EDGE", "Sketch_1/SketchCircle_1_2") aSession.finishOperation() assert (model.dof(aSketchFeature) == 7) aSession.startOperation() @@ -212,7 +212,7 @@ anExtLineStart = geomDataAPI_Point2D(anExtLine.attribute("StartPoint")) anExtLineEnd = geomDataAPI_Point2D(anExtLine.attribute("EndPoint")) anExtLineStart.setValue(-40., 35.) anExtLineEnd.setValue(-60., 25.) -anExtLine.selection("External").selectSubShape("EDGE", "Sketch_1/Edge-SketchLine_1") +anExtLine.selection("External").selectSubShape("EDGE", "Sketch_1/SketchLine_1") anExtLineLen = lineLength(anExtLine) aSession.finishOperation() assert (model.dof(aSketchFeature) == 13) diff --git a/src/SketchPlugin/Test/TestConstraintRadiusFailure.py b/src/SketchPlugin/Test/TestConstraintRadiusFailure.py new file mode 100644 index 000000000..c989fc917 --- /dev/null +++ b/src/SketchPlugin/Test/TestConstraintRadiusFailure.py @@ -0,0 +1,34 @@ +## Copyright (C) 2018-20xx 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, 0, -10, 0) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchLine_1.result(), 20) +model.do() + +assert(SketchConstraintRadius_1.feature().error() != "") + +model.end() diff --git a/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py index 0e4464774..92666b178 100644 --- a/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py +++ b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py @@ -272,6 +272,116 @@ verifyPointOnCircle(aStart, aPrevArc) model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 6) model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0) +#========================================================================= +# Test 5. Create another arc by center and points coincident to other features +#========================================================================= +# create new arc +aSession.startOperation() +anArc = aSketchFeature.addFeature("SketchMacroArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aCenterRef = anArc.refattr("center_point_ref") +aStart = geomDataAPI_Point2D(anArc.attribute("start_point_1")) +aStartRef = anArc.refattr("start_point_ref") +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1")) +aEndRef = anArc.refattr("end_point_ref") +anArcType = anArc.string("arc_type") +# initialize attributes +anArcType.setValue("by_center_and_points") +aCenterRef.setObject(aLine.lastResult()) +aCenter.setValue(aLineStartPoint.pnt()) +aStartRef.setObject(aLine.lastResult()) +aStart.setValue(aLineEndPoint.pnt()) +aEndRef.setObject(aPrevArc.lastResult()) +aEnd.setValue(aPrevArcStart.pnt()) +aSession.finishOperation() +assert (aSketchFeature.numberOfSubs() == 16), "Number of subs {}".format(aSketchFeature.numberOfSubs()) +# check connected features do not change their positions +model.assertArc(aPrevArc, aPrevArcCenterXY, aPrevArcStartXY, aPrevArcEndXY) +model.assertLine(aLine, aLineStart, aLineEnd) +# verify newly created arc +anArc = model.lastSubFeature(aSketchFeature, "SketchArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aStart = geomDataAPI_Point2D(anArc.attribute("start_point")) +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point")) +verifyPointOnLine(aCenter, aLine) +verifyPointOnLine(aStart, aLine) +verifyPointOnCircle(aEnd, aPrevArc) +model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 9) +model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0) + +#========================================================================= +# Test 6. Create one more arc by center and points coincident to other features +#========================================================================= +# get previous arc +aPrevArc = model.lastSubFeature(aSketchFeature, "SketchArc") +aPrevArcCenter = geomDataAPI_Point2D(aPrevArc.attribute("center_point")) +aPrevArcStart = geomDataAPI_Point2D(aPrevArc.attribute("start_point")) +aPrevArcEnd = geomDataAPI_Point2D(aPrevArc.attribute("end_point")) +aPrevArcCenterXY = [aPrevArcCenter.x(), aPrevArcCenter.y()] +aPrevArcStartXY = [aPrevArcStart.x(), aPrevArcStart.y()] +aPrevArcEndXY = [aPrevArcEnd.x(), aPrevArcEnd.y()] +# create new arc +aSession.startOperation() +anArc = aSketchFeature.addFeature("SketchMacroArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aCenterRef = anArc.refattr("center_point_ref") +aStart = geomDataAPI_Point2D(anArc.attribute("start_point_1")) +aStartRef = anArc.refattr("start_point_ref") +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1")) +aEndRef = anArc.refattr("end_point_ref") +anArcType = anArc.string("arc_type") +# initialize attributes +anArcType.setValue("by_center_and_points") +delta = [aPrevArcEndXY[0] - aPrevArcCenterXY[0], aPrevArcEndXY[1] - aPrevArcCenterXY[1]] +aCenter.setValue(aPrevArcCenterXY[0] + 2 * delta[0], aPrevArcCenterXY[1] + 2 * delta[1]) +aStart.setValue(aPrevArcCenterXY[0] + 2 * delta[0] - 0.9 * delta[1], aPrevArcCenterXY[1] + 2 * delta[1] + 0.9 * delta[0]) +aEndRef.setObject(aPrevArc.lastResult()) +aEnd.setValue(aPrevArcCenterXY[0] + 1.1 * delta[0], aPrevArcCenterXY[1] + 1.1 * delta[1]) +aSession.finishOperation() +assert (aSketchFeature.numberOfSubs() == 18), "Number of subs {}".format(aSketchFeature.numberOfSubs()) +# verify newly created arc +anArc = model.lastSubFeature(aSketchFeature, "SketchArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aStart = geomDataAPI_Point2D(anArc.attribute("start_point")) +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point")) +verifyPointOnCircle(aEnd, aPrevArc) +model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 10) +model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0) + +#========================================================================= +# Test 7. Create one more arc by center and points coincident to other features +#========================================================================= +aPrevArcCenterXY = [aPrevArcCenter.x(), aPrevArcCenter.y()] +aPrevArcStartXY = [aPrevArcStart.x(), aPrevArcStart.y()] +aPrevArcEndXY = [aPrevArcEnd.x(), aPrevArcEnd.y()] +# create new arc +aSession.startOperation() +anArc = aSketchFeature.addFeature("SketchMacroArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aCenterRef = anArc.refattr("center_point_ref") +aStart = geomDataAPI_Point2D(anArc.attribute("start_point_1")) +aStartRef = anArc.refattr("start_point_ref") +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point_1")) +aEndRef = anArc.refattr("end_point_ref") +anArcType = anArc.string("arc_type") +# initialize attributes +anArcType.setValue("by_center_and_points") +delta = [aPrevArcEndXY[0] - aPrevArcCenterXY[0], aPrevArcEndXY[1] - aPrevArcCenterXY[1]] +aCenter.setValue(aPrevArcCenterXY[0] + 2 * delta[0], aPrevArcCenterXY[1] + 2 * delta[1]) +aStart.setValue(aPrevArcCenterXY[0] + 2 * delta[0] - delta[1], aPrevArcCenterXY[1] + 2 * delta[1] + delta[0]) +aEndRef.setObject(aPrevArc.lastResult()) +aEnd.setValue(aPrevArcCenterXY[0] + delta[0], aPrevArcCenterXY[1] + delta[1]) +aSession.finishOperation() +assert (aSketchFeature.numberOfSubs() == 20), "Number of subs {}".format(aSketchFeature.numberOfSubs()) +# verify newly created arc +anArc = model.lastSubFeature(aSketchFeature, "SketchArc") +aCenter = geomDataAPI_Point2D(anArc.attribute("center_point")) +aStart = geomDataAPI_Point2D(anArc.attribute("start_point")) +aEnd = geomDataAPI_Point2D(anArc.attribute("end_point")) +verifyPointOnCircle(aEnd, aPrevArc) +model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 11) +model.testNbSubFeatures(aSketch, "SketchConstraintTangent", 0) + #========================================================================= # End of test #========================================================================= diff --git a/src/SketchPlugin/Test/TestEdgesOrder.py b/src/SketchPlugin/Test/TestEdgesOrder.py index cc8ae38a7..5a53a81f0 100644 --- a/src/SketchPlugin/Test/TestEdgesOrder.py +++ b/src/SketchPlugin/Test/TestEdgesOrder.py @@ -55,26 +55,26 @@ Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) Sketch_1.setLength(SketchLine_1.result(), 20) Sketch_1.setLength(SketchLine_2.result(), 40) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r")], model.selection(), 10, 0) # Extrude all lateral faces to check their area Extrusion_2 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2")) SketchLine_5 = Sketch_2.addLine(0.7346748749771982, 2.736245541082907e-015, 0.7346748749771982, 10.00000000000001) -SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]"), False) SketchPoint_1 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchPoint_1.result()) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchPoint_2.result()) SketchLine_6 = Sketch_2.addLine(0.7346748749771982, 10.00000000000001, -19.2653251250228, 10.00000000000001) SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) SketchPoint_3 = SketchProjection_3.createdFeature() SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchPoint_3.result()) SketchLine_7 = Sketch_2.addLine(-19.2653251250228, 10.00000000000001, -19.2653251250228, 2.775557561562891e-015) SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) -SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]"), False) SketchPoint_4 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchPoint_4.result()) SketchLine_8 = Sketch_2.addLine(-19.2653251250228, 2.775557561562891e-015, 0.7346748749771974, 3.386180225106727e-015) @@ -83,22 +83,22 @@ SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_5.startPoint( Extrusion_2.setNestedSketch(Sketch_2) Extrusion_3 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_2")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")) SketchLine_9 = Sketch_3.addLine(36.86324678550901, 2.286454635368208e-015, 36.86324678550901, 10) -SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]"), False) SketchPoint_5 = SketchProjection_5.createdFeature() SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_9.startPoint(), SketchPoint_5.result()) -SketchProjection_6 = Sketch_3.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchProjection_6 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) SketchPoint_6 = SketchProjection_6.createdFeature() SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchPoint_6.result()) SketchLine_10 = Sketch_3.addLine(36.86324678550901, 10, -3.136753214490995, 10) SketchConstraintCoincidence_15 = Sketch_3.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) -SketchProjection_7 = Sketch_3.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), False) +SketchProjection_7 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]"), False) SketchPoint_7 = SketchProjection_7.createdFeature() SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchPoint_7.result()) SketchLine_11 = Sketch_3.addLine(-3.136753214490995, 10, -3.136753214490995, 2.275957200481571e-015) SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint()) -SketchProjection_8 = Sketch_3.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1"), False) +SketchProjection_8 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]"), False) SketchPoint_8 = SketchProjection_8.createdFeature() SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_11.endPoint(), SketchPoint_8.result()) SketchLine_12 = Sketch_3.addLine(-3.136753214490995, 2.275957200481571e-015, 36.86324678550902, 1.387778780781446e-015) @@ -107,22 +107,22 @@ SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_9.startPoint( Extrusion_3.setNestedSketch(Sketch_3) Extrusion_4 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4")) SketchLine_13 = Sketch_4.addLine(22.60959895285982, 4.420942808558057e-016, 22.60959895285982, 10) -SketchProjection_9 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1"), False) +SketchProjection_9 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/From_Face]"), False) SketchPoint_9 = SketchProjection_9.createdFeature() SketchConstraintCoincidence_21 = Sketch_4.setCoincident(SketchLine_13.startPoint(), SketchPoint_9.result()) -SketchProjection_10 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), False) +SketchProjection_10 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]"), False) SketchPoint_10 = SketchProjection_10.createdFeature() SketchConstraintCoincidence_22 = Sketch_4.setCoincident(SketchLine_13.endPoint(), SketchPoint_10.result()) SketchLine_14 = Sketch_4.addLine(22.60959895285982, 10, -7.390401047140179, 10) SketchConstraintCoincidence_23 = Sketch_4.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) -SketchProjection_11 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), False) +SketchProjection_11 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), False) SketchPoint_11 = SketchProjection_11.createdFeature() SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchLine_14.endPoint(), SketchPoint_11.result()) SketchLine_15 = Sketch_4.addLine(-7.390401047140179, 10, -7.390401047140179, 8.881784197001252e-016) SketchConstraintCoincidence_25 = Sketch_4.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) -SketchProjection_12 = Sketch_4.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1"), False) +SketchProjection_12 = Sketch_4.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]"), False) SketchPoint_12 = SketchProjection_12.createdFeature() SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchLine_15.endPoint(), SketchPoint_12.result()) SketchLine_16 = Sketch_4.addLine(-7.390401047140179, 8.881784197001252e-016, 22.60959895285983, 0) @@ -131,22 +131,22 @@ SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchLine_13.startPoint Extrusion_4.setNestedSketch(Sketch_4) Extrusion_5 = model.addExtrusion(Part_1_doc, [], model.selection(), 10, 0) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4")) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5")) SketchLine_17 = Sketch_5.addLine(-10.64977324988603, -1.185841873934692e-016, -10.64977324988603, -10) -SketchProjection_13 = Sketch_5.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1"), False) +SketchProjection_13 = Sketch_5.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/From_Face]"), False) SketchPoint_13 = SketchProjection_13.createdFeature() SketchConstraintCoincidence_29 = Sketch_5.setCoincident(SketchLine_17.startPoint(), SketchPoint_13.result()) -SketchProjection_14 = Sketch_5.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), False) +SketchProjection_14 = Sketch_5.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), False) SketchPoint_14 = SketchProjection_14.createdFeature() SketchConstraintCoincidence_30 = Sketch_5.setCoincident(SketchLine_17.endPoint(), SketchPoint_14.result()) SketchLine_18 = Sketch_5.addLine(-10.64977324988603, -10, 39.35022675011398, -10) SketchConstraintCoincidence_31 = Sketch_5.setCoincident(SketchLine_17.endPoint(), SketchLine_18.startPoint()) -SketchProjection_15 = Sketch_5.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), False) +SketchProjection_15 = Sketch_5.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) SketchPoint_15 = SketchProjection_15.createdFeature() SketchConstraintCoincidence_32 = Sketch_5.setCoincident(SketchLine_18.endPoint(), SketchPoint_15.result()) SketchLine_19 = Sketch_5.addLine(39.35022675011398, -10, 39.35022675011398, 4.440892098500626e-016) SketchConstraintCoincidence_33 = Sketch_5.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) -SketchProjection_16 = Sketch_5.addProjection(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +SketchProjection_16 = Sketch_5.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]"), False) SketchPoint_16 = SketchProjection_16.createdFeature() SketchConstraintCoincidence_34 = Sketch_5.setCoincident(SketchLine_19.endPoint(), SketchPoint_16.result()) SketchLine_20 = Sketch_5.addLine(39.35022675011398, 4.440892098500626e-016, -10.64977324988603, 0) diff --git a/src/SketchPlugin/Test/TestFilletAfterFolder.py b/src/SketchPlugin/Test/TestFilletAfterFolder.py index 557b74daa..27f2ff5f1 100644 --- a/src/SketchPlugin/Test/TestFilletAfterFolder.py +++ b/src/SketchPlugin/Test/TestFilletAfterFolder.py @@ -48,7 +48,7 @@ SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), "Size") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), "Size") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), "Size", 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), "Size", 0) Folder_1 = model.addFolder(Part_1_doc, Sketch_1, Extrusion_1) model.do() diff --git a/src/SketchPlugin/Test/TestIntersectionChangeEdge.py b/src/SketchPlugin/Test/TestIntersectionChangeEdge.py index b6ef8dc27..07f2831cd 100644 --- a/src/SketchPlugin/Test/TestIntersectionChangeEdge.py +++ b/src/SketchPlugin/Test/TestIntersectionChangeEdge.py @@ -51,11 +51,11 @@ SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.center(), Ske SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 60) SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchArc_2_2f-SketchLine_1f-SketchLine_2r")], model.selection(), 50, 50) -Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1")]) -Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1"), model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), False) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchArc_2_2f-SketchLine_2r-SketchArc_1_2r")], model.selection(), 50, 50) +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/To_Face]")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/From_Face]"), False) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_1-SketchArc_2-SketchProjection_1-SketchPoint_1"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchArc_1"), False) SketchPoint_2 = SketchProjection_2.createdFeature() SketchLine_3 = Sketch_2.addLine(-70, 60, 70, 60) SketchLine_4 = Sketch_2.addLine(70, 60, 70, -60) @@ -74,19 +74,19 @@ SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2) SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_4.result(), 70, True) SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_6.result(), 70, True) model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_6r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r")]) Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("FACE", "Filling_1_1"), model.selection("FACE", "Face_1_1")]) # set different edges used for intersection and check reference data: number of intersection points and their coordinates -REF_DATA = [("Sketch_1/Edge-SketchArc_1_2", 1, [[30, 0]]), - ("Sketch_1/Edge-SketchLine_2", 1, [[-36.024358588836, 0]]), - ("Sketch_1/Edge-SketchArc_2_2", 2, [[60, 0], [-60, 0]]), - ("Sketch_1/Edge-SketchLine_1", 0, []), - ("Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1", 1, [[30, 50]]), - ("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1", 1, [[-36.024358588836, 50]]), - ("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1", 2, [[60, 50], [-60, 50]]), - ("Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1", 0, []), - ("Intersection_1_1", 2, [[-0.0515933488223, -11.6181750315], [41.6438615258, -11.6181750315]])] +REF_DATA = [("Sketch_1/SketchArc_1_2", 1, [[30, 0]]), + ("Sketch_1/SketchLine_2", 1, [[-36.024358588836, 0]]), + ("Sketch_1/SketchArc_2_2", 2, [[60, 0], [-60, 0]]), + ("Sketch_1/SketchLine_1", 0, []), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]", 1, [[30, 50]]), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]", 1, [[-36.024358588836, 50]]), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/To_Face]", 2, [[60, 50], [-60, 50]]), + ("[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]", 0, []), + ("Intersection_1_1", 2, [[41.6438615258, -11.6181750315], [-0.0515933488223, -11.6181750315]])] TOLERANCE = 1.e-7 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) diff --git a/src/SketchPlugin/Test/TestIntersectionWithCircle.py b/src/SketchPlugin/Test/TestIntersectionWithCircle.py index 47237e813..22f0dfc0b 100644 --- a/src/SketchPlugin/Test/TestIntersectionWithCircle.py +++ b/src/SketchPlugin/Test/TestIntersectionWithCircle.py @@ -56,10 +56,10 @@ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 50) SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 10) SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_1.center(), SketchLine_2.result(), 19, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchArc_1_2r")], model.selection(), 10, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4"), "D", True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchArc_1_2r")], model.selection(), 10, 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2"), "D", True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), True) +SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]"), True) SketchIntersectionPoint_1.result().setName("SketchIntersectionPoint_1") [SketchPoint_2, SketchPoint_3] = SketchIntersectionPoint_1.intersectionPoints() SketchCircle_1 = Sketch_2.addCircle(38.14142842854285, 10, 1) @@ -83,7 +83,7 @@ SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchConstraintDistanceVertical_2 = Sketch_2.setVerticalDistance(SketchAPI_Point(SketchPoint_3).coordinates(), SketchArc_2.startPoint(), 5) SketchConstraintTangent_1 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_6.result()) model.do() -RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchArc_2_2f")], model.selection("EDGE", "Sketch_2/Edge-SketchLine_5"), 360, 0, [model.selection("SOLID", "Extrusion_1_1")]) +RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_6r-SketchArc_2_2f-SketchLine_5r")], model.selection("EDGE", "Sketch_2/SketchLine_5"), 360, 0, [model.selection("SOLID", "Extrusion_1_1")]) ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), 5, 5, [model.selection("SOLID", "RevolutionCut_1_1")]) model.do() diff --git a/src/SketchPlugin/Test/TestIntersectionWithLine.py b/src/SketchPlugin/Test/TestIntersectionWithLine.py index a6b163ca2..36bcc53ae 100644 --- a/src/SketchPlugin/Test/TestIntersectionWithLine.py +++ b/src/SketchPlugin/Test/TestIntersectionWithLine.py @@ -67,10 +67,10 @@ SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_2.result(), 10) SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_1.startPoint(), SketchLine_4.startPoint(), "D") SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.endPoint(), SketchLine_7.startPoint(), 40, True) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f")], model.selection(), 10, 0) ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), 5, 5, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_5")) -SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4")) +SketchIntersectionPoint_1 = Sketch_2.addIntersectionPoint(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/To_Face]"), False) [SketchPoint_2] = SketchIntersectionPoint_1.intersectionPoints() SketchCircle_1 = Sketch_2.addCircle(40, 10, 5) SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchCircle_1.center()) diff --git a/src/SketchPlugin/Test/TestIntersectionWithSpline.py b/src/SketchPlugin/Test/TestIntersectionWithSpline.py index a3f396566..44e1eda7b 100644 --- a/src/SketchPlugin/Test/TestIntersectionWithSpline.py +++ b/src/SketchPlugin/Test/TestIntersectionWithSpline.py @@ -50,9 +50,9 @@ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 65) SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchArc_1.center(), SketchAPI_Line(SketchLine_3).startPoint(), 20) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 55) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_1f-SketchLine_2f")], model.selection(), 25, 25) -Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1")]) -Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_1f-SketchLine_2f")]) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_1f-SketchLine_2f")], model.selection(), 25, 25) +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/From_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2r-SketchLine_1f-SketchLine_2f")]) Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("FACE", "Filling_1_1"), model.selection("FACE", "Face_1_1")]) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchLine_4 = Sketch_2.addLine(-34.11217447219568, 40, 20, -37.28019411294778) @@ -70,9 +70,9 @@ SketchConstraintDistance_2 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_1) SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_4.result(), "D", True) SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_5.result(), SketchLine_4.result(), 35) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), 10, 10) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_4r-SketchLine_5f-SketchLine_6f")], model.selection(), 10, 10) ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [], model.selection(), 10, 0, [model.selection("SOLID", "Extrusion_2_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face_3")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_4")) SketchIntersectionPoint_1 = Sketch_3.addIntersectionPoint(model.selection("EDGE", "Intersection_1_1"), False) [SketchPoint_2, SketchPoint_3] = SketchIntersectionPoint_1.intersectionPoints() SketchCircle_1 = Sketch_3.addCircle(-33.22640570408476, 0, 5) @@ -115,12 +115,12 @@ model.do(); assert(SketchIntersectionPoint_1.feature().results().size() == 1) model.testNbResults(ExtrusionFuse_1, 1) -model.testNbSubResults(ExtrusionFuse_1, [1]) +model.testNbSubResults(ExtrusionFuse_1, [0]) model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.SOLID, [1]) -model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.FACE, [11]) -model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.EDGE, [42]) -model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.VERTEX, [84]) -model.testResultsVolumes(ExtrusionFuse_1, [89224.362837261898675933480262756]) +model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.FACE, [9]) +model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.EDGE, [30]) +model.testNbSubShapes(ExtrusionFuse_1, GeomAPI_Shape.VERTEX, [60]) +model.testResultsVolumes(ExtrusionFuse_1, [89638.890852351003559306263923645]) # change parameter and check intersection is NOT valid now ParamD.setValue(50) diff --git a/src/SketchPlugin/Test/TestMovementComplex.py b/src/SketchPlugin/Test/TestMovementComplex.py index 228f50427..d0db233b2 100644 --- a/src/SketchPlugin/Test/TestMovementComplex.py +++ b/src/SketchPlugin/Test/TestMovementComplex.py @@ -202,7 +202,7 @@ for i in range(1, 10): assert(model.dof(Sketch_1) == 0) # Extrude main part of clamp -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchArc_1_2f-SketchCircle_1_2r")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5r-SketchArc_1_2f-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r-SketchCircle_1_2r")], model.selection(), 10, 0) model.do() @@ -210,7 +210,7 @@ model.do() Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchRectangle_1 = Sketch_2.addRectangle(20, 0, 100, 50) [SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9] = SketchRectangle_1.lines() -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_10 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_7).startPoint(), SketchAPI_Line(SketchLine_10).startPoint()) SketchConstraintEqual_1 = Sketch_2.setEqual(SketchLine_8.result(), SketchLine_10.result()) @@ -337,12 +337,12 @@ SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], 6.5) SketchConstraintDistance_3 = Sketch_2.setDistance(SketchCircle_2.center(), SketchLine_8.result(), 30) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchCircle_2_2r-SketchArc_2_2r-SketchLine_13r-SketchLine_14f-SketchLine_15f-SketchArc_3_2r-SketchLine_16r")], model.selection(), -165, 155) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_14f-SketchLine_16r-SketchArc_3_2r-SketchLine_15f-SketchLine_13r-SketchArc_2_2r-SketchCircle_2_2r")], model.selection(), -165, 155) Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Fuse_1_1/Modified_Face_2")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)")) SketchLine_17 = Sketch_3.addLine(145, 0, 165, 0) -SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "Fuse_1_1/Modified_Face_divided_6_1&Fuse_1_1/Modified_Face_3&Fuse_1_1/Modified_Face_divided_5_1")) +SketchProjection_2 = Sketch_3.addProjection(model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Extrusion_1_1/From_Face&Sketch_2/SketchLine_6][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_1&Extrusion_2_1/To_Face][Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7]")) SketchPoint_2 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_17.endPoint(), SketchAPI_Point(SketchPoint_2).result()) SketchLine_18 = Sketch_3.addLine(165, 0, 165, -20) @@ -365,12 +365,12 @@ SketchArc_5 = Sketch_3.addArc(145, -20, 155, -20, 145, -10, False) SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_19.endPoint(), SketchArc_5.center()) SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_20.result(), SketchArc_5.endPoint()) SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchArc_5.startPoint(), SketchLine_19.result()) -SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "Fuse_1_1/Modified_Face_4&Fuse_1_1/Modified_Face_divided_2_1")) +SketchLine_21 = Sketch_3.addLine(model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face][(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)(Fuse_1_1/Modified_Face&Sketch_1/SketchLine_5&Sketch_2/SketchLine_7)]")) SketchConstraintTangent_5 = Sketch_3.setTangent(SketchArc_5.results()[1], SketchLine_21.result()) model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_17r-SketchLine_18r-SketchArc_4_2r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face_divided_1_1"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")]) -ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_19r-SketchLine_20r-SketchArc_4_2f-SketchArc_5_2r")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_8"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2r-SketchLine_18r-SketchLine_17r")], model.selection(), model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")]) +ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_4_2f-SketchLine_20r-SketchArc_5_2r-SketchLine_19r")], model.selection(), model.selection("FACE", "(Fuse_1_1/Modified_Face&Extrusion_2_1/From_Face)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_2&Sketch_2/SketchLine_9)(ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchArc_4_2)(ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face)(Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_8)"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) model.do() model.end() diff --git a/src/SketchPlugin/Test/TestMultiRotationWithParameter.py b/src/SketchPlugin/Test/TestMultiRotationWithParameter.py index d69ce986b..9acedebaa 100644 --- a/src/SketchPlugin/Test/TestMultiRotationWithParameter.py +++ b/src/SketchPlugin/Test/TestMultiRotationWithParameter.py @@ -47,7 +47,7 @@ SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/O SketchPoint_1 = SketchProjection_1.createdFeature() model.do() SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_2.result()], SketchAPI_Point(SketchPoint_1).coordinates(), "360/N", "N") -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 10, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 10, 0) model.do() # change parameters diff --git a/src/SketchPlugin/Test/TestPresentation.py b/src/SketchPlugin/Test/TestPresentation.py new file mode 100644 index 000000000..f4ebf9eb5 --- /dev/null +++ b/src/SketchPlugin/Test/TestPresentation.py @@ -0,0 +1,130 @@ +## Copyright (C) 2018-20xx 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 +## + +""" + TestPresentation.py + Test AIS presentations for constraints and macro-features +""" + +from salome.shaper import model +from GeomAPI import * +from ModelAPI import * +from GeomDataAPI import * + +from ConfigAPI import * +Config_PropManager().registerProp("Visualization", "dimension_value_size", "Dimension value size", Config_Prop.IntSpin, "16") + +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(-1.492165138365909, 9.860293583877349, 21.86930170264727, 26.80555863006795) +SketchLine_2 = Sketch_1.addLine(21.86930170264727, 26.80555863006795, 23.42558840321396, 11.88651135131589) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_1.result(), SketchLine_2.result(), 60) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_2.endPoint(), 25, True) +SketchLine_3 = Sketch_1.addLine(23.50783486163409, 27.99407041552052, 34.45590553653152, 35.9352652297464) +SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_1.result(), SketchLine_3.result()) +SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchLine_1.startPoint(), SketchLine_3.startPoint(), 25) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 15) +SketchLine_4 = Sketch_1.addLine(53.74716193144771, -7.706985565972583, 35.95905823005196, -7.706985565972583) +SketchLine_5 = Sketch_1.addLine(35.95905823005196, -7.706985565972583, 35.95905823005196, 16.71916358123427) +SketchLine_6 = Sketch_1.addLine(35.95905823005196, 16.71916358123427, 53.74716193144771, 16.71916358123427) +SketchLine_7 = Sketch_1.addLine(53.74716193144771, 16.71916358123427, 53.74716193144771, -7.706985565972583) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_4.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_5.result()) +SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_5.result(), SketchLine_7.result()) +SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_6.result(), SketchLine_7.result()) +SketchCircle_1 = Sketch_1.addCircle(20.43340729011699, -17.26699099051272, 10) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 10) +SketchConstraintRigid_1 = Sketch_1.setFixed(SketchCircle_1.center()) +SketchArc_1 = Sketch_1.addArc(44.85311008074984, -7.706985565972585, 49.46781809225963, -16.57853954306742, 34.85430557643821, -7.861609252895618, False) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchArc_1.results()[1]) +SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchArc_1.center(), SketchLine_4.result()) +SketchLine_8 = Sketch_1.addLine(49.46781809225963, -16.57853954306742, 32.21747944141746, -25.55163221418553) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_8.startPoint()) +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_8.result()) +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), [SketchLine_2.result()]) +SketchMultiTranslation_1 = Sketch_1.addTranslation([SketchLine_2.result()], SketchLine_3.startPoint(), SketchLine_3.endPoint(), 3, True) +SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_3.result()], SketchLine_3.endPoint(), 360, 4, True) +model.do() + +assert(featureToPresentation(SketchConstraintAngle_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintCoincidence_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintCollinear_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintDistance_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintDistanceHorizontal_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintEqual_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintHorizontal_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintLength_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintMiddle_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintParallel_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintPerpendicular_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintRadius_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintRigid_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintTangent_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintVertical_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchConstraintMirror_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchMultiTranslation_1.feature()).getAISObject(None) is not None) +assert(featureToPresentation(SketchMultiRotation_1.feature()).getAISObject(None) is not None) + +# Test presentation for Fillet on low-level +aSession = ModelAPI_Session.get() +aSketchFeature = featureToCompositeFeature(Sketch_1.feature()) +aSession.startOperation() +aFillet = aSketchFeature.addFeature("SketchFillet") +aFillet.refattr("fillet_point").setAttr(SketchLine_1.endPoint()); +assert(featureToPresentation(aFillet).getAISObject(None) is not None) +aSession.finishOperation() + +# Test presentation for MacroCircle on low-level +aSession.startOperation() +aCircle = aSketchFeature.addFeature("SketchMacroCircle") +aCirclePnt1 = geomDataAPI_Point2D(aCircle.attribute("first_point")) +aCirclePnt2 = geomDataAPI_Point2D(aCircle.attribute("second_point")) +aCirclePnt3 = geomDataAPI_Point2D(aCircle.attribute("third_point")) +aCircleType = aCircle.string("circle_type") +aCircleType.setValue("circle_type_by_three_points") +aCirclePnt1.setValue(10, 0) +aCirclePnt2.setValue(-10, 0) +aCirclePnt3.setValue(0, 10) +assert(featureToPresentation(aCircle).getAISObject(None) is not None) +aSession.finishOperation() + +# Test presentation for MacroArc on low-level +aSession.startOperation() +anArc = aSketchFeature.addFeature("SketchMacroArc") +anArcPnt1 = geomDataAPI_Point2D(anArc.attribute("start_point_2")) +anArcPnt2 = geomDataAPI_Point2D(anArc.attribute("end_point_2")) +anArcPnt3 = geomDataAPI_Point2D(anArc.attribute("passed_point")) +anArcType = anArc.string("arc_type") +anArcType.setValue("by_three_points") +anArcPnt1.setValue(5, 0) +anArcPnt2.setValue(-5, 0) +anArcPnt3.setValue(0, 5) +assert(featureToPresentation(anArc).getAISObject(None) is not None) +aSession.finishOperation() + +model.end() diff --git a/src/SketchPlugin/Test/TestProjection.py b/src/SketchPlugin/Test/TestProjection.py index 7e24e3ed5..d8dc75f50 100644 --- a/src/SketchPlugin/Test/TestProjection.py +++ b/src/SketchPlugin/Test/TestProjection.py @@ -94,17 +94,17 @@ aSession.finishOperation() #========================================================================= aSession.startOperation() aLineProjector = aSketchFeature.addFeature("SketchProjection") -aLineProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchLine_1") +aLineProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchLine_1") aLineProjector.boolean("IncludeToResult").setValue(False) aLineProjector.execute() aCircleProjector = aSketchFeature.addFeature("SketchProjection") -aCircleProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2") +aCircleProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchCircle_1_2") aCircleProjector.boolean("IncludeToResult").setValue(False) aCircleProjector.execute() anArcProjector = aSketchFeature.addFeature("SketchProjection") -anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchArc_1_2") +anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/SketchArc_1_2") anArcProjector.boolean("IncludeToResult").setValue(False) anArcProjector.execute() aSession.finishOperation() diff --git a/src/SketchPlugin/Test/TestProjectionIntoResult.py b/src/SketchPlugin/Test/TestProjectionIntoResult.py index adfd8ebcc..d5f43d158 100644 --- a/src/SketchPlugin/Test/TestProjectionIntoResult.py +++ b/src/SketchPlugin/Test/TestProjectionIntoResult.py @@ -1,3 +1,28 @@ +## 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 +## + +""" + TestProjectionIntoResult.py + Unit test of SketchPlugin_Projection class +""" + from salome.shaper import model from GeomAPI import * @@ -66,75 +91,75 @@ SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_2.startPoint(), SketchLine_7.endPoint()) SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_7.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_2r-SketchLine_5r-SketchLine_6r-SketchLine_7r")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_2r")], model.selection(), 100, 0) model.do() #============================================================================== # Tests #============================================================================== -aProjectedList = [("EDGE", "Sketch_1/Edge-SketchCircle_1_2"), - ("EDGE", "Sketch_1/Edge-SketchArc_1_2"), - ("EDGE", "Sketch_1/Edge-SketchLine_1"), - ("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), +aProjectedList = [("EDGE", "Sketch_1/SketchCircle_1_2"), + ("EDGE", "Sketch_1/SketchArc_1_2"), + ("EDGE", "Sketch_1/SketchLine_1"), + ("VERTEX", "Sketch_1/SketchPoint_1"), # - ("VERTEX", "Sketch_1/Vertex-SketchCircle_1"), - ("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), - ("VERTEX", "Sketch_1/Vertex-SketchLine_1s"), - ("VERTEX", "Sketch_1/Vertex-SketchArc_1_2s"), - ("VERTEX", "Sketch_1/Vertex-SketchArc_1_2e"), - ("VERTEX", "Sketch_1/Vertex-SketchArc_1"), + ("VERTEX", "Sketch_1/SketchCircle_1_2__cc"), + ("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), + ("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), + ("VERTEX", "Sketch_1/SketchArc_1_2_StartVertex"), + ("VERTEX", "Sketch_1/SketchArc_1_2_EndVertex"), + ("VERTEX", "Sketch_1/SketchArc_1"), # - ("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), - ("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/From_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/From_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/From_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/From_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/To_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/To_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/To_Face]"), + ("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/To_Face]"), # - ("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/From_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/From_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/From_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/From_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/From_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/From_Face]"), # - ("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_3"), - ("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/Generated_Face_2"), - ("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6]"), # - ("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1"), - ("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1") + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5][Extrusion_1_1/To_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2][Extrusion_1_1/To_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_1_1/To_Face]"), + ("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_1_1/To_Face]") ] # Test projection to the same plane -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_2")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_5")) aFailedIDs = set([21, 29]) testProjections(Part_1_doc, Sketch_3, aProjectedList, aFailedIDs) # Test projection to parallel plane -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_7")) testProjections(Part_1_doc, Sketch_4, aProjectedList, aFailedIDs) # Test projection to lower base of the prism -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1")) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face")) aFailedIDs = set([0, 1, 22, 23, 24, 25]) testProjections(Part_1_doc, Sketch_5, aProjectedList, aFailedIDs) # Test projection to upper base of the prism -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) testProjections(Part_1_doc, Sketch_6, aProjectedList, aFailedIDs) # Test projection to orthogonal side face of the prism -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_6")) aFailedIDs = set([0, 1, 18, 20, 26, 28]) testProjections(Part_1_doc, Sketch_7, aProjectedList, aFailedIDs) # Test projection to slope side face of the prism -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1")) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_2")) aFailedIDs = set([0, 1]) testProjections(Part_1_doc, Sketch_8, aProjectedList, aFailedIDs) diff --git a/src/SketchPlugin/Test/TestSketchDrawer.py b/src/SketchPlugin/Test/TestSketchDrawer.py new file mode 100644 index 000000000..b90c9489c --- /dev/null +++ b/src/SketchPlugin/Test/TestSketchDrawer.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +from SketchAPI import * + +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(-14.48008258397498, -13.79591274114419, 5.519917416025022, -13.79591274114419) +SketchLine_2 = Sketch_1.addLine(10.51991741602502, -8.795912741144186, 10.51991741602502, 18.20408725885581) +SketchLine_3 = Sketch_1.addLine(10.51991741602502, 18.20408725885581, -14.48008258397498, 13.79591274114419) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2") +SketchLine_4 = Sketch_1.addLine(-14.48008258397498, 13.79591274114419, -14.48008258397498, -13.79591274114419) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3") +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) +SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4") +SketchArc_1 = Sketch_1.addArc(5.519917416025022, -8.795912741144186, 5.519917416025022, -13.79591274114419, 10.51991741602502, -8.795912741144186, False) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5") +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6") +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result()) +SketchCircle_1 = Sketch_1.addCircle(0, 0, 5) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()) +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_4.result(), SketchLine_3.result(), 100) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 27) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_2.result(), 25, True) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 5) +SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result()) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_4.startPoint(), SketchCircle_1.center(), 20, True) +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_4.endPoint(), SketchCircle_1.center(), 20, True) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7") +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchCircle_1_2r")], model.selection(), 10, 0) +model.do() +# create a drawer feature of the extrusion and upper face +Drawer = Part_1_doc.addFeature("SketchDrawer") +Drawer.selection("base_shape").setValue(Extrusion_1.feature(), None) +PlaneSelection = model.selection("FACE", "Extrusion_1_1/To_Face") +PlaneSelection.fillAttribute(Drawer.selection("plane")) +model.end() + +# check that a sketch is created with valid elements +assert(Part_1_doc.size("Construction") == 2) # two sketches: base of extrusion and this new one + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() + +Sketch = objectToFeature(Part_1_doc.object("Features", 2)) # created sketch feature +assert(aFactory.validate(Sketch)) +assert(len(Sketch.results()) == 1) diff --git a/src/SketchPlugin/Test/TestSplitLine.py b/src/SketchPlugin/Test/TestSplitLine.py new file mode 100644 index 000000000..bdabae161 --- /dev/null +++ b/src/SketchPlugin/Test/TestSplitLine.py @@ -0,0 +1,59 @@ +## Copyright (C) 2018-20xx 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 SketchAPI import * + +from salome.shaper import model +from salome.shaper import geom + +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(-38.2842712474619, 18.28427124746191, -10, -10) +SketchLine_2 = Sketch_1.addLine(-10, -10, -10, 20) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(-10, 20, -25, 5) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40) +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()]) +[SketchLine_4, SketchLine_5] = SketchConstraintMirror_1.mirrored() +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchLine", 5) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 3) +model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1) +model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 1) + +#perform split +SketchSplit = Sketch_1.addSplit(SketchLine_1, geom.Pnt2d(-12, -8)) +SketchSplit.execute() +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchLine", 6) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 5) +model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1) +model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 0) + +model.end() + +assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/TestSplitPreview.py b/src/SketchPlugin/Test/TestSplitPreview.py new file mode 100644 index 000000000..6cfdf582c --- /dev/null +++ b/src/SketchPlugin/Test/TestSplitPreview.py @@ -0,0 +1,93 @@ +## Copyright (C) 2018-20xx 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 + +from ModelAPI import * +from GeomDataAPI import * + +from ConfigAPI import * +Config_PropManager().registerProp("Visualization", "operation_remove_feature_color", "Color of removed feature in operation", Config_Prop.Color, "255, 174, 201") + +# base sketch +model.begin() +partSet = model.moduleDocument() +Part = model.addPart(partSet) +Part_doc = Part.document() +Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch.addLine(0, 20, 100, 20) +SketchLine_2 = Sketch.addLine(20, 0, 20, 40) +SketchLine_3 = Sketch.addLine(80, 0, 80, 40) +SketchCircle_1 = Sketch.addCircle(50, 50, 50) +SketchPoint_1 = Sketch.addPoint(20, 20) +SketchConstraintCoincidence_1 = Sketch.setCoincident(SketchPoint_1.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_2 = Sketch.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()) +SketchPoint_2 = Sketch.addPoint(80, 20) +SketchConstraintCoincidence_3 = Sketch.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result()) +SketchConstraintCoincidence_4 = Sketch.setCoincident(SketchPoint_2.coordinates(), SketchLine_3.result()) +SketchPoint_3 = Sketch.addPoint(20, 10) +SketchConstraintCoincidence_5 = Sketch.setCoincident(SketchPoint_3.coordinates(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_6 = Sketch.setCoincident(SketchPoint_3.coordinates(), SketchLine_2.result()) +SketchPoint_4 = Sketch.addPoint(80, 10) +SketchConstraintCoincidence_7 = Sketch.setCoincident(SketchPoint_4.coordinates(), SketchCircle_1.results()[1]) +SketchConstraintCoincidence_8 = Sketch.setCoincident(SketchPoint_4.coordinates(), SketchLine_3.result()) +model.do() +model.end() + +aSession = ModelAPI_Session.get() +aSketchFeature = featureToCompositeFeature(Sketch.feature()) + +# Create Split feature for a line +aSession.startOperation() +aSplit = aSketchFeature.addFeature("SketchSplit") +aSelectedObj = aSplit.reference("SelectedObject") +aSelectedObj.setValue(SketchLine_1.feature()) +aSelectedPoint = geomDataAPI_Point2D(aSplit.attribute("SelectedPoint")) +aSelectedPoint.setValue(50, 20) +aPreviewObj = aSplit.reference("PreviewObject") +aPreviewObj.setValue(SketchLine_1.feature()) +aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint")) +aPreviewPoint.setValue(aSelectedPoint.pnt()) +assert(featureToPresentation(aSplit).getAISObject(None) is not None) +aSession.finishOperation() + +model.testNbSubFeatures(Sketch, "SketchArc", 0) +model.testNbSubFeatures(Sketch, "SketchCircle", 1) +model.testNbSubFeatures(Sketch, "SketchLine", 5) +model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 12) + +# Create Split feature for a circle to perform its substitution by an arc +aSession.startOperation() +aSplit = aSketchFeature.addFeature("SketchSplit") +aSelectedObj = aSplit.reference("SelectedObject") +aSelectedObj.setValue(SketchCircle_1.feature()) +aSelectedPoint = geomDataAPI_Point2D(aSplit.attribute("SelectedPoint")) +aSelectedPoint.setValue(50, 0) +aPreviewObj = aSplit.reference("PreviewObject") +aPreviewObj.setValue(SketchCircle_1.feature()) +aPreviewPoint = geomDataAPI_Point2D(aSplit.attribute("PreviewPoint")) +aPreviewPoint.setValue(aSelectedPoint.pnt()) +assert(featureToPresentation(aSplit).getAISObject(None) is not None) +aSession.finishOperation() + +model.testNbSubFeatures(Sketch, "SketchArc", 2) +model.testNbSubFeatures(Sketch, "SketchCircle", 0) +model.testNbSubFeatures(Sketch, "SketchLine", 5) +model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 16) diff --git a/src/SketchPlugin/Test/TestTrimArc08.py b/src/SketchPlugin/Test/TestTrimArc08.py new file mode 100644 index 000000000..fbf25849f --- /dev/null +++ b/src/SketchPlugin/Test/TestTrimArc08.py @@ -0,0 +1,68 @@ +## Copyright (C) 2018-20xx 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 +from salome.shaper import geom + +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(12, -8, -12, -8) +SketchLine_2 = Sketch_1.addLine(-12, -8, -12, 20) +SketchLine_3 = Sketch_1.addLine(-12, 20, 12, 20) +SketchLine_4 = Sketch_1.addLine(12, 20, 12, -8) +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()) +SketchArc_1 = Sketch_1.addArc(0, -3, 20, -3, -20, -3, False) +SketchLine_5 = Sketch_1.addLine(20, -3, 20, -30) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(20, 17, 50, 17) +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_5.result(), SketchArc_1.results()[1]) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchLine_6.result(), SketchArc_1.results()[1]) +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchArc", 1) +model.testNbSubFeatures(Sketch_1, "SketchLine", 6) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 5) +model.testNbSubFeatures(Sketch_1, "SketchConstraintTangent", 2) +model.testNbSubFeatures(Sketch_1, "SketchConstraintEqual", 0) + +# perform trim +SketchTrim = Sketch_1.addTrim(SketchArc_1, geom.Pnt2d(0, 17)) +SketchTrim.execute() +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchArc", 2) +model.testNbSubFeatures(Sketch_1, "SketchLine", 6) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 8) +model.testNbSubFeatures(Sketch_1, "SketchConstraintTangent", 2) +model.testNbSubFeatures(Sketch_1, "SketchConstraintEqual", 1) + +model.end() + +assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/TestTrimLine03.py b/src/SketchPlugin/Test/TestTrimLine03.py new file mode 100644 index 000000000..acc9201ae --- /dev/null +++ b/src/SketchPlugin/Test/TestTrimLine03.py @@ -0,0 +1,59 @@ +## Copyright (C) 2018-20xx 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 SketchAPI import * + +from salome.shaper import model +from salome.shaper import geom + +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(-38.2842712474619, 18.28427124746191, -10, -10) +SketchLine_2 = Sketch_1.addLine(-10, -10, -10, 20) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(-10, 20, -25, 5) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_1.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 40) +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), [SketchLine_1.result(), SketchLine_3.result()]) +[SketchLine_4, SketchLine_5] = SketchConstraintMirror_1.mirrored() +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchLine", 5) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 3) +model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1) +model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 1) + +#perform trim +SketchTrim = Sketch_1.addTrim(SketchLine_1, geom.Pnt2d(-12, -8)) +SketchTrim.execute() +model.do() + +model.testNbSubFeatures(Sketch_1, "SketchLine", 5) +model.testNbSubFeatures(Sketch_1, "SketchConstraintCoincidence", 2) +model.testNbSubFeatures(Sketch_1, "SketchConstraintLength", 1) +model.testNbSubFeatures(Sketch_1, "SketchConstraintMirror", 0) + +model.end() + +assert(model.checkPythonDump()) diff --git a/src/SketchPlugin/Test/TestTrimPreview.py b/src/SketchPlugin/Test/TestTrimPreview.py new file mode 100644 index 000000000..2361d369b --- /dev/null +++ b/src/SketchPlugin/Test/TestTrimPreview.py @@ -0,0 +1,81 @@ +## Copyright (C) 2018-20xx 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 + +from ModelAPI import * +from GeomDataAPI import * + +from ConfigAPI import * +Config_PropManager().registerProp("Visualization", "operation_remove_feature_color", "Color of removed feature in operation", Config_Prop.Color, "255, 174, 201") + +# base sketch +model.begin() +partSet = model.moduleDocument() +Part = model.addPart(partSet) +Part_doc = Part.document() +Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch.addLine(0, 20, 100, 20) +SketchLine_2 = Sketch.addLine(20, 0, 20, 40) +SketchLine_3 = Sketch.addLine(80, 0, 80, 40) +SketchCircle_1 = Sketch.addCircle(50, 50, 50) +model.do() +model.end() + +aSession = ModelAPI_Session.get() +aSketchFeature = featureToCompositeFeature(Sketch.feature()) + +# Create Trim feature for a line +aSession.startOperation() +aTrim = aSketchFeature.addFeature("SketchTrim") +aSelectedObj = aTrim.reference("SelectedObject") +aSelectedObj.setValue(SketchLine_1.feature()) +aSelectedPoint = geomDataAPI_Point2D(aTrim.attribute("SelectedPoint")) +aSelectedPoint.setValue(50, 20) +aPreviewObj = aTrim.reference("PreviewObject") +aPreviewObj.setValue(SketchLine_1.feature()) +aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint")) +aPreviewPoint.setValue(aSelectedPoint.pnt()) +assert(featureToPresentation(aTrim).getAISObject(None) is not None) +aSession.finishOperation() + +model.testNbSubFeatures(Sketch, "SketchArc", 0) +model.testNbSubFeatures(Sketch, "SketchCircle", 1) +model.testNbSubFeatures(Sketch, "SketchLine", 4) +model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 2) + +# Create Trim feature for a circle to perform its substitution by an arc +aSession.startOperation() +aTrim = aSketchFeature.addFeature("SketchTrim") +aSelectedObj = aTrim.reference("SelectedObject") +aSelectedObj.setValue(SketchCircle_1.feature()) +aSelectedPoint = geomDataAPI_Point2D(aTrim.attribute("SelectedPoint")) +aSelectedPoint.setValue(50, 0) +aPreviewObj = aTrim.reference("PreviewObject") +aPreviewObj.setValue(SketchCircle_1.feature()) +aPreviewPoint = geomDataAPI_Point2D(aTrim.attribute("PreviewPoint")) +aPreviewPoint.setValue(aSelectedPoint.pnt()) +assert(featureToPresentation(aTrim).getAISObject(None) is not None) +aSession.finishOperation() + +model.testNbSubFeatures(Sketch, "SketchArc", 1) +model.testNbSubFeatures(Sketch, "SketchCircle", 0) +model.testNbSubFeatures(Sketch, "SketchLine", 4) +model.testNbSubFeatures(Sketch, "SketchConstraintCoincidence", 4) diff --git a/src/SketchPlugin/doc/SketchPlugin.rst b/src/SketchPlugin/doc/SketchPlugin.rst index fd95d68e9..627ca479a 100644 --- a/src/SketchPlugin/doc/SketchPlugin.rst +++ b/src/SketchPlugin/doc/SketchPlugin.rst @@ -154,3 +154,4 @@ The plug-in includes the following operations: mirrorFeature.rst translationFeature.rst rotationFeature.rst + sketchDrawer.rst diff --git a/src/SketchPlugin/doc/images/SketchDrawer.png b/src/SketchPlugin/doc/images/SketchDrawer.png new file mode 100644 index 000000000..e3f53d131 Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer.png differ diff --git a/src/SketchPlugin/doc/images/SketchDrawer_panel.png b/src/SketchPlugin/doc/images/SketchDrawer_panel.png new file mode 100644 index 000000000..8b786503d Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer_panel.png differ diff --git a/src/SketchPlugin/doc/images/SketchDrawer_res.png b/src/SketchPlugin/doc/images/SketchDrawer_res.png new file mode 100644 index 000000000..b746e4e98 Binary files /dev/null and b/src/SketchPlugin/doc/images/SketchDrawer_res.png differ diff --git a/src/SketchPlugin/doc/sketchDrawer.rst b/src/SketchPlugin/doc/sketchDrawer.rst new file mode 100644 index 000000000..20bb2eb4d --- /dev/null +++ b/src/SketchPlugin/doc/sketchDrawer.rst @@ -0,0 +1,53 @@ + .. _create_sketch_drawer: + +Sketch Drawer +========= + +Sketch Drawer featrure is a macro-feature, i.e. it is removed after its execution. +It allows simplify creation of sketches basing on existing models without referencing to +these models. + +For an example, to create a sketch on exising STEP file model planar face +and then remove the original model, to keep only the sketch with copy of contour. So, to be +able to remove the initial model, there are no references created by this feature. + +To add a new Sketch Drawing: + +#. select in the Main Menu *Macros - > Sketch drawer* item or +#. click **Sketch drawer** button in Macros toolbar: + +.. image:: images/SketchDrawer.png + :align: center + +.. centered:: + **Sketch drawer** button + +The following property panel appears: + +.. image:: images/SketchDrawer_panel.png + :align: center + +.. centered:: + Sketch drawer + +Click in the view once to set the whole original model, then click a second time to set the +plane or planar face - a base of sketch. This can be plane on the original model. +On Apply button press the new sketch will be created in the Object Browser tree. + +Result +"""""" + +A resulting sketch will contain linear and circular edges as well as circular arcs corresponding to the +original model edges that lay in the sketch plane. Other types of edges are not supported. + +Radius, length, vertical, horizontal and points-coincidence constraints will be created +automatically where it is possible. The resulting sketch may be overconstrained or not fully +constrained. So, it is just a helper for the sketch creation, not universal tool. After this +sketch creation normally user must edit this sketch to input reasonable constraints and +parametrization, or remove not needed constraints or sketch lements. + +.. image:: images/SketchDrawer_res.png + :align: center + +.. centered:: + Drawn sketch diff --git a/src/SketchPlugin/icons/drawer.png b/src/SketchPlugin/icons/drawer.png new file mode 100644 index 000000000..e3f53d131 Binary files /dev/null and b/src/SketchPlugin/icons/drawer.png differ diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index f90172408..3fdd8c0ce 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -1057,4 +1057,19 @@ email : webmaster.salome@opencascade.com + + + + + + + + + + + + diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp index 44daa41fa..1f827a3c6 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp @@ -167,8 +167,12 @@ void SketchSolver_ConstraintDistance::removeConstraintsKeepingSign() aParams.insert(myOddPoint->y); aStorage->removeParameters(aParams); - aGCSConstraints.pop_back(); - aGCSConstraints.pop_back(); + // remove constraints keeping sign of point-line distance, + // not more than 2 additional constraints is possible + if (!aGCSConstraints.empty()) + aGCSConstraints.pop_back(); + if (!aGCSConstraints.empty()) + aGCSConstraints.pop_back(); aConstraint->setConstraints(aGCSConstraints); aStorage->addConstraint(myBaseConstraint, aConstraint); diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index d4b96d1c5..fc3e6e78a 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -333,7 +333,7 @@ void SketchSolver_Group::computeDoF() if (aDoF > 0 && myDOF <= 0) sendMessage(EVENT_SKETCH_UNDER_CONSTRAINED, mySketch, aDoF); - else if (aDoF == 0/* && myDOF > 0*/) + else if (aDoF == 0 && myDOF != 0) sendMessage(EVENT_SKETCH_FULLY_CONSTRAINED, mySketch, aDoF); else if (aDoF < 0) sendMessage(EVENT_SKETCH_OVER_CONSTRAINED, mySketch, aDoF); diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 33fea2149..55ef5f31b 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -94,41 +94,12 @@ void SketchSolver_Storage::addConstraint(ConstraintPtr theConstraint, theConstraint->data()->blockSendAttributeUpdated(myEventsBlocked); } -static std::list pointAttributes(FeaturePtr theFeature) -{ - std::list aPoints; - if (!theFeature->data() || !theFeature->data()->isValid()) - return aPoints; - if (theFeature->getKind() == SketchPlugin_Arc::ID()) { - aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::CENTER_ID())); - aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::START_ID())); - aPoints.push_back(theFeature->attribute(SketchPlugin_Arc::END_ID())); - } - else if (theFeature->getKind() == SketchPlugin_Circle::ID()) - aPoints.push_back(theFeature->attribute(SketchPlugin_Circle::CENTER_ID())); - else if (theFeature->getKind() == SketchPlugin_Line::ID()) { - aPoints.push_back(theFeature->attribute(SketchPlugin_Line::START_ID())); - aPoints.push_back(theFeature->attribute(SketchPlugin_Line::END_ID())); - } - else if (theFeature->getKind() == SketchPlugin_Point::ID() || - theFeature->getKind() == SketchPlugin_IntersectionPoint::ID()) - aPoints.push_back(theFeature->attribute(SketchPlugin_Point::COORD_ID())); - return aPoints; -} - void SketchSolver_Storage::addEntity(FeaturePtr theFeature, EntityWrapperPtr theSolverEntity) { if (theSolverEntity) { myFeatureMap[theFeature] = theSolverEntity; setNeedToResolve(true); - } else { - // feature links to the empty entity, add its attributes - std::list aPntAttrs = pointAttributes(theFeature); - std::list::const_iterator anAttrIt = aPntAttrs.begin(); - for (; anAttrIt != aPntAttrs.end(); ++anAttrIt) - addEntity(*anAttrIt, EntityWrapperPtr()); - myFeatureMap[theFeature] = theSolverEntity; } // block events if necessary diff --git a/src/SketcherPrs/SketcherPrs_Coincident.cpp b/src/SketcherPrs/SketcherPrs_Coincident.cpp index acf5d24a7..c123960a5 100644 --- a/src/SketcherPrs/SketcherPrs_Coincident.cpp +++ b/src/SketcherPrs/SketcherPrs_Coincident.cpp @@ -124,7 +124,8 @@ void SketcherPrs_Coincident::Compute( std::shared_ptr aPnt = getCoincidencePoint(myConstraint); std::shared_ptr aP; FeaturePtr aSub; - for (int i = 0; i < mySketch->numberOfSubs(); i++) { + int aNumberOfSubs = mySketch->numberOfSubs(); + for (int i = 0; i < aNumberOfSubs; i++) { aSub = mySketch->subFeature(i); if (aSub->getKind() == SketchPlugin_ConstraintCoincidence::ID() && aSub.get() != myConstraint) { diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index ee7f93457..a574c0353 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -73,13 +73,21 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess ModuleBase_ITreeNode* aParent; int aRow = 0; QModelIndex aParentIndex1, aParentIndex2; + ObjectPtr aObj; foreach(ModuleBase_ITreeNode* aNode, aNodes) { + aObj = aNode->object(); aParent = aNode->parent(); - aRow = aParent->nodeRow(aNode); - aParentIndex1 = getParentIndex(aNode, 0); - aParentIndex2 = getParentIndex(aNode, 2); - insertRows(aRow, 1, aParentIndex1); - dataChanged(aParentIndex1, aParentIndex2); + if (aObj.get() && (aObj->groupName() == ModelAPI_Folder::group())) { + aParent->update(); + rebuildDataTree(); + } + else { + aRow = aParent->nodeRow(aNode); + aParentIndex1 = getParentIndex(aNode, 0); + aParentIndex2 = getParentIndex(aNode, 2); + insertRows(aRow, 1, aParentIndex1); + dataChanged(aParentIndex1, aParentIndex2); + } } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { @@ -92,7 +100,14 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++) { aList.append(myRoot->objectsDeleted(aIt->first, aIt->second.c_str())); } + // Remove obsolete nodes + QTreeNodesList aRemaining; foreach(ModuleBase_ITreeNode* aNode, aList) { + if (myRoot->hasSubNode(aNode)) + aRemaining.append(aNode); + } + // Update remaining nodes + foreach(ModuleBase_ITreeNode* aNode, aRemaining) { if (aNode->parent()) aNode->parent()->update(); } @@ -124,28 +139,27 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess rebuildDataTree(); } else { + QSet aParents; foreach(ObjectPtr aObj, aCreated) { ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj); if (aNode) { - int aOldNb = aNode->childrenCount(); - aNode->update(); - int aNewNb = aNode->childrenCount(); - - QModelIndex aFirstIdx = getIndex(aNode, 0); - QModelIndex aLastIdx = getIndex(aNode, 2); - - if (aNewNb > aOldNb) { - insertRows(aOldNb - 1, aNewNb - aOldNb, aFirstIdx); - } - else if (aNewNb < aOldNb) { - if (aNewNb) - removeRows(aNewNb - 1, aOldNb - aNewNb, aFirstIdx); - else if (aOldNb) - removeRows(0, aOldNb, aFirstIdx); + if (aNode->parent()) { + if (aNode->parent() == myRoot) { + aParents.clear(); + aParents.insert(myRoot); + break; + } + else { + aNode = aNode->parent(); + } } - dataChanged(aFirstIdx, aLastIdx); + aParents.insert(aNode); } } + foreach(ModuleBase_ITreeNode* aNode, aParents) { + aNode->update(); + } + rebuildDataTree(); } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) { diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 7910ec06a..202afd6b2 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -454,8 +454,9 @@ bool XGUI_Displayer::isVisible(XGUI_Displayer* theDisplayer, const ObjectPtr& th if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultBody::group()) { ResultBodyPtr aCompsolidResult = std::dynamic_pointer_cast(aResult); if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids - bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0; - for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) { + int aNumberOfSubs = aCompsolidResult->numberOfSubs(); + bool anAllSubsVisible = aNumberOfSubs > 0; + for(int i = 0; i < aNumberOfSubs && anAllSubsVisible; i++) { anAllSubsVisible = theDisplayer->isVisible(aCompsolidResult->subResult(i)); } aVisible = anAllSubsVisible; diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index 5c67a3d50..0c7dcd6be 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -137,9 +137,7 @@ void XGUI_ModuleConnector::setSelected(const QList& the foreach(ModuleBase_ViewerPrsPtr aVal, theValues) { anObjects.append(aVal->object()); } - bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); aBrowser->setObjectsSelected(anObjects); - myWorkshop->objectBrowser()->blockSignals(aBlocked); } } diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index b08ccc36e..1862244a5 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef DEBUG_INDXES #include @@ -488,10 +489,12 @@ void XGUI_ObjectsBrowser::onEditItem() // Find index which corresponds the feature QModelIndex aIndex; foreach(QModelIndex aIdx, selectedIndexes()) { - ObjectPtr aFea = dataModel()->object(aIdx); - if (dataModel()->object(aIdx)->isSame(anObject)) { - aIndex = aIdx; - break; + if (aIdx.column() == 1) { + ObjectPtr aFea = dataModel()->object(aIdx); + if (dataModel()->object(aIdx)->isSame(anObject)) { + aIndex = aIdx; + break; + } } } if (aIndex.isValid()) { @@ -533,17 +536,61 @@ void XGUI_ObjectsBrowser::rebuildDataTree() //*************************************************** void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects) { - QList theIndexes; QItemSelectionModel* aSelectModel = myTreeView->selectionModel(); - aSelectModel->clear(); + QModelIndexList aIndexes = aSelectModel->selectedIndexes(); + if (theObjects.size() == 0) { + bool aIsBlock = aSelectModel->blockSignals(true); + aSelectModel->clear(); + aSelectModel->blockSignals(aIsBlock); + foreach(QModelIndex aIdx, aIndexes) { + myTreeView->update(aIdx); + } + return; + } - foreach(ObjectPtr aFeature, theObjects) - { - QModelIndex aIndex = myDocModel->objectIndex(aFeature); - if (aIndex.isValid()) { - aSelectModel->select(aIndex, QItemSelectionModel::Select); + ObjectPtr aObject; + QModelIndexList aUnselect; + QObjectPtrList aToSelect = theObjects; + QHash aNotChanged; + foreach(QModelIndex aIdx, aIndexes) { + aObject = myDocModel->object(aIdx); + if (aObject.get()) { + if (aToSelect.contains(aObject)) { + aNotChanged.insert((qint64)aObject.get(), aObject); + } else { + aUnselect.append(aIdx); + } + } + else { + aUnselect.append(aIdx); } } + + foreach(ObjectPtr aObj, aNotChanged) + aToSelect.removeAll(aObj); + + bool aIsBlock = aSelectModel->blockSignals(true); + foreach(QModelIndex aIdx, aUnselect) { + aSelectModel->select(aIdx, QItemSelectionModel::Deselect); + myTreeView->update(aIdx); + } + + QModelIndex aIndex0, aIndex1, aIndex2, aCurrent; + foreach(ObjectPtr aFeature, aToSelect) { + aIndex1 = myDocModel->objectIndex(aFeature, 1); + if (aIndex1.isValid()) { + if (!aCurrent.isValid()) + aCurrent = aIndex1; + aIndex0 = myDocModel->objectIndex(aFeature, 0); + aIndex2 = myDocModel->objectIndex(aFeature, 2); + aSelectModel->select(aIndex1, QItemSelectionModel::Select | QItemSelectionModel::Rows); + myTreeView->update(aIndex0); + myTreeView->update(aIndex1); + myTreeView->update(aIndex2); + } + } + aSelectModel->setCurrentIndex(aCurrent, QItemSelectionModel::NoUpdate); + aSelectModel->blockSignals(aIsBlock); } //*************************************************** @@ -585,14 +632,14 @@ QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) QObjectPtrList aList; QModelIndexList aIndexes = selectedIndexes(); XGUI_DataModel* aModel = dataModel(); - QModelIndexList::const_iterator aIt; - for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) { - if ((*aIt).column() == 1) { - ObjectPtr aObject = aModel->object(*aIt); + + foreach(QModelIndex aIdx, aIndexes) { + if (aIdx.column() == 1) { + ObjectPtr aObject = aModel->object(aIdx); if (aObject) { aList.append(aObject); if (theIndexes) - theIndexes->append(*aIt); + theIndexes->append(aIdx); } } } diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 6ea539481..a4cf3bbcb 100755 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -146,10 +146,7 @@ void XGUI_SelectionMgr::onViewerSelection() QObjectPtrList anObjects; convertToObjectBrowserSelection(aValues, anObjects); - - bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); myWorkshop->objectBrowser()->setObjectsSelected(anObjects); - myWorkshop->objectBrowser()->blockSignals(aBlocked); emit selectionChanged(); } @@ -191,9 +188,7 @@ void XGUI_SelectionMgr::updateSelectionBy(const ModuleBase_ISelection::Selection void XGUI_SelectionMgr::clearSelection() { QObjectPtrList aFeatures; - bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); - myWorkshop->objectBrowser()->blockSignals(aBlocked); QList aSelectedPrs = myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser); @@ -211,12 +206,9 @@ void XGUI_SelectionMgr::setSelected(const QList& theVal aDisplayer->setSelected(theValues); // update selection in Object Browser - bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); QObjectPtrList anObjects; convertToObjectBrowserSelection(theValues, anObjects); - myWorkshop->objectBrowser()->setObjectsSelected(anObjects); - myWorkshop->objectBrowser()->blockSignals(aBlocked); } //************************************************************** diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index e5bc7a308..aafafbfce 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include @@ -149,14 +151,31 @@ bool canRemoveOrRename(QWidget* theParent, const std::set& theFeatur //****************************************************************** bool canRename(const ObjectPtr& theObject, const QString& theName) { - if (std::dynamic_pointer_cast(theObject).get()) { + std::string aType = theObject->groupName(); + if (aType == ModelAPI_ResultParameter::group()) { double aValue; ResultParameterPtr aParam; if (ModelAPI_Tools::findVariable(theObject->document(), FeaturePtr(), qPrintable(theName), aValue, aParam)) { const char* aKeyStr = "Selected parameter can not be renamed to: %1. " "There is a parameter with the same name. Its value is: %2."; - QString aErrMsg(QObject::tr(aKeyStr).arg(qPrintable(theName)).arg(aValue)); + QString aErrMsg(QObject::tr(aKeyStr).arg(theName).arg(aValue)); + // We can not use here a dialog box for message - + // it will crash editing process in ObjectBrowser + Events_InfoMessage("XGUI_Tools", aErrMsg.toStdString()).send(); + return false; + } + } + else if ((aType == ModelAPI_ResultConstruction::group()) || + (aType == ModelAPI_ResultBody::group())) { + DocumentPtr aDoc = theObject->document(); + ObjectPtr aObj = + aDoc->objectByName(ModelAPI_ResultConstruction::group(), theName.toStdString()); + if (!aObj.get()) + aObj = aDoc->objectByName(ModelAPI_ResultBody::group(), theName.toStdString()); + + if (aObj.get()) { + QString aErrMsg(QObject::tr("Object with name %1 already exists.").arg(theName)); // We can not use here a dialog box for message - // it will crash editing process in ObjectBrowser Events_InfoMessage("XGUI_Tools", aErrMsg.toStdString()).send(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 2e135c8d9..95901d380 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -170,8 +170,15 @@ QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end"); //#define DEBUG_FEATURE_NAME //#define DEBUG_CLEAN_HISTORY - -static QString MyFilter(QObject::tr("OpenParts files (*.opp)")); +#ifdef HAVE_SALOME +static QString MyFilter(QObject::tr("SHAPER files (*.shaper *.opp)")); +static QString MyFilter2(QObject::tr("SHAPER files (*.shaper)")); +static QString MyExtension(".shaper"); +#else +static QString MyFilter(QObject::tr("OpenParts files (*.opp);;All files (*.*)")); +static QString MyFilter2(QObject::tr("OpenParts files (*.opp)")); +static QString MyExtension(".opp"); +#endif //****************************************************** @@ -303,6 +310,8 @@ XGUI_Workshop::~XGUI_Workshop(void) delete myDisplayer; delete myDataModelXMLReader; + delete mySelectionActivate; + delete myMenuMgr; clearTemporaryDir(); } @@ -1082,10 +1091,10 @@ bool XGUI_Workshop::onSaveAs() if(!myOperationMgr->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage)) return false; myCurrentFile = QFileDialog::getSaveFileName(desktop(), tr("Select name to save file..."), - QString(), MyFilter); + QString(), MyFilter2); if (!myCurrentFile.isNull()) { - if (!myCurrentFile.endsWith(".opp")) { - myCurrentFile += ".opp"; + if (!myCurrentFile.endsWith(MyExtension)) { + myCurrentFile += MyExtension; } } else @@ -2207,6 +2216,9 @@ void setColor(ResultPtr theResult, const std::vector& theColor) aColorAttr->setValue(1, theColor[1]); aColorAttr->setValue(2, theColor[2]); } + static const Events_ID kRedisplayEvent = + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent); } //************************************************************** @@ -2285,6 +2297,9 @@ void setDeflection(ResultPtr theResult, const double theDeflection) AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID()); if (aDeflectionAttr.get() != NULL) aDeflectionAttr->setValue(theDeflection); + static const Events_ID kRedisplayEvent = + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent); } //************************************************************** @@ -2296,6 +2311,9 @@ void setTransparency(ResultPtr theResult, double theTransparency) AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); if (anAttribute.get() != NULL) anAttribute->setValue(theTransparency); + static const Events_ID kRedisplayEvent = + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(theResult, kRedisplayEvent); } //************************************************************** @@ -2714,9 +2732,7 @@ void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects) } if (aSelList.count() > theObjects.count()) { // if something was found - bool aBlocked = objectBrowser()->blockSignals(true); objectBrowser()->setObjectsSelected(aSelList); - objectBrowser()->blockSignals(aBlocked); objectBrowser()->ensureVisible(aNewSel.first()); } if (aHasHidden) @@ -2743,9 +2759,7 @@ void XGUI_Workshop::highlightFeature(const QObjectPtrList& theObjects) } if (aSelList.count() > theObjects.count()) { // if something was found - bool aBlocked = objectBrowser()->blockSignals(true); objectBrowser()->setObjectsSelected(aSelList); - objectBrowser()->blockSignals(aBlocked); objectBrowser()->ensureVisible(aNewSel.first()); } } diff --git a/test.API/SHAPER/Primitives/TestBox.py b/test.API/SHAPER/Primitives/TestBox.py index 772056c0a..1bd767d8a 100644 --- a/test.API/SHAPER/Primitives/TestBox.py +++ b/test.API/SHAPER/Primitives/TestBox.py @@ -54,8 +54,8 @@ SketchLine_7 = Sketch_2.addLine(40, 20, 20, 20) SketchLine_8 = Sketch_2.addLine(20, 20, 20, 10) SketchConstraintCoincidence_3 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_4 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_8.endPoint()) -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e")]) -Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_2/SketchLine_6_EndVertex")]) # Extrusion Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0) @@ -81,8 +81,8 @@ Box_11 = model.addBox(Part_1_doc, Point_1, Point_4) Box_12 = model.addBox(Part_1_doc, Point_1, Point_5) Box_13 = model.addBox(Part_1_doc, Vertex_3, Point_2) Box_14 = model.addBox(Part_1_doc, Point_2, Vertex_3) -Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_4e"), model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_7s-SketchLine_6e")) -Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/Generated_Face_2&Extrusion_2_1/To_Face_1")) +Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_2/SketchLine_6_EndVertex")) +Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_2_1/To_Face]")) Box_17 = model.addBox(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) Box_18 = model.addBox(Part_1_doc, "dx", "dy", "dz") model.do() diff --git a/test.API/SHAPER/Primitives/TestCylinder.py b/test.API/SHAPER/Primitives/TestCylinder.py index 850ce6733..630afeb74 100644 --- a/test.API/SHAPER/Primitives/TestCylinder.py +++ b/test.API/SHAPER/Primitives/TestCylinder.py @@ -46,12 +46,12 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint() model.do() # Extrusion -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")], model.selection(), 100, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 100, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")], model.selection(), 100, 0) # Edge -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_3")]) # Axis Axis_1 = model.addAxis(Part_1_doc, 0, 10, 0) @@ -74,9 +74,9 @@ Cylinder_6 = model.addCylinder(Part_1_doc, 5, 0) Cylinder_7 = model.addCylinder(Part_1_doc, 5, -10) Cylinder_8 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "InvalidName"), model.selection("EDGE", "PartSet/OX"), 5, 10) Cylinder_9 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "InvalidName"), 5, 10) -Cylinder_10 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_3s-SketchLine_2e"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 50, 120) +Cylinder_10 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine_2_EndVertex"), model.selection("EDGE", "Sketch_1/SketchLine_3"), 50, 120) Cylinder_11 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_1_1"), 60, 100) -Cylinder_12 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1"), 5, 10) +Cylinder_12 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]"), 5, 10) Cylinder_13 = model.addCylinder(Part_1_doc, "r", "h") Cylinder_14 = model.addCylinder(Part_1_doc, 5, 10, 45) Cylinder_15 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 5, 10, 90) @@ -91,9 +91,9 @@ Cylinder_23 = model.addCylinder(Part_1_doc, 5, 10, -45) Cylinder_24 = model.addCylinder(Part_1_doc, 5, 10, 450) Cylinder_25 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "InvalidName"), model.selection("EDGE", "PartSet/OX"), 5, 10, 90) Cylinder_26 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "InvalidName"), 5, 10, 90) -Cylinder_27 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 50, 120, 90) +Cylinder_27 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), model.selection("EDGE", "Sketch_1/SketchLine_3"), 50, 120, 90) Cylinder_28 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("EDGE", "Edge_2_1"), 60, 100, 180) -Cylinder_29 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/Generated_Face_2&Extrusion_2_1/To_Face_1"), model.selection("EDGE", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/To_Face_1"), 5, 10, 120) +Cylinder_29 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_2_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_2_1/To_Face]"), model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_2_1/To_Face]"), 5, 10, 120) Cylinder_30 = model.addCylinder(Part_1_doc, "r2", "h2", "angle") model.do() diff --git a/test.API/SHAPER/Transformations/TestMultiTranslation.py b/test.API/SHAPER/Transformations/TestMultiTranslation.py index bcfd1db29..8c8f9271f 100644 --- a/test.API/SHAPER/Transformations/TestMultiTranslation.py +++ b/test.API/SHAPER/Transformations/TestMultiTranslation.py @@ -55,11 +55,11 @@ SketchCircle_1 = Sketch_2.addCircle(3.420516499282639, 6.702654232424678, 2.6604 model.do() # Create Wire & Extrusion -Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_3")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OZ"), 50, 0) # Revolution of the circle -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r_wire")], model.selection("EDGE", "PartSet/OZ"), 360, 0) # Create MultiTranslations MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "PartSet/OX"), 15, 5) @@ -175,4 +175,4 @@ assert(MultiTranslation_8.feature().error() == 'Attribute "axis_second_dir" is n #model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.SOLID, [0]) #model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.SHELL, [10]) #model.testNbSubShapes(MultiTranslation_9, GeomAPI_Shape.FACE, [30]) -#model.testHaveNamingFaces(MultiTranslation_9, model, Part_1_doc) \ No newline at end of file +#model.testHaveNamingFaces(MultiTranslation_9, model, Part_1_doc) diff --git a/test.API/SHAPER/Transformations/TestScale.py b/test.API/SHAPER/Transformations/TestScale.py index 0df7c1b98..6d38e273d 100644 --- a/test.API/SHAPER/Transformations/TestScale.py +++ b/test.API/SHAPER/Transformations/TestScale.py @@ -70,25 +70,25 @@ model.do() Point_1 = model.addPoint(Part_1_doc, -10, -10, -10) # Create Vertexes -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")]) # Create Wire & Extrusion -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f_wire")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 50, 0) # Create Scales Scale_1 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_1_1")] , model.selection("VERTEX", "PartSet/Origin"), 2) Scale_2 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_2_1")] , model.selection("VERTEX", "Point_1"), 2) -Scale_3 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_3_1")] , model.selection("VERTEX", "Box_3_1/Back&Box_3_1/Left&Box_3_1/Top"), 2) -Scale_4 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_4_1")] , model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), 2) +Scale_3 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_3_1")] , model.selection("VERTEX", "[Box_3_1/Back][Box_3_1/Left][Box_3_1/Top]"), 2) +Scale_4 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_4_1")] , model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), 2) Scale_5 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_5_1")] , model.selection("VERTEX", "Vertex_1_1"), 2) Scale_6 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_6_1")] , model.selection("VERTEX", "PartSet/Origin"), 0) Scale_7 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_7_1")] , model.selection("VERTEX", "PartSet/Origin"), -3) Scale_8 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_8_1")] , model.selection("VERTEX", "InvalidName"), 2) Scale_9 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_9_1")] , model.selection("VERTEX", "PartSet/Origin"), 2 , 3, 1) Scale_10 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_10_1")] , model.selection("VERTEX", "Point_1"), 2 , 3, 1) -Scale_11 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_11_1")] , model.selection("VERTEX", "Box_11_1/Back&Box_11_1/Right&Box_11_1/Top"), 2 , 3, 1) -Scale_12 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_12_1")] , model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e"), 2 , 3, 1) +Scale_11 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_11_1")] , model.selection("VERTEX", "[Box_11_1/Back][Box_11_1/Right][Box_11_1/Top]"), 2 , 3, 1) +Scale_12 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_12_1")] , model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), 2 , 3, 1) Scale_13 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_13_1")] , model.selection("VERTEX", "Vertex_1_1"), 2 , 3, 1) Scale_14 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_14_1")] , model.selection("VERTEX", "PartSet/Origin"), 0 , 3, 1) Scale_15 = model.addScale(Part_1_doc, [model.selection("SOLID", "Box_15_1")] , model.selection("VERTEX", "PartSet/Origin"), 2 , 0, 1) @@ -201,4 +201,4 @@ assert(Scale_18.feature().error() == 'Attribute "center_point" is not initialize #model.testNbSubShapes(Scale_19, GeomAPI_Shape.SHELL, [1]) #model.testNbSubShapes(Scale_19, GeomAPI_Shape.SOLID, [0]) #model.testNbSubShapes(Scale_19, GeomAPI_Shape.FACE, [5]) -#model.testHaveNamingFaces(Scale_19, model, Part_1_doc) \ No newline at end of file +#model.testHaveNamingFaces(Scale_19, model, Part_1_doc) diff --git a/test.API/SHAPER/Transformations/TestSymmetry.py b/test.API/SHAPER/Transformations/TestSymmetry.py index e32052e06..bb1bbc623 100644 --- a/test.API/SHAPER/Transformations/TestSymmetry.py +++ b/test.API/SHAPER/Transformations/TestSymmetry.py @@ -89,13 +89,13 @@ SketchConstraintCoincidence_5 = Sketch_3.setCoincident(SketchLine_6.startPoint() model.do() # Vertexes -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")]) # Edges -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) # Wire & Extrusion -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_6r-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f_wire")]) Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 50, 0) # Planes @@ -103,22 +103,22 @@ Plane_1 = model.addPlane(Part_1_doc, model.selection("FACE", "Box_14_1/Top"), 10 Plane_2 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), 40, False) # Faces -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f_wire")]) # Symmetries Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "PartSet/Origin")) Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Point_1")) -Symmetry_3 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "Box_3_1/Front&Box_3_1/Right&Box_3_1/Top")) -Symmetry_4 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1e")) +Symmetry_3 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "[Box_3_1/Front][Box_3_1/Right][Box_3_1/Top]")) +Symmetry_4 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")) Symmetry_5 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("VERTEX", "Vertex_1_1")) Symmetry_6 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("VERTEX", "InvalidName")) Symmetry_7 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("VERTEX", "PartSet/Origin"), False) Symmetry_8 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "PartSet/OZ")) Symmetry_9 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "Axis_1")) -Symmetry_10 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_10_1")], model.selection("EDGE", "Box_9_1/Front&Box_9_1/Top")) -Symmetry_11 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +Symmetry_10 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_10_1")], model.selection("EDGE", "[Box_9_1/Front][Box_9_1/Top]")) +Symmetry_11 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "Sketch_1/SketchLine_1")) Symmetry_12 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_12_1")], model.selection("EDGE", "Edge_1_1")) Symmetry_13 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("EDGE", "InvalidName")) Symmetry_14 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Box_14_1")], model.selection("EDGE", "PartSet/OZ"), False) @@ -185,7 +185,11 @@ model.testNbSubShapes(Symmetry_9, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Symmetry_9, GeomAPI_Shape.FACE, [12]) model.testHaveNamingFaces(Symmetry_9, model, Part_1_doc) -model.testNbResults(Symmetry_10, 0) +model.testNbResults(Symmetry_10, 1) +model.testNbSubResults(Symmetry_10, [2]) +model.testNbSubShapes(Symmetry_10, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Symmetry_10, GeomAPI_Shape.FACE, [12]) +model.testHaveNamingFaces(Symmetry_10, model, Part_1_doc) model.testNbResults(Symmetry_11, 1) model.testNbSubResults(Symmetry_11, [2]) @@ -217,7 +221,11 @@ model.testNbSubShapes(Symmetry_16, GeomAPI_Shape.SOLID, [2]) model.testNbSubShapes(Symmetry_16, GeomAPI_Shape.FACE, [12]) model.testHaveNamingFaces(Symmetry_16, model, Part_1_doc) -model.testNbResults(Symmetry_17, 0) +model.testNbResults(Symmetry_17, 1) +model.testNbSubResults(Symmetry_17, [2]) +model.testNbSubShapes(Symmetry_17, GeomAPI_Shape.SOLID, [2]) +model.testNbSubShapes(Symmetry_17, GeomAPI_Shape.FACE, [12]) +model.testHaveNamingFaces(Symmetry_17, model, Part_1_doc) model.testNbResults(Symmetry_18, 1) model.testNbSubResults(Symmetry_18, [2]) diff --git a/test.API/SHAPER/Transformations/TestTranslation_1.py b/test.API/SHAPER/Transformations/TestTranslation_1.py index fcd1406ab..d164a9ee2 100644 --- a/test.API/SHAPER/Transformations/TestTranslation_1.py +++ b/test.API/SHAPER/Transformations/TestTranslation_1.py @@ -140,19 +140,19 @@ SketchLine_12 = Sketch_10.addLine(2.442711482557598, 6.454964041059345, 8.035432 model.do() # Extrusions -Extrusion_1 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_3 = model.addExtrusion(Part_3_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_4 = model.addExtrusion(Part_4_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_5 = model.addExtrusion(Part_5_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_6 = model.addExtrusion(Part_6_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_7 = model.addExtrusion(Part_7_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_8 = model.addExtrusion(Part_8_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_9 = model.addExtrusion(Part_9_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) +Extrusion_1 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_3 = model.addExtrusion(Part_3_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_4 = model.addExtrusion(Part_4_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_5 = model.addExtrusion(Part_5_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_6 = model.addExtrusion(Part_6_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_7 = model.addExtrusion(Part_7_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_8 = model.addExtrusion(Part_8_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_9 = model.addExtrusion(Part_9_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) # Edges -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Edge_2 = model.addEdge(Part_7_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Edge_2 = model.addEdge(Part_7_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1")]) # Axis Axis_1 = model.addAxis(partSet, 10, 10, 10) @@ -177,19 +177,18 @@ Translation_2 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_ Translation_3 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_4 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("EDGE", "InvalidName"), 15) Translation_5 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_5_1")], model.selection("EDGE", "PartSet/OY"), "d") -Translation_6 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), 15) +Translation_6 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_3"), 15) Translation_7 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_7_1")], model.selection("EDGE", "Edge_1_1"), 15) -Translation_8 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "Box_8_1/Right&Box_8_1/Top"), 15) +Translation_8 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_8_1")], model.selection("EDGE", "[Box_8_1/Right][Box_8_1/Top]"), 15) Translation_9 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_9_1")], model.selection("EDGE", "PartSet/Axis_4"), 15) Translation_10 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OZ"), 15) Translation_11 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_2_1")], model.selection("EDGE", "PartSet/OZ"), 0) Translation_12 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_3_1")], model.selection("EDGE", "PartSet/OZ"), -15) Translation_13 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_4_1")], model.selection("EDGE", "InvalidName"), 15) Translation_14 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_5_1")], model.selection("EDGE", "PartSet/OZ"), "d") -Translation_15 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 50) +Translation_15 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 50) Translation_16 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_7_1")], model.selection("EDGE", "Edge_1_1"), 50) -#Translation_17 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_8_1")], model.selection("EDGE", "LinearCopy_8_1/Translated_Edge_8_8"), 50) -Translation_17 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_8_1")], model.selection("EDGE", "LinearCopy_8_1/Translated_Face_3_4&LinearCopy_8_1/Translated_Face_3_1"), 50) +Translation_17 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_8_1")], model.selection("EDGE", "[LinearCopy_8_1_3/MF:Translated_Face&Box_17_1/Left][LinearCopy_8_1_3/MF:Translated_Face&Box_17_1/Top]"), 50) Translation_18 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_9_1")], model.selection("EDGE", "PartSet/Axis_4"), 50) Translation_19 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("EDGE", "OX"), 15) Translation_20 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_3/")], model.selection("EDGE", "OX"), 0) @@ -197,7 +196,7 @@ Translation_21 = model.addTranslation(partSet, [model.selection("COMPOUND", "Par Translation_22 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_5/")], model.selection("EDGE", "InvalidName"), 15) Translation_23 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_6/")], model.selection("EDGE", "OX"), "d") Translation_24 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_7/")], model.selection("EDGE", "Part_7/Edge_1_1"), 15) -Translation_25 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_8/")], model.selection("EDGE", "Part_8/Box_1_1/Front&Box_1_1/Left"), 15) +Translation_25 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_8/")], model.selection("EDGE", "Part_8/[Box_1_1/Front][Box_1_1/Left]"), 15) Translation_26 = model.addTranslation(partSet, [model.selection("COMPOUND", "Part_9/")], model.selection("EDGE", "Axis_4"), 15) model.do() model.end() @@ -376,4 +375,4 @@ model.testNbResults(Translation_26, 1) #model.testNbSubShapes(Translation_26, GeomAPI_Shape.COMPOUND, [1]) #model.testNbSubShapes(Translation_26, GeomAPI_Shape.SOLID, [2]) #model.testNbSubShapes(Translation_26, GeomAPI_Shape.FACE, [9]) -#model.testHaveNamingFaces(Translation_26, model, Part_9_doc) \ No newline at end of file +#model.testHaveNamingFaces(Translation_26, model, Part_9_doc) diff --git a/test.API/SHAPER/Transformations/TestTranslation_2.py b/test.API/SHAPER/Transformations/TestTranslation_2.py index 152f759ac..1379bd931 100644 --- a/test.API/SHAPER/Transformations/TestTranslation_2.py +++ b/test.API/SHAPER/Transformations/TestTranslation_2.py @@ -81,7 +81,7 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint() model.do() # Edges -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2")]) # Axis Axis_1 = model.addAxis(Part_1_doc, 10, 10, 10) @@ -117,7 +117,7 @@ Translation_31 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", " # Translation 32 Translation_32_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_11_1")], model.selection("EDGE", "PartSet/OX"), 5) Intersection_6 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Box_12_1"), model.selection("SOLID", "Translation_11_1")]) -Translation_32 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15) +Translation_32 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Intersection_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_1"), 15) # Translation 33 Translation_33_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_13_1")], model.selection("EDGE", "PartSet/OX"), 5) @@ -162,7 +162,7 @@ Translation_40 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", # Translation 41 Translation_41_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_29_1")], model.selection("EDGE", "PartSet/OX"), 5) Partition_6 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Box_30_1"), model.selection("SOLID", "Translation_29_1")]) -Translation_41 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_6_1")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 15) +Translation_41 = model.addTranslation(Part_1_doc, [model.selection("COMPSOLID", "Partition_6_1")], model.selection("EDGE", "Sketch_1/SketchLine_1"), 15) # Translation 42 Translation_42_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_31_1")], model.selection("EDGE", "PartSet/OX"), 5) diff --git a/test.API/SHAPER/Transformations/TestTranslation_3.py b/test.API/SHAPER/Transformations/TestTranslation_3.py index 0a089ea94..7bc34a775 100644 --- a/test.API/SHAPER/Transformations/TestTranslation_3.py +++ b/test.API/SHAPER/Transformations/TestTranslation_3.py @@ -103,62 +103,62 @@ SketchCircle_2 = Sketch_8.addCircle(5.043472022955523, 6.180989956958394, 2.6548 model.do() # Extrusions -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 15, 0) -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_8/Wire-SketchCircle_2_2f")], model.selection(), 15, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r_wire")], model.selection(), 15, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_8/Face-SketchCircle_2_2r_wire")], model.selection(), 15, 0) # Edges -Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")]) -Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) -Edge_3 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) -Edge_4 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) -Edge_5 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) -Edge_6 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/Edge-SketchLine_5")]) -Edge_7 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) -Edge_8 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_6")]) -Edge_9 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) -Edge_10 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/Edge-SketchLine_7")]) -Edge_11 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_5/Edge-SketchLine_11")]) -Edge_12 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_7/Edge-SketchLine_22")]) +Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_2")]) +Edge_2 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_5")]) +Edge_3 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_5")]) +Edge_4 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_5")]) +Edge_5 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_5")]) +Edge_6 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_3/SketchLine_5")]) +Edge_7 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/SketchLine_7")]) +Edge_8 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/SketchLine_6")]) +Edge_9 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/SketchLine_7")]) +Edge_10 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_4/SketchLine_7")]) +Edge_11 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_5/SketchLine_11")]) +Edge_12 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_7/SketchLine_22")]) # Axis Axis_1 = model.addAxis(Part_1_doc, 10, 10, 10) # Vertex -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_5 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_6 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_7 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_8 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) -Vertex_9 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/Vertex-SketchLine_5e")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_3 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_4 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_5 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_6 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_7 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_8 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) +Vertex_9 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_3/SketchLine_5_EndVertex")]) # Wires -Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_2 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_3 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_4 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_5 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_6 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) -Wire_7 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) -Wire_8 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Wire_9 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) +Wire_1 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_2 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_3 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_4 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_5 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_6 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f_wire")]) +Wire_7 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f_wire")]) +Wire_8 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Wire_9 = model.addWire(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) # Faces -Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_6 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) -Face_7 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_8f-SketchLine_9f-SketchLine_10f")]) -Face_8 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_9 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_2f-SketchLine_3f")]) -Face_10 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchLine_12f-SketchLine_13f-SketchLine_14f")]) -Face_11 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchLine_14r-SketchLine_15r-SketchLine_16r")]) -Face_12 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchLine_17f-SketchLine_18f-SketchLine_19f")]) -Face_13 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchLine_19r-SketchLine_20r-SketchLine_21r")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_4 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_5 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_6 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f_wire")]) +Face_7 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_8r-SketchLine_9f-SketchLine_10f_wire")]) +Face_8 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_9 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_3r-SketchLine_2r-SketchLine_1r_wire")]) +Face_10 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Face-SketchLine_12r-SketchLine_13f-SketchLine_14f_wire")]) +Face_11 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_6/Face-SketchLine_16r-SketchLine_15r-SketchLine_14r_wire")]) +Face_12 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Face-SketchLine_17r-SketchLine_18f-SketchLine_19f_wire")]) +Face_13 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_7/Face-SketchLine_21r-SketchLine_20r-SketchLine_19r_wire")]) # Shells Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")]) @@ -203,45 +203,45 @@ Translation_46 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Ve Translation_47 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_3_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_48 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_4_1")], model.selection("EDGE", "InvalidName"), 15) Translation_49 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_5_1")], model.selection("EDGE", "PartSet/OX"), "d") -Translation_50 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_6_1")], model.selection("EDGE", "Sketch_3/Edge-SketchLine_5"), 15) +Translation_50 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_6_1")], model.selection("EDGE", "Sketch_3/SketchLine_5"), 15) Translation_51 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_7_1")], model.selection("EDGE", "Edge_2_1"), 15) -Translation_52 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_8_1")], model.selection("EDGE", "Box_1_1/Back&Box_1_1/Right"), 15) +Translation_52 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_8_1")], model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"), 15) Translation_53 = model.addTranslation(Part_1_doc, [model.selection("VERTEX", "Vertex_9_1")], model.selection("EDGE", "Axis_1"), 15) Translation_54 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_2_1")], model.selection("EDGE", "PartSet/OX"), 15) Translation_55 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_3_1")], model.selection("EDGE", "PartSet/OX"), 0) Translation_56 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_4_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_57 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_5_1")], model.selection("EDGE", "InvalidName"), 15) Translation_58 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_6_1")], model.selection("EDGE", "PartSet/OY"), "d") -Translation_59 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_7_1")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_6"), 15) +Translation_59 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_7_1")], model.selection("EDGE", "Sketch_4/SketchLine_6"), 15) Translation_60 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_8_1")], model.selection("EDGE", "Edge_9_1"), 15) -Translation_61 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_9_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_61 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_9_1")], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), 15) Translation_62 = model.addTranslation(Part_1_doc, [model.selection("EDGE", "Edge_10_1")], model.selection("EDGE", "Axis_1"), 15) Translation_63 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection("EDGE", "PartSet/OX"), 15) Translation_64 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_2_1")], model.selection("EDGE", "PartSet/OX"), 0) Translation_65 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_3_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_66 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_4_1")], model.selection("EDGE", "InvalidName"), 15) Translation_67 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_5_1")], model.selection("EDGE", "PartSet/OY"), "d") -Translation_68 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_6_1")], model.selection("EDGE", "Sketch_5/Edge-SketchLine_11"), 15) +Translation_68 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_6_1")], model.selection("EDGE", "Sketch_5/SketchLine_11"), 15) Translation_69 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_7_1")], model.selection("EDGE", "Edge_11_1"), 15) -Translation_70 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_8_1")], model.selection("EDGE", "Box_1_1/Back&Box_1_1/Right"), 15) +Translation_70 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_8_1")], model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Right]"), 15) Translation_71 = model.addTranslation(Part_1_doc, [model.selection("WIRE", "Wire_9_1")], model.selection("EDGE", "Axis_1"), 15) Translation_72 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OX"), 15) Translation_73 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OX"), 0) Translation_74 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_3_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_75 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_4_1")], model.selection("EDGE", "InvalidName"), -15) Translation_76 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_5_1")], model.selection("EDGE", "PartSet/OX"), "d") -Translation_77 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_6_1")], model.selection("EDGE", "Sketch_5/Edge-SketchLine_11"), 15) +Translation_77 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_6_1")], model.selection("EDGE", "Sketch_5/SketchLine_11"), 15) Translation_78 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_7_1")], model.selection("EDGE", "Edge_11_1"), 15) -Translation_79 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_8_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_79 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_8_1")], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), 15) Translation_80 = model.addTranslation(Part_1_doc, [model.selection("FACE", "Face_9_1")], model.selection("EDGE", "Axis_1"), 15) Translation_81 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_1_1")], model.selection("EDGE", "PartSet/OX"), 15) Translation_82 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_2_1")], model.selection("EDGE", "PartSet/OX"), 0) Translation_83 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_3_1")], model.selection("EDGE", "PartSet/OX"), -15) Translation_84 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_4_1")], model.selection("EDGE", "InvalidName"), 15) Translation_85 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_5_1")], model.selection("EDGE", "PartSet/OX"), "d") -Translation_86 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_6_1")], model.selection("EDGE", "Sketch_7/Edge-SketchLine_22"), 15) +Translation_86 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_6_1")], model.selection("EDGE", "Sketch_7/SketchLine_22"), 15) Translation_87 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_7_1")], model.selection("EDGE", "Edge_12_1"), 15) -Translation_88 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_8_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Right"), 15) +Translation_88 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_8_1")], model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Right]"), 15) Translation_89 = model.addTranslation(Part_1_doc, [model.selection("SHELL", "Shell_9_1")], model.selection("EDGE", "Axis_1"), 15) Translation_90 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1"), model.selection("SOLID", "Extrusion_2_1")], model.selection("EDGE", "PartSet/OY"), 15) model.do() diff --git a/test.API/SHAPER/Transformations/TestTranslation_5.py b/test.API/SHAPER/Transformations/TestTranslation_5.py index a903dc477..3b654a72e 100644 --- a/test.API/SHAPER/Transformations/TestTranslation_5.py +++ b/test.API/SHAPER/Transformations/TestTranslation_5.py @@ -50,17 +50,17 @@ Point_1 = model.addPoint(Part_1_doc, 10, 0, 0) Point_2 = model.addPoint(Part_1_doc, 10, 10, 0) # Vertex -Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_3e")]) -Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e")]) +Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")]) +Vertex_2 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")]) # Translations Translation_99 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")) -Translation_100 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_1")) -Translation_101 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_1")) -Translation_102 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "InvalidName")) -Translation_103 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_3e"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchLine_1e")) +Translation_100 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_1")) +Translation_101 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "InvalidName"), model.selection("VERTEX", "Point_1")) +Translation_102 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Translation_1_1")], model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "InvalidName")) +Translation_103 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_2_1")], model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")) Translation_104 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_3_1")], model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) -Translation_105 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "Box_4_1/Back&Box_4_1/Left&Box_4_1/Bottom"), model.selection("VERTEX", "Box_4_1/Front&Box_4_1/Right&Box_4_1/Top")) +Translation_105 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_4_1")], model.selection("VERTEX", "[Box_4_1/Back][Box_4_1/Left][Box_4_1/Bottom]"), model.selection("VERTEX", "[Box_4_1/Front][Box_4_1/Right][Box_4_1/Top]")) model.do() model.end() @@ -99,4 +99,4 @@ model.testNbResults(Translation_101, 0) assert(Translation_101.feature().error() == 'Attribute "start_point" is not initialized.') model.testNbResults(Translation_102, 0) -assert(Translation_102.feature().error() == 'Attribute "end_point" is not initialized.') \ No newline at end of file +assert(Translation_102.feature().error() == 'Attribute "end_point" is not initialized.') diff --git a/test.models/CSWA.py b/test.models/CSWA.py index b1f5181dc..98409756f 100644 --- a/test.models/CSWA.py +++ b/test.models/CSWA.py @@ -93,24 +93,24 @@ SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.coordinates()) SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_15") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchLine_10f-SketchArc_1_2r-SketchArc_2_2r")], model.selection(), "b/2", "b/2") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/To_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchArc_2_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchLine_9f-SketchArc_1_2r-SketchLine_10f")], model.selection(), "b/2", "b/2") +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/To_Face]")) SketchCircle_1 = Sketch_2.addCircle(-15, 35.00000000000001, 25) SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchCircle_1.center()) SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_16") SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_1.results()[1], "50/2") model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_4")) -SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_4")) -SketchLine_11 = Sketch_3.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_4")) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f_wire")], model.selection(), 0, 13, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&ExtrusionCut_1_1/From_Face")) +SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Generated_Vertex&ExtrusionCut_1_1/From_Face")) +SketchLine_11 = Sketch_3.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_2")) SketchArc_3 = Sketch_3.addArc(-15, 35.00000000000001, -15, 46.0103340429751, -17.02045759563166, 24.17663606626138, True) SketchConstraintCoincidence_16 = Sketch_3.setCoincident(SketchPoint_3.result(), SketchArc_3.center()) SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_17") SketchConstraintCoincidence_17 = Sketch_3.setCoincident(SketchLine_11.result(), SketchArc_3.startPoint()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_18") -SketchArc_4 = Sketch_3.addArc(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_1_1/Modfied_4")) +SketchArc_4 = Sketch_3.addArc(model.selection("EDGE", "ExtrusionCut_1_1/Generated_Edge&ExtrusionCut_1_1/From_Face&weak_name_1")) SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchArc_4.results()[1]) SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_19") SketchLine_12 = Sketch_3.addLine(-15, 46.0103340429751, -15, 35.00000000000001) @@ -127,20 +127,20 @@ SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchArc_3.results()[1] SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_24") model.do() ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchArc_3_2f-SketchLine_12f-SketchArc_5_2r")], model.selection(), 5, 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_1_1/To_Face_1")) -SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionFuse_1_1/Modfied_4&ExtrusionFuse_1_1/Modfied_5&ExtrusionFuse_1_1/To_Face_1")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_1_1/To_Face")) +SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "[ExtrusionFuse_1_1/Generated_Face&Sketch_3/SketchArc_5_2][ExtrusionFuse_1_1/Generated_Face&Sketch_3/SketchLine_12][ExtrusionFuse_1_1/To_Face]")) SketchCircle_2 = Sketch_4.addCircle(-15, 35.00000000000001, 5) SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchPoint_4.result(), SketchCircle_2.center()) SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_25") SketchConstraintRadius_4 = Sketch_4.setRadius(SketchCircle_2.results()[1], "10/2") model.do() ExtrusionFuse_2 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchCircle_2_2f")], model.selection(), 8, 0, [model.selection("SOLID", "ExtrusionFuse_1_1")]) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_1")) -SketchArc_6 = Sketch_5.addArc(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionFuse_1_1/Modfied_3")) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face")) +SketchArc_6 = Sketch_5.addArc(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionFuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2]")) SketchArc_7 = Sketch_5.addArc(-45, 35, -45, 5, -25.41666666666737, 12.27351642784166, False) SketchConstraintCoincidence_25 = Sketch_5.setCoincident(SketchArc_6.result(), SketchArc_7.center()) SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_26") -SketchCircle_3 = Sketch_5.addCircle(model.selection("EDGE", "ExtrusionFuse_2_1/Modfied_5&ExtrusionFuse_2_1/To_Face_1")) +SketchCircle_3 = Sketch_5.addCircle(model.selection("EDGE", "[ExtrusionFuse_2_1/Generated_Face&Sketch_4/SketchCircle_2_2][ExtrusionFuse_2_1/To_Face]")) SketchArc_8 = Sketch_5.addArc(-15, 35.00000000000001, -25.41666666666737, 12.27351642784166, -30.00000000000075, 14.99999999999944, True) SketchConstraintCoincidence_26 = Sketch_5.setCoincident(SketchCircle_3.result(), SketchArc_8.center()) SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_27") @@ -163,53 +163,53 @@ SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_33") SketchConstraintCoincidence_33 = Sketch_5.setCoincident(SketchArc_9.startPoint(), SketchLine_13.endPoint()) SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_34") model.do() -ExtrusionFuse_3 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_7_2f-SketchArc_8_2r-SketchLine_13r-SketchArc_9_2r")], model.selection(), 0, 8, [model.selection("SOLID", "ExtrusionFuse_2_1")]) -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_3_1/Modfied_3")) -SketchLine_14 = Sketch_6.addLine(model.selection("EDGE", "ExtrusionFuse_3_1/Modfied_3&Extrusion_1_1/Generated_Face_7")) +ExtrusionFuse_3 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_7_2f-SketchArc_8_2r-SketchArc_9_2r-SketchLine_13r")], model.selection(), 0, 8, [model.selection("SOLID", "ExtrusionFuse_2_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_3_1/Modified_Face&Extrusion_1_1/To_Face")) +SketchLine_14 = Sketch_6.addLine(model.selection("EDGE", "[ExtrusionFuse_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5]")) SketchArc_10 = Sketch_6.addArc(55, 35, 55, 15, 35, 35, True) SketchConstraintCoincidence_34 = Sketch_6.setCoincident(SketchLine_14.result(), SketchArc_10.center()) SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_35") SketchConstraintCoincidence_35 = Sketch_6.setCoincident(SketchLine_14.result(), SketchArc_10.startPoint()) SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_36") -SketchLine_15 = Sketch_6.addLine(model.selection("EDGE", "ExtrusionFuse_3_1/Modfied_3&Extrusion_1_1/Generated_Face_8")) -SketchConstraintDistance_8 = Sketch_6.setDistance(SketchArc_10.center(), SketchLine_15.result(), 35) -SketchLine_16 = Sketch_6.addLine(35, 35, 35, 48) +SketchLine_15 = Sketch_6.addLine(model.selection("EDGE", "[ExtrusionFuse_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4]")) +SketchConstraintDistance_8 = Sketch_6.setDistance(SketchArc_10.center(), SketchLine_15.result(), 35, False) +SketchLine_16 = Sketch_6.addLine(35, 35, 35, 47.99999999999999) SketchConstraintCoincidence_36 = Sketch_6.setCoincident(SketchArc_10.endPoint(), SketchLine_16.startPoint()) SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_37") -SketchLine_17 = Sketch_6.addLine(model.selection("EDGE", "ExtrusionFuse_3_1/Modfied_3&Extrusion_1_1/Generated_Face_6")) +SketchLine_17 = Sketch_6.addLine(model.selection("EDGE", "[ExtrusionFuse_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]")) SketchConstraintCoincidence_37 = Sketch_6.setCoincident(SketchLine_16.endPoint(), SketchLine_17.result()) SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_38") SketchConstraintVertical_6 = Sketch_6.setVertical(SketchLine_16.result()) SketchConstraintTangent_4 = Sketch_6.setTangent(SketchLine_16.result(), SketchArc_10.results()[1]) SketchConstraintRadius_5 = Sketch_6.setRadius(SketchArc_10.results()[1], 20) -SketchLine_18 = Sketch_6.addLine(55, 15, 55, 48) +SketchLine_18 = Sketch_6.addLine(55, 15, 55, 47.99999999999999) SketchConstraintCoincidence_38 = Sketch_6.setCoincident(SketchArc_10.startPoint(), SketchLine_18.startPoint()) SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_39") SketchConstraintCoincidence_39 = Sketch_6.setCoincident(SketchLine_14.endPoint(), SketchLine_18.endPoint()) SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_40") -SketchLine_19 = Sketch_6.addLine(35, 48, 55, 48) +SketchLine_19 = Sketch_6.addLine(35, 47.99999999999999, 55, 47.99999999999999) SketchConstraintCoincidence_40 = Sketch_6.setCoincident(SketchLine_16.endPoint(), SketchLine_19.startPoint()) SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_41") SketchConstraintCoincidence_41 = Sketch_6.setCoincident(SketchLine_14.endPoint(), SketchLine_19.endPoint()) SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_42") model.do() -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchArc_10_2f-SketchLine_16r-SketchLine_18f-SketchLine_19r")], model.selection(), 0, 9, [model.selection("SOLID", "ExtrusionFuse_3_1")]) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/From_Face_1")) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_6/Face-SketchArc_10_2f-SketchLine_18f-SketchLine_19r-SketchLine_16r_wire")], model.selection(), 0, 9, [model.selection("SOLID", "ExtrusionFuse_3_1")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/From_Face")) SketchCircle_4 = Sketch_7.addCircle(45, -35, 5) -SketchLine_20 = Sketch_7.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/From_Face_1")) -SketchConstraintDistance_9 = Sketch_7.setDistance(SketchCircle_4.center(), SketchLine_20.result(), 10) +SketchLine_20 = Sketch_7.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_5][ExtrusionCut_2_1/From_Face]")) +SketchConstraintDistance_9 = Sketch_7.setDistance(SketchCircle_4.center(), SketchLine_20.result(), 10, False) SketchConstraintRadius_6 = Sketch_7.setRadius(SketchCircle_4.results()[1], "10/2") SketchLine_21 = Sketch_7.addLine(35, -35, 45, -35) SketchLine_21.setAuxiliary(True) -SketchPoint_5 = Sketch_7.addPoint(model.selection("VERTEX", "ExtrusionCut_2_1/Generated_Face_1&ExtrusionCut_2_1/Generated_Face_4&ExtrusionCut_2_1/From_Face_1")) +SketchPoint_5 = Sketch_7.addPoint(model.selection("VERTEX", "[ExtrusionCut_2_1/Generated_Face&Sketch_6/SketchLine_16][ExtrusionCut_2_1/Generated_Face&Sketch_6/SketchArc_10_2][ExtrusionCut_2_1/From_Face]")) SketchConstraintCoincidence_42 = Sketch_7.setCoincident(SketchLine_21.startPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_43") SketchConstraintCoincidence_43 = Sketch_7.setCoincident(SketchCircle_4.center(), SketchLine_21.endPoint()) SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_44") SketchConstraintHorizontal_4 = Sketch_7.setHorizontal(SketchLine_21.result()) model.do() -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_7/Face-SketchCircle_4_2f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/From_Face_1"), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_4")) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_7/Face-SketchCircle_4_2r")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/From_Face"), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8")) SketchLine_22 = Sketch_8.addLine(55, 25, 5.000000000000002, 25) SketchLine_23 = Sketch_8.addLine(5.000000000000002, 25, 5.000000000000002, 13) SketchLine_24 = Sketch_8.addLine(5.000000000000002, 13, 55, 13) @@ -228,26 +228,26 @@ SketchConstraintHorizontal_6 = Sketch_8.setHorizontal(SketchLine_24.result()) SketchConstraintVertical_8 = Sketch_8.setVertical(SketchLine_25.result()) SketchConstraintLength_2 = Sketch_8.setLength(SketchLine_22.result(), 50) SketchConstraintLength_3 = Sketch_8.setLength(SketchLine_25.result(), 12) -SketchProjection_1 = Sketch_8.addProjection(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_1")) +SketchProjection_1 = Sketch_8.addProjection(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_5][ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_6]"), False) SketchLine_26 = SketchProjection_1.createdFeature() SketchConstraintCoincidence_48 = Sketch_8.setCoincident(SketchLine_22.startPoint(), SketchLine_26.result()) SketchConstraintCoincidence_48.setName("SketchConstraintCoincidence_49") -SketchLine_27 = Sketch_8.addLine(model.selection("EDGE", "ExtrusionCut_3_1/Modfied_2&Extrusion_1_1/Generated_Face_4")) +SketchLine_27 = Sketch_8.addLine(model.selection("EDGE", "[ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8]")) SketchConstraintCoincidence_49 = Sketch_8.setCoincident(SketchLine_22.startPoint(), SketchLine_27.result()) SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_50") model.do() -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_22f-SketchLine_23f-SketchLine_24f-SketchLine_25f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_8"), 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) -Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_1_1/Modfied_2")) -SketchLine_28 = Sketch_9.addLine(25, -45, 18.44853578320836, -63) -SketchLine_29 = Sketch_9.addLine(model.selection("EDGE", "ExtrusionFuse_1_1/Modfied_2&ExtrusionCut_4_1/Modfied_6")) +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_22r-SketchLine_23f-SketchLine_24f-SketchLine_25f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) +Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_1_1/Modified_Face&Sketch_1/SketchLine_9")) +SketchLine_28 = Sketch_9.addLine(25, -45, 18.44853578320833, -63) +SketchLine_29 = Sketch_9.addLine(model.selection("EDGE", "[ExtrusionFuse_1_1/Modified_Face&Sketch_1/SketchLine_9][ExtrusionCut_4_1/Modified_Face&Sketch_1/SketchLine_8]")) SketchConstraintCoincidence_50 = Sketch_9.setCoincident(SketchLine_28.endPoint(), SketchLine_29.result()) SketchConstraintCoincidence_50.setName("SketchConstraintCoincidence_51") -SketchLine_30 = Sketch_9.addLine(model.selection("EDGE", "ExtrusionCut_4_1/Modfied_9&ExtrusionFuse_1_1/Modfied_2")) +SketchLine_30 = Sketch_9.addLine(model.selection("EDGE", "[ExtrusionCut_4_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionFuse_1_1/Modified_Face&Sketch_1/SketchLine_9]")) SketchConstraintCoincidence_51 = Sketch_9.setCoincident(SketchLine_28.startPoint(), SketchLine_30.result()) SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_52") -SketchConstraintAngle_3 = Sketch_9.setAngle(SketchLine_28.result(), SketchLine_30.result(), 20) -SketchConstraintDistance_10 = Sketch_9.setDistance(SketchLine_28.startPoint(), SketchLine_29.result(), 18) -SketchLine_31 = Sketch_9.addLine(18.44853578320836, -63, 25, -63) +SketchConstraintAngle_3 = Sketch_9.setAngle(SketchLine_28.result(), SketchLine_30.result(), 20.00000000000009) +SketchConstraintDistance_10 = Sketch_9.setDistance(SketchLine_28.startPoint(), SketchLine_29.result(), 18, False) +SketchLine_31 = Sketch_9.addLine(18.44853578320833, -63, 25, -63) SketchConstraintCoincidence_52 = Sketch_9.setCoincident(SketchLine_28.endPoint(), SketchLine_31.startPoint()) SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_53") SketchConstraintCoincidence_53 = Sketch_9.setCoincident(SketchLine_29.startPoint(), SketchLine_31.endPoint()) @@ -258,16 +258,16 @@ SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_55") SketchConstraintCoincidence_55 = Sketch_9.setCoincident(SketchLine_28.startPoint(), SketchLine_32.endPoint()) SketchConstraintCoincidence_55.setName("SketchConstraintCoincidence_56") model.do() -ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchLine_28f-SketchLine_31f-SketchLine_32f")], model.selection(), model.selection(), 0, model.selection("FACE", "ExtrusionCut_4_1/Modfied_3"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) -Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modfied_1")) +ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchLine_28r-SketchLine_31f-SketchLine_32f")], model.selection(), model.selection(), 0, model.selection("FACE", "ExtrusionCut_4_1/Modified_Face&Sketch_1/SketchLine_5"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) +Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_8")) SketchCircle_5 = Sketch_10.addCircle(-6.000000000000002, 4.999999999999997, 5) -SketchLine_33 = Sketch_10.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_5_1/Modfied_1")) -SketchConstraintDistance_11 = Sketch_10.setDistance(SketchCircle_5.center(), SketchLine_33.result(), 30) -SketchLine_34 = Sketch_10.addLine(model.selection("EDGE", "ExtrusionCut_5_1/Modfied_2&ExtrusionCut_5_1/Modfied_1")) -SketchConstraintDistance_12 = Sketch_10.setDistance(SketchCircle_5.result(), SketchLine_34.result(), 9) +SketchLine_33 = Sketch_10.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_8]")) +SketchConstraintDistance_11 = Sketch_10.setDistance(SketchCircle_5.center(), SketchLine_33.result(), 30, False) +SketchLine_34 = Sketch_10.addLine(model.selection("EDGE", "[ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_9][ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_8]")) +SketchConstraintDistance_12 = Sketch_10.setDistance(SketchCircle_5.result(), SketchLine_34.result(), 9, False) SketchConstraintRadius_7 = Sketch_10.setRadius(SketchCircle_5.results()[1], "10/2") model.do() -ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_10/Face-SketchCircle_5_2f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) +ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_10/Face-SketchCircle_5_2r")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) model.do() # Test reexecution after parameter change diff --git a/test.models/angle30.py b/test.models/angle30.py index 5a37ad7d3..020917c8a 100644 --- a/test.models/angle30.py +++ b/test.models/angle30.py @@ -129,7 +129,7 @@ SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_13.startPoint SketchConstraintHorizontal_2 = Sketch_3.setHorizontal(SketchLine_16.result()) SketchConstraintVertical_3 = Sketch_3.setVertical(SketchLine_15.result()) SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_13.result()) -SketchLine_17 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")) +SketchLine_17 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/SketchLine_4")) SketchConstraintParallel_2 = Sketch_3.setParallel(SketchLine_14.result(), SketchLine_17.result()) SketchConstraintDistance_6 = Sketch_3.setDistance(SketchLine_14.endPoint(), SketchLine_17.result(), 1, False) SketchLine_18 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OZ")) @@ -138,7 +138,7 @@ SketchConstraintDistance_8 = Sketch_3.setDistance(SketchLine_13.startPoint(), Sk SketchLine_19 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OY")) SketchConstraintDistance_9 = Sketch_3.setDistance(SketchLine_15.endPoint(), SketchLine_19.result(), 70, False) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f")], model.selection(), 75, 45) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r-SketchCircle_2_2r_wire")], model.selection(), 75, 45) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 22, 22) Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) Sketch_4 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) @@ -298,7 +298,7 @@ SketchConstraintCoincidence_51 = Sketch_4.setCoincident(SketchLine_36.startPoint SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_57") SketchConstraintCoincidence_52 = Sketch_4.setCoincident(SketchLine_25.startPoint(), SketchLine_34.endPoint()) SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_58") -SketchCircle_3 = Sketch_4.addCircle(model.selection("EDGE", "Sketch_2/Edge-SketchCircle_1_2")) +SketchCircle_3 = Sketch_4.addCircle(model.selection("EDGE", "Sketch_2/SketchCircle_1_2")) SketchConstraintCoincidence_53 = Sketch_4.setCoincident(SketchLine_22.startPoint(), SketchCircle_3.results()[1]) SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_59") SketchConstraintCoincidence_54 = Sketch_4.setCoincident(SketchArc_4.endPoint(), SketchCircle_3.results()[1]) @@ -379,18 +379,18 @@ Sketch_5 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchLine_38 = Sketch_5.addLine(44, 3.464101615137744, 16.50000000000003, 51.09549882328188) SketchLine_38.setName("SketchLine_41") SketchLine_38.result().setName("SketchLine_41") -SketchPoint_5 = Sketch_5.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s-SketchLine_4e")) +SketchPoint_5 = Sketch_5.addPoint(model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex")) SketchConstraintCoincidence_69 = Sketch_5.setCoincident(SketchLine_38.startPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_69.setName("SketchConstraintCoincidence_73") -SketchLine_39 = Sketch_5.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")) +SketchLine_39 = Sketch_5.addLine(model.selection("EDGE", "Sketch_1/SketchLine_4")) SketchLine_39.setName("SketchLine_42") SketchLine_39.result().setName("SketchLine_42") SketchConstraintPerpendicular_2 = Sketch_5.setPerpendicular(SketchLine_38.result(), SketchLine_39.result()) SketchConstraintLength_1 = Sketch_5.setLength(SketchLine_38.result(), 55) SketchConstraintLength_1.setName("SketchConstraintLength_6") model.do() -Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_10r-SketchLine_11r-SketchLine_8r-SketchLine_3r-SketchLine_9r-SketchLine_6r-SketchArc_1_2r-SketchArc_2_2f"), model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_5s-SketchLine_4e")) -Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Sketch_5/Vertex-SketchLine_41e"), False) +Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_8r-SketchArc_1_2r-SketchLine_9r-SketchLine_3r-SketchLine_11r-SketchArc_2_2f-SketchLine_10r"), model.selection("VERTEX", "Sketch_1/SketchLine_4_EndVertex")) +Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Axis_1"), model.selection("VERTEX", "Sketch_5/SketchLine_41_EndVertex"), False) Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_40 = Sketch_6.addLine(3.999999999999999, 13.00000000002605, 4, 12.89999999999998) SketchLine_40.setName("SketchLine_55") @@ -459,7 +459,7 @@ SketchConstraintDistance_20 = Sketch_6.setDistance(SketchLine_48.startPoint(), S SketchConstraintDistance_20.setName("SketchConstraintDistance_20") SketchConstraintDistance_21 = Sketch_6.setDistance(SketchLine_51.startPoint(), SketchLine_49.result(), 0.8, False) SketchConstraintDistance_21.setName("SketchConstraintDistance_21") -SketchLine_52 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_41")) +SketchLine_52 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/SketchLine_41")) SketchLine_52.setName("SketchLine_51") SketchLine_52.result().setName("SketchLine_51") SketchConstraintDistance_22 = Sketch_6.setDistance(SketchLine_45.startPoint(), SketchLine_52.result(), 4, False) @@ -517,23 +517,23 @@ SketchLine_53.result().setName("SketchLine_56") SketchConstraintCoincidence_90 = Sketch_6.setCoincident(SketchArc_12.startPoint(), SketchLine_53.result()) SketchConstraintCoincidence_90.setName("SketchConstraintCoincidence_94") model.do() -Extrusion_7 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchLine_55r-SketchLine_44r-SketchLine_52r-SketchLine_53r-SketchLine_54r-SketchLine_47r-SketchLine_48r-SketchLine_49r-SketchArc_12_2r-SketchArc_13_2r")], model.selection(), 0, 40) +Extrusion_7 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchArc_13_2r-SketchLine_54r-SketchLine_49r-SketchLine_48r-SketchLine_47r-SketchLine_53r-SketchArc_12_2r-SketchLine_52r-SketchLine_44r-SketchLine_55r")], model.selection(), 0, 40) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Common_1_1")], [model.selection("SOLID", "Common_2_1")]) Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Fuse_1_1")], [model.selection("SOLID", "Extrusion_7_1")]) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fuse_2_1")], [model.selection("SOLID", "Common_3_1")]) -Extrusion_8 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_10r-SketchLine_11r-SketchLine_8r-SketchLine_3r-SketchLine_9r-SketchLine_6r-SketchArc_1_2r-SketchArc_2_2f")], model.selection(), 55, 55) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_8_1/Generated_Face_1")) +Extrusion_8 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_6r-SketchLine_8r-SketchArc_1_2r-SketchLine_9r-SketchLine_3r-SketchLine_11r-SketchArc_2_2f-SketchLine_10r_wire")], model.selection(), 55, 55) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10")) SketchLine_54 = Sketch_7.addLine(55, -9.237604307034024, 55, -60) SketchLine_54.setName("SketchLine_66") SketchLine_54.result().setName("SketchLine_66") -SketchPoint_6 = Sketch_7.addPoint(model.selection("VERTEX", "Extrusion_8_1/Generated_Face_2&Extrusion_8_1/Generated_Face_1&Extrusion_8_1/To_Face_1")) +SketchPoint_6 = Sketch_7.addPoint(model.selection("VERTEX", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_8_1/To_Face]")) SketchLine_55 = Sketch_7.addLine(55, -9.237604307034024, 55, -70) SketchLine_55.setName("SketchLine_57") SketchLine_55.result().setName("SketchLine_57") SketchLine_55.setAuxiliary(True) SketchConstraintCoincidence_91 = Sketch_7.setCoincident(SketchLine_55.startPoint(), SketchPoint_6.result()) SketchConstraintCoincidence_91.setName("SketchConstraintCoincidence_95") -SketchPoint_7 = Sketch_7.addPoint(model.selection("VERTEX", "Extrusion_8_1/Generated_Face_8&Extrusion_8_1/Generated_Face_1&Extrusion_8_1/To_Face_1")) +SketchPoint_7 = Sketch_7.addPoint(model.selection("VERTEX", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_8_1/To_Face]")) SketchConstraintCoincidence_92 = Sketch_7.setCoincident(SketchLine_55.endPoint(), SketchPoint_7.result()) SketchConstraintCoincidence_92.setName("SketchConstraintCoincidence_96") SketchLine_56 = Sketch_7.addLine(45.00000000000001, -70, -45.00000000000001, -70) @@ -545,7 +545,7 @@ SketchLine_57.result().setName("SketchLine_58") SketchLine_57.setAuxiliary(True) SketchConstraintCoincidence_93 = Sketch_7.setCoincident(SketchLine_55.endPoint(), SketchLine_57.startPoint()) SketchConstraintCoincidence_93.setName("SketchConstraintCoincidence_97") -SketchPoint_8 = Sketch_7.addPoint(model.selection("VERTEX", "Extrusion_8_1/Generated_Face_8&Extrusion_8_1/Generated_Face_1&Extrusion_8_1/From_Face_1")) +SketchPoint_8 = Sketch_7.addPoint(model.selection("VERTEX", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_8_1/From_Face]")) SketchConstraintCoincidence_94 = Sketch_7.setCoincident(SketchLine_57.endPoint(), SketchPoint_8.result()) SketchConstraintCoincidence_94.setName("SketchConstraintCoincidence_98") SketchLine_58 = Sketch_7.addLine(-55.00000000000001, -59.99999999999999, -55, -9.237604307034024) @@ -557,7 +557,7 @@ SketchLine_59.result().setName("SketchLine_59") SketchLine_59.setAuxiliary(True) SketchConstraintCoincidence_95 = Sketch_7.setCoincident(SketchLine_57.endPoint(), SketchLine_59.startPoint()) SketchConstraintCoincidence_95.setName("SketchConstraintCoincidence_99") -SketchPoint_9 = Sketch_7.addPoint(model.selection("VERTEX", "Extrusion_8_1/Generated_Face_2&Extrusion_8_1/Generated_Face_1&Extrusion_8_1/From_Face_1")) +SketchPoint_9 = Sketch_7.addPoint(model.selection("VERTEX", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_8_1/From_Face]")) SketchConstraintCoincidence_96 = Sketch_7.setCoincident(SketchLine_59.endPoint(), SketchPoint_9.result()) SketchConstraintCoincidence_96.setName("SketchConstraintCoincidence_100") SketchLine_60 = Sketch_7.addLine(-55, -9.237604307034024, -60.00000000000001, -9.237604307034024) @@ -654,7 +654,7 @@ SketchCircle_7 = Sketch_7.addCircle(-44, -20.23760430703402, 5) SketchConstraintRadius_16 = Sketch_7.setRadius(SketchCircle_7.results()[1], 5) SketchConstraintDistance_31 = Sketch_7.setDistance(SketchCircle_6.center(), SketchLine_54.result(), 11, False) SketchConstraintDistance_31.setName("SketchConstraintDistance_31") -SketchLine_66 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_8_1/Generated_Face_2&Extrusion_8_1/Generated_Face_1")) +SketchLine_66 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_10]")) SketchLine_66.setName("SketchLine_69") SketchLine_66.result().setName("SketchLine_69") SketchConstraintDistance_32 = Sketch_7.setDistance(SketchCircle_6.center(), SketchLine_66.result(), 11, False) @@ -669,20 +669,20 @@ SketchConstraintLength_3 = Sketch_7.setLength(SketchLine_61.result(), 70) SketchConstraintLength_3.setName("SketchConstraintLength_8") SketchConstraintDistanceHorizontal_1 = Sketch_7.setHorizontalDistance(SketchPoint_7.coordinates(), SketchLine_62.endPoint(), 5) model.do() -ExtrusionCut_1_objects_1 = [model.selection("WIRE", "Sketch_7/Wire-SketchLine_66f-SketchLine_67f-SketchLine_68f-SketchLine_60f-SketchLine_61f-SketchLine_62f-SketchLine_63f-SketchLine_64f-SketchArc_14_2r-SketchArc_15_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_4_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_7_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_6_2f")] +ExtrusionCut_1_objects_1 = [model.selection("WIRE", "Sketch_7/Face-SketchLine_66r-SketchArc_14_2r-SketchLine_67f-SketchArc_15_2r-SketchLine_68f-SketchLine_60f-SketchLine_61f-SketchLine_62f-SketchLine_63f-SketchLine_64f_wire"), model.selection("FACE", "Sketch_7/Face-SketchCircle_4_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_5_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_7_2f"), model.selection("FACE", "Sketch_7/Face-SketchCircle_6_2f")] ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_1_objects_1, model.selection(), 0, 10, [model.selection("SOLID", "Extrusion_8_1")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_8_1/Generated_Face_3")) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11")) SketchLine_67 = Sketch_8.addLine(55, -34.06366588218793, 55, 66.69872981077805) SketchLine_67.setName("SketchLine_79") SketchLine_67.result().setName("SketchLine_79") -SketchPoint_10 = Sketch_8.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_3&Extrusion_8_1/Generated_Face_3&ExtrusionCut_1_1/Modfied_13")) +SketchPoint_10 = Sketch_8.addPoint(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_1_1/Generated_Face&Sketch_7/SketchLine_66)(Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_9)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3)]")) SketchLine_68 = Sketch_8.addLine(55, -34.06366588218793, 55, 76.69872981077803) SketchLine_68.setName("SketchLine_70") SketchLine_68.result().setName("SketchLine_70") SketchLine_68.setAuxiliary(True) SketchConstraintCoincidence_116 = Sketch_8.setCoincident(SketchLine_68.startPoint(), SketchPoint_10.result()) SketchConstraintCoincidence_116.setName("SketchConstraintCoincidence_120") -SketchPoint_11 = Sketch_8.addPoint(model.selection("VERTEX", "Extrusion_8_1/Generated_Face_3&ExtrusionCut_1_1/Modfied_13&Extrusion_8_1/Generated_Face_4")) +SketchPoint_11 = Sketch_8.addPoint(model.selection("VERTEX", "[Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_1_1/Generated_Face&Sketch_7/SketchLine_66)(Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_9)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3)][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3]")) SketchConstraintCoincidence_117 = Sketch_8.setCoincident(SketchLine_68.endPoint(), SketchPoint_11.result()) SketchConstraintCoincidence_117.setName("SketchConstraintCoincidence_121") SketchLine_69 = Sketch_8.addLine(45, 76.69872981077805, -44.9999999570576, 76.69872981077805) @@ -694,7 +694,7 @@ SketchLine_70.result().setName("SketchLine_71") SketchLine_70.setAuxiliary(True) SketchConstraintCoincidence_118 = Sketch_8.setCoincident(SketchLine_68.endPoint(), SketchLine_70.startPoint()) SketchConstraintCoincidence_118.setName("SketchConstraintCoincidence_122") -SketchPoint_12 = Sketch_8.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_1&Extrusion_8_1/Generated_Face_3&Extrusion_8_1/Generated_Face_4")) +SketchPoint_12 = Sketch_8.addPoint(model.selection("VERTEX", "[(ExtrusionCut_1_1/Generated_Face&Sketch_7/SketchLine_68)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_9)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3)][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3]")) SketchConstraintCoincidence_119 = Sketch_8.setCoincident(SketchLine_70.endPoint(), SketchPoint_12.result()) SketchConstraintCoincidence_119.setName("SketchConstraintCoincidence_123") SketchLine_71 = Sketch_8.addLine(-55, 66.69872976783566, -55, -34.06366588218793) @@ -706,7 +706,7 @@ SketchLine_72.result().setName("SketchLine_72") SketchLine_72.setAuxiliary(True) SketchConstraintCoincidence_120 = Sketch_8.setCoincident(SketchLine_70.endPoint(), SketchLine_72.startPoint()) SketchConstraintCoincidence_120.setName("SketchConstraintCoincidence_124") -SketchPoint_13 = Sketch_8.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_3&ExtrusionCut_1_1/Modfied_1&Extrusion_8_1/Generated_Face_3")) +SketchPoint_13 = Sketch_8.addPoint(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2][(ExtrusionCut_1_1/Generated_Face&Sketch_7/SketchLine_68)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchArc_2_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchArc_1_2)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_9)(Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_3)][Extrusion_8_1/Generated_Face&Sketch_1/SketchLine_11]")) SketchConstraintCoincidence_121 = Sketch_8.setCoincident(SketchLine_72.endPoint(), SketchPoint_13.result()) SketchConstraintCoincidence_121.setName("SketchConstraintCoincidence_125") SketchLine_73 = Sketch_8.addLine(-55, -34.06366588218793, -83.25521566485324, -34.06366588218793) @@ -846,7 +846,7 @@ SketchConstraintDistance_43.setName("SketchConstraintDistance_45") SketchConstraintDistance_44 = Sketch_8.setDistance(SketchArc_18.startPoint(), SketchLine_69.result(), 25, False) SketchConstraintDistance_44.setName("SketchConstraintDistance_46") model.do() -ExtrusionCut_2_objects_1 = [model.selection("FACE", "Sketch_8/Face-SketchLine_79r-SketchLine_80r-SketchLine_81r-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r-SketchLine_77r-SketchArc_16_2r-SketchArc_17_2r"), model.selection("WIRE", "Sketch_8/Wire-SketchCircle_8_2f"), model.selection("WIRE", "Sketch_8/Wire-SketchCircle_9_2f"), model.selection("WIRE", "Sketch_8/Wire-SketchArc_19_2f-SketchArc_18_2f-SketchLine_82f-SketchLine_83r")] +ExtrusionCut_2_objects_1 = [model.selection("FACE", "Sketch_8/Face-SketchLine_77r-SketchLine_76r-SketchLine_75r-SketchLine_74r-SketchLine_73r-SketchLine_81r-SketchArc_17_2r-SketchLine_80r-SketchArc_16_2r-SketchLine_79r"), model.selection("WIRE", "Sketch_8/Face-SketchCircle_8_2f_wire"), model.selection("WIRE", "Sketch_8/Face-SketchCircle_9_2f_wire"), model.selection("WIRE", "Sketch_8/Face-SketchArc_19_2f-SketchLine_82f-SketchArc_18_2f-SketchLine_83r_wire")] ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_2_objects_1, model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_1_1")]) Fuse_3 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("SOLID", "ExtrusionCut_2_1")]) model.do() @@ -864,8 +864,9 @@ model.testNbResults(Fuse_3, 1) model.testNbSubResults(Fuse_3, [0]) model.testNbSubShapes(Fuse_3, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Fuse_3, GeomAPI_Shape.FACE, [50]) -model.testNbSubShapes(Fuse_3, GeomAPI_Shape.EDGE, [266]) -model.testNbSubShapes(Fuse_3, GeomAPI_Shape.VERTEX, [532]) +# unstable numbers +#model.testNbSubShapes(Fuse_3, GeomAPI_Shape.EDGE, [266]) +#model.testNbSubShapes(Fuse_3, GeomAPI_Shape.VERTEX, [532]) model.testResultsVolumes(Fuse_3, [156999.209584889642428606748580933]) assert(model.checkPythonDump()) diff --git a/test.models/bearing_puller.py b/test.models/bearing_puller.py index 5a20aecd3..ce59dc0f9 100644 --- a/test.models/bearing_puller.py +++ b/test.models/bearing_puller.py @@ -98,15 +98,15 @@ SketchLine_7.result().setName("SketchLine_30") SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_7.result()) SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_35") model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_4r-SketchArc_1_2f-SketchArc_2_2f-SketchLine_28r-SketchLine_29r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_2")) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_2_2f-SketchArc_1_2f-SketchLine_4r-SketchLine_29r-SketchLine_28r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2")) SketchLine_8 = Sketch_2.addLine(0, 0, 25, 43.30127018922193) SketchLine_8.setName("SketchLine_5") SketchLine_8.result().setName("SketchLine_5") SketchLine_8.setAuxiliary(True) SketchPoint_3 = Sketch_2.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_8.startPoint(), SketchPoint_3.result()) -SketchCircle_1 = Sketch_2.addCircle(model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1")) +SketchCircle_1 = Sketch_2.addCircle(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1]")) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchCircle_1.results()[1]) SketchLine_9 = Sketch_2.addLine(39.43375672974064, -43.30127018922192, 15.87711932209923, -2.499977343709401) SketchLine_9.setName("SketchLine_10") @@ -116,7 +116,7 @@ SketchLine_10.setName("SketchLine_6") SketchLine_10.result().setName("SketchLine_6") SketchLine_10.setAuxiliary(True) SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchLine_10.startPoint(), SketchPoint_3.result()) -SketchCircle_2 = Sketch_2.addCircle(model.selection("EDGE", "Revolution_1_1/Generated_Face_2&Revolution_1_1/Generated_Face_1")) +SketchCircle_2 = Sketch_2.addCircle(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1]")) SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchCircle_2.results()[1]) SketchLine_11 = Sketch_2.addLine(15.87713238415337, 2.499999967850816, 39.43375672974065, 43.30127018922192) SketchLine_11.setName("SketchLine_11") @@ -229,10 +229,10 @@ SketchLine_22.result().setName("SketchLine_19") SketchConstraintDistance_9 = Sketch_2.setDistance(SketchArc_9.center(), SketchPoint_3.coordinates(), 21) SketchConstraintDistance_9.setName("SketchConstraintDistance_8") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_10r-SketchLine_11r-SketchArc_3_2f-SketchArc_4_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchLine_14r-SketchArc_7_2f-SketchLine_15r-SketchArc_8_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_12r-SketchArc_5_2f-SketchLine_13r-SketchArc_6_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_19f-SketchLine_20f-SketchLine_21f-SketchArc_10_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_16f-SketchLine_17f-SketchLine_18f-SketchArc_9_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchLine_22f-SketchLine_23f-SketchLine_24f-SketchArc_11_2f")], model.selection(), model.selection(), 10, model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 10) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchArc_4_2f-SketchLine_11r-SketchArc_3_2f-SketchLine_10r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchArc_7_2f-SketchLine_15r-SketchArc_8_2f-SketchLine_14r_wire"), model.selection("FACE", "Sketch_2/Face-SketchArc_5_2f-SketchLine_13r-SketchArc_6_2f-SketchLine_12r"), model.selection("FACE", "Sketch_2/Face-SketchLine_19f-SketchLine_20f-SketchLine_21f-SketchArc_10_2f"), model.selection("FACE", "Sketch_2/Face-SketchLine_16f-SketchLine_17f-SketchLine_18f-SketchArc_9_2f"), model.selection("WIRE", "Sketch_2/Face-SketchLine_22f-SketchLine_23f-SketchLine_24f-SketchArc_11_2f_wire")], model.selection(), model.selection(), 10, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_4"), 10) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_4"), model.selection("SOLID", "Extrusion_1_5")]) Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("SOLID", "Extrusion_1_2"), model.selection("SOLID", "Extrusion_1_3"), model.selection("SOLID", "Extrusion_1_6")]) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Cut_2_1/Modified_Face_7"), model.selection("FACE", "Cut_2_1/Modified_Face_9")) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_2/SketchLine_21"), model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_2/SketchLine_19")) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchCircle_3 = Sketch_3.addCircle(25, -10, 4) SketchCircle_4 = Sketch_3.addCircle(40, -10, 4) @@ -245,7 +245,7 @@ SketchConstraintDistance_10 = Sketch_3.setDistance(SketchCircle_3.center(), Sket SketchConstraintDistance_10.setName("SketchConstraintDistance_9") SketchConstraintDistance_11 = Sketch_3.setDistance(SketchCircle_4.center(), SketchLine_28.result(), 40) SketchConstraintDistance_11.setName("SketchConstraintDistance_10") -SketchProjection_1 = Sketch_3.addProjection(model.selection("EDGE", "Cut_2_1/Modified_Face_divided_20_e_15_1"), False) +SketchProjection_1 = Sketch_3.addProjection(model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_2/SketchLine_21&Sketch_1/SketchLine_2"), False) SketchLine_29 = SketchProjection_1.createdFeature() SketchLine_29.setName("SketchLine_26") SketchLine_29.result().setName("SketchLine_26") @@ -254,7 +254,7 @@ SketchConstraintDistance_12.setName("SketchConstraintDistance_11") SketchConstraintDistance_13 = Sketch_3.setDistance(SketchCircle_3.center(), SketchLine_29.result(), 10) SketchConstraintDistance_13.setName("SketchConstraintDistance_12") model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_3_2f"), model.selection("WIRE", "Sketch_3/Wire-SketchCircle_4_2f")], model.selection(), model.selection("FACE", "Cut_1_1/Modified_Face_6"), 5, model.selection("FACE", "Cut_1_1/Modified_Face_8"), 5) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_3_2r"), model.selection("WIRE", "Sketch_3/Face-SketchCircle_4_2f_wire")], model.selection(), model.selection("FACE", "Cut_1_1/Modified_Face&Sketch_2/SketchLine_11"), 5, model.selection("FACE", "Cut_1_1/Modified_Face&Sketch_2/SketchLine_13"), 5) Cut_3 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_2_1")], [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2")]) Recover_1 = model.addRecover(Part_1_doc, Cut_3, [Extrusion_2.results()[1], Extrusion_2.result()]) Rotation_1 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Recover_1_1"), model.selection("SOLID", "Recover_1_2")], model.selection("EDGE", "PartSet/OZ"), 120) @@ -496,15 +496,15 @@ SketchConstraintCoincidence_97 = Sketch_5.setCoincident(SketchLine_49.endPoint() SketchConstraintCoincidence_97.setName("SketchConstraintCoincidence_75") SketchConstraintDistance_19 = Sketch_5.setDistance(SketchLine_49.endPoint(), SketchLine_41.result(), 10) model.do() -Face_1 = model.addFace(Part_2_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_1_2f-SketchArc_4_2f-SketchArc_5_2f-SketchArc_6_2f-SketchArc_7_2f-SketchArc_8_2f-SketchArc_9_2f-SketchArc_10_2f")]) -Axis_4 = model.addAxis(Part_2_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("VERTEX", "Sketch_2/Vertex-SketchArc_3-SketchLine_20s")) +Face_1 = model.addFace(Part_2_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_7_2f-SketchArc_8_2f-SketchArc_9_2f-SketchArc_10_2f-SketchArc_6_2f-SketchArc_5_2f-SketchArc_4_2f_wire")]) +Axis_4 = model.addAxis(Part_2_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("VERTEX", "Sketch_2/SketchArc_3")) Rotation_3 = model.addRotation(Part_2_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "Axis_1"), -43.8752) -Pipe_1 = model.addPipe(Part_2_doc, [model.selection("FACE", "Rotation_1_1")], model.selection("EDGE", "Sketch_2/Edge-SketchArc_3_2")) -Extrusion_3 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_2_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchLine_14r-SketchLine_15r-SketchLine_16r-SketchLine_17r")], model.selection(), "Gap/2", "Gap/2") +Pipe_1 = model.addPipe(Part_2_doc, [model.selection("FACE", "Rotation_1_1")], model.selection("EDGE", "Sketch_2/SketchArc_3_2")) +Extrusion_3 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_2_2f-SketchCircle_3_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchLine_17r-SketchLine_16r-SketchLine_15r-SketchLine_14r_wire")], model.selection(), "Gap/2", "Gap/2") Fuse_1 = model.addFuse(Part_2_doc, [model.selection("SOLID", "Pipe_1_1")], [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) Extrusion_4 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f")], model.selection(), "Gap", "Gap") Cut_1 = model.addCut(Part_2_doc, [model.selection("SOLID", "Fuse_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) -Translation_1 = model.addTranslation(Part_2_doc, [model.selection("SOLID", "Cut_1_1")], model.selection("VERTEX", "Sketch_2/Edge-SketchCircle_2_2__cc"), model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_21e")) +Translation_1 = model.addTranslation(Part_2_doc, [model.selection("SOLID", "Cut_1_1")], model.selection("VERTEX", "Sketch_2/SketchCircle_2_2__cc"), model.selection("VERTEX", "Sketch_2/SketchLine_21_EndVertex")) model.do() Part_3 = model.duplicatePart(Part_2) Part_3.setName("Arm 2") @@ -547,11 +547,11 @@ SketchConstraintCoincidence_238 = Sketch_10.setCoincident(SketchPoint_7.coordina SketchLine_99 = Sketch_10.addLine(model.selection("EDGE", "PartSet/OY")) SketchConstraintDistance_35 = Sketch_10.setDistance(SketchLine_98.endPoint(), SketchLine_99.result(), "Thickness") model.do() -Revolution_2 = model.addRevolution(Part_5_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r-SketchLine_5r-SketchLine_6r")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_6"), 360, 0) -Sketch_11 = model.addSketch(Part_5_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) +Revolution_2 = model.addRevolution(Part_5_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection("EDGE", "Sketch_1/SketchLine_6"), 360, 0) +Sketch_11 = model.addSketch(Part_5_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1")) SketchCircle_14 = Sketch_11.addCircle(0, 0, 8.5) SketchCircle_14.setAuxiliary(True) -SketchPoint_8 = Sketch_11.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_6e")) +SketchPoint_8 = Sketch_11.addPoint(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")) SketchConstraintCoincidence_239 = Sketch_11.setCoincident(SketchCircle_14.center(), SketchPoint_8.result()) SketchConstraintRadius_18 = Sketch_11.setRadius(SketchCircle_14.results()[1], "(Rod+5)/2") SketchLine_100 = Sketch_11.addLine(-8.5, -4.907477288111821, -8.5, 4.907477288111821) @@ -579,7 +579,7 @@ SketchConstraintEqual_8 = Sketch_11.setEqual(SketchLine_101.result(), SketchLine SketchConstraintEqual_9 = Sketch_11.setEqual(SketchLine_102.result(), SketchLine_103.result()) SketchConstraintEqual_10 = Sketch_11.setEqual(SketchLine_103.result(), SketchLine_104.result()) model.do() -Extrusion_9 = model.addExtrusion(Part_5_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_8r-SketchLine_9r-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_13r")], model.selection(), 25, 0) +Extrusion_9 = model.addExtrusion(Part_5_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_10r-SketchLine_9r-SketchLine_8r")], model.selection(), 25, 0) Sketch_12 = model.addSketch(Part_5_doc, model.standardPlane("YOZ")) SketchLine_106 = Sketch_12.addLine(9.814954576223595, 48.99999999999999, 9.814954576223595, 52.35726558990813) SketchLine_107 = Sketch_12.addLine(9.814954576223595, 52.35726558990813, 4, 52.35726558990813) @@ -590,15 +590,15 @@ SketchConstraintCoincidence_248 = Sketch_12.setCoincident(SketchLine_106.startPo SketchConstraintHorizontal_20 = Sketch_12.setHorizontal(SketchLine_107.result()) SketchConstraintVertical_20 = Sketch_12.setVertical(SketchLine_106.result()) SketchConstraintAngle_8 = Sketch_12.setAngle(SketchLine_108.result(), SketchLine_107.result(), 30) -SketchLine_109 = Sketch_12.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_3")) +SketchLine_109 = Sketch_12.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_10][Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_9]")) SketchConstraintCoincidence_249 = Sketch_12.setCoincident(SketchLine_108.endPoint(), SketchLine_109.result()) -SketchProjection_2 = Sketch_12.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1")) +SketchProjection_2 = Sketch_12.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_2/SketchLine_10][Extrusion_1_1/To_Face]"), False) SketchLine_110 = SketchProjection_2.createdFeature() SketchConstraintDistance_36 = Sketch_12.setDistance(SketchLine_110.result(), SketchLine_108.endPoint(), 1) SketchLine_111 = Sketch_12.addLine(model.selection("EDGE", "PartSet/OZ")) SketchConstraintDistance_37 = Sketch_12.setDistance(SketchLine_108.startPoint(), SketchLine_111.result(), 4) model.do() -Revolution_3 = model.addRevolution(Part_5_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_14f-SketchLine_15f-SketchLine_16f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Revolution_3 = model.addRevolution(Part_5_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_14r-SketchLine_15f-SketchLine_16f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) Cut_12 = model.addCut(Part_5_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_2_1")]) Cut_13 = model.addFuse(Part_5_doc, [model.selection("SOLID", "Cut_1_1"), model.selection("SOLID", "Revolution_1_1")], []) diff --git a/test.models/bobine_film_reel.py b/test.models/bobine_film_reel.py index 1fade828a..5a9600e24 100644 --- a/test.models/bobine_film_reel.py +++ b/test.models/bobine_film_reel.py @@ -43,8 +43,8 @@ SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.coordinates SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1]) model.do() Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "h", 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_2 = SketchProjection_1.createdFeature() SketchCircle_2 = Sketch_2.addCircle(0, 0, 33.5) SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], "R2") @@ -53,16 +53,16 @@ SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_14") model.do() Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), "h2", 0) Extrusion_3 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2*3", 0) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_1")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face")) SketchCircle_3 = Sketch_3.addCircle(0, 0, 28.25) SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_3.results()[1], 28.25) -SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_3 = SketchProjection_2.createdFeature() SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchCircle_3.center(), SketchAPI_Line(SketchLine_3).startPoint()) Extrusion_3.setNestedSketch(Sketch_3) Extrusion_4 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face_1")) -SketchProjection_3 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face")) +SketchProjection_3 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_4 = SketchProjection_3.createdFeature() SketchCircle_4 = Sketch_4.addCircle(0, 0, 25.9) SketchConstraintRadius_4 = Sketch_4.setRadius(SketchCircle_4.results()[1], "R3") @@ -70,8 +70,8 @@ SketchConstraintCoincidence_7 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_15") Extrusion_4.setNestedSketch(Sketch_4) Extrusion_5 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_4_1/To_Face_1")) -SketchProjection_4 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_4_1/To_Face")) +SketchProjection_4 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_5 = SketchProjection_4.createdFeature() SketchCircle_5 = Sketch_5.addCircle(0, 0, 8) SketchConstraintRadius_5 = Sketch_5.setRadius(SketchCircle_5.results()[1], 8) @@ -79,15 +79,15 @@ SketchConstraintCoincidence_8 = Sketch_5.setCoincident(SketchAPI_Line(SketchLine SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_16") Extrusion_5.setNestedSketch(Sketch_5) Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1"), model.selection("SOLID", "Extrusion_5_1"), model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_3_1")], []) -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Extrusion_5_1/To_Face_1"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")]) -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face_1")) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Extrusion_5_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face")) SketchCircle_6 = Sketch_6.addCircle(0, 0, 4.2) SketchConstraintRadius_6 = Sketch_6.setRadius(SketchCircle_6.results()[1], 4.2) SketchPoint_2 = Sketch_6.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchConstraintCoincidence_9 = Sketch_6.setCoincident(SketchPoint_2.coordinates(), SketchCircle_6.center()) SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_17") ExtrusionCut_1.setNestedSketch(Sketch_6) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_2")) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face")) SketchCircle_7 = Sketch_7.addCircle(0, -85, 66) SketchLine_6 = Sketch_7.addLine(model.selection("EDGE", "PartSet/OY")) SketchConstraintCoincidence_10 = Sketch_7.setCoincident(SketchCircle_7.center(), SketchLine_6.result()) @@ -96,8 +96,8 @@ SketchConstraintDistance_1 = Sketch_7.setDistance(SketchCircle_7.center(), Sketc SketchMultiRotation_1 = Sketch_7.addRotation([SketchCircle_7.results()[1]], SketchLine_6.startPoint(), 120, 3) [SketchCircle_8, SketchCircle_9] = SketchMultiRotation_1.rotated() model.do() -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_1"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_1")) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_5_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face")) SketchLine_7 = Sketch_8.addLine(-2.320957096353877e-016, 11.00000001704673, -7, 11.00000001704673) SketchConstraintHorizontal_1 = Sketch_8.setHorizontal(SketchLine_7.result()) SketchLine_8 = Sketch_8.addLine(-7, 11.00000001704673, -6.329882773485103e-016, 30.00000001704673) @@ -126,7 +126,8 @@ SketchLine_14.result().setName("SketchLine_13") SketchLine_13.setName("SketchLine_16") SketchLine_13.result().setName("SketchLine_16") model.do() -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_7r-SketchLine_8r-SketchLine_10f-SketchLine_11f"), model.selection("FACE", "Sketch_8/Face-SketchLine_16f-SketchLine_17f-SketchLine_18r-SketchLine_19r"), model.selection("FACE", "Sketch_8/Face-SketchLine_12f-SketchLine_13f-SketchLine_14r-SketchLine_15r")], model.selection(), model.selection("FACE", "ExtrusionCut_2_1/Modfied_3"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionCut_3_objects_1 = [model.selection("FACE", "Sketch_8/Face-SketchLine_10f-SketchLine_11f-SketchLine_8r-SketchLine_7r"), model.selection("FACE", "Sketch_8/Face-SketchLine_16f-SketchLine_18r-SketchLine_19r-SketchLine_17f"), model.selection("FACE", "Sketch_8/Face-SketchLine_12f-SketchLine_14r-SketchLine_15r-SketchLine_13f")] +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_3_objects_1, model.selection(), model.selection("FACE", "ExtrusionCut_2_1/Modified_Face&Extrusion_4_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) # Test reexecution after parameter change Parameter_R.setValue(50) diff --git a/test.models/bracket32.py b/test.models/bracket32.py index de8e95449..cc5b65b01 100644 --- a/test.models/bracket32.py +++ b/test.models/bracket32.py @@ -389,7 +389,7 @@ SketchConstraintRadius_8 = Sketch_3.setRadius(SketchCircle_2.results()[1], "TDE/ SketchConstraintRadius_8.setName("SketchConstraintRadius_2") SketchConstraintDistance_15 = Sketch_3.setDistance(SketchCircle_2.center(), SketchCircle_1.center(), 30) SketchConstraintDistance_15.setName("SketchConstraintDistance_9") -SketchLine_36 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchLine_36 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_36.setName("SketchLine_25") SketchLine_36.result().setName("SketchLine_25") SketchConstraintDistance_16 = Sketch_3.setDistance(SketchCircle_1.center(), SketchLine_36.result(), 85) @@ -398,10 +398,10 @@ model.do() Sketch_4 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchCircle_3 = Sketch_4.addCircle(0, 85, 7) SketchCircle_4 = Sketch_4.addCircle(0, 55, 7) -SketchPoint_1 = Sketch_4.addPoint(model.selection("VERTEX", "Sketch_3/Edge-SketchCircle_1_2__cc")) +SketchPoint_1 = Sketch_4.addPoint(model.selection("VERTEX", "Sketch_3/SketchCircle_1_2__cc")) SketchConstraintCoincidence_61 = Sketch_4.setCoincident(SketchPoint_1.coordinates(), SketchCircle_3.center()) SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_19") -SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "Sketch_3/Edge-SketchCircle_2_2__cc")) +SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "Sketch_3/SketchCircle_2_2__cc")) SketchConstraintCoincidence_62 = Sketch_4.setCoincident(SketchPoint_2.coordinates(), SketchCircle_4.center()) SketchConstraintCoincidence_62.setName("SketchConstraintCoincidence_20") SketchConstraintRadius_9 = Sketch_4.setRadius(SketchCircle_3.results()[1], "TDI/2") @@ -436,7 +436,7 @@ SketchConstraintMirror_2.setName("SketchConstraintMirror_3") model.do() Sketch_6 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) SketchCircle_9 = Sketch_6.addCircle(30, -41, 4) -SketchPoint_3 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/Edge-SketchCircle_5_2__cc")) +SketchPoint_3 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/SketchCircle_5_2__cc")) SketchConstraintCoincidence_63 = Sketch_6.setCoincident(SketchPoint_3.coordinates(), SketchCircle_9.center()) SketchConstraintCoincidence_63.setName("SketchConstraintCoincidence_21") SketchConstraintRadius_12 = Sketch_6.setRadius(SketchCircle_9.results()[1], "BHD/2") @@ -457,7 +457,7 @@ model.do() Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 30, False) Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_41 = Sketch_7.addLine(-41, 0, -41, 8) -SketchPoint_4 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_5/Edge-SketchCircle_5_2__cc")) +SketchPoint_4 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_5/SketchCircle_5_2__cc")) SketchConstraintCoincidence_64 = Sketch_7.setCoincident(SketchLine_41.startPoint(), SketchPoint_4.result()) SketchConstraintCoincidence_64.setName("SketchConstraintCoincidence_34") SketchLine_42 = Sketch_7.addLine(-41, 8, -34, 8) @@ -538,7 +538,7 @@ SketchConstraintCoincidence_77.setName("SketchConstraintCoincidence_47") SketchConstraintRadius_13 = Sketch_7.setRadius(SketchArc_7.results()[1], "BHPFR") SketchConstraintRadius_13.setName("SketchConstraintRadius_8") model.do() -RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection("EDGE", "Sketch_7/Edge-SketchLine_41"), 360, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection("EDGE", "Sketch_7/SketchLine_41"), 360, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_49 = Sketch_8.addLine(32, 6, 32.50001476412091, 6.000000000000001) SketchLine_49.setName("SketchLine_55") @@ -546,7 +546,7 @@ SketchLine_49.result().setName("SketchLine_55") SketchLine_50 = Sketch_8.addLine(32, 0, 41, 0) SketchLine_50.setName("SketchLine_49") SketchLine_50.result().setName("SketchLine_49") -SketchPoint_5 = Sketch_8.addPoint(model.selection("VERTEX", "Sketch_6/Edge-SketchCircle_10_2__cc")) +SketchPoint_5 = Sketch_8.addPoint(model.selection("VERTEX", "Sketch_6/SketchCircle_10_2__cc")) SketchConstraintCoincidence_78 = Sketch_8.setCoincident(SketchLine_50.endPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_78.setName("SketchConstraintCoincidence_50") SketchLine_51 = Sketch_8.addLine(41, 0, 41, 8) @@ -634,7 +634,7 @@ SketchConstraintCoincidence_94.setName("SketchConstraintCoincidence_66") SketchConstraintRadius_14 = Sketch_8.setRadius(SketchArc_8.results()[1], 1.5) SketchConstraintRadius_14.setName("SketchConstraintRadius_9") model.do() -RevolutionFuse_2 = model.addRevolutionFuse(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_55r-SketchLine_49f-SketchLine_50f-SketchLine_56r-SketchLine_52f-SketchLine_53f-SketchArc_7_2r")], model.selection("EDGE", "Sketch_8/Edge-SketchLine_50"), 360, 0, [model.selection("SOLID", "RevolutionFuse_1_1")]) +RevolutionFuse_2 = model.addRevolutionFuse(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_52f-SketchLine_49f-SketchLine_50f-SketchLine_53f-SketchLine_56r-SketchArc_7_2r-SketchLine_55r")], model.selection("EDGE", "Sketch_8/SketchLine_50"), 360, 0, [model.selection("SOLID", "RevolutionFuse_1_1")]) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 30, True) Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) SketchLine_57 = Sketch_9.addLine(-32.50001494742042, 5.999999999999998, -32, 6) @@ -643,7 +643,7 @@ SketchLine_57.result().setName("SketchLine_63") SketchLine_58 = Sketch_9.addLine(-32, 0, -41, 0) SketchLine_58.setName("SketchLine_57") SketchLine_58.result().setName("SketchLine_57") -SketchPoint_8 = Sketch_9.addPoint(model.selection("VERTEX", "Sketch_6/Edge-SketchCircle_11_2__cc")) +SketchPoint_8 = Sketch_9.addPoint(model.selection("VERTEX", "Sketch_6/SketchCircle_11_2__cc")) SketchConstraintCoincidence_95 = Sketch_9.setCoincident(SketchLine_58.endPoint(), SketchPoint_8.result()) SketchConstraintCoincidence_95.setName("SketchConstraintCoincidence_67") SketchLine_59 = Sketch_9.addLine(-41, 0, -41, 7.999999999999999) @@ -738,7 +738,7 @@ SketchLine_65.result().setName("SketchLine_71") SketchLine_66 = Sketch_10.addLine(32, 0, 41, 0) SketchLine_66.setName("SketchLine_65") SketchLine_66.result().setName("SketchLine_65") -SketchPoint_11 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_6/Edge-SketchCircle_12_2__cc")) +SketchPoint_11 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_6/SketchCircle_12_2__cc")) SketchConstraintCoincidence_112 = Sketch_10.setCoincident(SketchLine_66.endPoint(), SketchPoint_11.result()) SketchConstraintCoincidence_112.setName("SketchConstraintCoincidence_84") SketchLine_67 = Sketch_10.addLine(41, 0, 41, 7.999999999999999) @@ -826,9 +826,9 @@ SketchConstraintCoincidence_128.setName("SketchConstraintCoincidence_100") SketchConstraintRadius_16 = Sketch_10.setRadius(SketchArc_10.results()[1], 1.5) SketchConstraintRadius_16.setName("SketchConstraintRadius_11") model.do() -RevolutionFuse_3 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection("EDGE", "Sketch_9/Edge-SketchLine_58"), 360, 0, [model.selection("SOLID", "RevolutionFuse_2_1")]) -RevolutionFuse_4 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_10")], model.selection("EDGE", "Sketch_10/Edge-SketchLine_66"), 360, 0, [model.selection("SOLID", "RevolutionFuse_3_1")]) -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchCircle_11_2f"), model.selection("FACE", "Sketch_6/Face-SketchCircle_9_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchCircle_10_2f"), model.selection("FACE", "Sketch_6/Face-SketchCircle_12_2f")], model.selection("EDGE", "PartSet/OZ"), "BPS+5", 5, [model.selection("SOLID", "RevolutionFuse_4_1")]) +RevolutionFuse_3 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection("EDGE", "Sketch_9/SketchLine_58"), 360, 0, [model.selection("SOLID", "RevolutionFuse_2_1")]) +RevolutionFuse_4 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_10")], model.selection("EDGE", "Sketch_10/SketchLine_66"), 360, 0, [model.selection("SOLID", "RevolutionFuse_3_1")]) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchCircle_11_2f"), model.selection("FACE", "Sketch_6/Face-SketchCircle_9_2r"), model.selection("WIRE", "Sketch_6/Face-SketchCircle_10_2f_wire"), model.selection("FACE", "Sketch_6/Face-SketchCircle_12_2f")], model.selection("EDGE", "PartSet/OZ"), "BPS+5", 5, [model.selection("SOLID", "RevolutionFuse_4_1")]) # Test reexecution after parameter change Parameter_BPS.setValue(3) diff --git a/test.models/bushing.py b/test.models/bushing.py index c3f15e14d..ed2831085 100644 --- a/test.models/bushing.py +++ b/test.models/bushing.py @@ -582,9 +582,9 @@ SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_55") SketchLine_379 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OY")) SketchConstraintDistance_13 = Sketch_3.setDistance(SketchCircle_4.center(), SketchLine_379.result(), 15) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_8f-SketchLine_9f-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_14f")], model.selection("EDGE", "PartSet/OX"), 360, 0) -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_1_2r-SketchLine_382f-SketchLine_383f-SketchLine_20f-SketchLine_22f-SketchLine_23f-SketchLine_24f-SketchLine_25f-SketchLine_26f-SketchLine_27f-SketchLine_28f-SketchLine_29f-SketchLine_30f-SketchLine_31f-SketchLine_32f-SketchLine_33f-SketchLine_34f-SketchLine_35f-SketchLine_36f-SketchLine_37f-SketchLine_38f-SketchLine_39f-SketchLine_40f-SketchLine_41f-SketchLine_42f-SketchLine_43f-SketchLine_44f-SketchLine_45f-SketchLine_46f-SketchLine_47f-SketchLine_48f-SketchLine_49f-SketchLine_50f-SketchLine_51f-SketchLine_52f-SketchLine_53f-SketchLine_54f-SketchLine_55f-SketchLine_56f-SketchLine_57f-SketchLine_58f-SketchLine_59f-SketchLine_60f-SketchLine_61f-SketchLine_62f-SketchLine_63f-SketchLine_64f-SketchLine_65f-SketchLine_66f-SketchLine_67f-SketchLine_68f-SketchLine_69f-SketchLine_70f-SketchLine_71f-SketchLine_72f-SketchLine_73f-SketchLine_74f-SketchLine_75f-SketchLine_76f-SketchLine_77f-SketchLine_78f-SketchLine_79f-SketchLine_80f-SketchLine_81f-SketchLine_82f-SketchLine_83f-SketchLine_84f-SketchLine_85f-SketchLine_86f-SketchLine_87f-SketchLine_88f-SketchLine_89f-SketchLine_90f-SketchLine_91f-SketchLine_92f-SketchLine_93f-SketchLine_94f-SketchLine_95f-SketchLine_96f-SketchLine_97f-SketchLine_98f-SketchLine_99f-SketchLine_100f-SketchLine_101f-SketchLine_102f-SketchLine_103f-SketchLine_104f-SketchLine_105f-SketchLine_106f-SketchLine_107f-SketchLine_108f-SketchLine_109f-SketchLine_110f-SketchLine_111f-SketchLine_112f-SketchLine_113f-SketchLine_114f-SketchLine_115f-SketchLine_116f-SketchLine_117f-SketchLine_118f-SketchLine_119f-SketchLine_120f-SketchLine_121f-SketchLine_122f-SketchLine_123f-SketchLine_124f-SketchLine_125f-SketchLine_126f-SketchLine_127f-SketchLine_128f-SketchLine_129f-SketchLine_130f-SketchLine_131f-SketchLine_132f-SketchLine_133f-SketchLine_134f-SketchLine_135f-SketchLine_136f-SketchLine_137f-SketchLine_138f-SketchLine_139f-SketchLine_140f-SketchLine_141f-SketchLine_142f-SketchLine_143f-SketchLine_144f-SketchLine_145f-SketchLine_146f-SketchLine_147f-SketchLine_148f-SketchLine_149f-SketchLine_150f-SketchLine_151f-SketchLine_152f-SketchLine_153f-SketchLine_154f-SketchLine_155f-SketchLine_156f-SketchLine_157f-SketchLine_158f-SketchLine_159f-SketchLine_160f-SketchLine_161f-SketchLine_162f-SketchLine_163f-SketchLine_164f-SketchLine_165f-SketchLine_166f-SketchLine_167f-SketchLine_168f-SketchLine_169f-SketchLine_170f-SketchLine_171f-SketchLine_172f-SketchLine_173f-SketchLine_174f-SketchLine_175f-SketchLine_176f-SketchLine_177f-SketchLine_178f-SketchLine_179f-SketchLine_180f-SketchLine_181f-SketchLine_182f-SketchLine_183f-SketchLine_184f-SketchLine_185f-SketchLine_186f-SketchLine_187f-SketchLine_188f-SketchLine_189f-SketchLine_190f-SketchLine_191f-SketchLine_192f-SketchLine_193f-SketchLine_194f-SketchLine_195f-SketchLine_196f-SketchLine_197f-SketchLine_198f-SketchLine_199f-SketchArc_2_2r-SketchArc_3_2r-SketchArc_4_2r-SketchArc_5_2r-SketchArc_6_2r-SketchArc_7_2r-SketchArc_8_2r-SketchArc_9_2r-SketchArc_10_2r-SketchArc_11_2r-SketchArc_12_2r-SketchArc_13_2r-SketchArc_14_2r-SketchArc_15_2r-SketchArc_16_2r-SketchArc_17_2r-SketchArc_18_2r-SketchArc_19_2r-SketchArc_20_2r-SketchArc_21_2r-SketchArc_22_2r-SketchArc_23_2r-SketchArc_24_2r-SketchArc_25_2r-SketchArc_26_2r-SketchArc_27_2r-SketchArc_28_2r-SketchArc_29_2r-SketchArc_30_2r-SketchArc_31_2r-SketchArc_32_2r-SketchArc_33_2r-SketchArc_34_2r-SketchArc_35_2r-SketchArc_36_2r-SketchArc_37_2r-SketchArc_38_2r-SketchArc_39_2r-SketchArc_40_2r-SketchArc_41_2r-SketchArc_42_2r-SketchArc_43_2r-SketchArc_44_2r-SketchArc_45_2r-SketchArc_46_2r-SketchArc_47_2r-SketchArc_48_2r-SketchArc_49_2r-SketchArc_50_2r-SketchArc_51_2r-SketchArc_52_2r-SketchArc_53_2r-SketchArc_54_2r-SketchArc_55_2r-SketchArc_56_2r-SketchArc_57_2r-SketchArc_58_2r-SketchArc_59_2r-SketchArc_60_2r-SketchArc_61_2r-SketchArc_62_2r-SketchArc_63_2r-SketchArc_64_2r-SketchArc_65_2r-SketchArc_66_2r-SketchArc_67_2r-SketchArc_68_2r-SketchArc_69_2r-SketchArc_70_2r-SketchArc_71_2r-SketchArc_72_2r-SketchArc_73_2r-SketchArc_74_2r-SketchArc_75_2r-SketchArc_76_2r-SketchArc_77_2r-SketchArc_78_2r-SketchArc_79_2r-SketchArc_80_2r-SketchArc_81_2r-SketchArc_82_2r-SketchArc_83_2r-SketchArc_84_2r-SketchArc_85_2r-SketchArc_86_2r-SketchArc_87_2r-SketchArc_88_2r-SketchArc_89_2r-SketchArc_90_2r-SketchArc_91_2r-SketchArc_92_2r-SketchArc_93_2r-SketchArc_94_2r-SketchArc_95_2r-SketchArc_96_2r-SketchArc_97_2r-SketchArc_98_2r-SketchArc_99_2r-SketchArc_100_2r-SketchArc_101_2r-SketchArc_102_2r-SketchArc_103_2r-SketchArc_104_2r-SketchArc_105_2r-SketchArc_106_2r-SketchArc_107_2r-SketchArc_108_2r-SketchArc_109_2r-SketchArc_110_2r-SketchArc_111_2r-SketchArc_112_2r-SketchArc_113_2r-SketchArc_114_2r-SketchArc_115_2r-SketchArc_116_2r-SketchArc_117_2r-SketchArc_118_2r-SketchArc_119_2r-SketchArc_120_2r-SketchArc_121_2r-SketchArc_122_2r-SketchArc_123_2r-SketchArc_124_2r-SketchArc_125_2r-SketchArc_126_2r-SketchArc_127_2r-SketchArc_128_2r-SketchArc_129_2r-SketchArc_130_2r-SketchArc_131_2r-SketchArc_132_2r-SketchArc_133_2r-SketchArc_134_2r-SketchArc_135_2r-SketchArc_136_2r-SketchArc_137_2r-SketchArc_138_2r-SketchArc_139_2r-SketchArc_140_2r-SketchArc_141_2r-SketchArc_142_2r-SketchArc_143_2r-SketchArc_144_2r-SketchArc_145_2r-SketchArc_146_2r-SketchArc_147_2r-SketchArc_148_2r-SketchArc_149_2r-SketchArc_150_2r-SketchArc_151_2r-SketchArc_152_2r-SketchArc_153_2r-SketchArc_154_2r-SketchArc_155_2r-SketchArc_156_2r-SketchArc_157_2r-SketchArc_158_2r-SketchArc_159_2r-SketchArc_160_2r-SketchArc_161_2r-SketchArc_162_2r-SketchArc_163_2r-SketchArc_164_2r-SketchArc_165_2r-SketchArc_166_2r-SketchArc_167_2r-SketchArc_168_2r-SketchArc_169_2r-SketchArc_170_2r-SketchArc_171_2r-SketchArc_172_2r-SketchArc_173_2r-SketchArc_174_2r-SketchArc_175_2r-SketchArc_176_2r-SketchArc_177_2r-SketchArc_178_2r-SketchArc_179_2r-SketchArc_180_2r-SketchLine_21f-SketchLine_200f-SketchLine_201f-SketchLine_202f-SketchLine_203f-SketchLine_204f-SketchLine_205f-SketchLine_206f-SketchLine_207f-SketchLine_208f-SketchLine_209f-SketchLine_210f-SketchLine_211f-SketchLine_212f-SketchLine_213f-SketchLine_214f-SketchLine_215f-SketchLine_216f-SketchLine_217f-SketchLine_218f-SketchLine_219f-SketchLine_220f-SketchLine_221f-SketchLine_222f-SketchLine_223f-SketchLine_224f-SketchLine_225f-SketchLine_226f-SketchLine_227f-SketchLine_228f-SketchLine_229f-SketchLine_230f-SketchLine_231f-SketchLine_232f-SketchLine_233f-SketchLine_234f-SketchLine_235f-SketchLine_236f-SketchLine_237f-SketchLine_238f-SketchLine_239f-SketchLine_240f-SketchLine_241f-SketchLine_242f-SketchLine_243f-SketchLine_244f-SketchLine_245f-SketchLine_246f-SketchLine_247f-SketchLine_248f-SketchLine_249f-SketchLine_250f-SketchLine_251f-SketchLine_252f-SketchLine_253f-SketchLine_254f-SketchLine_255f-SketchLine_256f-SketchLine_257f-SketchLine_258f-SketchLine_259f-SketchLine_260f-SketchLine_261f-SketchLine_262f-SketchLine_263f-SketchLine_264f-SketchLine_265f-SketchLine_266f-SketchLine_267f-SketchLine_268f-SketchLine_269f-SketchLine_270f-SketchLine_271f-SketchLine_272f-SketchLine_273f-SketchLine_274f-SketchLine_275f-SketchLine_276f-SketchLine_277f-SketchLine_278f-SketchLine_279f-SketchLine_280f-SketchLine_281f-SketchLine_282f-SketchLine_283f-SketchLine_284f-SketchLine_285f-SketchLine_286f-SketchLine_287f-SketchLine_288f-SketchLine_289f-SketchLine_290f-SketchLine_291f-SketchLine_292f-SketchLine_293f-SketchLine_294f-SketchLine_295f-SketchLine_296f-SketchLine_297f-SketchLine_298f-SketchLine_299f-SketchLine_300f-SketchLine_301f-SketchLine_302f-SketchLine_303f-SketchLine_304f-SketchLine_305f-SketchLine_306f-SketchLine_307f-SketchLine_308f-SketchLine_309f-SketchLine_310f-SketchLine_311f-SketchLine_312f-SketchLine_313f-SketchLine_314f-SketchLine_315f-SketchLine_316f-SketchLine_317f-SketchLine_318f-SketchLine_319f-SketchLine_320f-SketchLine_321f-SketchLine_322f-SketchLine_323f-SketchLine_324f-SketchLine_325f-SketchLine_326f-SketchLine_327f-SketchLine_328f-SketchLine_329f-SketchLine_330f-SketchLine_331f-SketchLine_332f-SketchLine_333f-SketchLine_334f-SketchLine_335f-SketchLine_336f-SketchLine_337f-SketchLine_338f-SketchLine_339f-SketchLine_340f-SketchLine_341f-SketchLine_342f-SketchLine_343f-SketchLine_344f-SketchLine_345f-SketchLine_346f-SketchLine_347f-SketchLine_348f-SketchLine_349f-SketchLine_350f-SketchLine_351f-SketchLine_352f-SketchLine_353f-SketchLine_354f-SketchLine_355f-SketchLine_356f-SketchLine_357f-SketchLine_358f-SketchLine_359f-SketchLine_360f-SketchLine_361f-SketchLine_362f-SketchLine_363f-SketchLine_364f-SketchLine_365f-SketchLine_366f-SketchLine_367f-SketchLine_368f-SketchLine_369f-SketchLine_370f-SketchLine_371f-SketchLine_372f-SketchLine_373f-SketchLine_374f-SketchLine_375f-SketchLine_376f-SketchLine_377f-SketchCircle_3_2f")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_4_2f")], model.selection(), 30, 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_12f-SketchLine_13f-SketchLine_14f-SketchLine_8f-SketchLine_9f-SketchLine_11f")], model.selection("EDGE", "PartSet/OX"), 360, 0) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_3_2f-SketchLine_383f-SketchLine_199f-SketchArc_180_2r-SketchLine_377f-SketchLine_198f-SketchArc_179_2r-SketchLine_376f-SketchLine_197f-SketchArc_178_2r-SketchLine_375f-SketchLine_196f-SketchArc_177_2r-SketchLine_374f-SketchLine_195f-SketchArc_176_2r-SketchLine_373f-SketchLine_194f-SketchArc_175_2r-SketchLine_372f-SketchLine_193f-SketchArc_174_2r-SketchLine_371f-SketchLine_192f-SketchArc_173_2r-SketchLine_370f-SketchLine_191f-SketchArc_172_2r-SketchLine_369f-SketchLine_190f-SketchArc_171_2r-SketchLine_368f-SketchLine_189f-SketchArc_170_2r-SketchLine_367f-SketchLine_188f-SketchArc_169_2r-SketchLine_366f-SketchLine_187f-SketchArc_168_2r-SketchLine_365f-SketchLine_186f-SketchArc_167_2r-SketchLine_364f-SketchLine_185f-SketchArc_166_2r-SketchLine_363f-SketchLine_184f-SketchArc_165_2r-SketchLine_362f-SketchLine_183f-SketchArc_164_2r-SketchLine_361f-SketchLine_182f-SketchArc_163_2r-SketchLine_360f-SketchLine_181f-SketchArc_162_2r-SketchLine_359f-SketchLine_180f-SketchArc_161_2r-SketchLine_358f-SketchLine_179f-SketchArc_160_2r-SketchLine_357f-SketchLine_178f-SketchArc_159_2r-SketchLine_356f-SketchLine_177f-SketchArc_158_2r-SketchLine_355f-SketchLine_176f-SketchArc_157_2r-SketchLine_354f-SketchLine_175f-SketchArc_156_2r-SketchLine_353f-SketchLine_174f-SketchArc_155_2r-SketchLine_352f-SketchLine_173f-SketchArc_154_2r-SketchLine_351f-SketchLine_172f-SketchArc_153_2r-SketchLine_350f-SketchLine_171f-SketchArc_152_2r-SketchLine_349f-SketchLine_170f-SketchArc_151_2r-SketchLine_348f-SketchLine_169f-SketchArc_150_2r-SketchLine_347f-SketchLine_168f-SketchArc_149_2r-SketchLine_346f-SketchLine_167f-SketchArc_148_2r-SketchLine_345f-SketchLine_166f-SketchArc_147_2r-SketchLine_344f-SketchLine_165f-SketchArc_146_2r-SketchLine_343f-SketchLine_164f-SketchArc_145_2r-SketchLine_342f-SketchLine_163f-SketchArc_144_2r-SketchLine_341f-SketchLine_162f-SketchArc_143_2r-SketchLine_340f-SketchLine_161f-SketchArc_142_2r-SketchLine_339f-SketchLine_160f-SketchArc_141_2r-SketchLine_338f-SketchLine_159f-SketchArc_140_2r-SketchLine_337f-SketchLine_158f-SketchArc_139_2r-SketchLine_336f-SketchLine_157f-SketchArc_138_2r-SketchLine_335f-SketchLine_156f-SketchArc_137_2r-SketchLine_334f-SketchLine_155f-SketchArc_136_2r-SketchLine_333f-SketchLine_154f-SketchArc_135_2r-SketchLine_332f-SketchLine_153f-SketchArc_134_2r-SketchLine_331f-SketchLine_152f-SketchArc_133_2r-SketchLine_330f-SketchLine_151f-SketchArc_132_2r-SketchLine_329f-SketchLine_150f-SketchArc_131_2r-SketchLine_328f-SketchLine_149f-SketchArc_130_2r-SketchLine_327f-SketchLine_148f-SketchArc_129_2r-SketchLine_326f-SketchLine_147f-SketchArc_128_2r-SketchLine_325f-SketchLine_146f-SketchArc_127_2r-SketchLine_324f-SketchLine_145f-SketchArc_126_2r-SketchLine_323f-SketchLine_144f-SketchArc_125_2r-SketchLine_322f-SketchLine_143f-SketchArc_124_2r-SketchLine_321f-SketchLine_142f-SketchArc_123_2r-SketchLine_320f-SketchLine_141f-SketchArc_122_2r-SketchLine_319f-SketchLine_140f-SketchArc_121_2r-SketchLine_318f-SketchLine_139f-SketchArc_120_2r-SketchLine_317f-SketchLine_138f-SketchArc_119_2r-SketchLine_316f-SketchLine_137f-SketchArc_118_2r-SketchLine_315f-SketchLine_136f-SketchArc_117_2r-SketchLine_314f-SketchLine_135f-SketchArc_116_2r-SketchLine_313f-SketchLine_134f-SketchArc_115_2r-SketchLine_312f-SketchLine_133f-SketchArc_114_2r-SketchLine_311f-SketchLine_132f-SketchArc_113_2r-SketchLine_310f-SketchLine_131f-SketchArc_112_2r-SketchLine_309f-SketchLine_130f-SketchArc_111_2r-SketchLine_308f-SketchLine_129f-SketchArc_110_2r-SketchLine_307f-SketchLine_128f-SketchArc_109_2r-SketchLine_306f-SketchLine_127f-SketchArc_108_2r-SketchLine_305f-SketchLine_126f-SketchArc_107_2r-SketchLine_304f-SketchLine_125f-SketchArc_106_2r-SketchLine_303f-SketchLine_124f-SketchArc_105_2r-SketchLine_302f-SketchLine_123f-SketchArc_104_2r-SketchLine_301f-SketchLine_122f-SketchArc_103_2r-SketchLine_300f-SketchLine_121f-SketchArc_102_2r-SketchLine_299f-SketchLine_120f-SketchArc_101_2r-SketchLine_298f-SketchLine_119f-SketchArc_100_2r-SketchLine_297f-SketchLine_118f-SketchArc_99_2r-SketchLine_296f-SketchLine_117f-SketchArc_98_2r-SketchLine_295f-SketchLine_116f-SketchArc_97_2r-SketchLine_294f-SketchLine_115f-SketchArc_96_2r-SketchLine_293f-SketchLine_114f-SketchArc_95_2r-SketchLine_292f-SketchLine_113f-SketchArc_94_2r-SketchLine_291f-SketchLine_112f-SketchArc_93_2r-SketchLine_290f-SketchLine_111f-SketchArc_92_2r-SketchLine_289f-SketchLine_110f-SketchArc_91_2r-SketchLine_288f-SketchLine_109f-SketchArc_90_2r-SketchLine_287f-SketchLine_108f-SketchArc_89_2r-SketchLine_286f-SketchLine_107f-SketchArc_88_2r-SketchLine_285f-SketchLine_106f-SketchArc_87_2r-SketchLine_284f-SketchLine_105f-SketchArc_86_2r-SketchLine_283f-SketchLine_104f-SketchArc_85_2r-SketchLine_282f-SketchLine_103f-SketchArc_84_2r-SketchLine_281f-SketchLine_102f-SketchArc_83_2r-SketchLine_280f-SketchLine_101f-SketchArc_82_2r-SketchLine_279f-SketchLine_100f-SketchArc_81_2r-SketchLine_278f-SketchLine_99f-SketchArc_80_2r-SketchLine_277f-SketchLine_98f-SketchArc_79_2r-SketchLine_276f-SketchLine_97f-SketchArc_78_2r-SketchLine_275f-SketchLine_96f-SketchArc_77_2r-SketchLine_274f-SketchLine_95f-SketchArc_76_2r-SketchLine_273f-SketchLine_94f-SketchArc_75_2r-SketchLine_272f-SketchLine_93f-SketchArc_74_2r-SketchLine_271f-SketchLine_92f-SketchArc_73_2r-SketchLine_270f-SketchLine_91f-SketchArc_72_2r-SketchLine_269f-SketchLine_90f-SketchArc_71_2r-SketchLine_268f-SketchLine_89f-SketchArc_70_2r-SketchLine_267f-SketchLine_88f-SketchArc_69_2r-SketchLine_266f-SketchLine_87f-SketchArc_68_2r-SketchLine_265f-SketchLine_86f-SketchArc_67_2r-SketchLine_264f-SketchLine_85f-SketchArc_66_2r-SketchLine_263f-SketchLine_84f-SketchArc_65_2r-SketchLine_262f-SketchLine_83f-SketchArc_64_2r-SketchLine_261f-SketchLine_82f-SketchArc_63_2r-SketchLine_260f-SketchLine_81f-SketchArc_62_2r-SketchLine_259f-SketchLine_80f-SketchArc_61_2r-SketchLine_258f-SketchLine_79f-SketchArc_60_2r-SketchLine_257f-SketchLine_78f-SketchArc_59_2r-SketchLine_256f-SketchLine_77f-SketchArc_58_2r-SketchLine_255f-SketchLine_76f-SketchArc_57_2r-SketchLine_254f-SketchLine_75f-SketchArc_56_2r-SketchLine_253f-SketchLine_74f-SketchArc_55_2r-SketchLine_252f-SketchLine_73f-SketchArc_54_2r-SketchLine_251f-SketchLine_72f-SketchArc_53_2r-SketchLine_250f-SketchLine_71f-SketchArc_52_2r-SketchLine_249f-SketchLine_70f-SketchArc_51_2r-SketchLine_248f-SketchLine_69f-SketchArc_50_2r-SketchLine_247f-SketchLine_68f-SketchArc_49_2r-SketchLine_246f-SketchLine_67f-SketchArc_48_2r-SketchLine_245f-SketchLine_66f-SketchArc_47_2r-SketchLine_244f-SketchLine_65f-SketchArc_46_2r-SketchLine_243f-SketchLine_64f-SketchArc_45_2r-SketchLine_242f-SketchLine_63f-SketchArc_44_2r-SketchLine_241f-SketchLine_62f-SketchArc_43_2r-SketchLine_240f-SketchLine_61f-SketchArc_42_2r-SketchLine_239f-SketchLine_60f-SketchArc_41_2r-SketchLine_238f-SketchLine_59f-SketchArc_40_2r-SketchLine_237f-SketchLine_58f-SketchArc_39_2r-SketchLine_236f-SketchLine_57f-SketchArc_38_2r-SketchLine_235f-SketchLine_56f-SketchArc_37_2r-SketchLine_234f-SketchLine_55f-SketchArc_36_2r-SketchLine_233f-SketchLine_54f-SketchArc_35_2r-SketchLine_232f-SketchLine_53f-SketchArc_34_2r-SketchLine_231f-SketchLine_52f-SketchArc_33_2r-SketchLine_230f-SketchLine_51f-SketchArc_32_2r-SketchLine_229f-SketchLine_50f-SketchArc_31_2r-SketchLine_228f-SketchLine_49f-SketchArc_30_2r-SketchLine_227f-SketchLine_48f-SketchArc_29_2r-SketchLine_226f-SketchLine_47f-SketchArc_28_2r-SketchLine_225f-SketchLine_46f-SketchArc_27_2r-SketchLine_224f-SketchLine_45f-SketchArc_26_2r-SketchLine_223f-SketchLine_44f-SketchArc_25_2r-SketchLine_222f-SketchLine_43f-SketchArc_24_2r-SketchLine_221f-SketchLine_42f-SketchArc_23_2r-SketchLine_220f-SketchLine_41f-SketchArc_22_2r-SketchLine_219f-SketchLine_40f-SketchArc_21_2r-SketchLine_218f-SketchLine_39f-SketchArc_20_2r-SketchLine_217f-SketchLine_38f-SketchArc_19_2r-SketchLine_216f-SketchLine_37f-SketchArc_18_2r-SketchLine_215f-SketchLine_36f-SketchArc_17_2r-SketchLine_214f-SketchLine_35f-SketchArc_16_2r-SketchLine_213f-SketchLine_34f-SketchArc_15_2r-SketchLine_212f-SketchLine_33f-SketchArc_14_2r-SketchLine_211f-SketchLine_32f-SketchArc_13_2r-SketchLine_210f-SketchLine_31f-SketchArc_12_2r-SketchLine_209f-SketchLine_30f-SketchArc_11_2r-SketchLine_208f-SketchLine_29f-SketchArc_10_2r-SketchLine_207f-SketchLine_28f-SketchArc_9_2r-SketchLine_206f-SketchLine_27f-SketchArc_8_2r-SketchLine_205f-SketchLine_26f-SketchArc_7_2r-SketchLine_204f-SketchLine_25f-SketchArc_6_2r-SketchLine_203f-SketchLine_24f-SketchArc_5_2r-SketchLine_202f-SketchLine_23f-SketchArc_4_2r-SketchLine_201f-SketchLine_22f-SketchArc_3_2r-SketchLine_200f-SketchLine_20f-SketchArc_2_2r-SketchLine_21f-SketchLine_382f-SketchArc_1_2r")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_4_2r")], model.selection(), 30, 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) # Test reexecution after parameter change Parameter_H.setValue(14) diff --git a/test.models/case24.py b/test.models/case24.py index 5db96a7f2..3c003a303 100644 --- a/test.models/case24.py +++ b/test.models/case24.py @@ -30,7 +30,7 @@ Parameter_R = model.addParameter(Part_1_doc, "R", "3") model.addParameter(Part_1_doc, "DBody", "65") Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/YOZ"), 89, False) Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchLine_1 = Sketch_1.addLine(0, 20, 16.99998550401508, 20) +SketchLine_1 = Sketch_1.addLine(0, 20, 17, 20) SketchLine_1.setName("SketchLine_7") SketchLine_1.result().setName("SketchLine_7") SketchLine_2 = Sketch_1.addLine(20, 0, 0, 0) @@ -39,7 +39,7 @@ SketchLine_2.result().setName("SketchLine_1") SketchLine_3 = Sketch_1.addLine(0, 0, 0, 20) SketchLine_3.setName("SketchLine_2") SketchLine_3.result().setName("SketchLine_2") -SketchLine_4 = Sketch_1.addLine(20, 16.99999846116062, 20, 0) +SketchLine_4 = Sketch_1.addLine(20, 17, 20, 0) SketchLine_4.setName("SketchLine_8") SketchLine_4.result().setName("SketchLine_8") SketchLine_5 = Sketch_1.addLine(20, 20, 20, 0) @@ -66,7 +66,7 @@ SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY" SketchLine_8 = SketchProjection_2.createdFeature() SketchLine_8.setName("SketchLine_6") SketchLine_8.result().setName("SketchLine_6") -SketchArc_1 = Sketch_1.addArc(17, 17, 20, 16.99999846116062, 16.99998550401508, 20, False) +SketchArc_1 = Sketch_1.addArc(17, 17, 20, 17, 17, 20, False) SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_4.startPoint()) SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint()) SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result()) @@ -80,21 +80,21 @@ SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_3.startPoint( SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_3.result(), 20) SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_3.endPoint(), SketchLine_2.result(), 20) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_1r-SketchLine_2r-SketchLine_8r-SketchArc_1_2f")], model.selection("EDGE", "Sketch_1/Edge-SketchLine_2"), 0, 180) -ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_7r-SketchLine_1r-SketchLine_2r-SketchLine_8r-SketchArc_1_2f")], model.selection(), 0, 25, [model.selection("SOLID", "Revolution_1_1")]) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchLine_1r-SketchLine_8r-SketchArc_1_2f-SketchLine_7r")], model.selection("EDGE", "Sketch_1/SketchLine_2"), 0, 180) +ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchLine_1r-SketchLine_8r-SketchArc_1_2f-SketchLine_7r")], model.selection(), 0, 25, [model.selection("SOLID", "Revolution_1_1")]) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchLine_9 = Sketch_2.addLine(0, 20, -17.00000285538278, 20) +SketchLine_9 = Sketch_2.addLine(0, 20, -17, 20) SketchLine_9.setName("SketchLine_13") SketchLine_9.result().setName("SketchLine_13") SketchLine_10 = Sketch_2.addLine(-20, 0, 0, 0) SketchLine_10.setName("SketchLine_9") SketchLine_10.result().setName("SketchLine_9") -SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_2s-SketchProjection_1s-SketchLine_5s-SketchProjection_2s-SketchLine_6s-SketchLine_1e")) +SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex")) SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchPoint_1.result()) SketchLine_11 = Sketch_2.addLine(0, 0, 0, 20) SketchLine_11.setName("SketchLine_10") SketchLine_11.result().setName("SketchLine_10") -SketchLine_12 = Sketch_2.addLine(-20, 17.00000633266883, -20, 0) +SketchLine_12 = Sketch_2.addLine(-20, 17, -20, 0) SketchLine_12.setName("SketchLine_14") SketchLine_12.result().setName("SketchLine_14") SketchLine_13 = Sketch_2.addLine(-20, 20, -20, 0) @@ -113,7 +113,7 @@ SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_10.result()) SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_11.result()) SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_14.result()) SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_13.result()) -SketchArc_2 = Sketch_2.addArc(-17, 17, -17.00000285538278, 20, -20, 17.00000633266883, False) +SketchArc_2 = Sketch_2.addArc(-17, 17, -17, 20, -20, 17, False) SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchArc_2.startPoint(), SketchLine_9.endPoint()) SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchArc_2.endPoint(), SketchLine_12.startPoint()) SketchConstraintTangent_3 = Sketch_2.setTangent(SketchArc_2.results()[1], SketchLine_9.result()) @@ -126,20 +126,20 @@ SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_2.results()[1], 3) SketchConstraintDistance_3 = Sketch_2.setDistance(SketchLine_10.startPoint(), SketchLine_11.result(), 20) SketchConstraintDistance_4 = Sketch_2.setDistance(SketchLine_11.endPoint(), SketchLine_10.result(), 20) model.do() -ExtrusionFuse_2 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_13f-SketchLine_9f-SketchLine_10f-SketchLine_14f-SketchArc_2_2f")], model.selection(), 0, 25, [model.selection("SOLID", "ExtrusionFuse_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_2_1/Modfied_8")) +ExtrusionFuse_2 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_13r-SketchArc_2_2f-SketchLine_14f-SketchLine_9f-SketchLine_10f")], model.selection(), 0, 25, [model.selection("SOLID", "ExtrusionFuse_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionFuse_2_1/Modified_Face&ExtrusionFuse_2_1/From_Face")) SketchLine_15 = Sketch_3.addLine(0, -20, -17.00000002635728, -20) SketchLine_15.setName("SketchLine_19") SketchLine_15.result().setName("SketchLine_19") SketchLine_16 = Sketch_3.addLine(-20, 0, 0, 0) SketchLine_16.setName("SketchLine_15") SketchLine_16.result().setName("SketchLine_15") -SketchPoint_2 = Sketch_3.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_9&ExtrusionFuse_2_1/Modfied_5&ExtrusionFuse_2_1/Modfied_8&ExtrusionFuse_2_1/Modfied_2")) +SketchPoint_2 = Sketch_3.addPoint(model.selection("VERTEX", "[ExtrusionFuse_2_1/Generated_Face&Sketch_2/SketchLine_9][(ExtrusionFuse_2_1/Generated_Face&Sketch_2/SketchLine_9)(ExtrusionFuse_1_1/Generated_Face&Sketch_1/SketchLine_8)(ExtrusionFuse_2_1/Modified_Face&ExtrusionFuse_1_1/From_Face)][ExtrusionFuse_2_1/Modified_Face&ExtrusionFuse_2_1/From_Face][ExtrusionFuse_2_1/Modified_Face&ExtrusionFuse_1_1/From_Face]")) SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchPoint_2.result()) SketchLine_17 = Sketch_3.addLine(0, 0, 0, -20) SketchLine_17.setName("SketchLine_16") SketchLine_17.result().setName("SketchLine_16") -SketchLine_18 = Sketch_3.addLine(-20, -16.99998301947517, -20, 0) +SketchLine_18 = Sketch_3.addLine(-20, -17, -20, 0) SketchLine_18.setName("SketchLine_20") SketchLine_18.result().setName("SketchLine_20") SketchLine_19 = Sketch_3.addLine(-20, -20, -20, 0) @@ -158,7 +158,7 @@ SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_16.result()) SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_17.result()) SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_20.result()) SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_19.result()) -SketchArc_3 = Sketch_3.addArc(-17, -17, -20, -16.99998301947517, -17.00000002635728, -20, False) +SketchArc_3 = Sketch_3.addArc(-17, -17, -20, -17, -17.00000002635728, -20, False) SketchConstraintCoincidence_28 = Sketch_3.setCoincident(SketchArc_3.startPoint(), SketchLine_18.startPoint()) SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchArc_3.endPoint(), SketchLine_15.endPoint()) SketchConstraintTangent_5 = Sketch_3.setTangent(SketchArc_3.results()[1], SketchLine_15.result()) @@ -174,9 +174,9 @@ SketchLine_21 = Sketch_3.addLine(-23, -0.01462093666115485, -23, -19.98755081419 SketchConstraintParallel_1 = Sketch_3.setParallel(SketchLine_17.result(), SketchLine_21.result()) SketchConstraintDistance_7 = Sketch_3.setDistance(SketchLine_21.startPoint(), SketchLine_18.result(), 3) model.do() -RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "Sketch_3/Edge-SketchLine_21"), 71, 0, [model.selection("SOLID", "ExtrusionFuse_2_1")]) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "RevolutionFuse_1_1/Modfied_4")) -SketchLine_22 = Sketch_4.addLine(-3, -20, 17.00000452949485, -20) +RevolutionFuse_1 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection("EDGE", "Sketch_3/SketchLine_21"), 71, 0, [model.selection("SOLID", "ExtrusionFuse_2_1")]) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "RevolutionFuse_1_1/Modified_Face&ExtrusionFuse_1_1/From_Face")) +SketchLine_22 = Sketch_4.addLine(-3, -20, 17, -20) SketchLine_22.setName("SketchLine_26") SketchLine_22.result().setName("SketchLine_26") SketchLine_23 = Sketch_4.addLine(20, 0, -3, 0) @@ -185,7 +185,7 @@ SketchLine_23.result().setName("SketchLine_22") SketchLine_24 = Sketch_4.addLine(-3, 0, -3, -20) SketchLine_24.setName("SketchLine_23") SketchLine_24.result().setName("SketchLine_23") -SketchLine_25 = Sketch_4.addLine(20, -17.00001580618423, 20, 0) +SketchLine_25 = Sketch_4.addLine(20, -17, 20, 0) SketchLine_25.setName("SketchLine_27") SketchLine_25.result().setName("SketchLine_27") SketchLine_26 = Sketch_4.addLine(20, -20, 20, 0) @@ -204,7 +204,7 @@ SketchConstraintHorizontal_7 = Sketch_4.setHorizontal(SketchLine_23.result()) SketchConstraintVertical_7 = Sketch_4.setVertical(SketchLine_24.result()) SketchConstraintHorizontal_8 = Sketch_4.setHorizontal(SketchLine_27.result()) SketchConstraintVertical_8 = Sketch_4.setVertical(SketchLine_26.result()) -SketchArc_4 = Sketch_4.addArc(17, -17, 17.00000452949485, -20, 20, -17.00001580618423, False) +SketchArc_4 = Sketch_4.addArc(17, -17, 17, -20, 20, -17, False) SketchConstraintCoincidence_38 = Sketch_4.setCoincident(SketchArc_4.startPoint(), SketchLine_22.endPoint()) SketchConstraintCoincidence_39 = Sketch_4.setCoincident(SketchArc_4.endPoint(), SketchLine_25.startPoint()) SketchConstraintTangent_7 = Sketch_4.setTangent(SketchArc_4.results()[1], SketchLine_22.result()) @@ -214,7 +214,7 @@ SketchConstraintCoincidence_41 = Sketch_4.setCoincident(SketchLine_26.endPoint() SketchConstraintCoincidence_42 = Sketch_4.setCoincident(SketchLine_22.endPoint(), SketchLine_27.result()) SketchConstraintCoincidence_43 = Sketch_4.setCoincident(SketchLine_25.startPoint(), SketchLine_26.result()) SketchConstraintRadius_4 = Sketch_4.setRadius(SketchArc_4.results()[1], 3) -SketchLine_28 = Sketch_4.addLine(model.selection("EDGE", "Sketch_3/Edge-SketchLine_15")) +SketchLine_28 = Sketch_4.addLine(model.selection("EDGE", "Sketch_3/SketchLine_15")) SketchConstraintCoincidence_44 = Sketch_4.setCoincident(SketchLine_24.startPoint(), SketchLine_28.result()) SketchConstraintDistance_8 = Sketch_4.setDistance(SketchLine_22.endPoint(), SketchLine_23.result(), 20) SketchConstraintDistance_9 = Sketch_4.setDistance(SketchLine_28.endPoint(), SketchLine_25.result(), 20) @@ -223,12 +223,12 @@ SketchLine_29 = Sketch_4.addLine(23, -0.2448405100241045, 23, -19.61338093143246 SketchConstraintParallel_2 = Sketch_4.setParallel(SketchLine_25.result(), SketchLine_29.result()) SketchConstraintDistance_11 = Sketch_4.setDistance(SketchLine_23.startPoint(), SketchLine_29.result(), 3) model.do() -RevolutionFuse_2 = model.addRevolutionFuse(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_26f-SketchLine_22f-SketchLine_23f-SketchLine_27f-SketchArc_4_2f")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_29"), 0, 71, [model.selection("SOLID", "RevolutionFuse_1_1")]) +RevolutionFuse_2 = model.addRevolutionFuse(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_26r-SketchArc_4_2f-SketchLine_27f-SketchLine_22f-SketchLine_23f")], model.selection("EDGE", "Sketch_4/SketchLine_29"), 0, 71, [model.selection("SOLID", "RevolutionFuse_1_1")]) Sketch_5 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_30 = Sketch_5.addLine(0, 0, 0, 82) SketchLine_31 = Sketch_5.addLine(model.selection("EDGE", "PartSet/OZ")) SketchConstraintCoincidence_45 = Sketch_5.setCoincident(SketchLine_30.endPoint(), SketchLine_31.result()) -SketchLine_32 = Sketch_5.addLine(27.41618692363446, 77.00000000000001, 58.99998109391454, 77.00000000000001) +SketchLine_32 = Sketch_5.addLine(27.41618692363446, 77, 58.99998109391454, 77) SketchLine_32.setName("SketchLine_39") SketchLine_32.result().setName("SketchLine_39") SketchLine_33 = Sketch_5.addLine(0, 82, 20, 82) @@ -238,7 +238,7 @@ SketchConstraintCoincidence_46 = Sketch_5.setCoincident(SketchLine_30.endPoint() SketchLine_34 = Sketch_5.addLine(65, 70.99999917134223, 65, 0) SketchLine_34.setName("SketchLine_40") SketchLine_34.result().setName("SketchLine_40") -SketchLine_35 = Sketch_5.addLine(27.41618692363446, 77.00000000000001, 65, 77.00000000000001) +SketchLine_35 = Sketch_5.addLine(27.41618692363446, 77, 65, 77) SketchLine_35.setName("SketchLine_34") SketchLine_35.result().setName("SketchLine_34") SketchLine_35.setAuxiliary(True) @@ -263,7 +263,7 @@ SketchConstraintDistance_12 = Sketch_5.setDistance(SketchLine_33.endPoint(), Ske SketchConstraintDistance_12.setName("SketchConstraintDistance_14") SketchConstraintDistance_13 = Sketch_5.setDistance(SketchLine_30.endPoint(), SketchLine_37.result(), 82) SketchConstraintDistance_13.setName("SketchConstraintDistance_15") -SketchArc_5 = Sketch_5.addArc(59, 70.99999999999999, 65, 70.99999917134223, 58.99998109391454, 77.00000000000001, False) +SketchArc_5 = Sketch_5.addArc(59, 70.99999999999999, 65, 70.99999917134223, 58.99998109391454, 77, False) SketchArc_5.setName("SketchArc_6") SketchArc_5.result().setName("SketchArc_6") SketchArc_5.results()[1].setName("SketchArc_6_2") @@ -285,7 +285,7 @@ SketchConstraintCoincidence_55 = Sketch_5.setCoincident(SketchLine_34.startPoint SketchConstraintCoincidence_55.setName("SketchConstraintCoincidence_62") SketchConstraintRadius_5 = Sketch_5.setRadius(SketchArc_5.results()[1], 6) SketchConstraintRadius_5.setName("SketchConstraintRadius_6") -SketchArc_6 = Sketch_5.addArc(27.41619848709567, 84.99999999999999, 27.41618692363446, 77.00000000000001, 20, 82, True) +SketchArc_6 = Sketch_5.addArc(27.41619848709567, 84.99999999999999, 27.41618692363446, 77, 20, 82, True) SketchArc_6.setName("SketchArc_7") SketchArc_6.result().setName("SketchArc_7") SketchArc_6.results()[1].setName("SketchArc_7_2") @@ -304,7 +304,7 @@ SketchConstraintCoincidence_59.setName("SketchConstraintCoincidence_66") SketchConstraintDistance_15 = Sketch_5.setDistance(SketchLine_37.startPoint(), SketchLine_30.result(), "DBody") SketchConstraintDistance_15.setName("SketchConstraintDistance_16") model.do() -RevolutionFuse_3 = model.addRevolutionFuse(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_30r-SketchLine_39r-SketchLine_32r-SketchLine_40r-SketchLine_38r-SketchArc_6_2f-SketchArc_7_2r")], model.selection("EDGE", "PartSet/OZ"), 45, 315, [model.selection("SOLID", "RevolutionFuse_2_1")]) +RevolutionFuse_3 = model.addRevolutionFuse(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_38r-SketchLine_40r-SketchArc_6_2f-SketchLine_39r-SketchArc_7_2r-SketchLine_32r-SketchLine_30r_wire")], model.selection("EDGE", "PartSet/OZ"), 45, 315, [model.selection("SOLID", "RevolutionFuse_2_1")]) Sketch_6 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) SketchLine_38 = Sketch_6.addLine(19.99999999999999, 60, -20, 60) SketchLine_38.setName("SketchLine_48") @@ -318,11 +318,11 @@ SketchLine_40.result().setName("SketchLine_51") SketchLine_41 = Sketch_6.addLine(20, 30, 19.99999999999999, 60) SketchLine_41.setName("SketchLine_50") SketchLine_41.result().setName("SketchLine_50") -SketchLine_43 = Sketch_6.addLine(-19.99999999999998, 30.00000000000001, 20, 30.00000000000001) +SketchLine_43 = Sketch_6.addLine(-20, 30, 20, 30) SketchLine_43.setName("SketchLine_41") SketchLine_43.result().setName("SketchLine_41") SketchLine_43.setAuxiliary(True) -SketchLine_42 = Sketch_6.addLine(-19.99999999999999, 60, -19.99999999999998, 30.00000000000001) +SketchLine_42 = Sketch_6.addLine(-20, 60, -20, 30) SketchLine_42.setName("SketchLine_44") SketchLine_42.result().setName("SketchLine_44") SketchLine_42.setAuxiliary(True) @@ -394,7 +394,7 @@ SketchConstraintCoincidence_78 = Sketch_6.setCoincident(SketchLine_40.endPoint() SketchConstraintCoincidence_78.setName("SketchConstraintCoincidence_93") SketchConstraintCoincidence_79 = Sketch_6.setCoincident(SketchLine_39.startPoint(), SketchLine_49.result()) SketchConstraintCoincidence_79.setName("SketchConstraintCoincidence_94") -SketchPoint_3 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/Vertex-SketchLine_30s-SketchLine_31s-SketchLine_38e")) +SketchPoint_3 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/SketchLine_30_StartVertex")) SketchConstraintDistance_16 = Sketch_6.setDistance(SketchLine_40.result(), SketchPoint_3.coordinates(), 20) SketchConstraintDistance_16.setName("SketchConstraintDistance_18") SketchConstraintDistance_17 = Sketch_6.setDistance(SketchPoint_3.coordinates(), SketchLine_41.result(), 20) @@ -417,7 +417,7 @@ Sketch_7 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchLine_50 = Sketch_7.addLine(65, 23.09999999999939, 65, 23.00000523211526) SketchLine_50.setName("SketchLine_61") SketchLine_50.result().setName("SketchLine_61") -SketchLine_51 = Sketch_7.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_35")) +SketchLine_51 = Sketch_7.addLine(model.selection("EDGE", "Sketch_5/SketchLine_35")) SketchLine_51.setName("SketchLine_54") SketchLine_51.result().setName("SketchLine_54") SketchLine_52 = Sketch_7.addLine(65, 23.09999999999939, 65, 20) @@ -435,7 +435,7 @@ SketchLine_54.result().setName("SketchLine_55") SketchLine_54.setAuxiliary(True) SketchConstraintCoincidence_86 = Sketch_7.setCoincident(SketchLine_52.endPoint(), SketchLine_54.startPoint()) SketchConstraintCoincidence_86.setName("SketchConstraintCoincidence_96") -SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "RevolutionFuse_3_1/Modfied_6&RevolutionFuse_3_1/Modfied_5")) +SketchLine_55 = Sketch_7.addLine(model.selection("EDGE", "[RevolutionFuse_3_1/Modified_Face&Sketch_2/SketchLine_13][RevolutionFuse_3_1/Modified_Face&Sketch_1/SketchLine_7]")) SketchLine_55.setName("SketchLine_56") SketchLine_55.result().setName("SketchLine_56") SketchConstraintCoincidence_87 = Sketch_7.setCoincident(SketchLine_54.endPoint(), SketchLine_55.result()) @@ -498,12 +498,12 @@ model.do() RevolutionFuse_4 = model.addRevolutionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection("EDGE", "PartSet/OZ"), 14.4, 14.4, [model.selection("SOLID", "ExtrusionCut_1_1")]) Sketch_8 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchCircle_1 = Sketch_8.addCircle(0, 45, 12.5) -SketchLine_60 = Sketch_8.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_30")) +SketchLine_60 = Sketch_8.addLine(model.selection("EDGE", "Sketch_5/SketchLine_30")) SketchLine_60.setName("SketchLine_63") SketchLine_60.result().setName("SketchLine_63") SketchConstraintCoincidence_99 = Sketch_8.setCoincident(SketchCircle_1.center(), SketchLine_60.result()) SketchConstraintCoincidence_99.setName("SketchConstraintCoincidence_109") -SketchLine_61 = Sketch_8.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_38")) +SketchLine_61 = Sketch_8.addLine(model.selection("EDGE", "Sketch_5/SketchLine_38")) SketchLine_61.setName("SketchLine_64") SketchLine_61.result().setName("SketchLine_64") SketchConstraintDistance_22 = Sketch_8.setDistance(SketchCircle_1.center(), SketchLine_61.result(), 45) @@ -511,7 +511,7 @@ SketchConstraintDistance_22.setName("SketchConstraintDistance_24") SketchConstraintRadius_8 = Sketch_8.setRadius(SketchCircle_1.results()[1], 12.5) SketchConstraintRadius_8.setName("SketchConstraintRadius_13") model.do() -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchCircle_1_2f")], model.selection(), 100, 100, [model.selection("SOLID", "RevolutionFuse_4_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchCircle_1_2r")], model.selection(), 100, 100, [model.selection("SOLID", "RevolutionFuse_4_1")]) Sketch_9 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchLine_62 = Sketch_9.addLine(0, 84, 0, -2) SketchLine_62.setName("SketchLine_65") @@ -596,7 +596,7 @@ SketchConstraintDistance_26 = Sketch_9.setDistance(SketchLine_71.endPoint(), Ske SketchConstraintDistance_26.setName("SketchConstraintDistance_28") SketchConstraintDistance_27 = Sketch_9.setDistance(SketchLine_72.endPoint(), SketchLine_63.result(), 15) SketchConstraintDistance_27.setName("SketchConstraintDistance_29") -SketchLine_76 = Sketch_9.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_32")) +SketchLine_76 = Sketch_9.addLine(model.selection("EDGE", "Sketch_5/SketchLine_32")) SketchLine_76.setName("SketchLine_75") SketchLine_76.result().setName("SketchLine_75") SketchConstraintDistance_28 = Sketch_9.setDistance(SketchLine_62.startPoint(), SketchLine_76.result(), 2) @@ -652,22 +652,22 @@ Sketch_10 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_77 = Sketch_10.addLine(64, 20, 89, 20) SketchLine_77.setName("SketchLine_76") SketchLine_77.result().setName("SketchLine_76") -SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_9&RevolutionFuse_2_1/Modfied_6&RevolutionFuse_3_1/Modfied_divided_22_1&RevolutionFuse_2_1/Modfied_11")) +SketchPoint_4 = Sketch_10.addPoint(model.selection("VERTEX", "[RevolutionFuse_3_1/Modified_Face&Sketch_1/SketchLine_1&weak_name_2][RevolutionFuse_2_1/Modified_Face&Sketch_1/SketchLine_8][RevolutionFuse_3_1/Modified_Face&Sketch_4/SketchLine_22&weak_name_2][RevolutionFuse_2_1/Generated_Face&Sketch_4/SketchLine_27]")) SketchConstraintCoincidence_122 = Sketch_10.setCoincident(SketchLine_77.startPoint(), SketchPoint_4.result()) SketchConstraintCoincidence_122.setName("SketchConstraintCoincidence_120") -SketchPoint_5 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_1s-SketchLine_8e-SketchLine_4e")) +SketchPoint_5 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_1/SketchLine_1_StartVertex")) SketchConstraintCoincidence_123 = Sketch_10.setCoincident(SketchLine_77.endPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_123.setName("SketchConstraintCoincidence_121") SketchLine_78 = Sketch_10.addLine(64, -20, 89, -20) SketchLine_78.setName("SketchLine_77") SketchLine_78.result().setName("SketchLine_77") -SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_10&RevolutionFuse_1_1/Modfied_5&RevolutionFuse_3_1/Modfied_divided_21_1&RevolutionFuse_1_1/Modfied_10")) +SketchPoint_6 = Sketch_10.addPoint(model.selection("VERTEX", "[RevolutionFuse_3_1/Modified_Face&Sketch_2/SketchLine_9&weak_name_2][RevolutionFuse_1_1/Modified_Face&Sketch_2/SketchLine_14][RevolutionFuse_3_1/Modified_Face&Sketch_3/SketchLine_15&weak_name_2][RevolutionFuse_1_1/Generated_Face&Sketch_3/SketchLine_20]")) SketchConstraintCoincidence_124 = Sketch_10.setCoincident(SketchLine_78.startPoint(), SketchPoint_6.result()) SketchConstraintCoincidence_124.setName("SketchConstraintCoincidence_122") -SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "ExtrusionFuse_2_1/Modfied_7&ExtrusionFuse_2_1/Modfied_6&RevolutionFuse_3_1/Modfied_10&RevolutionFuse_1_1/Modfied_5")) +SketchPoint_7 = Sketch_10.addPoint(model.selection("VERTEX", "[ExtrusionFuse_2_1/Modified_Face&Sketch_1/SketchLine_1&weak_name_2][ExtrusionFuse_2_1/Modified_Face&Sketch_1/SketchLine_8][RevolutionFuse_3_1/Modified_Face&Sketch_2/SketchLine_9&weak_name_2][RevolutionFuse_1_1/Modified_Face&Sketch_2/SketchLine_14]")) SketchConstraintCoincidence_125 = Sketch_10.setCoincident(SketchLine_78.endPoint(), SketchPoint_7.result()) SketchConstraintCoincidence_125.setName("SketchConstraintCoincidence_123") -SketchArc_10 = Sketch_10.addArc(89.00000104846708, 1.669244441022778e-015, 89, -20, 89, 20, False) +SketchArc_10 = Sketch_10.addArc(89, 0, 89, -20, 89, 20, False) SketchArc_10.setName("SketchArc_13") SketchArc_10.result().setName("SketchArc_13") SketchArc_10.results()[1].setName("SketchArc_13_2") @@ -687,7 +687,7 @@ SketchConstraintCoincidence_129 = Sketch_10.setCoincident(SketchArc_11.startPoin SketchConstraintCoincidence_129.setName("SketchConstraintCoincidence_127") SketchConstraintTangent_19 = Sketch_10.setTangent(SketchArc_11.results()[1], SketchLine_78.result()) SketchConstraintTangent_19.setName("SketchConstraintTangent_24") -SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_divided_21_1&RevolutionFuse_1_1/Modfied_10&RevolutionFuse_3_1/Modfied_8")) +SketchPoint_8 = Sketch_10.addPoint(model.selection("VERTEX", "[RevolutionFuse_3_1/Modified_Face&Sketch_3/SketchLine_15&weak_name_2][RevolutionFuse_1_1/Generated_Face&Sketch_3/SketchLine_20][RevolutionFuse_3_1/Modified_Face&RevolutionFuse_1_1/To_Face]")) SketchConstraintCoincidence_130 = Sketch_10.setCoincident(SketchArc_11.endPoint(), SketchPoint_8.result()) SketchConstraintCoincidence_130.setName("SketchConstraintCoincidence_128") SketchArc_12 = Sketch_10.addArc(64.00001789135865, 23.01137360115889, 64, 20, 61.15622559702543, 22.02080994708722, True) @@ -698,7 +698,7 @@ SketchConstraintCoincidence_131 = Sketch_10.setCoincident(SketchArc_12.startPoin SketchConstraintCoincidence_131.setName("SketchConstraintCoincidence_129") SketchConstraintTangent_20 = Sketch_10.setTangent(SketchArc_12.results()[1], SketchLine_77.result()) SketchConstraintTangent_20.setName("SketchConstraintTangent_25") -SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "RevolutionFuse_3_1/Modfied_divided_22_1&RevolutionFuse_2_1/Modfied_11&RevolutionFuse_3_1/Modfied_7")) +SketchPoint_9 = Sketch_10.addPoint(model.selection("VERTEX", "[RevolutionFuse_3_1/Modified_Face&Sketch_4/SketchLine_22&weak_name_2][RevolutionFuse_2_1/Generated_Face&Sketch_4/SketchLine_27][RevolutionFuse_3_1/Modified_Face&RevolutionFuse_2_1/From_Face]")) SketchConstraintCoincidence_132 = Sketch_10.setCoincident(SketchArc_12.endPoint(), SketchPoint_9.result()) SketchConstraintCoincidence_132.setName("SketchConstraintCoincidence_130") SketchLine_79 = Sketch_10.addLine(61.15622559702543, 22.02080994708722, 59.81204392543111, 22.0208099470871) @@ -725,7 +725,7 @@ SketchConstraintCoincidence_138.setName("SketchConstraintCoincidence_136") SketchConstraintParallel_3 = Sketch_10.setParallel(SketchLine_78.result(), SketchLine_81.result()) SketchConstraintParallel_4 = Sketch_10.setParallel(SketchLine_77.result(), SketchLine_79.result()) SketchConstraintPerpendicular_1 = Sketch_10.setPerpendicular(SketchLine_80.result(), SketchLine_77.result()) -SketchPoint_10 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_6/Vertex-SketchPoint_3")) +SketchPoint_10 = Sketch_10.addPoint(model.selection("VERTEX", "Sketch_6/SketchPoint_3")) SketchMultiRotation_1_objects = [SketchArc_10.results()[1], SketchLine_77.result(), SketchLine_78.result(), SketchArc_12.results()[1], SketchLine_79.result(), SketchLine_80.result(), SketchLine_81.result(), SketchArc_11.results()[1]] SketchMultiRotation_1 = Sketch_10.addRotation(SketchMultiRotation_1_objects, SketchPoint_10.coordinates(), 120, 3) [SketchArc_13, SketchArc_14, SketchLine_82, SketchLine_83, SketchLine_84, SketchLine_85, SketchArc_15, SketchArc_16, SketchLine_86, SketchLine_87, SketchLine_88, SketchLine_89, SketchLine_90, SketchLine_91, SketchArc_17, SketchArc_18] = SketchMultiRotation_1.rotated() @@ -768,10 +768,10 @@ SketchArc_13.setName("SketchArc_16") SketchArc_13.result().setName("SketchArc_16") SketchArc_13.results()[1].setName("SketchArc_16_2") model.do() -ExtrusionFuse_3 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_10/Face-SketchArc_16_2f-SketchLine_81r-SketchLine_82f-SketchArc_17_2r-SketchLine_83f-SketchLine_84f-SketchLine_85r-SketchArc_18_2r"), model.selection("FACE", "Sketch_10/Face-SketchArc_19_2f-SketchLine_86r-SketchLine_87f-SketchArc_20_2r-SketchLine_88f-SketchLine_89f-SketchLine_90r-SketchArc_21_2r")], model.selection(), 20, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionFuse_3 = model.addExtrusionFuse(Part_1_doc, [model.selection("FACE", "Sketch_10/Face-SketchArc_16_2f-SketchLine_81r-SketchArc_17_2r-SketchLine_83f-SketchLine_84f-SketchLine_85r-SketchArc_18_2r-SketchLine_82f"), model.selection("FACE", "Sketch_10/Face-SketchArc_19_2f-SketchLine_86r-SketchArc_20_2r-SketchLine_88f-SketchLine_89f-SketchLine_90r-SketchArc_21_2r-SketchLine_87f")], model.selection(), 20, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) Sketch_11 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchCircle_2 = Sketch_11.addCircle(89, 0, 6) -SketchPoint_11 = Sketch_11.addPoint(model.selection("VERTEX", "Sketch_2/Vertex-SketchPoint_1-SketchLine_10s-SketchLine_9e")) +SketchPoint_11 = Sketch_11.addPoint(model.selection("VERTEX", "Sketch_2/SketchLine_90_EndVertex")) SketchConstraintCoincidence_139 = Sketch_11.setCoincident(SketchCircle_2.center(), SketchPoint_11.result()) SketchConstraintCoincidence_139.setName("SketchConstraintCoincidence_137") SketchConstraintRadius_11 = Sketch_11.setRadius(SketchCircle_2.results()[1], 6) @@ -788,8 +788,10 @@ SketchMultiRotation_2 = Sketch_11.addRotation([SketchCircle_3.results()[1], Sket [SketchCircle_4, SketchCircle_5, SketchCircle_6, SketchCircle_7] = SketchMultiRotation_2.rotated() model.do() RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection("EDGE", "PartSet/OZ"), 0, 360, [model.selection("SOLID", "ExtrusionFuse_3_1")]) -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_11/Wire-SketchCircle_4_2f"), model.selection("WIRE", "Sketch_11/Wire-SketchCircle_3_2f"), model.selection("WIRE", "Sketch_11/Wire-SketchCircle_5_2f")], model.selection(), 30, -15, [model.selection("SOLID", "RevolutionCut_1_1")]) -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_11/Wire-SketchCircle_2_2f"), model.selection("FACE", "Sketch_11/Face-SketchCircle_6_2f"), model.selection("WIRE", "Sketch_11/Wire-SketchCircle_7_2f")], model.selection(), 30, 2, [model.selection("SOLID", "ExtrusionCut_3_1")]) +ExtrusionCut_3_objects_1 = [model.selection("WIRE", "Sketch_11/Face-SketchCircle_4_2f-SketchCircle_6_2r_wire"), model.selection("WIRE", "Sketch_11/Face-SketchCircle_3_2f-SketchCircle_2_2r_wire"), model.selection("WIRE", "Sketch_11/Face-SketchCircle_5_2f-SketchCircle_7_2r_wire")] +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_3_objects_1, model.selection(), 30, -15, [model.selection("SOLID", "RevolutionCut_1_1")]) +ExtrusionCut_4_objects_1 = [model.selection("WIRE", "Sketch_11/Face-SketchCircle_2_2r_wire"), model.selection("FACE", "Sketch_11/Face-SketchCircle_6_2f"), model.selection("WIRE", "Sketch_11/Face-SketchCircle_7_2f_wire")] +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_4_objects_1, model.selection(), 30, 2, [model.selection("SOLID", "ExtrusionCut_3_1")]) # Test reexecution after parameter change Parameter_R.setValue(5) diff --git a/test.models/clothespin.py b/test.models/clothespin.py index f69307ae2..aa5407966 100644 --- a/test.models/clothespin.py +++ b/test.models/clothespin.py @@ -133,20 +133,20 @@ SketchConstraintHorizontal_4.setName("SketchConstraintHorizontal_9") SketchConstraintDistance_7 = Sketch_1.setDistance(SketchLine_5.startPoint(), SketchLine_2.result(), 32, False) SketchConstraintDistance_7.setName("SketchConstraintDistance_9") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r")], model.selection(), 12, 0) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_14r-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchArc_2_2r-SketchLine_12r-SketchLine_11r-SketchLine_10r_wire")], model.selection(), 12, 0) Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) SketchArc_3 = Sketch_2.addArc(54, 6, 54, 12, 54, 0, True) -SketchLine_13 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_13&Extrusion_1_1/To_Face_1")) +SketchLine_13 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]")) SketchLine_13.setName("SketchLine_15") SketchLine_13.result().setName("SketchLine_15") SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchArc_3.startPoint(), SketchLine_13.result()) SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_23") -SketchLine_14 = Sketch_2.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchLine_14 = Sketch_2.addLine(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_14.setName("SketchLine_16") SketchLine_14.result().setName("SketchLine_16") SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchArc_3.endPoint(), SketchLine_14.result()) SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_24") -SketchLine_15 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_13&Extrusion_1_1/Generated_Face_12")) +SketchLine_15 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]")) SketchLine_15.setName("SketchLine_17") SketchLine_15.result().setName("SketchLine_17") SketchConstraintTangent_1 = Sketch_2.setTangent(SketchArc_3.results()[1], SketchLine_15.result()) @@ -180,13 +180,13 @@ SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_29") SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchArc_3.endPoint(), SketchLine_20.endPoint()) SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_30") model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_3_2r-SketchLine_18r-SketchLine_19r-SketchLine_20r-SketchLine_21r-SketchLine_22r")], model.selection(), 7, 15, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_9")) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_22r-SketchLine_21r-SketchLine_20r-SketchLine_19r-SketchLine_18r-SketchArc_3_2r")], model.selection(), 7, 15, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14")) SketchLine_21 = Sketch_3.addLine(28, -6, -4.270492394552598, -6) SketchLine_21.setName("SketchLine_23") SketchLine_21.result().setName("SketchLine_23") SketchLine_21.setAuxiliary(True) -SketchLine_22 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/Generated_Face_9")) +SketchLine_22 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14]")) SketchLine_22.setName("SketchLine_24") SketchLine_22.result().setName("SketchLine_24") SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchLine_22.result()) @@ -304,26 +304,26 @@ SketchConstraintCoincidence_51.setName("SketchConstraintCoincidence_55") SketchConstraintMiddle_2 = Sketch_3.setMiddlePoint(SketchLine_34.result(), SketchPoint_4.coordinates()) SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchPoint_4.coordinates(), SketchLine_21.result()) SketchConstraintCoincidence_52.setName("SketchConstraintCoincidence_56") -SketchLine_35 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&ExtrusionCut_1_1/Modfied_3")) +SketchLine_35 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_5]")) SketchLine_35.setName("SketchLine_37") SketchLine_35.result().setName("SketchLine_37") SketchConstraintCoincidence_53 = Sketch_3.setCoincident(SketchLine_25.startPoint(), SketchLine_35.result()) SketchConstraintCoincidence_53.setName("SketchConstraintCoincidence_57") SketchConstraintLength_10 = Sketch_3.setLength(SketchLine_24.result(), 31) SketchConstraintLength_10.setName("SketchConstraintLength_11") -SketchLine_36 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_5")) +SketchLine_36 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9]")) SketchLine_36.setName("SketchLine_38") SketchLine_36.result().setName("SketchLine_38") SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_30.startPoint(), SketchLine_36.result()) SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_58") SketchConstraintEqual_2 = Sketch_3.setEqual(SketchLine_30.result(), SketchLine_25.result()) model.do() -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_32f-SketchLine_33f-SketchLine_34f-SketchLine_35f"), model.selection("FACE", "Sketch_3/Face-SketchLine_26f-SketchLine_27f-SketchLine_28f-SketchLine_29f")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_1")) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_32f-SketchLine_33f-SketchLine_34f-SketchLine_35f"), model.selection("FACE", "Sketch_3/Face-SketchLine_26f-SketchLine_27f-SketchLine_28f-SketchLine_29f")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face")) SketchLine_37 = Sketch_4.addLine(0.4324637622511017, 3.581086955422081, 1.55585595716119, 2.812450190483599) SketchLine_37.setName("SketchLine_39") SketchLine_37.result().setName("SketchLine_39") -SketchLine_38 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_2")) +SketchLine_38 = Sketch_4.addLine(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_11]")) SketchLine_38.setName("SketchLine_40") SketchLine_38.result().setName("SketchLine_40") SketchConstraintCoincidence_55 = Sketch_4.setCoincident(SketchLine_37.startPoint(), SketchLine_38.result()) @@ -369,8 +369,8 @@ SketchLine_42.result().setName("SketchLine_44") SketchLine_41.setName("SketchLine_43") SketchLine_41.result().setName("SketchLine_43") model.do() -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_2"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_5&ExtrusionCut_3_1/Modfied_3&Extrusion_1_1/Generated_Face_1"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_3&Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_7"), model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_5&ExtrusionCut_2_1/Modfied_5&ExtrusionCut_3_1/Modfied_3")) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Plane_4 = model.addPlane(Part_1_doc, model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10]"), model.selection("VERTEX", "[ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_4&ExtrusionCut_2_1/To_Face_2)][ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face]")) Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchArc_4 = Sketch_5.addArc(25, -7.50002056854448, 22, -7.5, 28, -7.5, True) SketchPoint_5 = Sketch_5.addPoint(22, -7.5) @@ -410,11 +410,11 @@ SketchConstraintVertical_11 = Sketch_5.setVertical(SketchLine_52.result()) SketchConstraintHorizontal_11 = Sketch_5.setHorizontal(SketchLine_51.result()) SketchConstraintHorizontal_11.setName("SketchConstraintHorizontal_12") model.do() -Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), 6, True) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face"), 6, True) Plane_6 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 3, True) -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2f-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), 3, 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) -ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2f-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection("FACE", "Plane_2"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modfied_6")) +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2r-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), 3, 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) +ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2r-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection("FACE", "Plane_2"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modified_Face&Extrusion_1_1/To_Face")) SketchArc_5 = Sketch_6.addArc(46, 0, 45.5, 0, 46.5, 0, False) SketchLine_53 = Sketch_6.addLine(0, 0, 54, 0) SketchLine_53.setName("SketchLine_55") @@ -464,8 +464,8 @@ SketchLine_57.result().setName("SketchLine_59") SketchLine_56.setName("SketchLine_58") SketchLine_56.result().setName("SketchLine_58") model.do() -ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_8")) +ExtrusionFuse_1 = model.addExtrusionFuse(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_14r-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchArc_2_2r-SketchLine_12r-SketchLine_11r-SketchLine_10r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_27)(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_26)(ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_4&ExtrusionCut_2_1/To_Face_2)(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_28)")) SketchLine_64 = Sketch_7.addLine(50.25, -4.5, 31.25, -4.5) SketchLine_64.setName("SketchLine_76") SketchLine_64.result().setName("SketchLine_76") @@ -639,7 +639,7 @@ SketchConstraintRadius_7 = Sketch_7.setRadius(SketchArc_17.results()[1], 0.25) SketchConstraintRadius_7.setName("SketchConstraintRadius_10") model.do() ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), 0, 20, [model.selection("SOLID", "ExtrusionFuse_1_1")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_6_1/Modfied_10")) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "(ExtrusionFuse_1_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_76)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchArc_15_2)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_80)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchArc_17_2)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_79)(ExtrusionFuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10)")) SketchPoint_12 = Sketch_8.addPoint(54, 0) SketchPoint_13 = Sketch_8.addPoint(54, 0) SketchConstraintRigid_7 = Sketch_8.setFixed(SketchPoint_13.result()) @@ -788,7 +788,7 @@ SketchConstraintCoincidence_142 = Sketch_8.setCoincident(SketchPoint_21.coordina SketchConstraintCoincidence_142.setName("SketchConstraintCoincidence_145") model.do() ExtrusionCut_7 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection(), 10, 0, [model.selection("SOLID", "ExtrusionCut_6_1")]) -Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_7_1/Modfied_14")) +Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_7_1/Modified_Face&Extrusion_1_1/To_Face")) SketchLine_94 = Sketch_9.addLine(21, 4.163450069699051, 21, 0) SketchLine_94.setName("SketchLine_107") SketchLine_94.result().setName("SketchLine_107") @@ -931,7 +931,7 @@ model.do() Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 4, False) Plane_8 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 4, True) ExtrusionCut_8 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection(), model.selection("FACE", "Plane_5"), 0, model.selection("FACE", "Plane_4"), 0, [model.selection("SOLID", "ExtrusionCut_7_1")]) -Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_8_1/Modfied_5")) +Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_8_1/Modified_Face&Sketch_1/SketchLine_1")) SketchCircle_1 = Sketch_10.addCircle(12, 6, 1) SketchConstraintRadius_9 = Sketch_10.setRadius(SketchCircle_1.results()[1], 1) SketchPoint_24 = Sketch_10.addPoint(0, 6) @@ -956,7 +956,7 @@ SketchConstraintCoincidence_174 = Sketch_10.setCoincident(SketchCircle_1.center( SketchConstraintCoincidence_174.setName("SketchConstraintCoincidence_178") SketchConstraintDistance_17 = Sketch_10.setDistance(SketchLine_105.result(), SketchCircle_1.center(), 12, False) model.do() -ExtrusionCut_9 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_10/Wire-SketchCircle_1_2f")], model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_8_1")]) +ExtrusionCut_9 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_10/Face-SketchCircle_1_2r_wire")], model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_8_1")]) model.do() Part_2 = model.addPart(partSet) Part_2_doc = Part_2.document() @@ -1068,20 +1068,20 @@ SketchConstraintHorizontal_26.setName("SketchConstraintHorizontal_9") SketchConstraintDistance_24 = Sketch_11.setDistance(SketchLine_111.startPoint(), SketchLine_108.result(), 32, False) SketchConstraintDistance_24.setName("SketchConstraintDistance_9") model.do() -Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r")], model.selection(), 12, 0) +Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_14r-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchArc_2_2r-SketchLine_12r-SketchLine_11r-SketchLine_10r_wire")], model.selection(), 12, 0) Sketch_12 = model.addSketch(Part_2_doc, model.standardPlane("XOZ")) SketchArc_26 = Sketch_12.addArc(54, 6, 54, 12, 54, 0, True) -SketchLine_119 = Sketch_12.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_13&Extrusion_1_1/To_Face_1")) +SketchLine_119 = Sketch_12.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]")) SketchLine_119.setName("SketchLine_15") SketchLine_119.result().setName("SketchLine_15") SketchConstraintCoincidence_193 = Sketch_12.setCoincident(SketchArc_26.startPoint(), SketchLine_119.result()) SketchConstraintCoincidence_193.setName("SketchConstraintCoincidence_23") -SketchLine_120 = Sketch_12.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")) +SketchLine_120 = Sketch_12.addLine(model.selection("EDGE", "Sketch_1/SketchLine_1")) SketchLine_120.setName("SketchLine_16") SketchLine_120.result().setName("SketchLine_16") SketchConstraintCoincidence_194 = Sketch_12.setCoincident(SketchArc_26.endPoint(), SketchLine_120.result()) SketchConstraintCoincidence_194.setName("SketchConstraintCoincidence_24") -SketchLine_121 = Sketch_12.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_13&Extrusion_1_1/Generated_Face_12")) +SketchLine_121 = Sketch_12.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]")) SketchLine_121.setName("SketchLine_17") SketchLine_121.result().setName("SketchLine_17") SketchConstraintTangent_16 = Sketch_12.setTangent(SketchArc_26.results()[1], SketchLine_121.result()) @@ -1115,13 +1115,13 @@ SketchConstraintCoincidence_199.setName("SketchConstraintCoincidence_29") SketchConstraintCoincidence_200 = Sketch_12.setCoincident(SketchArc_26.endPoint(), SketchLine_126.endPoint()) SketchConstraintCoincidence_200.setName("SketchConstraintCoincidence_30") model.do() -ExtrusionCut_10 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_3_2r-SketchLine_18r-SketchLine_19r-SketchLine_20r-SketchLine_21r-SketchLine_22r")], model.selection(), 7, 15, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_13 = model.addSketch(Part_2_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_9")) +ExtrusionCut_10 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_22r-SketchLine_21r-SketchLine_20r-SketchLine_19r-SketchLine_18r-SketchArc_3_2r")], model.selection(), 7, 15, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_13 = model.addSketch(Part_2_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14")) SketchLine_127 = Sketch_13.addLine(28, -6, -4.270492394552598, -6) SketchLine_127.setName("SketchLine_23") SketchLine_127.result().setName("SketchLine_23") SketchLine_127.setAuxiliary(True) -SketchLine_128 = Sketch_13.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/Generated_Face_9")) +SketchLine_128 = Sketch_13.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14]")) SketchLine_128.setName("SketchLine_24") SketchLine_128.result().setName("SketchLine_24") SketchConstraintCoincidence_201 = Sketch_13.setCoincident(SketchLine_127.startPoint(), SketchLine_128.result()) @@ -1239,26 +1239,26 @@ SketchConstraintCoincidence_225.setName("SketchConstraintCoincidence_55") SketchConstraintMiddle_10 = Sketch_13.setMiddlePoint(SketchLine_140.result(), SketchPoint_28.coordinates()) SketchConstraintCoincidence_226 = Sketch_13.setCoincident(SketchPoint_28.coordinates(), SketchLine_127.result()) SketchConstraintCoincidence_226.setName("SketchConstraintCoincidence_56") -SketchLine_141 = Sketch_13.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_9&ExtrusionCut_1_1/Modfied_3")) +SketchLine_141 = Sketch_13.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_14][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_5]")) SketchLine_141.setName("SketchLine_37") SketchLine_141.result().setName("SketchLine_37") SketchConstraintCoincidence_227 = Sketch_13.setCoincident(SketchLine_131.startPoint(), SketchLine_141.result()) SketchConstraintCoincidence_227.setName("SketchConstraintCoincidence_57") SketchConstraintLength_27 = Sketch_13.setLength(SketchLine_130.result(), 31) SketchConstraintLength_27.setName("SketchConstraintLength_11") -SketchLine_142 = Sketch_13.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_5")) +SketchLine_142 = Sketch_13.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9]")) SketchLine_142.setName("SketchLine_38") SketchLine_142.result().setName("SketchLine_38") SketchConstraintCoincidence_228 = Sketch_13.setCoincident(SketchLine_136.startPoint(), SketchLine_142.result()) SketchConstraintCoincidence_228.setName("SketchConstraintCoincidence_58") SketchConstraintEqual_5 = Sketch_13.setEqual(SketchLine_136.result(), SketchLine_131.result()) model.do() -ExtrusionCut_11 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_32f-SketchLine_33f-SketchLine_34f-SketchLine_35f"), model.selection("FACE", "Sketch_3/Face-SketchLine_26f-SketchLine_27f-SketchLine_28f-SketchLine_29f")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Sketch_14 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_1")) +ExtrusionCut_11 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_32f-SketchLine_33f-SketchLine_34f-SketchLine_35f"), model.selection("FACE", "Sketch_3/Face-SketchLine_26f-SketchLine_27f-SketchLine_28f-SketchLine_29f")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_4"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Sketch_14 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face")) SketchLine_143 = Sketch_14.addLine(0.4324637622511017, 3.581086955422081, 1.55585595716119, 2.812450190483599) SketchLine_143.setName("SketchLine_39") SketchLine_143.result().setName("SketchLine_39") -SketchLine_144 = Sketch_14.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_2")) +SketchLine_144 = Sketch_14.addLine(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_11]")) SketchLine_144.setName("SketchLine_40") SketchLine_144.result().setName("SketchLine_40") SketchConstraintCoincidence_229 = Sketch_14.setCoincident(SketchLine_143.startPoint(), SketchLine_144.result()) @@ -1304,8 +1304,8 @@ SketchLine_148.result().setName("SketchLine_44") SketchLine_147.setName("SketchLine_43") SketchLine_147.result().setName("SketchLine_43") model.do() -ExtrusionCut_12 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_2"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -Plane_9 = model.addPlane(Part_2_doc, model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_5&ExtrusionCut_3_1/Modfied_3&Extrusion_1_1/Generated_Face_1"), model.selection("VERTEX", "ExtrusionCut_3_1/Modfied_3&Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_7"), model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_5&ExtrusionCut_2_1/Modfied_5&ExtrusionCut_3_1/Modfied_3")) +ExtrusionCut_12 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Plane_9 = model.addPlane(Part_2_doc, model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10]"), model.selection("VERTEX", "[ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_4&ExtrusionCut_2_1/To_Face_2)][ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face]")) Sketch_15 = model.addSketch(Part_2_doc, model.selection("FACE", "Plane_1")) SketchArc_27 = Sketch_15.addArc(25, -7.50002056854448, 22, -7.5, 28, -7.5, True) SketchPoint_29 = Sketch_15.addPoint(22, -7.5) @@ -1345,11 +1345,11 @@ SketchConstraintVertical_30 = Sketch_15.setVertical(SketchLine_158.result()) SketchConstraintHorizontal_33 = Sketch_15.setHorizontal(SketchLine_157.result()) SketchConstraintHorizontal_33.setName("SketchConstraintHorizontal_12") model.do() -Plane_10 = model.addPlane(Part_2_doc, model.selection("FACE", "ExtrusionCut_3_1/Modfied_3"), 6, True) +Plane_10 = model.addPlane(Part_2_doc, model.selection("FACE", "ExtrusionCut_3_1/Modified_Face&Extrusion_1_1/To_Face"), 6, True) Plane_11 = model.addPlane(Part_2_doc, model.selection("FACE", "Plane_2"), 3, True) -ExtrusionCut_13 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2f-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), 3, 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) -ExtrusionCut_14 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2f-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection("FACE", "Plane_2"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) -Sketch_16 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_4_1/Modfied_6")) +ExtrusionCut_13 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2r-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), 3, 0, [model.selection("SOLID", "ExtrusionCut_3_1")]) +ExtrusionCut_14 = model.addExtrusionCut(Part_2_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_4_2r-SketchLine_52f-SketchLine_53f-SketchLine_54f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection("FACE", "Plane_2"), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) +Sketch_16 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_4_1/Modified_Face&Extrusion_1_1/To_Face")) SketchArc_28 = Sketch_16.addArc(46, 0, 45.5, 0, 46.5, 0, False) SketchLine_159 = Sketch_16.addLine(0, 0, 54, 0) SketchLine_159.setName("SketchLine_55") @@ -1399,8 +1399,8 @@ SketchLine_163.result().setName("SketchLine_59") SketchLine_162.setName("SketchLine_58") SketchLine_162.result().setName("SketchLine_58") model.do() -ExtrusionFuse_2 = model.addExtrusionFuse(Part_2_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchLine_10r-SketchLine_11r-SketchLine_12r-SketchLine_14r-SketchArc_2_2r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) -Sketch_17 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_2_1/Modfied_8")) +ExtrusionFuse_2 = model.addExtrusionFuse(Part_2_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchLine_14r-SketchLine_7f-SketchArc_1_2f-SketchLine_8f-SketchLine_9f-SketchArc_2_2r-SketchLine_12r-SketchLine_11r-SketchLine_10r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_5_1")]) +Sketch_17 = model.addSketch(Part_2_doc, model.selection("FACE", "(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_27)(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_26)(ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_4&ExtrusionCut_2_1/To_Face_2)(ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_28)")) SketchLine_170 = Sketch_17.addLine(50.25, -4.5, 31.25, -4.5) SketchLine_170.setName("SketchLine_76") SketchLine_170.result().setName("SketchLine_76") @@ -1574,7 +1574,7 @@ SketchConstraintRadius_16 = Sketch_17.setRadius(SketchArc_40.results()[1], 0.25) SketchConstraintRadius_16.setName("SketchConstraintRadius_10") model.do() ExtrusionCut_15 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), 0, 20, [model.selection("SOLID", "ExtrusionFuse_1_1")]) -Sketch_18 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_6_1/Modfied_10")) +Sketch_18 = model.addSketch(Part_2_doc, model.selection("FACE", "(ExtrusionFuse_1_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_76)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchArc_15_2)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_80)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchArc_17_2)(ExtrusionCut_6_1/Generated_Face&Sketch_7/SketchLine_79)(ExtrusionFuse_1_1/Modified_Face&Extrusion_1_1/To_Face)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10)")) SketchPoint_36 = Sketch_18.addPoint(54, 0) SketchPoint_37 = Sketch_18.addPoint(54, 0) SketchConstraintRigid_20 = Sketch_18.setFixed(SketchPoint_37.result()) @@ -1723,7 +1723,7 @@ SketchConstraintCoincidence_316 = Sketch_18.setCoincident(SketchPoint_45.coordin SketchConstraintCoincidence_316.setName("SketchConstraintCoincidence_145") model.do() ExtrusionCut_16 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection(), 10, 0, [model.selection("SOLID", "ExtrusionCut_6_1")]) -Sketch_19 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_7_1/Modfied_14")) +Sketch_19 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_7_1/Modified_Face&Extrusion_1_1/To_Face")) SketchLine_200 = Sketch_19.addLine(21, 4.163450069699051, 21, 0) SketchLine_200.setName("SketchLine_107") SketchLine_200.result().setName("SketchLine_107") @@ -1866,7 +1866,7 @@ model.do() Plane_12 = model.addPlane(Part_2_doc, model.selection("FACE", "Plane_2"), 4, False) Plane_13 = model.addPlane(Part_2_doc, model.selection("FACE", "Plane_2"), 4, True) ExtrusionCut_17 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection(), model.selection("FACE", "Plane_5"), 0, model.selection("FACE", "Plane_4"), 0, [model.selection("SOLID", "ExtrusionCut_7_1")]) -Sketch_20 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_8_1/Modfied_5")) +Sketch_20 = model.addSketch(Part_2_doc, model.selection("FACE", "ExtrusionCut_8_1/Modified_Face&Sketch_1/SketchLine_1")) SketchCircle_2 = Sketch_20.addCircle(12, 6, 1) SketchConstraintRadius_18 = Sketch_20.setRadius(SketchCircle_2.results()[1], 1) SketchPoint_48 = Sketch_20.addPoint(0, 6) @@ -1891,11 +1891,11 @@ SketchConstraintCoincidence_348 = Sketch_20.setCoincident(SketchCircle_2.center( SketchConstraintCoincidence_348.setName("SketchConstraintCoincidence_178") SketchConstraintDistance_34 = Sketch_20.setDistance(SketchLine_211.result(), SketchCircle_2.center(), 12, False) model.do() -ExtrusionCut_18 = model.addExtrusionCut(Part_2_doc, [model.selection("WIRE", "Sketch_10/Wire-SketchCircle_1_2f")], model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_8_1")]) +ExtrusionCut_18 = model.addExtrusionCut(Part_2_doc, [model.selection("WIRE", "Sketch_10/Face-SketchCircle_1_2r_wire")], model.selection(), 0, 0.75, [model.selection("SOLID", "ExtrusionCut_8_1")]) model.do() -Rotation_1 = model.addRotation(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("EDGE", "Part_1/ExtrusionCut_9_1/Modfied_1&ExtrusionCut_7_1/Modfied_19"), 180) -Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Rotation_1/")], model.selection("FACE", "Rotation_1/ExtrusionCut_5_1/Modfied_5"), model.selection("FACE", "Part_1/ExtrusionCut_5_1/Modfied_5"), False, True) -Rotation_2 = model.addRotation(partSet, [model.selection("COMPOUND", "Placement_1/")], model.selection("EDGE", "Part_1/ExtrusionCut_5_1/Modfied_5&ExtrusionCut_8_1/Modfied_3"), 7) +Rotation_1 = model.addRotation(partSet, [model.selection("COMPOUND", "Part_2/")], model.selection("EDGE", "Part_1/[ExtrusionCut_9_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_7_1/Modified_Face&Extrusion_1_1/From_Face]"), 180) +Placement_1 = model.addPlacement(partSet, [model.selection("COMPOUND", "Rotation_1/")], model.selection("FACE", "Rotation_1/ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_9"), model.selection("FACE", "Part_1/ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_9"), False, True) +Rotation_2 = model.addRotation(partSet, [model.selection("COMPOUND", "Placement_1/")], model.selection("EDGE", "Part_1/[ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_9][ExtrusionCut_8_1/Modified_Face&Sketch_3/SketchLine_35]"), 7) Rotation_2.result().setColor(255, 85, 0) model.end() diff --git a/test.models/ecran.py b/test.models/ecran.py index 1a0dc5ac0..597228c54 100644 --- a/test.models/ecran.py +++ b/test.models/ecran.py @@ -115,12 +115,12 @@ SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 2) SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 2.3) SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_5.result(), SketchLine_9.startPoint()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchLine_10f-SketchLine_11f-SketchLine_12f-SketchLine_13f-SketchLine_4f-SketchLine_8f-SketchLine_9f-SketchArc_1_2r-SketchArc_2_2f")], model.selection(), "307/2.", "307/2.") +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchLine_10f-SketchArc_1_2r-SketchLine_11f-SketchLine_4f-SketchLine_13f-SketchArc_2_2f-SketchLine_12f-SketchLine_8f-SketchLine_9f_wire")], model.selection(), "307/2.", "307/2.") Extrusion_1.setName("Profil") Extrusion_1.result().setName("Extrusion_1_1") -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_12")) SketchLine_14 = Sketch_2.addLine(149.5, -2.3, 153.5, -2.3) -SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1")) +SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_12][Extrusion_1_1/To_Face]")) SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchPoint_1.result()) SketchLine_15 = Sketch_2.addLine(153.5, -2.3, 153.5, 7.7) SketchLine_16 = Sketch_2.addLine(153.5, 7.7, 149.5, 7.7) @@ -150,25 +150,25 @@ SketchConstraintLength_5 = Sketch_2.setLength(SketchLine_21.result(), 10) SketchConstraintLength_5.setName("SketchConstraintLength_6") SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_16.endPoint(), SketchLine_21.result(), 299) SketchConstraintEqual_1 = Sketch_2.setEqual(SketchLine_16.result(), SketchLine_20.result()) -SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_3&Extrusion_1_1/From_Face_1")) +SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_12][Extrusion_1_1/From_Face]")) SketchPoint_2.setName("SketchPoint_4") SketchPoint_2.result().setName("SketchPoint_4") SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchLine_19.startPoint(), SketchPoint_2.coordinates()) SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_39") model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_6"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) ExtrusionCut_1.setName("Decoupe_Angle") ExtrusionCut_1.result().setName("ExtrusionCut_1_1") -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_2")) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8")) SketchLine_22 = Sketch_3.addLine(153.5, -10.3, 153.5, -8.3) SketchLine_22.setName("SketchLine_29") SketchLine_22.result().setName("SketchLine_29") -SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_2")) +SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9][ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8]")) SketchPoint_3.setName("SketchPoint_5") SketchPoint_3.result().setName("SketchPoint_5") SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchLine_22.startPoint(), SketchPoint_3.result()) SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_40") -SketchLine_23 = Sketch_3.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&Extrusion_1_1/Generated_Face_2")) +SketchLine_23 = Sketch_3.addLine(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8]")) SketchLine_23.setName("SketchLine_30") SketchLine_23.result().setName("SketchLine_30") SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_23.result()) @@ -193,7 +193,7 @@ SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_25.result(), 2) SketchConstraintLength_6.setName("SketchConstraintLength_8") SketchConstraintAngle_1 = Sketch_3.setAngleBackward(SketchLine_24.result(), SketchLine_25.result(), 45) SketchConstraintAngle_1.setName("SketchConstraintAngle_2") -SketchLine_26 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_8")) +SketchLine_26 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/SketchLine_8")) SketchLine_26.setName("SketchLine_34") SketchLine_26.result().setName("SketchLine_34") SketchConstraintMirror_1_objects = [SketchLine_22.result(), SketchLine_25.result(), SketchLine_24.result()] @@ -207,16 +207,16 @@ Sketch_3.result().setName("Sketch_4") ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_1_1")]) ExtrusionCut_2.setName("Chamfrein_1") ExtrusionCut_2.result().setName("ExtrusionCut_2_1") -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_5")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_13")) SketchLine_30 = Sketch_4.addLine(-149.5, 10.3, -149.5, 8.3) SketchLine_30.setName("SketchLine_35") SketchLine_30.result().setName("SketchLine_35") -SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_5&ExtrusionCut_1_1/Modfied_6")) +SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_21][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_13][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_4]")) SketchPoint_4.setName("SketchPoint_6") SketchPoint_4.result().setName("SketchPoint_6") SketchConstraintCoincidence_42 = Sketch_4.setCoincident(SketchLine_30.startPoint(), SketchPoint_4.result()) SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_43") -SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_11&ExtrusionCut_1_1/Modfied_5")) +SketchLine_31 = Sketch_4.addLine(model.selection("EDGE", "[ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_21][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_13]")) SketchLine_31.setName("SketchLine_36") SketchLine_31.result().setName("SketchLine_36") SketchConstraintCoincidence_43 = Sketch_4.setCoincident(SketchLine_30.endPoint(), SketchLine_31.result()) @@ -260,7 +260,7 @@ SketchLine_38.setName("SketchLine_43") SketchLine_38.result().setName("SketchLine_43") SketchLine_38.setAuxiliary(True) SketchConstraintHorizontal_10 = Sketch_4.setHorizontal(SketchLine_38.result()) -SketchProjection_1 = Sketch_4.addProjection(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_2")) +SketchProjection_1 = Sketch_4.addProjection(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), False) SketchLine_39 = SketchProjection_1.createdFeature() SketchLine_39.setName("SketchLine_44") SketchLine_39.result().setName("SketchLine_44") @@ -291,15 +291,15 @@ SketchConstraintCoincidence_54.setName("SketchConstraintCoincidence_59") model.do() Sketch_4.setName("Sketch_5") Sketch_4.result().setName("Sketch_5") -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_7"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_3")) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_5")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_11"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_12")) SketchLine_40 = Sketch_5.addLine(152.2999838762584, -21.04999053274691, 153.5, -21.04999053274714) SketchLine_40.setName("SketchLine_58") SketchLine_40.result().setName("SketchLine_58") SketchLine_41 = Sketch_5.addLine(152.2999838292651, -45.04999053274704, 153.5, -45.04999053274702) SketchLine_41.setName("SketchLine_57") SketchLine_41.result().setName("SketchLine_57") -SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_1_1/Modfied_3")) +SketchLine_42 = Sketch_5.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_12]")) SketchLine_42.setName("SketchLine_46") SketchLine_42.result().setName("SketchLine_46") SketchLine_43 = Sketch_5.addLine(150.8, -45.04999053274702, 153.5, -45.04999053274702) @@ -385,7 +385,7 @@ SketchLine_55.result().setName("SketchLine_54") SketchLine_55.setAuxiliary(True) SketchConstraintCoincidence_66 = Sketch_5.setCoincident(SketchPoint_5.coordinates(), SketchLine_55.startPoint()) SketchConstraintCoincidence_66.setName("SketchConstraintCoincidence_71") -SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_1_1/Modfied_9")) +SketchLine_56 = Sketch_5.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_10]")) SketchLine_56.setName("SketchLine_55") SketchLine_56.result().setName("SketchLine_55") SketchConstraintCoincidence_67 = Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchLine_56.result()) @@ -509,8 +509,9 @@ SketchLine_68.result().setName("SketchLine_73") model.do() Sketch_5.setName("Sketch_6") Sketch_5.result().setName("Sketch_6") -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_6/Wire-SketchArc_9_2f-SketchArc_10_2f-SketchLine_73r-SketchLine_74r-SketchLine_75r-SketchLine_76r"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_58f-SketchLine_61f-SketchLine_60f-SketchLine_51f-SketchArc_4_2f-SketchArc_5_2f"), model.selection("WIRE", "Sketch_6/Wire-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchLine_63f-SketchArc_3_2f-SketchArc_6_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")]) -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modfied_1")) +ExtrusionCut_4_objects_1 = [model.selection("WIRE", "Sketch_6/Face-SketchArc_9_2f-SketchLine_74r-SketchArc_10_2f-SketchLine_75r-SketchLine_73r-SketchLine_76r_wire"), model.selection("WIRE", "Sketch_6/Face-SketchLine_58r-SketchLine_51f-SketchLine_60f-SketchArc_5_2f-SketchLine_61f-SketchArc_4_2f_wire"), model.selection("WIRE", "Sketch_6/Face-SketchLine_57f-SketchLine_47f-SketchLine_62f-SketchArc_6_2f-SketchLine_63f-SketchArc_3_2f_wire")] +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_4_objects_1, model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_3_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_4_1/Modified_Face&Sketch_1/SketchLine_12")) SketchArc_11 = Sketch_6.addArc(44.89, -23.55, 43.89, -23.55, 44.89, -22.55, False) SketchArc_12 = Sketch_6.addArc(44.89, -13.55, 44.89, -14.55, 43.89, -13.55, False) SketchArc_13 = Sketch_6.addArc(5.89, -13.55, 6.89, -13.55, 5.89, -14.55, False) @@ -567,7 +568,7 @@ SketchLine_80 = Sketch_6.addLine(model.selection("EDGE", "PartSet/OY")) SketchLine_80.setName("SketchLine_85") SketchLine_80.result().setName("SketchLine_85") SketchConstraintDistance_12 = Sketch_6.setDistance(SketchLine_79.startPoint(), SketchLine_80.result(), 5.89) -SketchLine_81 = Sketch_6.addLine(model.selection("EDGE", "Sketch_6/Edge-SketchLine_54")) +SketchLine_81 = Sketch_6.addLine(model.selection("EDGE", "Sketch_6/SketchLine_54")) SketchLine_81.setName("SketchLine_86") SketchLine_81.result().setName("SketchLine_86") SketchConstraintDistance_13 = Sketch_6.setDistance(SketchLine_76.endPoint(), SketchLine_81.result(), 5.3) @@ -845,15 +846,16 @@ SketchArc_35.results()[1].setName("SketchArc_36_2") model.do() Sketch_6.setName("Sketch_7") Sketch_6.result().setName("Sketch_7") -ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_20_2f-SketchArc_21_2f-SketchArc_22_2f-SketchArc_23_2f-SketchLine_91r-SketchLine_92f-SketchLine_93r-SketchLine_94f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_52_2f-SketchArc_53_2f-SketchArc_56_2f-SketchArc_57_2f-SketchLine_114r-SketchLine_115f-SketchLine_116r-SketchLine_121f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_44_2f-SketchArc_45_2f-SketchArc_48_2f-SketchArc_49_2f-SketchLine_107f-SketchLine_113f-SketchLine_117r-SketchLine_123r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2f-SketchArc_17_2f-SketchArc_18_2f-SketchArc_19_2f-SketchLine_87f-SketchLine_88f-SketchLine_89r-SketchLine_90r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchArc_14_2f-SketchLine_81f-SketchLine_82r-SketchLine_83f-SketchLine_84r-SketchArc_15_2f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_36_2f-SketchArc_38_2f-SketchArc_40_2f-SketchArc_41_2f-SketchLine_108r-SketchLine_119r-SketchLine_127f-SketchLine_129f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_37_2f-SketchArc_39_2f-SketchArc_42_2f-SketchArc_43_2f-SketchLine_118r-SketchLine_120f-SketchLine_122r-SketchLine_130f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_24_2f-SketchArc_25_2f-SketchArc_26_2f-SketchArc_27_2f-SketchLine_98f-SketchLine_100r-SketchLine_101f-SketchLine_103r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_30_2f-SketchArc_31_2f-SketchArc_34_2f-SketchArc_35_2f-SketchLine_95f-SketchLine_96r-SketchLine_97f-SketchLine_105r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_46_2f-SketchArc_47_2f-SketchArc_50_2f-SketchArc_51_2f-SketchLine_124f-SketchLine_125r-SketchLine_126f-SketchLine_128r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_54_2f-SketchArc_55_2f-SketchArc_58_2f-SketchArc_59_2f-SketchLine_109f-SketchLine_110r-SketchLine_111r-SketchLine_112f"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_28_2f-SketchArc_29_2f-SketchArc_32_2f-SketchArc_33_2f-SketchLine_99r-SketchLine_102f-SketchLine_104f-SketchLine_106r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")]) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modfied_1")) +ExtrusionCut_5_objects_1 = [model.selection("WIRE", "Sketch_7/Face-SketchArc_20_2f-SketchLine_93r-SketchArc_21_2f-SketchLine_91r-SketchArc_23_2f-SketchLine_94f-SketchArc_22_2f-SketchLine_92f_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_52_2f-SketchLine_116r-SketchArc_53_2f-SketchLine_115f-SketchArc_57_2f-SketchLine_121f-SketchArc_56_2f-SketchLine_114r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_44_2f-SketchLine_117r-SketchArc_45_2f-SketchLine_113f-SketchArc_49_2f-SketchLine_107f-SketchArc_48_2f-SketchLine_123r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_16_2f-SketchLine_90r-SketchArc_17_2f-SketchLine_88f-SketchArc_19_2f-SketchLine_87f-SketchArc_18_2f-SketchLine_89r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_11_2r-SketchLine_83f-SketchArc_12_2f-SketchLine_82r-SketchArc_14_2f-SketchLine_84r-SketchArc_15_2f-SketchLine_81f_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_36_2f-SketchLine_119r-SketchArc_38_2f-SketchLine_129f-SketchArc_41_2f-SketchLine_127f-SketchArc_40_2f-SketchLine_108r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_37_2f-SketchLine_130f-SketchArc_42_2f-SketchLine_122r-SketchArc_43_2f-SketchLine_118r-SketchArc_39_2f-SketchLine_120f_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_24_2f-SketchLine_103r-SketchArc_26_2f-SketchLine_98f-SketchArc_27_2f-SketchLine_101f-SketchArc_25_2f-SketchLine_100r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_30_2f-SketchLine_105r-SketchArc_34_2f-SketchLine_97f-SketchArc_35_2f-SketchLine_95f-SketchArc_31_2f-SketchLine_96r_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_46_2f-SketchLine_124f-SketchArc_50_2f-SketchLine_125r-SketchArc_51_2f-SketchLine_128r-SketchArc_47_2f-SketchLine_126f_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_54_2f-SketchLine_112f-SketchArc_58_2f-SketchLine_110r-SketchArc_59_2f-SketchLine_111r-SketchArc_55_2f-SketchLine_109f_wire"), model.selection("WIRE", "Sketch_7/Face-SketchArc_28_2f-SketchLine_102f-SketchArc_29_2f-SketchLine_104f-SketchArc_33_2f-SketchLine_99r-SketchArc_32_2f-SketchLine_106r_wire")] +ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_5_objects_1, model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_4_1")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_5_1/Modified_Face&Sketch_1/SketchLine_12")) SketchLine_126 = Sketch_7.addLine(-153.5, -37.05, -152.3, -37.05) SketchLine_126.setName("SketchLine_135") SketchLine_126.result().setName("SketchLine_135") SketchLine_127 = Sketch_7.addLine(-150.8, -38.55, -150.8, -43.55) SketchLine_127.setName("SketchLine_138") SketchLine_127.result().setName("SketchLine_138") -SketchPoint_10 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/Vertex-SketchLine_67s-SketchLine_68e-SketchLine_69e")) +SketchPoint_10 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/SketchLine_67_StartVertex")) SketchPoint_10.setName("SketchPoint_12") SketchPoint_10.result().setName("SketchPoint_12") SketchLine_128 = Sketch_7.addLine(-150.8, -45.05, -153.5, -45.05) @@ -888,7 +890,7 @@ SketchConstraintHorizontal_18 = Sketch_7.setHorizontal(SketchLine_128.result()) SketchConstraintVertical_15 = Sketch_7.setVertical(SketchLine_129.result()) SketchConstraintHorizontal_19 = Sketch_7.setHorizontal(SketchLine_132.result()) SketchConstraintVertical_16 = Sketch_7.setVertical(SketchLine_131.result()) -SketchPoint_11 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/Vertex-SketchLine_70s-SketchLine_72s-SketchLine_71e")) +SketchPoint_11 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_6/SketchLine_70_StartVertex")) SketchPoint_11.setName("SketchPoint_13") SketchPoint_11.result().setName("SketchPoint_13") SketchConstraintCoincidence_118 = Sketch_7.setCoincident(SketchLine_132.endPoint(), SketchPoint_11.result()) @@ -939,7 +941,7 @@ model.do() Sketch_7.setName("Sketch_8") Sketch_7.result().setName("Sketch_8") ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_5_1")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_6_1/Modfied_2")) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_6_1/Modified_Face&Sketch_1/SketchLine_10")) SketchLine_134 = Sketch_8.addLine(0.85, 50.75, -0.85, 50.75) SketchLine_134.setName("SketchLine_139") SketchLine_134.result().setName("SketchLine_139") @@ -1019,7 +1021,7 @@ SketchConstraintCoincidence_148.setName("SketchConstraintCoincidence_158") SketchConstraintCoincidence_149 = Sketch_8.setCoincident(SketchArc_62.startPoint(), SketchLine_134.endPoint()) SketchConstraintCoincidence_149.setName("SketchConstraintCoincidence_159") SketchConstraintCoincidence_150 = Sketch_8.setCoincident(SketchArc_62.center(), SketchLine_137.result()) -SketchLine_140 = Sketch_8.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_6_1/Modfied_2")) +SketchLine_140 = Sketch_8.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_6_1/Modified_Face&Sketch_1/SketchLine_10]")) SketchLine_140.setName("SketchLine_145") SketchLine_140.result().setName("SketchLine_145") SketchConstraintDistance_18 = Sketch_8.setDistance(SketchLine_140.result(), SketchPoint_12.coordinates(), 6) @@ -1061,7 +1063,7 @@ SketchArc_65.results()[1].setName("SketchArc_66_2") model.do() Sketch_8.setName("Sketch_9") Sketch_8.result().setName("Sketch_9") -ExtrusionCut_7 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchLine_147f-SketchLine_148f-SketchArc_64_2f-SketchArc_65_2f"), model.selection("FACE", "Sketch_9/Face-SketchLine_139f-SketchLine_141f-SketchArc_63_2f-SketchArc_62_2f"), model.selection("FACE", "Sketch_9/Face-SketchArc_66_2f-SketchArc_67_2f-SketchLine_149r-SketchLine_150r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_6_1")]) +ExtrusionCut_7 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchLine_147f-SketchArc_65_2f-SketchLine_148f-SketchArc_64_2f"), model.selection("FACE", "Sketch_9/Face-SketchLine_139r-SketchArc_62_2f-SketchLine_141f-SketchArc_63_2f"), model.selection("FACE", "Sketch_9/Face-SketchArc_66_2f-SketchLine_150r-SketchArc_67_2f-SketchLine_149r")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_6_1")]) model.do() # Test reexecution after parameter change diff --git a/test.models/flange.py b/test.models/flange.py index bf7d9362d..256e55d5c 100644 --- a/test.models/flange.py +++ b/test.models/flange.py @@ -65,7 +65,7 @@ SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), SketchConst [SketchArc_5, SketchArc_6, SketchLine_6, SketchLine_7, SketchLine_8, SketchArc_7, SketchArc_8] = SketchConstraintMirror_1.mirrored() SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], "dint/2") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_2_2r-SketchArc_3_2r-SketchArc_4_2f-SketchArc_5_2r-SketchArc_6_2f-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchArc_7_2r-SketchArc_8_2f")], model.selection(), 35, 35) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_3_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_4_2f-SketchArc_2_2r-SketchArc_5_2r-SketchArc_6_2f-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchArc_7_2r-SketchArc_8_2f")], model.selection(), 35, 35) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchArc_9 = Sketch_2.addArc(0, 106, 0, 78, 0, 134, True) SketchConstraintRadius_3 = Sketch_2.setRadius(SketchArc_9.results()[1], 28) @@ -79,7 +79,7 @@ SketchLine_11 = Sketch_2.addLine(0, 78, 0, 134) SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchArc_9.startPoint(), SketchLine_11.startPoint()) SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchArc_9.endPoint(), SketchLine_11.endPoint()) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_9_2f-SketchLine_11f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_9_2r-SketchLine_11f")], model.selection("EDGE", "PartSet/OZ"), 360, 0) Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_1_1")]) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ")) SketchLine_12 = Sketch_3.addLine(0, 106, -4, 106) @@ -110,9 +110,9 @@ SketchLine_16.setName("SketchLine_17") SketchLine_16.result().setName("SketchLine_17") SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchArc_10.endPoint(), SketchLine_16.result()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_12f-SketchLine_13f-SketchArc_10_2f-SketchLine_17r-SketchLine_18r")], model.selection(), "172/2", "172/2") +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_12r-SketchLine_13f-SketchArc_10_2f-SketchLine_17r-SketchLine_18r_wire")], model.selection(), "172/2", "172/2") Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("SOLID", "Extrusion_2_1")]) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_10")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5")) SketchLine_18 = Sketch_4.addLine(-65, 16, -65, -16) SketchLine_18.setName("SketchLine_19") SketchLine_18.result().setName("SketchLine_19") @@ -149,8 +149,8 @@ SketchConstraintTangent_5 = Sketch_4.setTangent(SketchLine_20.result(), SketchAr SketchConstraintTangent_6 = Sketch_4.setTangent(SketchLine_21.result(), SketchArc_11.results()[1]) SketchConstraintTangent_7 = Sketch_4.setTangent(SketchArc_12.results()[1], SketchLine_20.result()) model.do() -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Wire-SketchArc_11_2f-SketchArc_12_2f-SketchLine_21f-SketchLine_22r")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face_12"), 0) -MultiTranslation_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1")], model.selection("EDGE", "Extrusion_1_1/To_Face_1&Extrusion_1_1/Generated_Face_12"), -130, 2) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Face-SketchArc_11_2f-SketchLine_21f-SketchArc_12_2f-SketchLine_22r_wire")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0) +LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1")], model.selection("EDGE", "[Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]"), -130, 2) Cut_3 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_2_1")], [model.selection("COMPOUND", "LinearCopy_1_1")]) model.do() diff --git a/test.models/gear.py b/test.models/gear.py index 217e25a83..3b0a64de9 100644 --- a/test.models/gear.py +++ b/test.models/gear.py @@ -162,8 +162,8 @@ SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_83.result()) SketchConstraintLength_9 = Sketch_3.setLength(SketchLine_84.result(), "2*R_fillet") SketchConstraintLength_10 = Sketch_3.setLength(SketchLine_83.result(), "2*R_fillet") model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_1"), 360, 0) -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_1")) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/SketchLine_1"), 360, 0) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_8")) SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchLine_86 = Sketch_4.addLine(0, -13.49999999999519, 3.1, -13.49999999999519) SketchLine_87 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OZ")) @@ -195,7 +195,7 @@ SketchConstraintCoincidence_61 = Sketch_4.setCoincident(SketchPoint_6.coordinate SketchConstraintCoincidence_62 = Sketch_4.setCoincident(SketchPoint_6.coordinates(), SketchLine_89.result()) SketchConstraintDistance_6 = Sketch_4.setDistance(SketchPoint_6.coordinates(), SketchLine_86.result(), 24.5) model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face_5"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_3"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")]) RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 0, 360, [model.selection("SOLID", "ExtrusionCut_1_1")]) ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 0, 5, [model.selection("SOLID", "RevolutionCut_1_1")]) model.do() diff --git a/test.models/idler_plate.py b/test.models/idler_plate.py index c00585ba7..9c105d2ea 100644 --- a/test.models/idler_plate.py +++ b/test.models/idler_plate.py @@ -131,13 +131,13 @@ SketchConstraintRadius_10 = Sketch_1.setRadius(SketchArc_16.results()[1], 6.25) SketchConstraintRadius_11 = Sketch_1.setRadius(SketchArc_13.results()[1], 6.25) SketchConstraintTangent_14 = Sketch_1.setTangent(SketchLine_6.result(), SketchArc_8.results()[1]) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_2_2r-SketchArc_3_2f-SketchArc_4_2r-SketchArc_5_2r-SketchArc_6_2r-SketchLine_3r-SketchLine_4f-SketchArc_7_2r-SketchCircle_1_2r-SketchCircle_2_2r-SketchArc_8_2f-SketchArc_9_2f-SketchArc_10_2r-SketchLine_6r-SketchArc_11_2f-SketchLine_7f-SketchArc_12_2f-SketchArc_13_2r-SketchArc_14_2f-SketchArc_15_2f-SketchArc_16_2r")], model.selection(), 0, 2) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_8_2f-SketchLine_7f-SketchArc_11_2f-SketchArc_13_2r-SketchArc_12_2f-SketchArc_14_2f-SketchArc_15_2f-SketchArc_16_2r-SketchArc_9_2f-SketchArc_10_2r-SketchLine_6r-SketchCircle_1_2r-SketchArc_3_2f-SketchArc_5_2r-SketchArc_4_2r-SketchArc_2_2r-SketchLine_3r-SketchArc_7_2r-SketchLine_4f-SketchArc_6_2r-SketchCircle_2_2r")], model.selection(), 0, 2) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) -SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_7")) +SketchPoint_1 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchArc_7")) SketchArc_17 = Sketch_2.addArc(-24.92, -4.314010717669617e-016, -24.92, 7.500000000006299, -24.92, -7.500000000006299, True) SketchConstraintCoincidence_41 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchArc_17.center()) -SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_8_2s-SketchLine_6s")) -SketchPoint_3 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Vertex-SketchArc_6-SketchArc_8")) +SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchArc_8_2_StartVertex")) +SketchPoint_3 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchArc_6")) SketchArc_18 = Sketch_2.addArc(-34.92, 0, -34.91999999999937, 7.500000000006299, -34.92003434105975, -7.500000000006299, False) SketchConstraintCoincidence_42 = Sketch_2.setCoincident(SketchPoint_3.result(), SketchArc_18.center()) SketchConstraintCoincidence_43 = Sketch_2.setCoincident(SketchPoint_2.result(), SketchArc_18.startPoint()) @@ -151,19 +151,19 @@ SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_8.result()) SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_9.result()) SketchConstraintTangent_15 = Sketch_2.setTangent(SketchLine_8.result(), SketchArc_17.results()[1]) SketchConstraintTangent_16 = Sketch_2.setTangent(SketchArc_17.results()[1], SketchLine_9.result()) -SketchPoint_4 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Edge-SketchCircle_2_2__cc")) +SketchPoint_4 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchCircle_2_2__cc")) SketchCircle_3 = Sketch_2.addCircle(-7.5, 18.75, 8.125) SketchConstraintCoincidence_48 = Sketch_2.setCoincident(SketchPoint_4.result(), SketchCircle_3.center()) -SketchArc_19 = Sketch_2.addArc(model.selection("EDGE", "Sketch_1/Edge-SketchArc_9_2")) +SketchArc_19 = Sketch_2.addArc(model.selection("EDGE", "Sketch_1/SketchArc_9_2")) SketchConstraintEqual_1 = Sketch_2.setEqual(SketchCircle_3.results()[1], SketchArc_19.results()[1]) -SketchPoint_5 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/Edge-SketchCircle_1_2__cc")) +SketchPoint_5 = Sketch_2.addPoint(model.selection("VERTEX", "Sketch_1/SketchCircle_1_2__cc")) SketchCircle_4 = Sketch_2.addCircle(0, 0, 8.75) SketchConstraintCoincidence_49 = Sketch_2.setCoincident(SketchPoint_5.result(), SketchCircle_4.center()) SketchConstraintRadius_12 = Sketch_2.setRadius(SketchCircle_4.results()[1], "17.5/2") model.do() -Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchLine_8"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_17_2"), model.selection("EDGE", "Sketch_2/Edge-SketchLine_9"), model.selection("EDGE", "Sketch_2/Edge-SketchArc_18_2"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_6_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_3"), model.selection("EDGE", "Sketch_1/Edge-SketchArc_7_2"), model.selection("EDGE", "Sketch_1/Edge-SketchLine_4")]) -Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_3_2"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2")]) -Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchCircle_4_2"), model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")]) +Face_1 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_8"), model.selection("EDGE", "Sketch_2/SketchArc_17_2"), model.selection("EDGE", "Sketch_2/SketchLine_9"), model.selection("EDGE", "Sketch_2/SketchArc_18_2"), model.selection("EDGE", "Sketch_1/SketchArc_6_2"), model.selection("EDGE", "Sketch_1/SketchLine_3"), model.selection("EDGE", "Sketch_1/SketchArc_7_2"), model.selection("EDGE", "Sketch_1/SketchLine_4")]) +Face_2 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchCircle_3_2"), model.selection("EDGE", "Sketch_1/SketchCircle_2_2")]) +Face_3 = model.addFace(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchCircle_4_2"), model.selection("EDGE", "Sketch_1/SketchCircle_1_2")]) Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Face_1_1"), model.selection("FACE", "Face_2_1"), model.selection("FACE", "Face_3_1")], model.selection(), 2, 0) Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_2_2"), model.selection("SOLID", "Extrusion_2_3")], []) model.do() diff --git a/test.models/piece_02.py b/test.models/piece_02.py index 95025acd1..ea2d58dd6 100644 --- a/test.models/piece_02.py +++ b/test.models/piece_02.py @@ -70,28 +70,28 @@ SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 36) SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_5.result(), 32) SketchConstraintTangent_8 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_6.result()) model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_3f-SketchLine_5r-SketchLine_6r-SketchArc_1_2f-SketchArc_2_2f-SketchArc_3_2f-SketchArc_4_2f")], model.selection(), 76, 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchLine_7 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_3_2f-SketchLine_3f-SketchArc_4_2f-SketchLine_6r-SketchArc_2_2f-SketchLine_5r-SketchArc_1_2f-SketchLine_1r")], model.selection(), 76, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchLine_7 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/To_Face]")) SketchLine_7.setName("SketchLine_8") SketchLine_7.result().setName("SketchLine_8") SketchLine_8 = Sketch_2.addLine(21, 45.99999999998655, 20.99999999998684, 0) SketchLine_8.setName("SketchLine_9") SketchLine_8.result().setName("SketchLine_9") SketchLine_8.setAuxiliary(True) -SketchLine_9 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/To_Face_1")) +SketchLine_9 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/To_Face]")) SketchLine_9.setName("SketchLine_10") SketchLine_9.result().setName("SketchLine_10") SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_8.startPoint(), SketchLine_9.result()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_18") -SketchLine_10 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/To_Face_1")) +SketchLine_10 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/To_Face]")) SketchLine_10.setName("SketchLine_11") SketchLine_10.result().setName("SketchLine_11") SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_10.result()) SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_19") SketchConstraintMiddle_1 = Sketch_2.setMiddlePoint(SketchLine_8.startPoint(), SketchLine_9.result()) SketchConstraintMiddle_2 = Sketch_2.setMiddlePoint(SketchLine_8.endPoint(), SketchLine_10.result()) -SketchLine_11 = Sketch_2.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/To_Face_1")) +SketchLine_11 = Sketch_2.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/To_Face]")) SketchLine_11.setName("SketchLine_12") SketchLine_11.result().setName("SketchLine_12") SketchPoint_1 = Sketch_2.addPoint(20.99999999999342, 22.99999999999327) @@ -128,8 +128,8 @@ SketchConstraintMiddle_4 = Sketch_2.setMiddlePoint(SketchLine_12.endPoint(), Ske SketchConstraintRadius_3 = Sketch_2.setRadius(SketchCircle_2.results()[1], 2.5) SketchConstraintDistance_3 = Sketch_2.setDistance(SketchLine_12.result(), SketchCircle_4.center(), 8) model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchCircle_1_2f"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_2_2r"), model.selection("WIRE", "Sketch_2/Wire-SketchCircle_3_2f")], model.selection(), 0, 15, [model.selection("SOLID", "Extrusion_1_1")]) -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/From_Face_1"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f-SketchCircle_2_2r-SketchCircle_3_2r-SketchCircle_4_2r_wire"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2f-SketchCircle_2_2r-SketchCircle_3_2r-SketchCircle_4_2r_wire_2"), model.selection("WIRE", "Sketch_2/Face-SketchCircle_3_2f_wire")], model.selection(), 0, 15, [model.selection("SOLID", "Extrusion_1_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_4_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/From_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) SketchCircle_5 = Sketch_3.addCircle(20.99999999999342, 22.99999999999327, 19) SketchConstraintRadius_4 = Sketch_3.setRadius(SketchCircle_5.results()[1], 19) @@ -137,12 +137,12 @@ SketchLine_13 = Sketch_3.addLine(41.99999999999999, 22.99999999998655, 0, 22.999 SketchLine_13.setName("SketchLine_14") SketchLine_13.result().setName("SketchLine_14") SketchLine_13.setAuxiliary(True) -SketchLine_14 = Sketch_3.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&Extrusion_1_1/Generated_Face_5")) +SketchLine_14 = Sketch_3.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]")) SketchLine_14.setName("SketchLine_15") SketchLine_14.result().setName("SketchLine_15") SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_13.startPoint(), SketchLine_14.result()) SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_27") -SketchLine_15 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_2_1/Modfied_2")) +SketchLine_15 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face]")) SketchLine_15.setName("SketchLine_16") SketchLine_15.result().setName("SketchLine_16") SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_15.result()) @@ -151,12 +151,12 @@ SketchLine_16 = Sketch_3.addLine(21, 45.99999999998655, 20.99999999998684, 0) SketchLine_16.setName("SketchLine_17") SketchLine_16.result().setName("SketchLine_17") SketchLine_16.setAuxiliary(True) -SketchLine_17 = Sketch_3.addLine(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&Extrusion_1_1/Generated_Face_3")) +SketchLine_17 = Sketch_3.addLine(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5]")) SketchLine_17.setName("SketchLine_18") SketchLine_17.result().setName("SketchLine_18") SketchConstraintCoincidence_28 = Sketch_3.setCoincident(SketchLine_16.startPoint(), SketchLine_17.result()) SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_29") -SketchLine_18 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_3")) +SketchLine_18 = Sketch_3.addLine(model.selection("EDGE", "Sketch_1/SketchLine_3")) SketchLine_18.setName("SketchLine_19") SketchLine_18.result().setName("SketchLine_19") SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_18.result()) @@ -182,26 +182,26 @@ SketchConstraintRadius_5 = Sketch_3.setRadius(SketchCircle_7.results()[1], 2.5) SketchConstraintDistance_4 = Sketch_3.setDistance(SketchCircle_6.center(), SketchCircle_7.center(), 16) SketchConstraintDistance_5 = Sketch_3.setDistance(SketchCircle_6.center(), SketchLine_16.result(), 8) model.do() -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2f-SketchCircle_6_2r-SketchCircle_7_2r")], model.selection(), 15, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2r-SketchCircle_7_2r-SketchCircle_6_2r")], model.selection(), 15, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) ExtrusionCut_3.result().setName("ExtrusionCut_3_1") -Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_3")) -SketchProjection_1 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&Extrusion_1_1/Generated_Face_2")) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5")) +SketchProjection_1 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2]"), False) SketchLine_19 = SketchProjection_1.createdFeature() SketchLine_19.setName("SketchLine_20") SketchLine_19.result().setName("SketchLine_20") -SketchProjection_2 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_5&Extrusion_1_1/Generated_Face_4")) +SketchProjection_2 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), False) SketchLine_20 = SketchProjection_2.createdFeature() SketchLine_20.setName("SketchLine_21") SketchLine_20.result().setName("SketchLine_21") SketchLine_21 = Sketch_4.addLine(4.999999999999999, -28, 37, -28) SketchLine_21.setName("SketchLine_22") SketchLine_21.result().setName("SketchLine_22") -SketchLine_22 = Sketch_4.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_3")) +SketchLine_22 = Sketch_4.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5]")) SketchLine_22.setName("SketchLine_23") SketchLine_22.result().setName("SketchLine_23") SketchConstraintCoincidence_34 = Sketch_4.setCoincident(SketchLine_21.startPoint(), SketchLine_22.result()) SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_35") -SketchLine_23 = Sketch_4.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_4")) +SketchLine_23 = Sketch_4.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_2_2]")) SketchLine_23.setName("SketchLine_24") SketchLine_23.result().setName("SketchLine_24") SketchConstraintCoincidence_35 = Sketch_4.setCoincident(SketchLine_21.endPoint(), SketchLine_23.result()) @@ -266,8 +266,8 @@ SketchConstraintMiddle_10 = Sketch_4.setMiddlePoint(SketchLine_27.endPoint(), Sk SketchConstraintMiddle_11 = Sketch_4.setMiddlePoint(SketchLine_27.startPoint(), SketchLine_19.result()) SketchConstraintMiddle_12 = Sketch_4.setMiddlePoint(SketchLine_25.result(), SketchLine_27.startPoint()) model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_22r-SketchLine_25f-SketchLine_26f-SketchLine_27r-SketchArc_5_2f-SketchArc_6_2f-SketchArc_7_2f-SketchArc_8_2f")], model.selection(), 2, 17) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face_1")) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchArc_5_2f-SketchLine_26f-SketchArc_6_2f-SketchLine_25f-SketchArc_8_2f-SketchLine_27r-SketchArc_7_2f-SketchLine_22r")], model.selection(), 2, 17) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face")) SketchLine_28 = Sketch_5.addLine(5.000000000000001, -46, 37.00000000000001, -46) SketchLine_28.setName("SketchLine_29") SketchLine_28.result().setName("SketchLine_29") @@ -286,19 +286,19 @@ SketchConstraintVertical_2 = Sketch_5.setVertical(SketchLine_30.result()) SketchConstraintVertical_3 = Sketch_5.setVertical(SketchLine_31.result()) SketchConstraintEqual_8 = Sketch_5.setEqual(SketchLine_29.result(), SketchLine_28.result()) SketchConstraintEqual_9 = Sketch_5.setEqual(SketchLine_31.result(), SketchLine_30.result()) -SketchLine_32 = Sketch_5.addLine(model.selection("EDGE", "Extrusion_2_1/Generated_Face_7&Extrusion_2_1/To_Face_1")) +SketchLine_32 = Sketch_5.addLine(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_4/SketchLine_26][Extrusion_2_1/To_Face]")) SketchLine_32.setName("SketchLine_33") SketchLine_32.result().setName("SketchLine_33") SketchConstraintDistance_7 = Sketch_5.setDistance(SketchLine_30.endPoint(), SketchLine_32.result(), 2) -SketchLine_33 = Sketch_5.addLine(model.selection("EDGE", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/To_Face_1")) +SketchLine_33 = Sketch_5.addLine(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_4/SketchLine_27][Extrusion_2_1/To_Face]")) SketchLine_33.setName("SketchLine_34") SketchLine_33.result().setName("SketchLine_34") SketchConstraintDistance_8 = Sketch_5.setDistance(SketchLine_31.startPoint(), SketchLine_33.result(), 2) -SketchLine_34 = Sketch_5.addLine(model.selection("EDGE", "Extrusion_2_1/Generated_Face_1&Extrusion_2_1/To_Face_1")) +SketchLine_34 = Sketch_5.addLine(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_4/SketchLine_22][Extrusion_2_1/To_Face]")) SketchLine_34.setName("SketchLine_35") SketchLine_34.result().setName("SketchLine_35") SketchConstraintDistance_9 = Sketch_5.setDistance(SketchLine_29.startPoint(), SketchLine_34.result(), 2) -SketchLine_35 = Sketch_5.addLine(model.selection("EDGE", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/To_Face_1")) +SketchLine_35 = Sketch_5.addLine(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_4/SketchLine_25][Extrusion_2_1/To_Face]")) SketchLine_35.setName("SketchLine_36") SketchLine_35.result().setName("SketchLine_36") SketchConstraintDistance_10 = Sketch_5.setDistance(SketchLine_28.startPoint(), SketchLine_35.result(), 2) @@ -363,7 +363,7 @@ SketchConstraintMiddle_15 = Sketch_5.setMiddlePoint(SketchLine_37.startPoint(), SketchConstraintMiddle_16 = Sketch_5.setMiddlePoint(SketchLine_37.endPoint(), SketchLine_35.result()) SketchConstraintDistance_12 = Sketch_5.setDistance(SketchCircle_8.center(), SketchLine_37.result(), 8) model.do() -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_5/Wire-SketchLine_29f-SketchLine_30r-SketchLine_31r-SketchLine_32r-SketchArc_9_2f-SketchArc_10_2f-SketchArc_11_2f-SketchArc_12_2f")], model.selection(), 0, 15, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "ExtrusionCut_3_1")]) +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_5/Face-SketchLine_29r-SketchArc_12_2f-SketchLine_32r-SketchArc_11_2f-SketchLine_30r-SketchArc_9_2f-SketchLine_31r-SketchArc_10_2f-SketchCircle_9_2r-SketchCircle_8_2r_wire")], model.selection(), 0, 15, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "ExtrusionCut_3_1")]) ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchCircle_8_2f"), model.selection("FACE", "Sketch_5/Face-SketchCircle_9_2f")], model.selection(), 0, 20, [model.selection("SOLID", "ExtrusionCut_4_1"), model.selection("SOLID", "ExtrusionCut_4_2")]) Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ")) SketchLine_38 = Sketch_6.addLine(-59, 44, -59, 2) @@ -420,33 +420,33 @@ SketchConstraintLength_3 = Sketch_6.setLength(SketchLine_38.result(), 42) SketchConstraintLength_4 = Sketch_6.setLength(SketchLine_43.result(), 20) SketchConstraintLength_5 = Sketch_6.setLength(SketchLine_44.result(), 15) SketchConstraintLength_6 = Sketch_6.setLength(SketchLine_39.result(), 42) -SketchProjection_3 = Sketch_6.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6")) +SketchProjection_3 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2]"), False) SketchLine_46 = SketchProjection_3.createdFeature() SketchLine_46.setName("SketchLine_47") SketchLine_46.result().setName("SketchLine_47") -SketchProjection_4 = Sketch_6.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_1_1/Modfied_1")) +SketchProjection_4 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchCircle_1_2)]"), False) SketchLine_47 = SketchProjection_4.createdFeature() SketchLine_47.setName("SketchLine_48") SketchLine_47.result().setName("SketchLine_48") -SketchProjection_5 = Sketch_6.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6")) +SketchProjection_5 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2]"), False) SketchLine_48 = SketchProjection_5.createdFeature() SketchLine_48.setName("SketchLine_49") SketchLine_48.result().setName("SketchLine_49") SketchConstraintDistance_13 = Sketch_6.setDistance(SketchLine_38.endPoint(), SketchLine_46.result(), 2) SketchConstraintDistance_14 = Sketch_6.setDistance(SketchLine_38.startPoint(), SketchLine_47.result(), 17) model.do() -ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_5"), -2, model.selection(), -2, [model.selection("SOLID", "ExtrusionCut_5_2")]) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1")) +ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6"), -2, model.selection(), -2, [model.selection("SOLID", "ExtrusionCut_5_2")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1")) SketchLine_49 = Sketch_7.addLine(0, -22.99999999998656, -76, -22.99999999998655) SketchLine_49.setName("SketchLine_50") SketchLine_49.result().setName("SketchLine_50") SketchLine_49.setAuxiliary(True) -SketchLine_50 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_3_1/Modfied_2")) +SketchLine_50 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_3_1/Generated_Face&Sketch_3/SketchCircle_5_2)]")) SketchLine_50.setName("SketchLine_51") SketchLine_50.result().setName("SketchLine_51") SketchConstraintCoincidence_74 = Sketch_7.setCoincident(SketchLine_49.startPoint(), SketchLine_50.result()) SketchConstraintCoincidence_74.setName("SketchConstraintCoincidence_75") -SketchPoint_3 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_2/Vertex-SketchLine_13s")) +SketchPoint_3 = Sketch_7.addPoint(model.selection("VERTEX", "Sketch_2/SketchLine_13_StartVertex")) SketchConstraintCoincidence_75 = Sketch_7.setCoincident(SketchLine_49.endPoint(), SketchPoint_3.result()) SketchConstraintCoincidence_75.setName("SketchConstraintCoincidence_76") SketchConstraintMiddle_17 = Sketch_7.setMiddlePoint(SketchLine_49.startPoint(), SketchLine_50.result()) @@ -454,12 +454,12 @@ SketchLine_51 = Sketch_7.addLine(-38, -40.99999999998656, -38, -4.99999999998656 SketchLine_51.setName("SketchLine_52") SketchLine_51.result().setName("SketchLine_52") SketchLine_51.setAuxiliary(True) -SketchLine_52 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_4_2/Modfied_3")) +SketchLine_52 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2]")) SketchLine_52.setName("SketchLine_53") SketchLine_52.result().setName("SketchLine_53") SketchConstraintCoincidence_76 = Sketch_7.setCoincident(SketchLine_51.startPoint(), SketchLine_52.result()) SketchConstraintCoincidence_76.setName("SketchConstraintCoincidence_77") -SketchLine_53 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/Generated_Face_1")) +SketchLine_53 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]")) SketchLine_53.setName("SketchLine_54") SketchLine_53.result().setName("SketchLine_54") SketchConstraintCoincidence_77 = Sketch_7.setCoincident(SketchLine_51.endPoint(), SketchLine_53.result()) @@ -475,13 +475,13 @@ SketchConstraintCoincidence_79 = Sketch_7.setCoincident(SketchPoint_4.coordinate SketchConstraintCoincidence_79.setName("SketchConstraintCoincidence_80") SketchConstraintRadius_8 = Sketch_7.setRadius(SketchCircle_10.results()[1], 17) model.do() -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchCircle_10_2f")], model.selection(), 16, 0) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face_1")) -SketchProjection_6 = Sketch_8.addProjection(model.selection("EDGE", "Sketch_2/Edge-SketchLine_9")) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_7/Face-SketchCircle_10_2f_wire")], model.selection(), 16, 0) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face")) +SketchProjection_6 = Sketch_8.addProjection(model.selection("EDGE", "Sketch_2/SketchLine_9"), False) SketchLine_54 = SketchProjection_6.createdFeature() SketchLine_54.setName("SketchLine_55") SketchLine_54.result().setName("SketchLine_55") -SketchProjection_7 = Sketch_8.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_3_1/Modfied_2")) +SketchProjection_7 = Sketch_8.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_3_1/Generated_Face&Sketch_3/SketchCircle_5_2)]"), False) SketchLine_55 = SketchProjection_7.createdFeature() SketchLine_55.setName("SketchLine_56") SketchLine_55.result().setName("SketchLine_56") @@ -506,11 +506,11 @@ SketchConstraintMiddle_23 = Sketch_8.setMiddlePoint(SketchLine_56.result(), Sket SketchConstraintCoincidence_83 = Sketch_8.setCoincident(SketchLine_57.result(), SketchPoint_5.coordinates()) SketchConstraintCoincidence_83.setName("SketchConstraintCoincidence_84") SketchConstraintPerpendicular_1 = Sketch_8.setPerpendicular(SketchLine_57.result(), SketchLine_56.result()) -SketchProjection_8 = Sketch_8.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_1&ExtrusionCut_4_2/Modfied_3")) +SketchProjection_8 = Sketch_8.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2]"), False) SketchLine_58 = SketchProjection_8.createdFeature() SketchLine_58.setName("SketchLine_59") SketchLine_58.result().setName("SketchLine_59") -SketchProjection_9 = Sketch_8.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/Generated_Face_1")) +SketchProjection_9 = Sketch_8.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1]"), False) SketchLine_59 = SketchProjection_9.createdFeature() SketchLine_59.setName("SketchLine_60") SketchLine_59.result().setName("SketchLine_60") @@ -530,7 +530,7 @@ SketchConstraintDistance_15 = Sketch_8.setDistance(SketchCircle_11.center(), Ske SketchConstraintDistance_16 = Sketch_8.setDistance(SketchCircle_11.center(), SketchCircle_12.center(), 16) model.do() Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchCircle_11_2f"), model.selection("FACE", "Sketch_8/Face-SketchCircle_12_2f")], model.selection(), 17, 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "ExtrusionCut_3_1/Modfied_2"), 38, True) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_3_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_1_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6)(ExtrusionCut_4_2/Modified_Face&Sketch_1/SketchArc_2_2)(ExtrusionCut_3_1/Generated_Face&Sketch_3/SketchCircle_5_2)"), 38, True) Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchLine_60 = Sketch_9.addLine(-14, -36.99999999998992, 0, -36.99999999998992) SketchLine_60.setName("SketchLine_61") @@ -562,19 +562,19 @@ SketchLine_64 = Sketch_9.addLine(-5.662490896925754, -22.99999999998992, -60.521 SketchLine_64.setName("SketchLine_65") SketchLine_64.result().setName("SketchLine_65") SketchLine_64.setAuxiliary(True) -SketchPoint_6 = Sketch_9.addPoint(model.selection("VERTEX", "Sketch_8/Vertex-SketchPoint_5")) +SketchPoint_6 = Sketch_9.addPoint(model.selection("VERTEX", "Sketch_8/SketchPoint_5")) SketchConstraintCoincidence_92 = Sketch_9.setCoincident(SketchLine_64.result(), SketchPoint_6.coordinates()) SketchConstraintCoincidence_92.setName("SketchConstraintCoincidence_93") SketchConstraintHorizontal_13 = Sketch_9.setHorizontal(SketchLine_64.result()) SketchConstraintCoincidence_93 = Sketch_9.setCoincident(SketchLine_62.startPoint(), SketchLine_64.result()) SketchConstraintCoincidence_93.setName("SketchConstraintCoincidence_94") -SketchLine_65 = Sketch_9.addLine(model.selection("EDGE", "Sketch_7/Edge-SketchLine_52")) +SketchLine_65 = Sketch_9.addLine(model.selection("EDGE", "Sketch_7/SketchLine_52")) SketchLine_65.setName("SketchLine_66") SketchLine_65.result().setName("SketchLine_66") SketchConstraintCoincidence_94 = Sketch_9.setCoincident(SketchLine_60.endPoint(), SketchLine_65.result()) SketchConstraintCoincidence_94.setName("SketchConstraintCoincidence_95") model.do() -RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection("EDGE", "Sketch_9/Edge-SketchLine_65"), 360, 0, [model.selection("SOLID", "Extrusion_3_1")]) +RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection("EDGE", "Sketch_9/SketchLine_65"), 360, 0, [model.selection("SOLID", "Extrusion_3_1")]) model.do() from GeomAPI import GeomAPI_Shape diff --git a/test.models/piece_09.py b/test.models/piece_09.py index 99e22b96c..e576ecb00 100644 --- a/test.models/piece_09.py +++ b/test.models/piece_09.py @@ -147,12 +147,12 @@ SketchConstraintDistance_5 = Sketch_1.setDistance(SketchArc_2.center(), SketchAr SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_1.result(), SketchArc_6.endPoint(), "(h4-d_diff)*coeff") SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_10.result(), "d1*coeff") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1f-SketchArc_1_2f-SketchLine_3f-SketchArc_2_2r-SketchLine_4f-SketchArc_3_2r-SketchLine_5f-SketchArc_4_2f-SketchLine_6f-SketchLine_7r-SketchLine_8r-SketchArc_5_2r-SketchLine_9r-SketchArc_6_2f-SketchLine_10r-SketchArc_7_2f-SketchLine_11r-SketchArc_8_2r-SketchLine_12r-SketchLine_13r")], model.selection(), "epaisseur_plat*coeff", 0) -Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), "d2*coeff", True) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_3f-SketchArc_2_2r-SketchLine_4f-SketchArc_3_2r-SketchLine_5f-SketchArc_4_2f-SketchLine_6f-SketchLine_13r-SketchLine_12r-SketchArc_8_2r-SketchLine_11r-SketchArc_7_2f-SketchLine_10r-SketchArc_6_2f-SketchLine_9r-SketchArc_5_2r-SketchLine_8r-SketchLine_7r_wire")], model.selection(), "epaisseur_plat*coeff", 0) +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7"), "d2*coeff", True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_7&Extrusion_1_1/Generated_Face_6"), False) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_7_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10]"), False) SketchLine_14 = SketchProjection_1.createdFeature() -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_8&Extrusion_1_1/To_Face_1"), False) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_11][Extrusion_1_1/To_Face]"), False) SketchLine_15 = SketchProjection_2.createdFeature() SketchLine_16 = Sketch_2.addLine(-24.99999999999999, -35.00000000000001, -31.24999999999999, -35.00000000000001) SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_14).endPoint(), SketchLine_16.startPoint()) @@ -208,10 +208,10 @@ SketchConstraintEqual_10 = Sketch_2.setEqual(SketchArc_11.results()[1], SketchAr SketchConstraintRadius_4 = Sketch_2.setRadius(SketchArc_12.results()[1], "r3*coeff") SketchConstraintDistance_13 = Sketch_2.setDistance(SketchArc_10.startPoint(), SketchLine_19.result(), "d8*coeff") model.do() -Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Wire-SketchLine_16r-SketchArc_9_2f-SketchLine_17r-SketchArc_10_2f-SketchLine_18r-SketchLine_19r-SketchLine_20r-SketchArc_11_2r-SketchLine_21r-SketchArc_12_2r-SketchLine_22r-SketchLine_23f")], model.selection(), "d6*coeff", 0) -Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face_3")) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_23f-SketchLine_22r-SketchArc_12_2r-SketchLine_21r-SketchArc_11_2r-SketchLine_20r-SketchLine_19r-SketchLine_18r-SketchArc_10_2f-SketchLine_17r-SketchArc_9_2f-SketchLine_16r_wire")], model.selection(), "d6*coeff", 0) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_17")) SketchLine_24 = Sketch_3.addLine(46.25, 22.91561885925604, 51.3, 20.00000000000001) -SketchLine_25 = Sketch_3.addLine(model.selection("EDGE", "Extrusion_2_1/Generated_Face_3&Extrusion_2_1/To_Face_1")) +SketchLine_25 = Sketch_3.addLine(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_17][Extrusion_2_1/To_Face]")) SketchLine_26 = Sketch_3.addLine(51.3, 20.00000000000001, 62.50000000000001, 20.00000000000001) SketchConstraintCoincidence_42 = Sketch_3.setCoincident(SketchLine_24.endPoint(), SketchLine_26.startPoint()) SketchLine_27 = Sketch_3.addLine(62.50000000000001, 20.00000000000001, 62.5, -4.999999999999999) @@ -238,9 +238,9 @@ SketchConstraintVertical_12 = Sketch_3.setVertical(SketchLine_27.result()) SketchConstraintVertical_13 = Sketch_3.setVertical(SketchLine_33.result()) SketchConstraintVertical_14 = Sketch_3.setVertical(SketchLine_31.result()) SketchConstraintAngle_1 = Sketch_3.setAngleComplementary(SketchLine_26.result(), SketchLine_24.result(), "angle") -SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "Extrusion_2_1/Generated_Face_5&Extrusion_2_1/Generated_Face_4")) +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_18][Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_10_2]"), False) SketchLine_34 = SketchProjection_3.createdFeature() -SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "Extrusion_2_1/Generated_Face_2&Extrusion_2_1/Generated_Face_1")) +SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_9_2][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_16]"), False) SketchLine_35 = SketchProjection_4.createdFeature() SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchLine_34.result()) SketchConstraintDistance_15 = Sketch_3.setDistance(SketchLine_31.result(), SketchLine_33.endPoint(), "(d6-d5)*coeff") @@ -252,15 +252,15 @@ SketchConstraintCoincidence_54 = Sketch_3.setCoincident(SketchLine_29.endPoint() SketchConstraintDistance_17 = Sketch_3.setDistance(SketchLine_26.result(), SketchAPI_Line(SketchLine_35).startPoint(), "h2*coeff") SketchConstraintLength_4 = Sketch_3.setLength(SketchLine_26.result(), "d7*coeff") model.do() -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_24r-SketchLine_26r-SketchLine_27r-SketchLine_28r-SketchLine_29r")], model.selection(), model.selection("FACE", "Extrusion_2_1/Generated_Face_6"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_2_1")]) -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_30r-SketchLine_31r-SketchLine_32r-SketchLine_33r")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face_1"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) -Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), "d3*coeff", True) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_29r-SketchLine_28r-SketchLine_27r-SketchLine_26r-SketchLine_24r")], model.selection(), model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_19"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_2_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_33r-SketchLine_32r-SketchLine_31r-SketchLine_30r")], model.selection(), model.selection("FACE", "Extrusion_1_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7"), "d3*coeff", True) Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) -SketchProjection_5 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/To_Face_1")) +SketchProjection_5 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_9][Extrusion_1_1/To_Face]"), False) SketchLine_36 = SketchProjection_5.createdFeature() -SketchProjection_6 = Sketch_4.addProjection(model.selection("EDGE", "ExtrusionCut_2_1/Modfied_8&ExtrusionCut_2_1/Modfied_9")) +SketchProjection_6 = Sketch_4.addProjection(model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Sketch_2/SketchLine_23][ExtrusionCut_2_1/Generated_Face&Sketch_3/SketchLine_31]"), False) SketchLine_37 = SketchProjection_6.createdFeature() -SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/Generated_Face_5")) +SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_6_2]"), False) SketchLine_38 = SketchProjection_7.createdFeature() SketchLine_39 = Sketch_4.addLine(-25, -35.00000000000001, -31.24999999999999, -35.00000000000001) SketchConstraintCoincidence_55 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_37).startPoint(), SketchLine_39.startPoint()) @@ -295,39 +295,39 @@ SketchConstraintRadius_6 = Sketch_4.setRadius(SketchArc_14.results()[1], "r3*coe SketchConstraintDistance_19 = Sketch_4.setDistance(SketchLine_41.endPoint(), SketchLine_40.result(), "epaisseur*coeff") SketchConstraintDistance_20 = Sketch_4.setDistance(SketchLine_41.startPoint(), SketchLine_39.result(), "h2") model.do() -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Wire-SketchLine_39r-SketchArc_13_2f-SketchLine_40r-SketchLine_41r-SketchLine_42r-SketchArc_14_2r-SketchLine_43r-SketchLine_44f")], model.selection(), 0, "e1*coeff") -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modfied_4")) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Face-SketchLine_44f-SketchLine_43r-SketchArc_14_2r-SketchLine_42r-SketchLine_41r-SketchLine_40r-SketchArc_13_2f-SketchLine_39r_wire")], model.selection(), 0, "e1*coeff") +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_18")) SketchCircle_1 = Sketch_5.addCircle(70, 17.5, 3.125) -SketchLine_45 = Sketch_5.addLine(model.selection("EDGE", "ExtrusionCut_1_1/Modfied_5&ExtrusionCut_1_1/Modfied_4")) +SketchLine_45 = Sketch_5.addLine(model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_19][ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_18]")) SketchConstraintDistance_21 = Sketch_5.setDistance(SketchCircle_1.center(), SketchLine_45.result(), "d9*coeff") -SketchProjection_8 = Sketch_5.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_12&Extrusion_1_1/Generated_Face_11")) +SketchProjection_8 = Sketch_5.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_13]")) SketchLine_46 = SketchProjection_8.createdFeature() -SketchProjection_9 = Sketch_5.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_20&Extrusion_1_1/Generated_Face_1")) +SketchProjection_9 = Sketch_5.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]"), False) SketchLine_47 = SketchProjection_9.createdFeature() SketchConstraintDistance_22 = Sketch_5.setDistance(SketchCircle_1.center(), SketchLine_47.result(), "d1*coeff") SketchConstraintRadius_7 = Sketch_5.setRadius(SketchCircle_1.results()[1], "r_trou") model.do() -ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modfied_6"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) -Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_6")) +ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchCircle_1_2r")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_2/SketchLine_20"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10")) SketchCircle_2 = Sketch_6.addCircle(70, -17.5, 5) -SketchLine_48 = Sketch_6.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_6&Extrusion_1_1/To_Face_1")) -SketchProjection_10 = Sketch_6.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1")) +SketchLine_48 = Sketch_6.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10][Extrusion_1_1/To_Face]")) +SketchProjection_10 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]"), False) SketchLine_49 = SketchProjection_10.createdFeature() SketchConstraintDistance_23 = Sketch_6.setDistance(SketchCircle_2.center(), SketchLine_49.result(), "d1*coeff") SketchConstraintDistance_23.setName("SketchConstraintDistance_24") SketchConstraintRadius_8 = Sketch_6.setRadius(SketchCircle_2.results()[1], "r_trou2") -SketchLine_50 = Sketch_6.addLine(model.selection("EDGE", "Sketch_1/Edge-SketchLine_10")) +SketchLine_50 = Sketch_6.addLine(model.selection("EDGE", "Sketch_1/SketchLine_10")) SketchConstraintDistance_24 = Sketch_6.setDistance(SketchCircle_2.center(), SketchLine_50.result(), "d_trou") SketchConstraintDistance_24.setName("SketchConstraintDistance_25") model.do() -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchCircle_2_2f")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_16"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face_12")) +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchCircle_2_2r")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6")) SketchLine_51 = Sketch_7.addLine(110, 21.46600893000899, 110, 7.22841614740048) SketchLine_51.setAuxiliary(True) -SketchLine_52 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_12&Extrusion_1_1/Generated_Face_11")) +SketchLine_52 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_13]")) SketchConstraintCoincidence_65 = Sketch_7.setCoincident(SketchLine_51.startPoint(), SketchLine_52.result()) SketchConstraintCoincidence_66 = Sketch_7.setCoincident(SketchLine_51.endPoint(), SketchLine_52.result()) -SketchLine_53 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/From_Face_1&Extrusion_1_1/Generated_Face_12")) +SketchLine_53 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]")) SketchArc_15 = Sketch_7.addArc(102.5, 7.22841614740048, 110, 7.22841614740048, 104.5, 0, True) SketchConstraintCoincidence_67 = Sketch_7.setCoincident(SketchLine_51.endPoint(), SketchArc_15.startPoint()) SketchConstraintTangent_29 = Sketch_7.setTangent(SketchLine_51.result(), SketchArc_15.results()[1]) @@ -344,11 +344,11 @@ SketchConstraintLength_5 = Sketch_7.setLength(SketchLine_54.result(), "5.5*coeff SketchLine_56 = Sketch_7.addLine(110, 12.5, 0, 12.5) SketchLine_56.setAuxiliary(True) SketchConstraintCoincidence_73 = Sketch_7.setCoincident(SketchLine_56.startPoint(), SketchLine_52.result()) -SketchLine_57 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_1_1/Generated_Face_20&Extrusion_1_1/Generated_Face_1")) +SketchLine_57 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]")) SketchConstraintCoincidence_74 = Sketch_7.setCoincident(SketchLine_56.endPoint(), SketchLine_57.result()) SketchConstraintMiddle_1 = Sketch_7.setMiddlePoint(SketchLine_56.endPoint(), SketchLine_57.result()) SketchConstraintMiddle_2 = Sketch_7.setMiddlePoint(SketchLine_56.startPoint(), SketchLine_52.result()) -SketchProjection_11 = Sketch_7.addProjection(model.selection("EDGE", "Extrusion_1_1/To_Face_1&ExtrusionCut_4_1/Modfied_2")) +SketchProjection_11 = Sketch_7.addProjection(model.selection("EDGE", "[Extrusion_1_1/To_Face][ExtrusionCut_4_1/Modified_Face&Sketch_1/SketchLine_4]"), False) SketchLine_58 = SketchProjection_11.createdFeature() SketchLine_59 = Sketch_7.addLine(55.00000000000002, 0, 55.00000000000002, 25) SketchLine_59.setAuxiliary(True) @@ -364,7 +364,7 @@ SketchConstraintMirror_2_objects = [SketchArc_15.results()[1], SketchLine_55.res SketchConstraintMirror_2 = Sketch_7.addMirror(SketchLine_59.result(), SketchConstraintMirror_2_objects) [SketchArc_17, SketchLine_63, SketchLine_64, SketchArc_18, SketchLine_65, SketchLine_66] = SketchConstraintMirror_2.mirrored() model.do() -ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchArc_16_2r-SketchLine_61f-SketchLine_62r"), model.selection("FACE", "Sketch_7/Face-SketchArc_18_2r-SketchLine_65f-SketchLine_66r"), model.selection("FACE", "Sketch_7/Face-SketchArc_17_2r-SketchLine_64r-SketchLine_66r"), model.selection("WIRE", "Sketch_7/Wire-SketchArc_15_2r-SketchLine_54f-SketchLine_55r")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_10"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) +ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Face-SketchLine_61f-SketchLine_62r-SketchArc_16_2r_wire"), model.selection("FACE", "Sketch_7/Face-SketchLine_65f-SketchLine_66r-SketchArc_18_2r"), model.selection("FACE", "Sketch_7/Face-SketchLine_63f-SketchLine_64r-SketchArc_17_2r"), model.selection("WIRE", "Sketch_7/Face-SketchLine_54f-SketchLine_55r-SketchArc_15_2r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_12"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_4_1")]) Boolean_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "ExtrusionCut_5_1")], [model.selection("SOLID", "Extrusion_3_1"), model.selection("SOLID", "ExtrusionCut_3_1")]) model.do() diff --git a/test.models/piece_12.py b/test.models/piece_12.py index 05c3b5107..d1adc75e5 100644 --- a/test.models/piece_12.py +++ b/test.models/piece_12.py @@ -106,13 +106,13 @@ SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10") SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_3.result()) SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11") SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_1.results()[1], SketchArc_2.results()[1]) -SketchArc_3 = Sketch_1.addArc(9.077705920073647e-31, -3.860574861749558e-31, 15.46247221747307, -11.0413745939477, 18.89444362769119, -2, False) +SketchArc_3 = Sketch_1.addArc(0, 0, 15.46247221747307, -11.0413745939477, 18.89444362769119, -2, False) SketchArc_3.setName("SketchArc_7") SketchArc_3.result().setName("SketchArc_7") SketchArc_3.results()[1].setName("SketchArc_7_2") SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchArc_3.center()) SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_54") -SketchArc_4 = Sketch_1.addArc(3.497294868556922e-32, 3.186289860391258e-33, 18.89444362769119, 2, 15.46247221747308, 11.04137459394768, False) +SketchArc_4 = Sketch_1.addArc(0, 0, 18.89444362769119, 2, 15.46247221747308, 11.04137459394768, False) SketchArc_4.setName("SketchArc_8") SketchArc_4.result().setName("SketchArc_8") SketchArc_4.results()[1].setName("SketchArc_8_2") @@ -134,7 +134,7 @@ SketchArc_6.results()[1].setName("SketchArc_10_2") SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchArc_6.startPoint()) SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_57") SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchArc_6.results()[1]) -SketchLine_4 = Sketch_1.addLine(17.5, 15, 37.99999999999999, 15) +SketchLine_4 = Sketch_1.addLine(17.5, 15, 38, 15) SketchLine_4.setName("SketchLine_42") SketchLine_4.result().setName("SketchLine_42") SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_5.endPoint(), SketchLine_4.startPoint()) @@ -149,7 +149,7 @@ SketchLine_6.setName("SketchLine_45") SketchLine_6.result().setName("SketchLine_45") SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchLine_6.startPoint()) SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_61") -SketchLine_7 = Sketch_1.addLine(37.99999999999999, 15, 38.00000000000001, 5.505556372308819) +SketchLine_7 = Sketch_1.addLine(38, 15, 38, 5.505556372308819) SketchLine_7.setName("SketchLine_46") SketchLine_7.result().setName("SketchLine_46") SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_7.startPoint()) @@ -166,7 +166,7 @@ SketchConstraintHorizontal_5 = Sketch_1.setHorizontal(SketchLine_5.result()) SketchConstraintHorizontal_5.setName("SketchConstraintHorizontal_14") SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_7.result()) SketchConstraintVertical_1.setName("SketchConstraintVertical_7") -SketchLine_8 = Sketch_1.addLine(40, 17, 40, -17.00000000000001) +SketchLine_8 = Sketch_1.addLine(40, 17, 40, -17) SketchLine_8.setName("SketchLine_47") SketchLine_8.result().setName("SketchLine_47") SketchLine_8.setAuxiliary(True) @@ -193,7 +193,7 @@ SketchConstraintRadius_6 = Sketch_1.setRadius(SketchArc_4.results()[1], "(r4+4)* SketchConstraintRadius_6.setName("SketchConstraintRadius_13") SketchConstraintDistance_6 = Sketch_1.setDistance(SketchLine_4.endPoint(), SketchLine_8.result(), "2*coeff") SketchConstraintDistance_6.setName("SketchConstraintDistance_19") -SketchArc_7 = Sketch_1.addArc(40, 2.220450266386716e-15, 34.49444362769118, 2, 38.00000000000001, 5.505556372308819, True) +SketchArc_7 = Sketch_1.addArc(40, 0, 34.49444362769118, 2, 38, 5.505556372308819, True) SketchArc_7.setName("SketchArc_11") SketchArc_7.result().setName("SketchArc_11") SketchArc_7.results()[1].setName("SketchArc_11_2") @@ -201,7 +201,7 @@ SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchPoint_2.coordinate SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_66") SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchArc_7.startPoint()) SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_67") -SketchArc_8 = Sketch_1.addArc(40.00000000000001, -2.652239435709897e-15, 34.49444362769118, -2, 37.95784774655168, -5.490060577298436, False) +SketchArc_8 = Sketch_1.addArc(40, 0, 34.49444362769118, -2, 37.95784774655168, -5.490060577298436, False) SketchArc_8.setName("SketchArc_12") SketchArc_8.result().setName("SketchArc_12") SketchArc_8.results()[1].setName("SketchArc_12_2") @@ -241,12 +241,12 @@ SketchConstraintRadius_8 = Sketch_1.setRadius(SketchArc_9.results()[1], "(2.5+2) SketchConstraintRadius_8.setName("SketchConstraintRadius_15") SketchConstraintDistance_8 = Sketch_1.setDistance(SketchCircle_5.center(), SketchLine_2.result(), "4*coeff") SketchConstraintDistance_8.setName("SketchConstraintDistance_22") -SketchLine_10 = Sketch_1.addLine(17.5, -15, 34.00000000000001, -15) +SketchLine_10 = Sketch_1.addLine(17.5, -15, 34, -15) SketchLine_10.setName("SketchLine_43") SketchLine_10.result().setName("SketchLine_43") SketchConstraintCoincidence_31 = Sketch_1.setCoincident(SketchArc_6.endPoint(), SketchLine_10.startPoint()) SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_73") -SketchArc_10 = Sketch_1.addArc(34.00000000000001, -13.48076923076937, 34.00000000000001, -15, 35.51437699680511, -13.35942492012782, False) +SketchArc_10 = Sketch_1.addArc(34, -13.48076923076937, 34, -15, 35.51437699680511, -13.35942492012782, False) SketchArc_10.setName("SketchArc_14") SketchArc_10.result().setName("SketchArc_14") SketchArc_10.results()[1].setName("SketchArc_14_2") @@ -320,14 +320,14 @@ SketchArc_11.results()[1].setName("SketchArc_15_2") SketchLine_12.setName("SketchLine_50") SketchLine_12.result().setName("SketchLine_50") model.do() -Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_4_2f-SketchLine_6r-SketchLine_10f-SketchArc_2_2f")], model.selection(), "h_p*coeff", 0) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) -SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchCircle_2_2")) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_4_2f-SketchLine_10f-SketchArc_2_2f-SketchLine_6r-SketchArc_8_2f-SketchArc_9_2r-SketchLine_42f-SketchLine_46f-SketchArc_11_2f-SketchLine_45r-SketchArc_15_2r-SketchArc_16_2f-SketchLine_51f-SketchArc_17_2f-SketchLine_52r-SketchLine_50r-SketchCircle_11_2r-SketchArc_22_2f-SketchArc_21_2r-SketchLine_55f-SketchArc_20_2r-SketchArc_19_2f-SketchLine_54r-SketchArc_18_2f-SketchLine_53r-SketchArc_7_2f-SketchLine_44f-SketchArc_12_2f-SketchLine_48f-SketchArc_13_2f-SketchArc_14_2r-SketchLine_43r-SketchArc_10_2r-SketchCircle_1_2r-SketchCircle_2_2r_wire")], model.selection(), "h_p*coeff", 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchCircle_2_2")) SketchCircle_6 = SketchProjection_1.createdFeature() SketchCircle_6.setName("SketchCircle_5") SketchCircle_6.result().setName("SketchCircle_5") SketchCircle_6.results()[1].setName("SketchCircle_5_2") -SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchCircle_4_2")) +SketchProjection_2 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchCircle_4_2")) SketchCircle_7 = SketchProjection_2.createdFeature() SketchCircle_7.setName("SketchCircle_6") SketchCircle_7.result().setName("SketchCircle_6") @@ -342,18 +342,18 @@ SketchConstraintRadius_9 = Sketch_2.setRadius(SketchCircle_8.results()[1], "r2*c SketchConstraintRadius_9.setName("SketchConstraintRadius_6") model.do() Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), "10*coeff", 0) -ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_3_2f")], model.selection(), "p_trou1*coeff", 0, [model.selection("SOLID", "Extrusion_1_1")]) -ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2r")], model.selection(), "p2_trou1*coeff", 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchCircle_3_2f_wire")], model.selection(), "p_trou1*coeff", 0, [model.selection("SOLID", "Extrusion_1_1")]) +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_4_2f-SketchLine_10f-SketchArc_2_2f-SketchLine_6r-SketchArc_8_2f-SketchArc_9_2r-SketchLine_42f-SketchLine_46f-SketchArc_11_2f-SketchLine_45r-SketchArc_15_2r-SketchArc_16_2f-SketchLine_51f-SketchArc_17_2f-SketchLine_52r-SketchLine_50r-SketchCircle_11_2r-SketchArc_22_2f-SketchArc_21_2r-SketchLine_55f-SketchArc_20_2r-SketchArc_19_2f-SketchLine_54r-SketchArc_18_2f-SketchLine_53r-SketchArc_7_2f-SketchLine_44f-SketchArc_12_2f-SketchLine_48f-SketchArc_13_2f-SketchArc_14_2r-SketchLine_43r-SketchArc_10_2r-SketchCircle_1_2r-SketchCircle_2_2r_wire_7")], model.selection(), "p2_trou1*coeff", 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_4_2f")], model.selection(), "p_trou2*coeff", 0, [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "ExtrusionCut_2_1")]) -ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_2_2r")], model.selection(), "p2_trou*coeff", 0, [model.selection("SOLID", "ExtrusionCut_3_2")]) +ExtrusionCut_4 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Face-SketchArc_4_2f-SketchLine_10f-SketchArc_2_2f-SketchLine_6r-SketchArc_8_2f-SketchArc_9_2r-SketchLine_42f-SketchLine_46f-SketchArc_11_2f-SketchLine_45r-SketchArc_15_2r-SketchArc_16_2f-SketchLine_51f-SketchArc_17_2f-SketchLine_52r-SketchLine_50r-SketchCircle_11_2r-SketchArc_22_2f-SketchArc_21_2r-SketchLine_55f-SketchArc_20_2r-SketchArc_19_2f-SketchLine_54r-SketchArc_18_2f-SketchLine_53r-SketchArc_7_2f-SketchLine_44f-SketchArc_12_2f-SketchLine_48f-SketchArc_13_2f-SketchArc_14_2r-SketchLine_43r-SketchArc_10_2r-SketchCircle_1_2r-SketchCircle_2_2r_wire_8")], model.selection(), "p2_trou*coeff", 0, [model.selection("SOLID", "ExtrusionCut_3_2")]) Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "22.5*coeff", False) Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), "45*coeff", True) Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) -SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "Extrusion_1_1/Generated_Face_4&Extrusion_1_1/Generated_Face_1")) +SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_4_2][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]"), False) SketchLine_18 = SketchProjection_3.createdFeature() SketchLine_18.setName("SketchLine_4") SketchLine_18.result().setName("SketchLine_4") -SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_6")) +SketchProjection_4 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_6")) SketchLine_19 = SketchProjection_4.createdFeature() SketchLine_19.setName("SketchLine_5") SketchLine_19.result().setName("SketchLine_5") @@ -430,9 +430,9 @@ SketchConstraintDistance_13.setName("SketchConstraintDistance_11") SketchConstraintDistance_14 = Sketch_3.setDistance(SketchLine_23.result(), SketchLine_25.startPoint(), "2.5*coeff") SketchConstraintDistance_14.setName("SketchConstraintDistance_12") model.do() -Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_9r-SketchLine_12r-SketchLine_14r-SketchLine_26r-SketchLine_27r-SketchLine_28r")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), 0, model.selection(), 0) +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_14r-SketchLine_27r-SketchLine_26r-SketchLine_28r-SketchLine_12r-SketchLine_9r-SketchCircle_8_2r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_10"), 0, model.selection(), 0) Smash_1 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1")], [model.selection("SOLID", "ExtrusionCut_4_1")]) -ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchCircle_8_2f")], model.selection(), 10, 0, [model.selection("SOLID", "Smash_1_1_1")]) +ExtrusionCut_5 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchCircle_8_2f_wire")], model.selection(), 10, 0, [model.selection("SOLID", "Smash_1_1_1")]) ExtrusionCut_6 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_8_2f")], model.selection(), 10, 0, [model.selection("SOLID", "ExtrusionCut_5_1_1")]) Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OY")) @@ -516,11 +516,11 @@ SketchConstraintDistance_16.setName("SketchConstraintDistance_10") SketchConstraintLength_10 = Sketch_4.setLength(SketchLine_36.result(), 12.975642079145) SketchConstraintLength_10.setName("SketchConstraintLength_7") model.do() -Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Wire-SketchLine_19f-SketchLine_20f-SketchLine_24f-SketchLine_21f-SketchLine_22f-SketchLine_23f")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), 0, model.selection(), 0) +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Face-SketchLine_19f-SketchLine_20f-SketchLine_21f-SketchLine_22f-SketchLine_23f-SketchLine_24f-SketchCircle_9_2r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6"), 0, model.selection(), 0) Smash_2 = model.addSmash(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1")], [model.selection("COMPSOLID", "ExtrusionCut_6_1")]) ExtrusionCut_7 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchCircle_9_2f")], model.selection(), 0, 10, [model.selection("SOLID", "Smash_2_1_3")]) ExtrusionCut_8 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchCircle_9_2f")], model.selection(), 0, 10, [model.selection("SOLID", "ExtrusionCut_7_1_1")]) -Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Smash_2_1_3/Modified_Face_1")) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Smash_2_1_3/Modified_Face&Extrusion_1_1/From_Face")) SketchPoint_3 = Sketch_5.addPoint(model.selection("VERTEX", "PartSet/Origin")) SketchPoint_3.setName("SketchPoint_2") SketchPoint_3.result().setName("SketchPoint_2") @@ -539,7 +539,7 @@ SketchLine_39.setName("SketchLine_31") SketchLine_39.result().setName("SketchLine_31") SketchConstraintDistance_17 = Sketch_5.setDistance(SketchLine_37.result(), SketchLine_38.startPoint(), "epaisseur*coeff") SketchConstraintDistance_17.setName("SketchConstraintDistance_13") -SketchArc_19 = Sketch_5.addArc(2.175718373563154e-31, -6.039735315912772e-31, -13.96424004376904, 17, -13.964240043769, -17, False) +SketchArc_19 = Sketch_5.addArc(0, 0, -13.964240043769, 17, -13.964240043769, -17, False) SketchArc_19.setName("SketchArc_5") SketchArc_19.result().setName("SketchArc_5") SketchArc_19.results()[1].setName("SketchArc_5_2") @@ -567,7 +567,7 @@ SketchConstraintDistance_19.setName("SketchConstraintDistance_15") SketchConstraintCoincidence_59 = Sketch_5.setCoincident(SketchArc_19.endPoint(), SketchLine_37.startPoint()) SketchConstraintCoincidence_59.setName("SketchConstraintCoincidence_40") model.do() -Extrusion_5 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchLine_29r-SketchLine_30r-SketchArc_5_2r-SketchLine_32r")], model.selection(), 0, "22*coeff") +Extrusion_5 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchArc_5_2r-SketchLine_30r-SketchLine_32r-SketchLine_29r")], model.selection(), 0, "22*coeff") Sketch_6_origin = GeomAPI_Pnt(0, 0, 0) Sketch_6_norm = GeomAPI_Dir(0, 1, 0) Sketch_6_dirx = GeomAPI_Dir(1, 0, 0) @@ -575,23 +575,23 @@ Sketch_6 = model.addSketch(Part_1_doc, GeomAPI_Ax3(Sketch_6_origin, Sketch_6_dir SketchLine_41 = Sketch_6.addLine(-32, -17, -32, 17) SketchLine_41.setName("SketchLine_33") SketchLine_41.result().setName("SketchLine_33") -SketchPoint_4 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/Vertex-SketchLine_32s-SketchLine_29e")) +SketchPoint_4 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/SketchLine_29_EndVertex")) SketchPoint_4.setName("SketchPoint_3") SketchPoint_4.result().setName("SketchPoint_3") SketchConstraintCoincidence_60 = Sketch_6.setCoincident(SketchLine_41.startPoint(), SketchPoint_4.result()) SketchConstraintCoincidence_60.setName("SketchConstraintCoincidence_41") -SketchPoint_5 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/Vertex-SketchLine_30s-SketchLine_32e")) +SketchPoint_5 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/SketchLine_30_StartVertex")) SketchPoint_5.setName("SketchPoint_4") SketchPoint_5.result().setName("SketchPoint_4") SketchConstraintCoincidence_61 = Sketch_6.setCoincident(SketchLine_41.endPoint(), SketchPoint_5.result()) SketchConstraintCoincidence_61.setName("SketchConstraintCoincidence_42") -SketchPoint_6 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/Vertex-SketchPoint_2-SketchArc_5-SketchLine_31s")) +SketchPoint_6 = Sketch_6.addPoint(model.selection("VERTEX", "Sketch_5/SketchPoint_2")) SketchPoint_6.setName("SketchPoint_5") SketchPoint_6.result().setName("SketchPoint_5") -SketchLine_42 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_30")) +SketchLine_42 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/SketchLine_30")) SketchLine_42.setName("SketchLine_34") SketchLine_42.result().setName("SketchLine_34") -SketchLine_43 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/Edge-SketchLine_29")) +SketchLine_43 = Sketch_6.addLine(model.selection("EDGE", "Sketch_5/SketchLine_29")) SketchLine_43.setName("SketchLine_35") SketchLine_43.result().setName("SketchLine_35") SketchArc_20 = Sketch_6.addArc(0, 0, -20.32855135026245, 17, -20.32855135026245, -17, False) @@ -621,18 +621,18 @@ SketchConstraintCoincidence_68.setName("SketchConstraintCoincidence_49") SketchConstraintRadius_13 = Sketch_6.setRadius(SketchArc_20.results()[1], "r1*coeff") SketchConstraintRadius_13.setName("SketchConstraintRadius_10") model.do() -Extrusion_6 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchLine_33r-SketchArc_6_2r-SketchLine_36r-SketchLine_37f")], model.selection(), "77*coeff-h_p*coeff", 0) -Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_6_1/Generated_Face_1")) +Extrusion_6 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_6/Face-SketchLine_36r-SketchArc_6_2r-SketchLine_37f-SketchLine_33r")], model.selection(), "77*coeff-h_p*coeff", 0) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_6_1/Generated_Face&Sketch_6/SketchLine_33")) SketchLine_46 = Sketch_7.addLine(37, -8.881784197001252e-16, -22, 1.665334536937735e-15) SketchLine_46.setName("SketchLine_38") SketchLine_46.result().setName("SketchLine_38") SketchLine_46.setAuxiliary(True) -SketchLine_47 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_6_1/Generated_Face_1&Extrusion_6_1/To_Face_1")) +SketchLine_47 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_6_1/Generated_Face&Sketch_6/SketchLine_33][Extrusion_6_1/To_Face]")) SketchLine_47.setName("SketchLine_39") SketchLine_47.result().setName("SketchLine_39") SketchConstraintCoincidence_69 = Sketch_7.setCoincident(SketchLine_46.startPoint(), SketchLine_47.result()) SketchConstraintCoincidence_69.setName("SketchConstraintCoincidence_50") -SketchLine_48 = Sketch_7.addLine(model.selection("EDGE", "Extrusion_5_1/Generated_Face_2&Extrusion_5_1/From_Face_1")) +SketchLine_48 = Sketch_7.addLine(model.selection("EDGE", "[Extrusion_5_1/Generated_Face&Sketch_5/SketchLine_32][Extrusion_5_1/From_Face]")) SketchLine_48.setName("SketchLine_40") SketchLine_48.result().setName("SketchLine_40") SketchConstraintCoincidence_70 = Sketch_7.setCoincident(SketchLine_46.endPoint(), SketchLine_48.result()) @@ -661,24 +661,25 @@ SketchConstraintCoincidence_72.setName("SketchConstraintCoincidence_53") SketchConstraintRadius_14 = Sketch_7.setRadius(SketchCircle_11.results()[1], "r3") SketchConstraintRadius_14.setName("SketchConstraintRadius_12") model.do() -ExtrusionCut_9 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Wire-SketchCircle_10_2f")], model.selection(), 0, "10*coeff", [model.selection("SOLID", "Extrusion_6_1")]) -ExtrusionCut_10 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchArc_7_2r-SketchArc_10_2f-SketchLine_44r-SketchArc_12_2r-SketchArc_13_2r-SketchLine_48r-SketchLine_43f-SketchArc_14_2f"), model.selection("FACE", "Sketch_1/Face-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_1/Wire-SketchLine_50f-SketchArc_15_2f-SketchArc_16_2r-SketchLine_51r-SketchArc_17_2r-SketchLine_52f"), model.selection("FACE", "Sketch_1/Face-SketchLine_53f-SketchArc_18_2r-SketchLine_54f-SketchArc_19_2r-SketchArc_20_2f-SketchLine_55r-SketchArc_21_2f-SketchArc_22_2r"), model.selection("FACE", "Sketch_1/Face-SketchArc_8_2r-SketchArc_9_2f-SketchLine_42r-SketchLine_45f-SketchLine_46r-SketchArc_11_2r")], model.selection(), model.selection("FACE", "ExtrusionCut_3_2/Modfied_1"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_8_1_2")]) -Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_9_1/Modfied_1")) +ExtrusionCut_9 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_7/Face-SketchCircle_10_2f_wire")], model.selection(), 0, "10*coeff", [model.selection("SOLID", "Extrusion_6_1")]) +ExtrusionCut_10_objects_1 = [model.selection("WIRE", "Sketch_1/Face-SketchArc_10_2f-SketchLine_43f-SketchArc_14_2f-SketchArc_13_2r-SketchLine_48r-SketchArc_12_2r-SketchLine_44r-SketchArc_7_2r_wire"), model.selection("FACE", "Sketch_1/Face-SketchCircle_11_2f"), model.selection("WIRE", "Sketch_1/Face-SketchLine_50f-SketchLine_52f-SketchArc_17_2r-SketchLine_51r-SketchArc_16_2r-SketchArc_15_2f_wire"), model.selection("FACE", "Sketch_1/Face-SketchLine_53f-SketchArc_18_2r-SketchLine_54f-SketchArc_19_2r-SketchArc_20_2f-SketchLine_55r-SketchArc_21_2f-SketchArc_22_2r"), model.selection("FACE", "Sketch_1/Face-SketchLine_45f-SketchArc_11_2r-SketchLine_46r-SketchLine_42r-SketchArc_9_2f-SketchArc_8_2r")] +ExtrusionCut_10 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_10_objects_1, model.selection(), model.selection("FACE", "ExtrusionCut_3_2/Modified_Face&Extrusion_1_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_8_1_2")]) +Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_9_1/Modified_Face&Sketch_6/SketchLine_33")) SketchLine_50 = Sketch_8.addLine(37, 14.80042035331162, 37, -14) SketchLine_50.setName("SketchLine_56") SketchLine_50.result().setName("SketchLine_56") SketchLine_50.setAuxiliary(True) -SketchLine_51 = Sketch_8.addLine(model.selection("EDGE", "ExtrusionCut_9_1/Modfied_1&Extrusion_6_1/To_Face_1")) +SketchLine_51 = Sketch_8.addLine(model.selection("EDGE", "[ExtrusionCut_9_1/Modified_Face&Sketch_6/SketchLine_33][Extrusion_6_1/To_Face]")) SketchLine_51.setName("SketchLine_57") SketchLine_51.result().setName("SketchLine_57") SketchConstraintCoincidence_73 = Sketch_8.setCoincident(SketchLine_50.startPoint(), SketchLine_51.result()) SketchConstraintCoincidence_73.setName("SketchConstraintCoincidence_81") SketchConstraintCoincidence_74 = Sketch_8.setCoincident(SketchLine_50.endPoint(), SketchLine_51.result()) SketchConstraintCoincidence_74.setName("SketchConstraintCoincidence_82") -SketchLine_52 = Sketch_8.addLine(model.selection("EDGE", "Extrusion_6_1/Generated_Face_4&ExtrusionCut_9_1/Modfied_1")) +SketchLine_52 = Sketch_8.addLine(model.selection("EDGE", "[Extrusion_6_1/Generated_Face&Sketch_6/SketchLine_36][ExtrusionCut_9_1/Modified_Face&Sketch_6/SketchLine_33]")) SketchLine_52.setName("SketchLine_58") SketchLine_52.result().setName("SketchLine_58") -SketchArc_21 = Sketch_8.addArc(34, -14, 37, -14, 34.00000001126211, -17, True) +SketchArc_21 = Sketch_8.addArc(34, -14, 37, -14, 33.9999999583228, -17, True) SketchArc_21.setName("SketchArc_23") SketchArc_21.result().setName("SketchArc_23") SketchArc_21.results()[1].setName("SketchArc_23_2") @@ -688,7 +689,7 @@ SketchConstraintTangent_6 = Sketch_8.setTangent(SketchLine_50.result(), SketchAr SketchConstraintCoincidence_76 = Sketch_8.setCoincident(SketchLine_52.result(), SketchArc_21.endPoint()) SketchConstraintCoincidence_76.setName("SketchConstraintCoincidence_84") SketchConstraintTangent_7 = Sketch_8.setTangent(SketchArc_21.results()[1], SketchLine_52.result()) -SketchLine_53 = Sketch_8.addLine(34.00000002238511, -17, 37, -17) +SketchLine_53 = Sketch_8.addLine(34, -17, 37, -17) SketchLine_53.setName("SketchLine_59") SketchLine_53.result().setName("SketchLine_59") SketchConstraintCoincidence_77 = Sketch_8.setCoincident(SketchArc_21.endPoint(), SketchLine_53.startPoint()) @@ -704,7 +705,7 @@ SketchConstraintCoincidence_80 = Sketch_8.setCoincident(SketchLine_51.startPoint SketchConstraintCoincidence_80.setName("SketchConstraintCoincidence_88") SketchConstraintRadius_15 = Sketch_8.setRadius(SketchArc_21.results()[1], "3*coeff") SketchConstraintRadius_15.setName("SketchConstraintRadius_16") -SketchLine_55 = Sketch_8.addLine(model.selection("EDGE", "Sketch_7/Edge-SketchLine_38")) +SketchLine_55 = Sketch_8.addLine(model.selection("EDGE", "Sketch_7/SketchLine_38")) SketchLine_55.setName("SketchLine_61") SketchLine_55.result().setName("SketchLine_61") SketchConstraintMirror_2_objects = [SketchArc_21.results()[1], SketchLine_54.result(), SketchLine_53.result()] @@ -718,20 +719,20 @@ SketchArc_22.setName("SketchArc_24") SketchArc_22.result().setName("SketchArc_24") SketchArc_22.results()[1].setName("SketchArc_24_2") model.do() -ExtrusionCut_11 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchArc_23_2r-SketchLine_59f-SketchLine_60r"), model.selection("WIRE", "Sketch_8/Wire-SketchArc_24_2r-SketchLine_62f-SketchLine_63r")], model.selection(), 0, "100*coeff", [model.selection("SOLID", "ExtrusionCut_9_1")]) -Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_5_1/Generated_Face_1")) +ExtrusionCut_11 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_59f-SketchLine_60r-SketchArc_23_2r"), model.selection("WIRE", "Sketch_8/Face-SketchLine_62f-SketchLine_63r-SketchArc_24_2r_wire")], model.selection(), 0, "100*coeff", [model.selection("SOLID", "ExtrusionCut_9_1")]) +Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_5_1/Generated_Face&Sketch_5/SketchLine_29")) SketchLine_58 = Sketch_9.addLine(-32, -19, -32, -3.575047476349699) SketchLine_58.setName("SketchLine_64") SketchLine_58.result().setName("SketchLine_64") SketchLine_58.setAuxiliary(True) -SketchLine_59 = Sketch_9.addLine(model.selection("EDGE", "Extrusion_5_1/Generated_Face_1&Extrusion_5_1/Generated_Face_2")) +SketchLine_59 = Sketch_9.addLine(model.selection("EDGE", "[Extrusion_5_1/Generated_Face&Sketch_5/SketchLine_32][Extrusion_5_1/Generated_Face&Sketch_5/SketchLine_29]")) SketchLine_59.setName("SketchLine_65") SketchLine_59.result().setName("SketchLine_65") SketchConstraintCoincidence_81 = Sketch_9.setCoincident(SketchLine_58.startPoint(), SketchLine_59.result()) SketchConstraintCoincidence_81.setName("SketchConstraintCoincidence_89") SketchConstraintCoincidence_82 = Sketch_9.setCoincident(SketchLine_58.endPoint(), SketchLine_59.result()) SketchConstraintCoincidence_82.setName("SketchConstraintCoincidence_90") -SketchLine_60 = Sketch_9.addLine(model.selection("EDGE", "Extrusion_5_1/Generated_Face_1&Extrusion_5_1/From_Face_1")) +SketchLine_60 = Sketch_9.addLine(model.selection("EDGE", "[Extrusion_5_1/Generated_Face&Sketch_5/SketchLine_29][Extrusion_5_1/From_Face]")) SketchLine_60.setName("SketchLine_66") SketchLine_60.result().setName("SketchLine_66") SketchArc_23 = Sketch_9.addArc(-29, -19, -32, -19, -29.00002201340376, -22, False) @@ -761,7 +762,7 @@ SketchConstraintCoincidence_88.setName("SketchConstraintCoincidence_96") SketchConstraintRadius_16 = Sketch_9.setRadius(SketchArc_23.results()[1], "3*coeff") SketchConstraintRadius_16.setName("SketchConstraintRadius_17") model.do() -ExtrusionCut_12 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchArc_25_2r-SketchLine_67f-SketchLine_68f")], model.selection(), 0, "100*coeff", [model.selection("SOLID", "Extrusion_5_1")]) +ExtrusionCut_12 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_9/Face-SketchLine_67f-SketchLine_68f-SketchArc_25_2r")], model.selection(), 0, "100*coeff", [model.selection("SOLID", "Extrusion_5_1")]) model.do() from GeomAPI import GeomAPI_Shape @@ -777,7 +778,7 @@ model.testResultsVolumes(Part_1, [118190.673218984]) # checking for parametric update Parameter_Epaisseur.setValue(33.9) model.do() -model.testResultsVolumes(Part_1, [118105.9369682]) +model.testResultsVolumes(Part_1, [122133.938213185]) Parameter_Epaisseur.setValue(34) model.do() model.testResultsVolumes(Part_1, [118190.673218984]) diff --git a/test.models/plug.py b/test.models/plug.py index 37ce6db8b..a0de918f0 100644 --- a/test.models/plug.py +++ b/test.models/plug.py @@ -191,12 +191,12 @@ model.testNbSubShapes(Revolution_1, GeomAPI_Shape.EDGE, [114]) model.testNbSubShapes(Revolution_1, GeomAPI_Shape.VERTEX, [228]) model.testResultsVolumes(Revolution_1, [29055.346994571114919381216168404]) -Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OY"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), True) +Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OY"), model.selection("VERTEX", "Sketch_1/SketchPoint_2"), True) Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) -SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2"), False) +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchPoint_2"), False) SketchPoint_3 = SketchProjection_3.createdFeature() -SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Revolution_1_1/Generated_Face_28"), False) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8])"), False) SketchLine_36 = SketchProjection_4.createdFeature() SketchCircle_1 = Sketch_2.addCircle(14.5, 0, 2.25) SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchPoint_3.result(), SketchCircle_1.center()) @@ -215,7 +215,7 @@ model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.EDGE, [132]) model.testNbSubShapes(ExtrusionCut_1, GeomAPI_Shape.VERTEX, [264]) model.testResultsVolumes(ExtrusionCut_1, [28943.115000463178148493170738220]) -Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "Revolution_1_1/Generated_Face_14&Revolution_1_1/Generated_Face_15")], "Fillet1") +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20]")], "Fillet1") # check Fillet_1 model.testNbResults(Fillet_1, 1) model.testNbSubResults(Fillet_1, [0]) @@ -225,7 +225,7 @@ model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [136]) model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [272]) model.testResultsVolumes(Fillet_1, [28340.280766451105591841042041779]) -Fillet_2 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_4"), model.selection("FACE", "Revolution_1_1/Generated_Face_6"), model.selection("FACE", "Revolution_1_1/Generated_Face_8"), model.selection("FACE", "Revolution_1_1/Generated_Face_10")], "Fillet2") +Fillet_2 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_31"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_29"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_27"), model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25")], "Fillet2") # check Fillet_2 model.testNbResults(Fillet_2, 1) model.testNbSubResults(Fillet_2, [0]) @@ -235,7 +235,7 @@ model.testNbSubShapes(Fillet_2, GeomAPI_Shape.EDGE, [168]) model.testNbSubShapes(Fillet_2, GeomAPI_Shape.VERTEX, [336]) model.testResultsVolumes(Fillet_2, [28339.715350479829794494435191154]) -Fillet_3 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_16")], "Fillet3") +Fillet_3 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19")], "Fillet3") # check Fillet_3 model.testNbResults(Fillet_3, 1) model.testNbSubResults(Fillet_3, [0]) @@ -245,7 +245,7 @@ model.testNbSubShapes(Fillet_3, GeomAPI_Shape.EDGE, [176]) model.testNbSubShapes(Fillet_3, GeomAPI_Shape.VERTEX, [352]) model.testResultsVolumes(Fillet_3, [28338.609830057110229972749948502]) -Fillet_4 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_24")], "Fillet3") +Fillet_4 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_11")], "Fillet3") # check Fillet_4 model.testNbResults(Fillet_4, 1) model.testNbSubResults(Fillet_4, [0]) @@ -255,7 +255,7 @@ model.testNbSubShapes(Fillet_4, GeomAPI_Shape.EDGE, [184]) model.testNbSubShapes(Fillet_4, GeomAPI_Shape.VERTEX, [368]) model.testResultsVolumes(Fillet_4, [28347.280717884430487174540758133]) -Fillet_5 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face_26")], "Fillet2") +Fillet_5 = model.addFillet(Part_1_doc, [model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_9")], "Fillet2") # check Fillet_5 model.testNbResults(Fillet_5, 1) model.testNbSubResults(Fillet_5, [0]) @@ -281,17 +281,17 @@ SketchConstraintCoincidence_43 = Sketch_3.setCoincident(SketchLine_41.endPoint() SketchConstraintCoincidence_44 = Sketch_3.setCoincident(SketchLine_42.endPoint(), SketchLine_37.startPoint()) SketchProjection_5 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) SketchLine_43 = SketchProjection_5.createdFeature() -SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_33"), False) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_33"), False) SketchLine_44 = SketchProjection_6.createdFeature() -SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_33"), False) +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_33"), False) SketchLine_45 = SketchProjection_7.createdFeature() -SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_33"), False) +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_33"), False) SketchLine_46 = SketchProjection_8.createdFeature() -SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_32"), False) +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_32"), False) SketchLine_47 = SketchProjection_9.createdFeature() -SketchProjection_10 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_32"), False) +SketchProjection_10 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_32"), False) SketchLine_48 = SketchProjection_10.createdFeature() -SketchProjection_11 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_32"), False) +SketchProjection_11 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_32"), False) SketchLine_49 = SketchProjection_11.createdFeature() SketchConstraintVertical_13 = Sketch_3.setVertical(SketchLine_37.result()) SketchConstraintVertical_14 = Sketch_3.setVertical(SketchLine_39.result()) @@ -347,11 +347,11 @@ SketchConstraintVertical_15 = Sketch_4.setVertical(SketchLine_52.result()) SketchConstraintVertical_16 = Sketch_4.setVertical(SketchLine_55.result()) SketchConstraintVertical_17 = Sketch_4.setVertical(SketchLine_58.result()) SketchConstraintHorizontal_11 = Sketch_4.setHorizontal(SketchLine_56.result()) -SketchProjection_13 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/Vertex-SketchLine_24s-SketchLine_23e"), False) +SketchProjection_13 = Sketch_4.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_23_EndVertex"), False) SketchPoint_4 = SketchProjection_13.createdFeature() SketchConstraintDistanceHorizontal_17 = Sketch_4.setHorizontalDistance(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_52.endPoint(), "Drill2_Loc") SketchConstraintDistanceHorizontal_18 = Sketch_4.setHorizontalDistance(SketchLine_54.startPoint(), SketchLine_54.endPoint(), "Drill2_InnerRadius") -SketchProjection_14 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_20"), False) +SketchProjection_14 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_20"), False) SketchLine_59 = SketchProjection_14.createdFeature() SketchConstraintAngle_6 = Sketch_4.setAngle(SketchLine_57.result(), SketchLine_56.result(), 45) SketchConstraintMirror_2 = Sketch_4.addMirror(SketchLine_53.result(), [SketchLine_59.result()]) @@ -370,7 +370,7 @@ model.do() # check Sketch_4 model.checkSketch(Sketch_4, 0) -RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_52r-SketchLine_54r-SketchLine_55r-SketchLine_56f-SketchLine_57f-SketchLine_58f-SketchArc_2_2f")], model.selection("EDGE", "Sketch_4/Edge-SketchLine_52"), 360, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) +RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_56f-SketchLine_57f-SketchLine_58f-SketchArc_2_2f-SketchLine_55r-SketchLine_54r-SketchLine_52r")], model.selection("EDGE", "Sketch_4/SketchLine_52"), 360, 0, [model.selection("SOLID", "ExtrusionCut_2_1")]) # check RevolutionCut_1 model.testNbResults(RevolutionCut_1, 1) model.testNbSubResults(RevolutionCut_1, [0]) @@ -384,7 +384,7 @@ RevolutionCut_2 = model.addRevolutionCut(Part_1_doc, [], model.selection("EDGE", Sketch_5 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) SketchLine_61 = Sketch_5.addLine(63.5, 10.5, 64, 10.5) SketchLine_61.setAuxiliary(True) -SketchProjection_15 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_7"), False) +SketchProjection_15 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_7"), False) SketchLine_62 = SketchProjection_15.createdFeature() SketchConstraintCoincidence_58 = Sketch_5.setCoincident(SketchLine_61.startPoint(), SketchLine_62.result()) SketchConstraintCoincidence_59 = Sketch_5.setCoincident(SketchAPI_Line(SketchLine_62).endPoint(), SketchLine_61.endPoint()) @@ -437,11 +437,6 @@ model.testNbSubShapes(Result, GeomAPI_Shape.EDGE, [366]) model.testNbSubShapes(Result, GeomAPI_Shape.VERTEX, [732]) model.testResultsVolumes(Result, [14144.443128843522572424262762070]) -Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Plug/Modified_Face_27_1"), model.selection("FACE", "Plug/Modified_Face_26_1"), model.selection("FACE", "Plug/Modified_Face_28_1"), model.selection("FACE", "Plug/Modified_Face_32_1")]) -Group_1.result().setColor(68, 68, 68) -# check Group_1 -model.checkGroup(Group_1, GeomAPI_Shape.FACE) - model.do() # change parameters of the model @@ -519,8 +514,6 @@ model.testNbSubShapes(Result, GeomAPI_Shape.EDGE, [364]) model.testNbSubShapes(Result, GeomAPI_Shape.VERTEX, [728]) model.testResultsVolumes(Result, [23373.503259112552768783643841743]) -model.checkGroup(Group_1, GeomAPI_Shape.FACE) - model.end() assert(model.checkPythonDump()) diff --git a/test.models/sprocket.py b/test.models/sprocket.py index 30c174ab2..a5a013a7d 100644 --- a/test.models/sprocket.py +++ b/test.models/sprocket.py @@ -114,7 +114,7 @@ model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [1080]) model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [2160]) model.testResultsVolumes(Extrusion_1, [10398.453966298400700907222926617]) -Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1")) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) SketchCircle_3 = Sketch_2.addCircle(0, 0, 4.5) SketchLine_125 = Sketch_2.addLine(0, 0, -24.375, 0) SketchLine_125.setAuxiliary(True) diff --git a/test.models/wheel_rim.py b/test.models/wheel_rim.py index a55623b16..6c5f4782a 100644 --- a/test.models/wheel_rim.py +++ b/test.models/wheel_rim.py @@ -187,7 +187,7 @@ SketchConstraintDistance_4 = Sketch_1.setDistance(SketchLine_10.startPoint(), Sk SketchConstraintDistance_5 = Sketch_1.setDistance(SketchLine_10.startPoint(), SketchLine_22.result(), 1, True) SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_6.results()[1], 15) model.do() -Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2r-SketchArc_1_2r-SketchLine_3r-SketchArc_2_2r-SketchArc_3_2f-SketchLine_8f-SketchLine_10f-SketchArc_5_2f-SketchLine_12f-SketchArc_6_2r-SketchLine_14r-SketchLine_16r-SketchArc_7_2r-SketchLine_17r-SketchLine_18r-SketchLine_20f-SketchArc_8_2f-SketchLine_23r-SketchArc_10_2f-SketchLine_24r")], model.selection("EDGE", "PartSet/OX"), 360, 0) +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8f-SketchLine_10f-SketchLine_24r-SketchLine_23r-SketchArc_8_2f-SketchLine_19r-SketchLine_18r-SketchLine_17r-SketchArc_7_2r-SketchLine_16r-SketchArc_10_2f-SketchLine_12f-SketchArc_5_2f-SketchArc_6_2r-SketchLine_14r-SketchArc_3_2f-SketchArc_2_2r-SketchLine_3r-SketchArc_1_2r-SketchLine_2r")], model.selection("EDGE", "PartSet/OX"), 360, 0) Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ")) SketchCircle_1 = Sketch_2.addCircle(0, 120, 7.5) SketchLine_24 = Sketch_2.addLine(model.selection("EDGE", "PartSet/OZ"))