mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
53f06757c2 | ||
|
0b4962a7f0 | ||
|
b3284f3ba9 | ||
|
b95eefe1c2 | ||
|
5bde4773f9 | ||
|
b0f92d3d5c | ||
|
b9f787f180 | ||
|
a939fd40eb | ||
|
c4ea4ca3d1 | ||
|
f3573fb54b | ||
|
78aade7569 | ||
|
03b0ca59cb | ||
|
d6baf70a93 | ||
|
526c506cb0 | ||
|
2949b238c1 | ||
|
dfb5aebd35 | ||
|
8da2801496 | ||
|
e92d322d40 | ||
|
b71cb85f67 | ||
|
05cfce4d83 | ||
|
d7eefb11bf | ||
|
80d4753574 | ||
|
ed6a17ef6c | ||
|
2182812a5b | ||
|
92915edda8 | ||
|
06aa200142 | ||
|
acac44d571 | ||
|
7aaed2ce3b | ||
|
da76ea432b | ||
|
53152e6dd9 | ||
|
1a1739b200 | ||
|
fd5c113a03 | ||
|
f74f684b16 | ||
|
621ed3bc36 | ||
|
81d569625e | ||
|
6072d3093c | ||
|
e1b097eb67 | ||
|
92d22d7d62 | ||
|
1b423e3287 | ||
|
cb8519be19 | ||
|
617a2905a9 | ||
|
18559e93cf | ||
|
c2e01cc5cc | ||
|
0acc1ab47c | ||
|
b315a85dd7 | ||
|
411ad1a819 | ||
|
bbf49a300c | ||
|
0bab2704ae | ||
|
33c8a72788 | ||
|
315ed0be41 | ||
|
d74b1e9dd3 | ||
|
b47b075ac5 | ||
|
7a52478f16 | ||
|
9db675b3d6 | ||
|
e1d576bf31 | ||
|
e1f7382910 | ||
|
dee5eb82b5 | ||
|
c2eed2a326 | ||
|
3a2ca49b6d | ||
|
4f53e7b37c | ||
|
e01ce0cd52 | ||
|
34c407eb34 | ||
|
ef4e5e3bf1 | ||
|
ca1491f88b | ||
|
b284dc42dc | ||
|
a0ffd4a521 | ||
|
07e803dee1 | ||
|
ec2d883e53 | ||
|
1593d38b13 | ||
|
aaa03c1efb | ||
|
b2bce1d928 | ||
|
581016faeb | ||
|
6bf38f219b |
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
|
||||
cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
|
||||
|
||||
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/adm/cmake")
|
||||
|
||||
@@ -6,6 +6,26 @@ set (CMAKE_SUPPRESS_REGENERATION TRUE)
|
||||
|
||||
set (CMAKE_CONFIGURATION_TYPES Release Debug RelWithDebInfo CACHE INTERNAL "" FORCE)
|
||||
|
||||
# set using C++ standard
|
||||
set (BUILD_CPP_STANDARD "C++11" CACHE STRING "Select using c++ standard.")
|
||||
set_property(CACHE BUILD_CPP_STANDARD PROPERTY STRINGS "C++11" "C++14" "C++17" "C++20" "C++23")
|
||||
|
||||
# Set desired C++ standard
|
||||
if ("${BUILD_CPP_STANDARD}" STREQUAL "C++11")
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++14")
|
||||
set (CMAKE_CXX_STANDARD 14)
|
||||
elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++17")
|
||||
set (CMAKE_CXX_STANDARD 17)
|
||||
elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++20")
|
||||
set (CMAKE_CXX_STANDARD 20)
|
||||
elseif ("${BUILD_CPP_STANDARD}" STREQUAL "C++23")
|
||||
set (CMAKE_CXX_STANDARD 23)
|
||||
else ()
|
||||
message (FATAL_ERROR, "misprint in c++ standard name")
|
||||
endif()
|
||||
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# macro: include patched file if it exists
|
||||
macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
|
||||
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${BEING_INCLUDED_FILE}.cmake")
|
||||
@@ -800,6 +820,12 @@ else()
|
||||
OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
|
||||
endif()
|
||||
|
||||
# ExpToCasExe
|
||||
if (EMSCRIPTEN)
|
||||
list (REMOVE_ITEM BUILD_TOOLKITS TKExpress)
|
||||
list (REMOVE_ITEM BUILD_TOOLKITS ExpToCasExe)
|
||||
endif()
|
||||
|
||||
# bison
|
||||
if (BUILD_YACCLEX)
|
||||
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
|
||||
|
@@ -3,5 +3,5 @@ ModelingData TKG2d TKG3d TKGeomBase TKBRep
|
||||
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
|
||||
Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost
|
||||
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF
|
||||
DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade
|
||||
DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade TKExpress ExpToCasExe
|
||||
Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
|
||||
|
@@ -480,3 +480,6 @@ n TreeModel
|
||||
n View
|
||||
n ViewControl
|
||||
n VInspector
|
||||
n Express
|
||||
t TKExpress
|
||||
x ExpToCasExe
|
||||
|
@@ -22,6 +22,4 @@ if (3RDPARTY_DIR)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# bison 3.2 is required because it provides options to avoid generation of redundant header
|
||||
# files and embedding of local paths in the generated code
|
||||
find_package (BISON 3.2)
|
||||
find_package (BISON 3.7.4)
|
||||
|
@@ -32,15 +32,13 @@ if(__COTIRE_INCLUDED)
|
||||
endif()
|
||||
set(__COTIRE_INCLUDED TRUE)
|
||||
|
||||
# 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()
|
||||
# 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)
|
||||
|
||||
set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}")
|
||||
set (COTIRE_CMAKE_MODULE_VERSION "1.7.9")
|
||||
|
@@ -1,4 +1,96 @@
|
||||
# Draco - a library for a lossy vertex data compression, used as extension to glTF format.
|
||||
# https://github.com/google/draco
|
||||
|
||||
THIRDPARTY_PRODUCT("DRACO" "draco/compression/decode.h" "CSF_Draco" "")
|
||||
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()
|
||||
|
||||
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)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR)
|
||||
set (3RDPARTY_DRACO_LIBRARY_DIR "" CACHE PATH "The directory containing Draco library")
|
||||
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)
|
||||
if (DRACO_DIR_NAME)
|
||||
set (3RDPARTY_DRACO_DIR "${3RDPARTY_DIR}/${DRACO_DIR_NAME}" CACHE PATH "The directory containing Draco" FORCE)
|
||||
endif()
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
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)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DRACO_INCLUDE_DIR AND EXISTS "${3RDPARTY_DRACO_INCLUDE_DIR}")
|
||||
list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_DRACO_INCLUDE_DIR}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_DRACO_INCLUDE_DIR)
|
||||
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 (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}"
|
||||
PATH_SUFFIXES lib
|
||||
CMAKE_FIND_ROOT_PATH_BOTH
|
||||
NO_DEFAULT_PATH)
|
||||
if (3RDPARTY_DRACO_LIBRARY AND EXISTS "${3RDPARTY_DRACO_LIBRARY}")
|
||||
get_filename_component (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY}" PATH)
|
||||
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 (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")
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -26,9 +26,7 @@ if (3RDPARTY_DIR)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# flex 2.5.37 is required because closest known lower version, 2.5.3 from WOK 6.8.0,
|
||||
# generates code which is unusable on Windows (includes unistd.h without any way to avoid this)
|
||||
find_package (FLEX 2.5.37)
|
||||
find_package (FLEX 2.6.4)
|
||||
|
||||
if (NOT FLEX_FOUND OR NOT FLEX_INCLUDE_DIR OR NOT EXISTS "${FLEX_INCLUDE_DIR}/FlexLexer.h")
|
||||
list (APPEND 3RDPARTY_NOT_INCLUDED FLEX_INCLUDE_DIR)
|
||||
|
@@ -116,9 +116,9 @@ if (MSVC)
|
||||
else()
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]"))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshorten-64-to-32")
|
||||
endif()
|
||||
if (BUILD_SHARED_LIBS)
|
||||
@@ -130,14 +130,10 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMP
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
|
||||
if (APPLE)
|
||||
# CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated.
|
||||
set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
||||
elseif(NOT WIN32)
|
||||
# CLang for Windows (at least CLang 8.0 distributed with VS 2019)
|
||||
# does not support option "-std=c++0x"
|
||||
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
# Optimize size of binaries
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
@@ -148,14 +144,10 @@ elseif(MINGW)
|
||||
# workaround bugs in mingw with vtable export
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
|
||||
|
||||
# Require C++11
|
||||
set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}")
|
||||
# Optimize size of binaries
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
|
||||
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
|
||||
# Require C++11
|
||||
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
|
||||
# Optimize size of binaries
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
|
||||
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
|
||||
|
@@ -80,9 +80,9 @@ macro (OCCT_MAKE_COMPILER_SHORT_NAME)
|
||||
set (COMPILER gcc)
|
||||
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (COMPILER gxx)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
|
||||
set (COMPILER clang)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Ii][Nn][Tt][Ee][Ll]")
|
||||
set (COMPILER icc)
|
||||
else()
|
||||
set (COMPILER ${CMAKE_GENERATOR})
|
||||
@@ -589,9 +589,7 @@ macro (OCCT_UPDATE_TARGET_FILE)
|
||||
endif()
|
||||
|
||||
install (CODE
|
||||
"cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0007 NEW)
|
||||
string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWERCASE)
|
||||
"string (TOLOWER \"\${CMAKE_INSTALL_CONFIG_NAME}\" CMAKE_INSTALL_CONFIG_NAME_LOWERCASE)
|
||||
file (GLOB ALL_OCCT_TARGET_FILES \"${INSTALL_DIR}/${INSTALL_DIR_CMAKE}/OpenCASCADE*Targets-\${CMAKE_INSTALL_CONFIG_NAME_LOWERCASE}.cmake\")
|
||||
foreach(TARGET_FILENAME \${ALL_OCCT_TARGET_FILES})
|
||||
file (STRINGS \"\${TARGET_FILENAME}\" TARGET_FILE_CONTENT)
|
||||
@@ -600,8 +598,7 @@ macro (OCCT_UPDATE_TARGET_FILE)
|
||||
string (REGEX REPLACE \"[\\\\]?[\\\$]{OCCT_INSTALL_BIN_LETTER}\" \"\${OCCT_INSTALL_BIN_LETTER}\" line \"\${line}\")
|
||||
file (APPEND \"\${TARGET_FILENAME}\" \"\${line}\\n\")
|
||||
endforeach()
|
||||
endforeach()
|
||||
cmake_policy(POP)")
|
||||
endforeach()")
|
||||
endmacro()
|
||||
|
||||
macro (OCCT_INSERT_CODE_FOR_TARGET)
|
||||
@@ -615,17 +612,14 @@ macro (OCCT_INSERT_CODE_FOR_TARGET)
|
||||
endmacro()
|
||||
|
||||
macro (OCCT_UPDATE_DRAW_DEFAULT_FILE)
|
||||
install(CODE "cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0007 NEW)
|
||||
set (DRAW_DEFAULT_FILE_NAME \"${INSTALL_DIR}/${INSTALL_DIR_RESOURCE}/DrawResources/DrawPlugin\")
|
||||
install(CODE "set (DRAW_DEFAULT_FILE_NAME \"${INSTALL_DIR}/${INSTALL_DIR_RESOURCE}/DrawResources/DrawPlugin\")
|
||||
file (STRINGS \"\${DRAW_DEFAULT_FILE_NAME}\" DRAW_DEFAULT_CONTENT)
|
||||
file (REMOVE \"\${DRAW_DEFAULT_FILE_NAME}\")
|
||||
foreach (line IN LISTS DRAW_DEFAULT_CONTENT)
|
||||
string (REGEX MATCH \": TK\([a-zA-Z]+\)$\" IS_TK_LINE \"\${line}\")
|
||||
string (REGEX REPLACE \": TK\([a-zA-Z]+\)$\" \": TK\${CMAKE_MATCH_1}${BUILD_SHARED_LIBRARY_NAME_POSTFIX}\" line \"\${line}\")
|
||||
file (APPEND \"\${DRAW_DEFAULT_FILE_NAME}\" \"\${line}\\n\")
|
||||
endforeach()
|
||||
cmake_policy(POP)")
|
||||
endforeach()")
|
||||
endmacro()
|
||||
|
||||
macro (OCCT_CREATE_SYMLINK_TO_FILE LIBRARY_NAME LINK_NAME)
|
||||
|
@@ -106,6 +106,12 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES})
|
||||
set (BISON_OUTPUT_FILE_EXT "cxx")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (EXISTS ${FLEX_BISON_TARGET_DIR}/FlexLexer.h)
|
||||
message (STATUS "Info: remove old FLEX header file: ${FLEX_BISON_TARGET_DIR}/FlexLexer.h")
|
||||
file(REMOVE ${FLEX_BISON_TARGET_DIR}/FlexLexer.h)
|
||||
endif()
|
||||
|
||||
file (STRINGS "${CURRENT_FLEX_FILE}" FILE_FLEX_CONTENT)
|
||||
foreach (FILE_FLEX_CONTENT_LINE ${FILE_FLEX_CONTENT})
|
||||
string (REGEX MATCH "%option c\\+\\+" CXX_FLEX_LANGUAGE_FOUND ${FILE_FLEX_CONTENT_LINE})
|
||||
@@ -121,6 +127,19 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES})
|
||||
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT})
|
||||
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.${FLEX_OUTPUT_FILE_EXT})
|
||||
|
||||
if (EXISTS ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT})
|
||||
message (STATUS "Info: remove old output BISON file: ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT}")
|
||||
file(REMOVE ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT})
|
||||
endif()
|
||||
if (EXISTS ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.hxx)
|
||||
message (STATUS "Info: remove old output BISON file: ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.hxx")
|
||||
file(REMOVE ${FLEX_BISON_TARGET_DIR}/${CURRENT_BISON_FILE_NAME}.tab.hxx)
|
||||
endif()
|
||||
if (EXISTS ${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE})
|
||||
message (STATUS "Info: remove old output FLEX file: ${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE}")
|
||||
file(REMOVE ${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE})
|
||||
endif()
|
||||
|
||||
BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} "${FLEX_BISON_TARGET_DIR}/${BISON_OUTPUT_FILE}"
|
||||
COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME} -l -M ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/=")
|
||||
FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} "${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE}"
|
||||
@@ -320,10 +339,10 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
|
||||
else() # get CSF_ value
|
||||
set (CURRENT_CSF ${${USED_ITEM}})
|
||||
if (NOT "x${CURRENT_CSF}" STREQUAL "x")
|
||||
if ("${CURRENT_CSF}" STREQUAL "CSF_OpenGlLibs")
|
||||
if ("${CURRENT_CSF}" STREQUAL "${CSF_OpenGlLibs}")
|
||||
add_definitions (-DHAVE_OPENGL)
|
||||
endif()
|
||||
if ("${CURRENT_CSF}" STREQUAL "CSF_OpenGlesLibs")
|
||||
if ("${CURRENT_CSF}" STREQUAL "${CSF_OpenGlesLibs}")
|
||||
add_definitions (-DHAVE_GLES2)
|
||||
endif()
|
||||
|
||||
|
@@ -1,5 +1,13 @@
|
||||
# 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()
|
||||
@@ -69,226 +77,186 @@ else()
|
||||
set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "the path to tbb.h" FORCE)
|
||||
endif()
|
||||
|
||||
# common steps for tbb and tbbmalloc
|
||||
macro (TBB_PRODUCT_SEARCH PRODUCT_LIBRARY_NAME)
|
||||
# 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()
|
||||
|
||||
string (TOUPPER ${PRODUCT_LIBRARY_NAME} upper_PRODUCT_LIBRARY_NAME)
|
||||
# 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}")
|
||||
|
||||
# define required tbb/tbbmalloc variables
|
||||
if (NOT DEFINED 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY OR NOT 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}")
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
endif()
|
||||
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()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (NOT DEFINED 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL OR NOT 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR OR NOT EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR}")
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL "" CACHE FILEPATH "${upper_PRODUCT_LIBRARY_NAME} shared library" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32 AND NOT DEFINED 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} shared library")
|
||||
endif()
|
||||
|
||||
# check 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_ paths for consistency with specified 3RDPARTY_TBB_DIR
|
||||
if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
|
||||
CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY FILEPATH "the path to ${upper_PRODUCT_LIBRARY_NAME} library")
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}")
|
||||
get_filename_component (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}" PATH)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
else()
|
||||
CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL FILEPATH "the path to ${upper_PRODUCT_LIBRARY_NAME} shared library")
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL AND EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}")
|
||||
get_filename_component (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}" PATH)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} shared library" FORCE)
|
||||
else()
|
||||
|
||||
CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} shared library")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
OCCT_MAKE_COMPILER_SHORT_NAME()
|
||||
OCCT_MAKE_COMPILER_BITNESS()
|
||||
|
||||
if (${COMPILER_BITNESS} EQUAL 32)
|
||||
set (${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME ia32)
|
||||
# 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()
|
||||
set (${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME intel64)
|
||||
endif()
|
||||
|
||||
# tbb/tbbmalloc library
|
||||
if (NOT 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}")
|
||||
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a)
|
||||
set (PRODUCT_PATH_SUFFIXES lib ${PRODUCT_LIBRARY_NAME})
|
||||
|
||||
# set 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY "3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
|
||||
if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
|
||||
if (NOT EXISTS "${3RDPARTY_TBB_DIR}/lib/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${COMPILER}")
|
||||
if (EXISTS "${3RDPARTY_TBB_DIR}/lib/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}")
|
||||
file (GLOB ${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST "${3RDPARTY_TBB_DIR}/lib/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/*")
|
||||
if (${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST)
|
||||
list (GET ${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST -1 THE_MOST_FRESH_COMPILER_VERSION)
|
||||
if (THE_MOST_FRESH_COMPILER_VERSION)
|
||||
get_filename_component (THE_MOST_FRESH_COMPILER_VERSION_NAME "${THE_MOST_FRESH_COMPILER_VERSION}" NAME)
|
||||
set (PRODUCT_PATH_SUFFIXES lib ${PRODUCT_LIBRARY_NAME} lib/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${THE_MOST_FRESH_COMPILER_VERSION_NAME})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set (PRODUCT_PATH_SUFFIXES lib ${PRODUCT_LIBRARY_NAME} lib/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${COMPILER})
|
||||
endif()
|
||||
|
||||
find_library (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY ${PRODUCT_LIBRARY_NAME}
|
||||
PATHS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}" "${3RDPARTY_TBB_DIR}"
|
||||
PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
|
||||
CMAKE_FIND_ROOT_PATH_BOTH
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY ${PRODUCT_LIBRARY_NAME}
|
||||
PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
|
||||
CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}")
|
||||
get_filename_component (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}" PATH)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
else()
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
# 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}).")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR AND EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}")
|
||||
list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY_DIR)
|
||||
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "The path to ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
endif()
|
||||
|
||||
# tbb/tbbmalloc shared library
|
||||
if (WIN32)
|
||||
if (NOT 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .dll)
|
||||
set (PRODUCT_PATH_SUFFIXES bin)
|
||||
|
||||
# set 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL "3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL-NOTFOUND" CACHE FILEPATH "${upper_PRODUCT_LIBRARY_NAME} shared library" FORCE)
|
||||
|
||||
if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
|
||||
if (NOT EXISTS "${3RDPARTY_TBB_DIR}/bin/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${COMPILER}")
|
||||
if (EXISTS "${3RDPARTY_TBB_DIR}/bin/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}")
|
||||
file (GLOB ${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST "${3RDPARTY_TBB_DIR}/bin/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/*")
|
||||
if (${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST)
|
||||
list (GET ${upper_PRODUCT_LIBRARY_NAME}_COMPILER_LIST -1 THE_MOST_FRESH_COMPILER_VERSION)
|
||||
if (THE_MOST_FRESH_COMPILER_VERSION)
|
||||
get_filename_component (THE_MOST_FRESH_COMPILER_VERSION_NAME "${THE_MOST_FRESH_COMPILER_VERSION}" NAME)
|
||||
set (PRODUCT_PATH_SUFFIXES bin bin/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${THE_MOST_FRESH_COMPILER_VERSION_NAME})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set (PRODUCT_PATH_SUFFIXES bin bin/${${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME}/${COMPILER})
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
|
||||
find_library (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL ${PRODUCT_LIBRARY_NAME}
|
||||
PATHS "${3RDPARTY_TBB_DIR}"
|
||||
PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL ${PRODUCT_LIBRARY_NAME} PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES})
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL AND EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}")
|
||||
get_filename_component (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}" PATH)
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
|
||||
else()
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR "" CACHE PATH "The directory containing ${upper_PRODUCT_LIBRARY_NAME} shared library" FORCE)
|
||||
|
||||
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL "" CACHE FILEPATH "${upper_PRODUCT_LIBRARY_NAME} shared library" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR OR EXISTS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR}")
|
||||
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL_DIR)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install tbb/tbbmalloc
|
||||
if (INSTALL_TBB)
|
||||
OCCT_MAKE_OS_WITH_BITNESS()
|
||||
OCCT_MAKE_COMPILER_SHORT_NAME()
|
||||
|
||||
if (WIN32)
|
||||
if (SINGLE_GENERATOR)
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL} DESTINATION "${INSTALL_DIR_BIN}")
|
||||
else()
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}
|
||||
CONFIGURATIONS Release
|
||||
DESTINATION "${INSTALL_DIR_BIN}")
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
DESTINATION "${INSTALL_DIR_BIN}i")
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL}
|
||||
CONFIGURATIONS Debug
|
||||
DESTINATION "${INSTALL_DIR_BIN}d")
|
||||
endif()
|
||||
else()
|
||||
get_filename_component (PRODUCT_LIBRARY_NAME ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY} NAME)
|
||||
|
||||
if (SINGLE_GENERATOR)
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}.2
|
||||
DESTINATION "${INSTALL_DIR_LIB}"
|
||||
RENAME ${PRODUCT_LIBRARY_NAME}.2)
|
||||
else()
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}.2
|
||||
CONFIGURATIONS Release
|
||||
DESTINATION "${INSTALL_DIR_LIB}"
|
||||
RENAME ${PRODUCT_LIBRARY_NAME}.2)
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}.2
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
DESTINATION "${INSTALL_DIR_LIB}i"
|
||||
RENAME ${PRODUCT_LIBRARY_NAME}.2)
|
||||
install (FILES ${3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY}.2
|
||||
CONFIGURATIONS Debug
|
||||
DESTINATION "${INSTALL_DIR_LIB}d"
|
||||
RENAME ${PRODUCT_LIBRARY_NAME}.2)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
mark_as_advanced (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY 3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_DLL)
|
||||
endmacro()
|
||||
|
||||
#if (BUILD_SHARED_LIBS)
|
||||
separate_arguments (CSF_TBB)
|
||||
foreach (LIB IN LISTS CSF_TBB)
|
||||
TBB_PRODUCT_SEARCH (${LIB})
|
||||
endforeach()
|
||||
# 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 (INSTALL_TBB)
|
||||
set (USED_3RDPARTY_TBB_DIR "")
|
||||
if ("${PROPERTY_TO_SET}" STREQUAL "LIBRARY")
|
||||
get_target_property (FILE_NAME "${TARGET_NAME}" IMPORTED_IMPLIB_RELEASE)
|
||||
else()
|
||||
# the library directory for using by the executable
|
||||
if (WIN32)
|
||||
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR})
|
||||
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)
|
||||
else()
|
||||
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR})
|
||||
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_${LIB_NAME}_${PROPERTY_TO_SET}_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}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_DLL_DIRS "${FILE_DIR}")
|
||||
endif()
|
||||
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}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if (WIN32)
|
||||
# Here we should set:
|
||||
# - 3RDPARTY_*_LIBRARY
|
||||
# - 3RDPARTY_*_LIBRARY_DIR
|
||||
# - 3RDPARTY_*_DLL
|
||||
# - 3RDPARTY_*_DLL_DIR
|
||||
# where * - is TBB or TBBMALLOC
|
||||
|
||||
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()
|
||||
endif()
|
||||
else()
|
||||
if (SINGLE_GENERATOR)
|
||||
foreach (LIB IN LISTS CSF_TBB)
|
||||
string(TOUPPER "${LIB}" LIB_UPPER)
|
||||
install (FILES ${3RDPARTY_${LIB_UPPER}_LIBRARY} DESTINATION "${INSTALL_DIR_LIB}")
|
||||
endforeach()
|
||||
else()
|
||||
foreach (LIB IN LISTS CSF_TBB)
|
||||
string(TOUPPER "${LIB}" LIB_UPPER)
|
||||
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()
|
||||
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})
|
||||
else()
|
||||
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -780,14 +780,14 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
|
||||
}
|
||||
}
|
||||
if { "$::tcl_platform(platform)" == "windows" } {
|
||||
set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter"]
|
||||
set aTbbDllPath [wokdep:SearchBin "tbb12.dll" "$anArchIter"]
|
||||
if { "$aTbbDllPath" == "" } {
|
||||
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{tbb}*] $aVcLib "$anArchIter" ]
|
||||
set aTbbDllPath [wokdep:SearchBin "tbb.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"]
|
||||
set aTbbDllPath [wokdep:SearchBin "tbb12.dll" "$anArchIter" "$aPath/bin/$aSubDir/$aVcLib"]
|
||||
if { "$aTbbDllPath" != "" } {
|
||||
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/$aSubDir/$aVcLib"
|
||||
} else {
|
||||
lappend anErrBin$anArchIter "Error: 'tbb.dll' not found (Intel TBB)"
|
||||
lappend anErrBin$anArchIter "Error: 'tbb12.dll' not found (Intel TBB)"
|
||||
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
|
||||
}
|
||||
}
|
||||
|
179
adm/genproj.tcl
179
adm/genproj.tcl
@@ -1233,28 +1233,11 @@ proc osutils:convertModules { theModules theSrcDir theSourceDirOther theProjects
|
||||
lappend aProjectsInModule($aModule) $aToolKit
|
||||
lappend aDependencies [LibToLink $aToolKit $theSrcDir $theSourceDirOther]
|
||||
}
|
||||
# executables, assume one project per cxx file...
|
||||
# executables
|
||||
foreach aUnit [OS:executable ${aModule}] {
|
||||
set aUnitLoc $aUnit
|
||||
set src_files [_get_used_files $aUnit $theSrcDir false]
|
||||
set aSrcFiles {}
|
||||
foreach s $src_files {
|
||||
regexp {source ([^\s]+)} $s dummy name
|
||||
lappend aSrcFiles $name
|
||||
}
|
||||
foreach aSrcFile $aSrcFiles {
|
||||
set aFileExtension [file extension $aSrcFile]
|
||||
if { $aFileExtension == ".cxx" } {
|
||||
set aPrjName [file rootname $aSrcFile]
|
||||
lappend aProjects $aPrjName
|
||||
lappend aProjectsInModule($aModule) $aPrjName
|
||||
if {[file isdirectory $path/$theSrcDir/$aUnitLoc]} {
|
||||
lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile] $theSrcDir $theSourceDirOther]
|
||||
} else {
|
||||
lappend aDependencies {}
|
||||
}
|
||||
}
|
||||
}
|
||||
lappend aProjects $aUnit
|
||||
lappend aProjectsInModule($aModule) $aUnit
|
||||
lappend aDependencies [LibToLink $aUnit $theSrcDir $theSourceDirOther]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2110,98 +2093,106 @@ proc osutils:tk:execfiles { theFiles theOutDir theCommand thePrefix theExtension
|
||||
# Generate Visual Studio project file for executable
|
||||
proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir theSourceDirOther } {
|
||||
set aVcFiles {}
|
||||
foreach f [osutils:tk:cxxfiles $theToolKit wnt $theSrcDir] {
|
||||
set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
|
||||
set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
|
||||
|
||||
set aProjName [file rootname [file tail $f]]
|
||||
set l_compilable [osutils:compilable wnt]
|
||||
regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
|
||||
set aProjName $theToolKit
|
||||
set l_compilable [osutils:compilable wnt]
|
||||
regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
|
||||
|
||||
upvar $theGuidsMap aGuidsMap
|
||||
if { ! [info exists aGuidsMap($aProjName)] } {
|
||||
set aGuidsMap($aProjName) [OS:genGUID]
|
||||
}
|
||||
regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
|
||||
upvar $theGuidsMap aGuidsMap
|
||||
if { ! [info exists aGuidsMap($aProjName)] } {
|
||||
set aGuidsMap($aProjName) [OS:genGUID]
|
||||
}
|
||||
regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
|
||||
|
||||
set aUsedLibs [list]
|
||||
foreach tkx [osutils:commonUsedTK $theToolKit $theSrcDir $theSourceDirOther] {
|
||||
lappend aUsedLibs "${tkx}.lib"
|
||||
}
|
||||
set aUsedLibs [list]
|
||||
foreach tkx [osutils:commonUsedTK $theToolKit $theSrcDir $theSourceDirOther] {
|
||||
lappend aUsedLibs "${tkx}.lib"
|
||||
}
|
||||
|
||||
set anOsReleaseLibs {}
|
||||
set anOsDebugLibs {}
|
||||
osutils:usedOsLibs $theToolKit "wnt" anOsReleaseLibs aFrameworks $theSrcDir true
|
||||
osutils:usedOsLibs $theToolKit "wnt" anOsDebugLibs aFrameworks $theSrcDir false
|
||||
set anOsReleaseLibs {}
|
||||
set anOsDebugLibs {}
|
||||
osutils:usedOsLibs $theToolKit "wnt" anOsReleaseLibs aFrameworks $theSrcDir true
|
||||
osutils:usedOsLibs $theToolKit "wnt" anOsDebugLibs aFrameworks $theSrcDir false
|
||||
|
||||
set aVCRTVer [string range $theVcVer 0 3]
|
||||
regsub -all -- {__TKDEP__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] aProjTmpl
|
||||
regsub -all -- {__TKDEP_DEBUG__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] aProjTmpl
|
||||
regsub -all -- {__TKDEFINES__} $aProjTmpl "" aProjTmpl
|
||||
set aVCRTVer [string range $theVcVer 0 3]
|
||||
regsub -all -- {__TKDEP__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] aProjTmpl
|
||||
regsub -all -- {__TKDEP_DEBUG__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] aProjTmpl
|
||||
regsub -all -- {__TKDEFINES__} $aProjTmpl "" aProjTmpl
|
||||
|
||||
set aFilesSection ""
|
||||
set aVcFilesCxx(units) ""
|
||||
set aVcFilesHxx(units) ""
|
||||
set aFilesSection ""
|
||||
set aVcFilesCxx(units) ""
|
||||
set aVcFilesHxx(units) ""
|
||||
|
||||
if { ![info exists written([file tail $f])] } {
|
||||
set written([file tail $f]) 1
|
||||
|
||||
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
|
||||
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
|
||||
foreach f [osutils:tk:cxxfiles $theToolKit wnt $theSrcDir] {
|
||||
if { ![info exists written([file tail $f])] } {
|
||||
set written([file tail $f]) 1
|
||||
append aFilesSection [osutils:vcxproj:cxxfile $f "" 3]
|
||||
if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
|
||||
lappend aVcFilesCxx($theToolKit) $f
|
||||
} else {
|
||||
append aFilesSection "\t\t\t<Filter\n"
|
||||
append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
|
||||
append aFilesSection "\t\t\t\t>\n"
|
||||
append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
|
||||
append aFilesSection "\t\t\t</Filter>"
|
||||
puts "Warning : in vcproj there are more than one occurrences for [file tail $f]"
|
||||
}
|
||||
} else {
|
||||
puts "Warning : in vcproj there are more than one occurrences for [file tail $f]"
|
||||
}
|
||||
#puts "$aProjTmpl $aFilesSection"
|
||||
set anIncPaths "..\\..\\..\\inc"
|
||||
regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
|
||||
regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
|
||||
regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
|
||||
} else {
|
||||
append aFilesSection "\t\t\t<Filter\n"
|
||||
append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
|
||||
append aFilesSection "\t\t\t\t>\n"
|
||||
foreach f [osutils:tk:cxxfiles $theToolKit wnt $theSrcDir] {
|
||||
if { ![info exists written([file tail $f])] } {
|
||||
set written([file tail $f]) 1
|
||||
append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
|
||||
} else {
|
||||
puts "Warning : in vcproj there are more than one occurrences for [file tail $f]"
|
||||
}
|
||||
}
|
||||
append aFilesSection "\t\t\t</Filter>"
|
||||
}
|
||||
|
||||
regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
|
||||
#puts "$aProjTmpl $aFilesSection"
|
||||
set anIncPaths "..\\..\\..\\inc"
|
||||
regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
|
||||
regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
|
||||
regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
|
||||
|
||||
set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
|
||||
regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
|
||||
|
||||
set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
|
||||
fconfigure $aFile -translation crlf
|
||||
puts $aFile $aProjTmpl
|
||||
close $aFile
|
||||
|
||||
set aCommonSettingsFile "$aVcFilePath.user"
|
||||
lappend aVcFiles $aVcFilePath
|
||||
|
||||
# write filters file for vc10
|
||||
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
|
||||
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
|
||||
}
|
||||
|
||||
# write resource file
|
||||
lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
|
||||
|
||||
set aCommonSettingsFileTmpl ""
|
||||
if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
|
||||
# nothing
|
||||
} elseif { "$theVcVer" == "vc9" } {
|
||||
set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
|
||||
} else {
|
||||
set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
|
||||
}
|
||||
if { "$aCommonSettingsFileTmpl" != "" } {
|
||||
regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
|
||||
|
||||
set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
|
||||
fconfigure $aFile -translation crlf
|
||||
puts $aFile $aProjTmpl
|
||||
puts $aFile $aCommonSettingsFileTmpl
|
||||
close $aFile
|
||||
|
||||
set aCommonSettingsFile "$aVcFilePath.user"
|
||||
lappend aVcFiles $aVcFilePath
|
||||
|
||||
# write filters file for vc10
|
||||
if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
|
||||
lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
|
||||
}
|
||||
|
||||
# write resource file
|
||||
lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
|
||||
|
||||
set aCommonSettingsFileTmpl ""
|
||||
if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
|
||||
# nothing
|
||||
} elseif { "$theVcVer" == "vc9" } {
|
||||
set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
|
||||
} else {
|
||||
set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
|
||||
}
|
||||
if { "$aCommonSettingsFileTmpl" != "" } {
|
||||
regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
|
||||
|
||||
set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
|
||||
fconfigure $aFile -translation crlf
|
||||
puts $aFile $aCommonSettingsFileTmpl
|
||||
close $aFile
|
||||
|
||||
lappend aVcFiles "$aCommonSettingsFile"
|
||||
}
|
||||
lappend aVcFiles "$aCommonSettingsFile"
|
||||
}
|
||||
|
||||
return $aVcFiles
|
||||
}
|
||||
|
||||
|
17
dox/build/build_3rdparty/building_3rdparty.md
vendored
17
dox/build/build_3rdparty/building_3rdparty.md
vendored
@@ -128,8 +128,9 @@ You can download its sources from https://freetype.org/
|
||||
|
||||
@subsection dev_guides__building_3rdparty_win_3_1 TBB
|
||||
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb.
|
||||
Go to the **Download** page, find the release version you need (e.g. `tbb30_018oss`) and pick the archive for Windows platform.
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0.
|
||||
Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Windows platform.
|
||||
To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-win.zip`)
|
||||
|
||||
Unpack the downloaded archive of TBB product into the `3rdparty` folder.
|
||||
|
||||
@@ -304,9 +305,9 @@ Download the necessary archive from https://freetype.org/ and unpack it.
|
||||
|
||||
@subsection dev_guides__building_3rdparty_linux_3_1 TBB
|
||||
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb.
|
||||
Go to the **Download** page, find the release version you need and pick the archive for Linux platform.
|
||||
To install, unpack the downloaded archive of TBB product.
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0.
|
||||
Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Linux platform.
|
||||
To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-lin.tgz`).
|
||||
|
||||
@subsection dev_guides__building_3rdparty_linux_3_3 FreeImage
|
||||
|
||||
@@ -477,9 +478,9 @@ Download the necessary archive from https://freetype.org/ and unpack it.
|
||||
|
||||
@subsection dev_guides__building_3rdparty_osx_3_1 TBB
|
||||
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/intel/tbb.
|
||||
Go to the **Download** page, find the release version you need (e.g. `tbb30_018oss`) and pick the archive for Mac OS X platform.
|
||||
To install, unpack the downloaded archive of TBB product (`tbb30_018oss_osx.tgz`).
|
||||
This third-party product is installed with binaries from the archive that can be downloaded from https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0.
|
||||
Go to the **Download** page, find the release version you need (e.g. `oneTBB 2021.5.0`) and pick the archive for Mac OS X platform.
|
||||
To install, unpack the downloaded archive of TBB product (`oneapi-tbb-2021.5.0-mac.tgz`).
|
||||
|
||||
@subsection dev_guides__building_3rdparty_osx_3_3 FreeImage
|
||||
|
||||
|
@@ -17,7 +17,7 @@ On Linux and macOS we recommend to use libraries maintained by distributive deve
|
||||
@section build_occt_win_cmake Building with CMake tool
|
||||
|
||||
This chapter describes the [CMake](https://cmake.org/download/)-based build process, which is now suggested as a standard way to produce the binaries of Open CASCADE Technology from sources.
|
||||
OCCT requires CMake version 2.8.12 or later.
|
||||
OCCT requires CMake version 3.1 or later.
|
||||
|
||||
CMake is a tool that generates the actual project files for the selected target build system (e.g. Unix makefiles) or IDE (e.g. Visual Studio 2010).
|
||||
Here we describe the build procedure on the example of Windows platform with Visual Studio 2010.
|
||||
@@ -113,6 +113,7 @@ The following table gives the full list of environment variables used at the con
|
||||
| BUILD_PATCH | Path | Points to the directory recognized as a "patch" for OCCT. If specified, the files from this directory take precedence over the corresponding native OCCT sources. This way you are able to introduce patches to Open CASCADE Technology not affecting the original source distribution |
|
||||
| BUILD_WITH_DEBUG | Boolean | Enables extended messages of many OCCT algorithms, usually printed to cout. These include messages on internal errors and special cases encountered, timing, etc. |
|
||||
| BUILD_ENABLE_FPE_SIGNAL_HANDLER | Boolean | Enable/Disable the floating point exceptions (FPE) during DRAW execution only. Corresponding environment variable (CSF_FPE) can be changed manually in custom.bat/sh scripts without regeneration by CMake. |
|
||||
| BUILD_CPP_STANDARD | String | Employ corresponding c++ standard (C++11, C++14, ..C++23) for building OCCT |
|
||||
| CMAKE_CONFIGURATION_TYPES | String | Semicolon-separated CMake configurations |
|
||||
| INSTALL_DIR | Path | Points to the installation directory. *INSTALL_DIR* is a synonym of *CMAKE_INSTALL_PREFIX*. The user can specify both *INSTALL_DIR* or *CMAKE_INSTALL_PREFIX* |
|
||||
| INSTALL_DIR_BIN | Path | Relative path to the binaries installation directory (absolute path is ${INSTALL_DIR}/${INSTALL_DIR_BIN}) |
|
||||
|
@@ -341,7 +341,7 @@ The tables below describe the recommended software configurations for which OCCT
|
||||
|
||||
| OS | Compiler |
|
||||
| --------- | ----------- |
|
||||
| Windows | Microsoft Visual Studio: 2013 Update 5, 2015 Update 3, 2017 <sup>1</sup>, 2019, 2022 <br>, LLVM (ClangCL), GCC 4.3+ (Mingw-w64)|
|
||||
| Windows | Microsoft Visual Studio: 2015 Update 3, 2017 <sup>1</sup>, 2019, 2022 <br>, LLVM (ClangCL), GCC 4.3+ (Mingw-w64)|
|
||||
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
|
||||
| OS X / macOS | XCode 6 or newer |
|
||||
| Android | NDK r12, GNU gcc 4.9 or newer |
|
||||
@@ -359,8 +359,8 @@ https://dev.opencascade.org/resources/download/3rd-party-components
|
||||
|
||||
| Component | Where to find | Used for | Purpose |
|
||||
| --------- | ------------- | -------- | -------------------- |
|
||||
| CMake 2.8+ | https://cmake.org/ | Configuration | Build from sources |
|
||||
| Intel TBB 4.x or later | https://oneapi-src.github.io/oneTBB/ | All | Parallelization of algorithms (alternative to built-in thread pool) |
|
||||
| CMake 3.1+ | https://cmake.org/ | Configuration | Build from sources |
|
||||
| Intel oneTBB 2021.5.0 | https://github.com/oneapi-src/oneTBB/releases/tag/v2021.5.0 | All | Parallelization of algorithms (alternative to built-in thread pool) |
|
||||
| OpenGL 3.3+, OpenGL ES 2.0+ | System | Visualization | Required for using 3D Viewer |
|
||||
| OpenVR 1.10+ | https://github.com/ValveSoftware/openvr | Visualization | VR (Virtual Reality) support in 3D Viewer |
|
||||
| FreeType 2.4+ | https://www.freetype.org/download.html | Visualization | Text rendering in 3D Viewer |
|
||||
@@ -572,8 +572,7 @@ FreeType 2 is released under two open-source licenses: BSD-like FreeType License
|
||||
It is a library that helps you to take advantage of multi-core processor performance without having to be a threading expert.
|
||||
Threading Building Blocks is not just a threads-replacement library. It represents a higher-level, task-based parallelism that
|
||||
abstracts platform details and threading mechanisms for scalability and performance.
|
||||
TBB version 2017 is available under Apache 2.0 license, while older versions
|
||||
until 4.4 are available under GPLv2 license with the runtime exception (https://www.threadingbuildingblocks.org).
|
||||
Intel oneTBB 2021.5.0 is available under Apache 2.0 license (https://www.threadingbuildingblocks.org).
|
||||
|
||||
**OpenGL** is an industry standard API for 3D graphics used by OCCT for
|
||||
implementation of 3D viewer. OpenGL specification is developed by the
|
||||
|
@@ -2338,3 +2338,8 @@ or to include system OpenGL headers in advance (with help of `OpenGl_GlNative.hx
|
||||
|
||||
Method `StdPrs_ToolTriangulatedShape::Normal()` has been removed.
|
||||
Please use `BRepLib_ToolTriangulatedShape::ComputeNormals()` to fill in normal attributes in triangulation and fetch them directly using `Poly_Triangulation::Normal()`.
|
||||
|
||||
@subsection upgrade_occt770_shapeproximity BRepExtrema_ShapeProximity
|
||||
|
||||
A new way of using the `BRepExtrema_ShapeProximity` class was provided for computing a proximity value between two shapes.
|
||||
If at initialization of the `BRepExtrema_ShapeProximity` class the *theTolerance* parameter is not defined (Precision::Infinite() by default), the proximity value will be computed.
|
||||
|
@@ -326,7 +326,8 @@ The <i>Geom2dConvert</i> package provides the following:
|
||||
* a global function which is used to construct a BSpline curve from a bounded curve based on a 2D curve from the Geom2d package,
|
||||
* a splitting algorithm which computes the points at which a 2D BSpline curve should be cut in order to obtain arcs with the same degree of continuity,
|
||||
* global functions used to construct the BSpline curves created by this splitting algorithm, or by other types of segmentation of the BSpline curve,
|
||||
* an algorithm which converts a 2D BSpline curve into a series of adjacent Bezier curves.
|
||||
* an algorithm which converts a 2D BSpline curve into a series of adjacent Bezier curves,
|
||||
* an algorithm which converts an arbitrary 2D curve into a series of adjacent 2D circular arcs and 2D linear segments.
|
||||
|
||||
The <i>GeomConvert</i> package also provides the following:
|
||||
|
||||
@@ -338,7 +339,8 @@ The <i>GeomConvert</i> package also provides the following:
|
||||
* a splitting algorithm, which determines the curves along which a BSpline surface should be cut in order to obtain patches with the same degree of continuity,
|
||||
* global functions to construct BSpline surfaces created by this splitting algorithm, or by other types of BSpline surface segmentation,
|
||||
* an algorithm, which converts a BSpline surface into a series of adjacent Bezier surfaces,
|
||||
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
|
||||
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
|
||||
* algorithms that converts NURBS, Bezier and other general parametrized curves and surface into anaytical curves and surfaces.
|
||||
|
||||
@subsection occt_modat_1_4 Points on Curves
|
||||
|
||||
|
@@ -1007,6 +1007,25 @@ Standard_Integer aNbOffsetSurfaces = aCheckContents.NbOffsetSurf();
|
||||
Handle(TopTools_HSequenceOfShape) aSeqFaces = aCheckContents.OffsetSurfaceSec();
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_shg_3_2_4 Analysis of shape underlined geometry
|
||||
|
||||
Class *ShapeAnalysis_CanonicalRecognition* provides tools that analyze geometry of shape and explore the possibility of converting geometry into a canonical form.
|
||||
Canonical forms for curves are lines, circles and ellipses.
|
||||
Canonical forms for surfaces are planar, cylindrical, conical and spherical surfaces.
|
||||
|
||||
Recognition and converting into canonical form is performed according to maximal deviation criterium: maximal distance between initial and canonical geometrical objects must be less, than given value.
|
||||
|
||||
Analysis of curves is allowed for following shapes:
|
||||
* edge - algorithm checks 3d curve of edge
|
||||
* wire - algorithm checks 3d curves of all edges in order to convert them in the same analytical curve
|
||||
|
||||
Analysis of surfaces is allowed for following shapes:
|
||||
* face - algorithm checks surface of face
|
||||
* shell - algorithm checks surfaces of all faces in order to convert them in the same analytical surface
|
||||
* edge - algorithm checks all surfaces that are shared by given edge in order convert one of them in analytical surface, which most close to the input sample surface.
|
||||
* wire - the same as for edge, but algorithm checks all edges of wire in order to find analytical surface, which most close to the input sample surface.
|
||||
|
||||
|
||||
@section occt_shg_4 Upgrading
|
||||
|
||||
Upgrading tools are intended for adaptation of shapes for better use by Open CASCADE Technology or for customization to particular needs, i.e. for export to another system.
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>IE_WPF_D3D</RootNamespace>
|
||||
<AssemblyName>IE_WPF_D3D</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>IE_WPF_WinForms</RootNamespace>
|
||||
<AssemblyName>IE_WPF_WinForms</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
|
@@ -35,4 +35,4 @@
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
|
@@ -4,7 +4,6 @@ project(glfw-occt-demo)
|
||||
|
||||
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/adm/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(APP_VERSION_MAJOR 1)
|
||||
set(APP_VERSION_MINOR 0)
|
||||
set(APP_TARGET glfwocct)
|
||||
|
@@ -39,9 +39,9 @@ elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
|
||||
set (MY_COMPILER gcc)
|
||||
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (MY_COMPILER gcc)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Cc][Ll][Aa][Nn][Gg]")
|
||||
set (MY_COMPILER clang)
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "[Ii][Nn][Tt][Ee][Ll]")
|
||||
set (MY_COMPILER icc)
|
||||
else()
|
||||
set (MY_COMPILER ${CMAKE_GENERATOR})
|
||||
|
@@ -37,7 +37,7 @@ list(APPEND aLibDeps lib_FreeType)
|
||||
# system libraries
|
||||
list(APPEND aLibDeps EGL GLESv2 log android)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -frtti -fexceptions -fpermissive")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -frtti -fexceptions -fpermissive")
|
||||
|
||||
add_library(TKJniSample SHARED ${SOURCE_FILES})
|
||||
target_link_libraries(TKJniSample ${aLibDeps})
|
||||
|
@@ -1,4 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
# 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)
|
||||
|
||||
project (Geometry)
|
||||
|
||||
|
@@ -1,4 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
# 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)
|
||||
|
||||
project (Modeling)
|
||||
|
||||
|
@@ -1,4 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
# 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)
|
||||
|
||||
project (ImportExport)
|
||||
|
||||
|
@@ -1,4 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
# 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)
|
||||
|
||||
project (HLR)
|
||||
|
||||
|
@@ -1,4 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
# 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)
|
||||
|
||||
project (mfcsample)
|
||||
|
||||
|
@@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(occt-webgl-sample)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(APP_VERSION_MAJOR 1)
|
||||
set(APP_VERSION_MINOR 0)
|
||||
set(APP_TARGET occt-webgl-sample)
|
||||
|
@@ -251,7 +251,9 @@ void AIS_Animation::Stop()
|
||||
myState = AnimationState_Stopped;
|
||||
if (!myTimer.IsNull())
|
||||
{
|
||||
const Standard_Real anElapsedTime = ElapsedTime();
|
||||
myTimer->Stop();
|
||||
myTimer->Seek (Min (Duration(), anElapsedTime));
|
||||
}
|
||||
|
||||
for (NCollection_Sequence<Handle(AIS_Animation)>::Iterator anIter (myAnimations); anIter.More(); anIter.Next())
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Select3D_SensitiveCircle.hxx>
|
||||
#include <Select3D_SensitivePoly.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
@@ -41,9 +42,9 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_Circle,AIS_InteractiveObject)
|
||||
AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& aComponent):
|
||||
AIS_InteractiveObject(PrsMgr_TOP_AllView),
|
||||
myComponent(aComponent),
|
||||
myUStart(0.),
|
||||
myUEnd(2*M_PI),
|
||||
myCircleIsArc(Standard_False),
|
||||
myUStart (0.0),
|
||||
myUEnd (2.0 * M_PI),
|
||||
myCircleIsArc (Standard_False),
|
||||
myIsFilledCircleSens (Standard_False)
|
||||
{
|
||||
}
|
||||
@@ -60,7 +61,7 @@ AIS_Circle::AIS_Circle(const Handle(Geom_Circle)& theComponent,
|
||||
myComponent (theComponent),
|
||||
myUStart (theUStart),
|
||||
myUEnd (theUEnd),
|
||||
myCircleIsArc (Standard_True),
|
||||
myCircleIsArc (Abs (Abs (theUEnd - theUStart) - 2.0 * M_PI) > gp::Resolution()),
|
||||
myIsFilledCircleSens (theIsFilledCircleSens)
|
||||
{
|
||||
}
|
||||
@@ -207,14 +208,14 @@ void AIS_Circle::UnsetWidth()
|
||||
//function : ComputeCircle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
|
||||
void AIS_Circle::ComputeCircle (const Handle(Prs3d_Presentation)& thePresentation)
|
||||
{
|
||||
|
||||
GeomAdaptor_Curve curv(myComponent);
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient(1.e-5);
|
||||
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
|
||||
myDrawer->SetDeviationCoefficient(prevdev);
|
||||
myDrawer->SetDeviationCoefficient (1.e-5);
|
||||
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer);
|
||||
myDrawer->SetDeviationCoefficient (prevdev);
|
||||
|
||||
}
|
||||
|
||||
@@ -223,13 +224,13 @@ void AIS_Circle::ComputeCircle( const Handle(Prs3d_Presentation)& aPresentation)
|
||||
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
|
||||
void AIS_Circle::ComputeArc (const Handle(Prs3d_Presentation)& thePresentation)
|
||||
{
|
||||
GeomAdaptor_Curve curv(myComponent,myUStart,myUEnd);
|
||||
GeomAdaptor_Curve curv(myComponent, myUStart, myUEnd);
|
||||
Standard_Real prevdev = myDrawer->DeviationCoefficient();
|
||||
myDrawer->SetDeviationCoefficient(1.e-5);
|
||||
StdPrs_DeflectionCurve::Add(aPresentation,curv,myDrawer);
|
||||
myDrawer->SetDeviationCoefficient(prevdev);
|
||||
myDrawer->SetDeviationCoefficient (1.e-5);
|
||||
StdPrs_DeflectionCurve::Add (thePresentation, curv, myDrawer);
|
||||
myDrawer->SetDeviationCoefficient (prevdev);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -237,27 +238,25 @@ void AIS_Circle::ComputeArc( const Handle(Prs3d_Presentation)& aPresentation)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_Circle::ComputeCircleSelection(const Handle(SelectMgr_Selection)& aSelection)
|
||||
void AIS_Circle::ComputeCircleSelection (const Handle(SelectMgr_Selection)& theSelection)
|
||||
{
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
|
||||
myComponent->Circ(),
|
||||
myIsFilledCircleSens);
|
||||
aSelection->Add(seg);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitiveCircle) aCirc = new Select3D_SensitiveCircle (anOwner,
|
||||
myComponent->Circ(),
|
||||
myIsFilledCircleSens);
|
||||
theSelection->Add (aCirc);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ComputeArcSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelection)
|
||||
void AIS_Circle::ComputeArcSelection (const Handle(SelectMgr_Selection)& theSelection)
|
||||
{
|
||||
|
||||
|
||||
Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitiveCircle) seg = new Select3D_SensitiveCircle (eown,
|
||||
myComponent->Circ(),
|
||||
myUStart, myUEnd,
|
||||
myIsFilledCircleSens);
|
||||
aSelection->Add(seg);
|
||||
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this);
|
||||
Handle(Select3D_SensitivePoly) aSeg = new Select3D_SensitivePoly (anOwner,
|
||||
myComponent->Circ(),
|
||||
myUStart, myUEnd,
|
||||
myIsFilledCircleSens);
|
||||
theSelection->Add (aSeg);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Created on: 1997-01-17
|
||||
// Created on: 1997-01-17
|
||||
// Created by: Robert COUBLANC
|
||||
// Copyright (c) 1997-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
@@ -1001,6 +1001,14 @@ void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_Interactiv
|
||||
return;
|
||||
}
|
||||
|
||||
TColStd_ListOfInteger aModes;
|
||||
ActivatedModes (theIO, aModes);
|
||||
|
||||
for (TColStd_ListIteratorOfListOfInteger aModesIter (aModes); aModesIter.More(); aModesIter.Next())
|
||||
{
|
||||
mgrSelector->Deactivate (theIO, aModesIter.Value());
|
||||
}
|
||||
|
||||
mgrSelector->RecomputeSelection (theIO);
|
||||
|
||||
const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIO);
|
||||
@@ -1010,10 +1018,7 @@ void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_Interactiv
|
||||
return;
|
||||
}
|
||||
|
||||
TColStd_ListOfInteger aModes;
|
||||
ActivatedModes (theIO, aModes);
|
||||
TColStd_ListIteratorOfListOfInteger aModesIter (aModes);
|
||||
for (; aModesIter.More(); aModesIter.Next())
|
||||
for (TColStd_ListIteratorOfListOfInteger aModesIter (aModes); aModesIter.More(); aModesIter.Next())
|
||||
{
|
||||
mgrSelector->Activate (theIO, aModesIter.Value());
|
||||
}
|
||||
|
@@ -84,9 +84,8 @@ namespace
|
||||
public:
|
||||
//! Main constructor.
|
||||
ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
|
||||
const gp_Circ& theCircle,
|
||||
const Standard_Integer theNbPnts)
|
||||
: Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False, theNbPnts),
|
||||
const gp_Circ& theCircle)
|
||||
: Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False),
|
||||
ManipSensRotation (theCircle.Position().Direction()) {}
|
||||
|
||||
//! Checks whether the circle overlaps current selecting volume
|
||||
@@ -1168,7 +1167,7 @@ void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSe
|
||||
}
|
||||
// define sensitivity by circle
|
||||
const gp_Circ aGeomCircle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
|
||||
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
|
||||
Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle);
|
||||
aCircle->SetSensitivityFactor (15);
|
||||
theSelection->Add (aCircle);
|
||||
// enlarge sensitivity by triangulation
|
||||
|
@@ -1948,7 +1948,7 @@ int mcrcomm_(integer *kop,
|
||||
/* Local variables */
|
||||
intptr_t ideb;
|
||||
doublereal dtab[32000];
|
||||
intptr_t itab[160] = {0} /* was [4][40] */;
|
||||
intptr_t itab[160] /* was [4][40] */;
|
||||
intptr_t ipre;
|
||||
integer i__, j, k;
|
||||
|
||||
@@ -2522,7 +2522,7 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const
|
||||
|
||||
/* Local variables */
|
||||
char cfmt[1];
|
||||
doublereal dfmt = 0.0; // unused
|
||||
doublereal dfmt;
|
||||
integer ifmt, i__, nufmt, ntotal;
|
||||
char subrou[7];
|
||||
|
||||
@@ -2667,7 +2667,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit,
|
||||
integer i__1, i__2;
|
||||
|
||||
/* Local variables */
|
||||
doublereal dfmt = 0.0; // unused
|
||||
doublereal dfmt;
|
||||
integer ifmt, iver;
|
||||
char subr[7];
|
||||
integer ksys , ibyte, irest, ier;
|
||||
|
@@ -77,8 +77,7 @@ static void ComputeTrsf2d(const Handle(TheWLine)& theline,
|
||||
for(Standard_Integer i=1; i<=aNbPnts; i++)
|
||||
{
|
||||
const IntSurf_PntOn2S POn2S = theline->Point(i);
|
||||
Standard_Real U = 0.0;
|
||||
Standard_Real V = 0.0;
|
||||
Standard_Real U,V;
|
||||
(POn2S.*pfunc)(U,V);
|
||||
aUmin = Min(U, aUmin);
|
||||
aVmin = Min(V, aVmin);
|
||||
|
@@ -15,8 +15,13 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Curve2d.hxx>
|
||||
#include <BRepAlgo.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLib_MakeEdge.hxx>
|
||||
@@ -25,10 +30,13 @@
|
||||
#include <ElCLib.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
#include <Geom2dConvert_ApproxArcsSegments.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <GeomConvert.hxx>
|
||||
#include <GeomConvert_CompCurveToBSplineCurve.hxx>
|
||||
#include <GeomLProp.hxx>
|
||||
#include <NCollection_Vector.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <ShapeFix_Shape.hxx>
|
||||
@@ -40,6 +48,7 @@
|
||||
#include <TColStd_SequenceOfBoolean.hxx>
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
@@ -47,6 +56,166 @@
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
// The minimal tolerance of approximation (edges can be defined with yet smaller tolerance)
|
||||
static const Standard_Real MINIMAL_TOLERANCE = 0.0001;
|
||||
|
||||
namespace {
|
||||
|
||||
struct OrientedCurve
|
||||
{
|
||||
Handle(Geom2d_TrimmedCurve) Curve;
|
||||
Standard_Boolean IsReverse;
|
||||
inline gp_Pnt2d Point (const Standard_Boolean isEnd) const
|
||||
{
|
||||
if (isEnd == IsReverse)
|
||||
return Curve->StartPoint();
|
||||
return Curve->EndPoint();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertWire
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Wire BRepAlgo::ConvertWire(const TopoDS_Wire& theWire,
|
||||
const Standard_Real theAngleTol,
|
||||
const TopoDS_Face& theFace)
|
||||
{
|
||||
TopoDS_Wire aResult;
|
||||
Standard_Real aMaxTol(0.);
|
||||
const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace);
|
||||
NCollection_Vector<OrientedCurve> vecCurve;
|
||||
|
||||
BRepTools_WireExplorer anExpE(theWire, theFace);
|
||||
// Explore the edges in the current wire, in their connection order
|
||||
for (; anExpE.More(); anExpE.Next()) {
|
||||
const TopoDS_Edge& anEdge = anExpE.Current();
|
||||
BRepAdaptor_Curve2d aCurve(anEdge, theFace);
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(anEdge);
|
||||
if (aTol < MINIMAL_TOLERANCE)
|
||||
aTol = MINIMAL_TOLERANCE;
|
||||
if (aTol > aMaxTol)
|
||||
aMaxTol = aTol;
|
||||
Geom2dConvert_ApproxArcsSegments anAlgo(aCurve, aTol, theAngleTol);
|
||||
const TColGeom2d_SequenceOfCurve& aResultApprox = anAlgo.GetResult();
|
||||
|
||||
// Form the array of approximated elementary curves
|
||||
if (anEdge.Orientation() == TopAbs_REVERSED) {
|
||||
for (Standard_Integer iCrv = aResultApprox.Length(); iCrv > 0 ; iCrv--) {
|
||||
const Handle(Geom2d_Curve)& aCrv = aResultApprox(iCrv);
|
||||
if (aCrv.IsNull() == Standard_False) {
|
||||
OrientedCurve& anOCurve = vecCurve.Append(OrientedCurve());
|
||||
anOCurve.Curve = Handle(Geom2d_TrimmedCurve)::DownCast(aCrv);
|
||||
anOCurve.IsReverse = Standard_True;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Standard_Integer iCrv = 1; iCrv <= aResultApprox.Length(); iCrv++) {
|
||||
const Handle(Geom2d_Curve)& aCrv = aResultApprox(iCrv);
|
||||
if (aCrv.IsNull() == Standard_False) {
|
||||
OrientedCurve& anOCurve = vecCurve.Append(OrientedCurve());
|
||||
anOCurve.Curve = Handle(Geom2d_TrimmedCurve)::DownCast(aCrv);
|
||||
anOCurve.IsReverse = Standard_False;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vecCurve.Length() > 0)
|
||||
{
|
||||
// Build the first vertex
|
||||
BRep_Builder aVBuilder;
|
||||
gp_Pnt2d aPnt[2] = {
|
||||
vecCurve(0).Point(Standard_False),
|
||||
vecCurve(vecCurve.Length() - 1).Point(Standard_True)
|
||||
};
|
||||
Standard_Real aDist = aPnt[0].Distance(aPnt[1]);
|
||||
if (aDist > aMaxTol + Precision::Confusion())
|
||||
aDist = Precision::Confusion();
|
||||
else {
|
||||
aDist = 0.5 * aDist + Precision::Confusion();
|
||||
aPnt[0] = 0.5 * (aPnt[0].XY() + aPnt[1].XY());
|
||||
}
|
||||
gp_Pnt aPnt3d;
|
||||
aSurf->D0(aPnt[0].X(), aPnt[0].Y(), aPnt3d);
|
||||
TopoDS_Vertex aFirstVertex;
|
||||
aVBuilder.MakeVertex(aFirstVertex, aPnt3d, aDist);
|
||||
|
||||
// Loop creating edges
|
||||
BRepBuilderAPI_MakeWire aMkWire;
|
||||
TopoDS_Edge anEdgeRes;
|
||||
TopoDS_Vertex aVertex = aFirstVertex;
|
||||
for (Standard_Integer iCrv = 0; iCrv < vecCurve.Length(); iCrv++) {
|
||||
const OrientedCurve& anOCurve = vecCurve(iCrv);
|
||||
TopoDS_Vertex aNextVertex;
|
||||
aPnt[0] = anOCurve.Point(Standard_True);
|
||||
if (iCrv == vecCurve.Length() - 1) {
|
||||
aPnt[1] = vecCurve(0).Point(Standard_False);
|
||||
aDist = aPnt[0].Distance(aPnt[1]);
|
||||
if (aDist > aMaxTol + Precision::Confusion()) {
|
||||
aSurf->D0(aPnt[0].X(), aPnt[0].Y(), aPnt3d);
|
||||
aVBuilder.MakeVertex(aNextVertex, aPnt3d, Precision::Confusion());
|
||||
} else {
|
||||
aNextVertex = aFirstVertex;
|
||||
}
|
||||
} else {
|
||||
aPnt[1] = vecCurve(iCrv + 1).Point(Standard_False);
|
||||
aDist = 0.5 * (aPnt[0].Distance(aPnt[1])) + Precision::Confusion();
|
||||
aPnt[0] = 0.5 * (aPnt[0].XY() + aPnt[1].XY());
|
||||
aSurf->D0(aPnt[0].X(), aPnt[0].Y(), aPnt3d);
|
||||
aVBuilder.MakeVertex(aNextVertex, aPnt3d, aDist);
|
||||
}
|
||||
const Standard_Real aParam[2] = {
|
||||
anOCurve.Curve->FirstParameter(),
|
||||
anOCurve.Curve->LastParameter()
|
||||
};
|
||||
if (anOCurve.IsReverse) {
|
||||
BRepBuilderAPI_MakeEdge aMkEdge(anOCurve.Curve, aSurf, aNextVertex,
|
||||
aVertex, aParam[0], aParam[1]);
|
||||
anEdgeRes = aMkEdge.Edge();
|
||||
anEdgeRes.Orientation(TopAbs_REVERSED);
|
||||
} else {
|
||||
BRepBuilderAPI_MakeEdge aMkEdge(anOCurve.Curve, aSurf, aVertex,
|
||||
aNextVertex, aParam[0], aParam[1]);
|
||||
anEdgeRes = aMkEdge.Edge();
|
||||
}
|
||||
aVertex = aNextVertex;
|
||||
aMkWire.Add(anEdgeRes);
|
||||
}
|
||||
|
||||
if (aMkWire.IsDone())
|
||||
aResult = aMkWire.Wire();
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Face BRepAlgo::ConvertFace (const TopoDS_Face& theFace,
|
||||
const Standard_Real theAngleTolerance)
|
||||
{
|
||||
TopoDS_Face aResult;
|
||||
const Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace);
|
||||
BRepBuilderAPI_MakeFace aMkFace(aSurf,Precision::Confusion());
|
||||
|
||||
TopExp_Explorer anExp(theFace, TopAbs_WIRE);
|
||||
for (; anExp.More(); anExp.Next()) {
|
||||
const TopoDS_Wire& aWire = TopoDS::Wire(anExp.Current());
|
||||
const TopoDS_Wire aNewWire = ConvertWire(aWire, theAngleTolerance, theFace);
|
||||
aMkFace.Add(aNewWire);
|
||||
}
|
||||
if (aMkFace.IsDone()) {
|
||||
aResult = aMkFace.Face();
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConcatenateWire
|
||||
//purpose :
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
class TopoDS_Wire;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Face;
|
||||
class TopoDS_Shape;
|
||||
|
||||
|
||||
@@ -43,6 +44,28 @@ public:
|
||||
//! Junction points between edges of wire may be sharp,
|
||||
//! resulting curve of the resulting edge may be C0.
|
||||
Standard_EXPORT static TopoDS_Edge ConcatenateWireC0 (const TopoDS_Wire& Wire);
|
||||
|
||||
//! Method of wire conversion, calls BRepAlgo_Approx internally.
|
||||
//! @param theWire
|
||||
//! Input Wire object.
|
||||
//! @param theAngleTolerance
|
||||
//! Angle (in radians) defining the continuity of the wire: if two vectors
|
||||
//! differ by less than this angle, the result will be smooth (zero angle of
|
||||
//! tangent lines between curve elements).
|
||||
//! @return
|
||||
//! The new TopoDS_Wire object consisting of edges each representing an arc
|
||||
//! of circle or a linear segment. The accuracy of conversion is defined
|
||||
//! as the maximal tolerance of edges in theWire.
|
||||
static Standard_EXPORT TopoDS_Wire ConvertWire
|
||||
(const TopoDS_Wire& theWire,
|
||||
const Standard_Real theAngleTolerance,
|
||||
const TopoDS_Face& theFace);
|
||||
|
||||
//! Method of face conversion. The API corresponds to the method ConvertWire.
|
||||
//! This is a shortcut for calling ConvertWire() for each wire in theFace.
|
||||
static Standard_EXPORT TopoDS_Face ConvertFace
|
||||
(const TopoDS_Face& theFace,
|
||||
const Standard_Real theAngleTolerance);
|
||||
|
||||
//! Checks if the shape is "correct". If not, returns
|
||||
//! <Standard_False>, else returns <Standard_True>.
|
||||
|
@@ -15,186 +15,8 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepTools_Modification.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
|
||||
namespace {
|
||||
|
||||
//! Tool class implementing necessary functionality for copying geometry
|
||||
class BRepBuilderAPI_Copy_Modification : public BRepTools_Modification
|
||||
{
|
||||
public:
|
||||
BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom,
|
||||
const Standard_Boolean copyMesh)
|
||||
: myCopyGeom(copyGeom),
|
||||
myCopyMesh(copyMesh)
|
||||
{
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy face;
|
||||
//! copies surface if requested
|
||||
Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L, Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
RevWires = RevFace = Standard_False;
|
||||
|
||||
if ( ! S.IsNull() && myCopyGeom )
|
||||
S = Handle(Geom_Surface)::DownCast(S->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy triangulation;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (F))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location L;
|
||||
T = BRep_Tool::Triangulation(F, L);
|
||||
|
||||
if (T.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// mesh is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
T = T->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy edge;
|
||||
//! copies curves if requested
|
||||
Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L, Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::Curve (E, L, f, l);
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
|
||||
if ( ! C.IsNull() && myCopyGeom )
|
||||
C = Handle(Geom_Curve)::DownCast(C->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy polygon;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (E))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
P = BRep_Tool::Polygon3D(E, aLoc);
|
||||
|
||||
if (P.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
P = P->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy polygon;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F,
|
||||
Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (E))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(F, aLoc);
|
||||
P = BRep_Tool::PolygonOnTriangulation(E, aTria, aLoc);
|
||||
|
||||
if (P.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
P = P->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy vertex
|
||||
Standard_Boolean NewPoint (const TopoDS_Vertex& V, gp_Pnt& P,
|
||||
Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
P = BRep_Tool::Pnt(V);
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy edge;
|
||||
//! copies pcurve if requested
|
||||
Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF*/,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface (E, F, f, l);
|
||||
|
||||
if ( ! C.IsNull() && myCopyGeom )
|
||||
C = Handle(Geom2d_Curve)::DownCast (C->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy vertex
|
||||
Standard_Boolean NewParameter (const TopoDS_Vertex& V, const TopoDS_Edge& E,
|
||||
Standard_Real& P, Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
if (V.IsNull()) return Standard_False; // infinite edge may have Null vertex
|
||||
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
P = BRep_Tool::Parameter (V, E);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns the continuity of E between F1 and F2
|
||||
GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2, const TopoDS_Edge&,
|
||||
const TopoDS_Face&, const TopoDS_Face&) Standard_OVERRIDE
|
||||
{
|
||||
return BRep_Tool::Continuity (E, F1, F2);
|
||||
}
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_RTTI_INLINE(BRepBuilderAPI_Copy_Modification,BRepTools_Modification)
|
||||
|
||||
private:
|
||||
Standard_Boolean myCopyGeom;
|
||||
Standard_Boolean myCopyMesh;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepBuilderAPI_Copy
|
||||
@@ -203,7 +25,7 @@ private:
|
||||
|
||||
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
|
||||
{
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(Standard_True, Standard_False);
|
||||
myModification = new BRepTools_CopyModification(Standard_True, Standard_False);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +36,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
|
||||
|
||||
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
|
||||
{
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
|
||||
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
|
||||
DoModif(S);
|
||||
}
|
||||
|
||||
@@ -226,7 +48,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_B
|
||||
|
||||
void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
|
||||
{
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
|
||||
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
|
||||
NotDone(); // on force la copie si on vient deja d`en faire une
|
||||
DoModif(S);
|
||||
}
|
||||
|
247
src/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx
Normal file
247
src/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.cxx
Normal file
@@ -0,0 +1,247 @@
|
||||
// Created on: 2022-06-30
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 2022-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepBuilderAPI_MakeShapeOnMesh.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Structure representing mesh edge.
|
||||
struct Edge
|
||||
{
|
||||
//! Constructor. Sets edge nodes.
|
||||
Edge(const Standard_Integer TheIdx1,
|
||||
const Standard_Integer TheIdx2)
|
||||
: Idx1(Min(TheIdx1, TheIdx2)),
|
||||
Idx2(Max(TheIdx1, TheIdx2))
|
||||
{}
|
||||
|
||||
//! Comparison operator.
|
||||
Standard_Boolean operator<(const Edge& other) const
|
||||
{
|
||||
if (Idx1 < other.Idx1 ||
|
||||
(Idx1 == other.Idx1 && Idx2 < other.Idx2))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! First index. It is lower or equal than the second.
|
||||
Standard_Integer Idx1;
|
||||
|
||||
//! Second index.
|
||||
Standard_Integer Idx2;
|
||||
};
|
||||
|
||||
//! Hasher of Edge structure.
|
||||
struct EdgeHasher
|
||||
{
|
||||
|
||||
//! Returns hash code for the given edge.
|
||||
static Standard_Integer HashCode(const Edge& theEdge,
|
||||
const Standard_Integer theUpperBound)
|
||||
{
|
||||
// Circle-based collisions.
|
||||
return ::HashCode(theEdge.Idx1 * theEdge.Idx1 + theEdge.Idx2 * theEdge.Idx2, theUpperBound);
|
||||
}
|
||||
|
||||
//! Returns true if two edges are equal.
|
||||
static Standard_Boolean IsEqual(const Edge& theEdge1,
|
||||
const Edge& theEdge2)
|
||||
{
|
||||
return theEdge1.Idx1 == theEdge2.Idx1 && theEdge1.Idx2 == theEdge2.Idx2;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange)
|
||||
{
|
||||
// Generally, this method guarantees topology sharing by mapping mesh primitives
|
||||
// into topological counterparts.
|
||||
// mesh points -> topological vertices
|
||||
// mesh edges -> topological edges
|
||||
|
||||
// Cannot reconstruct anything from null or empty mesh.
|
||||
if (myMesh.IsNull() || myMesh->NbNodes() == 0 || myMesh->NbTriangles() == 0)
|
||||
return;
|
||||
|
||||
const Standard_Integer aNbNodes = myMesh->NbNodes();
|
||||
const Standard_Integer aNbTriangles = myMesh->NbTriangles();
|
||||
|
||||
// We are going to have three loops: iterate once over nodes and iterate twice
|
||||
// over triangles of input mesh.
|
||||
Message_ProgressScope aPS(theRange,
|
||||
"Per-facet shape construction",
|
||||
Standard_Real(aNbNodes + 2 * aNbTriangles));
|
||||
|
||||
// Build shared vertices.
|
||||
NCollection_IndexedDataMap<Standard_Integer, TopoDS_Vertex> aPnt2VertexMap;
|
||||
|
||||
for (Standard_Integer i = 1; i <= aNbNodes; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
const gp_Pnt aP = myMesh->Node(i);
|
||||
const TopoDS_Vertex aV = BRepBuilderAPI_MakeVertex(aP);
|
||||
aPnt2VertexMap.Add(i, aV);
|
||||
}
|
||||
|
||||
// Build shared edges.
|
||||
NCollection_IndexedDataMap<Edge, TopoDS_Edge, EdgeHasher> anEdgeToTEgeMap;
|
||||
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
Standard_Integer anIdx[3];
|
||||
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
|
||||
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
|
||||
|
||||
// Skip degenerated triangles.
|
||||
if (anIdx[0] == anIdx[1] || anIdx[0] == anIdx[2] || anIdx[1] == anIdx[2])
|
||||
continue;
|
||||
|
||||
const gp_Pnt aP1 = myMesh->Node(anIdx[0]);
|
||||
const gp_Pnt aP2 = myMesh->Node(anIdx[1]);
|
||||
const gp_Pnt aP3 = myMesh->Node(anIdx[2]);
|
||||
const Standard_Real aD1 = aP1.SquareDistance(aP2);
|
||||
const Standard_Real aD2 = aP1.SquareDistance(aP3);
|
||||
const Standard_Real aD3 = aP2.SquareDistance(aP3);
|
||||
if (aD1 < gp::Resolution() ||
|
||||
aD2 < gp::Resolution() ||
|
||||
aD3 < gp::Resolution())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Edges are constructed in forward order for the existing normals orientation.
|
||||
// In Poly_Triangulation, positive direction is defined as cross product:
|
||||
// (aV1, aV2) x (aV1, aV3).
|
||||
const TopoDS_Vertex& aV1 = aPnt2VertexMap.FindFromKey(anIdx[0]);
|
||||
const TopoDS_Vertex& aV2 = aPnt2VertexMap.FindFromKey(anIdx[1]);
|
||||
const TopoDS_Vertex& aV3 = aPnt2VertexMap.FindFromKey(anIdx[2]);
|
||||
|
||||
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
|
||||
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
|
||||
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
|
||||
|
||||
BRepBuilderAPI_MakeEdge aMaker1(aV1, aV2);
|
||||
BRepBuilderAPI_MakeEdge aMaker2(aV2, aV3);
|
||||
BRepBuilderAPI_MakeEdge aMaker3(aV3, aV1);
|
||||
|
||||
TopoDS_Edge aTE1 = aMaker1.Edge();
|
||||
if (anIdx[1] < anIdx[0])
|
||||
aTE1.Reverse();
|
||||
|
||||
TopoDS_Edge aTE2 = aMaker2.Edge();
|
||||
if (anIdx[2] < anIdx[1])
|
||||
aTE2.Reverse();
|
||||
|
||||
TopoDS_Edge aTE3 = aMaker3.Edge();
|
||||
if (anIdx[0] < anIdx[2])
|
||||
aTE3.Reverse();
|
||||
|
||||
anEdgeToTEgeMap.Add(aMeshEdge1, aTE1);
|
||||
anEdgeToTEgeMap.Add(aMeshEdge2, aTE2);
|
||||
anEdgeToTEgeMap.Add(aMeshEdge3, aTE3);
|
||||
}
|
||||
|
||||
// Construct planar faces using shared topology.
|
||||
TopoDS_Compound aResult;
|
||||
BRep_Builder aBB;
|
||||
aBB.MakeCompound(aResult);
|
||||
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
Standard_Integer anIdx[3];
|
||||
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
|
||||
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
|
||||
|
||||
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
|
||||
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
|
||||
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
|
||||
const Standard_Boolean isReversed1 = anIdx[1] < anIdx[0];
|
||||
const Standard_Boolean isReversed2 = anIdx[2] < anIdx[1];
|
||||
const Standard_Boolean isReversed3 = anIdx[0] < anIdx[2];
|
||||
|
||||
// Edges can be skipped in case of mesh defects - topologically or geometrically
|
||||
// degenerated triangles.
|
||||
const Standard_Boolean aHasAllEdges = anEdgeToTEgeMap.Contains(aMeshEdge1) &&
|
||||
anEdgeToTEgeMap.Contains(aMeshEdge2) &&
|
||||
anEdgeToTEgeMap.Contains(aMeshEdge3) ;
|
||||
if (!aHasAllEdges)
|
||||
continue;
|
||||
|
||||
TopoDS_Edge aTEdge1 = anEdgeToTEgeMap.FindFromKey(aMeshEdge1);
|
||||
if (isReversed1)
|
||||
aTEdge1.Reverse();
|
||||
TopoDS_Edge aTEdge2 = anEdgeToTEgeMap.FindFromKey(aMeshEdge2);
|
||||
if (isReversed2)
|
||||
aTEdge2.Reverse();
|
||||
TopoDS_Edge aTEdge3 = anEdgeToTEgeMap.FindFromKey(aMeshEdge3);
|
||||
if (isReversed3)
|
||||
aTEdge3.Reverse();
|
||||
|
||||
BRepBuilderAPI_MakeWire aWireMaker;
|
||||
aWireMaker.Add(aTEdge1);
|
||||
aWireMaker.Add(aTEdge2);
|
||||
aWireMaker.Add(aTEdge3);
|
||||
const TopoDS_Wire aWire = aWireMaker.Wire();
|
||||
|
||||
// Construct plane explicitly since it is faster than automatic construction
|
||||
// within BRepBuilderAPI_MakeFace.
|
||||
BRepAdaptor_Curve aC1(aTEdge1);
|
||||
BRepAdaptor_Curve aC2(aTEdge2);
|
||||
const gp_Dir aD1 = aC1.Line().Direction();
|
||||
const gp_Dir aD2 = aC2.Line().Direction();
|
||||
gp_XYZ aN = aD1.XYZ().Crossed(aD2.XYZ());
|
||||
if (aN.SquareModulus() < Precision::SquareConfusion())
|
||||
continue;
|
||||
if (aTEdge1.Orientation() == TopAbs_REVERSED)
|
||||
aN.Reverse();
|
||||
if (aTEdge2.Orientation() == TopAbs_REVERSED)
|
||||
aN.Reverse();
|
||||
const gp_Dir aNorm(aN);
|
||||
gp_Pln aPln(myMesh->Node(anIdx[0]), aNorm);
|
||||
|
||||
BRepBuilderAPI_MakeFace aFaceMaker(aPln, aWire);
|
||||
const TopoDS_Face aFace = aFaceMaker.Face();
|
||||
|
||||
aBB.Add(aResult, aFace);
|
||||
}
|
||||
|
||||
this->Done();
|
||||
myShape = aResult;
|
||||
}
|
46
src/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.hxx
Normal file
46
src/BRepBuilderAPI/BRepBuilderAPI_MakeShapeOnMesh.hxx
Normal file
@@ -0,0 +1,46 @@
|
||||
// Created on: 2022-06-30
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 2022-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
||||
#define _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
||||
|
||||
#include <BRepBuilderAPI_MakeShape.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
|
||||
//! Builds shape on per-facet basis on the input mesh. Resulting shape has shared
|
||||
//! edges by construction, but no maximization (unify same domain) is applied.
|
||||
//! No generation history is provided.
|
||||
class BRepBuilderAPI_MakeShapeOnMesh : public BRepBuilderAPI_MakeShape
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Ctor. Sets mesh to process.
|
||||
//! @param theMesh [in] - Mesh to construct shape for.
|
||||
BRepBuilderAPI_MakeShapeOnMesh(const Handle(Poly_Triangulation)& theMesh)
|
||||
: myMesh(theMesh)
|
||||
{}
|
||||
|
||||
//! Builds shape on mesh.
|
||||
Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Handle(Poly_Triangulation) myMesh;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
@@ -36,13 +36,14 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const gp_Trsf& T) :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
|
||||
const gp_Trsf& T,
|
||||
const Standard_Boolean Copy) :
|
||||
myTrsf(T)
|
||||
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& theShape,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theCopyGeom,
|
||||
const Standard_Boolean theCopyMesh)
|
||||
: myTrsf(theTrsf)
|
||||
{
|
||||
myModification = new BRepTools_TrsfModification(T);
|
||||
Perform(S,Copy);
|
||||
myModification = new BRepTools_TrsfModification(theTrsf);
|
||||
Perform(theShape, theCopyGeom, theCopyMesh);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,19 +53,21 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& S,
|
||||
const Standard_Boolean Copy)
|
||||
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theCopyGeom,
|
||||
const Standard_Boolean theCopyMesh)
|
||||
{
|
||||
myUseModif = Copy || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
|
||||
myUseModif = theCopyGeom || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
|
||||
if (myUseModif) {
|
||||
Handle(BRepTools_TrsfModification) theModif =
|
||||
Handle(BRepTools_TrsfModification)::DownCast(myModification);
|
||||
theModif->Trsf() = myTrsf;
|
||||
DoModif(S,myModification);
|
||||
theModif->IsCopyMesh() = theCopyMesh;
|
||||
DoModif(theShape, myModification);
|
||||
}
|
||||
else {
|
||||
myLocation = myTrsf;
|
||||
myShape = S.Moved(myLocation);
|
||||
myShape = theShape.Moved(myLocation);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
@@ -50,28 +50,37 @@ public:
|
||||
//! to define the shape to transform.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const gp_Trsf& T);
|
||||
|
||||
//! Creates a transformation from the gp_Trsf <T>, and
|
||||
//! applies it to the shape <S>. If the transformation
|
||||
//! Creates a transformation from the gp_Trsf <theTrsf>, and
|
||||
//! applies it to the shape <theShape>. If the transformation
|
||||
//! is direct and isometric (determinant = 1) and
|
||||
//! <Copy> = Standard_False, the resulting shape is
|
||||
//! <S> on which a new location has been set.
|
||||
//! <theCopyGeom> = Standard_False, the resulting shape is
|
||||
//! <theShape> on which a new location has been set.
|
||||
//! Otherwise, the transformation is applied on a
|
||||
//! duplication of <S>.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& S, const gp_Trsf& T, const Standard_Boolean Copy = Standard_False);
|
||||
//! duplication of <theShape>.
|
||||
//! If <theCopyMesh> is true, the triangulation will be copied,
|
||||
//! and the copy will be assigned to the result shape.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& theShape,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theCopyGeom = Standard_False,
|
||||
const Standard_Boolean theCopyMesh = Standard_False);
|
||||
|
||||
//! pplies the geometric transformation defined at the
|
||||
//! Applies the geometric transformation defined at the
|
||||
//! time of construction of this framework to the shape S.
|
||||
//! - If the transformation T is direct and isometric, in
|
||||
//! other words, if the determinant of the vectorial part
|
||||
//! of T is equal to 1., and if Copy equals false (the
|
||||
//! of T is equal to 1., and if theCopyGeom equals false (the
|
||||
//! default value), the resulting shape is the same as
|
||||
//! the original but with a new location assigned to it.
|
||||
//! - In all other cases, the transformation is applied to a duplicate of S.
|
||||
//! - In all other cases, the transformation is applied to a duplicate of theShape.
|
||||
//! - If theCopyMesh is true, the triangulation will be copied,
|
||||
//! and the copy will be assigned to the result shape.
|
||||
//! Use the function Shape to access the result.
|
||||
//! Note: this framework can be reused to apply the same
|
||||
//! geometric transformation to other shapes. You only
|
||||
//! need to specify them by calling the function Perform again.
|
||||
Standard_EXPORT void Perform (const TopoDS_Shape& S, const Standard_Boolean Copy = Standard_False);
|
||||
Standard_EXPORT void Perform (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theCopyGeom = Standard_False,
|
||||
const Standard_Boolean theCopyMesh = Standard_False);
|
||||
|
||||
//! Returns the modified shape corresponding to <S>.
|
||||
Standard_EXPORT virtual TopoDS_Shape ModifiedShape (const TopoDS_Shape& S) const Standard_OVERRIDE;
|
||||
|
@@ -26,6 +26,8 @@ BRepBuilderAPI_MakePolygon.cxx
|
||||
BRepBuilderAPI_MakePolygon.hxx
|
||||
BRepBuilderAPI_MakeShape.cxx
|
||||
BRepBuilderAPI_MakeShape.hxx
|
||||
BRepBuilderAPI_MakeShapeOnMesh.cxx
|
||||
BRepBuilderAPI_MakeShapeOnMesh.hxx
|
||||
BRepBuilderAPI_MakeShell.cxx
|
||||
BRepBuilderAPI_MakeShell.hxx
|
||||
BRepBuilderAPI_MakeSolid.cxx
|
||||
|
@@ -197,10 +197,12 @@ Standard_Boolean CheckOn(IntRes2d_IntersectionPoint& thePntInter,
|
||||
if (aMinDist <= theTolZ) {
|
||||
IntRes2d_Transition aTrOnLin(IntRes2d_Head);
|
||||
IntRes2d_Position aPosOnCurve = IntRes2d_Middle;
|
||||
if (Abs(aPar - theDeb) <= Precision::Confusion()) {
|
||||
if ((Abs(aPar - theDeb) <= Precision::Confusion())
|
||||
|| (aPar < theDeb)) {
|
||||
aPosOnCurve = IntRes2d_Head;
|
||||
}
|
||||
else if (Abs(aPar - theFin) <= Precision::Confusion()) {
|
||||
else if ((Abs(aPar - theFin) <= Precision::Confusion())
|
||||
|| (aPar > theFin)) {
|
||||
aPosOnCurve = IntRes2d_End;
|
||||
}
|
||||
//
|
||||
@@ -381,8 +383,16 @@ void BRepClass_Intersector::Perform(const gp_Lin2d& L,
|
||||
{
|
||||
Standard_Boolean aStatusOn = Standard_False;
|
||||
IntRes2d_IntersectionPoint aPntInter;
|
||||
Standard_Real aDebTol = deb;
|
||||
Standard_Real aFinTol = fin;
|
||||
if (aTolZ > Precision::Confusion())
|
||||
{
|
||||
aDebTol = deb - aTolZ;
|
||||
aFinTol = fin + aTolZ;
|
||||
}
|
||||
Geom2dAdaptor_Curve aCurAdaptor(aC2D, aDebTol, aFinTol);
|
||||
|
||||
aStatusOn = CheckOn(aPntInter, F, L, C, aTolZ, fin, deb);
|
||||
aStatusOn = CheckOn(aPntInter, F, L, aCurAdaptor, aTolZ, fin, deb);
|
||||
if (aStatusOn)
|
||||
{
|
||||
Append(aPntInter);
|
||||
|
460
src/BRepExtrema/BRepExtrema_ProximityDistTool.cxx
Normal file
460
src/BRepExtrema/BRepExtrema_ProximityDistTool.cxx
Normal file
@@ -0,0 +1,460 @@
|
||||
// Created on: 2022-08-08
|
||||
// Created by: Kseniya NOSULKO
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepExtrema_ProximityDistTool.hxx>
|
||||
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pln.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Standard_NullValue.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ProximityDistTool
|
||||
//purpose : Creates new unitialized tool
|
||||
//=======================================================================
|
||||
BRepExtrema_ProximityDistTool::BRepExtrema_ProximityDistTool()
|
||||
: myMinDistance (std::numeric_limits<Standard_Real>::max()),
|
||||
myProxDist (-1.),
|
||||
myPntStatus1 (ProxPnt_Status_UNKNOWN),
|
||||
myPntStatus2 (ProxPnt_Status_UNKNOWN),
|
||||
myNbSamples1 (0),
|
||||
myProxVtxIdx1 (-1)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ProximityDistTool
|
||||
//purpose : Creates new tool for the given element sets
|
||||
//=======================================================================
|
||||
BRepExtrema_ProximityDistTool::BRepExtrema_ProximityDistTool (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Standard_Integer theNbSamples1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2)
|
||||
: myMinDistance (std::numeric_limits<Standard_Real>::max()),
|
||||
myProxDist (-1.),
|
||||
myPntStatus1 (ProxPnt_Status_UNKNOWN),
|
||||
myPntStatus2 (ProxPnt_Status_UNKNOWN),
|
||||
myNbSamples1 (theNbSamples1),
|
||||
myProxVtxIdx1 (-1)
|
||||
{
|
||||
LoadTriangleSets (theSet1, theSet2);
|
||||
LoadShapeLists (theShapeList1, theShapeList2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadTriangleSets
|
||||
//purpose : Loads the given element sets into the tool
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::LoadTriangleSets (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2)
|
||||
{
|
||||
mySet1 = theSet1;
|
||||
mySet2 = theSet2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadTriangleSets
|
||||
//purpose : Loads the given list of subshapes into the proximity tool
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2)
|
||||
{
|
||||
myShapeList1 = theShapeList1;
|
||||
myShapeList2 = theShapeList2;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose : Performs searching of the proximity distance
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::Perform()
|
||||
{
|
||||
SetBVHSet (mySet2.get());
|
||||
|
||||
const BVH_Array3d& aVertices1 = mySet1->GetVertices();
|
||||
Standard_Integer aVtxSize = (Standard_Integer)aVertices1.size();
|
||||
Standard_Integer aVtxStep = Max (myNbSamples1 <= 0 ? 1 : aVtxSize / myNbSamples1, 1);
|
||||
for (Standard_Integer aVtxIdx = 0; aVtxIdx < aVtxSize; aVtxIdx += aVtxStep)
|
||||
{
|
||||
myDistance = std::numeric_limits<Standard_Real>::max();
|
||||
myMinDistance = std::numeric_limits<Standard_Real>::max();
|
||||
myIsDone = Standard_False;
|
||||
SetObject (aVertices1[aVtxIdx]);
|
||||
|
||||
ComputeDistance();
|
||||
|
||||
if (!IsDone() && myProxDist < 0.) return;
|
||||
|
||||
if (IsDone() && myDistance > myProxDist)
|
||||
{
|
||||
myPnt1 = aVertices1[aVtxIdx];
|
||||
myPnt2 = myExtremaPoint;
|
||||
myProxDist = myDistance;
|
||||
myProxVtxIdx1 = aVtxIdx;
|
||||
myProxPrjState = myExtPrjState;
|
||||
}
|
||||
}
|
||||
|
||||
myIsDone = myProxDist > -1.;
|
||||
|
||||
if (myIsDone)
|
||||
{
|
||||
DefineStatusProxPnt();
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Real pointBoxSquareMaxDistance (const BVH_Vec3d& thePoint,
|
||||
const BVH_Vec3d& theCMin,
|
||||
const BVH_Vec3d& theCMax)
|
||||
{
|
||||
Standard_Real aDist = 0;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (thePoint[i] <= 0.5 * (theCMax[i] + theCMin[i])) { Standard_Real d = theCMax[i] - thePoint[i]; d *= d; aDist += d; }
|
||||
else { Standard_Real d = thePoint[i] - theCMin[i]; d *= d; aDist += d; }
|
||||
}
|
||||
return aDist;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Branch rejection
|
||||
//purpose : Defines the rules for node rejection by bounding box
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_ProximityDistTool::RejectNode (const BVH_Vec3d& theCornerMin,
|
||||
const BVH_Vec3d& theCornerMax,
|
||||
Standard_Real& theMetric) const
|
||||
{
|
||||
theMetric = sqrt (BVH_Tools<Standard_Real, 3>::PointBoxSquareDistance (myObject,
|
||||
theCornerMin,
|
||||
theCornerMax));
|
||||
|
||||
Standard_Real aMaxMetric = sqrt (pointBoxSquareMaxDistance (myObject,
|
||||
theCornerMin,
|
||||
theCornerMax));
|
||||
|
||||
return theMetric > myDistance || aMaxMetric < myProxDist;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Leaf acceptance
|
||||
//purpose : Defines the rules for leaf acceptance
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_ProximityDistTool::Accept (const Standard_Integer theTrgIdx,
|
||||
const Standard_Real&)
|
||||
{
|
||||
BVH_Vec3d aTrgVert1;
|
||||
BVH_Vec3d aTrgVert2;
|
||||
BVH_Vec3d aTrgVert3;
|
||||
|
||||
BVH_PrjState aBVH_PrjState;
|
||||
Standard_Integer aNumberOfFirstNode = -1;
|
||||
Standard_Integer aNumberOfLastNode = -1;
|
||||
|
||||
mySet2->GetVertices (theTrgIdx, aTrgVert1, aTrgVert2, aTrgVert3);
|
||||
|
||||
BVH_Vec3d aNearestPnt = BVH_Tools<Standard_Real, 3>::PointTriangleProjection (myObject,
|
||||
aTrgVert1, aTrgVert2, aTrgVert3,
|
||||
&aBVH_PrjState,
|
||||
&aNumberOfFirstNode, &aNumberOfLastNode);
|
||||
|
||||
PrjState aPrjState (theTrgIdx, aBVH_PrjState, aNumberOfFirstNode, aNumberOfLastNode);
|
||||
BVH_Vec3d aDirect = myObject - aNearestPnt;
|
||||
Standard_Real aSqDistance = aDirect.Dot(aDirect);
|
||||
|
||||
if (aSqDistance > Precision::SquareConfusion()) // point belongs to triangle
|
||||
{
|
||||
const BVH_Vec3d aAB = aTrgVert2 - aTrgVert1;
|
||||
|
||||
BVH_Vec3d aNorm;
|
||||
if (aTrgVert2.IsEqual (aTrgVert3)) // is this degenerate triangle (= segment)
|
||||
{
|
||||
const BVH_Vec3d aAP = myObject - aTrgVert1;
|
||||
aNorm = BVH_Vec3d::Cross (BVH_Vec3d::Cross (aAP, aAB), aAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
const BVH_Vec3d aAC = aTrgVert3 - aTrgVert1;
|
||||
aNorm = BVH_Vec3d::Cross (aAB, aAC);
|
||||
}
|
||||
|
||||
Standard_Real aNormSqLen = aNorm.Dot (aNorm);
|
||||
|
||||
// check if the distance is under perpendicular
|
||||
const BVH_Vec3d aCrossCross = BVH_Vec3d::Cross (aDirect, aNorm);
|
||||
Standard_Real aCrossCrossSqLen = aCrossCross.Dot (aCrossCross);
|
||||
if (aCrossCrossSqLen > Precision::SquareConfusion() * aSqDistance * aNormSqLen)
|
||||
{
|
||||
// the distance is not under perpendicular
|
||||
if (myMinDistance - sqrt (aSqDistance) > Precision::Confusion())
|
||||
{
|
||||
myMinDistance = sqrt (aSqDistance);
|
||||
myMinDistPoint = aNearestPnt;
|
||||
myMinPrjState = aPrjState;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
// the distance is under perpendicular
|
||||
if (myDistance - sqrt (aSqDistance) > Precision::Confusion())
|
||||
{
|
||||
myDistance = sqrt (aSqDistance);
|
||||
myExtremaPoint = aNearestPnt;
|
||||
myExtPrjState = aPrjState;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeDistance
|
||||
//purpose : Computes the distance between object and BVH tree
|
||||
//=======================================================================
|
||||
Standard_Real BRepExtrema_ProximityDistTool::ComputeDistance()
|
||||
{
|
||||
myIsDone = this->Select() > 0;
|
||||
|
||||
if (!myIsDone)
|
||||
{
|
||||
if (myMinDistance < std::numeric_limits<Standard_Real>::max())
|
||||
{
|
||||
myExtremaPoint = myMinDistPoint;
|
||||
myExtPrjState = myMinPrjState;
|
||||
myIsDone = true;
|
||||
}
|
||||
|
||||
myDistance = myMinDistance;
|
||||
}
|
||||
|
||||
return myDistance;
|
||||
}
|
||||
|
||||
static Standard_Boolean isNodeOnBorder (const Standard_Integer theNodeIdx, const Handle (Poly_Triangulation)& theTr)
|
||||
{
|
||||
Poly_Connect aPolyConnect (theTr);
|
||||
|
||||
Standard_Integer aContTrg; //index of triangle containing exploring node
|
||||
for (aPolyConnect.Initialize (theNodeIdx); aPolyConnect.More(); aPolyConnect.Next())
|
||||
{
|
||||
aContTrg = aPolyConnect.Value();
|
||||
|
||||
Standard_Integer aContTrgNodes[3];
|
||||
theTr->Triangle (aContTrg).Get (aContTrgNodes[0], aContTrgNodes[1], aContTrgNodes[2]); //indices of nodes of the triangle
|
||||
|
||||
Standard_Integer aAdjTrg[3];
|
||||
aPolyConnect.Triangles (aContTrg, aAdjTrg[0], aAdjTrg[1], aAdjTrg[2]); //indices of adjacent triangles
|
||||
|
||||
for (Standard_Integer j = 0; j < 3; j++)
|
||||
{
|
||||
Standard_Integer k = (j + 1) % 3;
|
||||
if (aAdjTrg[j] == 0) //free segment of triangle
|
||||
{
|
||||
//aContTrgNodes[j], aContTrgNodes[k] are ends of free segment and it is a part of border
|
||||
if (aContTrgNodes[j] == theNodeIdx || aContTrgNodes[k] == theNodeIdx)
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : defineStatusProxPnt1
|
||||
//purpose : Defines the status of proximity point from 1st BVH
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::defineStatusProxPnt1()
|
||||
{
|
||||
Standard_Integer aFaceID1 = mySet1->GetShapeIDOfVtx (myProxVtxIdx1);
|
||||
|
||||
if (myShapeList1 (aFaceID1).ShapeType() == TopAbs_EDGE)
|
||||
{
|
||||
const BVH_Array3d& aVertices1 = mySet1->GetVertices();
|
||||
Standard_Integer aVtxSize = (Standard_Integer)aVertices1.size();
|
||||
Standard_Integer aLastIdx = aVtxSize - 1;
|
||||
|
||||
if ((aVertices1[0] - aVertices1[aLastIdx]).Modulus() < Precision::Confusion()) // if closed
|
||||
{
|
||||
myPntStatus1 = ProxPnt_Status_MIDDLE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (myProxVtxIdx1 == 0 || myProxVtxIdx1 == aLastIdx)
|
||||
{
|
||||
myPntStatus1 = ProxPnt_Status_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPntStatus1 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
}
|
||||
else if (myShapeList1 (aFaceID1).ShapeType() == TopAbs_FACE)
|
||||
{
|
||||
Standard_Integer aNodeIdx = mySet1->GetVtxIdxInShape (myProxVtxIdx1) + 1;
|
||||
|
||||
TopLoc_Location aLocation;
|
||||
const TopoDS_Face& aF = TopoDS::Face (myShapeList1 (aFaceID1));
|
||||
Handle (Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation);
|
||||
|
||||
if (isNodeOnBorder (aNodeIdx, aTr))
|
||||
{
|
||||
myPntStatus1 = ProxPnt_Status_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPntStatus1 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : defineStatusProxPnt2
|
||||
//purpose : Defines the status of proximity point from 2nd BVH
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::defineStatusProxPnt2()
|
||||
{
|
||||
Standard_Integer aTrgIdx = myProxPrjState.GetTrgIdx();
|
||||
Standard_Integer aFaceID2 = mySet2->GetFaceID (aTrgIdx);
|
||||
|
||||
if (myShapeList2 (aFaceID2).ShapeType() == TopAbs_EDGE)
|
||||
{
|
||||
if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_INNER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
const BVH_Array3d& aVertices2 = mySet2->GetVertices();
|
||||
Standard_Integer aVtxSize = (Standard_Integer)aVertices2.size();
|
||||
Standard_Integer aLastIdx = aVtxSize - 1;
|
||||
|
||||
if ((aVertices2[0] - aVertices2[aLastIdx]).Modulus() < Precision::Confusion()) // if closed
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
return;
|
||||
}
|
||||
|
||||
NCollection_Array1<Standard_Integer> aVtxIndicesOfTrg;
|
||||
mySet2->GetVtxIndices (aTrgIdx, aVtxIndicesOfTrg);
|
||||
|
||||
Standard_Integer aFirstNodeNum = myProxPrjState.GetNumberOfFirstNode();
|
||||
Standard_Integer aFirstVtxIdx = aVtxIndicesOfTrg[aFirstNodeNum];
|
||||
|
||||
if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_VERTEX)
|
||||
{
|
||||
if (aFirstVtxIdx == 0 || aFirstVtxIdx == aLastIdx)
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
}
|
||||
else if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_EDGE)
|
||||
{
|
||||
Standard_Integer aLastNodeNum = myProxPrjState.GetNumberOfLastNode();
|
||||
Standard_Integer aLastVtxIdx = aVtxIndicesOfTrg[aLastNodeNum];
|
||||
|
||||
// it could be border only in case projection is on a degenerated edge
|
||||
if (aFirstVtxIdx == aLastVtxIdx && (aFirstVtxIdx == 0 || aFirstVtxIdx == aLastIdx))
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myShapeList2 (aFaceID2).ShapeType() == TopAbs_FACE)
|
||||
{
|
||||
if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_INNER)
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
TopLoc_Location aLocation;
|
||||
const TopoDS_Face& aF = TopoDS::Face (myShapeList2 (aFaceID2));
|
||||
Handle (Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation);
|
||||
|
||||
NCollection_Array1<Standard_Integer> aVtxIndicesOfTrg;
|
||||
mySet2->GetVtxIndices (aTrgIdx, aVtxIndicesOfTrg);
|
||||
|
||||
if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_VERTEX)
|
||||
{
|
||||
Standard_Integer aNodeNum = myProxPrjState.GetNumberOfFirstNode();
|
||||
Standard_Integer aNodeIdx = mySet2->GetVtxIdxInShape (aVtxIndicesOfTrg[aNodeNum]) + 1;
|
||||
|
||||
if (isNodeOnBorder (aNodeIdx, aTr))
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_BORDER;
|
||||
}
|
||||
else
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
}
|
||||
}
|
||||
else if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_EDGE)
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_MIDDLE;
|
||||
|
||||
Poly_Connect aPolyConnect (aTr);
|
||||
Standard_Integer aTrgIdxInShape = mySet2->GetTrgIdxInShape (aTrgIdx) + 1;
|
||||
|
||||
Standard_Integer aAdjTrg[3];
|
||||
aPolyConnect.Triangles (aTrgIdxInShape, aAdjTrg[0], aAdjTrg[1], aAdjTrg[2]); //indices of adjacent triangles
|
||||
|
||||
for (Standard_Integer j = 0; j < 3; j++)
|
||||
{
|
||||
Standard_Integer k = (j + 1) % 3;
|
||||
if (aAdjTrg[j] == 0) //free segment of triangle
|
||||
{
|
||||
//aVtxIndicesOfTrg[j] and aVtxIndicesOfTrg[k] are ends of free segment and it is a part of border
|
||||
if (j == myProxPrjState.GetNumberOfFirstNode() &&
|
||||
k == myProxPrjState.GetNumberOfLastNode())
|
||||
{
|
||||
myPntStatus2 = ProxPnt_Status_BORDER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //else if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_EDGE)
|
||||
}
|
||||
} //else if (myShapeList1 (aFaceID1).ShapeType() == TopAbs_FACE)
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DefineStatusProxPnt
|
||||
//purpose : Defines the status of proximity points
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityDistTool::DefineStatusProxPnt()
|
||||
{
|
||||
// define the status of proximity point from 1st BVH
|
||||
defineStatusProxPnt1();
|
||||
|
||||
// define the status of proximity point from 2nd BVH
|
||||
defineStatusProxPnt2();
|
||||
}
|
200
src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx
Normal file
200
src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx
Normal file
@@ -0,0 +1,200 @@
|
||||
// Created on: 2022-08-08
|
||||
// Created by: Kseniya NOSULKO
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepExtrema_ProximityDistTool_HeaderFile
|
||||
#define _BRepExtrema_ProximityDistTool_HeaderFile
|
||||
|
||||
#include <BRepExtrema_ElementFilter.hxx>
|
||||
#include <BRepExtrema_MapOfIntegerPackedMapOfInteger.hxx>
|
||||
#include <BRepExtrema_TriangleSet.hxx>
|
||||
#include <BVH_Distance.hxx>
|
||||
#include <BVH_Tools.hxx>
|
||||
|
||||
//! Tool class for computation the proximity distance from first
|
||||
//! primitive set to second one that is the maximal from minimum
|
||||
//! perpendicular distances. If no perpendicular distance is found, the
|
||||
//! minimum distance will be returned.
|
||||
//! This tool is not intended to be used independently, and is integrated
|
||||
//! in other classes, implementing algorithms based on shape tessellation
|
||||
//! (BRepExtrema_ProximityValueTool).
|
||||
//!
|
||||
//! Please note that algorithm results are approximate and depend greatly
|
||||
//! on the quality of input tessellation(s).
|
||||
class BRepExtrema_ProximityDistTool : public BVH_Distance <Standard_Real, 3, BVH_Vec3d,
|
||||
BRepExtrema_TriangleSet>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename BVH_Tools<Standard_Real, 3>::BVH_PrjStateInTriangle BVH_PrjState;
|
||||
|
||||
enum ProxPnt_Status
|
||||
{
|
||||
ProxPnt_Status_BORDER,
|
||||
ProxPnt_Status_MIDDLE,
|
||||
ProxPnt_Status_UNKNOWN
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Struct with information about projection point state from 2nd BVH,
|
||||
//! providing proximity point of 2nd shape
|
||||
struct PrjState
|
||||
{
|
||||
PrjState()
|
||||
: myTrgIdx (0),
|
||||
myPrjState (BVH_PrjState::BVH_PrjStateInTriangle_INNER),
|
||||
myNumberOfFirstNode (0),
|
||||
myNumberOfLastNode (0)
|
||||
{}
|
||||
|
||||
PrjState (const Standard_Integer theTrgIdx,
|
||||
const BVH_PrjState thePrjState,
|
||||
const Standard_Integer theNumberOfFirstNode,
|
||||
const Standard_Integer theNumberOfLastNode)
|
||||
: myTrgIdx (theTrgIdx),
|
||||
myPrjState (thePrjState),
|
||||
myNumberOfFirstNode (theNumberOfFirstNode),
|
||||
myNumberOfLastNode (theNumberOfLastNode)
|
||||
{}
|
||||
|
||||
Standard_Integer GetTrgIdx() const { return myTrgIdx; }
|
||||
|
||||
BVH_PrjState GetPrjState() const { return myPrjState; }
|
||||
|
||||
Standard_Integer GetNumberOfFirstNode() const { return myNumberOfFirstNode; }
|
||||
|
||||
Standard_Integer GetNumberOfLastNode() const { return myNumberOfLastNode; }
|
||||
|
||||
private:
|
||||
|
||||
Standard_Integer myTrgIdx; //!< Index of triangle on which the projection is located
|
||||
BVH_PrjState myPrjState; //!< Position of a projection on the triangle (vertex, edge, inner)
|
||||
Standard_Integer myNumberOfFirstNode; //!< The 1st vtx of the triangle edge on which the projection is located
|
||||
Standard_Integer myNumberOfLastNode; //!< The 2nd vtx of the triangle edge on which the projection is located
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new unitialized tool.
|
||||
Standard_EXPORT BRepExtrema_ProximityDistTool();
|
||||
|
||||
//! Creates new tool for the given element sets.
|
||||
Standard_EXPORT BRepExtrema_ProximityDistTool (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Standard_Integer theNbSamples1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2);
|
||||
|
||||
public:
|
||||
|
||||
//! Loads the given element sets into the tool.
|
||||
Standard_EXPORT void LoadTriangleSets (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2);
|
||||
|
||||
//! Loads the given list of subshapes into the tool.
|
||||
Standard_EXPORT void LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2);
|
||||
|
||||
//! Performs searching of the proximity distance.
|
||||
Standard_EXPORT void Perform();
|
||||
|
||||
public: //! @name Reject/Accept implementations
|
||||
|
||||
//! Defines the rules for node rejection by bounding box.
|
||||
Standard_EXPORT virtual Standard_Boolean RejectNode (const BVH_Vec3d& theCornerMin,
|
||||
const BVH_Vec3d& theCornerMax,
|
||||
Standard_Real& theMetric) const Standard_OVERRIDE;
|
||||
|
||||
//! Defines the rules for leaf acceptance.
|
||||
Standard_EXPORT virtual Standard_Boolean Accept (const Standard_Integer theSgmIdx,
|
||||
const Standard_Real&) Standard_OVERRIDE;
|
||||
|
||||
//! Returns points on triangles sets, which provide the proximity distance.
|
||||
void ProximityPoints (BVH_Vec3d& thePoint1, BVH_Vec3d& thePoint2) const
|
||||
{
|
||||
thePoint1 = myPnt1;
|
||||
thePoint2 = myPnt2;
|
||||
}
|
||||
|
||||
//! Returns status of points on triangles sets, which provide the proximity distance.
|
||||
void ProximityPointsStatus (ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const
|
||||
{
|
||||
thePointStatus1 = myPntStatus1;
|
||||
thePointStatus2 = myPntStatus2;
|
||||
}
|
||||
|
||||
//! Returns the computed distance
|
||||
Standard_Real ProximityDistance() const { return myProxDist; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Computes the distance between object and BVH tree.
|
||||
Standard_EXPORT Standard_Real ComputeDistance();
|
||||
|
||||
//! Defines the status of proximity points.
|
||||
Standard_EXPORT void DefineStatusProxPnt();
|
||||
|
||||
private:
|
||||
|
||||
//! Defines the status of proximity point from 1st BVH.
|
||||
void defineStatusProxPnt1();
|
||||
|
||||
//! Defines the status of proximity point from 2nd BVH.
|
||||
void defineStatusProxPnt2();
|
||||
|
||||
protected:
|
||||
|
||||
Standard_Real myMinDistance; //!< Minimal distance from point to BVH, could be not equal to myDistance
|
||||
BVH_Vec3d myMinDistPoint; //!< Point on BVH providing the minimal distance
|
||||
|
||||
BVH_Vec3d myExtremaPoint; //!< Point on BVH providing the extrema
|
||||
|
||||
Standard_Real myProxDist; //!< Proximity distance
|
||||
|
||||
//! Proximity points
|
||||
BVH_Vec3d myPnt1, myPnt2;
|
||||
|
||||
//! Proximity points' status
|
||||
ProxPnt_Status myPntStatus1, myPntStatus2;
|
||||
|
||||
private:
|
||||
|
||||
//! Set of all mesh elements (triangles) of the 1st shape.
|
||||
Handle(BRepExtrema_TriangleSet) mySet1;
|
||||
//! Set of all mesh elements (triangles) of the 2nd shape.
|
||||
Handle(BRepExtrema_TriangleSet) mySet2;
|
||||
|
||||
//! List of subshapes of the 1st shape.
|
||||
BRepExtrema_ShapeList myShapeList1;
|
||||
//! List of subshapes of the 2nd shape.
|
||||
BRepExtrema_ShapeList myShapeList2;
|
||||
|
||||
Standard_Integer myNbSamples1; //!< Number of samples points on the first shape
|
||||
|
||||
//! Vertex index from 1st BVH corresponding to proximity point of 1st shape
|
||||
Standard_Integer myProxVtxIdx1;
|
||||
|
||||
//! Information of projection point state from 2nd BVH providing proximity point of 2nd shape
|
||||
PrjState myProxPrjState;
|
||||
|
||||
//! Information of projection point state from 2nd BVH providing the extrema
|
||||
PrjState myExtPrjState;
|
||||
|
||||
//! Information of projection point state from 2nd BVH providing the minimal distance
|
||||
PrjState myMinPrjState;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepExtrema_ProximityDistTool_HeaderFile
|
161
src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx
Normal file
161
src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx
Normal file
@@ -0,0 +1,161 @@
|
||||
// Created on: 2022-08-08
|
||||
// Created by: Kseniya NOSULKO
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepExtrema_ProximityValueTool.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ProximityValueTool
|
||||
//purpose : Creates new unitialized proximity tool
|
||||
//=======================================================================
|
||||
BRepExtrema_ProximityValueTool::BRepExtrema_ProximityValueTool()
|
||||
: myDistance (std::numeric_limits<Standard_Real>::max()),
|
||||
myIsDone (Standard_False),
|
||||
myNbSamples1(0),
|
||||
myNbSamples2(0)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ProximityValueTool
|
||||
//purpose : Creates new proximity tool for the given element sets
|
||||
//=======================================================================
|
||||
BRepExtrema_ProximityValueTool::BRepExtrema_ProximityValueTool (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2)
|
||||
: myDistance (std::numeric_limits<Standard_Real>::max()),
|
||||
myIsDone (Standard_False),
|
||||
myNbSamples1(0),
|
||||
myNbSamples2(0)
|
||||
{
|
||||
LoadTriangleSets (theSet1, theSet2);
|
||||
LoadShapeLists (theShapeList1, theShapeList2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadTriangleSets
|
||||
//purpose : Loads the given element sets into the proximity tool
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityValueTool::LoadTriangleSets (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2)
|
||||
{
|
||||
mySet1 = theSet1;
|
||||
mySet2 = theSet2;
|
||||
|
||||
myIsDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadTriangleSets
|
||||
//purpose : Loads the given list of subshapes into the proximity tool
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityValueTool::LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2)
|
||||
{
|
||||
myShapeList1 = theShapeList1;
|
||||
myShapeList2 = theShapeList2;
|
||||
|
||||
myIsDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetNbSamplePoints
|
||||
//purpose : Sets number of sample points used for proximity calculation for each shape
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityValueTool::SetNbSamplePoints(const Standard_Integer theSamples1,
|
||||
const Standard_Integer theSamples2)
|
||||
{
|
||||
myNbSamples1 = theSamples1;
|
||||
myNbSamples2 = theSamples2;
|
||||
|
||||
myIsDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : computeProximityValue
|
||||
//purpose : Returns the computed proximity value from first BVH to another one
|
||||
//=======================================================================
|
||||
Standard_Real BRepExtrema_ProximityValueTool::computeProximityDist (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Standard_Integer theNbSamples1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2,
|
||||
BVH_Vec3d& thePoint1,
|
||||
BVH_Vec3d& thePoint2,
|
||||
ProxPnt_Status& thePointStatus1,
|
||||
ProxPnt_Status& thePointStatus2) const
|
||||
{
|
||||
BRepExtrema_ProximityDistTool aProxDistTool (theSet1, theNbSamples1, theSet2, theShapeList1, theShapeList2);
|
||||
aProxDistTool.Perform();
|
||||
|
||||
if (!aProxDistTool.IsDone())
|
||||
return -1.;
|
||||
|
||||
aProxDistTool.ProximityPoints (thePoint1, thePoint2);
|
||||
aProxDistTool.ProximityPointsStatus (thePointStatus1, thePointStatus2);
|
||||
|
||||
return aProxDistTool.ProximityDistance();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose : Performs the computation of the proximity value
|
||||
//=======================================================================
|
||||
void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance)
|
||||
{
|
||||
myIsDone = Standard_False;
|
||||
|
||||
// max(min) dist from the 1st shape to the 2nd one
|
||||
BVH_Vec3d aP1_1, aP1_2;
|
||||
ProxPnt_Status aPointStatus1_1 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
|
||||
ProxPnt_Status aPointStatus1_2 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
|
||||
|
||||
Standard_Real aProximityDist1 = computeProximityDist (mySet1, myNbSamples1, mySet2, myShapeList1, myShapeList2,
|
||||
aP1_1, aP1_2, aPointStatus1_1, aPointStatus1_2);
|
||||
|
||||
if (aProximityDist1 < 0.)
|
||||
return;
|
||||
|
||||
// max(min) dist from the 2nd shape to t he 1st one
|
||||
BVH_Vec3d aP2_1, aP2_2;
|
||||
ProxPnt_Status aPointStatus2_1 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
|
||||
ProxPnt_Status aPointStatus2_2 = ProxPnt_Status::ProxPnt_Status_UNKNOWN;
|
||||
|
||||
Standard_Real aProximityDist2 = computeProximityDist (mySet2, myNbSamples2, mySet1, myShapeList2, myShapeList1,
|
||||
aP2_2, aP2_1, aPointStatus2_2, aPointStatus2_1);
|
||||
|
||||
if (aProximityDist2 < 0.)
|
||||
return;
|
||||
|
||||
// min dist of the two max(min) dists
|
||||
if (aProximityDist1 < aProximityDist2)
|
||||
{
|
||||
myDistance = aProximityDist1;
|
||||
myPnt1.SetCoord(aP1_1.x(), aP1_1.y(), aP1_1.z());
|
||||
myPnt2.SetCoord(aP1_2.x(), aP1_2.y(), aP1_2.z());
|
||||
myPntStatus1 = aPointStatus1_1;
|
||||
myPntStatus2 = aPointStatus1_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
myDistance = aProximityDist2;
|
||||
myPnt1.SetCoord(aP2_1.x(), aP2_1.y(), aP2_1.z());
|
||||
myPnt2.SetCoord(aP2_2.x(), aP2_2.y(), aP2_2.z());
|
||||
myPntStatus1 = aPointStatus2_1;
|
||||
myPntStatus2 = aPointStatus2_2;
|
||||
}
|
||||
|
||||
myIsDone = Standard_True;
|
||||
theTolerance = myDistance;
|
||||
}
|
126
src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx
Normal file
126
src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx
Normal file
@@ -0,0 +1,126 @@
|
||||
// Created on: 2022-08-08
|
||||
// Created by: Kseniya NOSULKO
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepExtrema_ProximityValueTool_HeaderFile
|
||||
#define _BRepExtrema_ProximityValueTool_HeaderFile
|
||||
|
||||
#include <BRepExtrema_ProximityDistTool.hxx>
|
||||
#include <BRepExtrema_TriangleSet.hxx>
|
||||
|
||||
//! Tool class for computation of the proximity value from one BVH
|
||||
//! primitive set to another, solving max(min) problem.
|
||||
//! This tool is not intended to be used independently, and is integrated
|
||||
//! in other classes, implementing algorithms based on shape tessellation
|
||||
//! (BRepExtrema_ShapeProximity and BRepExtrema_SelfIntersection).
|
||||
//!
|
||||
//! Please note that algorithm results are approximate and depend greatly
|
||||
//! on the quality of input tessellation(s).
|
||||
class BRepExtrema_ProximityValueTool
|
||||
{
|
||||
public:
|
||||
typedef typename BRepExtrema_ProximityDistTool::ProxPnt_Status ProxPnt_Status;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new unitialized proximity tool.
|
||||
Standard_EXPORT BRepExtrema_ProximityValueTool();
|
||||
|
||||
//! Creates new proximity tool for the given element sets.
|
||||
Standard_EXPORT BRepExtrema_ProximityValueTool (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2);
|
||||
|
||||
public:
|
||||
|
||||
//! Loads the given element sets into the proximity tool.
|
||||
Standard_EXPORT void LoadTriangleSets (const Handle (BRepExtrema_TriangleSet)& theSet1,
|
||||
const Handle (BRepExtrema_TriangleSet)& theSet2);
|
||||
|
||||
//! Loads the given list of subshapes into the proximity tool.
|
||||
Standard_EXPORT void LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2);
|
||||
|
||||
//! Sets number of sample points used for proximity calculation for each shape.
|
||||
//! If number is less or equal zero, all triangulation nodes are used.
|
||||
Standard_EXPORT void SetNbSamplePoints (const Standard_Integer theSamples1 = 0,
|
||||
const Standard_Integer theSamples2 = 0);
|
||||
|
||||
//! Performs the computation of the proximity value.
|
||||
Standard_EXPORT void Perform (Standard_Real& theTolerance);
|
||||
|
||||
//! Is proximity test completed?
|
||||
Standard_Boolean IsDone() const { return myIsDone; }
|
||||
|
||||
//! Marks test results as outdated.
|
||||
void MarkDirty() { myIsDone = Standard_False; }
|
||||
|
||||
//! Returns the computed distance.
|
||||
Standard_Real Distance() const { return myDistance; }
|
||||
|
||||
//! Returns points on triangles sets, which provide the proximity distance.
|
||||
void ProximityPoints(gp_Pnt& thePoint1, gp_Pnt& thePoint2) const
|
||||
{
|
||||
thePoint1 = myPnt1;
|
||||
thePoint2 = myPnt2;
|
||||
}
|
||||
|
||||
//! Returns status of points on triangles sets, which provide the proximity distance.
|
||||
void ProximityPointsStatus (ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const
|
||||
{
|
||||
thePointStatus1 = myPntStatus1;
|
||||
thePointStatus2 = myPntStatus2;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Returns the computed proximity value from first BVH to another one.
|
||||
Standard_Real computeProximityDist (const Handle(BRepExtrema_TriangleSet)& theSet1,
|
||||
const Standard_Integer theNbSamples1,
|
||||
const Handle(BRepExtrema_TriangleSet)& theSet2,
|
||||
const BRepExtrema_ShapeList& theShapeList1,
|
||||
const BRepExtrema_ShapeList& theShapeList2,
|
||||
BVH_Vec3d& thePoint1,
|
||||
BVH_Vec3d& thePoint2,
|
||||
ProxPnt_Status& thePointStatus1,
|
||||
ProxPnt_Status& thePointStatus2) const;
|
||||
|
||||
private:
|
||||
|
||||
//! Set of all mesh primitives of the 1st shape.
|
||||
Handle(BRepExtrema_TriangleSet) mySet1;
|
||||
//! Set of all mesh primitives of the 2nd shape.
|
||||
Handle(BRepExtrema_TriangleSet) mySet2;
|
||||
|
||||
//! List of subshapes of the 1st shape.
|
||||
BRepExtrema_ShapeList myShapeList1;
|
||||
//! List of subshapes of the 2nd shape.
|
||||
BRepExtrema_ShapeList myShapeList2;
|
||||
|
||||
Standard_Real myDistance; //!< Distance
|
||||
Standard_Boolean myIsDone; //!< State of the algorithm
|
||||
|
||||
Standard_Integer myNbSamples1; //!< Number of samples points on the first shape
|
||||
Standard_Integer myNbSamples2; //!< Number of samples points on the second shape
|
||||
|
||||
//! Proximity points
|
||||
gp_Pnt myPnt1, myPnt2;
|
||||
|
||||
//! Proximity points' status
|
||||
ProxPnt_Status myPntStatus1, myPntStatus2;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepExtrema_ProximityValueTool_HeaderFile
|
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <BRepExtrema_OverlapTool.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
//! Tool class for detection of self-sections in the given shape.
|
||||
//! This class is based on BRepExtrema_OverlapTool and thus uses
|
||||
//! shape tessellation to detect incorrect mesh fragments (pairs
|
||||
@@ -76,7 +78,7 @@ public:
|
||||
//! Returns sub-shape from the shape for the given index (started from 0).
|
||||
const TopoDS_Face& GetSubShape (const Standard_Integer theID) const
|
||||
{
|
||||
return myFaceList.Value (theID);
|
||||
return TopoDS::Face(myFaceList.Value(theID));
|
||||
}
|
||||
|
||||
//! Returns set of all the face triangles of the shape.
|
||||
|
@@ -18,6 +18,28 @@
|
||||
#include <Precision.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
|
||||
// Assign a map of sub-shapes (edges/faces) of a given shape
|
||||
static Standard_Boolean initSubShapes(const TopoDS_Shape& theShape,
|
||||
BRepExtrema_ShapeList& theSubshapesList,
|
||||
Handle(BRepExtrema_TriangleSet)& theTriangleSet)
|
||||
{
|
||||
theSubshapesList.Clear();
|
||||
|
||||
for (TopExp_Explorer anIter(theShape, TopAbs_FACE); anIter.More(); anIter.Next())
|
||||
{
|
||||
theSubshapesList.Append(anIter.Current());
|
||||
}
|
||||
|
||||
for (TopExp_Explorer anIter(theShape, TopAbs_EDGE); anIter.More(); anIter.Next())
|
||||
{
|
||||
theSubshapesList.Append(anIter.Current());
|
||||
}
|
||||
|
||||
if (theTriangleSet.IsNull())
|
||||
theTriangleSet = new BRepExtrema_TriangleSet;
|
||||
return theTriangleSet->Init(theSubshapesList);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ShapeProximity
|
||||
//purpose : Creates uninitialized proximity tool
|
||||
@@ -25,7 +47,9 @@
|
||||
BRepExtrema_ShapeProximity::BRepExtrema_ShapeProximity (const Standard_Real theTolerance)
|
||||
: myTolerance (theTolerance),
|
||||
myElementSet1 (new BRepExtrema_TriangleSet),
|
||||
myElementSet2 (new BRepExtrema_TriangleSet)
|
||||
myElementSet2 (new BRepExtrema_TriangleSet),
|
||||
myNbSamples1 (0),
|
||||
myNbSamples2 (0)
|
||||
{
|
||||
// Should be initialized later
|
||||
myIsInitS1 = myIsInitS2 = Standard_False;
|
||||
@@ -40,7 +64,9 @@ BRepExtrema_ShapeProximity::BRepExtrema_ShapeProximity (const TopoDS_Shape& theS
|
||||
const Standard_Real theTolerance)
|
||||
: myTolerance (theTolerance),
|
||||
myElementSet1 (new BRepExtrema_TriangleSet),
|
||||
myElementSet2 (new BRepExtrema_TriangleSet)
|
||||
myElementSet2 (new BRepExtrema_TriangleSet),
|
||||
myNbSamples1 (0),
|
||||
myNbSamples2 (0)
|
||||
{
|
||||
LoadShape1 (theShape1);
|
||||
LoadShape2 (theShape2);
|
||||
@@ -52,16 +78,18 @@ BRepExtrema_ShapeProximity::BRepExtrema_ShapeProximity (const TopoDS_Shape& theS
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_ShapeProximity::LoadShape1 (const TopoDS_Shape& theShape1)
|
||||
{
|
||||
myFaceList1.Clear();
|
||||
myIsInitS1 = initSubShapes(theShape1, myShapeList1, myElementSet1);
|
||||
|
||||
for (TopExp_Explorer anIter (theShape1, TopAbs_FACE); anIter.More(); anIter.Next())
|
||||
if (myTolerance == Precision::Infinite())
|
||||
{
|
||||
myFaceList1.Append (static_cast<const TopoDS_Face&> (anIter.Current()));
|
||||
myProxValTool.MarkDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
myOverlapTool.MarkDirty();
|
||||
}
|
||||
|
||||
myOverlapTool.MarkDirty();
|
||||
|
||||
return myIsInitS1 = myElementSet1->Init (myFaceList1);
|
||||
return myIsInitS1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -70,16 +98,18 @@ Standard_Boolean BRepExtrema_ShapeProximity::LoadShape1 (const TopoDS_Shape& the
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_ShapeProximity::LoadShape2 (const TopoDS_Shape& theShape2)
|
||||
{
|
||||
myFaceList2.Clear();
|
||||
myIsInitS2 = initSubShapes(theShape2, myShapeList2, myElementSet2);
|
||||
|
||||
for (TopExp_Explorer anIter (theShape2, TopAbs_FACE); anIter.More(); anIter.Next())
|
||||
if (myTolerance == Precision::Infinite())
|
||||
{
|
||||
myFaceList2.Append (static_cast<const TopoDS_Face&> (anIter.Current()));
|
||||
myProxValTool.MarkDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
myOverlapTool.MarkDirty();
|
||||
}
|
||||
|
||||
myOverlapTool.MarkDirty();
|
||||
|
||||
return myIsInitS2 = myElementSet2->Init (myFaceList2);
|
||||
return myIsInitS2;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -88,13 +118,32 @@ Standard_Boolean BRepExtrema_ShapeProximity::LoadShape2 (const TopoDS_Shape& the
|
||||
//=======================================================================
|
||||
void BRepExtrema_ShapeProximity::Perform()
|
||||
{
|
||||
if (!myIsInitS1 || !myIsInitS2 || myOverlapTool.IsDone())
|
||||
if (myTolerance == Precision::Infinite())
|
||||
{
|
||||
return;
|
||||
if (!myIsInitS1 || !myIsInitS2 || myProxValTool.IsDone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myProxValTool.LoadTriangleSets (myElementSet1,
|
||||
myElementSet2);
|
||||
myProxValTool.LoadShapeLists (myShapeList1,
|
||||
myShapeList2);
|
||||
|
||||
myProxValTool.Perform (myTolerance);
|
||||
myProxValTool.ProximityPoints(myProxPoint1, myProxPoint2);
|
||||
myProxValTool.ProximityPointsStatus (myProxPntStatus1, myProxPntStatus2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!myIsInitS1 || !myIsInitS2 || myOverlapTool.IsDone())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myOverlapTool.LoadTriangleSets (myElementSet1,
|
||||
myElementSet2);
|
||||
myOverlapTool.LoadTriangleSets (myElementSet1,
|
||||
myElementSet2);
|
||||
|
||||
myOverlapTool.Perform (myTolerance);
|
||||
myOverlapTool.Perform (myTolerance);
|
||||
}
|
||||
}
|
||||
|
@@ -16,31 +16,48 @@
|
||||
#ifndef _BRepExtrema_ShapeProximity_HeaderFile
|
||||
#define _BRepExtrema_ShapeProximity_HeaderFile
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TColStd_PackedMapOfInteger.hxx>
|
||||
|
||||
#include <BRepExtrema_ProximityValueTool.hxx>
|
||||
#include <BRepExtrema_TriangleSet.hxx>
|
||||
#include <BRepExtrema_OverlapTool.hxx>
|
||||
|
||||
//! Tool class for shape proximity detection.
|
||||
//! @brief Tool class for shape proximity detection.
|
||||
//!
|
||||
//! First approach:
|
||||
//! For two given shapes and given tolerance (offset from the mesh) the algorithm allows
|
||||
//! to determine whether or not they are overlapped. The algorithm input consists of any
|
||||
//! shapes which can be decomposed into individual faces (used as basic shape elements).
|
||||
//! High performance is achieved through the use of existing triangulation of faces. So
|
||||
//! poly triangulation (with the desired deflection) should already be built. Note that
|
||||
//! solution is approximate (and corresponds to the deflection used for triangulation).
|
||||
//!
|
||||
//! The algorithm can be run in two modes. If tolerance is set to zero, the algorithm
|
||||
//! will detect only intersecting faces (containing triangles with common points). If
|
||||
//! tolerance is set to positive value, the algorithm will also detect faces located
|
||||
//! on distance less than the given tolerance from each other.
|
||||
//!
|
||||
//! Second approach:
|
||||
//! Compute the proximity value between two shapes if the tolerance is not defined (Precision::Infinite()).
|
||||
//! In this case the proximity value is a minimal thickness of a layer containing both shapes.
|
||||
//!
|
||||
//! For the both approaches the high performance is achieved through the use of existing
|
||||
//! triangulation of faces. So, poly triangulation (with the desired deflection) should already
|
||||
//! be built. Note that solution is approximate (and corresponds to the deflection used for
|
||||
//! triangulation).
|
||||
class BRepExtrema_ShapeProximity
|
||||
{
|
||||
public:
|
||||
typedef typename BRepExtrema_ProximityValueTool::ProxPnt_Status ProxPnt_Status;
|
||||
|
||||
public:
|
||||
|
||||
//! Creates empty proximity tool.
|
||||
Standard_EXPORT BRepExtrema_ShapeProximity (const Standard_Real theTolerance = 0.0);
|
||||
Standard_EXPORT BRepExtrema_ShapeProximity (const Standard_Real theTolerance = Precision::Infinite());
|
||||
|
||||
//! Creates proximity tool for the given two shapes.
|
||||
Standard_EXPORT BRepExtrema_ShapeProximity (const TopoDS_Shape& theShape1,
|
||||
const TopoDS_Shape& theShape2,
|
||||
const Standard_Real theTolerance = 0.0);
|
||||
const Standard_Real theTolerance = Precision::Infinite());
|
||||
|
||||
public:
|
||||
|
||||
@@ -56,19 +73,33 @@ public:
|
||||
myTolerance = theTolerance;
|
||||
}
|
||||
|
||||
//! Returns proximity value calculated for the whole input shapes.
|
||||
Standard_Real Proximity() const
|
||||
{
|
||||
return Tolerance();
|
||||
}
|
||||
|
||||
//! Loads 1st shape into proximity tool.
|
||||
Standard_EXPORT Standard_Boolean LoadShape1 (const TopoDS_Shape& theShape1);
|
||||
|
||||
//! Loads 2nd shape into proximity tool.
|
||||
Standard_EXPORT Standard_Boolean LoadShape2 (const TopoDS_Shape& theShape2);
|
||||
|
||||
//! Set number of sample points on the 1st shape used to compute the proximity value.
|
||||
//! In case of 0, all triangulation nodes will be used.
|
||||
void SetNbSamples1(const Standard_Integer theNbSamples) { myNbSamples1 = theNbSamples; }
|
||||
|
||||
//! Set number of sample points on the 2nd shape used to compute the proximity value.
|
||||
//! In case of 0, all triangulation nodes will be used.
|
||||
void SetNbSamples2(const Standard_Integer theNbSamples) { myNbSamples2 = theNbSamples; }
|
||||
|
||||
//! Performs search of overlapped faces.
|
||||
Standard_EXPORT void Perform();
|
||||
|
||||
//! True if the search is completed.
|
||||
Standard_Boolean IsDone() const
|
||||
{
|
||||
return myOverlapTool.IsDone();
|
||||
return myOverlapTool.IsDone() || myProxValTool.IsDone();
|
||||
}
|
||||
|
||||
//! Returns set of IDs of overlapped faces of 1st shape (started from 0).
|
||||
@@ -84,15 +115,15 @@ public:
|
||||
}
|
||||
|
||||
//! Returns sub-shape from 1st shape with the given index (started from 0).
|
||||
const TopoDS_Face& GetSubShape1 (const Standard_Integer theID) const
|
||||
const TopoDS_Shape& GetSubShape1 (const Standard_Integer theID) const
|
||||
{
|
||||
return myFaceList1.Value (theID);
|
||||
return myShapeList1.Value (theID);
|
||||
}
|
||||
|
||||
//! Returns sub-shape from 1st shape with the given index (started from 0).
|
||||
const TopoDS_Face& GetSubShape2 (const Standard_Integer theID) const
|
||||
const TopoDS_Shape& GetSubShape2 (const Standard_Integer theID) const
|
||||
{
|
||||
return myFaceList2.Value (theID);
|
||||
return myShapeList2.Value (theID);
|
||||
}
|
||||
|
||||
//! Returns set of all the face triangles of the 1st shape.
|
||||
@@ -107,6 +138,34 @@ public:
|
||||
return myElementSet2;
|
||||
}
|
||||
|
||||
//! Returns the point on the 1st shape, which could be used as a reference point
|
||||
//! for the value of the proximity.
|
||||
const gp_Pnt& ProximityPoint1() const
|
||||
{
|
||||
return myProxPoint1;
|
||||
}
|
||||
|
||||
//! Returns the point on the 2nd shape, which could be used as a reference point
|
||||
//! for the value of the proximity.
|
||||
const gp_Pnt& ProximityPoint2() const
|
||||
{
|
||||
return myProxPoint2;
|
||||
}
|
||||
|
||||
//! Returns the status of point on the 1st shape, which could be used as a reference point
|
||||
//! for the value of the proximity.
|
||||
const ProxPnt_Status& ProxPntStatus1() const
|
||||
{
|
||||
return myProxPntStatus1;
|
||||
}
|
||||
|
||||
//! Returns the status of point on the 2nd shape, which could be used as a reference point
|
||||
//! for the value of the proximity.
|
||||
const ProxPnt_Status& ProxPntStatus2() const
|
||||
{
|
||||
return myProxPntStatus2;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Maximum overlapping distance.
|
||||
@@ -117,19 +176,39 @@ private:
|
||||
//! Is the 2nd shape initialized?
|
||||
Standard_Boolean myIsInitS2;
|
||||
|
||||
//! List of faces of the 1st shape.
|
||||
BRepExtrema_ShapeList myFaceList1;
|
||||
//! List of faces of the 2nd shape.
|
||||
BRepExtrema_ShapeList myFaceList2;
|
||||
//! List of subshapes of the 1st shape.
|
||||
BRepExtrema_ShapeList myShapeList1;
|
||||
//! List of subshapes of the 2nd shape.
|
||||
BRepExtrema_ShapeList myShapeList2;
|
||||
|
||||
//! Set of all the face triangles of the 1st shape.
|
||||
Handle(BRepExtrema_TriangleSet) myElementSet1;
|
||||
//! Set of all the face triangles of the 2nd shape.
|
||||
Handle(BRepExtrema_TriangleSet) myElementSet2;
|
||||
|
||||
//! Number of sample points on the 1st shape used to compute the proximity value
|
||||
//! (if zero (default), all triangulation nodes will be used).
|
||||
Standard_Integer myNbSamples1;
|
||||
//! Number of sample points on the 2nd shape used to compute the proximity value
|
||||
//! (if zero (default), all triangulation nodes will be used).
|
||||
Standard_Integer myNbSamples2;
|
||||
|
||||
//! Reference point of the proximity value on the 1st shape.
|
||||
gp_Pnt myProxPoint1;
|
||||
//! Reference point of the proximity value on the 2st shape.
|
||||
gp_Pnt myProxPoint2;
|
||||
|
||||
//! Status of reference points of the proximity value.
|
||||
ProxPnt_Status myProxPntStatus1, myProxPntStatus2;
|
||||
|
||||
//! Overlap tool used for intersection/overlap test.
|
||||
BRepExtrema_OverlapTool myOverlapTool;
|
||||
|
||||
//! Shape-shape proximity tool used for computation of
|
||||
//! the minimal diameter of a tube containing both edges or
|
||||
//! the minimal thickness of a shell containing both faces.
|
||||
BRepExtrema_ProximityValueTool myProxValTool;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepExtrema_ShapeProximity_HeaderFile
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BVH_LinearBuilder.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
|
||||
|
||||
@@ -114,17 +115,65 @@ void BRepExtrema_TriangleSet::Swap (const Standard_Integer theIndex1, const Stan
|
||||
{
|
||||
std::swap (myTriangles[theIndex1],
|
||||
myTriangles[theIndex2]);
|
||||
|
||||
std::swap (myTrgIdxMap (theIndex1),
|
||||
myTrgIdxMap (theIndex2));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFaceID
|
||||
//purpose : Returns face ID of the given triangle
|
||||
//purpose : Returns face ID of the given vertex
|
||||
//=======================================================================
|
||||
Standard_Integer BRepExtrema_TriangleSet::GetFaceID (const Standard_Integer theIndex) const
|
||||
{
|
||||
return myTriangles[theIndex].w();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapeIDOfVtx
|
||||
//purpose : Returns shape ID of the given vertex index
|
||||
//=======================================================================
|
||||
Standard_Integer BRepExtrema_TriangleSet::GetShapeIDOfVtx (const Standard_Integer theIndex) const
|
||||
{
|
||||
return myShapeIdxOfVtxVec.Value (theIndex);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVtxIdxInShape
|
||||
//purpose : Returns vertex index in tringulation of the shape, which vertex belongs,
|
||||
// with the given vtx ID in whole set
|
||||
//=======================================================================
|
||||
Standard_Integer BRepExtrema_TriangleSet::GetVtxIdxInShape (const Standard_Integer theIndex) const
|
||||
{
|
||||
Standard_Integer aShID = myShapeIdxOfVtxVec.Value (theIndex);
|
||||
Standard_Integer aNumVertices = 0;
|
||||
|
||||
for (Standard_Integer aSIdx = 0; aSIdx < aShID; aSIdx++)
|
||||
{
|
||||
aNumVertices += myNumVtxInShapeVec.Value (aSIdx);
|
||||
}
|
||||
|
||||
return theIndex - aNumVertices;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTrgIdxInShape
|
||||
//purpose : Returns triangle index (before swapping) in tringulation of the shape, which triangle belongs,
|
||||
// with the given trg ID in whole set (after swapping)
|
||||
//=======================================================================
|
||||
Standard_Integer BRepExtrema_TriangleSet::GetTrgIdxInShape (const Standard_Integer theIndex) const
|
||||
{
|
||||
Standard_Integer aShID = GetFaceID (theIndex);
|
||||
Standard_Integer aNumTriangles = 0;
|
||||
|
||||
for (Standard_Integer aSIdx = 0; aSIdx < aShID; aSIdx++)
|
||||
{
|
||||
aNumTriangles += myNumTrgInShapeVec.Value (aSIdx);
|
||||
}
|
||||
|
||||
return myTrgIdxMap (theIndex) - aNumTriangles;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVertices
|
||||
//purpose : Returns vertices of the given triangle
|
||||
@@ -141,6 +190,21 @@ void BRepExtrema_TriangleSet::GetVertices (const Standard_Integer theIndex,
|
||||
theVertex3 = myVertexArray[aTriangle.z()];
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVertices
|
||||
//purpose : Returns vertices of the given triangle
|
||||
//=======================================================================
|
||||
void BRepExtrema_TriangleSet::GetVtxIndices (const Standard_Integer theIndex,
|
||||
NCollection_Array1<Standard_Integer>& theVtxIndices) const
|
||||
{
|
||||
BVH_Vec4i aTriangle = myTriangles[theIndex];
|
||||
|
||||
theVtxIndices = NCollection_Array1<Standard_Integer> (0, 2);
|
||||
theVtxIndices.SetValue (0, aTriangle.x());
|
||||
theVtxIndices.SetValue (1, aTriangle.y());
|
||||
theVtxIndices.SetValue (2, aTriangle.z());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clear
|
||||
//purpose : Clears triangle set data
|
||||
@@ -158,41 +222,26 @@ void BRepExtrema_TriangleSet::Clear()
|
||||
//function : Init
|
||||
//purpose : Initializes triangle set
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& theFaces)
|
||||
Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& theShapes)
|
||||
{
|
||||
Clear();
|
||||
|
||||
for (Standard_Integer aFaceIdx = 0; aFaceIdx < theFaces.Size(); ++aFaceIdx)
|
||||
Standard_Boolean isOK = Standard_True;
|
||||
for (Standard_Integer aShapeIdx = 0; aShapeIdx < theShapes.Size() && isOK; ++aShapeIdx)
|
||||
{
|
||||
TopLoc_Location aLocation;
|
||||
if (theShapes (aShapeIdx).ShapeType() == TopAbs_FACE)
|
||||
isOK = initFace (TopoDS::Face (theShapes(aShapeIdx)), aShapeIdx);
|
||||
else if (theShapes (aShapeIdx).ShapeType() == TopAbs_EDGE)
|
||||
isOK = initEdge (TopoDS::Edge (theShapes(aShapeIdx)), aShapeIdx);
|
||||
}
|
||||
|
||||
Handle(Poly_Triangulation) aTriangulation =
|
||||
BRep_Tool::Triangulation (theFaces (aFaceIdx), aLocation);
|
||||
Standard_Integer aNumTrg = static_cast<Standard_Integer> (myTriangles.size());
|
||||
myTrgIdxMap.Clear();
|
||||
myTrgIdxMap.ReSize (aNumTrg);
|
||||
|
||||
if (aTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Standard_Integer aVertOffset =
|
||||
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
|
||||
|
||||
for (Standard_Integer aVertIdx = 1; aVertIdx <= aTriangulation->NbNodes(); ++aVertIdx)
|
||||
{
|
||||
gp_Pnt aVertex = aTriangulation->Node (aVertIdx);
|
||||
aVertex.Transform (aLocation.Transformation());
|
||||
myVertexArray.push_back (BVH_Vec3d (aVertex.X(), aVertex.Y(), aVertex.Z()));
|
||||
}
|
||||
|
||||
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)
|
||||
{
|
||||
Standard_Integer aVertex1, aVertex2, aVertex3;
|
||||
aTriangulation->Triangle (aTriIdx).Get (aVertex1, aVertex2, aVertex3);
|
||||
myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
|
||||
aVertex2 + aVertOffset,
|
||||
aVertex3 + aVertOffset,
|
||||
aFaceIdx));
|
||||
}
|
||||
for (Standard_Integer aTrgIdx = 0; aTrgIdx < aNumTrg; ++aTrgIdx)
|
||||
{
|
||||
myTrgIdxMap.Bind (aTrgIdx, aTrgIdx);
|
||||
}
|
||||
|
||||
MarkDirty(); // needs BVH rebuilding
|
||||
@@ -203,3 +252,95 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : initFace
|
||||
//purpose : Initializes triangle set
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_TriangleSet::initFace (const TopoDS_Face& theFace, const Standard_Integer theIndex)
|
||||
{
|
||||
TopLoc_Location aLocation;
|
||||
|
||||
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (theFace, aLocation);
|
||||
if (aTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Standard_Integer aVertOffset =
|
||||
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
|
||||
|
||||
initNodes (aTriangulation->MapNodeArray()->ChangeArray1(), aLocation.Transformation(), theIndex);
|
||||
|
||||
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)
|
||||
{
|
||||
Standard_Integer aVertex1;
|
||||
Standard_Integer aVertex2;
|
||||
Standard_Integer aVertex3;
|
||||
|
||||
aTriangulation->Triangle (aTriIdx).Get (aVertex1,
|
||||
aVertex2,
|
||||
aVertex3);
|
||||
|
||||
myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
|
||||
aVertex2 + aVertOffset,
|
||||
aVertex3 + aVertOffset,
|
||||
theIndex));
|
||||
}
|
||||
|
||||
myNumTrgInShapeVec.SetValue (theIndex, aTriangulation->NbTriangles());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : initEdge
|
||||
//purpose : Initializes triangle set
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepExtrema_TriangleSet::initEdge (const TopoDS_Edge& theEdge, const Standard_Integer theIndex)
|
||||
{
|
||||
TopLoc_Location aLocation;
|
||||
|
||||
Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
|
||||
if (aPolygon.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
const Standard_Integer aVertOffset =
|
||||
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
|
||||
|
||||
initNodes (aPolygon->Nodes(), aLocation.Transformation(), theIndex);
|
||||
|
||||
for (Standard_Integer aVertIdx = 1; aVertIdx < aPolygon->NbNodes(); ++aVertIdx)
|
||||
{
|
||||
// segment as degenerate triangle
|
||||
myTriangles.push_back (BVH_Vec4i (aVertIdx + aVertOffset,
|
||||
aVertIdx + aVertOffset + 1,
|
||||
aVertIdx + aVertOffset + 1,
|
||||
theIndex));
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : initNodes
|
||||
//purpose : Initializes nodes
|
||||
//=======================================================================
|
||||
void BRepExtrema_TriangleSet::initNodes (const TColgp_Array1OfPnt& theNodes,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Integer theIndex)
|
||||
{
|
||||
for (Standard_Integer aVertIdx = 1; aVertIdx <= theNodes.Size(); ++aVertIdx)
|
||||
{
|
||||
gp_Pnt aVertex = theNodes.Value (aVertIdx);
|
||||
|
||||
aVertex.Transform (theTrsf);
|
||||
|
||||
myVertexArray.push_back (BVH_Vec3d (aVertex.X(),
|
||||
aVertex.Y(),
|
||||
aVertex.Z()));
|
||||
myShapeIdxOfVtxVec.Append (theIndex);
|
||||
}
|
||||
|
||||
myNumVtxInShapeVec.SetValue (theIndex, theNodes.Size());
|
||||
}
|
||||
|
@@ -16,11 +16,14 @@
|
||||
#ifndef _BRepExtrema_TriangleSet_HeaderFile
|
||||
#define _BRepExtrema_TriangleSet_HeaderFile
|
||||
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <BVH_PrimitiveSet3d.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_DataMapOfIntegerInteger.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
//! List of shapes and their IDs for collision detection.
|
||||
typedef NCollection_Vector<TopoDS_Face> BRepExtrema_ShapeList;
|
||||
typedef NCollection_Vector<TopoDS_Shape> BRepExtrema_ShapeList;
|
||||
|
||||
//! Triangle set corresponding to specific face.
|
||||
class BRepExtrema_TriangleSet : public BVH_PrimitiveSet3d
|
||||
@@ -59,7 +62,10 @@ public:
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
//! Initializes triangle set.
|
||||
Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theFaces);
|
||||
Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theShapes);
|
||||
|
||||
//! Returns all vertices.
|
||||
Standard_EXPORT const BVH_Array3d& GetVertices() const { return myVertexArray; }
|
||||
|
||||
//! Returns vertices of the given triangle.
|
||||
Standard_EXPORT void GetVertices (const Standard_Integer theIndex,
|
||||
@@ -67,9 +73,37 @@ public:
|
||||
BVH_Vec3d& theVertex2,
|
||||
BVH_Vec3d& theVertex3) const;
|
||||
|
||||
//! Returns vertex indices of the given triangle.
|
||||
Standard_EXPORT void GetVtxIndices (const Standard_Integer theIndex,
|
||||
NCollection_Array1<Standard_Integer>& theVtxIndices) const;
|
||||
|
||||
//! Returns face ID of the given triangle.
|
||||
Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns shape ID of the given vertex index.
|
||||
Standard_EXPORT Standard_Integer GetShapeIDOfVtx (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns vertex index in tringulation of the shape, which vertex belongs,
|
||||
//! with the given vtx ID in whole set.
|
||||
Standard_EXPORT Standard_Integer GetVtxIdxInShape (const Standard_Integer theIndex) const;
|
||||
|
||||
//! Returns triangle index (before swapping) in tringulation of the shape, which triangle belongs,
|
||||
//! with the given trg ID in whole set (after swapping).
|
||||
Standard_EXPORT Standard_Integer GetTrgIdxInShape (const Standard_Integer theIndex) const;
|
||||
|
||||
private:
|
||||
|
||||
//! Initializes triangle set from the face
|
||||
Standard_Boolean initFace (const TopoDS_Face& theFace, const Standard_Integer theIndex);
|
||||
|
||||
//! Initializes polygon from the edge
|
||||
Standard_Boolean initEdge (const TopoDS_Edge& theEdge, const Standard_Integer theIndex);
|
||||
|
||||
//! Initializes nodes
|
||||
void initNodes (const TColgp_Array1OfPnt& theNodes,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Integer theIndex);
|
||||
|
||||
protected:
|
||||
|
||||
//! Array of vertex indices.
|
||||
@@ -78,6 +112,19 @@ protected:
|
||||
//! Array of vertex coordinates.
|
||||
BVH_Array3d myVertexArray;
|
||||
|
||||
//! Vector of shapes' indices where index of item corresponds to index of vertex,
|
||||
//! belonging to this shape.
|
||||
NCollection_Vector<Standard_Integer> myShapeIdxOfVtxVec;
|
||||
|
||||
//! Vector of vertexes' number belonging to shape which index corresponds item's index.
|
||||
NCollection_Vector<Standard_Integer> myNumVtxInShapeVec;
|
||||
|
||||
//! Vector of triangles' number belonging to shape which index corresponds item's index.
|
||||
NCollection_Vector<Standard_Integer> myNumTrgInShapeVec;
|
||||
|
||||
//! Map of triangles' indices after (key) and before (value) swapping.
|
||||
TColStd_DataMapOfIntegerInteger myTrgIdxMap;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d)
|
||||
|
@@ -18,6 +18,10 @@ BRepExtrema_OverlapTool.cxx
|
||||
BRepExtrema_OverlapTool.hxx
|
||||
BRepExtrema_Poly.cxx
|
||||
BRepExtrema_Poly.hxx
|
||||
BRepExtrema_ProximityValueTool.cxx
|
||||
BRepExtrema_ProximityValueTool.hxx
|
||||
BRepExtrema_ProximityDistTool.cxx
|
||||
BRepExtrema_ProximityDistTool.hxx
|
||||
BRepExtrema_SelfIntersection.cxx
|
||||
BRepExtrema_SelfIntersection.hxx
|
||||
BRepExtrema_SeqOfSolution.hxx
|
||||
|
@@ -1585,7 +1585,7 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
NbSamples = 4;
|
||||
gp_Pln FirstPlane;
|
||||
PlaneOfWire(TopoDS::Wire(myWork(ideb)), FirstPlane);
|
||||
gp_Pnt FirstBary = FirstPlane.Location();
|
||||
gp_Pnt PrevBary = FirstPlane.Location();
|
||||
gp_Vec NormalOfFirstPlane = FirstPlane.Axis().Direction();
|
||||
for (i = ideb+1; i <= ifin; i++)
|
||||
{
|
||||
@@ -1596,10 +1596,10 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
gp_Pln CurPlane;
|
||||
PlaneOfWire(aWire, CurPlane);
|
||||
gp_Pnt CurBary = CurPlane.Location();
|
||||
gp_Vec aVec(FirstBary, CurBary);
|
||||
gp_Vec aVec(PrevBary, CurBary);
|
||||
gp_Vec anOffsetProj = (aVec * NormalOfFirstPlane) * NormalOfFirstPlane;
|
||||
CurBary.Translate(-anOffsetProj); //projected current bary center
|
||||
gp_Vec Offset(CurBary, FirstBary);
|
||||
gp_Vec Offset(CurBary, PrevBary);
|
||||
|
||||
TopoDS_Wire newwire;
|
||||
BRep_Builder BB;
|
||||
@@ -1804,6 +1804,8 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
newwire.Closed( Standard_True );
|
||||
newwire.Orientation( TopAbs_FORWARD );
|
||||
myWork(i) = newwire;
|
||||
|
||||
PrevBary = CurBary;
|
||||
}
|
||||
#ifdef OCCT_DEBUG_EFV
|
||||
|
||||
|
@@ -506,7 +506,14 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
|
||||
|
||||
if (!isSolved)
|
||||
return;
|
||||
|
||||
//Removing very small values
|
||||
Standard_Real aMaxV = Max(Abs(aVec(1)), Max(Abs(aVec(2)), Abs(aVec(3))));
|
||||
Standard_Real eps = Epsilon(aMaxV);
|
||||
for (i = 1; i <= 3; ++i)
|
||||
{
|
||||
if (Abs(aVec(i)) <= eps)
|
||||
aVec(i) = 0.;
|
||||
}
|
||||
gp_Vec aN (aVec (1), aVec (2), aVec (3));
|
||||
Handle(Geom_Plane) aPlane = new Geom_Plane (aBaryCenter, aN);
|
||||
myTolReached = Controle (aPoints, aPlane);
|
||||
|
@@ -41,10 +41,13 @@ std::pair<Standard_Real, Standard_Real> BRepMesh_ConeRangeSplitter::GetSplitStep
|
||||
|
||||
const Standard_Real aDiffU = aRangeU.second - aRangeU.first;
|
||||
const Standard_Real aDiffV = aRangeV.second - aRangeV.first;
|
||||
Standard_Integer nbU = (Standard_Integer) (aDiffU / Du);
|
||||
Standard_Integer nbV = (Standard_Integer) (nbU * (aDiffV) / (aDiffU * aRadius));
|
||||
const Standard_Real aScale = (Du * aRadius);
|
||||
const Standard_Real aRatio = Max(1., Log(aDiffV / aScale));
|
||||
const Standard_Integer nbU = (Standard_Integer)(aDiffU / Du);
|
||||
const Standard_Integer nbV = (Standard_Integer)(aDiffV / aScale / aRatio);
|
||||
|
||||
Du = aDiffU / (nbU + 1);
|
||||
Dv = aDiffV / (nbV + 1);
|
||||
Dv = aDiffV / (nbV + static_cast<Standard_Integer>(aRatio));
|
||||
|
||||
theStepsNb.first = nbU;
|
||||
theStepsNb.second = nbV;
|
||||
|
@@ -124,10 +124,12 @@ void BRepMesh_DefaultRangeSplitter::computeTolerance(
|
||||
const Standard_Real aDiffU = myRangeU.second - myRangeU.first;
|
||||
const Standard_Real aDiffV = myRangeV.second - myRangeV.first;
|
||||
|
||||
// Slightly increase exact resolution so to cover links with approximate
|
||||
// length equal to resolution itself on sub-resolution differences.
|
||||
const Standard_Real aTolerance = BRep_Tool::Tolerance (myDFace->GetFace());
|
||||
const Adaptor3d_Surface& aSurface = GetSurface()->Surface();
|
||||
const Standard_Real aResU = aSurface.UResolution (aTolerance);
|
||||
const Standard_Real aResV = aSurface.VResolution (aTolerance);
|
||||
const Standard_Real aResU = aSurface.UResolution (aTolerance) * 1.1;
|
||||
const Standard_Real aResV = aSurface.VResolution (aTolerance) * 1.1;
|
||||
|
||||
const Standard_Real aDeflectionUV = 1.e-05;
|
||||
myTolerance.first = Max(Min(aDeflectionUV, aResU), 1e-7 * aDiffU);
|
||||
|
45
src/BRepMesh/BRepMesh_ExtrusionRangeSplitter.cxx
Normal file
45
src/BRepMesh/BRepMesh_ExtrusionRangeSplitter.cxx
Normal file
@@ -0,0 +1,45 @@
|
||||
// Created on: 2022-09-07
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
// Created by: Oleg AGASHIN
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepMesh_ExtrusionRangeSplitter.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// Function: getUndefinedIntervalNb
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepMesh_ExtrusionRangeSplitter::getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean /*isU*/,
|
||||
const GeomAbs_Shape theContinuity) const
|
||||
{
|
||||
// Here we need just a regular grid along dimension with no
|
||||
// geometrical data regarding intervals like extrusion surface.
|
||||
const Handle(Adaptor3d_Curve) aCurve = theSurface->BasisCurve();
|
||||
Standard_Integer aIntervalsNb = aCurve->NbIntervals(theContinuity);
|
||||
if (aIntervalsNb == 1)
|
||||
{
|
||||
const GeomAbs_CurveType aCurveType = aCurve->GetType();
|
||||
const Standard_Boolean isBSplineCurve =
|
||||
aCurveType == GeomAbs_BezierCurve ||
|
||||
aCurveType == GeomAbs_BSplineCurve;
|
||||
|
||||
if (isBSplineCurve)
|
||||
{
|
||||
aIntervalsNb = aCurve->NbPoles() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
return aIntervalsNb;
|
||||
}
|
45
src/BRepMesh/BRepMesh_ExtrusionRangeSplitter.hxx
Normal file
45
src/BRepMesh/BRepMesh_ExtrusionRangeSplitter.hxx
Normal file
@@ -0,0 +1,45 @@
|
||||
// Created on: 2022-09-07
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
// Created by: Oleg AGASHIN
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepMesh_ExtrusionRangeSplitter_HeaderFile
|
||||
#define _BRepMesh_ExtrusionRangeSplitter_HeaderFile
|
||||
|
||||
#include <BRepMesh_NURBSRangeSplitter.hxx>
|
||||
|
||||
//! Auxiliary class analysing extrusion surface in order to generate internal nodes.
|
||||
class BRepMesh_ExtrusionRangeSplitter : public BRepMesh_NURBSRangeSplitter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
BRepMesh_ExtrusionRangeSplitter()
|
||||
{
|
||||
}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~BRepMesh_ExtrusionRangeSplitter()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Returns number of intervals computed using available geometrical parameters.
|
||||
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape theContinuity) const Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
@@ -21,6 +21,8 @@
|
||||
#include <BRepMesh_DelaunayBaseMeshAlgo.hxx>
|
||||
#include <BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx>
|
||||
#include <BRepMesh_BoundaryParamsRangeSplitter.hxx>
|
||||
#include <BRepMesh_ExtrusionRangeSplitter.hxx>
|
||||
#include <BRepMesh_UndefinedRangeSplitter.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_MeshAlgoFactory, IMeshTools_MeshAlgoFactory)
|
||||
|
||||
@@ -98,7 +100,18 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo(
|
||||
return new DeflectionControlMeshAlgo<BRepMesh_BoundaryParamsRangeSplitter>::Type;
|
||||
break;
|
||||
|
||||
default:
|
||||
case GeomAbs_SurfaceOfExtrusion:
|
||||
return new DeflectionControlMeshAlgo<BRepMesh_ExtrusionRangeSplitter>::Type;
|
||||
break;
|
||||
|
||||
case GeomAbs_BezierSurface:
|
||||
case GeomAbs_BSplineSurface:
|
||||
return new DeflectionControlMeshAlgo<BRepMesh_NURBSRangeSplitter>::Type;
|
||||
break;
|
||||
|
||||
case GeomAbs_OffsetSurface:
|
||||
case GeomAbs_OtherSurface:
|
||||
default:
|
||||
return new DeflectionControlMeshAlgo<BRepMesh_UndefinedRangeSplitter>::Type;
|
||||
}
|
||||
}
|
||||
|
@@ -46,7 +46,8 @@ namespace
|
||||
void operator()(const Standard_Integer theFaceIndex) const
|
||||
{
|
||||
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
|
||||
if (aDFace->IsSet(IMeshData_Outdated))
|
||||
if (aDFace->IsSet(IMeshData_Outdated) ||
|
||||
aDFace->GetFace().IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -119,7 +120,7 @@ namespace
|
||||
void operator()(const Standard_Integer theFaceIndex) const
|
||||
{
|
||||
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
|
||||
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone)
|
||||
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone || aDFace->IsSet(IMeshData_Failure))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -128,7 +129,7 @@ namespace
|
||||
for (Standard_Integer aEdgeIdx = 0; aEdgeIdx < aDWire->EdgesNb() - 1; ++aEdgeIdx)
|
||||
{
|
||||
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge (aEdgeIdx);
|
||||
|
||||
|
||||
if (aDEdge->GetPCurve(aDFace.get(), TopAbs_FORWARD) != aDEdge->GetPCurve(aDFace.get(), TopAbs_REVERSED))
|
||||
{
|
||||
if (aDEdge->GetCurve()->ParametersNb() == 2)
|
||||
@@ -146,7 +147,7 @@ namespace
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -392,27 +392,73 @@ Handle(IMeshData::ListOfPnt2d) BRepMesh_NURBSRangeSplitter::GenerateSurfaceNodes
|
||||
return aNodes;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function: getUndefinedIntervalNb
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepMesh_NURBSRangeSplitter::getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape /*theContinuity*/) const
|
||||
{
|
||||
return (isU ? theSurface->NbUPoles() : theSurface->NbVPoles()) - 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function: getUndefinedInterval
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
void BRepMesh_NURBSRangeSplitter::getUndefinedInterval(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape theContinuity,
|
||||
const std::pair<Standard_Real, Standard_Real>& theRange,
|
||||
TColStd_Array1OfReal& theIntervals) const
|
||||
{
|
||||
Standard_Integer aIntervalsNb = isU ?
|
||||
theSurface->NbUIntervals(theContinuity) :
|
||||
theSurface->NbVIntervals(theContinuity);
|
||||
|
||||
if (aIntervalsNb == 1)
|
||||
{
|
||||
aIntervalsNb = getUndefinedIntervalNb(theSurface, isU, theContinuity);
|
||||
if (aIntervalsNb > 1)
|
||||
{
|
||||
theIntervals = TColStd_Array1OfReal(1, aIntervalsNb - 1);
|
||||
const Standard_Real aDiff = (theRange.second - theRange.first) / aIntervalsNb;
|
||||
for (Standard_Integer i = theIntervals.Lower(); i <= theIntervals.Upper(); ++i)
|
||||
{
|
||||
theIntervals.SetValue(i, theRange.first + i * aDiff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (theIntervals.IsEmpty())
|
||||
{
|
||||
theIntervals = TColStd_Array1OfReal(1, aIntervalsNb + 1);
|
||||
if (isU)
|
||||
{
|
||||
theSurface->UIntervals(theIntervals, theContinuity);
|
||||
}
|
||||
else
|
||||
{
|
||||
theSurface->VIntervals(theIntervals, theContinuity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Function: initParameters
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepMesh_NURBSRangeSplitter::initParameters() const
|
||||
{
|
||||
const GeomAbs_Shape aContinuity = GeomAbs_CN;
|
||||
const Handle(BRepAdaptor_Surface)& aSurface = GetSurface();
|
||||
|
||||
const GeomAbs_Shape aContinuity = GeomAbs_CN;
|
||||
const std::pair<Standard_Integer, Standard_Integer> aIntervalsNb(
|
||||
aSurface->NbUIntervals(aContinuity),
|
||||
aSurface->NbVIntervals(aContinuity)
|
||||
);
|
||||
|
||||
TColStd_Array1OfReal aIntervals[2] = {
|
||||
TColStd_Array1OfReal(1, aIntervalsNb.first + 1),
|
||||
TColStd_Array1OfReal(1, aIntervalsNb.second + 1)
|
||||
};
|
||||
|
||||
aSurface->UIntervals(aIntervals[0], aContinuity);
|
||||
aSurface->VIntervals(aIntervals[1], aContinuity);
|
||||
TColStd_Array1OfReal aIntervals[2];
|
||||
getUndefinedInterval(aSurface, Standard_True, aContinuity, GetRangeU(), aIntervals[0]);
|
||||
getUndefinedInterval(aSurface, Standard_False, aContinuity, GetRangeV(), aIntervals[1]);
|
||||
|
||||
const Standard_Boolean isSplitIntervals = toSplitIntervals (aSurface->Surface().Surface(), aIntervals);
|
||||
|
||||
@@ -507,12 +553,17 @@ Handle(IMeshData::SequenceOfReal) BRepMesh_NURBSRangeSplitter::computeGrainAndFi
|
||||
aMinDiff /= theDelta;
|
||||
}
|
||||
|
||||
aMinDiff = Max(theParameters.MinSize, aMinDiff);
|
||||
const Handle(BRepAdaptor_Surface)& aSurface = GetSurface();
|
||||
const Standard_Real aMinSize2d = Max(
|
||||
aSurface->UResolution(theParameters.MinSize),
|
||||
aSurface->UResolution(theParameters.MinSize));
|
||||
|
||||
aMinDiff = Max(aMinSize2d, aMinDiff);
|
||||
|
||||
const Standard_Real aDiffMaxLim = 0.1 * theRangeDiff;
|
||||
const Standard_Real aDiffMinLim = Max(0.005 * theRangeDiff,
|
||||
2. * theTol2d);
|
||||
const Standard_Real aDiff = Max(theParameters.MinSize,
|
||||
const Standard_Real aDiff = Max(aMinSize2d,
|
||||
Min(aDiffMaxLim, aDiffMinLim));
|
||||
return filterParameters(theSourceParams, aMinDiff, aDiff, theAllocator);
|
||||
}
|
||||
|
@@ -49,7 +49,21 @@ protected:
|
||||
//! Initializes U and V parameters lists using CN continuity intervals.
|
||||
Standard_EXPORT virtual Standard_Boolean initParameters() const;
|
||||
|
||||
//! Returns number of intervals computed using available geometrical parameters.
|
||||
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape theContinuity) const;
|
||||
|
||||
private:
|
||||
//! Tries to compute intervals even for cases with no intervals
|
||||
//! at all using available geometrical parameters.
|
||||
void getUndefinedInterval(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape theContinuity,
|
||||
const std::pair<Standard_Real, Standard_Real>& theRange,
|
||||
TColStd_Array1OfReal& theIntervals) const;
|
||||
|
||||
//! Computes parameters of filter and applies it to the source parameters.
|
||||
Handle(IMeshData::SequenceOfReal) computeGrainAndFilterParameters(
|
||||
|
28
src/BRepMesh/BRepMesh_UndefinedRangeSplitter.cxx
Normal file
28
src/BRepMesh/BRepMesh_UndefinedRangeSplitter.cxx
Normal file
@@ -0,0 +1,28 @@
|
||||
// Created on: 2022-09-07
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
// Created by: Oleg AGASHIN
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepMesh_UndefinedRangeSplitter.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// Function: getUndefinedIntervalNb
|
||||
// Purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepMesh_UndefinedRangeSplitter::getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& /*theSurface*/,
|
||||
const Standard_Boolean /*isU*/,
|
||||
const GeomAbs_Shape /*theContinuity*/) const
|
||||
{
|
||||
return 1;
|
||||
}
|
46
src/BRepMesh/BRepMesh_UndefinedRangeSplitter.hxx
Normal file
46
src/BRepMesh/BRepMesh_UndefinedRangeSplitter.hxx
Normal file
@@ -0,0 +1,46 @@
|
||||
// Created on: 2022-09-07
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
// Created by: Oleg AGASHIN
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepMesh_UndefinedRangeSplitter_HeaderFile
|
||||
#define _BRepMesh_UndefinedRangeSplitter_HeaderFile
|
||||
|
||||
#include <BRepMesh_NURBSRangeSplitter.hxx>
|
||||
|
||||
//! Auxiliary class provides safe value for surfaces that looks like NURBS
|
||||
//! but has no poles or other characteristics.
|
||||
class BRepMesh_UndefinedRangeSplitter : public BRepMesh_NURBSRangeSplitter
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
BRepMesh_UndefinedRangeSplitter()
|
||||
{
|
||||
}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~BRepMesh_UndefinedRangeSplitter()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//! Returns number of intervals computed using available geometrical parameters.
|
||||
Standard_EXPORT virtual Standard_Integer getUndefinedIntervalNb(
|
||||
const Handle(Adaptor3d_Surface)& theSurface,
|
||||
const Standard_Boolean isU,
|
||||
const GeomAbs_Shape theContinuity) const Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif
|
@@ -40,6 +40,8 @@ BRepMesh_EdgeDiscret.hxx
|
||||
BRepMesh_EdgeParameterProvider.hxx
|
||||
BRepMesh_EdgeTessellationExtractor.cxx
|
||||
BRepMesh_EdgeTessellationExtractor.hxx
|
||||
BRepMesh_ExtrusionRangeSplitter.cxx
|
||||
BRepMesh_ExtrusionRangeSplitter.hxx
|
||||
BRepMesh_FaceChecker.cxx
|
||||
BRepMesh_FaceChecker.hxx
|
||||
BRepMesh_FaceDiscret.cxx
|
||||
@@ -80,6 +82,8 @@ BRepMesh_SphereRangeSplitter.hxx
|
||||
BRepMesh_TorusRangeSplitter.cxx
|
||||
BRepMesh_TorusRangeSplitter.hxx
|
||||
BRepMesh_Triangle.hxx
|
||||
BRepMesh_UndefinedRangeSplitter.cxx
|
||||
BRepMesh_UndefinedRangeSplitter.hxx
|
||||
BRepMesh_UVParamRangeSplitter.hxx
|
||||
BRepMesh_Vertex.hxx
|
||||
BRepMesh_VertexInspector.hxx
|
||||
|
@@ -17,9 +17,12 @@
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAlgo.hxx>
|
||||
#include <BRepAlgo_FaceRestrictor.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepOffsetAPI_MakeOffset.hxx>
|
||||
#include <BRepTopAdaptor_FClass2d.hxx>
|
||||
#include <Extrema_ExtPS.hxx>
|
||||
@@ -41,6 +44,50 @@
|
||||
static Standard_Boolean AffichSpine = Standard_False;
|
||||
#endif
|
||||
|
||||
static Standard_Boolean NeedsConvertion (const TopoDS_Wire& theWire)
|
||||
{
|
||||
TopoDS_Iterator anIter (theWire);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge (anIter.Value());
|
||||
BRepAdaptor_Curve aBAcurve (anEdge);
|
||||
GeomAbs_CurveType aType = aBAcurve.GetType();
|
||||
if (aType != GeomAbs_Line &&
|
||||
aType != GeomAbs_Circle)
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopoDS_Face BRepOffsetAPI_MakeOffset::ConvertFace (const TopoDS_Face& theFace,
|
||||
const Standard_Real theAngleTolerance)
|
||||
{
|
||||
TopAbs_Orientation anOr = theFace.Orientation();
|
||||
TopoDS_Face aFace = theFace;
|
||||
aFace.Orientation (TopAbs_FORWARD);
|
||||
|
||||
TopoDS_Face aNewFace = TopoDS::Face (aFace.EmptyCopied());
|
||||
BRep_Builder aBB;
|
||||
TopoDS_Iterator anIter (aFace);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
TopoDS_Wire aWire = TopoDS::Wire (anIter.Value());
|
||||
if (NeedsConvertion (aWire))
|
||||
{
|
||||
TopAbs_Orientation anOrOfWire = aWire.Orientation();
|
||||
aWire.Orientation (TopAbs_FORWARD);
|
||||
aWire = BRepAlgo::ConvertWire (aWire, theAngleTolerance, aFace);
|
||||
BRepLib::BuildCurves3d (aWire);
|
||||
aWire.Orientation (anOrOfWire);
|
||||
}
|
||||
aBB.Add (aNewFace, aWire);
|
||||
}
|
||||
aNewFace.Orientation (anOr);
|
||||
|
||||
return aNewFace;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepOffsetAPI_MakeOffset
|
||||
//purpose :
|
||||
@@ -49,7 +96,8 @@ static Standard_Boolean AffichSpine = Standard_False;
|
||||
BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset()
|
||||
: myIsInitialized( Standard_False),
|
||||
myJoin(GeomAbs_Arc),
|
||||
myIsOpenResult(Standard_False)
|
||||
myIsOpenResult(Standard_False),
|
||||
myIsToApprox(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -80,6 +128,7 @@ void BRepOffsetAPI_MakeOffset::Init(const TopoDS_Face& Spine,
|
||||
myIsInitialized = Standard_True;
|
||||
myJoin = Join;
|
||||
myIsOpenResult = IsOpenResult;
|
||||
myIsToApprox = Standard_False;
|
||||
TopExp_Explorer exp;
|
||||
for (exp.Init(myFace,TopAbs_WIRE); exp.More();exp.Next()) {
|
||||
myWires.Append(exp.Current());
|
||||
@@ -99,6 +148,7 @@ BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset(const TopoDS_Wire& Spine,
|
||||
myIsInitialized = Standard_True;
|
||||
myJoin = Join;
|
||||
myIsOpenResult = IsOpenResult;
|
||||
myIsToApprox = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -113,6 +163,18 @@ void BRepOffsetAPI_MakeOffset::Init(const GeomAbs_JoinType Join,
|
||||
myIsOpenResult = IsOpenResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetApprox
|
||||
//purpose : Set approximation flag
|
||||
// for convertion input contours into ones consisting of
|
||||
// 2D circular arcs and 2D linear segments only
|
||||
//=======================================================================
|
||||
|
||||
void BRepOffsetAPI_MakeOffset::SetApprox(const Standard_Boolean ToApprox)
|
||||
{
|
||||
myIsToApprox = ToApprox;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepOffsetAPI_MakeOffset
|
||||
//purpose :
|
||||
@@ -289,6 +351,46 @@ void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset,
|
||||
|
||||
try
|
||||
{
|
||||
if (myIsToApprox)
|
||||
{
|
||||
Standard_Real aTol = 0.1;
|
||||
if (myFace.IsNull())
|
||||
{
|
||||
TopoDS_Face aFace;
|
||||
Standard_Boolean OnlyPlane = Standard_True;
|
||||
TopTools_ListIteratorOfListOfShape anItl (myWires);
|
||||
for (; anItl.More(); anItl.Next())
|
||||
{
|
||||
BRepBuilderAPI_MakeFace aFaceMaker (TopoDS::Wire(anItl.Value()), OnlyPlane);
|
||||
if (aFaceMaker.Error() == BRepBuilderAPI_FaceDone)
|
||||
{
|
||||
aFace = aFaceMaker.Face();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (anItl.Initialize(myWires); anItl.More(); anItl.Next())
|
||||
{
|
||||
const TopoDS_Wire& aWire = TopoDS::Wire(anItl.Value());
|
||||
if (NeedsConvertion (aWire))
|
||||
{
|
||||
TopoDS_Wire aNewWire = BRepAlgo::ConvertWire (aWire, aTol, aFace);
|
||||
BRepLib::BuildCurves3d (aNewWire);
|
||||
aNewWire.Orientation (aWire.Orientation());
|
||||
anItl.ChangeValue() = aNewWire;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myFace = ConvertFace (myFace, aTol);
|
||||
BRepLib::BuildCurves3d (myFace);
|
||||
myWires.Clear();
|
||||
TopoDS_Iterator anIter (myFace);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
myWires.Append (anIter.Value());
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Integer i = 1;
|
||||
BRepFill_ListIteratorOfListOfOffsetWire itOW;
|
||||
TopoDS_Compound Res;
|
||||
|
@@ -63,6 +63,11 @@ public:
|
||||
//! Initialize the evaluation of Offsetting.
|
||||
Standard_EXPORT void Init (const GeomAbs_JoinType Join = GeomAbs_Arc, const Standard_Boolean IsOpenResult = Standard_False);
|
||||
|
||||
//! Set approximation flag
|
||||
//! for convertion input contours into ones consisting of
|
||||
//! 2D circular arcs and 2D linear segments only.
|
||||
Standard_EXPORT void SetApprox (const Standard_Boolean ToApprox);
|
||||
|
||||
//! Initializes the algorithm to construct parallels to the wire Spine.
|
||||
Standard_EXPORT void AddWire (const TopoDS_Wire& Spine);
|
||||
|
||||
@@ -79,7 +84,10 @@ public:
|
||||
//! from the shape <S>.
|
||||
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Converts each wire of the face into contour consisting only of
|
||||
//! arcs and segments. New 3D curves are built too.
|
||||
Standard_EXPORT static TopoDS_Face ConvertFace (const TopoDS_Face& theFace,
|
||||
const Standard_Real theAngleTolerance);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -96,6 +104,7 @@ private:
|
||||
Standard_Boolean myLastIsLeft;
|
||||
GeomAbs_JoinType myJoin;
|
||||
Standard_Boolean myIsOpenResult;
|
||||
Standard_Boolean myIsToApprox;
|
||||
TopoDS_Face myFace;
|
||||
TopTools_ListOfShape myWires;
|
||||
BRepFill_ListOfOffsetWire myLeft;
|
||||
|
@@ -124,7 +124,14 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
|
||||
Standard_Boolean isBasic = Standard_False;
|
||||
Standard_Boolean isForced = Standard_False;
|
||||
Standard_Boolean isCopy = Standard_False;
|
||||
Standard_Boolean isCopyMesh = Standard_False;
|
||||
|
||||
// Check "copymesh" flag.
|
||||
if (!strcmp(a[n - 1], "-copymesh"))
|
||||
{
|
||||
isCopyMesh = Standard_True;
|
||||
last = --n;
|
||||
}
|
||||
// Check "copy" flag.
|
||||
if (!strcmp(a[n-1], "-copy")) {
|
||||
isCopy = Standard_True;
|
||||
@@ -218,7 +225,7 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
trf.Perform(S, isCopy);
|
||||
trf.Perform(S, isCopy, isCopyMesh);
|
||||
if (!trf.IsDone())
|
||||
return 1;
|
||||
DBRep::Set(a[i],trf.Shape());
|
||||
@@ -1487,27 +1494,27 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tmove",
|
||||
"tmove name1 name2 ... name, set location from name [-copy]",
|
||||
"tmove name1 name2 ... name, set location from name [-copy] [-copymesh]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("ttranslate",
|
||||
"ttranslate name1 name2 ... dx dy dz [-copy]",
|
||||
"ttranslate name1 name2 ... dx dy dz [-copy [-copymesh]]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("trotate",
|
||||
"trotate name1 name2 ... x y z dx dy dz angle [-copy]",
|
||||
"trotate name1 name2 ... x y z dx dy dz angle [-copy [-copymesh]]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tmirror",
|
||||
"tmirror name x y z dx dy dz [-copy]",
|
||||
"tmirror name x y z dx dy dz [-copy] [-copymesh]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tscale",
|
||||
"tscale name x y z scale [-copy]",
|
||||
"tscale name x y z scale [-copy] [-copymesh]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
|
@@ -1530,10 +1530,23 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
|
||||
char name[100];
|
||||
|
||||
BRepOffsetAPI_MakeOffset Paral;
|
||||
|
||||
Standard_Boolean ToApprox = Standard_False;
|
||||
GeomAbs_JoinType theJoinType = GeomAbs_Arc;
|
||||
if (n >= 6 && strcmp(a[5], "i") == 0)
|
||||
theJoinType = GeomAbs_Intersection;
|
||||
Paral.Init(theJoinType);
|
||||
|
||||
Standard_Integer anIndArg = 6;
|
||||
if (n >= 6)
|
||||
{
|
||||
if (strcmp(a[5], "-approx") == 0)
|
||||
{
|
||||
ToApprox = Standard_True;
|
||||
anIndArg++;
|
||||
}
|
||||
|
||||
if (n >= anIndArg && strcmp(a[anIndArg-1], "i") == 0)
|
||||
theJoinType = GeomAbs_Intersection;
|
||||
}
|
||||
|
||||
TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_FACE);
|
||||
|
||||
if ( Base.IsNull())
|
||||
@@ -1553,6 +1566,7 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
|
||||
Base.Orientation(TopAbs_FORWARD);
|
||||
Paral.Init(TopoDS::Face(Base), theJoinType);
|
||||
}
|
||||
Paral.SetApprox (ToApprox);
|
||||
|
||||
Standard_Real U, dU;
|
||||
Standard_Integer Nb;
|
||||
@@ -1560,8 +1574,8 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
|
||||
Nb = Draw::Atoi(a[3]);
|
||||
|
||||
Standard_Real Alt = 0.;
|
||||
if ( n == 7)
|
||||
Alt = Draw::Atof(a[6]);
|
||||
if (n > anIndArg)
|
||||
Alt = Draw::Atof(a[anIndArg]);
|
||||
|
||||
Standard_Integer Compt = 1;
|
||||
|
||||
@@ -1598,16 +1612,30 @@ Standard_Integer openoffset(Draw_Interpretor& di,
|
||||
char name[100];
|
||||
|
||||
BRepOffsetAPI_MakeOffset Paral;
|
||||
|
||||
Standard_Boolean ToApprox = Standard_False;
|
||||
GeomAbs_JoinType theJoinType = GeomAbs_Arc;
|
||||
if (n == 6 && strcmp(a[5], "i") == 0)
|
||||
theJoinType = GeomAbs_Intersection;
|
||||
Paral.Init(theJoinType, Standard_True);
|
||||
|
||||
Standard_Integer anIndArg = 6;
|
||||
if (n >= 6)
|
||||
{
|
||||
if (strcmp(a[5], "-approx") == 0)
|
||||
{
|
||||
ToApprox = Standard_True;
|
||||
anIndArg++;
|
||||
}
|
||||
|
||||
if (n >= anIndArg && strcmp(a[anIndArg-1], "i") == 0)
|
||||
theJoinType = GeomAbs_Intersection;
|
||||
}
|
||||
|
||||
TopoDS_Shape Base = DBRep::Get(a[2] ,TopAbs_FACE);
|
||||
|
||||
if ( Base.IsNull())
|
||||
{
|
||||
Base = DBRep::Get(a[2], TopAbs_WIRE);
|
||||
if (Base.IsNull()) return 1;
|
||||
Paral.Init(theJoinType, Standard_True);
|
||||
Paral.AddWire(TopoDS::Wire(Base));
|
||||
}
|
||||
else
|
||||
@@ -1615,6 +1643,7 @@ Standard_Integer openoffset(Draw_Interpretor& di,
|
||||
Base.Orientation(TopAbs_FORWARD);
|
||||
Paral.Init(TopoDS::Face(Base), theJoinType, Standard_True);
|
||||
}
|
||||
Paral.SetApprox (ToApprox);
|
||||
|
||||
Standard_Real U, dU;
|
||||
Standard_Integer Nb;
|
||||
@@ -1755,6 +1784,72 @@ Standard_Integer edgeintersector(Draw_Interpretor& di,
|
||||
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
//function : arclinconvert
|
||||
//purpose : Convert a single face to a face with contour made of arcs and segments
|
||||
//=================================================================================
|
||||
|
||||
static Standard_Integer arclinconvert (Draw_Interpretor& /*dout*/, Standard_Integer n, const char** a)
|
||||
{
|
||||
// Check the command arguments
|
||||
if (n < 3) {
|
||||
std::cout<<"Error: "<<a[0]<<" - invalid number of arguments"<<std::endl;
|
||||
std::cout<<"Usage: type help "<<a[0]<<std::endl;
|
||||
return 1; //TCL_ERROR
|
||||
}
|
||||
|
||||
//read shape
|
||||
const TopoDS_Shape aShape = DBRep::Get(a[2]);
|
||||
if (aShape.IsNull()) {
|
||||
std::cout<<"Error: "<<a[2]<<" is null"<<std::endl;
|
||||
return 1; //TCL_ERROR
|
||||
}
|
||||
|
||||
TopAbs_ShapeEnum aType = aShape.ShapeType();
|
||||
if (aType != TopAbs_WIRE &&
|
||||
aType != TopAbs_FACE)
|
||||
{
|
||||
std::cout<<"Error: "<<a[2]<<" is neither wire no face"<<std::endl;
|
||||
return 1; //TCL_ERROR
|
||||
}
|
||||
|
||||
//read tolerance
|
||||
Standard_Real aTol = 0.01;
|
||||
if (n > 3)
|
||||
aTol = Draw::Atof(a[3]);
|
||||
std::cout<<"Info: tolerance is set to "<<aTol<<std::endl;
|
||||
|
||||
TopoDS_Shape aResult;
|
||||
|
||||
if (aType == TopAbs_WIRE)
|
||||
{
|
||||
Standard_Boolean OnlyPlane = Standard_False;
|
||||
BRepBuilderAPI_MakeFace aFaceMaker (TopoDS::Wire(aShape), OnlyPlane);
|
||||
if (aFaceMaker.Error() != BRepBuilderAPI_FaceDone)
|
||||
{
|
||||
std::cout<<"Error: failed to find a face for the wire "<<a[2]<<std::endl;
|
||||
return 1; //TCL_ERROR
|
||||
}
|
||||
TopoDS_Face aFace = aFaceMaker.Face();
|
||||
TopoDS_Iterator anIter (aFace);
|
||||
TopoDS_Wire aWire = TopoDS::Wire (anIter.Value());
|
||||
aResult = BRepAlgo::ConvertWire (aWire, aTol, aFace);
|
||||
}
|
||||
else if (aType == TopAbs_FACE)
|
||||
{
|
||||
TopoDS_Face aFace = TopoDS::Face(aShape);
|
||||
aResult = BRepAlgo::ConvertFace (aFace, aTol);
|
||||
}
|
||||
|
||||
if (aResult.IsNull()) {
|
||||
std::cout<<"Error: could not convert "<<a[2]<<std::endl;
|
||||
return 1; //TCL_ERROR
|
||||
}
|
||||
|
||||
DBRep::Set(a[1], aResult);
|
||||
return 0; //TCL_OK
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : concatC0wire
|
||||
//purpose :
|
||||
@@ -1908,11 +2003,11 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands)
|
||||
profile2d,g);
|
||||
|
||||
theCommands.Add("mkoffset",
|
||||
"mkoffset result face/compound of wires nboffset stepoffset [jointype(a/i) [alt]]",__FILE__,
|
||||
"mkoffset result face/compound of wires nboffset stepoffset [-approx] [jointype(a/i) [alt]]",__FILE__,
|
||||
mkoffset,g);
|
||||
|
||||
theCommands.Add("openoffset",
|
||||
"openoffset result face/wire nboffset stepoffset [jointype(a/i)]",__FILE__,
|
||||
"openoffset result face/wire nboffset stepoffset [-approx] [jointype(a/i)]",__FILE__,
|
||||
openoffset,g);
|
||||
|
||||
theCommands.Add("mkedge",
|
||||
@@ -1968,6 +2063,12 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands)
|
||||
"reducepcurves shape1 shape2 ...",__FILE__,
|
||||
reducepcurves, g);
|
||||
|
||||
theCommands.Add("arclinconvert",
|
||||
"arclinconvert result wire/face [tol]",
|
||||
__FILE__,
|
||||
arclinconvert,
|
||||
g);
|
||||
|
||||
theCommands.Add("concatC0wire",
|
||||
"concatC0wire result wire",
|
||||
__FILE__,
|
||||
|
@@ -173,7 +173,7 @@ static int ShapeProximity (Draw_Interpretor& theDI, Standard_Integer theNbArgs,
|
||||
{
|
||||
if (theNbArgs < 3 || theNbArgs > 6)
|
||||
{
|
||||
Message::SendFail() << "Usage: " << theArgs[0] << " Shape1 Shape2 [-tol <value>] [-profile]";
|
||||
Message::SendFail() << "Usage: " << theArgs[0] << " Shape1 Shape2 [-tol <value> | -value] [-profile]";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -186,9 +186,11 @@ static int ShapeProximity (Draw_Interpretor& theDI, Standard_Integer theNbArgs,
|
||||
return 1;
|
||||
}
|
||||
|
||||
BRepExtrema_ShapeProximity aTool;
|
||||
BRepExtrema_ShapeProximity aTool(0.0);
|
||||
|
||||
Standard_Boolean aProfile = Standard_False;
|
||||
Standard_Boolean isTolerance = Standard_False;
|
||||
Standard_Boolean isValue = Standard_False;
|
||||
|
||||
for (Standard_Integer anArgIdx = 3; anArgIdx < theNbArgs; ++anArgIdx)
|
||||
{
|
||||
@@ -197,6 +199,7 @@ static int ShapeProximity (Draw_Interpretor& theDI, Standard_Integer theNbArgs,
|
||||
|
||||
if (aFlag == "-tol")
|
||||
{
|
||||
isTolerance = Standard_True;
|
||||
if (++anArgIdx >= theNbArgs)
|
||||
{
|
||||
Message::SendFail() << "Error: wrong syntax at argument '" << aFlag;
|
||||
@@ -214,13 +217,23 @@ static int ShapeProximity (Draw_Interpretor& theDI, Standard_Integer theNbArgs,
|
||||
aTool.SetTolerance (aTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
if (aFlag == "-profile")
|
||||
else if (aFlag == "-value")
|
||||
{
|
||||
isValue = Standard_True;
|
||||
aTool.SetTolerance(Precision::Infinite());
|
||||
}
|
||||
else if (aFlag == "-profile")
|
||||
{
|
||||
aProfile = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (isTolerance && isValue)
|
||||
{
|
||||
Message::SendFail() << "Error: Proximity value could not be computed if the tolerance is set";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aInitTime = 0.0;
|
||||
Standard_Real aWorkTime = 0.0;
|
||||
|
||||
@@ -264,39 +277,74 @@ static int ShapeProximity (Draw_Interpretor& theDI, Standard_Integer theNbArgs,
|
||||
theDI << "Executing proximity test: " << aWorkTime << "\n";
|
||||
}
|
||||
|
||||
TopoDS_Builder aCompBuilder;
|
||||
|
||||
TopoDS_Compound aFaceCompound1;
|
||||
aCompBuilder.MakeCompound (aFaceCompound1);
|
||||
|
||||
for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt1 (aTool.OverlapSubShapes1()); anIt1.More(); anIt1.Next())
|
||||
if (isValue)
|
||||
{
|
||||
TCollection_AsciiString aStr = TCollection_AsciiString (theArgs[1]) + "_" + (anIt1.Key() + 1);
|
||||
theDI << "Proximity value: " << aTool.Proximity() << "\n";
|
||||
|
||||
const TopoDS_Face& aFace = aTool.GetSubShape1 (anIt1.Key());
|
||||
aCompBuilder.Add (aFaceCompound1, aFace);
|
||||
DBRep::Set (aStr.ToCString(), aFace);
|
||||
// proximity points
|
||||
TopoDS_Vertex aProxVtx1 = BRepLib_MakeVertex (aTool.ProximityPoint1());
|
||||
TopoDS_Vertex aProxVtx2 = BRepLib_MakeVertex (aTool.ProximityPoint2());
|
||||
|
||||
theDI << aStr << " \n";
|
||||
DBRep::Set ("ProxPnt1", aProxVtx1);
|
||||
DBRep::Set ("ProxPnt2", aProxVtx2);
|
||||
|
||||
// proximity points' status
|
||||
TCollection_AsciiString ProxPntStatus1;
|
||||
TCollection_AsciiString ProxPntStatus2;
|
||||
|
||||
switch (aTool.ProxPntStatus1())
|
||||
{
|
||||
case 0: ProxPntStatus1 = "Border"; break;
|
||||
case 1: ProxPntStatus1 = "Middle"; break;
|
||||
default: ProxPntStatus1 = "Unknown";
|
||||
}
|
||||
|
||||
switch (aTool.ProxPntStatus2())
|
||||
{
|
||||
case 0: ProxPntStatus2 = "Border"; break;
|
||||
case 1: ProxPntStatus2 = "Middle"; break;
|
||||
default: ProxPntStatus2 = "Unknown";
|
||||
}
|
||||
|
||||
theDI << " Status of ProxPnt1 on " << theArgs[1] << " : " << ProxPntStatus1 << "\n";
|
||||
theDI << " Status of ProxPnt2 on " << theArgs[2] << " : " << ProxPntStatus2 << "\n";
|
||||
}
|
||||
|
||||
TopoDS_Compound aFaceCompound2;
|
||||
aCompBuilder.MakeCompound (aFaceCompound2);
|
||||
|
||||
for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt2 (aTool.OverlapSubShapes2()); anIt2.More(); anIt2.Next())
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aStr = TCollection_AsciiString (theArgs[2]) + "_" + (anIt2.Key() + 1);
|
||||
TopoDS_Builder aCompBuilder;
|
||||
|
||||
const TopoDS_Face& aFace = aTool.GetSubShape2 (anIt2.Key());
|
||||
aCompBuilder.Add (aFaceCompound2, aFace);
|
||||
DBRep::Set (aStr.ToCString(), aFace);
|
||||
TopoDS_Compound aFaceCompound1;
|
||||
aCompBuilder.MakeCompound(aFaceCompound1);
|
||||
|
||||
theDI << aStr << " \n";
|
||||
for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt1(aTool.OverlapSubShapes1()); anIt1.More(); anIt1.Next())
|
||||
{
|
||||
TCollection_AsciiString aStr = TCollection_AsciiString(theArgs[1]) + "_" + (anIt1.Key() + 1);
|
||||
|
||||
const TopoDS_Shape& aShape = aTool.GetSubShape1(anIt1.Key());
|
||||
aCompBuilder.Add(aFaceCompound1, aShape);
|
||||
DBRep::Set(aStr.ToCString(), aShape);
|
||||
|
||||
theDI << aStr << " \n";
|
||||
}
|
||||
|
||||
TopoDS_Compound aFaceCompound2;
|
||||
aCompBuilder.MakeCompound(aFaceCompound2);
|
||||
|
||||
for (BRepExtrema_MapOfIntegerPackedMapOfInteger::Iterator anIt2(aTool.OverlapSubShapes2()); anIt2.More(); anIt2.Next())
|
||||
{
|
||||
TCollection_AsciiString aStr = TCollection_AsciiString(theArgs[2]) + "_" + (anIt2.Key() + 1);
|
||||
|
||||
const TopoDS_Shape& aShape = aTool.GetSubShape2(anIt2.Key());
|
||||
aCompBuilder.Add(aFaceCompound2, aShape);
|
||||
DBRep::Set(aStr.ToCString(), aShape);
|
||||
|
||||
theDI << aStr << " \n";
|
||||
}
|
||||
|
||||
DBRep::Set((TCollection_AsciiString(theArgs[1]) + "_" + "overlapped").ToCString(), aFaceCompound1);
|
||||
DBRep::Set((TCollection_AsciiString(theArgs[2]) + "_" + "overlapped").ToCString(), aFaceCompound2);
|
||||
}
|
||||
|
||||
DBRep::Set ((TCollection_AsciiString (theArgs[1]) + "_" + "overlapped").ToCString(), aFaceCompound1);
|
||||
DBRep::Set ((TCollection_AsciiString (theArgs[2]) + "_" + "overlapped").ToCString(), aFaceCompound2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -445,12 +493,14 @@ void BRepTest::ExtremaCommands (Draw_Interpretor& theCommands)
|
||||
aGroup);
|
||||
|
||||
theCommands.Add ("proximity",
|
||||
"proximity Shape1 Shape2 [-tol <value>] [-profile]"
|
||||
"proximity Shape1 Shape2 [-tol <value> | -value] [-profile]"
|
||||
"\n\t\t: Searches for pairs of overlapping faces of the given shapes."
|
||||
"\n\t\t: The options are:"
|
||||
"\n\t\t: -tol : non-negative tolerance value used for overlapping"
|
||||
"\n\t\t: test (for zero tolerance, the strict intersection"
|
||||
"\n\t\t: test will be performed)"
|
||||
"\n\t\t: -value : compute the proximity value (minimal value which"
|
||||
"\n\t\t: shows both shapes fully overlapped)"
|
||||
"\n\t\t: -profile : outputs execution time for main algorithm stages",
|
||||
__FILE__,
|
||||
ShapeProximity,
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include <Bisector_BisecAna.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <BRepOffsetAPI_MakeOffset.hxx>
|
||||
#include <BRepMAT2d_Explorer.hxx>
|
||||
#include <BRepMAT2d_BisectingLocus.hxx>
|
||||
#include <BRepMAT2d_LinkTopoBilo.hxx>
|
||||
@@ -44,6 +45,7 @@
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
#ifdef _WIN32
|
||||
Standard_IMPORT Draw_Viewer dout;
|
||||
@@ -70,7 +72,16 @@ static Standard_Integer topoload (Draw_Interpretor& , Standard_Integer argc, con
|
||||
|
||||
if (C1.IsNull()) return 1;
|
||||
|
||||
anExplo.Perform (TopoDS::Face(C1));
|
||||
TopoDS_Face aFace = TopoDS::Face(C1);
|
||||
|
||||
if (argc >= 3 &&
|
||||
(strcmp(argv[2], "-approx") == 0))
|
||||
{
|
||||
Standard_Real aTol = 0.1;
|
||||
aFace = BRepOffsetAPI_MakeOffset::ConvertFace (aFace, aTol);
|
||||
}
|
||||
|
||||
anExplo.Perform (aFace);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -267,7 +278,7 @@ void DrawCurve(const Handle(Geom2d_Curve)& aCurve,
|
||||
|
||||
void BRepTest::MatCommands (Draw_Interpretor& theCommands)
|
||||
{
|
||||
theCommands.Add("topoload","load face",__FILE__,topoload);
|
||||
theCommands.Add("topoload","load face: topoload face [-approx]",__FILE__,topoload);
|
||||
theCommands.Add("drawcont","display current contour",__FILE__,drawcont);
|
||||
theCommands.Add("mat","computes the mat: mat [a/i [o]]",__FILE__,mat);
|
||||
theCommands.Add("side","side left/right",__FILE__,side);
|
||||
|
@@ -893,6 +893,8 @@ void BRepTools::CleanGeometry(const TopoDS_Shape& theShape)
|
||||
aBuilder.UpdateEdge(anEdge, Handle(Geom_Curve)(),
|
||||
TopLoc_Location(), BRep_Tool::Tolerance(anEdge));
|
||||
}
|
||||
|
||||
RemoveUnusedPCurves(theShape);
|
||||
}
|
||||
|
||||
|
||||
|
215
src/BRepTools/BRepTools_CopyModification.cxx
Normal file
215
src/BRepTools/BRepTools_CopyModification.cxx
Normal file
@@ -0,0 +1,215 @@
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepTools_CopyModification
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTools_CopyModification::BRepTools_CopyModification(const Standard_Boolean copyGeom,
|
||||
const Standard_Boolean copyMesh)
|
||||
: myCopyGeom(copyGeom),
|
||||
myCopyMesh(copyMesh)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewSurface(const TopoDS_Face& theFace,
|
||||
Handle(Geom_Surface)& theSurf,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol,
|
||||
Standard_Boolean& theRevWires,
|
||||
Standard_Boolean& theRevFace)
|
||||
{
|
||||
theSurf = BRep_Tool::Surface(theFace, theLoc);
|
||||
theTol = BRep_Tool::Tolerance(theFace);
|
||||
theRevWires = theRevFace = Standard_False;
|
||||
|
||||
if (!theSurf.IsNull() && myCopyGeom)
|
||||
theSurf = Handle(Geom_Surface)::DownCast(theSurf->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theFace))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theTri = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
|
||||
if (theTri.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// mesh is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
theTri = theTri->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewCurve(const TopoDS_Edge& theEdge,
|
||||
Handle(Geom_Curve)& theCurve,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
Standard_Real aFirst, aLast;
|
||||
theCurve = BRep_Tool::Curve(theEdge, theLoc, aFirst, aLast);
|
||||
theTol = BRep_Tool::Tolerance(theEdge);
|
||||
|
||||
if (!theCurve.IsNull() && myCopyGeom)
|
||||
theCurve = Handle(Geom_Curve)::DownCast(theCurve->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
|
||||
|
||||
if (thePoly.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPolygonOnTriangulation(
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aTria, aLoc);
|
||||
|
||||
if (thePoly.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPoint(const TopoDS_Vertex& theVertex,
|
||||
gp_Pnt& thePnt,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
thePnt = BRep_Tool::Pnt(theVertex);
|
||||
theTol = BRep_Tool::Tolerance(theVertex);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewCurve2d(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge&,
|
||||
const TopoDS_Face&,
|
||||
Handle(Geom2d_Curve)& theCurve,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
theTol = BRep_Tool::Tolerance(theEdge);
|
||||
Standard_Real aFirst, aLast;
|
||||
theCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
|
||||
|
||||
if (!theCurve.IsNull() && myCopyGeom)
|
||||
theCurve = Handle(Geom2d_Curve)::DownCast(theCurve->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewParameter(const TopoDS_Vertex& theVertex,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& thePnt,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
if (theVertex.IsNull())
|
||||
return Standard_False; // infinite edge may have Null vertex
|
||||
|
||||
theTol = BRep_Tool::Tolerance(theVertex);
|
||||
thePnt = BRep_Tool::Parameter(theVertex, theEdge);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomAbs_Shape BRepTools_CopyModification::Continuity(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace1,
|
||||
const TopoDS_Face& theFace2,
|
||||
const TopoDS_Edge&,
|
||||
const TopoDS_Face&,
|
||||
const TopoDS_Face&)
|
||||
{
|
||||
return BRep_Tool::Continuity(theEdge, theFace1, theFace2);
|
||||
}
|
||||
|
||||
|
124
src/BRepTools/BRepTools_CopyModification.hxx
Normal file
124
src/BRepTools/BRepTools_CopyModification.hxx
Normal file
@@ -0,0 +1,124 @@
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepTools_CopyModification_HeaderFile
|
||||
#define _BRepTools_CopyModification_HeaderFile
|
||||
|
||||
#include <BRepTools_Modification.hxx>
|
||||
|
||||
class BRepTools_CopyModification;
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
//! Tool class implementing necessary functionality for copying geometry and triangulation.
|
||||
class BRepTools_CopyModification : public BRepTools_Modification
|
||||
{
|
||||
public:
|
||||
//! Constructor.
|
||||
//! \param[in] theCopyGeom indicates that the geomtery (surfaces and curves) should be copied
|
||||
//! \param[in] theCopyMesh indicates that the triangulation should be copied
|
||||
Standard_EXPORT explicit BRepTools_CopyModification(const Standard_Boolean theCopyGeom = Standard_True,
|
||||
const Standard_Boolean theCopyMesh = Standard_True);
|
||||
|
||||
//! Returns true if theFace has been modified.
|
||||
//! If the face has been modified:
|
||||
//! - theSurf is the new geometry of the face,
|
||||
//! - theLoc is its new location, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! theRevWires, theRevFace are always set to false, because the orientaion is not changed.
|
||||
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& theFace,
|
||||
Handle(Geom_Surface)& theSurf,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol,
|
||||
Standard_Boolean& theRevWires,
|
||||
Standard_Boolean& theRevFace) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theEdge has been modified.
|
||||
//! If the edge has been modified:
|
||||
//! - theCurve is the new geometric support of the edge,
|
||||
//! - theLoc is the new location, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If the edge has not been modified, this function
|
||||
//! returns false, and the values of theCurve, theLoc and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& theEdge,
|
||||
Handle(Geom_Curve)& theCurve,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theVertex has been modified.
|
||||
//! If the vertex has been modified:
|
||||
//! - thePnt is the new geometry of the vertex, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If the vertex has not been modified this function
|
||||
//! returns false, and the values of thePnt and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& theVertex, gp_Pnt& thePnt, Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theEdge has a new curve on surface on theFace.
|
||||
//! If a new curve exists:
|
||||
//! - theCurve is the new geometric support of the edge,
|
||||
//! - theTol the new tolerance.
|
||||
//! If no new curve exists, this function returns false, and
|
||||
//! the values of theCurve and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge& theNewEdge,
|
||||
const TopoDS_Face& theNewFace,
|
||||
Handle(Geom2d_Curve)& theCurve,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theVertex has a new parameter on theEdge.
|
||||
//! If a new parameter exists:
|
||||
//! - thePnt is the parameter, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If no new parameter exists, this function returns false,
|
||||
//! and the values of thePnt and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& theVertex,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& thePnt,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the continuity of theNewEdge between theNewFace1 and theNewFace2.
|
||||
//!
|
||||
//! theNewEdge is the new edge created from theEdge. theNewFace1
|
||||
//! (resp. theNewFace2) is the new face created from theFace1 (resp. theFace2).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace1,
|
||||
const TopoDS_Face& theFace2,
|
||||
const TopoDS_Edge& theNewEdge,
|
||||
const TopoDS_Face& theNewFace1,
|
||||
const TopoDS_Face& theNewFace2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
private:
|
||||
Standard_Boolean myCopyGeom;
|
||||
Standard_Boolean myCopyMesh;
|
||||
};
|
||||
|
||||
#endif // _BRepTools_CopyModification_HeaderFile
|
@@ -29,6 +29,7 @@
|
||||
#include <GeomLib.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Quaternion.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
@@ -88,7 +89,13 @@ Standard_Boolean BRepTools_GTrsfModification::NewSurface
|
||||
gp_GTrsf gtrsf;
|
||||
gtrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
gtrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
S = Handle(Geom_Surface)::DownCast(BRep_Tool::Surface(F,L)->Copy());
|
||||
S = BRep_Tool::Surface(F, L);
|
||||
if (S.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
S = Handle(Geom_Surface)::DownCast(S->Copy());
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
Tol *= myGScale;
|
||||
@@ -173,7 +180,7 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve
|
||||
C = new Geom_TrimmedCurve(C, f, l);
|
||||
}
|
||||
L.Identity() ;
|
||||
return Standard_True;
|
||||
return !C.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -214,6 +221,11 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve2d
|
||||
Tol *= myGScale;
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
if (C.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
C = new Geom2d_TrimmedCurve(C, f, l);
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -251,4 +263,113 @@ GeomAbs_Shape BRepTools_GTrsfModification::Continuity
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTriangulation)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
if (theTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_GTrsf aGTrsf;
|
||||
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
aGTrsf.Multiply(aLoc.Transformation());
|
||||
|
||||
theTriangulation = theTriangulation->Copy();
|
||||
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
|
||||
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myGScale));
|
||||
// apply transformation to 3D nodes
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt aP = theTriangulation->Node(anInd);
|
||||
aGTrsf.Transforms(aP.ChangeCoord());
|
||||
theTriangulation->SetNode(anInd, aP);
|
||||
}
|
||||
// modify triangles orientation in case of mirror transformation
|
||||
if (myGScale < 0.0)
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
|
||||
Standard_Integer aN1, aN2, aN3;
|
||||
aTria.Get(aN1, aN2, aN3);
|
||||
aTria.Set(aN1, aN3, aN2);
|
||||
theTriangulation->SetTriangle(anInd, aTria);
|
||||
}
|
||||
}
|
||||
// modify normals
|
||||
if (theTriangulation->HasNormals())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
gp_Dir aNormal = theTriangulation->Normal(anInd);
|
||||
aNormal.Transform(aGTrsf.Trsf());
|
||||
theTriangulation->SetNormal(anInd, aNormal);
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
|
||||
if (thePoly.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_GTrsf aGTrsf;
|
||||
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
aGTrsf.Multiply(aLoc.Transformation());
|
||||
|
||||
thePoly = thePoly->Copy();
|
||||
thePoly->Deflection(thePoly->Deflection() * Abs(myGScale));
|
||||
// transform nodes
|
||||
TColgp_Array1OfPnt& aNodesArray = thePoly->ChangeNodes();
|
||||
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
|
||||
{
|
||||
gp_Pnt& aP = aNodesArray.ChangeValue(anId);
|
||||
aGTrsf.Transforms(aP.ChangeCoord());
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewPolygonOnTriangulation
|
||||
(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
if (aT.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aT, aLoc);
|
||||
if (!thePoly.IsNull())
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -101,6 +101,25 @@ public:
|
||||
//! (resp. <F2>).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -20,7 +20,10 @@
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <Extrema_ExtPC2d.hxx>
|
||||
#include <Extrema_GenLocateExtPS.hxx>
|
||||
#include <Extrema_LocateExtPC.hxx>
|
||||
#include <Extrema_LocateExtPC2d.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
@@ -47,30 +50,163 @@
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
|
||||
|
||||
//
|
||||
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newU1,
|
||||
const Standard_Real newU2)
|
||||
namespace
|
||||
{
|
||||
TColStd_Array1OfReal knots(1,aSurface->NbUKnots()) ;
|
||||
aSurface->UKnots(knots) ;
|
||||
BSplCLib::Reparametrize(newU1,
|
||||
newU2,
|
||||
knots) ;
|
||||
aSurface->SetUKnots(knots) ;
|
||||
}
|
||||
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newV1,
|
||||
const Standard_Real newV2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1,aSurface->NbVKnots()) ;
|
||||
aSurface->VKnots(knots) ;
|
||||
BSplCLib::Reparametrize(newV1,
|
||||
newV2,
|
||||
knots) ;
|
||||
aSurface->SetVKnots(knots) ;
|
||||
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newU1,
|
||||
const Standard_Real newU2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1, aSurface->NbUKnots());
|
||||
aSurface->UKnots(knots);
|
||||
BSplCLib::Reparametrize(newU1, newU2, knots);
|
||||
aSurface->SetUKnots(knots);
|
||||
}
|
||||
|
||||
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newV1,
|
||||
const Standard_Real newV2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1, aSurface->NbVKnots());
|
||||
aSurface->VKnots(knots);
|
||||
BSplCLib::Reparametrize(newV1, newV2, knots);
|
||||
aSurface->SetVKnots(knots);
|
||||
}
|
||||
|
||||
// find 3D curve from theEdge in theMap, and return the transformed curve or NULL
|
||||
static Handle(Geom_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
Handle(Geom_Curve) aNewCurve;
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aLoc, theFirst, theLast);
|
||||
if (!aCurve.IsNull() && theMap.Contains(aCurve))
|
||||
{
|
||||
aNewCurve = Handle(Geom_Curve)::DownCast(theMap.FindFromKey(aCurve));
|
||||
aNewCurve = Handle(Geom_Curve)::DownCast(aNewCurve->Transformed(aLoc.Transformation()));
|
||||
}
|
||||
return aNewCurve;
|
||||
}
|
||||
|
||||
// find 2D curve from theEdge on theFace in theMap, and return the transformed curve or NULL
|
||||
static Handle(Geom2d_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, theFirst, theLast);
|
||||
return (!aC2d.IsNull() && theMap.Contains(aC2d)) ? Handle(Geom2d_Curve)::DownCast(theMap.FindFromKey(aC2d))
|
||||
: Handle(Geom2d_Curve)();
|
||||
}
|
||||
|
||||
// find surface from theFace in theMap, and return the transformed surface or NULL
|
||||
static Handle(Geom_Surface) newSurface(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Face& theFace)
|
||||
{
|
||||
Handle(Geom_Surface) aNewSurf;
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
if (!aSurf.IsNull() && theMap.Contains(aSurf))
|
||||
{
|
||||
aNewSurf = Handle(Geom_Surface)::DownCast(theMap.FindFromKey(aSurf));
|
||||
aNewSurf = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(aLoc.Transformation()));
|
||||
}
|
||||
return aNewSurf;
|
||||
}
|
||||
|
||||
static Standard_Boolean newParameter(const gp_Pnt& thePoint,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theTol,
|
||||
Standard_Real& theParam)
|
||||
{
|
||||
GeomAdaptor_Curve anAdaptor(theCurve);
|
||||
Extrema_LocateExtPC proj(thePoint, anAdaptor, theParam, theFirst, theLast, Precision::PConfusion());
|
||||
if (proj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = proj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
theParam = proj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
static Standard_Boolean newParameter(const gp_Pnt2d& theUV,
|
||||
const Handle(Geom2d_Curve)& theCurve2d,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theTol,
|
||||
Standard_Real& theParam)
|
||||
{
|
||||
Geom2dAdaptor_Curve anAdaptor(theCurve2d);
|
||||
Extrema_LocateExtPC2d aProj(theUV, anAdaptor, theParam, Precision::PConfusion());
|
||||
if (aProj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = aProj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
theParam = aProj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to use general extrema to find the parameter, because Extrema_LocateExtPC2d
|
||||
// sometimes could not find a solution if the parameter's first approach is several
|
||||
// spans away from the expected solution (test bugs/modalg_7/bug28722).
|
||||
Extrema_ExtPC2d anExt(theUV, anAdaptor, theFirst, theLast);
|
||||
if (anExt.IsDone())
|
||||
{
|
||||
Standard_Integer aMinInd = 0;
|
||||
Standard_Real aMinSqDist = Precision::Infinite();
|
||||
for (Standard_Integer anIndex = 1; anIndex <= anExt.NbExt(); ++anIndex)
|
||||
if (anExt.SquareDistance(anIndex) < aMinSqDist)
|
||||
{
|
||||
aMinSqDist = anExt.SquareDistance(anIndex);
|
||||
aMinInd = anIndex;
|
||||
}
|
||||
if (aMinSqDist < theTol * theTol)
|
||||
{
|
||||
theParam = anExt.Point(aMinInd).Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
static Standard_Boolean newUV(const gp_Pnt& thePoint,
|
||||
const Handle(Geom_Surface)& theSurf,
|
||||
const Standard_Real theTol,
|
||||
gp_Pnt2d& theUV)
|
||||
{
|
||||
GeomAdaptor_Surface anAdaptor(theSurf);
|
||||
Extrema_GenLocateExtPS aProj(anAdaptor);
|
||||
aProj.Perform(thePoint, theUV.X(), theUV.Y());
|
||||
if (aProj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = aProj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
gp_XY& aUV = theUV.ChangeCoord();
|
||||
aProj.Point().Parameter(aUV.ChangeCoord(1), aUV.ChangeCoord(2));
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -102,6 +238,12 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
Handle(Geom_Surface) SS = BRep_Tool::Surface(F,L);
|
||||
if (SS.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) TheTypeSS = SS->DynamicType();
|
||||
if ((TheTypeSS == STANDARD_TYPE(Geom_BSplineSurface)) ||
|
||||
(TheTypeSS == STANDARD_TYPE(Geom_BezierSurface))) {
|
||||
@@ -115,7 +257,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
//OCC466(apo)->
|
||||
U1 = curvU1; U2 = curvU2;
|
||||
V1 = curvV1; V2 = curvV2;
|
||||
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
S->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
|
||||
if (Abs(U1 - surfU1) <= TolPar)
|
||||
U1 = surfU1;
|
||||
@@ -192,10 +334,10 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
|
||||
if (Abs(surfU1-U1) > Tol || Abs(surfU2-U2) > Tol ||
|
||||
Abs(surfV1-V1) > Tol || Abs(surfV2-V2) > Tol)
|
||||
SS = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
|
||||
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
S = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
|
||||
S->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
|
||||
S = GeomConvert::SurfaceToBSplineSurface(SS);
|
||||
S = GeomConvert::SurfaceToBSplineSurface(S);
|
||||
Handle(Geom_BSplineSurface) BS = Handle(Geom_BSplineSurface)::DownCast(S) ;
|
||||
BS->Resolution(Tol, UTol, VTol) ;
|
||||
|
||||
@@ -210,6 +352,9 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
GeomLib_ChangeVBounds(BS, V1, V2) ;
|
||||
}
|
||||
|
||||
if (!myMap.Contains(SS)) {
|
||||
myMap.Add(SS, S);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -234,6 +379,41 @@ static Standard_Boolean IsConvert(const TopoDS_Edge& E)
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewTriangulation(theFace, theTri))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// convert UV nodes of the mesh
|
||||
if (theTri->HasUVNodes())
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
|
||||
if (!aSurf.IsNull() && !aNewSurf.IsNull())
|
||||
{
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(theFace);
|
||||
for (Standard_Integer anInd = 1; anInd <= theTri->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt2d aUV = theTri->UVNode(anInd);
|
||||
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
|
||||
if (newUV(aPoint, aNewSurf, aTol, aUV))
|
||||
theTri->SetUVNode(anInd, aUV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
@@ -312,6 +492,40 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve
|
||||
return Standard_True ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewPolygon(theEdge, thePoly))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// update parameters of polygon
|
||||
if (thePoly->HasParameters())
|
||||
{
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(theEdge);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast);
|
||||
Handle(Geom_Curve) aNewCurve = newCurve(myMap, theEdge, aFirst, aLast);
|
||||
if (!aCurve.IsNull() && !aNewCurve.IsNull()) // skip processing degenerated edges
|
||||
{
|
||||
TColStd_Array1OfReal& aParams = thePoly->ChangeParameters();
|
||||
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
|
||||
{
|
||||
Standard_Real& aParam = aParams(anInd);
|
||||
gp_Pnt aPoint = aCurve->Value(aParam);
|
||||
newParameter(aPoint, aNewCurve, aFirst, aLast, aTol, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
@@ -340,7 +554,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Standard_Real f2d,l2d;
|
||||
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
|
||||
Handle(Geom2d_Curve) aBaseC2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
|
||||
Standard_Real f3d,l3d;
|
||||
TopLoc_Location Loc;
|
||||
Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, Loc, f3d,l3d);
|
||||
@@ -348,6 +562,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
!C3d->IsKind(STANDARD_TYPE(Geom_BezierCurve))) ||
|
||||
IsConvert(E));
|
||||
|
||||
Handle(Geom2d_Curve) C2d = aBaseC2d;
|
||||
if(BRep_Tool::Degenerated(E)) {
|
||||
//Curve2d = C2d;
|
||||
if(!C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))
|
||||
@@ -356,6 +571,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
C2d = aTrimC;
|
||||
}
|
||||
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
if(!BRepTools::IsReallyClosed(E,F)) {
|
||||
@@ -381,9 +597,11 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
if(!newE.IsNull()) {
|
||||
C3d = BRep_Tool::Curve(newE, f3d, l3d);
|
||||
}
|
||||
else {
|
||||
if (C3d.IsNull()) {
|
||||
C3d = BRep_Tool::Curve(E,f3d,l3d);
|
||||
}
|
||||
if (C3d.IsNull())
|
||||
return Standard_False;
|
||||
GeomAdaptor_Curve G3dAC(C3d, f3d, l3d);
|
||||
Handle(GeomAdaptor_Curve) G3dAHC = new GeomAdaptor_Curve(G3dAC);
|
||||
|
||||
@@ -403,13 +621,16 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
S = BRep_Tool::Surface(newF);
|
||||
Handle(Geom_Surface) aNewS = BRep_Tool::Surface(newF);
|
||||
if (!aNewS.IsNull())
|
||||
S = aNewS;
|
||||
}
|
||||
S->Bounds(Uinf, Usup, Vinf, Vsup);
|
||||
//Uinf -= 1e-9; Usup += 1e-9; Vinf -= 1e-9; Vsup += 1e-9;
|
||||
@@ -451,6 +672,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
Curve2d = ProjOnCurve.BSpline();
|
||||
@@ -460,6 +682,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -502,6 +725,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
else {
|
||||
@@ -512,6 +736,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
@@ -557,6 +782,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
@@ -582,6 +808,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
@@ -629,6 +856,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
else {
|
||||
@@ -640,6 +868,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
mylcu.Append(C2dBis);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
@@ -651,11 +880,58 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
return Standard_False;
|
||||
}
|
||||
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygonOnTriangulation(
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewPolygonOnTriangulation(theEdge, theFace, thePoly))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// update parameters of 2D polygon
|
||||
if (thePoly->HasParameters())
|
||||
{
|
||||
Standard_Real aTol = Max(BRep_Tool::Tolerance(theEdge), thePoly->Deflection());
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
|
||||
Handle(Geom2d_Curve) aNewC2d = newCurve(myMap, theEdge, theFace, aFirst, aLast);
|
||||
if (!aSurf.IsNull() && !aC2d.IsNull() && !aNewSurf.IsNull() && !aNewC2d.IsNull())
|
||||
{
|
||||
// compute 2D tolerance
|
||||
GeomAdaptor_Surface aSurfAdapt(aSurf);
|
||||
Standard_Real aTol2D = Max(aSurfAdapt.UResolution(aTol), aSurfAdapt.VResolution(aTol));
|
||||
|
||||
for (Standard_Integer anInd = 1; anInd <= thePoly->NbNodes(); ++anInd)
|
||||
{
|
||||
Standard_Real aParam = thePoly->Parameter(anInd);
|
||||
gp_Pnt2d aUV = aC2d->Value(aParam);
|
||||
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
|
||||
if (newUV(aPoint, aNewSurf, aTol, aUV) &&
|
||||
newParameter(aUV, aNewC2d, aFirst, aLast, aTol2D, aParam))
|
||||
{
|
||||
thePoly->SetParameter(anInd, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
@@ -670,30 +946,12 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewParameter
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
if(BRep_Tool::Degenerated(E))
|
||||
return Standard_False;
|
||||
Standard_Real f, l, param = BRep_Tool::Parameter(V,E);
|
||||
TopLoc_Location L;
|
||||
|
||||
Handle(Geom_Curve) gc = BRep_Tool::Curve(E, L, f, l);
|
||||
if(!myMap.Contains(gc))
|
||||
return Standard_False;
|
||||
|
||||
Handle(Geom_BSplineCurve) gcc =
|
||||
Handle(Geom_BSplineCurve)::DownCast(myMap.FindFromKey(gc));
|
||||
|
||||
gcc = Handle(Geom_BSplineCurve)::DownCast(gcc->Transformed(L.Transformation()));
|
||||
|
||||
GeomAdaptor_Curve ac(gcc);
|
||||
gp_Pnt pnt = BRep_Tool::Pnt(V);
|
||||
|
||||
Extrema_LocateExtPC proj(pnt, ac, param, f, l, Tol);
|
||||
if(proj.IsDone()) {
|
||||
Standard_Real Dist2Min = proj.SquareDistance();
|
||||
if (Dist2Min < Tol*Tol) {
|
||||
P = proj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
P = BRep_Tool::Parameter(V,E);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aNewCurve = newCurve(myMap, E, aFirst, aLast);
|
||||
return !aNewCurve.IsNull() && newParameter(pnt, aNewCurve, aFirst, aLast, Tol, P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TColStd_ListOfTransient.hxx>
|
||||
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
|
||||
#include <BRepTools_Modification.hxx>
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
class TopoDS_Face;
|
||||
@@ -36,12 +36,12 @@ class Geom2d_Curve;
|
||||
|
||||
|
||||
class BRepTools_NurbsConvertModification;
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_Modification)
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_CopyModification)
|
||||
|
||||
//! Defines a modification of the geometry by a Trsf
|
||||
//! from gp. All methods return True and transform the
|
||||
//! geometry.
|
||||
class BRepTools_NurbsConvertModification : public BRepTools_Modification
|
||||
class BRepTools_NurbsConvertModification : public BRepTools_CopyModification
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -100,11 +100,27 @@ public:
|
||||
//! (resp. <F2>).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT const TopTools_ListOfShape& GetUpdatedEdges() const;
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <GeomLib.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
#include <gp_GTrsf2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
@@ -43,7 +44,8 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepTools_TrsfModification,BRepTools_Modification)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTools_TrsfModification::BRepTools_TrsfModification(const gp_Trsf& T) :
|
||||
myTrsf(T)
|
||||
myTrsf(T),
|
||||
myCopyMesh(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -58,6 +60,16 @@ gp_Trsf& BRepTools_TrsfModification::Trsf ()
|
||||
return myTrsf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsCopyMesh
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean& BRepTools_TrsfModification::IsCopyMesh()
|
||||
{
|
||||
return myCopyMesh;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
@@ -72,6 +84,12 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
if (S.IsNull())
|
||||
{
|
||||
//processing cases when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
Tol *= Abs(myTrsf.ScaleFactor());
|
||||
RevWires = Standard_False;
|
||||
@@ -87,6 +105,194 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewTriangulation
|
||||
(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTriangulation)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
|
||||
if (theTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf = myTrsf;
|
||||
if (!aLoc.IsIdentity())
|
||||
{
|
||||
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
|
||||
}
|
||||
|
||||
theTriangulation = theTriangulation->Copy();
|
||||
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
|
||||
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
// apply transformation to 3D nodes
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt aP = theTriangulation->Node(anInd);
|
||||
aP.Transform(aTrsf);
|
||||
theTriangulation->SetNode(anInd, aP);
|
||||
}
|
||||
// modify 2D nodes
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
if (theTriangulation->HasUVNodes() && !aSurf.IsNull())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt2d aP2d = theTriangulation->UVNode(anInd);
|
||||
aSurf->TransformParameters(aP2d.ChangeCoord().ChangeCoord(1),
|
||||
aP2d.ChangeCoord().ChangeCoord(2),
|
||||
myTrsf);
|
||||
theTriangulation->SetUVNode(anInd, aP2d);
|
||||
}
|
||||
}
|
||||
// modify triangles orientation in case of mirror transformation
|
||||
if (myTrsf.ScaleFactor() < 0.0)
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
|
||||
Standard_Integer aN1, aN2, aN3;
|
||||
aTria.Get(aN1, aN2, aN3);
|
||||
aTria.Set(aN1, aN3, aN2);
|
||||
theTriangulation->SetTriangle(anInd, aTria);
|
||||
}
|
||||
}
|
||||
// modify normals
|
||||
if (theTriangulation->HasNormals())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
gp_Dir aNormal = theTriangulation->Normal(anInd);
|
||||
aNormal.Transform(aTrsf);
|
||||
theTriangulation->SetNormal(anInd, aNormal);
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewPolygon
|
||||
(const TopoDS_Edge& theE,
|
||||
Handle(Poly_Polygon3D)& theP)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theP = BRep_Tool::Polygon3D(theE, aLoc);
|
||||
if (theP.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf = myTrsf;
|
||||
if (!aLoc.IsIdentity())
|
||||
{
|
||||
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
|
||||
}
|
||||
|
||||
theP = theP->Copy();
|
||||
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
TColgp_Array1OfPnt& aNodesArray = theP->ChangeNodes();
|
||||
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
|
||||
{
|
||||
//Applying the transformation to each node of polygon
|
||||
aNodesArray.ChangeValue(anId).Transform(aTrsf);
|
||||
}
|
||||
// transform the parametrization
|
||||
if (theP->HasParameters())
|
||||
{
|
||||
TopLoc_Location aCurveLoc;
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theE, aCurveLoc, aFirst, aLast);
|
||||
if (!aCurve.IsNull())
|
||||
{
|
||||
Standard_Real aReparametrization = aCurve->ParametricTransformation(aTrsf);
|
||||
if (Abs(aReparametrization - 1.0) > Precision::PConfusion())
|
||||
{
|
||||
TColStd_Array1OfReal& aParams = theP->ChangeParameters();
|
||||
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
|
||||
{
|
||||
aParams(anInd) *= aReparametrization;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewPolygonOnTriangulation
|
||||
(const TopoDS_Edge& theE,
|
||||
const TopoDS_Face& theF,
|
||||
Handle(Poly_PolygonOnTriangulation)& theP)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theF, aLoc);
|
||||
if (aT.IsNull())
|
||||
{
|
||||
theP = Handle(Poly_PolygonOnTriangulation) ();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theP = BRep_Tool::PolygonOnTriangulation(theE, aT, aLoc);
|
||||
if (theP.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
theP = theP->Copy();
|
||||
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
|
||||
// transform the parametrization
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theF, aLoc);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theE, theF, aFirst, aLast);
|
||||
if (!aSurf.IsNull() && !aC2d.IsNull() && Abs(Abs(myTrsf.ScaleFactor()) - 1.0) > TopLoc_Location::ScalePrec())
|
||||
{
|
||||
gp_GTrsf2d aGTrsf = aSurf->ParametricTransformation(myTrsf);
|
||||
if (aGTrsf.Form() != gp_Identity)
|
||||
{
|
||||
Handle(Geom2d_Curve) aNewC2d = GeomLib::GTransform(aC2d, aGTrsf);
|
||||
for (Standard_Integer anInd = 1; anInd <= theP->NbNodes(); ++anInd)
|
||||
{
|
||||
Standard_Real aParam = theP->Parameter(anInd);
|
||||
gp_Pnt2d aP2d = aC2d->Value(aParam);
|
||||
aGTrsf.Transforms(aP2d.ChangeCoord());
|
||||
GeomLib_Tool::Parameter(aNewC2d, aP2d, theP->Deflection(), aParam);
|
||||
theP->SetParameter(anInd, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
@@ -101,6 +307,10 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve
|
||||
{
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::Curve(E,L,f,l);
|
||||
if (C.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Tol *= Abs(myTrsf.ScaleFactor());
|
||||
@@ -153,6 +363,12 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve2d
|
||||
Standard_Real scale = myTrsf.ScaleFactor();
|
||||
Tol *= Abs(scale);
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,loc);
|
||||
|
||||
if (S.IsNull())
|
||||
{
|
||||
// processing the case when the surface (geometry) is deleted
|
||||
return Standard_False;
|
||||
}
|
||||
GeomAdaptor_Surface GAsurf(S);
|
||||
if (GAsurf.GetType() == GeomAbs_Plane)
|
||||
return Standard_False;
|
||||
|
@@ -50,6 +50,9 @@ public:
|
||||
//! Provides access to the gp_Trsf associated with this
|
||||
//! modification. The transformation can be changed.
|
||||
Standard_EXPORT gp_Trsf& Trsf();
|
||||
|
||||
//! Sets a flag to indicate the need to copy mesh.
|
||||
Standard_EXPORT Standard_Boolean& IsCopyMesh();
|
||||
|
||||
//! Returns true if the face F has been modified.
|
||||
//! If the face has been modified:
|
||||
@@ -64,6 +67,21 @@ public:
|
||||
//! associated with this modification is negative.
|
||||
Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& Tol, Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - T is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F, Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge E has been modified.
|
||||
//! If the edge has been modified:
|
||||
//! - C is the new geometric support of the edge,
|
||||
@@ -120,6 +138,7 @@ private:
|
||||
|
||||
|
||||
gp_Trsf myTrsf;
|
||||
Standard_Boolean myCopyMesh;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -1,5 +1,7 @@
|
||||
BRepTools.cxx
|
||||
BRepTools.hxx
|
||||
BRepTools_CopyModification.cxx
|
||||
BRepTools_CopyModification.hxx
|
||||
BRepTools_DataMapIteratorOfMapOfVertexPnt2d.hxx
|
||||
BRepTools_Debug.cxx
|
||||
BRepTools_GTrsfModification.cxx
|
||||
|
@@ -30,6 +30,15 @@ public: //! @name public types
|
||||
|
||||
typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
|
||||
|
||||
public:
|
||||
|
||||
enum BVH_PrjStateInTriangle
|
||||
{
|
||||
BVH_PrjStateInTriangle_VERTEX,
|
||||
BVH_PrjStateInTriangle_EDGE,
|
||||
BVH_PrjStateInTriangle_INNER
|
||||
};
|
||||
|
||||
public: //! @name Box-Box Square distance
|
||||
|
||||
//! Computes Square distance between Axis aligned bounding boxes
|
||||
@@ -113,11 +122,14 @@ public: //! @name Point-Box projection
|
||||
|
||||
public: //! @name Point-Triangle Square distance
|
||||
|
||||
//! Computes square distance between point and triangle
|
||||
static T PointTriangleSquareDistance (const BVH_VecNt& thePoint,
|
||||
const BVH_VecNt& theNode0,
|
||||
const BVH_VecNt& theNode1,
|
||||
const BVH_VecNt& theNode2)
|
||||
//! Find nearest point on a triangle for the given point
|
||||
static BVH_VecNt PointTriangleProjection (const BVH_VecNt& thePoint,
|
||||
const BVH_VecNt& theNode0,
|
||||
const BVH_VecNt& theNode1,
|
||||
const BVH_VecNt& theNode2,
|
||||
BVH_PrjStateInTriangle* thePrjState = nullptr,
|
||||
Standard_Integer* theNumberOfFirstNode = nullptr,
|
||||
Standard_Integer* theNumberOfLastNode = nullptr)
|
||||
{
|
||||
const BVH_VecNt aAB = theNode1 - theNode0;
|
||||
const BVH_VecNt aAC = theNode2 - theNode0;
|
||||
@@ -128,68 +140,110 @@ public: //! @name Point-Triangle Square distance
|
||||
|
||||
if (aABdotAP <= 0. && aACdotAP <= 0.)
|
||||
{
|
||||
return aAP.Dot(aAP);
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_VERTEX;
|
||||
*theNumberOfFirstNode = 0;
|
||||
*theNumberOfLastNode = 0;
|
||||
}
|
||||
return theNode0;
|
||||
}
|
||||
|
||||
|
||||
const BVH_VecNt aBC = theNode2 - theNode1;
|
||||
const BVH_VecNt aBP = thePoint - theNode1;
|
||||
|
||||
T aBAdotBP = -(aAB.Dot(aBP));
|
||||
T aBCdotBP = (aBC.Dot(aBP));
|
||||
|
||||
|
||||
T aBAdotBP = -(aAB.Dot (aBP));
|
||||
T aBCdotBP = (aBC.Dot (aBP));
|
||||
|
||||
if (aBAdotBP <= 0. && aBCdotBP <= 0.)
|
||||
{
|
||||
return (aBP.Dot(aBP));
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_VERTEX;
|
||||
*theNumberOfFirstNode = 1;
|
||||
*theNumberOfLastNode = 1;
|
||||
}
|
||||
return theNode1;
|
||||
}
|
||||
|
||||
|
||||
const BVH_VecNt aCP = thePoint - theNode2;
|
||||
|
||||
T aCBdotCP = -(aBC.Dot(aCP));
|
||||
T aCAdotCP = -(aAC.Dot(aCP));
|
||||
|
||||
|
||||
T aCBdotCP = -(aBC.Dot (aCP));
|
||||
T aCAdotCP = -(aAC.Dot (aCP));
|
||||
|
||||
if (aCAdotCP <= 0. && aCBdotCP <= 0.)
|
||||
{
|
||||
return (aCP.Dot(aCP));
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_VERTEX;
|
||||
*theNumberOfFirstNode = 2;
|
||||
*theNumberOfLastNode = 2;
|
||||
}
|
||||
return theNode2;
|
||||
}
|
||||
|
||||
T aACdotBP = (aAC.Dot(aBP));
|
||||
|
||||
|
||||
T aACdotBP = (aAC.Dot (aBP));
|
||||
|
||||
T aVC = aABdotAP * aACdotBP + aBAdotBP * aACdotAP;
|
||||
|
||||
|
||||
if (aVC <= 0. && aABdotAP > 0. && aBAdotBP > 0.)
|
||||
{
|
||||
const BVH_VecNt aDirect = aAP - aAB * (aABdotAP / (aABdotAP + aBAdotBP));
|
||||
|
||||
return (aDirect.Dot(aDirect));
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_EDGE;
|
||||
*theNumberOfFirstNode = 0;
|
||||
*theNumberOfLastNode = 1;
|
||||
}
|
||||
return theNode0 + aAB * (aABdotAP / (aABdotAP + aBAdotBP));
|
||||
}
|
||||
|
||||
T aABdotCP = (aAB.Dot(aCP));
|
||||
|
||||
|
||||
T aABdotCP = (aAB.Dot (aCP));
|
||||
|
||||
T aVA = aBAdotBP * aCAdotCP - aABdotCP * aACdotBP;
|
||||
|
||||
|
||||
if (aVA <= 0. && aBCdotBP > 0. && aCBdotCP > 0.)
|
||||
{
|
||||
const BVH_VecNt aDirect = aBP - aBC * (aBCdotBP / (aBCdotBP + aCBdotCP));
|
||||
|
||||
return (aDirect.Dot(aDirect));
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_EDGE;
|
||||
*theNumberOfFirstNode = 1;
|
||||
*theNumberOfLastNode = 2;
|
||||
}
|
||||
return theNode1 + aBC * (aBCdotBP / (aBCdotBP + aCBdotCP));
|
||||
}
|
||||
|
||||
|
||||
T aVB = aABdotCP * aACdotAP + aABdotAP * aCAdotCP;
|
||||
|
||||
|
||||
if (aVB <= 0. && aACdotAP > 0. && aCAdotCP > 0.)
|
||||
{
|
||||
const BVH_VecNt aDirect = aAP - aAC * (aACdotAP / (aACdotAP + aCAdotCP));
|
||||
|
||||
return (aDirect.Dot(aDirect));
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_EDGE;
|
||||
*theNumberOfFirstNode = 2;
|
||||
*theNumberOfLastNode = 0;
|
||||
}
|
||||
return theNode0 + aAC * (aACdotAP / (aACdotAP + aCAdotCP));
|
||||
}
|
||||
|
||||
|
||||
T aNorm = aVA + aVB + aVC;
|
||||
|
||||
const BVH_VecNt& aDirect = thePoint - (theNode0 * aVA +
|
||||
theNode1 * aVB +
|
||||
theNode2 * aVC) / aNorm;
|
||||
|
||||
return (aDirect.Dot(aDirect));
|
||||
|
||||
if (thePrjState != nullptr)
|
||||
{
|
||||
*thePrjState = BVH_PrjStateInTriangle_INNER;
|
||||
}
|
||||
|
||||
return (theNode0 * aVA + theNode1 * aVB + theNode2 * aVC) / aNorm;
|
||||
}
|
||||
|
||||
//! Computes square distance between point and triangle
|
||||
static T PointTriangleSquareDistance (const BVH_VecNt& thePoint,
|
||||
const BVH_VecNt& theNode0,
|
||||
const BVH_VecNt& theNode1,
|
||||
const BVH_VecNt& theNode2)
|
||||
{
|
||||
const BVH_VecNt aProj = PointTriangleProjection(thePoint, theNode0, theNode1, theNode2);
|
||||
const BVH_VecNt aPP = aProj - thePoint;
|
||||
return aPP.Dot(aPP);
|
||||
}
|
||||
|
||||
public: //! @name Ray-Box Intersection
|
||||
|
@@ -51,7 +51,7 @@ Standard_Boolean BinMDF_TagSourceDriver::Paste
|
||||
BinObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theTarget);
|
||||
const Standard_Integer aValue = -1;
|
||||
Standard_Integer aValue;
|
||||
Standard_Boolean ok = theSource >> aValue;
|
||||
if (ok)
|
||||
aTag->Set(aValue);
|
||||
|
@@ -73,7 +73,7 @@ Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
|
||||
}
|
||||
if(aSize) {
|
||||
Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
|
||||
const Standard_Integer aKey = -1;
|
||||
Standard_Integer aKey;
|
||||
for(Standard_Integer i = 0; i< aSize; i++) {
|
||||
Standard_Boolean ok = Source >> aKey;
|
||||
if (!ok) {
|
||||
|
@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
|
||||
BinObjMgt_RRelocationTable& theRT) const
|
||||
{
|
||||
Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theTarget);
|
||||
const Standard_Integer aValue = -1;
|
||||
Standard_Integer aValue;
|
||||
Standard_Boolean ok = theSource >> aValue;
|
||||
if (ok)
|
||||
anAtt->Set(aValue);
|
||||
|
@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const
|
||||
{
|
||||
Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theTarget);
|
||||
Standard_Real aValue = -1.0;
|
||||
Standard_Real aValue;
|
||||
Standard_Boolean ok = theSource >> aValue;
|
||||
if (ok)
|
||||
anAtt->Set(aValue);
|
||||
|
@@ -54,7 +54,7 @@ Standard_Boolean BinMDataXtd_GeometryDriver::Paste
|
||||
Handle(TDataXtd_Geometry) aT =
|
||||
Handle(TDataXtd_Geometry)::DownCast (theTarget);
|
||||
|
||||
const Standard_Integer aType = -1;
|
||||
Standard_Integer aType;
|
||||
Standard_Boolean ok = theSource >> aType;
|
||||
if (ok)
|
||||
aT->SetType ((TDataXtd_GeometryEnum) aType);
|
||||
|
@@ -55,7 +55,7 @@ Standard_Boolean BinMDataXtd_PositionDriver::Paste
|
||||
BinObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(TDataXtd_Position) anAtt = Handle(TDataXtd_Position)::DownCast(theTarget);
|
||||
Standard_Real aValue = 0.0;
|
||||
Standard_Real aValue;
|
||||
Standard_Boolean ok = theSource >> aValue;
|
||||
if (!ok) return ok;
|
||||
gp_Pnt aPosition(0., 0., 0.);
|
||||
|
@@ -56,7 +56,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
|
||||
Handle(TDataXtd_Presentation) anAttribute = Handle(TDataXtd_Presentation)::DownCast(theTarget);
|
||||
|
||||
// Display status
|
||||
const Standard_Integer aValue = -1;
|
||||
Standard_Integer aValue;
|
||||
ok = theSource >> aValue;
|
||||
if (!ok) return ok;
|
||||
anAttribute->SetDisplayed (aValue != 0);
|
||||
@@ -92,7 +92,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
|
||||
anAttribute->UnsetMaterial();
|
||||
|
||||
// Transparency
|
||||
Standard_Real aRValue = -1.0;
|
||||
Standard_Real aRValue;
|
||||
ok = theSource >> aRValue;
|
||||
if ( !ok ) return ok;
|
||||
if ( aRValue != -1. )
|
||||
|
@@ -62,7 +62,7 @@ Standard_Boolean BinMFunction_FunctionDriver::Paste
|
||||
Standard_Boolean ok = theSource >> aGUID;
|
||||
if (ok) {
|
||||
anAtt->SetDriverGUID(aGUID);
|
||||
const Standard_Integer aValue = -1;
|
||||
Standard_Integer aValue;
|
||||
ok = theSource >> aValue;
|
||||
if(ok)
|
||||
anAtt->SetFailure(aValue);
|
||||
|
@@ -117,9 +117,8 @@ static int TranslateFrom (const BinObjMgt_Persistent& theSource,
|
||||
TopoDS_Shape& theResult,
|
||||
BinTools_ShapeSet* theShapeSet)
|
||||
{
|
||||
const Standard_Integer aShapeID = -1;
|
||||
const Standard_Integer aLocID = -1;
|
||||
const Standard_Character aCharOrient = '0';
|
||||
Standard_Integer aShapeID, aLocID;
|
||||
Standard_Character aCharOrient;
|
||||
Standard_Boolean Ok = theSource >> aShapeID; //TShapeID;
|
||||
if(!Ok) return 1;
|
||||
// Read TShape and Orientation
|
||||
@@ -177,11 +176,11 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
|
||||
theSource >> aNbShapes;
|
||||
TDF_Label aLabel = theTarget->Label ();
|
||||
TNaming_Builder aBuilder (aLabel);
|
||||
const Standard_Integer aVer = -1;
|
||||
Standard_Integer aVer;
|
||||
Standard_Boolean ok = theSource >> aVer;
|
||||
if(!ok) return Standard_False;
|
||||
aTAtt->SetVersion(aVer); //Version
|
||||
const Standard_Character aCharEvol = '0';
|
||||
Standard_Character aCharEvol;
|
||||
ok = theSource >> aCharEvol;
|
||||
if(!ok) return Standard_False;
|
||||
TNaming_Evolution anEvol = EvolutionToEnum (aCharEvol); //Evolution
|
||||
|
@@ -152,7 +152,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
|
||||
TNaming_Name& aName = anAtt->ChangeName();
|
||||
TCollection_ExtendedString aMsg;
|
||||
//1. NameType
|
||||
const Standard_Character aValue = '0';
|
||||
Standard_Character aValue;
|
||||
Standard_Boolean ok = theSource >> aValue;
|
||||
Standard_Boolean aNewF = Standard_False;
|
||||
if (ok) {
|
||||
@@ -171,7 +171,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
|
||||
|
||||
//3. Args
|
||||
Standard_Integer aNbArgs=0;
|
||||
const Standard_Integer anIndx = -1;
|
||||
Standard_Integer anIndx;
|
||||
Handle(TNaming_NamedShape) aNS;
|
||||
ok = theSource >> aNbArgs;
|
||||
if (ok) {
|
||||
|
@@ -48,9 +48,7 @@ Standard_Boolean BinMXCAFDoc_CentroidDriver::Paste(const BinObjMgt_Persistent& t
|
||||
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
|
||||
{
|
||||
Handle(XCAFDoc_Centroid) anAtt = Handle(XCAFDoc_Centroid)::DownCast(theTarget);
|
||||
Standard_Real x = 0.0;
|
||||
Standard_Real y = 0.0;
|
||||
Standard_Real z = 0.0;
|
||||
Standard_Real x, y, z;
|
||||
Standard_Boolean isOk = theSource >> x >> y >> z;
|
||||
if(isOk) {
|
||||
gp_Pnt aPnt(x, y, z);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user