diff --git a/adm/cmake/cotire.cmake b/adm/cmake/cotire.cmake index b8b98a7119..acdca71a9f 100644 --- a/adm/cmake/cotire.cmake +++ b/adm/cmake/cotire.cmake @@ -3,7 +3,7 @@ # See the cotire manual for usage hints. # #============================================================================= -# Copyright 2012-2016 Sascha Kratky +# Copyright 2012-2018 Sascha Kratky # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -32,16 +32,18 @@ if(__COTIRE_INCLUDED) endif() set(__COTIRE_INCLUDED TRUE) -# Caution! Be careful, when increase minimal cmake version: -# using of newer version may leads (by default) to applying -# of some new policies. It may break compilation. -# For canceling of applying new policies use: -# cmake_policy(PUSH) before `cmake_minimum_required` -# and cmake_policy(POP) after. -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +# call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode +# cmake_minimum_required also sets the policy version as a side effect, which we have to avoid +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(PUSH) +endif() +cmake_minimum_required(VERSION 2.8.12) +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(POP) +endif() set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") -set (COTIRE_CMAKE_MODULE_VERSION "1.7.9") +set (COTIRE_CMAKE_MODULE_VERSION "1.8.1") # activate select policies if (POLICY CMP0025) @@ -104,6 +106,11 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif() +if (POLICY CMP0055) + # strict checking for break() command + cmake_policy(SET CMP0055 NEW) +endif() + include(CMakeParseArguments) include(ProcessorCount) @@ -232,7 +239,13 @@ function (cotire_filter_language_source_files _language _target _sourceFilesVar # add to excluded sources, if file has custom compile flags list (APPEND _excludedSourceFiles "${_sourceFile}") else() - list (APPEND _sourceFiles "${_sourceFile}") + get_source_file_property(_sourceCompileOptions "${_sourceFile}" COMPILE_OPTIONS) + if (_sourceCompileOptions) + # add to excluded sources, if file has list of custom compile options + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") + endif() endif() endif() endforeach() @@ -291,7 +304,7 @@ function (cotire_get_source_file_property_values _valuesVar _property) set (${_valuesVar} ${_values} PARENT_SCOPE) endfunction() -function (cotire_resolve_config_properites _configurations _propertiesVar) +function (cotire_resolve_config_properties _configurations _propertiesVar) set (_properties "") foreach (_property ${ARGN}) if ("${_property}" MATCHES "") @@ -307,8 +320,8 @@ function (cotire_resolve_config_properites _configurations _propertiesVar) set (${_propertiesVar} ${_properties} PARENT_SCOPE) endfunction() -function (cotire_copy_set_properites _configurations _type _source _target) - cotire_resolve_config_properites("${_configurations}" _properties ${ARGN}) +function (cotire_copy_set_properties _configurations _type _source _target) + cotire_resolve_config_properties("${_configurations}" _properties ${ARGN}) foreach (_property ${_properties}) get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) if (_isSet) @@ -318,13 +331,18 @@ function (cotire_copy_set_properites _configurations _type _source _target) endforeach() endfunction() -function (cotire_get_target_usage_requirements _target _targetRequirementsVar) +function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar) set (_targetRequirements "") get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) while (_librariesToProcess) # remove from head list (GET _librariesToProcess 0 _library) list (REMOVE_AT _librariesToProcess 0) + if (_library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + endif() if (TARGET ${_library}) list (FIND _targetRequirements ${_library} _index) if (_index LESS 0) @@ -439,7 +457,7 @@ function (cotire_get_target_compile_flags _config _language _target _flagsVar) # interface compile options from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS) if (_targetOptions) @@ -571,7 +589,7 @@ function (cotire_get_target_include_directories _config _language _target _inclu # interface include directories from linked library targets if (_target) set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_linkedTargetType ${_linkedTarget} TYPE) if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND @@ -625,7 +643,7 @@ function (cotire_get_target_include_directories _config _language _target _inclu if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) endif() - if (WIN32) + if (WIN32 AND NOT MINGW) # convert Windows paths in include directories to CMake paths if (_includeDirs) set (_paths "") @@ -701,7 +719,7 @@ function (cotire_get_target_compile_definitions _config _language _target _defin endif() # interface compile definitions from linked library targets set (_linkedTargets "") - cotire_get_target_usage_requirements(${_target} _linkedTargets) + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) foreach (_linkedTarget ${_linkedTargets}) get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS) if (_definitions) @@ -709,7 +727,7 @@ function (cotire_get_target_compile_definitions _config _language _target _defin endif() endforeach() # parse additional compile definitions from target compile flags - # and don't look at directory compile definitions, which we already handled + # and do not look at directory compile definitions, which we already handled set (_targetFlags "") cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) @@ -857,6 +875,9 @@ macro (cotire_set_cmd_to_prologue _cmdVar) list (APPEND ${_cmdVar} "--warn-uninitialized") endif() list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") + if (XCODE) + list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE") + endif() if (COTIRE_VERBOSE) list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") @@ -874,6 +895,9 @@ function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerE if (NOT _compilerArg1) set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) endif() + if (WIN32) + file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe) + endif() string (STRIP "${_compilerArg1}" _compilerArg1) if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") # compiler launcher is only supported for Makefile and Ninja @@ -900,16 +924,16 @@ function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemInclu foreach (_include ${_includeDirs}) if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") file (TO_NATIVE_PATH "${_include}" _include) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() set (_index -1) if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+") list (FIND ${_systemIncludesVar} "${_include}" _index) endif() if (_index GREATER -1) - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") else() - list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_${_language}_SEP}${_include}") + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") endif() endif() endforeach() @@ -1044,10 +1068,10 @@ macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar) set (${_headerIsIgnoredVar} TRUE) elseif (IS_DIRECTORY "${_headerFile}") set (${_headerIsIgnoredVar} TRUE) - elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed" AND "${_headerFile}" MATCHES "\\.h$") - # heuristic: ignore C headers with embedded parent directory references or "-fixed" or "_fixed" in path + elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed") + # heuristic: ignore headers with embedded parent directory references or "-fixed" or "_fixed" in path # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation - # with the error message "error: no include path in which to search for header.h" + # with the error message "error: no include path in which to search for header" set (${_headerIsIgnoredVar} TRUE) else() set (${_headerIsIgnoredVar} FALSE) @@ -1068,12 +1092,11 @@ endmacro() macro (cotire_parse_line _line _headerFileVar _headerDepthVar) if (MSVC) - # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: + # cl.exe /showIncludes produces different output, depending on the language pack used, e.g.: # English: "Note: including file: C:\directory\file" # German: "Hinweis: Einlesen der Datei: C:\directory\file" # We use a very general regular expression, relying on the presence of the : characters if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$") - # Visual Studio compiler output string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) else() @@ -1231,11 +1254,19 @@ function (cotire_scan_includes _includesVar) set (${_includesVar} "" PARENT_SCOPE) return() endif() - list (APPEND _cmd ${_existingSourceFiles}) + # add source files to be scanned + if (WIN32) + foreach (_sourceFile ${_existingSourceFiles}) + file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative) + list (APPEND _cmd "${_sourceFileNative}") + endforeach() + else() + list (APPEND _cmd ${_existingSourceFiles}) + endif() if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (_option_COMPILER_ID MATCHES "MSVC") + if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) endif() @@ -1471,11 +1502,16 @@ function (cotire_generate_prefix_header _prefixFile) if (_unparsedLines) if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders) list (LENGTH _unparsedLines _skippedLineCount) - message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") + if (WIN32) + file (TO_NATIVE_PATH "${_unparsedLinesFile}" _unparsedLinesLogPath) + else() + set (_unparsedLinesLogPath "${_unparsedLinesFile}") + endif() + message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesLogPath}") endif() string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") endif() - file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}") + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") endfunction() function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) @@ -1505,7 +1541,7 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags # append to list list (APPEND _flags -H -E) if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") - list (APPEND _flags "-fdirectives-only") + list (APPEND _flags -fdirectives-only) endif() else() # return as a flag string @@ -1515,16 +1551,36 @@ function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flags endif() endif() elseif (_compilerID MATCHES "Clang") - # Clang options used - # -H print the name of each header file used - # -E invoke preprocessor - # -fno-color-diagnostics don't prints diagnostics in color - if (_flags) - # append to list - list (APPEND _flags -H -E -fno-color-diagnostics) - else() - # return as a flag string - set (_flags "-H -E -fno-color-diagnostics") + if (UNIX) + # Clang options used + # -H print the name of each header file used + # -E invoke preprocessor + # -fno-color-diagnostics do not print diagnostics in color + # -Eonly just run preprocessor, no output + if (_flags) + # append to list + list (APPEND _flags -H -E -fno-color-diagnostics -Xclang -Eonly) + else() + # return as a flag string + set (_flags "-H -E -fno-color-diagnostics -Xclang -Eonly") + endif() + elseif (WIN32) + # Clang-cl.exe options used + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /EP preprocess to stdout without #line directives + # -H print the name of each header file used + # -fno-color-diagnostics do not print diagnostics in color + # -Eonly just run preprocessor, no output + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags "${_sourceFileType${_language}}" /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly") + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1598,8 +1654,8 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") endif() endif() - elseif (_compilerID MATCHES "GNU|Clang") - # GCC / Clang options used + elseif (_compilerID MATCHES "GNU") + # GCC options used # -x specify the source language # -c compile but do not link # -o place output in file @@ -1609,11 +1665,55 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio set (_xLanguage_CXX "c++-header") if (_flags) # append to list - list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}") else() # return as a flag string set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") endif() + elseif (_compilerID MATCHES "Clang") + if (UNIX) + # Clang options used + # -x specify the source language + # -c compile but do not link + # -o place output in file + # -fno-pch-timestamp disable inclusion of timestamp in precompiled headers (clang 4.0.0+) + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + if (_flags) + # append to list + list (APPEND _flags -x "${_xLanguage_${_language}}" -c "${_prefixFile}" -o "${_pchFile}") + if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") + list (APPEND _flags -Xclang -fno-pch-timestamp) + endif() + else() + # return as a flag string + set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") + set (_flags "${_flags} -Xclang -fno-pch-timestamp") + endif() + endif() + elseif (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) + # Clang-cl.exe options used + # /Yc creates a precompiled header file + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + # /Zs syntax check only + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags "${_sourceFileType${_language}}" + "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + else() + # return as a flag string + set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + endif() + endif() elseif (_compilerID MATCHES "Intel") if (WIN32) file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) @@ -1655,20 +1755,28 @@ function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersio get_filename_component(_pchName "${_pchFile}" NAME) set (_xLanguage_C "c-header") set (_xLanguage_CXX "c++-header") + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list if ("${_language}" STREQUAL "CXX") list (APPEND _flags -Kc++) endif() - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") + list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-create "${_pchName}" -fsyntax-only "${_hostFile}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags -Wpch-messages) + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() endif() @@ -1719,23 +1827,48 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV # note: ccache requires the -include flag to be used in order to process precompiled header correctly if (_flags) # append to list - list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") + list (APPEND _flags -Winvalid-pch -include "${_prefixFile}") else() # return as a flag string set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") endif() elseif (_compilerID MATCHES "Clang") - # Clang options used - # -include process include file as the first line of the primary source file - # -include-pch include precompiled header file - # -Qunused-arguments don't emit warning for unused driver arguments - # note: ccache requires the -include flag to be used in order to process precompiled header correctly - if (_flags) - # append to list - list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") - else() - # return as a flag string - set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + if (UNIX) + # Clang options used + # -include process include file as the first line of the primary source file + # note: ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags -include "${_prefixFile}") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\"") + endif() + elseif (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + # Clang-cl.exe options used + # /Yu uses a precompiled header file during build + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + if (_pchFile) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + if (_flags) + # append to list + list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + endif() + else() + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFileNative}\"") + endif() + endif() endif() elseif (_compilerID MATCHES "Intel") if (WIN32) @@ -1779,24 +1912,32 @@ function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerV if (_pchFile) get_filename_component(_pchDir "${_pchFile}" DIRECTORY) get_filename_component(_pchName "${_pchFile}" NAME) + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") + list (APPEND _flags -include "${_prefixFile}" -pch-dir "${_pchDir}" -pch-use "${_pchName}") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - list (APPEND _flags "-Wpch-messages") + if (NOT _pchSuppressMessages) + list (APPEND _flags -Wpch-messages) + endif() endif() else() # return as a flag string set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") - set (_flags "${_flags} -Wpch-messages") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() endif() endif() else() # no precompiled header, force inclusion of prefix header if (_flags) # append to list - list (APPEND _flags "-include" "${_prefixFile}") + list (APPEND _flags -include "${_prefixFile}") else() # return as a flag string set (_flags "-include \"${_prefixFile}\"") @@ -1834,9 +1975,17 @@ function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) if (COTIRE_VERBOSE) message (STATUS "execute_process: ${_cmd}") endif() - if (_option_COMPILER_ID MATCHES "MSVC") + if (MSVC_IDE OR _option_COMPILER_ID MATCHES "MSVC") # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared unset (ENV{VS_UNICODE_OUTPUT}) + elseif (_option_COMPILER_ID MATCHES "Clang" AND _option_COMPILER_VERSION VERSION_LESS "4.0.0") + if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR + _option_COMPILER_EXECUTABLE MATCHES "ccache") + # Newer versions of Clang embed a compilation timestamp into the precompiled header binary, + # which results in "file has been modified since the precompiled header was built" errors if ccache is used. + # We work around the problem by disabling ccache upon pre-compiling the prefix header. + set (ENV{CCACHE_DISABLE} "true") + endif() endif() execute_process( COMMAND ${_cmd} @@ -1851,7 +2000,7 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (_unsupportedCompiler "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") - # supported since Visual Studio C++ 6.0 + # PCH supported since Visual Studio C++ 6.0 # and CMake does not support an earlier version set (${_msgVar} "" PARENT_SCOPE) elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") @@ -1862,8 +2011,16 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) set (${_msgVar} "" PARENT_SCOPE) endif() elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") - # all Clang versions have PCH support - set (${_msgVar} "" PARENT_SCOPE) + if (UNIX) + # all Unix Clang versions have PCH support + set (${_msgVar} "" PARENT_SCOPE) + elseif (WIN32) + # only clang-cl is supported under Windows + get_filename_component(_compilerName "${CMAKE_${_language}_COMPILER}" NAME_WE) + if (NOT _compilerName MATCHES "cl$") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}. Use clang-cl instead." PARENT_SCOPE) + endif() + endif() elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") # Intel PCH support requires version >= 8.0.0 if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") @@ -1874,29 +2031,38 @@ function (cotire_check_precompiled_header_support _language _target _msgVar) else() set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) endif() + # check if ccache is used as a compiler launcher get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) - if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" REALPATH) + if (_realCompilerExe MATCHES "ccache" OR _launcher MATCHES "ccache") + # verify that ccache configuration is compatible with precompiled headers + # always check environment variable CCACHE_SLOPPINESS, because earlier versions of ccache + # do not report the "sloppiness" setting correctly upon printing ccache configuration if (DEFINED ENV{CCACHE_SLOPPINESS}) - if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR + NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") set (${_msgVar} "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." PARENT_SCOPE) endif() else() - if (_launcher MATCHES "ccache") - get_filename_component(_ccacheExe "${_launcher}" REALPATH) + if (_realCompilerExe MATCHES "ccache") + set (_ccacheExe "${_realCompilerExe}") else() - get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + set (_ccacheExe "${_launcher}") endif() + # ccache 3.7.0 replaced --print-config with --show-config + # use -p instead, which seems to work for all version for now, sigh execute_process( - COMMAND "${_ccacheExe}" "--print-config" + COMMAND "${_ccacheExe}" "-p" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" RESULT_VARIABLE _result OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - if (_result OR NOT - _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT - _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + if (_result) + set (${_msgVar} "ccache configuration cannot be determined." PARENT_SCOPE) + elseif (NOT _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR + NOT _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") set (${_msgVar} "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." PARENT_SCOPE) @@ -2189,7 +2355,7 @@ function (cotire_generate_target_script _language _configurations _target _targe XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 - CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_${_language}_SEP + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_SEP_${_language} CMAKE_INCLUDE_SYSTEM_FLAG_${_language} CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG @@ -2222,8 +2388,9 @@ endfunction() function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) set (_sourceFiles ${ARGN}) - if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we attach the precompiled header compilation to the host file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # for MSVC, Intel and Clang-cl, we attach the precompiled header compilation to the host file # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion if (_sourceFiles) set (_flags "") @@ -2231,6 +2398,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + if (COTIRE_DEBUG) + message (STATUS "set_property: SOURCE ${_hostFile} APPEND_STRING COMPILE_FLAGS ${_flags}") + endif() set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") # make object file generated from host file depend on prefix header set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") @@ -2268,8 +2438,9 @@ function (cotire_setup_pch_file_compilation _language _target _targetScript _pre endfunction() function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile _hostFile) - if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # for Visual Studio and Intel, we include the precompiled header in all but the host file + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" OR + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # for MSVC, Intel and clang-cl, we include the precompiled header in all but the host file # the host file does the precompiled header compilation, see cotire_setup_pch_file_compilation set (_sourceFiles ${ARGN}) list (LENGTH _sourceFiles _numberOfSourceFiles) @@ -2281,6 +2452,9 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + if (COTIRE_DEBUG) + message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}") + endif() # make object files generated from source files depend on precompiled header set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") endif() @@ -2294,6 +2468,9 @@ function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefix "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + if (COTIRE_DEBUG) + message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}") + endif() # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") endif() @@ -2311,6 +2488,9 @@ function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _flags) set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + if (COTIRE_DEBUG) + message (STATUS "set_property: SOURCE ${_sourceFiles} APPEND_STRING COMPILE_FLAGS ${_flags}") + endif() # mark sources as cotired to prevent them from being used in another cotired target set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") # make object files generated from source files depend on prefix header @@ -2400,7 +2580,7 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}") endif() # because CMake PRE_BUILD command does not support dependencies, - # we check dependencies explicitly in cotire script mode when the pre-build action is run + # we check dependencies explicity in cotire script mode when the pre-build action is run add_custom_command( TARGET "${_target}" PRE_BUILD ${_cmds} @@ -2415,9 +2595,10 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) # if this is a single-language target without any excluded files if (_wholeTarget) set (_language "${_languages}") - # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level + # for MSVC, Intel and clang-cl, precompiled header inclusion is always done on the source file level # see cotire_setup_pch_file_inclusion - if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) if (_prefixFile) get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) @@ -2426,6 +2607,9 @@ function (cotire_setup_target_pch_usage _languages _target _wholeTarget) "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" "${_prefixFile}" "${_pchFile}" _options) set_property(TARGET ${_target} APPEND PROPERTY ${_options}) + if (COTIRE_DEBUG) + message (STATUS "set_property: TARGET ${_target} APPEND PROPERTY ${_options}") + endif() endif() endif() endif() @@ -2452,7 +2636,8 @@ function (cotire_setup_unity_generation_commands _language _target _targetScript set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths}) endif() if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel + # unity file compilation results in potentially huge object file, + # thus use /bigobj by default unter cl.exe and Windows Intel set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") endif() cotire_set_cmd_to_prologue(_unityCmd) @@ -2658,6 +2843,9 @@ function (cotire_make_target_message _target _languages _disableMsg _targetMsgVa else() set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") endif() + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() else() if (_excludedStr) set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.") @@ -2747,6 +2935,20 @@ function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTarge set (_targetUsePCH FALSE) endif() endif() + if (_targetAddSCU) + # disable unity builds if automatic Qt processing is used + get_target_property(_targetAutoMoc ${_target} AUTOMOC) + get_target_property(_targetAutoUic ${_target} AUTOUIC) + get_target_property(_targetAutoRcc ${_target} AUTORCC) + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + if (_disableMsg) + set (_disableMsg "${_disableMsg} Target uses automatic CMake Qt processing.") + else() + set (_disableMsg "Target uses automatic CMake Qt processing.") + endif() + set (_targetAddSCU FALSE) + endif() + endif() set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU}) cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles}) @@ -2774,7 +2976,11 @@ function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) set (_sourceFiles ${ARGN}) get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)") - set (_numberOfThreads "${CMAKE_MATCH_2}") + if (DEFINED CMAKE_MATCH_2) + set (_numberOfThreads "${CMAKE_MATCH_2}") + else() + set (_numberOfThreads "") + endif() if (NOT _numberOfThreads) # use all available cores ProcessorCount(_numberOfThreads) @@ -2887,8 +3093,9 @@ function (cotire_setup_pch_target _languages _configurations _target) set (_dependsFiles "") foreach (_language ${_languages}) set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) - if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") - # Visual Studio and Intel only create precompiled header as a side effect + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel" AND NOT + (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) + # MSVC, Intel and clang-cl only create precompiled header as a side effect list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) endif() cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) @@ -2936,6 +3143,7 @@ function (cotire_collect_unity_target_sources _target _languages _unityTargetSou list (APPEND _unityTargetSources ${_unityFiles}) endif() endforeach() + # handle object libraries which are part of the target's sources get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$") cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles}) @@ -2980,21 +3188,6 @@ function (cotire_setup_unity_build_target _languages _configurations _target) # determine unity target sources set (_unityTargetSources "") cotire_collect_unity_target_sources(${_target} "${_languages}" _unityTargetSources) - # handle automatic Qt processing - get_target_property(_targetAutoMoc ${_target} AUTOMOC) - get_target_property(_targetAutoUic ${_target} AUTOUIC) - get_target_property(_targetAutoRcc ${_target} AUTORCC) - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # if the original target sources are subject to CMake's automatic Qt processing, - # also include implicitly generated _automoc.cpp file - if (CMAKE_VERSION VERSION_LESS "3.8.0") - list (APPEND _unityTargetSources "${_target}_automoc.cpp") - set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) - else() - list (APPEND _unityTargetSources "${_target}_autogen/moc_compilation.cpp") - set_property (SOURCE "${_target}_autogen/moc_compilation.cpp" PROPERTY GENERATED TRUE) - endif() - endif() # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created set (CMAKE_AUTOMOC OFF) set (CMAKE_AUTOUIC OFF) @@ -3008,21 +3201,6 @@ function (cotire_setup_unity_build_target _languages _configurations _target) else() add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) endif() - if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") - # depend on original target's automoc target, if it exists - if (TARGET ${_target}_automoc) - add_dependencies(${_unityTargetName} ${_target}_automoc) - endif() - else() - if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) - # depend on the original target's implicitly generated _automoc target - if (CMAKE_VERSION VERSION_LESS "3.8.0") - add_dependencies(${_unityTargetName} ${_target}_automoc) - else() - add_dependencies(${_unityTargetName} ${_target}_autogen) - endif() - endif() - endif() # copy output location properties set (_outputDirProperties ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ @@ -3034,8 +3212,8 @@ function (cotire_setup_unity_build_target _languages _configurations _target) set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") else() # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) - cotire_resolve_config_properites("${_configurations}" _properties ${_outputDirProperties}) + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties}) foreach (_property ${_properties}) get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) if (_outputDir) @@ -3055,11 +3233,11 @@ function (cotire_setup_unity_build_target _languages _configurations _target) RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") endif() else() - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) endif() # copy output name - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ OUTPUT_NAME OUTPUT_NAME_ @@ -3067,7 +3245,7 @@ function (cotire_setup_unity_build_target _languages _configurations _target) PREFIX _POSTFIX SUFFIX IMPORT_PREFIX IMPORT_SUFFIX) # copy compile stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ COMPILE_FLAGS COMPILE_OPTIONS Fortran_FORMAT Fortran_MODULE_DIRECTORY @@ -3079,12 +3257,12 @@ function (cotire_setup_unity_build_target _languages _configurations _target) C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN C_CLANG_TIDY CXX_CLANG_TIDY) # copy compile features - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED COMPILE_FEATURES) # copy interface stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS @@ -3092,8 +3270,9 @@ function (cotire_setup_unity_build_target _languages _configurations _target) INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) # copy link stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} - BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUILD_WITH_INSTALL_RPATH BUILD_WITH_INSTALL_NAME_DIR + INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_FLAGS LINK_FLAGS_ LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_ @@ -3101,18 +3280,18 @@ function (cotire_setup_unity_build_target _languages _configurations _target) LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ NO_SONAME SOVERSION VERSION - LINK_WHAT_YOU_USE) + LINK_WHAT_YOU_USE BUILD_RPATH) # copy cmake stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) # copy Apple platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST - IOS_INSTALL_COMBINED) + IOS_INSTALL_COMBINED XCODE_EXPLICIT_FILE_TYPE XCODE_PRODUCT_TYPE) # copy Windows platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} GNUtoMS COMPILE_PDB_NAME COMPILE_PDB_NAME_ COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ @@ -3126,15 +3305,19 @@ function (cotire_setup_unity_build_target _languages _configurations _target) VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE - VS_SDK_REFERENCES) + VS_SDK_REFERENCES VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY) # copy Android platform specific stuff - cotire_copy_set_properites("${_configurations}" TARGET ${_target} ${_unityTargetName} + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ANDROID_API ANDROID_API_MIN ANDROID_GUI ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE) + # copy CUDA platform specific stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + CUDA_PTX_COMPILATION CUDA_SEPARABLE_COMPILATION CUDA_RESOLVE_DEVICE_SYMBOLS + CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED) # use output name from original target get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) if (NOT _targetOutputName) @@ -3148,6 +3331,13 @@ function (cotire_setup_unity_build_target _languages _configurations _target) set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) endif() endif() + # enable parallel compilation for MSVC + if (MSVC AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") + list (LENGTH _unityTargetSources _numberOfUnityTargetSources) + if (_numberOfUnityTargetSources GREATER 1) + set_property(TARGET ${_unityTargetName} APPEND PROPERTY COMPILE_OPTIONS "/MP") + endif() + endif() cotire_init_target(${_unityTargetName}) cotire_add_to_unity_all_target(${_unityTargetName}) set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") @@ -3306,6 +3496,13 @@ function (cotire_target_link_libraries _target) message (STATUS "unity target ${_unityTargetName} interface link libraries: ${_unityLinkInterfaceLibraries}") endif() endif() + get_target_property(_manualDependencies ${_target} MANUALLY_ADDED_DEPENDENCIES) + if (_manualDependencies) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityManualDependencies ${_manualDependencies}) + if (_unityManualDependencies) + add_dependencies("${_unityTargetName}" ${_unityManualDependencies}) + endif() + endif() endif() endif() endfunction(cotire_target_link_libraries) @@ -3338,9 +3535,9 @@ function (cotire_init_target _targetName) set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}") endif() set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_ALL TRUE) - if (MSVC_IDE) - set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) - endif() + # if (MSVC_IDE) + # set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) + # endif() endfunction() function (cotire_add_to_pch_all_target _pchTargetName) @@ -3602,7 +3799,7 @@ else() set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING "Ignore sources with the listed file extensions from the generated unity source.") - set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING + set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "2" CACHE STRING "Minimum number of sources in target required to enable use of precompiled header.") if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT) @@ -3701,7 +3898,7 @@ else() FULL_DOCS "The variable can be set to an integer > 0." "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target." - "If not defined, defaults to 3." + "If not defined, defaults to 2." ) define_property( diff --git a/adm/cmake/draco.cmake b/adm/cmake/draco.cmake index 755391fa52..cebc75df99 100644 --- a/adm/cmake/draco.cmake +++ b/adm/cmake/draco.cmake @@ -3,10 +3,6 @@ OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") -if (NOT DEFINED INSTALL_DRACO) - set (INSTALL_DRACO OFF CACHE BOOL "${INSTALL_DRACO_DESCR}") -endif() - if (NOT DEFINED 3RDPARTY_DRACO_DIR) set (3RDPARTY_DRACO_DIR "" CACHE PATH "The directory containing Draco") endif() @@ -15,14 +11,24 @@ if (NOT DEFINED 3RDPARTY_DRACO_INCLUDE_DIR) set (3RDPARTY_DRACO_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the Draco") endif() -if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY OR NOT 3RDPARTY_DRACO_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}") - set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library" FORCE) +if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY) + set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library") endif() if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR) set (3RDPARTY_DRACO_LIBRARY_DIR "" CACHE PATH "The directory containing Draco library") endif() +if (WIN32) + if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DEBUG) + set (3RDPARTY_DRACO_LIBRARY_DEBUG "" CACHE FILEPATH "Draco debug library") + endif() + + if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR_DEBUG) + set (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "" CACHE PATH "The directory containing Draco debug library") + endif() +endif() + if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") if (NOT 3RDPARTY_DRACO_DIR OR NOT EXISTS "${3RDPARTY_DRACO_DIR}") FIND_PRODUCT_DIR("${3RDPARTY_DIR}" draco DRACO_DIR_NAME) @@ -32,20 +38,19 @@ if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") endif() endif() -if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") - set (DRACO_INCLUDE_PATH "${3RDPARTY_DRACO_DIR}/include") - set (DRACO_LIBRARY_PATH "${3RDPARTY_DRACO_DIR}/lib") -endif() +# header +if (NOT 3RDPARTY_DRACO_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_DRACO_INCLUDE_DIR}") + set (HEADER_NAMES draco) -if (NOT 3RDPARTY_DRACO_INCLUDE_DIR) - if (DRACO_INCLUDE_PATH AND EXISTS "${DRACO_INCLUDE_PATH}") - set (3RDPARTY_DRACO_INCLUDE_DIR "${DRACO_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of DRACO" FORCE) - endif() -endif() + # set 3RDPARTY_DRACO_INCLUDE_DIR as notfound, otherwise find_path can't assign a new value to 3RDPARTY_DRACO_INCLUDE_DIR + set (3RDPARTY_DRACO_INCLUDE_DIR "3RDPARTY_DRACO_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "The directory containing headers of the Draco" FORCE) -if (NOT 3RDPARTY_DRACO_LIBRARY_DIR) - if (DRACO_LIBRARY_PATH AND EXISTS "${DRACO_LIBRARY_PATH}") - set (3RDPARTY_DRACO_LIBRARY_DIR "${DRACO_LIBRARY_PATH}" CACHE FILEPATH "The directory containing DRACO library" FORCE) + if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") + find_path (3RDPARTY_DRACO_INCLUDE_DIR NAMES ${HEADER_NAMES} + PATHS ${3RDPARTY_DRACO_DIR} + PATH_SUFFIXES "include" + CMAKE_FIND_ROOT_PATH_BOTH + NO_DEFAULT_PATH) endif() endif() @@ -57,11 +62,11 @@ endif() if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") if (NOT 3RDPARTY_DRACO_LIBRARY OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY}") - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) set (3RDPARTY_DRACO_LIBRARY "3RDPARTY_DRACO_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to Draco library" FORCE) find_library (3RDPARTY_DRACO_LIBRARY NAMES ${CSF_Draco} - PATHS "${3RDPARTY_DRACO_LIBRARY_DIR}" + PATHS "${3RDPARTY_DRACO_DIR}" PATH_SUFFIXES lib CMAKE_FIND_ROOT_PATH_BOTH NO_DEFAULT_PATH) @@ -70,27 +75,19 @@ if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}") set (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY_DIR}" CACHE FILEPATH "The directory containing Draco library" FORCE) endif() endif() -endif() -if (3RDPARTY_DRACO_LIBRARY_DIR AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}") - list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_DRACO_LIBRARY_DIR}") -else() - list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_DRACO_LIBRARY_DIR) -endif() + if (WIN32 AND (NOT 3RDPARTY_DRACO_LIBRARY_DEBUG OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DEBUG}")) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) + set (3RDPARTY_DRACO_LIBRARY_DEBUG "3RDPARTY_DRACO_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "The path to debug Draco library" FORCE) -if (INSTALL_DRACO) - get_filename_component(3RDPARTY_DRACO_LIBRARY_REALPATH ${3RDPARTY_DRACO_LIBRARY} REALPATH) - if (SINGLE_GENERATOR) - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR_LIB}") - else() - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS Release - DESTINATION "${INSTALL_DIR_LIB}") - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS RelWithDebInfo - DESTINATION "${INSTALL_DIR_LIB}i") - install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} - CONFIGURATIONS Debug - DESTINATION "${INSTALL_DIR_LIB}d") + find_library (3RDPARTY_DRACO_LIBRARY_DEBUG NAMES ${CSF_Draco} + PATHS "${3RDPARTY_DRACO_DIR}" + PATH_SUFFIXES libd + CMAKE_FIND_ROOT_PATH_BOTH + NO_DEFAULT_PATH) + if (3RDPARTY_DRACO_LIBRARY_DEBUG AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DEBUG}") + get_filename_component (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "${3RDPARTY_DRACO_LIBRARY_DEBUG}" PATH) + set (3RDPARTY_DRACO_LIBRARY_DIR_DEBUG "${3RDPARTY_DRACO_LIBRARY_DIR_DEBUG}" CACHE FILEPATH "The directory containing debug Draco library" FORCE) + endif() endif() endif() diff --git a/adm/cmake/freetype.cmake b/adm/cmake/freetype.cmake index 7f6f950b24..8563c24f28 100644 --- a/adm/cmake/freetype.cmake +++ b/adm/cmake/freetype.cmake @@ -110,8 +110,19 @@ if (IS_BUILTIN_SEARCH_REQUIRED) set (ENV{FREETYPE_DIR} "${3RDPARTY_FREETYPE_DIR}") endif() + unset (FREETYPE_LIBRARY_RELEASE) find_package(Freetype) + # Only for UNIX (not APPLE) + if ((NOT WIN32) AND (NOT APPLE)) + # To avoid linker error on Ubuntu 18.04 and others linux distributives we should + # link with freetype library, compiled as Position Independent Code (PIC), + # for example, with shared object. + if ((DEFINED FREETYPE_LIBRARY_RELEASE) AND (NOT "${FREETYPE_LIBRARY_RELEASE}" STREQUAL "") AND (EXISTS "${FREETYPE_LIBRARY_RELEASE}")) + string (REPLACE "\.a" "\.so" FREETYPE_LIBRARY_RELEASE "${FREETYPE_LIBRARY_RELEASE}") + endif() + endif() + # restore ENV{FREETYPE_DIR} if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}") set (ENV{FREETYPE_DIR} ${CACHED_FREETYPE_DIR}) @@ -122,7 +133,7 @@ if (IS_BUILTIN_SEARCH_REQUIRED) CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_INCLUDE_DIR_ft2build FILEPATH "The directory containing ft2build.h header") CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_INCLUDE_DIR_freetype2 FILEPATH "The directory containing ftheader.h header") if (BUILD_SHARED_LIBS) - CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_LIBRARY FILEPATH "freetype library") + CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_LIBRARY_RELEASE FILEPATH "freetype library") endif() endif() @@ -141,8 +152,8 @@ if (IS_BUILTIN_SEARCH_REQUIRED) if (BUILD_SHARED_LIBS) if (NOT 3RDPARTY_FREETYPE_LIBRARY OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY}") - if (FREETYPE_LIBRARY AND EXISTS "${FREETYPE_LIBRARY}") - set (3RDPARTY_FREETYPE_LIBRARY "${FREETYPE_LIBRARY}" CACHE FILEPATH "The path to freetype library" FORCE) + if (FREETYPE_LIBRARY_RELEASE AND EXISTS "${FREETYPE_LIBRARY_RELEASE}") + set (3RDPARTY_FREETYPE_LIBRARY "${FREETYPE_LIBRARY_RELEASE}" CACHE FILEPATH "The path to freetype library" FORCE) endif() endif() @@ -220,7 +231,7 @@ endif() # freetype library #if (BUILD_SHARED_LIBS) if (NOT 3RDPARTY_FREETYPE_LIBRARY OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY}") - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a) + set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib) set (FREETYPE_PATH_SUFFIXES lib) if (ANDROID) @@ -242,6 +253,16 @@ endif() CMAKE_FIND_ROOT_PATH_BOTH) endif() + # Only for UNIX (not APPLE) + if ((NOT WIN32) AND (NOT APPLE)) + # To avoid linker error on Ubuntu 18.04 and some others linux distributives we should + # link with freetype library, compiled as Position Independent Code (PIC), + # for example, with shared object. + if ((DEFINED 3RDPARTY_FREETYPE_LIBRARY) AND (NOT "${3RDPARTY_FREETYPE_LIBRARY}" STREQUAL "") AND (EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")) + string (REPLACE "\.a" "\.so" 3RDPARTY_FREETYPE_LIBRARY "${3RDPARTY_FREETYPE_LIBRARY}") + endif() + endif() + if (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}") get_filename_component (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY}" PATH) set (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" CACHE PATH "The directory containing freetype library" FORCE) @@ -350,7 +371,7 @@ endif() # unset all redundant variables OCCT_CHECK_AND_UNSET(FREETYPE_INCLUDE_DIR_ft2build) OCCT_CHECK_AND_UNSET(FREETYPE_INCLUDE_DIR_freetype2) -OCCT_CHECK_AND_UNSET(FREETYPE_LIBRARY) +OCCT_CHECK_AND_UNSET(FREETYPE_LIBRARY_RELEASE) if (BUILD_SHARED_LIBS) mark_as_advanced (3RDPARTY_FREETYPE_LIBRARY 3RDPARTY_FREETYPE_DLL) diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index 4a060665f6..9fd3ec4cfb 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -160,6 +160,8 @@ function (FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT) if ("${lower_PRODUCT_NAME}" STREQUAL "egl") string (SUBSTRING "${lower_PRODUCT_NAME}" 1 -1 lower_PRODUCT_NAME) list (APPEND SEARCH_TEMPLATES "[^gl]+${lower_PRODUCT_NAME}.*") + elseif ("${lower_PRODUCT_NAME}" STREQUAL "tbb") + list (APPEND SEARCH_TEMPLATES "^.*${lower_PRODUCT_NAME}.*") else() list (APPEND SEARCH_TEMPLATES "^[^a-zA-Z]*${lower_PRODUCT_NAME}[^a-zA-Z]*${COMPILER}.*${COMPILER_BITNESS}") list (APPEND SEARCH_TEMPLATES "^[^a-zA-Z]*${lower_PRODUCT_NAME}[^a-zA-Z]*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}") diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake index 4ed3d4a66f..132890bc84 100644 --- a/adm/cmake/occt_toolkit.cmake +++ b/adm/cmake/occt_toolkit.cmake @@ -245,6 +245,18 @@ endif (USE_QT) if (EXECUTABLE_PROJECT) add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES}) + if (DEFINED ${PROJECT_NAME}_DISABLE_COTIRE AND ${PROJECT_NAME}_DISABLE_COTIRE) + set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) + set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) + else() + # To avoid excluding of PROJECT_NAME from cotire tool, we may use cotire + # COTIRE_PREFIX_HEADER_IGNORE_PATH instead. But, practically it causes many 'undefined symbols' error. + # So, we just exclude PROJECT_NAME from cotire list. + # if (DEFINED ${PROJECT_NAME}_COTIRE_IGNORE_PATH) + # set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_PREFIX_HEADER_IGNORE_PATH "${${PROJECT_NAME}_COTIRE_IGNORE_PATH}") + # endif() + endif() + install (TARGETS ${PROJECT_NAME} DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}") @@ -254,6 +266,18 @@ if (EXECUTABLE_PROJECT) else() add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES}) + if (DEFINED ${PROJECT_NAME}_DISABLE_COTIRE AND ${PROJECT_NAME}_DISABLE_COTIRE) + set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) + set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) + else() + # To avoid excluding of PROJECT_NAME from cotire tool, we may use cotire + # COTIRE_PREFIX_HEADER_IGNORE_PATH instead. But, practically it causes many 'undefined symbols' error. + # So, we just exclude PROJECT_NAME from cotire list. + # if (DEFINED ${PROJECT_NAME}_COTIRE_IGNORE_PATH) + # set_target_properties(${PROJECT_NAME} PROPERTIES COTIRE_PREFIX_HEADER_IGNORE_PATH "${${PROJECT_NAME}_COTIRE_IGNORE_PATH}") + # endif() + endif() + if (MSVC) if (BUILD_FORCE_RelWithDebInfo) set (aReleasePdbConf "Release") @@ -346,6 +370,10 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) add_definitions (-DHAVE_GLES2) endif() + if ("${CURRENT_CSF}" STREQUAL "${CSF_Draco}") + set (CURRENT_CSF "") + set (USED_DRACO 1) + endif() set (LIBRARY_FROM_CACHE 0) separate_arguments (CURRENT_CSF) foreach (CSF_LIBRARY ${CURRENT_CSF}) @@ -373,7 +401,7 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) endforeach() endforeach() - if (NOT ${LIBRARY_FROM_CACHE}) + if (NOT ${LIBRARY_FROM_CACHE} AND NOT "${CURRENT_CSF}" STREQUAL "") # prepare a list from a string with whitespaces separate_arguments (CURRENT_CSF) list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF}) @@ -384,6 +412,28 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) endif() endforeach() +if (USE_DRACO) + if (USED_DRACO) + set (USED_LIB_RELEASE ${3RDPARTY_DRACO_LIBRARY}) + if (WIN32) + set (USED_LIB_DEBUG ${3RDPARTY_DRACO_LIBRARY_DEBUG}) + else() + set (USED_LIB_DEBUG ${3RDPARTY_DRACO_LIBRARY}) + endif() + set (USED_LIB_CONF) + if (EXISTS ${USED_LIB_DEBUG}) + set (USED_LIB_CONF "$<$:${USED_LIB_DEBUG}>;${USED_LIB_CONF}") + endif() + if (EXISTS ${USED_LIB_RELEASE}) + set (USED_LIB_CONF "$<$:${USED_LIB_RELEASE}>;${USED_LIB_CONF}") + set (USED_LIB_CONF "$<$:${USED_LIB_RELEASE}>;${USED_LIB_CONF}") + endif() + if (DEFINED USED_LIB_CONF) + set_property (TARGET ${PROJECT_NAME} APPEND PROPERTY LINK_LIBRARIES "${USED_LIB_CONF}") + endif() + endif() +endif() + if (APPLE) list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND) if (NOT ${IS_X11_FOUND} EQUAL -1) diff --git a/adm/cmake/tbb.cmake b/adm/cmake/tbb.cmake index c39a1a9f2e..4e5f724ac2 100644 --- a/adm/cmake/tbb.cmake +++ b/adm/cmake/tbb.cmake @@ -1,262 +1,240 @@ # tbb -if (NOT DEFINED 3RDPARTY_DIR) - message (FATAL_ERROR "3RDPARTY_DIR is not defined.") -endif() - -if ((NOT EXISTS "${3RDPARTY_DIR}") OR ("${3RDPARTY_DIR}" STREQUAL "")) - message (FATAL_ERROR "Directory ${3RDPARTY_DIR} is not set.") -endif() - -if (NOT DEFINED INSTALL_TBB AND BUILD_SHARED_LIBS) - set (INSTALL_TBB OFF CACHE BOOL "${INSTALL_TBB_DESCR}") -endif() - -# tbb directory -if (NOT DEFINED 3RDPARTY_TBB_DIR) - set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing tbb") -endif() - if (MSVC AND BUILD_SHARED_LIBS) add_definitions (-D__TBB_NO_IMPLICIT_LINKAGE) add_definitions (-D__TBBMALLOC_NO_IMPLICIT_LINKAGE) endif() -# include occt macros. compiler_bitness, os_wiht_bit, compiler -OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros") +if (NOT DEFINED INSTALL_TBB AND BUILD_SHARED_LIBS) + set (INSTALL_TBB OFF CACHE BOOL "${INSTALL_TBB_DESCR}") +endif() -# specify TBB folder in connectin with 3RDPARTY_DIR -if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}") - #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_TBB_DIR PATH "The directory containing tbb") +# Initialize tbb directory. +if (NOT DEFINED 3RDPARTY_TBB_DIR) + set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing tbb") +endif() - if (NOT 3RDPARTY_TBB_DIR OR NOT EXISTS "${3RDPARTY_TBB_DIR}") +if (WIN32) + if (NOT DEFINED 3RDPARTY_DIR) + message (FATAL_ERROR "3RDPARTY_DIR is not defined.") + endif() + if ("${3RDPARTY_DIR}" STREQUAL "") + message (FATAL_ERROR "3RDPARTY_DIR is empty string.") + endif() + if (NOT EXISTS "${3RDPARTY_DIR}") + message (FATAL_ERROR "3RDPARTY_DIR is not exist.") + endif() + + # Below, we have correct 3RDPARTY_DIR. + + # Initialize TBB folder in connectin with 3RDPARTY_DIR. + if (("${3RDPARTY_TBB_DIR}" STREQUAL "") OR (NOT EXISTS "${3RDPARTY_TBB_DIR}")) FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" TBB TBB_DIR_NAME) if (TBB_DIR_NAME) set (3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${TBB_DIR_NAME}" CACHE PATH "The directory containing tbb" FORCE) endif() endif() -else() - #set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing TBB" FORCE) -endif() -if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR) - set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the TBB") -endif() + # Here we have full path name to installation directory of TBB. + # Employ it. + if (EXISTS "${3RDPARTY_TBB_DIR}") + find_package ( + TBB 2021.5 + PATHS "${3RDPARTY_TBB_DIR}" NO_DEFAULT_PATH + REQUIRED + CONFIG) -if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}") - # check 3RDPARTY_TBB_INCLUDE_DIR for consictency with specified 3RDPARTY_TBB_DIR - CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_TBB_INCLUDE_DIR PATH "The directory containing headers of the TBB") -endif() - -# tbb.h -if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}") - - set (HEADER_NAMES tbb.h tbb/tbb.h) - - # set 3RDPARTY_TBB_INCLUDE_DIR as notfound, otherwise find_library can't assign a new value to 3RDPARTY_TBB_INCLUDE_DIR - set (3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE PATH "the path to tbb.h" FORCE) - - if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}") - find_path (3RDPARTY_TBB_INCLUDE_DIR NAMES ${HEADER_NAMES} - PATHS ${3RDPARTY_TBB_DIR} - PATH_SUFFIXES include - CMAKE_FIND_ROOT_PATH_BOTH - NO_DEFAULT_PATH) - else() - find_path (3RDPARTY_TBB_INCLUDE_DIR NAMES ${HEADER_NAMES} - PATH_SUFFIXES include - CMAKE_FIND_ROOT_PATH_BOTH) - endif() -endif() - -if (3RDPARTY_TBB_INCLUDE_DIR AND EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}") - list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}") -else() - list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR) - - set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "the path to tbb.h" FORCE) -endif() - -# Throw execution if 3RDPARTY_TBB_DIR is equal to void string. -if ("${3RDPARTY_TBB_DIR}" STREQUAL "") - message (FATAL_ERROR "Directory with one TBB have not found.") -endif() - -# Searching TBBConfig.cmake and TBBTargets-release.cmake in 3RDPARTY_TBB_DIR -# TBBConfig.cmake - is required, TBBTargets-release.cmake is optional. -file (GLOB_RECURSE TBB_CONFIG_CMAKE_FILE "${3RDPARTY_TBB_DIR}/*TBBConfig.cmake") -if (NOT EXISTS "${TBB_CONFIG_CMAKE_FILE}") - message (FATAL_ERROR "TBBConfig.cmake has not been found.") -endif() -include ("${TBB_CONFIG_CMAKE_FILE}") - -file (GLOB_RECURSE TBB_TARGET_CMAKE_FILE "${3RDPARTY_TBB_DIR}/*TBBTargets-release.cmake") -if (EXISTS "${TBB_TARGET_CMAKE_FILE}") - include ("${TBB_TARGET_CMAKE_FILE}") -endif() - -# We do not know, full path to file is pointed, or local. -# So, we should check it and output FULL PATH to FILE. -macro (TBB_FILE_NAME_TO_FILEPATH FL_NAME FL_PATH) - if (EXISTS "${FL_NAME}") - # FL_NAME is full path. - set (${FL_PATH} "${FL_NAME}") - else() - # Here we deal with local path, so assign to var full path to file. - # Acquire full path. - set (${FL_PATH} "${3RDPARTY_TBB_DIR}${FL_NAME}") - if (NOT EXISTS "${${FL_PATH}}") - message (FATAL_ERROR "TBB: needed file not found (${FL_PATH}).") + # Achive include directory + get_target_property (TBB_INCLUDE_DIR TBB::tbb INTERFACE_INCLUDE_DIRECTORIES) + if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR) + set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the TBB") endif() - endif() -endmacro() - -# TARGET_NAME - is target name from oneTBB cmake file -# it is either "TBB::tbb", or "TBB::tbbmalloc" -# LIB_NAME_UC - is library id (TBB or TBBMALLOC) -# PROPERTY_TO_SET - LIBRARY or DLL -macro (WIN_TBB_PARSE TARGET_NAME LIB_NAME PROPERTY_TO_SET) - set (FILE_NAME "") - set (FILE_PATH "") - set (FILE_DIR "") - - if ("${PROPERTY_TO_SET}" STREQUAL "LIBRARY") - get_target_property (FILE_NAME "${TARGET_NAME}" IMPORTED_IMPLIB_RELEASE) - else() - get_target_property (FILE_NAME "${TARGET_NAME}" IMPORTED_LOCATION_RELEASE) - endif() - - # acquire full path - TBB_FILE_NAME_TO_FILEPATH("${FILE_NAME}" FILE_PATH) - - get_filename_component (FILE_NAME "${FILE_PATH}" NAME) - get_filename_component (FILE_DIR "${FILE_PATH}" DIRECTORY) - - if (NOT EXISTS "${FILE_DIR}/${FILE_NAME}") - set (3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET} "" CACHE FILEPATH "${LIB_NAME} library" FORCE) - set (3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET}_DIR "" CACHE PATH "The directory containing ${LIB_NAME} shared library") - - if ("${PROPERTY_TO_SET}" STREQUAL "LIBRARY") - list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET}_DIR) + if (EXISTS "${TBB_INCLUDE_DIR}") + set (3RDPARTY_TBB_INCLUDE_DIR "${TBB_INCLUDE_DIR}" CACHE PATH "The directory containing headers of the TBB" FORCE) + list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}") else() - list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET}_DIR) + list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR) endif() - else() - set (3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET} "${FILE_DIR}/${FILE_NAME}" CACHE FILEPATH "${LIB_NAME} library" FORCE) - set (3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET}_DIR "${FILE_DIR}" CACHE PATH "The directory containing ${LIB_NAME} shared library") - if ("${PROPERTY_TO_SET}" STREQUAL "LIBRARY") - list (APPEND 3RDPARTY_LIBRARY_DIRS "${FILE_DIR}") + separate_arguments (CSF_TBB) + foreach (LIB IN LISTS CSF_TBB) + string(TOLOWER "${LIB}" LIB_LOWER) + string(TOUPPER "${LIB}" LIB_UPPER) + + # Achive *.lib files and directory containing it. + get_target_property (TBB_LIB_FILE "TBB::${LIB_LOWER}" IMPORTED_IMPLIB_RELEASE) + # Reserve cache variable for *.lib. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_LIBRARY) + set (3RDPARTY_${LIB_UPPER}_LIBRARY "" CACHE FILEPATH "${LIB_UPPER} library (*.lib)") + endif() + # Reserve cache variable for directory containing *.lib file. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_LIBRARY_DIR) + set (3RDPARTY_${LIB_UPPER}_LIBRARY_DIR "" CACHE PATH "The directory containing ${LIB_UPPER} library (*.lib)") + endif() + if (EXISTS "${TBB_LIB_FILE}") + set (3RDPARTY_${LIB_UPPER}_LIBRARY + "${TBB_LIB_FILE}" + CACHE FILEPATH + "${LIB_UPPER} library (*.lib)" + FORCE) + get_filename_component (TBB_LIB_FILE_DIRECTORY "${TBB_LIB_FILE}" DIRECTORY) + set (3RDPARTY_${LIB_UPPER}_LIBRARY_DIR + "${TBB_LIB_FILE_DIRECTORY}" + CACHE PATH + "The directory containing ${LIB_UPPER} library (*.lib)" + FORCE) + list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIB_UPPER}_LIBRARY_DIR}") + else() + list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_${LIB_UPPER}_LIBRARY_DIR) + endif() + + # Achive *.dll files and directory containing it. + get_target_property (TBB_DLL_FILE "TBB::${LIB_LOWER}" IMPORTED_LOCATION_RELEASE) + # Reserve cache variable for *.dll. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_DLL) + set (3RDPARTY_${LIB_UPPER}_DLL "" CACHE FILEPATH "${LIB_UPPER} library (*.dll)") + endif() + # Reserve cache variable for directory containing *.dll file. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_DLL_DIR) + set (3RDPARTY_${LIB_UPPER}_DLL_DIR "" CACHE PATH "The directory containing ${LIB_UPPER} library (*.dll)") + endif() + if (EXISTS "${TBB_DLL_FILE}") + set (3RDPARTY_${LIB_UPPER}_DLL + "${TBB_DLL_FILE}" + CACHE FILEPATH + "${LIB_UPPER} library (*.dll)" + FORCE) + get_filename_component (TBB_DLL_FILE_DIRECTORY "${TBB_DLL_FILE}" DIRECTORY) + set (3RDPARTY_${LIB_UPPER}_DLL_DIR + "${TBB_DLL_FILE_DIRECTORY}" + CACHE PATH + "The directory containing ${LIB_UPPER} library (*.dll)" + FORCE) + list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${LIB_UPPER}_DLL_DIR}") + else() + list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_${LIB_UPPER}_DLL_DIR) + endif() + + # install *.dll (tbb & tbbmalloc) + if (INSTALL_TBB) + OCCT_MAKE_OS_WITH_BITNESS() + OCCT_MAKE_COMPILER_SHORT_NAME() + + if (SINGLE_GENERATOR) + install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} DESTINATION "${INSTALL_DIR_BIN}") + else() + install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS Release DESTINATION "${INSTALL_DIR_BIN}") + install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS RelWithDebInfo DESTINATION "${INSTALL_DIR_BIN}i") + install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS Debug DESTINATION "${INSTALL_DIR_BIN}d") + endif() + endif() + mark_as_advanced (3RDPARTY_${LIB_UPPER}_LIBRARY 3RDPARTY_${LIB_UPPER}_DLL) + endforeach() + if (INSTALL_TBB) + set (USED_3RDPARTY_TBB_DIR "") else() - list (APPEND 3RDPARTY_DLL_DIRS "${FILE_DIR}") + # the *.dll/*.so* directory for using by the executable + set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR}) endif() - endif() -endmacro() - -# TARGET_NAME - is target name from oneTBB cmake file -# it is either "TBB::tbb", or "TBB::tbbmalloc" -# LIB_NAME_UC - is library id (TBB or TBBMALLOC) -macro (LIN_TBB_PARSE TARGET_NAME LIB_NAME) - set (FILE_NAME "") - set (FILE_PATH "") - set (FILE_DIR "") - - get_target_property (FILE_NAME "${TARGET_NAME}" IMPORTED_LOCATION_RELEASE) - - # acquire full path - TBB_FILE_NAME_TO_FILEPATH("${FILE_NAME}" FILE_PATH) - - get_filename_component (FILE_NAME "${FILE_PATH}" NAME) - get_filename_component (FILE_DIR "${FILE_PATH}" DIRECTORY) - - if (NOT EXISTS "${FILE_DIR}/${FILE_NAME}") - set (3RDPARTY_${LIB_NAME}_LIBRARY "" CACHE FILEPATH "${LIB_NAME} library" FORCE) - set (3RDPARTY_${LIB_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${LIB_NAME} shared library") - - list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_${LIB_NAME}_LIBRARY_DIR) else() - set (3RDPARTY_${LIB_NAME}_LIBRARY "${FILE_DIR}/${FILE_NAME}" CACHE FILEPATH "${LIB_NAME} library" FORCE) - set (3RDPARTY_${LIB_NAME}_LIBRARY_DIR "${FILE_DIR}" CACHE PATH "The directory containing ${LIB_NAME} shared library") - - list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIB_NAME}_LIBRARY_DIR}") + message (FATAL_ERROR "Installation directory with TBB is not exist.") endif() -endmacro() +else () + # NOT WIN32 branch + if ((DEFINED 3RDPARTY_DIR) AND (NOT "${3RDPARTY_DIR}" STREQUAL "") AND (EXISTS "${3RDPARTY_DIR}")) + # Here, we have correct 3RDPARTY_DIR. + # Trying to specify TBB folder in connection with 3RDPARTY_DIR + if (("${3RDPARTY_TBB_DIR}" STREQUAL "") OR (NOT EXISTS "${3RDPARTY_TBB_DIR}")) + FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" TBB TBB_DIR_NAME) + if (TBB_DIR_NAME) + set (3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${TBB_DIR_NAME}" CACHE PATH "The directory containing tbb" FORCE) + endif() + endif() + if ((NOT "${3RDPARTY_TBB_DIR}" STREQUAL "") AND (EXISTS "${3RDPARTY_TBB_DIR}")) + # Find TBB 2021.5 in existing directory. + find_package ( + TBB 2021.5 + PATHS "${3RDPARTY_TBB_DIR}" NO_DEFAULT_PATH + REQUIRED + CONFIG) + else() + # Find TBB 2021.5 in system directory. + find_package ( + TBB 2021.5 + REQUIRED + CONFIG) + endif() + else() + # Find TBB 2021.5 in system directory. + find_package ( + TBB 2021.5 + REQUIRED + CONFIG) + endif() + # TBB has been configured (in other case FATAL_ERROR occures). -if (WIN32) - # Here we should set: - # - 3RDPARTY_*_LIBRARY - # - 3RDPARTY_*_LIBRARY_DIR - # - 3RDPARTY_*_DLL - # - 3RDPARTY_*_DLL_DIR - # where * - is TBB or TBBMALLOC + # Achive include directory. + get_target_property (TBB_INCLUDE_DIR TBB::tbb INTERFACE_INCLUDE_DIRECTORIES) + if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR) + set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the TBB") + endif() + if (EXISTS "${TBB_INCLUDE_DIR}") + set (3RDPARTY_TBB_INCLUDE_DIR "${TBB_INCLUDE_DIR}" CACHE PATH "The directory containing headers of the TBB" FORCE) + list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}") + else() + list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR) + endif() separate_arguments (CSF_TBB) foreach (LIB IN LISTS CSF_TBB) string(TOLOWER "${LIB}" LIB_LOWER) string(TOUPPER "${LIB}" LIB_UPPER) - WIN_TBB_PARSE("TBB::${LIB_LOWER}" "${LIB_UPPER}" "LIBRARY") - WIN_TBB_PARSE("TBB::${LIB_LOWER}" "${LIB_UPPER}" "DLL") - endforeach() -else() - # Here we should set: - # - 3RDPARTY_*_LIBRARY - # - 3RDPARTY_*_LIBRARY_DIR - separate_arguments (CSF_TBB) - foreach (LIB IN LISTS CSF_TBB) - string(TOLOWER "${LIB}" LIB_LOWER) - string(TOUPPER "${LIB}" LIB_UPPER) - LIN_TBB_PARSE("TBB::${LIB_LOWER}" "${LIB_UPPER}") - endforeach() -endif() - -# install tbb/tbbmalloc -if (INSTALL_TBB) - OCCT_MAKE_OS_WITH_BITNESS() - OCCT_MAKE_COMPILER_SHORT_NAME() - - if (WIN32) - if (SINGLE_GENERATOR) - foreach (LIB IN LISTS CSF_TBB) - string(TOUPPER "${LIB}" LIB_UPPER) - install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} DESTINATION "${INSTALL_DIR_BIN}") - endforeach() - else() - foreach (LIB IN LISTS CSF_TBB) - string(TOUPPER "${LIB}" LIB_UPPER) - install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS Release DESTINATION "${INSTALL_DIR_BIN}") - install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS RelWithDebInfo DESTINATION "${INSTALL_DIR_BIN}i") - install (FILES ${3RDPARTY_${LIB_UPPER}_DLL} CONFIGURATIONS Debug DESTINATION "${INSTALL_DIR_BIN}d") - endforeach() + # Achive *.so files and directory containing it. + get_target_property (TBB_SO_FILE "TBB::${LIB_LOWER}" IMPORTED_LOCATION_RELEASE) + # Reserve cache variable for *.so. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_LIBRARY) + set (3RDPARTY_${LIB_UPPER}_LIBRARY "" CACHE FILEPATH "${LIB_UPPER} library (*.so)") endif() - else() - if (SINGLE_GENERATOR) - foreach (LIB IN LISTS CSF_TBB) - string(TOUPPER "${LIB}" LIB_UPPER) + # Reserve cache variable for directory containing *.so file. + if (NOT DEFINED 3RDPARTY_${LIB_UPPER}_LIBRARY_DIR) + set (3RDPARTY_${LIB_UPPER}_LIBRARY_DIR "" CACHE PATH "The directory containing ${LIB_UPPER} library (*.so)") + endif() + if (EXISTS "${TBB_SO_FILE}") + set (3RDPARTY_${LIB_UPPER}_LIBRARY + "${TBB_SO_FILE}" + CACHE FILEPATH + "${LIB_UPPER} library (*.so)" + FORCE) + get_filename_component (TBB_SO_FILE_DIRECTORY "${TBB_SO_FILE}" DIRECTORY) + set (3RDPARTY_${LIB_UPPER}_LIBRARY_DIR + "${TBB_SO_FILE_DIRECTORY}" + CACHE PATH + "The directory containing ${LIB_UPPER} library (*.so)" + FORCE) + list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIB_UPPER}_LIBRARY_DIR}") + else() + list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_${LIB_UPPER}_LIBRARY_DIR) + endif() + + # install *.so* (tbb & tbbmalloc) + if (INSTALL_TBB) + OCCT_MAKE_OS_WITH_BITNESS() + OCCT_MAKE_COMPILER_SHORT_NAME() + + if (SINGLE_GENERATOR) install (FILES ${3RDPARTY_${LIB_UPPER}_LIBRARY} DESTINATION "${INSTALL_DIR_LIB}") - endforeach() - else() - foreach (LIB IN LISTS CSF_TBB) - string(TOUPPER "${LIB}" LIB_UPPER) + else() install (FILES ${3RDPARTY_${LIB_UPPER}_LIBRARY} CONFIGURATIONS Release DESTINATION "${INSTALL_DIR_LIB}") install (FILES ${3RDPARTY_${LIB_UPPER}_LIBRARY} CONFIGURATIONS RelWithDebInfo DESTINATION "${INSTALL_DIR_LIB}i") install (FILES ${3RDPARTY_${LIB_UPPER}_LIBRARY} CONFIGURATIONS Debug DESTINATION "${INSTALL_DIR_LIB}d") - endforeach() + endif() endif() - endif() -endif() -foreach (LIB IN LISTS CSF_TBB) - string(TOUPPER "${LIB}" LIB_UPPER) - mark_as_advanced (3RDPARTY_${LIB_UPPER}_LIBRARY 3RDPARTY_${LIB_UPPER}_DLL) -endforeach() - -if (INSTALL_TBB) - set (USED_3RDPARTY_TBB_DIR "") -else() - # the library directory for using by the executable - if (WIN32) - set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR}) + endforeach() + if (INSTALL_TBB) + set (USED_3RDPARTY_TBB_DIR "") else() + # the *.so* directory for using by the executable set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR}) endif() endif() diff --git a/dox/user_guides/foundation_classes/foundation_classes.md b/dox/user_guides/foundation_classes/foundation_classes.md index 75ee0e41db..83ac31168b 100644 --- a/dox/user_guides/foundation_classes/foundation_classes.md +++ b/dox/user_guides/foundation_classes/foundation_classes.md @@ -1331,7 +1331,7 @@ Therefore if the user of *NCollection* does not specify any allocator as a param Nevertheless, it is possible to define a custom *Allocator* type to manage the memory in the most optimal or convenient way for this algorithm. As one possible choice, the class *NCollection_IncAllocator* is included. -Unlike *NCollection_BaseAllocator*, the memory is allocated in big blocks (about 20kB) and the allocator keeps track of the amount of occupied memory. +Unlike *NCollection_BaseAllocator*, the memory is allocated in big blocks (about 12kB) and the allocator keeps track of the amount of occupied memory. The method *Allocate* just increments the pointer to non-occupied memory and returns its previous value. Memory is only released in the destructor of *NCollection_IncAllocator*, the method *Free* is empty. If used properly, this Allocator can greatly improve the performance of specific algorithms. diff --git a/samples/qt/Interface/src/Translate.cxx b/samples/qt/Interface/src/Translate.cxx index b27b89fcce..88d424ad4a 100755 --- a/samples/qt/Interface/src/Translate.cxx +++ b/samples/qt/Interface/src/Translate.cxx @@ -221,7 +221,7 @@ Handle(TopTools_HSequenceOfShape) Translate::importModel( const int format, cons shapes = importSTEP( file ); break; } - } catch ( Standard_Failure ) { + } catch ( const Standard_Failure& ) { shapes.Nullify(); } return shapes; @@ -256,7 +256,7 @@ bool Translate::exportModel( const int format, const QString& file, const Handle case FormatSTL: return exportSTL ( file, shapes ); case FormatVRML: return exportVRML( file, shapes ); } - } catch ( Standard_Failure ) { + } catch ( const Standard_Failure& ) { // } return false; @@ -528,26 +528,26 @@ bool Translate::exportSTL( const QString& file, const Handle(TopTools_HSequenceO if ( shapes.IsNull() || shapes->IsEmpty() ) return false; - TopoDS_Compound res; - BRep_Builder builder; - builder.MakeCompound( res ); + TopoDS_Compound res; + BRep_Builder builder; + builder.MakeCompound( res ); - for ( int i = 1; i <= shapes->Length(); i++ ) - { - TopoDS_Shape shape = shapes->Value( i ); - if ( shape.IsNull() ) - { - myInfo = QObject::tr( "INF_TRANSLATE_ERROR_INVALIDSHAPE" ); - return false; + for ( int i = 1; i <= shapes->Length(); i++ ) + { + TopoDS_Shape shape = shapes->Value( i ); + if ( shape.IsNull() ) + { + myInfo = QObject::tr( "INF_TRANSLATE_ERROR_INVALIDSHAPE" ); + return false; } - builder.Add( res, shape ); - } + builder.Add( res, shape ); + } - StlAPI_Writer writer; - - const TCollection_AsciiString anUtf8Path (file.toUtf8().data()); - - writer.Write( res, anUtf8Path.ToCString() ); + StlAPI_Writer writer; + + const TCollection_AsciiString anUtf8Path (file.toUtf8().data()); + + writer.Write( res, anUtf8Path.ToCString() ); return true; } @@ -557,26 +557,26 @@ bool Translate::exportVRML( const QString& file, const Handle(TopTools_HSequence if ( shapes.IsNull() || shapes->IsEmpty() ) return false; - TopoDS_Compound res; - BRep_Builder builder; - builder.MakeCompound( res ); + TopoDS_Compound res; + BRep_Builder builder; + builder.MakeCompound( res ); - for ( int i = 1; i <= shapes->Length(); i++ ) - { - TopoDS_Shape shape = shapes->Value( i ); - if ( shape.IsNull() ) - { - myInfo = QObject::tr( "INF_TRANSLATE_ERROR_INVALIDSHAPE" ); - return false; + for ( int i = 1; i <= shapes->Length(); i++ ) + { + TopoDS_Shape shape = shapes->Value( i ); + if ( shape.IsNull() ) + { + myInfo = QObject::tr( "INF_TRANSLATE_ERROR_INVALIDSHAPE" ); + return false; } - builder.Add( res, shape ); - } + builder.Add( res, shape ); + } - VrmlAPI_Writer writer; - - const TCollection_AsciiString anUtf8Path (file.toUtf8().data()); - - writer.Write( res, anUtf8Path.ToCString() ); + VrmlAPI_Writer writer; + + const TCollection_AsciiString anUtf8Path (file.toUtf8().data()); + + writer.Write( res, anUtf8Path.ToCString() ); return true; } diff --git a/src/BRepFill/BRepFill_Sweep.cxx b/src/BRepFill/BRepFill_Sweep.cxx index 1be188dd79..e6a1e238b8 100644 --- a/src/BRepFill/BRepFill_Sweep.cxx +++ b/src/BRepFill/BRepFill_Sweep.cxx @@ -3002,7 +3002,7 @@ void BRepFill_Sweep::Build(TopTools_MapOfShape& ReversedEdges, } } - if (aNbFaces == 0) + if ((NbTrous > 0) ? (aNbFaces < NbLaw) : (aNbFaces == 0)) { isDone = Standard_False; return; diff --git a/src/BRepMesh/BRepMesh_CurveTessellator.cxx b/src/BRepMesh/BRepMesh_CurveTessellator.cxx index fbb1b47305..3779a52425 100644 --- a/src/BRepMesh/BRepMesh_CurveTessellator.cxx +++ b/src/BRepMesh/BRepMesh_CurveTessellator.cxx @@ -35,11 +35,13 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_CurveTessellator, IMeshTools_CurveTessellato //======================================================================= BRepMesh_CurveTessellator::BRepMesh_CurveTessellator( const IMeshData::IEdgeHandle& theEdge, - const IMeshTools_Parameters& theParameters) + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb) : myDEdge(theEdge), myParameters(theParameters), myEdge(theEdge->GetEdge()), - myCurve(myEdge) + myCurve(myEdge), + myMinPointsNb (theMinPointsNb) { init(); } @@ -52,11 +54,13 @@ BRepMesh_CurveTessellator::BRepMesh_CurveTessellator ( const IMeshData::IEdgeHandle& theEdge, const TopAbs_Orientation theOrientation, const IMeshData::IFaceHandle& theFace, - const IMeshTools_Parameters& theParameters) + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb) : myDEdge(theEdge), myParameters(theParameters), myEdge(TopoDS::Edge(theEdge->GetEdge().Oriented(theOrientation))), - myCurve(myEdge, theFace->GetFace()) + myCurve(myEdge, theFace->GetFace()), + myMinPointsNb (theMinPointsNb) { init(); } @@ -97,7 +101,8 @@ void BRepMesh_CurveTessellator::init() myEdgeSqTol = BRep_Tool::Tolerance (myEdge); myEdgeSqTol *= myEdgeSqTol; - const Standard_Integer aMinPntNb = (myCurve.GetType() == GeomAbs_Circle) ? 4 : 2; //OCC287 + const Standard_Integer aMinPntNb = Max(myMinPointsNb, + (myCurve.GetType() == GeomAbs_Circle) ? 4 : 2); //OCC287 myDiscretTool.Initialize (myCurve, myCurve.FirstParameter(), myCurve.LastParameter(), diff --git a/src/BRepMesh/BRepMesh_CurveTessellator.hxx b/src/BRepMesh/BRepMesh_CurveTessellator.hxx index ddf3bcfa52..d9406a8423 100644 --- a/src/BRepMesh/BRepMesh_CurveTessellator.hxx +++ b/src/BRepMesh/BRepMesh_CurveTessellator.hxx @@ -34,14 +34,16 @@ public: //! Constructor. Standard_EXPORT BRepMesh_CurveTessellator( const IMeshData::IEdgeHandle& theEdge, - const IMeshTools_Parameters& theParameters); + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb = 2); //! Constructor. Standard_EXPORT BRepMesh_CurveTessellator ( const IMeshData::IEdgeHandle& theEdge, const TopAbs_Orientation theOrientation, const IMeshData::IFaceHandle& theFace, - const IMeshTools_Parameters& theParameters); + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb = 2); //! Destructor. Standard_EXPORT virtual ~BRepMesh_CurveTessellator (); @@ -96,6 +98,7 @@ private: const IMeshTools_Parameters& myParameters; TopoDS_Edge myEdge; BRepAdaptor_Curve myCurve; + Standard_Integer myMinPointsNb; GCPnts_TangentialDeflection myDiscretTool; TopoDS_Vertex myFirstVertex; TopoDS_Vertex myLastVertex; diff --git a/src/BRepMesh/BRepMesh_EdgeDiscret.cxx b/src/BRepMesh/BRepMesh_EdgeDiscret.cxx index a68165a291..31c7963c59 100644 --- a/src/BRepMesh/BRepMesh_EdgeDiscret.cxx +++ b/src/BRepMesh/BRepMesh_EdgeDiscret.cxx @@ -49,9 +49,10 @@ BRepMesh_EdgeDiscret::~BRepMesh_EdgeDiscret () //======================================================================= Handle(IMeshTools_CurveTessellator) BRepMesh_EdgeDiscret::CreateEdgeTessellator( const IMeshData::IEdgeHandle& theDEdge, - const IMeshTools_Parameters& theParameters) + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb) { - return new BRepMesh_CurveTessellator(theDEdge, theParameters); + return new BRepMesh_CurveTessellator(theDEdge, theParameters, theMinPointsNb); } //======================================================================= @@ -62,11 +63,12 @@ Handle(IMeshTools_CurveTessellator) BRepMesh_EdgeDiscret::CreateEdgeTessellator( const IMeshData::IEdgeHandle& theDEdge, const TopAbs_Orientation theOrientation, const IMeshData::IFaceHandle& theDFace, - const IMeshTools_Parameters& theParameters) + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb) { return theDEdge->GetSameParam() ? - new BRepMesh_CurveTessellator(theDEdge, theParameters) : - new BRepMesh_CurveTessellator(theDEdge, theOrientation, theDFace, theParameters); + new BRepMesh_CurveTessellator(theDEdge, theParameters, theMinPointsNb) : + new BRepMesh_CurveTessellator(theDEdge, theOrientation, theDFace, theParameters, theMinPointsNb); } //======================================================================= diff --git a/src/BRepMesh/BRepMesh_EdgeDiscret.hxx b/src/BRepMesh/BRepMesh_EdgeDiscret.hxx index c8db5ec342..89b67eda39 100644 --- a/src/BRepMesh/BRepMesh_EdgeDiscret.hxx +++ b/src/BRepMesh/BRepMesh_EdgeDiscret.hxx @@ -38,14 +38,16 @@ public: //! Creates instance of free edge tessellator. Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellator( const IMeshData::IEdgeHandle& theDEdge, - const IMeshTools_Parameters& theParameters); + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb = 2); //! Creates instance of edge tessellator. Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellator( const IMeshData::IEdgeHandle& theDEdge, const TopAbs_Orientation theOrientation, const IMeshData::IFaceHandle& theDFace, - const IMeshTools_Parameters& theParameters); + const IMeshTools_Parameters& theParameters, + const Standard_Integer theMinPointsNb = 2); //! Creates instance of tessellation extractor. Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellationExtractor( diff --git a/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx b/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx index ce7cb6fba9..917645f823 100644 --- a/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx +++ b/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx @@ -73,27 +73,37 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo( switch (theSurfaceType) { case GeomAbs_Plane: - return theParameters.InternalVerticesMode ? - new NodeInsertionMeshAlgo::Type : - new BaseMeshAlgo::Type; + return theParameters.EnableControlSurfaceDeflectionAllSurfaces ? + new DeflectionControlMeshAlgo::Type : + (theParameters.InternalVerticesMode ? + new NodeInsertionMeshAlgo::Type : + new BaseMeshAlgo::Type); break; case GeomAbs_Sphere: - return new NodeInsertionMeshAlgo::Type; + return theParameters.EnableControlSurfaceDeflectionAllSurfaces ? + new DeflectionControlMeshAlgo::Type : + new NodeInsertionMeshAlgo::Type; break; case GeomAbs_Cylinder: - return theParameters.InternalVerticesMode ? - new NodeInsertionMeshAlgo::Type : - new BaseMeshAlgo::Type; + return theParameters.EnableControlSurfaceDeflectionAllSurfaces ? + new DeflectionControlMeshAlgo::Type : + (theParameters.InternalVerticesMode ? + new NodeInsertionMeshAlgo::Type : + new BaseMeshAlgo::Type); break; case GeomAbs_Cone: - return new NodeInsertionMeshAlgo::Type; + return theParameters.EnableControlSurfaceDeflectionAllSurfaces ? + new DeflectionControlMeshAlgo::Type : + new NodeInsertionMeshAlgo::Type; break; case GeomAbs_Torus: - return new NodeInsertionMeshAlgo::Type; + return theParameters.EnableControlSurfaceDeflectionAllSurfaces ? + new DeflectionControlMeshAlgo::Type : + new NodeInsertionMeshAlgo::Type; break; case GeomAbs_SurfaceOfRevolution: diff --git a/src/BRepMesh/BRepMesh_ModelHealer.cxx b/src/BRepMesh/BRepMesh_ModelHealer.cxx index def938d41a..4c2eed209a 100644 --- a/src/BRepMesh/BRepMesh_ModelHealer.cxx +++ b/src/BRepMesh/BRepMesh_ModelHealer.cxx @@ -50,14 +50,32 @@ namespace void operator()(const IMeshData::IEdgePtr& theDEdge) const { const IMeshData::IEdgeHandle aDEdge = theDEdge; + + Standard_Integer aPointsNb = aDEdge->GetCurve()->ParametersNb(); + aDEdge->Clear(Standard_True); aDEdge->SetDeflection(Max(aDEdge->GetDeflection() / 3., Precision::Confusion())); + for (Standard_Integer aPCurveIt = 0; aPCurveIt < aDEdge->PCurvesNb(); ++aPCurveIt) + { + const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(aPCurveIt); + const IMeshData::IFaceHandle aDFace = aPCurve->GetFace(); + + // Check that outer wire contains 2 edges or less and add an additional point. + const IMeshData::IWireHandle& aDWire = aDFace->GetWire(0); + if (aDWire->EdgesNb() <= 2) + { + ++aPointsNb; + break; + } + } + const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(0); const IMeshData::IFaceHandle aDFace = aPCurve->GetFace(); Handle(IMeshTools_CurveTessellator) aTessellator = BRepMesh_EdgeDiscret::CreateEdgeTessellator( - aDEdge, aPCurve->GetOrientation(), aDFace, myParameters); + aDEdge, aPCurve->GetOrientation(), aDFace, + myParameters, aPointsNb); BRepMesh_EdgeDiscret::Tessellate3d(aDEdge, aTessellator, Standard_False); BRepMesh_EdgeDiscret::Tessellate2d(aDEdge, Standard_False); diff --git a/src/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx b/src/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx index d0cb22ea67..0f78d5e924 100644 --- a/src/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx +++ b/src/BRepMesh/BRepMesh_NURBSRangeSplitter.cxx @@ -556,7 +556,7 @@ Handle(IMeshData::SequenceOfReal) BRepMesh_NURBSRangeSplitter::computeGrainAndFi const Handle(BRepAdaptor_Surface)& aSurface = GetSurface(); const Standard_Real aMinSize2d = Max( aSurface->UResolution(theParameters.MinSize), - aSurface->UResolution(theParameters.MinSize)); + aSurface->VResolution(theParameters.MinSize)); aMinDiff = Max(aMinSize2d, aMinDiff); diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 6d2d01b0c8..be2af6c330 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -64,19 +64,18 @@ public: //! given transformation to this box. BVH_Box Transformed (const NCollection_Mat4& theTransform) const { - BVH_Box aResultBox; - + const BVH_Box *aThis = static_cast*>(this); if (theTransform.IsIdentity()) { - return aResultBox; + return *aThis; } - const BVH_Box *aThis = static_cast*>(this); if (!aThis->IsValid()) { - return aResultBox; + return *aThis; } + BVH_Box aResultBox; for (size_t aX = 0; aX <= 1; ++aX) { for (size_t aY = 0; aY <= 1; ++aY) diff --git a/src/Draft/Draft_Modification_1.cxx b/src/Draft/Draft_Modification_1.cxx index 778ad7dd83..108bf46e15 100644 --- a/src/Draft/Draft_Modification_1.cxx +++ b/src/Draft/Draft_Modification_1.cxx @@ -481,7 +481,7 @@ Standard_Boolean Draft_Modification::Propagate () Handle(Geom_Surface)::DownCast(S->Transformed(L.Transformation())); const Handle(Standard_Type)& typs = S->DynamicType(); - if (typs == STANDARD_TYPE(Geom_CylindricalSurface) || + if (/*typs == STANDARD_TYPE(Geom_CylindricalSurface) ||*/ typs == STANDARD_TYPE(Geom_ConicalSurface)) { Standard_Real umin,umax,vmin,vmax; BRepTools::UVBounds(F,umin,umax,vmin,vmax); diff --git a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index eea5ae45c9..62eb29784e 100644 --- a/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -502,16 +502,7 @@ GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const MajorRadius = aLin.Distance(aLC); if(MajorRadius > aR) { - Standard_Real aT = 0., aDx, dX; - gp_Pnt aPx; - - aPx = ElCLib::Value(aT, C); - aDx = aLin.Distance(aPx); - dX = aDx - MajorRadius - aR; - if (dX < 0.) - dX = -dX; - if (dX < TolConf) - return GeomAbs_Torus; + return GeomAbs_Torus; } } break; diff --git a/src/IFSelect/IFSelect_Functions.cxx b/src/IFSelect/IFSelect_Functions.cxx index 4a89cb7a9b..c044591316 100644 --- a/src/IFSelect/IFSelect_Functions.cxx +++ b/src/IFSelect/IFSelect_Functions.cxx @@ -839,14 +839,38 @@ static IFSelect_ReturnStatus fun27 Standard_Integer argc = pilot->NbWords(); Handle(IFSelect_WorkSession) WS = pilot->Session(); const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); + Standard_CString arg2 = pilot->Arg(2); + const Standard_CString anEmptyStr = ""; + if (arg2 && strlen(arg2) == 2 && arg2[0] == '"' && arg2[1] == '"') + { + arg2 = anEmptyStr; + } // **** Param(Value) **** Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { + if (argc < 2 || (argc == 3 && strcmp (arg1, "-p") == 0)) { Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items(); - Standard_Integer i,nb = li->Length(); - sout<<" List of parameters : "<Length(), aPatternNb = 0; + size_t aPatternLen = strlen(arg2); + if (argc == 3) + { + for (i = 1; i <= nb; i ++) + { + if (strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) == 0) + { + aPatternNb++; + } + } + } + else + { + aPatternNb = nb; + } + sout << " List of parameters : " << aPatternNb << " items : " << std::endl; for (i = 1; i <= nb; i ++) { + if (argc == 3 && strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) != 0) + { + continue; + } sout<Value(i)->String(); sout<<" : "<Value(i)->ToCString())<Vertex(aVertexNumber); - const Standard_Real aNewVertexParam = aLinOn2S->NbPoints() + 1; + Standard_Real aNewVertexParam = aLinOn2S->NbPoints() + 1; + Standard_Integer aNbPointsPrev = aLinOn2S->NbPoints(); //ATTENTION!!! // IsPoleOrSeam inserts new point in aLinOn2S if aVtx respects @@ -748,6 +749,7 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, aPrePointExist = IsPoleOrSeam(myS1, myS2, aPrefIso, aLinOn2S, aVtx, anArrPeriods, aTol, aSingularSurfaceID); + if (aPrePointExist == IntPatch_SPntPole || aPrePointExist == IntPatch_SPntPoleSeamU) { @@ -761,6 +763,11 @@ void IntPatch_ALineToWLine::MakeWLine(const Handle(IntPatch_ALine)& theALine, const Standard_Real aCurVertParam = aVtx.ParameterOnLine(); if(aPrePointExist != IntPatch_SPntNone) { + if (aNbPointsPrev == aLinOn2S->NbPoints()) + { + //Vertex coinsides any point of line and was not added into line + aNewVertexParam = aNbPointsPrev; + } aPrevParam = aParameter = aCurVertParam; } else diff --git a/src/IntStart/IntStart_SearchOnBoundaries.gxx b/src/IntStart/IntStart_SearchOnBoundaries.gxx index 8c013fbce1..59bac00346 100644 --- a/src/IntStart/IntStart_SearchOnBoundaries.gxx +++ b/src/IntStart/IntStart_SearchOnBoundaries.gxx @@ -354,6 +354,7 @@ void BoundedArc (const TheArc& A, { const IntSurf_Quadric& aQuadric = Func.Quadric(); GeomAbs_SurfaceType TypeQuad = aQuadric.TypeQuadric(); + GeomAbs_CurveType TypeConS = GeomAbs_OtherCurve; IntCurveSurface_HInter IntCS; Standard_Boolean IsIntCSdone = Standard_False; @@ -387,7 +388,7 @@ void BoundedArc (const TheArc& A, //Exact solution Handle(Adaptor3d_Surface) aSurf = Func.Surface(); Adaptor3d_CurveOnSurface ConS(A, aSurf); - GeomAbs_CurveType TypeConS = ConS.GetType(); + TypeConS = ConS.GetType(); #ifdef OCCT_DEBUG Handle(Geom_Curve) CurveConS; switch(TypeConS) @@ -608,13 +609,27 @@ void BoundedArc (const TheArc& A, para = aSI(i).Value(); Standard_Real param=(para+parap1)*0.5; - Standard_Real ym; - if(Func.Value(param,ym)) { - if(Abs(ym) 0.001) @@ -627,6 +642,7 @@ void BoundedArc (const TheArc& A, Standard_Integer aNbNodes = RealToInt(Ceiling((parap1 - para)/aTol)); Standard_Real aVal = RealLast(); + Standard_Real aValMax = 0.; //Standard_Integer aNbNodes = 23; Standard_Real aDelta = (parap1 - para)/(aNbNodes + 1.); Standard_Integer ii; @@ -637,17 +653,29 @@ void BoundedArc (const TheArc& A, aCurPar = (ii < aNbNodes + 1) ? para + ii*aDelta : parap1; if (Func.Value(aCurPar, aCurVal)) { - //if (aCurVal < aVal) { - if (Abs(aCurVal) < aVal) { - //aVal = aCurVal; - aVal = Abs(aCurVal); + Standard_Real anAbsVal = Abs(aCurVal); + if (anAbsVal < aVal) { + aVal = anAbsVal; param = aCurPar; } + if (anAbsVal > aValMax) + { + aValMax = anAbsVal; + } } } - // Modified by skv - Tue Aug 31 12:13:51 2004 OCC569 End - aSI(i).ChangeValue() = Pdeb - 1; - aSI(i + 1).ChangeValue() = param; + // At last, interval got by exact intersection can be considered as tangent if + // minimal distance is inside interval and + // minimal and maximal values are almost the same + if (IsIntCSdone && aNbNodes > 1) { + aTang = Abs(param - para) > EpsX && Abs(parap1 - param) > EpsX && + 0.01*aValMax <= aVal; + } + if (aTang) + { + aSI(i).ChangeValue() = Pdeb - 1; + aSI(i + 1).ChangeValue() = param; + } } } } diff --git a/src/IntWalk/IntWalk_PWalking.cxx b/src/IntWalk/IntWalk_PWalking.cxx index 464e42f876..bc32b6a9ed 100644 --- a/src/IntWalk/IntWalk_PWalking.cxx +++ b/src/IntWalk/IntWalk_PWalking.cxx @@ -1694,6 +1694,20 @@ void IntWalk_PWalking::Perform(const TColStd_Array1OfReal& ParDep, Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsoparametric theChoixIso, const Standard_Boolean theDirectionFlag) { + // Caro1 and Caro2 + const Handle(Adaptor3d_Surface)& Caro1 = myIntersectionOn2S.Function().AuxillarSurface1(); + const Handle(Adaptor3d_Surface)& Caro2 = myIntersectionOn2S.Function().AuxillarSurface2(); + // + const Standard_Real UFirst1 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro1); + const Standard_Real VFirst1 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro1); + const Standard_Real ULast1 = Adaptor3d_HSurfaceTool::LastUParameter(Caro1); + const Standard_Real VLast1 = Adaptor3d_HSurfaceTool::LastVParameter(Caro1); + + const Standard_Real UFirst2 = Adaptor3d_HSurfaceTool::FirstUParameter(Caro2); + const Standard_Real VFirst2 = Adaptor3d_HSurfaceTool::FirstVParameter(Caro2); + const Standard_Real ULast2 = Adaptor3d_HSurfaceTool::LastUParameter(Caro2); + const Standard_Real VLast2 = Adaptor3d_HSurfaceTool::LastVParameter(Caro2); + Standard_Boolean bOutOfTangentZone = Standard_False; Standard_Boolean bStop = !myIntersectionOn2S.IsTangent(); Standard_Integer dIncKey = 1; @@ -1705,6 +1719,42 @@ Standard_Boolean IntWalk_PWalking::ExtendLineInCommonZone(const IntImp_ConstIsop Standard_Integer uvit = 0; IntSurf_SequenceOfPntOn2S aSeqOfNewPoint; + previousPoint.Parameters(Param(1), Param(2), Param(3), Param(4)); + + if (Param(1) - UFirst1 < ResoU1) + { + return bOutOfTangentZone; + } + else if (Param(2) - VFirst1 < ResoV1) + { + return bOutOfTangentZone; + } + else if (Param(3) - UFirst2 < ResoU2) + { + return bOutOfTangentZone; + } + else if (Param(4) - VFirst2 < ResoV2) + { + return bOutOfTangentZone; + } + + if (Param(1) - ULast1 > -ResoU1) + { + return bOutOfTangentZone; + } + else if (Param(2) - VLast1 > -ResoV1) + { + return bOutOfTangentZone; + } + else if (Param(3) - ULast2 > -ResoU2) + { + return bOutOfTangentZone; + } + else if (Param(4) - VLast2 > -ResoV2) + { + return bOutOfTangentZone; + } + while (!bStop) { nbIterWithoutAppend++; diff --git a/src/Interface/Interface_Static.cxx b/src/Interface/Interface_Static.cxx index cbed11b7ba..afa597d56e 100644 --- a/src/Interface/Interface_Static.cxx +++ b/src/Interface/Interface_Static.cxx @@ -407,3 +407,29 @@ Handle(TColStd_HSequenceOfHAsciiString) Interface_Static::Items } return list; } + +//======================================================================= +// function : FillMap +// purpose : Fills given string-to-string map with all static data +//======================================================================= +void Interface_Static::FillMap (NCollection_DataMap& theMap) +{ + theMap.Clear(); + + NCollection_DataMap& aMap = MoniTool_TypedValue::Stats(); + + for (NCollection_DataMap::Iterator anIt(aMap); anIt.More(); anIt.Next()) + { + Handle(Interface_Static) aValue = Handle(Interface_Static)::DownCast(anIt.Value()); + if (aValue.IsNull()) + { + continue; + } + if (aValue->HStringValue().IsNull()) + { + continue; + } + + theMap.Bind (anIt.Key(), aValue->HStringValue()->String()); + } +} diff --git a/src/Interface/Interface_Static.hxx b/src/Interface/Interface_Static.hxx index 8c001e018f..7069c5f361 100644 --- a/src/Interface/Interface_Static.hxx +++ b/src/Interface/Interface_Static.hxx @@ -245,8 +245,8 @@ public: //! must be defined around it Standard_EXPORT static void Standards(); - - + //! Fills given string-to-string map with all static data + Standard_EXPORT static void FillMap(NCollection_DataMap& theMap); DEFINE_STANDARD_RTTIEXT(Interface_Static,Interface_TypedValue) diff --git a/src/MeshTest/MeshTest.cxx b/src/MeshTest/MeshTest.cxx index 351b51379c..4c165a8822 100644 --- a/src/MeshTest/MeshTest.cxx +++ b/src/MeshTest/MeshTest.cxx @@ -116,6 +116,10 @@ static Standard_Integer incrementalmesh (Draw_Interpretor& theDI, { aMeshParams.ControlSurfaceDeflection = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); } + else if (aNameCase == "-surf_def_all") + { + aMeshParams.EnableControlSurfaceDeflectionAllSurfaces = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } else if (aNameCase == "-adjust_min") { aMeshParams.AdjustMinSize = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter); @@ -1620,6 +1624,8 @@ void MeshTest::Commands(Draw_Interpretor& theCommands) "\n\t\t: -ai angular deflection inside of faces in deg (~57.29 deg = 1 rad by default);" "\n\t\t: -int_vert_off disables insertion of internal vertices into mesh (enabled by default);" "\n\t\t: -surf_def_off disables control of deflection of mesh from real surface (enabled by default);" + "\n\t\t: -surf_def_all enables control of deflection of mesh from real surface for all types of surfaces" + "\n\t\t: (FALSE by default);" "\n\t\t: -adjust_min enables local adjustment of min size depending on edge size (FALSE by default);" "\n\t\t: -force_face_def disables usage of shape tolerances for computing face deflection (FALSE by default);" "\n\t\t: -decrease enforces the meshing of the shape even if current mesh satisfies the new criteria" diff --git a/src/NCollection/NCollection_IncAllocator.hxx b/src/NCollection/NCollection_IncAllocator.hxx index 08e4219f0b..7dfe560af5 100644 --- a/src/NCollection/NCollection_IncAllocator.hxx +++ b/src/NCollection/NCollection_IncAllocator.hxx @@ -33,7 +33,12 @@ class Standard_Mutex; * type "aligned_t". To modify the size of memory blocks requested from the * OS, use the parameter of the constructor (measured in bytes); if this * parameter is smaller than 25 bytes on 32bit or 49 bytes on 64bit, the - * block size will be the default 24 kbytes + * block size will be the default 12 kbytes. + * + * It is not recommended to use memory blocks larger than 16KB on Windows + * platform for the repeated operations because Low Fragmentation Heap is + * not going to be used for these allocations which may lead to memory + * fragmentation and the general performance slow down. * * Note that this allocator is most suitable for single-threaded algorithms * (consider creating dedicated allocators per working thread), @@ -50,6 +55,12 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator //! Constructor. //! Note that this constructor does NOT setup mutex for using allocator concurrently from different threads, //! see SetThreadSafe() method. + //! + //! The default size of the memory blocks is 12KB. + //! It is not recommended to use memory blocks larger than 16KB on Windows + //! platform for the repeated operations (and thus multiple allocations) + //! because Low Fragmentation Heap is not going to be used for these allocations, + //! leading to memory fragmentation and eventual performance slow down. Standard_EXPORT NCollection_IncAllocator (size_t theBlockSize = DefaultBlockSize); //! Setup mutex for thread-safe allocations. @@ -83,7 +94,8 @@ class NCollection_IncAllocator : public NCollection_BaseAllocator Standard_EXPORT void Reset (const Standard_Boolean doReleaseMem=Standard_True); - static const size_t DefaultBlockSize = 24600; + //! Default size for the memory blocks - 12KB + static const size_t DefaultBlockSize = 12300; protected: struct IBlock; diff --git a/src/Resource/Resource_Manager.cxx b/src/Resource/Resource_Manager.cxx index 6d94e9aa07..01b8ab443f 100644 --- a/src/Resource/Resource_Manager.cxx +++ b/src/Resource/Resource_Manager.cxx @@ -128,6 +128,16 @@ Resource_Manager::Resource_Manager(const Standard_CString aName, std::cout << "Resource Manager Warning: Environment variable \"CSF_" << aName << "UserDefaults\" not set." << std::endl; } +// ======================================================================= +// function : Resource_Manager +// purpose : +// ======================================================================= +Resource_Manager::Resource_Manager() + : myName(""), myVerbose(Standard_False) +{ + +} + // ======================================================================= // function : Load // purpose : @@ -538,3 +548,12 @@ void Resource_Manager::GetResourcePath (TCollection_AsciiString& aPath, const St anOSDPath.SystemName(aPath); } + +//======================================================================= +// function : GetMap +// purpose : +//======================================================================= +Resource_DataMapOfAsciiStringAsciiString& Resource_Manager::GetMap(Standard_Boolean theRefMap) +{ + return theRefMap ? myRefMap : myUserMap; +} diff --git a/src/Resource/Resource_Manager.hxx b/src/Resource/Resource_Manager.hxx index 7697ad29bd..64bf32abc3 100644 --- a/src/Resource/Resource_Manager.hxx +++ b/src/Resource/Resource_Manager.hxx @@ -54,6 +54,9 @@ public: //! syntax of an individual resource line is: Standard_EXPORT Resource_Manager(const Standard_CString aName, const Standard_Boolean Verbose = Standard_False); + //! Create an empty Resource manager + Standard_EXPORT Resource_Manager(); + //! Create a Resource manager. //! @param theName [in] description file name //! @param theDefaultsDirectory [in] default folder for looking description file @@ -112,6 +115,9 @@ public: //! or file doesn't exist returns empty string. Standard_EXPORT static void GetResourcePath (TCollection_AsciiString& aPath, const Standard_CString aName, const Standard_Boolean isUserDefaults); + //! Returns internal Ref or User map with parameters + Standard_EXPORT Resource_DataMapOfAsciiStringAsciiString& GetMap(Standard_Boolean theRefMap = Standard_True); + private: Standard_EXPORT void Load (const TCollection_AsciiString& thePath, diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 04fc8af7d3..6c2ccfa8b4 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -336,14 +336,22 @@ TCollection_ExtendedString STEPCAFControl_Reader::convertName (const TCollection //======================================================================= //function : ReadFile -//purpose : +//purpose : //======================================================================= - -IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile(const Standard_CString filename) +IFSelect_ReturnStatus STEPCAFControl_Reader::ReadFile (const Standard_CString theFileName) { - return myReader.ReadFile(filename); + return myReader.ReadFile (theFileName); } +//======================================================================= +//function : ReadStream +//purpose : +//======================================================================= +IFSelect_ReturnStatus STEPCAFControl_Reader::ReadStream (const Standard_CString theName, + std::istream& theIStream) +{ + return myReader.ReadStream (theName, theIStream); +} //======================================================================= //function : NbRootsForTransfer diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.hxx b/src/STEPCAFControl/STEPCAFControl_Reader.hxx index a32197d168..1b1ac0c55a 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.hxx @@ -73,11 +73,20 @@ public: //! Clears the internal data structures and attaches to a new session //! Clears the session if it was not yet set for STEP Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); - + //! Loads a file and returns the read status - //! Provided for use like single-file reader - Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename); - + //! Provided for use like single-file reader. + //! @param theFileName [in] file to open + //! @return read status + Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString theFileName); + + //! Loads a file from stream and returns the read status. + //! @param theName [in] auxiliary stream name + //! @param theIStream [in] stream to read from + //! @return read status + Standard_EXPORT IFSelect_ReturnStatus ReadStream (const Standard_CString theName, + std::istream& theIStream); + //! Returns number of roots recognized for transfer //! Shortcut for Reader().NbRootsForTransfer() Standard_EXPORT Standard_Integer NbRootsForTransfer(); diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index b5a617282a..521d043df4 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -302,34 +302,51 @@ void STEPCAFControl_Writer::Init (const Handle(XSControl_WorkSession)& WS, //function : Write //purpose : //======================================================================= - -IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString filename) +IFSelect_ReturnStatus STEPCAFControl_Writer::Write (const Standard_CString theFileName) { - IFSelect_ReturnStatus status = myWriter.Write ( filename ); - - // get directory name of the main file - OSD_Path mainfile ( filename ); - mainfile.SetName ( "" ); - mainfile.SetExtension ( "" ); - TCollection_AsciiString dpath; - mainfile.SystemName ( dpath ); - - NCollection_DataMap::Iterator it(myFiles); - for ( ; it.More(); it.Next() ) { - Handle(STEPCAFControl_ExternFile) EF = it.Value(); - if ( EF->GetWriteStatus() != IFSelect_RetVoid ) continue; - - // construct extern file name - TCollection_AsciiString fname = OSD_Path::AbsolutePath ( dpath, EF->GetName()->String() ); - if ( fname.Length() <= 0 ) fname = EF->GetName()->String(); -#ifdef OCCT_DEBUG - std::cout << "Writing external file: " << fname.ToCString() << std::endl; -#endif - - EF->SetWriteStatus ( EF->GetWS()->SendAll ( fname.ToCString() ) ); + IFSelect_ReturnStatus aStatus = myWriter.Write (theFileName); + if (aStatus != IFSelect_RetDone) + { + return aStatus; } - return status; + // get directory name of the main file + TCollection_AsciiString aDirPath; + { + OSD_Path aMainFile (theFileName); + aMainFile.SetName (""); + aMainFile.SetExtension (""); + aMainFile.SystemName (aDirPath); + } + + for (NCollection_DataMap::Iterator anExtFileIter (myFiles); + anExtFileIter.More(); anExtFileIter.Next()) + { + Handle(STEPCAFControl_ExternFile) anExtFile = anExtFileIter.Value(); + if (anExtFile->GetWriteStatus() != IFSelect_RetVoid) + { + continue; + } + + // construct extern file name + TCollection_AsciiString aFileName = OSD_Path::AbsolutePath (aDirPath, anExtFile->GetName()->String()); + if (aFileName.Length() <= 0) + { + aFileName = anExtFile->GetName()->String(); + } +#ifdef OCCT_DEBUG + std::cout << "Writing external file: " << aFileName << std::endl; +#endif + + const IFSelect_ReturnStatus anExtStatus = anExtFile->GetWS()->SendAll (aFileName.ToCString()); + anExtFile->SetWriteStatus (anExtStatus); + if (anExtStatus != IFSelect_RetDone) + { + aStatus = anExtStatus; + } + } + + return aStatus; } //======================================================================= @@ -352,6 +369,21 @@ void STEPCAFControl_Writer::prepareUnit(const TDF_Label& theLabel, } } +//======================================================================= +//function : WriteStream +//purpose : +//======================================================================= +IFSelect_ReturnStatus STEPCAFControl_Writer::WriteStream (std::ostream& theStream) +{ + if (!myFiles.IsEmpty()) + { + // writing external files is unsupported via stream interface + return IFSelect_RetError; + } + + return myWriter.WriteStream (theStream); +} + //======================================================================= //function : Transfer //purpose : diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.hxx b/src/STEPCAFControl/STEPCAFControl_Writer.hxx index df6a4545d6..ca7f4b5340 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.hxx @@ -70,7 +70,11 @@ public: //! filename will be a name of root file, all other files //! have names of corresponding parts //! Provided for use like single-file writer - Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename); + Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString theFileName); + + //! Writes all the produced models into the stream. + //! Provided for use like single-file writer + Standard_EXPORT IFSelect_ReturnStatus WriteStream (std::ostream& theStream); //! Transfers a document (or single label) to a STEP model //! The mode of translation of shape is AsIs diff --git a/src/STEPControl/STEPControl_ActorWrite.cxx b/src/STEPControl/STEPControl_ActorWrite.cxx index 6b0706c9fe..3caee36941 100644 --- a/src/STEPControl/STEPControl_ActorWrite.cxx +++ b/src/STEPControl/STEPControl_ActorWrite.cxx @@ -1595,8 +1595,10 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferSubShape // SINON, la shape est prise et transferee telle quelle TopoDS_Shape sh0 = shape; gp_Trsf aLoc; + Standard_Boolean isShapeLocated = Standard_False; if ( GroupMode() >0) { TopLoc_Location shloc = shape.Location(); + isShapeLocated = !shloc.IsIdentity(); aLoc = shloc.Transformation(); TopLoc_Location shident; sh0.Location (shident); @@ -1676,7 +1678,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferSubShape myContext.NextIndex(); // abv 16.10.00: bind CDSR (et al) to located shape in order to be able to track instances - if (mapper != start && aLoc.Form() != gp_Identity) { + if (mapper != start && isShapeLocated) { Handle(Transfer_Binder) bnd = FP->Find ( start ); for ( Standard_Integer j=1; j <= roots->Length(); j++ ) if ( bnd.IsNull() ) bnd = TransientResult ( roots->Value(j) ); diff --git a/src/STEPControl/STEPControl_Controller.cxx b/src/STEPControl/STEPControl_Controller.cxx index 2408e2c67a..1970fff87a 100644 --- a/src/STEPControl/STEPControl_Controller.cxx +++ b/src/STEPControl/STEPControl_Controller.cxx @@ -179,12 +179,66 @@ STEPControl_Controller::STEPControl_Controller () Interface_Static::Init ("step","write.step.vertex.mode",'&',"eval One Compound"); Interface_Static::Init ("step","write.step.vertex.mode",'&',"eval Single Vertex"); Interface_Static::SetIVal("write.step.vertex.mode",0); - + // abv 15.11.00: ShapeProcessing - Interface_Static::Init ("XSTEP","write.step.resource.name",'t',"STEP"); - Interface_Static::Init ("XSTEP","read.step.resource.name",'t',"STEP"); - Interface_Static::Init ("XSTEP","write.step.sequence",'t',"ToSTEP"); - Interface_Static::Init ("XSTEP","read.step.sequence",'t',"FromSTEP"); + Interface_Static::Init ("XSTEP", "write.step.resource.name", 't', "STEP"); + Interface_Static::Init ("XSTEP", "read.step.resource.name", 't', "STEP"); + Interface_Static::Init ("XSTEP", "write.step.sequence", 't', "ToSTEP"); + Interface_Static::Init ("XSTEP", "read.step.sequence", 't', "FromSTEP"); + Interface_Static::Init ("XSTEP", "ToSTEP.exec.op", 't', "SplitCommonVertex,DirectFaces"); + Interface_Static::Init ("XSTEP", "FromSTEP.exec.op", 't', "FixShape"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.Tolerance3d", 't', "&Runtime.Tolerance"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.MaxTolerance3d", 't', "&Runtime.MaxTolerance"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.MinTolerance3d", 't', "1.e-7"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixFreeShellMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixFreeFaceMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixFreeWireMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSameParameterMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSolidMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixShellOrientationMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.CreateOpenSolidMode", 't', "0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixShellMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixFaceOrientationMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixFaceMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixWireMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixOrientationMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixAddNaturalBoundMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixMissingSeamMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSmallAreaWireMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.RemoveSmallAreaFaceMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixIntersectingWiresMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixLoopWiresMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSplitFaceMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.AutoCorrectPrecisionMode", 't', "1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.ModifyTopologyMode", 't', "0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.ModifyGeometryMode", 't', "1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.ClosedWireMode", 't', "1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.PreferencePCurveMode", 't', "1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixReorderMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSmallMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixConnectedMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixEdgeCurvesMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixDegeneratedMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixLackingMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSelfIntersectionMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.RemoveLoopMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixReversed2dMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixRemovePCurveMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixRemoveCurve3dMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixAddPCurveMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixAddCurve3dMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSeamMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixShiftedMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixEdgeSameParameterMode", 't', "0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixNotchedEdgesMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixTailMode", 't', "0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.MaxTailAngle", 't', "0.0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.MaxTailWidth", 't', "-1.0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixSelfIntersectingEdgeMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixIntersectingEdgesMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixNonAdjacentIntersectingEdgesMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixVertexPositionMode", 't', "0"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixVertexToleranceMode", 't', "-1"); // ika 28.07.16: Parameter to read all top level solids and shells, // should be used only in case of invalid shape_representation without links to shapes. diff --git a/src/STEPControl/STEPControl_Writer.cxx b/src/STEPControl/STEPControl_Writer.cxx index 5ab4d6bff1..96756267ec 100644 --- a/src/STEPControl/STEPControl_Writer.cxx +++ b/src/STEPControl/STEPControl_Writer.cxx @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -147,14 +150,37 @@ IFSelect_ReturnStatus STEPControl_Writer::Transfer //======================================================================= //function : Write -//purpose : +//purpose : //======================================================================= - -IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString filename) +IFSelect_ReturnStatus STEPControl_Writer::Write (const Standard_CString theFileName) { - return thesession->SendAll(filename); + return thesession->SendAll (theFileName); } +//======================================================================= +//function : WriteStream +//purpose : +//======================================================================= +IFSelect_ReturnStatus STEPControl_Writer::WriteStream (std::ostream& theOStream) +{ + Handle(StepData_StepModel) aModel = Model(); + if (aModel.IsNull()) + { + return IFSelect_RetFail; + } + + Handle(StepData_Protocol) aProtocol = Handle(StepData_Protocol)::DownCast (aModel->Protocol()); + if (aProtocol.IsNull()) + { + return IFSelect_RetFail; + } + + StepData_StepWriter aWriter (aModel); + aWriter.SendModel (aProtocol); + return aWriter.Print (theOStream) + ? IFSelect_RetDone + : IFSelect_RetFail; +} //======================================================================= //function : PrintStatsTransfer diff --git a/src/STEPControl/STEPControl_Writer.hxx b/src/STEPControl/STEPControl_Writer.hxx index 247cd047e6..d179c0f722 100644 --- a/src/STEPControl/STEPControl_Writer.hxx +++ b/src/STEPControl/STEPControl_Writer.hxx @@ -88,10 +88,13 @@ public: const STEPControl_StepModelType mode, const Standard_Boolean compgraph = Standard_True, const Message_ProgressRange& theProgress = Message_ProgressRange()); - + //! Writes a STEP model in the file identified by filename. - Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString filename); - + Standard_EXPORT IFSelect_ReturnStatus Write (const Standard_CString theFileName); + + //! Writes a STEP model in the std::ostream. + Standard_EXPORT IFSelect_ReturnStatus WriteStream (std::ostream& theOStream); + //! Displays the statistics for the //! last translation. what defines the kind of statistics that are displayed: //! - 0 gives general statistics (number of translated roots, diff --git a/src/ShapeAnalysis/ShapeAnalysis.cxx b/src/ShapeAnalysis/ShapeAnalysis.cxx index 6e18ddd42c..5517a17b35 100644 --- a/src/ShapeAnalysis/ShapeAnalysis.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis.cxx @@ -229,36 +229,31 @@ Standard_Boolean ShapeAnalysis::IsOuterBound(const TopoDS_Face& face) } //======================================================================= -//function : OuterBound -//purpose : replacement of bad BRepTools::OuterBound(), to be merged -// - skips internal vertices in face, if any, without exception -// - returns positively oriented wire rather than greater one +//function : OuterWire +//purpose : Returns positively oriented wire in the face. +// If there is no one - returns the last wire of the face. //======================================================================= -TopoDS_Wire ShapeAnalysis::OuterWire(const TopoDS_Face& face) +TopoDS_Wire ShapeAnalysis::OuterWire(const TopoDS_Face& theFace) { - TopoDS_Face F = face; - F.Orientation(TopAbs_FORWARD); + TopoDS_Face aF = theFace; + aF.Orientation (TopAbs_FORWARD); - BRep_Builder B; - TopoDS_Iterator anIt (F, Standard_False); + TopExp_Explorer anIt (aF, TopAbs_WIRE); while (anIt.More()) { - TopoDS_Shape aWire = anIt.Value(); + TopoDS_Wire aWire = TopoDS::Wire (anIt.Value()); anIt.Next(); - // skip possible internal vertices in face - if (aWire.ShapeType() != TopAbs_WIRE) - continue; - // if current wire is the last one, return it without analysis - if (! anIt.More()) - return TopoDS::Wire (aWire); + if (!anIt.More()) + return aWire; - TopoDS_Shape aTestFace = F.EmptyCopied(); - B.Add (aTestFace, aWire); - if (ShapeAnalysis::IsOuterBound (TopoDS::Face (aTestFace))) - return TopoDS::Wire (aWire); + // Check if the wire has positive area + Handle(ShapeExtend_WireData) aSEWD = new ShapeExtend_WireData (aWire); + Standard_Real anArea2d = ShapeAnalysis::TotCross2D (aSEWD, aF); + if (anArea2d >= 0.) + return aWire; } return TopoDS_Wire(); } diff --git a/src/ShapeAnalysis/ShapeAnalysis.hxx b/src/ShapeAnalysis/ShapeAnalysis.hxx index be6f228ab5..fc6bdccdd4 100644 --- a/src/ShapeAnalysis/ShapeAnalysis.hxx +++ b/src/ShapeAnalysis/ShapeAnalysis.hxx @@ -51,12 +51,9 @@ public: DEFINE_STANDARD_ALLOC - //! Returns the outer wire on the face . - //! This is replacement of the method BRepTools::OuterWire - //! until it works badly. - //! Returns the first wire oriented as outer according to - //! FClass2d_Classifier. If none, last wire is returned. - Standard_EXPORT static TopoDS_Wire OuterWire (const TopoDS_Face& face); + //! Returns positively oriented wire in the face. + //! If there is no such wire - returns the last wire of the face. + Standard_EXPORT static TopoDS_Wire OuterWire (const TopoDS_Face& theFace); //! Returns a total area of 2d wire Standard_EXPORT static Standard_Real TotCross2D (const Handle(ShapeExtend_WireData)& sewd, const TopoDS_Face& aFace); diff --git a/src/ShapeFix/ShapeFix_Face.cxx b/src/ShapeFix/ShapeFix_Face.cxx index 20388e08f1..15016761eb 100644 --- a/src/ShapeFix/ShapeFix_Face.cxx +++ b/src/ShapeFix/ShapeFix_Face.cxx @@ -647,11 +647,10 @@ Standard_Boolean ShapeFix_Face::Perform() // fix natural bounds Standard_Boolean NeedSplit = Standard_True; - if ( NeedFix ( myFixAddNaturalBoundMode ) ) { - if ( FixAddNaturalBound() ) { - NeedSplit = Standard_False; - myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 ); - } + if (FixAddNaturalBound()) + { + NeedSplit = Standard_False; + myStatus |= ShapeExtend::EncodeStatus ( ShapeExtend_DONE5 ); } // split face @@ -840,9 +839,11 @@ Standard_Boolean ShapeFix_Face::FixAddNaturalBound() return Standard_True; } - // check if surface is double-closed and fix is needed - if ( !IsSurfaceUVPeriodic (mySurf->Adaptor3d()) || ShapeAnalysis::IsOuterBound (myFace) ) + // check if surface doesn't need natural bounds + if (!isNeedAddNaturalBound(ws)) + { return Standard_False; + } // Collect information on free intervals in U and V TColgp_SequenceOfPnt2d intU, intV, centers; @@ -1002,6 +1003,50 @@ Standard_Boolean ShapeFix_Face::FixOrientation() return FixOrientation(MapWires); } +//======================================================================= +// function : isNeedAddNaturalBound +// purpose : +//======================================================================= +Standard_Boolean ShapeFix_Face::isNeedAddNaturalBound(const TopTools_SequenceOfShape& theOrientedWires) +{ + // if fix is not needed + if (!NeedFix (myFixAddNaturalBoundMode)) + { + return Standard_False; + } + // if surface is not double-closed + if (!IsSurfaceUVPeriodic (mySurf->Adaptor3d())) + { + return Standard_False; + } + // if face has an OUTER bound + if (ShapeAnalysis::IsOuterBound (myFace)) + { + return Standard_False; + } + // check that not any wire has a seam edge and not any edge is degenerated. + // because the presence of a seam or degenerated edge indicates that this wire should be an external one, + // and in case of its incorrect orientation, this will be corrected. + Standard_Integer aNbOriented = theOrientedWires.Length(); + for (Standard_Integer i = 1; i <= aNbOriented; i++) + { + TopoDS_Wire aWire = TopoDS::Wire(theOrientedWires.Value(i)); + for (TopoDS_Iterator anEdgeIt(aWire); anEdgeIt.More(); anEdgeIt.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(anEdgeIt.Value()); + if (BRep_Tool::Degenerated(anEdge)) + { + return Standard_False; + } + if (BRep_Tool::IsClosed(anEdge, myFace)) + { + return Standard_False; + } + } + } + + return Standard_True; +} //======================================================================= //function : FixOrientation @@ -1071,9 +1116,8 @@ Standard_Boolean ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShap // if no wires, just do nothing if ( nb <= 0) return Standard_False; - Standard_Integer nbInternal=0; - Standard_Boolean isAddNaturalBounds = (NeedFix (myFixAddNaturalBoundMode) && IsSurfaceUVPeriodic(mySurf->Adaptor3d())); + Standard_Boolean isAddNaturalBounds = isNeedAddNaturalBound(ws); TColStd_SequenceOfInteger aSeqReversed; // if wire is only one, check its orientation if ( nb == 1 ) { @@ -1084,9 +1128,7 @@ Standard_Boolean ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShap af.Orientation ( TopAbs_FORWARD ); B.Add (af,ws.Value(1)); - if ((myFixAddNaturalBoundMode != 1 || - !IsSurfaceUVPeriodic(mySurf->Adaptor3d())) && - !ShapeAnalysis::IsOuterBound(af)) + if (!isAddNaturalBounds && !ShapeAnalysis::IsOuterBound(af)) { Handle(ShapeExtend_WireData) sbdw = new ShapeExtend_WireData(TopoDS::Wire(ws.Value(1))); @@ -1244,7 +1286,7 @@ Standard_Boolean ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShap if(!(stb==ste)) { sta = TopAbs_UNKNOWN; SI.Bind(aw,0); - j=nb; + j=nbAll; break; } } @@ -1363,11 +1405,9 @@ Standard_Boolean ShapeFix_Face::FixOrientation(TopTools_DataMapOfShapeListOfShap } - //done = (done && (nb ==1 || (isAddNaturalBounds || (!isAddNaturalBounds && nbInternal using namespace tbb; #else diff --git a/src/Standard/Standard_Version.hxx b/src/Standard/Standard_Version.hxx index f09301df8d..da0836c415 100644 --- a/src/Standard/Standard_Version.hxx +++ b/src/Standard/Standard_Version.hxx @@ -34,7 +34,7 @@ // Primary definitions #define OCC_VERSION_MAJOR 7 -#define OCC_VERSION_MINOR 7 +#define OCC_VERSION_MINOR 8 #define OCC_VERSION_MAINTENANCE 0 //! This macro must be commented in official release, and set to non-empty @@ -42,12 +42,12 @@ //! - "dev" for development version between releases //! - "beta..." or "rc..." for beta releases or release candidates //! - "project..." for version containing project-specific fixes -//#define OCC_VERSION_DEVELOPMENT "dev" +#define OCC_VERSION_DEVELOPMENT "dev" // Derived (manually): version as real and string (major.minor) -#define OCC_VERSION 7.7 -#define OCC_VERSION_STRING "7.7" -#define OCC_VERSION_COMPLETE "7.7.0" +#define OCC_VERSION 7.8 +#define OCC_VERSION_STRING "7.8" +#define OCC_VERSION_COMPLETE "7.8.0" //! Derived: extended version as string ("major.minor.maintenance.dev") #ifdef OCC_VERSION_DEVELOPMENT diff --git a/src/TKDraw/EXTERNLIB b/src/TKDraw/EXTERNLIB index 7afca519af..7ca5eec4e5 100755 --- a/src/TKDraw/EXTERNLIB +++ b/src/TKDraw/EXTERNLIB @@ -9,6 +9,7 @@ TKShHealing TKMesh TKService TKHLR +TKTopAlgo CSF_TclLibs CSF_TclTkLibs CSF_XwLibs diff --git a/src/TKOpenGl/CMakeLists.txt b/src/TKOpenGl/CMakeLists.txt index ef9a09b27e..f1dd03f077 100644 --- a/src/TKOpenGl/CMakeLists.txt +++ b/src/TKOpenGl/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKOpenGl) +set (TKOpenGl_DISABLE_COTIRE ON) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKOpenGles/CMakeLists.txt b/src/TKOpenGles/CMakeLists.txt index 097b28b559..fdbd6cb820 100644 --- a/src/TKOpenGles/CMakeLists.txt +++ b/src/TKOpenGles/CMakeLists.txt @@ -1,4 +1,6 @@ project(TKOpenGles) +set (TKOpenGles_DISABLE_COTIRE ON) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) #add_definitions("-DOCCT_OPENGL") diff --git a/src/TKService/CMakeLists.txt b/src/TKService/CMakeLists.txt index 90c6b1e1a6..98599c060e 100644 --- a/src/TKService/CMakeLists.txt +++ b/src/TKService/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKService) +set (TKService_DISABLE_COTIRE ON) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXCAF/CMakeLists.txt b/src/TKXCAF/CMakeLists.txt index 4262ce1bd4..054ee4e5ea 100644 --- a/src/TKXCAF/CMakeLists.txt +++ b/src/TKXCAF/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKXCAF) +set (TKXCAF_DISABLE_COTIRE ON) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXDEDRAW/CMakeLists.txt b/src/TKXDEDRAW/CMakeLists.txt index 918e593cc2..a8348ecea3 100644 --- a/src/TKXDEDRAW/CMakeLists.txt +++ b/src/TKXDEDRAW/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKXDEDRAW) +set (TKXDEDRAW_DISABLE_COTIRE ON) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx index 84bafa4dbb..b226c6f133 100644 --- a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx +++ b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx @@ -416,6 +416,40 @@ void XCAFDoc_ShapeTool::MakeReference (const TDF_Label &L, SetLabelNameByLink(L); } +//======================================================================= +// function : SetLocation +// purpose : +//======================================================================= +Standard_Boolean XCAFDoc_ShapeTool::SetLocation (const TDF_Label& theShapeLabel, + const TopLoc_Location& theLoc, + TDF_Label& theRefLabel) +{ + if (theLoc.IsIdentity()) + { + theRefLabel = theShapeLabel; + return Standard_True; + } + // if input label is reference -> just change the location attribute + if (IsReference (theShapeLabel)) + { + TopLoc_Location anOldLoc; + anOldLoc = GetLocation (theShapeLabel); + TopLoc_Location aNewLoc (theLoc.Transformation() * anOldLoc.Transformation()); + XCAFDoc_Location::Set(theShapeLabel, aNewLoc); + theRefLabel = theShapeLabel; + return Standard_True; + } + // if input label is shape, and it is free -> create reference to the shape + if (IsShape(theShapeLabel) && IsFree(theShapeLabel)) + { + theRefLabel = TDF_TagSource::NewChild (Label()); + MakeReference (theRefLabel, theShapeLabel, theLoc); + return Standard_True; + } + // other cases of label meaning doesn't need to apply new location + return Standard_False; +} + //======================================================================= //function : addShape //purpose : private diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.hxx b/src/XCAFDoc/XCAFDoc_ShapeTool.hxx index 7aca2734a2..100b0f6b10 100644 --- a/src/XCAFDoc/XCAFDoc_ShapeTool.hxx +++ b/src/XCAFDoc/XCAFDoc_ShapeTool.hxx @@ -401,6 +401,15 @@ public: //! from upper_usage component to next_usage //! Returns null attribute if no SHUO found Standard_EXPORT static Standard_Boolean FindSHUO (const TDF_LabelSequence& Labels, Handle(XCAFDoc_GraphNode)& theSHUOAttr); + + //! Sets location to the shape label + //! If label is reference -> changes location attribute + //! If label is free shape -> creates reference with location to it + //! @param[in] theShapeLabel the shape label to change location + //! @param[in] theLoc location to set + //! @param[out] theRefLabel the reference label with new location + //! @return TRUE if new location was set + Standard_EXPORT Standard_Boolean SetLocation (const TDF_Label& theShapeLabel, const TopLoc_Location& theLoc, TDF_Label& theRefLabel); //! Convert Shape (compound/compsolid/shell/wire) to assembly Standard_EXPORT Standard_Boolean Expand (const TDF_Label& Shape); diff --git a/src/XDEDRAW/XDEDRAW_Common.cxx b/src/XDEDRAW/XDEDRAW_Common.cxx index 3da8366312..509e2b7793 100644 --- a/src/XDEDRAW/XDEDRAW_Common.cxx +++ b/src/XDEDRAW/XDEDRAW_Common.cxx @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -375,19 +378,26 @@ static Standard_Integer WriteIges(Draw_Interpretor& di, Standard_Integer argc, c //function : ReadStep //purpose : Read STEP file to DECAF document //======================================================================= - static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); + if (ctl.IsNull()) + { + XSDRAW::SetNorm ("STEP"); + } Standard_CString aDocName = NULL; TCollection_AsciiString aFilePath, aModeStr; + bool toTestStream = false; for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) { TCollection_AsciiString anArgCase(argv[anArgIter]); anArgCase.LowerCase(); - if (aDocName == NULL) + if (anArgCase == "-stream") + { + toTestStream = true; + } + else if (aDocName == NULL) { aDocName = argv[anArgIter]; } @@ -406,26 +416,26 @@ static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, co } } - TCollection_AsciiString fnom, rnom; - Standard_Boolean modfic = XSDRAW::FileAndVar(aFilePath.ToCString(), aDocName, "STEP", fnom, rnom); - if (modfic) di << " File STEP to read : " << fnom.ToCString() << "\n"; - else di << " Model taken from the session : " << fnom.ToCString() << "\n"; + TCollection_AsciiString aFileName, anOldVarName; + Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName, "STEP", aFileName, anOldVarName); + if (isFileMode) di << " File STEP to read : " << aFileName << "\n"; + else di << " Model taken from the session : " << aFileName << "\n"; // di<<" -- Names of variables BREP-DRAW prefixed by : "<Start(), "STEP import", isFileMode ? 2 : 1); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di); - Message_ProgressScope aRootScope(aProgress->Start(), "STEP import", modfic ? 2 : 1); - - IFSelect_ReturnStatus readstat = IFSelect_RetVoid; - if (modfic) + IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid; + if (isFileMode) { - Message_ProgressScope aReadScope(aRootScope.Next(), "File reading", 1); + Message_ProgressScope aReadScope (aRootScope.Next(), "File reading", 1); aReadScope.Show(); - readstat = reader.ReadFile(fnom.ToCString()); + if (toTestStream) + { + std::ifstream aStream; + OSD_OpenStream (aStream, aFileName.ToCString(), std::ios::in | std::ios::binary); + TCollection_AsciiString aFolder, aFileNameShort; + OSD_Path::FolderAndFileFromPath (aFileName, aFolder, aFileNameShort); + aReadStat = aReader.ReadStream (aFileNameShort.ToCString(), aStream); + } + else + { + aReadStat = aReader.ReadFile (aFileName.ToCString()); + } } else if (XSDRAW::Session()->NbStartingEntities() > 0) { - readstat = IFSelect_RetDone; + aReadStat = IFSelect_RetDone; } - if (readstat != IFSelect_RetDone) + if (aReadStat != IFSelect_RetDone) { - if (modfic) + if (isFileMode) { - di << "Could not read file " << fnom << " , abandon\n"; + di << "Could not read file " << aFileName << " , abandon\n"; } else { @@ -462,30 +483,29 @@ static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, co return 1; } - Handle(TDocStd_Document) doc; - if (!DDocStd::GetDocument(aDocName, doc, Standard_False)) + Handle(TDocStd_Document) aDoc; + if (!DDocStd::GetDocument (aDocName, aDoc, Standard_False)) { - Handle(TDocStd_Application) A = DDocStd::GetApplication(); - A->NewDocument("BinXCAF", doc); - TDataStd_Name::Set(doc->GetData()->Root(), aDocName); - Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc); - Draw::Set(aDocName, DD); + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + anApp->NewDocument("BinXCAF", aDoc); + TDataStd_Name::Set (aDoc->GetData()->Root(), aDocName); + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc); + Draw::Set (aDocName, aDrawDoc); // di << "Document saved with name " << aDocName; } - if (!reader.Transfer(doc, aRootScope.Next())) + if (!aReader.Transfer (aDoc, aRootScope.Next())) { di << "Cannot read any relevant data from the STEP file\n"; return 1; } - Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc); - Draw::Set(aDocName, DD); + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc); + Draw::Set (aDocName, aDrawDoc); di << "Document saved with name " << aDocName; - NCollection_DataMap DicFile = reader.ExternFiles(); - FillDicWS(DicFile); - AddWS(fnom, XSDRAW::Session()); - + NCollection_DataMap aDicFile = aReader.ExternFiles(); + FillDicWS (aDicFile); + AddWS (aFileName, XSDRAW::Session()); return 0; } @@ -493,131 +513,182 @@ static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, co //function : WriteStep //purpose : Write DECAF document to STEP //======================================================================= - static Standard_Integer WriteStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if (argc < 3) + DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); + if (ctl.IsNull()) { - di << "Use: " << argv[0] << " Doc filename [mode [multifile_prefix [label]]]: write document to the STEP file\n"; - di << "mode can be: a or 0 : AsIs (default)\n"; - di << " f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel\n"; - di << " m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame\n"; - di << "multifile_prefix: triggers writing assembly components as separate files,\n"; - di << " and defines common prefix for their names\n"; - di << "label: tag of the sub-assembly label to save only that sub-assembly\n"; + XSDRAW::SetNorm ("STEP"); + } + STEPCAFControl_Writer aWriter (XSDRAW::Session(), Standard_True); + + Handle(TDocStd_Document) aDoc; + TCollection_AsciiString aDocName, aFilePath; + STEPControl_StepModelType aMode = STEPControl_AsIs; + bool hasModeArg = false, toTestStream = false; + TCollection_AsciiString aMultiFilePrefix, aLabelName; + TDF_Label aLabel; + for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) + { + TCollection_AsciiString anArgCase (argv[anArgIter]); + anArgCase.LowerCase(); + if (anArgCase == "-stream") + { + toTestStream = true; + } + else if (aDocName.IsEmpty()) + { + Standard_CString aDocNameStr = argv[anArgIter]; + DDocStd::GetDocument (aDocNameStr, aDoc); + if (aDoc.IsNull()) + { + di << "Syntax error: '" << argv[anArgIter] << "' is not a document"; + return 1; + } + aDocName = aDocNameStr; + } + else if (aFilePath.IsEmpty()) + { + aFilePath = argv[anArgIter]; + } + else if (!hasModeArg) + { + hasModeArg = true; + switch (anArgCase.Value (1)) + { + case 'a': + case '0': aMode = STEPControl_AsIs; break; + case 'f': + case '1': aMode = STEPControl_FacetedBrep; break; + case 's': + case '2': aMode = STEPControl_ShellBasedSurfaceModel; break; + case 'm': + case '3': aMode = STEPControl_ManifoldSolidBrep; break; + case 'w': + case '4': aMode = STEPControl_GeometricCurveSet; break; + default: + { + di << "Syntax error: mode '" << argv[anArgIter] << "' is incorrect [give fsmw]"; + return 1; + } + } + Standard_Boolean wrmode = Standard_True; + for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i) + { + switch (anArgCase.Value (i)) + { + case '-' : wrmode = Standard_False; break; + case '+' : wrmode = Standard_True; break; + case 'c' : aWriter.SetColorMode (wrmode); break; + case 'n' : aWriter.SetNameMode (wrmode); break; + case 'l' : aWriter.SetLayerMode (wrmode); break; + case 'v' : aWriter.SetPropsMode (wrmode); break; + } + } + } + else if (aMultiFilePrefix.IsEmpty() + && anArgCase.Search (":") == -1) + { + aMultiFilePrefix = argv[anArgIter]; + } + else if (aLabel.IsNull()) + { + if (!DDF::FindLabel (aDoc->Main().Data(), argv[anArgIter], aLabel) + || aLabel.IsNull()) + { + di << "Syntax error: No label for entry '" << argv[anArgIter] << "'"; + return 1; + } + aLabelName = argv[anArgIter]; + } + else + { + di << "Syntax error: unknown argument '" << argv[anArgIter] << "'"; + return 1; + } + } + if (aFilePath.IsEmpty()) + { + di << "Syntax error: wrong number of arguments"; + return 1; + } + + TCollection_AsciiString aFileName, anOldVarName; + const Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName.ToCString(), "STEP", aFileName, anOldVarName); + + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di); + Message_ProgressScope aRootScope (aProgress->Start(), "STEP export", isFileMode ? 2 : 1); + if (!aLabel.IsNull()) + { + di << "Translating label " << aLabelName << " of document " << aDocName << " to STEP\n"; + if (!aWriter.Transfer (aLabel, aMode, + !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL, + aRootScope.Next())) + { + di << "Error: the label of document cannot be translated or gives no result"; + return 1; + } + } + else + { + di << "Translating document " << aDocName << " to STEP\n"; + if (!aWriter.Transfer (aDoc, aMode, + !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL, + aRootScope.Next())) + { + di << "Error: The document cannot be translated or gives no result\n"; + } + } + + if (!isFileMode) + { + di << "Document has been translated into the session"; return 0; } - Handle(TDocStd_Document) Doc; - DDocStd::GetDocument(argv[1], Doc); - if (Doc.IsNull()) - { - di << argv[1] << " is not a document\n"; - return 1; - } - Standard_CString multifile = 0; + Message_ProgressScope aWriteScope (aRootScope.Next(), "File writing", 1); + aWriteScope.Show(); + di << "Writing STEP file " << aFilePath << "\n"; - Standard_Integer k = 3; - DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); - STEPCAFControl_Writer writer(XSDRAW::Session(), Standard_True); - - STEPControl_StepModelType mode = STEPControl_AsIs; - if (argc > k) + IFSelect_ReturnStatus aStat = IFSelect_RetVoid; + if (toTestStream) { - switch (argv[k][0]) + std::ofstream aStream; + OSD_OpenStream (aStream, aFilePath, std::ios::out | std::ios::binary); + aStat = aWriter.WriteStream (aStream); + aStream.close(); + if (!aStream.good() + && aStat == IFSelect_RetDone) { - case 'a': - case '0': mode = STEPControl_AsIs; break; - case 'f': - case '1': mode = STEPControl_FacetedBrep; break; - case 's': - case '2': mode = STEPControl_ShellBasedSurfaceModel; break; - case 'm': - case '3': mode = STEPControl_ManifoldSolidBrep; break; - case 'w': - case '4': mode = STEPControl_GeometricCurveSet; break; - default: di << "3rd arg = mode, incorrect [give fsmw]\n"; return 1; - } - Standard_Boolean wrmode = Standard_True; - for (Standard_Integer i = 0; argv[k][i]; i++) - switch (argv[3][i]) - { - case '-': wrmode = Standard_False; break; - case '+': wrmode = Standard_True; break; - case 'c': writer.SetColorMode(wrmode); break; - case 'n': writer.SetNameMode(wrmode); break; - case 'l': writer.SetLayerMode(wrmode); break; - case 'v': writer.SetPropsMode(wrmode); break; - } - k++; - } - TDF_Label label; - if (argc > k) - { - TCollection_AsciiString aStr(argv[k]); - if (aStr.Search(":") == -1) - multifile = argv[k++]; - - } - if (argc > k) - { - - if (!DDF::FindLabel(Doc->Main().Data(), argv[k], label) || label.IsNull()) - { - di << "No label for entry" << "\n"; - return 1; - - } - } - - TCollection_AsciiString fnom, rnom; - const Standard_Boolean modfic = XSDRAW::FileAndVar(argv[2], argv[1], "STEP", fnom, rnom); - - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di); - Message_ProgressScope aRootScope(aProgress->Start(), "STEP export", modfic ? 2 : 1); - if (!label.IsNull()) - { - di << "Translating label " << argv[k] << " of document " << argv[1] << " to STEP\n"; - if (!writer.Transfer(label, mode, multifile, aRootScope.Next())) - { - di << "The label of document cannot be translated or gives no result\n"; - return 1; + aStat = IFSelect_RetFail; } } else { - di << "Translating document " << argv[1] << " to STEP\n"; - if (!writer.Transfer(Doc, mode, multifile, aRootScope.Next())) - { - di << "The document cannot be translated or gives no result\n"; - } + aStat = aWriter.Write (aFilePath.ToCString()); } - if (modfic) + switch (aStat) { - Message_ProgressScope aWriteScope(aRootScope.Next(), "File writing", 1); - aWriteScope.Show(); - di << "Writing STEP file " << argv[2] << "\n"; - IFSelect_ReturnStatus stat = writer.Write(argv[2]); - switch (stat) + case IFSelect_RetVoid: { - case IFSelect_RetVoid: di << "No file written\n"; break; - case IFSelect_RetDone: - { - di << "File " << argv[2] << " written\n"; - - NCollection_DataMap DicFile = writer.ExternFiles(); - FillDicWS(DicFile); - AddWS(argv[2], XSDRAW::Session()); - break; - } - default: di << "Error on writing file\n"; break; + di << "Error: no file written"; + break; + } + case IFSelect_RetDone: + { + di << "File " << aFilePath << " written\n"; + + NCollection_DataMap aDicFile = aWriter.ExternFiles(); + FillDicWS (aDicFile); + AddWS (aFilePath, XSDRAW::Session()); + break; + } + default: + { + di << "Error on writing file"; + break; } - } - else - { - di << "Document has been translated into the session"; } return 0; } @@ -1271,10 +1342,21 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& di) di.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g); di.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g); di.Add("ReadStep", - "Doc filename [mode]" - "\n\t\t: Read STEP file to a document.", + "Doc filename [mode] [-stream]" + "\n\t\t: Read STEP file to a document." + "\n\t\t: -stream read using istream reading interface (testing)", __FILE__, ReadStep, g); - di.Add("WriteStep", "Doc filename [mode=a [multifile_prefix] [label]]: Write DECAF document to STEP file", __FILE__, WriteStep, g); + di.Add("WriteStep" , + "Doc filename [mode=a [multifile_prefix] [label]] [-stream]" + "\n\t\t: Write DECAF document to STEP file" + "\n\t\t: mode can be: a or 0 : AsIs (default)" + "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel" + "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame" + "\n\t\t: multifile_prefix: triggers writing assembly components as separate files," + "\n\t\t: and defines common prefix for their names" + "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly" + "\n\t\t: -stream read using ostream writing interface (testing)", + __FILE__, WriteStep, g); di.Add("XFileList", "Print list of files that was transferred by the last transfer", __FILE__, GetDicWSList, g); di.Add("XFileCur", ": returns name of file which is set as current", __FILE__, GetCurWS, g); diff --git a/src/XDEDRAW/XDEDRAW_Shapes.cxx b/src/XDEDRAW/XDEDRAW_Shapes.cxx index 709808406b..dc0edf0b5e 100644 --- a/src/XDEDRAW/XDEDRAW_Shapes.cxx +++ b/src/XDEDRAW/XDEDRAW_Shapes.cxx @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -1113,6 +1115,127 @@ static Standard_Integer XAutoNaming (Draw_Interpretor& theDI, return 0; } +//======================================================================= +// function : parseXYZ +// purpose : Converts three string arguments, to gp_XYZ with check +//======================================================================= +static Standard_Boolean parseXYZ (const char** theArgVec, gp_XYZ& thePnt) +{ + const TCollection_AsciiString aXYZ[3] = {theArgVec[0], theArgVec[1], theArgVec[2] }; + if (!aXYZ[0].IsRealValue (Standard_True) + || !aXYZ[1].IsRealValue (Standard_True) + || !aXYZ[2].IsRealValue (Standard_True)) + { + return Standard_False; + } + + thePnt.SetCoord (aXYZ[0].RealValue(), aXYZ[1].RealValue(), aXYZ[2].RealValue()); + return Standard_True; +} + +//======================================================================= +// function : setLocation +// purpose : Sets location to the shape at the label in XDE document +//======================================================================= +static Standard_Integer setLocation (Draw_Interpretor& , Standard_Integer theArgNb, const char** theArgVec) +{ + if (theArgNb < 4) + { + Message::SendFail() << "Error: not enough arguments, see help " << theArgVec[0] << " for details"; + return 1; + } + // get and check the document + Handle(TDocStd_Document) aDoc; + DDocStd::GetDocument (theArgVec[1], aDoc); + if (aDoc.IsNull ()) + { + Message::SendFail() << "Error: " << theArgVec[1] << " is not a document"; + return 1; + } + // get and check the label + TDF_Label aShapeLabel; + TDF_Tool::Label (aDoc->GetData(), theArgVec[2], aShapeLabel); + if (aShapeLabel.IsNull ()) + { + Message::SendFail() << "Error: no such Label: " << theArgVec[2]; + return 1; + } + // get the transformation + gp_Trsf aTransformation; + for (Standard_Integer anArgIter = 3; anArgIter < theArgNb; ++anArgIter) + { + gp_Trsf aCurTransformation; + gp_XYZ aMoveXYZ, aRotPnt, aRotAxis, aScalePnt; + Standard_Real aRotAngle, aScale; + TCollection_AsciiString anArg = theArgVec[anArgIter]; + anArg.LowerCase(); + + if (anArg == "-rotate" && + anArgIter + 7 < theArgNb && + parseXYZ (theArgVec + anArgIter + 1, aRotPnt) && + parseXYZ (theArgVec + anArgIter + 4, aRotAxis) && + Draw::ParseReal (theArgVec[anArgIter + 7], aRotAngle)) + { + anArgIter += 7; + aCurTransformation.SetRotation (gp_Ax1 (gp_Pnt (aRotPnt), gp_Dir (aRotAxis)), aRotAngle * (M_PI / 180.0)); + } + else if (anArg == "-move" && + anArgIter + 3 < theArgNb && + parseXYZ (theArgVec + anArgIter + 1, aMoveXYZ)) + { + anArgIter += 3; + aCurTransformation.SetTranslation (aMoveXYZ); + } + // first check scale with base point + else if (anArg == "-scale" && + anArgIter + 4 < theArgNb && + parseXYZ (theArgVec + anArgIter + 1, aScalePnt) && + Draw::ParseReal (theArgVec[anArgIter + 4], aScale)) + { + anArgIter += 4; + aCurTransformation.SetScale (gp_Pnt (aScalePnt), aScale); + } + // second check for scale with scale factor only + else if (anArg == "-scale" && + anArgIter + 1 < theArgNb && + Draw::ParseReal (theArgVec[anArgIter + 1], aScale)) + { + anArgIter += 1; + aCurTransformation.SetScaleFactor (aScale); + } + else + { + Message::SendFail() << "Syntax error: unknown options '" << anArg << "', or incorrect option parameters"; + return 1; + } + aTransformation.PreMultiply (aCurTransformation); + } + TopLoc_Location aLoc(aTransformation); + + // Create the ShapeTool and try to set location + Handle(XCAFDoc_ShapeTool) anAssembly = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main()); + TDF_Label aRefLabel; + if (anAssembly->SetLocation (aShapeLabel, aLoc, aRefLabel)) + { + if (aShapeLabel == aRefLabel) + { + Message::SendInfo() << "New location was set"; + } + else + { + TCollection_AsciiString aLabelStr; + TDF_Tool::Entry(aRefLabel, aLabelStr); + Message::SendInfo() << "Reference to the shape at label " << aLabelStr << " was created and location was set"; + } + } + else + { + Message::SendFail() << "Error: an attempt to set the location to a shape to which there is a reference, or to not a shape at all"; + } + + return 0; +} + //======================================================================= //function : InitCommands //purpose : @@ -1222,6 +1345,20 @@ void XDEDRAW_Shapes::InitCommands(Draw_Interpretor& di) di.Add ("XSetInstanceSHUO","Doc shape \t: sets the SHUO structure for indicated component", __FILE__, setStyledComponent, g); + + di.Add ("XSetLocation", R"( +Doc Label transformation [transformation ... ] +Applies given complex transformation to the shape at Label from Document. +The label may contain a reference to a shape, an assembly or simple shape. +The assembly or simple shape should not be referred by any reference. +Transformations: + '-move x y z' - move shape + '-rotate x y z dx dy dz angle' - rotate shape + '-scale [x y z] factor' - scale shape +Transformations are applied from left to right. +There can be more than one transformation of the same type. +At least one transformation must be specified. +)", __FILE__, setLocation, g); di.Add ("XUpdateAssemblies","Doc \t: updates assembly compounds", __FILE__, updateAssemblies, g); diff --git a/src/XSAlgo/XSAlgo_AlgoContainer.cxx b/src/XSAlgo/XSAlgo_AlgoContainer.cxx index ab91acdb45..6f3ccb3bcb 100644 --- a/src/XSAlgo/XSAlgo_AlgoContainer.cxx +++ b/src/XSAlgo/XSAlgo_AlgoContainer.cxx @@ -100,9 +100,17 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape, if ( context.IsNull() ) { Standard_CString rscfile = Interface_Static::CVal(prscfile); - if (!rscfile) - rscfile = prscfile; - context = new ShapeProcess_ShapeContext(shape, rscfile); + if (rscfile != nullptr && strlen (rscfile) == 0) + { + context = new ShapeProcess_ShapeContext(shape, nullptr); + Interface_Static::FillMap(context->ResourceManager()->GetMap()); + } + else + { + if (!rscfile) + rscfile = prscfile; + context = new ShapeProcess_ShapeContext(shape, rscfile); + } context->SetDetalisation(TopAbs_EDGE); } context->SetNonManifold(NonManifold); diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index 3eaf3df394..7ceff7987b 100644 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -282,8 +284,11 @@ static Standard_Integer testreadstep (Draw_Interpretor& di, Standard_Integer arg IFSelect_ReturnStatus readstat; if (useStream) { - std::ifstream aStream (filename); - readstat = Reader.ReadStream(filename, aStream); + std::ifstream aStream; + OSD_OpenStream (aStream, filename, std::ios::in | std::ios::binary); + TCollection_AsciiString aFolder, aFileNameShort; + OSD_Path::FolderAndFileFromPath (filename, aFolder, aFileNameShort); + readstat = Reader.ReadStream (aFileNameShort.ToCString(), aStream); } else { @@ -435,22 +440,72 @@ static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, //======================================================================= static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if (argc != 3) - { - di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n"; - di << " Usage : " << argv[0] <<" file_name shape_name \n"; - return 1; + TCollection_AsciiString aFilePath; + TopoDS_Shape aShape; + bool toTestStream = false; + for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) + { + TCollection_AsciiString anArgCase (argv[anArgIter]); + anArgCase.LowerCase(); + if (anArgCase == "-stream") + { + toTestStream = true; } - STEPControl_Writer Writer; - Standard_CString filename = argv[1]; - TopoDS_Shape shape = DBRep::Get(argv[2]); - IFSelect_ReturnStatus stat = Writer.Transfer(shape,STEPControl_AsIs); - stat = Writer.Write(filename); - if(stat != IFSelect_RetDone){ - di<<"Error on writing file\n"; + else if (aFilePath.IsEmpty()) + { + aFilePath = argv[anArgIter]; + } + else if (aShape.IsNull()) + { + aShape = DBRep::Get (argv[anArgIter]); + if (aShape.IsNull()) + { + di << "Syntax error: '" << argv[anArgIter] << "' is not a shape"; + return 1; + } + } + else + { + di << "Syntax error: unknown argument '" << argv[anArgIter] << "'"; + return 1; + } + } + if (aShape.IsNull()) + { + di << "Syntax error: wrong number of arguments"; + return 1; + } + + STEPControl_Writer aWriter; + IFSelect_ReturnStatus aStat = aWriter.Transfer (aShape, STEPControl_AsIs); + if (aStat != IFSelect_RetDone) + { + di << "Error on transferring shape"; + return 1; + } + + if (toTestStream) + { + std::ofstream aStream; + OSD_OpenStream (aStream, aFilePath, std::ios::out | std::ios::binary); + aStat = aWriter.WriteStream (aStream); + aStream.close(); + if (!aStream.good() + && aStat == IFSelect_RetDone) + { + aStat = IFSelect_RetFail; + } + } + else + { + aStat = aWriter.Write (aFilePath.ToCString()); + } + if (aStat != IFSelect_RetDone) + { + di << "Error on writing file"; return 1; } - di<<"File Is Written\n"; + di << "File Is Written"; return 0; } @@ -550,7 +605,8 @@ void XSDRAWSTEP::InitCommands (Draw_Interpretor& theCommands) XSDRAWSTEP::Init(); XSDRAW::LoadDraw(theCommands); theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); - theCommands.Add("testwritestep", "testwritestep filename.stp shape", __FILE__, testwrite, g); + theCommands.Add("testwritestep", "testwritestep filename.stp shape [-stream]", + __FILE__, testwrite, g); theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g); theCommands.Add("testreadstep", "testreadstep file shape [-stream]",__FILE__, testreadstep, g); theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g); diff --git a/src/XSTEPResource/FILES b/src/XSTEPResource/FILES old mode 100755 new mode 100644 diff --git a/src/XSTEPResource/IGES b/src/XSTEPResource/IGES old mode 100755 new mode 100644 diff --git a/src/XSTEPResource/STEP b/src/XSTEPResource/STEP old mode 100755 new mode 100644 diff --git a/tests/bugs/begin b/tests/bugs/begin index 64eb606215..0f664ace6a 100755 --- a/tests/bugs/begin +++ b/tests/bugs/begin @@ -59,3 +59,47 @@ proc checktime {value expected tol_rel message} { puts "Improvement. ${message}, ${value} seconds, is less than expected time - ${expected} seconds" } } + +# Reads resource file, returns options from file as key-value dict +proc parse_resource_file {theFileName} { + # Creating empty dictionary + set aDict [dict create]; + # Check for resource file + if { [info exists theFileName] == 0 } { + puts "Error: resource file \"${theFileName}\" isn't found" + return $aDict + } + # Open a resource file + set aFD [open "${theFileName}" "rb"] + set aLineNo 0 + # Read line by line + while {[gets $aFD aLine] !=-1 } { + incr aLineNo + # Clear the line from comment + if {[regexp {(^[^!]+)} $aLine match aClearLine]} { + # remove spaces + set aClearLine [string trim $aClearLine] + if {[string length $aClearLine] != 0} { + if {[regexp {(\S+)\s*:\s*(\S*)} $aClearLine match aKey aValue]} { + dict set aDict $aKey $aValue + } else { + puts "Error: syntax error in resource file at line: ${aLineNo}" + } + } + } + } + close $aFD + return $aDict +} + +# Creates new resource file with options as key-value dict +proc create_resource_file {theFileName theOptions} { + # Open a resource file + set aFD [open "${theFileName}" "wb"] + set aLineNo 0 + # Write line by line + dict for {aKey aValue} $theOptions { + puts $aFD "${aKey} : ${aValue}" + } + close $aFD +} diff --git a/tests/bugs/iges/buc60820_1 b/tests/bugs/iges/buc60820_1 index 3253afd1af..9abdd7c07c 100755 --- a/tests/bugs/iges/buc60820_1 +++ b/tests/bugs/iges/buc60820_1 @@ -12,5 +12,5 @@ tclean result incmesh result 0.1 triangles result -checktrinfo result -tri 748 -nod 619 +checktrinfo result -tri 736 -nod 613 checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/iges/buc60820_2 b/tests/bugs/iges/buc60820_2 index e030c94fcb..0c676d4af6 100755 --- a/tests/bugs/iges/buc60820_2 +++ b/tests/bugs/iges/buc60820_2 @@ -13,6 +13,6 @@ vdisplay result vsetdispmode result 1 vfit -checktrinfo result -tri 278 -nod 254 +checktrinfo result -tri 222 -nod 226 checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/mesh/bug25044_12 b/tests/bugs/mesh/bug25044_12 index 1ddf82927d..31d1c179ad 100644 --- a/tests/bugs/mesh/bug25044_12 +++ b/tests/bugs/mesh/bug25044_12 @@ -1,6 +1,3 @@ -puts "TODO 25044 ALL: SelfIntersectingWire" -puts "TODO 25044 ALL: Number of triangles is equal to 0" - puts "=======" puts "0025044: BRepMesh tweaks" puts "=======" diff --git a/tests/bugs/mesh/bug25044_13 b/tests/bugs/mesh/bug25044_13 index f02bc31f58..12b8348b95 100644 --- a/tests/bugs/mesh/bug25044_13 +++ b/tests/bugs/mesh/bug25044_13 @@ -1,6 +1,3 @@ -puts "TODO 25044 ALL: SelfIntersectingWire" -puts "TODO 25044 ALL: Number of triangles is equal to 0" - puts "=======" puts "0025044: BRepMesh tweaks" puts "=======" diff --git a/tests/bugs/mesh/bug25044_60 b/tests/bugs/mesh/bug25044_60 index 78ae386109..6c89250587 100644 --- a/tests/bugs/mesh/bug25044_60 +++ b/tests/bugs/mesh/bug25044_60 @@ -3,6 +3,9 @@ puts "0025588: BRepMesh_ShapeTool::FindUV check for 2d points to be the same is puts "=======" puts "" +puts "TODO OCC25588 All: Not connected mesh inside face 893" +puts "TODO OCC25588 All: Not connected mesh inside face 1094" + pload XDE stepread [locate_data_file Median_cx-fs01_bicycle.stp] a * diff --git a/tests/bugs/mesh/bug25287 b/tests/bugs/mesh/bug25287 index 2905c18057..f03a9626d1 100644 --- a/tests/bugs/mesh/bug25287 +++ b/tests/bugs/mesh/bug25287 @@ -11,7 +11,7 @@ renamevar a_1 result incmesh result 0.0001 -a 30 -force_face_def -parallel -checktrinfo result -tri 14494 -nod 9510 -defl 0.00031502118964205414 -tol_abs_defl 1e-6 +checktrinfo result -tri 14058 -nod 9292 -defl 0.00031502118964205414 -tol_abs_defl 1e-6 vinit vsetdispmode 1 diff --git a/tests/bugs/mesh/bug27384_2 b/tests/bugs/mesh/bug27384_2 index 640c5ca59a..63e2923e22 100644 --- a/tests/bugs/mesh/bug27384_2 +++ b/tests/bugs/mesh/bug27384_2 @@ -17,7 +17,7 @@ vdefaults -autoTriang 0 vdisplay result vfit -set rel_tol 0.7607262575544315 +set rel_tol 0.7558889057543047 set max_rel_tol_diff 0.001 set area_eps 1 diff --git a/tests/bugs/mesh/bug27845 b/tests/bugs/mesh/bug27845 index 5428d732a7..6287701923 100644 --- a/tests/bugs/mesh/bug27845 +++ b/tests/bugs/mesh/bug27845 @@ -14,7 +14,7 @@ vdisplay result vfit checkview -screenshot -3d -path ${imagedir}/${test_image}.png -checktrinfo result -tri 3832 -nod 4773 -defl 3.0509255143612428 -tol_abs_defl 1e-6 +checktrinfo result -tri 3828 -nod 4771 -defl 3.0544822246414993 -tol_abs_defl 1e-6 set log [tricheck result] if { [llength $log] != 0 } { diff --git a/tests/bugs/mesh/bug28500 b/tests/bugs/mesh/bug28500 index 3bab0b6875..56e1699978 100644 --- a/tests/bugs/mesh/bug28500 +++ b/tests/bugs/mesh/bug28500 @@ -3,22 +3,20 @@ puts "CR28500: Artifact in shaded view of the shape" puts "=======" puts "" -puts "TODO CR28500 ALL: Artifact in shaded view of the shape" -puts "TODO CR30056 ALL: Meshing statuses: SelfIntersectingWire Failure Reused" +restore [locate_data_file bug28500_shape_mesh_artifact.brep] result -restore [locate_data_file bug28500_shape_mesh_artifact.brep] a - -incmesh a 0.01 +tclean result +incmesh result 0.01 vinit vsetdispmode 1 -vdisplay a +vdefaults -autoTriang 0 +vdisplay result vfit -set x 150 -set y 150 -if { [checkcolor $x $y 0 1 0] == 1 } { - puts "Error: Artifact in shaded view of the shape" +set log [tricheck result] +if { [llength $log] != 0 } { + puts "Error : Mesh contains faulties" } checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/mesh/bug30008_1 b/tests/bugs/mesh/bug30008_1 index add7ddfaab..0d6ccc4a9b 100644 --- a/tests/bugs/mesh/bug30008_1 +++ b/tests/bugs/mesh/bug30008_1 @@ -12,6 +12,6 @@ vdisplay result vviewparams -scale 8.46292 -proj 0.653203 -0.644806 0.396926 -up -0.0109833 0.51609 0.856464 -at 347.559 1026.89 219.262 -eye 2080.75 -684.022 1272.45 tricheck result -checktrinfo result -tri 9470 -nod 6136 -defl 4.7757836297551908 -tol_abs_defl 1e-6 +checktrinfo result -tri 9460 -nod 6131 -defl 4.7757836297551908 -tol_abs_defl 1e-6 checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/mesh/bug31144 b/tests/bugs/mesh/bug31144 index 31f40afbe2..173e6403a7 100644 --- a/tests/bugs/mesh/bug31144 +++ b/tests/bugs/mesh/bug31144 @@ -2,7 +2,6 @@ puts "=======" puts "0031144: Shape Healing - ShapeAnalysis::OuterWire() infinite loop on solid obtained from IFC" puts "=======" puts "" -puts "REQUIRED ALL: Meshing statuses: Failure" cpulimit 10 diff --git a/tests/bugs/mesh/bug31251 b/tests/bugs/mesh/bug31251 index d8693fe8e2..9a4c55cfb3 100644 --- a/tests/bugs/mesh/bug31251 +++ b/tests/bugs/mesh/bug31251 @@ -15,7 +15,7 @@ vdefaults -autoTriang 0 tclean result incmesh result 0.004 -a 14 -checktrinfo result -tri 72570 -nod 40951 -defl 0.24607185555570676 -tol_abs_defl 1e-6 +checktrinfo result -tri 72562 -nod 40947 -defl 0.24607185555570676 -tol_abs_defl 1e-6 vdisplay result -redisplay vfit @@ -23,7 +23,7 @@ checkview -screenshot -3d -path ${imagedir}/${test_image}_default.png tclean result incmesh result 0.004 -a 14 -force_face_def -checktrinfo result -tri 287990 -nod 148661 -defl 0.16388671063364907 -tol_abs_defl 1e-6 +checktrinfo result -tri 287982 -nod 148657 -defl 0.16388671063364907 -tol_abs_defl 1e-6 vdisplay result -redisplay vfit diff --git a/tests/bugs/mesh/bug31476 b/tests/bugs/mesh/bug31476 new file mode 100644 index 0000000000..58b529b2c2 --- /dev/null +++ b/tests/bugs/mesh/bug31476 @@ -0,0 +1,30 @@ +puts "================" +puts "0031476: Wrong shading of a toroidal face from a SAT file" +puts "================" +puts "" + +restore [locate_data_file bug31476_toroidal_face.brep] result + +fixshape result result +i + +vinit +vsetdispmode 1 +vdisplay result +vfit + +smallview +fit +isos result 0 +triangles result + +checktrinfo result -tri 135 -nod 104 + +set log [tricheck result] +if { [llength $log] != 0 } { + puts "Error : Invalid mesh" +} else { + puts "Mesh is OK" +} + +checkview -screenshot -3d -path ${imagedir}/${test_image}_3d.png +checkview -screenshot -2d -path ${imagedir}/${test_image}_2d.png diff --git a/tests/bugs/mesh/bug31926 b/tests/bugs/mesh/bug31926 new file mode 100644 index 0000000000..edc55f2e0f --- /dev/null +++ b/tests/bugs/mesh/bug31926 @@ -0,0 +1,39 @@ +puts "========" +puts "0031926: Shape Healing - ShapeAnalysis::OuterWire() considers next iteration element always to be a wire causing skipping of primal one" +puts "========" +puts "" + +vertex v11 0 1 0; vertex v12 1 0 0; vertex v13 0 0 0 +edge e11 v11 v12; edge e12 v12 v13; edge e13 v13 v11 +wire w1 e11 e12 e13 +mkplane f1 w1 + +vertex v21 0 0 2; vertex v22 1 0 0; vertex v23 0 0 0 +edge e21 v21 v22; edge e22 v22 v23; edge e23 v23 v21 +wire w2 e21 e22 e23 +mkplane f2 w2 + +vertex v31 0 0 2; vertex v32 0 1 0; vertex v33 1 0 0 +edge e31 v31 v32; edge e32 v32 v33; edge e33 v33 v31 +wire w3 e31 e32 e33 +mkplane f3 w3 + +vertex v41 0 0 2; vertex v42 0 0 0; vertex v43 0 1 0 +edge e41 v41 v42; edge e42 v42 v43; edge e43 v43 v41 +wire w4 e41 e42 e43 +mkplane f4 w4 + +psphere s1 1 +sewing sh2 f1 f2 f3 f4 +ssolid sh2 s2 +bcut result s1 s2 +incmesh result 1 + +checkview -display result -3d -path ${imagedir}/${test_image}.png + +set log [tricheck result] +if { [llength $log] != 0 } { + puts "Error : Invalid mesh" +} else { + puts "Mesh is OK" +} diff --git a/tests/bugs/mesh/bug32053 b/tests/bugs/mesh/bug32053 new file mode 100644 index 0000000000..304534d136 --- /dev/null +++ b/tests/bugs/mesh/bug32053 @@ -0,0 +1,14 @@ +puts "=======" +puts "0032053: Mesh - Invalid mesh after shape scaling" +puts "=======" +puts "" + +restore [locate_data_file bug32053_prob_face.brep] a + +scaleshape result a 0.1 +vdisplay result -dispMode 1 +vfit + +checktrinfo result -tri 168 -nod 133 + +checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/mesh/bug32424 b/tests/bugs/mesh/bug32424 index f5e12302e1..deb41d8bfa 100644 --- a/tests/bugs/mesh/bug32424 +++ b/tests/bugs/mesh/bug32424 @@ -8,7 +8,7 @@ restore [locate_data_file bug32424.brep] result incmesh result 0.17 -a 20 -checktrinfo result -tri 16168 -nod 8206 +checktrinfo result -tri 2360 -nod 1302 vinit vdefaults -autoTriang 0 diff --git a/tests/bugs/mesh/bug32692_1 b/tests/bugs/mesh/bug32692_1 index 5a85bff3db..1712b35ab1 100644 --- a/tests/bugs/mesh/bug32692_1 +++ b/tests/bugs/mesh/bug32692_1 @@ -8,4 +8,4 @@ puts "REQUIRED ALL: Meshing statuses: SelfIntersectingWire Failure" restore [locate_data_file bug32692.brep] s incmesh s 0.01 -parallel -checktrinfo s -nod 7427 -tri 7457 -empty 9 -face 309 +checktrinfo s -nod 7389 -tri 7419 -empty 9 -face 309 diff --git a/tests/bugs/mesh/bug33050 b/tests/bugs/mesh/bug33050 new file mode 100644 index 0000000000..466cfe9a2f --- /dev/null +++ b/tests/bugs/mesh/bug33050 @@ -0,0 +1,41 @@ +puts "================" +puts "0033050: \[Regression to OCCT 7.3.0\] Mesh - meshing deflection is not reached" +puts "================" +puts "" + +restore [locate_data_file bug33050.brep] result + +################## Deflection: 0.001 ################## +tclean result +incmesh result 0.001 + +checktrinfo result -tri 27652 -nod 28016 -defl 0.0027132671526737435 -tol_abs_defl 1e-6 + +tclean result +incmesh result 0.001 -surf_def_all + +checktrinfo result -tri 30102 -nod 29241 -defl 0.0010301984083541042 -tol_abs_defl 1e-6 + +################## Deflection: 0.0001 ################# + +tclean result +incmesh result 0.0001 + +checktrinfo result -tri 88140 -nod 84304 -defl 0.00073349807253346574 -tol_abs_defl 1e-6 + +tclean result +incmesh result 0.0001 -surf_def_all + +checktrinfo result -tri 103376 -nod 91922 -defl 0.00012553867394267057 -tol_abs_defl 1e-6 + +################## Deflection: 0.00005 ################ + +tclean result +incmesh result 0.00005 + +checktrinfo result -tri 127538 -nod 119773 -defl 0.00043153032084638013 -tol_abs_defl 1e-6 + +tclean result +incmesh result 0.00005 -surf_def_all + +checktrinfo result -tri 154246 -nod 133127 -defl 5.1157129731636775e-05 -tol_abs_defl 1e-6 \ No newline at end of file diff --git a/tests/bugs/modalg_2/bug264_11 b/tests/bugs/modalg_2/bug264_11 index a733dbcb47..eda4fb2af3 100755 --- a/tests/bugs/modalg_2/bug264_11 +++ b/tests/bugs/modalg_2/bug264_11 @@ -18,6 +18,6 @@ vclear isos result 0 triangles result -checktrinfo result -tri 31 -nod 28 +checktrinfo result -tri 55 -nod 40 checkprops result -s 0 checkview -display result -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_5/bug23954 b/tests/bugs/modalg_5/bug23954 index 58555b2bcb..1dc0cc10da 100644 --- a/tests/bugs/modalg_5/bug23954 +++ b/tests/bugs/modalg_5/bug23954 @@ -1,5 +1,3 @@ -puts "TODO OCC23954 ALL: Error: result is not Toroidal surface" - puts "============" puts "OCC23954" puts "============" diff --git a/tests/bugs/modalg_7/bug28640 b/tests/bugs/modalg_7/bug28640 index be1bd412fb..7afefceebe 100755 --- a/tests/bugs/modalg_7/bug28640 +++ b/tests/bugs/modalg_7/bug28640 @@ -1,37 +1,37 @@ -puts "TODO OCC28640 ALL: Faulty shapes in variables faulty_1" - -puts "========" -puts "OCC28640" -puts "========" +puts "================" +puts "0028640: Modeling Algorithms - BRepBuilderAPI_Transform builds invalid shape" +puts "================" puts "" -############################################## -# BRepBuilderAPI_Transform build invalid shape -############################################## +# Analyze triangulation after mirroring shape restore [locate_data_file bug28640_origin_copy.brep] a - -smallview -display a -front -fit +tmirror a 0 0 0 1 0 0 vinit vsetdispmode 1 vdisplay a vfront vfit +checkview -screenshot -3d -path ${imagedir}/${test_image}-mirror-3d_1.png -# +if {[tricheck a] != ""} { + puts "Error: invalid triangulation" +} +# Fix the shape and check its validity after mirroring +restore [locate_data_file bug28640_origin_copy.brep] a +fixshape a a +checkshape a tmirror a 0 0 0 1 0 0 - checkshape a -display a -fit -checkview -screenshot -2d -path ${imagedir}/${test_image}-mirror-2d.png - +# Check triangulation of healed and mirrored shape vclear vdisplay a +vfront vfit -checkview -screenshot -3d -path ${imagedir}/${test_image}-mirror-3d.png +checkview -screenshot -3d -path ${imagedir}/${test_image}-mirror-3d_2.png + +if {[tricheck a] != ""} { + puts "Error: invalid triangulation" +} diff --git a/tests/bugs/modalg_7/bug30273 b/tests/bugs/modalg_7/bug30273 index 503691099f..daaefa168b 100644 --- a/tests/bugs/modalg_7/bug30273 +++ b/tests/bugs/modalg_7/bug30273 @@ -5,5 +5,31 @@ puts "" pload XDE +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. +if { [info exists imagedir] == 0 } { + set imagedir ../BugNumber + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } +} +# remember the path to the old resource file +set old_resource_path $::env(CSF_STEPDefaults) +# reading old resource file +set anOptions [parse_resource_file "${old_resource_path}/STEP"] +# activation of ignoring the adding of natural bound +dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" +# path to new resource file +set new_resource_path ${imagedir} +# creating resource file +create_resource_file "${new_resource_path}/STEP" $anOptions +# changing the path to the resource file +set ::env(CSF_STEPDefaults) ${new_resource_path} + stepread [locate_data_file bug30273.stp] res * + +# Restoring the path to the old resource file +set ::env(CSF_STEPDefaults) ${old_resource_path} + checknbshapes res_1 -solid 176 -face 10463 -shape 72893 diff --git a/tests/bugs/modalg_7/bug32691 b/tests/bugs/modalg_7/bug32691 new file mode 100644 index 0000000000..e3132262b5 --- /dev/null +++ b/tests/bugs/modalg_7/bug32691 @@ -0,0 +1,19 @@ +puts "==============================================" +puts "0032691: Modeling Algorithms - Crash when trying to build solid during sweep algorithm" +puts "==============================================" +puts "" + +puts "REQUIRED ALL: Buildsweep : Not Done" + +bsplinecurve s 3 8 0 4 1 3 2 3 3 3 4 3 5 3 6 3 7 4 65.1 7.3076 2.1 1 65.1 7.3027 1.9217 1 65.1 7.2978 1.7434 1 65.1 7.2928 1.5652 1 65.1 7.2899 1.4588 1 65.1 7.2869 1.3524 1 65.1 7.284 1.2461 1 65.1 7.272 1.2388 1 65.1 7.26 1.2315 1 65.1 7.248 1.2243 1 65.1 7.1717 1.1778 1 65.1 7.0954 1.1314 1 65.1 7.019 1.0849 1 65.1 6.9424 1.0379 1 65.1 6.8657 0.9909 1 65.1 6.789 0.9438 1 65.1 6.7782 0.9372 1 65.1 6.7673 0.9305 1 65.1 6.7565 0.9238 1 65.1 6.7436 0.9159 1 65.1 6.7307 0.908 1 65.1 6.7178 0.9 1 +mkedge s s +wire s s + +polyline p 65.09999999999999 7.3076 2.1 65.0855660928097 7.16839889506023 2.10383597533476 65.0746247111087 7.16953256986072 2.10380518704116 65.08905861829901 7.30873367480049 2.0999692117064 65.09999999999999 7.3076 2.1 + +mksweep s +addsweep p +setsweep -DT +if [catch {buildsweep r -C -S}] { + puts "Error: exception is raised" +} diff --git a/tests/bugs/modalg_8/bug33165 b/tests/bugs/modalg_8/bug33165 new file mode 100644 index 0000000000..acc9a454af --- /dev/null +++ b/tests/bugs/modalg_8/bug33165 @@ -0,0 +1,41 @@ +puts "====================================" +puts "0033165: Data exchange - Instance name is not saved during writing step file" +puts "====================================" +puts "" + +pload OCAF XDEDRAW + +box b 1 1 1 +reset b +copy b b1 + +# set valid location with identity matrix +reset b1 + +ttranslate b 1 1 1 + +compound b1 b c +XNewDoc d +XAddShape d c 1 + +set label1 "0:1:1:1:1" +set label2 "0:1:1:1:2" +set name1 "name1" +set name2 "name2" + +SetName d $label1 $name1 +SetName d $label2 $name2 + +set file $imagedir/${test_image}.stp +WriteStep d $file +ReadStep d1 $file + +if { [GetName d1 $label1] != $name1 } { + puts "Error: The name is missed" +} + +if { [GetName d1 $label2] != $name2 } { + puts "Error: The name is missed" +} + +file delete -force ${file} \ No newline at end of file diff --git a/tests/bugs/moddata_1/bug22296 b/tests/bugs/moddata_1/bug22296 index 8a4cf3d154..5a0e4a2b59 100755 --- a/tests/bugs/moddata_1/bug22296 +++ b/tests/bugs/moddata_1/bug22296 @@ -23,8 +23,8 @@ if { ${E_Length} < 6} { set good_umin 0 set good_umax 6.28319 - set good_vmin 0 - set good_vmax 6.28319 + set good_vmin 3.14159 + set good_vmax 9.42478 set xlist [xbounds f] set umin [lindex $xlist 0] diff --git a/tests/bugs/moddata_2/bug428 b/tests/bugs/moddata_2/bug428 index d4cce3e9f8..913bb19935 100755 --- a/tests/bugs/moddata_2/bug428 +++ b/tests/bugs/moddata_2/bug428 @@ -19,5 +19,5 @@ isos result 0 triangles result fit -checktrinfo result -tri 10463 -nod 7643 +checktrinfo result -tri 10409 -nod 7615 checkview -screenshot -2d -path ${imagedir}/${test_image}_axo.png diff --git a/tests/bugs/moddata_2/fra62476_1 b/tests/bugs/moddata_2/fra62476_1 index 92646513ab..d06f426a18 100755 --- a/tests/bugs/moddata_2/fra62476_1 +++ b/tests/bugs/moddata_2/fra62476_1 @@ -1,5 +1,4 @@ puts "TODO OCC12345 ALL: Error: Number of triangles" -puts "TODO OCC12345 ALL: Error: Number of nodes" puts "============" puts "FRA62476" diff --git a/tests/bugs/moddata_2/fra62476_2 b/tests/bugs/moddata_2/fra62476_2 index a9c53d81e0..07a7bef755 100755 --- a/tests/bugs/moddata_2/fra62476_2 +++ b/tests/bugs/moddata_2/fra62476_2 @@ -13,5 +13,5 @@ tclean result incmesh result .1 triangles result -checktrinfo result -tri 163 -nod 114 +checktrinfo result -tri 159 -nod 112 checkview -display result -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/step/bug28024 b/tests/bugs/step/bug28024 new file mode 100644 index 0000000000..45df53c439 --- /dev/null +++ b/tests/bugs/step/bug28024 @@ -0,0 +1,47 @@ +puts "============" +puts "OCC28024 Data Exchange, Configuration - revise XSTEPResource initialization" +puts "============" +puts "" +##################################################### +# Testing the mechanism for changing options of ShapeHealing +# from DRAW +##################################################### + +pload MODELING XDE + +if { [info exists imagedir] == 0 } { + set imagedir ../bug28024 + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } +} +set step_file ${imagedir}/inv_triangle.stp + +# Make simple triangle with INNER wire +vertex v1 0 0 0 +vertex v2 1 0 0 +vertex v3 0 1 0 +edge e1 v2 v1 +edge e2 v3 v2 +edge e3 v1 v3 +wire w1 e1 e3 e2 +plane p1 +mkface f1 p1 w1 norient + +# Save to STEP +testwritestep ${step_file} f1 + +# Empty resource file name to take params from InterfaceStatic +param "read.step.resource.name" "\"\"" +# Turn off FixOrientation procedure +param "FromSTEP.FixShape.FixOrientationMode" 0 + +# Read from STEP without shape healing +stepread ${step_file} r * +explode r_1 f + +# The area of triangle must be negative +checkarea r_1_1 -0.5 1e-6 0.001 + +param "read.step.resource.name" "STEP" +param "FromSTEP.FixShape.FixOrientationMode" -1 diff --git a/tests/bugs/step/bug28414 b/tests/bugs/step/bug28414 new file mode 100644 index 0000000000..127f301c4f --- /dev/null +++ b/tests/bugs/step/bug28414 @@ -0,0 +1,20 @@ +puts "===================================================================" +puts "0028414: Data Exchange - Step entity not correctly read" +puts "===================================================================" +puts "" + +pload VISUALIZATION + +stepread [locate_data_file bug28414_bug_toroidal_surface.stp] a * + +checkshape a_1 f + +checkprops a_1 -s 3593.35 + +checkgravitycenter a_1 -s -30. 0. 137.993 0.001 + +vinit +vdisplay a_1 +vfit + +vdump $imagedir/${casename}.png \ No newline at end of file diff --git a/tests/bugs/step/bug32350 b/tests/bugs/step/bug32350 new file mode 100644 index 0000000000..4fe9624748 --- /dev/null +++ b/tests/bugs/step/bug32350 @@ -0,0 +1,36 @@ +puts "===================================================" +puts "0032350: Data Exchange - STEPControl_Writer.writeStream(std::ostream)" +puts "===================================================" +puts "" + +pload XDE OCAF MODELING VISUALIZATION + +Close D -silent + +set aTmpFile1 "$imagedir/${casename}_1.stp" +set aTmpFile2 "$imagedir/${casename}_2.stp" + +ReadStep D [locate_data_file "as1-oc-214-mat.stp"] -stream + +WriteStep D "$aTmpFile1" +WriteStep D "$aTmpFile2" -stream + +ReadStep D1 "$aTmpFile1" +ReadStep D2 "$aTmpFile2" + +file delete "$aTmpFile1" +file delete "$aTmpFile2" + +vclear +vinit View1 +XDisplay -dispMode 1 D +vfit +vdump "$imagedir/${casename}_src.png" + +vclear +XDisplay -dispMode 1 D1 +vdump "$imagedir/${casename}_out1.png" + +vclear +XDisplay -dispMode 1 D2 +vdump "$imagedir/${casename}_out2.png" diff --git a/tests/bugs/step/bug32922 b/tests/bugs/step/bug32922 index ed26939c1e..1c32f0dcc2 100644 --- a/tests/bugs/step/bug32922 +++ b/tests/bugs/step/bug32922 @@ -15,80 +15,18 @@ if { [info exists imagedir] == 0 } { file mkdir ${imagedir} } } - -# Generating resource file where all shape healing is off -set fdata { -ToSTEP.exec.op : SplitCommonVertex,DirectFaces - -FromSTEP.exec.op : FixShape - -FromSTEP.FixShape.Tolerance3d : &Runtime.Tolerance -FromSTEP.FixShape.MaxTolerance3d : &Runtime.MaxTolerance -FromSTEP.FixShape.MinTolerance3d : 1.e-7 -FromSTEP.FixShape.FixFreeShellMode : 0 -FromSTEP.FixShape.FixFreeFaceMode : 0 -FromSTEP.FixShape.FixFreeWireMode : 0 -FromSTEP.FixShape.FixSameParameterMode : 0 - -FromSTEP.FixShape.FixSolidMode : 0 -FromSTEP.FixShape.FixShellOrientationMode : 0 -FromSTEP.FixShape.CreateOpenSolidMode : 0 - -FromSTEP.FixShape.FixShellMode : 0 -FromSTEP.FixShape.FixFaceOrientationMode : 0 - -FromSTEP.FixShape.FixFaceMode : 0 -FromSTEP.FixShape.FixWireMode : 0 -FromSTEP.FixShape.FixOrientationMode : 0 -FromSTEP.FixShape.FixAddNaturalBoundMode : 0 -FromSTEP.FixShape.FixMissingSeamMode : 0 -FromSTEP.FixShape.FixSmallAreaWireMode : 0 -FromSTEP.FixShape.RemoveSmallAreaFaceMode : 0 -FromSTEP.FixShape.FixIntersectingWiresMode : 0 -FromSTEP.FixShape.FixLoopWiresMode : 0 -FromSTEP.FixShape.FixSplitFaceMode : 0 -FromSTEP.FixShape.AutoCorrectPrecisionMode : 0 -FromSTEP.FixShape.ModifyTopologyMode : 0 -FromSTEP.FixShape.ModifyGeometryMode : 0 -FromSTEP.FixShape.ClosedWireMode : 0 -FromSTEP.FixShape.PreferencePCurveMode : 0 -FromSTEP.FixShape.FixReorderMode : 0 -FromSTEP.FixShape.FixSmallMode : 0 -FromSTEP.FixShape.FixConnectedMode : 0 -FromSTEP.FixShape.FixEdgeCurvesMode : 0 -FromSTEP.FixShape.FixDegeneratedMode : 0 -FromSTEP.FixShape.FixLackingMode : 0 -FromSTEP.FixShape.FixSelfIntersectionMode : 0 -FromSTEP.FixShape.RemoveLoopMode : 0 -FromSTEP.FixShape.FixReversed2dMode : 0 -FromSTEP.FixShape.FixRemovePCurveMode : 0 -FromSTEP.FixShape.FixRemoveCurve3dMode : 0 -FromSTEP.FixShape.FixAddPCurveMode : 0 -FromSTEP.FixShape.FixAddCurve3dMode : 0 -FromSTEP.FixShape.FixSeamMode : 0 -FromSTEP.FixShape.FixShiftedMode : 0 -FromSTEP.FixShape.FixEdgeSameParameterMode : 0 -FromSTEP.FixShape.FixNotchedEdgesMode : 0 -FromSTEP.FixShape.FixTailMode : 0 -FromSTEP.FixShape.MaxTailAngle : 0 -FromSTEP.FixShape.MaxTailWidth : 0 -FromSTEP.FixShape.FixSelfIntersectingEdgeMode : 0 -FromSTEP.FixShape.FixIntersectingEdgesMode : 0 -FromSTEP.FixShape.FixNonAdjacentIntersectingEdgesMode : 0 - -FromSTEP.FixShape.FixVertexPositionMode : 0 -FromSTEP.FixShape.FixVertexToleranceMode : 0 -} - -set new_resource_path ${imagedir} -set resource_file STEP -set fo [open "${new_resource_path}/${resource_file}" "wb"] -puts -nonewline $fo $fdata -close $fo - -# Changing the path to the resource file +# remember the path to the old resource file set old_resource_path $::env(CSF_STEPDefaults) -set env(CSF_STEPDefaults) ${new_resource_path} +# reading old resource file +set anOptions [parse_resource_file "${old_resource_path}/STEP"] +# turn off shape healing +dict set anOptions "FromSTEP.exec.op" "" +# path to new resource file +set new_resource_path ${imagedir} +# creating resource file +create_resource_file "${new_resource_path}/STEP" $anOptions +# changing the path to the resource file +set ::env(CSF_STEPDefaults) ${new_resource_path} # Generating, writing and reading the torus ptorus tor 20 5 @@ -108,4 +46,4 @@ view 1 -2D- 728 20 400 400 checkview -screenshot -2d -path ${imagedir}/${test_image}.png # Restoring the path to the old resource file -set env(CSF_STEPDefaults) ${old_resource_path} +set ::env(CSF_STEPDefaults) ${old_resource_path} diff --git a/tests/bugs/xde/bug27142 b/tests/bugs/xde/bug27142 new file mode 100644 index 0000000000..49a76ca165 --- /dev/null +++ b/tests/bugs/xde/bug27142 @@ -0,0 +1,98 @@ +puts "==========" +puts "0027142: Data Exchange - add possibility to set location in XCAFDoc_ShapeTool interface" +puts "==========" +puts "" + +puts "TODO 0027142 ALL: Error: area of d1" +puts "TODO 0027142 ALL: Error: area of d2" +puts "TODO 0027142 ALL: Error: center of gravity" + +pload OCAF XDE +Close Doc -silent +XNewDoc Doc + +# Create five boxes 'a', 'b', 'c', 'd', 'e' +# Box 'e' will stay at origin of coords +# Boxes 'a', 'b', 'c', 'd' should form the new box of the size 2x2x1 at the point (3 3 0) +box a 1 1 1 +box b 1 1 1 +ttranslate b 1 1 0 +compound a b ab +XAddShape Doc ab +SetName Doc 0:1:1:1 ab +SetName Doc 0:1:1:1:1 ref_a +SetName Doc 0:1:1:1:2 ref_b +SetName Doc 0:1:1:2 a +SetName Doc 0:1:1:3 b +box c 1 1 1 +ttranslate c 1 0 0 +box d 0.5 0.5 0.5 +XAddShape Doc c +SetName Doc 0:1:1:4 ref_c +SetName Doc 0:1:1:5 c +XAddShape Doc d +SetName Doc 0:1:1:6 d +box e 1 1 1 +XAddShape Doc e +SetName Doc 0:1:1:7 e + +# Set location to the assembly (compound of boxes 'a' and 'b') +XSetLocation Doc 0:1:1:1 -rotate 0 0 0 0 0 1 90 -move 4 2 0 +SetName Doc 0:1:1:8 ref_ab +# Set location to the reference to shape (box 'c') +XSetLocation Doc 0:1:1:4 -move 1 0 0 -move 1 3 0 +# Set location to the simple shape (box 'd') +XSetLocation Doc 0:1:1:6 -move 2 2 0 -scale 2 2 0 2 +SetName Doc 0:1:1:9 ref_d + +# Write the document to files of different formats +WriteStep Doc ${imagedir}/step.step +WriteIges Doc ${imagedir}/iges.iges +XSave Doc ${imagedir}/xbf.xbf +Close Doc + +# Read document back and make screenshots +vinit +ReadStep Doc1 ${imagedir}/step.step +XDisplay Doc1; vfit +vdump ${imagedir}/step.png +vclear +ReadIges Doc2 ${imagedir}/iges.iges +XDisplay Doc2; vfit +vdump ${imagedir}/iges.png +vclear +XOpen ${imagedir}/xbf.xbf Doc3 +XDisplay Doc3; vfit +vdump ${imagedir}/xbf.png +vclose + +# Get the box 'd' from the documents +XGetShape d1 Doc1 0:1:1:8 +XGetShape d2 Doc2 0:1:1:4 +XGetShape d3 Doc3 0:1:1:9 + +# Saving disk space +Close Doc1 +Close Doc2 +Close Doc3 +file delete $imagedir/step.step +file delete $imagedir/iges.iges +file delete $imagedir/xbf.xbf + +# Scale transformation doesn't apply in STEP format and incorrectly applies in IGES format + +# Check the areas of the "problem" box 'd' +puts "Check area of the box from STEP file" +checkarea d1 6 1e-7 0.001 +puts "Check area of the box from IGES file" +checkarea d2 6 1e-7 0.001 +puts "Check area of the box from XBF file" +checkarea d3 6 1e-7 0.001 + +# Check the gravity centers of the "problem" box 'd' +puts "Check gravity center of the box from STEP file" +checkgravitycenter d1 -s 2.5 2.5 0.5 1e-7 +puts "Check gravity center of the box from IGES file" +checkgravitycenter d2 -s 2.5 2.5 0.5 1e-7 +puts "Check gravity center of the box from XBF file" +checkgravitycenter d3 -s 2.5 2.5 0.5 1e-7 diff --git a/tests/bugs/xde/bug6283 b/tests/bugs/xde/bug6283 index a19d6ce305..ba5dce2a20 100644 --- a/tests/bugs/xde/bug6283 +++ b/tests/bugs/xde/bug6283 @@ -8,24 +8,49 @@ puts "" set BugNumber OCC6283 +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. +if { [info exists imagedir] == 0 } { + set imagedir ../BugNumber + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } +} +# remember the path to the old resource file +set old_resource_path $::env(CSF_STEPDefaults) +# reading old resource file +set anOptions [parse_resource_file "${old_resource_path}/STEP"] +# activation of ignoring the adding of natural bound +dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" +# path to new resource file +set new_resource_path ${imagedir} +# creating resource file +create_resource_file "${new_resource_path}/STEP" $anOptions +# changing the path to the resource file +set ::env(CSF_STEPDefaults) ${new_resource_path} + set list [stepread [locate_data_file wgehaeuse_surface.stp] a *] if {[lsearch ${list} Error] > -1} { - puts "${BugNumber} : Error during reading attached IGES file" + puts "${BugNumber} : Error during reading attached STEP file" } else { tpcompound comp if [catch { set fixlist [fixshape result comp 1e-7] } res] { - puts "${BugNumber}: Error during fixshape" + puts "${BugNumber}: Error during fixshape" } else { - set index [string first "Segments were disordered; fixed\n" ${fixlist}] + set index [string first "Segments were disordered; fixed\n" ${fixlist}] if {$index != -1} { - puts "Faulty ${BugNumber}" + puts "Faulty ${BugNumber}" } else { - puts "OK ${BugNumber}" + puts "OK ${BugNumber}" } - checkprops result -s 2.22665e+06 -checkshape result - checkview -display result -2d -path ${imagedir}/${test_image}.png + checkprops result -s 2.22665e+06 + checkshape result + checkview -display result -2d -path ${imagedir}/${test_image}.png } } +# Restoring the path to the old resource file +set ::env(CSF_STEPDefaults) ${old_resource_path} + diff --git a/tests/bugs/xde/bug6805 b/tests/bugs/xde/bug6805 old mode 100755 new mode 100644 diff --git a/tests/de/begin b/tests/de/begin index 7dbfbf66fb..66bf8d3526 100644 --- a/tests/de/begin +++ b/tests/de/begin @@ -13,3 +13,47 @@ set lengthunit_start "" # Open a transaction NewCommand D + +# Reads resource file, returns options from file as key-value dict +proc parse_resource_file {theFileName} { + # Creating empty dictionary + set aDict [dict create]; + # Check for resource file + if { [info exists theFileName] == 0 } { + puts "Error: resource file \"${theFileName}\" isn't found" + return $aDict + } + # Open a resource file + set aFD [open "${theFileName}" "rb"] + set aLineNo 0 + # Read line by line + while {[gets $aFD aLine] !=-1 } { + incr aLineNo + # Clear the line from comment + if {[regexp {(^[^!]+)} $aLine match aClearLine]} { + # remove spaces + set aClearLine [string trim $aClearLine] + if {[string length $aClearLine] != 0} { + if {[regexp {(\S+)\s*:\s*(\S*)} $aClearLine match aKey aValue]} { + dict set aDict $aKey $aValue + } else { + puts "Error: syntax error in resource file at line: ${aLineNo}" + } + } + } + } + close $aFD + return $aDict +} + +# Creates new resource file with options as key-value dict +proc create_resource_file {theFileName theOptions} { + # Open a resource file + set aFD [open "${theFileName}" "wb"] + set aLineNo 0 + # Write line by line + dict for {aKey aValue} $theOptions { + puts $aFD "${aKey} : ${aValue}" + } + close $aFD +} diff --git a/tests/de/end b/tests/de/end index be9d6b28f0..cc0c34c71a 100644 --- a/tests/de/end +++ b/tests/de/end @@ -67,12 +67,24 @@ if { [string length $filename] > 1} { set tmp [param read.step.product.mode OFF] } set path_file [locate_data_file $filename] + + if { [info exists de_use_custom_scripts] } { + puts "Executing custom script for the test before reading data from file..." + set old_resource_path [de_before_script $filename] + } + if { [catch { $ReadCommand D_First $path_file } catch_result] } { set err_msg "Error: First - file was not read - exception " puts $err_msg append todo_msg $todo_mask $err_msg $end_line set mist 1 } + + if { [info exists de_use_custom_scripts] } { + puts "Executing custom script for the test after reading data from file..." + de_after_script $old_resource_path + unset de_use_custom_scripts + } } else { set mist 1 diff --git a/tests/de/iges_1/G8 b/tests/de/iges_1/G8 index 60f9cda3c5..f2b249db24 100644 --- a/tests/de/iges_1/G8 +++ b/tests/de/iges_1/G8 @@ -16,3 +16,39 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_IGESDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/IGES"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromIGES.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/IGES" $anOptions + # changing the path to the resource file + set ::env(CSF_IGESDefaults) ${new_resource_path} + puts "New path to IGES resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_IGESDefaults) ${old_resource_path} + puts "Restore path to IGES resource file: \"${old_resource_path}\"" +} diff --git a/tests/de/iges_1/J9 b/tests/de/iges_1/J9 index 516117f8f7..64b4f46cba 100644 --- a/tests/de/iges_1/J9 +++ b/tests/de/iges_1/J9 @@ -20,3 +20,39 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_IGESDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/IGES"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromIGES.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/IGES" $anOptions + # changing the path to the resource file + set ::env(CSF_IGESDefaults) ${new_resource_path} + puts "New path to IGES resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_IGESDefaults) ${old_resource_path} + puts "Restore path to IGES resource file: \"${old_resource_path}\"" +} diff --git a/tests/de/step_1/E1 b/tests/de/step_1/E1 index cf236b539a..b903a708cd 100644 --- a/tests/de/step_1/E1 +++ b/tests/de/step_1/E1 @@ -20,3 +20,39 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} \ No newline at end of file diff --git a/tests/de/step_1/E2 b/tests/de/step_1/E2 index a9dc84a82c..141debb92f 100644 --- a/tests/de/step_1/E2 +++ b/tests/de/step_1/E2 @@ -20,3 +20,39 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} \ No newline at end of file diff --git a/tests/de/step_1/G9 b/tests/de/step_1/G9 index ec8cda4fd2..712a3e5982 100644 --- a/tests/de/step_1/G9 +++ b/tests/de/step_1/G9 @@ -22,3 +22,39 @@ NLAYERS : NLayers = 0 ( 1 ) LAYERS : Layers = ( 001 ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} diff --git a/tests/de/step_1/J6 b/tests/de/step_1/J6 index f98dd6f7c2..c684948fa6 100755 --- a/tests/de/step_1/J6 +++ b/tests/de/step_1/J6 @@ -1,6 +1,8 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: Update of 3D-Parameters has failed" -puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" +puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" +puts "TODO CR23096 ALL: NBSHAPES : Faulty" +puts "TODO CR23096 ALL: STATSHAPE : Faulty" set filename bm1_pe_t4.stp @@ -8,8 +10,8 @@ set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) TPSTAT : Faulties = 0 ( 3 ) Warnings = 13 ( 30 ) Summary = 13 ( 33 ) CHECKSHAPE : Wires = 3 ( 2 ) Faces = 3 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 0 ( 0 ) Shell = 12 ( 12 ) Face = 15 ( 15 ) -STATSHAPE : Solid = 0 ( 0 ) Shell = 12 ( 12 ) Face = 15 ( 15 ) FreeWire = 0 ( 0 ) +NBSHAPES : Solid = 0 ( 0 ) Shell = 13 ( 12 ) Face = 16 ( 15 ) +STATSHAPE : Solid = 0 ( 0 ) Shell = 13 ( 12 ) Face = 16 ( 15 ) FreeWire = 0 ( 0 ) TOLERANCE : MaxTol = 1562.051497 ( 1562.051497 ) AvgTol = 272.6255712 ( 211.9512858 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) diff --git a/tests/de/step_2/B3 b/tests/de/step_2/B3 index efa4373c29..e08538bf00 100644 --- a/tests/de/step_2/B3 +++ b/tests/de/step_2/B3 @@ -20,3 +20,39 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} diff --git a/tests/de/step_2/Q5 b/tests/de/step_2/Q5 index 807def6dc3..035864159a 100644 --- a/tests/de/step_2/Q5 +++ b/tests/de/step_2/Q5 @@ -16,3 +16,40 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} + diff --git a/tests/de/step_2/Q6 b/tests/de/step_2/Q6 index 908b5fbf1c..1df2560691 100644 --- a/tests/de/step_2/Q6 +++ b/tests/de/step_2/Q6 @@ -16,3 +16,40 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # turn off the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} + diff --git a/tests/de/step_3/B9 b/tests/de/step_3/B9 index a3cf0a8375..2e78a1347f 100644 --- a/tests/de/step_3/B9 +++ b/tests/de/step_3/B9 @@ -22,3 +22,40 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} + diff --git a/tests/de/step_3/C8 b/tests/de/step_3/C8 index e9c1a96ca9..4f47b33248 100644 --- a/tests/de/step_3/C8 +++ b/tests/de/step_3/C8 @@ -20,3 +20,40 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} + diff --git a/tests/de/step_3/E4 b/tests/de/step_3/E4 index 941eff477c..cc5b077c81 100644 --- a/tests/de/step_3/E4 +++ b/tests/de/step_3/E4 @@ -20,3 +20,40 @@ NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) } + +# Due to the ambiguous interpretation of the "inner" wire on the surfaces +# that have natural bound (is it the cutout in the whole surface, or it's just wrong wire orientation), +# we must manually turn off the adding of the natural bound option of the shape healing for this test. + +set de_use_custom_scripts 1 + +proc de_before_script {TheFileName} { + if { [info exists imagedir] == 0 } { + set imagedir ../[file rootname $TheFileName] + if {![file exists ${imagedir}]} { + file mkdir ${imagedir} + } + } + # remember the path to the old resource file + set old_resource_path $::env(CSF_STEPDefaults) + # reading old resource file + set anOptions [parse_resource_file "${old_resource_path}/STEP"] + # activation of ignoring the adding of natural bound + dict set anOptions "FromSTEP.FixShape.FixAddNaturalBoundMode" "0" + # path to new resource file + set new_resource_path ${imagedir} + # creating resource file + create_resource_file "${new_resource_path}/STEP" $anOptions + # changing the path to the resource file + set ::env(CSF_STEPDefaults) ${new_resource_path} + puts "New path to STEP resource file is: \"${new_resource_path}\"" + + return ${old_resource_path} +} + +proc de_after_script {old_resource_path} { + # Restoring the path to the old resource file + set ::env(CSF_STEPDefaults) ${old_resource_path} + puts "Restore path to STEP resource file: \"${old_resource_path}\"" +} + diff --git a/tests/de_wrapper/configuration/A3 b/tests/de_wrapper/configuration/A3 index a54692fb9c..e3a1934835 100644 --- a/tests/de_wrapper/configuration/A3 +++ b/tests/de_wrapper/configuration/A3 @@ -62,7 +62,6 @@ provider.STEP.OCC.write.layer : 1 provider.STEP.OCC.write.props : 1 provider.STEP.OCC.write.model.type : 0 provider.VRML.OCC.read.file.unit : 1 -provider.VRML.OCC.read.memory.limit : -1 provider.VRML.OCC.read.file.coordinate.system : 1 provider.VRML.OCC.read.system.coordinate.system : 0 provider.VRML.OCC.read.fill.incomplete : 1 diff --git a/tests/evolved/voluved/HMC010 b/tests/evolved/voluved/HMC010 index 6ea24a3b5e..dd63f25b95 100644 --- a/tests/evolved/voluved/HMC010 +++ b/tests/evolved/voluved/HMC010 @@ -2,7 +2,7 @@ puts "==========" puts "OCC29523" puts "==========" -cpulimit 60 +cpulimit 120 restore [locate_data_file bug29523_cut_extrudewire09.brep] sw restore [locate_data_file bug29523_cut_toolwire09.brep] tw diff --git a/tests/hlr/poly_hlr/C13 b/tests/hlr/poly_hlr/C13 index bd4cf9a1cc..6a502fbb74 100644 --- a/tests/hlr/poly_hlr/C13 +++ b/tests/hlr/poly_hlr/C13 @@ -1,5 +1,5 @@ set viewname "vright" -set length 9548.13 +set length 9547.12 testreadstep [locate_data_file bug27341_Assembly_ABS_1_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C14 b/tests/hlr/poly_hlr/C14 index c49df14909..f76cc9ee72 100644 --- a/tests/hlr/poly_hlr/C14 +++ b/tests/hlr/poly_hlr/C14 @@ -1,5 +1,5 @@ set viewname "vright" -set length 5497.6 +set length 5501.45 testreadstep [locate_data_file bug27341_Assembly_BILZ_WFL2_1_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C16 b/tests/hlr/poly_hlr/C16 index 21f8c48b6c..4c2ecbe5c2 100644 --- a/tests/hlr/poly_hlr/C16 +++ b/tests/hlr/poly_hlr/C16 @@ -1,5 +1,5 @@ set viewname "vright" -set length 1662.87 +set length 1662.85 testreadstep [locate_data_file bug27341_CCS_Adapter_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C20 b/tests/hlr/poly_hlr/C20 index 0697995c73..ae4a9db262 100644 --- a/tests/hlr/poly_hlr/C20 +++ b/tests/hlr/poly_hlr/C20 @@ -1,5 +1,5 @@ set viewname "vright" -set length 1704.6 +set length 1704.86 testreadstep [locate_data_file bug27341_Drehkopf_HSK_Gewinde_R_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C3 b/tests/hlr/poly_hlr/C3 index 6efe35f15c..b6806e8256 100644 --- a/tests/hlr/poly_hlr/C3 +++ b/tests/hlr/poly_hlr/C3 @@ -1,5 +1,5 @@ set viewname "vright" -set length 3059.05 +set length 3057.35 testreadstep [locate_data_file bug27341_570-DWLNL-40-08-L_131LANG_16VERSATZ_DIN.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C5 b/tests/hlr/poly_hlr/C5 index 140df6fbfd..1c072cb09d 100644 --- a/tests/hlr/poly_hlr/C5 +++ b/tests/hlr/poly_hlr/C5 @@ -1,5 +1,5 @@ set viewname "vright" -set length 1718.9 +set length 1723.27 testreadstep [locate_data_file bug27341_ABS_Adapter_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C6 b/tests/hlr/poly_hlr/C6 index b63823c549..e0ad37efcc 100644 --- a/tests/hlr/poly_hlr/C6 +++ b/tests/hlr/poly_hlr/C6 @@ -1,5 +1,5 @@ set viewname "vright" -set length 2832.05 +set length 2832.09 testreadstep [locate_data_file bug27341_ABS_Grundhalter_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/C7 b/tests/hlr/poly_hlr/C7 index 76688f7cad..802b51a028 100644 --- a/tests/hlr/poly_hlr/C7 +++ b/tests/hlr/poly_hlr/C7 @@ -1,5 +1,5 @@ set viewname "vright" -set length 2261.81 +set length 2262.59 testreadstep [locate_data_file bug27341_AIF_Grundhalter_GR1_CAD.stp] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/bug23625_1 b/tests/hlr/poly_hlr/bug23625_1 index 598634bec4..ed7a28c97a 100644 --- a/tests/hlr/poly_hlr/bug23625_1 +++ b/tests/hlr/poly_hlr/bug23625_1 @@ -3,16 +3,8 @@ puts "OCC23625" puts "============" puts "" -puts "REQUIRED All: Meshing statuses: SelfIntersectingWire Failure" - set viewname "vfront" -set length 26411.7 +set length 26411.2 restore [locate_data_file bug23625_a1.brep] a - -# workaround bug 0031426 until fix -vinit View1 -vdefaults -autoTriang 0 -incmesh a 7.6 - COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/bug23625_2 b/tests/hlr/poly_hlr/bug23625_2 index 8ae9139745..09558857a0 100644 --- a/tests/hlr/poly_hlr/bug23625_2 +++ b/tests/hlr/poly_hlr/bug23625_2 @@ -4,7 +4,7 @@ puts "============" puts "" set viewname "vfront" -set length 27126.9 +set length 27223.1 restore [locate_data_file bug23625_a2.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/lowalgos/intss/bug32850 b/tests/lowalgos/intss/bug32850 new file mode 100644 index 0000000000..8312243c35 --- /dev/null +++ b/tests/lowalgos/intss/bug32850 @@ -0,0 +1,19 @@ +puts "========" +puts "0032850: Modeling Algorithms - Surface Surface Intersect Lost one line" +puts "========" +puts "" + +cylinder s1 25.8071575178163 0 -373.974517822281 0 1 0 -1.73024882663956e-06 0 0.999999999998503 408.974517822893 +trim s1 s1 0 0.0225015452057227 -146.010003766057 2146.01000376606 +cylinder s2 0 1974.19284248218 -373.974517822281 1 0 0 -0 1.73024882663956e-06 0.999999999998503 408.974517822893 +trim s2 s2 0 0.0225015452057227 -146.010003766057 946.010003766057 +mkface f1 s1; +mkface f2 s2; +set log [bopcurves f1 f2] +regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} $log full Toler NbCurv +if {$NbCurv != 4} { + puts "Error: Number of curves is wrong" +} +if { $Toler > 1.0e-12} { + puts "Error: Big tolerance value" +} \ No newline at end of file diff --git a/tests/mesh/data/standard/X1 b/tests/mesh/data/standard/X1 index d09c119532..fc5a589950 100755 --- a/tests/mesh/data/standard/X1 +++ b/tests/mesh/data/standard/X1 @@ -6,7 +6,7 @@ set TheFileName shading_wrongshape_030.brep set bug_cross "OCC22687" set nbcross(All) 4 if { [string compare $command "shading"] == 0 } { - set rel_tol 0.48575382373356474 + set rel_tol 0.4953655446472135 } else { set rel_tol 0.1856053577754922 } diff --git a/tests/perf/modalg/bug29093 b/tests/perf/modalg/bug29093 new file mode 100644 index 0000000000..43f155e093 --- /dev/null +++ b/tests/perf/modalg/bug29093 @@ -0,0 +1,30 @@ +puts "========" +puts "0029093: BOP PaveFiller hungs and constantly consumes memory" +puts "========" +puts "" + +bclearobjects; +bcleartools; + +restore [locate_data_file bug29093.brep] a + +explode a So +baddobjects a_7 +baddtools a_9 + +dchrono cr restart + +bfillds +bbuild result + +dchrono cr stop counter bbuild + +checkshape result +checkprops result -s 1329680 -v 34507100 +checknbshapes result -vertex 5 -edge 13 -wire 9 -face 9 -shell 3 -solid 3 + +smallview +donly result +fit + +checkview -display result -2d -path ${imagedir}/${test_image}.png diff --git a/tools/TKDFBrowser/CMakeLists.txt b/tools/TKDFBrowser/CMakeLists.txt index a2a5445156..94ffde503a 100644 --- a/tools/TKDFBrowser/CMakeLists.txt +++ b/tools/TKDFBrowser/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKDFBrowser) +set (TKDFBrowser_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKMessageModel/CMakeLists.txt b/tools/TKMessageModel/CMakeLists.txt index a6ef727d9e..69ed7e846a 100644 --- a/tools/TKMessageModel/CMakeLists.txt +++ b/tools/TKMessageModel/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKMessageModel) +set (TKMessageModel_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKMessageView/CMakeLists.txt b/tools/TKMessageView/CMakeLists.txt index ee948ecc72..f1865f107c 100644 --- a/tools/TKMessageView/CMakeLists.txt +++ b/tools/TKMessageView/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKMessageView) +set (TKMessageView_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKShapeView/CMakeLists.txt b/tools/TKShapeView/CMakeLists.txt index c4dd2e935b..b4fe9f9741 100644 --- a/tools/TKShapeView/CMakeLists.txt +++ b/tools/TKShapeView/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKShapeView) +set (TKShapeView_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKTInspector/CMakeLists.txt b/tools/TKTInspector/CMakeLists.txt index 23389b74cd..c7d6932ae9 100644 --- a/tools/TKTInspector/CMakeLists.txt +++ b/tools/TKTInspector/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKTInspector) +set (TKTInspector_DISABLE_COTIRE OFF) + set (INSTALL_API ON) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKTreeModel/CMakeLists.txt b/tools/TKTreeModel/CMakeLists.txt index 0b2d9c65eb..d00a9e69ed 100644 --- a/tools/TKTreeModel/CMakeLists.txt +++ b/tools/TKTreeModel/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKTreeModel) +set (TKTreeModel_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKVInspector/CMakeLists.txt b/tools/TKVInspector/CMakeLists.txt index cbe9037f6d..f57f9f5c10 100644 --- a/tools/TKVInspector/CMakeLists.txt +++ b/tools/TKVInspector/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKVInspector) +set (TKVInspector_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKView/CMakeLists.txt b/tools/TKView/CMakeLists.txt index d630f5bbe3..4733b3a698 100644 --- a/tools/TKView/CMakeLists.txt +++ b/tools/TKView/CMakeLists.txt @@ -1,5 +1,7 @@ project(TKView) +set (TKView_DISABLE_COTIRE OFF) + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)