From: GERALD NICOLAS Date: Thu, 7 Jan 2021 10:57:43 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' into gni/documentation X-Git-Tag: V9_7_0a1~58^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=20d35238897e717b51eaba89f9ba3695ebf57e49;hp=1328792d087a04725585ce752b38c81ba304f46c;p=modules%2Fshaper.git Merge remote-tracking branch 'origin/master' into gni/documentation --- diff --git a/CMakeCommon/FindSUIT.cmake b/CMakeCommon/FindSUIT.cmake index 43a29f809..518b31983 100644 --- a/CMakeCommon/FindSUIT.cmake +++ b/CMakeCommon/FindSUIT.cmake @@ -46,3 +46,6 @@ ELSE(HAVE_SALOME) ENDIF() ENDIF(EXISTS ${SUIT_DIR}) ENDIF(HAVE_SALOME) + +FILE(TO_CMAKE_PATH ${SUIT_LIB_DIR} SUIT_LIB_DIR) +FILE(TO_CMAKE_PATH ${SUIT_INCLUDE} SUIT_INCLUDE) diff --git a/CMakeCommon/UnitTest.cmake b/CMakeCommon/UnitTest.cmake index 730f12136..b3abbba73 100644 --- a/CMakeCommon/UnitTest.cmake +++ b/CMakeCommon/UnitTest.cmake @@ -42,18 +42,8 @@ ENABLE_TESTING() -MACRO(ADD_UNIT_TESTS) - if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") - else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") - endif() +function(GENERATE_TESTS PATH testdir TESTS) + SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) foreach(eachFileName ${ARGN}) # Strip the ".py" suffix @@ -64,66 +54,36 @@ MACRO(ADD_UNIT_TESTS) SET(aTestName "${aSubprojectName}_${aTestName}") # Full path to the python test file beeing executed - SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/Test/${eachFileName}") + SET(aTestFileName "${testdir}/${eachFileName}") IF(EXISTS ${aTestFileName}) ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" + SET_TESTS_PROPERTIES(${aTestName} PROPERTIES + ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1" LABELS "${aSubprojectName}") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - endif() # Debug output... #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}") ELSE(EXISTS ${aTestFileName}) MESSAGE(WARNING "Can not find the test file: ${aTestFileName}") ENDIF(EXISTS ${aTestFileName}) endforeach(eachFileName ${ARGN}) -ENDMACRO(ADD_UNIT_TESTS) +endfunction(GENERATE_TESTS) -MACRO(ADD_UNIT_TESTS_API) - if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};${SALOME_KERNEL_LIBDIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") - else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:${SALOME_KERNEL_LIBDIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") - endif() +function(ADD_UNIT_TESTS) + GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}/Test" TESTS ${ARGN}) +endfunction(ADD_UNIT_TESTS) - foreach(eachFileName ${ARGN}) - # Strip the ".py" suffix - GET_FILENAME_COMPONENT(aTestName ${eachFileName} NAME_WE) +function(ADD_UNIT_TESTS_API) + GENERATE_TESTS(PATH "${CMAKE_CURRENT_SOURCE_DIR}" TESTS ${ARGN}) +endfunction(ADD_UNIT_TESTS_API) - # Add "SubprojectName_" prefix - GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME) - SET(aTestName "${aSubprojectName}_${aTestName}") - # Full path to the python test file beeing executed - SET(aTestFileName "${CMAKE_CURRENT_SOURCE_DIR}/${eachFileName}") - IF(EXISTS ${aTestFileName}) - ADD_TEST(NAME ${aTestName} - COMMAND ${PYTHON_EXECUTABLE} ${aTestFileName}) - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES - ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "${aSubprojectName}") - endif() - # Debug output... - #MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFileName}") - ELSE(EXISTS ${aTestFileName}) - MESSAGE(WARNING "Can not find the test file: ${aTestFileName}") - ENDIF(EXISTS ${aTestFileName}) - endforeach(eachFileName ${ARGN}) -ENDMACRO(ADD_UNIT_TESTS_API) +function(ADD_RESTRICTED_TESTS) + SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository") + + if (EXISTS ${RESTRICTED_ROOT_DIR}) + GENERATE_TESTS(PATH "${RESTRICTED_ROOT_DIR}/SHAPER/bugs" TESTS ${ARGN}) + else() + message(WARNING "RESTRICTED_ROOT_DIR is not specified to run restricted tests") + endif() +endfunction(ADD_RESTRICTED_TESTS) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ef061f23..2d8fef60e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,25 +20,25 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10) PROJECT (SHAPER) +SET(${PROJECT_NAME}_MAJOR_VERSION 9) +SET(${PROJECT_NAME}_MINOR_VERSION 6) +SET(${PROJECT_NAME}_PATCH_VERSION 0) +SET(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}) + # Ensure a proper linker behavior: CMAKE_POLICY(SET CMP0003 NEW) IF(WIN32) CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib ENDIF(WIN32) -SET (SHAPER_Version 9.5.0) - SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeCommon" ${CMAKE_MODULE_PATH}) IF (NOT CADBUILDER_BUILD_DOC) OPTION(SHAPER_BUILD_DOC "Generate SHAPER documentation" ON) ENDIF(NOT CADBUILDER_BUILD_DOC) -INCLUDE(SalomeMacros) - INCLUDE(FindEclipse) INCLUDE(Common) -INCLUDE(FindSalomeQt5) INCLUDE(FindSalome) INCLUDE(FindSUIT) INCLUDE(FindTInspector) @@ -48,6 +48,7 @@ IF(${HAVE_SALOME}) IF(EXISTS ${CONFIGURATION_ROOT_DIR}) LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake") INCLUDE(SalomeMacros) + INCLUDE(FindSalomeQt5) ELSE() MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !") ENDIF() @@ -60,6 +61,11 @@ IF(${HAVE_SALOME}) ELSE(EXISTS ${KERNEL_ROOT_DIR}) MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") ENDIF(EXISTS ${KERNEL_ROOT_DIR}) + SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") + IF(EXISTS ${GUI_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/salome_adm/cmake_files") + FIND_PACKAGE(SalomeGUI REQUIRED) + ENDIF(EXISTS ${GUI_ROOT_DIR}) INCLUDE(SalomeSetupPlatform) # From CONFIGURATION FIND_PACKAGE(SalomePythonInterp REQUIRED) @@ -68,6 +74,8 @@ IF(${HAVE_SALOME}) FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) ELSE(${HAVE_SALOME}) + INCLUDE(SalomeMacros) + INCLUDE(FindSalomeQt5) INCLUDE(FindPython) INCLUDE(FindSalomeOpenCASCADE) ENDIF(${HAVE_SALOME}) @@ -81,11 +89,9 @@ IF(DEFINED ENV{LIBXML2_ROOT_DIR}) IF(WIN32) FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.lib LIBXML2_LIBRARIES) FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include LIBXML2_INCLUDE_DIR) - ELSE() - IF(NOT "$ENV{LIBXML2_ROOT_DIR}" STREQUAL "/usr") - FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.so LIBXML2_LIBRARIES) - FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include/libxml2 LIBXML2_INCLUDE_DIR) - ENDIF() + ELSEIF(NOT "$ENV{LIBXML2_ROOT_DIR}" STREQUAL "/usr") + FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.so LIBXML2_LIBRARIES) + FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/include/libxml2 LIBXML2_INCLUDE_DIR) ENDIF() ENDIF() # It could be called only once @@ -121,12 +127,27 @@ ELSE(${HAVE_SALOME}) SET(SHAPER_INSTALL_TUI_DOC doc CACHE INTERNAL "" FORCE) ENDIF(${HAVE_SALOME}) +# Test environment +# =================== + +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}") +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}") +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}") +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${SUIT_LIB_DIR}") +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK "${SALOME_KERNEL_LIBDIR}") + +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}") +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}") +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}") + +SET(SALOME_SHAPER_INSTALL_TESTS "${SHAPER_INSTALL_PYTHON_FILES}/test" CACHE PATH "Path to tests directory") + # Sketcher: Change radius of circular edges while dragging a point on the edge SET(SKETCHER_CHANGE_RADIUS_WHEN_MOVE TRUE) SET(MAKE_TRANSLATION YES) +ADD_DEFINITIONS( -DMAKE_TRANSLATION ) - ADD_DEFINITIONS( -DMAKE_TRANSLATION ) ADD_SUBDIRECTORY (src/Config) ADD_SUBDIRECTORY (src/Locale) ADD_SUBDIRECTORY (src/Events) @@ -196,9 +217,16 @@ IF(ADD_COMPATIBILITY_TESTS) ADD_CUSTOM_TARGET(run_compatibility_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -LE "tests_compatibility") ENDIF(ADD_COMPATIBILITY_TESTS) -IF(ADD_HDF_TESTS) - ADD_SUBDIRECTORY (test.hdfs) -ENDIF(ADD_HDF_TESTS) +IF(${HAVE_SALOME}) + IF(ADD_HDF_TESTS) + ADD_SUBDIRECTORY (test.hdfs) + ENDIF(ADD_HDF_TESTS) + + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/CTestTestfileInstall.cmake + DESTINATION ${SALOME_SHAPER_INSTALL_TESTS} + RENAME CTestTestfile.cmake) +ENDIF(${HAVE_SALOME}) + IF(SHAPER_BUILD_DOC) INCLUDE(FindSphinx) diff --git a/doc/gui/conf.py.in b/doc/gui/conf.py.in index d6a8bebf2..d1327b144 100644 --- a/doc/gui/conf.py.in +++ b/doc/gui/conf.py.in @@ -68,9 +68,9 @@ html_show_copyright = False # built documents. # # The short X.Y version. -version = u'@SHAPER_Version@' +version = u'@SHAPER_VERSION@' # The full version, including alpha/beta/rc tags. -release = u'@SHAPER_Version@' +release = u'@SHAPER_VERSION@' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/swig/doxyfile.in b/doc/swig/doxyfile.in index eded67497..0d4795380 100644 --- a/doc/swig/doxyfile.in +++ b/doc/swig/doxyfile.in @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = @CMAKE_PROJECT_NAME@ -PROJECT_NUMBER = @SHAPER_Version@ +PROJECT_NUMBER = @SHAPER_VERSION@ PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = diff --git a/doc/tui/doxyfile.in b/doc/tui/doxyfile.in index 538e95925..4d4d34857 100644 --- a/doc/tui/doxyfile.in +++ b/doc/tui/doxyfile.in @@ -32,7 +32,7 @@ PROJECT_NAME = @CMAKE_PROJECT_NAME@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @SHAPER_Version@ +PROJECT_NUMBER = @SHAPER_VERSION@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer diff --git a/env.sh b/env.sh index 5278ef68f..060985d4f 100644 --- a/env.sh +++ b/env.sh @@ -1,6 +1,6 @@ #!/bin/bash -x -export SALOME_DIR=/dn46/SALOME/series9x/current-2020-07-20 +export SALOME_DIR=/dn46/SALOME/series9x/current-2020-12-21 # Path to sources export SOURCES_DIR=$(pwd) diff --git a/src/BuildPlugin/BuildPlugin_Filling.cpp b/src/BuildPlugin/BuildPlugin_Filling.cpp index 457f2eeee..9f669cf71 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.cpp +++ b/src/BuildPlugin/BuildPlugin_Filling.cpp @@ -30,10 +30,13 @@ #include #include #include +#include +#include #include #include #include +#include #include @@ -48,6 +51,15 @@ struct FillingParameters bool isApprox; }; +static bool isReverseClosedCurve(const GeomEdgePtr& theEdge1, + const GeomEdgePtr& theEdge2); +static bool isReverseOpenedCurve(const GeomEdgePtr& theEdge1, + const GeomEdgePtr& theEdge2, + const double theTolerance); +static void shiftStartPoint(GeomWirePtr& theWire, + const GeomEdgePtr& theRefEdge, + const double theTolerance); + //================================================================================================= BuildPlugin_Filling::BuildPlugin_Filling() @@ -104,15 +116,11 @@ void BuildPlugin_Filling::execute() for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { AttributeSelectionPtr aSelection = aSelectionList->value(anIndex); GeomEdgePtr anEdge = toEdge(aSelection->value(), aParameters.method); - if (!anEdge) { - myLastEdgeStartPoint = GeomPointPtr(); - myLastEdgeEndPoint = GeomPointPtr(); + if (!anEdge) return; - } aFilling->add(anEdge); } - myLastEdgeStartPoint = GeomPointPtr(); - myLastEdgeEndPoint = GeomPointPtr(); + myLastEdge = GeomEdgePtr(); // build result aFilling->build(aParameters.isApprox); @@ -148,15 +156,20 @@ void BuildPlugin_Filling::attributeChanged(const std::string& theID) //================================================================================================= GeomEdgePtr BuildPlugin_Filling::toEdge(const GeomShapePtr& theShape, const std::string& theMethod) { + static const double TOLERANCE = 1.e-7; + GeomEdgePtr anEdge; switch (theShape->shapeType()) { case GeomAPI_Shape::EDGE: anEdge = GeomEdgePtr(new GeomAPI_Edge(GeomAlgoAPI_Copy(theShape).shape())); break; - case GeomAPI_Shape::WIRE: - anEdge = GeomAlgoAPI_ShapeTools::wireToEdge( - GeomWirePtr(new GeomAPI_Wire(theShape))); + case GeomAPI_Shape::WIRE: { + GeomWirePtr aWire(new GeomAPI_Wire(theShape)); + if (myLastEdge && theMethod == Method::AUTO_CORRECT_ORIENTATION()) + shiftStartPoint(aWire, myLastEdge, TOLERANCE); + anEdge = GeomAlgoAPI_ShapeTools::wireToEdge(aWire); break; + } default: break; } @@ -171,34 +184,18 @@ GeomEdgePtr BuildPlugin_Filling::toEdge(const GeomShapePtr& theShape, const std: // correct edge orientation according to filling method if (theMethod == Method::AUTO_CORRECT_ORIENTATION()) { // check the distance to previous edge boundaries, reverse edge if necessary - GeomPointPtr aStartPnt = anEdge->firstPoint(); - GeomPointPtr aEndPnt = anEdge->lastPoint(); - if (anEdge->orientation() == GeomAPI_Shape::REVERSED) { - aStartPnt = anEdge->lastPoint(); - aEndPnt = anEdge->firstPoint(); - } bool isReverse = false; - if (myLastEdgeStartPoint) { - double d1 = myLastEdgeStartPoint->distance(aStartPnt) - + myLastEdgeEndPoint->distance(aEndPnt); - double d2 = myLastEdgeStartPoint->distance(aEndPnt) - + myLastEdgeEndPoint->distance(aStartPnt); - if (fabs(d1 - d2) < 1.e-7) { - // undefined case => check distance to start point only - d1 = myLastEdgeStartPoint->distance(aStartPnt); - d2 = myLastEdgeStartPoint->distance(aEndPnt); - } - isReverse = d2 < d1; + if (myLastEdge) { + if (myLastEdge->firstPoint()->distance(myLastEdge->lastPoint()) < TOLERANCE && + anEdge->firstPoint()->distance(anEdge->lastPoint()) < TOLERANCE) + isReverse = isReverseClosedCurve(myLastEdge, anEdge); + else + isReverse = isReverseOpenedCurve(myLastEdge, anEdge, TOLERANCE); } - if (isReverse) { + myLastEdge = anEdge; + if (isReverse) anEdge->reverse(); - myLastEdgeStartPoint = aEndPnt; - myLastEdgeEndPoint = aStartPnt; - } else { - myLastEdgeStartPoint = aStartPnt; - myLastEdgeEndPoint = aEndPnt; - } } else if (theMethod == Method::USE_CURVE_INFORMATION()) { // make all edges FORWARD to avoid reversing the curves by GeomAlgoAPI_Filling algorithm @@ -218,3 +215,93 @@ void BuildPlugin_Filling::restoreDefaultParameters() real(TOLERANCE_3D_ID())->setValue(TOLERANCE_3D_DEFAULT()); boolean(APPROXIMATION_ID())->setValue(APPROXIMATION_DEFAULT()); } + + +//============ Auxiliary functions ======================================================== + +static std::pair edgeBoundaries(const GeomEdgePtr& theEdge) +{ + GeomPointPtr aStart = theEdge->firstPoint(); + GeomPointPtr anEnd = theEdge->lastPoint(); + if (theEdge->orientation() == GeomAPI_Shape::REVERSED) + std::swap(aStart, anEnd); + return std::pair(aStart, anEnd); +} + +static void edgePoints(const GeomEdgePtr& theEdge, std::list& thePoints) +{ + GeomAPI_Curve aCurve(theEdge); + static const int aNbSegments = 10; + double aStart = aCurve.startParam(); + double aEnd = aCurve.endParam(); + for (int i = 0; i <= aNbSegments; ++i) + thePoints.push_back(aCurve.getPoint(aStart * (1.0 - (double)i / aNbSegments) + + aEnd * (double)i / aNbSegments )); + if (theEdge->orientation() == GeomAPI_Shape::REVERSED) + thePoints.reverse(); +} + +bool isReverseClosedCurve(const GeomEdgePtr& theEdge1, + const GeomEdgePtr& theEdge2) +{ + std::list anEdge1Points, anEdge2Points; + edgePoints(theEdge1, anEdge1Points); + edgePoints(theEdge2, anEdge2Points); + + double d1 = 0.0; + double d2 = 0.0; + std::list::const_iterator anIt1 = anEdge1Points.begin(); + std::list::const_iterator anIt2 = anEdge2Points.begin(); + std::list::const_reverse_iterator anIt2Rev = anEdge2Points.rbegin(); + for (; anIt1 != anEdge1Points.end(); ++anIt1, ++anIt2, ++anIt2Rev) { + d1 += (*anIt1)->distance(*anIt2); + d2 += (*anIt1)->distance(*anIt2Rev); + } + return d2 < d1; +} + +bool isReverseOpenedCurve(const GeomEdgePtr& theEdge1, + const GeomEdgePtr& theEdge2, + const double theTolerance) +{ + std::pair anEdge1Points = edgeBoundaries(theEdge1); + std::pair anEdge2Points = edgeBoundaries(theEdge2); + double d1 = anEdge1Points.first->distance(anEdge2Points.first) + + anEdge1Points.second->distance(anEdge2Points.second); + double d2 = anEdge1Points.first->distance(anEdge2Points.second) + + anEdge1Points.second->distance(anEdge2Points.first); + if (fabs(d1 - d2) < theTolerance) { + // undefined case => check distance to start point only + d1 = anEdge1Points.first->distance(anEdge2Points.first); + d2 = anEdge1Points.first->distance(anEdge2Points.second); + } + return d2 < d1; +} + +void shiftStartPoint(GeomWirePtr& theWire, const GeomEdgePtr& theRefEdge, const double theTolerance) +{ + if (!theWire->isClosed()) { + GeomVertexPtr aV1, aV2; + GeomAlgoAPI_ShapeTools::findBounds(theWire, aV1, aV2); + if (aV1->point()->distance(aV2->point()) > theTolerance) + return; + } + + // find closest vertex on the wire to the start point on the edge + GeomPointPtr aFirstRefPnt = theRefEdge->firstPoint(); + ListOfShape aBegin, aEnd; + double aMinDist = 1.e100; + for (GeomAPI_WireExplorer anExp(theWire); anExp.more(); anExp.next()) { + double aDist = anExp.currentVertex()->point()->distance(aFirstRefPnt); + if (aDist < aMinDist) { + aMinDist = aDist; + aEnd.insert(aEnd.end(), aBegin.begin(), aBegin.end()); + aBegin.clear(); + } + aBegin.push_back(anExp.current()); + } + aBegin.insert(aBegin.end(), aEnd.begin(), aEnd.end()); + + GeomShapePtr aShape = GeomAlgoAPI_WireBuilder::wire(aBegin); + theWire.reset(new GeomAPI_Wire(aShape)); +} diff --git a/src/BuildPlugin/BuildPlugin_Filling.h b/src/BuildPlugin/BuildPlugin_Filling.h index 1d7297309..9725c8a33 100644 --- a/src/BuildPlugin/BuildPlugin_Filling.h +++ b/src/BuildPlugin/BuildPlugin_Filling.h @@ -171,8 +171,7 @@ private: void restoreDefaultParameters(); private: - std::shared_ptr myLastEdgeStartPoint; - std::shared_ptr myLastEdgeEndPoint; + std::shared_ptr myLastEdge; }; #endif diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp index 57d001894..c1bf527de 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.cpp +++ b/src/BuildPlugin/BuildPlugin_Wire.cpp @@ -396,7 +396,9 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape, else { // both vertices are found aFoundStart->second->push_back(anEdge); - if (aFoundStart->second != aFoundEnd->second) { + if (aFoundStart->second == aFoundEnd->second) + aMapVW.erase(aFoundStart); + else { // different wires => merge segments aFoundStart->second->insert(aFoundStart->second->end(), aFoundEnd->second->begin(), aFoundEnd->second->end()); @@ -407,9 +409,9 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape, break; } aNewWires.erase(aFoundEnd->second); + aMapVW.erase(aFoundStart); + aMapVW.erase(aFoundEnd); } - aMapVW.erase(aFoundStart); - aMapVW.erase(aFoundEnd); continue; } } diff --git a/src/BuildPlugin/CMakeLists.txt b/src/BuildPlugin/CMakeLists.txt index ca262f1fb..4bcf4a001 100644 --- a/src/BuildPlugin/CMakeLists.txt +++ b/src/BuildPlugin/CMakeLists.txt @@ -159,4 +159,6 @@ ADD_UNIT_TESTS(TestVertex.py Test3125.py Test3271.py Test19056.py + Test20469.py + Test20513.py ) diff --git a/src/BuildPlugin/Test/Test20469.py b/src/BuildPlugin/Test/Test20469.py new file mode 100644 index 000000000..6b2868e4e --- /dev/null +++ b/src/BuildPlugin/Test/Test20469.py @@ -0,0 +1,478 @@ +# Copyright (C) 2020 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() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "ep", "0.055") + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 2.8667, False) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(1.771, 0, 1.771) + +### Create SketchCircle +SketchCircle_2 = Sketch_1.addCircle(1.771, 0, 1.826) +model.do() + +### Create Plane +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 5.6, False) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) + +### Create SketchPoint +SketchPoint_1 = Sketch_2.addPoint(0, 0) + +### Create SketchPoint +SketchPoint_2 = Sketch_2.addPoint(0.03453184, 0.15311942) +SketchPoint_3 = Sketch_2.addPoint(0.11839488, 0.28145762) +SketchPoint_4 = Sketch_2.addPoint(0.20229646, 0.3653592) +SketchPoint_5 = Sketch_2.addPoint(0.325663, 0.44425058) +SketchPoint_6 = Sketch_2.addPoint(0.44409642, 0.5083426) +SketchPoint_7 = Sketch_2.addPoint(0.5625298400000001, 0.5526636) +SketchPoint_8 = Sketch_2.addPoint(0.70069574, 0.5969460600000001) +SketchPoint_9 = Sketch_2.addPoint(0.8684989, 0.63132374) +SketchPoint_10 = Sketch_2.addPoint(1.02146416, 0.6509020600000001) +SketchPoint_11 = Sketch_2.addPoint(1.22873228, 0.65063228) +SketchPoint_12 = Sketch_2.addPoint(1.41129626, 0.6454293800000001) +SketchPoint_13 = Sketch_2.addPoint(1.58403254, 0.6205325399999999) +SketchPoint_14 = Sketch_2.addPoint(1.7369978, 0.60550194) +SketchPoint_15 = Sketch_2.addPoint(1.9244949, 0.5632621) +SketchPoint_16 = Sketch_2.addPoint(2.10709742, 0.5160891400000001) +SketchPoint_17 = Sketch_2.addPoint(2.27486204, 0.4763544) +SketchPoint_18 = Sketch_2.addPoint(2.4179996, 0.43661966) +SketchPoint_19 = Sketch_2.addPoint(2.55123238, 0.39692346) +SketchPoint_20 = Sketch_2.addPoint(2.70913076, 0.3522556) +SketchPoint_21 = Sketch_2.addPoint(2.89173328, 0.29768296) +SketchPoint_22 = Sketch_2.addPoint(3.04469854, 0.2530151) +SketchPoint_23 = Sketch_2.addPoint(3.19273068, 0.20341412) +SketchPoint_24 = Sketch_2.addPoint(3.35556218, 0.1537746) +SketchPoint_25 = Sketch_2.addPoint(3.50363286, 0.10914528) +SketchPoint_26 = Sketch_2.addPoint(3.63686564, 0.06944908000000001) +SketchPoint_27 = Sketch_2.addPoint(3.7404997, 0.03965766) +SketchPoint_28 = Sketch_2.addPoint(3.838584, 0.004933120000000001) +SketchPoint_29 = Sketch_2.addPoint(3.854, -0.009866240000000002) +SketchPoint_30 = Sketch_2.addPoint(3.77009842, -0.004817500000000001) +SketchPoint_31 = Sketch_2.addPoint(3.56040228, 0.01025164) +SketchPoint_32 = Sketch_2.addPoint(3.43946376, 0.00300612) +SketchPoint_33 = Sketch_2.addPoint(3.31609722, -0.02154386) +SketchPoint_34 = Sketch_2.addPoint(3.18779756, -0.05349352) +SketchPoint_35 = Sketch_2.addPoint(3.04963166, -0.09777598) +SketchPoint_36 = Sketch_2.addPoint(2.89173328, -0.15192468) +SketchPoint_37 = Sketch_2.addPoint(2.70913076, -0.22580586) +SketchPoint_38 = Sketch_2.addPoint(2.54629926, -0.2947539200000001) +SketchPoint_39 = Sketch_2.addPoint(2.39822858, -0.3588074) +SketchPoint_40 = Sketch_2.addPoint(2.26992892, -0.41299464) +SketchPoint_41 = Sketch_2.addPoint(2.12189678, -0.47704812) +SketchPoint_42 = Sketch_2.addPoint(1.8998293, -0.5558238799999999) +SketchPoint_43 = Sketch_2.addPoint(1.70246596, -0.6247334) +SketchPoint_44 = Sketch_2.addPoint(1.52479656, -0.6640442000000001) +SketchPoint_45 = Sketch_2.addPoint(1.33236634, -0.68847856) +SketchPoint_46 = Sketch_2.addPoint(1.15223038, -0.7006186600000001) +SketchPoint_47 = Sketch_2.addPoint(0.9819992000000001, -0.69792086) +SketchPoint_48 = Sketch_2.addPoint(0.83392852, -0.6730240200000001) +SketchPoint_49 = Sketch_2.addPoint(0.68589638, -0.63826094) +SketchPoint_50 = Sketch_2.addPoint(0.5403308, -0.59359308) +SketchPoint_51 = Sketch_2.addPoint(0.4144977, -0.52425962) +SketchPoint_52 = Sketch_2.addPoint(0.30593052, -0.4549647) +SketchPoint_53 = Sketch_2.addPoint(0.19243022, -0.37079334) +SketchPoint_54 = Sketch_2.addPoint(0.09866240000000001, -0.26199492) +SketchPoint_55 = Sketch_2.addPoint(0.04439808000000001, -0.17296752) +SketchPoint_56 = Sketch_2.addPoint(0.009866240000000002, -0.08397866) + +### Create SketchBSpline +SketchBSpline_1_poles = [(0, 0), + (9.014752251795682e-05, 0.05451214529317949), + (0.02532271171862411, 0.15579971775632), + (0.1083431350565314, 0.2748971692083296), + (0.2055162110916063, 0.3762476714704591), + (0.3226869043516477, 0.4417758873955893), + (0.4396106030030269, 0.5114950821406695), + (0.5686113665746824, 0.5543315380381274), + (0.7080109281378321, 0.6032643908580265), + (0.8627418437966349, 0.6310529967664337), + (1.038760710497959, 0.658153841986185), + (1.22044861142381, 0.6481760900098785), + (1.409221724680022, 0.652722089409154), + (1.576578009046891, 0.6165884029638471), + (1.750622207371201, 0.6101568179490738), + (1.923498511038718, 0.5633997285939256), + (2.101468637706691, 0.5160168977121142), + (2.26756869845679, 0.4799182653430439), + (2.415109663038519, 0.4380247760586003), + (2.559003214216268, 0.3937264274604114), + (2.717970834232034, 0.3510185960290838), + (2.881379255194576, 0.2994130045705585), + (3.044331614256414, 0.2554589350745441), + (3.196663224032949, 0.2002205281261157), + (3.35069087314937, 0.1557508658621287), + (3.498630901739528, 0.1100749985226144), + (3.626758629069007, 0.07354615416618171), + (3.739427723854896, 0.03597634464461345), + (3.813716543275791, 0.02837078095396758), + (3.876876038873482, -0.02879298081488075), + (3.682323148493558, 0.01775150116288641), + (3.59938700895519, 0.01042701260276317), + (3.435447203044759, 0.007149079513330234), + (3.314513764134776, -0.02220772128681932), + (3.18286942455218, -0.05232760411385905), + (3.042896269666392, -0.1005145549495807), + (2.881422363667546, -0.1529357624091193), + (2.715356347244343, -0.2233467064370982), + (2.550824101050534, -0.2921770145750037), + (2.405271709687024, -0.3565989754466209), + (2.262755596022538, -0.4148284616351946), + (2.100460548562433, -0.4902544331640812), + (1.907228846399618, -0.5500679945393977), + (1.712805296024295, -0.6276431801884527), + (1.52116538281023, -0.6672841271228219), + (1.336949021174942, -0.6896647034143828), + (1.155869430538025, -0.7022133885319179), + (0.9881819820589015, -0.7038770986545503), + (0.8328846107160076, -0.6739914241952796), + (0.6860347780845882, -0.6386140063120748), + (0.5400707121799601, -0.6015647674456689), + (0.4182774376387844, -0.5270750025520176), + (0.3022771427307028, -0.4533773192679936), + (0.1872763782990937, -0.3753721045244912), + (0.1041307066426412, -0.2741285283554168), + (0.04291862690830676, -0.177004007658222), + (0.0185030859727657, -0.1148400743684852), + (0.009866240000000002, -0.08397866) + ] +SketchBSpline_1 = Sketch_2.addSpline(degree = 3, poles = SketchBSpline_1_poles, weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], knots = [0, 0.01860336163521267, 0.03677344027717935, 0.0508363049754388, 0.0681916392804011, 0.08415184938325194, 0.09913917386834825, 0.1163349772413292, 0.1366359422890603, 0.1549131538674821, 0.1794784236049427, 0.2011245430557611, 0.2218086624397829, 0.2400252925906828, 0.2628042259083713, 0.2851566328948674, 0.3055900477586722, 0.3231961160252453, 0.3396727392234426, 0.359121125995382, 0.3817088598254108, 0.4005953257674918, 0.4190986615685892, 0.4392741570447567, 0.4576031798532225, 0.4740798030514198, 0.4868598578148062, 0.4991917342048151, 0.5017244814860118, 0.5116864156093297, 0.5366035207975692, 0.5509627564215326, 0.5658707575129726, 0.5815411201190975, 0.5987369234920785, 0.6185207473608354, 0.641866954108396, 0.6628243946707135, 0.6819452440086935, 0.6984518054499047, 0.7175684625877018, 0.7454946578808465, 0.7702707840614231, 0.7918372885014108, 0.8148270864302183, 0.836225083387823, 0.8564032777714525, 0.8741988374599583, 0.8922207646184928, 0.910267059554588, 0.9272947229425885, 0.9425596161747006, 0.9593069836005957, 0.9763298627094416, 0.9886868701731323, 1], multiplicities = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4]) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_1.startPoint()) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_7.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_8.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_9.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_10.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_11.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_12.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_13.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_14.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_15.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_16.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_17.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_18.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_19.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_20.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_21.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_22.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_23.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_24.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_25.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_26.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_27.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_28.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_29.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_30.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_31.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_32.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_33.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_34.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_35.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_36.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_37.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_38.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_39.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_40.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_41.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_42.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_43.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_44.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_45.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_46.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_47.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_48.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_49.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_50.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_51.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_52.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_53.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_54.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_55.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_56.coordinates(), SketchBSpline_1.endPoint()) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_1.startPoint()) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_7.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_8.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_9.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_10.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_11.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_12.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_13.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_14.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_15.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_16.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_17.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_18.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_19.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_20.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_21.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_22.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_23.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_24.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_25.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_26.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_27.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_28.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_29.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_30.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_31.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_32.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_33.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_34.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_35.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_36.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_37.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_38.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_39.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_40.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_41.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_42.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_43.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_44.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_45.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_46.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_47.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_48.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_49.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_50.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_51.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_52.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_53.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_54.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_55.coordinates(), SketchBSpline_1.result()) +Sketch_2.setCoincident(SketchPoint_56.coordinates(), SketchBSpline_1.endPoint()) + +### Create SketchBSpline +SketchBSpline_2_poles = [(0, 0), + (9.014752251795682e-05, 0.05451214529317949), + (0.02532271171862411, 0.15579971775632), + (0.1083431350565314, 0.2748971692083296), + (0.2055162110916063, 0.3762476714704591), + (0.3226869043516477, 0.4417758873955893), + (0.4396106030030269, 0.5114950821406695), + (0.5686113665746824, 0.5543315380381274), + (0.7080109281378321, 0.6032643908580265), + (0.8627418437966349, 0.6310529967664337), + (1.038760710497959, 0.658153841986185), + (1.22044861142381, 0.6481760900098785), + (1.409221724680022, 0.652722089409154), + (1.576578009046891, 0.6165884029638471), + (1.750622207371201, 0.6101568179490738), + (1.923498511038718, 0.5633997285939256), + (2.101468637706691, 0.5160168977121142), + (2.26756869845679, 0.4799182653430439), + (2.415109663038519, 0.4380247760586003), + (2.559003214216268, 0.3937264274604114), + (2.717970834232034, 0.3510185960290838), + (2.881379255194576, 0.2994130045705585), + (3.044331614256414, 0.2554589350745441), + (3.196663224032949, 0.2002205281261157), + (3.35069087314937, 0.1557508658621287), + (3.498630901739528, 0.1100749985226144), + (3.626758629069007, 0.07354615416618171), + (3.739427723854896, 0.03597634464461345), + (3.813716543275791, 0.02837078095396758), + (3.876876038873482, -0.02879298081488075), + (3.682323148493558, 0.01775150116288641), + (3.59938700895519, 0.01042701260276316), + (3.435447203044759, 0.007149079513330239), + (3.314513764134776, -0.02220772128681934), + (3.182869424552179, -0.05232760411385898), + (3.042896269666394, -0.100514554949581), + (2.881422363667536, -0.1529357624091178), + (2.715356347244389, -0.2233467064371046), + (2.550824101050389, -0.2921770145749832), + (2.405271709687486, -0.3565989754466863), + (2.262755596020973, -0.4148284616349733), + (2.100460548570712, -0.490254433165252), + (1.907228846355101, -0.5500679945331017), + (1.712805296160232, -0.627643180207678), + (1.521165382362285, -0.66728412705947), + (1.336949022926033, -0.6896647036620358), + (1.155869424658838, -0.7022133877004375), + (0.9881820016357848, -0.7038771014232653), + (0.8328845467272493, -0.6739914151454918), + (0.6860350214810707, -0.638614040735098), + (0.5400698242489836, -0.6015646418675653), + (0.4182804086275665, -0.5270754227323547), + (0.302266907807943, -0.4533758717656259), + (0.1873191972961234, -0.3753781603200299), + (0.1039872761267704, -0.2741082432964857), + (0.04328037620103962, -0.1770551690563165), + (0.006988972040230026, -0.08835445483623842), + (-0.0008115069204040052, -0.02871741534942534), + (0, 0) + ] +SketchBSpline_2 = Sketch_2.addSpline(degree = 3, poles = SketchBSpline_2_poles, weights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], knots = [0, 0.01841877717868692, 0.03640857044229438, 0.0503319019589481, 0.06751503486217877, 0.08331688612829682, 0.09815550484724707, 0.1151806897007172, 0.1352802264972665, 0.1533760897133781, 0.1776976203324573, 0.1991289647725509, 0.2196078542088847, 0.2376437370925934, 0.2601966555045284, 0.2823272796231457, 0.3025579520551492, 0.3199893311119836, 0.3363024715699076, 0.3555578894595023, 0.3779215054846461, 0.3966205779803185, 0.4149403217914447, 0.43491563393835, 0.453062794308183, 0.4693759347661071, 0.4820291845192418, 0.4942387027706504, 0.496746319874324, 0.5066094106685624, 0.5312792857910991, 0.5454960476108249, 0.5602561299909423, 0.5757710096568369, 0.592796194510307, 0.6123837212555427, 0.6354982845523691, 0.6562477832463178, 0.6751789135618669, 0.6915216952124962, 0.7104486749233012, 0.7380977836510125, 0.762628078574017, 0.7839805979515587, 0.8067422887543781, 0.8279279725980087, 0.8479059568735401, 0.8655249471990413, 0.8833680589533851, 0.9012352967057089, 0.9180940098763235, 0.9332074432767975, 0.9497886416105058, 0.9666426179720728, 0.9788770179440802, 0.9900778977399243, 1], multiplicities = [4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4]) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_2.startPoint()) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_2.endPoint()) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_7.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_8.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_9.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_10.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_11.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_12.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_13.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_14.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_15.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_16.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_17.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_18.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_19.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_20.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_21.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_22.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_23.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_24.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_25.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_26.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_27.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_28.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_29.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_30.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_31.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_32.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_33.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_34.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_35.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_36.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_37.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_38.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_39.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_40.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_41.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_42.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_43.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_44.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_45.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_46.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_47.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_48.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_49.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_50.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_51.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_52.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_53.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_54.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_55.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_56.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_2.startPoint()) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_3.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_4.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_7.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_8.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_9.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_10.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_11.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_12.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_13.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_14.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_15.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_16.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_17.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_18.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_19.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_20.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_21.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_22.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_23.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_24.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_25.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_26.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_27.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_28.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_29.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_30.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_31.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_32.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_33.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_34.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_35.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_36.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_37.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_38.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_39.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_40.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_41.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_42.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_43.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_44.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_45.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_46.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_47.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_48.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_49.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_50.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_51.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_52.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_53.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_54.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_55.coordinates(), SketchBSpline_2.result()) +Sketch_2.setCoincident(SketchPoint_1.coordinates(), SketchBSpline_2.endPoint()) + +### Create SketchOffset +SketchOffset_1 = Sketch_2.addOffset([SketchBSpline_2.result()], 0.055, False) +[SketchBSpline_3, SketchBSpline_4, SketchBSpline_5, SketchBSpline_6, SketchBSpline_7, SketchBSpline_8, SketchBSpline_9, SketchBSpline_10, SketchBSpline_11, SketchBSpline_12, SketchBSpline_13, SketchBSpline_14, SketchBSpline_15, SketchBSpline_16, SketchBSpline_17, SketchBSpline_18, SketchBSpline_19, SketchBSpline_20, SketchBSpline_21, SketchBSpline_22, SketchBSpline_23, SketchBSpline_24, SketchBSpline_25, SketchBSpline_26, SketchBSpline_27, SketchBSpline_28, SketchBSpline_29, SketchBSpline_30, SketchBSpline_31, SketchBSpline_32, SketchBSpline_33, SketchBSpline_34, SketchBSpline_35, SketchBSpline_36, SketchBSpline_37, SketchBSpline_38, SketchBSpline_39, SketchBSpline_40, SketchBSpline_41, SketchBSpline_42, SketchBSpline_43, SketchBSpline_44, SketchBSpline_45, SketchBSpline_46, SketchBSpline_47, SketchBSpline_48, SketchBSpline_49, SketchBSpline_50, SketchBSpline_51, SketchBSpline_52, SketchBSpline_53, SketchBSpline_54, SketchBSpline_55, SketchBSpline_56, SketchBSpline_57, SketchBSpline_58, SketchBSpline_59, SketchBSpline_60, SketchBSpline_61, SketchBSpline_62, SketchBSpline_63] = SketchOffset_1.offset() +model.do() + +### Create Wire +Wire_1 = model.addWire(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], False) + +model.end() + +from GeomAPI import * + +model.testNbResults(Wire_1, 2) +model.testNbSubResults(Wire_1, [0, 0]) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.SOLID, [0, 0]) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.FACE, [0, 0]) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.EDGE, [2, 61]) +model.testNbSubShapes(Wire_1, GeomAPI_Shape.VERTEX, [4, 122]) + +assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/Test/Test20513.py b/src/BuildPlugin/Test/Test20513.py new file mode 100644 index 000000000..11192d91d --- /dev/null +++ b/src/BuildPlugin/Test/Test20513.py @@ -0,0 +1,97 @@ +# Copyright (C) 2020 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 + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() + +### Create SketchBSpline +SketchBSpline_1_poles = [(0, 0), + (64.69989977297864, 3.820449445888325), + (63.227018959685, 42.02181716036146), + (19.7442263567145, 66.94290132940253), + (0, 0) + ] +SketchBSpline_1 = Sketch_1.addSpline(poles = SketchBSpline_1_poles) +[SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6] = SketchBSpline_1.controlPoles(auxiliary = [0, 1, 2, 3, 4]) +[SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4] = SketchBSpline_1.controlPolygon(auxiliary = [0, 1, 2, 3]) +Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchPoint_1.result()) +Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_6).coordinates(), SketchPoint_1.result()) +model.do() + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchBSpline_1f"), 10, False) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchProjection +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_7 = SketchProjection_2.createdFeature() + +### Create SketchBSpline +SketchBSpline_2_poles = [(0, 0), + (8.839087148173476, 45.21301708610518), + (53.18579907801947, 39.22586299994072), + (47.99568029170977, 4.506542817571567), + (0, 0) + ] +SketchBSpline_2 = Sketch_2.addSpline(poles = SketchBSpline_2_poles) +[SketchPoint_8, SketchPoint_9, SketchPoint_10, SketchPoint_11, SketchPoint_12] = SketchBSpline_2.controlPoles(auxiliary = [0, 1, 2, 3, 4]) +[SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchBSpline_2.controlPolygon(auxiliary = [0, 1, 2, 3]) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_8).coordinates(), SketchPoint_7.result()) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_12).coordinates(), SketchPoint_7.result()) +model.do() + +### Create Wire +Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchBSpline_1")], False) + +### Create Wire +Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchBSpline_2")], False) + +### Create Filling +Filling_1 = model.addFilling(Part_1_doc, [model.selection("WIRE", "Wire_1_1"), model.selection("WIRE", "Wire_2_1")]) + +model.end() + +from GeomAPI import * + +model.testNbResults(Filling_1, 1) +model.testNbSubResults(Filling_1, [0]) +model.testNbSubShapes(Filling_1, GeomAPI_Shape.SOLID, [0]) +model.testNbSubShapes(Filling_1, GeomAPI_Shape.FACE, [1]) +model.testNbSubShapes(Filling_1, GeomAPI_Shape.EDGE, [4]) +model.testNbSubShapes(Filling_1, GeomAPI_Shape.VERTEX, [8]) +model.testResultsVolumes(Filling_1, [1872.0403629667237]) + +assert(model.checkPythonDump()) diff --git a/src/BuildPlugin/doc/compoundFeature.rst b/src/BuildPlugin/doc/compoundFeature.rst index 6ba8de92f..4c4d1b31e 100644 --- a/src/BuildPlugin/doc/compoundFeature.rst +++ b/src/BuildPlugin/doc/compoundFeature.rst @@ -12,7 +12,7 @@ To create a compound in the active part: The following property panel will be opened: -.. figure:: images/Compound.png +.. figure:: images/CompoundPanel.png :align: center Create a compound diff --git a/src/BuildPlugin/doc/images/Compound.png b/src/BuildPlugin/doc/images/Compound.png deleted file mode 100644 index 39d748b6c..000000000 Binary files a/src/BuildPlugin/doc/images/Compound.png and /dev/null differ diff --git a/src/BuildPlugin/doc/images/CompoundPanel.png b/src/BuildPlugin/doc/images/CompoundPanel.png new file mode 100644 index 000000000..39d748b6c Binary files /dev/null and b/src/BuildPlugin/doc/images/CompoundPanel.png differ diff --git a/src/CTestTestfileInstall.cmake b/src/CTestTestfileInstall.cmake new file mode 100644 index 000000000..c4e4606f1 --- /dev/null +++ b/src/CTestTestfileInstall.cmake @@ -0,0 +1,27 @@ +# Copyright (C) 2020 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 +# + +SET(SALOME_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/salome_test_driver.py") + +SET(COMPONENT_NAME SHAPER) + +# Add all test subdirs +SUBDIRS(ConnectorAPI + HDFs +) diff --git a/src/ConnectorAPI/Test/CMakeLists.txt b/src/ConnectorAPI/Test/CMakeLists.txt index cc288b03a..7e0b4846d 100644 --- a/src/ConnectorAPI/Test/CMakeLists.txt +++ b/src/ConnectorAPI/Test/CMakeLists.txt @@ -21,19 +21,8 @@ INCLUDE(tests.set) SET(COMPONENT_NAME SHAPER) -SET(SALOME_SHAPER_INSTALL_TESTS "${SHAPER_INSTALL_PYTHON_FILES}/test") -SET(TEST_INSTALL_DIRECTORY ${SALOME_SHAPER_INSTALL_TESTS}) - -# make test -SET(SALOME_INSTALL_LIBS "lib/salome") -# Adding KERNEL and GUI libraries to environment so that Salome launches correctly -if (WIN32) - SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK ${KERNEL_ROOT_DIR}/${SALOME_INSTALL_LIBS}) - SALOME_ACCUMULATE_ENVIRONMENT(PATH NOCHECK ${GUI_ROOT_DIR}/${SALOME_INSTALL_LIBS}) -else() - SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${KERNEL_ROOT_DIR}/${SALOME_INSTALL_LIBS}) - SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${GUI_ROOT_DIR}/${SALOME_INSTALL_LIBS}) -endif() +SET(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/ConnectorAPI") + SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) diff --git a/src/ConnectorAPI/Test/TestExportSTL.py b/src/ConnectorAPI/Test/TestExportSTL.py new file mode 100644 index 000000000..edc7eaf01 --- /dev/null +++ b/src/ConnectorAPI/Test/TestExportSTL.py @@ -0,0 +1,159 @@ +# Copyright (C) 2014-2020 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 +# + +""" + TestExport.py + Unit test of ExchangePlugin_TestExport class +""" +#========================================================================= +# Initialization of the test +#========================================================================= + +import salome + +import os +import math +from tempfile import TemporaryDirectory + +import GEOM + +from ModelAPI import * + +from salome.shaper import model + +from salome.geom import geomBuilder + +from GeomAlgoAPI import * + +__updated__ = "2015-05-22" + +salome.salome_init(1) +geompy = geomBuilder.New() + +#========================================================================= +# Help functions +#========================================================================= +def removeFile(theFileName): + try: os.remove(theFileName) + except OSError: pass + assert not os.path.exists(theFileName), \ + "Can not remove file {0}".format(theFileName) + +#========================================================================= +# test Export STL +#========================================================================= +def testExportSTL(theFile, theDelta, theErrorExpected = False): + + 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, 20, 20, 20) + model.do() + + # First export to GEOM + model.exportToGEOM(Part_1_doc) + model.end() + + theSurface = 600 + + print("theFile=",theFile) + + # deflection relative 0.0001 et Ascii + model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID","Box_1_1"),0.0001, 0.5, True,False) + + #== assert os.path.exists(theFile) + + # Check results + test_stl_1 = geompy.ImportSTL(theFile) + Props = geompy.BasicProperties(test_stl_1) + print("\nBasic Properties:") + print(" Wires length: ", Props[0]) + print(" Surface area: ", Props[1]) + print(" Volume : ", Props[2]) + + aRefSurface = theSurface + aResSurface = Props[1] + assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) + + removeFile(theFile) + + theSurface = 600 + # deflection relative 0.0001 et binaire + model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, True,True) + + # Check results + test_stl_1 = geompy.ImportSTL(theFile) + Props = geompy.BasicProperties(test_stl_1) + print("\nBasic Properties:") + print(" Wires length: ", Props[0]) + print(" Surface area: ", Props[1]) + print(" Volume : ", Props[2]) + + aRefSurface = theSurface + aResSurface = Props[1] + assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) + + removeFile(theFile) + + theSurface = 600 + # deflection absolue et AScii + model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False, False) + + # Check results + test_stl_1 = geompy.ImportSTL(theFile) + Props = geompy.BasicProperties(test_stl_1) + print("\nBasic Properties:") + print(" Wires length: ", Props[0]) + print(" Surface area: ", Props[1]) + print(" Volume : ", Props[2]) + + aRefSurface = theSurface + aResSurface = Props[1] + assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) + + theSurface = 600 + # deflection absolue et binaire + model.exportToSTL(Part_1_doc, theFile, model.selection("SOLID", "Box_1_1" ),0.0001, 0.5, False,True) + + # Check results + test_stl_1 = geompy.ImportSTL(theFile) + Props = geompy.BasicProperties(test_stl_1) + print("\nBasic Properties:") + print(" Wires length: ", Props[0]) + print(" Surface area: ", Props[1]) + print(" Volume : ", Props[2]) + + aRefSurface = theSurface + aResSurface = Props[1] + assert (math.fabs(aResSurface - aRefSurface) < theDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) + + model.end() + +if __name__ == '__main__': + with TemporaryDirectory() as tmp_dir: + aRealSurface = 0.00192878 + #========================================================================= + # Export a shape into STL + #========================================================================= + testExportSTL(os.path.join(tmp_dir, "export.stl"), 10 ** -5, True) + #========================================================================= + # End of test + #========================================================================= diff --git a/src/ConnectorAPI/Test/TestImportSTEP.py b/src/ConnectorAPI/Test/TestImportSTEP.py new file mode 100644 index 000000000..c3a80f8a0 --- /dev/null +++ b/src/ConnectorAPI/Test/TestImportSTEP.py @@ -0,0 +1,113 @@ +# Copyright (C) 2014-2020 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 +# + +""" + TestImportStep.py + Unit test of ExchangePlugin_ImportFeature class for STEP +""" +#========================================================================= +# Initialization of the test +#========================================================================= + +import salome + +import os +import math +from tempfile import TemporaryDirectory + +from ModelAPI import * + +from salome.shaper import model + +from GeomAPI import GeomAPI_Shape + +from GeomAlgoAPI import * + +__updated__ = "2015-05-22" + +salome.salome_init(1) + +#========================================================================= +# Help functions +#========================================================================= +def removeFile(theFileName): + try: os.remove(theFileName) + except OSError: pass + assert not os.path.exists(theFileName), \ + "Can not remove file {0}".format(theFileName) + +#========================================================================= +# test Import STEP +#========================================================================= +def testImportSTEP(): + + model.begin() + partSet = model.moduleDocument() + Part_1 = model.addPart(partSet) + Part_1_doc = Part_1.document() + aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "black_and_white.step") + print("aShapePath=",aShapePath) + Import_1 = model.addImportSTEP(Part_1_doc,aShapePath, True, True, True) + + model.do() + + # Check results + Import_1_Feature = Import_1.feature() + assert Import_1_Feature.error() == '' + assert Import_1_Feature.name() == "black_and_white" + assert len(Import_1_Feature.results()) == 1 + model.testNbSubShapes(Import_1, GeomAPI_Shape.SOLID, [2]) + + aCompositeFeature = featureToCompositeFeature(Import_1_Feature) + assert aCompositeFeature.numberOfSubs(False) == 4 + + aFeature1 = aCompositeFeature.subFeature(0, False) + assert aFeature1.getKind() == "Group" + assert aFeature1.name() == "Color_1" + + aSelectionList = aFeature1.selectionList("group_list") + assert aSelectionList.size() == 1 + + aFeature1 = aCompositeFeature.subFeature(1, False) + assert aFeature1.getKind() == "Group" + assert aFeature1.name() == "Color_2" + + aSelectionList = aFeature1.selectionList("group_list") + assert aSelectionList.size() == 1 + + aFeature1 = aCompositeFeature.subFeature(2, False) + assert aFeature1.getKind() == "Group" + assert aFeature1.name() == "Material_black" + + aSelectionList = aFeature1.selectionList("group_list") + assert aSelectionList.size() == 1 + + + aFeature1 = aCompositeFeature.subFeature(3, False) + assert aFeature1.getKind() == "Group" + assert aFeature1.name() == "Material_white" + + aSelectionList = aFeature1.selectionList("group_list") + assert aSelectionList.size() == 1 + + model.end() + +if __name__ == '__main__': + with TemporaryDirectory() as tmp_dir: + testImportSTEP() diff --git a/src/ConnectorAPI/Test/tests.set b/src/ConnectorAPI/Test/tests.set index 60e932add..3f4eb7ec2 100644 --- a/src/ConnectorAPI/Test/tests.set +++ b/src/ConnectorAPI/Test/tests.set @@ -27,4 +27,6 @@ SET(TEST_NAMES Test17917 Test18887 Test3195 + TestExportSTL + TestImportSTEP ) diff --git a/src/ExchangeAPI/CMakeLists.txt b/src/ExchangeAPI/CMakeLists.txt index bdf5bcb34..b61f22ce9 100644 --- a/src/ExchangeAPI/CMakeLists.txt +++ b/src/ExchangeAPI/CMakeLists.txt @@ -33,12 +33,14 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES ModelAPI ModelHighAPI + GeomAlgoAPI ) INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/ModelAPI ${PROJECT_SOURCE_DIR}/src/ModelHighAPI + ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ) # Plugin headers dependency diff --git a/src/ExchangeAPI/ExchangeAPI_Export.cpp b/src/ExchangeAPI/ExchangeAPI_Export.cpp index 000e178ab..b0d9e094c 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Export.cpp @@ -53,6 +53,52 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& apply(); // finish operation to make sure the export is done on the current state of the history } +// Constructor with values for STL of selected result export. +ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, + const std::string & theFilePath, + const ModelHighAPI_Selection& theSelectedShape, + const ModelHighAPI_Double& theDeflectionRelative, + const ModelHighAPI_Double& theDeflectionAbsolute, + const bool theIsRelative, + const bool theIsASCII) + : ModelHighAPI_Interface(theFeature) +{ + initialize(); + fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID())); + fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())); + + if (theIsRelative) { + fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), + theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) ); + fillAttribute(theDeflectionRelative, + theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) ); + } + else { + fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), + theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) ); + fillAttribute(theDeflectionAbsolute, + theFeature->real(ExchangePlugin_ExportFeature::STL_ABSOLUTE()) ); + } + + if(theIsASCII){ + fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(), + theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE())); + } + else + { + fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY(), + theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE())); + } + + fillAttribute(theSelectedShape, + theFeature->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED())); + fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID())); + execute(); + apply(); // finish operation to make sure the export is done on the current state of the history +} + + + ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, const std::string & theFilePath, const ModelHighAPI_Selection& theResult, const std::string & theAuthor, const std::string & theGeometryName) @@ -74,6 +120,7 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& } + /// Constructor with values for export in other formats than XAO. ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr& theFeature, const std::string & theFilePath, @@ -144,6 +191,34 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", '" << theGeometryName << "'"; theDumper << ")" << std::endl; } + else if (exportType == "STL") { + std::string aTmpSTLFile = + aBase->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value(); + correctSeparators(aTmpSTLFile); + theDumper << "exportToSTL(" << aDocName << ", '" << aTmpSTLFile << "'" ; + AttributeSelectionPtr aShapeSelected = + aBase->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED()); + + theDumper<<","<< aShapeSelected; + + theDumper <<","<< stlabsolute() <<","<< stlrelative(); + + if (stldeflectionType()->value() + == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()){ + theDumper <<","<< "True"; + } + else { + theDumper <<","<< "False"; + } + + if (stlfileType()->value() == ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY()) { + theDumper << "False"; + } + else { + theDumper << "True"; + } + theDumper << ")" << std::endl; + } else { std::string aFilePath = aBase->string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->value(); correctSeparators(aFilePath); @@ -179,6 +254,27 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, return ExportPtr(new ExchangeAPI_Export(aFeature, theFilePath, theAuthor, theGeometryName)); } +ExportPtr exportToSTL(const std::shared_ptr & thePart, + const std::string & theFilePath, + const ModelHighAPI_Selection& theSelectedShape, + const ModelHighAPI_Double& theDeflectionRelative, + const ModelHighAPI_Double& theDeflectionAbsolute, + const bool theIsRelative, + const bool theIsASCII) +{ + apply(); // finish previous operation to make sure all previous operations are done + std::shared_ptr aFeature = + thePart->addFeature(ExchangePlugin_ExportFeature::ID()); + + return ExportPtr(new ExchangeAPI_Export(aFeature, + theFilePath, + theSelectedShape, + theDeflectionRelative, + theDeflectionAbsolute, + theIsRelative, + theIsASCII)); +} + ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & theFilePath, const ModelHighAPI_Selection& theSelectedShape, const std::string & /*theAuthor*/, const std::string & /*theGeometryName*/) diff --git a/src/ExchangeAPI/ExchangeAPI_Export.h b/src/ExchangeAPI/ExchangeAPI_Export.h index 24211c9fa..0d5caa212 100644 --- a/src/ExchangeAPI/ExchangeAPI_Export.h +++ b/src/ExchangeAPI/ExchangeAPI_Export.h @@ -32,6 +32,7 @@ #include //-------------------------------------------------------------------------------------- class ModelHighAPI_Selection; +class ModelHighAPI_Double; //-------------------------------------------------------------------------------------- @@ -52,6 +53,16 @@ public: const std::string & theAuthor = std::string(), const std::string & theGeometryName = std::string()); + /// Constructor with values for STL of selected result export. + EXCHANGEAPI_EXPORT + explicit ExchangeAPI_Export(const std::shared_ptr& theFeature, + const std::string & theFilePath, + const ModelHighAPI_Selection& theSelectedShape, + const ModelHighAPI_Double& theDeflectionRelative , + const ModelHighAPI_Double& theDeflectionAbsolute, + const bool theIsRelative, + const bool theIsASCII); + /// Constructor with values for XAO of selected result export. EXCHANGEAPI_EXPORT explicit ExchangeAPI_Export(const std::shared_ptr& theFeature, @@ -71,7 +82,7 @@ public: EXCHANGEAPI_EXPORT virtual ~ExchangeAPI_Export(); - INTERFACE_7(ExchangePlugin_ExportFeature::ID(), + INTERFACE_15(ExchangePlugin_ExportFeature::ID(), exportType, ExchangePlugin_ExportFeature::EXPORT_TYPE_ID(), ModelAPI_AttributeString, /** ExportType */, filePath, ExchangePlugin_ExportFeature::FILE_PATH_ID(), @@ -85,7 +96,25 @@ public: xaoAuthor, ExchangePlugin_ExportFeature::XAO_AUTHOR_ID(), ModelAPI_AttributeString, /** xao author */, xaoGeometryName, ExchangePlugin_ExportFeature::XAO_GEOMETRY_NAME_ID(), - ModelAPI_AttributeString, /** xao geometry name */) + ModelAPI_AttributeString, /** xao geometry name */, + stlFilePath, ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(), + ModelAPI_AttributeString, /** stl_file_path */, + stlobjectselected, ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), + ModelAPI_AttributeSelection, /** Object selected to export in stl file*/, + stldeflectionType, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(), + ModelAPI_AttributeString, /** Type of the defelection */, + stlrelative, ExchangePlugin_ExportFeature::STL_RELATIVE(), + ModelAPI_AttributeDouble, /** Relative*/, + stlabsolute, ExchangePlugin_ExportFeature::STL_ABSOLUTE(), + ModelAPI_AttributeDouble, /** Absolute */, + stlfileType, ExchangePlugin_ExportFeature::STL_FILE_TYPE(), + ModelAPI_AttributeString, /** Type of the stl file*/, + stldeflectionTypeabsolute, + ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), + ModelAPI_AttributeString, /** Type of the defelection */, + stldeflectionTyperelative, + ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), + ModelAPI_AttributeString, /** Type of the defelection */) /// Dump wrapped feature EXCHANGEAPI_EXPORT @@ -113,6 +142,18 @@ ExportPtr exportToXAO(const std::shared_ptr & thePart, const std::string & theAuthor = std::string(), const std::string & theGeometryName = std::string()); +/**\ingroup CPPHighAPI + * \brief Exports to STL file the result of the current document + */ +EXCHANGEAPI_EXPORT +ExportPtr exportToSTL(const std::shared_ptr & thePart, + const std::string & theFilePath, + const ModelHighAPI_Selection& theSelectedShape, + const ModelHighAPI_Double& theDeflectionRelative, + const ModelHighAPI_Double& theDeflectionAbsolute, + const bool theIsRelative, + const bool theIsASCII); + /**\ingroup CPPHighAPI * \brief Exports to XAO file the selected result with groups parts related to it only. */ diff --git a/src/ExchangeAPI/ExchangeAPI_Import.cpp b/src/ExchangeAPI/ExchangeAPI_Import.cpp index b1a6c832d..f12ea5dc6 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.cpp +++ b/src/ExchangeAPI/ExchangeAPI_Import.cpp @@ -28,6 +28,7 @@ #include #include #include +#include //-------------------------------------------------------------------------------------- #include @@ -47,17 +48,49 @@ ExchangeAPI_Import::ExchangeAPI_Import( setFilePath(theFilePath); } +ExchangeAPI_Import::ExchangeAPI_Import( + const std::shared_ptr & theFeature, + const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + setParameters(theFilePath, theScalInterUnits, theMaterials, theColor); +} + ExchangeAPI_Import::~ExchangeAPI_Import() { } +//-------------------------------------------------------------------------------------- +void ExchangeAPI_Import::setParameters(const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor) +{ + fillAttribute(theFilePath, mystepFilePath); + fillAttribute("STEP", myimportType); + fillAttribute(theScalInterUnits, myscalInterUnits); + fillAttribute(theMaterials,mymaterials); + fillAttribute(theColor,mycolors); + execute(); +} + //-------------------------------------------------------------------------------------- void ExchangeAPI_Import::setFilePath(const std::string & theFilePath) { - fillAttribute(theFilePath, myfilePath); - execute(); + std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(theFilePath); + if (anExtension == "STEP" || anExtension == "STP") { + setParameters(theFilePath,true,false,false); + } else { + fillAttribute(theFilePath, myfilePath); + fillAttribute(anExtension, myimportType); + execute(); + } } //-------------------------------------------------------------------------------------- @@ -66,7 +99,17 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); std::string aPartName = theDumper.name(aBase->document()); - std::string aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value(); + AttributeStringPtr aImportTypeAttr = + aBase->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); + std::string aFormat = aImportTypeAttr->value(); + std::string aFilePath; + if (aFormat == "STEP" || aFormat == "STP") + { + aFilePath = aBase->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID())->value(); + } else { + aFilePath = aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID())->value(); + } + std::string aFrom = "\\"; std::string aTo = "\\\\"; for(std::size_t aPos = aFilePath.find(aFrom); @@ -75,15 +118,25 @@ void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const aFilePath.replace(aPos, aFrom.size(), aTo); aPos += aTo.size(); } - - theDumper << aBase << " = model.addImport(" << aPartName << ", \"" + std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath); + if (anExtension == "STP" || anExtension == "STEP"){ + theDumper << aBase << " = model.addImportSTEP(" << aPartName << ", \"" + << aFilePath << "\"" ; + + theDumper << ", " << scalInterUnits()->value() + << ", " << materials()->value() + << ", " << colors()->value() << ")"<< std::endl; + } else { + theDumper << aBase << " = model.addImport(" << aPartName << ", \"" << aFilePath << "\")" << std::endl; + } + // to make import have results theDumper << "model.do()" << std::endl; CompositeFeaturePtr aCompositeFeature = std::dynamic_pointer_cast(aBase); - if(aCompositeFeature.get()) { + if (aCompositeFeature.get()) { int aNbOfSubs = aCompositeFeature->numberOfSubs(); for(int anIndex = 0; anIndex < aNbOfSubs; ++anIndex) { std::string aSubFeatureGet = @@ -102,6 +155,18 @@ ImportPtr addImport( return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath)); } +ImportPtr addImportSTEP( + const std::shared_ptr & thePart, + const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor ) +{ + std::shared_ptr aFeature = thePart->addFeature(ExchangeAPI_Import::ID()); + return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath, + theScalInterUnits, theMaterials, theColor)); +} + void importPart(const std::shared_ptr & thePart, const std::string & theFilePath, const ModelHighAPI_Reference & theAfterThis) diff --git a/src/ExchangeAPI/ExchangeAPI_Import.h b/src/ExchangeAPI/ExchangeAPI_Import.h index f38db9bbb..d3403e544 100644 --- a/src/ExchangeAPI/ExchangeAPI_Import.h +++ b/src/ExchangeAPI/ExchangeAPI_Import.h @@ -46,19 +46,43 @@ public: EXCHANGEAPI_EXPORT ExchangeAPI_Import(const std::shared_ptr & theFeature, const std::string & theFilePath); + + /// Constructor with values for Step file + EXCHANGEAPI_EXPORT + ExchangeAPI_Import(const std::shared_ptr & theFeature, + const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor); /// Destructor EXCHANGEAPI_EXPORT virtual ~ExchangeAPI_Import(); - INTERFACE_1(ExchangePlugin_ImportFeature::ID(), + INTERFACE_6(ExchangePlugin_ImportFeature::ID(), filePath, ExchangePlugin_ImportFeature::FILE_PATH_ID(), - ModelAPI_AttributeString, /** File path */ + ModelAPI_AttributeString, /** File path */, + importType, ExchangePlugin_ImportFeature::IMPORT_TYPE_ID(), + ModelAPI_AttributeString, /**import type */, + stepFilePath, ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID(), + ModelAPI_AttributeString, /**step File path */, + scalInterUnits, ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID(), + ModelAPI_AttributeBoolean, /** Scale internationals units */, + materials, ExchangePlugin_ImportFeature::STEP_MATERIALS_ID(), + ModelAPI_AttributeBoolean, /** Materials */, + colors, ExchangePlugin_ImportFeature::STEP_COLORS_ID(), + ModelAPI_AttributeBoolean, /** Colors */ ) /// Set point values EXCHANGEAPI_EXPORT void setFilePath(const std::string & theFilePath); + EXCHANGEAPI_EXPORT + void setParameters(const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor); + /// Dump wrapped feature EXCHANGEAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -74,6 +98,17 @@ EXCHANGEAPI_EXPORT ImportPtr addImport(const std::shared_ptr & thePart, const std::string & theFilePath); +/**\ingroup CPPHighAPI + * \brief Create Import Step feature + */ +EXCHANGEAPI_EXPORT +ImportPtr addImportSTEP(const std::shared_ptr & thePart, + const std::string & theFilePath, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor); + + /** \ingroup CPPHighAPI * \brief Import features from the file to the document after the current feature (or to the end). */ diff --git a/src/ExchangePlugin/CMakeLists.txt b/src/ExchangePlugin/CMakeLists.txt index 67880c8e6..3df98bece 100644 --- a/src/ExchangePlugin/CMakeLists.txt +++ b/src/ExchangePlugin/CMakeLists.txt @@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events ${PROJECT_SOURCE_DIR}/src/XAO ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin ${PROJECT_SOURCE_DIR}/src/PartSetPlugin + ${OpenCASCADE_INCLUDE_DIR} ) SET(PROJECT_HEADERS diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index d898a08e5..e81ae860d 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -27,6 +27,7 @@ #include #endif + #include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include @@ -48,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -98,9 +101,27 @@ void ExchangePlugin_ExportFeature::initAttributes() ModelAPI_AttributeString::typeId()); data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), + ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(), + ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(), + ModelAPI_AttributeDouble::typeId()); + + double defelection = Config_PropManager::real("Visualization", "body_deflection"); + real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection); + + data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(), + ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(), + ModelAPI_AttributeString::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), + ExchangePlugin_ExportFeature::STL_FILE_PATH_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ExchangePlugin_ExportFeature::XAO_AUTHOR_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), @@ -128,6 +149,11 @@ void ExchangePlugin_ExportFeature::attributeChanged(const std::string& theID) string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value()); } + else if (theID == STL_FILE_PATH_ID()) { + string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue( + string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value()); + } + } /* @@ -170,6 +196,9 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, if (aFormatName == "XAO") { exportXAO(theFileName); return; + }else if (aFormatName == "STL") { + exportSTL(theFileName); + return; } // make shape for export from selected shapes @@ -316,6 +345,48 @@ static bool isInResults(AttributeSelectionListPtr theSelection, return false; } +void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName) +{ + // Get shape. + AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED()); + GeomShapePtr aShape = aSelection->value(); + if (!aShape.get()) { + aShape = aSelection->context()->shape(); + } + + // Get relative value and percent flag. + double aValue; + bool anIsRelative = false; + bool anIsASCII = false; + + if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) { + aValue = real(STL_RELATIVE())->value(); + anIsRelative = true; + } else { + aValue = real(STL_ABSOLUTE())->value(); + } + + if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) { + anIsASCII = true; + } + // Perform the export + std::string anError; + bool aResult = false; + + aResult = STLExport(theFileName, + aShape, + aValue, + anIsRelative, + anIsASCII, + anError); + + if (!aResult || !anError.empty()) { + setError("An error occurred while exporting " + theFileName + ": " + anError); + return; + } +} + + void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName) { try { diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h index 1067d99af..bc975ea5b 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.h @@ -60,6 +60,66 @@ public: static const std::string MY_XAO_FILE_PATH_ID("xao_file_path"); return MY_XAO_FILE_PATH_ID; } + /// attribute name of stl file path + inline static const std::string& STL_FILE_PATH_ID() + { + static const std::string MY_STL_FILE_PATH_ID("stl_file_path"); + return MY_STL_FILE_PATH_ID; + } + /// Attribute name for selected object to export in stl file path. + inline static const std::string& STL_OBJECT_SELECTED() + { + static const std::string ATTR_ID("stl_object_selected"); + return ATTR_ID; + } + /// Attribute name for deflection type. + inline static const std::string& STL_DEFLECTION_TYPE() + { + static const std::string ATTR_ID("stl_deflection_type"); + return ATTR_ID; + } + /// Attribute name for deflection type relative. + inline static const std::string& STL_DEFLECTION_TYPE_RELATIVE() + { + static const std::string ATTR_ID("stl_deflection_type_relative"); + return ATTR_ID; + } + /// Attribute name for deflection type absolute. + inline static const std::string& STL_DEFLECTION_TYPE_ABSOLUTE() + { + static const std::string ATTR_ID("stl_deflection_type_absolute"); + return ATTR_ID; + } + /// Attribute name for relative. + inline static const std::string& STL_RELATIVE() + { + static const std::string ATTR_ID("stl_relative"); + return ATTR_ID; + } + /// Attribute name for absolute. + inline static const std::string& STL_ABSOLUTE() + { + static const std::string ATTR_ID("stl_absolute"); + return ATTR_ID; + } + /// Attribute name for stl file type. + inline static const std::string& STL_FILE_TYPE() + { + static const std::string ATTR_ID("stl_file_type"); + return ATTR_ID; + } + /// Attribute name for stl file type ascii. + inline static const std::string& STL_FILE_TYPE_ASCII() + { + static const std::string ATTR_ID("stl_file_type_acii"); + return ATTR_ID; + } + /// Attribute name for stl file type binary. + inline static const std::string& STL_FILE_TYPE_BINARY() + { + static const std::string ATTR_ID("stl_file_type_binary"); + return ATTR_ID; + } /// attribute name of file format inline static const std::string& FILE_FORMAT_ID() { @@ -129,6 +189,9 @@ protected: /// Performs export to XAO file EXCHANGEPLUGIN_EXPORT void exportXAO(const std::string& theFileName); + + /// Performs export to STL file + EXCHANGEPLUGIN_EXPORT void exportSTL(const std::string& theFileName); }; #endif /* EXPORT_EXPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_Import.cpp b/src/ExchangePlugin/ExchangePlugin_Import.cpp index b5a51ff08..e9b041582 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Import.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -81,8 +82,15 @@ ExchangePlugin_Import::~ExchangePlugin_Import() void ExchangePlugin_Import::initAttributes() { data()->addAttribute(FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); + data()->addAttribute(STEP_TARGET_PART_ID(), ModelAPI_AttributeInteger::typeId()); + data()->addAttribute(STEP_TARGET_PARTS_LIST_ID(), ModelAPI_AttributeStringArray::typeId()); + data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId()); } /* @@ -90,26 +98,62 @@ void ExchangePlugin_Import::initAttributes() */ void ExchangePlugin_Import::execute() { - AttributeStringPtr aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID()); - std::string aFilePath = aFilePathAttr->value(); - if (aFilePath.empty()) { - setError("File path is empty."); - return; + AttributeStringPtr aFormatAttr = + this->string(ExchangePlugin_Import::IMPORT_TYPE_ID()); + std::string aFormat = aFormatAttr->value(); + + AttributeStringPtr aFilePathAttr; + std::string aFilePath; + AttributeStringArrayPtr aPartsAttr; + AttributeIntegerPtr aTargetAttr; + if (aFormat == "STEP" || aFormat == "STP") + { + aFilePathAttr = string(ExchangePlugin_Import::STEP_FILE_PATH_ID()); + aFilePath = aFilePathAttr->value(); + // get the document where to import + aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID()); + aTargetAttr = integer(STEP_TARGET_PART_ID()); + }else{ + aFilePathAttr = string(ExchangePlugin_Import::FILE_PATH_ID()); + aFilePath = aFilePathAttr->value(); + // get the document where to import + aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); + aTargetAttr = integer(TARGET_PART_ID()); } - // get the document where to import - AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); - AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID()); + if (aFilePath.empty()) { + setError("File path is empty."); + return; + } SessionPtr aSession = ModelAPI_Session::get(); - DocumentPtr aDoc = - findDocument(aSession->moduleDocument(), + DocumentPtr aDoc = findDocument(aSession->moduleDocument(), Locale::Convert::toWString(aPartsAttr->value(aTargetAttr->value()))); if (aDoc.get()) { FeaturePtr aImportFeature = aDoc->addFeature(ExchangePlugin_ImportFeature::ID()); DataPtr aData = aImportFeature->data(); - AttributeStringPtr aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); + AttributeStringPtr aPathAttr; + if (aFormat == "STEP" || aFormat == "STP") + { + aPathAttr = aData->string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID()); + }else + { + aPathAttr = aData->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); + } + + AttributeStringPtr aImportTypeAttr = + aData->string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); + + aData->boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()) + ->setValue(boolean(ExchangePlugin_Import::STEP_MATERIALS_ID())->value()); + aData->boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID()) + ->setValue(boolean(ExchangePlugin_Import::STEP_COLORS_ID())->value()); + aData->boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()) + ->setValue(boolean(ExchangePlugin_Import::STEP_SCALE_INTER_UNITS_ID())->value()); + aPathAttr->setValue(aFilePathAttr->value()); + aImportTypeAttr->setValue(aFormat); + aImportFeature->execute(); } } @@ -117,14 +161,32 @@ void ExchangePlugin_Import::execute() void ExchangePlugin_Import::attributeChanged(const std::string& theID) { - if (theID == FILE_PATH_ID()) { - AttributeStringPtr aFilePathAttr = string(FILE_PATH_ID()); - if (aFilePathAttr->value().empty()) + AttributeStringPtr aFilePathAttr; + AttributeStringArrayPtr aPartsAttr; + AttributeIntegerPtr aTargetAttr; + + if (theID == FILE_PATH_ID() ||theID == STEP_FILE_PATH_ID() ) { + aFilePathAttr = string(FILE_PATH_ID()); + if (theID == FILE_PATH_ID() && aFilePathAttr->value().empty()) + return; + aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); + aTargetAttr = integer(TARGET_PART_ID()); + + updatePart(aPartsAttr, aTargetAttr); + + aFilePathAttr = string(STEP_FILE_PATH_ID()); + if (theID == STEP_FILE_PATH_ID() && aFilePathAttr->value().empty()) return; - AttributeStringArrayPtr aPartsAttr = stringArray(TARGET_PARTS_LIST_ID()); - AttributeIntegerPtr aTargetAttr = integer(TARGET_PART_ID()); + aPartsAttr = stringArray(STEP_TARGET_PARTS_LIST_ID()); + aTargetAttr = integer(STEP_TARGET_PART_ID()); + updatePart(aPartsAttr, aTargetAttr); + } +} +void ExchangePlugin_Import::updatePart(AttributeStringArrayPtr& thePartsAttr, + AttributeIntegerPtr& theTargetAttr) +{ // update the list of target parts SessionPtr aSession = ModelAPI_Session::get(); DocumentPtr aDoc = document(); @@ -141,23 +203,22 @@ void ExchangePlugin_Import::attributeChanged(const std::string& theID) anAcceptedValues.push_back((*aFIt)->name()); } - if ((size_t)aPartsAttr->size() != anAcceptedValues.size()) - aTargetAttr->setValue(0); + if ((size_t)thePartsAttr->size() != anAcceptedValues.size()) + theTargetAttr->setValue(0); - aPartsAttr->setSize((int)anAcceptedValues.size()); + thePartsAttr->setSize((int)anAcceptedValues.size()); std::list::iterator anIt = anAcceptedValues.begin(); for (int anInd = 0; anIt != anAcceptedValues.end(); ++anIt, ++anInd) - aPartsAttr->setValue(anInd, Locale::Convert::toString(*anIt)); + thePartsAttr->setValue(anInd, Locale::Convert::toString(*anIt)); } else { // keep only the name of the current part - if (aPartsAttr->size() == 0) { + if (thePartsAttr->size() == 0) { FeaturePtr aPartFeature = ModelAPI_Tools::findPartFeature(aSession->moduleDocument(), aDoc); - aPartsAttr->setSize(1); - aPartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name())); - aTargetAttr->setValue(0); + thePartsAttr->setSize(1); + thePartsAttr->setValue(0, Locale::Convert::toString(aPartFeature->name())); + theTargetAttr->setValue(0); } } - } } diff --git a/src/ExchangePlugin/ExchangePlugin_Import.h b/src/ExchangePlugin/ExchangePlugin_Import.h index c09b3ebab..eeac51794 100644 --- a/src/ExchangePlugin/ExchangePlugin_Import.h +++ b/src/ExchangePlugin/ExchangePlugin_Import.h @@ -24,6 +24,8 @@ #include #include +#include +#include #include @@ -43,6 +45,12 @@ class ExchangePlugin_Import : public ModelAPI_Feature static const std::string MY_IMPORT_ID("ImportMacro"); return MY_IMPORT_ID; } + /// Feature kind + inline static const std::string& IMPORT_TYPE_ID() + { + static const std::string MY_IMPORT_TYPE_ID("ImportType"); + return MY_IMPORT_TYPE_ID; + } /// attribute name of file path inline static const std::string& FILE_PATH_ID() { @@ -61,6 +69,42 @@ class ExchangePlugin_Import : public ModelAPI_Feature static const std::string MY_TARGET_PARTS_LIST_ID("target_parts_list"); return MY_TARGET_PARTS_LIST_ID; } + /// attribute name of step file path + inline static const std::string& STEP_FILE_PATH_ID() + { + static const std::string MY_STEP_FILE_PATH_ID("step_file_path"); + return MY_STEP_FILE_PATH_ID; + } + /// attribute name of step target part + inline static const std::string& STEP_TARGET_PART_ID() + { + static const std::string MY_STEP_TARGET_PART_ID("step_target_part"); + return MY_STEP_TARGET_PART_ID; + } + /// attribute name of list ofstep target parts + inline static const std::string& STEP_TARGET_PARTS_LIST_ID() + { + static const std::string MY_STEP_TARGET_PARTS_LIST_ID("step_target_parts_list"); + return MY_STEP_TARGET_PARTS_LIST_ID; + } + /// attribute name of step Scale to International System Units + inline static const std::string& STEP_SCALE_INTER_UNITS_ID() + { + static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units"); + return MY_STEP_SCALE_INTER_UNITS_ID; + } + /// attribute name of step materiels + inline static const std::string& STEP_MATERIALS_ID() + { + static const std::string MY_STEP_MATERIALS_ID("step_materials"); + return MY_STEP_MATERIALS_ID; + } + /// attribute name of step colors + inline static const std::string& STEP_COLORS_ID() + { + static const std::string MY_STEP_COLORS_ID("step_colors"); + return MY_STEP_COLORS_ID; + } /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_Import(); /// Default destructor @@ -87,6 +131,11 @@ class ExchangePlugin_Import : public ModelAPI_Feature /// Reimplemented from ModelAPI_Feature::isPreviewNeeded(). Returns false. EXCHANGEPLUGIN_EXPORT virtual bool isPreviewNeeded() const { return false; } + + private: + /// Called to update part + EXCHANGEPLUGIN_EXPORT + void updatePart(AttributeStringArrayPtr& thePartsAttr, AttributeIntegerPtr& theTargetAttr); }; #endif /* IMPORT_IMPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index ade0a3115..24c821f1c 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -42,6 +43,8 @@ #include #include #include +#include +#include #include #include #include @@ -60,6 +63,8 @@ #include + + ExchangePlugin_ImportFeature::ExchangePlugin_ImportFeature() { } @@ -77,12 +82,28 @@ void ExchangePlugin_ImportFeature::initAttributes() data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); AttributePtr aFeaturesAttribute = - data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(), + data()->addAttribute(ExchangePlugin_ImportFeature::FEATURES_ID(), ModelAPI_AttributeRefList::typeId()); + data()->addAttribute(STEP_FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(IMPORT_TYPE_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(STEP_MATERIALS_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(STEP_COLORS_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(STEP_SCALE_INTER_UNITS_ID(), ModelAPI_AttributeBoolean::typeId()); + aFeaturesAttribute->setIsArgument(false); ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), ExchangePlugin_ImportFeature::FEATURES_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), ExchangePlugin_ImportFeature::STEP_COLORS_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), ExchangePlugin_ImportFeature::STEP_MATERIALS_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory( + getKind(), ExchangePlugin_ImportFeature::FILE_PATH_ID()); } /* @@ -90,7 +111,15 @@ void ExchangePlugin_ImportFeature::initAttributes() */ void ExchangePlugin_ImportFeature::execute() { - AttributeStringPtr aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); + AttributeStringPtr aImportTypeAttr = string(ExchangePlugin_ImportFeature::IMPORT_TYPE_ID()); + std::string aFormat = aImportTypeAttr->value(); + AttributeStringPtr aFilePathAttr; + if (aFormat == "STEP" || aFormat == "STP") + { + aFilePathAttr = string(ExchangePlugin_ImportFeature::STEP_FILE_PATH_ID()); + } else { + aFilePathAttr = string(ExchangePlugin_ImportFeature::FILE_PATH_ID()); + } std::string aFilePath = aFilePathAttr->value(); if (aFilePath.empty()) { setError("File path is empty."); @@ -101,11 +130,11 @@ void ExchangePlugin_ImportFeature::execute() } std::shared_ptr ExchangePlugin_ImportFeature::createResultBody( - std::shared_ptr aGeomShape) + std::shared_ptr theGeomShape) { std::shared_ptr aResultBody = document()->createBody(data()); //LoadNamingDS of the imported shape - loadNamingDS(aGeomShape, aResultBody); + loadNamingDS(theGeomShape, aResultBody); return aResultBody; } @@ -122,10 +151,40 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) // Perform the import std::string anError; std::shared_ptr aGeomShape; + + std::map> theMaterialShape; + + std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); + data()->setName(Locale::Convert::toWString(anObjectName)); + + ResultBodyPtr aResult = document()->createBody(data()); + + bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())->value(); + bool anMaterialsGroupSelected = + boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value(); + if (anExtension == "BREP" || anExtension == "BRP") { aGeomShape = BREPImport(theFileName, anExtension, anError); } else if (anExtension == "STEP" || anExtension == "STP") { - aGeomShape = STEPImport(theFileName, anExtension, anError); + bool anScalInterUnits = + boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value(); + + // Process groups/fields + std::shared_ptr aRefListOfGroups = + std::dynamic_pointer_cast(data()->attribute(FEATURES_ID())); + + // Remove previous groups/fields stored in RefList + std::list anGroupList = aRefListOfGroups->list(); + std::list::iterator anGroupIt = anGroupList.begin(); + for (; anGroupIt != anGroupList.end(); ++anGroupIt) { + std::shared_ptr aFeature = ModelAPI_Feature::feature(*anGroupIt); + if (aFeature) + document()->removeFeature(aFeature); + } + + aGeomShape = STEPImportAttributs(theFileName, aResult, anScalInterUnits, + anMaterialsGroupSelected, anColorGroupSelected, + theMaterialShape, anError); } else if (anExtension == "IGES" || anExtension == "IGS") { aGeomShape = IGESImport(theFileName, anExtension, anError); } else { @@ -139,10 +198,140 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) } // Pass the results into the model - std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName); - data()->setName(Locale::Convert::toWString(anObjectName)); - setResult(createResultBody(aGeomShape)); + loadNamingDS(aGeomShape, aResult); + + // create color group + if (anColorGroupSelected) + { + setColorGroups(aResult); + } + + // create Materiel group + if (anMaterialsGroupSelected){ + setMaterielGroup(aResult,theMaterialShape); + } + + setResult(aResult); + aResult->clearShapeNameAndColor(); + +} + +void ExchangePlugin_ImportFeature::setColorGroups( + std::shared_ptr theResultBody) +{ + std::vector aColor; + int anIndice = 1; + std::list> aColorsRead; + + ModelAPI_Tools::getColor(theResultBody, aColor); + if (!aColor.empty() ){ + std::wstringstream aColorName; + aColorName < allRes; + ModelAPI_Tools::allSubs(theResultBody, allRes); + for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) { + ModelAPI_Tools::getColor(*aRes, aColor); + if (!aColor.empty() ){ + auto it = std::find(aColorsRead.begin(), aColorsRead.end(), aColor); + if ( it == aColorsRead.end() ){ + std::wstringstream aColorName; + aColorName< theResultBody, + std::vector &theColor, + const std::wstring& theName ) +{ + std::vector aColor; + std::shared_ptr aGroupFeature = addFeature("Group"); + + // group name + aGroupFeature->data()->setName(theName); + + // fill selection + AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); + + ModelAPI_Tools::getColor(theResultBody, aColor); + if (!aColor.empty()){ + if (aColor == theColor) { + GeomShapePtr aShape = theResultBody->shape(); + aSelectionList->setSelectionType(aShape->shapeTypeStr()); + aSelectionList->append(theResultBody,aShape); + } + } + // add element with the same color + std::list allRes; + ModelAPI_Tools::allSubs(theResultBody, allRes); + for(std::list::iterator aRes = allRes.begin(); + aRes != allRes.end(); ++aRes) { + ModelAPI_Tools::getColor(*aRes, aColor); + GeomShapePtr aShape = (*aRes)->shape(); + + if (!aColor.empty()){ + if (aRes->get() && aColor == theColor) { + aSelectionList->setSelectionType(aShape->shapeTypeStr()); + aSelectionList->append(theResultBody,aShape); + } + } + } + + // Create the group in the document to be able to set its color + ResultPtr aGroup = document()->createGroup(aGroupFeature->data()); + aGroupFeature->setResult(aGroup); + + ModelAPI_Tools::setColor(aGroupFeature->lastResult(),theColor); + + if (aSelectionList->size() == 0) { + document()->removeFeature(aGroupFeature); + } +} + +void ExchangePlugin_ImportFeature::setMaterielGroup( + std::shared_ptr theResultBody, + std::map< std::wstring,std::list>& theMaterialShape) +{ + std::map< std::wstring, std::list>::iterator anIt; + for (anIt = theMaterialShape.begin(); anIt != theMaterialShape.end(); ++anIt) { + + std::shared_ptr aGroupFeature = addFeature("Group"); + // group name + aGroupFeature->data()->setName((*anIt).first); + + // fill selection + AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list"); + + std::list allRes; + ModelAPI_Tools::allSubs(theResultBody, allRes); + for (std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) { + + GeomShapePtr aShape = (*aRes)->shape(); + for (std::list::iterator aResMat = anIt->second.begin(); + aResMat != anIt->second.end(); ++aResMat) { + if (aRes->get() && ((*aRes)->data()->name() == (*aResMat))) + { + aSelectionList->append(theResultBody,aShape); + aSelectionList->setSelectionType(aShape->shapeTypeStr()); + break; + } + } + } + if (aSelectionList->size() == 0){ + document()->removeFeature(aGroupFeature); + } + } } void ExchangePlugin_ImportFeature::importXAO(const std::string& theFileName) @@ -415,7 +604,6 @@ void ExchangePlugin_ImportFeature::loadNamingDS( { //load result theResultBody->store(theGeomShape); - std::string aNameMS = "Shape"; theResultBody->loadFirstLevel(theGeomShape, aNameMS); } diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h index c087af2ab..3c34eced6 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h @@ -24,6 +24,7 @@ #include #include +#include #include @@ -43,18 +44,48 @@ class ExchangePlugin_ImportFeature : public ModelAPI_CompositeFeature static const std::string MY_IMPORT_ID("Import"); return MY_IMPORT_ID; } + /// Feature kind + inline static const std::string& IMPORT_TYPE_ID() + { + static const std::string MY_IMPORT_TYPE_ID("ImportType"); + return MY_IMPORT_TYPE_ID; + } /// attribute name of file path inline static const std::string& FILE_PATH_ID() { static const std::string MY_FILE_PATH_ID("file_path"); return MY_FILE_PATH_ID; } + /// attribute name of file path + inline static const std::string& STEP_FILE_PATH_ID() + { + static const std::string MY_STEP_FILE_PATH_ID("step_file_path"); + return MY_STEP_FILE_PATH_ID; + } /// All features (list of references) inline static const std::string& FEATURES_ID() { static const std::string MY_FEATURES_ID("Features"); return MY_FEATURES_ID; } + /// attribute name of step Scale to International System Units + inline static const std::string& STEP_SCALE_INTER_UNITS_ID() + { + static const std::string MY_STEP_SCALE_INTER_UNITS_ID("step_scale_inter_units"); + return MY_STEP_SCALE_INTER_UNITS_ID; + } + /// attribute name of step materiels + inline static const std::string& STEP_MATERIALS_ID() + { + static const std::string MY_STEP_MATERIALS_ID("step_materials"); + return MY_STEP_MATERIALS_ID; + } + /// attribute name of step colors + inline static const std::string& STEP_COLORS_ID() + { + static const std::string MY_STEP_COLORS_ID("step_colors"); + return MY_STEP_COLORS_ID; + } /// Default constructor EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature(); /// Default destructor @@ -108,6 +139,18 @@ private: /// Loads Naming data structure to the document void loadNamingDS(std::shared_ptr theGeomShape, std::shared_ptr theResultBody); + /// Set groups of color + void setColorGroups(std::shared_ptr theResultBody); + + /// set a group of color + void setColorGroup(std::shared_ptr theResultBody, + std::vector& theColor, + const std::wstring& theName ); + + /// set Materiel group of color + void setMaterielGroup(std::shared_ptr theResultBody, + std::map< std::wstring, std::list>& theMaterialShape); + }; #endif /* IMPORT_IMPORTFEATURE_H_ */ diff --git a/src/ExchangePlugin/ExchangePlugin_msg_fr.ts b/src/ExchangePlugin/ExchangePlugin_msg_fr.ts index 3e4061b1e..2774f3d59 100644 --- a/src/ExchangePlugin/ExchangePlugin_msg_fr.ts +++ b/src/ExchangePlugin/ExchangePlugin_msg_fr.ts @@ -134,6 +134,10 @@ XAO XAO + + STL + STL + Export:file_path @@ -193,6 +197,81 @@ Veuillez saisir le nom de la géométrie + + Export:stl_file_path + + Export file + Fichier d'export + + + + Export:stl_file_path:ExchangePlugin_ExportFormat + + %1 is not initialized. + %1 n'est pas initialisé. + + + File name is empty. + Le nom du fichier est vide. + + + + Export:stl_object_selected + + Object + Objet + + + Object to export. + Objet à exporter. + + + + Export:stl_file_type + + File type + type du fichier + + + Binary + Binaire + + + ASCII + ASCII + + + + Export:Deflection + + Deflection + Déflection + + + Relative + Relative + + + Relative value. + Valeur relative + + + Calculate by size of shape + Calcul par rapport à la taille de la shape + + + Absolute + Absolue + + + Value indicate by user + Valeur indiquée par l'utilisateur + + + Absolute value. + Valeur absolue. + + @@ -216,8 +295,12 @@ Importer - Import a file - Importer un fichier + Create groups from + Créer des groupes à partir + + + Materials + Matériels @@ -227,7 +310,34 @@ Importer un fichier - + + Import:step_file_path + + Import file + Importer un fichier + + + + Import:step_scale_inter_units + + Scale to International System of Units + Mettre à l'échelle du système international d'unités + + + + Import:step_materials + + Materials + Matériels + + + + Import:step_colors + + Colors + Couleurs + + ImportMacro @@ -238,7 +348,11 @@ Import a file Importer un fichier - + + Create groups from + Créer des groupes à partir + + ImportMacro:target_part @@ -246,6 +360,34 @@ Importer vers + + ImportMacro:step_target_part + + Import to + Importer vers + + + + ImportMacro:step_scale_inter_units + + Scale to International System of Units + Mettre à l'échelle du système international d'unités + + + + ImportMacro:step_materials + + Materials + Matériels + + + + ImportMacro:step_colors + + Colors + Couleurs + + ImportMacro:file_path @@ -253,6 +395,13 @@ Fichier à importer + + ImportMacro:step_file_path + + Import file + Importer un fichier + + ImportMacro:file_path:ExchangePlugin_ImportFormat diff --git a/src/ExchangePlugin/Test/TestExport.py b/src/ExchangePlugin/Test/TestExport.py index 511b95835..8e4ca9835 100644 --- a/src/ExchangePlugin/Test/TestExport.py +++ b/src/ExchangePlugin/Test/TestExport.py @@ -59,7 +59,9 @@ def testExport(theType, theFormat, theFile, theVolume, theDelta, theErrorExpecte aSession.startOperation("Import screw") anImportFeature = aPart.addFeature("Import") aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Step", "screw.step") - anImportFeature.string("file_path").setValue(aShapePath) + anImportFeature.string("step_file_path").setValue(aShapePath) + anImportFeature.string("ImportType").setValue("STEP") + anImportFeature.boolean("step_scale_inter_units").setValue(True) aSession.finishOperation() removeFile(theFile) @@ -101,6 +103,7 @@ def testExportXAO(theFile, theEmptyFormat = False): anImportFeature = aPart.addFeature("Import") aShapePath = os.path.join(os.getenv("DATA_DIR"), "Shapes", "Brep", "box1.brep") anImportFeature.string("file_path").setValue(aShapePath) + anImportFeature.string("ImportType").setValue("BREP") aSession.finishOperation() # Create groups @@ -175,21 +178,21 @@ if __name__ == '__main__': aRealVolume = 3.78827401738e-06 testExport("BREP", "BREP", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17) testExport("BRP", "BREP", os.path.join(tmp_dir, "screw_export.brp"), aRealVolume, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17) + testExport("BREP", "", os.path.join(tmp_dir, "screw_export.brep"), aRealVolume, 10 ** -17) #========================================================================= # Export a shape into STEP #========================================================================= testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17) - testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.788258075329978e-06, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17) + testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.788258075329978e-06, 10 ** -17) + testExport("STEP", "", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17) #========================================================================= # Export a shape into IGES #========================================================================= - testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17) - testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 0.0019293313766693052, 10 ** -17) - testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17) - testExport("IGES-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17) - testExport("IGS-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17) + testExport("IGES", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17) + testExport("IGS", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 0.0019293313766693052, 10 ** -17) + testExport("IGES", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17) + testExport("IGES", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17) + testExport("IGS", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17) #========================================================================= # Export a shape into XAO #========================================================================= @@ -198,7 +201,7 @@ if __name__ == '__main__': #========================================================================= # Check error when export to unsupported format #========================================================================= - testExport("Regular", "", os.path.join(tmp_dir, "screw_export.dwg"), 3.78825807533e-06, 10 ** -17, True) + testExport("BREP", "", os.path.join(tmp_dir, "screw_export.dwg"), 3.78825807533e-06, 10 ** -17, True) #========================================================================= # End of test #========================================================================= diff --git a/src/ExchangePlugin/Test/TestImport.py b/src/ExchangePlugin/Test/TestImport.py index a4895e081..67998ea22 100644 --- a/src/ExchangePlugin/Test/TestImport.py +++ b/src/ExchangePlugin/Test/TestImport.py @@ -54,10 +54,23 @@ def testImport(theType, theFile, theVolume, theDelta, theErrorExpected = False): aFeatureKind = "Import" anImportFeature = aPart.addFeature(aFeatureKind) assert anImportFeature, "{0}: Can not create a feature {1}".format(theType, aFeatureKind) + if theType == "STP" or theType == "STEP": + aFieldName = "step_file_path" + file = anImportFeature.string(aFieldName) + assert file, "{0}: Can not receive string field {1}".format(theType, aFieldName) + file.setValue(theFile) + aFieldName = "step_scale_inter_units" + units = anImportFeature.boolean(aFieldName) + assert units, "{0}: Can not receive string field {1}".format(theType, aFieldName) + units.setValue(True) aFieldName = "file_path" file = anImportFeature.string(aFieldName) assert file, "{0}: Can not receive string field {1}".format(theType, aFieldName) file.setValue(theFile) + aFieldName = "ImportType" + type = anImportFeature.string(aFieldName) + assert type, "{0}: Can not receive string field {1}".format(theType, aFieldName) + type.setValue(theType) aSession.finishOperation() if theErrorExpected: @@ -86,6 +99,9 @@ def testImportXAO(): aSession.startOperation("Import XAO") anImportFeature = aPart.addFeature("Import") anImportFeature.string("file_path").setValue(getShapePath("Xao/box1.xao")) + aFieldName = "ImportType" + type = anImportFeature.string(aFieldName) + type.setValue("XAO") aSession.finishOperation() # Check results @@ -140,22 +156,29 @@ if __name__ == '__main__': # Create a shape imported from STEP #========================================================================= shape_path = getShapePath("Step/screw.step") - testImport("STP", shape_path, 3.78827401738e-06, 10 ** -17) + testImport("STEP", shape_path, 3.78827401738e-06, 10 ** -17) shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "screw.stp")) testImport("STEP", shape_path, 3.78827401738e-06, 10 ** -17) #========================================================================= # Create a shape imported from IGES #========================================================================= shape_path = getShapePath("Iges/bearing.igs") - testImport("IGES", shape_path, 1.3407098545036494e-08, 10 ** -25) - shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "bearing.iges")) testImport("IGS", shape_path, 1.3407098545036494e-08, 10 ** -25) + shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "bearing.iges")) + testImport("IGES", shape_path, 1.3407098545036494e-08, 10 ** -25) #========================================================================= # Create a shape imported from XAO #========================================================================= testImportXAO() + #========================================================================= + # End of test + #========================================================================= + + from salome.shaper import model + assert(model.checkPythonDump()) + #========================================================================= # Check import errors #========================================================================= @@ -164,10 +187,3 @@ if __name__ == '__main__': testImport("BREP", shape_path, 0, 10 ** -25, True) shape_path = getShapePath("Xao/wrong_file.xao") testImport("XAO", shape_path, 0, 10 ** -25, True) - - #========================================================================= - # End of test - #========================================================================= - - from salome.shaper import model - assert(model.checkPythonDump()) diff --git a/src/ExchangePlugin/doc/TUI_exportFeature.rst b/src/ExchangePlugin/doc/TUI_exportFeature.rst index 49eecc5aa..4ef25d686 100644 --- a/src/ExchangePlugin/doc/TUI_exportFeature.rst +++ b/src/ExchangePlugin/doc/TUI_exportFeature.rst @@ -9,4 +9,16 @@ Export File :language: python :download:`Download this script ` + + .. _tui_export_file_STL: + +Export STL File +=============== + +.. literalinclude:: examples/exportSTL.py + :linenos: + :language: python + +:download:`Download this script ` + diff --git a/src/ExchangePlugin/doc/TUI_importFeature.rst b/src/ExchangePlugin/doc/TUI_importFeature.rst index 69ed88ab6..ff000831f 100644 --- a/src/ExchangePlugin/doc/TUI_importFeature.rst +++ b/src/ExchangePlugin/doc/TUI_importFeature.rst @@ -10,3 +10,13 @@ Import File :download:`Download this script ` + .. _tui_import_file_step: + +Import STEP File +================ + +.. literalinclude:: examples/importStep.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/ExchangePlugin/doc/examples/export.py b/src/ExchangePlugin/doc/examples/export.py index feb837252..1f9b7c2b5 100644 --- a/src/ExchangePlugin/doc/examples/export.py +++ b/src/ExchangePlugin/doc/examples/export.py @@ -1,11 +1,13 @@ from salome.shaper import model +import os model.begin() +file_path = os.path.join(os.getenv("DATA_DIR"), "test.step") partSet = model.moduleDocument() Part_1 = model.addPart(partSet) Part_1_doc = Part_1.document() Box_1 = model.addBox(Part_1_doc, 10, 10, 10) -Export_1 = model.exportToFile(Part_1_doc, "/dn48/newgeom/vsv/test.step", +Export_1 = model.exportToFile(Part_1_doc, file_path, [model.selection("SOLID", "Box_1_1")]) model.do() model.end() diff --git a/src/ExchangePlugin/doc/examples/exportSTL.py b/src/ExchangePlugin/doc/examples/exportSTL.py new file mode 100644 index 000000000..a152c4a2e --- /dev/null +++ b/src/ExchangePlugin/doc/examples/exportSTL.py @@ -0,0 +1,13 @@ +from salome.shaper import model +import os + +model.begin() +file_path = os.path.join(os.getenv("DATA_DIR"), "test.stl") +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Export_1 = model.exportToSTL(Part_1_doc, file_path, + model.selection("SOLID", "Box_1_1"),0.0001,0.5,True,False) +model.do() +model.end() diff --git a/src/ExchangePlugin/doc/examples/importStep.py b/src/ExchangePlugin/doc/examples/importStep.py new file mode 100644 index 000000000..0adc73a7a --- /dev/null +++ b/src/ExchangePlugin/doc/examples/importStep.py @@ -0,0 +1,11 @@ +from salome.shaper import model +import os + +model.begin() +file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","black_and_white.step") +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Import_1 = model.addImportSTEP(Part_1_doc,file_path, True, True, True) +model.do() +model.end() diff --git a/src/ExchangePlugin/doc/exportFeature.rst b/src/ExchangePlugin/doc/exportFeature.rst index e11ede6ad..5867d1bf5 100644 --- a/src/ExchangePlugin/doc/exportFeature.rst +++ b/src/ExchangePlugin/doc/exportFeature.rst @@ -69,9 +69,10 @@ The Result of operation is an exported file. Export to CAD format -------------------- -It is possible to export objects to files in the following CAD-neutral formats: BREP, STEP, IGES, XAO. +It is possible to export objects to files in the following CAD-neutral formats: BREP, STEP, IGES, XAO, STL. To export objects to a file select in the Main Menu *File -> Export -> To CAD formats...* item. + The following property panel will be opened: .. figure:: images/Export_panel.png @@ -79,15 +80,22 @@ The following property panel will be opened: **Export property panel** -In this panel, it is necessary to select desirable format of export file. It can be **'BREP, STEP, IGES'** or **'XAO'**. In case of first choice the format of exported file will be defined according to file extension. The file name and path can be defined in **Export file** field by direct input or browsing with **'...'** button, which opens **Export file** dialog box: +In this panel, it is necessary to select desirable format of export file. It can be **'BREP, STEP, IGES'** , **'XAO'** or **'STL'** . + + +Export to BREP, STEP, IGES +"""""""""""""""""""""""""" + +In case of first choice the format of exported file will be defined according to file extension. The file name and path can be defined in **Export file** field by direct input or browsing with **'...'** button, which opens **Export file** dialog box: .. figure:: images/ExportFileDlg.png :align: center - **Dialog box tp export in CAD-neutral format** + **Dialog box to export in CAD-neutral format** Selection list in the property panel contains a list of exported objects which can be selected in a viewer or object browser. + **Apply** button exports the file. **Cancel** button cancels the operation. @@ -115,3 +123,50 @@ Result The Result of operation is an exported file. **See Also** a sample TUI Script of :ref:`tui_export_file` operation. + +Result +"""""" + +The Result of operation is an exported file. + +**See Also** a sample TUI Script of :ref:`tui_export_file` operation. + +Export to STL +""""""""""""" +In this case, the following property panel will be opened: + +.. figure:: images/ExportSTL.png + :align: center + + **Dialog box to export in STL format** + + +The file name and path can be defined in **Export file** field by direct input or browsing with ‘…’ button, which opens Export file dialog box. + +**Object** field contains an exported object which can be selected in a viewer or object browser. + +**Deflection** (**Relative** or **Absolute**) has to be chosen and defined in the corresponding field as well as the **File type** which can defined as **Binary** or as **ASCII**. + + +**Apply** button exports the file. + +**Cancel** button cancels the operation. + +**TUI Command**: + +.. py:function:: model.exportToSTL(Part_doc, FileNameString, selectedShape, relative, absolute, isRelative, isASCII) + + :param part: The current part object + :param string: The file name + :param object: An exporting object + :param real: value of the relative deflection + :param real: value of the absolute deflection + :param boolean: indicate if use deflection relative + :param boolean: indicate if the file is in ASCII type + +Result +"""""" + +The Result of operation is an exported STL file. + +**See Also** a sample TUI Script of :ref:`tui_export_file_STL` operation. diff --git a/src/ExchangePlugin/doc/images/ExportSTL.png b/src/ExchangePlugin/doc/images/ExportSTL.png new file mode 100644 index 000000000..e69de29bb diff --git a/src/ExchangePlugin/doc/images/FileImportedSTEP.png b/src/ExchangePlugin/doc/images/FileImportedSTEP.png new file mode 100644 index 000000000..d4f171d81 Binary files /dev/null and b/src/ExchangePlugin/doc/images/FileImportedSTEP.png differ diff --git a/src/ExchangePlugin/doc/images/ImportSTEP.png b/src/ExchangePlugin/doc/images/ImportSTEP.png new file mode 100644 index 000000000..457d02d8b Binary files /dev/null and b/src/ExchangePlugin/doc/images/ImportSTEP.png differ diff --git a/src/ExchangePlugin/doc/images/Import_panel.png b/src/ExchangePlugin/doc/images/Import_panel.png index c22176e77..4d610af44 100644 Binary files a/src/ExchangePlugin/doc/images/Import_panel.png and b/src/ExchangePlugin/doc/images/Import_panel.png differ diff --git a/src/ExchangePlugin/doc/importFeature.rst b/src/ExchangePlugin/doc/importFeature.rst index 4692ec669..64251ddb2 100644 --- a/src/ExchangePlugin/doc/importFeature.rst +++ b/src/ExchangePlugin/doc/importFeature.rst @@ -67,6 +67,8 @@ The following property panel will be opened: **Import property panel** +The first combobox provides the list of formats avalables (BREP, XAO, IGES or STEP). + The **Import to** combobox provides the list of destinations (one of existing Parts or a new Part). In this panel it is possible to enter a file name directly or press **'...'** button and browse it with help of import file dialog box: @@ -75,7 +77,11 @@ In this panel it is possible to enter a file name directly or press **'...'** bu :align: center **Dialog box to import CAD-neutral format** - + +Import BREP, XAO, IGES +"""""""""""""""""""""" +In case of first choice the format of imported file will be defined according to file extension. + **Apply** button imports the file. **Cancel** button cancels the operation. @@ -98,3 +104,45 @@ The Result of the operation depends on the imported file content. Import of BREP file. **See Also** a sample TUI Script of :ref:`tui_import_file` operation. + + +Import STEP +""""""""""" + +In this case, the following property panel will be opened: + +.. figure:: images/ImportSTEP.png + :align: center + + **Dialog box to import file in STEP format** + + +The file name and path can be defined in **Import file** field by direct input or browsing with ‘…’ button, which opens **Import file** dialog box. +The **Import to** combobox provides the list of destinations (one of existing Parts or a new Part). +**STEP options** provide the possibility to **Scale to International System Units** as well as to create groups from **Materials** and/or **Colors** if defined in assemblies of the file to import. + +**Apply** button imports the file. + +**Cancel** button cancels the operation. + +**TUI Command**: + +.. py:function:: model.addImportSTEP(Part_doc, FileNameString,scalInterUnits,materials,colors) + + :param part: The current part object + :param string: A file name string. + :param boolean: True if scale to UIS + :param boolean: True to create groups from materials + :param boolean: True to create groups from colors + +Result +"""""" + +The Result of the operation depends on the imported file content. + +.. figure:: images/FileImportedSTEP.png + :align: center + + Import of STEP file. + +**See Also** a sample TUI Script of :ref:`tui_import_file_step` operation. diff --git a/src/ExchangePlugin/export_widget.xml b/src/ExchangePlugin/export_widget.xml index 9e134b805..83b9aba4d 100644 --- a/src/ExchangePlugin/export_widget.xml +++ b/src/ExchangePlugin/export_widget.xml @@ -31,5 +31,54 @@ placeholder="Please input the geometry name"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ExchangePlugin/plugin-Exchange.xml b/src/ExchangePlugin/plugin-Exchange.xml index 7f240ba69..8f2445633 100644 --- a/src/ExchangePlugin/plugin-Exchange.xml +++ b/src/ExchangePlugin/plugin-Exchange.xml @@ -4,19 +4,67 @@ - - - + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + @@ -75,4 +123,4 @@ - \ No newline at end of file + diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp index 33956df7c..6d4b09057 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp @@ -75,10 +75,13 @@ FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize) + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theDirection, mydirection); setSizes(theToSize, theFromSize); @@ -107,10 +110,13 @@ FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptrsetSelectionType(theSelectionType); fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theDirection, mydirection); setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); @@ -228,6 +234,18 @@ void FeaturesAPI_Extrusion::dump(ModelHighAPI_Dumper& theDumper) const ", " << anAttrFromObject << ", " << anAttrFromOffset; } + // write explicitly the type of selection if it does not correspond + // to the type of first selected shape + if (!anAttrSketch->isInitialized()) { + std::string aListSelType = anAttrObjects->selectionType(); + AttributeSelectionPtr aFirstSelection = anAttrObjects->value(0); + GeomShapePtr aFirstShape = aFirstSelection->value(); + if (!aFirstShape) + aFirstShape = aFirstSelection->context()->shape(); + if (!aFirstShape || aFirstShape->shapeType() != GeomAPI_Shape::shapeTypeByStr(aListSelType)) + theDumper << ", \"" << aListSelType << "\""; + } + theDumper << ")" << std::endl; if(anAttrSketch->isInitialized()) { @@ -277,14 +295,16 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize) + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID()); return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theDirection, theToSize, - theFromSize)); + theFromSize, + theSelectionType)); } //================================================================================================== @@ -311,7 +331,8 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID()); return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, @@ -320,5 +341,6 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, theToObject, theToOffset, theFromObject, - theFromOffset)); + theFromOffset, + theSelectionType)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.h b/src/FeaturesAPI/FeaturesAPI_Extrusion.h index b56f662b1..84d66913a 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.h +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.h @@ -66,7 +66,8 @@ public: const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize); + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType = std::string()); /// Constructor with values. FEATURESAPI_EXPORT @@ -85,7 +86,8 @@ public: const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); /// Destructor. FEATURESAPI_EXPORT @@ -183,7 +185,8 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theDirection, const ModelHighAPI_Double& theToSize, - const ModelHighAPI_Double& theFromSize); + const ModelHighAPI_Double& theFromSize, + const std::string& theSelectionType = std::string()); /// \ingroup CPPHighAPI /// \brief Create Extrusion feature. @@ -204,6 +207,7 @@ ExtrusionPtr addExtrusion(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); #endif // FeaturesAPI_Extrusion_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp index f2b511b6f..7799776da 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp @@ -52,10 +52,13 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution( const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle) + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theAxis, myaxis); setAngles(theToAngle, theFromAngle); @@ -70,10 +73,13 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution( const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) : ModelHighAPI_Interface(theFeature) { if(initialize()) { + if (!theSelectionType.empty()) + mybaseObjects->setSelectionType(theSelectionType); fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theAxis, myaxis); setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset); @@ -191,6 +197,18 @@ void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const ", " << anAttrFromObject << ", " << anAttrFromOffset; } + // write explicitly the type of selection if it does not correspond + // to the type of first selected shape + if (!anAttrSketch->isInitialized()) { + std::string aListSelType = anAttrObjects->selectionType(); + AttributeSelectionPtr aFirstSelection = anAttrObjects->value(0); + GeomShapePtr aFirstShape = aFirstSelection->value(); + if (!aFirstShape) + aFirstShape = aFirstSelection->context()->shape(); + if (!aFirstShape || aFirstShape->shapeType() != GeomAPI_Shape::shapeTypeByStr(aListSelType)) + theDumper << ", \"" << aListSelType << "\""; + } + theDumper << ")" << std::endl; if(anAttrSketch->isInitialized()) { @@ -221,14 +239,16 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle) + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID()); return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theToAngle, - theFromAngle)); + theFromAngle, + theSelectionType)); } //================================================================================================== @@ -238,7 +258,8 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset) + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID()); return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, @@ -247,5 +268,6 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, theToObject, theToOffset, theFromObject, - theFromOffset)); + theFromOffset, + theSelectionType)); } diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.h b/src/FeaturesAPI/FeaturesAPI_Revolution.h index b947db43b..cc1c78bf5 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.h +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.h @@ -54,7 +54,8 @@ public: const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle); + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType = std::string()); /// Constructor with values. FEATURESAPI_EXPORT @@ -64,7 +65,8 @@ public: const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); /// Destructor. FEATURESAPI_EXPORT @@ -147,7 +149,8 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Selection& theAxis, const ModelHighAPI_Double& theToAngle, - const ModelHighAPI_Double& theFromAngle); + const ModelHighAPI_Double& theFromAngle, + const std::string& theSelectionType = std::string()); /// \ingroup CPPHighAPI /// \brief Create Revolution feature. @@ -158,6 +161,7 @@ RevolutionPtr addRevolution(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theToObject, const ModelHighAPI_Double& theToOffset, const ModelHighAPI_Selection& theFromObject, - const ModelHighAPI_Double& theFromOffset); + const ModelHighAPI_Double& theFromOffset, + const std::string& theSelectionType = std::string()); #endif // FeaturesAPI_Revolution_H_ diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 0169cd9e3..1dce791a9 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -682,4 +682,10 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillet1D_Wire_3.py TestFillet1D_Wire_4.py TestFillet1D_Wire_5.py + Test19931.py + Test20027.py + Test20245_1.py + Test20245_2.py + Test20245_3.py + Test20247.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp index 4c43be8cc..3ab6d589c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFuse.cpp @@ -41,6 +41,22 @@ #include #include +static void explodeCompound(const GeomShapePtr& theShape, ListOfShape& theResult) +{ + if (theShape->shapeType() == GeomAPI_Shape::COMPOUND) { + GeomAPI_ShapeIterator it(theShape); + for (; it.more(); it.next()) + theResult.push_back(it.current()); + } else + theResult.push_back(theShape); +} + +static void collectSolids(const ListOfShape& theShapes, ListOfShape& theResult) +{ + for (ListOfShape::const_iterator it = theShapes.begin(); it != theShapes.end(); ++it) + explodeCompound(*it, theResult); +} + //================================================================================================== FeaturesPlugin_BooleanFuse::FeaturesPlugin_BooleanFuse() : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_FUSE) @@ -105,9 +121,13 @@ void FeaturesPlugin_BooleanFuse::execute() const std::string aFuseVersion = data()->version(); // Collecting all solids which will be fused. + // We explode the top-level compounds here because of issue #19931. It performs Fuse operation + // on a set of compounds, one of which is treated as self-intersected. + // But this problem is eliminated after the exploding, because in this case, + // the shapes are intersected, but not self-intersected. ListOfShape aSolidsToFuse; - aSolidsToFuse.insert(aSolidsToFuse.end(), anObjects.begin(), anObjects.end()); - aSolidsToFuse.insert(aSolidsToFuse.end(), aTools.begin(), aTools.end()); + collectSolids(anObjects, aSolidsToFuse); + collectSolids(aTools, aSolidsToFuse); // Collecting solids from compsolids which will not be modified // in boolean operation and will be added to result. diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index ab0d12b7d..0bd58e26c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -32,6 +32,8 @@ #include +static const std::string COMPOSITESKETCH_VERSION_1("v9.6"); + static void storeSubShape(const std::shared_ptr theMakeShape, ResultBodyPtr theResultBody, const GeomShapePtr theShape, @@ -49,9 +51,15 @@ void FeaturesPlugin_CompositeSketch::initCompositeSketchAttribtues(const int the // Initialize selection list. if(theInitFlags & InitBaseObjectsList) { - data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); + AttributeSelectionListPtr anObjectsAttr = + std::dynamic_pointer_cast( + data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId())); myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType(); - selectionList(BASE_OBJECTS_ID())->setWholeResultAllowed(true); + anObjectsAttr->setWholeResultAllowed(true); + if (!anObjectsAttr->isInitialized()) { + // new feature, specify the version + data()->setVersion(COMPOSITESKETCH_VERSION_1); + } } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 9235d933e..55bad81ce 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -402,7 +402,11 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute AttributeSelectionListPtr aListAttr = std::dynamic_pointer_cast(theAttribute); - const std::string& aSelType = aListAttr->selectionType(); + const std::string& aVersion = theAttribute->owner()->data()->version(); + std::string aSelType; + if (!aVersion.empty()) + aSelType = aListAttr->selectionType(); + std::list anApplicableTypes; switch (GeomValidators_ShapeType::shapeType(aSelType)) { case GeomValidators_ShapeType::Vertex: diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index 6f821a2e2..66977d71f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -522,8 +522,8 @@ Extrusion:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -696,8 +696,8 @@ ExtrusionCut:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -880,8 +880,8 @@ ExtrusionFuse:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -1685,8 +1685,8 @@ Revolution:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -1866,8 +1866,8 @@ RevolutionCut:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -2028,8 +2028,8 @@ RevolutionFuse:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. diff --git a/src/FeaturesPlugin/Test/Test19931.py b/src/FeaturesPlugin/Test/Test19931.py new file mode 100644 index 000000000..9f2c5b0e4 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test19931.py @@ -0,0 +1,743 @@ +# Copyright (C) 2020 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 + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(0, 62.99999999999999, 32, 63) +Sketch_1.setHorizontal(SketchLine_1.result()) + +### Create SketchLine +SketchLine_2 = Sketch_1.addLine(35, 66, 35, 87.99999999999999) +Sketch_1.setVertical(SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(35, 87.99999999999999, 75.00000000000001, 87.99999999999999) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +Sketch_1.setHorizontal(SketchLine_3.result()) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(75.00000000000001, 87.99999999999999, 75.00000000000001, 78) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +Sketch_1.setVertical(SketchLine_4.result()) + +### Create SketchArc +SketchArc_1 = Sketch_1.addArc(75.00000000000004, 71.99999999999689, 75.00000000000001, 78, 69, 71.99999999999613, False) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchArc_1.startPoint()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(69, 71.99999999999613, 69, 52.00000000001324) +Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_5.startPoint()) +Sketch_1.setVertical(SketchLine_5.result()) + +### Create SketchArc +SketchArc_2 = Sketch_1.addArc(57, 52.00000000001324, 69, 52.00000000001324, 57.0000000000007, 40, True) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchArc_2.startPoint()) +Sketch_1.setTangent(SketchLine_5.result(), SketchArc_2.results()[1]) + +### Create SketchArc +SketchArc_3 = Sketch_1.addArc(57, 27.99999999998618, 57.0000000000007, 40, 45, 27.99999999998618, False) +Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchArc_3.startPoint()) +Sketch_1.setTangent(SketchArc_2.results()[1], SketchArc_3.results()[1]) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(45, 27.99999999998618, 45, 0) +Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_6.startPoint()) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_7 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.result()) +Sketch_1.setVertical(SketchLine_6.result()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(45, 0, 0, 0) +Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_8.startPoint()) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_7).startPoint(), SketchLine_8.endPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_9 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_9.result()) +Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_6.result()) +Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_5.result()) +Sketch_1.setLength(SketchLine_8.result(), 45) +Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_4.result(), "150/2", True) +Sketch_1.setDistance(SketchLine_3.result(), SketchArc_1.startPoint(), 10, True) +Sketch_1.setRadius(SketchArc_1.results()[1], 6) +Sketch_1.setRadius(SketchArc_2.results()[1], 12) +Sketch_1.setEqual(SketchArc_2.results()[1], SketchArc_3.results()[1]) +Sketch_1.setDistance(SketchLine_7.result(), SketchArc_3.startPoint(), 40, True) +Sketch_1.setVerticalDistance(SketchArc_3.startPoint(), SketchArc_1.startPoint(), 38) +Sketch_1.setDistance(SketchLine_9.result(), SketchLine_5.startPoint(), "138/2", True) + +### Create SketchLine +SketchLine_10 = Sketch_1.addLine(-75.00000000000001, 77.99999999999693, -50.99999999999996, 78) +SketchLine_10.setName("SketchLine_17") +SketchLine_10.result().setName("SketchLine_17") +Sketch_1.setHorizontal(SketchLine_10.result()) + +### Create SketchArc +SketchArc_4 = Sketch_1.addArc(-50.99999999999996, 72, -50.99999999999996, 78, -44.99999999999996, 72, True) +SketchArc_4.setName("SketchArc_7") +SketchArc_4.result().setName("SketchArc_7") +SketchArc_4.results()[1].setName("SketchArc_7_2") +Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchArc_4.startPoint()) +Sketch_1.setTangent(SketchLine_10.result(), SketchArc_4.results()[1]) + +### Create SketchArc +SketchArc_5 = Sketch_1.addArc(-28, 49.99999999999999, -28, 52.99999999999999, -25, 49.99999999999999, True) +SketchArc_5.setName("SketchArc_9") +SketchArc_5.result().setName("SketchArc_9") +SketchArc_5.results()[1].setName("SketchArc_9_2") + +### Create SketchLine +SketchLine_11 = Sketch_1.addLine(-25, 49.99999999999999, -25, 27.99999999999997) +SketchLine_11.setName("SketchLine_18") +SketchLine_11.result().setName("SketchLine_18") +Sketch_1.setCoincident(SketchArc_5.endPoint(), SketchLine_11.startPoint()) +Sketch_1.setVertical(SketchLine_11.result()) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(0, 27.99999999999997, 25) +Sketch_1.setCoincident(SketchLine_9.result(), SketchCircle_1.center()) +Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchCircle_1.results()[1]) + +### Create SketchCircle +SketchCircle_2 = Sketch_1.addCircle(0, 27.99999999999997, 16) +Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center()) +Sketch_1.setRadius(SketchArc_4.results()[1], 6) +Sketch_1.setRadius(SketchArc_5.results()[1], 3) +Sketch_1.setTangent(SketchArc_5.results()[1], SketchLine_11.result()) +Sketch_1.setRadius(SketchCircle_1.results()[1], 25) +Sketch_1.setRadius(SketchCircle_2.results()[1], 16) + +### Create SketchLine +SketchLine_12 = Sketch_1.addLine(-44.99999999999996, 72, -44.99999999999998, 64.99999999999999) +SketchLine_12.setName("SketchLine_19") +SketchLine_12.result().setName("SketchLine_19") +Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_12.startPoint()) +Sketch_1.setVertical(SketchLine_12.result()) + +### Create SketchLine +SketchLine_13 = Sketch_1.addLine(-28, 52.99999999999999, -32.99999999999998, 52.99999999999999) +SketchLine_13.setName("SketchLine_20") +SketchLine_13.result().setName("SketchLine_20") +Sketch_1.setCoincident(SketchArc_5.startPoint(), SketchLine_13.startPoint()) +Sketch_1.setHorizontal(SketchLine_13.result()) + +### Create SketchArc +SketchArc_6 = Sketch_1.addArc(-32.99999999999998, 64.99999999999999, -44.99999999999998, 64.99999999999999, -32.99999999999998, 52.99999999999999, False) +SketchArc_6.setName("SketchArc_10") +SketchArc_6.result().setName("SketchArc_10") +SketchArc_6.results()[1].setName("SketchArc_10_2") +Sketch_1.setCoincident(SketchLine_12.endPoint(), SketchArc_6.startPoint()) +Sketch_1.setTangent(SketchLine_12.result(), SketchArc_6.results()[1]) +Sketch_1.setCoincident(SketchLine_13.result(), SketchArc_6.endPoint()) +Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_12.result()) +Sketch_1.setTangent(SketchArc_6.results()[1], SketchLine_13.result()) +Sketch_1.setTangent(SketchLine_13.result(), SketchArc_5.results()[1]) +Sketch_1.setRadius(SketchArc_6.results()[1], 12) +Sketch_1.setCoincident(SketchArc_6.endPoint(), SketchLine_13.endPoint()) + +### Create SketchLine +SketchLine_14 = Sketch_1.addLine(-25, 27.99999999999997, 0, 27.99999999999997) +SketchLine_14.setName("SketchLine_21") +SketchLine_14.result().setName("SketchLine_21") +SketchLine_14.setAuxiliary(True) +Sketch_1.setCoincident(SketchLine_11.endPoint(), SketchLine_14.startPoint()) +Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_14.endPoint()) +Sketch_1.setHorizontal(SketchLine_14.result()) + +### Create SketchArc +SketchArc_7 = Sketch_1.addArc(32, 66, 32, 63, 35, 66, False) +SketchArc_7.setName("SketchArc_11") +SketchArc_7.result().setName("SketchArc_11") +SketchArc_7.results()[1].setName("SketchArc_11_2") + +### Create SketchConstraintMirror +SketchConstraintMirror_1_objects = [SketchLine_4.result(), SketchLine_5.result(), SketchLine_1.result(), SketchLine_3.result(), SketchLine_2.result(), SketchLine_6.result(), SketchLine_8.result(), SketchArc_1.results()[1], SketchArc_3.results()[1], SketchArc_2.results()[1], SketchArc_7.results()[1]] +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_9.result(), SketchConstraintMirror_1_objects) +[SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19, SketchLine_20, SketchLine_21, SketchArc_8, SketchArc_9, SketchArc_10, SketchArc_11] = SketchConstraintMirror_1.mirrored() +SketchArc_11.setName("SketchArc_12") +SketchArc_11.result().setName("SketchArc_12") +SketchArc_11.results()[1].setName("SketchArc_12_2") +SketchArc_10.setName("SketchArc_6") +SketchArc_10.result().setName("SketchArc_6") +SketchArc_10.results()[1].setName("SketchArc_6_2") +SketchArc_9.setName("SketchArc_5") +SketchArc_9.result().setName("SketchArc_5") +SketchArc_9.results()[1].setName("SketchArc_5_2") +SketchArc_8.setName("SketchArc_4") +SketchArc_8.result().setName("SketchArc_4") +SketchArc_8.results()[1].setName("SketchArc_4_2") +SketchLine_21.setName("SketchLine_16") +SketchLine_21.result().setName("SketchLine_16") +SketchLine_20.setName("SketchLine_15") +SketchLine_20.result().setName("SketchLine_15") +SketchLine_19.setName("SketchLine_14") +SketchLine_19.result().setName("SketchLine_14") +SketchLine_18.setName("SketchLine_13") +SketchLine_18.result().setName("SketchLine_13") +SketchLine_17.setName("SketchLine_12") +SketchLine_17.result().setName("SketchLine_12") +SketchLine_16.setName("SketchLine_11") +SketchLine_16.result().setName("SketchLine_11") +SketchLine_15.setName("SketchLine_10") +SketchLine_15.result().setName("SketchLine_10") +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_15).endPoint(), SketchLine_10.startPoint()) +Sketch_1.setDistance(SketchLine_12.result(), SketchAPI_Line(SketchLine_17).startPoint(), 45, True) +Sketch_1.setDistance(SketchLine_18.result(), SketchLine_14.endPoint(), 60, True) +Sketch_1.setDistance(SketchLine_17.result(), SketchLine_13.startPoint(), 10, True) + +### Create SketchPoint +SketchPoint_1 = Sketch_1.addPoint(35, 62.99999999999999) +SketchPoint_1.setAuxiliary(True) +Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.result()) +Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_2.result()) +Sketch_1.setDistance(SketchLine_1.startPoint(), SketchPoint_1.coordinates(), 35, False) +Sketch_1.setDistance(SketchPoint_1.coordinates(), SketchLine_2.endPoint(), 25, False) +Sketch_1.setCoincident(SketchArc_7.startPoint(), SketchLine_1.endPoint()) +Sketch_1.setCoincident(SketchArc_7.endPoint(), SketchLine_2.startPoint()) +Sketch_1.setTangent(SketchArc_7.results()[1], SketchLine_1.result()) +Sketch_1.setTangent(SketchArc_7.results()[1], SketchLine_2.result()) +Sketch_1.setRadius(SketchArc_7.results()[1], 3) + +### Create SketchConstraintMirror +SketchConstraintMirror_2_objects = [SketchLine_10.result(), SketchArc_4.results()[1], SketchLine_12.result(), SketchArc_6.results()[1], SketchLine_13.result(), SketchArc_5.results()[1], SketchLine_11.result()] +SketchConstraintMirror_2 = Sketch_1.addMirror(SketchLine_9.result(), SketchConstraintMirror_2_objects) +[SketchLine_22, SketchArc_12, SketchLine_23, SketchArc_13, SketchLine_24, SketchArc_14, SketchLine_25] = SketchConstraintMirror_2.mirrored() +SketchArc_14.setName("SketchArc_15") +SketchArc_14.result().setName("SketchArc_15") +SketchArc_14.results()[1].setName("SketchArc_15_2") +SketchArc_13.setName("SketchArc_14") +SketchArc_13.result().setName("SketchArc_14") +SketchArc_13.results()[1].setName("SketchArc_14_2") +SketchArc_12.setName("SketchArc_13") +SketchArc_12.result().setName("SketchArc_13") +SketchArc_12.results()[1].setName("SketchArc_13_2") +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_22f-SketchArc_13_2f-SketchLine_23f-SketchArc_14_2r-SketchLine_24r-SketchArc_15_2f-SketchLine_25f-SketchCircle_1_2r-SketchLine_18r-SketchArc_9_2f-SketchLine_20f-SketchArc_10_2r-SketchLine_19r-SketchArc_7_2f-SketchLine_17r-SketchArc_4_2r-SketchLine_11f-SketchArc_6_2f-SketchArc_5_2r-SketchLine_15f-SketchLine_16f-SketchLine_8r-SketchLine_6r-SketchArc_3_2r-SketchArc_2_2f-SketchLine_5r-SketchArc_1_2r")], model.selection(), 10, 0) + +### Create Extrusion +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_12f-SketchArc_12_2r-SketchLine_14f-SketchLine_13f-SketchLine_10f-SketchLine_17f-SketchArc_7_2r-SketchLine_19f-SketchArc_10_2f-SketchLine_20r-SketchArc_9_2r-SketchLine_18f-SketchCircle_1_2r-SketchLine_25r-SketchArc_15_2r-SketchLine_24f-SketchArc_14_2f-SketchLine_23r-SketchArc_13_2r-SketchLine_22r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchArc_11_2r-SketchLine_1r")], model.selection(), 35, 0) + +### Create Extrusion +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_1_2f-SketchCircle_2_2r")], model.selection(), 45, 0) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_1/SketchLine_22")) + +### Create SketchCircle +SketchCircle_3 = Sketch_2.addCircle(63, 23, 5) +Sketch_2.setRadius(SketchCircle_3.results()[1], 5) + +### Create SketchProjection +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_26 = SketchProjection_3.createdFeature() +Sketch_2.setDistance(SketchCircle_3.center(), SketchLine_26.result(), "126/2", True) + +### Create SketchProjection +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_27 = SketchProjection_4.createdFeature() +Sketch_2.setDistance(SketchCircle_3.center(), SketchLine_27.result(), 23, True) + +### Create SketchConstraintMirror +SketchConstraintMirror_3 = Sketch_2.addMirror(SketchLine_26.result(), [SketchCircle_3.results()[1]]) +[SketchCircle_4] = SketchConstraintMirror_3.mirrored() +model.do() + +### Create ExtrusionCut +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_2")], model.selection(), 0, 10, [model.selection("SOLID", "Extrusion_2_1")]) + +### Create Sketch +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6")) + +### Create SketchLine +SketchLine_28 = Sketch_3.addLine(0, 0, 9, -55.99999999999999) + +### Create SketchCircle +SketchCircle_5 = Sketch_3.addCircle(28, -56, 19) +Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchCircle_5.results()[1]) + +### Create SketchCircle +SketchCircle_6 = Sketch_3.addCircle(28, -56, 10) +Sketch_3.setCoincident(SketchCircle_5.center(), SketchCircle_6.center()) + +### Create SketchLine +SketchLine_29 = Sketch_3.addLine(47, -55.99999999999999, 56.26584765647708, -18.93660937409168) +Sketch_3.setCoincident(SketchLine_29.startPoint(), SketchCircle_5.results()[1]) +Sketch_3.setRadius(SketchCircle_5.results()[1], "38/2") +Sketch_3.setRadius(SketchCircle_6.results()[1], 10) + +### Create SketchProjection +SketchProjection_5 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]"), False) +SketchPoint_2 = SketchProjection_5.createdFeature() +Sketch_3.setCoincident(SketchLine_28.startPoint(), SketchAPI_Point(SketchPoint_2).coordinates()) + +### Create SketchProjection +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]"), False) +SketchLine_30 = SketchProjection_6.createdFeature() +Sketch_3.setDistance(SketchCircle_5.center(), SketchLine_30.result(), 56, True) + +### Create SketchLine +SketchLine_31 = Sketch_3.addLine(9, -55.99999999999999, 47, -55.99999999999999) +SketchLine_31.setAuxiliary(True) +Sketch_3.setCoincident(SketchLine_31.startPoint(), SketchCircle_5.results()[1]) +Sketch_3.setCoincident(SketchLine_31.endPoint(), SketchCircle_5.results()[1]) +Sketch_3.setHorizontal(SketchLine_31.result()) +Sketch_3.setCoincident(SketchLine_31.result(), SketchCircle_5.center()) +Sketch_3.setCoincident(SketchLine_28.endPoint(), SketchLine_31.startPoint()) +Sketch_3.setCoincident(SketchLine_29.startPoint(), SketchLine_31.endPoint()) + +### Create SketchProjection +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]"), False) +SketchLine_32 = SketchProjection_7.createdFeature() +Sketch_3.setDistance(SketchCircle_6.center(), SketchLine_32.result(), 28, True) + +### Create SketchLine +SketchLine_33 = Sketch_3.addLine(56.26584765647708, -18.93660937409168, 61, 0) +SketchLine_33.setAuxiliary(True) +Sketch_3.setCoincident(SketchLine_29.endPoint(), SketchLine_33.startPoint()) +Sketch_3.setCoincident(SketchLine_33.endPoint(), SketchLine_30.result()) +Sketch_3.setCollinear(SketchLine_33.result(), SketchLine_29.result()) +Sketch_3.setHorizontalDistance(SketchCircle_5.center(), SketchLine_33.endPoint(), 33) + +### Create SketchProjection +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_23][Extrusion_1_1/From_Face]"), False) +SketchLine_34 = SketchProjection_8.createdFeature() + +### Create SketchArc +SketchArc_15 = Sketch_3.addArc(80.51941016011038, -25, 56.26584765647708, -18.93660937409168, 80.519344153399, 0, True) +SketchArc_15.setName("SketchArc_16") +SketchArc_15.result().setName("SketchArc_16") +SketchArc_15.results()[1].setName("SketchArc_16_2") +Sketch_3.setCoincident(SketchLine_29.endPoint(), SketchArc_15.startPoint()) +Sketch_3.setTangent(SketchLine_29.result(), SketchArc_15.results()[1]) +Sketch_3.setCoincident(SketchLine_34.result(), SketchArc_15.endPoint()) +Sketch_3.setTangent(SketchLine_34.result(), SketchArc_15.results()[1]) +Sketch_3.setRadius(SketchArc_15.results()[1], 25) + +### Create SketchLine +SketchLine_35 = Sketch_3.addLine(0, 0, 80.519344153399, 0) +Sketch_3.setCoincident(SketchLine_28.startPoint(), SketchLine_35.startPoint()) +Sketch_3.setCoincident(SketchArc_15.endPoint(), SketchLine_35.endPoint()) +model.do() +Sketch_3.changeFacesOrder([[SketchCircle_6.results()[1]], + [SketchLine_28.result(), SketchCircle_5.results()[1], SketchCircle_5.results()[1], SketchLine_29.result(), SketchArc_15.results()[1], SketchLine_35.result()], + [SketchCircle_5.results()[1], SketchCircle_5.results()[1], SketchCircle_5.results()[1], SketchCircle_6.results()[1]] + ]) +model.do() + +### Create Extrusion +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_28r-SketchCircle_5_2r-SketchCircle_5_2r-SketchLine_29f-SketchArc_16_2r-SketchLine_35r")], model.selection(), 0, 10) + +### Create Extrusion +Extrusion_5 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2f-SketchCircle_5_2f-SketchCircle_5_2f-SketchCircle_6_2r")], model.selection(), 3, 13) + +### Create Symmetry +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_4"), model.selection("COMPOUND", "all-in-Extrusion_5")], model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Fuse +Fuse_1_objects_1 = [model.selection("COMPOUND", "all-in-Extrusion_1"), + model.selection("COMPOUND", "all-in-Extrusion_3"), + model.selection("COMPOUND", "all-in-ExtrusionCut_1"), + model.selection("COMPOUND", "all-in-Symmetry_1")] +Fuse_1 = model.addFuse(Part_1_doc, Fuse_1_objects_1, removeEdges = True, keepSubResults = True) + +model.do() + + +### Create Part +Part_2 = model.addPart(partSet) +Part_2_doc = Part_2.document() + +### Create Sketch +Sketch_4 = model.addSketch(Part_2_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_36 = Sketch_4.addLine(0, 62.99999999999999, 32, 63) +Sketch_4.setHorizontal(SketchLine_36.result()) + +### Create SketchLine +SketchLine_37 = Sketch_4.addLine(35, 66, 35, 87.99999999999999) +Sketch_4.setVertical(SketchLine_37.result()) + +### Create SketchLine +SketchLine_38 = Sketch_4.addLine(35, 87.99999999999999, 75.00000000000001, 87.99999999999999) +Sketch_4.setCoincident(SketchLine_37.endPoint(), SketchLine_38.startPoint()) +Sketch_4.setHorizontal(SketchLine_38.result()) + +### Create SketchLine +SketchLine_39 = Sketch_4.addLine(75.00000000000001, 87.99999999999999, 75.00000000000001, 78) +Sketch_4.setCoincident(SketchLine_38.endPoint(), SketchLine_39.startPoint()) +Sketch_4.setVertical(SketchLine_39.result()) + +### Create SketchArc +SketchArc_16 = Sketch_4.addArc(75.00000000000004, 71.99999999999689, 75.00000000000001, 78, 69, 71.99999999999613, False) +Sketch_4.setCoincident(SketchLine_39.endPoint(), SketchArc_16.startPoint()) + +### Create SketchLine +SketchLine_40 = Sketch_4.addLine(69, 71.99999999999613, 69, 52.00000000001324) +Sketch_4.setCoincident(SketchArc_16.endPoint(), SketchLine_40.startPoint()) +Sketch_4.setVertical(SketchLine_40.result()) + +### Create SketchArc +SketchArc_17 = Sketch_4.addArc(57, 52.00000000001324, 69, 52.00000000001324, 57.0000000000007, 40, True) +Sketch_4.setCoincident(SketchLine_40.endPoint(), SketchArc_17.startPoint()) +Sketch_4.setTangent(SketchLine_40.result(), SketchArc_17.results()[1]) + +### Create SketchArc +SketchArc_18 = Sketch_4.addArc(57, 27.99999999998618, 57.0000000000007, 40, 45, 27.99999999998618, False) +Sketch_4.setCoincident(SketchArc_17.endPoint(), SketchArc_18.startPoint()) +Sketch_4.setTangent(SketchArc_17.results()[1], SketchArc_18.results()[1]) + +### Create SketchLine +SketchLine_41 = Sketch_4.addLine(45, 27.99999999998618, 45, 0) +Sketch_4.setCoincident(SketchArc_18.endPoint(), SketchLine_41.startPoint()) + +### Create SketchProjection +SketchProjection_9 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_42 = SketchProjection_9.createdFeature() +Sketch_4.setCoincident(SketchLine_41.endPoint(), SketchLine_42.result()) +Sketch_4.setVertical(SketchLine_41.result()) + +### Create SketchLine +SketchLine_43 = Sketch_4.addLine(45, 0, 0, 0) +Sketch_4.setCoincident(SketchLine_41.endPoint(), SketchLine_43.startPoint()) +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_42).startPoint(), SketchLine_43.endPoint()) + +### Create SketchProjection +SketchProjection_10 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_44 = SketchProjection_10.createdFeature() +Sketch_4.setCoincident(SketchLine_36.startPoint(), SketchLine_44.result()) +Sketch_4.setTangent(SketchArc_18.results()[1], SketchLine_41.result()) +Sketch_4.setTangent(SketchArc_16.results()[1], SketchLine_40.result()) +Sketch_4.setLength(SketchLine_43.result(), 45) +Sketch_4.setDistance(SketchLine_36.startPoint(), SketchLine_39.result(), "150/2", True) +Sketch_4.setDistance(SketchLine_38.result(), SketchArc_16.startPoint(), 10, True) +Sketch_4.setRadius(SketchArc_16.results()[1], 6) +Sketch_4.setRadius(SketchArc_17.results()[1], 12) +Sketch_4.setEqual(SketchArc_17.results()[1], SketchArc_18.results()[1]) +Sketch_4.setDistance(SketchLine_42.result(), SketchArc_18.startPoint(), 40, True) +Sketch_4.setVerticalDistance(SketchArc_18.startPoint(), SketchArc_16.startPoint(), 38) +Sketch_4.setDistance(SketchLine_44.result(), SketchLine_40.startPoint(), "138/2", True) + +### Create SketchLine +SketchLine_45 = Sketch_4.addLine(-75.00000000000001, 77.99999999999693, -50.99999999999996, 78) +SketchLine_45.setName("SketchLine_17") +SketchLine_45.result().setName("SketchLine_17") +Sketch_4.setHorizontal(SketchLine_45.result()) + +### Create SketchArc +SketchArc_19 = Sketch_4.addArc(-50.99999999999996, 72, -50.99999999999996, 78, -44.99999999999996, 72, True) +SketchArc_19.setName("SketchArc_7") +SketchArc_19.result().setName("SketchArc_7") +SketchArc_19.results()[1].setName("SketchArc_7_2") +Sketch_4.setCoincident(SketchLine_45.endPoint(), SketchArc_19.startPoint()) +Sketch_4.setTangent(SketchLine_45.result(), SketchArc_19.results()[1]) + +### Create SketchArc +SketchArc_20 = Sketch_4.addArc(-28, 49.99999999999999, -28, 52.99999999999999, -25, 49.99999999999999, True) +SketchArc_20.setName("SketchArc_9") +SketchArc_20.result().setName("SketchArc_9") +SketchArc_20.results()[1].setName("SketchArc_9_2") + +### Create SketchLine +SketchLine_46 = Sketch_4.addLine(-25, 49.99999999999999, -25, 27.99999999999997) +SketchLine_46.setName("SketchLine_18") +SketchLine_46.result().setName("SketchLine_18") +Sketch_4.setCoincident(SketchArc_20.endPoint(), SketchLine_46.startPoint()) +Sketch_4.setVertical(SketchLine_46.result()) + +### Create SketchCircle +SketchCircle_7 = Sketch_4.addCircle(0, 27.99999999999997, 25) +Sketch_4.setCoincident(SketchLine_44.result(), SketchCircle_7.center()) +Sketch_4.setCoincident(SketchLine_46.endPoint(), SketchCircle_7.results()[1]) + +### Create SketchCircle +SketchCircle_8 = Sketch_4.addCircle(0, 27.99999999999997, 16) +Sketch_4.setCoincident(SketchCircle_7.center(), SketchCircle_8.center()) +Sketch_4.setRadius(SketchArc_19.results()[1], 6) +Sketch_4.setRadius(SketchArc_20.results()[1], 3) +Sketch_4.setTangent(SketchArc_20.results()[1], SketchLine_46.result()) +Sketch_4.setRadius(SketchCircle_7.results()[1], 25) +Sketch_4.setRadius(SketchCircle_8.results()[1], 16) + +### Create SketchLine +SketchLine_47 = Sketch_4.addLine(-44.99999999999996, 72, -44.99999999999998, 64.99999999999999) +SketchLine_47.setName("SketchLine_19") +SketchLine_47.result().setName("SketchLine_19") +Sketch_4.setCoincident(SketchArc_19.endPoint(), SketchLine_47.startPoint()) +Sketch_4.setVertical(SketchLine_47.result()) + +### Create SketchLine +SketchLine_48 = Sketch_4.addLine(-28, 52.99999999999999, -32.99999999999998, 52.99999999999999) +SketchLine_48.setName("SketchLine_20") +SketchLine_48.result().setName("SketchLine_20") +Sketch_4.setCoincident(SketchArc_20.startPoint(), SketchLine_48.startPoint()) +Sketch_4.setHorizontal(SketchLine_48.result()) + +### Create SketchArc +SketchArc_21 = Sketch_4.addArc(-32.99999999999998, 64.99999999999999, -44.99999999999998, 64.99999999999999, -32.99999999999998, 52.99999999999999, False) +SketchArc_21.setName("SketchArc_10") +SketchArc_21.result().setName("SketchArc_10") +SketchArc_21.results()[1].setName("SketchArc_10_2") +Sketch_4.setCoincident(SketchLine_47.endPoint(), SketchArc_21.startPoint()) +Sketch_4.setTangent(SketchLine_47.result(), SketchArc_21.results()[1]) +Sketch_4.setCoincident(SketchLine_48.result(), SketchArc_21.endPoint()) +Sketch_4.setTangent(SketchArc_19.results()[1], SketchLine_47.result()) +Sketch_4.setTangent(SketchArc_21.results()[1], SketchLine_48.result()) +Sketch_4.setTangent(SketchLine_48.result(), SketchArc_20.results()[1]) +Sketch_4.setRadius(SketchArc_21.results()[1], 12) +Sketch_4.setCoincident(SketchArc_21.endPoint(), SketchLine_48.endPoint()) + +### Create SketchLine +SketchLine_49 = Sketch_4.addLine(-25, 27.99999999999997, 0, 27.99999999999997) +SketchLine_49.setName("SketchLine_21") +SketchLine_49.result().setName("SketchLine_21") +SketchLine_49.setAuxiliary(True) +Sketch_4.setCoincident(SketchLine_46.endPoint(), SketchLine_49.startPoint()) +Sketch_4.setCoincident(SketchCircle_7.center(), SketchLine_49.endPoint()) +Sketch_4.setHorizontal(SketchLine_49.result()) + +### Create SketchArc +SketchArc_22 = Sketch_4.addArc(32, 66, 32, 63, 35, 66, False) +SketchArc_22.setName("SketchArc_11") +SketchArc_22.result().setName("SketchArc_11") +SketchArc_22.results()[1].setName("SketchArc_11_2") + +### Create SketchConstraintMirror +SketchConstraintMirror_4_objects = [SketchLine_39.result(), SketchLine_40.result(), SketchLine_36.result(), SketchLine_38.result(), SketchLine_37.result(), SketchLine_41.result(), SketchLine_43.result(), SketchArc_16.results()[1], SketchArc_18.results()[1], SketchArc_17.results()[1], SketchArc_22.results()[1]] +SketchConstraintMirror_4 = Sketch_4.addMirror(SketchLine_44.result(), SketchConstraintMirror_4_objects) +[SketchLine_50, SketchLine_51, SketchLine_52, SketchLine_53, SketchLine_54, SketchLine_55, SketchLine_56, SketchArc_23, SketchArc_24, SketchArc_25, SketchArc_26] = SketchConstraintMirror_4.mirrored() +SketchArc_26.setName("SketchArc_12") +SketchArc_26.result().setName("SketchArc_12") +SketchArc_26.results()[1].setName("SketchArc_12_2") +SketchArc_25.setName("SketchArc_6") +SketchArc_25.result().setName("SketchArc_6") +SketchArc_25.results()[1].setName("SketchArc_6_2") +SketchArc_24.setName("SketchArc_5") +SketchArc_24.result().setName("SketchArc_5") +SketchArc_24.results()[1].setName("SketchArc_5_2") +SketchArc_23.setName("SketchArc_4") +SketchArc_23.result().setName("SketchArc_4") +SketchArc_23.results()[1].setName("SketchArc_4_2") +SketchLine_56.setName("SketchLine_16") +SketchLine_56.result().setName("SketchLine_16") +SketchLine_55.setName("SketchLine_15") +SketchLine_55.result().setName("SketchLine_15") +SketchLine_54.setName("SketchLine_14") +SketchLine_54.result().setName("SketchLine_14") +SketchLine_53.setName("SketchLine_13") +SketchLine_53.result().setName("SketchLine_13") +SketchLine_52.setName("SketchLine_12") +SketchLine_52.result().setName("SketchLine_12") +SketchLine_51.setName("SketchLine_11") +SketchLine_51.result().setName("SketchLine_11") +SketchLine_50.setName("SketchLine_10") +SketchLine_50.result().setName("SketchLine_10") +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_50).endPoint(), SketchLine_45.startPoint()) +Sketch_4.setDistance(SketchLine_47.result(), SketchAPI_Line(SketchLine_52).startPoint(), 45, True) +Sketch_4.setDistance(SketchLine_53.result(), SketchLine_49.endPoint(), 60, True) +Sketch_4.setDistance(SketchLine_52.result(), SketchLine_48.startPoint(), 10, True) + +### Create SketchPoint +SketchPoint_3 = Sketch_4.addPoint(35, 62.99999999999999) +SketchPoint_3.setAuxiliary(True) +Sketch_4.setCoincident(SketchPoint_3.coordinates(), SketchLine_36.result()) +Sketch_4.setCoincident(SketchPoint_3.coordinates(), SketchLine_37.result()) +Sketch_4.setDistance(SketchLine_36.startPoint(), SketchPoint_3.coordinates(), 35, False) +Sketch_4.setDistance(SketchPoint_3.coordinates(), SketchLine_37.endPoint(), 25, False) +Sketch_4.setCoincident(SketchArc_22.startPoint(), SketchLine_36.endPoint()) +Sketch_4.setCoincident(SketchArc_22.endPoint(), SketchLine_37.startPoint()) +Sketch_4.setTangent(SketchArc_22.results()[1], SketchLine_36.result()) +Sketch_4.setTangent(SketchArc_22.results()[1], SketchLine_37.result()) +Sketch_4.setRadius(SketchArc_22.results()[1], 3) + +### Create SketchConstraintMirror +SketchConstraintMirror_5_objects = [SketchLine_45.result(), SketchArc_19.results()[1], SketchLine_47.result(), SketchArc_21.results()[1], SketchLine_48.result(), SketchArc_20.results()[1], SketchLine_46.result()] +SketchConstraintMirror_5 = Sketch_4.addMirror(SketchLine_44.result(), SketchConstraintMirror_5_objects) +[SketchLine_57, SketchArc_27, SketchLine_58, SketchArc_28, SketchLine_59, SketchArc_29, SketchLine_60] = SketchConstraintMirror_5.mirrored() +SketchArc_29.setName("SketchArc_15") +SketchArc_29.result().setName("SketchArc_15") +SketchArc_29.results()[1].setName("SketchArc_15_2") +SketchArc_28.setName("SketchArc_14") +SketchArc_28.result().setName("SketchArc_14") +SketchArc_28.results()[1].setName("SketchArc_14_2") +SketchArc_27.setName("SketchArc_13") +SketchArc_27.result().setName("SketchArc_13") +SketchArc_27.results()[1].setName("SketchArc_13_2") +model.do() + +### Create Extrusion +Extrusion_6 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_22f-SketchArc_13_2f-SketchLine_23f-SketchArc_14_2r-SketchLine_24r-SketchArc_15_2f-SketchLine_25f-SketchCircle_1_2r-SketchLine_18r-SketchArc_9_2f-SketchLine_20f-SketchArc_10_2r-SketchLine_19r-SketchArc_7_2f-SketchLine_17r-SketchArc_4_2r-SketchLine_11f-SketchArc_6_2f-SketchArc_5_2r-SketchLine_15f-SketchLine_16f-SketchLine_8r-SketchLine_6r-SketchArc_3_2r-SketchArc_2_2f-SketchLine_5r-SketchArc_1_2r")], model.selection(), 10, 0) + +### Create Extrusion +Extrusion_7 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_12f-SketchArc_12_2r-SketchLine_14f-SketchLine_13f-SketchLine_10f-SketchLine_17f-SketchArc_7_2r-SketchLine_19f-SketchArc_10_2f-SketchLine_20r-SketchArc_9_2r-SketchLine_18f-SketchCircle_1_2r-SketchLine_25r-SketchArc_15_2r-SketchLine_24f-SketchArc_14_2f-SketchLine_23r-SketchArc_13_2r-SketchLine_22r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchArc_11_2r-SketchLine_1r")], model.selection(), 35, 0) + +### Create Extrusion +Extrusion_8 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f-SketchCircle_1_2f-SketchCircle_2_2r")], model.selection(), 45, 0) + +### Create Sketch +Sketch_5 = model.addSketch(Part_2_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_1/SketchLine_22")) + +### Create SketchCircle +SketchCircle_9 = Sketch_5.addCircle(63, 23, 5) +Sketch_5.setRadius(SketchCircle_9.results()[1], 5) + +### Create SketchProjection +SketchProjection_11 = Sketch_5.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_61 = SketchProjection_11.createdFeature() +Sketch_5.setDistance(SketchCircle_9.center(), SketchLine_61.result(), "126/2", True) + +### Create SketchProjection +SketchProjection_12 = Sketch_5.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_62 = SketchProjection_12.createdFeature() +Sketch_5.setDistance(SketchCircle_9.center(), SketchLine_62.result(), 23, True) + +### Create SketchConstraintMirror +SketchConstraintMirror_6 = Sketch_5.addMirror(SketchLine_61.result(), [SketchCircle_9.results()[1]]) +[SketchCircle_10] = SketchConstraintMirror_6.mirrored() +model.do() + +### Create ExtrusionCut +ExtrusionCut_2 = model.addExtrusionCut(Part_2_doc, [model.selection("COMPOUND", "all-in-Sketch_2")], model.selection(), 0, 10, [model.selection("SOLID", "Extrusion_2_1")]) + +### Create Sketch +Sketch_6 = model.addSketch(Part_2_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6")) + +### Create SketchLine +SketchLine_63 = Sketch_6.addLine(0, 0, 9, -55.99999999999999) + +### Create SketchCircle +SketchCircle_11 = Sketch_6.addCircle(28, -56, 19) +Sketch_6.setCoincident(SketchLine_63.endPoint(), SketchCircle_11.results()[1]) + +### Create SketchCircle +SketchCircle_12 = Sketch_6.addCircle(28, -56, 10) +Sketch_6.setCoincident(SketchCircle_11.center(), SketchCircle_12.center()) + +### Create SketchLine +SketchLine_64 = Sketch_6.addLine(47, -55.99999999999999, 56.26584765647708, -18.93660937409168) +Sketch_6.setCoincident(SketchLine_64.startPoint(), SketchCircle_11.results()[1]) +Sketch_6.setRadius(SketchCircle_11.results()[1], "38/2") +Sketch_6.setRadius(SketchCircle_12.results()[1], 10) + +### Create SketchProjection +SketchProjection_13 = Sketch_6.addProjection(model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]"), False) +SketchPoint_4 = SketchProjection_13.createdFeature() +Sketch_6.setCoincident(SketchLine_63.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates()) + +### Create SketchProjection +SketchProjection_14 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/From_Face]"), False) +SketchLine_65 = SketchProjection_14.createdFeature() +Sketch_6.setDistance(SketchCircle_11.center(), SketchLine_65.result(), 56, True) + +### Create SketchLine +SketchLine_66 = Sketch_6.addLine(9, -55.99999999999999, 47, -55.99999999999999) +SketchLine_66.setAuxiliary(True) +Sketch_6.setCoincident(SketchLine_66.startPoint(), SketchCircle_11.results()[1]) +Sketch_6.setCoincident(SketchLine_66.endPoint(), SketchCircle_11.results()[1]) +Sketch_6.setHorizontal(SketchLine_66.result()) +Sketch_6.setCoincident(SketchLine_66.result(), SketchCircle_11.center()) +Sketch_6.setCoincident(SketchLine_63.endPoint(), SketchLine_66.startPoint()) +Sketch_6.setCoincident(SketchLine_64.startPoint(), SketchLine_66.endPoint()) + +### Create SketchProjection +SketchProjection_15 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_8][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6]"), False) +SketchLine_67 = SketchProjection_15.createdFeature() +Sketch_6.setDistance(SketchCircle_12.center(), SketchLine_67.result(), 28, True) + +### Create SketchLine +SketchLine_68 = Sketch_6.addLine(56.26584765647708, -18.93660937409168, 61, 0) +SketchLine_68.setAuxiliary(True) +Sketch_6.setCoincident(SketchLine_64.endPoint(), SketchLine_68.startPoint()) +Sketch_6.setCoincident(SketchLine_68.endPoint(), SketchLine_65.result()) +Sketch_6.setCollinear(SketchLine_68.result(), SketchLine_64.result()) +Sketch_6.setHorizontalDistance(SketchCircle_11.center(), SketchLine_68.endPoint(), 33) + +### Create SketchProjection +SketchProjection_16 = Sketch_6.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_23][Extrusion_1_1/From_Face]"), False) +SketchLine_69 = SketchProjection_16.createdFeature() + +### Create SketchArc +SketchArc_30 = Sketch_6.addArc(80.51941016011038, -25, 56.26584765647708, -18.93660937409168, 80.519344153399, 0, True) +SketchArc_30.setName("SketchArc_16") +SketchArc_30.result().setName("SketchArc_16") +SketchArc_30.results()[1].setName("SketchArc_16_2") +Sketch_6.setCoincident(SketchLine_64.endPoint(), SketchArc_30.startPoint()) +Sketch_6.setTangent(SketchLine_64.result(), SketchArc_30.results()[1]) +Sketch_6.setCoincident(SketchLine_69.result(), SketchArc_30.endPoint()) +Sketch_6.setTangent(SketchLine_69.result(), SketchArc_30.results()[1]) +Sketch_6.setRadius(SketchArc_30.results()[1], 25) + +### Create SketchLine +SketchLine_70 = Sketch_6.addLine(0, 0, 80.519344153399, 0) +Sketch_6.setCoincident(SketchLine_63.startPoint(), SketchLine_70.startPoint()) +Sketch_6.setCoincident(SketchArc_30.endPoint(), SketchLine_70.endPoint()) +model.do() +Sketch_6.changeFacesOrder([[SketchCircle_12.results()[1]], + [SketchLine_63.result(), SketchCircle_11.results()[1], SketchCircle_11.results()[1], SketchLine_64.result(), SketchArc_30.results()[1], SketchLine_70.result()], + [SketchCircle_11.results()[1], SketchCircle_11.results()[1], SketchCircle_11.results()[1], SketchCircle_12.results()[1]] + ]) +model.do() + +### Create Extrusion +Extrusion_9 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_28r-SketchCircle_5_2r-SketchCircle_5_2r-SketchLine_29f-SketchArc_16_2r-SketchLine_35r")], model.selection(), 0, 10) + +### Create Extrusion +Extrusion_10 = model.addExtrusion(Part_2_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2f-SketchCircle_5_2f-SketchCircle_5_2f-SketchCircle_6_2r")], model.selection(), 3, 13) + +### Create Symmetry +Symmetry_2 = model.addSymmetry(Part_2_doc, [model.selection("COMPOUND", "all-in-Extrusion_4"), model.selection("COMPOUND", "all-in-Extrusion_5")], model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Fuse +Fuse_2_objects_1 = [model.selection("SOLID", "Extrusion_1_1"), + model.selection("SOLID", "Extrusion_3_1"), + model.selection("SOLID", "ExtrusionCut_1_1"), + model.selection("COMPOUND", "Symmetry_1_1"), + model.selection("COMPOUND", "Symmetry_1_2")] +Fuse_2 = model.addFuse(Part_2_doc, Fuse_2_objects_1, removeEdges = True, keepSubResults = True) + +model.do() + +model.end() + + +model.checkResult(Fuse_1, model, 1, [0], [1], [58], [326], [652]) +model.testResultsVolumes(Fuse_1, [244644.913443274]) +model.checkResult(Fuse_2, model, 1, [0], [1], [58], [326], [652]) +model.testResultsVolumes(Fuse_2, [244644.913443274]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20027.py b/src/FeaturesPlugin/Test/Test20027.py new file mode 100644 index 000000000..21d21c301 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20027.py @@ -0,0 +1,285 @@ +# Copyright (C) 2020 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 + +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(0, 0, 0, -99) +SketchLine_1.setAuxiliary(True) +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()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) +SketchLine_2 = Sketch_1.addLine(0, 0, -44, 0) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.startPoint()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result()) +SketchLine_3 = Sketch_1.addLine(-44, 0, -44, -57.48528137423859) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result()) +SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_2.result(), 44) +SketchArc_1 = Sketch_1.addArc(-31, -57.48528137423859, -44, -57.48528137423859, -40.19238815542511, -66.6776695296637, False) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchArc_1.startPoint()) +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_3.result(), SketchArc_1.results()[1]) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 13) +SketchLine_4 = Sketch_1.addLine(-40.19238815542511, -66.6776695296637, -13.4350288425444, -93.43502884254441) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_4.startPoint()) +SketchArc_2 = Sketch_1.addArc(0, -80, -13.4350288425444, -93.43502884254441, 0, -99, False) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_2.center()) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchArc_2.startPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_2.endPoint()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_4.result()) +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchLine_4.result(), SketchArc_2.results()[1]) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.endPoint()) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 19) +SketchLine_5 = Sketch_1.addLine(0, -80, -13.4350288425444, -93.43502884254441) +SketchLine_5.setName("SketchLine_6") +SketchLine_5.result().setName("SketchLine_6") +SketchLine_5.setAuxiliary(True) +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_5.startPoint()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_12") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.endPoint()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_13") +SketchConstraintAngle_1 = Sketch_1.setAngle(SketchLine_5.result(), SketchLine_1.result(), 45, type = "Supplementary") +SketchConstraintMirror_1_objects = [SketchLine_2.result(), SketchLine_3.result(), SketchArc_1.results()[1], SketchLine_4.result(), SketchArc_2.results()[1]] +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), SketchConstraintMirror_1_objects) +[SketchLine_6, SketchLine_7, SketchArc_3, SketchLine_8, SketchArc_4] = SketchConstraintMirror_1.mirrored() +SketchLine_8.setName("SketchLine_9") +SketchLine_8.result().setName("SketchLine_9") +SketchLine_7.setName("SketchLine_8") +SketchLine_7.result().setName("SketchLine_8") +SketchLine_6.setName("SketchLine_7") +SketchLine_6.result().setName("SketchLine_7") +SketchCircle_1 = Sketch_1.addCircle(-25, -44, 5) +SketchCircle_1.setName("SketchCircle_2") +SketchCircle_1.result().setName("SketchCircle_2") +SketchCircle_1.results()[1].setName("SketchCircle_2_2") +SketchCircle_2 = Sketch_1.addCircle(25, -44, 5) +SketchCircle_2.setName("SketchCircle_3") +SketchCircle_2.result().setName("SketchCircle_3") +SketchCircle_2.results()[1].setName("SketchCircle_3_2") +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchCircle_1.results()[1], SketchCircle_2.results()[1]) +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5) +SketchConstraintRadius_3.setName("SketchConstraintRadius_7") +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchCircle_1.center(), SketchCircle_2.center(), 50, True) +SketchConstraintDistance_1.setName("SketchConstraintDistance_4") +SketchLine_9 = Sketch_1.addLine(-25, -44, 25, -44) +SketchLine_9.setName("SketchLine_21") +SketchLine_9.result().setName("SketchLine_21") +SketchLine_9.setAuxiliary(True) +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_9.startPoint()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_28") +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_9.endPoint()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_29") +SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_9.result()) +SketchConstraintHorizontal_2.setName("SketchConstraintHorizontal_4") +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchAPI_Arc(SketchArc_4).center(), SketchLine_9.result(), 36, True) +SketchConstraintDistance_2.setName("SketchConstraintDistance_5") +SketchPoint_2 = Sketch_1.addPoint(2.896598636358403e-31, -44) +SketchPoint_2.setName("SketchPoint_4") +SketchPoint_2.result().setName("SketchPoint_4") +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_9.result()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_30") +SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchLine_9.result(), SketchPoint_2.coordinates()) +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_31") +SketchConstraintDistance_3 = Sketch_1.setDistance(SketchLine_6.result(), SketchLine_5.startPoint(), 80, True) +SketchConstraintDistance_3.setName("SketchConstraintDistance_8") +model.do() +Sketch_1.changeFacesOrder([[SketchLine_2.result(), SketchLine_3.result(), SketchArc_1.results()[1], SketchLine_4.result(), SketchArc_2.results()[1], SketchArc_4.results()[1], SketchLine_8.result(), SketchArc_3.results()[1], SketchLine_7.result(), SketchLine_6.result(), SketchCircle_1.results()[1], SketchCircle_2.results()[1]], + [SketchCircle_2.results()[1]], + [SketchCircle_1.results()[1]] + ]) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchLine_3f-SketchArc_1_2f-SketchLine_4f-SketchArc_2_2f-SketchArc_4_2f-SketchLine_9r-SketchArc_3_2f-SketchLine_8r-SketchLine_7r-SketchCircle_2_2r-SketchCircle_3_2r")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchLine_10 = Sketch_2.addLine(0, 0, 0, -16) +SketchLine_10.setName("SketchLine_10") +SketchLine_10.result().setName("SketchLine_10") +SketchLine_10.setAuxiliary(True) +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_7][Extrusion_1_1/To_Face]"), False) +SketchPoint_3 = SketchProjection_2.createdFeature() +SketchPoint_3.setName("SketchPoint_2") +SketchPoint_3.result().setName("SketchPoint_2") +SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_10.startPoint(), SketchPoint_3.result()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_14") +SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_10.result()) +SketchLine_11 = Sketch_2.addLine(-44, 0, -44, -13) +SketchLine_11.setName("SketchLine_11") +SketchLine_11.result().setName("SketchLine_11") +SketchProjection_3 = 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_4 = SketchProjection_3.createdFeature() +SketchPoint_4.setName("SketchPoint_3") +SketchPoint_4.result().setName("SketchPoint_3") +SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_11.startPoint(), SketchPoint_4.result()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_15") +SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_11.result()) +SketchLine_12 = Sketch_2.addLine(-44, -13, -21.99999999999997, -13) +SketchLine_12.setName("SketchLine_12") +SketchLine_12.result().setName("SketchLine_12") +SketchConstraintCoincidence_18 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_16") +SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_12.result()) +SketchConstraintHorizontal_3.setName("SketchConstraintHorizontal_2") +SketchArc_5 = Sketch_2.addArc(-22, -16.00000000000039, -21.99999999999997, -13, -19, -16, True) +SketchConstraintCoincidence_19 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchArc_5.startPoint()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_17") +SketchConstraintTangent_4 = Sketch_2.setTangent(SketchLine_12.result(), SketchArc_5.results()[1]) +SketchLine_13 = Sketch_2.addLine(-19, -16, 0, -16) +SketchLine_13.setName("SketchLine_13") +SketchLine_13.result().setName("SketchLine_13") +SketchConstraintCoincidence_20 = Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchLine_13.startPoint()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_18") +SketchConstraintCoincidence_21 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_10.result()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_19") +SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_13.result()) +SketchConstraintHorizontal_4.setName("SketchConstraintHorizontal_3") +SketchConstraintRadius_4 = Sketch_2.setRadius(SketchArc_5.results()[1], 3) +SketchConstraintRadius_4.setName("SketchConstraintRadius_3") +SketchConstraintLength_2 = Sketch_2.setLength(SketchLine_13.result(), "38/2") +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchLine_13.result(), SketchLine_12.endPoint(), 3, True) +SketchConstraintDistance_4.setName("SketchConstraintDistance_2") +SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_11.result(), 13) +SketchConstraintCoincidence_22 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_10.endPoint()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_20") +SketchLine_14 = Sketch_2.addLine(-44, 0, -25, 0) +SketchLine_14.setName("SketchLine_14") +SketchLine_14.result().setName("SketchLine_14") +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_11.startPoint(), SketchLine_14.startPoint()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_21") +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"), False) +SketchLine_15 = SketchProjection_4.createdFeature() +SketchLine_15.setName("SketchLine_15") +SketchLine_15.result().setName("SketchLine_15") +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.result()) +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_22") +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_16 = SketchProjection_5.createdFeature() +SketchLine_16.setName("SketchLine_16") +SketchLine_16.result().setName("SketchLine_16") +SketchArc_6 = Sketch_2.addArc(-25, 6, -25, 0, -19, 6, False) +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchArc_6.startPoint()) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_23") +SketchConstraintTangent_5 = Sketch_2.setTangent(SketchLine_14.result(), SketchArc_6.results()[1]) +SketchArc_7 = Sketch_2.addArc(0, 5.999999999999997, -19, 6, 0, 25, True) +SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchArc_6.endPoint(), SketchArc_7.startPoint()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_24") +SketchConstraintTangent_6 = Sketch_2.setTangent(SketchArc_6.results()[1], SketchArc_7.results()[1]) +SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchArc_7.endPoint(), SketchLine_16.result()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_25") +SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchArc_7.center(), SketchLine_16.result()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_26") +SketchConstraintRadius_5 = Sketch_2.setRadius(SketchArc_7.results()[1], 19) +SketchConstraintRadius_5.setName("SketchConstraintRadius_4") +SketchConstraintRadius_6 = Sketch_2.setRadius(SketchArc_6.results()[1], 6) +SketchConstraintRadius_6.setName("SketchConstraintRadius_5") +SketchConstraintDistance_5 = Sketch_2.setDistance(SketchArc_7.center(), SketchLine_12.result(), 19, True) +SketchConstraintDistance_5.setName("SketchConstraintDistance_3") +SketchConstraintMirror_2_objects = [SketchArc_5.results()[1], SketchLine_12.result(), SketchLine_11.result(), SketchArc_6.results()[1], SketchArc_7.results()[1], SketchLine_13.result(), SketchLine_14.result()] +SketchConstraintMirror_2 = Sketch_2.addMirror(SketchLine_10.result(), SketchConstraintMirror_2_objects) +[SketchArc_8, SketchLine_17, SketchLine_18, SketchArc_9, SketchArc_10, SketchLine_19, SketchLine_20] = SketchConstraintMirror_2.mirrored() +SketchLine_20.setName("SketchLine_20") +SketchLine_20.result().setName("SketchLine_20") +SketchLine_19.setName("SketchLine_19") +SketchLine_19.result().setName("SketchLine_19") +SketchLine_18.setName("SketchLine_18") +SketchLine_18.result().setName("SketchLine_18") +SketchLine_17.setName("SketchLine_17") +SketchLine_17.result().setName("SketchLine_17") +SketchCircle_3 = Sketch_2.addCircle(0, 5.999999999999997, 9.5) +SketchCircle_3.setName("SketchCircle_1") +SketchCircle_3.result().setName("SketchCircle_1") +SketchCircle_3.results()[1].setName("SketchCircle_1_2") +SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchArc_7.center(), SketchCircle_3.center()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_27") +SketchConstraintRadius_7 = Sketch_2.setRadius(SketchCircle_3.results()[1], "19/2") +SketchConstraintRadius_7.setName("SketchConstraintRadius_6") +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_11f-SketchLine_12f-SketchArc_5_2r-SketchLine_13f-SketchLine_19r-SketchArc_8_2r-SketchLine_17r-SketchLine_18r-SketchLine_20f-SketchArc_9_2r-SketchArc_10_2f-SketchArc_7_2f-SketchArc_6_2r-SketchLine_14r-SketchCircle_1_2r")], model.selection(), 40, 10) +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) +SketchLine_21 = Sketch_3.addLine(-16, 50, -20, 50) +SketchLine_21.setName("SketchLine_22") +SketchLine_21.result().setName("SketchLine_22") +SketchProjection_6 = Sketch_3.addProjection(model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_13][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_19][Extrusion_2_1/To_Face]"), False) +SketchPoint_5 = SketchProjection_6.createdFeature() +SketchConstraintCoincidence_30 = Sketch_3.setCoincident(SketchLine_21.startPoint(), SketchPoint_5.result()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_32") +SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_21.result()) +SketchLine_22 = Sketch_3.addLine(-20, 50, -80, 10) +SketchLine_22.setName("SketchLine_23") +SketchLine_22.result().setName("SketchLine_23") +SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint()) +SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_33") +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchArc_5_2][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_13]"), True) +SketchLine_23 = SketchProjection_7.createdFeature() +SketchLine_23.setName("SketchLine_24") +SketchLine_23.result().setName("SketchLine_24") +SketchLine_24 = Sketch_3.addLine(-16, 9.999999999999996, -80, 10) +SketchLine_24.setName("SketchLine_25") +SketchLine_24.result().setName("SketchLine_25") +SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_24.startPoint(), SketchLine_23.result()) +SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_34") +SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_24.result()) +SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchLine_22.endPoint(), SketchLine_24.endPoint()) +SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_35") +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_25 = SketchProjection_8.createdFeature() +SketchLine_25.setName("SketchLine_26") +SketchLine_25.result().setName("SketchLine_26") +SketchConstraintDistance_6 = Sketch_3.setDistance(SketchLine_22.startPoint(), SketchLine_25.result(), 20, True) +SketchConstraintDistance_6.setName("SketchConstraintDistance_6") +SketchConstraintDistance_7 = Sketch_3.setDistance(SketchAPI_Point(SketchPoint_5).coordinates(), SketchLine_24.startPoint(), 40, True) +SketchConstraintDistance_7.setName("SketchConstraintDistance_7") +SketchConstraintLength_4 = Sketch_3.setLength(SketchLine_24.result(), "67-3") +model.do() +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchLine_22r-SketchLine_23f-SketchLine_25r-SketchProjection_7f")], model.selection(), 5, 5) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), [model.selection("SOLID", "Extrusion_1_1")]) +Fuse_1_objects_1 = [model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "ExtrusionCut_1_1"), model.selection("SOLID", "Extrusion_3_1")] +Fuse_1 = model.addFuse(Part_1_doc, Fuse_1_objects_1, removeEdges = True, keepSubResults = True) +model.testHaveNamingSubshapes(Fuse_1, model, Part_1_doc) +model.end() + +from GeomAPI import GeomAPI_Shape +model.testNbResults(Fuse_1, 1) +model.testNbSubResults(Fuse_1, [0]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.FACE, [27]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.EDGE, [150]) +model.testNbSubShapes(Fuse_1, GeomAPI_Shape.VERTEX, [300]) +model.testResultsVolumes(Fuse_1, [162690.939657109178369864821434021]) + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() + +# Check that the features are not in error +for i in range(Part_1_doc.size("Features")): + feature = objectToFeature(Part_1_doc.object("Features", i)) + name = feature.name() + error = feature.error() + assert(error == ''), "The feature {0} is in error: {1}".format(name, error) + assert(aFactory.validate(feature)), "The feature {0} is in error: {1}".format(name, error) + +assert(Part_1_doc.size("Groups") == 3) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20245_1.py b/src/FeaturesPlugin/Test/Test20245_1.py new file mode 100644 index 000000000..e77f4f5e7 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20245_1.py @@ -0,0 +1,248 @@ +# Copyright (C) 2020 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 + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "r_ext", "80") +model.addParameter(Part_1_doc, "r_int", "60") +model.addParameter(Part_1_doc, "r_cut", "30") +model.addParameter(Part_1_doc, "h", "200") + +### Create Cylinder +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_ext", "h") + +### Create Cylinder +Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "r_int", "h") + +### Create Sphere +Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_ext") + +### Create Sphere +Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), "r_int") + +### Create Rotation +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_1")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True) + +### Create Rotation +Rotation_2 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Sphere_2")], axis = model.selection("EDGE", "PartSet/OY"), angle = 90, keepSubResults = True) + +### Create Translation +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("COMPOUND", "Rotation_1_1"), model.selection("COMPOUND", "Rotation_2_1")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "h", keepSubResults = True) + +### Create Fuse +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Translation_1_1_1"), model.selection("SOLID", "Cylinder_1_1")], keepSubResults = True) + +### Create Fuse +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_2_1"), model.selection("SOLID", "Translation_1_2_1")], keepSubResults = True) + +### Create Partition +Partition_1 = model.addPartition(Part_1_doc, [model.selection("SOLID", "Fuse_1_1"), model.selection("SOLID", "Fuse_2_1")], keepSubResults = True) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(0, 30, -30, 0) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(-30, 0, 0, -30) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(0, -30, 30, 0) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_5 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.result()) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(30, 0, 0, 30) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_6.startPoint()) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) + +### Create SketchLine +SketchLine_7 = Sketch_1.addLine(-30, 0, -110, 0) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_7.startPoint()) +Sketch_1.setHorizontal(SketchLine_7.result()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(0, -30, 0, -110) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_8.startPoint()) +Sketch_1.setVertical(SketchLine_8.result()) + +### Create SketchLine +SketchLine_9 = Sketch_1.addLine(0, 30, 0, 110) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_9.startPoint()) +Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_10 = Sketch_1.addLine(30, 0, 110, 0) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_10.startPoint()) +Sketch_1.setCoincident(SketchLine_10.endPoint(), SketchLine_5.result()) +Sketch_1.setEqual(SketchLine_10.result(), SketchLine_7.result()) +Sketch_1.setEqual(SketchLine_9.result(), SketchLine_8.result()) +Sketch_1.setParallel(SketchLine_1.result(), SketchLine_4.result()) +Sketch_1.setParallel(SketchLine_6.result(), SketchLine_3.result()) +Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_2.result()) +Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_3.result()) +Sketch_1.setLength(SketchLine_7.result(), "r_ext") +Sketch_1.setDistance(SketchLine_7.startPoint(), SketchLine_2.result(), "r_int/2", True) +Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_5.result()) +Sketch_1.setEqual(SketchLine_9.result(), SketchLine_10.result()) +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection(), "h", 0, "Edges") + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), "h", False) + +### Create Split +Split_1 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Partition_1_1")], [model.selection("FACE", "Plane_1"), model.selection("COMPOUND", "Extrusion_1_1")], keepSubResults = True) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchProjection +SketchProjection_3 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_10/Modified_Edge&Extrusion_1_1_1/To_Edge"), True) +SketchLine_11 = SketchProjection_3.createdFeature() + +### Create SketchProjection +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_9/Modified_Edge&Extrusion_1_1_4/To_Edge"), True) +SketchLine_12 = SketchProjection_4.createdFeature() + +### Create SketchProjection +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_8/Modified_Edge&Extrusion_1_1_3/To_Edge"), True) +SketchLine_13 = SketchProjection_5.createdFeature() + +### Create SketchProjection +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_2/To_Edge"), True) +SketchLine_14 = SketchProjection_6.createdFeature() +model.do() + +### Create Extrusion +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection(), "r_cut/sqrt(2)", 0, "Faces|Wires") + +### Create Sketch +Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) + +### Create SketchProjection +SketchProjection_7 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_5]"), True) +SketchLine_15 = SketchProjection_7.createdFeature() + +### Create SketchProjection +SketchProjection_8 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_7/Modified_Edge&Extrusion_1_1_6/To_Edge"), True) +SketchLine_16 = SketchProjection_8.createdFeature() + +### Create SketchProjection +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "Split_1_1_2/Modified_Edge&Extrusion_1_1_6/To_Edge"), True) +SketchLine_17 = SketchProjection_9.createdFeature() + +### Create SketchLine +SketchLine_18 = Sketch_3.addLine(-30, 221.2132034355964, -136.4686528504195, 327.681856286016) +Sketch_3.setCoincident(SketchAPI_Line(SketchLine_15).endPoint(), SketchLine_18.startPoint()) + +### Create SketchLine +SketchLine_19 = Sketch_3.addLine(-136.4686528504195, 327.681856286016, -80, 200) +Sketch_3.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) +Sketch_3.setCoincident(SketchAPI_Line(SketchLine_17).endPoint(), SketchLine_19.endPoint()) + +### Create SketchConstraintAngle +Sketch_3.setAngle(SketchLine_15.result(), SketchLine_18.result(), 135, type = "Direct") +model.do() + +### Create Face +Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchProjection_7r-SketchLine_18f-SketchLine_19f-SketchProjection_9r-SketchProjection_8r")]) + +### Create AngularCopy +AngularCopy_1 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_1_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True) + +### Create Plane +Plane_5 = model.addPlane(Part_1_doc, model.selection("VERTEX", "AngularCopy_1_1_3/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_19_StartVertex&Sketch_3/SketchLine_18_EndVertex"), model.selection("VERTEX", "AngularCopy_1_1_4/MV:Rotated&Sketch_3/SketchLine_18_StartVertex&Sketch_3/SketchProjection_7_EndVertex")) + +### Create Sketch +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) + +### Create SketchProjection +SketchProjection_10 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_3/ME:Rotated&Sketch_3/SketchLine_18"), True) +SketchLine_20 = SketchProjection_10.createdFeature() + +### Create SketchProjection +SketchProjection_11 = Sketch_4.addProjection(model.selection("EDGE", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchProjection_3][Extrusion_2_1/To_Face]"), True) +SketchLine_21 = SketchProjection_11.createdFeature() + +### Create SketchProjection +SketchProjection_12 = Sketch_4.addProjection(model.selection("EDGE", "AngularCopy_1_1_4/ME:Rotated&Sketch_3/SketchLine_18"), True) +SketchLine_22 = SketchProjection_12.createdFeature() + +### Create SketchLine +SketchLine_23 = Sketch_4.addLine(-245.2017461009716, 231.7060626516377, -78.06246341670106, 328.2039725015621) +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_22).endPoint(), SketchLine_23.startPoint()) +Sketch_4.setCoincident(SketchAPI_Line(SketchLine_20).endPoint(), SketchLine_23.endPoint()) +model.do() + +### Create Face +Face_2 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchProjection_10r-SketchLine_23r-SketchProjection_12r-SketchProjection_11r")]) + +### Create AngularCopy +AngularCopy_2 = model.addMultiRotation(Part_1_doc, [model.selection("FACE", "Face_2_1")], model.selection("EDGE", "PartSet/OZ"), 4, keepSubResults = True) + +### Create Split +Split_2_objects_2 = [model.selection("COMPOUND", "AngularCopy_1_1"), + model.selection("COMPOUND", "AngularCopy_2_1"), + model.selection("SOLID", "Extrusion_2_1")] +Split_2 = model.addSplit(Part_1_doc, [model.selection("COMPSOLID", "Split_1_1")], Split_2_objects_2, keepSubResults = True) + +### Create Group +Group_1_objects = [model.selection("FACE", "Split_2_1_16/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_17/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_18/Modified_Face&Cylinder_2_1/Face_1"), + model.selection("FACE", "Split_2_1_19/Modified_Face&Cylinder_2_1/Face_1")] +Group_1 = model.addGroup(Part_1_doc, "Faces", Group_1_objects) +Group_1.setName("shared_face_cyl") +Group_1.result().setName("shared_face_cyl") + +model.end() + +from GeomAPI import * + +model.testNbResults(Split_2, 1) +model.testNbSubResults(Split_2, [20]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.SOLID, [20]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.FACE, [120]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.EDGE, [492]) +model.testNbSubShapes(Split_2, GeomAPI_Shape.VERTEX, [984]) +model.testResultsVolumes(Split_2, [5093568.889]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20245_2.py b/src/FeaturesPlugin/Test/Test20245_2.py new file mode 100644 index 000000000..de33ec847 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20245_2.py @@ -0,0 +1,114 @@ +# Copyright (C) 2020 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() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Box +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Box_1_1/Top")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(7.071067811865538, 2.928932188134462, 2.928932188134676, 2.928932188134462) + +### Create SketchLine +SketchLine_2 = Sketch_1.addLine(2.928932188134676, 2.928932188134462, 2.928932188134676, 7.071067811865324) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(2.928932188134676, 7.071067811865324, 7.071067811865538, 7.071067811865324) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(7.071067811865538, 7.071067811865324, 7.071067811865538, 2.928932188134462) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint()) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +Sketch_1.setHorizontal(SketchLine_1.result()) +Sketch_1.setVertical(SketchLine_2.result()) +Sketch_1.setHorizontal(SketchLine_3.result()) +Sketch_1.setVertical(SketchLine_4.result()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(0, 0, 2.928932188134676, 2.928932188134462) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchPoint_1.result()) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.endPoint()) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(10, 0, 7.071067811865538, 2.928932188134462) + +### Create SketchProjection +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() +Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchPoint_2.result()) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) + +### Create SketchLine +SketchLine_7 = Sketch_1.addLine(10, 10, 7.071067811865538, 7.071067811865324) + +### Create SketchProjection +SketchProjection_3 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]"), False) +SketchPoint_3 = SketchProjection_3.createdFeature() +Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchPoint_3.result()) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_7.endPoint()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(0, 10, 2.928932188134676, 7.071067811865324) + +### Create SketchProjection +SketchProjection_4 = Sketch_1.addProjection(model.selection("VERTEX", "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]"), False) +SketchPoint_4 = SketchProjection_4.createdFeature() +Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchPoint_4.result()) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_8.endPoint()) +Sketch_1.setEqual(SketchLine_4.result(), SketchLine_3.result()) +Sketch_1.setEqual(SketchLine_5.result(), SketchLine_6.result()) +Sketch_1.setEqual(SketchLine_6.result(), SketchLine_7.result()) +Sketch_1.setEqual(SketchLine_5.result(), SketchLine_2.result()) +model.do() + +### Create Revolution +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_1")], model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0, 90, "Edges") + +### Create Split +Split_1 = model.addSplit(Part_1_doc, [model.selection("SOLID", "Box_1_1")], [model.selection("COMPOUND", "Revolution_1_1")], keepSubResults = True) + +model.end() + +from GeomAPI import * + +model.testNbResults(Split_1, 1) +model.testNbSubResults(Split_1, [5]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.SOLID, [5]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.FACE, [32]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.EDGE, [124]) +model.testNbSubShapes(Split_1, GeomAPI_Shape.VERTEX, [248]) +model.testResultsVolumes(Split_1, [1000]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20245_3.py b/src/FeaturesPlugin/Test/Test20245_3.py new file mode 100644 index 000000000..162ca1ac0 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20245_3.py @@ -0,0 +1,1337 @@ +# Copyright (C) 2020 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 + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(6.188000000000001, 9.028, 6.188000000000001, -3.45) + +### Create SketchLine +SketchLine_2 = Sketch_1.addLine(6.188000000000001, -3.45, 0, -3.45) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(0, -3.45, 0, -6.45) +Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) + +### Create SketchLine +SketchLine_4 = Sketch_1.addLine(0, -6.45, 7.781999999999999, -6.45) +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(7.781999999999999, -6.45, 7.781999999999999, -3.45) +Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) + +### Create SketchLine +SketchLine_6 = Sketch_1.addLine(7.781999999999999, -3.45, 6.538000000000001, -3.45) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) + +### Create SketchLine +SketchLine_7 = Sketch_1.addLine(6.538000000000001, -3.45, 6.538000000000002, -2.4) +Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint()) + +### Create SketchLine +SketchLine_8 = Sketch_1.addLine(6.538000000000002, -2.4, 6.376, -2.25) +Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint()) + +### Create SketchLine +SketchLine_9 = Sketch_1.addLine(6.376, -2.25, 6.375999999999999, 9.028) +Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint()) + +### Create SketchLine +SketchLine_10 = Sketch_1.addLine(6.375999999999999, 9.028, 6.188000000000001, 9.028) +SketchLine_10.setAuxiliary(True) +Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint()) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_10.endPoint()) +Sketch_1.setHorizontal(SketchLine_10.result()) +Sketch_1.setVertical(SketchLine_1.result()) +Sketch_1.setVertical(SketchLine_9.result()) +Sketch_1.setVertical(SketchLine_3.result()) +Sketch_1.setVertical(SketchLine_5.result()) +Sketch_1.setHorizontal(SketchLine_2.result()) +Sketch_1.setHorizontal(SketchLine_6.result()) +Sketch_1.setHorizontal(SketchLine_4.result()) +Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchLine_2.result()) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_11 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_11.result()) +Sketch_1.setLength(SketchLine_5.result(), 3) +Sketch_1.setDistance(SketchAPI_Line(SketchLine_11).startPoint(), SketchLine_1.result(), 6.188, True) +Sketch_1.setVertical(SketchLine_7.result()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_12 = SketchProjection_2.createdFeature() +Sketch_1.setDistance(SketchLine_9.endPoint(), SketchLine_12.result(), 9.028, True) +Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_9.result(), 0.188, True) +Sketch_1.setDistance(SketchLine_2.startPoint(), SketchLine_7.result(), 0.35, True) +Sketch_1.setVerticalDistance(SketchLine_7.endPoint(), SketchLine_8.endPoint(), 0.15) +Sketch_1.setDistance(SketchLine_5.endPoint(), SketchLine_12.result(), 3.45, True) +Sketch_1.setDistance(SketchLine_8.endPoint(), SketchLine_12.result(), 2.25, True) + +### Create SketchLine +SketchLine_13 = Sketch_1.addLine(7.031999999999999, -4.05, 5.531999999999999, -4.05) + +### Create SketchLine +SketchLine_14 = Sketch_1.addLine(5.531999999999999, -4.05, 5.531999999999999, -5.850000000000001) + +### Create SketchLine +SketchLine_15 = Sketch_1.addLine(5.531999999999999, -5.850000000000001, 7.031999999999999, -5.850000000000001) + +### Create SketchLine +SketchLine_16 = Sketch_1.addLine(7.031999999999999, -5.850000000000001, 7.031999999999999, -4.05) +Sketch_1.setCoincident(SketchLine_16.endPoint(), SketchLine_13.startPoint()) +Sketch_1.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint()) +Sketch_1.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint()) +Sketch_1.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint()) +Sketch_1.setHorizontal(SketchLine_13.result()) +Sketch_1.setVertical(SketchLine_14.result()) +Sketch_1.setHorizontal(SketchLine_15.result()) +Sketch_1.setVertical(SketchLine_16.result()) +Sketch_1.setLength(SketchLine_14.result(), 1.8) +Sketch_1.setLength(SketchLine_15.result(), 1.5) + +### Create SketchLine +SketchLine_17 = Sketch_1.addLine(6.281999999999999, -4.050000000000001, 6.281999999999999, 9.028000000000002) +SketchLine_17.setAuxiliary(True) +Sketch_1.setCoincident(SketchLine_17.startPoint(), SketchLine_13.result()) +Sketch_1.setCoincident(SketchLine_17.endPoint(), SketchLine_10.result()) +Sketch_1.setVertical(SketchLine_17.result()) +Sketch_1.setMiddlePoint(SketchLine_17.startPoint(), SketchLine_13.result()) +Sketch_1.setDistance(SketchLine_17.startPoint(), SketchLine_5.result(), 1.5, True) +Sketch_1.setMiddlePoint(SketchLine_10.result(), SketchLine_17.endPoint()) +Sketch_1.setDistance(SketchLine_14.startPoint(), SketchLine_2.result(), 0.6, True) + +### Create SketchLine +SketchLine_18 = Sketch_1.addLine(6.375999999999999, 9.028, 6.534999999999997, 9.186999999999999) +Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_18.startPoint()) + +### Create SketchLine +SketchLine_19 = Sketch_1.addLine(6.534999999999997, 9.186999999999999, 6.534999999999997, 10.256) +Sketch_1.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint()) + +### Create SketchLine +SketchLine_20 = Sketch_1.addLine(6.534999999999997, 10.256, 6.184999999999998, 10.256) +Sketch_1.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint()) + +### Create SketchLine +SketchLine_21 = Sketch_1.addLine(6.184999999999998, 10.256, 4.917500000000027, 10.94235984621998) +Sketch_1.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint()) +Sketch_1.setHorizontal(SketchLine_20.result()) +Sketch_1.setVertical(SketchLine_19.result()) + +### Create SketchConstraintAngle +Sketch_1.setAngle(SketchLine_10.result(), SketchLine_18.result(), 45, type = "Supplementary") +Sketch_1.setLength(SketchLine_20.result(), 0.35) +Sketch_1.setDistance(SketchLine_19.endPoint(), SketchLine_12.result(), 10.256, True) + +### Create SketchArc +SketchArc_1 = Sketch_1.addArc(0, 2.425, 4.917500000000027, 10.94235984621998, 0, 12.26, False) +Sketch_1.setCoincident(SketchLine_11.result(), SketchArc_1.center()) +Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchArc_1.startPoint()) +Sketch_1.setCoincident(SketchLine_11.result(), SketchArc_1.endPoint()) + +### Create SketchLine +SketchLine_22 = Sketch_1.addLine(6.188000000000001, 9.028, 6.082, 9.532) +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_22.startPoint()) + +### Create SketchArc +SketchArc_2 = Sketch_1.addArc(4.79378612024245, 9.263, 6.082, 9.532, 5.676067550792229, 10.23944020672391, False) +Sketch_1.setCoincident(SketchLine_22.endPoint(), SketchArc_2.startPoint()) +Sketch_1.setRadius(SketchArc_2.results()[1], 1.316) +Sketch_1.setDistance(SketchArc_2.startPoint(), SketchLine_1.result(), 0.106, True) + +### Create SketchLine +SketchLine_23 = Sketch_1.addLine(5.676067550792229, 10.23944020672391, 5.405090045827156, 10.43837553323928) +Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_23.startPoint()) + +### Create SketchLine +SketchLine_24 = Sketch_1.addLine(5.405090045827156, 10.43837553323928, 5.126644475052085, 10.62934617154252) +Sketch_1.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint()) + +### Create SketchLine +SketchLine_25 = Sketch_1.addLine(5.126644475052085, 10.62934617154252, 4.83550000000003, 10.80033167999934) +Sketch_1.setCoincident(SketchLine_24.endPoint(), SketchLine_25.startPoint()) + +### Create SketchArc +SketchArc_3 = Sketch_1.addArc(0, 2.425, 4.83550000000003, 10.80033167999934, 0, 12.096, False) +Sketch_1.setCoincident(SketchLine_11.result(), SketchArc_3.center()) +Sketch_1.setCoincident(SketchLine_25.endPoint(), SketchArc_3.startPoint()) +Sketch_1.setCoincident(SketchLine_11.result(), SketchArc_3.endPoint()) + +### Create SketchLine +SketchLine_26 = Sketch_1.addLine(0, 12.096, 0, 12.26) +Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_26.startPoint()) +Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_26.endPoint()) +Sketch_1.setDistance(SketchArc_1.center(), SketchLine_12.result(), 2.425, True) +Sketch_1.setCoincident(SketchArc_3.center(), SketchArc_1.center()) +Sketch_1.setLength(SketchLine_26.result(), 0.164) + +### Create SketchLine +SketchLine_27 = Sketch_1.addLine(0, 2.425, 4.917500000000027, 10.94235984621998) +SketchLine_27.setAuxiliary(True) +Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_27.startPoint()) +Sketch_1.setCoincident(SketchLine_21.endPoint(), SketchLine_27.endPoint()) +Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_27.result()) + +### Create SketchLine +SketchLine_28 = Sketch_1.addLine(0, 2.425, 5.21991026555713, 10.77860263646605) +SketchLine_28.setAuxiliary(True) +Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_28.startPoint()) +Sketch_1.setCoincident(SketchLine_28.endPoint(), SketchLine_21.result()) +Sketch_1.setCoincident(SketchLine_28.result(), SketchLine_25.startPoint()) + +### Create SketchLine +SketchLine_29 = Sketch_1.addLine(0, 2.425, 5.523638941362955, 10.61413149862094) +SketchLine_29.setAuxiliary(True) +Sketch_1.setCoincident(SketchArc_1.center(), SketchLine_29.startPoint()) +Sketch_1.setCoincident(SketchLine_29.endPoint(), SketchLine_21.result()) +Sketch_1.setCoincident(SketchLine_29.result(), SketchLine_24.startPoint()) +Sketch_1.setDistance(SketchLine_25.startPoint(), SketchLine_28.endPoint(), 0.176, True) +Sketch_1.setDistance(SketchLine_24.startPoint(), SketchLine_29.endPoint(), 0.212, True) + +### Create SketchConstraintAngle +Sketch_1.setAngle(SketchLine_28.result(), SketchLine_11.result(), 32, type = "Direct") + +### Create SketchConstraintAngle +Sketch_1.setAngle(SketchLine_29.result(), SketchLine_11.result(), 34, type = "Direct") + +### Create SketchConstraintAngle +Sketch_1.setAngle(SketchLine_27.result(), SketchLine_11.result(), 30, type = "Direct") + +### Create SketchLine +SketchLine_30 = Sketch_1.addLine(4.79378612024245, 9.263, 5.676067550792229, 10.23944020672391) +SketchLine_30.setAuxiliary(True) +Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_30.startPoint()) +Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_30.endPoint()) + +### Create SketchLine +SketchLine_31 = Sketch_1.addLine(4.79378612024245, 9.263, 4.79378612024245, 10.72808112087839) +SketchLine_31.setAuxiliary(True) +Sketch_1.setCoincident(SketchArc_2.center(), SketchLine_31.startPoint()) +Sketch_1.setVertical(SketchLine_31.result()) + +### Create SketchConstraintAngle +Sketch_1.setAngle(SketchLine_30.result(), SketchLine_31.result(), 42.1, type = "Direct") +Sketch_1.setDistance(SketchArc_2.center(), SketchLine_12.result(), 9.263, True) +Sketch_1.setCoincident(SketchLine_31.endPoint(), SketchLine_27.result()) +Sketch_1.setDistance(SketchLine_22.endPoint(), SketchLine_12.result(), 9.532, True) +Sketch_1.setDistance(SketchLine_18.endPoint(), SketchLine_12.result(), 9.186999999999999, True) +Sketch_1.setRadius(SketchArc_1.results()[1], 9.835000000000001) +model.do() + +### Create Revolution +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_18f-SketchLine_19f-SketchLine_20f-SketchLine_21f-SketchArc_1_2f-SketchLine_26r-SketchArc_3_2r-SketchLine_25r-SketchLine_24r-SketchLine_23r-SketchArc_2_2r-SketchLine_22r-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) + +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ")) + +### Create SketchProjection +SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_29_StartVertex"), False) +SketchPoint_1 = SketchProjection_3.createdFeature() + +### Create SketchProjection +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_26"), False) +SketchLine_32 = SketchProjection_4.createdFeature() + +### Create SketchArc +SketchArc_4 = Sketch_2.addArc(0, 2.425, 0, 12.178, 5.453808387550563, 10.51060344512907, True) +SketchArc_4.setAuxiliary(True) +Sketch_2.setCoincident(SketchPoint_1.result(), SketchArc_4.center()) +Sketch_2.setCoincident(SketchLine_32.result(), SketchArc_4.startPoint()) + +### Create SketchProjection +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_29"), False) +SketchLine_33 = SketchProjection_5.createdFeature() +Sketch_2.setCoincident(SketchArc_4.endPoint(), SketchLine_33.result()) +Sketch_2.setMiddlePoint(SketchArc_4.startPoint(), SketchLine_32.result()) + +### Create SketchLine +SketchLine_34 = Sketch_2.addLine(0, 2.425, 3.282538500974084, 11.74164236673399) +SketchLine_34.setAuxiliary(True) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_34.startPoint()) + +### Create SketchLine +SketchLine_35 = Sketch_2.addLine(3.282538500974084, 11.74164236673399, 3.199461499025965, 11.50584963625379) +Sketch_2.setCoincident(SketchLine_34.endPoint(), SketchLine_35.startPoint()) +Sketch_2.setCoincident(SketchLine_35.endPoint(), SketchLine_34.result()) +Sketch_2.setLength(SketchLine_35.result(), 0.25) + +### Create SketchPoint +SketchPoint_2 = Sketch_2.addPoint(3.241, 11.6237460014939) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchArc_4.results()[1]) +Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_35.result()) + +### Create SketchProjection +SketchProjection_6 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_36 = SketchProjection_6.createdFeature() +Sketch_2.setDistance(SketchPoint_2.coordinates(), SketchLine_36.result(), 3.241, True) + +### Create SketchArc +SketchArc_5 = Sketch_2.addArc(0, 2.425, 3.282538500974084, 11.74164236673399, 4.1398177019328, 11.393656164374, True) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_5.center()) +Sketch_2.setCoincident(SketchLine_34.endPoint(), SketchArc_5.startPoint()) + +### Create SketchArc +SketchArc_6 = Sketch_2.addArc(0, 2.425, 3.199461499025965, 11.50584963625379, 4.035044020470642, 11.16667053559353, True) +Sketch_2.setCoincident(SketchAPI_Line(SketchLine_33).startPoint(), SketchArc_6.center()) +Sketch_2.setCoincident(SketchLine_35.endPoint(), SketchArc_6.startPoint()) + +### Create SketchLine +SketchLine_37 = Sketch_2.addLine(0, 2.425, 3.911506014428326, 11.49555702253677) +SketchLine_37.setAuxiliary(True) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_37.startPoint()) +Sketch_2.setCoincident(SketchLine_37.endPoint(), SketchArc_5.results()[1]) + +### Create SketchLine +SketchLine_38 = Sketch_2.addLine(0, 2.425, 4.1398177019328, 11.393656164374) +SketchLine_38.setAuxiliary(True) +Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_38.startPoint()) +Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchLine_38.endPoint()) +Sketch_2.setCoincident(SketchArc_6.endPoint(), SketchLine_38.result()) +Sketch_2.setDistance(SketchLine_35.startPoint(), SketchLine_37.result(), 0.675, True) +Sketch_2.setMiddlePoint(SketchPoint_2.coordinates(), SketchLine_35.result()) + +### Create SketchLine +SketchLine_39 = Sketch_2.addLine(3.911506014428326, 11.49555702253677, 3.81251062025875, 11.26599240868435) +Sketch_2.setCoincident(SketchLine_37.endPoint(), SketchLine_39.startPoint()) +Sketch_2.setCoincident(SketchLine_39.endPoint(), SketchArc_6.results()[1]) +Sketch_2.setCoincident(SketchLine_39.endPoint(), SketchLine_37.result()) + +### Create SketchLine +SketchLine_40 = Sketch_2.addLine(4.1398177019328, 11.393656164374, 4.459277785066647, 11.19096067956113) +Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchLine_40.startPoint()) + +### Create SketchProjection +SketchProjection_7 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchArc_1_2"), False) +SketchArc_7 = SketchProjection_7.createdFeature() +Sketch_2.setCoincident(SketchLine_40.endPoint(), SketchArc_7.results()[1]) + +### Create SketchLine +SketchLine_41 = Sketch_2.addLine(4.459277785066647, 11.19096067956113, 4.390495384356095, 11.04194790978503) +Sketch_2.setCoincident(SketchLine_40.endPoint(), SketchLine_41.startPoint()) + +### Create SketchProjection +SketchProjection_8 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchArc_3_2"), False) +SketchArc_8 = SketchProjection_8.createdFeature() +Sketch_2.setCoincident(SketchLine_41.endPoint(), SketchArc_8.results()[1]) + +### Create SketchLine +SketchLine_42 = Sketch_2.addLine(4.390495384356095, 11.04194790978503, 4.035044020470642, 11.16667053559353) +Sketch_2.setCoincident(SketchLine_41.endPoint(), SketchLine_42.startPoint()) +Sketch_2.setCoincident(SketchLine_42.endPoint(), SketchLine_38.result()) +Sketch_2.setCoincident(SketchLine_42.endPoint(), SketchArc_6.endPoint()) +Sketch_2.setDistance(SketchArc_5.endPoint(), SketchLine_41.result(), 0.375, True) +Sketch_2.setDistance(SketchLine_39.startPoint(), SketchLine_38.result(), 0.25, True) +Sketch_2.setParallel(SketchLine_41.result(), SketchLine_38.result()) +model.do() + +### Create Revolution +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_35f-SketchArc_6_2r-SketchLine_39r-SketchArc_5_2f_wire")], model.selection("EDGE", "Sketch_2/SketchLine_35"), 360, 0) + +### Create Revolution +Revolution_3 = model.addRevolution(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchArc_5_2f-SketchLine_39f-SketchArc_6_2r-SketchLine_42r-SketchLine_41r-SketchLine_40r_wire")], model.selection("EDGE", "Sketch_2/SketchLine_35"), 360, 0) + +### Create Symmetry +Symmetry_1 = model.addSymmetry(Part_1_doc, [model.selection("SOLID", "Revolution_2_1"), model.selection("SOLID", "Revolution_3_1")], model.selection("FACE", "PartSet/YOZ"), keepOriginal = True) + +### Create Cut +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Revolution_1_1")], [model.selection("COMPOUND", "Symmetry_1_1")]) + +### Create Fuse +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cut_1_1"), model.selection("COMPOUND", "Symmetry_1_2")], removeEdges = True) + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOY"), 3.6, False) + +### Create Sketch +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchProjection +SketchProjection_9 = Sketch_3.addProjection(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), True) +SketchCircle_1 = SketchProjection_9.createdFeature() + +### Create SketchProjection +SketchProjection_10 = Sketch_3.addProjection(model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_9][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8]"), True) +SketchCircle_2 = SketchProjection_10.createdFeature() + +### Create SketchArc +SketchArc_9 = Sketch_3.addArc(0, 0, 6.094, 0, 5.859569950090201, -1.674, True) +Sketch_3.setCoincident(SketchAPI_Circle(SketchCircle_1).center(), SketchArc_9.center()) + +### Create SketchProjection +SketchProjection_11 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_43 = SketchProjection_11.createdFeature() +Sketch_3.setCoincident(SketchArc_9.startPoint(), SketchLine_43.result()) + +### Create SketchPoint +SketchPoint_3 = Sketch_3.addPoint(6.188000000000001, 0) +Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchLine_43.result()) +Sketch_3.setCoincident(SketchPoint_3.coordinates(), SketchCircle_1.results()[1]) +Sketch_3.setDistance(SketchArc_9.startPoint(), SketchPoint_3.coordinates(), 0.094, True) +Sketch_3.setDistance(SketchArc_9.endPoint(), SketchLine_43.result(), 1.674, True) + +### Create SketchLine +SketchLine_44 = Sketch_3.addLine(5.859569950090201, -1.674, 5.870724657144867, -1.956000000000001) +Sketch_3.setCoincident(SketchArc_9.endPoint(), SketchLine_44.startPoint()) +Sketch_3.setCoincident(SketchLine_44.endPoint(), SketchCircle_1.results()[1]) + +### Create SketchArc +SketchArc_10 = Sketch_3.addArc(0, 0, 6.470000000000001, 0, 6.167249305809295, -1.955999999999993, True) +Sketch_3.setCoincident(SketchAPI_Circle(SketchCircle_1).center(), SketchArc_10.center()) +Sketch_3.setCoincident(SketchLine_43.result(), SketchArc_10.startPoint()) + +### Create SketchLine +SketchLine_45 = Sketch_3.addLine(6.167249305809295, -1.955999999999993, 6.068561608816571, -1.956000000000005) +Sketch_3.setCoincident(SketchArc_10.endPoint(), SketchLine_45.startPoint()) +Sketch_3.setCoincident(SketchLine_45.endPoint(), SketchCircle_2.results()[1]) +Sketch_3.setHorizontal(SketchLine_45.result()) +Sketch_3.setCoincident(SketchLine_44.endPoint(), SketchLine_45.result()) +Sketch_3.setDistance(SketchArc_10.startPoint(), SketchLine_45.result(), 1.956, True) + +### Create SketchPoint +SketchPoint_4 = Sketch_3.addPoint(6.376, 0) +Sketch_3.setCoincident(SketchPoint_4.coordinates(), SketchCircle_2.results()[1]) +Sketch_3.setCoincident(SketchPoint_4.coordinates(), SketchLine_43.result()) +Sketch_3.setDistance(SketchPoint_4.coordinates(), SketchArc_10.startPoint(), 0.094, True) + +### Create SketchConstraintMirror +SketchConstraintMirror_1_objects = [SketchArc_9.results()[1], SketchLine_44.result(), SketchArc_10.results()[1], SketchLine_45.result()] +SketchConstraintMirror_1 = Sketch_3.addMirror(SketchLine_43.result(), SketchConstraintMirror_1_objects) +[SketchArc_11, SketchLine_46, SketchArc_12, SketchLine_47] = SketchConstraintMirror_1.mirrored() +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchProjection_9r-SketchProjection_9r-SketchLine_46r-SketchArc_11_2r-SketchArc_9_2r-SketchLine_44f"), model.selection("WIRE", "Sketch_3/Face-SketchProjection_10r-SketchLine_45r-SketchArc_10_2f-SketchArc_12_2f-SketchLine_47f-SketchProjection_10r_wire")], model.selection(), 0, 4.2) + +### Create Sketch +Sketch_4 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) + +### Create SketchLine +SketchLine_48 = Sketch_4.addLine(0.75, 2.1, -0.75, 2.1) + +### Create SketchLine +SketchLine_49 = Sketch_4.addLine(-0.75, 2.1, -0.75, 0.3) + +### Create SketchLine +SketchLine_50 = Sketch_4.addLine(-0.75, 0.3, 0.75, 0.3) + +### Create SketchLine +SketchLine_51 = Sketch_4.addLine(0.75, 0.3, 0.75, 2.1) +Sketch_4.setCoincident(SketchLine_51.endPoint(), SketchLine_48.startPoint()) +Sketch_4.setCoincident(SketchLine_48.endPoint(), SketchLine_49.startPoint()) +Sketch_4.setCoincident(SketchLine_49.endPoint(), SketchLine_50.startPoint()) +Sketch_4.setCoincident(SketchLine_50.endPoint(), SketchLine_51.startPoint()) +Sketch_4.setHorizontal(SketchLine_48.result()) +Sketch_4.setVertical(SketchLine_49.result()) +Sketch_4.setHorizontal(SketchLine_50.result()) +Sketch_4.setVertical(SketchLine_51.result()) + +### Create SketchProjection +SketchProjection_12 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_52 = SketchProjection_12.createdFeature() +Sketch_4.setDistance(SketchLine_52.result(), SketchLine_50.endPoint(), 0.3, True) +Sketch_4.setDistance(SketchLine_51.endPoint(), SketchLine_52.result(), 2.1, True) + +### Create SketchPoint +SketchPoint_5 = Sketch_4.addPoint(0, 2.1) +Sketch_4.setCoincident(SketchPoint_5.coordinates(), SketchLine_48.result()) +Sketch_4.setMiddlePoint(SketchLine_48.result(), SketchPoint_5.coordinates()) + +### Create SketchProjection +SketchProjection_13 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_53 = SketchProjection_13.createdFeature() +Sketch_4.setCoincident(SketchPoint_5.coordinates(), SketchLine_53.result()) +Sketch_4.setDistance(SketchPoint_5.coordinates(), SketchLine_51.endPoint(), 0.75, True) +model.do() + +### Create Extrusion +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_4/Face-SketchLine_48r-SketchLine_49f-SketchLine_50f-SketchLine_51f")], model.selection(), 10, 0) + +### Create Rotation +Rotation_1 = model.addRotation(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = -90) + +### Create Rotation +Rotation_2 = model.addRotation(Part_1_doc, [model.selection("SOLID", "Extrusion_2_1")], axis = model.selection("EDGE", "PartSet/OZ"), angle = -90) + +### Create Fuse +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Fuse_1_1"), model.selection("COMPOUND", "Rotation_1_1")], removeEdges = True) + +### Create Cut +Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fuse_2_1")], [model.selection("SOLID", "Rotation_2_1")]) + +### Create Group +Group_1_objects = [model.selection("VERTEX", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40]"), + model.selection("VERTEX", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1]"), + model.selection("VERTEX", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2]"), + model.selection("VERTEX", "[(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21]"), + model.selection("VERTEX", "[_new_weak_name_87_Cut_2_1]e[_new_weak_name_78_Cut_2_1]e[_new_weak_name_77_Cut_2_1]e[_new_weak_name_85_Cut_2_1]e"), + model.selection("VERTEX", "[_new_weak_name_78_Cut_2_1]e[_new_weak_name_64_Cut_2_1]e[_new_weak_name_77_Cut_2_1]e"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][new_weak_name_2]"), + model.selection("VERTEX", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20]"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2]"), + model.selection("VERTEX", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19]"), + model.selection("VERTEX", "[Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2][(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1]"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25]"), + model.selection("VERTEX", "[_new_weak_name_86_Cut_2_1]e[_new_weak_name_75_Cut_2_1]e[_new_weak_name_74_Cut_2_1]e[_new_weak_name_84_Cut_2_1]e"), + model.selection("VERTEX", "[_new_weak_name_75_Cut_2_1]e[_new_weak_name_63_Cut_2_1]e[_new_weak_name_74_Cut_2_1]e"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][new_weak_name_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18]"), + model.selection("VERTEX", "[(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24]"), + model.selection("VERTEX", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45][Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23][Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45][Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6]"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2&new_weak_name_4"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2&new_weak_name_3"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2&new_weak_name_1"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2&new_weak_name_2"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5]"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2&new_weak_name_4"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2&new_weak_name_3"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2&new_weak_name_1"), + model.selection("VERTEX", "Cut_2_1/Generated_Vertex&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2&new_weak_name_2"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46]"), + model.selection("VERTEX", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_4]"), + model.selection("VERTEX", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face]"), + model.selection("VERTEX", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("VERTEX", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46]"), + model.selection("VERTEX", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14]"), + model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14]")] +Group_1 = model.addGroup(Part_1_doc, "VERTEX", Group_1_objects) + +### Create Group +Group_2_objects = [model.selection("EDGE", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40]"), + model.selection("EDGE", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1]"), + model.selection("EDGE", "([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40])([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2])2_Cut_2_1"), + model.selection("EDGE", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2]"), + model.selection("EDGE", "([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40])([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2])_Cut_2_1"), + model.selection("EDGE", "([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40])2([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42])2_Cut_2_1"), + model.selection("EDGE", "[(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20])2([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])2_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][new_weak_name_2]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21])3([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])3_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][new_weak_name_1]"), + model.selection("EDGE", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42]"), + model.selection("EDGE", "([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42])([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2])2_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20])_Cut_2_1"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21])2_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2]"), + model.selection("EDGE", "[Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2]"), + model.selection("EDGE", "([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2][Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42])([Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42][Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2])_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19]"), + model.selection("EDGE", "[Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2][(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21])3([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])3_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24])2([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])2_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][new_weak_name_2]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25])3([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])3_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][new_weak_name_1]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18])_Cut_2_1"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])2([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])2_Cut_2_1"), + model.selection("EDGE", "[(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24]"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24])_Cut_2_1"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25])2_Cut_2_1"), + model.selection("EDGE", "[Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9])_Cut_2_1"), + model.selection("EDGE", "([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2])([Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40][Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2])3([Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25])3_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23])_Cut_2_1"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9])([Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8])_Cut_2_1"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23][Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23][Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2])_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7]"), + model.selection("EDGE", "([Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7])_Cut_2_1"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45][Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47][Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23][Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2])([Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22])_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8][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_6])_Cut_2_1"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_51&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_50&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_49&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_48&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1])_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5]"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_51&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_4/SketchLine_51][Cut_2_1/Modified_Face&Sketch_4/SketchLine_48]"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_4/SketchLine_51][Cut_2_1/Modified_Face&Sketch_4/SketchLine_50]"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_50&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_4/SketchLine_50][Cut_2_1/Modified_Face&Sketch_4/SketchLine_49]"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_49&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_4/SketchLine_49][Cut_2_1/Modified_Face&Sketch_4/SketchLine_48]"), + model.selection("EDGE", "Cut_2_1/Generated_Edge&Sketch_4/SketchLine_48&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22][Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1])([Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2])_Cut_2_1"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_4]"), + 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_4])_Cut_2_1"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44]"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face]"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("EDGE", "[Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face][Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46]"), + model.selection("EDGE", "[Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46][Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13])_Cut_2_1"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14]"), + model.selection("EDGE", "[Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14]"), + model.selection("EDGE", "([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14])([Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13][Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14])_Cut_2_1")] +Group_2 = model.addGroup(Part_1_doc, "EDGE", Group_2_objects) + +### Create Group +Group_3_objects = [model.selection("FACE", "Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2"), + model.selection("FACE", "Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_40"), + model.selection("FACE", "(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1"), + model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_1/SketchArc_1_2"), + model.selection("FACE", "Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchArc_6_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_21"), + model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_2/SketchLine_40"), + model.selection("FACE", "Symmetry_1_2_2/MF:Symmetried&Sketch_2/SketchLine_42"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_20"), + model.selection("FACE", "Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2"), + model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_1/SketchArc_3_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_19"), + model.selection("FACE", "(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_5_2)(Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2)_Cut_2_1"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_25"), + model.selection("FACE", "Fuse_1_1/Modified_Face&Sketch_2/SketchLine_42"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_18"), + model.selection("FACE", "Symmetry_1_2_1/MF:Symmetried&Sketch_2/SketchArc_6_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_24"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_1/SketchLine_9"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_23"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_8"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Extrusion_1_2/From_Face"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_3/SketchLine_45"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Extrusion_1_2/To_Face"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_3/SketchLine_47"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchArc_2_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_7"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_3/SketchArc_12_2&Sketch_3/SketchArc_10_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_22"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_6"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_4/SketchLine_51"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_4/SketchLine_50"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_4/SketchLine_49"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_4/SketchLine_48"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_1/SketchLine_1"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_5"), + model.selection("FACE", "Cut_2_1/Modified_Face&Sketch_3/SketchArc_9_2&Sketch_3/SketchArc_11_2"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_2"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_3/SketchLine_44"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Extrusion_1_1/From_Face"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Sketch_3/SketchLine_46"), + model.selection("FACE", "Fuse_2_1/Modified_Face&Extrusion_1_1/To_Face"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_4"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_16"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_15"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_13"), + model.selection("FACE", "Revolution_1_1/Generated_Face&Sketch_1/SketchLine_14")] +Group_3 = model.addGroup(Part_1_doc, "FACE", Group_3_objects) + +### Create Partition +Partition_1_objects = [model.selection("SOLID", "Cut_2_1"), + model.selection("FACE", "PartSet/XOZ"), + model.selection("FACE", "PartSet/YOZ")] +Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects, keepSubResults = True) + +### Create Revolution +Revolution_4 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Sketch_2/SketchLine_35")], model.selection("EDGE", "PartSet/OZ"), 360, 0) + +### Create Split +Split_1 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Partition_1")], [model.selection("FACE", "Revolution_4_1")], keepSubResults = True) + +### Create Plane +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "PartSet/XOZ"), model.selection("EDGE", "Sketch_2/SketchLine_34"), 45) + +### Create Sketch +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) + +### Create SketchLine +SketchLine_54 = Sketch_5.addLine(5.509213645269787, 10.82082332930156, 5.382690082387538, 10.60520378465038) + +### Create SketchLine +SketchLine_55 = Sketch_5.addLine(5.382690082387538, 10.60520378465038, 5.5912917558727, 10.4792224745154) +Sketch_5.setCoincident(SketchLine_54.endPoint(), SketchLine_55.startPoint()) + +### Create SketchLine +SketchLine_56 = Sketch_5.addLine(5.5912917558727, 10.4792224745154, 5.928669438910004, 10.31165844357506) +Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchLine_56.startPoint()) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_1 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_2/SketchLine_39][Split_1_1_7/Modified_Face&Sketch_2/SketchArc_5_2]"), True) +[SketchPoint_6] = SketchIntersectionPoint_1.intersectionPoints() + +### Create SketchIntersectionPoint +SketchIntersectionPoint_2 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_2/SketchArc_5_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_40]"), True) +[SketchPoint_7] = SketchIntersectionPoint_2.intersectionPoints() + +### Create SketchIntersectionPoint +SketchIntersectionPoint_3 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_1/SketchArc_1_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_40]"), True) +[SketchPoint_8] = SketchIntersectionPoint_3.intersectionPoints() + +### Create SketchIntersectionPoint +SketchIntersectionPoint_4 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_2/SketchArc_6_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_39]"), True) +[SketchPoint_9] = SketchIntersectionPoint_4.intersectionPoints() +Sketch_5.setCoincident(SketchLine_54.startPoint(), SketchAPI_Point(SketchPoint_6).coordinates()) +Sketch_5.setCoincident(SketchLine_55.startPoint(), SketchAPI_Point(SketchPoint_9).coordinates()) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_5 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_2/SketchLine_42][Split_1_1_7/Modified_Face&Sketch_2/SketchArc_6_2]"), True) +[SketchPoint_10] = SketchIntersectionPoint_5.intersectionPoints() + +### Create SketchIntersectionPoint +SketchIntersectionPoint_6 = Sketch_5.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_1/SketchArc_3_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_42]"), True) +[SketchPoint_11] = SketchIntersectionPoint_6.intersectionPoints() +Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchAPI_Point(SketchPoint_10).coordinates()) +Sketch_5.setCoincident(SketchLine_56.endPoint(), SketchAPI_Point(SketchPoint_11).coordinates()) + +### Create SketchLine +SketchLine_57 = Sketch_5.addLine(5.723231855768999, 10.69157079694662, 5.5912917558727, 10.4792224745154) +SketchLine_57.setName("SketchLine_72") +SketchLine_57.result().setName("SketchLine_72") +Sketch_5.setCoincident(SketchLine_55.endPoint(), SketchLine_57.endPoint()) + +### Create SketchLine +SketchLine_58 = Sketch_5.addLine(5.928669438910005, 10.31165844357506, 6.034221518827074, 10.48153710152002) +SketchLine_58.setName("SketchLine_109") +SketchLine_58.result().setName("SketchLine_109") +Sketch_5.setCoincident(SketchLine_56.endPoint(), SketchLine_58.startPoint()) + +### Create SketchLine +SketchLine_59 = Sketch_5.addLine(6.034221518827074, 10.48153710152002, 5.723231855768999, 10.69157079694662) +SketchLine_59.setName("SketchLine_113") +SketchLine_59.result().setName("SketchLine_113") +Sketch_5.setCoincident(SketchLine_58.endPoint(), SketchLine_59.startPoint()) +Sketch_5.setCoincident(SketchLine_58.result(), SketchAPI_Point(SketchPoint_8).coordinates()) +Sketch_5.setLength(SketchLine_58.result(), 0.2) + +### Create SketchLine +SketchLine_60 = Sketch_5.addLine(5.723231855768999, 10.69157079694662, 5.514274587785066, 10.82944811108761) +SketchLine_60.setName("SketchLine_114") +SketchLine_60.result().setName("SketchLine_114") +Sketch_5.setCoincident(SketchAPI_Point(SketchPoint_7).coordinates(), SketchLine_60.startPoint()) + +### Create SketchLine +SketchLine_61 = Sketch_5.addLine(5.514274587785066, 10.82944811108761, 5.509213645269788, 10.82082332930156) +SketchLine_61.setName("SketchLine_115") +SketchLine_61.result().setName("SketchLine_115") +Sketch_5.setCoincident(SketchLine_60.endPoint(), SketchLine_61.startPoint()) +Sketch_5.setCoincident(SketchLine_54.startPoint(), SketchLine_61.endPoint()) +Sketch_5.setCollinear(SketchLine_61.result(), SketchLine_54.result()) +Sketch_5.setLength(SketchLine_61.result(), 0.01) +Sketch_5.setCoincident(SketchLine_60.startPoint(), SketchLine_59.endPoint()) +Sketch_5.setCoincident(SketchLine_60.startPoint(), SketchLine_57.startPoint()) +model.do() + +### Create Face +Face_1 = model.addFace(Part_1_doc, [model.selection("COMPOUND", "all-in-Sketch_5")]) + +### Create Revolution +Revolution_5 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Face_1_2/Modified_Edge&Sketch_5/SketchLine_109")], model.selection("EDGE", "PartSet/OZ"), model.selection("FACE", "PartSet/YOZ"), 0, model.selection(), 0) + +### Create Symmetry +Symmetry_2 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Face_1"), model.selection("COMPOUND", "all-in-Revolution_5")], model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Symmetry +Symmetry_3 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Symmetry_2")], model.selection("FACE", "PartSet/XOZ"), keepOriginal = True, keepSubResults = True) + +### Create Point +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_1/SketchArc_1_2][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_21]"), 1.25, False, False) + +### Create Plane +Plane_6 = model.addPlane(Part_1_doc, model.selection("EDGE", "Symmetry_3_1_1_1_1_2/ME:Symmetried&Sketch_5/SketchLine_109"), model.selection("VERTEX", "Point_1"), False) + +### Create Sketch +Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_3")) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_7 = Sketch_6.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_25][Split_1_1_7/Modified_Face&Sketch_1/SketchArc_3_2]"), True) +[SketchPoint_12] = SketchIntersectionPoint_7.intersectionPoints() + +### Create SketchIntersectionPoint +SketchIntersectionPoint_8 = Sketch_6.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_1/SketchArc_1_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_40]"), True) +SketchIntersectionPoint_8.setName("SketchIntersectionPoint_9") +SketchIntersectionPoint_8.result().setName("SketchIntersectionPoint_9") +[SketchPoint_13] = SketchIntersectionPoint_8.intersectionPoints() +SketchPoint_13.setName("SketchPoint_14") +SketchPoint_13.result().setName("SketchPoint_14") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_9 = Sketch_6.addIntersectionPoint(model.selection("EDGE", "[Split_1_1_7/Modified_Face&Sketch_1/SketchArc_3_2][Split_1_1_7/Modified_Face&Sketch_2/SketchLine_42]"), True) +SketchIntersectionPoint_9.setName("SketchIntersectionPoint_10") +SketchIntersectionPoint_9.result().setName("SketchIntersectionPoint_10") +[SketchPoint_14] = SketchIntersectionPoint_9.intersectionPoints() +SketchPoint_14.setName("SketchPoint_15") +SketchPoint_14.result().setName("SketchPoint_15") + +### Create SketchProjection +SketchProjection_14 = Sketch_6.addProjection(model.selection("VERTEX", "Point_1"), False) +SketchPoint_15 = SketchProjection_14.createdFeature() +SketchPoint_15.setName("SketchPoint_16") +SketchPoint_15.result().setName("SketchPoint_16") + +### Create SketchLine +SketchLine_62 = Sketch_6.addLine(5.246389275102901, -10.59990828317982, 5.359721474154084, -10.7814541886472) +SketchLine_62.setName("SketchLine_60") +SketchLine_62.result().setName("SketchLine_60") +Sketch_6.setCoincident(SketchLine_62.result(), SketchAPI_Point(SketchPoint_15).coordinates()) +Sketch_6.setCoincident(SketchLine_62.result(), SketchAPI_Point(SketchPoint_12).coordinates()) +Sketch_6.setDistance(SketchAPI_Point(SketchPoint_15).coordinates(), SketchLine_62.endPoint(), 0.05, True) +Sketch_6.setCoincident(SketchLine_62.startPoint(), SketchAPI_Point(SketchPoint_12).coordinates()) +model.do() + +### Create Filling +Filling_1 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_6/SketchLine_60"), model.selection("EDGE", "Symmetry_3_1_1_1_1_2/ME:Symmetried&Sketch_5/SketchLine_109")]) + +### Create Revolution +Revolution_6 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Sketch_6/SketchLine_60")], model.selection("EDGE", "PartSet/OZ"), 360, 0) + +### Create Point +Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_21][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_20]"), 1.5, False, False) + +### Create Plane +Plane_7 = model.addPlane(Part_1_doc, model.selection("EDGE", "Sketch_6/SketchLine_60"), model.selection("VERTEX", "Point_2"), False) + +### Create Sketch +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_4")) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_10 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_20][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_19]"), True) +SketchIntersectionPoint_10.setName("SketchIntersectionPoint_11") +SketchIntersectionPoint_10.result().setName("SketchIntersectionPoint_11") +[SketchPoint_16] = SketchIntersectionPoint_10.intersectionPoints() +SketchPoint_16.setName("SketchPoint_17") +SketchPoint_16.result().setName("SketchPoint_17") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_11 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_19][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_18]"), True) +SketchIntersectionPoint_11.setName("SketchIntersectionPoint_12") +SketchIntersectionPoint_11.result().setName("SketchIntersectionPoint_12") +[SketchPoint_17] = SketchIntersectionPoint_11.intersectionPoints() +SketchPoint_17.setName("SketchPoint_18") +SketchPoint_17.result().setName("SketchPoint_18") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_12 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_18][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_9]"), True) +SketchIntersectionPoint_12.setName("SketchIntersectionPoint_13") +SketchIntersectionPoint_12.result().setName("SketchIntersectionPoint_13") +[SketchPoint_18] = SketchIntersectionPoint_12.intersectionPoints() +SketchPoint_18.setName("SketchPoint_19") +SketchPoint_18.result().setName("SketchPoint_19") + +### Create SketchLine +SketchLine_63 = Sketch_7.addLine(6.348502432487296, -9.04671367200557, 6.153596006787127, -10.27430623369788) +SketchLine_63.setName("SketchLine_65") +SketchLine_63.result().setName("SketchLine_65") +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_18).coordinates(), SketchLine_63.startPoint()) + +### Create SketchProjection +SketchProjection_15 = Sketch_7.addProjection(model.selection("VERTEX", "Point_2"), False) +SketchProjection_15.setName("SketchProjection_16") +SketchProjection_15.result().setName("SketchProjection_16") +SketchPoint_19 = SketchProjection_15.createdFeature() +SketchPoint_19.setName("SketchPoint_20") +SketchPoint_19.result().setName("SketchPoint_20") +Sketch_7.setCoincident(SketchLine_63.endPoint(), SketchPoint_19.result()) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_13 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchArc_2_2][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_23]"), True) +SketchIntersectionPoint_13.setName("SketchIntersectionPoint_14") +SketchIntersectionPoint_13.result().setName("SketchIntersectionPoint_14") +[SketchPoint_20] = SketchIntersectionPoint_13.intersectionPoints() +SketchPoint_20.setName("SketchPoint_21") +SketchPoint_20.result().setName("SketchPoint_21") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_14 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_22][Partition_1_1_4/Modified_Face&Sketch_1/SketchArc_2_2]"), True) +SketchIntersectionPoint_14.setName("SketchIntersectionPoint_15") +SketchIntersectionPoint_14.result().setName("SketchIntersectionPoint_15") +[SketchPoint_21] = SketchIntersectionPoint_14.intersectionPoints() +SketchPoint_21.setName("SketchPoint_22") +SketchPoint_21.result().setName("SketchPoint_22") + +### Create SketchLine +SketchLine_64 = Sketch_7.addLine(5.644308024489205, -10.25641345263865, 6.15359600678713, -10.27430623369788) +SketchLine_64.setName("SketchLine_67") +SketchLine_64.result().setName("SketchLine_67") +SketchLine_64.setAuxiliary(True) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_20).coordinates(), SketchLine_64.startPoint()) +Sketch_7.setCoincident(SketchLine_63.endPoint(), SketchLine_64.endPoint()) + +### Create SketchLine +SketchLine_65 = Sketch_7.addLine(6.15359600678713, -10.27430623369788, 6.052762716433288, -9.549982350617446) +SketchLine_65.setName("SketchLine_68") +SketchLine_65.result().setName("SketchLine_68") +SketchLine_65.setAuxiliary(True) +Sketch_7.setCoincident(SketchLine_63.endPoint(), SketchLine_65.startPoint()) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_21).coordinates(), SketchLine_65.endPoint()) + +### Create SketchLine +SketchLine_66 = Sketch_7.addLine(5.644308024489205, -10.25641345263865, 6.052762716433288, -9.549982350617446) +SketchLine_66.setName("SketchLine_69") +SketchLine_66.result().setName("SketchLine_69") +SketchLine_66.setAuxiliary(True) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_20).coordinates(), SketchLine_66.startPoint()) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_21).coordinates(), SketchLine_66.endPoint()) + +### Create SketchLine +SketchLine_67 = Sketch_7.addLine(6.15359600678713, -10.27430623369788, 5.812047228248534, -9.966304921873915) +SketchLine_67.setName("SketchLine_70") +SketchLine_67.result().setName("SketchLine_70") +Sketch_7.setCoincident(SketchLine_63.endPoint(), SketchLine_67.startPoint()) +Sketch_7.setCoincident(SketchLine_67.endPoint(), SketchLine_66.result()) + +### Create SketchConstraintAngle +Sketch_7.setAngle(SketchLine_67.result(), SketchLine_64.result(), "80.0626341144/2", type = "Direct") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_15 = Sketch_7.addIntersectionPoint(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_1][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_22]"), True) +SketchIntersectionPoint_15.setName("SketchIntersectionPoint_16") +SketchIntersectionPoint_15.result().setName("SketchIntersectionPoint_16") +[SketchPoint_22] = SketchIntersectionPoint_15.intersectionPoints() +SketchPoint_22.setName("SketchPoint_23") +SketchPoint_22.result().setName("SketchPoint_23") + +### Create SketchLine +SketchLine_68 = Sketch_7.addLine(6.348502432487296, -9.04671367200557, 6.160385566110681, -9.046221812193464) +SketchLine_68.setName("SketchLine_71") +SketchLine_68.result().setName("SketchLine_71") +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_18).coordinates(), SketchLine_68.startPoint()) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_22).coordinates(), SketchLine_68.endPoint()) + +### Create SketchLine +SketchLine_69 = Sketch_7.addLine(6.348502432487297, -9.046713672005572, 6.603839274138267, -9.303368522147153) +SketchLine_69.setName("SketchLine_83") +SketchLine_69.result().setName("SketchLine_83") +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_18).coordinates(), SketchLine_69.startPoint()) + +### Create SketchLine +SketchLine_70 = Sketch_7.addLine(6.603839274138267, -9.303368522147153, 6.603839274138267, -10.27548346237037) +SketchLine_70.setName("SketchLine_85") +SketchLine_70.result().setName("SketchLine_85") +Sketch_7.setCoincident(SketchLine_69.endPoint(), SketchLine_70.startPoint()) +Sketch_7.setVertical(SketchLine_70.result()) + +### Create SketchLine +SketchLine_71 = Sketch_7.addLine(6.603839274138267, -10.27548346237037, 6.153596006787128, -10.27430623369788) +SketchLine_71.setName("SketchLine_86") +SketchLine_71.result().setName("SketchLine_86") +Sketch_7.setCoincident(SketchLine_70.endPoint(), SketchLine_71.startPoint()) +Sketch_7.setCoincident(SketchLine_63.endPoint(), SketchLine_71.endPoint()) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_16).coordinates(), SketchLine_71.result()) +Sketch_7.setCoincident(SketchAPI_Point(SketchPoint_17).coordinates(), SketchLine_69.result()) +Sketch_7.setDistance(SketchAPI_Point(SketchPoint_16).coordinates(), SketchLine_70.result(), 0.1, True) +model.do() + +### Create Filling +Filling_2 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_7/SketchLine_70"), model.selection("EDGE", "Revolution_6_1/From_Edge")]) + +### Create Face +Face_2 = model.addFace(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")]) + +### Create Filling +Filling_3 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_7/SketchLine_71"), model.selection("EDGE", "Sketch_7/SketchLine_70")]) + +### Create Symmetry +Symmetry_4_objects = [model.selection("FACE", "Filling_1_1"), + model.selection("FACE", "Filling_2_1"), + model.selection("FACE", "Filling_3_1"), + model.selection("FACE", "Face_2_1")] +Symmetry_4 = model.addSymmetry(Part_1_doc, Symmetry_4_objects, model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Symmetry +Symmetry_5 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Symmetry_4")], model.selection("FACE", "PartSet/XOZ"), keepOriginal = True, keepSubResults = True) + +### Create Revolution +Revolution_7_objects = [model.selection("EDGE", "Sketch_7/SketchLine_70"), + model.selection("EDGE", "Sketch_7/SketchLine_71"), + model.selection("EDGE", "Symmetry_5_1_1_3_1/ME:Symmetried&Filling_3_1/Edge_0_1")] +Revolution_7 = model.addRevolution(Part_1_doc, Revolution_7_objects, model.selection("EDGE", "PartSet/OZ"), 360, 0) + +### Create Split +Split_2_objects_2 = [model.selection("COMPOUND", "all-in-Revolution_7"), + model.selection("COMPOUND", "all-in-Symmetry_5"), + model.selection("COMPOUND", "all-in-Revolution_6"), + model.selection("COMPOUND", "all-in-Symmetry_3")] +Split_2 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Split_1")], Split_2_objects_2, keepSubResults = True) + +### Create Revolution +Revolution_8 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Split_2_1_43/Modified_Edge&Sketch_5/SketchLine_72"), model.selection("EDGE", "Split_2_1_43/Modified_Edge&Revolution_5_1/From_Edge&Sketch_5/SketchLine_109&Filling_1_1/Edge_0_4")], model.selection("EDGE", "Sketch_2/SketchLine_34"), 360, 0) + +### Create Symmetry +Symmetry_6 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Revolution_8")], model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Split +Split_3 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Split_2")], [model.selection("COMPOUND", "all-in-Symmetry_6")], keepSubResults = True) + +### Create Sketch +Sketch_8 = model.addSketch(Part_1_doc, model.standardPlane("YOZ")) + +### Create SketchLine +SketchLine_72 = Sketch_8.addLine(5.126644475052088, 10.62934617154252, 5.215654385578071, 10.78090722433818) +SketchLine_72.setName("SketchLine_74") +SketchLine_72.result().setName("SketchLine_74") + +### Create SketchLine +SketchLine_73 = Sketch_8.addLine(5.405090045827155, 10.43837553323928, 5.525091876190383, 10.61334472455802) +SketchLine_73.setName("SketchLine_76") +SketchLine_73.result().setName("SketchLine_76") + +### Create SketchLine +SketchLine_74 = Sketch_8.addLine(6.082, 9.532, 6.535000000000001, 9.532) +SketchLine_74.setName("SketchLine_78") +SketchLine_74.result().setName("SketchLine_78") +Sketch_8.setHorizontal(SketchLine_74.result()) + +### Create SketchProjection +SketchProjection_16 = Sketch_8.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_25"), False) +SketchProjection_16.setName("SketchProjection_33") +SketchProjection_16.result().setName("SketchProjection_33") +SketchLine_75 = SketchProjection_16.createdFeature() +SketchLine_75.setName("SketchLine_116") +SketchLine_75.result().setName("SketchLine_116") + +### Create SketchProjection +SketchProjection_17 = Sketch_8.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_24"), False) +SketchProjection_17.setName("SketchProjection_38") +SketchProjection_17.result().setName("SketchProjection_38") +SketchLine_76 = SketchProjection_17.createdFeature() +SketchLine_76.setName("SketchLine_117") +SketchLine_76.result().setName("SketchLine_117") + +### Create SketchProjection +SketchProjection_18 = Sketch_8.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_23"), False) +SketchProjection_18.setName("SketchProjection_39") +SketchProjection_18.result().setName("SketchProjection_39") +SketchLine_77 = SketchProjection_18.createdFeature() +SketchLine_77.setName("SketchLine_118") +SketchLine_77.result().setName("SketchLine_118") + +### Create SketchProjection +SketchProjection_19 = Sketch_8.addProjection(model.selection("EDGE", "Split_2_1_17/Modified_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchArc_2_2"), False) +SketchProjection_19.setName("SketchProjection_40") +SketchProjection_19.result().setName("SketchProjection_40") +SketchBSpline_1 = SketchProjection_19.createdFeature() + +### Create SketchProjection +SketchProjection_20 = Sketch_8.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_19"), False) +SketchProjection_20.setName("SketchProjection_41") +SketchProjection_20.result().setName("SketchProjection_41") +SketchLine_78 = SketchProjection_20.createdFeature() +SketchLine_78.setName("SketchLine_119") +SketchLine_78.result().setName("SketchLine_119") +Sketch_8.setCoincident(SketchLine_74.endPoint(), SketchLine_78.result()) +Sketch_8.setCoincident(SketchLine_74.startPoint(), SketchAPI_BSpline(SketchBSpline_1).startPoint()) + +### Create SketchLine +SketchLine_79 = Sketch_8.addLine(5.676067550792231, 10.23944020672391, 5.829536340268943, 10.44848598250872) +SketchLine_79.setName("SketchLine_120") +SketchLine_79.result().setName("SketchLine_120") +Sketch_8.setCoincident(SketchAPI_Line(SketchLine_77).endPoint(), SketchLine_79.startPoint()) + +### Create SketchProjection +SketchProjection_21 = Sketch_8.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_21"), False) +SketchProjection_21.setName("SketchProjection_42") +SketchProjection_21.result().setName("SketchProjection_42") +SketchLine_80 = SketchProjection_21.createdFeature() +SketchLine_80.setName("SketchLine_121") +SketchLine_80.result().setName("SketchLine_121") +Sketch_8.setCoincident(SketchLine_79.endPoint(), SketchLine_80.result()) +Sketch_8.setPerpendicular(SketchLine_79.result(), SketchLine_77.result()) +Sketch_8.setPerpendicular(SketchLine_73.result(), SketchLine_76.result()) +Sketch_8.setPerpendicular(SketchLine_72.result(), SketchLine_75.result()) +Sketch_8.setCoincident(SketchLine_73.startPoint(), SketchAPI_Line(SketchLine_76).endPoint()) +Sketch_8.setCoincident(SketchLine_72.startPoint(), SketchAPI_Line(SketchLine_75).endPoint()) +Sketch_8.setCoincident(SketchLine_72.endPoint(), SketchLine_80.result()) +Sketch_8.setCoincident(SketchLine_73.endPoint(), SketchLine_80.result()) +model.do() + +### Create Revolution +Revolution_9 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_8")], model.selection("EDGE", "PartSet/OZ"), 360, 0, "Edges") + +### Create Split +Split_4 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Split_3")], [model.selection("COMPOUND", "all-in-Revolution_9")], keepSubResults = True) + +### Create Sketch +Sketch_9 = model.addSketch(Part_1_doc, model.selection("FACE", "Partition_1_1_2/Modified_Face&Sketch_1/SketchLine_4")) + +### Create SketchLine +SketchLine_81 = Sketch_9.addLine(5.502704971193711, -5.502704971193713, 3.192087844797337, -3.192087844797337) +SketchLine_81.setName("SketchLine_87") +SketchLine_81.result().setName("SketchLine_87") + +### Create SketchProjection +SketchProjection_22 = Sketch_9.addProjection(model.selection("EDGE", "[Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_5][Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_4]"), False) +SketchProjection_22.setName("SketchProjection_26") +SketchProjection_22.result().setName("SketchProjection_26") +SketchArc_13 = SketchProjection_22.createdFeature() +Sketch_9.setCoincident(SketchLine_81.startPoint(), SketchArc_13.results()[1]) + +### Create SketchLine +SketchLine_82 = Sketch_9.addLine(3.192087844797337, -3.192087844797337, 3.891, 0) +SketchLine_82.setName("SketchLine_88") +SketchLine_82.result().setName("SketchLine_88") +Sketch_9.setCoincident(SketchLine_81.endPoint(), SketchLine_82.startPoint()) + +### Create SketchProjection +SketchProjection_23 = Sketch_9.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/XOZ/XOZ&Sketch_1/SketchLine_4"), False) +SketchProjection_23.setName("SketchProjection_27") +SketchProjection_23.result().setName("SketchProjection_27") +SketchLine_83 = SketchProjection_23.createdFeature() +SketchLine_83.setName("SketchLine_89") +SketchLine_83.result().setName("SketchLine_89") +Sketch_9.setCoincident(SketchLine_82.endPoint(), SketchLine_83.result()) + +### Create SketchLine +SketchLine_84 = Sketch_9.addLine(3.192087844797337, -3.192087844797337, 0, -3.891) +SketchLine_84.setName("SketchLine_90") +SketchLine_84.result().setName("SketchLine_90") +Sketch_9.setCoincident(SketchLine_81.endPoint(), SketchLine_84.startPoint()) + +### Create SketchProjection +SketchProjection_24 = Sketch_9.addProjection(model.selection("EDGE", "Partition_1_1_4/Generated_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_4"), False) +SketchProjection_24.setName("SketchProjection_28") +SketchProjection_24.result().setName("SketchProjection_28") +SketchLine_85 = SketchProjection_24.createdFeature() +SketchLine_85.setName("SketchLine_91") +SketchLine_85.result().setName("SketchLine_91") +Sketch_9.setCoincident(SketchLine_84.endPoint(), SketchLine_85.result()) +Sketch_9.setEqual(SketchLine_84.result(), SketchLine_81.result()) +Sketch_9.setEqual(SketchLine_81.result(), SketchLine_82.result()) +Sketch_9.setMiddlePoint(SketchLine_84.endPoint(), SketchLine_85.result()) +Sketch_9.setMiddlePoint(SketchLine_82.endPoint(), SketchLine_83.result()) +Sketch_9.setMiddlePoint(SketchLine_81.startPoint(), SketchArc_13.results()[1]) + +### Create SketchMultiRotation +SketchMultiRotation_1_objects = [SketchLine_81.result(), SketchLine_84.result(), SketchLine_82.result()] +SketchMultiRotation_1 = Sketch_9.addRotation(SketchMultiRotation_1_objects, SketchAPI_Line(SketchLine_83).endPoint(), 360, 4, True) +[SketchLine_86, SketchLine_87, SketchLine_88, SketchLine_89, SketchLine_90, SketchLine_91, SketchLine_92, SketchLine_93, SketchLine_94] = SketchMultiRotation_1.rotated() +SketchLine_94.setName("SketchLine_100") +SketchLine_94.result().setName("SketchLine_100") +SketchLine_93.setName("SketchLine_99") +SketchLine_93.result().setName("SketchLine_99") +SketchLine_92.setName("SketchLine_98") +SketchLine_92.result().setName("SketchLine_98") +SketchLine_91.setName("SketchLine_97") +SketchLine_91.result().setName("SketchLine_97") +SketchLine_90.setName("SketchLine_96") +SketchLine_90.result().setName("SketchLine_96") +SketchLine_89.setName("SketchLine_95") +SketchLine_89.result().setName("SketchLine_95") +SketchLine_88.setName("SketchLine_94") +SketchLine_88.result().setName("SketchLine_94") +SketchLine_87.setName("SketchLine_93") +SketchLine_87.result().setName("SketchLine_93") +SketchLine_86.setName("SketchLine_92") +SketchLine_86.result().setName("SketchLine_92") +model.do() + +### Create Extrusion +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_9")], model.selection(), model.selection("FACE", "Partition_1_1_4/Modified_Face&Sketch_1/SketchLine_2"), 0, model.selection(), 0, "Edges") + +### Create Plane +Plane_8 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/OZ"), model.selection("VERTEX", "Split_2_1_10/Modified_Vertex&Sketch_7/SketchLine_83_StartVertex&Sketch_7/SketchLine_65_StartVertex"), False) + +### Create Split +Split_5 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Split_4")], [model.selection("COMPOUND", "all-in-Extrusion_3")], keepSubResults = True) + +### Create Sketch +Sketch_10 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_5")) + +### Create SketchProjection +SketchProjection_25 = Sketch_10.addProjection(model.selection("VERTEX", "Split_2_1_10/Modified_Vertex&Sketch_7/SketchLine_83_StartVertex&Sketch_7/SketchLine_65_StartVertex"), False) +SketchProjection_25.setName("SketchProjection_35") +SketchProjection_25.result().setName("SketchProjection_35") +SketchPoint_23 = SketchProjection_25.createdFeature() +SketchPoint_23.setName("SketchPoint_27") +SketchPoint_23.result().setName("SketchPoint_27") + +### Create SketchLine +SketchLine_95 = Sketch_10.addLine(-7.781999999999998, -3.45, -3.801997755365569, -3.45) +SketchLine_95.setName("SketchLine_107") +SketchLine_95.result().setName("SketchLine_107") + +### Create SketchLine +SketchLine_96 = Sketch_10.addLine(-6.188000000000001, -3.45, -6.538000000000001, -3.45) +SketchLine_96.setName("SketchLine_108") +SketchLine_96.result().setName("SketchLine_108") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_16 = Sketch_10.addIntersectionPoint(model.selection("EDGE", "[Split_5_1_21/Modified_Face&Sketch_1/SketchLine_5&new_weak_name_1][(Split_5_1_21/Modified_Face&PartSet/XOZ/XOZ)(Split_5_1_21/Modified_Face&Sketch_1/SketchLine_7)(Split_5_1_21/Modified_Face&Extrusion_3_1_5/Extrusion_3_1_5)]"), True) +SketchIntersectionPoint_16.setName("SketchIntersectionPoint_17") +SketchIntersectionPoint_16.result().setName("SketchIntersectionPoint_17") +[SketchPoint_24] = SketchIntersectionPoint_16.intersectionPoints() +SketchPoint_24.setName("SketchPoint_25") +SketchPoint_24.result().setName("SketchPoint_25") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_17 = Sketch_10.addIntersectionPoint(model.selection("EDGE", "Extrusion_3_1_11/To_Edge"), True) +SketchIntersectionPoint_17.setName("SketchIntersectionPoint_18") +SketchIntersectionPoint_17.result().setName("SketchIntersectionPoint_18") +[SketchPoint_25] = SketchIntersectionPoint_17.intersectionPoints() +SketchPoint_25.setName("SketchPoint_26") +SketchPoint_25.result().setName("SketchPoint_26") +Sketch_10.setCoincident(SketchLine_95.startPoint(), SketchAPI_Point(SketchPoint_24).coordinates()) +Sketch_10.setCoincident(SketchLine_95.endPoint(), SketchAPI_Point(SketchPoint_25).coordinates()) + +### Create SketchIntersectionPoint +SketchIntersectionPoint_18 = Sketch_10.addIntersectionPoint(model.selection("EDGE", "[(Split_5_1_21/Modified_Face&PartSet/XOZ/XOZ)(Split_5_1_21/Modified_Face&Sketch_1/SketchLine_7)(Split_5_1_21/Modified_Face&Extrusion_3_1_5/Extrusion_3_1_5)][Split_5_1_21/Modified_Face&Sketch_1/SketchLine_7]"), True) +SketchIntersectionPoint_18.setName("SketchIntersectionPoint_19") +SketchIntersectionPoint_18.result().setName("SketchIntersectionPoint_19") +[SketchPoint_26] = SketchIntersectionPoint_18.intersectionPoints() +SketchPoint_26.setName("SketchPoint_28") +SketchPoint_26.result().setName("SketchPoint_28") + +### Create SketchIntersectionPoint +SketchIntersectionPoint_19 = Sketch_10.addIntersectionPoint(model.selection("EDGE", "[Split_5_1_21/Modified_Face&Sketch_1/SketchLine_1][(Split_5_1_21/Modified_Face&PartSet/XOZ/XOZ)(Split_5_1_21/Modified_Face&Sketch_1/SketchLine_1)(Split_5_1_21/Modified_Face&Extrusion_3_1_11/Extrusion_3_1_11)(Split_5_1_21/Modified_Face&Extrusion_3_1_5/Extrusion_3_1_5)]"), True) +SketchIntersectionPoint_19.setName("SketchIntersectionPoint_20") +SketchIntersectionPoint_19.result().setName("SketchIntersectionPoint_20") +[SketchPoint_27] = SketchIntersectionPoint_19.intersectionPoints() +SketchPoint_27.setName("SketchPoint_29") +SketchPoint_27.result().setName("SketchPoint_29") +Sketch_10.setCoincident(SketchAPI_Point(SketchPoint_26).coordinates(), SketchLine_96.endPoint()) +Sketch_10.setCoincident(SketchAPI_Point(SketchPoint_27).coordinates(), SketchLine_96.startPoint()) +model.do() +Sketch_10.result().setName("Sketch_10_Copy") + +### Create Filling +Filling_4 = model.addFilling(Part_1_doc, [model.selection("EDGE", "Sketch_10_Copy/SketchLine_108"), model.selection("EDGE", "Split_2_1_9/Modified_Edge&Filling_3_1/Edge_0_2")]) + +### Create Extrusion +Extrusion_4 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Sketch_10_Copy/SketchLine_107")], model.selection("EDGE", "PartSet/OZ"), model.selection("FACE", "(Split_5_1_21/Modified_Face&PartSet/XOZ/XOZ)(Split_5_1_21/Modified_Face&Extrusion_3_1_11/Extrusion_3_1_11)(Split_5_1_21/Modified_Face&Extrusion_3_1_5/Extrusion_3_1_5)(Split_5_1_21/Modified_Face&Sketch_1/SketchLine_7)2(Partition_1_1_1/Modified_Face&Sketch_1/SketchLine_8)2(Split_2_1_8/Modified_Face&Sketch_1/SketchLine_9)2(Split_5_1_21/Modified_Face&Sketch_1/SketchLine_1)2(Split_5_1_21/Modified_Face&PartSet/YOZ/YOZ)2(Split_5_1_21/Modified_Face&Extrusion_3_1_8/Extrusion_3_1_8)2"), 0, model.selection(), 0) + +### Create Sketch +Sketch_11 = model.addSketch(Part_1_doc, model.selection("FACE", "Sketch_9/Face-SketchLine_88f-SketchLine_95r-SketchLine_98f-SketchLine_96r-SketchLine_99f-SketchLine_97r-SketchLine_100f-SketchLine_90r")) + +### Create SketchLine +SketchLine_97 = Sketch_11.addLine(-3.693983753048041, 0.8998171836933224, 0, 1.098155695798001) +SketchLine_97.setName("SketchLine_111") +SketchLine_97.result().setName("SketchLine_111") + +### Create SketchProjection +SketchProjection_26 = Sketch_11.addProjection(model.selection("VERTEX", "[Extrusion_4_1/To_Edge]e[Extrusion_4_1/Generated_Edge&Sketch_10_Copy/SketchLine_107_EndVertex]e"), False) +SketchProjection_26.setName("SketchProjection_34") +SketchProjection_26.result().setName("SketchProjection_34") +SketchPoint_28 = SketchProjection_26.createdFeature() +SketchPoint_28.setName("SketchPoint_30") +SketchPoint_28.result().setName("SketchPoint_30") +Sketch_11.setCoincident(SketchLine_97.startPoint(), SketchPoint_28.result()) + +### Create SketchProjection +SketchProjection_27 = Sketch_11.addProjection(model.selection("EDGE", "Split_5_1_20/Modified_Edge&PartSet/YOZ/YOZ&Sketch_1/SketchLine_4"), False) +SketchProjection_27.setName("SketchProjection_29") +SketchProjection_27.result().setName("SketchProjection_29") +SketchLine_98 = SketchProjection_27.createdFeature() +SketchLine_98.setName("SketchLine_101") +SketchLine_98.result().setName("SketchLine_101") +Sketch_11.setCoincident(SketchLine_97.endPoint(), SketchLine_98.result()) +Sketch_11.setDistance(SketchAPI_Line(SketchLine_98).startPoint(), SketchLine_97.result(), "0.921*3.891/3.268", True) +model.do() + +### Create Extrusion +Extrusion_5 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_11")], model.selection("EDGE", "PartSet/OZ"), model.selection("FACE", "Split_5_1_20/Modified_Face&Sketch_1/SketchLine_2"), 0, model.selection(), 0, "Edges") + +### Create Symmetry +Symmetry_7_objects = [model.selection("FACE", "Extrusion_5_1"), + model.selection("FACE", "Extrusion_4_1"), + model.selection("FACE", "Filling_4_1")] +Symmetry_7 = model.addSymmetry(Part_1_doc, Symmetry_7_objects, model.selection("FACE", "PartSet/YOZ"), keepOriginal = True, keepSubResults = True) + +### Create Symmetry +Symmetry_8 = model.addSymmetry(Part_1_doc, [model.selection("COMPOUND", "all-in-Symmetry_7")], model.selection("FACE", "PartSet/XOZ"), keepOriginal = True, keepSubResults = True) + +### Create Split +Split_6 = model.addSplit(Part_1_doc, [model.selection("COMPOUND", "all-in-Split_5")], [model.selection("COMPOUND", "all-in-Symmetry_8")], keepSubResults = True) + +model.end() + +from GeomAPI import * + +model.testNbResults(Split_6, 1) +model.testNbSubResults(Split_6, [116]) +model.testNbSubShapes(Split_6, GeomAPI_Shape.SOLID, [116]) +model.testNbSubShapes(Split_6, GeomAPI_Shape.FACE, [856]) +model.testNbSubShapes(Split_6, GeomAPI_Shape.EDGE, [3636]) +model.testNbSubShapes(Split_6, GeomAPI_Shape.VERTEX, [7272]) +model.testResultsVolumes(Split_6, [612.72746616262998]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/Test20247.py b/src/FeaturesPlugin/Test/Test20247.py new file mode 100644 index 000000000..ce7d0ea46 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test20247.py @@ -0,0 +1,60 @@ +# Copyright (C) 2020 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() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Box +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) + +### Create Translation +Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], vector = [200, 100, 0], keepSubResults = True) + +### Create Plane +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Translation_1_1/MF:Translated&Box_1_1/Top"), 3, False) + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(205, 105, 3) +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Translation_1_1/MF:Translated&Box_1_1/Top"), 0, model.selection(), 0, "Faces|Wires") + +model.end() + +from GeomAPI import * + +model.testNbResults(Extrusion_1, 1) +model.testNbSubResults(Extrusion_1, [0]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [3]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [6]) +model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [12]) +model.testResultsVolumes(Extrusion_1, [84.823001647]) + +assert(model.checkPythonDump()) diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut_ThroughAll.py b/src/FeaturesPlugin/Test/TestExtrusionCut_ThroughAll.py index 54e0f6fd4..e19da51a6 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut_ThroughAll.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut_ThroughAll.py @@ -64,7 +64,7 @@ SketchCircle_3 = Sketch_3.addCircle(7, 2, 1.5) ExtrusionCut_3.setNestedSketch(Sketch_3) model.do() Shape = ExtrusionCut_3.results()[0].resultSubShapePair()[0].shape() -checkMiddlePoint(Shape, 5.00008072, 5.079732786, 5.08050663) +checkMiddlePoint(Shape, 5.00008072, 5.079732577, 5.08050677) model.end() diff --git a/src/FeaturesPlugin/doc/FeaturesPlugin.rst b/src/FeaturesPlugin/doc/FeaturesPlugin.rst index fb8e2a344..d3d384b68 100644 --- a/src/FeaturesPlugin/doc/FeaturesPlugin.rst +++ b/src/FeaturesPlugin/doc/FeaturesPlugin.rst @@ -18,8 +18,8 @@ Features plug-in provides a set of common topological operations. It implements extrusionCutFeature.rst extrusionFeature.rst extrusionFuseFeature.rst - fillet1dFeature.rst filletFeature.rst + fillet1dFeature.rst fuseFeatureFaces.rst importResultFeature.rst linearCopyFeature.rst diff --git a/src/FeaturesPlugin/doc/images/Fillet.png b/src/FeaturesPlugin/doc/images/Fillet.png deleted file mode 100644 index 3b5a98289..000000000 Binary files a/src/FeaturesPlugin/doc/images/Fillet.png and /dev/null differ diff --git a/src/FeaturesPlugin/doc/images/Split_panel.png b/src/FeaturesPlugin/doc/images/Split_panel.png new file mode 100644 index 000000000..7673ef4a3 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/Split_panel.png differ diff --git a/src/FeaturesPlugin/doc/images/Symmetry.png b/src/FeaturesPlugin/doc/images/Symmetry.png deleted file mode 100644 index fdc73b21c..000000000 Binary files a/src/FeaturesPlugin/doc/images/Symmetry.png and /dev/null differ diff --git a/src/FeaturesPlugin/doc/splitFeature.rst b/src/FeaturesPlugin/doc/splitFeature.rst index 61970dcd5..d31bee857 100644 --- a/src/FeaturesPlugin/doc/splitFeature.rst +++ b/src/FeaturesPlugin/doc/splitFeature.rst @@ -15,7 +15,7 @@ To perform Split in the active part: The following property panel will be opened: -.. figure:: images/Split.png +.. figure:: images/Split_panel.png :align: center **Split operation** diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index 94a9d4bc3..4a566d21e 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -4,8 +4,8 @@ label="Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> -3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it." - shape_types="Vertices Edges Faces" +3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it." + shape_types="Vertices Edges Faces|Wires" type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png" default_type = "2" use_choice="true"> @@ -14,7 +14,7 @@ @@ -16,7 +16,7 @@ label="Select a sketch face" icon="icons/Features/sketch.png" tooltip="Select a sketch face" - shape_types="Vertices Edges Faces" + shape_types="Vertices Edges Faces|Wire" type_icons=":/icons/extrusion_vertex32.png :/icons/extrusion_edge32.png :/icons/extrusion_face32.png" default_type = "2" use_choice="true" diff --git a/src/FeaturesPlugin/pipe_widget.xml b/src/FeaturesPlugin/pipe_widget.xml index f3ad50514..ce17e7cd1 100644 --- a/src/FeaturesPlugin/pipe_widget.xml +++ b/src/FeaturesPlugin/pipe_widget.xml @@ -2,6 +2,7 @@ diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index ba80beedd..08c08b775 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -134,7 +134,7 @@ + icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="fuseFeatureFaces.html"> (exc))), SWIGTYPE_p_GeomAlgoAPI_Exception, SWIG_POINTER_OWN), "GeomAlgoAPI_Exception", SWIGTYPE_p_GeomAlgoAPI_Exception); + SWIG_fail; + } +} + // shared pointers %shared_ptr(GeomAlgoAPI_Boolean) %shared_ptr(GeomAlgoAPI_Intersection) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp index 558e3fd90..8a70c92b8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp @@ -26,12 +26,12 @@ GeomAlgoAPI_Exception::GeomAlgoAPI_Exception(std::string theMessageError) } //================================================================================================= -GeomAlgoAPI_Exception::~GeomAlgoAPI_Exception() throw() +GeomAlgoAPI_Exception::~GeomAlgoAPI_Exception() noexcept { } //================================================================================================= -const char* GeomAlgoAPI_Exception::what() const throw() +const char* GeomAlgoAPI_Exception::what() const noexcept { return myMessageError.c_str(); -} \ No newline at end of file +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h index 669d30962..023ced1a7 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h @@ -35,13 +35,13 @@ class GeomAlgoAPI_Exception : public std::exception /// \param theMessageError Error message to be displayed GEOMALGOAPI_EXPORT GeomAlgoAPI_Exception(std::string theMessageError); /// Destroyer - GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Exception() throw(); + GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Exception() noexcept; /// Allows to collet the error - GEOMALGOAPI_EXPORT const char* what() const throw(); + GEOMALGOAPI_EXPORT const char* what() const noexcept; private: std::string myMessageError; /// Error message to be displayed. }; -#endif \ No newline at end of file +#endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 50b2ef2b1..6903fbdb6 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -416,6 +416,8 @@ void GeomAlgoAPI_Prism::buildByPlanes(const GeomShapePtr theBaseShap TopoDS_Shape aResult = aPrismBuilder->Shape(); BRepBndLib::Add(aResult, aBndBox); + aBndBox.Add(aFromPnt->impl()); + aBndBox.Add(aToPnt->impl()); Standard_Real aBndBoxSize = aBndBox.CornerMin().Distance(aBndBox.CornerMax()); // Orienting bounding planes. diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp index 193dcbfbb..4773b1e22 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp @@ -70,6 +70,9 @@ static gp_Pnt centreOfMass(const TopoDS_Shape& theShape); /// \return solid. static TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint); +/// \brief Create plane by 3 points. Return empty handle if failed. +static Handle(Geom_Plane) makePlane(const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3); + static void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, const TopoDS_Shape& theBase, const TopAbs_ShapeEnum theType, @@ -146,31 +149,21 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr& theBaseSh aBasePlane = aFindPlane.Plane(); } else { gp_Pnt aPnt1 = anAxis.Location(); - gp_Pnt aPnt2 = aPnt1; - aPnt2.Translate(anAxis.Direction()); - gp_Pnt aPnt3; - - for(TopExp_Explorer anExp(aBaseShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) { - aPnt3 = BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())); - GC_MakePlane aMkPlane(aPnt1, aPnt2, aPnt3); - if(aMkPlane.IsDone() != Standard_True) { - continue; - } + TopExp_Explorer anExp(aBaseShape, TopAbs_VERTEX); + gp_Pnt aPnt2 = BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())); + gp_Pnt aPnt3 = aPnt1; - aBasePlane = aMkPlane.Value(); - break; + for (anExp.Next(); anExp.More() && aBasePlane.IsNull(); anExp.Next()) { + aPnt3 = BRep_Tool::Pnt(TopoDS::Vertex(anExp.Current())); + aBasePlane = makePlane(aPnt1, aPnt2, aPnt3); } if(aBasePlane.IsNull()) { - aPnt3 = centreOfMass(aBaseShape); - - GC_MakePlane aMkPlane(aPnt1, aPnt2, aPnt3); - if(aMkPlane.IsDone() != Standard_True) { - return; - } - - aBasePlane = aMkPlane.Value(); + gp_Pnt aPossiblePoints[] = { aPnt1.Translated(anAxis.Direction()), centreOfMass(aBaseShape) }; + for (auto it = std::begin(aPossiblePoints); + it != std::end(aPossiblePoints) && aBasePlane.IsNull(); ++it) + aBasePlane = makePlane(aPnt1, aPnt2, *it); } } @@ -591,6 +584,16 @@ TopoDS_Shape findClosest(const TopoDS_Shape& theShape, const gp_Pnt& thePoint) return aResult; } +//================================================================================================ +Handle(Geom_Plane) makePlane(const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3) +{ + Handle(Geom_Plane) aPlane; + GC_MakePlane aMkPlane(theP1, theP2, theP3); + if (aMkPlane.IsDone()) + aPlane = aMkPlane.Value(); + return aPlane; +} + //================================================================================================ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, const TopoDS_Shape& theBase, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp index 3a824f106..479c213a1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp @@ -18,6 +18,7 @@ // #include +#include #include #include @@ -31,6 +32,8 @@ #include #include #include + +#include #include #include #include @@ -54,17 +57,57 @@ #include #include #include -#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC +#include -#include +//================================================================================================= +bool readUnits(STEPControl_Reader& aReader, + const bool theScalInterUnits, + std::string& theError) +{ + // Regard or not the model units + if (!theScalInterUnits) { + // set UnitFlag to units from file + TColStd_SequenceOfAsciiString anUnitLengthNames; + TColStd_SequenceOfAsciiString anUnitAngleNames; + TColStd_SequenceOfAsciiString anUnitSolidAngleNames; + aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); + if (anUnitLengthNames.Length() > 0) { + TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); + if (aLenUnits == "millimetre") + Interface_Static::SetCVal("xstep.cascade.unit", "MM"); + else if (aLenUnits == "centimetre") + Interface_Static::SetCVal("xstep.cascade.unit", "CM"); + else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) + Interface_Static::SetCVal("xstep.cascade.unit", "M"); + else if (aLenUnits == "INCH") + Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); + else { + theError = "The file contains not supported units."; + return false; + } + // TODO (for other units than mm, cm, m or inch) + //else if (aLenUnits == "") + // Interface_Static::SetCVal("xstep.cascade.unit", "???"); + } + } + else { + //cout<<"need re-scale a model"< -#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//================================================================================================== std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, + const bool theScalInterUnits, std::string& theError) { + TopoDS_Shape aResShape; // Set "C" numeric locale to save numbers correctly @@ -87,39 +130,11 @@ std::shared_ptr STEPImport(const std::string& theFileName, IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.c_str()); if (status == IFSelect_RetDone) { - // Regard or not the model units - if (theFormatName == "STEP_SCALE") { - // set UnitFlag to units from file - TColStd_SequenceOfAsciiString anUnitLengthNames; - TColStd_SequenceOfAsciiString anUnitAngleNames; - TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); - if (anUnitLengthNames.Length() > 0) { - TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); - if (aLenUnits == "millimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "MM"); - else if (aLenUnits == "centimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "CM"); - else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) - Interface_Static::SetCVal("xstep.cascade.unit", "M"); - else if (aLenUnits == "INCH") - Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); - else { - theError = "The file contains not supported units."; - std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape(aResShape)); - return aGeomShape; - } - // TODO (for other units than mm, cm, m or inch) - //else if (aLenUnits == "") - // Interface_Static::SetCVal("xstep.cascade.unit", "???"); - } - } - else { - //cout<<"need re-scale a model"< aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; } Standard_Boolean failsonly = Standard_False; @@ -194,3 +209,63 @@ std::shared_ptr STEPImport(const std::string& theFileName, aGeomShape->setImpl(new TopoDS_Shape(aResShape)); return aGeomShape; } + +//================================================================================================== +GeomShapePtr STEPImportAttributs(const std::string& theFileName, + std::shared_ptr theResultBody, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor, + std::map< std::wstring, + std::list>& theMaterialShape, + std::string& theError) +{ + + try { + STEPControl_Reader aReader; + std::shared_ptr aGeomShape(new GeomAPI_Shape); + + Interface_Static::SetCVal("xstep.cascade.unit","M"); + Interface_Static::SetIVal("read.step.ideas", 1); + Interface_Static::SetIVal("read.step.nonmanifold", 1); + + try { + OCC_CATCH_SIGNALS; + + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.c_str()); + + if (status == IFSelect_RetDone) { + // Regard or not the model units + if( !readUnits(aReader,theScalInterUnits,theError)) { + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; + } + } + } catch (Standard_Failure const& anException) { + theError = anException.GetMessageString(); + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; + } + + STEPCAFControl_Reader aCafreader; + aCafreader.SetColorMode(true); + aCafreader.SetNameMode(true); + aCafreader.SetMatMode(true); + + if (aCafreader.ReadFile(theFileName.c_str()) != IFSelect_RetDone) { + theError = "Wrong format of the imported file. Can't import file."; + std::shared_ptr aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; + } + + return readAttributes(aCafreader, + theResultBody, + theMaterials, + theMaterialShape, + theError); + } catch (OSD_Exception& e) { + //Try to load STEP file without colors... + return STEPImport(theFileName,"",theScalInterUnits,theError); + } +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h index 470791a3b..5740fc520 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h @@ -23,13 +23,27 @@ #include #include - #include +#include + + /// Implementation of the import STEP files algorithms GEOMALGOAPI_EXPORT std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, + const bool theScalInterUnits, std::string& theError); +/// Implementation of the import STEP files algorithms with Attributs (Name, Color, Materials) +GEOMALGOAPI_EXPORT +GeomShapePtr STEPImportAttributs(const std::string& theFileName, + std::shared_ptr theResultBody, + const bool theScalInterUnits, + const bool theMaterials, + const bool theColor, + std::map< std::wstring, + std::list>& theMaterialShape, + std::string& theError); + #endif /* GEOMALGOAPI_STEPIMPORT_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp new file mode 100644 index 000000000..b77defd14 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.cpp @@ -0,0 +1,409 @@ +// Copyright (C) 2014-2020 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 + +//============================================================================= +TopoDS_Shape getShape(const Handle(Standard_Transient) &theEnti, + const Handle(Transfer_TransientProcess) &theTP) +{ + TopoDS_Shape aResult; + Handle(Transfer_Binder) aBinder = theTP->Find(theEnti); + + if (aBinder.IsNull()) { + return aResult; + } + + aResult = TransferBRep::ShapeResult(aBinder); + + return aResult; +} + +//============================================================================= +std::shared_ptr readAttributes(STEPCAFControl_Reader &theReader, + std::shared_ptr theResultBody, + const bool theIsMaterials, + std::map< std::wstring,std::list> &theMaterialShape, + std::string& theError) +{ + // dummy XCAF Application to handle the STEP XCAF Document + Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication(); + // XCAF Document to contain the STEP/IGES file itself + Handle(TDocStd_Document) adoc; + + dummy_app->NewDocument( TCollection_ExtendedString("MDTV-CAF"), adoc); + // transfer STEP/IGES into the document, and get the main label + theReader.Transfer(adoc); + TDF_Label mainLabel = adoc->Main(); + Handle_XCAFDoc_ShapeTool shapeTool = XCAFDoc_DocumentTool::ShapeTool(mainLabel); + Handle_XCAFDoc_ColorTool colorTool = XCAFDoc_DocumentTool::ColorTool(mainLabel); + Handle(XCAFDoc_MaterialTool) materialTool = XCAFDoc_DocumentTool::MaterialTool(mainLabel); + // traverse the labels recursively to set attributes on shapes + setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel, + TopLoc_Location(),theResultBody,theMaterialShape,false); + + std::shared_ptr ageom = setgeom(shapeTool,mainLabel,theError); + + STEPControl_Reader aReader = theReader.ChangeReader(); + + // BEGIN: reading materials of sub-shapes from file + if ( theIsMaterials ) + { + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(ageom->impl(), anIndices); + + Handle(Interface_InterfaceModel) Model = aReader.WS()->Model(); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if (!TR.IsNull()) { + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + + Standard_Integer nb = Model->NbEntities(); + + for (Standard_Integer ie = 1; ie <= nb; ie++) { + Handle(Standard_Transient) enti = Model->Value(ie); + + // Store materials. + storeMaterial(theResultBody,enti, anIndices, TP, mainLabel,theMaterialShape); + } + } + } + if (adoc->CanClose() == CDM_CCS_OK) + adoc->Close(); + return ageom; +} + +//============================================================================= +std::shared_ptr setgeom(const Handle(XCAFDoc_ShapeTool) &theShapeTool, + const TDF_Label &theLabel, + std::string& theError) +{ + BRep_Builder aB; + TopoDS_Compound aCompound; + aB.MakeCompound(aCompound); + + TDF_LabelSequence aFrshapes; + theShapeTool->GetShapes(aFrshapes); + + std::shared_ptr aGeomShape(new GeomAPI_Shape); + + if (aFrshapes.Length() == 0) { + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; + } else if (aFrshapes.Length() == 1) { + TopoDS_Shape shape = theShapeTool->GetShape(aFrshapes.Value(1)); + aGeomShape->setImpl(new TopoDS_Shape(shape)); + return aGeomShape; + } else { + for (Standard_Integer i=1; iGetShape(aFrshapes.Value(i)); + TDF_Label aLabel = theShapeTool->FindShape(aS, Standard_False); + if ( (!aLabel.IsNull()) && (theShapeTool->IsShape(aLabel)) ) { + if (theShapeTool->IsFree(aLabel) ) { + if (aS.IsNull()) { + continue; + } else { + if (!theShapeTool->IsReference(aLabel) ){ + for(TDF_ChildIterator anIt(aLabel); anIt.More(); anIt.Next()) { + aB.Add(aCompound, theShapeTool->GetShape(anIt.Value()) ); + } + } else { + aB.Add(aCompound, aS); + } + } + } + } + } + + TopoDS_Shape aShape = aCompound; + // Check if any BRep entity has been read, there must be at least a vertex + if ( !TopExp_Explorer( aShape, TopAbs_VERTEX ).More() ) + { + theError = "No geometrical data in the imported file."; + std::shared_ptr aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape()); + return aGeomShape; + } + + aGeomShape->setImpl(new TopoDS_Shape(aShape)); + return aGeomShape; + } +} +//============================================================================= +void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool, + const Handle(XCAFDoc_ColorTool) &theColorTool, + const Handle(XCAFDoc_MaterialTool) &theMaterialTool, + const TDF_Label &theLabel, + const TopLoc_Location &theLoc, + std::shared_ptr theResultBody, + std::map< std::wstring,std::list> &theMaterialShape, + bool theIsRef) +{ + std::wstring aShapeName; + Handle(TDataStd_Name) aN; + + if (theLabel.FindAttribute(TDataStd_Name::GetID(), aN)) { + TCollection_ExtendedString aName = aN->Get(); + + aShapeName = Locale::Convert::toWString(TCollection_AsciiString(aName).ToCString()) ; + } + + TopLoc_Location aPartLoc = theLoc; + Handle(XCAFDoc_Location) al; + if (theLabel.FindAttribute(XCAFDoc_Location::GetID(), al)) { + if (theIsRef) + aPartLoc = aPartLoc * al->Get(); + else + aPartLoc = al->Get(); + } + + TDF_Label aRef; + if (theShapeTool->IsReference(theLabel) && theShapeTool->GetReferredShape(theLabel, aRef)) { + + setShapeAttributes( theShapeTool, theColorTool, theMaterialTool, aRef, + aPartLoc,theResultBody,theMaterialShape,true); + } + + if (theShapeTool->IsSimpleShape(theLabel) && (theIsRef || theShapeTool->IsFree(theLabel))) { + + TopoDS_Shape aShape = theShapeTool->GetShape(theLabel); + + std::shared_ptr aShapeGeom(new GeomAPI_Shape); + if (!theLoc.IsIdentity()){ + aShape.Move(theLoc); + } + aShapeGeom->setImpl(new TopoDS_Shape(aShape)); + aShapeName = theResultBody->addShapeName(aShapeGeom, aShapeName); + + + aShape.Location(theIsRef ? theLoc : aPartLoc); + int aDim = + (aShape.ShapeType() == TopAbs_VERTEX) ? + 0 : + (aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE) ? + 1 : + (aShape.ShapeType() == TopAbs_FACE || + aShape.ShapeType() == TopAbs_SHELL) ? 2 :3; + + Handle(TCollection_HAsciiString) aMatName; + Handle(TCollection_HAsciiString) aMatDescription; + Standard_Real aMatDensity; + Handle(TCollection_HAsciiString) aMatDensName; + Handle(TCollection_HAsciiString) aMatDensValType; + + if (theMaterialTool->GetMaterial(theLabel, aMatName, aMatDescription, aMatDensity, + aMatDensName, aMatDensValType)) { + std::wstring aNameMaterial = Locale::Convert::toWString(aMatName->ToCString()); + + theMaterialShape[aNameMaterial].push_back(aShapeName); + } + + Quantity_Color aCol; + if (theColorTool->GetColor(theLabel, XCAFDoc_ColorGen, aCol)) { + double r = aCol.Red(), g = aCol.Green(), b = aCol.Blue(); + std::vector ColRGB = {int(r*255),int(g*255),int(b*255)}; + theResultBody->addShapeColor(aShapeName, ColRGB); + } else if (theColorTool->GetColor(theLabel, XCAFDoc_ColorSurf, aCol)) { + double r = aCol.Red(), g = aCol.Green(), b = aCol.Blue(); + std::vector aColRGB = {int(r*255),int(g*255),int(b*255)}; + theResultBody->addShapeColor(aShapeName, aColRGB); + } else if (theColorTool->GetColor(theLabel, XCAFDoc_ColorCurv, aCol)) { + double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue(); + std::vector aColRGB = {int(aR*255),int(aG*255),int(aB*255)}; + theResultBody->addShapeColor(aShapeName, aColRGB); + } + // check explicit coloring of boundary entities + if (aDim == 3) { + TopExp_Explorer aXp2(aShape, TopAbs_FACE); + while(aXp2.More()) { + if (theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorGen, aCol) || + theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorSurf, aCol) || + theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorCurv, aCol)) { + double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue(); + TopoDS_Face aFace = TopoDS::Face(aXp2.Current()); + std::vector aColRGB = {int(aR*255),int(aG*255),int(aB*255)}; + std::wstringstream aNameFace; + TopoDS_Shape aShapeface = aXp2.Current(); + if (!theLoc.IsIdentity()){ + aShapeface.Move(theLoc); + } + aShapeGeom->setImpl(new TopoDS_Shape(aShapeface)); + theResultBody->addShapeColor( + theResultBody->addShapeName(aShapeGeom , aNameFace.str()), aColRGB); + } + aXp2.Next(); + } + } + if (aDim == 2) { + TopExp_Explorer aXp1(aShape, TopAbs_EDGE); + while(aXp1.More()) { + if (theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorGen, aCol) || + theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorSurf, aCol) || + theColorTool->GetColor(aXp1.Current(), XCAFDoc_ColorCurv, aCol)) { + double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue(); + std::vector aColRGB = {int(aR*255),int(aG*255),int(aB*255)}; + std::wstringstream aNameEdge; + aNameEdge << L"Edge_"<< aShapeName; + aShapeGeom->setImpl(new TopoDS_Shape(aXp1.Current() )); + theResultBody->addShapeColor( + theResultBody->addShapeName(aShapeGeom , aNameEdge.str()), aColRGB); + } + aXp1.Next(); + } + } + } else { + if (!theShapeTool->IsReference(theLabel) ){ + TopoDS_Shape aShape = theShapeTool->GetShape(theLabel); + + std::shared_ptr aShapeGeom(new GeomAPI_Shape); + if (!theLoc.IsIdentity()){ + aShape.Move(theLoc); + } + aShapeGeom->setImpl(new TopoDS_Shape(aShape)); + aShapeName = theResultBody->addShapeName(aShapeGeom, aShapeName); + } + for(TDF_ChildIterator anIt(theLabel); anIt.More(); anIt.Next()) { + + setShapeAttributes( theShapeTool, theColorTool, theMaterialTool, + anIt.Value(), aPartLoc,theResultBody,theMaterialShape, theIsRef); + } + } +} + +//============================================================================= +void storeMaterial( std::shared_ptr theResultBody, + const Handle(Standard_Transient) &theEnti, + const TopTools_IndexedMapOfShape &theIndices, + const Handle(Transfer_TransientProcess) &theTP, + const TDF_Label &theShapeLabel, + std::map< std::wstring, std::list> &theMaterialShape ) +{ + // Treat Product Definition Shape only. + Handle(StepRepr_ProductDefinitionShape) aPDS = + Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti); + Handle(StepBasic_ProductDefinition) aProdDef; + + if (!aPDS.IsNull()) { + // Product Definition Shape ==> Product Definition + aProdDef = aPDS->Definition().ProductDefinition(); + } + + if (!aProdDef.IsNull()) { + // Product Definition ==> Property Definition + const Interface_Graph &aGraph = theTP->Graph(); + Interface_EntityIterator aSubs = aGraph.Sharings(aProdDef); + TopoDS_Shape aShape; + + for(aSubs.Start(); aSubs.More(); aSubs.Next()) { + Handle(StepRepr_PropertyDefinition) aPropD = + Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value()); + + if (!aPropD.IsNull()) { + // Property Definition ==> Representation. + Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD); + + for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) { + Handle(StepRepr_PropertyDefinitionRepresentation) aPDR = + Handle(StepRepr_PropertyDefinitionRepresentation):: + DownCast(aSubs1.Value()); + + if (!aPDR.IsNull()) { + // Property Definition ==> Material Name. + Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation(); + + if (!aRepr.IsNull()) { + Standard_Integer anIr; + + for(anIr = 1; anIr <= aRepr->NbItems(); anIr++) { + Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(anIr); + Handle(StepRepr_DescriptiveRepresentationItem) aDRI = + Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI); + + if (!aDRI.IsNull()) { + // Get shape from Product Definition + Handle(TCollection_HAsciiString) aMatName = aDRI->Name(); + if (!aMatName.IsNull()) { + TCollection_ExtendedString + aMatNameExt (aMatName->ToCString()); + + if (aShape.IsNull()) { + //Get the shape. + aShape = getShape(aProdDef, theTP); + if (aShape.IsNull()) { + return; + } + } + + // as PRODUCT can be included in the main shape + // several times, we look here for all iclusions. + Standard_Integer anISub, aNbSubs = theIndices.Extent(); + + for (anISub = 1; anISub <= aNbSubs; anISub++) { + TopoDS_Shape aSub = theIndices.FindKey(anISub); + + if (aSub.IsPartner(aShape)) { + std::shared_ptr aShapeGeom(new GeomAPI_Shape); + aShapeGeom->setImpl(new TopoDS_Shape(aSub)); + std::wstring aNom = theResultBody->findShapeName(aShapeGeom); + std::wstring aMName= Locale::Convert::toWString(aMatName->ToCString()); + theMaterialShape[aMName].push_back(aNom); + + } + } + } + } + } + } + } + } + } + } + } +} + diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h new file mode 100644 index 000000000..d43019068 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImportXCAF.h @@ -0,0 +1,66 @@ +// Copyright (C) 2014-2020 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 GEOMALGOAPI_STEPIMPORTXCAF_H_ +#define GEOMALGOAPI_STEPIMPORTXCAF_H_ + +#include + +#include +#include + +#include + +#include +#include + + /// read Attributs of step file + GEOMALGOAPI_EXPORT + std::shared_ptr readAttributes(STEPCAFControl_Reader &theReader, + std::shared_ptr theResultBody, + const bool theMaterials, + std::map< std::wstring,std::list> &theMaterialShape, + std::string& theError); +/// read attributs for label + GEOMALGOAPI_EXPORT + void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &theShapeTool, + const Handle(XCAFDoc_ColorTool) &theColorTool, + const Handle(XCAFDoc_MaterialTool) &TheMaterialTool, + const TDF_Label &theLabel, + const TopLoc_Location &theLoc, + std::shared_ptr theResultBody, + std::map< std::wstring, std::list> &theMaterialShape, + bool theIsRef); + +// read geometry +GEOMALGOAPI_EXPORT +std::shared_ptr setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool, + const TDF_Label &theLabel, + std::string& theError); + +// store Materiel for theShapeLabel in the map theMaterialShape +GEOMALGOAPI_EXPORT +void storeMaterial(std::shared_ptr theResultBody, + const Handle(Standard_Transient) &theEnti, + const TopTools_IndexedMapOfShape &theIndices, + const Handle(Transfer_TransientProcess) &theTP, + const TDF_Label &theShapeLabel, + std::map< std::wstring, std::list> &theMaterialShape); + +#endif /* GEOMALGOAPI_STEPIMPORTXCAF_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp new file mode 100644 index 000000000..48477c36a --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp @@ -0,0 +1,88 @@ +// Copyright (C) 2014-2020 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 "GeomAlgoAPI_STLExport.h" + +#include "GeomAlgoAPI_Tools.h" + +#include + +// OOCT includes +#include +#include +#include +#include +#include +#include +#include + + + +#define MAX2(X, Y) ( Abs(X) > Abs(Y) ? Abs(X) : Abs(Y) ) +#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X, Y) , Z ) ) + +bool STLExport(const std::string& theFileName, + const std::shared_ptr& theShape, + const double theDeflection, + const bool theIsRelative, + const bool theIsASCII, + std::string& theError) +{ + #ifdef _DEBUG + std::cout << "Export STl into file " << theFileName << std::endl; + #endif + + if (!theShape.get()) { + theError = "STl Export failed: An invalid argument"; + return false; + } + + try + { + + double aDeflection = theDeflection; + StlAPI_Writer aWriter; + // copy source shape + BRepBuilderAPI_Copy aCopy( theShape->impl(), Standard_False ); + TopoDS_Shape aCopyShape = aCopy.Shape(); + // ASCII mode + aWriter.ASCIIMode() = theIsASCII; + if ( theIsRelative ) { + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + Bnd_Box aBndBox; + BRepBndLib::Add( theShape->impl(), aBndBox ); + aBndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax ); + aDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * theDeflection; + } + //Compute triangulation + BRepTools::Clean( aCopyShape ); + BRepMesh_IncrementalMesh aMesh( aCopyShape, aDeflection ); + + if (!aWriter.Write( aCopyShape, theFileName.c_str())) { + theError = "STL Export failed"; + return false; + } + return true; + } + catch( Standard_Failure ) + { + theError = "Exception catched in STlExport"; + } + return false; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h new file mode 100644 index 000000000..7c36584b1 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h @@ -0,0 +1,38 @@ +// Copyright (C) 2014-2020 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 GEOMALGOAPI_STLEXPORT_H_ +#define GEOMALGOAPI_STLEXPORT_H_ + +#include + +#include + +#include + +/// Implementation of the export STL files algorithms +GEOMALGOAPI_EXPORT +bool STLExport(const std::string& theFileName, + const std::shared_ptr& theShape, + const double theDeflection, + const bool theIsRelative, + const bool theIsASCII, + std::string& theError); + +#endif /* GEOMALGOAPI_STLEXPORT_H_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index d6b736d3a..fcb595531 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -36,7 +36,7 @@ #include -static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo) throw (GeomAlgoAPI_Exception) +static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo) { if (!theAlgo.check()) throw GeomAlgoAPI_Exception(theAlgo.getError()); @@ -50,7 +50,6 @@ static GeomShapePtr runAlgo(GeomAlgoAPI_MakeShape& theAlgo) throw (GeomAlgoAPI_ } static GeomShapePtr runAlgoAndCheckShape(GeomAlgoAPI_MakeShape& theAlgo, const std::string& theMsg) -throw (GeomAlgoAPI_Exception) { if (!theAlgo.check()) throw GeomAlgoAPI_Exception(theAlgo.getError()); @@ -68,7 +67,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox( const double theDx, const double theDy, - const double theDz) throw (GeomAlgoAPI_Exception) + const double theDz) { static const std::string aMsg("Box builder with dimensions"); GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz); @@ -78,7 +77,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeBox( std::shared_ptr theFirstPoint, - std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception) + std::shared_ptr theSecondPoint) { static const std::string aMsg("Box builder with two points"); GeomAlgoAPI_Box aBoxAlgo(theFirstPoint, theSecondPoint); @@ -88,7 +87,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( std::shared_ptr theBasePoint, std::shared_ptr theEdge, - double theRadius, double theHeight) throw (GeomAlgoAPI_Exception) + double theRadius, double theHeight) { // Check if the base point is OK if (!theBasePoint) { @@ -112,7 +111,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( std::shared_ptr theBasePoint, std::shared_ptr theEdge, - double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception) + double theRadius, double theHeight, double theAngle) { // Check if the base point is OK if (!theBasePoint) { @@ -135,7 +134,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( - double theRadius, double theHeight) throw (GeomAlgoAPI_Exception) + double theRadius, double theHeight) { std::shared_ptr aBasePoint = std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); @@ -152,7 +151,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCylinder( - double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception) + double theRadius, double theHeight, double theAngle) { std::shared_ptr aBasePoint = std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); @@ -169,7 +168,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSphere( - std::shared_ptr theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception) + std::shared_ptr theCenterPoint, double theRadius) { static const std::string aMsg("Sphere builder"); GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius); @@ -178,7 +177,6 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius) - throw (GeomAlgoAPI_Exception) { std::shared_ptr aCenterPoint = std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); @@ -193,7 +191,6 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTorus( std::shared_ptr theBasePoint, std::shared_ptr theEdge,double theRadius, double theRingRadius) - throw (GeomAlgoAPI_Exception) { // Check if the base point is OK if (!theBasePoint) { @@ -216,7 +213,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTorus(double theRadius, - double theRingRadius) throw (GeomAlgoAPI_Exception) + double theRingRadius) { std::shared_ptr aBasePoint = std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); @@ -236,7 +233,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theBasePoint, std::shared_ptr theEdge, double theBaseRadius, double theTopRadius, - double theHeight) throw (GeomAlgoAPI_Exception) + double theHeight) { // Check if the base point is OK if (!theBasePoint) { @@ -260,7 +257,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeCone( double theBaseRadius, double theTopRadius, - double theHeight) throw (GeomAlgoAPI_Exception) + double theHeight) { std::shared_ptr aBasePoint = std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); @@ -279,7 +276,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const double theDistance) throw (GeomAlgoAPI_Exception) + const double theDistance) { GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theAxis, theDistance); return runAlgo(aTranslationAlgo); @@ -290,7 +287,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theSourceShape, const double theDx, const double theDy, - const double theDz) throw (GeomAlgoAPI_Exception) + const double theDz) { GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theDx, theDy, theDz); return runAlgo(aTranslationAlgo); @@ -300,7 +297,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( std::shared_ptr theSourceShape, std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception) + std::shared_ptr theEndPoint) { GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint); return runAlgo(aTranslationAlgo); @@ -310,7 +307,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeRotation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const double theAngle) throw (GeomAlgoAPI_Exception) + const double theAngle) { GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theAxis, theAngle); return runAlgo(aRotationAlgo); @@ -321,7 +318,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theSourceShape, std::shared_ptr theCenterPoint, std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception) + std::shared_ptr theEndPoint) { GeomAlgoAPI_Rotation aRotationAlgo(theSourceShape, theCenterPoint, theStartPoint, theEndPoint); return runAlgo(aRotationAlgo); @@ -330,7 +327,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePoint) throw (GeomAlgoAPI_Exception) + std::shared_ptr thePoint) { GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePoint); return runAlgo(aSymmetryAlgo); @@ -339,7 +336,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr theAxis) throw (GeomAlgoAPI_Exception) + std::shared_ptr theAxis) { GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, theAxis); return runAlgo(aSymmetryAlgo); @@ -348,7 +345,7 @@ namespace GeomAlgoAPI_ShapeAPI //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePlane) throw (GeomAlgoAPI_Exception) + std::shared_ptr thePlane) { GeomAlgoAPI_Symmetry aSymmetryAlgo(theSourceShape, thePlane); return runAlgo(aSymmetryAlgo); @@ -358,7 +355,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeScale( std::shared_ptr theSourceShape, std::shared_ptr theCenterPoint, - const double theScaleFactor) throw (GeomAlgoAPI_Exception) + const double theScaleFactor) { GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactor); return runAlgo(aScaleAlgo); @@ -370,7 +367,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theCenterPoint, const double theScaleFactorX, const double theScaleFactorY, - const double theScaleFactorZ) throw (GeomAlgoAPI_Exception) + const double theScaleFactorZ) { GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, theScaleFactorX, theScaleFactorY, theScaleFactorZ); @@ -382,7 +379,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theSourceShape, std::shared_ptr theAxis, const double theStep, - const int theNumber) throw (GeomAlgoAPI_Exception) + const int theNumber) { if (!theAxis) { std::string aError = "Multitranslation builder "; @@ -412,7 +409,7 @@ namespace GeomAlgoAPI_ShapeAPI const int theFirstNumber, std::shared_ptr theSecondAxis, const double theSecondStep, - const int theSecondNumber) throw (GeomAlgoAPI_Exception) + const int theSecondNumber) { if (!theFirstAxis) { std::string aError = "Multitranslation builder "; @@ -466,7 +463,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr GeomAlgoAPI_ShapeAPI::makeMultiRotation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const int theNumber) throw (GeomAlgoAPI_Exception) + const int theNumber) { if (!theAxis) { std::string aError = "Multirotation builder "; @@ -495,7 +492,7 @@ namespace GeomAlgoAPI_ShapeAPI std::shared_ptr theSourceShape, std::shared_ptr theAxis, const double theStep, - const int theNumber) throw (GeomAlgoAPI_Exception) + const int theNumber) { if (!theAxis) { std::string aError = "Multirotation builder "; @@ -522,7 +519,7 @@ namespace GeomAlgoAPI_ShapeAPI const double theRMin1, const double theRMax1, const double theRMin2, const double theRMax2, const double theZ, - const double theStartPhi, const double theDeltaPhi) throw (GeomAlgoAPI_Exception) + const double theStartPhi, const double theDeltaPhi) { GeomAlgoAPI_ConeSegment aConeSegmentAlgo(theRMin1, theRMax1, theRMin2, theRMax2, theZ, theStartPhi, theDeltaPhi); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index 145abb5d6..c7aac3ab4 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -47,14 +47,14 @@ public: /// \param theDz The dimension on Z /// \return a shape static std::shared_ptr makeBox(const double theDx, const double theDy, - const double theDz) throw (GeomAlgoAPI_Exception); + const double theDz); /// Creates a box using the two points that defined a diagonal. /// \param theFirstPoint One extermity of the diagonal /// \param theSecondPoint The other extremity of the diagonal /// \return a shape static std::shared_ptr makeBox(std::shared_ptr theFirstPoint, - std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr theSecondPoint); /// Creates a cylinder using a center, an axis, a radius and a height. /// \param theBasePoint The center of the lower base of the cylinder @@ -62,8 +62,7 @@ public: /// \param theRadius The radius of the cylinder /// \param theHeight The heigth of the cylinder static std::shared_ptr makeCylinder(std::shared_ptr theBasePoint, - std::shared_ptr theEdge, double theRadius, double theHeight) - throw (GeomAlgoAPI_Exception); + std::shared_ptr theEdge, double theRadius, double theHeight); /// Creates a portion of cylinder using a center, an axis, a radius, a height and an angle. /// \param theBasePoint The center of the lower base of the cylinder @@ -73,31 +72,29 @@ public: /// \param theAngle The angle defining the portion static std::shared_ptr makeCylinder(std::shared_ptr theBasePoint, std::shared_ptr theEdge, double theRadius, double theHeight, - double theAngle) throw (GeomAlgoAPI_Exception); + double theAngle); /// Creates a cylinder using the origin, the OZ axis, a radius and a height. /// \param theRadius The radius of the cylinder /// \param theHeight The heigth of the cylinder - static std::shared_ptr makeCylinder(double theRadius, double theHeight) - throw (GeomAlgoAPI_Exception); + static std::shared_ptr makeCylinder(double theRadius, double theHeight); /// Creates a portion of cylinder using the origin, the OZ axis, a radius, a height and an angle. /// \param theRadius The radius of the cylinder /// \param theHeight The heigth of the cylinder /// \param theAngle The angle defining the portion static std::shared_ptr makeCylinder(double theRadius, double theHeight, - double theAngle) throw (GeomAlgoAPI_Exception); + double theAngle); /// Creates a sphere using a center and a radius. /// \param theCenterPoint The center of the sphere /// \param theRadius The radius of the sphere static std::shared_ptr makeSphere(std::shared_ptr theCenterPoint, - double theRadius) throw (GeomAlgoAPI_Exception); + double theRadius); /// Creates a sphere using the origin and a radius. /// \param theRadius The radius of the sphere - static std::shared_ptr makeSphere(double theRadius) - throw (GeomAlgoAPI_Exception); + static std::shared_ptr makeSphere(double theRadius); /// Creates a torus using a base point, an axis, a radius and a ring radius. /// \param theBasePoint The center of the torus @@ -105,14 +102,12 @@ public: /// \param theRadius The radius of the torus /// \param theRingRadius The ring radius of the torus static std::shared_ptr makeTorus(std::shared_ptr theBasePoint, - std::shared_ptr theEdge, double theRadius, double theRingRadius) - throw (GeomAlgoAPI_Exception); + std::shared_ptr theEdge, double theRadius, double theRingRadius); /// Creates a torus using a radius and a ring radius. /// \param theRadius The radius of the torus /// \param theRingRadius The ring radius of the torus - static std::shared_ptr makeTorus(double theRadius, double theRingRadius) - throw (GeomAlgoAPI_Exception); + static std::shared_ptr makeTorus(double theRadius, double theRingRadius); /// Creates a cone using a base point, an axis, a base radius, a top radius and a height. /// \param theBasePoint The center of the lower base of the cone @@ -122,14 +117,14 @@ public: /// \param theHeight The height of the cone static std::shared_ptr makeCone(std::shared_ptr theBasePoint, std::shared_ptr theEdge, double theBaseRadius, - double theTopRadius, double theHeight) throw (GeomAlgoAPI_Exception); + double theTopRadius, double theHeight); /// Creates a cone using a base radius, a top radius and a height. /// \param theBaseRadius The base radius of the cone /// \param theTopRadius The top radius of the cone /// \param theHeight The height of the cone static std::shared_ptr makeCone(double theBaseRadius, double theTopRadius, - double theHeight) throw (GeomAlgoAPI_Exception); + double theHeight); /// Performs a translation from an axis and a distance. /// \param theSourceShape Shape to be moved @@ -139,7 +134,7 @@ public: static std::shared_ptr makeTranslation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const double theDistance) throw (GeomAlgoAPI_Exception); + const double theDistance); /// Performs a translation from dimensions. /// \param theSourceShape Shape to be moved @@ -151,7 +146,7 @@ public: std::shared_ptr theSourceShape, const double theDx, const double theDy, - const double theDz) throw (GeomAlgoAPI_Exception); + const double theDz); /// Performs a translation from two points. /// \param theSourceShape Shape to be moved @@ -161,7 +156,7 @@ public: static std::shared_ptr makeTranslation( std::shared_ptr theSourceShape, std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr theEndPoint); /// Performs a rotation from an axis and an angle. /// \param theSourceShape Shape to be rotated @@ -171,7 +166,7 @@ public: static std::shared_ptr makeRotation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const double theAngle) throw (GeomAlgoAPI_Exception); + const double theAngle); /// Performs a rotation from three points. /// \param theSourceShape Shape to be rotated @@ -183,28 +178,28 @@ public: std::shared_ptr theSourceShape, std::shared_ptr theCenterPoint, std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr theEndPoint); /// Performs a symmetry by a point. /// \param theSourceShape Shape be symmetrized /// \param thePoint Point of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr thePoint); /// Performs a symmetry by an axis. /// \param theSourceShape Shape be symmetrized /// \param theAxis Axis of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr theAxis) throw (GeomAlgoAPI_Exception); + std::shared_ptr theAxis); /// Performs a symmetry by a plane. /// \param theSourceShape Shape be symmetrized /// \param thePlane Plane of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePlane) throw (GeomAlgoAPI_Exception); + std::shared_ptr thePlane); /// Performs a scale by a scale factor. /// \param theSourceShape Shape be scaled @@ -213,7 +208,7 @@ public: static std::shared_ptr makeScale( std::shared_ptr theSourceShape, std::shared_ptr theCenterPoint, - const double theScaleFactor) throw (GeomAlgoAPI_Exception); + const double theScaleFactor); /// Performs a scale by dimensions. /// \param theSourceShape Shape be scaled @@ -226,7 +221,7 @@ public: std::shared_ptr theCenterPoint, const double theScaleFactorX, const double theScaleFactorY, - const double theScaleFactorZ) throw (GeomAlgoAPI_Exception); + const double theScaleFactorZ); /// Performs a multi translation along one axis, at a distance and a number of times /// \param theSourceShape Shape to be moved @@ -238,7 +233,7 @@ public: std::shared_ptr theSourceShape, std::shared_ptr theAxis, const double theStep, - const int theNumber) throw (GeomAlgoAPI_Exception); + const int theNumber); /// Performs a multi translation along two axis : a different distance on each axis /// and a different number of times for each axis @@ -257,7 +252,7 @@ public: const int theFirstNumber, std::shared_ptr theSecondAxis, const double theSecondStep, - const int theSecondNumber) throw (GeomAlgoAPI_Exception); + const int theSecondNumber); /// Performs a multi rotation along one axis and a number of times /// \param[in] theSourceShape Shape to be rotated @@ -266,7 +261,7 @@ public: static std::shared_ptr makeMultiRotation( std::shared_ptr theSourceShape, std::shared_ptr theAxis, - const int theNumber) throw (GeomAlgoAPI_Exception); + const int theNumber); /// Performs a multi rotation along one axis, at a step and a number of times /// \param theSourceShape Shape to be moved @@ -277,7 +272,7 @@ public: std::shared_ptr theSourceShape, std::shared_ptr theAxis, const double theStep, - const int theNumber) throw (GeomAlgoAPI_Exception); + const int theNumber); /// Creates a cone segment using standard GDML parameters. /// \param theRMin1 Inner radius at base of cone @@ -294,7 +289,7 @@ public: const double theRMax2, const double theZ, const double theStartPhi, - const double theDeltaPhi) throw (GeomAlgoAPI_Exception); + const double theDeltaPhi); }; } #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 5b04d9f06..89133a06b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -1130,12 +1130,18 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::wireToEdge( GeomEdgePtr anEdge; if (theWire) { TopoDS_Wire aWire = theWire->impl(); - // Workaround: when concatenate a wire consisting of two edges based on the same B-spline curve - // (non-periodic, but having equal start and end points), first of which is placed at the end - // on the curve and second is placed at the start, this workaround copies second curve to avoid - // treating these edges as a single curve by setting trim parameters. - aWire = fixParametricGaps(aWire); - TopoDS_Edge aNewEdge = BRepAlgo::ConcatenateWireC0(aWire); + BRepTools_WireExplorer aWExp(aWire); + TopoDS_Edge aNewEdge = aWExp.Current(); + aWExp.Next(); + if (aWExp.More()) { + // Workaround: when concatenate a wire consisting of two edges based on the same B-spline + // curve (non-periodic, but having equal start and end points), first of which is placed + // at the end on the curve and second is placed at the start, this workaround copies + // second curve to avoid treating these edges as a single curve by setting trim parameters. + aWire = fixParametricGaps(aWire); + aWire = BRepAlgo::ConcatenateWire(aWire, GeomAbs_G1); // join smooth parts of wire + aNewEdge = BRepAlgo::ConcatenateWireC0(aWire); // join C0 parts of wire + } anEdge = GeomEdgePtr(new GeomAPI_Edge); anEdge->setImpl(new TopoDS_Edge(aNewEdge)); } @@ -1196,6 +1202,10 @@ void GeomAlgoAPI_ShapeTools::computeThroughAll(const ListOfShape& theObjects, return; } + // the value to enlarge the bounding box of each object to make the extruded shape + // a little bit larger than overall objects to get the correct result of Boolean CUT operation + double anEnlargement = 0.1 * aBndObjs.front()->distance(aBndObjs.back()); + // Prism direction if (theDir.get()) { // One direction for all prisms @@ -1235,7 +1245,7 @@ void GeomAlgoAPI_ShapeTools::computeThroughAll(const ListOfShape& theObjects, // Bounding box of the base std::list > aBndBases = - GeomAlgoAPI_ShapeTools::getBoundingBox(aBaseShapes_i); + GeomAlgoAPI_ShapeTools::getBoundingBox(aBaseShapes_i, anEnlargement); if (aBndBases.size() != 8) { return; } diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index 6fb763a02..44f7e44ab 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -182,7 +182,9 @@ ObjectPtr Model_AttributeRefList::iteratedObject(TDF_ListIteratorOfLabelList& th } theExtIter.Next(); } else { // internal document object - anObj = theDoc->objects()->object(theLIter.Value()); + TDF_Label aLab = theLIter.Value(); + if (!aLab.IsNull()) + anObj = theDoc->objects()->object(theLIter.Value()); } } return anObj; diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 6c3a491c5..17e0ceddf 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -714,7 +714,9 @@ void Model_BodyBuilder::loadGeneratedShapes(const GeomMakeShapePtr& theAlgo, bool anOldSubShapeNotInTree = !isShapeInTree(aData->shapeLab(), anAccess2, anOldSubShape_, anOriginalLabel); if (anOldSubShapeAlreadyProcessed || anOldSubShapeNotInTree) { - if (theSaveOldIfNotInTree) { + // The second condition is added due to #20170 because sub-shape must be added to real parent + // shape, not the reference. The naming name of pure reference is not registered in document. + if (theSaveOldIfNotInTree && !aData->shapeLab().IsAttribute(TDF_Reference::GetID())) { std::string aSelectionName = theName + "Selected"; generated(anOldSubShape, aSelectionName, false); } else diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 6046533ab..5b68969e8 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -73,8 +73,12 @@ #include #include #include + +#ifdef TINSPECTOR #include #include +#endif + #include #include @@ -317,6 +321,8 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum std::shared_ptr aSession = std::dynamic_pointer_cast(Model_Session::get()); if (isOk) { + // keep handle to avoid destruction of the document until myObjs works on it + Handle(TDocStd_Document) anOldDoc = myDoc; myDoc = aLoaded; myDoc->SetUndoLimit(UNDO_LIMIT); @@ -325,6 +331,7 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum aSession->setCheckTransactions(false); if (myObjs) delete myObjs; + anOldDoc.Nullify(); myObjs = new Model_Objects(myDoc->Main()); // synchronization is inside myObjs->setOwner(theThis); // update the current features status @@ -2309,6 +2316,8 @@ void Model_Document::appendTransactionToPrevious() { Transaction anAppended = myTransactions.back(); myTransactions.pop_back(); + if (!myNestedNum.empty()) + (*myNestedNum.rbegin())--; if (!myTransactions.empty()) { // if it is empty, just forget the appended myTransactions.back().myOCAFNum += anAppended.myOCAFNum; } diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 2c32988e2..c7ea99cb0 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1226,7 +1226,8 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData, void Model_Objects::storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex) + const int theResultIndex, + const std::wstring& theNameShape) { theResult->init(); theResult->setDoc(myDoc); @@ -1240,11 +1241,15 @@ void Model_Objects::storeResult(std::shared_ptr theFeatureData, theResult->data()->setName(L""); } else { std::wstringstream aName; - aName << aNewName; - // if there are several results (issue #899: any number of result), - // add unique prefix starting from second - if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) - aName << "_" << theResultIndex + 1; + if ( theNameShape != L"" ){ + aName << theNameShape; + } else { + aName << aNewName; + // if there are several results (issue #899: any number of result), + // add unique prefix starting from second + if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) + aName << "_" << theResultIndex + 1; + } aNewName = aName.str(); } theResult->data()->setName(aNewName); @@ -1269,7 +1274,9 @@ std::shared_ptr Model_Objects::createConstruction( } std::shared_ptr Model_Objects::createBody( - const std::shared_ptr& theFeatureData, const int theIndex) + const std::shared_ptr& theFeatureData, + const int theIndex, + const std::wstring& theNameShape) { TDF_Label aLab = resultLabel(theFeatureData, theIndex); TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str()); @@ -1280,7 +1287,7 @@ std::shared_ptr Model_Objects::createBody( } if (!aResult.get()) { aResult = std::shared_ptr(new Model_ResultBody); - storeResult(theFeatureData, aResult, theIndex); + storeResult(theFeatureData, aResult, theIndex, theNameShape); } return aResult; } diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index c929be8ce..3ae6c713a 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -124,7 +124,8 @@ class Model_Objects const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body result std::shared_ptr createBody( - const std::shared_ptr& theFeatureData, const int theIndex = 0); + const std::shared_ptr& theFeatureData, const int theIndex = 0, + const std::wstring& theNameShape = L""); /// Creates a part result std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -224,7 +225,8 @@ class Model_Objects //! (attaches 'data' of result to tree) void storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex = 0); + const int theResultIndex = 0, + const std::wstring& theNameShape = L""); //! returns the label of result by index; creates this label if it was not created before TDF_Label resultLabel(const std::shared_ptr& theFeatureData, diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 7d6918c6a..c58ed7b06 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -233,6 +235,57 @@ void Model_ResultBody::updateConcealment() } } +void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector& color) { + + if (myColorsShape.find(theName) == myColorsShape.end()) + myColorsShape[ theName ] = color; +} + +std::wstring Model_ResultBody::addShapeName(std::shared_ptr theshape, + const std::wstring& theName ){ + + int indice = 1; + std::wstringstream aName; + aName << theName; + while(myNamesShape.find(aName.str()) != myNamesShape.end() ){ + aName.str(L""); + aName << theName << L"__" << indice; + indice++; + } + myNamesShape[ aName.str() ] = theshape; + + return aName.str(); +} + +std::wstring Model_ResultBody::findShapeName(std::shared_ptr theShape){ + + TopoDS_Shape aShape = theShape->impl(); + for (std::map< std::wstring, std::shared_ptr >::iterator it = + myNamesShape.begin(); + it != myNamesShape.end(); + ++it) + { + TopoDS_Shape curSelectedShape = (*it).second->impl(); + if ((aShape.IsSame(curSelectedShape))) { + return (*it).first; + } + } + return L"material not found" ; +} + +void Model_ResultBody::setShapeName( + std::map< std::wstring, std::shared_ptr>& theShapeName, + std::map< std::wstring, std::vector>& theColorsShape) +{ + myNamesShape = theShapeName; + myColorsShape = theColorsShape; +} + +void Model_ResultBody::clearShapeNameAndColor(){ + myNamesShape.clear(); + myColorsShape.clear(); +} + void Model_ResultBody::updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged) { @@ -262,13 +315,33 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS aShape->setImpl(new TopoDS_Shape(aShapesIter.Value())); ResultBodyPtr aSub; if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result - aSub = anObjects->createBody(this->data(), aSubIndex); + std::wstring thenameshape = L""; + // find shape name read + for (std::map< std::wstring, std::shared_ptr >::iterator it = + myNamesShape.begin(); + it != myNamesShape.end(); + ++it) + { + TopoDS_Shape curSelectedShape = (*it).second->impl(); + if (!(aShapesIter.Value().IsSame(curSelectedShape))) continue; + thenameshape = (*it).first; + break; + } + aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape); + //finf color read + std::map< std::wstring, std::vector>::iterator itColor = + myColorsShape.find(thenameshape); + if (itColor != myColorsShape.end()){ + ModelAPI_Tools::setColor(aSub,(*itColor).second); + } + aSub->setShapeName(myNamesShape,myColorsShape); mySubs.push_back(aSub); mySubsMap[aSub] = int(mySubs.size() - 1); if (isConcealed()) { // for issue #2579 note7 aSub->ModelAPI_ResultBody::setIsConcealed(true); std::dynamic_pointer_cast(aSub)->updateConcealment(); } + } else { // just update shape of this result aSub = mySubs[aSubIndex]; } diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 94e9d9b7c..fff856c5f 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -126,7 +126,7 @@ protected: const GeomShapePtr& theThisShape, const std::list& theOlds, const std::shared_ptr theMakeShape, const bool isGenerated); - // Checks the state of children and parents 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(); /// Adds to theOldForSub only old shapes that where used for theSub creation @@ -134,6 +134,31 @@ protected: const std::list& theAllOlds, std::list& theOldForSub); friend class Model_Objects; + + /// Add shape Name for read shape in step file + std::wstring addShapeName(std::shared_ptr,const std::wstring& theName) override; + + /// Add color for shape Name read shape in step file + void addShapeColor( const std::wstring& theName,std::vector& color) override; + + /// Set the map of name and color read shape in step file + void setShapeName(std::map< std::wstring, + std::shared_ptr>& theShapeName, + std::map< std::wstring, + std::vector>& theColorsShape) override; + + /// find the name of shapp read in step file + std::wstring findShapeName(std::shared_ptr theShape) override; + + /// Clear the map of name and color read shape in step file + void clearShapeNameAndColor() override; + + /// map with the name read in step file and shape + std::map< std::wstring, std::shared_ptr > myNamesShape; + + /// map with the name contruct and color read + std::map< std::wstring, std::vector> myColorsShape; + }; #endif diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index a0dfe058a..79751881e 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -190,13 +190,14 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { #endif } // clear processed and fill modified recursively + std::set aRefSet; const std::set >& aRefs = theFeature->data()->refsToMe(); std::set >::const_iterator aRefIter = aRefs.cbegin(); for(; aRefIter != aRefs.cend(); aRefIter++) { if ((*aRefIter)->isArgument()) { FeaturePtr aReferenced = std::dynamic_pointer_cast((*aRefIter)->owner()); if (aReferenced.get()) { - addModified(aReferenced, theFeature); + aRefSet.insert(aReferenced); } } } @@ -211,19 +212,21 @@ bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { if ((*aRIter)->isArgument()) { FeaturePtr aReferenced = std::dynamic_pointer_cast((*aRIter)->owner()); if (aReferenced.get()) { - addModified(aReferenced, theFeature); + aRefSet.insert(aReferenced); } } } } - // also add part feature that contains this feature to the modified if (theFeature->document()->kind() != "PartSet") { FeaturePtr aPart = ModelAPI_Tools::findPartFeature( ModelAPI_Session::get()->moduleDocument(), theFeature->document()); if (aPart.get()) - addModified(aPart, theFeature); + aRefSet.insert(aPart); } + for(std::set::iterator aRef = aRefSet.begin(); aRef != aRefSet.end(); aRef++) + addModified(*aRef, theFeature); + return true; } @@ -343,18 +346,6 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag if (anUpdated.get()) { if (addModified(anUpdated, FeaturePtr())) aSomeModified = true; - if (myUpdateBlocked) { // execute this feature anyway to show the current result - /*if (!anUpdated->isStable() && anUpdated->results().size() && ( - anUpdated->firstResult()->groupName() == ModelAPI_ResultBody::group() || - anUpdated->firstResult()->groupName() == ModelAPI_ResultPart::group())) { - if (aFactory->validate(anUpdated)) { - executeFeature(anUpdated); - redisplayWithResults(anUpdated, ModelAPI_StateNothing, false); - static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); - aLoop->flush(EVENT_DISP); - } - }*/ - } } else { // process the updated result as update of features that refers to this result const std::set >& @@ -732,7 +723,8 @@ bool Model_Update::processFeature(FeaturePtr theFeature) if (!isPostponedMain) { bool aDoExecute = true; if (myUpdateBlocked) { - if (!theFeature->isStable()) { + if (!theFeature->isStable() || (theFeature->getKind().size() > 6 && + theFeature->getKind().substr(0, 6) == "Sketch")) { // automatic update sketch elements aDoExecute = true; } else if (theFeature->results().size()) { // execute only not persistent results features aDoExecute = !theFeature->isPersistentResult(); diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index dd2f4acd9..68b34a177 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -267,4 +267,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19912.py Test19932.py Test19989.py + Test20170.py ) diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index c88fb08fc..f51233b6f 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -24,6 +24,8 @@ #include #include #include +#include +#include class ModelAPI_BodyBuilder; class GeomAlgoAPI_MakeShape; @@ -183,6 +185,26 @@ public: /// Cleans cash related to the already stored elements MODELAPI_EXPORT virtual void cleanCash() = 0; + /// Add shape Name for read shape in step file + MODELAPI_EXPORT virtual std::wstring addShapeName + (std::shared_ptr,const std::wstring& theName) = 0; + + /// Add color for shape Name read shape in step file + MODELAPI_EXPORT virtual void addShapeColor + (const std::wstring& theName,std::vector& theColor) = 0; + + /// Set the map of name and color read shape in step file + MODELAPI_EXPORT virtual void setShapeName + (std::map< std::wstring, std::shared_ptr > &theShapeName, + std::map< std::wstring, std::vector> & theColorsShape) = 0; + + /// Clear the map of name and color read shape in step file + MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0; + + /// find the name of shapp read in step file + MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr theShape) = 0; + + protected: /// Default constructor accessible only from Model_Objects MODELAPI_EXPORT ModelAPI_ResultBody(); diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 69a882af6..c5985e310 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -617,7 +617,8 @@ void getConcealedResults(const FeaturePtr& theFeature, } std::pair getDefaultName(const std::shared_ptr& theResult, - const bool theInherited) + const bool theInherited, + const bool theRecursive) { typedef std::list< std::pair < std::string, std::list > > ListOfReferences; @@ -706,7 +707,8 @@ std::pair getDefaultName(const std::shared_ptrdata()->hasUserDefinedName()) { + if (anObjRes->data()->hasUserDefinedName() || + (theRecursive && anObjRes->data()->name() != getDefaultName(anObjRes).first)) { std::wstringstream aName; aName << anObjRes->data()->name(); std::map::iterator aFound = aNbRefToObject.find(anObjRes); diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index 5fd96b917..ab4633d98 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -198,9 +198,12 @@ MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr /*! Return the default name of the result according the features it depends or name of the feature. * Return also whether the name is get from the concealing result of parent object * (means that concealing result has user-defined name). + * \param[in] theRecursive recursively check the concealed results if they have user-defined names */ MODELAPI_EXPORT std::pair getDefaultName( - const std::shared_ptr& theResult, const bool theInherited = true); + const std::shared_ptr& theResult, + const bool theInherited = true, + const bool theRecursive = false); /*! Collect all parents for the given feature, including the Part */ diff --git a/src/ModelAPI/Test/Test20170.py b/src/ModelAPI/Test/Test20170.py new file mode 100644 index 000000000..d3ed72eda --- /dev/null +++ b/src/ModelAPI/Test/Test20170.py @@ -0,0 +1,35 @@ +# Copyright (C) 2014-2020 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(8, 23, 2.5) +SketchCircle_2 = Sketch_1.addCircle(14, 17, 2.5) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")], model.selection(), 10, 0) +Compound_1 = model.addCompound(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_1_2")]) +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Compound_1_1_2/Modified_Face&Sketch_1/SketchCircle_2_2][Compound_1_1_2/Modified_Face&Extrusion_1_2/To_Face]")], 2, keepSubResults = True) +Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Fillet_1_1_2/GF:Fillet&Fillet_1_1_2/FilletSelected")]) +model.end() + +assert(model.checkPythonDump()) diff --git a/src/ModelHighAPI/CMakeLists.txt b/src/ModelHighAPI/CMakeLists.txt index 982450580..e52c3807d 100644 --- a/src/ModelHighAPI/CMakeLists.txt +++ b/src/ModelHighAPI/CMakeLists.txt @@ -128,4 +128,5 @@ ADD_UNIT_TESTS( Test19031.py Test19990_1.py Test19990_2.py + Test20167.py ) diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 6d8affba8..33d8cb39a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -687,7 +687,7 @@ void ModelHighAPI_Dumper::saveResultNames(const FeaturePtr& theFeature) std::list allRes; ModelAPI_Tools::allResults(theFeature, allRes); for(std::list::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) { - std::pair aName = ModelAPI_Tools::getDefaultName(*aRes); + std::pair aName = ModelAPI_Tools::getDefaultName(*aRes, true, true); std::string aDefaultName = Locale::Convert::toString(aName.first); std::string aResName = Locale::Convert::toString((*aRes)->data()->name()); bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName); @@ -992,6 +992,18 @@ bool ModelHighAPI_Dumper::isDumped(const AttributeRefListPtr& theRefList) const return true; } +size_t ModelHighAPI_Dumper::indexOfFirstNotDumped( + const std::shared_ptr& theRefList) const +{ + size_t anIndex = 0; + std::list anObjects = theRefList->list(); + for (std::list::const_iterator anIt = anObjects.begin(); + anIt != anObjects.end(); ++anIt, ++anIndex) + if (!isDumped(ModelAPI_Feature::feature(*anIt))) + break; + return anIndex; +} + static bool isSketchSub(const FeaturePtr& theFeature) { static const std::string SKETCH("Sketch"); @@ -1071,7 +1083,7 @@ bool ModelHighAPI_Dumper::dumpCommentBeforeFeature(const FeaturePtr& theFeature) if (aFilters) return false; // all other features should be commented before the dump - return true; + return !isDumped(theFeature); } ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar) @@ -1445,6 +1457,11 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( bool isAdded = false; std::list::const_iterator anIt = aList.begin(); for (; anIt != aList.end(); ++anIt) { + if (!(*anIt)) + continue; + if (!isDumped(ModelAPI_Feature::feature(*anIt))) + break; // stop if the object is not dumped yet (parent feature should be postponed) + if (isAdded) *myDumpStorage << ", "; else @@ -1505,12 +1522,12 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<( } if(isAdded) { - *myDumpStorage << ", "; // print each attribute on separate line with the appropriate shift if (aNbSpaces > 0) { std::string aSpaces(aNbSpaces + 1, ' '); - *myDumpStorage << "\n" << aSpaces; - } + *myDumpStorage << ",\n" << aSpaces; + } else + *myDumpStorage << ", "; } else { isAdded = true; } diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.h b/src/ModelHighAPI/ModelHighAPI_Dumper.h index 1fa21e9da..8e12c05bb 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.h +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.h @@ -354,6 +354,10 @@ public: MODELHIGHAPI_EXPORT bool isDumped(const std::shared_ptr& theRefList) const; + /// Returns the index of the first object in the list which is not dumped yet. + MODELHIGHAPI_EXPORT + size_t indexOfFirstNotDumped(const std::shared_ptr& theRefList) const; + /// Export variables names to another module (calls exportVariable implemented in python) MODELHIGHAPI_EXPORT virtual void exportVariables() const; diff --git a/src/ModelHighAPI/ModelHighAPI_Macro.h b/src/ModelHighAPI/ModelHighAPI_Macro.h index 333de514e..a372090fe 100644 --- a/src/ModelHighAPI/ModelHighAPI_Macro.h +++ b/src/ModelHighAPI/ModelHighAPI_Macro.h @@ -535,6 +535,59 @@ SET_ATTRIBUTE(N_13, T_13, AN_13) \ END_INIT() \ public: +//-------------------------------------------------------------------------------------- +#define INTERFACE_15(KIND, \ + N_0, AN_0, T_0, C_0, \ + N_1, AN_1, T_1, C_1, \ + N_2, AN_2, T_2, C_2, \ + N_3, AN_3, T_3, C_3, \ + N_4, AN_4, T_4, C_4, \ + N_5, AN_5, T_5, C_5, \ + N_6, AN_6, T_6, C_6, \ + N_7, AN_7, T_7, C_7, \ + N_8, AN_8, T_8, C_8, \ + N_9, AN_9, T_9, C_9, \ + N_10, AN_10, T_10, C_10, \ + N_11, AN_11, T_11, C_11, \ + N_12, AN_12, T_12, C_12, \ + N_13, AN_13, T_13, C_13, \ + N_14, AN_14, T_14, C_14) \ + public: \ + INTERFACE_COMMON(KIND) \ + DEFINE_ATTRIBUTE(N_0, T_0, C_0) \ + DEFINE_ATTRIBUTE(N_1, T_1, C_1) \ + DEFINE_ATTRIBUTE(N_2, T_2, C_2) \ + DEFINE_ATTRIBUTE(N_3, T_3, C_3) \ + DEFINE_ATTRIBUTE(N_4, T_4, C_4) \ + DEFINE_ATTRIBUTE(N_5, T_5, C_5) \ + DEFINE_ATTRIBUTE(N_6, T_6, C_6) \ + DEFINE_ATTRIBUTE(N_7, T_7, C_7) \ + DEFINE_ATTRIBUTE(N_8, T_8, C_8) \ + DEFINE_ATTRIBUTE(N_9, T_9, C_9) \ + DEFINE_ATTRIBUTE(N_10, T_10, C_10) \ + DEFINE_ATTRIBUTE(N_11, T_11, C_11) \ + DEFINE_ATTRIBUTE(N_12, T_12, C_12) \ + DEFINE_ATTRIBUTE(N_13, T_13, C_13) \ + DEFINE_ATTRIBUTE(N_14, T_14, C_14) \ + protected: \ + START_INIT() \ + SET_ATTRIBUTE(N_0, T_0, AN_0) \ + SET_ATTRIBUTE(N_1, T_1, AN_1) \ + SET_ATTRIBUTE(N_2, T_2, AN_2) \ + SET_ATTRIBUTE(N_3, T_3, AN_3) \ + SET_ATTRIBUTE(N_4, T_4, AN_4) \ + SET_ATTRIBUTE(N_5, T_5, AN_5) \ + SET_ATTRIBUTE(N_6, T_6, AN_6) \ + SET_ATTRIBUTE(N_7, T_7, AN_7) \ + SET_ATTRIBUTE(N_8, T_8, AN_8) \ + SET_ATTRIBUTE(N_9, T_9, AN_9) \ + SET_ATTRIBUTE(N_10, T_10, AN_10) \ + SET_ATTRIBUTE(N_11, T_11, AN_11) \ + SET_ATTRIBUTE(N_12, T_12, AN_12) \ + SET_ATTRIBUTE(N_13, T_13, AN_13) \ + SET_ATTRIBUTE(N_14, T_14, AN_14) \ + END_INIT() \ + public: //-------------------------------------------------------------------------------------- #define INTERFACE_16(KIND, \ diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index 0b72c418f..1e2648cf2 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -168,8 +168,18 @@ void fillAttribute(const std::shared_ptr & theValue, void fillAttribute(const std::list > & theValue, const std::shared_ptr & theAttribute) { - theAttribute->clear(); - for (auto it = theValue.begin(); it != theValue.end(); ++it) + int aSize = theAttribute->size(); + // keep objects at the beginning of the list if they the same + auto it = theValue.begin(); + for (int anIndex = 0; it != theValue.end() && anIndex < aSize; ++it, ++anIndex) + if (theAttribute->object(anIndex) != *it) { + // remove the tail of the list + while (++anIndex <= aSize) + theAttribute->removeLast(); + break; + } + // append the rest of elements + for (; it != theValue.end(); ++it) theAttribute->append(*it); } @@ -349,7 +359,7 @@ GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection case ModelHighAPI_Selection::VT_ResultSubShapePair: { ResultSubShapePair aPair = theSelection.resultSubShapePair(); GeomShapePtr aShape = aPair.second; - if(!aShape.get()) { + if(!aShape.get() && aPair.first.get()) { aShape = aPair.first->shape(); } if(!aShape.get()) { diff --git a/src/ModelHighAPI/Test/Test20167.py b/src/ModelHighAPI/Test/Test20167.py new file mode 100644 index 000000000..7223a0b5b --- /dev/null +++ b/src/ModelHighAPI/Test/Test20167.py @@ -0,0 +1,421 @@ +# Copyright (C) 2020 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 + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "h1", "15") +model.addParameter(Part_1_doc, "h2", "70") +model.addParameter(Part_1_doc, "h3", "7") +model.addParameter(Part_1_doc, "d", "15") +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() +SketchLine_1 = Sketch_1.addLine(-7.500000000000083, -15.81138830084192, -7.500000000000083, -26.99999999999995) +SketchLine_1.setName("SketchLine_2") +SketchLine_1.result().setName("SketchLine_2") +SketchLine_2 = Sketch_1.addLine(-4.499999999999853, -30, 4.499999999999912, -30) +SketchLine_2.setName("SketchLine_3") +SketchLine_2.result().setName("SketchLine_3") +SketchLine_3 = Sketch_1.addLine(7.499999999999912, -27, 7.499999999999912, -15.81138830084196) +SketchLine_3.setName("SketchLine_4") +SketchLine_3.result().setName("SketchLine_4") +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) +SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result()) +SketchConstraintHorizontal_1.setName("SketchConstraintHorizontal_2") +SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result()) +SketchPoint_2 = Sketch_1.addPoint(0, -30) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_6") +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_4 = SketchProjection_2.createdFeature() +SketchLine_4.setName("SketchLine_5") +SketchLine_4.result().setName("SketchLine_5") +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_4.result()) +SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_7") +SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_5 = SketchProjection_3.createdFeature() +SketchLine_5.setName("SketchLine_6") +SketchLine_5.result().setName("SketchLine_6") +SketchArc_1 = Sketch_1.addArc(0, 0, -7.500000000000083, -15.81138830084192, -17.44306393762917, 1.410503622037771, True) +SketchArc_1.setName("SketchArc_2") +SketchArc_1.result().setName("SketchArc_2") +SketchArc_1.results()[1].setName("SketchArc_2_2") +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchArc_1.center()) +SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_3") +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 17.5) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.startPoint()) +SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_14") +SketchArc_2 = Sketch_1.addArc(-4.499999999999853, -27, -7.500000000000083, -26.99999999999995, -4.499999999999853, -30, False) +SketchArc_2.setName("SketchArc_3") +SketchArc_2.result().setName("SketchArc_3") +SketchArc_2.results()[1].setName("SketchArc_3_2") +SketchPoint_3 = Sketch_1.addPoint(-7.500000000000085, -30) +SketchPoint_3.setAuxiliary(True) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchLine_5.result(), 30, True) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_8") +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_1.result()) +SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_9") +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_1.endPoint()) +SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_10") +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_2.startPoint()) +SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_11") +SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result()) +SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_1.result()) +SketchArc_3 = Sketch_1.addArc(4.499999999999912, -27, 4.499999999999912, -30, 7.499999999999912, -27, False) +SketchArc_3.setName("SketchArc_4") +SketchArc_3.result().setName("SketchArc_4") +SketchArc_3.results()[1].setName("SketchArc_4_2") +SketchPoint_4 = Sketch_1.addPoint(7.499999999999914, -30) +SketchPoint_4.setAuxiliary(True) +SketchConstraintDistance_2 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchPoint_4.coordinates(), 15, False) +SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_3.result()) +SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_13") +SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_2.result()) +SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_15") +SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_2.endPoint()) +SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_16") +SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_17") +SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_3.result()) +SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_2.result()) +SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 3) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_3.results()[1], SketchArc_2.results()[1]) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result()) +SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchArc_2.results()[1], SketchLine_2.result(), SketchArc_3.results()[1], SketchLine_3.result()] +SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchAPI_Line(SketchLine_5).startPoint(), 360, 3, True) +[SketchLine_6, SketchLine_7, SketchArc_4, SketchArc_5, SketchLine_8, SketchLine_9, SketchArc_6, SketchArc_7, SketchLine_10, SketchLine_11] = SketchMultiRotation_1.rotated() +SketchLine_11.setName("SketchLine_14") +SketchLine_11.result().setName("SketchLine_14") +SketchLine_10.setName("SketchLine_13") +SketchLine_10.result().setName("SketchLine_13") +SketchArc_7.setName("SketchArc_9") +SketchArc_7.result().setName("SketchArc_9") +SketchArc_7.results()[1].setName("SketchArc_9_2") +SketchArc_6.setName("SketchArc_8") +SketchArc_6.result().setName("SketchArc_8") +SketchArc_6.results()[1].setName("SketchArc_8_2") +SketchLine_9.setName("SketchLine_11") +SketchLine_9.result().setName("SketchLine_11") +SketchLine_8.setName("SketchLine_10") +SketchLine_8.result().setName("SketchLine_10") +SketchArc_5.setName("SketchArc_6") +SketchArc_5.result().setName("SketchArc_6") +SketchArc_5.results()[1].setName("SketchArc_6_2") +SketchArc_4.setName("SketchArc_5") +SketchArc_4.result().setName("SketchArc_5") +SketchArc_4.results()[1].setName("SketchArc_5_2") +SketchLine_7.setName("SketchLine_8") +SketchLine_7.result().setName("SketchLine_8") +SketchLine_6.setName("SketchLine_7") +SketchLine_6.result().setName("SketchLine_7") +SketchArc_8 = Sketch_1.addArc(0, 0, -9.943063937629109, 14.40088467880429, 9.94306393762926, 14.40088467880419, True) +SketchArc_8.setName("SketchArc_10") +SketchArc_8.result().setName("SketchArc_10") +SketchArc_8.results()[1].setName("SketchArc_10_2") +SketchConstraintEqual_3 = Sketch_1.setEqual(SketchArc_1.results()[1], SketchArc_8.results()[1]) +SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_8.center()) +SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_18") +SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_11.result()) +SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_19") +SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_8.startPoint(), SketchLine_7.result()) +SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_20") +SketchArc_9 = Sketch_1.addArc(0, 0, 17.44306393762918, 1.410503622037589, 7.499999999999912, -15.81138830084196, True) +SketchArc_9.setName("SketchArc_11") +SketchArc_9.result().setName("SketchArc_11") +SketchArc_9.results()[1].setName("SketchArc_11_2") +SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchArc_9.endPoint(), SketchLine_3.endPoint()) +SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_12") +SketchConstraintEqual_4 = Sketch_1.setEqual(SketchArc_8.results()[1], SketchArc_9.results()[1]) +SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_8.center(), SketchArc_9.center()) +SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_21") +SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_8.endPoint(), SketchLine_10.result()) +SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_22") +SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_9.startPoint(), SketchLine_6.result()) +SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_23") +SketchCircle_1 = Sketch_1.addCircle(0, 0, 24) +SketchCircle_1.setAuxiliary(True) +SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchCircle_1.center()) +SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_24") +SketchConstraintRadius_3 = Sketch_1.setRadius(SketchCircle_1.results()[1], 24) +SketchCircle_2 = Sketch_1.addCircle(0, -24, 4) +SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center()) +SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_25") +SketchConstraintRadius_4 = Sketch_1.setRadius(SketchCircle_2.results()[1], 4) +SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_4.result()) +SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_26") +SketchMultiRotation_2 = Sketch_1.addRotation([SketchCircle_2.results()[1]], SketchAPI_Line(SketchLine_4).startPoint(), 360, 3, True) +[SketchCircle_3, SketchCircle_4] = SketchMultiRotation_2.rotated() +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchArc_3_2f-SketchLine_3f-SketchArc_4_2f-SketchLine_4f-SketchArc_11_2f-SketchLine_7f-SketchArc_5_2f-SketchLine_10f-SketchArc_8_2f-SketchLine_13f-SketchArc_10_2f-SketchLine_8f-SketchArc_6_2f-SketchLine_11f-SketchArc_9_2f-SketchLine_14f-SketchArc_2_2f-SketchCircle_2_2r-SketchCircle_3_2r-SketchCircle_4_2r")], model.selection(), "h1", 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face")) +SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_12 = SketchProjection_4.createdFeature() +SketchLine_12.setName("SketchLine_12") +SketchLine_12.result().setName("SketchLine_12") +SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_13 = SketchProjection_5.createdFeature() +SketchLine_13.setName("SketchLine_15") +SketchLine_13.result().setName("SketchLine_15") +SketchLine_14 = Sketch_2.addLine(7.500000000000332, 12.99038105676728, 15, 0) +SketchLine_14.setName("SketchLine_16") +SketchLine_14.result().setName("SketchLine_16") +SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_12.result()) +SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_28") +SketchConstraintDistance_3 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_14.startPoint(), "d", True) +SketchConstraintDistance_4 = Sketch_2.setDistance(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_14.endPoint(), "d", True) +SketchLine_15 = Sketch_2.addLine(0, 0, 7.500000000000332, 12.99038105676728) +SketchLine_15.setName("SketchLine_17") +SketchLine_15.result().setName("SketchLine_17") +SketchLine_15.setAuxiliary(True) +SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_12).startPoint(), SketchLine_15.startPoint()) +SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_27") +SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchLine_15.endPoint()) +SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_29") +SketchConstraintAngle_1 = Sketch_2.setAngle(SketchLine_12.result(), SketchLine_15.result(), "360/6") +SketchMultiRotation_3 = Sketch_2.addRotation([SketchLine_14.result()], SketchAPI_Line(SketchLine_12).startPoint(), 360, 6, True) +[SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19, SketchLine_20] = SketchMultiRotation_3.rotated() +SketchLine_20.setName("SketchLine_22") +SketchLine_20.result().setName("SketchLine_22") +SketchLine_19.setName("SketchLine_21") +SketchLine_19.result().setName("SketchLine_21") +SketchLine_18.setName("SketchLine_20") +SketchLine_18.result().setName("SketchLine_20") +SketchLine_17.setName("SketchLine_19") +SketchLine_17.result().setName("SketchLine_19") +SketchLine_16.setName("SketchLine_18") +SketchLine_16.result().setName("SketchLine_18") +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchLine_18r-SketchLine_19r-SketchLine_20r-SketchLine_21r-SketchLine_22r-SketchLine_16r_wire")], model.selection(), "h2-h3-h1", 0) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face")) +SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_21 = SketchProjection_6.createdFeature() +SketchLine_21.setName("SketchLine_23") +SketchLine_21.result().setName("SketchLine_23") +SketchCircle_5 = Sketch_3.addCircle(0, 0, 10) +SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_21).startPoint(), SketchCircle_5.center()) +SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_30") +SketchConstraintRadius_5 = Sketch_3.setRadius(SketchCircle_5.results()[1], 10) +model.do() +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1")]) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_5_2f")], model.selection(), 0, 60, [model.selection("SOLID", "Fuse_1_1")]) +Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/From_Face")) +SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_22 = SketchProjection_7.createdFeature() +SketchLine_22.setName("SketchLine_24") +SketchLine_22.result().setName("SketchLine_24") +SketchCircle_6 = Sketch_4.addCircle(0, 0, 12.5) +SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_22).startPoint(), SketchCircle_6.center()) +SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_31") +SketchConstraintRadius_6 = Sketch_4.setRadius(SketchCircle_6.results()[1], 12.5) +model.do() +ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), model.selection("FACE", "Sketch_1/Face-SketchLine_2f-SketchArc_3_2f-SketchLine_3f-SketchArc_4_2f-SketchLine_4f-SketchArc_11_2f-SketchLine_7f-SketchArc_5_2f-SketchLine_10f-SketchArc_8_2f-SketchLine_13f-SketchArc_10_2f-SketchLine_8f-SketchArc_6_2f-SketchLine_11f-SketchArc_9_2f-SketchLine_14f-SketchArc_2_2f-SketchCircle_2_2r-SketchCircle_3_2r-SketchCircle_4_2r"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")]) +Fillet_1_objects = [model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_20]"), model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_21]"), model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_22]"), model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_16]"), model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_19]"), model.selection("EDGE", "[Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_18]")] +Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 1) +Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face")) +SketchProjection_8 = Sketch_5.addProjection(model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Extrusion_2_1/To_Face][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchCircle_5_2]__cc"), False) +SketchPoint_5 = SketchProjection_8.createdFeature() +SketchCircle_7 = Sketch_5.addCircle(0, 0, 22) +SketchConstraintCoincidence_28 = Sketch_5.setCoincident(SketchPoint_5.result(), SketchCircle_7.center()) +SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_32") +SketchConstraintRadius_7 = Sketch_5.setRadius(SketchCircle_7.results()[1], 22) +model.do() +Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_5/Face-SketchCircle_7_2f")], model.selection(), "h3", 0) +Fuse_2 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Fillet_1_1"), model.selection("SOLID", "Extrusion_3_1")]) +Sketch_6 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_23 = Sketch_6.addLine(22, 70, 20, 70) +SketchLine_23.setName("SketchLine_25") +SketchLine_23.result().setName("SketchLine_25") +SketchProjection_9 = Sketch_6.addProjection(model.selection("VERTEX", "[Extrusion_3_1/Generated_Face&Sketch_5/SketchCircle_7_2][Extrusion_3_1/To_Face]"), False) +SketchPoint_6 = SketchProjection_9.createdFeature() +SketchConstraintCoincidence_29 = Sketch_6.setCoincident(SketchLine_23.startPoint(), SketchPoint_6.result()) +SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_33") +SketchLine_24 = Sketch_6.addLine(20, 70, 22, 68.84529946162075) +SketchLine_24.setName("SketchLine_26") +SketchLine_24.result().setName("SketchLine_26") +SketchConstraintCoincidence_30 = Sketch_6.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint()) +SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_34") +SketchProjection_10 = Sketch_6.addProjection(model.selection("EDGE", "([Extrusion_3_1/Generated_Face&Sketch_5/SketchCircle_7_2][Extrusion_3_1/To_Face])_Fuse_2_1"), False) +SketchLine_25 = SketchProjection_10.createdFeature() +SketchLine_25.setName("SketchLine_27") +SketchLine_25.result().setName("SketchLine_27") +SketchConstraintCoincidence_31 = Sketch_6.setCoincident(SketchLine_24.endPoint(), SketchLine_25.result()) +SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_35") +SketchLine_26 = Sketch_6.addLine(22, 68.84529946162075, 22, 70) +SketchLine_26.setName("SketchLine_28") +SketchLine_26.result().setName("SketchLine_28") +SketchConstraintCoincidence_32 = Sketch_6.setCoincident(SketchLine_24.endPoint(), SketchLine_26.startPoint()) +SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_36") +SketchConstraintCoincidence_33 = Sketch_6.setCoincident(SketchLine_23.startPoint(), SketchLine_26.endPoint()) +SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_37") +SketchLine_27 = Sketch_6.addLine(21.99999999999999, 64, 22, 63) +SketchLine_27.setName("SketchLine_29") +SketchLine_27.result().setName("SketchLine_29") +SketchConstraintCoincidence_34 = Sketch_6.setCoincident(SketchLine_27.startPoint(), SketchLine_25.result()) +SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_38") +SketchConstraintCoincidence_35 = Sketch_6.setCoincident(SketchAPI_Line(SketchLine_25).startPoint(), SketchLine_27.endPoint()) +SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_39") +SketchLine_28 = Sketch_6.addLine(21.99999999999999, 64, 21.73205080756888, 63) +SketchLine_28.setName("SketchLine_30") +SketchLine_28.result().setName("SketchLine_30") +SketchConstraintCoincidence_36 = Sketch_6.setCoincident(SketchLine_27.startPoint(), SketchLine_28.startPoint()) +SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_40") +SketchLine_29 = Sketch_6.addLine(21.73205080756888, 63, 22, 63) +SketchLine_29.setName("SketchLine_31") +SketchLine_29.result().setName("SketchLine_31") +SketchConstraintCoincidence_37 = Sketch_6.setCoincident(SketchLine_28.endPoint(), SketchLine_29.startPoint()) +SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_41") +SketchConstraintCoincidence_38 = Sketch_6.setCoincident(SketchAPI_Line(SketchLine_25).startPoint(), SketchLine_29.endPoint()) +SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_42") +SketchConstraintLength_1 = Sketch_6.setLength(SketchLine_23.result(), 2) +SketchConstraintAngle_2 = Sketch_6.setAngleBackward(SketchLine_23.result(), SketchLine_24.result(), 30) +SketchConstraintHorizontal_2 = Sketch_6.setHorizontal(SketchLine_23.result()) +SketchConstraintHorizontal_2.setName("SketchConstraintHorizontal_3") +SketchConstraintHorizontal_3 = Sketch_6.setHorizontal(SketchLine_29.result()) +SketchConstraintHorizontal_3.setName("SketchConstraintHorizontal_4") +SketchConstraintLength_2 = Sketch_6.setLength(SketchLine_27.result(), 1) +SketchConstraintAngle_3 = Sketch_6.setAngle(SketchLine_28.result(), SketchLine_27.result(), 15) +model.do() +Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "Sketch_6")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fuse_2_1")], [model.selection("SOLID", "Revolution_1_2"), model.selection("SOLID", "Revolution_1_1")]) +Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "Cut_1_1/Modified_Face&Extrusion_3_1/To_Face")) +SketchProjection_11 = Sketch_7.addProjection(model.selection("VERTEX", "[Revolution_1_1/Generated_Face&Sketch_6/SketchLine_26][Cut_1_1/Modified_Face&Extrusion_3_1/To_Face]__cc"), False) +SketchPoint_7 = SketchProjection_11.createdFeature() +SketchCircle_8 = Sketch_7.addCircle(0, 0, 26) +SketchCircle_8.setAuxiliary(True) +SketchConstraintCoincidence_39 = Sketch_7.setCoincident(SketchPoint_7.result(), SketchCircle_8.center()) +SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_43") +SketchConstraintRadius_8 = Sketch_7.setRadius(SketchCircle_8.results()[1], 26) +SketchCircle_9 = Sketch_7.addCircle(0, -26, 5.25) +SketchConstraintCoincidence_40 = Sketch_7.setCoincident(SketchCircle_8.results()[1], SketchCircle_9.center()) +SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_44") +SketchProjection_12 = Sketch_7.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_30 = SketchProjection_12.createdFeature() +SketchLine_30.setName("SketchLine_32") +SketchLine_30.result().setName("SketchLine_32") +SketchConstraintRadius_9 = Sketch_7.setRadius(SketchCircle_9.results()[1], 5.25) +SketchConstraintCoincidence_41 = Sketch_7.setCoincident(SketchCircle_9.center(), SketchLine_30.result()) +SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_45") +SketchMultiRotation_4 = Sketch_7.addRotation([SketchCircle_9.results()[1]], SketchAPI_Line(SketchLine_30).startPoint(), 360, 16, True) +[SketchCircle_10, SketchCircle_11, SketchCircle_12, SketchCircle_13, SketchCircle_14, SketchCircle_15, SketchCircle_16, SketchCircle_17, SketchCircle_18, SketchCircle_19, SketchCircle_20, SketchCircle_21, SketchCircle_22, SketchCircle_23, SketchCircle_24] = SketchMultiRotation_4.rotated() +model.do() +Extrusion_4_objects = [model.selection("FACE", "Sketch_7/Face-SketchCircle_19_2f-SketchCircle_20_2r-SketchCircle_19_2f-SketchCircle_19_2f-SketchCircle_18_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_18_2f-SketchCircle_19_2r-SketchCircle_18_2f-SketchCircle_17_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_17_2f-SketchCircle_18_2r-SketchCircle_18_2r-SketchCircle_17_2f-SketchCircle_16_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_15_2f-SketchCircle_15_2f-SketchCircle_16_2r-SketchCircle_15_2f-SketchCircle_14_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_16_2f-SketchCircle_16_2f-SketchCircle_17_2r-SketchCircle_17_2r-SketchCircle_16_2f-SketchCircle_15_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_14_2f-SketchCircle_14_2f-SketchCircle_15_2r-SketchCircle_14_2f-SketchCircle_13_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_13_2f-SketchCircle_13_2f-SketchCircle_14_2r-SketchCircle_13_2f-SketchCircle_12_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_12_2f-SketchCircle_12_2f-SketchCircle_13_2r-SketchCircle_12_2f-SketchCircle_11_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_11_2f-SketchCircle_11_2f-SketchCircle_12_2r-SketchCircle_11_2f-SketchCircle_10_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_9_2r-SketchCircle_10_2f-SketchCircle_10_2f-SketchCircle_11_2r-SketchCircle_10_2f-SketchCircle_9_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_9_2f-SketchCircle_24_2r-SketchCircle_24_2r-SketchCircle_9_2f-SketchCircle_10_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_24_2f-SketchCircle_23_2r-SketchCircle_24_2f-SketchCircle_9_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_23_2f-SketchCircle_24_2r-SketchCircle_23_2f-SketchCircle_23_2f-SketchCircle_22_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_22_2f-SketchCircle_23_2r-SketchCircle_22_2f-SketchCircle_22_2f-SketchCircle_21_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_21_2f-SketchCircle_22_2r-SketchCircle_21_2f-SketchCircle_21_2f-SketchCircle_20_2r"), model.selection("FACE", "Sketch_7/Face-SketchCircle_20_2f-SketchCircle_21_2r-SketchCircle_20_2f-SketchCircle_20_2f-SketchCircle_19_2r")] +Extrusion_4 = model.addExtrusion(Part_1_doc, Extrusion_4_objects, model.selection(), model.selection("FACE", "Sketch_5/Face-SketchCircle_7_2f"), 0, model.selection(), 0) +Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("COMPOUND", "all-in-Extrusion_4")]) +Sketch_8 = model.addSketch(Part_1_doc, model.standardPlane("XOZ")) +SketchLine_31 = Sketch_8.addLine(0, 97, 4.25, 97) +SketchLine_31.setName("SketchLine_33") +SketchLine_31.result().setName("SketchLine_33") +SketchProjection_13 = Sketch_8.addProjection(model.selection("EDGE", "PartSet/OZ"), False) +SketchLine_32 = SketchProjection_13.createdFeature() +SketchLine_32.setName("SketchLine_34") +SketchLine_32.result().setName("SketchLine_34") +SketchConstraintCoincidence_42 = Sketch_8.setCoincident(SketchLine_31.startPoint(), SketchLine_32.result()) +SketchConstraintCoincidence_42.setName("SketchConstraintCoincidence_46") +SketchLine_33 = Sketch_8.addLine(4.25, 97, 4.25, 91.05) +SketchLine_33.setName("SketchLine_35") +SketchLine_33.result().setName("SketchLine_35") +SketchConstraintCoincidence_43 = Sketch_8.setCoincident(SketchLine_31.endPoint(), SketchLine_33.startPoint()) +SketchConstraintCoincidence_43.setName("SketchConstraintCoincidence_47") +SketchLine_34 = Sketch_8.addLine(4.25, 91.05, 6, 89.3) +SketchLine_34.setName("SketchLine_36") +SketchLine_34.result().setName("SketchLine_36") +SketchConstraintCoincidence_44 = Sketch_8.setCoincident(SketchLine_33.endPoint(), SketchLine_34.startPoint()) +SketchConstraintCoincidence_44.setName("SketchConstraintCoincidence_48") +SketchLine_35 = Sketch_8.addLine(6, 89.3, 6, 70) +SketchLine_35.setName("SketchLine_37") +SketchLine_35.result().setName("SketchLine_37") +SketchConstraintCoincidence_45 = Sketch_8.setCoincident(SketchLine_34.endPoint(), SketchLine_35.startPoint()) +SketchConstraintCoincidence_45.setName("SketchConstraintCoincidence_49") +SketchLine_36 = Sketch_8.addLine(6, 70, 0, 70) +SketchLine_36.setName("SketchLine_38") +SketchLine_36.result().setName("SketchLine_38") +SketchConstraintCoincidence_46 = Sketch_8.setCoincident(SketchLine_35.endPoint(), SketchLine_36.startPoint()) +SketchConstraintCoincidence_46.setName("SketchConstraintCoincidence_50") +SketchProjection_14 = Sketch_8.addProjection(model.selection("VERTEX", "Sketch_7/SketchCircle_8"), False) +SketchPoint_8 = SketchProjection_14.createdFeature() +SketchConstraintCoincidence_47 = Sketch_8.setCoincident(SketchLine_36.endPoint(), SketchPoint_8.result()) +SketchConstraintCoincidence_47.setName("SketchConstraintCoincidence_51") +SketchLine_37 = Sketch_8.addLine(0, 70, 0, 97) +SketchLine_37.setName("SketchLine_39") +SketchLine_37.result().setName("SketchLine_39") +SketchConstraintCoincidence_48 = Sketch_8.setCoincident(SketchLine_36.endPoint(), SketchLine_37.startPoint()) +SketchConstraintCoincidence_48.setName("SketchConstraintCoincidence_52") +SketchConstraintCoincidence_49 = Sketch_8.setCoincident(SketchLine_31.startPoint(), SketchLine_37.endPoint()) +SketchConstraintCoincidence_49.setName("SketchConstraintCoincidence_53") +SketchConstraintHorizontal_4 = Sketch_8.setHorizontal(SketchLine_36.result()) +SketchConstraintHorizontal_4.setName("SketchConstraintHorizontal_5") +SketchConstraintHorizontal_5 = Sketch_8.setHorizontal(SketchLine_31.result()) +SketchConstraintHorizontal_5.setName("SketchConstraintHorizontal_6") +SketchConstraintVertical_3 = Sketch_8.setVertical(SketchLine_33.result()) +SketchConstraintVertical_4 = Sketch_8.setVertical(SketchLine_35.result()) +SketchConstraintLength_3 = Sketch_8.setLength(SketchLine_31.result(), 4.25) +SketchConstraintLength_4 = Sketch_8.setLength(SketchLine_36.result(), 6) +SketchConstraintLength_5 = Sketch_8.setLength(SketchLine_35.result(), 19.3) +SketchConstraintAngle_4 = Sketch_8.setAngle(SketchLine_34.result(), SketchLine_31.result(), 45) +SketchProjection_15 = Sketch_8.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_38 = SketchProjection_15.createdFeature() +SketchLine_38.setName("SketchLine_40") +SketchLine_38.result().setName("SketchLine_40") +SketchConstraintDistance_5 = Sketch_8.setDistance(SketchLine_33.startPoint(), SketchLine_38.result(), 97, True) +model.do() +Revolution_2 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_8/Face-SketchLine_39r-SketchLine_38r-SketchLine_37r-SketchLine_36r-SketchLine_35r-SketchLine_33r")], model.selection("EDGE", "PartSet/OZ"), 360, 0) +Fuse_3 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cut_2_1"), model.selection("SOLID", "Revolution_2_1")]) +Fillet_2 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Fuse_3_1/Modified_Face&Extrusion_3_1/To_Face][Revolution_2_1/Generated_Face&Sketch_8/SketchLine_37]")], 1) +model.testHaveNamingSubshapes(Fillet_2, model, Part_1_doc) +Group_4_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_2_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_3_2"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchCircle_4_2")] +Group_4 = model.addGroup(Part_1_doc, Group_4_objects) +Group_4.setName("SCREW") +Group_4.result().setName("SCREW") +Group_5 = model.addGroup(Part_1_doc, [model.selection("FACE", "Revolution_2_1/Generated_Face&Sketch_8/SketchLine_33")]) +Group_5.setName("TOP") +Group_5.result().setName("TOP") +model.do() +model.end() + +from GeomAPI import GeomAPI_Shape + +model.testNbResults(Fillet_2, 1) +model.testNbSubResults(Fillet_2, [0]) +model.testNbSubShapes(Fillet_2, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Fillet_2, GeomAPI_Shape.FACE, [98]) +model.testNbSubShapes(Fillet_2, GeomAPI_Shape.EDGE, [528]) +model.testNbSubShapes(Fillet_2, GeomAPI_Shape.VERTEX, [1056]) +model.testResultsVolumes(Fillet_2, [41200.919845003852969966828823090]) + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() + +# Check that the features are not in error +for i in range(Part_1_doc.size("Features")): + feature = objectToFeature(Part_1_doc.object("Features", i)) + name = feature.name() + error = feature.error() + assert(error == ''), "The feature {0} is in error: {1}".format(name, error) + assert(aFactory.validate(feature)), "The feature {0} is in error: {1}".format(name, error) + +assert(Part_1_doc.size("Groups") == 5) + +assert(model.checkPythonDump()) \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_PagedContainer.cpp b/src/ModuleBase/ModuleBase_PagedContainer.cpp index d96a7c70a..2b0117acf 100644 --- a/src/ModuleBase/ModuleBase_PagedContainer.cpp +++ b/src/ModuleBase/ModuleBase_PagedContainer.cpp @@ -105,14 +105,15 @@ bool ModuleBase_PagedContainer::restoreValueCustom() if (aStringAttr->isInitialized()) { if (myIsEditing) aCaseId = QString::fromStdString(aStringAttr->value()); - else + else { aCaseId = QString::fromStdString(aDefVal.empty() ? aStringAttr->value() : aDefVal); - if (!aStringAttr->isInitialized()) - storeValueCustom(); + } int idx = myCaseIds.indexOf(aCaseId); if (idx == -1) idx = currentPageIndex(); setCurrentPageIndex(idx); + if (aStringAttr->value() != aCaseId.toStdString()) + storeValueCustom(); } else { // It is added because if user edits the feature created from Python diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 21df54023..9ed25e82e 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -352,7 +352,7 @@ bool ModuleBase_WidgetMultiSelector::restoreValueCustom() if (aSelectionType.empty()) aSelectionListAttr->setSelectionType(myDefMode); else { - setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionType.c_str())); + setCurrentShapeType(aSelectionType.c_str()); myDefMode = aSelectionType; myIsFirst = false; } @@ -752,23 +752,30 @@ QIntList ModuleBase_WidgetMultiSelector::shapeTypes() const QIntList aShapeTypes; if (myShapeTypes.length() > 1 && myIsUseChoice) { - aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue())); + QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts); + for(QString aType: aTypes) { + aShapeTypes.append(ModuleBase_Tools::shapeType(aType)); + } } else { foreach (QString aType, myShapeTypes) { - aShapeTypes.append(ModuleBase_Tools::shapeType(aType)); + QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts); + for(QString aSubType: aSubTypes) { + aShapeTypes.append(ModuleBase_Tools::shapeType(aSubType)); + } } } return aShapeTypes; } //******************************************************************** -void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const int theShapeType) +void ModuleBase_WidgetMultiSelector::setCurrentShapeType(const QString& theShapeType) { int idx = 0; + GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::shapeTypeByStr(theShapeType.toStdString()); foreach (QString aShapeTypeName, myShapeTypes) { - int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName); - if(aRefType == theShapeType && idx != myTypeCtrl->value()) { + if(GeomAPI_Shape::shapeTypeByStr(aShapeTypeName.toStdString()) == aShapeType && + idx != myTypeCtrl->value()) { updateSelectionModesAndFilters(false); bool isBlocked = myTypeCtrl->blockSignals(true); myTypeCtrl->setValue(idx); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 8e788d655..946b46d77 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -182,7 +182,7 @@ protected: virtual QIntList shapeTypes() const; /// Set current shape type for selection - void setCurrentShapeType(const int theShapeType); + void setCurrentShapeType(const QString& theShapeType); /// Return the attribute values wrapped in a list of viewer presentations /// \return a list of viewer presentations, which contains an attribute result and diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 30d34b993..c6a6197c3 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1656,7 +1656,8 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess CompositeFeaturePtr aSketch = mySketchMgr->activeSketch(); if (aSketch.get()) { ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); - if (PartSet_SketcherMgr::isSketchOperation(anOperation)) + if (PartSet_SketcherMgr::isSketchOperation(anOperation) && + mySketchMgr->previewSketchPlane()->isDisplayed()) mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop); } } diff --git a/src/PartSet/PartSet_PreviewSketchPlane.cpp b/src/PartSet/PartSet_PreviewSketchPlane.cpp index 72018bd0f..13c3ab8f1 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.cpp +++ b/src/PartSet/PartSet_PreviewSketchPlane.cpp @@ -71,6 +71,13 @@ void PartSet_PreviewSketchPlane::displaySketchPlane(ModuleBase_IWorkshop* theWor } +void PartSet_PreviewSketchPlane::clearPlanePreview() +{ + myPlane = std::shared_ptr(); + myShape = std::shared_ptr(); +} + + void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop) { diff --git a/src/PartSet/PartSet_PreviewSketchPlane.h b/src/PartSet/PartSet_PreviewSketchPlane.h index c255aca42..0f32c3b0f 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.h +++ b/src/PartSet/PartSet_PreviewSketchPlane.h @@ -74,12 +74,22 @@ public: void setSizeOfView(double theSizeOfView, bool isUseSizeOfView, const std::shared_ptr& theCentralPoint = std::shared_ptr()); + /// Returns True if the plane preview is already created bool isPlaneCreated() const { return myPlane.get(); } + /// Returns current state of the plane preview visibility + bool isDisplayed() const { return myPreviewIsDisplayed; } + + /// Displays preview planes + /// \param theWorkshop the application workshop void displaySketchPlane(ModuleBase_IWorkshop* theWorkshop); + /// Nullyfies current plane preview object. + /// Important: Before call of this function the plane has to be erased from viewer + void clearPlanePreview(); + private: /// Create a square face by parameters std::shared_ptr createPreviewPlane(); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1b515d32b..ecc6f36d8 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1096,6 +1096,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation) myCurrentSketch = std::dynamic_pointer_cast(aFOperation->feature()); double aSizeOfView = 0; std::shared_ptr aCentralPoint; + // Reset size of view from previous launches + mySketchPlane->setSizeOfView(aSizeOfView, false, aCentralPoint); if (aFOperation->isEditOperation() && mySketchPlane->getDefaultSizeOfView(myCurrentSketch, aSizeOfView, aCentralPoint)) { mySketchPlane->setSizeOfView(aSizeOfView, true, aCentralPoint); diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index c8068e18c..8f6f4fcd5 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -284,19 +284,22 @@ bool PartSet_WidgetPoint2D::setSelection(QList& theValu Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); const TopoDS_Shape& aTDShape = aShape->impl(); GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch); + if (aPnt) { - isDone = setPoint(aPnt->x(), aPnt->y()); - setConstraintToPoint(aPnt->x(), aPnt->y(), aValue); + //isDone = setPoint(aPnt->x(), aPnt->y()); + //setConstraintToPoint(aPnt->x(), aPnt->y(), aValue); + processSelection(aValue, aPnt->x(), aPnt->y()); + isDone = true; } } } return isDone; } -void PartSet_WidgetPoint2D::selectContent() -{ - // myXSpin->selectAll(); -} +//void PartSet_WidgetPoint2D::selectContent() +//{ +// // myXSpin->selectAll(); +//} bool PartSet_WidgetPoint2D::setPoint(double theX, double theY) { @@ -554,12 +557,36 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo aFirstValue = myPreSelected; } + double aX=0, aY=0; + bool aHasPoint = false; + if (aFirstValue.get()) { + GeomShapePtr aShape = aFirstValue->shape(); + if (aShape.get() && aShape->shapeType() == GeomAPI_Shape::VERTEX) { + const TopoDS_Shape& aTDShape = aShape->impl(); + GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch); + aX = aPnt->x(); + aY = aPnt->y(); + aHasPoint = true; + } + } + if (!aHasPoint) { + gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); + PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY); + } + processSelection(aFirstValue, aX, aY); +} + +void PartSet_WidgetPoint2D::processSelection(const ModuleBase_ViewerPrsPtr& theValue, + double theX, double theY) +{ + if (!setPoint(theX, theY)) + return; // if we have selection and use it - if (aFirstValue.get() && isValidSelectionCustom(aFirstValue) && - aFirstValue->shape().get()) { /// Trihedron Axis may be selected, but shape is empty - GeomShapePtr aGeomShape = aFirstValue->shape(); + if (theValue.get() && isValidSelectionCustom(theValue) && theValue->shape().get()) { + /// Trihedron Axis may be selected, but shape is empty + GeomShapePtr aGeomShape = theValue->shape(); TopoDS_Shape aShape = aGeomShape->impl(); - ObjectPtr aObject = aFirstValue->object(); + ObjectPtr aObject = theValue->object(); FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(aObject); bool anExternal = false; @@ -585,34 +612,12 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo } } if (anExternal) { - GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch); - double aX = 0, aY = 0; - if (aPnt) { - aX = aPnt->x(); - aY = aPnt->y(); - } - if (aPnt && isFeatureContainsPoint(myFeature, aX, aY)) { - // do not create a constraint to the point, which already used by the feature - // if the feature contains the point, focus is not switched - setPoint(aX, aY); - } - else { - if (aPnt) - setPoint(aX, aY); - else { - if (aShape.ShapeType() == TopAbs_EDGE) { - // point is taken from mouse event and set in attribute. It should be done before set - // coinident constraint to the external line. If a point is created, it should be in - // the mouse clicked point - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), - theWindow->v3dView()); - PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY); - setPoint(aX, aY); - } + if (!isFeatureContainsPoint(myFeature, theX, theY)) { + if (aShape.ShapeType() == TopAbs_EDGE) { setValueState(Stored); // in case of edge selection, Apply state should also be updated } bool anOrphanPoint = aShape.ShapeType() == TopAbs_VERTEX || - isOrphanPoint(aSelectedFeature, mySketch, aX, aY); + isOrphanPoint(aSelectedFeature, mySketch, theX, theY); if (anExternal) { // we should not stop reentrant operation on external objects because anOrphanPoint = true; @@ -620,7 +625,7 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo if (aShape.ShapeType() == TopAbs_VERTEX) { FeaturePtr aFixedFeature = ModelAPI_Feature::feature(aFixedObject); if (aFixedFeature.get() && aFixedFeature->getKind() == SketchPlugin_Point::ID()) { - anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, aX, aY); + anOrphanPoint = isOrphanPoint(aFixedFeature, mySketch, theX, theY); } } } @@ -637,33 +642,21 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo emit focusOutWidget(this); } } - if (!anExternal) { - GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch); - if (aPnt && isFeatureContainsPoint(myFeature, aPnt->x(), aPnt->y())) { - // when the point is selected, the coordinates of the point should be set into the attribute - // if the feature contains the point, focus is not switched - setPoint(aPnt->x(), aPnt->y()); - } - else { + else { + if (!isFeatureContainsPoint(myFeature, theX, theY)) { double aX = 0, aY = 0; bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY); // do not set a coincidence constraint in the attribute if the feature contains a point // with the same coordinates. It is important for line creation in order to do not set // the same constraints for the same points, oterwise the result line has zero length. bool isAuxiliaryFeature = false; - if (aPnt) { - aX = aPnt->x(); - aY = aPnt->y(); - setPoint(aX, aY); - setConstraintToPoint(aX, aY, aFirstValue); + if (aShape.ShapeType() == TopAbs_VERTEX) { + setConstraintToPoint(theX, theY, theValue); } else if (aShape.ShapeType() == TopAbs_EDGE) { // point is taken from mouse event and set in attribute. It should be done before setting // coinident constraint to the external line. If a point is created, it should be in // the mouse clicked point - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView()); - PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY); - setPoint(aX, aY); setConstraintToObject(aObject); setValueState(Stored); // in case of edge selection, Apply state should also be updated isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject); @@ -683,9 +676,9 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo } } // The selection could be a center of an external circular object - else if (aFirstValue.get() && (!aFirstValue->interactive().IsNull())) { + else if (theValue.get() && (!theValue->interactive().IsNull())) { Handle(PartSet_CenterPrs) aAIS = - Handle(PartSet_CenterPrs)::DownCast(aFirstValue->interactive()); + Handle(PartSet_CenterPrs)::DownCast(theValue->interactive()); if (!aAIS.IsNull()) { gp_Pnt aPntComp = aAIS->Component()->Pnt(); GeomVertexPtr aVertPtr(new GeomAPI_Vertex(aPntComp.X(), aPntComp.Y(), aPntComp.Z())); @@ -705,12 +698,6 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo // external objects e.g. selection of trihedron axis when input end arc point updateObject(feature()); - GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch); - if (aPnt) { - // do not create a constraint to the point, which already used by the feature - // if the feature contains the point, focus is not switched - setPoint(aPnt->x(), aPnt->y()); - } emit vertexSelected(); // it stops the reentrant operation myPreSelected.reset(); emit focusOutWidget(this); @@ -718,12 +705,9 @@ void PartSet_WidgetPoint2D::mouseReleased(ModuleBase_IViewWindow* theWindow, QMo } else { // A case when point is taken from mouse event - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView()); - double aX = 0, aY = 0; - PartSet_Tools::convertTo2D(aPoint, mySketch, aView, aX, aY); // if the feature contains the point, focus is not switched - if (!setPoint(aX, aY) || isFeatureContainsPoint(myFeature, aX, aY)) + if (isFeatureContainsPoint(myFeature, theX, theY)) return; myPreSelected.reset(); diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index 19846bfe7..f0a06a8ec 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -25,6 +25,7 @@ #include #include +#include #include @@ -98,7 +99,7 @@ Q_OBJECT const bool theToValidate); /// Select the internal content if it can be selected. It is empty in the default realization - virtual void selectContent(); + //virtual void selectContent(); /// Returns list of widget controls /// \return a control list @@ -222,6 +223,13 @@ protected: /// \return true if succed bool setConstraintToObject(const ObjectPtr& theObject); + /// Process selected value + /// \param theValue the selected object + /// \param theX X coordinate of clicked point + /// \param theY Y coordinate of clicked point + void processSelection(const ModuleBase_ViewerPrsPtr& theValue, double theX, double theY); + + public: /// Returns if the feature is an orphan point, circle or an arc. Returns true if it /// has no a coincident to other lines. It processes point, circle and arc features diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp index 3fe190981..6d570d985 100644 --- a/src/PartSet/PartSet_WidgetSketchCreator.cpp +++ b/src/PartSet/PartSet_WidgetSketchCreator.cpp @@ -307,11 +307,17 @@ QIntList PartSet_WidgetSketchCreator::shapeTypes() const { QIntList aShapeTypes; if (myShapeTypes.length() > 1 && myIsUseChoice) { - aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue())); + QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts); + foreach(QString aType, aTypes) { + aShapeTypes.append(ModuleBase_Tools::shapeType(aType)); + } } else { foreach(QString aType, myShapeTypes) { - aShapeTypes.append(ModuleBase_Tools::shapeType(aType)); + QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts); + foreach(QString asubType, aSubTypes) { + aShapeTypes.append(ModuleBase_Tools::shapeType(asubType)); + } } } return aShapeTypes; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 2f41d3ed9..87c535a54 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -365,6 +365,8 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, isSetSizeOfView); if (myViewVisible->isChecked()) aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop); + else + aModule->sketchMgr()->previewSketchPlane()->clearPlanePreview(); } // 2. if the planes were displayed, change the view projection diff --git a/src/PythonAPI/model/exchange/__init__.py b/src/PythonAPI/model/exchange/__init__.py index a37fdd678..800ab45f9 100644 --- a/src/PythonAPI/model/exchange/__init__.py +++ b/src/PythonAPI/model/exchange/__init__.py @@ -19,7 +19,7 @@ """Package for Exchange plugin for the Parametric Geometry API of the Modeler. """ -from ExchangeAPI import addImport, exportToFile, exportToXAO +from ExchangeAPI import addImport, addImportSTEP, exportToFile, exportToXAO, exportToSTL from ExchangeAPI import exportPart, importPart from .tools import * diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index 081f2b03e..33908724f 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -7,7 +7,7 @@ - +
diff --git a/src/SketchAPI/SketchAPI_Mirror.cpp b/src/SketchAPI/SketchAPI_Mirror.cpp index 1013e3cf5..534f50576 100644 --- a/src/SketchAPI/SketchAPI_Mirror.cpp +++ b/src/SketchAPI/SketchAPI_Mirror.cpp @@ -39,15 +39,18 @@ SketchAPI_Mirror::SketchAPI_Mirror( { if (initialize()) { fillAttribute(theMirrorLine, mirrorLine()); - fillAttribute(theObjects, mirrorList()); - - execute(); + setMirrorList(theObjects); } } SketchAPI_Mirror::~SketchAPI_Mirror() { +} +void SketchAPI_Mirror::setMirrorList(const std::list >& theObjects) +{ + fillAttribute(theObjects, mirrorList()); + execute(); } std::list > SketchAPI_Mirror::mirrored() const @@ -69,44 +72,71 @@ void SketchAPI_Mirror::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aSketchName = theDumper.parentName(aBase); - AttributeRefAttrPtr aMirrorLine = mirrorLine(); AttributeRefListPtr aMirrorObjects = mirrorList(); // Check all attributes are already dumped. If not, store the constraint as postponed. - if (!theDumper.isDumped(aMirrorLine) || !theDumper.isDumped(aMirrorObjects)) { + size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aMirrorObjects); + if (!theDumper.isDumped(aMirrorLine) || aFirstNotDumped == 0) { + theDumper.postpone(aBase); + return; + } + + + // the number of dumped aMirrorObjects is not changed, no need to dump anything + static std::map aNbDumpedArguments; + std::map::iterator aFound = aNbDumpedArguments.find(aBase); + if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) { theDumper.postpone(aBase); return; } + else + aNbDumpedArguments[aBase] = aFirstNotDumped; - theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", " - << aMirrorObjects << ")" << std::endl; + if (theDumper.isDumped(aBase)) { + // the feature is already dumped, but it was postponed, because of some arguments + // were not dumped yet, thus, it is necessary to update the list of rotated objects + theDumper << "\n### Update " << aBase->getKind() << std::endl; + theDumper << aBase << ".setMirrorList(" << aMirrorObjects << ")" << std::endl; + } + else { + // the feature is not dumped yet, make the full dump + theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", " + << aMirrorObjects << ")" << std::endl; + } // Dump variables for a list of mirrored features theDumper << "["; std::list > aList = mirrored(); std::list >::const_iterator anIt = aList.begin(); - for (; anIt != aList.end(); ++anIt) { + for (size_t anIndex = 0; anIndex < aFirstNotDumped; ++anIndex, ++anIt) { if (anIt != aList.begin()) theDumper << ", "; theDumper << (*anIt)->feature(); } theDumper << "] = " << theDumper.name(aBase) << ".mirrored()" << std::endl; - // Set necessary "auxiliary" flag for mirrored features - // (flag is set if it differs to base entity) - std::list aMirList = aMirrorObjects->list(); - std::list::const_iterator aMIt = aMirList.begin(); - for (anIt = aList.begin(); aMIt != aMirList.end(); ++aMIt, ++anIt) { - FeaturePtr aFeature = ModelAPI_Feature::feature(*aMIt); - if (!aFeature) - continue; - bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + if (theDumper.isDumped(aMirrorObjects)) { + aNbDumpedArguments.erase(aBase); + // Set necessary "auxiliary" flag for mirrored features + // (flag is set if it differs to base entity) + std::list aMirList = aMirrorObjects->list(); + std::list::const_iterator aMIt = aMirList.begin(); + for (anIt = aList.begin(); aMIt != aMirList.end(); ++aMIt, ++anIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*aMIt); + if (!aFeature) + continue; + bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - aFeature = (*anIt)->feature(); - bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - if (aFeatAux != aBaseAux) - theDumper << theDumper.name((*anIt)->feature(), false) - << ".setAuxiliary(" << aFeatAux << ")" <feature(); + bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + if (aFeatAux != aBaseAux) + theDumper << theDumper.name((*anIt)->feature(), false) + << ".setAuxiliary(" << aFeatAux << ")" < >& theObjects); + /// List of mirrored objects SKETCHAPI_EXPORT std::list > mirrored() const; diff --git a/src/SketchAPI/SketchAPI_Rotation.cpp b/src/SketchAPI/SketchAPI_Rotation.cpp index eb81b0d70..4a83244ce 100644 --- a/src/SketchAPI/SketchAPI_Rotation.cpp +++ b/src/SketchAPI/SketchAPI_Rotation.cpp @@ -43,14 +43,13 @@ SketchAPI_Rotation::SketchAPI_Rotation( : ModelHighAPI_Interface(theFeature) { if (initialize()) { - fillAttribute(theObjects, rotationList()); fillAttribute(theCenter, center()); fillAttribute(theFullValue ? "FullAngle" : "SingleAngle", valueType()); fillAttribute(theAngle, angle()); fillAttribute(theReversed, reversed()); fillAttribute(theNumberOfObjects, numberOfObjects()); - execute(true); + setRotationList(theObjects); } } @@ -59,6 +58,13 @@ SketchAPI_Rotation::~SketchAPI_Rotation() } +void SketchAPI_Rotation::setRotationList( + const std::list >& theObjects) +{ + fillAttribute(theObjects, rotationList()); + execute(true); +} + std::list > SketchAPI_Rotation::rotated() const { std::list aList = rotatedObjects()->list(); @@ -74,6 +80,26 @@ std::list > SketchAPI_Rotation::rotated( return SketchAPI_SketchEntity::wrap(anIntermediate); } +std::list > SketchAPI_Rotation::rotatedList() const +{ + std::list aList = rotationList()->list(); + std::set anOriginalObjects; + anOriginalObjects.insert(aList.begin(), aList.end()); + // remove all initial features + std::list anIntermediate; + aList = rotatedObjects()->list(); + std::list::const_iterator anIt = aList.begin(); + for (; anIt != aList.end(); ++anIt) { + if (anOriginalObjects.find(*anIt) != anOriginalObjects.end()) + continue; // skip initial object + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + AttributeBooleanPtr isCopy = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + if (isCopy.get() && isCopy->value()) + anIntermediate.push_back(aFeature); + } + return SketchAPI_SketchEntity::wrap(anIntermediate); +} + //-------------------------------------------------------------------------------------- void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const @@ -89,49 +115,77 @@ void SketchAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const bool isReversed = reversed()->value(); // Check all attributes are already dumped. If not, store the constraint as postponed. - if (!theDumper.isDumped(aCenter) || !theDumper.isDumped(aRotObjects)) { + size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aRotObjects); + if (!theDumper.isDumped(aCenter) || aFirstNotDumped == 0) { theDumper.postpone(aBase); return; } - theDumper << aBase << " = " << aSketchName << ".addRotation(" - << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies; - if (isFullValue || isReversed) - { - theDumper << ", " << isFullValue; - if (isReversed) - theDumper << ", " << isReversed; + // the number of dumped aRotObjects is not changed, no need to dump anything + static std::map aNbDumpedArguments; + std::map::iterator aFound = aNbDumpedArguments.find(aBase); + if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) { + theDumper.postpone(aBase); + return; + } + else + aNbDumpedArguments[aBase] = aFirstNotDumped; + + if (theDumper.isDumped(aBase)) { + // the feature is already dumped, but it was postponed, because of some arguments + // were not dumped yet, thus, it is necessary to update the list of rotated objects + theDumper << "\n### Update " << aBase->getKind() << std::endl; + theDumper << aBase << ".setRotationList(" << aRotObjects << ")" << std::endl; + } + else { + // the feature is not dumped yet, make the full dump + theDumper << aBase << " = " << aSketchName << ".addRotation(" + << aRotObjects << ", " << aCenter << ", " << anAngle << ", " << aNbCopies; + if (isFullValue || isReversed) + { + theDumper << ", " << isFullValue; + if (isReversed) + theDumper << ", " << isReversed; + } + theDumper << ")" << std::endl; } - theDumper << ")" << std::endl; // Dump variables for a list of rotated features theDumper << "["; - std::list > aList = rotated(); + std::list > aList = rotatedList(); std::list >::const_iterator anIt = aList.begin(); - for (; anIt != aList.end(); ++anIt) { - if (anIt != aList.begin()) - theDumper << ", "; - theDumper << (*anIt)->feature(); - } - theDumper << "] = " << theDumper.name(aBase) << ".rotated()" << std::endl; - - // Set necessary "auxiliary" flag for rotated features - // (flag is set if it differs to base entity) - std::list aRotList = aRotObjects->list(); - std::list::const_iterator aRIt = aRotList.begin(); - anIt = aList.begin(); - for (; aRIt != aRotList.end(); ++aRIt) { - FeaturePtr aFeature = ModelAPI_Feature::feature(*aRIt); - if (!aFeature) - continue; - bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - - for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) { - aFeature = (*anIt)->feature(); - bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - if (aFeatAux != aBaseAux) - theDumper << theDumper.name((*anIt)->feature(), false) - << ".setAuxiliary(" << aFeatAux << ")" <value() && anIt != aList.end(); ++i, ++anIt) { + if (anIt != aList.begin()) + theDumper << ", "; + theDumper << (*anIt)->feature(); } + theDumper << "] = " << theDumper.name(aBase) << ".rotatedList()" << std::endl; + + if (theDumper.isDumped(aRotObjects)) { + aNbDumpedArguments.erase(aBase); + // Set necessary "auxiliary" flag for rotated features + // (flag is set if it differs to base entity) + std::list aRotList = aRotObjects->list(); + std::list::const_iterator aRIt = aRotList.begin(); + anIt = aList.begin(); + for (; aRIt != aRotList.end(); ++aRIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*aRIt); + if (!aFeature) + continue; + bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + + for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) { + aFeature = (*anIt)->feature(); + bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + if (aFeatAux != aBaseAux) + theDumper << theDumper.name((*anIt)->feature(), false) + << ".setAuxiliary(" << aFeatAux << ")" << std::endl; + } + } + } + else { + // If all refereced objects are not dumped yet, mark the feature as postponed. + theDumper.postpone(aBase); } } diff --git a/src/SketchAPI/SketchAPI_Rotation.h b/src/SketchAPI/SketchAPI_Rotation.h index ac3392f92..beff1d64d 100644 --- a/src/SketchAPI/SketchAPI_Rotation.h +++ b/src/SketchAPI/SketchAPI_Rotation.h @@ -78,10 +78,19 @@ public: ModelAPI_AttributeRefList, /** Rotated objects */ ) - /// List of rotated objects + /// Set list of objects to be rotated + SKETCHAPI_EXPORT + void setRotationList(const std::list >& theObjects); + + /// List of rotated objects. + /// [DEPRECATED]: use rotatedList() instead. SKETCHAPI_EXPORT std::list > rotated() const; + /// List of rotated objects. + SKETCHAPI_EXPORT + std::list > rotatedList() const; + /// Dump wrapped feature virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; diff --git a/src/SketchAPI/SketchAPI_Translation.cpp b/src/SketchAPI/SketchAPI_Translation.cpp index 660286d45..60b88fbf6 100644 --- a/src/SketchAPI/SketchAPI_Translation.cpp +++ b/src/SketchAPI/SketchAPI_Translation.cpp @@ -42,19 +42,24 @@ SketchAPI_Translation::SketchAPI_Translation( : ModelHighAPI_Interface(theFeature) { if (initialize()) { - fillAttribute(theObjects, translationList()); fillAttribute(thePoint1, startPoint()); fillAttribute(thePoint2, endPoint()); fillAttribute(theNumberOfObjects, numberOfObjects()); fillAttribute(theFullValue ? "FullValue" : "SingleValue", valueType()); - execute(true); + setTranslationList(theObjects); } } SketchAPI_Translation::~SketchAPI_Translation() { +} +void SketchAPI_Translation::setTranslationList( + const std::list >& theObjects) +{ + fillAttribute(theObjects, translationList()); + execute(true); } std::list > SketchAPI_Translation::translated() const @@ -72,6 +77,26 @@ std::list > SketchAPI_Translation::trans return SketchAPI_SketchEntity::wrap(anIntermediate); } +std::list > SketchAPI_Translation::translatedList() const +{ + std::list aList = translationList()->list(); + std::set anOriginalObjects; + anOriginalObjects.insert(aList.begin(), aList.end()); + // remove all initial features + std::list anIntermediate; + aList = translatedObjects()->list(); + std::list::const_iterator anIt = aList.begin(); + for (; anIt != aList.end(); ++anIt) { + if (anOriginalObjects.find(*anIt) != anOriginalObjects.end()) + continue; // skip initial object + FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); + AttributeBooleanPtr isCopy = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + if (isCopy.get() && isCopy->value()) + anIntermediate.push_back(aFeature); + } + return SketchAPI_SketchEntity::wrap(anIntermediate); +} + //-------------------------------------------------------------------------------------- void SketchAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const @@ -86,46 +111,73 @@ void SketchAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const bool isFullValue = valueType()->value() != "SingleValue"; // Check all attributes are already dumped. If not, store the constraint as postponed. - if (!theDumper.isDumped(aStart) || !theDumper.isDumped(aEnd) || - !theDumper.isDumped(aTransObjects)) { + size_t aFirstNotDumped = theDumper.indexOfFirstNotDumped(aTransObjects); + if (!theDumper.isDumped(aStart) || !theDumper.isDumped(aEnd) || aFirstNotDumped == 0) { theDumper.postpone(aBase); return; } - theDumper << aBase << " = " << aSketchName << ".addTranslation(" - << aTransObjects << ", " << aStart << ", " << aEnd << ", " << aNbCopies; - if (isFullValue) - theDumper << ", " << isFullValue; - theDumper << ")" << std::endl; + // the number of dumped aTransObjects is not changed, no need to dump anything + static std::map aNbDumpedArguments; + std::map::iterator aFound = aNbDumpedArguments.find(aBase); + if (aFound != aNbDumpedArguments.end() && aFound->second == aFirstNotDumped) { + theDumper.postpone(aBase); + return; + } + else + aNbDumpedArguments[aBase] = aFirstNotDumped; + + if (theDumper.isDumped(aBase)) { + // the feature is already dumped, but it was postponed, because of some arguments + // were not dumped yet, thus, it is necessary to update the list of rotated objects + theDumper << "\n### Update " << aBase->getKind() << std::endl; + theDumper << aBase << ".setTranslationList(" << aTransObjects << ")" << std::endl; + } + else { + // the feature is not dumped yet, make the full dump + theDumper << aBase << " = " << aSketchName << ".addTranslation(" + << aTransObjects << ", " << aStart << ", " << aEnd << ", " << aNbCopies; + if (isFullValue) + theDumper << ", " << isFullValue; + theDumper << ")" << std::endl; + } // Dump variables for a list of translated features theDumper << "["; - std::list > aList = translated(); + std::list > aList = translatedList(); std::list >::const_iterator anIt = aList.begin(); - for (; anIt != aList.end(); ++anIt) { - if (anIt != aList.begin()) - theDumper << ", "; - theDumper << (*anIt)->feature(); - } - theDumper << "] = " << theDumper.name(aBase) << ".translated()" << std::endl; - - // Set necessary "auxiliary" flag for translated features - // (flag is set if it differs to base entity) - std::list aTransList = aTransObjects->list(); - std::list::const_iterator aTrIt = aTransList.begin(); - anIt = aList.begin(); - for (; aTrIt != aTransList.end(); ++aTrIt) { - FeaturePtr aFeature = ModelAPI_Feature::feature(*aTrIt); - if (!aFeature) - continue; - bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - - for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) { - aFeature = (*anIt)->feature(); - bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); - if (aFeatAux != aBaseAux) - theDumper << theDumper.name((*anIt)->feature(), false) - << ".setAuxiliary(" << aFeatAux << ")" <value() && anIt != aList.end(); ++i, ++anIt) { + if (anIt != aList.begin()) + theDumper << ", "; + theDumper << (*anIt)->feature(); } + theDumper << "] = " << theDumper.name(aBase) << ".translatedList()" << std::endl; + + if (theDumper.isDumped(aTransObjects)) { + aNbDumpedArguments.erase(aBase); + // Set necessary "auxiliary" flag for translated features + // (flag is set if it differs to base entity) + std::list aTransList = aTransObjects->list(); + std::list::const_iterator aTrIt = aTransList.begin(); + anIt = aList.begin(); + for (; aTrIt != aTransList.end(); ++aTrIt) { + FeaturePtr aFeature = ModelAPI_Feature::feature(*aTrIt); + if (!aFeature) + continue; + bool aBaseAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + + for (int i = 1; i < aNbCopies->value(); ++i, ++anIt) { + aFeature = (*anIt)->feature(); + bool aFeatAux = aFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value(); + if (aFeatAux != aBaseAux) + theDumper << theDumper.name((*anIt)->feature(), false) + << ".setAuxiliary(" << aFeatAux << ")" << std::endl; + } + } + } + else { + // If all refereced objects are not dumped yet, mark the feature as postponed. + theDumper.postpone(aBase); } } diff --git a/src/SketchAPI/SketchAPI_Translation.h b/src/SketchAPI/SketchAPI_Translation.h index 558fa5a50..d0ed7840f 100644 --- a/src/SketchAPI/SketchAPI_Translation.h +++ b/src/SketchAPI/SketchAPI_Translation.h @@ -74,10 +74,19 @@ public: ModelAPI_AttributeRefList, /** Translationed objects */ ) - /// List of translated objects + /// Set list of objects to be translated + SKETCHAPI_EXPORT + void setTranslationList(const std::list >& theObjects); + + /// List of translated objects. + /// [DEPRECATED]: use translatedList() instead. SKETCHAPI_EXPORT std::list > translated() const; + /// List of translated objects. + SKETCHAPI_EXPORT + std::list > translatedList() const; + /// Dump wrapped feature virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 85715599a..b5cbdd3d3 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -233,6 +233,10 @@ ADD_UNIT_TESTS( Test3240.py Test19089.py Test19101.py + Test20274_1.py + Test20274_2.py + Test20274_3.py + TestArcBehavior.py TestBSplineAddPole.py TestChangeSketchPlane1.py @@ -406,3 +410,7 @@ if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) TestMovePoint.py ) endif() + +ADD_RESTRICTED_TESTS( + Test20204.py +) \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index a8eb3d6c4..009e9ab44 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -62,6 +62,11 @@ void SketchPlugin_ConstraintMirror::execute() if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, false); + // Save the current feature of the document, because new features may appear while executing. + // In this case, they will become current. But if the number of copies is updated from outside + // of sketch (e.g. by parameter change), the history line should not hold in sketch. + keepCurrentFeature(); + std::shared_ptr aData = data(); AttributeRefListPtr aRefListOfShapes = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::ENTITY_B())); @@ -198,6 +203,8 @@ void SketchPlugin_ConstraintMirror::execute() } } + restoreCurrentFeature(); + // send events to update the sub-features by the solver if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, true); diff --git a/src/SketchPlugin/SketchPlugin_Offset.cpp b/src/SketchPlugin/SketchPlugin_Offset.cpp index f3f8d2b89..0412143d0 100644 --- a/src/SketchPlugin/SketchPlugin_Offset.cpp +++ b/src/SketchPlugin/SketchPlugin_Offset.cpp @@ -127,6 +127,11 @@ void SketchPlugin_Offset::execute() if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, false); + // Save the current feature of the document, because new features may appear while executing. + // In this case, they will become current. But if the number of copies is updated from outside + // of sketch (e.g. by parameter change), the history line should not hold in sketch. + keepCurrentFeature(); + // 5. Gather wires and make offset for each wire ListOfMakeShape anOffsetAlgos; std::set aProcessedEdgesSet; @@ -187,10 +192,15 @@ void SketchPlugin_Offset::execute() std::shared_ptr anOffsetShape( new GeomAlgoAPI_Offset(aPlane, aWireShape, aValue*aSign)); - std::shared_ptr aMakeList(new GeomAlgoAPI_MakeShapeList); - aMakeList->appendAlgo(aWireBuilder); - aMakeList->appendAlgo(anOffsetShape); - anOffsetAlgos.push_back(aMakeList); + if (anOffsetShape->isDone()) { + std::shared_ptr aMakeList(new GeomAlgoAPI_MakeShapeList); + aMakeList->appendAlgo(aWireBuilder); + aMakeList->appendAlgo(anOffsetShape); + anOffsetAlgos.push_back(aMakeList); + } + else { + setError("Offset algorithm failed"); + } } } @@ -199,6 +209,8 @@ void SketchPlugin_Offset::execute() // created features in CREATED_ID() to remove them on next execute() addToSketch(anOffsetAlgos); + restoreCurrentFeature(); + // send events to update the sub-features by the solver if (isUpdateFlushed) Events_Loop::loop()->setFlushed(anUpdateEvent, true); @@ -626,9 +638,9 @@ void SketchPlugin_Offset::mkBSpline (FeaturePtr& theResult, } else { // non-rational B-spline aWeightsAttr->setSize((int)aWeights.size()); - std::list::iterator anIt = aWeights.begin(); - for (int anIndex = 0; anIt != aWeights.end(); ++anIt, ++anIndex) - aWeightsAttr->setValue(anIndex, *anIt); + std::list::iterator aWIt = aWeights.begin(); + for (int anIndex = 0; aWIt != aWeights.end(); ++aWIt, ++anIndex) + aWeightsAttr->setValue(anIndex, *aWIt); } AttributeDoubleArrayPtr aKnotsAttr = diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index 9133b197d..48d4a7323 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -395,7 +395,7 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE if (aProjectedCurve->isCircle()) { if (aProjectedCurve->isTrimmed()) { // ARC is a projection - isOk = fillArc(theProjection, aProjectedCurve, aSketchPlane); + isOk = fillArc(theProjection, aProjectedCurve, aSketchPlane, theEdge); } else { // CIRCLE is a projection @@ -405,7 +405,7 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE else if (aProjectedCurve->isEllipse()) { if (aProjectedCurve->isTrimmed()) { // ELLIPTIC ARC is a projection - isOk = fillEllipticArc(theProjection, aProjectedCurve, aSketchPlane); + isOk = fillEllipticArc(theProjection, aProjectedCurve, aSketchPlane, theEdge); } else { // ELLIPSE is a projection @@ -420,7 +420,8 @@ bool SketchPlugin_Projection::projectEdge(FeaturePtr& theProjection, const GeomE bool SketchPlugin_Projection::fillArc(FeaturePtr& theProjection, const GeomCurvePtr& theArc, - const GeomPlanePtr& thePlane) + const GeomPlanePtr& thePlane, + const GeomEdgePtr& theOriginalEdge) { rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_Arc::ID()); @@ -432,6 +433,13 @@ bool SketchPlugin_Projection::fillArc(FeaturePtr& theProjection, bool isInversed = aNormalsDot < 0.; + GeomCirclePtr anOriginalCircle = theOriginalEdge->circle(); + if (anOriginalCircle) { + double aCirclesDot = anOriginalCircle->normal()->dot(aCircle.normal()); + if (aCirclesDot < 0.) + isInversed = !isInversed; + } + GeomPointPtr aCenter = thePlane->project(aCircle.center()); GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter); @@ -508,7 +516,8 @@ bool SketchPlugin_Projection::fillEllipse(FeaturePtr& theProjection, bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection, const GeomCurvePtr& theEllipticArc, - const GeomPlanePtr& thePlane) + const GeomPlanePtr& thePlane, + const GeomEdgePtr& theOriginalEdge) { rebuildProjectedFeature(theProjection, ARC_PROJECTION(), SketchPlugin_EllipticArc::ID()); @@ -520,6 +529,13 @@ bool SketchPlugin_Projection::fillEllipticArc(FeaturePtr& theProjection, bool isInversed = aNormalsDot < 0.; + GeomEllipsePtr anOriginalEllipse = theOriginalEdge->ellipse(); + if (anOriginalEllipse) { + double anEllipsesDot = anOriginalEllipse->normal()->dot(anEllipse.normal()); + if (anEllipsesDot < 0.) + isInversed = !isInversed; + } + GeomPointPtr aCenter = thePlane->project(anEllipse.center()); GeomPnt2dPtr aCenterInSketch = sketch()->to2D(aCenter); GeomPointPtr aFocus = thePlane->project(anEllipse.firstFocus()); diff --git a/src/SketchPlugin/SketchPlugin_Projection.h b/src/SketchPlugin/SketchPlugin_Projection.h index aea956bc5..cd39b8c16 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.h +++ b/src/SketchPlugin/SketchPlugin_Projection.h @@ -126,7 +126,8 @@ private: /// \brief Fill attributes of the Arc feature bool fillArc(FeaturePtr& theProjection, const std::shared_ptr& theArc, - const std::shared_ptr& thePlane); + const std::shared_ptr& thePlane, + const std::shared_ptr& theOriginalEdge); /// \brief Fill attributes of the Circle feature bool fillCircle(FeaturePtr& theProjection, const std::shared_ptr& theCircle, @@ -138,7 +139,8 @@ private: /// \brief Fill attributes of the EllipticArc feature bool fillEllipticArc(FeaturePtr& theProjection, const std::shared_ptr& theEllipticArc, - const std::shared_ptr& thePlane); + const std::shared_ptr& thePlane, + const std::shared_ptr& theOriginalEdge); /// \brief Fill attributes of the B-spline feature bool fillBSpline(FeaturePtr& theProjection, const std::shared_ptr& theCurve, diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 984293083..d7efa170f 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -153,6 +153,19 @@ void SketchPlugin_Sketch::execute() std::shared_ptr SketchPlugin_Sketch::addFeature(std::string theID) { + // It is necessary to keep and restore the current feature in the document, + // if the sketch is updated from Python API. Because in that case, the current feature + // may be a non-sketch feature, so it is required to set it back, after adding a sketch feature, + // to keep the sequence of non-sketch features within the document. + FeaturePtr aCurFeature = document()->currentFeature(false); + std::shared_ptr aCurSketchFeature = + std::dynamic_pointer_cast(aCurFeature); + std::shared_ptr aCurSketch = + std::dynamic_pointer_cast(aCurFeature); + if ((aCurSketch && aCurSketch.get() == this) || + (aCurSketchFeature && aCurSketchFeature->sketch() == this)) + aCurFeature = FeaturePtr(); // no need to restore feature if it is from the current sketch + // Set last feature of the sketch as current feature. // Reason: Changing of parameter through Python API may lead to creation of new features // (e.g. changing number of copies in MultiRotation). If the sketch is not the last @@ -177,8 +190,10 @@ std::shared_ptr SketchPlugin_Sketch::addFeature(std::string th aSketchFeature->setSketch(this); data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->append(aNew); } - // set as current also after it becomes sub to set correctly enabled for other sketch subs - document()->setCurrentFeature(aNew, false); + + // set as current also after it becomes sub to set correctly enabled for other sketch subs + // or restore the previous current feature + document()->setCurrentFeature(aCurFeature ? aCurFeature : aNew, false); return aNew; } diff --git a/src/SketchPlugin/Test/Test20274_1.py b/src/SketchPlugin/Test/Test20274_1.py new file mode 100644 index 000000000..e083254cd --- /dev/null +++ b/src/SketchPlugin/Test/Test20274_1.py @@ -0,0 +1,112 @@ +# Copyright (C) 2020 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 GeomAlgoAPI import * +from SketchAPI import * + +from salome.shaper import model + +import math + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_4 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint()) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(0, 0, 100) +SketchCircle_1.setAuxiliary(True) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center()) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result()) +Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result()) +Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result()) + +### Create SketchMultiRotation +SketchMultiRotation_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()] +SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchCircle_1.center(), 360, 4, True) +[SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_14] = SketchMultiRotation_1.rotatedList() +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges") +model.end() + +### Store volumes of sub-shapes as a reference +TOLERANCE = 1.e-7 +REFERENCE = [] +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())) + +### Add new edges to Sketch_1 then check the Extrusion and update reference data +model.begin() +SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result()) +Sketch_1.setLength(SketchLine_6.result(), 10) + +SketchMultiRotation_1.rotationList().append(SketchLine_6.defaultResult()) +model.end() + +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + if (ind < len(REFERENCE)): + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) + else: + REFERENCE.append(area) + +assert(model.checkPythonDump(model.CHECK_NAMING)) + +### Check results after dump +resultExtrusion_1 = Extrusion_1.result() +assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs()) +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) diff --git a/src/SketchPlugin/Test/Test20274_2.py b/src/SketchPlugin/Test/Test20274_2.py new file mode 100644 index 000000000..b67809398 --- /dev/null +++ b/src/SketchPlugin/Test/Test20274_2.py @@ -0,0 +1,112 @@ +# Copyright (C) 2020 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 GeomAlgoAPI import * +from SketchAPI import * + +from salome.shaper import model + +import math + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_4 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint()) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(0, 0, 100) +SketchCircle_1.setAuxiliary(True) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center()) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result()) +Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result()) +Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result()) + +### Create SketchMultiTranslation +SketchMultiTranslation_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()] +SketchMultiTranslation_1 = Sketch_1.addTranslation(SketchMultiTranslation_1_objects, SketchAPI_Line(SketchLine_4).startPoint(), SketchLine_5.endPoint(), 2) +[SketchLine_7, SketchLine_8, SketchLine_9] = SketchMultiTranslation_1.translatedList() +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges") +model.end() + +### Store volumes of sub-shapes as a reference +TOLERANCE = 1.e-7 +REFERENCE = [] +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())) + +### Add new edges to Sketch_1 then check the Extrusion and update reference data +model.begin() +SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result()) +Sketch_1.setLength(SketchLine_6.result(), 10) + +SketchMultiTranslation_1.translationList().append(SketchLine_6.defaultResult()) +model.end() + +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + if (ind < len(REFERENCE)): + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) + else: + REFERENCE.append(area) + +assert(model.checkPythonDump(model.CHECK_NAMING)) + +### Check results after dump +resultExtrusion_1 = Extrusion_1.result() +assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs()) +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) diff --git a/src/SketchPlugin/Test/Test20274_3.py b/src/SketchPlugin/Test/Test20274_3.py new file mode 100644 index 000000000..de30b85cc --- /dev/null +++ b/src/SketchPlugin/Test/Test20274_3.py @@ -0,0 +1,112 @@ +# Copyright (C) 2020 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 GeomAlgoAPI import * +from SketchAPI import * + +from salome.shaper import model + +import math + +model.begin() +partSet = model.moduleDocument() + +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() + +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) + +### Create SketchLine +SketchLine_1 = Sketch_1.addLine(50, 0, 41.0188620508502, 41.01886205085074) + +### Create SketchProjection +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False) +SketchLine_2 = SketchProjection_1.createdFeature() +Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_2.result()) + +### Create SketchLine +SketchLine_3 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 0, 50) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint()) + +### Create SketchProjection +SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False) +SketchLine_4 = SketchProjection_2.createdFeature() +Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result()) + +### Create SketchLine +SketchLine_5 = Sketch_1.addLine(41.0188620508502, 41.01886205085074, 70.71067811865088, 70.71067811866516) +Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_5.startPoint()) + +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(0, 0, 100) +SketchCircle_1.setAuxiliary(True) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_1.center()) +Sketch_1.setCoincident(SketchAPI_Line(SketchLine_2).endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchCircle_1.results()[1]) +Sketch_1.setMiddlePoint(SketchLine_1.startPoint(), SketchLine_2.result()) +Sketch_1.setMiddlePoint(SketchLine_3.endPoint(), SketchLine_4.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_3.result()) +Sketch_1.setEqual(SketchLine_1.result(), SketchLine_5.result()) +Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_5.result()) + +### Create SketchConstraintMirror +SketchConstraintMirror_1_objects = [SketchLine_1.result(), SketchLine_3.result(), SketchLine_5.result()] +SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_2.result(), SketchConstraintMirror_1_objects) +[SketchLine_7, SketchLine_8, SketchLine_9] = SketchConstraintMirror_1.mirrored() +model.do() + +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 100, 0, "Edges") +model.end() + +### Store volumes of sub-shapes as a reference +TOLERANCE = 1.e-7 +REFERENCE = [] +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + REFERENCE.append(GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape())) + +### Add new edges to Sketch_1 then check the Extrusion and update reference data +model.begin() +SketchLine_6 = Sketch_1.addLine(70.71067811865088, 70.71067811866516, 77.78174593052023, 77.78174593052023) +Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_6.result()) +Sketch_1.setLength(SketchLine_6.result(), 10) + +SketchConstraintMirror_1.mirrorList().append(SketchLine_6.defaultResult()) +model.end() + +resultExtrusion_1 = Extrusion_1.result() +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + if (ind < len(REFERENCE)): + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) + else: + REFERENCE.append(area) + +assert(model.checkPythonDump(model.CHECK_NAMING)) + +### Check results after dump +resultExtrusion_1 = Extrusion_1.result() +assert(len(REFERENCE) == resultExtrusion_1.numberOfSubs()) +for ind in range(resultExtrusion_1.numberOfSubs()): + area = GeomAlgoAPI_ShapeTools.volume(resultExtrusion_1.subResult(ind).resultSubShapePair()[0].shape()) + assert(math.fabs(REFERENCE[ind] - area) < TOLERANCE) diff --git a/src/SketchPlugin/Test/TestConstraintCoincidenceEllipse.py b/src/SketchPlugin/Test/TestConstraintCoincidenceEllipse.py index 070770dd6..eb1087289 100644 --- a/src/SketchPlugin/Test/TestConstraintCoincidenceEllipse.py +++ b/src/SketchPlugin/Test/TestConstraintCoincidenceEllipse.py @@ -56,6 +56,7 @@ class TestCoincidenceEllipse(unittest.TestCase): self.myMinorStart = macroEllipse.minorAxisStart() self.myMinorEnd = macroEllipse.minorAxisEnd() self.myExpectFailure = False + self.myNbCoindicences = 1 def tearDown(self): model.end() @@ -79,7 +80,7 @@ class TestCoincidenceEllipse(unittest.TestCase): model.testNbSubFeatures(self.mySketch, "SketchLine", 3) model.testNbSubFeatures(self.mySketch, "SketchEllipse", 1) model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidenceInternal", 11) - model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", 1) + model.testNbSubFeatures(self.mySketch, "SketchConstraintCoincidence", self.myNbCoindicences) def checkDOF(self): @@ -103,7 +104,7 @@ class TestCoincidenceEllipse(unittest.TestCase): self.myDOF -= 1 model.do() if not self.myExpectFailure: - self.assertAlmostEqual(thePoint.y(), 0.0) + self.assertAlmostEqual(thePoint.y(), 0.0, delta = 1.e-6) self.assertGreater(self.myEllipse.majorRadius().value(), 0.0) self.assertGreater(self.myEllipse.minorRadius().value(), 0.0) @@ -112,7 +113,7 @@ class TestCoincidenceEllipse(unittest.TestCase): vecL = [theLineEnd.x() - theLineStart.x(), theLineEnd.y() - theLineStart.y()] dist = math.fabs(vecP[0] * vecL[1] - vecP[1] * vecL[0]) / math.hypot(vecL[0], vecL[1]) - self.assertAlmostEqual(dist, 0.0) + self.assertAlmostEqual(dist, 0.0, delta = 1.e-6) self.assertGreater(self.myEllipse.majorRadius().value(), 0.0) self.assertGreater(self.myEllipse.minorRadius().value(), 0.0) @@ -153,6 +154,12 @@ class TestCoincidenceEllipse(unittest.TestCase): """ Test 6. Make start point on the minor axis of ellipse coincident with the Origin """ self.checkPointFixing(self.myMinorStart.coordinates()) + # workaround: kill the constraint to avoid instability on dump check + model.end() + model.undo() + model.begin() + self.myDOF += 2 + self.myNbCoindicences -= 1 def test_coincident_minor_axis_end(self): """ Test 7. Make end point on the minor axis of ellipse coincident with the Origin. diff --git a/src/SketchPlugin/Test/TestMoveEllipticArc.py b/src/SketchPlugin/Test/TestMoveEllipticArc.py index 4fa550f1d..84e060881 100644 --- a/src/SketchPlugin/Test/TestMoveEllipticArc.py +++ b/src/SketchPlugin/Test/TestMoveEllipticArc.py @@ -61,7 +61,7 @@ class TestMoveEllipticArc(unittest.TestCase): aCoord = [theCoordinates.x(), theCoordinates.y()] else: aCoord = theCoordinates - DIGITS = 7 - math.floor(math.log10(math.hypot(aCoord[0], aCoord[1]))) + DIGITS = 7 - math.ceil(math.log10(math.hypot(aCoord[0], aCoord[1]))) self.assertAlmostEqual(thePoint.x(), aCoord[0], DIGITS) self.assertAlmostEqual(thePoint.y(), aCoord[1], DIGITS) @@ -71,7 +71,12 @@ class TestMoveEllipticArc(unittest.TestCase): distPF1 = model.distancePointPoint(firstFocus2d, point) secondFocus2d = GeomAPI_Pnt2d(theEllipticArc.secondFocus().x(), theEllipticArc.secondFocus().y()) distPF2 = model.distancePointPoint(secondFocus2d, point) - self.assertAlmostEqual(distPF1 + distPF2, 2.0 * theEllipticArc.majorRadius().value(), 7 - math.floor(math.log10(theEllipticArc.majorRadius().value()))) + DIGITS = 7 - math.ceil(math.log10(theEllipticArc.majorRadius().value())) + self.assertAlmostEqual(distPF1 + distPF2, 2.0 * theEllipticArc.majorRadius().value(), DIGITS) + + def checkAlmostEqual(self, theValue1, theValue2): + DIGITS = 7 - math.ceil(math.log10(theValue1)) + self.assertAlmostEqual(theValue1, theValue2, DIGITS) def fixMajorRadius(self): self.mySketch.setDistance(self.myEllipticArc.center(), self.myEllipticArc.majorAxisPositive(), self.myMajorRadius) @@ -120,7 +125,7 @@ class TestMoveEllipticArc(unittest.TestCase): self.mySketch.move(self.myEllipticArc.center(), newPosition[0], newPosition[1]) model.do() self.checkPointCoordinates(self.myEllipticArc.center(), newPosition) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) def test_move_ellipse_fixed_major_radius(self): """ Test 4. Movement of ellipse with fixed major radius @@ -132,7 +137,7 @@ class TestMoveEllipticArc(unittest.TestCase): model.do() self.checkPointOnEllipse(newPosition, self.myEllipticArc) self.assertNotEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) def test_move_center_ellipse_fixed_minor_radius(self): """ Test 5. Movement of central point of ellipse with fixed minor radius @@ -143,7 +148,7 @@ class TestMoveEllipticArc(unittest.TestCase): self.mySketch.move(self.myEllipticArc.center(), newPosition[0], newPosition[1]) model.do() self.checkPointCoordinates(self.myEllipticArc.center(), newPosition) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) def test_move_ellipse_fixed_minor_radius(self): """ Test 6. Movement of ellipse with fixed minor radius @@ -154,7 +159,7 @@ class TestMoveEllipticArc(unittest.TestCase): self.mySketch.move(self.myEllipticArc.defaultResult(), newPosition.x(), newPosition.y()) model.do() self.checkPointOnEllipse(newPosition, self.myEllipticArc) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) self.assertNotEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) def test_move_center_ellipse_fixed_center(self): @@ -166,8 +171,8 @@ class TestMoveEllipticArc(unittest.TestCase): self.mySketch.move(self.myEllipticArc.center(), newPosition[0], newPosition[1]) model.do() self.checkPointCoordinates(self.myEllipticArc.center(), self.myCenter) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) def test_move_ellipse_fixed_center(self): """ Test 8. Movement of ellipse with fixed center @@ -205,8 +210,8 @@ class TestMoveEllipticArc(unittest.TestCase): self.mySketch.move(self.myEllipticArc.firstFocus(), newPosition.x(), newPosition.y()) model.do() self.checkPointCoordinates(self.myEllipticArc.firstFocus(), focus) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) def test_move_ellipse_fixed_focus(self): """ Test 11. Movement of ellipse with fixed focus @@ -237,8 +242,8 @@ class TestMoveEllipticArc(unittest.TestCase): self.checkPointCoordinates(self.myEllipticArc.majorAxisPositive(), self.myAxisPoint) self.checkPointCoordinates(self.myEllipticArc.startPoint(), self.myStartPoint) self.checkPointCoordinates(self.myEllipticArc.endPoint(), self.myEndPoint) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) def test_move_start_point_free_ellipse(self): """ Test 13. Trying to move start point of elliptic arc @@ -271,8 +276,8 @@ class TestMoveEllipticArc(unittest.TestCase): self.checkPointCoordinates(self.myEllipticArc.majorAxisPositive(), self.myAxisPoint) self.checkPointCoordinates(self.myEllipticArc.startPoint(), self.myStartPoint) self.checkPointCoordinates(self.myEllipticArc.endPoint(), self.myEndPoint) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) def test_move_end_point_fixed_ellipse(self): """ Test 16. Trying to move end point of fully fixed ellipse @@ -289,8 +294,8 @@ class TestMoveEllipticArc(unittest.TestCase): self.checkPointCoordinates(self.myEllipticArc.majorAxisPositive(), self.myAxisPoint) self.checkPointCoordinates(self.myEllipticArc.startPoint(), self.myStartPoint) self.checkPointCoordinates(self.myEllipticArc.endPoint(), self.myEndPoint) - self.assertAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) - self.assertAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) + self.checkAlmostEqual(self.myEllipticArc.majorRadius().value(), self.myMajorRadius) + self.checkAlmostEqual(self.myEllipticArc.minorRadius().value(), self.myMinorRadius) if __name__ == "__main__": diff --git a/src/XAO/XAO_BooleanField.cxx b/src/XAO/XAO_BooleanField.cxx index 7e9239ea0..dfae8c33f 100644 --- a/src/XAO/XAO_BooleanField.cxx +++ b/src/XAO/XAO_BooleanField.cxx @@ -24,26 +24,23 @@ using namespace XAO; -BooleanField::BooleanField(const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents, const std::string& name) +BooleanField::BooleanField(XAO::Dimension dimension, + int nbElements, int nbComponents, const std::string& name) : Field(dimension, nbElements, nbComponents, name) { } -Step* BooleanField::addNewStep(const int& step) -throw (XAO_Exception) +Step* BooleanField::addNewStep(int step) { return addStep(step, 0); } -BooleanStep* BooleanField::addStep(const int& step) -throw (XAO_Exception) +BooleanStep* BooleanField::addStep(int step) { return addStep(step, 0); } -BooleanStep* BooleanField::addStep(const int& step, const int& stamp) -throw (XAO_Exception) +BooleanStep* BooleanField::addStep(int step, int stamp) { if (hasStep(step)) throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists."); @@ -53,8 +50,7 @@ throw (XAO_Exception) return bstep; } -BooleanStep* BooleanField::getStep(const int& index) -throw (XAO_Exception) +BooleanStep* BooleanField::getStep(int index) { checkStepIndex(index); return (BooleanStep*)m_steps[index]; diff --git a/src/XAO/XAO_BooleanField.hxx b/src/XAO/XAO_BooleanField.hxx index 083fc73ca..e6f5870c1 100644 --- a/src/XAO/XAO_BooleanField.hxx +++ b/src/XAO/XAO_BooleanField.hxx @@ -49,18 +49,18 @@ namespace XAO * @param nbComponents the number of components. * @param name the name of the field. */ - BooleanField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); + BooleanField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name); - virtual const XAO::Type getType() { return XAO::BOOLEAN; } + virtual XAO::Type getType() { return XAO::BOOLEAN; } - virtual Step* addNewStep(const int& step) throw (XAO_Exception); + virtual Step* addNewStep(int step); /** * Adds a new step. * @param step the number of the step. * @return the newly created step. */ - BooleanStep* addStep(const int& step) throw (XAO_Exception); + BooleanStep* addStep(int step); /** * Adds a new step. @@ -68,15 +68,14 @@ namespace XAO * @param stamp the stamp of the step. * @return the newly created step. */ - BooleanStep* addStep(const int& step, const int& stamp) - throw (XAO_Exception); + BooleanStep* addStep(int step, int stamp); /** * Gets the step of given index. * @param index the index. * @return the step for the given index. */ - BooleanStep* getStep(const int& index) throw (XAO_Exception); + BooleanStep* getStep(int index); }; } diff --git a/src/XAO/XAO_BooleanStep.cxx b/src/XAO/XAO_BooleanStep.cxx index 46b75ae69..571f7e9b8 100644 --- a/src/XAO/XAO_BooleanStep.cxx +++ b/src/XAO/XAO_BooleanStep.cxx @@ -23,7 +23,7 @@ using namespace XAO; -BooleanStep::BooleanStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents) +BooleanStep::BooleanStep(int step, int stamp, int nbElements, int nbComponents) { m_nbElements = nbElements; m_nbComponents = nbComponents; @@ -56,8 +56,7 @@ std::vector BooleanStep::getValues() return result; } -std::vector BooleanStep::getElement(const int& element) -throw (XAO_Exception) +std::vector BooleanStep::getElement(int element) { checkElementIndex(element); @@ -65,8 +64,7 @@ throw (XAO_Exception) return result; } -std::vector BooleanStep::getComponent(const int& component) -throw (XAO_Exception) +std::vector BooleanStep::getComponent(int component) { checkComponentIndex(component); @@ -83,8 +81,7 @@ throw (XAO_Exception) return result; } -const bool BooleanStep::getValue(const int& element, const int& component) -throw (XAO_Exception) +bool BooleanStep::getValue(int element, int component) { checkElementIndex(element); checkComponentIndex(component); @@ -92,14 +89,12 @@ throw (XAO_Exception) return m_values[element][component]; } -const std::string BooleanStep::getStringValue(const int& element, const int& component) -throw (XAO_Exception) +const std::string BooleanStep::getStringValue(int element, int component) { return XaoUtils::booleanToString(getValue(element, component)); } void BooleanStep::setValues(const std::vector& values) -throw (XAO_Exception) { checkNbValues((int)values.size()); @@ -112,28 +107,25 @@ throw (XAO_Exception) } } -void BooleanStep::setElement(const int& element, const std::vector& elements) -throw (XAO_Exception) +void BooleanStep::setElement(int element, const std::vector& elements) { checkElementIndex(element); - checkNbComponents((int)elements.size()); + checkNbComponents(elements.size()); for (int i = 0; i < m_nbComponents; ++i) m_values[element][i] = elements[i]; } -void BooleanStep::setComponent(const int& component, const std::vector& components) -throw (XAO_Exception) +void BooleanStep::setComponent(int component, const std::vector& components) { checkComponentIndex(component); - checkNbElements((int)components.size()); + checkNbElements(components.size()); for (int i = 0; i < m_nbElements; ++i) m_values[i][component] = components[i]; } -void BooleanStep::setValue(const int& element, const int& component, const bool& value) -throw (XAO_Exception) +void BooleanStep::setValue(int element, int component, bool value) { checkElementIndex(element); checkComponentIndex(component); @@ -141,8 +133,7 @@ throw (XAO_Exception) m_values[element][component] = value; } -void BooleanStep::setStringValue(const int& element, const int& component, const std::string& value) -throw (XAO_Exception) +void BooleanStep::setStringValue(int element, int component, const std::string& value) { setValue(element, component, XaoUtils::stringToBoolean(value)); } diff --git a/src/XAO/XAO_BooleanStep.hxx b/src/XAO/XAO_BooleanStep.hxx index bde926ff4..6b0845342 100644 --- a/src/XAO/XAO_BooleanStep.hxx +++ b/src/XAO/XAO_BooleanStep.hxx @@ -49,9 +49,9 @@ namespace XAO * @param nbElements the number elements of the geometry. * @param nbComponents the number of components of the field. */ - BooleanStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents); + BooleanStep(int step, int stamp, int nbElements, int nbComponents); - virtual const XAO::Type getType() { return XAO::BOOLEAN; } + virtual XAO::Type getType() { return XAO::BOOLEAN; } /** * Gets all the values in a vector by elements and by components. @@ -64,14 +64,14 @@ namespace XAO * @param element the index of the element to get. * @return a vector containing all the values for the given element. */ - std::vector getElement(const int& element) throw (XAO_Exception); + std::vector getElement(int element); /** * Gets all the values for a component. * @param component the index of the component to get. * @return a vector containing all the values for the given component. */ - std::vector getComponent(const int& component) throw (XAO_Exception); + std::vector getComponent(int component); /** * Gets a value for an element and a component. @@ -79,27 +79,27 @@ namespace XAO * @param component the index of the component. * @return the value. */ - const bool getValue(const int& element, const int& component) throw (XAO_Exception); + bool getValue(int element, int component); /** * Sets all the values from a list. * @param values the list of values to set. */ - void setValues(const std::vector& values) throw (XAO_Exception); + void setValues(const std::vector& values); /** * Sets the values for an element. * @param element the index of the element to set. * @param elements the values to set. */ - void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(int element, const std::vector& elements); /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(int component, const std::vector& components); /** * Sets the value for an element and a component. @@ -107,10 +107,10 @@ namespace XAO * @param component the index of the component. * @param value the value. */ - void setValue(const int& element, const int& component, const bool& value) throw (XAO_Exception); + void setValue(int element, int component, bool value); - virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception); - virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception); + virtual const std::string getStringValue(int element, int component); + virtual void setStringValue(int element, int component, const std::string& value); private: std::vector< std::vector > m_values; diff --git a/src/XAO/XAO_BrepGeometry.cxx b/src/XAO/XAO_BrepGeometry.cxx index 1dccf451a..e69f66d18 100644 --- a/src/XAO/XAO_BrepGeometry.cxx +++ b/src/XAO/XAO_BrepGeometry.cxx @@ -66,7 +66,6 @@ void BrepGeometry::setShapeString(const std::string& shape) } void BrepGeometry::writeShapeFile(const std::string& fileName) -throw (XAO_Exception) { bool res = BRepTools::Write(m_shape, fileName.c_str()); if (!res) @@ -74,7 +73,6 @@ throw (XAO_Exception) } void BrepGeometry::readShapeFile(const std::string& fileName) -throw (XAO_Exception) { BRep_Builder builder; bool res = BRepTools::Read(m_shape, fileName.c_str(), builder); @@ -136,8 +134,7 @@ void BrepGeometry::initListIds(const TopAbs_ShapeEnum& shapeType, GeometricEleme } } -TopoDS_Shape BrepGeometry::getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex) -throw (XAO_Exception) +TopoDS_Shape BrepGeometry::getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, int shapeIndex) { TopTools_MapOfShape mapShape; TopTools_ListOfShape listShape; @@ -166,7 +163,7 @@ throw (XAO_Exception) } // ----------------------------- -const int BrepGeometry::countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType) +int BrepGeometry::countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType) { int res = 0; TopExp_Explorer exp(shape, shapeType); @@ -176,7 +173,7 @@ const int BrepGeometry::countGeometricalElements(const TopoDS_Shape& shape, cons return res; } -std::vector BrepGeometry::getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim) +std::vector BrepGeometry::getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, XAO::Dimension dim) { std::vector indexList; @@ -208,7 +205,7 @@ std::vector BrepGeometry::getGeometricalElements(const TopoDS_Shape& shape, return indexList; } -void BrepGeometry::getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB) +void BrepGeometry::getEdgeVertices(int edgeIndex, int& vertexA, int& vertexB) { TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex); std::vector vertices = getGeometricalElements(edge, TopAbs_VERTEX, XAO::VERTEX); @@ -218,13 +215,13 @@ void BrepGeometry::getEdgeVertices(const int& edgeIndex, int& vertexA, int& vert vertexB = vertices[1]; } -const int BrepGeometry::countFaceWires(const int& faceIndex) +int BrepGeometry::countFaceWires(int faceIndex) { TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex); return countGeometricalElements(face, TopAbs_WIRE); } -std::vector BrepGeometry::getFaceEdges(const int& faceIndex, const int& wireIndex) +std::vector BrepGeometry::getFaceEdges(int faceIndex, int wireIndex) { // get the face TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex); @@ -233,21 +230,20 @@ std::vector BrepGeometry::getFaceEdges(const int& faceIndex, const int& wir return getGeometricalElements(wire, TopAbs_EDGE, XAO::EDGE); } -const int BrepGeometry::countSolidShells(const int& solidIndex) +int BrepGeometry::countSolidShells(int solidIndex) { TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex); return countGeometricalElements(solid, TopAbs_SHELL); } -std::vector BrepGeometry::getSolidFaces(const int& solidIndex, const int& shellIndex) +std::vector BrepGeometry::getSolidFaces(int solidIndex, int shellIndex) { TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex); TopoDS_Shape shell = getSubShape(solid, TopAbs_SHELL, shellIndex); return getGeometricalElements(shell, TopAbs_FACE, XAO::FACE); } -void BrepGeometry::getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord) -throw (XAO_Exception) +void BrepGeometry::getVertexXYZ(int vertexIndex, double& xCoord, double& yCoord, double& zCoord) { xCoord = 0.; yCoord = 0.; @@ -268,7 +264,7 @@ throw (XAO_Exception) } // ----------------------------- -const double BrepGeometry::getEdgeLength(const int& edgeIndex) +double BrepGeometry::getEdgeLength(int edgeIndex) { TopoDS_Shape edge = getSubShape(m_shape, TopAbs_EDGE, edgeIndex); GProp_GProps system; @@ -276,7 +272,7 @@ const double BrepGeometry::getEdgeLength(const int& edgeIndex) return system.Mass(); } -const double BrepGeometry::getFaceArea(const int& faceIndex) +double BrepGeometry::getFaceArea(int faceIndex) { TopoDS_Shape face = getSubShape(m_shape, TopAbs_FACE, faceIndex); GProp_GProps system; @@ -284,7 +280,7 @@ const double BrepGeometry::getFaceArea(const int& faceIndex) return system.Mass(); } -const double BrepGeometry::getSolidVolume(const int& solidIndex) +double BrepGeometry::getSolidVolume(int solidIndex) { TopoDS_Shape solid = getSubShape(m_shape, TopAbs_SOLID, solidIndex); GProp_GProps system; @@ -293,50 +289,49 @@ const double BrepGeometry::getSolidVolume(const int& solidIndex) } // ----------------------------- -const int BrepGeometry::getVertexID(const int& index) +int BrepGeometry::getVertexID(int index) { return XaoUtils::stringToInt(getVertexReference(index)); } -const int BrepGeometry::getEdgeID(const int& index) +int BrepGeometry::getEdgeID(int index) { return XaoUtils::stringToInt(getEdgeReference(index)); } -const int BrepGeometry::getFaceID(const int& index) +int BrepGeometry::getFaceID(int index) { return XaoUtils::stringToInt(getFaceReference(index)); } -const int BrepGeometry::getSolidID(const int& index) +int BrepGeometry::getSolidID(int index) { return XaoUtils::stringToInt(getSolidReference(index)); } // ----------------------------- -void BrepGeometry::setVertexID(const int& index, const int& id) +void BrepGeometry::setVertexID(int index, int id) { setVertexReference(index, XaoUtils::intToString(id)); } -void BrepGeometry::setEdgeID(const int& index, const int& id) +void BrepGeometry::setEdgeID(int index, int id) { setEdgeReference(index, XaoUtils::intToString(id)); } -void BrepGeometry::setFaceID(const int& index, const int& id) +void BrepGeometry::setFaceID(int index, int id) { setEdgeReference(index, XaoUtils::intToString(id)); } -void BrepGeometry::setSolidID(const int& index, const int& id) +void BrepGeometry::setSolidID(int index, int id) { setEdgeReference(index, XaoUtils::intToString(id)); } // ----------------------------- -const int BrepGeometry::findElement(const XAO::Dimension& dim, const int& id) -throw (XAO_Exception) +int BrepGeometry::findElement(XAO::Dimension dim, int id) { if (dim == XAO::VERTEX) return findVertex(id); @@ -350,68 +345,64 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown Dimension: " << dim); } -const int BrepGeometry::findVertex(const int& id) +int BrepGeometry::findVertex(int id) { return getVertexIndexByReference(XaoUtils::intToString(id)); } -const int BrepGeometry::findEdge(const int& id) +int BrepGeometry::findEdge(int id) { return getEdgeIndexByReference(XaoUtils::intToString(id)); } -const int BrepGeometry::findFace(const int& id) +int BrepGeometry::findFace(int id) { return getFaceIndexByReference(XaoUtils::intToString(id)); } -const int BrepGeometry::findSolid(const int& id) +int BrepGeometry::findSolid(int id) { return getSolidIndexByReference(XaoUtils::intToString(id)); } // ----------------------------- -const std::string BrepGeometry::findVertexName(const int& id) +const std::string BrepGeometry::findVertexName(int id) { return getVertexName(findVertex(id)); } -const std::string BrepGeometry::findEdgeName(const int& id) +const std::string BrepGeometry::findEdgeName(int id) { return getEdgeName(findEdge(id)); } -const std::string BrepGeometry::findFaceName(const int& id) +const std::string BrepGeometry::findFaceName(int id) { return getFaceName(findFace(id)); } -const std::string BrepGeometry::findSolidName(const int& id) +const std::string BrepGeometry::findSolidName(int id) { return getSolidName(findSolid(id)); } // ----------------------------- -void BrepGeometry::changeVertexName(const int& id, const std::string& name) -throw (XAO_Exception) +void BrepGeometry::changeVertexName(int id, const std::string& name) { setVertexName(findVertex(id), name); } -void BrepGeometry::changeEdgeName(const int& id, const std::string& name) -throw (XAO_Exception) +void BrepGeometry::changeEdgeName(int id, const std::string& name) { setEdgeName(findEdge(id), name); } -void BrepGeometry::changeFaceName(const int& id, const std::string& name) -throw (XAO_Exception) +void BrepGeometry::changeFaceName(int id, const std::string& name) { setFaceName(findFace(id), name); } -void BrepGeometry::changeSolidName(const int& id, const std::string& name) -throw (XAO_Exception) +void BrepGeometry::changeSolidName(int id, const std::string& name) { setSolidName(findSolid(id), name); } diff --git a/src/XAO/XAO_BrepGeometry.hxx b/src/XAO/XAO_BrepGeometry.hxx index 5e02757ab..082c8165e 100644 --- a/src/XAO/XAO_BrepGeometry.hxx +++ b/src/XAO/XAO_BrepGeometry.hxx @@ -61,7 +61,7 @@ namespace XAO * Gets the format of the geometry. * @return the format of the geometry. */ - virtual const XAO::Format getFormat() { return XAO::BREP; } + virtual XAO::Format getFormat() { return XAO::BREP; } /** * Gets the shape as a string. @@ -79,13 +79,13 @@ namespace XAO * Writes shape to a file * @param fileName the path to the file */ - virtual void writeShapeFile(const std::string& fileName) throw (XAO_Exception); + virtual void writeShapeFile(const std::string& fileName) ; /** * Reads shape from a file * @param fileName the path to the file */ - virtual void readShapeFile(const std::string& fileName) throw (XAO_Exception); + virtual void readShapeFile(const std::string& fileName) ; #ifdef SWIG %pythoncode %{ @@ -115,14 +115,14 @@ namespace XAO * @param vertexA * @param vertexB */ - void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB); + void getEdgeVertices(int edgeIndex, int& vertexA, int& vertexB); /** * Gets the number of wires of a face (including holes). * @param faceIndex the index of the face. * @return the number of wires. */ - const int countFaceWires(const int& faceIndex); + int countFaceWires(int faceIndex); /** * Gets the indices of the wires of the face. @@ -130,14 +130,14 @@ namespace XAO * @param wireIndex the index of the wire. * @return the list of wires for the given face. */ - std::vector getFaceEdges(const int& faceIndex, const int& wireIndex); + std::vector getFaceEdges(int faceIndex, int wireIndex); /** * Gets the number of shells of a solid (including cavities). * @param solidIndex the index of the solid. * @return the number of shells. */ - const int countSolidShells(const int& solidIndex); + int countSolidShells(int solidIndex); /** * Gets the indices of the shells of the solids. @@ -145,7 +145,7 @@ namespace XAO * @param shellIndex the index of the shell (for the given solid). * @return the list of shells for the given solid. */ - std::vector getSolidFaces(const int& solidIndex, const int& shellIndex); + std::vector getSolidFaces(int solidIndex, int shellIndex); /** * Gets the coordinates of a vertex. @@ -154,179 +154,179 @@ namespace XAO * @param yCoord the Y coordinate. * @param zCoord the Z coordinate. */ - void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord) - throw (XAO_Exception); + void getVertexXYZ(int vertexIndex, double& xCoord, double& yCoord, double& zCoord) + ; /** * Gets the length of an edge. * @param index the index of the edge. * @return the length of the edge. */ - const double getEdgeLength(const int& index); + double getEdgeLength(int index); /** * Gets the are of a face. * @param index the index of a face. * @return the area of the face. */ - const double getFaceArea(const int& index); + double getFaceArea(int index); /** * Gets the volume of a solid. * @param index the index of the solid. * @return the volume of the solid. */ - const double getSolidVolume(const int& index); + double getSolidVolume(int index); /** * Gets the ID of a vertex. * @param index the index of the vertex. * @return the ID of the vertex. */ - const int getVertexID(const int& index); + int getVertexID(int index); /** * Gets the ID of an edge. * @param index the index of the edge. * @return the ID of the edge. */ - const int getEdgeID(const int& index); + int getEdgeID(int index); /** * Gets the ID of a face. * @param index the index of the face. * @return the ID of the face. */ - const int getFaceID(const int& index); + int getFaceID(int index); /** * Gets the ID of a solid. * @param index the index of the solid. * @return the ID of the solid. */ - const int getSolidID(const int& index); + int getSolidID(int index); /** * Sets the ID of a vertex. * @param index the index of the vertex to set. * @param id the id to set. */ - void setVertexID(const int& index, const int& id); + void setVertexID(int index, int id); /** * Sets the ID of an edge. * @param index the index of the edge to set. * @param id the id to set. */ - void setEdgeID(const int& index, const int& id); + void setEdgeID(int index, int id); /** * Sets the ID of a face. * @param index the index of the face to set. * @param id the id to set. */ - void setFaceID(const int& index, const int& id); + void setFaceID(int index, int id); /** * Sets the ID of a solid. * @param index the index of the solid to set. * @param id the id to set. */ - void setSolidID(const int& index, const int& id); + void setSolidID(int index, int id); /** * Finds a vertex with its ID. * @param id the ID of the vertex. * @return the index of the vertex. */ - const int findVertex(const int& id); + int findVertex(int id); /** * Finds an edge with its ID. * @param id the ID of the edge. * @return the index of the edge. */ - const int findEdge(const int& id); + int findEdge(int id); /** * Finds a face with its ID. * @param id the ID of the face. * @return the index of the face. */ - const int findFace(const int& id); + int findFace(int id); /** * Finds a solid with its ID. * @param id the ID of the solid. * @return th index of the solid. */ - const int findSolid(const int& id); + int findSolid(int id); /** * Finds the name of a vertex with its ID. * @param id the ID of the vertex. * @return the name of the vertex. */ - const std::string findVertexName(const int& id); + const std::string findVertexName(int id); /** * Finds the name of an edge with its ID. * @param id the ID of the edge. * @return the name of the edge. */ - const std::string findEdgeName(const int& id); + const std::string findEdgeName(int id); /** * Finds the name of a face with its ID. * @param id the ID of the face. * @return the name of the face. */ - const std::string findFaceName(const int& id); + const std::string findFaceName(int id); /** * Finds the name of a solid with its ID. * @param id the ID of the solid. * @return the name of the solid. */ - const std::string findSolidName(const int& id); + const std::string findSolidName(int id); /** * Changes the name of a vertex. * @param id the ID of the vertex. * @param name the name to set. */ - void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception); + void changeVertexName(int id, const std::string& name) ; /** * Changes the name of an edge. * @param id the ID of the edge * @param name the name to set. */ - void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception); + void changeEdgeName(int id, const std::string& name) ; /** * Changes the name of a face. * @param id the ID of the face. * @param name the name to set. */ - void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception); + void changeFaceName(int id, const std::string& name) ; /** * Changes the name of a solid. * @param id the ID of the solid. * @param name the name to set. */ - void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception); + void changeSolidName(int id, const std::string& name) ; private: void initIds(); void initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList); - TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex) - throw (XAO_Exception); - const int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType); - std::vector getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim); - const int findElement(const XAO::Dimension& dim, const int& id) - throw (XAO_Exception); + TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, int shapeIndex) + ; + int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType); + std::vector getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, XAO::Dimension dim); + int findElement(XAO::Dimension dim, int id) + ; private: TopoDS_Shape m_shape; diff --git a/src/XAO/XAO_DoubleField.cxx b/src/XAO/XAO_DoubleField.cxx index e6544525e..e237d4acf 100644 --- a/src/XAO/XAO_DoubleField.cxx +++ b/src/XAO/XAO_DoubleField.cxx @@ -24,25 +24,25 @@ using namespace XAO; -DoubleField::DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) +DoubleField::DoubleField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name) : Field(dimension, nbElements, nbComponents, name) { } -Step* DoubleField::addNewStep(const int& step) -throw (XAO_Exception) +Step* DoubleField::addNewStep(int step) + { return addStep(step, 0); } -DoubleStep* DoubleField::addStep(const int& step) -throw (XAO_Exception) +DoubleStep* DoubleField::addStep(int step) + { return addStep(step, 0); } -DoubleStep* DoubleField::addStep(const int& step, const int& stamp) -throw (XAO_Exception) +DoubleStep* DoubleField::addStep(int step, int stamp) + { if (hasStep(step)) throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists."); @@ -52,8 +52,8 @@ throw (XAO_Exception) return bstep; } -DoubleStep* DoubleField::getStep(const int& index) -throw (XAO_Exception) +DoubleStep* DoubleField::getStep(int index) + { checkStepIndex(index); return (DoubleStep*)m_steps[index]; diff --git a/src/XAO/XAO_DoubleField.hxx b/src/XAO/XAO_DoubleField.hxx index ee055c534..4ac86366e 100644 --- a/src/XAO/XAO_DoubleField.hxx +++ b/src/XAO/XAO_DoubleField.hxx @@ -49,18 +49,18 @@ namespace XAO * @param nbComponents the number of components. * @param name the name of the field. */ - DoubleField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); + DoubleField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name); - virtual const XAO::Type getType() { return XAO::DOUBLE; } + virtual XAO::Type getType() { return XAO::DOUBLE; } - virtual Step* addNewStep(const int& step) throw (XAO_Exception); + virtual Step* addNewStep(int step) ; /** * Adds a new step. * @param step the number of the step. * @return the newly created step. */ - DoubleStep* addStep(const int& step) throw (XAO_Exception); + DoubleStep* addStep(int step) ; /** * Adds a new step. @@ -68,14 +68,14 @@ namespace XAO * @param stamp the stamp of the step. * @return the newly created step. */ - DoubleStep* addStep(const int& step, const int& stamp) throw (XAO_Exception); + DoubleStep* addStep(int step, int stamp) ; /** * Gets the step of given index. * @param index the index. * @return the step for the given index. */ - DoubleStep* getStep(const int& index) throw (XAO_Exception); + DoubleStep* getStep(int index) ; }; } diff --git a/src/XAO/XAO_DoubleStep.cxx b/src/XAO/XAO_DoubleStep.cxx index 787155320..64f56925f 100644 --- a/src/XAO/XAO_DoubleStep.cxx +++ b/src/XAO/XAO_DoubleStep.cxx @@ -23,7 +23,7 @@ using namespace XAO; -DoubleStep::DoubleStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents) +DoubleStep::DoubleStep(int step, int stamp, int nbElements, int nbComponents) { m_nbElements = nbElements; m_nbComponents = nbComponents; @@ -56,8 +56,8 @@ std::vector DoubleStep::getValues() return result; } -std::vector DoubleStep::getElement(const int& element) -throw (XAO_Exception) +std::vector DoubleStep::getElement(int element) + { checkElementIndex(element); @@ -65,8 +65,8 @@ throw (XAO_Exception) return result; } -std::vector DoubleStep::getComponent(const int& component) -throw (XAO_Exception) +std::vector DoubleStep::getComponent(int component) + { checkComponentIndex(component); @@ -83,8 +83,8 @@ throw (XAO_Exception) return result; } -const double DoubleStep::getValue(const int& element, const int& component) -throw (XAO_Exception) +double DoubleStep::getValue(int element, int component) + { checkElementIndex(element); checkComponentIndex(component); @@ -92,16 +92,16 @@ throw (XAO_Exception) return m_values[element][component]; } -const std::string DoubleStep::getStringValue(const int& element, const int& component) -throw (XAO_Exception) +const std::string DoubleStep::getStringValue(int element, int component) + { return XaoUtils::doubleToString(getValue(element, component)); } void DoubleStep::setValues(const std::vector& values) -throw (XAO_Exception) + { - checkNbValues((int)values.size()); + checkNbValues(values.size()); for (int i = 0; i < m_nbElements; ++i) { @@ -112,28 +112,28 @@ throw (XAO_Exception) } } -void DoubleStep::setElement(const int& element, const std::vector& elements) -throw (XAO_Exception) +void DoubleStep::setElement(int element, const std::vector& elements) + { checkElementIndex(element); - checkNbComponents((int)elements.size()); + checkNbComponents(elements.size()); for (int i = 0; i < m_nbComponents; ++i) m_values[element][i] = elements[i]; } -void DoubleStep::setComponent(const int& component, const std::vector& components) -throw (XAO_Exception) +void DoubleStep::setComponent(int component, const std::vector& components) + { checkElementIndex(component); - checkNbElements((int)components.size()); + checkNbElements(components.size()); for (int i = 0; i < m_nbElements; ++i) m_values[i][component] = components[i]; } -void DoubleStep::setValue(const int& element, const int& component, const double& value) -throw (XAO_Exception) +void DoubleStep::setValue(int element, int component, double value) + { checkElementIndex(element); checkComponentIndex(component); @@ -141,8 +141,8 @@ throw (XAO_Exception) m_values[element][component] = value; } -void DoubleStep::setStringValue(const int& element, const int& component, const std::string& value) -throw (XAO_Exception) +void DoubleStep::setStringValue(int element, int component, const std::string& value) + { setValue(element, component, XaoUtils::stringToDouble(value)); } diff --git a/src/XAO/XAO_DoubleStep.hxx b/src/XAO/XAO_DoubleStep.hxx index 18cb9c073..f14280a8e 100644 --- a/src/XAO/XAO_DoubleStep.hxx +++ b/src/XAO/XAO_DoubleStep.hxx @@ -28,7 +28,6 @@ #include "XAO_Step.hxx" #ifdef WIN32 -#pragma warning(disable:4251) // std::vector needs dll-interface #pragma warning(disable:4290) // Warning Exception ... #endif @@ -49,9 +48,9 @@ namespace XAO * @param nbElements the number elements of the geometry. * @param nbComponents the number of components of the field. */ - DoubleStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents); + DoubleStep(int step, int stamp, int nbElements, int nbComponents); - virtual const XAO::Type getType() { return XAO::DOUBLE; } + virtual XAO::Type getType() { return XAO::DOUBLE; } /** * Gets all the values of the step as a list. @@ -64,14 +63,14 @@ namespace XAO * @param element the index of the element. * @return a vector containing all the values for the given element. */ - std::vector getElement(const int& element) throw (XAO_Exception); + std::vector getElement(int element) ; /** * Gets all the values for a given component. * @param component the index of the component. * @return a vector containing all the values for the given component. */ - std::vector getComponent(const int& component) throw (XAO_Exception); + std::vector getComponent(int component) ; /** * Gets the value for an element and a component. @@ -79,27 +78,27 @@ namespace XAO * @param component the index of the component. * @return the value for the given element and component. */ - const double getValue(const int& element, const int& component) throw (XAO_Exception); + double getValue(int element, int component) ; /** * Sets all the values from a list. * @param values the list of values to set. */ - void setValues(const std::vector& values) throw (XAO_Exception); + void setValues(const std::vector& values) ; /** * Sets the values for an element. * @param element the index of the element to set. * @param elements the values to set. */ - void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(int element, const std::vector& elements) ; /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(int component, const std::vector& components) ; /** * Sets the value for an element and a component. @@ -107,10 +106,10 @@ namespace XAO * @param component the index of the component. * @param value the value. */ - void setValue(const int& element, const int& component, const double& value) throw (XAO_Exception); + void setValue(int element, int component, double value) ; - virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception); - virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception); + virtual const std::string getStringValue(int element, int component) ; + virtual void setStringValue(int element, int component, const std::string& value) ; private: std::vector< std::vector > m_values; diff --git a/src/XAO/XAO_Exception.hxx b/src/XAO/XAO_Exception.hxx index 3c99bb7a5..03a268f63 100644 --- a/src/XAO/XAO_Exception.hxx +++ b/src/XAO/XAO_Exception.hxx @@ -24,10 +24,6 @@ #include "XAO.hxx" #include -#ifdef WIN32 -#pragma warning(disable : 4275) // for std::exception -#endif - namespace XAO { /** @@ -45,13 +41,13 @@ namespace XAO { } - virtual ~XAO_Exception() throw() {}; + virtual ~XAO_Exception() noexcept {}; /** * Returns the error message. * @return the error message. */ - virtual const char* what() const throw () + virtual const char* what() const noexcept { return m_message; } diff --git a/src/XAO/XAO_Field.cxx b/src/XAO/XAO_Field.cxx index cc7087c7b..9213c463f 100644 --- a/src/XAO/XAO_Field.cxx +++ b/src/XAO/XAO_Field.cxx @@ -33,8 +33,8 @@ using namespace XAO; // ------------------------------------------------------- -Field::Field(const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents, const std::string& name) +Field::Field(XAO::Dimension dimension, + int nbElements, int nbComponents, const std::string& name) : m_name(name), m_dimension(dimension), m_nbComponents(nbComponents), m_components(nbComponents, ""), m_nbElements(nbElements) @@ -47,9 +47,8 @@ Field::~Field() delete m_steps[i]; } -Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +Field* Field::createField(XAO::Type type, XAO::Dimension dimension, + int nbElements, int nbComponents, const std::string& name) { if (type == XAO::BOOLEAN) return new BooleanField(dimension, nbElements, nbComponents, name); @@ -63,22 +62,19 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad Type: " << type); } -const std::string Field::getComponentName(const int& index) -throw (XAO_Exception) +const std::string Field::getComponentName(int index) { checkComponent(index); return m_components[index]; } -void Field::setComponentName(const int& index, const std::string& name) -throw (XAO_Exception) +void Field::setComponentName(int index, const std::string& name) { checkComponent(index); m_components[index] = name; } void Field::setComponentsNames(const std::vector& names) -throw (XAO_Exception) { for (unsigned int i = 0; i < names.size(); ++i) { @@ -103,7 +99,7 @@ bool Field::removeStep(Step* step) return false; } -bool Field::hasStep(const int& step) +bool Field::hasStep(int step) { std::vector::iterator it = m_steps.begin(); for (; it != m_steps.end(); ++it) @@ -116,8 +112,7 @@ bool Field::hasStep(const int& step) return false; } -void Field::checkComponent(const int& component) -throw (XAO_Exception) +void Field::checkComponent(int component) { if (component < m_nbComponents && component >= 0) return; @@ -126,8 +121,7 @@ throw (XAO_Exception) << m_nbComponents-1 << "]: " << component); } -void Field::checkStepIndex(const int& step) -throw (XAO_Exception) +void Field::checkStepIndex(int step) { if (step < (int)m_steps.size() && step >= 0) return; diff --git a/src/XAO/XAO_Field.hxx b/src/XAO/XAO_Field.hxx index 22cd0ae09..1b0ded1ff 100644 --- a/src/XAO/XAO_Field.hxx +++ b/src/XAO/XAO_Field.hxx @@ -52,8 +52,8 @@ namespace XAO * @param nbComponents the number of components. * @param name the name of the field. */ - Field(const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents, const std::string& name); + Field(XAO::Dimension dimension, + int nbElements, int nbComponents, const std::string& name); public: /** @@ -65,10 +65,9 @@ namespace XAO * @name the name of the field. * @return the created field. */ - static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension, - const int& nbElements, const int& nbComponents, - const std::string& name = std::string("")) - throw (XAO_Exception); + static Field* createField(XAO::Type type, XAO::Dimension dimension, + int nbElements, int nbComponents, + const std::string& name = std::string("")); /** * Destructor. @@ -79,7 +78,7 @@ namespace XAO * Gets the Type of the field. * @return the Type of the field. */ - virtual const XAO::Type getType() = 0; + virtual XAO::Type getType() = 0; /** * Gets the name of the Field. @@ -103,7 +102,7 @@ namespace XAO * Gets the Dimension of the Field. * @return the Dimension of the Field. */ - const XAO::Dimension getDimension() const + XAO::Dimension getDimension() const { return m_dimension; } @@ -112,7 +111,7 @@ namespace XAO * Gets the number of elements of each step. * @return the number of elements of each step. */ - const int countElements() const + int countElements() const { return m_nbElements; } @@ -121,7 +120,7 @@ namespace XAO * Gets the number of components. * @return the number of components. */ - const int countComponents() const + int countComponents() const { return m_nbComponents; } @@ -130,7 +129,7 @@ namespace XAO * Gets the number of values for each step. * @return the number of values for each step. */ - const int countValues() const + int countValues() const { return m_nbElements * m_nbComponents; } @@ -139,34 +138,34 @@ namespace XAO * Gets the number of the steps. * @return the number of steps. */ - const int countSteps() const { return (int)m_steps.size(); } + int countSteps() const { return m_steps.size(); } /** * Gets the name of a component. * @param index the index of the component to get. * @return the name of the component for the given index. */ - const std::string getComponentName(const int& index) throw (XAO_Exception); + const std::string getComponentName(int index); /** * Sets the name of a component. * @param componentIndex the index of the component to set. * @param name the name to set. */ - void setComponentName(const int& componentIndex, const std::string& name) throw (XAO_Exception); + void setComponentName(int componentIndex, const std::string& name); /** * Sets the name of the components. * @param names the names to set. */ - void setComponentsNames(const std::vector& names) throw (XAO_Exception); + void setComponentsNames(const std::vector& names); /** * Adds a new step of the same type than the field. * @param number the numer of the step. * @return the new create step. */ - virtual Step* addNewStep(const int& number) throw (XAO_Exception) = 0; + virtual Step* addNewStep(int number) = 0; /** * Remove a step. @@ -180,7 +179,7 @@ namespace XAO * @param step the step number. * @return true if the field has a step for the given number. */ - bool hasStep(const int& step); + bool hasStep(int step); /** * Returns the first step. @@ -195,8 +194,8 @@ namespace XAO stepIterator end() { return m_steps.end(); } protected: - void checkComponent(const int& component) throw (XAO_Exception); - void checkStepIndex(const int& step) throw (XAO_Exception); + void checkComponent(int component) ; + void checkStepIndex(int step) ; protected: /** The name of the Field. */ diff --git a/src/XAO/XAO_GeometricElement.cxx b/src/XAO/XAO_GeometricElement.cxx index 82cd85048..566f9b34e 100644 --- a/src/XAO/XAO_GeometricElement.cxx +++ b/src/XAO/XAO_GeometricElement.cxx @@ -40,7 +40,7 @@ GeometricElement::~GeometricElement() { } -const bool GeometricElement::hasName() +bool GeometricElement::hasName() { return !m_name.empty(); } @@ -50,12 +50,12 @@ GeometricElementList::GeometricElementList() setSize(0); } -GeometricElementList::GeometricElementList(const int& count) +GeometricElementList::GeometricElementList(int count) { setSize(count); } -void GeometricElementList::setSize(const int& nb) +void GeometricElementList::setSize(int nb) { m_count = nb; m_elements.clear(); @@ -65,8 +65,7 @@ void GeometricElementList::setSize(const int& nb) } } -void GeometricElementList::checkElementIndex(const int& index) const -throw (XAO_Exception) +void GeometricElementList::checkElementIndex(int index) const { if (m_count >= 0 && index < m_count) return; @@ -75,51 +74,44 @@ throw (XAO_Exception) << m_count-1 << "]: " << index); } -void GeometricElementList::setElement(const int& index, const std::string& name, const std::string& reference) -throw (XAO_Exception) +void GeometricElementList::setElement(int index, const std::string& name, const std::string& reference) { checkElementIndex(index); m_elements[index].setName(name); m_elements[index].setReference(reference); } -const std::string GeometricElementList::getName(const int& index) -throw (XAO_Exception) +const std::string GeometricElementList::getName(int index) { checkElementIndex(index); return m_elements[index].getName(); } -void GeometricElementList::setName(const int& index, const std::string& name) -throw (XAO_Exception) +void GeometricElementList::setName(int index, const std::string& name) { checkElementIndex(index); m_elements[index].setName(name); } -const bool GeometricElementList::hasName(const int& index) -throw (XAO_Exception) +bool GeometricElementList::hasName(int index) { checkElementIndex(index); return m_elements[index].hasName(); } -const std::string GeometricElementList::getReference(const int& index) -throw (XAO_Exception) +const std::string GeometricElementList::getReference(int index) { checkElementIndex(index); return m_elements[index].getReference(); } -void GeometricElementList::setReference(const int& index, const std::string& name) -throw (XAO_Exception) +void GeometricElementList::setReference(int index, const std::string& name) { checkElementIndex(index); m_elements[index].setReference(name); } -const int GeometricElementList::getIndexByReference(const std::string& ref) -throw (XAO_Exception) +int GeometricElementList::getIndexByReference(const std::string& ref) { for (int index = 0; index < m_count; ++index) { diff --git a/src/XAO/XAO_GeometricElement.hxx b/src/XAO/XAO_GeometricElement.hxx index 234f63bf7..c10b8a6e9 100644 --- a/src/XAO/XAO_GeometricElement.hxx +++ b/src/XAO/XAO_GeometricElement.hxx @@ -78,7 +78,7 @@ namespace XAO * Checks if the element has a name. * @return true if the element has a name, false otherwise. */ - const bool hasName(); + bool hasName(); /** * Gets the reference of the element. @@ -120,7 +120,7 @@ namespace XAO * Constructor with size. * \param nb the size to set. */ - GeometricElementList(const int& nb); + GeometricElementList(int nb); /** * Destructor. @@ -131,14 +131,14 @@ namespace XAO * Gets the size of the list. * \return the size of the list. */ - const int getSize() const { return m_count; } + int getSize() const { return m_count; } /** * Sets the size of the list. * \param nb the size to set. * \warning the list will be cleared. */ - void setSize(const int& nb); + void setSize(int nb); /** * Sets the name and the reference of an element. @@ -147,28 +147,28 @@ namespace XAO * \param reference the reference to set. * \throw XAO_Exception if index is bigger than the size of the list. */ - void setElement(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception); + void setElement(int index, const std::string& name, const std::string& reference); /** * Gets the name of an element. * \param index the index of the element to set. * \return the name of the element with the given index. * \throw XAO_Exception if index is bigger than the size of the list. */ - const std::string getName(const int& index) throw (XAO_Exception); + const std::string getName(int index); /** * Sets the name of an element. * \param index the index of the element. * \param name the name to set. * \throw XAO_Exception if index is bigger than the size of the list. */ - void setName(const int& index, const std::string& name) throw (XAO_Exception); + void setName(int index, const std::string& name); /** * Checks if an element has a name. * @param index the index of the element. * @return true if the element has a name, false otherwise. */ - const bool hasName(const int& index) throw (XAO_Exception); + bool hasName(int index); /** * Gets the reference of an element. @@ -176,21 +176,21 @@ namespace XAO * \return the reference of the element. * \throw XAO_Exception if index is bigger than the size of the list. */ - const std::string getReference(const int& index) throw (XAO_Exception); + const std::string getReference(int index); /** * Sets the reference of an element. * \param index the index of the element to set. * \param reference the reference to set. * \throw XAO_Exception if index is bigger than the size of the list. */ - void setReference(const int& index, const std::string& reference) throw (XAO_Exception); + void setReference(int index, const std::string& reference); /** * Gets the index of an element using its reference. * \param reference the searched reference. * \return the index of the element or -1 if no element found. */ - const int getIndexByReference(const std::string& reference) throw (XAO_Exception); + int getIndexByReference(const std::string& reference); /** * Iterator on the element of the list. @@ -210,7 +210,7 @@ namespace XAO iterator end() { return m_elements.end(); } private: - void checkElementIndex(const int& index) const throw (XAO_Exception); + void checkElementIndex(int index) const; private: int m_count; diff --git a/src/XAO/XAO_Geometry.cxx b/src/XAO/XAO_Geometry.cxx index 22031582e..fe72864d5 100644 --- a/src/XAO/XAO_Geometry.cxx +++ b/src/XAO/XAO_Geometry.cxx @@ -30,14 +30,12 @@ Geometry::Geometry(const std::string& name) m_readOnly = false; } -Geometry* Geometry::createGeometry(const XAO::Format& format) -throw (XAO_Exception) +Geometry* Geometry::createGeometry(XAO::Format format) { return createGeometry(format, ""); } -Geometry* Geometry::createGeometry(const XAO::Format& format, const std::string& name) -throw (XAO_Exception) +Geometry* Geometry::createGeometry(XAO::Format format, const std::string& name) { if (format == XAO::BREP) return new BrepGeometry(name); @@ -50,14 +48,12 @@ Geometry::~Geometry() } void Geometry::checkReadOnly() -throw (XAO_Exception) { if (m_readOnly) throw XAO_Exception("Geometry is read only."); } -const int Geometry::countElements(const XAO::Dimension& dim) const -throw (XAO_Exception) +int Geometry::countElements(XAO::Dimension dim) const { if (dim == XAO::VERTEX) return countVertices(); @@ -73,8 +69,7 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); } -const std::string Geometry::getElementReference(const XAO::Dimension& dim, const int& index) -throw (XAO_Exception) +const std::string Geometry::getElementReference(XAO::Dimension dim, int index) { if (dim == XAO::VERTEX) return getVertexReference(index); @@ -88,8 +83,7 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); } -const int Geometry::getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) -throw (XAO_Exception) +int Geometry::getElementIndexByReference(XAO::Dimension dim, const std::string& reference) { if (dim == XAO::VERTEX) return getVertexIndexByReference(reference); @@ -103,8 +97,7 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); } -GeometricElementList::iterator Geometry::begin(const XAO::Dimension& dim) -throw (XAO_Exception) +GeometricElementList::iterator Geometry::begin(XAO::Dimension dim) { if (dim == XAO::VERTEX) return m_vertices.begin(); @@ -118,8 +111,7 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); } -GeometricElementList::iterator Geometry::end(const XAO::Dimension& dim) -throw (XAO_Exception) +GeometricElementList::iterator Geometry::end(XAO::Dimension dim) { if (dim == XAO::VERTEX) return m_vertices.end(); @@ -133,64 +125,64 @@ throw (XAO_Exception) throw XAO_Exception(MsgBuilder() << "Unknown dimension:" << dim); } -void Geometry::setCountVertices(const int& nb) throw (XAO_Exception) +void Geometry::setCountVertices(int nb) { checkReadOnly(); m_vertices.setSize(nb); } -void Geometry::setCountEdges(const int& nb) throw (XAO_Exception) +void Geometry::setCountEdges(int nb) { checkReadOnly(); m_edges.setSize(nb); } -void Geometry::setCountFaces(const int& nb) throw (XAO_Exception) +void Geometry::setCountFaces(int nb) { checkReadOnly(); m_faces.setSize(nb); } -void Geometry::setCountSolids(const int& nb) throw (XAO_Exception) +void Geometry::setCountSolids(int nb) { checkReadOnly(); m_solids.setSize(nb); } -void Geometry::setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception) +void Geometry::setVertexReference(int index, const std::string& reference) { checkReadOnly(); m_vertices.setReference(index, reference); } -void Geometry::setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception) +void Geometry::setEdgeReference(int index, const std::string& reference) { checkReadOnly(); m_edges.setReference(index, reference); } -void Geometry::setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception) +void Geometry::setFaceReference(int index, const std::string& reference) { checkReadOnly(); m_faces.setReference(index, reference); } -void Geometry::setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception) +void Geometry::setSolidReference(int index, const std::string& reference) { checkReadOnly(); m_solids.setReference(index, reference); } -void Geometry::setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception) +void Geometry::setVertex(int index, const std::string& name, const std::string& reference) { checkReadOnly(); m_vertices.setElement(index, name, reference); } -void Geometry::setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception) +void Geometry::setEdge(int index, const std::string& name, const std::string& reference) { checkReadOnly(); m_edges.setElement(index, name, reference); } -void Geometry::setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception) +void Geometry::setFace(int index, const std::string& name, const std::string& reference) { checkReadOnly(); m_faces.setElement(index, name, reference); } -void Geometry::setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception) +void Geometry::setSolid(int index, const std::string& name, const std::string& reference) { checkReadOnly(); m_solids.setElement(index, name, reference); diff --git a/src/XAO/XAO_Geometry.hxx b/src/XAO/XAO_Geometry.hxx index e7a42a482..1216c2862 100644 --- a/src/XAO/XAO_Geometry.hxx +++ b/src/XAO/XAO_Geometry.hxx @@ -55,7 +55,7 @@ namespace XAO * @param format the format of the geometry. * @return the created geometry. */ - static Geometry* createGeometry(const XAO::Format& format) throw (XAO_Exception); + static Geometry* createGeometry(XAO::Format format) ; /** * Constructor. @@ -63,8 +63,7 @@ namespace XAO * @name name the name of the geometry. * @return the created geometry. */ - static Geometry* createGeometry(const XAO::Format& format, const std::string& name) - throw (XAO_Exception); + static Geometry* createGeometry(XAO::Format format, const std::string& name); /** Destructor. */ virtual ~Geometry(); @@ -90,63 +89,63 @@ namespace XAO * Gets the format of the geometry. * @return the format of the geometry. */ - virtual const XAO::Format getFormat() = 0; + virtual XAO::Format getFormat() = 0; virtual const std::string getShapeString() = 0; virtual void setShapeString(const std::string& shape) = 0; virtual void writeShapeFile(const std::string& fileName) = 0; virtual void readShapeFile(const std::string& fileName) = 0; - const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception); - const int countVertices() const { return m_vertices.getSize(); } - const int countEdges() const { return m_edges.getSize(); } - const int countFaces() const { return m_faces.getSize(); } - const int countSolids() const { return m_solids.getSize(); } - - void setCountVertices(const int& nb) throw (XAO_Exception); - void setCountEdges(const int& nb) throw (XAO_Exception); - void setCountFaces(const int& nb) throw (XAO_Exception); - void setCountSolids(const int& nb) throw (XAO_Exception); - - const std::string getVertexName(const int& index) throw (XAO_Exception) { return m_vertices.getName(index); } - const std::string getEdgeName(const int& index) throw (XAO_Exception) { return m_edges.getName(index); } - const std::string getFaceName(const int& index) throw (XAO_Exception) { return m_faces.getName(index); } - const std::string getSolidName(const int& index) throw (XAO_Exception) { return m_solids.getName(index); } - - void setVertexName(const int& index, const std::string& name) throw (XAO_Exception) { m_vertices.setName(index, name); } - void setEdgeName(const int& index, const std::string& name) throw (XAO_Exception) { m_edges.setName(index, name); } - void setFaceName(const int& index, const std::string& name) throw (XAO_Exception) { m_faces.setName(index, name); } - void setSolidName(const int& index, const std::string& name) throw (XAO_Exception) { m_solids.setName(index, name); } - - const bool hasVertexName(const int& index) throw (XAO_Exception) { return m_vertices.hasName(index); } - const bool hasEdgeName(const int& index) throw (XAO_Exception) { return m_edges.hasName(index); } - const bool hasFaceName(const int& index) throw (XAO_Exception) { return m_faces.hasName(index); } - const bool hasSolidName(const int& index) throw (XAO_Exception) { return m_solids.hasName(index); } - - const std::string getVertexReference(const int& index) throw (XAO_Exception) { return m_vertices.getReference(index); } - const std::string getEdgeReference(const int& index) throw (XAO_Exception) { return m_edges.getReference(index); } - const std::string getFaceReference(const int& index) throw (XAO_Exception) { return m_faces.getReference(index); } - const std::string getSolidReference(const int& index) throw (XAO_Exception) { return m_solids.getReference(index); } - const std::string getElementReference(const XAO::Dimension& dim, const int& index) throw (XAO_Exception); - - void setVertexReference(const int& index, const std::string& reference) throw (XAO_Exception); - void setEdgeReference(const int& index, const std::string& reference) throw (XAO_Exception); - void setFaceReference(const int& index, const std::string& reference) throw (XAO_Exception); - void setSolidReference(const int& index, const std::string& reference) throw (XAO_Exception); - - void setVertex(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception); - void setEdge(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception); - void setFace(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception); - void setSolid(const int& index, const std::string& name, const std::string& reference) throw (XAO_Exception); - - const int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); } - const int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); } - const int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); } - const int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); } - const int getElementIndexByReference(const XAO::Dimension& dim, const std::string& reference) throw (XAO_Exception); - - GeometricElementList::iterator begin(const XAO::Dimension& dim) throw (XAO_Exception); - GeometricElementList::iterator end(const XAO::Dimension& dim) throw (XAO_Exception); + int countElements(XAO::Dimension dim) const ; + int countVertices() const { return m_vertices.getSize(); } + int countEdges() const { return m_edges.getSize(); } + int countFaces() const { return m_faces.getSize(); } + int countSolids() const { return m_solids.getSize(); } + + void setCountVertices(int nb); + void setCountEdges(int nb); + void setCountFaces(int nb); + void setCountSolids(int nb); + + const std::string getVertexName(int index) { return m_vertices.getName(index); } + const std::string getEdgeName(int index) { return m_edges.getName(index); } + const std::string getFaceName(int index) { return m_faces.getName(index); } + const std::string getSolidName(int index) { return m_solids.getName(index); } + + void setVertexName(int index, const std::string& name) { m_vertices.setName(index, name); } + void setEdgeName(int index, const std::string& name) { m_edges.setName(index, name); } + void setFaceName(int index, const std::string& name) { m_faces.setName(index, name); } + void setSolidName(int index, const std::string& name) { m_solids.setName(index, name); } + + bool hasVertexName(int index) { return m_vertices.hasName(index); } + bool hasEdgeName(int index) { return m_edges.hasName(index); } + bool hasFaceName(int index) { return m_faces.hasName(index); } + bool hasSolidName(int index) { return m_solids.hasName(index); } + + const std::string getVertexReference(int index) { return m_vertices.getReference(index); } + const std::string getEdgeReference(int index) { return m_edges.getReference(index); } + const std::string getFaceReference(int index) { return m_faces.getReference(index); } + const std::string getSolidReference(int index) { return m_solids.getReference(index); } + const std::string getElementReference(XAO::Dimension dim, int index) ; + + void setVertexReference(int index, const std::string& reference) ; + void setEdgeReference(int index, const std::string& reference) ; + void setFaceReference(int index, const std::string& reference) ; + void setSolidReference(int index, const std::string& reference) ; + + void setVertex(int index, const std::string& name, const std::string& reference) ; + void setEdge(int index, const std::string& name, const std::string& reference) ; + void setFace(int index, const std::string& name, const std::string& reference) ; + void setSolid(int index, const std::string& name, const std::string& reference) ; + + int getVertexIndexByReference(const std::string& reference) { return m_vertices.getIndexByReference(reference); } + int getEdgeIndexByReference(const std::string& reference) { return m_edges.getIndexByReference(reference); } + int getFaceIndexByReference(const std::string& reference) { return m_faces.getIndexByReference(reference); } + int getSolidIndexByReference(const std::string& reference) { return m_solids.getIndexByReference(reference); } + int getElementIndexByReference(XAO::Dimension dim, const std::string& reference) ; + + GeometricElementList::iterator begin(XAO::Dimension dim) ; + GeometricElementList::iterator end(XAO::Dimension dim) ; /** * Verifies if the geometry is read only. @@ -160,7 +159,7 @@ namespace XAO void setReadOnly() { m_readOnly = true; } protected: - void checkReadOnly() throw (XAO_Exception); + void checkReadOnly() ; protected: std::string m_name; diff --git a/src/XAO/XAO_Group.cxx b/src/XAO/XAO_Group.cxx index fe66b47cb..83af8e416 100644 --- a/src/XAO/XAO_Group.cxx +++ b/src/XAO/XAO_Group.cxx @@ -24,8 +24,7 @@ using namespace XAO; -Group::Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name) -throw (XAO_Exception) +Group::Group(XAO::Dimension dim, int nbElements, const std::string& name) { if (dim == XAO::WHOLE) throw XAO_Exception("Dimension WHOLE is not valid for group."); @@ -40,8 +39,7 @@ Group::~Group() { } -void Group::checkIndex(const int& element) -throw (XAO_Exception) +void Group::checkIndex(int element) { if (element < (int)m_elements.size() && element >= 0) return; @@ -50,12 +48,12 @@ throw (XAO_Exception) << m_elements.size()-1 << "]: " << element); } -void Group::add(const int& value) +void Group::add(int value) { m_elements.insert(value); } -void Group::remove(const int& value) +void Group::remove(int value) { m_elements.erase(value); } diff --git a/src/XAO/XAO_Group.hxx b/src/XAO/XAO_Group.hxx index c0279d2d6..61170ef6e 100644 --- a/src/XAO/XAO_Group.hxx +++ b/src/XAO/XAO_Group.hxx @@ -44,8 +44,7 @@ namespace XAO * @param nbElements the number of geometrical elements for the dimension in the geometry. * @param name the name of the group. */ - Group(const XAO::Dimension& dim, const int& nbElements, const std::string& name = std::string("")) - throw (XAO_Exception); + Group(XAO::Dimension dim, int nbElements, const std::string& name = std::string("")); /** * Destructor. @@ -73,7 +72,7 @@ namespace XAO * Gets the dimension of the group. * \return the dimension of the group. */ - const XAO::Dimension getDimension() + XAO::Dimension getDimension() { return m_dimension; } @@ -82,7 +81,7 @@ namespace XAO * Gets the numbers of elements in the geometry of the same type than the group. * \return the number of elements in the associated geometry. */ - const int getNbElements() + int getNbElements() { return m_nbElements; } @@ -91,9 +90,9 @@ namespace XAO * Gets the number of elements in the group. * \return the number of elements. */ - const int count() const + int count() const { - return (int)m_elements.size(); + return m_elements.size(); } /** @@ -102,7 +101,7 @@ namespace XAO * \return the reference of the element. * \note use begin() and end() if you need to iterate. */ - const int get(const int& index) + int get(int index) { checkIndex(index); std::set::iterator it = m_elements.begin(); @@ -114,13 +113,13 @@ namespace XAO * Adds an element to the group. * \param value the index of the element to add. */ - void add(const int& value); + void add(int value); /** * Removes an element from the group. * \param value the index of the element to remove. */ - void remove(const int& value); + void remove(int value); /** * Gets an iterator on the first element in the group. @@ -140,8 +139,7 @@ namespace XAO * @param element * @throw XAO_Exception if element is bigger than the number of elements. */ - void checkIndex(const int& element) - throw (XAO_Exception); + void checkIndex(int element); private: /** The name of the group. */ diff --git a/src/XAO/XAO_IntegerField.cxx b/src/XAO/XAO_IntegerField.cxx index 1e1bcdd65..16736a7d8 100644 --- a/src/XAO/XAO_IntegerField.cxx +++ b/src/XAO/XAO_IntegerField.cxx @@ -24,25 +24,25 @@ using namespace XAO; -IntegerField::IntegerField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) +IntegerField::IntegerField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name) : Field(dimension, nbElements, nbComponents, name) { } -Step* IntegerField::addNewStep(const int& step) -throw (XAO_Exception) +Step* IntegerField::addNewStep(int step) + { return addStep(step, 0); } -IntegerStep* IntegerField::addStep(const int& step) -throw (XAO_Exception) +IntegerStep* IntegerField::addStep(int step) + { return addStep(step, 0); } -IntegerStep* IntegerField::addStep(const int& step, const int& stamp) -throw (XAO_Exception) +IntegerStep* IntegerField::addStep(int step, int stamp) + { if (hasStep(step)) throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists."); @@ -52,8 +52,8 @@ throw (XAO_Exception) return bstep; } -IntegerStep* IntegerField::getStep(const int& index) -throw (XAO_Exception) +IntegerStep* IntegerField::getStep(int index) + { checkStepIndex(index); return (IntegerStep*)m_steps[index]; diff --git a/src/XAO/XAO_IntegerField.hxx b/src/XAO/XAO_IntegerField.hxx index 2d9cac221..a761684de 100644 --- a/src/XAO/XAO_IntegerField.hxx +++ b/src/XAO/XAO_IntegerField.hxx @@ -49,18 +49,18 @@ namespace XAO * @param nbComponents the number of components. * @param name the name of the field. */ - IntegerField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); + IntegerField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name); - virtual const XAO::Type getType() { return XAO::INTEGER; } + virtual XAO::Type getType() { return XAO::INTEGER; } - virtual Step* addNewStep(const int& step) throw (XAO_Exception); + virtual Step* addNewStep(int step) ; /** * Adds a new step. * @param step the number of the step. * @return the newly created step. */ - IntegerStep* addStep(const int& step) throw (XAO_Exception); + IntegerStep* addStep(int step) ; /** * Adds a new step. @@ -68,14 +68,14 @@ namespace XAO * @param stamp the stamp of the step. * @return the newly created step. */ - IntegerStep* addStep(const int& step, const int& stamp) throw (XAO_Exception); + IntegerStep* addStep(int step, int stamp) ; /** * Gets the step of given index. * @param index the index of the step. * @return the step for the given index. */ - IntegerStep* getStep(const int& index) throw (XAO_Exception); + IntegerStep* getStep(int index) ; }; } diff --git a/src/XAO/XAO_IntegerStep.cxx b/src/XAO/XAO_IntegerStep.cxx index 67a377034..afe690d12 100644 --- a/src/XAO/XAO_IntegerStep.cxx +++ b/src/XAO/XAO_IntegerStep.cxx @@ -23,7 +23,7 @@ using namespace XAO; -IntegerStep::IntegerStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents) +IntegerStep::IntegerStep(int step, int stamp, int nbElements, int nbComponents) { m_nbElements = nbElements; m_nbComponents = nbComponents; @@ -56,8 +56,8 @@ std::vector IntegerStep::getValues() return result; } -std::vector IntegerStep::getElement(const int& element) -throw (XAO_Exception) +std::vector IntegerStep::getElement(int element) + { checkElementIndex(element); @@ -65,8 +65,8 @@ throw (XAO_Exception) return result; } -std::vector IntegerStep::getComponent(const int& component) -throw (XAO_Exception) +std::vector IntegerStep::getComponent(int component) + { checkComponentIndex(component); @@ -83,8 +83,8 @@ throw (XAO_Exception) return result; } -const int IntegerStep::getValue(const int& element, const int& component) -throw (XAO_Exception) +int IntegerStep::getValue(int element, int component) + { checkElementIndex(element); checkComponentIndex(component); @@ -92,16 +92,16 @@ throw (XAO_Exception) return m_values[element][component]; } -const std::string IntegerStep::getStringValue(const int& element, const int& component) -throw (XAO_Exception) +const std::string IntegerStep::getStringValue(int element, int component) + { return XaoUtils::intToString(getValue(element, component)); } void IntegerStep::setValues(const std::vector& values) -throw (XAO_Exception) + { - checkNbValues((int)values.size()); + checkNbValues(values.size()); for (int i = 0; i < m_nbElements; ++i) { @@ -112,28 +112,28 @@ throw (XAO_Exception) } } -void IntegerStep::setElement(const int& element, const std::vector& elements) -throw (XAO_Exception) +void IntegerStep::setElement(int element, const std::vector& elements) + { checkElementIndex(element); - checkNbComponents((int)elements.size()); + checkNbComponents(elements.size()); for (int i = 0; i < m_nbComponents; ++i) m_values[element][i] = elements[i]; } -void IntegerStep::setComponent(const int& component, const std::vector& components) -throw (XAO_Exception) +void IntegerStep::setComponent(int component, const std::vector& components) + { checkElementIndex(component); - checkNbElements((int)components.size()); + checkNbElements(components.size()); for (int i = 0; i < m_nbElements; ++i) m_values[i][component] = components[i]; } -void IntegerStep::setValue(const int& element, const int& component, const int& value) -throw (XAO_Exception) +void IntegerStep::setValue(int element, int component, int value) + { checkElementIndex(element); checkComponentIndex(component); @@ -141,8 +141,8 @@ throw (XAO_Exception) m_values[element][component] = value; } -void IntegerStep::setStringValue(const int& element, const int& component, const std::string& value) -throw (XAO_Exception) +void IntegerStep::setStringValue(int element, int component, const std::string& value) + { setValue(element, component, XaoUtils::stringToInt(value)); } diff --git a/src/XAO/XAO_IntegerStep.hxx b/src/XAO/XAO_IntegerStep.hxx index 26b02f283..8757d648a 100644 --- a/src/XAO/XAO_IntegerStep.hxx +++ b/src/XAO/XAO_IntegerStep.hxx @@ -49,9 +49,9 @@ namespace XAO * @param nbElements the number elements of the geometry. * @param nbComponents the number of components of the field. */ - IntegerStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents); + IntegerStep(int step, int stamp, int nbElements, int nbComponents); - virtual const XAO::Type getType() { return XAO::INTEGER; } + virtual XAO::Type getType() { return XAO::INTEGER; } /** * Gets all the values of the step as a list. @@ -64,14 +64,14 @@ namespace XAO * @param element the index of the element. * @return a vector containing all the values for the given element. */ - std::vector getElement(const int& element) throw (XAO_Exception); + std::vector getElement(int element) ; /** * Gets all the values for a given component. * @param component the index of the component. * @return a vector containing all the values for the given component. */ - std::vector getComponent(const int& component) throw (XAO_Exception); + std::vector getComponent(int component) ; /** * Gets the value for an element and a component. @@ -79,27 +79,27 @@ namespace XAO * @param component the index of the component. * @return the value for the given element and component. */ - const int getValue(const int& element, const int& component) throw (XAO_Exception); + int getValue(int element, int component) ; /** * Sets all the values from a list. * @param values the list of values to set. */ - void setValues(const std::vector& values) throw (XAO_Exception); + void setValues(const std::vector& values) ; /** * Sets the values for an element. * @param element the index of the element to set. * @param elements the values to set. */ - void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(int element, const std::vector& elements) ; /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(int component, const std::vector& components) ; /** * Sets the value for an element and a component. @@ -107,10 +107,10 @@ namespace XAO * @param component the index of the component. * @param value the value. */ - void setValue(const int& element, const int& component, const int& value) throw (XAO_Exception); + void setValue(int element, int component, int value) ; - virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception); - virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception); + virtual const std::string getStringValue(int element, int component) ; + virtual void setStringValue(int element, int component, const std::string& value) ; private: std::vector< std::vector > m_values; diff --git a/src/XAO/XAO_Step.cxx b/src/XAO/XAO_Step.cxx index c2353170f..2285c1459 100644 --- a/src/XAO/XAO_Step.cxx +++ b/src/XAO/XAO_Step.cxx @@ -28,8 +28,7 @@ using namespace XAO; -void Step::checkElementIndex(const int& element) -throw (XAO_Exception) +void Step::checkElementIndex(int element) { if (element < m_nbElements && element >= 0) return; @@ -38,8 +37,7 @@ throw (XAO_Exception) << m_nbElements-1 << "]: " << element); } -void Step::checkComponentIndex(const int& component) -throw (XAO_Exception) +void Step::checkComponentIndex(int component) { if (component < m_nbComponents && component >= 0) return; @@ -48,8 +46,7 @@ throw (XAO_Exception) << m_nbComponents-1 << "]: " << component); } -void Step::checkNbElements(const int& nbElements) -throw (XAO_Exception) +void Step::checkNbElements(int nbElements) { if (nbElements == m_nbElements) return; @@ -58,8 +55,7 @@ throw (XAO_Exception) << ", expected " << m_nbElements); } -void Step::checkNbComponents(const int& nbComponents) -throw (XAO_Exception) +void Step::checkNbComponents(int nbComponents) { if (nbComponents == m_nbComponents) return; @@ -68,8 +64,7 @@ throw (XAO_Exception) << ", expected " << m_nbComponents); } -void Step::checkNbValues(const int& nbValues) -throw (XAO_Exception) +void Step::checkNbValues(int nbValues) { if (nbValues == m_nbElements * m_nbComponents) return; diff --git a/src/XAO/XAO_Step.hxx b/src/XAO/XAO_Step.hxx index 071722370..8226171e6 100644 --- a/src/XAO/XAO_Step.hxx +++ b/src/XAO/XAO_Step.hxx @@ -51,49 +51,49 @@ namespace XAO * Gets the type of the step. * @return */ - virtual const XAO::Type getType() = 0; + virtual XAO::Type getType() = 0; /** * Gets the step index. * @return the index of the step. */ - const int getStep() { return m_step; } + int getStep() { return m_step; } /** * Sets the number of the step. * @param step the index to set. */ - void setStep(const int& step) { m_step = step; } + void setStep(int step) { m_step = step; } /** * Gets the stamp of the index. * @return the stamp of the index. */ - const int getStamp() { return m_stamp; } + int getStamp() { return m_stamp; } /** * Sets the stamp of the index. * @param stamp the stamp to set. */ - void setStamp(const int& stamp) { m_stamp = stamp; } + void setStamp(int stamp) { m_stamp = stamp; } /** * Gets the number of components of the step. * @return the number of components. */ - const int countComponents() { return m_nbComponents; } + int countComponents() { return m_nbComponents; } /** * Gets the number of elements for the step. * @return the number of elements. */ - const int countElements() { return m_nbElements; } + int countElements() { return m_nbElements; } /** * Gets the number of values for the step. * @return the number of values. */ - const int countValues() { return m_nbElements * m_nbComponents; } + int countValues() { return m_nbElements * m_nbComponents; } /** * Gets a value as a string. @@ -101,7 +101,7 @@ namespace XAO * @param component the index of the component. * @return the value as a string. */ - virtual const std::string getStringValue(const int& element, const int& component) = 0; + virtual const std::string getStringValue(int element, int component) = 0; /** * Sets a value as a string @@ -110,37 +110,37 @@ namespace XAO * @param value the string value. * @throw XAO_Exception if the value is not valid. */ - virtual void setStringValue(const int& element, const int& component, const std::string& value) = 0; + virtual void setStringValue(int element, int component, const std::string& value) = 0; protected: /** * Checks that given element index is in the range of element indexes. * @param element the index to check. */ - void checkElementIndex(const int& element) throw (XAO_Exception); + void checkElementIndex(int element); /** * Checks that given component index is in the range of component indexes. * @param component the index to check. */ - void checkComponentIndex(const int& component)throw (XAO_Exception); + void checkComponentIndex(int component); /** * Checks that the given number of elements is correct. * @param nbElements the number of elements to check. */ - void checkNbElements(const int& nbElements)throw (XAO_Exception); + void checkNbElements(int nbElements); /** * Checks that the given number of components is correct. * @param nbComponents the number of components to check. */ - void checkNbComponents(const int& nbComponents)throw (XAO_Exception); + void checkNbComponents(int nbComponents); /** * checks that the given number of values is correct. * @param nbValues the number of values to check. */ - void checkNbValues(const int& nbValues)throw (XAO_Exception); + void checkNbValues(int nbValues); protected: /** the index of the step. */ diff --git a/src/XAO/XAO_StringField.cxx b/src/XAO/XAO_StringField.cxx index 81b7a8bea..11a1b49bb 100644 --- a/src/XAO/XAO_StringField.cxx +++ b/src/XAO/XAO_StringField.cxx @@ -24,25 +24,25 @@ using namespace XAO; -StringField::StringField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name) +StringField::StringField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name) : Field(dimension, nbElements, nbComponents, name) { } -Step* StringField::addNewStep(const int& step) -throw (XAO_Exception) +Step* StringField::addNewStep(int step) + { return addStep(step, 0); } -StringStep* StringField::addStep(const int& step) -throw (XAO_Exception) +StringStep* StringField::addStep(int step) + { return addStep(step, 0); } -StringStep* StringField::addStep(const int& step, const int& stamp) -throw (XAO_Exception) +StringStep* StringField::addStep(int step, int stamp) + { if (hasStep(step)) throw XAO_Exception(MsgBuilder() << "Step with number " << step << " already exists."); @@ -52,8 +52,8 @@ throw (XAO_Exception) return bstep; } -StringStep* StringField::getStep(const int& index) -throw (XAO_Exception) +StringStep* StringField::getStep(int index) + { checkStepIndex(index); return (StringStep*)m_steps[index]; diff --git a/src/XAO/XAO_StringField.hxx b/src/XAO/XAO_StringField.hxx index 56c3eebf7..c5b5b9fe9 100644 --- a/src/XAO/XAO_StringField.hxx +++ b/src/XAO/XAO_StringField.hxx @@ -48,18 +48,18 @@ namespace XAO * @param nbComponents the number of components. * @param name the name of the field. */ - StringField(const XAO::Dimension& dimension, const int& nbElements, const int& nbComponents, const std::string& name); + StringField(XAO::Dimension dimension, int nbElements, int nbComponents, const std::string& name); - virtual const XAO::Type getType() { return XAO::STRING; } + virtual XAO::Type getType() { return XAO::STRING; } - virtual Step* addNewStep(const int& step) throw (XAO_Exception); + virtual Step* addNewStep(int step) ; /** * Adds a new step. * @param step the number of the step. * @return the newly created step. */ - StringStep* addStep(const int& step) throw (XAO_Exception); + StringStep* addStep(int step) ; /** * Adds a new step. @@ -67,14 +67,14 @@ namespace XAO * @param stamp the stamp of the step. * @return the newly created step. */ - StringStep* addStep(const int& step, const int& stamp) throw (XAO_Exception); + StringStep* addStep(int step, int stamp) ; /** * Gets the step of given index. * @param index the index of the step. * @return the step for the given index. */ - StringStep* getStep(const int& index) throw (XAO_Exception); + StringStep* getStep(int index) ; }; } diff --git a/src/XAO/XAO_StringStep.cxx b/src/XAO/XAO_StringStep.cxx index e1a5915ce..233200826 100644 --- a/src/XAO/XAO_StringStep.cxx +++ b/src/XAO/XAO_StringStep.cxx @@ -22,7 +22,7 @@ using namespace XAO; -StringStep::StringStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents) +StringStep::StringStep(int step, int stamp, int nbElements, int nbComponents) { m_nbElements = nbElements; m_nbComponents = nbComponents; @@ -55,8 +55,8 @@ std::vector StringStep::getValues() return result; } -std::vector StringStep::getElement(const int& element) -throw (XAO_Exception) +std::vector StringStep::getElement(int element) + { checkElementIndex(element); @@ -64,8 +64,8 @@ throw (XAO_Exception) return result; } -std::vector StringStep::getComponent(const int& component) -throw (XAO_Exception) +std::vector StringStep::getComponent(int component) + { checkComponentIndex(component); @@ -82,8 +82,8 @@ throw (XAO_Exception) return result; } -const std::string StringStep::getValue(const int& element, const int& component) -throw (XAO_Exception) +const std::string StringStep::getValue(int element, int component) + { checkElementIndex(element); checkComponentIndex(component); @@ -91,16 +91,16 @@ throw (XAO_Exception) return m_values[element][component]; } -const std::string StringStep::getStringValue(const int& element, const int& component) -throw (XAO_Exception) +const std::string StringStep::getStringValue(int element, int component) + { return getValue(element, component); } void StringStep::setValues(const std::vector& values) -throw (XAO_Exception) + { - checkNbValues((int)values.size()); + checkNbValues(values.size()); for (int i = 0; i < m_nbElements; ++i) { @@ -111,28 +111,28 @@ throw (XAO_Exception) } } -void StringStep::setElement(const int& element, const std::vector& elements) -throw (XAO_Exception) +void StringStep::setElement(int element, const std::vector& elements) + { checkElementIndex(element); - checkNbComponents((int)elements.size()); + checkNbComponents(elements.size()); for (int i = 0; i < m_nbComponents; ++i) m_values[element][i] = elements[i]; } -void StringStep::setComponent(const int& component, const std::vector& components) -throw (XAO_Exception) +void StringStep::setComponent(int component, const std::vector& components) + { checkElementIndex(component); - checkNbElements((int)components.size()); + checkNbElements(components.size()); for (int i = 0; i < m_nbElements; ++i) m_values[i][component] = components[i]; } -void StringStep::setValue(const int& element, const int& component, const std::string& value) -throw (XAO_Exception) +void StringStep::setValue(int element, int component, const std::string& value) + { checkElementIndex(element); checkComponentIndex(component); @@ -140,8 +140,8 @@ throw (XAO_Exception) m_values[element][component] = value; } -void StringStep::setStringValue(const int& element, const int& component, const std::string& value) -throw (XAO_Exception) +void StringStep::setStringValue(int element, int component, const std::string& value) + { setValue(element, component, value); } diff --git a/src/XAO/XAO_StringStep.hxx b/src/XAO/XAO_StringStep.hxx index 8f73b3a02..e5d10034d 100644 --- a/src/XAO/XAO_StringStep.hxx +++ b/src/XAO/XAO_StringStep.hxx @@ -49,9 +49,9 @@ namespace XAO * @param nbElements the number elements of the geometry. * @param nbComponents the number of components of the field. */ - StringStep(const int& step, const int& stamp, const int& nbElements, const int& nbComponents); + StringStep(int step, int stamp, int nbElements, int nbComponents); - virtual const XAO::Type getType() { return XAO::STRING; } + virtual XAO::Type getType() { return XAO::STRING; } /** * Gets all the values of the step as a list. @@ -64,14 +64,14 @@ namespace XAO * @param element the index of the element. * @return a vector containing all the values for the given element. */ - std::vector getElement(const int& element) throw (XAO_Exception); + std::vector getElement(int element) ; /** * Gets all the values for a given component. * @param component the index of the component. * @return a vector containing all the values for the given component. */ - std::vector getComponent(const int& component) throw (XAO_Exception); + std::vector getComponent(int component) ; /** * Gets the value for an element and a component. @@ -79,27 +79,27 @@ namespace XAO * @param component the index of the component. * @return the value for the given element and component. */ - const std::string getValue(const int& element, const int& component) throw (XAO_Exception); + const std::string getValue(int element, int component) ; /** * Sets all the values from a list. * @param values the list of values to set. */ - void setValues(const std::vector& values) throw (XAO_Exception); + void setValues(const std::vector& values) ; /** * Sets the values for an element. * @param element the index of the element to set. * @param elements the values to set. */ - void setElement(const int& element, const std::vector& elements) throw (XAO_Exception); + void setElement(int element, const std::vector& elements) ; /** * Sets the values for a component. * @param component the index of the component to set. * @param components the values to set. */ - void setComponent(const int& component, const std::vector& components) throw (XAO_Exception); + void setComponent(int component, const std::vector& components) ; /** * Sets the value for an element and a component. @@ -107,10 +107,10 @@ namespace XAO * @param component the index of the component. * @param value the value. */ - void setValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception); + void setValue(int element, int component, const std::string& value) ; - virtual const std::string getStringValue(const int& element, const int& component) throw (XAO_Exception); - virtual void setStringValue(const int& element, const int& component, const std::string& value) throw (XAO_Exception); + virtual const std::string getStringValue(int element, int component) ; + virtual void setStringValue(int element, int component, const std::string& value) ; private: std::vector< std::vector > m_values; diff --git a/src/XAO/XAO_Xao.cxx b/src/XAO/XAO_Xao.cxx index 3fb767f06..6c521f6ca 100644 --- a/src/XAO/XAO_Xao.cxx +++ b/src/XAO/XAO_Xao.cxx @@ -69,13 +69,13 @@ Xao::~Xao() } } -const int Xao::countGroups() const +int Xao::countGroups() const { - return (int)m_groups.size(); + return m_groups.size(); } -Group* Xao::getGroup(const int& index) -throw (XAO_Exception) +Group* Xao::getGroup(int index) + { checkGroupIndex(index); @@ -89,8 +89,8 @@ throw (XAO_Exception) return NULL; } -Group* Xao::addGroup(const XAO::Dimension& dim, const std::string& name) -throw (XAO_Exception) +Group* Xao::addGroup(XAO::Dimension dim, const std::string& name) + { checkGeometry(); checkGroupDimension(dim); @@ -115,19 +115,19 @@ bool Xao::removeGroup(Group* group) return res; } -const int Xao::countFields() const +int Xao::countFields() const { - return (int)m_fields.size(); + return m_fields.size(); } -const XAO::Type Xao::getFieldType(const int& index) -throw (XAO_Exception) +XAO::Type Xao::getFieldType(int index) + { return getField(index)->getType(); } -Field* Xao::getField(const int& index) -throw (XAO_Exception) +Field* Xao::getField(int index) + { checkFieldIndex(index); @@ -141,8 +141,8 @@ throw (XAO_Exception) throw XAO_Exception("Field not found."); } -BooleanField* Xao::getBooleanField(const int& index) -throw (XAO_Exception) +BooleanField* Xao::getBooleanField(int index) + { Field* field = getField(index); if (field->getType() != XAO::BOOLEAN) @@ -150,8 +150,8 @@ throw (XAO_Exception) return (BooleanField*)field; } -DoubleField* Xao::getDoubleField(const int& index) -throw (XAO_Exception) +DoubleField* Xao::getDoubleField(int index) + { Field* field = getField(index); if (field->getType() != XAO::DOUBLE) @@ -159,8 +159,8 @@ throw (XAO_Exception) return (DoubleField*)field; } -IntegerField* Xao::getIntegerField(const int& index) -throw (XAO_Exception) +IntegerField* Xao::getIntegerField(int index) + { Field* field = getField(index); if (field->getType() != XAO::INTEGER) @@ -168,8 +168,8 @@ throw (XAO_Exception) return (IntegerField*)field; } -StringField* Xao::getStringField(const int& index) -throw (XAO_Exception) +StringField* Xao::getStringField(int index) + { Field* field = getField(index); if (field->getType() != XAO::STRING) @@ -177,8 +177,8 @@ throw (XAO_Exception) return (StringField*)field; } -Field* Xao::addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +Field* Xao::addField(XAO::Type type, XAO::Dimension dim, int nbComponents, const std::string& name) + { checkGeometry(); int nbElts = m_geometry->countElements(dim); @@ -187,8 +187,8 @@ throw (XAO_Exception) return field; } -IntegerField* Xao::addIntegerField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +IntegerField* Xao::addIntegerField(XAO::Dimension dim, int nbComponents, const std::string& name) + { checkGeometry(); int nbElts = m_geometry->countElements(dim); @@ -196,8 +196,8 @@ throw (XAO_Exception) m_fields.push_back(field); return field; } -BooleanField* Xao::addBooleanField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +BooleanField* Xao::addBooleanField(XAO::Dimension dim, int nbComponents, const std::string& name) + { checkGeometry(); int nbElts = m_geometry->countElements(dim); @@ -205,8 +205,8 @@ throw (XAO_Exception) m_fields.push_back(field); return field; } -DoubleField* Xao::addDoubleField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +DoubleField* Xao::addDoubleField(XAO::Dimension dim, int nbComponents, const std::string& name) + { checkGeometry(); int nbElts = m_geometry->countElements(dim); @@ -214,8 +214,8 @@ throw (XAO_Exception) m_fields.push_back(field); return field; } -StringField* Xao::addStringField(const XAO::Dimension& dim, const int& nbComponents, const std::string& name) -throw (XAO_Exception) +StringField* Xao::addStringField(XAO::Dimension dim, int nbComponents, const std::string& name) + { checkGeometry(); int nbElts = m_geometry->countElements(dim); @@ -241,7 +241,7 @@ bool Xao::removeField(Field* field) return res; } -const bool Xao::exportXAO(const std::string& fileName, const std::string& shapeFileName) +bool Xao::exportXAO(const std::string& fileName, const std::string& shapeFileName) { return XaoExporter::saveToFile(this, fileName, shapeFileName); } @@ -251,25 +251,23 @@ const std::string Xao::getXML() return XaoExporter::saveToXml(this); } -const bool Xao::importXAO(const std::string& fileName) +bool Xao::importXAO(const std::string& fileName) { return XaoExporter::readFromFile(fileName, this); } -const bool Xao::setXML(const std::string& xml) +bool Xao::setXML(const std::string& xml) { return XaoExporter::setXML(xml, this); } void Xao::checkGeometry() const -throw(XAO_Exception) { if (m_geometry == NULL) throw XAO_Exception("Geometry is null"); } -void Xao::checkGroupIndex(const int& index) const -throw(XAO_Exception) +void Xao::checkGroupIndex(int index) const { if (index >= 0 && index < countGroups()) return; @@ -278,8 +276,7 @@ throw(XAO_Exception) << countGroups()-1 << "]: " << index); } -void Xao::checkFieldIndex(const int& index) const -throw(XAO_Exception) +void Xao::checkFieldIndex(int index) const { if (index >= 0 && index < countFields()) return; @@ -288,8 +285,7 @@ throw(XAO_Exception) << countFields()-1 << "]: " << index); } -void Xao::checkGroupDimension(const XAO::Dimension& dim) const -throw(XAO_Exception) +void Xao::checkGroupDimension(XAO::Dimension dim) const { if (dim == XAO::WHOLE) throw XAO_Exception(MsgBuilder() << "Invalid dimension for group: " << dim); diff --git a/src/XAO/XAO_Xao.hxx b/src/XAO/XAO_Xao.hxx index 5354fc98c..6701510e0 100644 --- a/src/XAO/XAO_Xao.hxx +++ b/src/XAO/XAO_Xao.hxx @@ -115,7 +115,7 @@ namespace XAO * Sets the geometry. * \param geometry the geometry to set. */ - void setGeometry(Geometry* geometry) throw (XAO_Exception) + void setGeometry(Geometry* geometry) { if (m_geometry != NULL) throw XAO_Exception("Geometry already set."); @@ -131,20 +131,20 @@ namespace XAO * Gets the number of groups. * \return the number of groups. */ - const int countGroups() const; + int countGroups() const; /** * Gets a group. * \param index the index of the wanted group. * \return the group. */ - Group* getGroup(const int& index) throw (XAO_Exception); + Group* getGroup(int index) ; /** * Adds a group. * \param dim the dimension of the group. * \param name the name of the group. * \return the created group. */ - Group* addGroup(const XAO::Dimension& dim, const std::string& name = std::string("")) throw (XAO_Exception); + Group* addGroup(XAO::Dimension dim, const std::string& name = std::string("")) ; /** * Removes a group. * \param group the group to remove. @@ -160,26 +160,26 @@ namespace XAO * Gets the number of fields. * \return the number of fields. */ - const int countFields() const; + int countFields() const; /** * Gets the type of a field. * \param index the index of the wanted field. * \return the type of the field. */ - const XAO::Type getFieldType(const int& index) throw (XAO_Exception); + XAO::Type getFieldType(int index) ; /** * Gets a field. * \param index the index of the wanted field. * \return the field. */ - Field* getField(const int& index) throw (XAO_Exception); + Field* getField(int index) ; - BooleanField* getBooleanField(const int& index) throw (XAO_Exception); - DoubleField* getDoubleField(const int& index) throw (XAO_Exception); - IntegerField* getIntegerField(const int& index) throw (XAO_Exception); - StringField* getStringField(const int& index) throw (XAO_Exception); + BooleanField* getBooleanField(int index) ; + DoubleField* getDoubleField(int index) ; + IntegerField* getIntegerField(int index) ; + StringField* getStringField(int index) ; /** * Adds a field. @@ -189,18 +189,18 @@ namespace XAO * \param name the name of the field. * \return the created field. */ - Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents, + Field* addField(XAO::Type type, XAO::Dimension dim, int nbComponents, const std::string& name = std::string("")) - throw (XAO_Exception); + ; - BooleanField* addBooleanField(const XAO::Dimension& dim, const int& nbComponents, - const std::string& name = std::string("")) throw (XAO_Exception); - IntegerField* addIntegerField(const XAO::Dimension& dim, const int& nbComponents, - const std::string& name = std::string("")) throw (XAO_Exception); - DoubleField* addDoubleField(const XAO::Dimension& dim, const int& nbComponents, - const std::string& name = std::string("")) throw (XAO_Exception); - StringField* addStringField(const XAO::Dimension& dim, const int& nbComponents, - const std::string& name = std::string("")) throw (XAO_Exception); + BooleanField* addBooleanField(XAO::Dimension dim, int nbComponents, + const std::string& name = std::string("")) ; + IntegerField* addIntegerField(XAO::Dimension dim, int nbComponents, + const std::string& name = std::string("")) ; + DoubleField* addDoubleField(XAO::Dimension dim, int nbComponents, + const std::string& name = std::string("")) ; + StringField* addStringField(XAO::Dimension dim, int nbComponents, + const std::string& name = std::string("")) ; /** * Removes a field. @@ -218,7 +218,7 @@ namespace XAO * \param shapeFileName if not empty, export the shape to this external file. * \return true is the export is successful. */ - const bool exportXAO(const std::string& fileName, const std::string& shapeFileName); + bool exportXAO(const std::string& fileName, const std::string& shapeFileName); /** * Gets the XML corresponding to this XAO. * \return the XML as a string. @@ -230,19 +230,19 @@ namespace XAO * \param fileName the name of the file to import. * \return true if the import is successful. */ - const bool importXAO(const std::string& fileName); + bool importXAO(const std::string& fileName); /** * Sets an XML describing an XAO format to this object. * \param xml the XML to set. * \return true if the import is successful. */ - const bool setXML(const std::string& xml); + bool setXML(const std::string& xml); private: - void checkGeometry() const throw (XAO_Exception); - void checkGroupIndex(const int& index) const throw (XAO_Exception); - void checkFieldIndex(const int& index) const throw (XAO_Exception); - void checkGroupDimension(const XAO::Dimension& dim) const throw (XAO_Exception); + void checkGeometry() const ; + void checkGroupIndex(int index) const ; + void checkFieldIndex(int index) const ; + void checkGroupDimension(XAO::Dimension dim) const ; private: /** The author of the file. */ diff --git a/src/XAO/XAO_XaoExporter.cxx b/src/XAO/XAO_XaoExporter.cxx index cddabd7c3..7faadbf0b 100644 --- a/src/XAO/XAO_XaoExporter.cxx +++ b/src/XAO/XAO_XaoExporter.cxx @@ -116,14 +116,14 @@ namespace { void parseStepElementNode(xmlNodePtr eltNode, Step* step); std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const std::string& defaultValue, + bool required, const std::string& defaultValue, const std::string& exception = std::string("")); int readIntegerProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const int& defaultValue, + bool required, int defaultValue, const std::string& exception = std::string("")); std::string readStringProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const std::string& defaultValue, + bool required, const std::string& defaultValue, const std::string& exception /*= std::string() */) { xmlChar* strAttr = xmlGetProp(node, attribute); @@ -147,7 +147,7 @@ namespace { } int readIntegerProp(xmlNodePtr node, const xmlChar* attribute, - const bool& required, const int& defaultValue, + bool required, int defaultValue, const std::string& exception /*= std::string() */) { xmlChar* strAttr = xmlGetProp(node, attribute); @@ -222,7 +222,7 @@ namespace { { // export the shape in the XAO file std::string txtShape = xaoGeometry->getShapeString(); - xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), (int)txtShape.size()); + xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size()); xmlAddChild(shape, cdata); } else @@ -638,8 +638,8 @@ namespace { } } -const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) -throw (XAO_Exception) +bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) + { xmlDocPtr doc = exportXMLDoc(xaoObject, shapeFileName); xmlSaveFormatFileEnc(fileName.c_str(), doc, "UTF-8", 1); // format = 1 for node indentation @@ -649,7 +649,7 @@ throw (XAO_Exception) } const std::string XaoExporter::saveToXml(Xao* xaoObject) -throw (XAO_Exception) + { xmlDocPtr doc = exportXMLDoc(xaoObject, ""); @@ -662,8 +662,8 @@ throw (XAO_Exception) return (char*)xmlbuff; } -const bool XaoExporter::readFromFile(const std::string& fileName, Xao* xaoObject) -throw (XAO_Exception) +bool XaoExporter::readFromFile(const std::string& fileName, Xao* xaoObject) + { // parse the file and get the DOM int options = XML_PARSE_HUGE | XML_PARSE_NOCDATA; @@ -677,8 +677,8 @@ throw (XAO_Exception) return true; } -const bool XaoExporter::setXML(const std::string& xml, Xao* xaoObject) -throw (XAO_Exception) +bool XaoExporter::setXML(const std::string& xml, Xao* xaoObject) + { int options = XML_PARSE_HUGE | XML_PARSE_NOCDATA; xmlDocPtr doc = xmlReadDoc(BAD_CAST xml.c_str(), "", NULL, options); diff --git a/src/XAO/XAO_XaoExporter.hxx b/src/XAO/XAO_XaoExporter.hxx index af90b8b1c..5656eb5b5 100644 --- a/src/XAO/XAO_XaoExporter.hxx +++ b/src/XAO/XAO_XaoExporter.hxx @@ -47,8 +47,8 @@ namespace XAO * @param shapeFileName if not empty save the shape in an this external file. * @return true if the export was successful, false otherwise. */ - static const bool saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) - throw (XAO_Exception); + static bool saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName) + ; /** * Saves the XAO object to a XML string. @@ -56,7 +56,7 @@ namespace XAO * @return the XML string. */ static const std::string saveToXml(Xao* xaoObject) - throw (XAO_Exception); + ; /** * Reads a XAO object from a file. @@ -64,8 +64,8 @@ namespace XAO * @param xaoObject the XAO object. * @return true if the XAO object was read successful, false otherwise. */ - static const bool readFromFile(const std::string& fileName, Xao* xaoObject) - throw (XAO_Exception); + static bool readFromFile(const std::string& fileName, Xao* xaoObject) + ; /** * Reads a XAO object from an XML string. @@ -73,8 +73,8 @@ namespace XAO * @param xaoObject the XAO object. * @return true if the XAO object was read successful, false otherwise. */ - static const bool setXML(const std::string& xml, Xao* xaoObject) - throw (XAO_Exception); + static bool setXML(const std::string& xml, Xao* xaoObject) + ; }; } diff --git a/src/XAO/XAO_XaoUtils.cxx b/src/XAO/XAO_XaoUtils.cxx index 144548269..4c64f6634 100644 --- a/src/XAO/XAO_XaoUtils.cxx +++ b/src/XAO/XAO_XaoUtils.cxx @@ -27,15 +27,14 @@ using namespace XAO; -const std::string XaoUtils::intToString(const int& value) +std::string XaoUtils::intToString(int value) { std::ostringstream str; str << value; return str.str(); } -const int XaoUtils::stringToInt(const std::string& value) -throw(XAO_Exception) +int XaoUtils::stringToInt(const std::string& value) { int res; std::istringstream convert(value); @@ -44,15 +43,14 @@ throw(XAO_Exception) return res; } -const std::string XaoUtils::doubleToString(const double& value) +std::string XaoUtils::doubleToString(double value) { std::ostringstream str; str << value; return str.str(); } -const double XaoUtils::stringToDouble(const std::string& value) -throw(XAO_Exception) +double XaoUtils::stringToDouble(const std::string& value) { double res; std::istringstream convert(value); @@ -61,15 +59,12 @@ throw(XAO_Exception) return res; } -const std::string XaoUtils::booleanToString(const bool& value) +std::string XaoUtils::booleanToString(bool value) { - if (value) - return "true"; - return "false"; + return value ? "true" : "false"; } -const bool XaoUtils::stringToBoolean(const std::string& value) -throw(XAO_Exception) +bool XaoUtils::stringToBoolean(const std::string& value) { if (value == "true" || value == "1") return true; @@ -79,8 +74,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Invalid boolean value: " << value); } -const std::string XaoUtils::dimensionToString(const XAO::Dimension& dimension) -throw(XAO_Exception) +std::string XaoUtils::dimensionToString(XAO::Dimension dimension) { if (dimension == XAO::VERTEX) return "vertex"; @@ -96,8 +90,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad dimension: " << dimension); } -const XAO::Dimension XaoUtils::stringToDimension(const std::string& dimension) -throw(XAO_Exception) +XAO::Dimension XaoUtils::stringToDimension(const std::string& dimension) { if (dimension == "vertex") return XAO::VERTEX; @@ -113,8 +106,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad dimension: " << dimension); } -const std::string XaoUtils::fieldTypeToString(const XAO::Type& type) -throw(XAO_Exception) +std::string XaoUtils::fieldTypeToString(XAO::Type type) { if (type ==XAO:: BOOLEAN) return "boolean"; @@ -128,8 +120,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad type: " << type); } -const XAO::Type XaoUtils::stringToFieldType(const std::string& type) -throw(XAO_Exception) +XAO::Type XaoUtils::stringToFieldType(const std::string& type) { if (type == "boolean") return XAO::BOOLEAN; @@ -143,8 +134,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad type: " << type); } -const std::string XaoUtils::shapeFormatToString(const XAO::Format& format) -throw(XAO_Exception) +std::string XaoUtils::shapeFormatToString(XAO::Format format) { if (format == XAO::BREP) return "BREP"; @@ -154,8 +144,7 @@ throw(XAO_Exception) throw XAO_Exception(MsgBuilder() << "Bad format: " << format); } -const XAO::Format XaoUtils::stringToShapeFormat(const std::string& format) -throw(XAO_Exception) +XAO::Format XaoUtils::stringToShapeFormat(const std::string& format) { if (format == "BREP") return XAO::BREP; diff --git a/src/XAO/XAO_XaoUtils.hxx b/src/XAO/XAO_XaoUtils.hxx index 524e056ae..33bc891b4 100644 --- a/src/XAO/XAO_XaoUtils.hxx +++ b/src/XAO/XAO_XaoUtils.hxx @@ -78,7 +78,7 @@ namespace XAO * \param value the integer to convert. * \return the string. */ - static const std::string intToString(const int& value); + static std::string intToString(int value); /** * Converts a string into an integer. @@ -86,28 +86,28 @@ namespace XAO * \return the integer value. * \throw XAO_Exception if value cannot be converted to string. */ - static const int stringToInt(const std::string& value) throw(XAO_Exception); + static int stringToInt(const std::string& value); /** * Converts a double into a string. * \param value the double to convert. * \return the string. */ - static const std::string doubleToString(const double& value); + static std::string doubleToString(double value); /** * Converts a string into a double. * \param value the string to convert. * \return the double value. * \throw XAO_Exception if value cannot be converted to string. */ - static const double stringToDouble(const std::string& value) throw(XAO_Exception); + static double stringToDouble(const std::string& value); /** * Converts a boolean into a string. * \param value the boolean to convert. * \return the string. */ - static const std::string booleanToString(const bool& value); + static std::string booleanToString(bool value); /** * Converts a string into a boolean. * \param value the string to convert. @@ -115,7 +115,7 @@ namespace XAO * \throw XAO_Exception if value cannot be converted to boolean. * \note accepted values are "true", "1", "false", "0". */ - static const bool stringToBoolean(const std::string& value) throw(XAO_Exception); + static bool stringToBoolean(const std::string& value); /** * Converts a Dimension to string. @@ -123,7 +123,7 @@ namespace XAO * \return the dimension as a string. * \throw XAO_Exception */ - static const std::string dimensionToString(const XAO::Dimension& dimension) throw(XAO_Exception); + static std::string dimensionToString(XAO::Dimension dimension); /** * Converts a string into a Dimension. @@ -131,7 +131,7 @@ namespace XAO * \return the converted Dimension. * \throw XAO_Exception if dimension cannot be converted. */ - static const XAO::Dimension stringToDimension(const std::string& dimension) throw(XAO_Exception); + static XAO::Dimension stringToDimension(const std::string& dimension); /** * Converts a Type to string. @@ -139,7 +139,7 @@ namespace XAO * \return the Type as a string. * \throw XAO_Exception */ - static const std::string fieldTypeToString(const XAO::Type& type) throw(XAO_Exception); + static std::string fieldTypeToString(XAO::Type type); /** * Converts a string into a Type. @@ -147,7 +147,7 @@ namespace XAO * \return the converted Type. * \throw XAO_Exception if type cannot be converted. */ - static const XAO::Type stringToFieldType(const std::string& type) throw(XAO_Exception); + static XAO::Type stringToFieldType(const std::string& type); /** * Converts a Format to string. @@ -155,7 +155,7 @@ namespace XAO * \return the Format as a string. * \throw XAO_Exception */ - static const std::string shapeFormatToString(const XAO::Format& format) throw(XAO_Exception); + static std::string shapeFormatToString(XAO::Format format); /** * Converts a string into a Format. @@ -163,7 +163,7 @@ namespace XAO * \return the converted Format. * \throw XAO_Exception if format cannot be converted. */ - static const XAO::Format stringToShapeFormat(const std::string& format) throw(XAO_Exception); + static XAO::Format stringToShapeFormat(const std::string& format); }; /** diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index d5b9bf15a..03fc180a8 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -97,6 +97,7 @@ void XGUI_ContextMenuMgr::createActions() aAction->setShortcut(Qt::Key_F2); addAction("RENAME_CMD", aAction); +#ifdef HAVE_SALOME aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end.png"), XGUI_Workshop::MOVE_TO_END_COMMAND, this); addAction("MOVE_CMD", aAction); @@ -104,6 +105,7 @@ void XGUI_ContextMenuMgr::createActions() aAction = ModuleBase_Tools::createAction(QIcon(":pictures/move_to_end_split.png"), XGUI_Workshop::MOVE_TO_END_SPLIT_COMMAND, this); addAction("MOVE_SPLIT_CMD", aAction); +#endif aAction = ModuleBase_Tools::createAction(QIcon(":pictures/clean_history.png"), tr("Clean history"), aDesktop); @@ -344,10 +346,12 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if (!(hasParameter || hasFeature)) action("SHOW_ONLY_CMD")->setEnabled(true); } +#ifdef HAVE_SALOME else if (hasFeature && myWorkshop->canMoveFeature()) { action("MOVE_CMD")->setEnabled(true); action("MOVE_SPLIT_CMD")->setEnabled(true); } +#endif if( aMgr->activeDocument() == aObject->document() ) { diff --git a/test.hdfs/CMakeLists.txt b/test.hdfs/CMakeLists.txt index 1ec952253..64f59848b 100644 --- a/test.hdfs/CMakeLists.txt +++ b/test.hdfs/CMakeLists.txt @@ -19,57 +19,79 @@ ENABLE_TESTING() -SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository") - -set(hdfFilesRestr "") -if (EXISTS ${RESTRICTED_ROOT_DIR}) - file(GLOB hdfFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf") -endif() +# get all restricted HDF tests +SET(hdfFilesRestr "") +IF (EXISTS $ENV{RESTRICTED_ROOT_DIR}) + FILE(GLOB hdfFilesRestr "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf") +ENDIF() +# get all HDF tests from the current drectory file(GLOB hdfFilesCur "${CMAKE_CURRENT_SOURCE_DIR}/*.hdf") -set(hdfFilesRestr ${hdfFilesCur} ${hdfFilesRestr}) - -if (WIN32) # different separators and path to libraries variable name - SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};$ENV{PATH}") - STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}") - STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}") - STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}") - STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}") -else() - SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:$ENV{LD_LIBRARY_PATH}") - SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}") -endif() -foreach(eachFilePath ${hdfFilesRestr}) +# collect test names +set(TEST_NAMES "") +foreach(eachFilePath IN LISTS hdfFilesCur hdfFilesRestr) # Strip the ".hdf" suffix - GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE) + get_filename_component(aTestName ${eachFilePath} NAME_WE) # Check corresponding ".py" file with reference data exists - IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py") - MESSAGE(WARNING "File ${aTestName}.py containing reference data does not exist") - continue() - ENDIF() + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py") + set(TEST_NAMES ${TEST_NAMES} ${aTestName}) + else() + message(WARNING "File ${aTestName}.py containing reference data for ${aTestName}.hdf does not exist") + endif() +endforeach() + +SET(COMPONENT_NAME SHAPER) +SET(TIMEOUT 600) + +SET(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/HDFs") + +SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env) - # Add "SubprojectName_" prefix - GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME) - SET(aTestName "${aSubprojectName}_${aTestName}") +SET(PUBLIC_TESTS "") +SET(RESTRICTED_TESTS "") +FOREACH(tfile ${TEST_NAMES}) + SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile}) - # Full path to the python test file being executed - SET(aTestFilePath "${eachFilePath}") - IF(EXISTS ${aTestFilePath}) - ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${aTestFilePath}") - if (WIN32) # different path to libraries variable name - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "models_hdf") - else() - SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH};SHAPER_UNIT_TEST_IN_PROGRESS=1" - LABELS "models_hdf") - endif() - # Debug output... - # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}") - ELSE(EXISTS ${aTestFilePath}) - MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}") - ENDIF(EXISTS ${aTestFilePath}) -endforeach(eachFilePath ${ARGN}) + IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf") + SET(HDF_TEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf") + SET(PUBLIC_TESTS ${PUBLIC_TESTS} ${tfile}) + ELSEIF(EXISTS "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf") + SET(HDF_TEST_FILE "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf") + SET(RESTRICTED_TESTS ${RESTRICTED_TESTS} ${tfile}) + ENDIF() + + ADD_TEST(NAME ${TEST_NAME} + COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/testme.py" "${HDF_TEST_FILE}" "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES ENVIRONMENT "${tests_env};SHAPER_UNIT_TEST_IN_PROGRESS=1") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};models_hdf") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES TIMEOUT ${TIMEOUT}) +ENDFOREACH() ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf") + +# salome test +FOREACH(tfile ${TEST_NAMES}) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.py + DESTINATION ${TEST_INSTALL_DIRECTORY}) + IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf") + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${tfile}.hdf + DESTINATION ${TEST_INSTALL_DIRECTORY}) + ENDIF() +ENDFOREACH() + +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${TEST_INSTALL_DIRECTORY} + RENAME CTestTestfile.cmake) + +INSTALL(FILES testme.py DESTINATION ${TEST_INSTALL_DIRECTORY} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) +FILE(COPY test_hdf.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +INSTALL(FILES test_hdf.py DESTINATION ${TEST_INSTALL_DIRECTORY} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) +CONFIGURE_FILE(tests.set.in ${CMAKE_CURRENT_BINARY_DIR}/tests.set @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) diff --git a/test.hdfs/CTestTestfileInstall.cmake b/test.hdfs/CTestTestfileInstall.cmake new file mode 100644 index 000000000..d6a3dbbb9 --- /dev/null +++ b/test.hdfs/CTestTestfileInstall.cmake @@ -0,0 +1,36 @@ +# Copyright (C) 2016-2020 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(tests.set) + +SET(COMPONENT_NAME SHAPER) +SET(SALOME_TEST_DRIVER "testme.py") +SET(TIMEOUT 600) + +FOREACH(tfile ${PUBLIC_TESTS}) + SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile}) + ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} "${TIMEOUT}" "${tfile}.hdf" "${tfile}.py") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() + +FOREACH(tfile ${RESTRICTED_TESTS}) + SET(TEST_NAME ${COMPONENT_NAME}_HDF_${tfile}) + ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} "${TIMEOUT}" "$ENV{RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/${tfile}.hdf" "${tfile}.py") + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") +ENDFOREACH() diff --git a/test.hdfs/Test20456.hdf b/test.hdfs/Test20456.hdf new file mode 100644 index 000000000..dd6b2f864 Binary files /dev/null and b/test.hdfs/Test20456.hdf differ diff --git a/test.hdfs/Test20456.py b/test.hdfs/Test20456.py new file mode 100644 index 000000000..f9295e154 --- /dev/null +++ b/test.hdfs/Test20456.py @@ -0,0 +1,30 @@ +# Copyright (C) 2020 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 +# + +if __name__ == "__main__": + aPartFeature = locals()["Part_1"] + model.testNbResults(aPartFeature, 1) + model.testNbSubResults(aPartFeature, [0]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [2]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [22]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [88]) + model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [176]) + model.testResultsVolumes(aPartFeature, [55179.3113664]) + + assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING)) diff --git a/test.hdfs/__main__.py b/test.hdfs/__main__.py new file mode 100644 index 000000000..02a198310 --- /dev/null +++ b/test.hdfs/__main__.py @@ -0,0 +1,24 @@ +# Copyright (C) 2016-2020 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 +# + +# ============================================================ # +# # +# Attention: Keep this file for correct execution on Windows # +# # +# ============================================================ # diff --git a/test.hdfs/test.py b/test.hdfs/test.py deleted file mode 100644 index dc671d1e6..000000000 --- a/test.hdfs/test.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python -if __name__ == '__main__': - - import subprocess - from time import sleep - import sys, os - - salomeKernelDir = sys.argv[1] - sourceDir = sys.argv[2] - testfile = sys.argv[3] - - portlogfile = os.getcwd() + "/.salome_port" - testlogfile = os.getcwd() + "/test.log" - # remove port file if any - try: - os.remove(portlogfile) - except: - pass - - isOk = True - error = "" - - proc = subprocess.Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - try: - proc.communicate(timeout = 600) - except TimeoutExpired: - isOk = False - proc.kill() - out, err = proc.communicate() - error = "Killed by CPU limit." - print(err) - - with open(testlogfile, 'r') as inputFile: - s = inputFile.read() - print(s) - isOk = isOk and s.find("FAIL") < 0 - try: - os.remove(testlogfile) - except: - pass - - assert isOk, "Test failed. {}".format(error) diff --git a/test.hdfs/test_hdf.py b/test.hdfs/test_hdf.py index b58ea3b83..526fad991 100644 --- a/test.hdfs/test_hdf.py +++ b/test.hdfs/test_hdf.py @@ -34,10 +34,6 @@ class TestHDF(unittest.TestCase): def setUp(self): salome.salome_close() - # leave file name only (trim path and extension) - fileName = os.path.basename(self.testfile) - self.reffile = self.reffile + "/" + os.path.splitext(fileName)[0] + ".py" - salome.salome_init(self.testfile, embedded=1) myStudyName = salome.myStudy._get_Name() self.session = salome.naming_service.Resolve('/Kernel/Session') @@ -77,13 +73,11 @@ if __name__ == "__main__": if len(sys.argv) > 1: TestHDF.testfile = sys.argv[1] if len(sys.argv) > 2: - salomePortFile = sys.argv[2] + TestHDF.reffile = sys.argv[2] if len(sys.argv) > 3: - errFile = open(sys.argv[3], 'w') + salomePortFile = sys.argv[3] if len(sys.argv) > 4: - salomeKernelDir = sys.argv[4] - if len(sys.argv) > 5: - TestHDF.reffile = sys.argv[5] + errFile = open(sys.argv[4], 'w') aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF) unittest.TextTestRunner(stream=errFile).run(aTest) @@ -91,7 +85,7 @@ if __name__ == "__main__": # close Salome GUI port = salome_utils.getPortNumber() - proc = subprocess.Popen([salomeKernelDir + "/bin/salome/killSalomeWithPort.py", "{}".format(port)]) + proc = subprocess.Popen(["killSalomeWithPort.py", "{}".format(port)]) try: os.remove(salomePortFile) diff --git a/test.hdfs/testme.py b/test.hdfs/testme.py new file mode 100644 index 000000000..96c1580c2 --- /dev/null +++ b/test.hdfs/testme.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2020 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 +# + +if __name__ == '__main__': + + import subprocess + from time import sleep + import sys, os + import tempfile + + testTimeout = 600 + if len(sys.argv) > 3: + testTimeout = int(sys.argv[1]) + hdffile = sys.argv[2] + testdatafile = sys.argv[3] + else: + hdffile = sys.argv[1] + testdatafile = sys.argv[2] + + tempdir = tempfile.gettempdir() + portlogfile = tempdir + "/.salome_port" + testlogfile = tempdir + "/test.log" + # remove port file if any + try: + os.remove(portlogfile) + except: + pass + + isOk = True + error = "" + + proc = subprocess.Popen(["runSalome.py", "--modules", "SHAPER,GEOM,SHAPERSTUDY", "--gui", "--splash", "0", "--ns-port-log=" + portlogfile, "test_hdf.py", "args:" + hdffile + "," + testdatafile + "," + portlogfile + "," + testlogfile], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + try: + proc.communicate(timeout = testTimeout) + except TimeoutExpired: + isOk = False + proc.kill() + out, err = proc.communicate() + error = "Killed by CPU limit." + print(err) + + with open(testlogfile, 'r') as inputFile: + s = inputFile.read() + print(s) + isOk = isOk and s.find("FAIL") < 0 + try: + os.remove(testlogfile) + except: + pass + + assert isOk, "Test failed. {}".format(error) diff --git a/test.hdfs/tests.set.in b/test.hdfs/tests.set.in new file mode 100644 index 000000000..9acd7b2bd --- /dev/null +++ b/test.hdfs/tests.set.in @@ -0,0 +1,26 @@ +# Copyright (C) 2020 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 +# + +SET(PUBLIC_TESTS @PUBLIC_TESTS@) + +IF(EXISTS $ENV{RESTRICTED_ROOT_DIR}) + SET(RESTRICTED_TESTS @RESTRICTED_TESTS@) +ELSE() + SET(RESTRICTED_TESTS "") +ENDIF() diff --git a/test.models/bobine_film_reel.py b/test.models/bobine_film_reel.py index b0caf33c9..766cca10f 100644 --- a/test.models/bobine_film_reel.py +++ b/test.models/bobine_film_reel.py @@ -111,7 +111,7 @@ SketchConstraintDistance_2 = Sketch_8.setDistance(SketchLine_9.startPoint(), Ske SketchConstraintDistance_3 = Sketch_8.setDistance(SketchLine_8.endPoint(), SketchLine_9.startPoint(), 30) SketchMultiRotation_2_objects = [SketchLine_11.result(), SketchLine_10.result(), SketchLine_8.result(), SketchLine_7.result()] SketchMultiRotation_2 = Sketch_8.addRotation(SketchMultiRotation_2_objects, SketchLine_9.startPoint(), 120, 3) -[SketchLine_11, SketchLine_12, SketchLine_13, SketchLine_10, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19] = SketchMultiRotation_2.rotated() +[SketchLine_12, SketchLine_13, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19] = SketchMultiRotation_2.rotatedList() SketchLine_18.setName("SketchLine_15") SketchLine_18.result().setName("SketchLine_15") SketchLine_17.setName("SketchLine_18") diff --git a/test.models/ecran.py b/test.models/ecran.py index db1d6ba67..e97f7d7ec 100644 --- a/test.models/ecran.py +++ b/test.models/ecran.py @@ -721,7 +721,7 @@ SketchConstraintCoincidence_112.setName("SketchConstraintCoincidence_119") SketchConstraintDistance_16 = Sketch_6.setDistance(SketchPoint_9.coordinates(), SketchLine_81.result(), "10+5.3+5.7") SketchMultiTranslation_3_objects = [SketchArc_13.results()[1], SketchArc_34.results()[1], SketchArc_14.results()[1], SketchArc_33.results()[1], SketchArc_12.results()[1], SketchArc_11.results()[1], SketchArc_30.results()[1], SketchArc_29.results()[1], SketchArc_15.results()[1], SketchArc_16.results()[1], SketchArc_26.results()[1], SketchArc_25.results()[1], SketchArc_17.results()[1], SketchArc_18.results()[1], SketchArc_24.results()[1], SketchArc_23.results()[1], SketchArc_20.results()[1], SketchArc_22.results()[1], SketchArc_28.results()[1], SketchArc_27.results()[1], SketchArc_19.results()[1], SketchArc_21.results()[1], SketchArc_32.results()[1], SketchArc_31.results()[1], SketchLine_82.result(), SketchLine_77.result(), SketchLine_97.result(), SketchLine_94.result(), SketchLine_101.result(), SketchLine_99.result(), SketchLine_83.result(), SketchLine_88.result(), SketchLine_89.result(), SketchLine_86.result(), SketchLine_85.result(), SketchLine_100.result(), SketchLine_79.result(), SketchLine_92.result(), SketchLine_87.result(), SketchLine_91.result(), SketchLine_84.result(), SketchLine_96.result(), SketchLine_95.result(), SketchLine_93.result(), SketchLine_78.result(), SketchLine_98.result(), SketchLine_76.result(), SketchLine_90.result()] SketchMultiTranslation_3 = Sketch_6.addTranslation(SketchMultiTranslation_3_objects, SketchPoint_6.coordinates(), SketchPoint_9.coordinates(), 2) -[SketchArc_35, SketchArc_34, SketchArc_36, SketchArc_37, SketchArc_33, SketchArc_38, SketchArc_39, SketchArc_40, SketchArc_30, SketchArc_41, SketchArc_29, SketchArc_42, SketchArc_15, SketchArc_43, SketchArc_16, SketchArc_44, SketchArc_26, SketchArc_45, SketchArc_25, SketchArc_46, SketchArc_17, SketchArc_47, SketchArc_18, SketchArc_48, SketchArc_24, SketchArc_49, SketchArc_23, SketchArc_50, SketchArc_20, SketchArc_51, SketchArc_22, SketchArc_52, SketchArc_28, SketchArc_53, SketchArc_27, SketchArc_54, SketchArc_19, SketchArc_55, SketchArc_21, SketchArc_56, SketchArc_32, SketchArc_57, SketchArc_31, SketchArc_58, SketchLine_82, SketchLine_102, SketchLine_103, SketchLine_97, SketchLine_104, SketchLine_94, SketchLine_105, SketchLine_101, SketchLine_106, SketchLine_99, SketchLine_107, SketchLine_83, SketchLine_108, SketchLine_88, SketchLine_109, SketchLine_89, SketchLine_110, SketchLine_86, SketchLine_111, SketchLine_85, SketchLine_112, SketchLine_100, SketchLine_113, SketchLine_114, SketchLine_92, SketchLine_115, SketchLine_87, SketchLine_116, SketchLine_91, SketchLine_117, SketchLine_84, SketchLine_118, SketchLine_96, SketchLine_119, SketchLine_95, SketchLine_120, SketchLine_93, SketchLine_121, SketchLine_122, SketchLine_98, SketchLine_123, SketchLine_124, SketchLine_90, SketchLine_125] = SketchMultiTranslation_3.translated() +[SketchArc_35, SketchArc_36, SketchArc_37, SketchArc_38, SketchArc_39, SketchArc_40, SketchArc_41, SketchArc_42, SketchArc_43, SketchArc_44, SketchArc_45, SketchArc_46, SketchArc_47, SketchArc_48, SketchArc_49, SketchArc_50, SketchArc_51, SketchArc_52, SketchArc_53, SketchArc_54, SketchArc_55, SketchArc_56, SketchArc_57, SketchArc_58, SketchLine_102, SketchLine_103, SketchLine_104, SketchLine_105, SketchLine_106, SketchLine_107, SketchLine_108, SketchLine_109, SketchLine_110, SketchLine_111, SketchLine_112, SketchLine_113, SketchLine_114, SketchLine_115, SketchLine_116, SketchLine_117, SketchLine_118, SketchLine_119, SketchLine_120, SketchLine_121, SketchLine_122, SketchLine_123, SketchLine_124, SketchLine_125] = SketchMultiTranslation_3.translatedList() SketchLine_125.setName("SketchLine_130") SketchLine_125.result().setName("SketchLine_130") SketchLine_124.setName("SketchLine_129")