1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Compare commits

..

23 Commits

Author SHA1 Message Date
ddzama
c0418c96db ??????: Fix error of TKernal and TMath compilation.
Error occured if using c++20 standard with new oneTBB 2021.5.0.
The error was:
   Error C2672 'tbb::v1::parallel_for_each': no matching overloaded function found TKernel
   could be 'void tbb::detail::d2::parallel_for_each(Iterator,Iterator,const Body &)' TKernel
   'tbb::detail::d2::parallel_for_each': the associated constraints are not satisfied TKernel
Note, that if we use c++14 or c++17, all ok, error does not occures.
To solve the problem, i have to modify `UniversalIterator` class:
`value_type` instead `UniversalIterator` converted to `IteratorInterface*`
`pointer` = `reference` = `value_type`
Method `DownCast` moved into `FunctorInterface` abstract class.
argument `UniversalIterator& item` of the unary fuctions converted to `IteratorInterface*`.
The proposed solution solved the compilation error.
2022-08-29 13:45:15 +03:00
ddzama
83cc25e05b moving to intel oneTBB 2021* 2022-08-29 13:45:15 +03:00
ddzama
8b536fff48 0032986: Fix error of compilation WPF_D3D, WPF_WinForms and WinForms with MSVC 2022. 2022-08-29 13:44:36 +03:00
ddzama
ac76263667 0032986: Fix error of compilation CSharp samples/OCCTProxy project with MSVC 2022. 2022-08-29 13:44:36 +03:00
ddzama
efc007f044 0032921: Set C++11 standard for several projects.
Several projects depends on Qt library 0f 5.11.2 version.
TKDFBrowser
TKMessageView
TKShapeView
TKTInspector
TInspectorEXE
TKTreeModel
TKMessageModel
TKVInspector
TKToolsDraw
TKTInspectorAPI
TKView

When using C++20 language standard, compilation errors occures because
of incompatibility of 5.11.2 version of Qt library interface with C++20 standard.
Therefore, these projects stay on C++11 language standard.
2022-08-29 13:32:30 +03:00
ddzama
c45ac27846 0032921: Update CMAKE requirements in documentation. 2022-08-29 12:47:38 +03:00
ddzama
4a1eddc2c9 0032921: Add description of new CMAKE variable BUILD_CPP_STANDARD into documantation. 2022-08-29 12:47:38 +03:00
ddzama
f001c6f012 0032921: more flexible CMAKE_CXX_COMPILER_ID identification (fixups previous commit!) 2022-08-29 12:47:38 +03:00
ddzama
8271ac6728 0032921: require minimum CMAKE version 3.1 (for enabling CMAKE_CXX_STANDARD)
If we require CMAKE minimal version 3.1, rather than 2.8,
by default new policies are employed:
from CMP0024 to CMP0054.
Unique problematic policy is CMP0054:
`Only interpret if() arguments as variables or keywords when unquoted.`

Requiring of 3.1 as minimal version without preserving old behavior of 54th policy breaks MSVC compilation.
If we require cmake_policy (SET CMP0054 OLD), compilation finishs without errors.
New behavior of CMP0054 leads to changes in next target MSVC vcxproj files:
 - TKV3d
 - TKOpenGl
 - TKOpenGlTest
 - TKOpenGles
 - TKOpenGlesTest
Difference is absense of HAVE_OPENGL/HAVE_OPENGLES definitions.
So, source of error has been localizedin file occt_toolkit.cmake, in lines ~325 and ~327.
In accordance with old CMP0054 policy "CSF_OpenGlLibs" interprets as variable CSF_OpenGlLibs, rather than just a string.
Contrary, new policy interpret "CSF_OpenGlLibs" as a string.
To employ new policy, began since CMAKE 3.1 we should replace "CSF_OpenGlLibs" to "${CSF_OpenGlLibs}"
and "CSF_OpenGlesLibs" to "${CSF_OpenGlesLibs}".

P.S.

When cmake policy CMP0054 is set to NEW
expression
  "${CURRENT_CSF}" STREQUAL "CSF_OpenGlLibs"
is false,
while if policy CMP0054 is set to OLD
expression
  "${CURRENT_CSF}" STREQUAL "CSF_OpenGlLibs"
is true.
If replace "CSF_OpenGlLibs" to "${CSF_OpenGlLibs}"
expression is true independent on CMP0054 policy.
Notice, that OLD policy had beed taken place by default on master before
this ticket integration.
2022-08-29 12:47:38 +03:00
ddzama
293b9f436b 0032921: Configuratiuon, CMake - allow selecting C++ standard
Make C++ standard to be enable from cmake settings:
Now, user can choose standard by setting cmake variable CPP_STANDARD.
Available next standard items: C++11, C++14, C++17, C++20, C++23.
2022-08-29 12:47:38 +03:00
dpasukhi
acac44d571 0033053: Data Exchange, Step Export - Compound with vertex is ignored
Fixed problem with deep compound including with vertex group.
2022-08-26 17:39:36 +03:00
mzernova
7aaed2ce3b 0032547: Visualization, Select3D_SensitiveCylinder - implement picking of a hollow cylinder
Select3D_SensitiveCircle now inherits directly from Select3D_SensitiveEntity.
The sensitive circle sector is created using the Select3D_SensitivePoly class directly.

Added appropriate methods for selecting sensitive circles.
Added parameter myIsHollow to Select3D_SensitiveCylinder class.
It allows you to search for intersections with cylinders without covers.

The Draw vcircle command has been extended with UStart and UEnd parameters
to create a sector of a circle.

Added tests: vselect/cone_cylinder/circle_sector
             vselect/cone_cylinder/circle_wire
             vselect/cone_cylinder/filled_circle
             vselect/cone_cylinder/transformed
             vselect/cone_cylinder/hollow_cone_cyl
2022-08-26 17:38:19 +03:00
ngavrilo
da76ea432b 0032782: Visualization, TKD3DHost - improve robustness of test case opengl/drivers/d3dhost 2022-08-23 18:35:39 +03:00
gka
53152e6dd9 0033101: Data Exchange - STEP reader makes unexpected enormous scaling of some parts
Modification to apply units scale factor for faces based on the triangulation
2022-08-23 18:34:10 +03:00
ddzama
1a1739b200 0032957: Add Standard_Noexcept definition
into Standard_Macro.hxx and
employ Standard_Noexcept.
2022-08-18 11:55:14 +03:00
msv
fd5c113a03 0033100: Modeling Algorithms - XCAFDoc_Editor::RescaleGeometry does not rescale triangulations
Make XCAFDoc_Editor::RescaleGeometry to pass the flag theCopyMesh==true
in call to BRepBuilderAPI_Transform::Perform.

Correct the help of the command XRescaleGeometry.
2022-08-13 13:53:14 +03:00
ichesnok
f74f684b16 0032979: Data Exchange, RWGltf_CafWriter - support multi-threaded Draco compression
'MultiThread' field was added to structure RWGltf_DracoParameters for using multithreading.
Class CafWriter_DracoEncodingFunctor was added for multithreaded compression.
2022-08-12 19:04:03 +03:00
dpasukhi
621ed3bc36 0033095: Data Exchange, Step Import - Wrong PMI values when loading a *.stp file in m
Fixed problem with dimension tolerance values (upper/lower)
 - Update supported type for tolerance measure unit, now we can handle base class
2022-08-11 10:43:32 +03:00
mzernova
81d569625e 0033084: Visualization - Cylindrical prism is selectable only by its base when extruded in some directions
Fixed bounding boxes for Select3D_SensitiveCylinder.

Added display of Select3D_SensitiveCylinder presentation using the "vsensdis" command.
Added test vselect/bugs/bug33084.
2022-08-04 17:50:46 +03:00
ngavrilo
6072d3093c 0032992: Visualization - Font_TextFormatter should wrap words when possible 2022-08-02 17:13:03 +03:00
jgv
e1b097eb67 0033006: Modelling Algorithms - UnifySameDomain raises exception
Correct processing cases where a group of faces lies on U-periodic and V-periodic (torus-like) surface.

Add comments according to the remarks
2022-07-29 19:11:52 +03:00
jgv
92d22d7d62 0033080: Wrong projection point from ShapeAnalysis_Surface
Correct Draw command "projface" so that it really finds only projection points belonging to the face.
2022-07-29 19:10:37 +03:00
dpasukhi
1b423e3287 0033068: Draw Harness, XDEDRAW - improve XGetProperties command to work with all document labels
Upgrade DRAW function XGetProperties to work with all document labels or sequence of labels
2022-07-24 22:33:24 +03:00
128 changed files with 3506 additions and 1569 deletions

View File

@@ -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,10 @@ 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")
# 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")
@@ -713,14 +717,14 @@ if (NOT DEFINED ANDROID AND CAN_USE_TBB)
add_definitions (-DHAVE_TBB)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tbb")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB12")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
endif()
else()
OCCT_CHECK_AND_UNSET ("USE_TBB")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB12")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
endif()

View File

@@ -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")

View File

@@ -12,7 +12,7 @@ endif()
# TBB
if (USE_TBB)
set (CSF_TBB "tbb tbbmalloc")
set (CSF_TBB "tbb12 tbbmalloc")
else()
set (CSF_TBB)
endif()

View File

@@ -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,26 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMP
endif()
endif()
if ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
# 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)
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 +160,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")

View File

@@ -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)

View File

@@ -320,10 +320,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()

View File

@@ -69,12 +69,12 @@ else()
set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "the path to tbb.h" FORCE)
endif()
# common steps for tbb and tbbmalloc
# common steps for tbb12 and tbbmalloc
macro (TBB_PRODUCT_SEARCH PRODUCT_LIBRARY_NAME)
string (TOUPPER ${PRODUCT_LIBRARY_NAME} upper_PRODUCT_LIBRARY_NAME)
# define required tbb/tbbmalloc variables
# define required tbb12/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()
@@ -126,7 +126,7 @@ macro (TBB_PRODUCT_SEARCH PRODUCT_LIBRARY_NAME)
set (${upper_PRODUCT_LIBRARY_NAME}_ARCH_NAME intel64)
endif()
# tbb/tbbmalloc library
# tbb12/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)
@@ -178,7 +178,7 @@ macro (TBB_PRODUCT_SEARCH PRODUCT_LIBRARY_NAME)
set (3RDPARTY_${upper_PRODUCT_LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "The path to ${upper_PRODUCT_LIBRARY_NAME} library" FORCE)
endif()
# tbb/tbbmalloc shared library
# tbb12/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)
@@ -230,7 +230,7 @@ macro (TBB_PRODUCT_SEARCH PRODUCT_LIBRARY_NAME)
endif()
endif()
# install tbb/tbbmalloc
# install tbb12/tbbmalloc
if (INSTALL_TBB)
OCCT_MAKE_OS_WITH_BITNESS()
OCCT_MAKE_COMPILER_SHORT_NAME()
@@ -286,9 +286,9 @@ endmacro()
else()
# the library directory for using by the executable
if (WIN32)
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_DLL_DIR})
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB12_DLL_DIR})
else()
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR})
set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB12_LIBRARY_DIR})
endif()
endif()
#endif()

View File

@@ -775,19 +775,19 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/$aSubDir/$aVcLib"
}
if { "$aTbbLibPath" == "" } {
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}tbb12.${::SYS_LIB_SUFFIX}' not found (Intel TBB)"
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
}
}
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" }
}
}

View File

@@ -1437,7 +1437,7 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil"
}
if { "$::HAVE_TBB" == "true" } {
set aLibsMap(CSF_TBB) "tbb tbbmalloc"
set aLibsMap(CSF_TBB) "tbb12 tbbmalloc"
}
if { "$::HAVE_VTK" == "true" } {
if { "$theOS" == "wnt" } {

View File

@@ -23,7 +23,7 @@ CSF_TclLibs = -ltcl8.6
CSF_TclTkLibs = -ltk8.6
HAVE_FREEIMAGE { CSF_FreeImagePlus = -lfreeimage } else:win32 { CSF_FreeImagePlus = -lwindowscodecs -lole32 }
HAVE_FFMPEG { CSF_FFmpeg = -lavcodec -lavformat -lswscale -lavutil }
HAVE_TBB { CSF_TBB = -ltbb -ltbbmalloc }
HAVE_TBB { CSF_TBB = -ltbb12 -ltbbmalloc }
HAVE_ZLIB { CSF_ZLIB = -lzlib }
HAVE_LIBLZMA { CSF_LIBLZMA = -lliblzma }
HAVE_DRACO { CSF_Draco = -ldraco }

View File

@@ -11,7 +11,7 @@ if /I "%VCVER%" == "@COMPILER@" (
set "FREEIMAGE_DIR=@3RDPARTY_FREEIMAGE_DLL_DIRS@"
set "EGL_DIR=@3RDPARTY_EGL_DLL_DIRS@"
set "GLES2_DIR=@3RDPARTY_GLES2_DLL_DIRS@"
set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@"
set "TBB_DIR=@3RDPARTY_TBB12_DLL_DIR@"
set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@"
set "FFMPEG_DIR=@3RDPARTY_FFMPEG_DLL_DIR@"
set "OPENVR_DIR=@3RDPARTY_OPENVR_DLL_DIRS@"

View File

@@ -9,7 +9,7 @@ if [ "$1" == "@BIN_LETTER@" ]; then
export TK_DIR="@3RDPARTY_TK_LIBRARY_DIR@"
export FREETYPE_DIR="@3RDPARTY_FREETYPE_LIBRARY_DIR@"
export FREEIMAGE_DIR="@3RDPARTY_FREEIMAGE_LIBRARY_DIRS@"
export TBB_DIR="@3RDPARTY_TBB_LIBRARY_DIR@"
export TBB_DIR="@3RDPARTY_TBB12_LIBRARY_DIR@"
export VTK_DIR="@3RDPARTY_VTK_LIBRARY_DIR@"
export FFMPEG_DIR="@3RDPARTY_FFMPEG_LIBRARY_DIR@"

View File

@@ -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

View File

@@ -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}) |

View File

@@ -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,7 +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
oneTBB 2021.5.0 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).
**OpenGL** is an industry standard API for 3D graphics used by OCCT for

View File

@@ -91,6 +91,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy.dll</OutputFile>
@@ -121,6 +122,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy.dll</OutputFile>
@@ -145,6 +147,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy.dll</OutputFile>
@@ -172,6 +175,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy.dll</OutputFile>

View File

@@ -92,6 +92,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy_D3D.dll</OutputFile>
@@ -123,6 +124,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy_D3D.dll</OutputFile>
@@ -147,6 +149,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy_D3D.dll</OutputFile>
@@ -174,6 +177,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<OutputFile>$(OutDir)OCCTProxy_D3D.dll</OutputFile>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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)

View File

@@ -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})

View File

@@ -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})

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -51,7 +51,7 @@ unix {
DEFINES += OCC_CONVERT_SIGNALS QT_NO_STL
!macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD
LIBS += -lfreeimageplus
LIBS += -ltbb -ltbbmalloc
LIBS += -ltbb12 -ltbbmalloc
QMAKE_CXXFLAGS += -std=gnu++11
}

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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

View File

@@ -371,7 +371,7 @@ bool D3DHost_View::d3dSwap()
}
const HRESULT isOK = myD3dDevice->Present (NULL, NULL, NULL, NULL);
if (isOK != D3D_OK)
if (isOK != D3D_OK && isOK != S_PRESENT_OCCLUDED)
{
myWorkspace->GetGlContext()->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
TCollection_AsciiString("Direct3D9, Present device failed, ") + d3dFormatError (isOK));

View File

@@ -60,6 +60,7 @@ Font_TextFormatter::Font_TextFormatter()
myAlignY (Graphic3d_VTA_TOP),
myTabSize (8),
myWrappingWidth (0.0f),
myIsWordWrapping (true),
myLastSymbolWidth (0.0f),
myMaxSymbolWidth (0.0f),
//
@@ -249,6 +250,7 @@ void Font_TextFormatter::Format()
}
}
Standard_Utf32Char aCharPrev = 0;
for (Font_TextFormatter::Iterator aFormatterIt(*this);
aFormatterIt.More(); aFormatterIt.Next())
{
@@ -269,12 +271,30 @@ void Font_TextFormatter::Format()
Font_Rect aBndBox;
GlyphBoundingBox (aRectIter, aBndBox);
const Standard_ShortReal aNextXPos = aBndBox.Right - BottomLeft (aFirstCornerId).x();
if (aNextXPos > aMaxLineWidth) // wrap the line and do processing of the symbol
Standard_Boolean isCurWordFits = true;
if(myIsWordWrapping && IsSeparatorSymbol(aCharPrev))
{
for (Font_TextFormatter::Iterator aWordIt = aFormatterIt; aWordIt.More(); aWordIt.Next())
{
if (IsSeparatorSymbol(aWordIt.Symbol()))
{
break;
}
float aWordWidthPx = myCorners[aWordIt.SymbolPosition()].x() - myCorners[aRectIter].x();
if (aNextXPos + aWordWidthPx > aMaxLineWidth)
{
isCurWordFits = false;
break;
}
}
}
if (aNextXPos > aMaxLineWidth || !isCurWordFits) // wrap the line and do processing of the symbol
{
const Standard_Integer aLastRect = aRectIter - 1; // last rect on current line
newLine (aLastRect, aMaxLineWidth);
}
}
aCharPrev = aCharThis;
}
myBndWidth = aMaxLineWidth;

View File

@@ -220,6 +220,12 @@ public:
//! Returns text maximum width, zero means that the text is not bounded by width
Standard_ShortReal Wrapping() const { return myWrappingWidth; }
//! returns TRUE when trying not to break words when wrapping text
Standard_Boolean WordWrapping () const { return myIsWordWrapping; }
//! returns TRUE when trying not to break words when wrapping text
void SetWordWrapping (const Standard_Boolean theIsWordWrapping) { myIsWordWrapping = theIsWordWrapping; }
//! @return width of formatted text.
inline Standard_ShortReal ResultWidth() const
{
@@ -274,6 +280,14 @@ public:
return Standard_False;
}
//! Returns true if the symbol separates words when wrapping is enabled
static Standard_Boolean IsSeparatorSymbol (const Standard_Utf32Char& theSymbol)
{
return theSymbol == '\x0A' // new line
|| theSymbol == ' ' // space
|| theSymbol == '\x09'; // tab
}
DEFINE_STANDARD_RTTIEXT (Font_TextFormatter, Standard_Transient)
protected: //! @name class auxiliary methods
@@ -288,6 +302,7 @@ protected: //! @name configuration
Graphic3d_VerticalTextAlignment myAlignY; //!< vertical alignment style
Standard_Integer myTabSize; //!< horizontal tabulation width (number of space symbols)
Standard_ShortReal myWrappingWidth; //!< text is wrapped by the width if defined (more 0)
Standard_Boolean myIsWordWrapping; //!< if TRUE try not to break words when wrapping text (true by default)
Standard_ShortReal myLastSymbolWidth; //!< width of the last symbol
Standard_ShortReal myMaxSymbolWidth; //!< maximum symbol width of the formatter string

View File

@@ -432,10 +432,8 @@ static Standard_Integer intersect(Draw_Interpretor& di, Standard_Integer n, cons
Standard_Integer aNbSegments = Intersector.NbSegments();
for (Standard_Integer i = 1; i <= aNbSegments; i++)
{
Intersector.Segment(i,S1,S2);
di << "Segment #" << i << " found.\n";
di << "Curve 1 first parameter: " << S1->FirstParameter() << " last parameter: " << S1->LastParameter() <<"\n";
di << "Curve 2 first parameter: " << S2->FirstParameter() << " last parameter: " << S2->LastParameter() <<"\n";
Intersector.Segment(i,S1,S2);
CD = new DrawTrSurf_Curve2d(S1, Draw_bleu, 30);
dout << CD;
CD = new DrawTrSurf_Curve2d(S2, Draw_violet, 30);

View File

@@ -392,7 +392,6 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
Standard_Real dO1O2=Line.Distance(Circle.Location());
Standard_Real R=Circle.Radius();
Standard_Real RmTol=R-Tol;
Standard_Real RpTol = R + Tol;
Standard_Real binf1,binf2=0,bsup1,bsup2=0;
//----------------------------------------------------------------
@@ -426,7 +425,7 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
if(dO1O2 > RmTol && !b2Sol) {
//if(dO1O2 > RmTol) {
Standard_Real dx=dO1O2;
Standard_Real dy = RpTol * RpTol - dx * dx;
Standard_Real dy=0.0; //(RpTol*RpTol-dx*dx); //Patch !!!
dy=(dy>=0.0)? Sqrt(dy) : 0.0;
dAlpha1=ATan2(dy,dx);
@@ -440,7 +439,7 @@ void LineCircleGeometricIntersection(const gp_Lin2d& Line,
else {
//------------------- Intersection Line Circle+ --------------------------
Standard_Real dx=dO1O2;
Standard_Real dy = RpTol * RpTol - dx * dx;
Standard_Real dy=R*R-dx*dx; //(RpTol*RpTol-dx*dx); //Patch !!!
dy=(dy>=0.0)? Sqrt(dy) : 0.0;
dAlpha1=ATan2(dy,dx);

View File

@@ -18,6 +18,7 @@
#include <Standard_OutOfMemory.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Standard_Macro.hxx>
//! Defines an array of values of configurable size.
//! For instance, this class allows defining an array of 32-bit or 64-bit integer values with bitness determined in runtime.
@@ -63,7 +64,7 @@ public:
}
//! Move constructor
NCollection_AliasedArray (NCollection_AliasedArray&& theOther) noexcept
NCollection_AliasedArray (NCollection_AliasedArray&& theOther) Standard_Noexcept
: myData (theOther.myData), myStride (theOther.myStride), mySize (theOther.mySize), myDeletable (theOther.myDeletable)
{
theOther.myDeletable = false;

View File

@@ -125,10 +125,10 @@ protected:
// Since C++20 inheritance from std::iterator is deprecated, so define predefined types manually:
using iterator_category = std::forward_iterator_tag;
using value_type = UniversalIterator;
using value_type = IteratorInterface*;
using difference_type = ptrdiff_t;
using pointer = UniversalIterator*;
using reference = UniversalIterator&;
using pointer = value_type;
using reference = value_type;
UniversalIterator() {}
@@ -171,18 +171,8 @@ protected:
return aValue;
}
const UniversalIterator& operator* () const { return *this; }
UniversalIterator& operator* () { return *this; }
const UniversalIterator* operator->() const { return this; }
UniversalIterator* operator->() { return this; }
// type cast to actual iterator
template <typename Iterator>
const Iterator& DownCast () const
{
return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(myPtr.get())->Value();
}
const reference operator* () const { return myPtr.get(); }
reference operator* () { return myPtr.get(); }
private:
std::unique_ptr<IteratorInterface> myPtr;
@@ -196,7 +186,14 @@ protected:
public:
virtual ~FunctorInterface() {}
virtual void operator () (UniversalIterator& theIterator) const = 0;
virtual void operator () (IteratorInterface* theIterator) const = 0;
// type cast to actual iterator
template <typename Iterator>
static const Iterator& DownCast(IteratorInterface* theIterator)
{
return dynamic_cast<OSD_Parallel::IteratorWrapper<Iterator>*>(theIterator)->Value();
}
};
private:
@@ -211,9 +208,9 @@ private:
{
}
virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
const Iterator& anIt = theIterator.DownCast<Iterator>();
const Iterator& anIt = DownCast<Iterator>(theIterator);
myFunctor(*anIt);
}
@@ -233,9 +230,9 @@ private:
{
}
virtual void operator() (UniversalIterator& theIterator) const Standard_OVERRIDE
virtual void operator() (IteratorInterface* theIterator) const Standard_OVERRIDE
{
Standard_Integer anIndex = theIterator.DownCast<Standard_Integer>();
Standard_Integer anIndex = DownCast<Standard_Integer>(theIterator);
myFunctor(anIndex);
}

View File

@@ -100,7 +100,7 @@ namespace
{
for (OSD_Parallel::UniversalIterator anIter = myRange.It(); anIter != myRange.End(); anIter = myRange.It())
{
myPerformer (anIter);
myPerformer (*anIter);
}
}

View File

@@ -17,6 +17,7 @@
#include <NCollection_AliasedArray.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec3f.hxx>
#include <Standard_Macro.hxx>
//! Defines an array of 3D nodes of single/double precision configurable at construction time.
class Poly_ArrayOfNodes : public NCollection_AliasedArray<>
@@ -85,14 +86,14 @@ public:
Poly_ArrayOfNodes& operator= (const Poly_ArrayOfNodes& theOther) { return Assign (theOther); }
//! Move constructor
Poly_ArrayOfNodes (Poly_ArrayOfNodes&& theOther) noexcept
Poly_ArrayOfNodes (Poly_ArrayOfNodes&& theOther) Standard_Noexcept
: NCollection_AliasedArray (std::move (theOther))
{
//
}
//! Move assignment operator; @sa Move()
Poly_ArrayOfNodes& operator= (Poly_ArrayOfNodes&& theOther) noexcept
Poly_ArrayOfNodes& operator= (Poly_ArrayOfNodes&& theOther) Standard_Noexcept
{
return Move (theOther);
}

View File

@@ -17,6 +17,7 @@
#include <NCollection_AliasedArray.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2f.hxx>
#include <Standard_Macro.hxx>
//! Defines an array of 2D nodes of single/double precision configurable at construction time.
class Poly_ArrayOfUVNodes : public NCollection_AliasedArray<>
@@ -85,14 +86,14 @@ public:
Poly_ArrayOfUVNodes& operator= (const Poly_ArrayOfUVNodes& theOther) { return Assign (theOther); }
//! Move constructor
Poly_ArrayOfUVNodes (Poly_ArrayOfUVNodes&& theOther) noexcept
Poly_ArrayOfUVNodes (Poly_ArrayOfUVNodes&& theOther) Standard_Noexcept
: NCollection_AliasedArray (std::move (theOther))
{
//
}
//! Move assignment operator; @sa Move()
Poly_ArrayOfUVNodes& operator= (Poly_ArrayOfUVNodes&& theOther) noexcept
Poly_ArrayOfUVNodes& operator= (Poly_ArrayOfUVNodes&& theOther) Standard_Noexcept
{
return Move (theOther);
}

View File

@@ -213,37 +213,39 @@ void PrsDim_ConcentricRelation::ComputeTwoEdgesConcentric(const Handle(Prs3d_Pre
//purpose :
//=======================================================================
void PrsDim_ConcentricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
void PrsDim_ConcentricRelation::ComputeSelection (const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer)
{
Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner(this,7);
//Creation of 2 sensitive circles
// the greater
gp_Ax2 ax(myCenter, myDir);
gp_Circ aCirc (ax, myRad);
Handle(Select3D_SensitiveCircle) sensit = new Select3D_SensitiveCircle (own, aCirc);
aSelection->Add(sensit);
// the smaller
aCirc.SetRadius(myRad/2);
sensit = new Select3D_SensitiveCircle (own, aCirc);
aSelection->Add(sensit);
// the greater
gp_Ax2 anAx (myCenter, myDir);
gp_Circ aCirc (anAx, myRad);
Handle(Select3D_SensitiveCircle) sensit = new Select3D_SensitiveCircle (anOwner, aCirc);
aSelection->Add (sensit);
// the smaller
aCirc.SetRadius (myRad / 2);
sensit = new Select3D_SensitiveCircle (anOwner, aCirc);
aSelection->Add (sensit);
//Creation of 2 segments sensitive for the cross
Handle(Select3D_SensitiveSegment) seg;
gp_Pnt otherPnt = myPnt.Mirrored(myCenter);
seg = new Select3D_SensitiveSegment(own,
otherPnt,
myPnt);
aSelection->Add(seg);
seg = new Select3D_SensitiveSegment(anOwner,
otherPnt,
myPnt);
aSelection->Add (seg);
gp_Ax1 RotateAxis(myCenter, myDir);
gp_Pnt FPnt = myCenter.Rotated(RotateAxis, M_PI/2);
gp_Pnt SPnt = myCenter.Rotated(RotateAxis, -M_PI/2);
seg = new Select3D_SensitiveSegment(own,
FPnt,
SPnt);
aSelection->Add(seg);
gp_Pnt FPnt = myCenter.Rotated (RotateAxis, M_PI_2);
gp_Pnt SPnt = myCenter.Rotated (RotateAxis, -M_PI_2);
seg = new Select3D_SensitiveSegment(anOwner,
FPnt,
SPnt);
aSelection->Add (seg);
}

View File

@@ -36,7 +36,7 @@
#include <Prs3d_Drawer.hxx>
#include <Prs3d_Presentation.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <TopoDS_Edge.hxx>
@@ -202,124 +202,141 @@ void PrsDim_EqualDistanceRelation::Compute (const Handle(PrsMgr_PresentationMana
//=======================================================================
//function : ComputeSelection
//purpose :
//purpose :
//=======================================================================
void PrsDim_EqualDistanceRelation::ComputeSelection( const Handle( SelectMgr_Selection )& aSelection,
const Standard_Integer )
void PrsDim_EqualDistanceRelation::ComputeSelection (const Handle( SelectMgr_Selection )& aSelection,
const Standard_Integer)
{
Handle( SelectMgr_EntityOwner ) own = new SelectMgr_EntityOwner( this, 7 );
Handle( Select3D_SensitiveSegment ) seg;
seg = new Select3D_SensitiveSegment( own, myPoint1, myPoint2 );
aSelection->Add( seg );
aSelection->Add (seg);
seg = new Select3D_SensitiveSegment( own, myPoint3, myPoint4 );
aSelection->Add( seg );
aSelection->Add (seg);
// Line between two middles
gp_Pnt Middle12( (myPoint1.XYZ() + myPoint2.XYZ()) * 0.5 ),
gp_Pnt Middle12( (myPoint1.XYZ() + myPoint2.XYZ()) * 0.5 ),
Middle34( (myPoint3.XYZ() + myPoint4.XYZ()) *0.5 );
seg = new Select3D_SensitiveSegment( own, Middle12, Middle34 );
aSelection->Add( seg );
aSelection->Add (seg);
gp_Pnt Middle((Middle12.XYZ() + Middle34.XYZ())*0.5);
Standard_Real SmallDist = .001;
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox( own,
Middle.X() - SmallDist,
Middle.Y() - SmallDist,
Middle.Z() - SmallDist,
Middle.X() + SmallDist,
Middle.Y() + SmallDist,
Middle.Z() + SmallDist );
aSelection->Add(box);
Handle( Select3D_SensitiveBox ) box = new Select3D_SensitiveBox(own,
Middle.X() - SmallDist,
Middle.Y() - SmallDist,
Middle.Z() - SmallDist,
Middle.X() + SmallDist,
Middle.Y() + SmallDist,
Middle.Z() + SmallDist);
aSelection->Add (box);
if (myFShape.ShapeType() == TopAbs_EDGE){
if (myFShape.ShapeType() == TopAbs_EDGE)
{
BRepAdaptor_Curve aCurve(TopoDS::Edge(myFShape));
if (aCurve.GetType() == GeomAbs_Line){
//add sensetive element - line
if (aCurve.GetType() == GeomAbs_Line)
{
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
aSelection->Add( seg );
aSelection->Add (seg);
}
else if (aCurve.GetType() == GeomAbs_Circle){
else if (aCurve.GetType() == GeomAbs_Circle)
{
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint1),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint1);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
if (LastPar < FirstPar ) LastPar += M_PI * 2;
Handle(Select3D_SensitivePoly) circ = new Select3D_SensitivePoly (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add (circ);
}
}
else {
else
{
seg = new Select3D_SensitiveSegment( own, myAttachPoint1, myPoint1);
aSelection->Add( seg );
}
if (mySShape.ShapeType() == TopAbs_EDGE){
aSelection->Add (seg);
}
if (mySShape.ShapeType() == TopAbs_EDGE)
{
BRepAdaptor_Curve aCurve(TopoDS::Edge(mySShape));
if (aCurve.GetType() == GeomAbs_Line) {
if (aCurve.GetType() == GeomAbs_Line)
{
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
aSelection->Add( seg );
aSelection->Add (seg);
}
else if (aCurve.GetType() == GeomAbs_Circle){
else if (aCurve.GetType() == GeomAbs_Circle)
{
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint2),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint2);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
if (LastPar < FirstPar) LastPar += M_PI * 2;
Handle(Select3D_SensitivePoly) circ = new Select3D_SensitivePoly (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add (circ);
}
}
else {
else
{
seg = new Select3D_SensitiveSegment( own, myAttachPoint2, myPoint2);
aSelection->Add( seg );
aSelection->Add (seg);
}
if (myShape3.ShapeType() == TopAbs_EDGE){
if (myShape3.ShapeType() == TopAbs_EDGE)
{
BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape3));
if (aCurve.GetType() == GeomAbs_Line) {
if (aCurve.GetType() == GeomAbs_Line)
{
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
aSelection->Add (seg);
}
else if (aCurve.GetType() == GeomAbs_Circle){
else if (aCurve.GetType() == GeomAbs_Circle)
{
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint3),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint3);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
if (LastPar < FirstPar) LastPar += M_PI * 2;
Handle(Select3D_SensitivePoly) circ = new Select3D_SensitivePoly (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add (circ);
}
else {
else
{
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
aSelection->Add (seg);
}
}
else {
else
{
seg = new Select3D_SensitiveSegment( own, myAttachPoint3, myPoint3);
aSelection->Add( seg );
aSelection->Add (seg);
}
if (myShape4.ShapeType() == TopAbs_EDGE){
if (myShape4.ShapeType() == TopAbs_EDGE)
{
BRepAdaptor_Curve aCurve(TopoDS::Edge(myShape4));
if (aCurve.GetType() == GeomAbs_Line) {
if (aCurve.GetType() == GeomAbs_Line)
{
//add sensetive element - line
seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
aSelection->Add( seg );
aSelection->Add (seg);
}
else if (aCurve.GetType() == GeomAbs_Circle){
else if (aCurve.GetType() == GeomAbs_Circle)
{
Handle(Geom_Circle) aCircle = Handle(Geom_Circle)::DownCast(aCurve.Curve().Curve());
Standard_Real FirstPar = ElCLib::Parameter(aCircle->Circ(), myAttachPoint4),
LastPar = ElCLib::Parameter(aCircle->Circ(), myPoint4);
if (LastPar < FirstPar ) LastPar+=M_PI*2;
Handle(Select3D_SensitiveCircle) circ = new Select3D_SensitiveCircle (own, aCircle->Circ(), FirstPar, LastPar);
if (LastPar < FirstPar) LastPar += M_PI * 2;
Handle(Select3D_SensitivePoly) circ = new Select3D_SensitivePoly (own, aCircle->Circ(), FirstPar, LastPar);
aSelection->Add( circ );
}
}
else {
else
{
seg = new Select3D_SensitiveSegment( own, myAttachPoint4, myPoint4);
aSelection->Add( seg );
aSelection->Add (seg);
}
}

View File

@@ -21,6 +21,7 @@
#include <NCollection_DataMap.hxx>
#include <OSD_FileSystem.hxx>
#include <OSD_File.hxx>
#include <OSD_Parallel.hxx>
#include <OSD_Path.hxx>
#include <OSD_Timer.hxx>
#include <RWGltf_GltfAccessorLayout.hxx>
@@ -170,6 +171,72 @@ namespace
#endif
}
#ifdef HAVE_DRACO
//! Functor for parallel execution of encoding meshes to Draco buffers.
class DracoEncodingFunctor
{
public:
DracoEncodingFunctor (const Message_ProgressRange& theProgress,
draco::Encoder& theDracoEncoder,
const std::vector<std::shared_ptr<RWGltf_CafWriter::Mesh>>& theMeshes,
std::vector<std::shared_ptr<draco::EncoderBuffer>>& theEncoderBuffers)
: myProgress(theProgress, "Draco compression", Max(1, int(theMeshes.size()))),
myDracoEncoder(&theDracoEncoder),
myRanges(0, int(theMeshes.size()) - 1),
myMeshes(&theMeshes),
myEncoderBuffers(&theEncoderBuffers)
{
for (int anIndex = 0; anIndex != int(theMeshes.size()); ++anIndex)
{
myRanges.SetValue(anIndex, myProgress.Next());
}
}
void operator () (int theMeshIndex) const
{
const std::shared_ptr<RWGltf_CafWriter::Mesh>& aCurrentMesh = myMeshes->at(theMeshIndex);
if (aCurrentMesh->NodesVec.empty())
{
return;
}
Message_ProgressScope aScope(myRanges[theMeshIndex], NULL, 1);
draco::Mesh aMesh;
writeNodesToDracoMesh (aMesh, aCurrentMesh->NodesVec);
if (!aCurrentMesh->NormalsVec.empty())
{
writeNormalsToDracoMesh (aMesh, aCurrentMesh->NormalsVec);
}
if (!aCurrentMesh->TexCoordsVec.empty())
{
writeTexCoordsToDracoMesh (aMesh, aCurrentMesh->TexCoordsVec);
}
writeIndicesToDracoMesh (aMesh, aCurrentMesh->IndicesVec);
std::shared_ptr<draco::EncoderBuffer> anEncoderBuffer = std::make_shared<draco::EncoderBuffer>();
draco::Status aStatus = myDracoEncoder->EncodeMeshToBuffer (aMesh, anEncoderBuffer.get());
if (aStatus.ok())
{
myEncoderBuffers->at(theMeshIndex) = anEncoderBuffer;
}
aScope.Next();
}
private:
Message_ProgressScope myProgress;
draco::Encoder* myDracoEncoder;
NCollection_Array1<Message_ProgressRange> myRanges;
const std::vector<std::shared_ptr<RWGltf_CafWriter::Mesh>>* myMeshes;
std::vector<std::shared_ptr<draco::EncoderBuffer>>* myEncoderBuffers;
};
#endif
//================================================================
// Function : Constructor
// Purpose :
@@ -185,7 +252,8 @@ RWGltf_CafWriter::RWGltf_CafWriter (const TCollection_AsciiString& theFile,
myToEmbedTexturesInGlb (true),
myToMergeFaces (false),
myToSplitIndices16 (false),
myBinDataLen64 (0)
myBinDataLen64 (0),
myToParallel (false)
{
myCSTrsf.SetOutputLengthUnit (1.0); // meters
myCSTrsf.SetOutputCoordinateSystem (RWMesh_CoordinateSystem_glTF);
@@ -537,6 +605,8 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
myBinDataMap.Clear();
myBinDataLen64 = 0;
Message_ProgressScope aScope(theProgress, "Write binary data", myDracoParameters.DracoCompression ? 2 : 1);
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::ostream> aBinFile = aFileSystem->OpenOStream (myBinFileNameFull, std::ios::out | std::ios::binary);
if (aBinFile.get() == NULL
@@ -546,7 +616,7 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
return false;
}
Message_ProgressScope aPSentryBin (theProgress, "Binary data", 4);
Message_ProgressScope aPSentryBin (aScope.Next(), "Binary data", 4);
const RWGltf_GltfArrayType anArrTypes[4] =
{
RWGltf_GltfArrayType_Position,
@@ -797,7 +867,6 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
#ifdef HAVE_DRACO
OSD_Timer aDracoTimer;
aDracoTimer.Start();
int aBuffId = 0;
draco::Encoder aDracoEncoder;
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::POSITION, myDracoParameters.QuantizePositionBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::NORMAL, myDracoParameters.QuantizeNormalBits);
@@ -805,38 +874,23 @@ bool RWGltf_CafWriter::writeBinData (const Handle(TDocStd_Document)& theDocument
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::COLOR, myDracoParameters.QuantizeColorBits);
aDracoEncoder.SetAttributeQuantization (draco::GeometryAttribute::GENERIC, myDracoParameters.QuantizeGenericBits);
aDracoEncoder.SetSpeedOptions (myDracoParameters.CompressionLevel, myDracoParameters.CompressionLevel);
for (size_t aMeshInd = 0; aMeshInd != aMeshes.size(); ++aMeshInd)
std::vector<std::shared_ptr<draco::EncoderBuffer>> anEncoderBuffers(aMeshes.size());
DracoEncodingFunctor aFunctor (aScope.Next(), aDracoEncoder, aMeshes, anEncoderBuffers);
OSD_Parallel::For (0, int(aMeshes.size()), aFunctor, !myToParallel);
for (size_t aBuffInd = 0; aBuffInd != anEncoderBuffers.size(); ++aBuffInd)
{
const std::shared_ptr<RWGltf_CafWriter::Mesh>& aCurrentMesh = aMeshes[aMeshInd];
if (aCurrentMesh->NodesVec.empty())
if (anEncoderBuffers.at(aBuffInd).get() == nullptr)
{
continue;
}
draco::Mesh aDracoMesh;
writeNodesToDracoMesh (aDracoMesh, aCurrentMesh->NodesVec);
if (!aCurrentMesh->NormalsVec.empty())
{
writeNormalsToDracoMesh (aDracoMesh, aCurrentMesh->NormalsVec);
}
if (!aCurrentMesh->TexCoordsVec.empty())
{
writeTexCoordsToDracoMesh (aDracoMesh, aCurrentMesh->TexCoordsVec);
}
writeIndicesToDracoMesh (aDracoMesh, aCurrentMesh->IndicesVec);
draco::EncoderBuffer anEncoderBuff;
draco::Status aStatus = aDracoEncoder.EncodeMeshToBuffer (aDracoMesh, &anEncoderBuff);
if (!aStatus.ok())
{
Message::SendFail (TCollection_AsciiString("Error: mesh cannot be encoded in draco buffer."));
Message::SendFail(TCollection_AsciiString("Error: mesh not encoded in draco buffer."));
return false;
}
RWGltf_GltfBufferView aBuffViewDraco;
aBuffViewDraco.Id = aBuffId++;
aBuffViewDraco.Id = (int)aBuffInd;
aBuffViewDraco.ByteOffset = aBinFile->tellp();
aBinFile->write (anEncoderBuff.data(), std::streamsize(anEncoderBuff.size()));
const draco::EncoderBuffer& anEncoderBuff = *anEncoderBuffers.at(aBuffInd);
aBinFile->write(anEncoderBuff.data(), std::streamsize(anEncoderBuff.size()));
if (!aBinFile->good())
{
Message::SendFail (TCollection_AsciiString("File '") + myBinFileNameFull + "' cannot be written");

View File

@@ -125,6 +125,12 @@ public:
//! May reduce binary data size thanks to smaller triangle indexes.
void SetSplitIndices16 (bool theToSplit) { myToSplitIndices16 = theToSplit; }
//! Return TRUE if multithreaded optimizations are allowed; FALSE by default.
bool ToParallel() const { return myToParallel; }
//! Setup multithreaded execution.
void SetParallel (bool theToParallel) { myToParallel = theToParallel; }
//! Return Draco parameters
const RWGltf_DracoParameters& CompressionParameters() const { return myDracoParameters; }
@@ -397,6 +403,7 @@ protected:
int64_t myBinDataLen64; //!< length of binary file
std::vector<RWGltf_GltfBufferView> myBuffViewsDraco; //!< vector of buffers view with compression data
Standard_Boolean myToParallel; //!< flag to use multithreading; FALSE by default
RWGltf_DracoParameters myDracoParameters; //!< Draco parameters
};

View File

@@ -3365,17 +3365,17 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
if (anUnit.IsNull()) continue;
if (!(anUnit.CaseNum(anUnit.Value()) == 1)) continue;
Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
STEPConstruct_UnitContext anUnitCtx;
anUnitCtx.ComputeFactors(NU);
if (aMWU->IsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit)) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)))
{
aVal = aVal * anUnitCtx.LengthFactor();
}
else if (aMWU->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit)) ||
STEPConstruct_UnitContext anUnitCtxUpperBound;
anUnitCtxUpperBound.ComputeFactors(NU);
if (aMWU->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit)) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI)))
{
convertAngleValue(anUnitCtx, aVal);
convertAngleValue(anUnitCtxUpperBound, aVal);
}
else if ((aMWU->IsKind(STANDARD_TYPE(StepBasic_MeasureWithUnit)) && anUnitCtxUpperBound.LengthFactor() > 0.) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)))
{
aVal = aVal * anUnitCtxUpperBound.LengthFactor();
}
aDim3 = aVal;
@@ -3401,16 +3401,17 @@ static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
if (anUnit.IsNull()) continue;
if (!(anUnit.CaseNum(anUnit.Value()) == 1)) continue;
NU = anUnit.NamedUnit();
anUnitCtx.ComputeFactors(NU);
if (aMWU->IsKind(STANDARD_TYPE(StepBasic_LengthMeasureWithUnit)) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)))
{
aVal = aVal * anUnitCtx.LengthFactor();
}
else if (aMWU->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit)) ||
STEPConstruct_UnitContext anUnitCtxLowerBound;
anUnitCtxLowerBound.ComputeFactors(NU);
if (aMWU->IsKind(STANDARD_TYPE(StepBasic_PlaneAngleMeasureWithUnit)) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI)))
{
convertAngleValue(anUnitCtx, aVal);
convertAngleValue(anUnitCtxLowerBound, aVal);
}
else if ((aMWU->IsKind(STANDARD_TYPE(StepBasic_MeasureWithUnit)) && anUnitCtxLowerBound.LengthFactor() > 0.) ||
aMWU->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI)))
{
aVal = aVal * anUnitCtxLowerBound.LengthFactor();
}
aDim2 = Abs(aVal);
}

View File

@@ -341,6 +341,43 @@ void STEPControl_ActorWrite::mergeInfoForNM(const Handle(Transfer_FinderProcess)
}
}
//=======================================================================
//function : separateShapeToSoloVertex
//purpose :
//=======================================================================
Standard_Boolean STEPControl_ActorWrite::separateShapeToSoloVertex(const TopoDS_Shape& theShape,
TopTools_SequenceOfShape& theVertices)
{
if (theShape.IsNull())
{
return Standard_False;
}
switch (theShape.ShapeType())
{
case TopAbs_COMPOUND:
{
for (TopoDS_Iterator anIter(theShape); anIter.More(); anIter.Next())
{
if (!separateShapeToSoloVertex(anIter.Value(), theVertices))
{
return Standard_False;
}
}
break;
}
case TopAbs_VERTEX:
{
theVertices.Append(theShape);
break;
}
default:
{
theVertices.Clear();
return Standard_False;
}
}
return Standard_True;
}
//=======================================================================
//function : SetMode
@@ -814,42 +851,49 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape
// create a list of items to translate
Handle(TopTools_HSequenceOfShape) RepItemSeq = new TopTools_HSequenceOfShape();
Standard_Boolean isSeparateVertices =
Standard_Boolean isSeparateVertices =
Interface_Static::IVal("write.step.vertex.mode") == 0;//bug 23950
// PTV 16.09.2002 OCC725 separate shape from solo vertices.
Standard_Boolean isOnlyVertices = Standard_False;
if (theShape.ShapeType() == TopAbs_COMPOUND) {
Standard_Integer countVrtx = 0;
Standard_Integer countSh = 0;
if (theShape.ShapeType() == TopAbs_COMPOUND && isSeparateVertices)
{
TopoDS_Compound aNewShape, aCompOfVrtx;
BRep_Builder aB;
aB.MakeCompound(aNewShape);
aB.MakeCompound(aCompOfVrtx);
TopoDS_Iterator anCompIt(theShape);
if (isSeparateVertices) {
for (; anCompIt.More(); anCompIt.Next()) {
TopoDS_Shape aCurSh = anCompIt.Value();
if (aCurSh.ShapeType() != TopAbs_VERTEX) {
aB.Add(aNewShape, aCurSh);
countSh++;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aNewShape);
aBuilder.MakeCompound(aCompOfVrtx);
TopTools_SequenceOfShape aVertices;
isOnlyVertices = separateShapeToSoloVertex(theShape, aVertices);
if (!isOnlyVertices)
{
for (TopoDS_Iterator anCompIt(theShape); anCompIt.More(); anCompIt.Next())
{
const TopoDS_Shape& aCurSh = anCompIt.Value();
TopTools_SequenceOfShape aVerticesOfSubSh;
if (separateShapeToSoloVertex(aCurSh, aVerticesOfSubSh))
{
aVertices.Append(aVerticesOfSubSh);
}
else {
aB.Add(aCompOfVrtx, aCurSh);
countVrtx++;
else
{
aBuilder.Add(aNewShape, aCurSh);
}
}
// replace the shapes
if (countSh)
theShape = aNewShape;
if (countVrtx)
RepItemSeq->Append(aCompOfVrtx);
if (countSh == 0)
isOnlyVertices = Standard_True;
theShape = aNewShape;
}
}
if (theShape.ShapeType() == TopAbs_COMPOUND) {
for (TopTools_HSequenceOfShape::Iterator anIterV(aVertices);
anIterV.More(); anIterV.Next())
{
aBuilder.Add(aCompOfVrtx, anIterV.Value());
}
if (!aVertices.IsEmpty())
{
RepItemSeq->Append(aCompOfVrtx);
}
}
if (theShape.ShapeType() == TopAbs_COMPOUND)
{
TopExp_Explorer SolidExp, ShellExp, FaceExp;
if (mymode != STEPControl_GeometricCurveSet) {
for (SolidExp.Init(theShape, TopAbs_SOLID);

View File

@@ -117,6 +117,15 @@ private:
//! bind already written shared faces to STEP entity for non-manifold
Standard_EXPORT void mergeInfoForNM(const Handle(Transfer_FinderProcess)& theFP, const Handle(Standard_Transient) &theInfo) const;
//! Gets sequence of vertices of all compounds level by recursive
//! @param[in] theShape shape to iterate, checked for compound type and sub shapes vertex type
//! @param[out] theVertices sequence of found vertices via recursively iterate of shape
//! @return TRUE if one or more vertex was found and all shapes were compound or vertex
Standard_Boolean separateShapeToSoloVertex(const TopoDS_Shape& theShape,
TopTools_SequenceOfShape& theVertices);
Standard_Integer mygroup;
Standard_Real mytoler;
STEPConstruct_ContextTool myContext;

View File

@@ -141,13 +141,18 @@ static Standard_Integer tolerance
static Standard_Integer projface
(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 4) { di<<"Give FACE name and X Y [Z]\n"; return 1 /* Error */; }
if (argc < 4)
{
di << "Give FACE name and X Y [Z]\n";
return 1;
}
Standard_CString arg1 = argv[1];
TopoDS_Shape Shape = DBRep::Get(arg1);
if (Shape.IsNull()) { di<<"Shape unknown : "<<arg1<<"\n"; return 1 /* Error */; }
if (Shape.ShapeType() != TopAbs_FACE) { di<<"Not a face\n"; return 1 /* Error */; }
TopoDS_Face F = TopoDS::Face (Shape);
Handle(Geom_Surface) thesurf = BRep_Tool::Surface (F); // pas locface
BRepTopAdaptor_FClass2d aClassifier (F, Precision::Confusion());
// On y va
Standard_Real X,Y,Z,U,V;
X = U = Draw::Atof (argv[2]);
@@ -167,28 +172,52 @@ static Standard_Integer projface
GeomAPI_ProjectPointOnSurf proj(P3D, thesurf, uf-du, ul+du, vf-dv, vl+dv);
Standard_Integer sol, nPSurf = proj.NbPoints();
di<<" Found "<<nPSurf<<" Points\n";
Standard_Integer anIndSol = 0, anIndMin = 0;
Standard_Real aMinDist = RealLast();
for (sol = 1; sol <= nPSurf; sol ++) {
di<<"n0 "<<sol<<" Distance "<<proj.Distance(sol);
proj.Parameters(sol, U,V);
di<<" U = "<<U<<" V = "<<V<<"\n";
TopAbs_State aStatus = aClassifier.Perform (gp_Pnt2d (U,V));
if (aStatus == TopAbs_OUT)
continue;
anIndSol++;
Standard_Real aDist = proj.Distance(sol);
di << "n0 " << anIndSol << " Distance " << aDist;
di << " U = " << U << " V = " << V << "\n";
if (aDist < aMinDist)
{
aMinDist = aDist;
anIndMin = sol;
}
// reprojection
P3D = thesurf->Value (U,V);
di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
}
// Que donne ShapeTool ?
P3D.SetCoord (X,Y,Z);
Handle(ShapeAnalysis_Surface) su = new ShapeAnalysis_Surface(thesurf);
gp_Pnt2d suval = su->ValueOfUV (P3D,BRep_Tool::Tolerance(F));
suval.Coord(U,V);
di<<"** ShapeAnalysis_Surface gives U = "<<U<<" V = "<<V<<"\n";
P3D = thesurf->Value(U,V);
di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
di<<" Found "<<anIndSol<<" Points\n";
} else {
di<<" Point UV U = "<<U<<" V = "<<V<<"\n";
gp_Pnt P3D = thesurf->Value(U,V);
di<<" => proj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
if (anIndMin != 0) //there is at least one suitable solution
{
di << "** Minimal distance to face = " << aMinDist << "\n";
proj.Parameters(anIndMin, U,V);
di << "** Solution of minimal distance: U = " << U << " V = " << V << "\n";
P3D = thesurf->Value(U,V);
di<<" => reproj X = "<<P3D.X()<<" Y = "<<P3D.Y()<<" Z = "<<P3D.Z()<<"\n";
}
}
else //Check 2D point
{
di << " Point UV U = " << U << " V = " << V << "\n";
TopAbs_State aStatus = aClassifier.Perform (gp_Pnt2d (U,V));
if (aStatus == TopAbs_OUT)
di << "does not belong to the face" << "\n";
else
{
gp_Pnt P3D = thesurf->Value(U,V);
di << " => proj X = " << P3D.X() << " Y = " << P3D.Y() << " Z = " << P3D.Z() << "\n";
}
}
return 0;
}
@@ -1199,7 +1228,7 @@ Standard_Integer getanacurve(Draw_Interpretor& di,
Standard_CString g = SWDRAW::GroupName();
theCommands.Add ("tolerance","shape [tolmin tolmax:real]", __FILE__,tolerance,g);
theCommands.Add ("projface","nom_face X Y [Z]", __FILE__,projface,g);
theCommands.Add ("projface","nom_face X Y [Z] - returns the closest orthogonal projection if exists", __FILE__,projface,g);
theCommands.Add ("projcurve","nom_edge | curve3d | curve3d first last + X Y Z",
__FILE__,projcurve,g);
theCommands.Add("projpcurve", "edge face tol x y z [start_param]",

View File

@@ -16,195 +16,29 @@
#include <Select3D_SensitiveCircle.hxx>
#include <ElCLib.hxx>
#include <Precision.hxx>
#include <Select3D_SensitiveTriangle.hxx>
#include <gp_Ax3.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCircle,Select3D_SensitivePoly)
namespace
{
static Standard_Integer GetCircleNbPoints (const gp_Circ& theCircle,
const Standard_Integer theNbPnts)
{
// Check if number of points is invalid.
// In this case myPolyg raises Standard_ConstructionError
// exception (see constructor below).
if (theNbPnts <= 0)
return 0;
if (theCircle.Radius() > Precision::Confusion())
return 2 * theNbPnts + 1;
// The radius is too small and circle degenerates into point
return 1;
}
//! Definition of circle polyline
static void initCircle (Select3D_PointData& thePolygon,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Integer theNbPnts)
{
const Standard_Real aStep = (theU2 - theU1) / theNbPnts;
const Standard_Real aRadius = theCircle.Radius();
Standard_Integer aPntIdx = 0;
Standard_Real aCurU = theU1;
gp_Pnt aP1;
gp_Vec aV1;
for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; ++anIndex, aCurU += aStep)
{
ElCLib::CircleD1 (aCurU, theCircle.Position(), theCircle.Radius(), aP1, aV1);
thePolygon.SetPnt (aPntIdx++, aP1);
aV1.Normalize();
const gp_Pnt aP2 = aP1.XYZ() + aV1.XYZ() * Tan (aStep * 0.5) * aRadius;
thePolygon.SetPnt (aPntIdx++, aP2);
}
aP1 = ElCLib::CircleValue (theU2, theCircle.Position(), theCircle.Radius());
thePolygon.SetPnt (theNbPnts * 2, aP1);
}
}
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitiveEntity)
//=======================================================================
//function : Select3D_SensitiveCircle (constructor)
//purpose : Definition of a sensitive circle
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts)),
myCircle (theCircle),
myStart (0.0),
myEnd (2.0 * M_PI)
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
myCenter3D = theCircle.Position().Location();
if (myPolyg.Size() != 1)
{
initCircle (myPolyg, theCircle, myStart, myEnd, theNbPnts);
}
// Radius = 0.0
else
{
myPolyg.SetPnt (0, theCircle.Position().Location());
}
if (mySensType == Select3D_TOS_BOUNDARY)
{
SetSensitivityFactor (6);
}
}
//=======================================================================
//function : Select3D_SensitiveCircle (constructor)
//purpose : Definition of a sensitive arc
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts)),
myCircle (theCircle),
myStart (Min (theU1, theU2)),
myEnd (Max (theU1, theU2))
const Standard_Boolean theIsFilled)
: Select3D_SensitiveEntity (theOwnerId)
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
myCenter3D = theCircle.Position().Location();
if (myPolyg.Size() != 1)
{
initCircle (myPolyg, theCircle, myStart, myEnd, theNbPnts);
}
else
{
myPolyg.SetPnt (0, theCircle.Position().Location());
}
myRadius = theCircle.Radius();
myTrsf.SetTransformation (theCircle.Position(), gp::XOY());
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
if (mySensType == Select3D_TOS_BOUNDARY)
{
SetSensitivityFactor (6);
}
}
//=======================================================================
//function : Select3D_SensitiveCircle
//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
const Handle(TColgp_HArray1OfPnt)& thePnts3d,
const Standard_Boolean theIsFilled)
: Select3D_SensitivePoly (theOwnerId, thePnts3d, static_cast<Standard_Boolean> (!theIsFilled)),
myStart (0),
myEnd (0)
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
if (myPolyg.Size() != 1)
computeCenter3D();
else
myCenter3D = myPolyg.Pnt (0);
if (mySensType == Select3D_TOS_BOUNDARY)
{
SetSensitivityFactor (6);
}
}
//=======================================================================
//function : Select3D_SensitiveCircle
//purpose :
//=======================================================================
Select3D_SensitiveCircle::Select3D_SensitiveCircle(const Handle(SelectMgr_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePnts3d,
const Standard_Boolean theIsFilled)
: Select3D_SensitivePoly (theOwnerId, thePnts3d, !theIsFilled),
myStart (0),
myEnd (0)
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
if (myPolyg.Size() != 1)
computeCenter3D();
else
myCenter3D = myPolyg.Pnt (0);
if (mySensType == Select3D_TOS_BOUNDARY)
{
SetSensitivityFactor (6);
}
}
//=======================================================================
// function : BVH
// purpose : Builds BVH tree for a circle's edge segments if needed
//=======================================================================
void Select3D_SensitiveCircle::BVH()
{
if (mySensType == Select3D_TOS_BOUNDARY)
{
Select3D_SensitivePoly::BVH();
}
}
//=======================================================================
// function : ToBuildBVH
// purpose :
//=======================================================================
Standard_Boolean Select3D_SensitiveCircle::ToBuildBVH() const
{
if (mySensType != Select3D_TOS_BOUNDARY)
{
return Standard_False;
}
return Select3D_SensitivePoly::ToBuildBVH();
}
//=======================================================================
// function : Matches
// purpose : Checks whether the circle overlaps current selecting volume
@@ -212,40 +46,26 @@ Standard_Boolean Select3D_SensitiveCircle::ToBuildBVH() const
Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
if (mySensType == Select3D_TOS_BOUNDARY)
const Standard_Boolean aIsFilled = mySensType == Select3D_TOS_INTERIOR;
if (theMgr.GetActiveSelectionType() != SelectMgr_SelectionType_Point)
{
if (!Select3D_SensitivePoly::Matches (theMgr, thePickResult))
{
return Standard_False;
}
}
else if (mySensType == Select3D_TOS_INTERIOR)
{
Handle(TColgp_HArray1OfPnt) anArrayOfPnt;
Points3D (anArrayOfPnt);
if (!theMgr.IsOverlapAllowed())
{
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
{
SelectBasics_PickResult aDummy;
return theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), mySensType, aDummy);
}
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
{
if (!theMgr.OverlapsPoint (anArrayOfPnt->Value(aPntIdx)))
{
return Standard_False;
}
}
return Standard_True;
bool isInside = true;
return theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, &isInside) && isInside;
}
if (!theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), Select3D_TOS_INTERIOR, thePickResult))
else
{
return Standard_False;
return theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, NULL);
}
thePickResult.SetDistToGeomCenter(distanceToCOG(theMgr));
}
if (!theMgr.OverlapsCircle (myRadius, myTrsf, aIsFilled, thePickResult))
{
return false;
}
thePickResult.SetDistToGeomCenter (theMgr.DistToGeometryCenter (CenterOfGeometry()));
return Standard_True;
}
@@ -254,81 +74,36 @@ Standard_Boolean Select3D_SensitiveCircle::Matches (SelectBasics_SelectingVolume
//function : GetConnected
//purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) Select3D_SensitiveCircle::GetConnected()
{
Standard_Boolean isFilled = mySensType == Select3D_TOS_INTERIOR;
// Create a copy of this
Handle(Select3D_SensitiveEntity) aNewEntity;
// this was constructed using Handle(Geom_Circle)
if (!Precision::IsInfinite (myCircle.Radius()))
{
if ((myEnd - myStart) > Precision::Confusion())
{
// Arc
aNewEntity = new Select3D_SensitiveCircle (myOwnerId, myCircle, myStart, myEnd, isFilled);
}
else
{
// Circle
aNewEntity = new Select3D_SensitiveCircle (myOwnerId, myCircle, isFilled);
}
}
// this was constructed using TColgp_Array1OfPnt
else
{
Standard_Integer aSize = myPolyg.Size();
TColgp_Array1OfPnt aPolyg (1, aSize);
for(Standard_Integer anIndex = 1; anIndex <= aSize; ++anIndex)
{
aPolyg.SetValue(anIndex, myPolyg.Pnt (anIndex-1));
}
aNewEntity = new Select3D_SensitiveCircle (myOwnerId, aPolyg, isFilled);
}
Standard_Boolean anIsFilled = mySensType == Select3D_TOS_INTERIOR;
Handle(Select3D_SensitiveEntity) aNewEntity = new Select3D_SensitiveCircle (myOwnerId,
Circle(),
anIsFilled);
return aNewEntity;
}
//=======================================================================
//function : computeCenter3D
//purpose :
//=======================================================================
void Select3D_SensitiveCircle::computeCenter3D()
//==================================================
// Function: BoundingBox
// Purpose :
//==================================================
Select3D_BndBox3d Select3D_SensitiveCircle::BoundingBox()
{
gp_XYZ aCenter;
Standard_Integer aNbPnts = myPolyg.Size();
if (aNbPnts != 1)
{
// The mass of points system
Standard_Integer aMass = aNbPnts - 1;
// Find the circle barycenter
for (Standard_Integer anIndex = 0; anIndex < aNbPnts - 1; ++anIndex)
{
aCenter += myPolyg.Pnt(anIndex);
}
myCenter3D = aCenter / aMass;
}
else
{
myCenter3D = myPolyg.Pnt(0);
}
Graphic3d_Mat4d aTrsf;
myTrsf.GetMat4 (aTrsf);
Select3D_BndBox3d aBox (SelectMgr_Vec3 (-myRadius, -myRadius, 0),
SelectMgr_Vec3 (myRadius, myRadius, 0));
aBox.Transform (aTrsf);
return aBox;
}
//=======================================================================
// function : CenterOfGeometry
// purpose : Returns center of the circle. If location transformation
// is set, it will be applied
//=======================================================================
//==================================================
// Function: CenterOfGeometry
// Purpose :
//==================================================
gp_Pnt Select3D_SensitiveCircle::CenterOfGeometry() const
{
return myCenter3D;
}
//=======================================================================
// function : distanceToCOG
// purpose :
//=======================================================================
Standard_Real Select3D_SensitiveCircle::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
{
return theMgr.DistToGeometryCenter (myCenter3D);
return gp_Pnt (myTrsf.TranslationPart());
}

View File

@@ -17,93 +17,70 @@
#ifndef _Select3D_SensitiveCircle_HeaderFile
#define _Select3D_SensitiveCircle_HeaderFile
#include <gp_Circ.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
#include <SelectMgr_SelectingVolumeManager.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <Select3D_SensitiveEntity.hxx>
//! A framework to define sensitive 3D arcs and circles.
//! In some cases this class can raise Standard_ConstructionError and
//! Standard_OutOfRange exceptions. For more details see Select3D_SensitivePoly.
class Select3D_SensitiveCircle : public Select3D_SensitivePoly
#include <gp_Circ.hxx>
//! A framework to define sensitive 3D circles.
class Select3D_SensitiveCircle : public Select3D_SensitiveEntity
{
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitivePoly)
DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveCircle, Select3D_SensitiveEntity)
public:
//! Constructs the sensitive circle object defined by the
//! owner theOwnerId, the circle theCircle and the boolean theIsFilled.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Boolean theIsFilled = Standard_False);
//! Constructs the sensitive circle object defined by the
//! owner theOwnerId, the circle theCircle, the boolean
//! theIsFilled and the number of points theNbPnts.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Boolean theIsFilled = Standard_False,
const Standard_Integer theNbPnts = 12);
//! Constructs the sensitive arc object defined by the
//! owner theOwnerId, the circle theCircle, the parameters theU1
//! and theU2, the boolean theIsFilled and the number of points theNbPnts.
//! theU1 and theU2 define the first and last points of the arc on theCircle.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled = Standard_False,
const Standard_Integer theNbPnts = 12);
//! Constructs the sensitive circle object defined by the
//! owner theOwnerId, the array of triangles thePnts3d, and the boolean theIsFilled.
//! thePnts3d is an array of consecutive triangles on the
//! circle. The triangle i+1 lies on the intersection of the
//! tangents to the circle of i and i+2. Note, that the first point of thePnts3d
//! must be equal to the last point of thePnts3d.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const Handle(TColgp_HArray1OfPnt)& thePnts3d,
const Standard_Boolean theIsFilled = Standard_False);
//! Constructs the sensitive circle object defined by the
//! owner theOwnerId, the array of points thePnts3d, and the boolean theIsFilled.
//! If the length of thePnts3d is more then 1, the first point of thePnts3d
//! must be equal to the last point of thePnts3d.
Standard_EXPORT Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePnts3d,
const Standard_Boolean theIsFilled = Standard_False);
Standard_DEPRECATED("Deprecated constructor, theNbPnts parameter will be ignored")
Select3D_SensitiveCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Boolean theIsFilled,
const Standard_Integer /*theNbPnts*/)
: Select3D_SensitiveCircle (theOwnerId, theCircle, theIsFilled)
{ }
//! Checks whether the circle overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Returns a copy of this sensitive circle
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
//! Returns center of the circle. If location
//! transformation is set, it will be applied
//! Returns bounding box of the circle.
//! If location transformation is set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Always returns Standard_False
virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE { return Standard_False; }
//! Returns the amount of points
virtual Standard_Integer NbSubElements() const Standard_OVERRIDE { return 1; }
//! Returns center of the circle with transformation applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Builds BVH tree for a circle's edge segments if needed
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! The transformation for gp::XOY() with center in gp::Origin(),
//! it specifies the position and orientation of the circle.
const gp_Trsf& Transformation() const { return myTrsf; }
//! Returns TRUE if BVH tree is in invalidated state
Standard_EXPORT virtual Standard_Boolean ToBuildBVH() const Standard_OVERRIDE;
//! Returns circle
gp_Circ Circle() const { return gp_Circ (gp::XOY().Transformed (myTrsf), myRadius); }
protected:
//! Calculates distance from the 3d projection of used-picked screen point
//! to center of the geometry
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
//! Returns circle radius
Standard_Real Radius() const { return myRadius; }
private:
//! Computes myCenter3D as the barycenter of points from mypolyg3d
void computeCenter3D();
private:
Select3D_TypeOfSensitivity mySensType; //!< True if type of selection is interior, false otherwise
gp_Pnt myCenter3D; //!< Center of a circle
gp_Circ myCircle; //!< Points of the circle
Standard_Real myStart; //!< Sensitive arc parameter
Standard_Real myEnd; //!< Sensitive arc parameter
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
gp_Trsf myTrsf; //!< Circle transformation to apply
Standard_Real myRadius; //!< Circle radius
};
DEFINE_STANDARD_HANDLE(Select3D_SensitiveCircle, Select3D_SensitivePoly)
DEFINE_STANDARD_HANDLE(Select3D_SensitiveCircle, Select3D_SensitiveEntity)
#endif // _Select3D_SensitiveCircle_HeaderFile

View File

@@ -25,12 +25,14 @@ Select3D_SensitiveCylinder::Select3D_SensitiveCylinder (const Handle(SelectMgr_E
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf)
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow)
: Select3D_SensitiveEntity (theOwnerId),
myTrsf (theTrsf),
myBottomRadius (theBottomRad),
myTopRadius (theTopRad),
myHeight (theHeight)
myHeight (theHeight),
myIsHollow (theIsHollow)
{
}
@@ -46,14 +48,14 @@ Standard_Boolean Select3D_SensitiveCylinder::Matches (SelectBasics_SelectingVolu
if (!theMgr.IsOverlapAllowed())
{
bool isInside = true;
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, &isInside) && isInside;
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, &isInside) && isInside;
}
else
{
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, NULL);
return theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, NULL);
}
}
if (!theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, thePickResult))
if (!theMgr.OverlapsCylinder (myBottomRadius, myTopRadius, myHeight, myTrsf, myIsHollow, thePickResult))
{
return false;
}
@@ -81,17 +83,14 @@ Handle(Select3D_SensitiveEntity) Select3D_SensitiveCylinder::GetConnected()
Select3D_BndBox3d Select3D_SensitiveCylinder::BoundingBox()
{
Standard_Real aMaxRad = Max (myBottomRadius, myTopRadius);
gp_Pnt aCenterBottom (0, 0, 0);
gp_Pnt aCenterTop (0, 0, myHeight);
aCenterBottom.Transform (myTrsf);
aCenterTop.Transform (myTrsf);
const SelectMgr_Vec3 aMinPnt (Min (aCenterBottom.X(), aCenterTop.X()) - aMaxRad,
Min (aCenterBottom.Y(), aCenterTop.Y()) - aMaxRad,
Min (aCenterBottom.Z(), aCenterTop.Z()) - aMaxRad);
const SelectMgr_Vec3 aMaxPnt (Max (aCenterBottom.X(), aCenterTop.X()) + aMaxRad,
Max (aCenterBottom.Y(), aCenterTop.Y()) + aMaxRad,
Max (aCenterBottom.Z(), aCenterTop.Z()) + aMaxRad);
return Select3D_BndBox3d (aMinPnt, aMaxPnt);
Graphic3d_Mat4d aTrsf;
myTrsf.GetMat4 (aTrsf);
Select3D_BndBox3d aBox (SelectMgr_Vec3 (-aMaxRad, -aMaxRad, 0),
SelectMgr_Vec3 (aMaxRad, aMaxRad, myHeight));
aBox.Transform (aTrsf);
return aBox;
}
//==================================================

View File

@@ -32,7 +32,8 @@ public:
const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf);
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow = Standard_False);
//! Checks whether the cylinder overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
@@ -54,11 +55,27 @@ public:
//! Returns center of the cylinder with transformation applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Returns cylinder transformation
const gp_Trsf& Transformation() const { return myTrsf; }
//! Returns cylinder top radius
Standard_Real TopRadius() const { return myTopRadius; }
//! Returns cylinder bottom radius
Standard_Real BottomRadius() const { return myBottomRadius; }
//! Returns cylinder height
Standard_Real Height() const { return myHeight; }
//! Returns true if the cylinder is empty inside
Standard_Boolean IsHollow() const { return myIsHollow; }
protected:
gp_Trsf myTrsf; //!< cylinder transformation to apply
Standard_Real myBottomRadius; //!< cylinder bottom radius
Standard_Real myTopRadius; //!< cylinder top radius
Standard_Real myHeight; //!< cylinder height
gp_Trsf myTrsf; //!< cylinder transformation to apply
Standard_Real myBottomRadius; //!< cylinder bottom radius
Standard_Real myTopRadius; //!< cylinder top radius
Standard_Real myHeight; //!< cylinder height
Standard_Boolean myIsHollow; //!< true if the cylinder is empty inside
};
#endif // _Select3D_SensitiveSphere_HeaderFile

View File

@@ -13,8 +13,71 @@
#include <Select3D_SensitivePoly.hxx>
#include <ElCLib.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitivePoly,Select3D_SensitiveSet)
namespace
{
static Standard_Integer GetCircleNbPoints (const gp_Circ& theCircle,
const Standard_Integer theNbPnts,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled)
{
// Check if number of points is invalid.
// In this case myPolyg raises Standard_ConstructionError
// exception (see constructor below).
if (theNbPnts <= 0)
{
return 0;
}
if (theCircle.Radius() > Precision::Confusion())
{
const Standard_Boolean isSector = theIsFilled && Abs (Abs (theU2 - theU1) - 2.0 * M_PI) > gp::Resolution();
return 2 * theNbPnts + 1 + (isSector ? 2 : 0);
}
// The radius is too small and circle degenerates into point
return 1;
}
//! Definition of circle polyline
static void initCircle (Select3D_PointData& thePolygon,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
{
const Standard_Real aStep = (theU2 - theU1) / theNbPnts;
const Standard_Real aRadius = theCircle.Radius();
Standard_Integer aPntIdx = 0;
Standard_Real aCurU = theU1;
gp_Pnt aP1;
gp_Vec aV1;
const Standard_Boolean isSector = Abs (theU2 - theU1 - 2.0 * M_PI) > gp::Resolution();
if (isSector && theIsFilled) { thePolygon.SetPnt (aPntIdx++, theCircle.Location()); }
for (Standard_Integer anIndex = 1; anIndex <= theNbPnts; ++anIndex, aCurU += aStep)
{
ElCLib::CircleD1 (aCurU, theCircle.Position(), theCircle.Radius(), aP1, aV1);
thePolygon.SetPnt (aPntIdx++, aP1);
aV1.Normalize();
const gp_Pnt aP2 = aP1.XYZ() + aV1.XYZ() * Tan (aStep * 0.5) * aRadius;
thePolygon.SetPnt (aPntIdx++, aP2);
}
aP1 = ElCLib::CircleValue (theU2, theCircle.Position(), theCircle.Radius());
thePolygon.SetPnt (aPntIdx++, aP1);
if (isSector && theIsFilled) { thePolygon.SetPnt (aPntIdx++, theCircle.Location()); }
}
}
//==================================================
// Function: Select3D_SensitivePoly
// Purpose :
@@ -23,7 +86,8 @@ Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwn
const TColgp_Array1OfPnt& thePoints,
const Standard_Boolean theIsBVHEnabled)
: Select3D_SensitiveSet (theOwnerId),
myPolyg (thePoints.Upper() - thePoints.Lower() + 1)
myPolyg (thePoints.Upper() - thePoints.Lower() + 1),
mySensType (Select3D_TOS_BOUNDARY)
{
Standard_Integer aLowerIdx = thePoints.Lower();
Standard_Integer anUpperIdx = thePoints.Upper();
@@ -64,7 +128,8 @@ Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwn
const Handle(TColgp_HArray1OfPnt)& thePoints,
const Standard_Boolean theIsBVHEnabled)
: Select3D_SensitiveSet (theOwnerId),
myPolyg (thePoints->Upper() - thePoints->Lower() + 1)
myPolyg (thePoints->Upper() - thePoints->Lower() + 1),
mySensType (Select3D_TOS_BOUNDARY)
{
Standard_Integer aLowerIdx = thePoints->Lower();
Standard_Integer anUpperIdx = thePoints->Upper();
@@ -105,7 +170,8 @@ Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwn
const Standard_Boolean theIsBVHEnabled,
const Standard_Integer theNbPnts)
: Select3D_SensitiveSet (theOwnerId),
myPolyg (theNbPnts)
myPolyg (theNbPnts),
mySensType (Select3D_TOS_BOUNDARY)
{
if (theIsBVHEnabled)
{
@@ -119,6 +185,80 @@ Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwn
myIsComputed = Standard_False;
}
//==================================================
// Function: Creation
// Purpose :
//==================================================
Select3D_SensitivePoly::Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled,
const Standard_Integer theNbPnts)
: Select3D_SensitivePoly (theOwnerId, !theIsFilled, GetCircleNbPoints (theCircle, theNbPnts, theU1, theU2, theIsFilled))
{
mySensType = theIsFilled ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
if (myPolyg.Size() != 1)
{
initCircle (myPolyg, theCircle, Min (theU1, theU2), Max (theU1, theU2), theIsFilled, theNbPnts);
}
else
{
myPolyg.SetPnt (0, theCircle.Position().Location());
}
if (!theIsFilled)
{
SetSensitivityFactor (6);
}
}
//=======================================================================
// function : Matches
// purpose :
//=======================================================================
Standard_Boolean Select3D_SensitivePoly::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
if (mySensType == Select3D_TOS_BOUNDARY)
{
if (!Select3D_SensitiveSet::Matches (theMgr, thePickResult))
{
return Standard_False;
}
}
else if (mySensType == Select3D_TOS_INTERIOR)
{
Handle(TColgp_HArray1OfPnt) anArrayOfPnt;
Points3D (anArrayOfPnt);
if (!theMgr.IsOverlapAllowed())
{
if (theMgr.GetActiveSelectionType() == SelectMgr_SelectionType_Polyline)
{
SelectBasics_PickResult aDummy;
return theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), mySensType, aDummy);
}
for (Standard_Integer aPntIdx = anArrayOfPnt->Lower(); aPntIdx <= anArrayOfPnt->Upper(); ++aPntIdx)
{
if (!theMgr.OverlapsPoint (anArrayOfPnt->Value(aPntIdx)))
{
return Standard_False;
}
}
return Standard_True;
}
if (!theMgr.OverlapsPolygon (anArrayOfPnt->Array1(), Select3D_TOS_INTERIOR, thePickResult))
{
return Standard_False;
}
thePickResult.SetDistToGeomCenter (distanceToCOG(theMgr));
}
return Standard_True;
}
//==================================================
// function : BoundingBox
// purpose : Returns bounding box of a polygon. If location

View File

@@ -14,13 +14,13 @@
#ifndef _Select3D_SensitivePoly_HeaderFile
#define _Select3D_SensitivePoly_HeaderFile
#include <gp_Circ.hxx>
#include <Select3D_PointData.hxx>
#include <Select3D_SensitiveSet.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_HArray1OfPnt.hxx>
//! Sensitive Entity to make a face selectable.
//! In some cases this class can raise Standard_ConstructionError and
//! Standard_OutOfRange exceptions from its member Select3D_PointData
@@ -46,13 +46,28 @@ public:
const Handle(TColgp_HArray1OfPnt)& thePoints,
const Standard_Boolean theIsBVHEnabled);
//! Constructs the sensitive circle object defined by the
//! owner OwnerId, the circle Circle, the Boolean
//! FilledCircle and the number of points NbOfPoints.
//! Constructs the sensitive arc object defined by the
//! owner theOwnerId, the circle theCircle, the parameters theU1
//! and theU2, the boolean theIsFilled and the number of points theNbPnts.
//! theU1 and theU2 define the first and last points of the arc on theCircle.
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
const Standard_Real theU1,
const Standard_Real theU2,
const Standard_Boolean theIsFilled = Standard_False,
const Standard_Integer theNbPnts = 12);
//! Constructs a sensitive curve or arc object defined by the
//! owner theOwnerId, the theIsBVHEnabled flag, and the
//! maximum number of points on the curve: theNbPnts.
Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const Standard_Boolean theIsBVHEnabled,
const Standard_Integer theNbPnts = 6);
//! Checks whether the poly overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Returns the amount of segments in poly
Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
@@ -128,11 +143,12 @@ protected:
protected:
Select3D_PointData myPolyg; //!< Points of the poly
mutable gp_Pnt myCOG; //!< Center of the poly
Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
Select3D_PointData myPolyg; //!< Points of the poly
mutable gp_Pnt myCOG; //!< Center of the poly
Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
Select3D_TypeOfSensitivity mySensType; //!< Type of sensitivity: boundary or interior
mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
};
DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)

View File

@@ -96,21 +96,41 @@ public:
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
//! and theTopRad, height theHeight, the boolean theIsHollow and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
//! and theTopRad, height theHeight, the boolean theIsHollow and transformation to apply theTrsf.
virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! the boolean theIsFilled, and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! the boolean theIsFilled, and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const = 0;
public:
//! Calculates distance from 3d projection of user-defined selection point

View File

@@ -13,6 +13,7 @@
#include <SelectMgr.hxx>
#include <Geom_Circle.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Poly_Triangulation.hxx>
@@ -22,6 +23,8 @@
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitiveCylinder.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <Select3D_SensitivePoint.hxx>
@@ -130,6 +133,58 @@ namespace
theSeqLines.Append (aPoints);
}
}
//! Fill in circle polylines.
static void addCircle (Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Real theHeight = 0)
{
const Standard_Real anUStep = 0.1;
gp_XYZ aVec (0, 0, theHeight);
Handle(TColgp_HSequenceOfPnt) aPoints = new TColgp_HSequenceOfPnt();
Geom_Circle aGeom (gp_Ax2(), theRadius);
for (Standard_Real anU = 0.0f; anU < (2.0 * M_PI + anUStep); anU += anUStep)
{
gp_Pnt aCircPnt = aGeom.Value (anU).Coord() + aVec;
aCircPnt.Transform (theTrsf);
aPoints->Append (aCircPnt);
}
theSeqLines.Append (aPoints);
}
//! Fill in cylinder polylines.
static void addCylinder (Prs3d_NListOfSequenceOfPnt& theSeqLines,
const Handle(Select3D_SensitiveCylinder)& theSensCyl,
const gp_Trsf& theLoc)
{
Handle(TColgp_HSequenceOfPnt) aVertLine1 = new TColgp_HSequenceOfPnt();
Handle(TColgp_HSequenceOfPnt) aVertLine2 = new TColgp_HSequenceOfPnt();
const gp_Trsf& aTrsf = theLoc.Multiplied (theSensCyl->Transformation());
const Standard_Real aHeight = theSensCyl->Height();
for (int aCircNum = 0; aCircNum < 3; aCircNum++)
{
Standard_Real aRadius = 0.5 * (2 - aCircNum) * theSensCyl->BottomRadius()
+ 0.5 * aCircNum * theSensCyl->TopRadius();
const gp_XYZ aVec (0, 0, aHeight * 0.5 * aCircNum);
if (aCircNum != 1)
{
aVertLine1->Append (gp_Pnt (gp_XYZ (aRadius, 0, 0) + aVec).Transformed (aTrsf));
aVertLine2->Append (gp_Pnt (gp_XYZ (-aRadius, 0, 0) + aVec).Transformed (aTrsf));
}
if (aRadius > Precision::Confusion())
{
addCircle (theSeqLines, aRadius, aTrsf, aVec.Z());
}
}
theSeqLines.Append (aVertLine1);
theSeqLines.Append (aVertLine2);
}
}
//=======================================================================
@@ -152,6 +207,14 @@ void SelectMgr::ComputeSensitivePrs (const Handle(Graphic3d_Structure)& thePrs,
{
addBoundingBox (aSeqLines, aSensBox, theLoc);
}
else if (Handle(Select3D_SensitiveCylinder) aSensCyl = Handle(Select3D_SensitiveCylinder)::DownCast (anEnt))
{
addCylinder (aSeqLines, aSensCyl, theLoc);
}
else if (Handle(Select3D_SensitiveCircle) aSensCircle = Handle(Select3D_SensitiveCircle)::DownCast (anEnt))
{
addCircle (aSeqLines, aSensCircle->Radius(), theLoc.Multiplied (aSensCircle->Transformation()));
}
else if (Handle(Select3D_SensitiveFace) aFace = Handle(Select3D_SensitiveFace)::DownCast(anEnt))
{
Handle(TColgp_HArray1OfPnt) aSensPnts;

View File

@@ -227,7 +227,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsBox (const SelectMgr_Vec3& t
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsBox() should be called after selection axis initialization");
(void )theInside;
Standard_Real aTimeEnter, aTimeLeave;
@@ -252,7 +252,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsBox (const SelectMgr_Vec3& t
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsBox() should be called after selection axis initialization");
Standard_Real aTimeEnter, aTimeLeave;
if (!hasIntersection (theBoxMin, theBoxMax, aTimeEnter, aTimeLeave))
@@ -283,7 +283,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsPoint (const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsPoint() should be called after selection axis initialization");
Standard_Real aDepth = 0.0;
if (!hasIntersection (thePnt, aDepth))
@@ -304,7 +304,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsPoint (const gp_Pnt& thePnt,
Standard_Boolean SelectMgr_AxisIntersector::OverlapsPoint (const gp_Pnt& thePnt) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsPoint() should be called after selection axis initialization");
Standard_Real aDepth = 0.0;
return hasIntersection (thePnt, aDepth);
@@ -320,7 +320,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsSegment (const gp_Pnt& thePn
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsSegment() should be called after selection axis initialization");
if (!raySegmentDistance (thePnt1, thePnt2, thePickResult))
{
@@ -340,7 +340,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsPolygon (const TColgp_Array1
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsPolygon() should be called after selection axis initialization");
if (theSensType == Select3D_TOS_BOUNDARY)
{
@@ -400,7 +400,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsTriangle (const gp_Pnt& theP
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE(mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsTriangle() should be called after selection axis initialization");
if (theSensType == Select3D_TOS_BOUNDARY)
{
@@ -503,7 +503,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsSphere (const gp_Pnt& theCen
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsSphere() should be called after selection axis initialization");
(void )theInside;
Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
if (!RaySphereIntersection (theCenter, theRadius, myAxis.Location(), myAxis.Direction(), aTimeEnter, aTimeLeave))
@@ -527,7 +527,7 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsSphere (const gp_Pnt& theCen
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsSphere() should be called after selection axis initialization");
Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
if (!RaySphereIntersection (theCenter, theRadius, myAxis.Location(), myAxis.Direction(), aTimeEnter, aTimeLeave))
{
@@ -558,22 +558,24 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsCylinder (const Standard_Rea
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsCylinder() should be called after selection axis initialization");
Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
gp_Trsf aTrsfInv = theTrsf.Inverted();
gp_Pnt aLoc = myAxis.Location() .Transformed (aTrsfInv);
gp_Dir aRayDir = myAxis.Direction().Transformed (aTrsfInv);
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, aTimeEnter, aTimeLeave))
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir,
theIsHollow, aTimeEnter, aTimeLeave))
{
return false;
}
Standard_Real aDepth = 0.0;
Bnd_Range aRange (Max (aTimeEnter, 0.0), aTimeLeave);
Bnd_Range aRange (Max (aTimeEnter, 0.0), Max (aTimeEnter, aTimeLeave));
aRange.GetMin (aDepth);
if (!theClipRange.GetNearestDepth (aRange, aDepth))
{
@@ -606,15 +608,17 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsCylinder (const Standard_Rea
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
Standard_Boolean* theInside) const
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::Overlaps() should be called after selection axis initialization");
"Error! SelectMgr_AxisIntersector::OverlapsCylinder() should be called after selection axis initialization");
Standard_Real aTimeEnter = 0.0, aTimeLeave = 0.0;
gp_Trsf aTrsfInv = theTrsf.Inverted();
gp_Pnt aLoc = myAxis.Location() .Transformed (aTrsfInv);
gp_Dir aRayDir = myAxis.Direction().Transformed (aTrsfInv);
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, aTimeEnter, aTimeLeave))
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir,
theIsHollow, aTimeEnter, aTimeLeave))
{
return false;
}
@@ -625,6 +629,74 @@ Standard_Boolean SelectMgr_AxisIntersector::OverlapsCylinder (const Standard_Rea
return true;
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_AxisIntersector::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::OverlapsCircle() should be called after selection axis initialization");
Standard_Real aTime = 0.0;
gp_Trsf aTrsfInv = theTrsf.Inverted();
gp_Pnt aLoc = myAxis.Location().Transformed (aTrsfInv);
gp_Dir aRayDir = myAxis.Direction().Transformed (aTrsfInv);
if (!RayCircleIntersection (theRadius, aLoc, aRayDir, theIsFilled, aTime))
{
return false;
}
Standard_Real aDepth = Max (aTime, 0.0);
if (theClipRange.IsClipped (aDepth))
{
return false;
}
const gp_Pnt aPntOnCylinder = aLoc.XYZ() + aRayDir.XYZ() * aDepth;
thePickResult.SetDepth (aDepth);
thePickResult.SetPickedPoint (aPntOnCylinder.Transformed (theTrsf));
if (Abs (aPntOnCylinder.Z()) < Precision::Confusion())
{
thePickResult.SetSurfaceNormal (-gp::DZ().Transformed (theTrsf));
}
else
{
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCylinder.X(), aPntOnCylinder.Y(), 0.0).Transformed (theTrsf));
}
return true;
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_AxisIntersector::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point,
"Error! SelectMgr_AxisIntersector::OverlapsCircle() should be called after selection axis initialization");
Standard_Real aTime = 0.0;
gp_Trsf aTrsfInv = theTrsf.Inverted();
gp_Pnt aLoc = myAxis.Location().Transformed (aTrsfInv);
gp_Dir aRayDir = myAxis.Direction().Transformed (aTrsfInv);
if (!RayCircleIntersection (theRadius, aLoc, aRayDir, theIsFilled, aTime))
{
return false;
}
if (theInside != NULL)
{
*theInside &= (aTime >= 0.0);
}
return true;
}
//=======================================================================
// function : GetNearPnt
// purpose :

View File

@@ -117,6 +117,7 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
@@ -126,8 +127,28 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
public:
//! Measures distance between start axis point and given point theCOG.

View File

@@ -176,15 +176,15 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const
{
Standard_Integer aNbIntersections = 0;
Standard_Real anIntersections[4] = { RealLast(), RealLast(), RealLast(), RealLast() };
//NCollection_Vector<Standard_Real> anIntersections; // vector for all intersections
// Check intersections with end faces
// point of intersection theRayDir and z = 0
if (theRayDir.Z() != 0)
if (!theIsHollow && theRayDir.Z() != 0)
{
const Standard_Real aTime1 = (0 - theLoc.Z()) / theRayDir.Z();
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime1;
@@ -293,6 +293,33 @@ Standard_Boolean SelectMgr_BaseIntersector::RayCylinderIntersection (const Stand
return true;
}
//=======================================================================
// function : RayCircleIntersection
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_BaseIntersector::RayCircleIntersection (const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const
{
if (theRayDir.Z() != 0)
{
const Standard_Real aTime = (0 - theLoc.Z()) / theRayDir.Z();
const Standard_Real aX1 = theLoc.X() + theRayDir.X() * aTime;
const Standard_Real anY1 = theLoc.Y() + theRayDir.Y() * aTime;
const Standard_Real aK = aX1 * aX1 + anY1 * anY1;
if ((theIsFilled && aK <= theRadius * theRadius)
|| (!theIsFilled && Abs (sqrt (aK) - theRadius) <= Precision::Confusion()))
{
theTime = aTime;
return true;
}
}
return false;
}
//=======================================================================
// function : DistToGeometryCenter
// purpose :

View File

@@ -187,6 +187,7 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
@@ -196,8 +197,28 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const = 0;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const = 0;
public:
//! Measures distance between 3d projection of user-picked
@@ -224,15 +245,37 @@ public:
Standard_Real& theTimeLeave) const;
//! Checks whether the ray that starts at the point theLoc and directs with the direction theRayDir intersects
//! with the cylinder (or cone) with radiuses theBottomRad and theTopRad and height theHeights
//! with the hollow cylinder (or cone)
//! @param[in] theBottomRadius the bottom cylinder radius
//! @param[in] theTopRadius the top cylinder radius
//! @param[in] theHeight the cylinder height
//! @param[in] theLoc the location of the ray
//! @param[in] theRayDir the ray direction
//! @param[in] theIsHollow true if the cylinder is hollow
//! @param[out] theTimeEnter the entering the intersection
//! @param[out] theTimeLeave the leaving the intersection
Standard_EXPORT virtual Standard_Boolean RayCylinderIntersection (const Standard_Real theBottomRadius,
const Standard_Real theTopRadius,
const Standard_Real theHeight,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsHollow,
Standard_Real& theTimeEnter,
Standard_Real& theTimeLeave) const;
//! Checks whether the ray that starts at the point theLoc and directs with the direction theRayDir intersects
//! with the circle
//! @param[in] theRadius the circle radius
//! @param[in] theLoc the location of the ray
//! @param[in] theRayDir the ray direction
//! @param[in] theIsFilled true if it's a circle, false if it's a circle outline
//! @param[out] theTime the intersection
Standard_EXPORT virtual Standard_Boolean RayCircleIntersection (const Standard_Real theRadius,
const gp_Pnt& theLoc,
const gp_Dir& theRayDir,
const Standard_Boolean theIsFilled,
Standard_Real& theTime) const;
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseIntersector,Standard_Transient)
protected:

View File

@@ -98,11 +98,25 @@ protected:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const;
//! Intersection test between defined volume and given circle.
Standard_Boolean hasCircleOverlap (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const;
//! Returns True if all vertices (theVertices) are inside the top and bottom sides of the cylinder.
Standard_Boolean isInsideCylinderEndFace (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Checking whether the point thePnt is inside the shape with borders theVertices.
//! thePnt and theVertices lie in the same plane.
Standard_Boolean IsDotInside (const gp_Pnt& thePnt,
Standard_Boolean isDotInside (const gp_Pnt& thePnt,
const TColgp_Array1OfPnt& theVertices) const;
private:
@@ -116,10 +130,10 @@ private:
//! Checking whether the borders theVertices of the shape intersect
//! the cylinder (or cone) end face with the center theCenter and radius theRadius
Standard_Boolean isIntersectCylinderEndFace (const Standard_Real theRad,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
Standard_Boolean isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Checks if AABB and frustum are separated along the given axis
Standard_Boolean isSeparated (const SelectMgr_Vec3& theBoxMin,

View File

@@ -1,4 +1,4 @@
// Created on: 2015-03-16
// Created on: 2015-03-16
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
@@ -520,7 +520,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasSphereOverlap (const gp_Pnt& thePnt,
// purpose :
// =======================================================================
template<int N>
Standard_Boolean SelectMgr_Frustum<N>::IsDotInside (const gp_Pnt& thePnt,
Standard_Boolean SelectMgr_Frustum<N>::isDotInside (const gp_Pnt& thePnt,
const TColgp_Array1OfPnt& theVertices) const
{
Standard_Real anAngle = 0.0;
@@ -598,14 +598,14 @@ Standard_Boolean SelectMgr_Frustum<N>::isSegmentsIntersect (const gp_Pnt& thePnt
}
// =======================================================================
// function : isIntersectCylinderEndFace
// function : isIntersectCircle
// purpose :
// =======================================================================
template<int N>
Standard_Boolean SelectMgr_Frustum<N>::isIntersectCylinderEndFace (const Standard_Real theRad,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const
Standard_Boolean SelectMgr_Frustum<N>::isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const
{
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Dir aRayDir = gp_Dir (myEdgeDirs[N == 4 ? 4 : 0]).Transformed (aTrsfInv);
@@ -633,7 +633,7 @@ Standard_Boolean SelectMgr_Frustum<N>::isIntersectCylinderEndFace (const Standar
// Solving quadratic equation anA * T^2 + 2 * aK * T + aC = 0
const Standard_Real anA = (aX1 - aX2) * (aX1 - aX2) + (anY1 - anY2) * (anY1 - anY2);
const Standard_Real aK = aX1 * (aX2 - aX1) + anY1 * (anY2 - anY1);
const Standard_Real aC = aX1 * aX1 + anY1 * anY1 - theRad * theRad;
const Standard_Real aC = aX1 * aX1 + anY1 * anY1 - theRadius * theRadius;
const Standard_Real aDiscr = aK * aK - anA * aC;
if (aDiscr >= 0.0)
@@ -649,6 +649,47 @@ Standard_Boolean SelectMgr_Frustum<N>::isIntersectCylinderEndFace (const Standar
return false;
}
// =======================================================================
// function : isInsideCylinderEndFace
// purpose :
// =======================================================================
template<int N>
Standard_Boolean SelectMgr_Frustum<N>::isInsideCylinderEndFace (const Standard_Real theBottomRad,
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const
{
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Dir aRayDir = gp_Dir (myEdgeDirs[N == 4 ? 4 : 0]).Transformed (aTrsfInv);
if (aRayDir.Z() == 0.0)
{
return false;
}
for (Standard_Integer anIdx = theVertices.Lower(); anIdx <= theVertices.Upper(); anIdx++)
{
const gp_Pnt aLoc = theVertices.Value (anIdx).Transformed (aTrsfInv);
const Standard_Real aTime1 = (0 - aLoc.Z()) / aRayDir.Z();
const Standard_Real aX1 = aLoc.X() + aRayDir.X() * aTime1;
const Standard_Real anY1 = aLoc.Y() + aRayDir.Y() * aTime1;
const Standard_Real aTime2 = (theHeight - aLoc.Z()) / aRayDir.Z();
const Standard_Real aX2 = aLoc.X() + aRayDir.X() * aTime2;
const Standard_Real anY2 = aLoc.Y() + aRayDir.Y() * aTime2;
if (aX1 * aX1 + anY1 * anY1 <= theBottomRad * theBottomRad
&& aX2 * aX2 + anY2 * anY2 <= theTopRad * theTopRad)
{
continue;
}
return false;
}
return true;
}
// =======================================================================
// function : hasCylinderOverlap
// purpose :
@@ -658,8 +699,37 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCylinderOverlap (const Standard_Real t
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
gp_Pnt aVerticesBuf[N];
TColgp_Array1OfPnt aVertices (aVerticesBuf[0], 0, N - 1);
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
if (anIncFactor == 2)
{
const Standard_Integer anIndices[] = { 0, 2, 6, 4 };
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIndices[anIdx]]);
}
}
else
{
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIdx]);
}
}
if (theIsHollow && isInsideCylinderEndFace (theBottomRad, theTopRad, theHeight, theTrsf, aVertices))
{
if (theInside != NULL)
{
*theInside = false;
}
return false;
}
const gp_Dir aCylNorm (gp::DZ().Transformed (theTrsf));
const gp_Pnt aBottomCenter (gp::Origin().Transformed (theTrsf));
const gp_Pnt aTopCenter = aBottomCenter.XYZ() + aCylNorm.XYZ() * theHeight;
@@ -698,29 +768,11 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCylinderOverlap (const Standard_Real t
aPoints[5] = aBottomCenterProject.XYZ() - aDirEndFaces.XYZ() * theBottomRad;
const TColgp_Array1OfPnt aPointsArr (aPoints[0], 0, 5);
gp_Pnt aVerticesBuf[N];
TColgp_Array1OfPnt aVertices (aVerticesBuf[0], 0, N - 1);
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
if (anIncFactor == 2)
{
const Standard_Integer anIndices[] = { 0, 2, 6, 4 };
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIndices[anIdx]]);
}
}
else
{
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIdx]);
}
}
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
if ((aCylNormProject.Dot (aCylNormProject) == 0.0
&& aVertices.Value (anIdx).Distance (aPoints[0]) <= Max (theTopRad, theBottomRad))
|| IsDotInside (aVertices.Value (anIdx), aPointsArr))
|| isDotInside (aVertices.Value (anIdx), aPointsArr))
{
if (theInside != NULL)
{
@@ -747,8 +799,9 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCylinderOverlap (const Standard_Real t
}
}
if (isIntersectCylinderEndFace (theBottomRad, gp_Pnt (0, 0, 0), theTrsf, aVertices)
|| isIntersectCylinderEndFace (theTopRad, gp_Pnt (0, 0, theHeight), theTrsf, aVertices))
if (!theIsHollow
&& (isIntersectCircle (theBottomRad, gp_Pnt (0, 0, 0), theTrsf, aVertices)
|| isIntersectCircle (theTopRad, gp_Pnt (0, 0, theHeight), theTrsf, aVertices)))
{
if (theInside != NULL)
{
@@ -759,7 +812,7 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCylinderOverlap (const Standard_Real t
bool isCylInsideRec = true;
for (int i = 0; i < 6; ++i)
{
isCylInsideRec &= IsDotInside (aPoints[i], aVertices);
isCylInsideRec &= isDotInside (aPoints[i], aVertices);
}
if (theInside != NULL)
{
@@ -768,6 +821,82 @@ Standard_Boolean SelectMgr_Frustum<N>::hasCylinderOverlap (const Standard_Real t
return isCylInsideRec;
}
// =======================================================================
// function : hasCircleOverlap
// purpose :
// =======================================================================
template<int N>
Standard_Boolean SelectMgr_Frustum<N>::hasCircleOverlap (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
gp_Pnt aVerticesBuf[N];
TColgp_Array1OfPnt aVertices (aVerticesBuf[0], 0, N - 1);
const Standard_Integer anIncFactor = (Camera()->IsOrthographic() && N == 4) ? 2 : 1;
if (anIncFactor == 2)
{
const Standard_Integer anIndices[] = { 0, 2, 6, 4 };
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIndices[anIdx]]);
}
}
else
{
for (Standard_Integer anIdx = 0; anIdx < N; anIdx++)
{
aVertices.SetValue (anIdx, myVertices[anIdx]);
}
}
if (isIntersectCircle (theRadius, gp_Pnt (0, 0, 0), theTrsf, aVertices))
{
if (theInside != NULL)
{
*theInside = false;
}
return true;
}
gp_Pnt aCircCenter = gp::Origin();//.Transformed (theTrsf);
const gp_Dir aViewRayDir = gp_Dir (myEdgeDirs[N == 4 ? 4 : 0]);
const gp_Pln aPln (myVertices[0], aViewRayDir);
Standard_Real aCoefA, aCoefB, aCoefC, aCoefD;
aPln.Coefficients (aCoefA, aCoefB, aCoefC, aCoefD);
const Standard_Real aTCenter = -(aCircCenter.XYZ().Dot (aViewRayDir.XYZ()) + aCoefD);
const gp_Pnt aCenterProject (aCoefA * aTCenter,
aCoefB * aTCenter,
aCoefC * aTCenter);
if (isDotInside (aCenterProject, aVertices))
{
return true;
}
Standard_Boolean isInside = true;
for (Standard_Integer anIdx = aVertices.Lower(); anIdx <= aVertices.Upper(); anIdx++)
{
if (aVertices.Value (anIdx).Distance (aCenterProject) > theRadius)
{
isInside = false;
break;
}
}
if (theInside != NULL)
{
*theInside = false;
}
if (!theIsFilled && isInside)
{
return false;
}
return isInside;
}
//=======================================================================
//function : DumpJson
//purpose :

View File

@@ -748,6 +748,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
@@ -757,7 +758,7 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Pnt aLoc = myNearPickedPnt.Transformed (aTrsfInv);
const gp_Dir aRayDir = myViewRayDir .Transformed (aTrsfInv);
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, aTimes[0], aTimes[1]))
if (!RayCylinderIntersection (theBottomRad, theTopRad, theHeight, aLoc, aRayDir, theIsHollow, aTimes[0], aTimes[1]))
{
return Standard_False;
}
@@ -787,6 +788,165 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
return !theClipRange.IsClipped (thePickResult.Depth());
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box,
"Error! SelectMgr_RectangularFrustum::Overlaps() should be called after selection frustum initialization");
Standard_Real aTime = 0.0;
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Pnt aLoc = myNearPickedPnt.Transformed (aTrsfInv);
const gp_Dir aRayDir = myViewRayDir.Transformed (aTrsfInv);
if (!theIsFilled)
{
if (!hasCircleOverlap (theRadius, theTrsf, theIsFilled, NULL))
{
return Standard_False;
}
if (aRayDir.Z() != 0)
{
aTime = (0 - aLoc.Z()) / aRayDir.Z();
}
}
else if (!RayCircleIntersection (theRadius, aLoc, aRayDir, theIsFilled, aTime))
{
return Standard_False;
}
thePickResult.SetDepth (aTime * myScale);
if (theClipRange.IsClipped (thePickResult.Depth()))
{
thePickResult.SetDepth (aTime * myScale);
}
const gp_Pnt aPntOnCircle = aLoc.XYZ() + aRayDir.XYZ() * aTime;
if (Abs (aPntOnCircle.Z()) < Precision::Confusion())
{
thePickResult.SetSurfaceNormal (-gp::DZ().Transformed (theTrsf));
}
else
{
thePickResult.SetSurfaceNormal (gp_Vec (aPntOnCircle.X(), aPntOnCircle.Y(), 0.0).Transformed (theTrsf));
}
thePickResult.SetPickedPoint (aPntOnCircle.Transformed (theTrsf));
return !theClipRange.IsClipped (thePickResult.Depth());
}
//=======================================================================
// function : isIntersectCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const
{
const gp_Trsf aTrsfInv = theTrsf.Inverted();
const gp_Dir aRayDir = gp_Dir (myEdgeDirs[4 == 4 ? 4 : 0]).Transformed (aTrsfInv);
if (aRayDir.Z() == 0.0)
{
return false;
}
for (Standard_Integer anIdx = theVertices.Lower(); anIdx <= theVertices.Upper(); anIdx++)
{
const gp_Pnt aPntStart = theVertices.Value (anIdx).Transformed (aTrsfInv);
const gp_Pnt aPntFinish = anIdx == theVertices.Upper()
? theVertices.Value (theVertices.Lower()).Transformed (aTrsfInv)
: theVertices.Value (anIdx + 1).Transformed (aTrsfInv);
// Project points on the end face plane
const Standard_Real aParam1 = (theCenter.Z() - aPntStart.Z()) / aRayDir.Z();
const Standard_Real aX1 = aPntStart.X() + aRayDir.X() * aParam1;
const Standard_Real anY1 = aPntStart.Y() + aRayDir.Y() * aParam1;
const Standard_Real aParam2 = (theCenter.Z() - aPntFinish.Z()) / aRayDir.Z();
const Standard_Real aX2 = aPntFinish.X() + aRayDir.X() * aParam2;
const Standard_Real anY2 = aPntFinish.Y() + aRayDir.Y() * aParam2;
// Solving quadratic equation anA * T^2 + 2 * aK * T + aC = 0
const Standard_Real anA = (aX1 - aX2) * (aX1 - aX2) + (anY1 - anY2) * (anY1 - anY2);
const Standard_Real aK = aX1 * (aX2 - aX1) + anY1 * (anY2 - anY1);
const Standard_Real aC = aX1 * aX1 + anY1 * anY1 - theRadius * theRadius;
const Standard_Real aDiscr = aK * aK - anA * aC;
if (aDiscr >= 0.0)
{
const Standard_Real aT1 = (-aK + Sqrt (aDiscr)) / anA;
const Standard_Real aT2 = (-aK - Sqrt (aDiscr)) / anA;
if ((aT1 >= 0 && aT1 <= 1) || (aT2 >= 0 && aT2 <= 1))
{
return true;
}
}
}
return false;
}
//=======================================================================
// function : isSegmentsIntersect
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::isSegmentsIntersect (const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const
{
const gp_Mat aMatPln (thePnt2Seg1.X() - thePnt1Seg1.X(), thePnt2Seg1.Y() - thePnt1Seg1.Y(), thePnt2Seg1.Z() - thePnt1Seg1.Z(),
thePnt1Seg2.X() - thePnt1Seg1.X(), thePnt1Seg2.Y() - thePnt1Seg1.Y(), thePnt1Seg2.Z() - thePnt1Seg1.Z(),
thePnt2Seg2.X() - thePnt1Seg1.X(), thePnt2Seg2.Y() - thePnt1Seg1.Y(), thePnt2Seg2.Z() - thePnt1Seg1.Z());
if (Abs (aMatPln.Determinant()) > Precision::Confusion())
{
return false;
}
Standard_Real aFst[4] = { thePnt1Seg1.X(), thePnt2Seg1.X(), thePnt1Seg2.X(), thePnt2Seg2.X() };
Standard_Real aSnd[4] = { thePnt1Seg1.Y(), thePnt2Seg1.Y(), thePnt1Seg2.Y(), thePnt2Seg2.Y() };
if (aFst[0] == aFst[2] && aFst[1] == aFst[3])
{
aFst[0] = thePnt1Seg1.Z();
aFst[1] = thePnt2Seg1.Z();
aFst[2] = thePnt1Seg2.Z();
aFst[3] = thePnt2Seg2.Z();
}
if (aSnd[0] == aSnd[2]
&& aSnd[1] == aSnd[3])
{
aSnd[0] = thePnt1Seg1.Z();
aSnd[1] = thePnt2Seg1.Z();
aSnd[2] = thePnt1Seg2.Z();
aSnd[3] = thePnt2Seg2.Z();
}
const gp_Mat2d aMat (gp_XY (aFst[0] - aFst[1], aSnd[0] - aSnd[1]),
gp_XY (aFst[3] - aFst[2], aSnd[3] - aSnd[2]));
const gp_Mat2d aMatU (gp_XY (aFst[0] - aFst[2], aSnd[0] - aSnd[2]),
gp_XY (aFst[3] - aFst[2], aSnd[3] - aSnd[2]));
const gp_Mat2d aMatV (gp_XY (aFst[0] - aFst[1], aSnd[0] - aSnd[1]),
gp_XY (aFst[0] - aFst[2], aSnd[0] - aSnd[2]));
if (aMat.Determinant() == 0.0)
{
return false;
}
const Standard_Real anU = aMatU.Determinant() / aMat.Determinant();
const Standard_Real aV = aMatV.Determinant() / aMat.Determinant();
if (anU >= 0.0 && anU <= 1.0
&& aV >= 0.0 && aV <= 1.0)
{
return true;
}
return false;
}
//=======================================================================
// function : OverlapsCylinder
// purpose :
@@ -795,12 +955,28 @@ Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCylinder (const Standard_
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box,
"Error! SelectMgr_RectangularFrustum::Overlaps() should be called after selection frustum initialization");
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theInside);
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow, theInside);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Point || mySelectionType == SelectMgr_SelectionType_Box,
"Error! SelectMgr_RectangularFrustum::Overlaps() should be called after selection frustum initialization");
return hasCircleOverlap (theRadius, theTrsf, theIsFilled, theInside);
}
// =======================================================================

View File

@@ -66,6 +66,18 @@ public:
Standard_EXPORT void Init (const gp_Pnt2d& theMinPnt,
const gp_Pnt2d& theMaxPnt);
//! Returns True if Frustum (theVertices) intersects the circle.
Standard_EXPORT Standard_Boolean isIntersectCircle (const Standard_Real theRadius,
const gp_Pnt& theCenter,
const gp_Trsf& theTrsf,
const TColgp_Array1OfPnt& theVertices) const;
//! Returns True if Seg1 (thePnt1Seg1, thePnt2Seg1) and Seg2 (thePnt1Seg2, thePnt2Seg2) intersect.
Standard_EXPORT Standard_Boolean isSegmentsIntersect (const gp_Pnt& thePnt1Seg1,
const gp_Pnt& thePnt2Seg1,
const gp_Pnt& thePnt1Seg2,
const gp_Pnt& thePnt2Seg2) const;
//! Builds volume according to internal parameters.
//! NOTE: it should be called after Init() method
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
@@ -150,6 +162,7 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
@@ -159,8 +172,28 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG.
//! It makes sense only for frustums built on a single point.

View File

@@ -426,13 +426,15 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder (const Stand
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf, myViewClipRange, thePickResult);
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf,
theIsHollow, myViewClipRange, thePickResult);
}
//=======================================================================
@@ -443,13 +445,47 @@ Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCylinder (const Stand
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf, theInside);
return myActiveSelectingVolume->OverlapsCylinder (theBottomRad, theTopRad, theHeight,
theTrsf, theIsHollow, theInside);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCircle (theRadius, theTrsf, theIsFilled, myViewClipRange, thePickResult);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectingVolumeManager::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
if (myActiveSelectingVolume.IsNull())
{
return false;
}
return myActiveSelectingVolume->OverlapsCircle (theRadius, theTrsf, theIsFilled, theInside);
}
//=======================================================================

View File

@@ -168,6 +168,7 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
@@ -176,8 +177,27 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Measures distance between 3d projection of user-picked
//! screen point and given point theCOG
Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;

View File

@@ -337,12 +337,13 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder (const Standard_R
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf);
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=======================================================================
@@ -353,10 +354,39 @@ Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCylinder (const Standard_R
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
(void) theInside;
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf);
return hasCylinderOverlap (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
(void)theClipRange;
(void)thePickResult;
return hasCircleOverlap (theRadius, theTrsf, theIsFilled);
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustum::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
(void)theInside;
return hasCircleOverlap (theRadius, theTrsf, theIsFilled);
}
// =======================================================================

View File

@@ -123,6 +123,7 @@ public: //! @name SAT Tests for different objects
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
@@ -132,8 +133,28 @@ public: //! @name SAT Tests for different objects
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by circle with radius theRadius,
//! boolean theIsFilled and transformation to apply theTrsf.
//! The position and orientation of the circle are specified
//! via theTrsf transformation for gp::XOY() with center in gp::Origin().
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
public:
//! Nullifies the handle to corresponding builder instance to prevent memory leaks

View File

@@ -17,6 +17,10 @@
#include <BRepMesh_DataStructureOfDelaun.hxx>
#include <BRepMesh_Delaun.hxx>
#include <Geom_Plane.hxx>
#include <GeomInt_IntSS.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <NCollection_IncAllocator.hxx>
#include <SelectMgr_FrustumBuilder.hxx>
@@ -506,6 +510,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
@@ -513,7 +518,8 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
"Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization");
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf, theClipRange, thePickResult))
if (anIter.Value()->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf,
theIsHollow, theClipRange, thePickResult))
{
return true;
}
@@ -529,6 +535,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside) const
{
const gp_Dir aCylNorm (gp::DZ().Transformed (theTrsf));
@@ -589,7 +596,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
{
aVertices[anIdx] = anIter.Value()->myVertices[anIdx];
}
if (anIter.Value()->IsDotInside (aPoints[i], aVertices))
if (anIter.Value()->isDotInside (aPoints[i], aVertices))
{
isInside = true;
break;
@@ -607,7 +614,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
}
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf, theInside))
if (anIter.Value()->OverlapsCylinder (theBottomRad, theTopRad, theHeight, theTrsf, theIsHollow, theInside))
{
return true;
}
@@ -615,6 +622,109 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCylinder (const Standar
return false;
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const
{
Standard_ASSERT_RAISE (mySelectionType == SelectMgr_SelectionType_Polyline,
"Error! SelectMgr_TriangularFrustumSet::Overlaps() should be called after selection frustum initialization");
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
{
if (anIter.Value()->OverlapsCircle (theRadius, theTrsf, theIsFilled, theClipRange, thePickResult))
{
return true;
}
}
return false;
}
//=======================================================================
// function : OverlapsCircle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::OverlapsCircle (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside) const
{
const gp_Pnt aCenter (gp::Origin().Transformed (theTrsf));
const gp_Vec aVecPlane1 (myFrustums.First()->myVertices[0], myFrustums.First()->myVertices[1]);
const gp_Vec aVecPlane2 (myFrustums.First()->myVertices[0], myFrustums.First()->myVertices[2]);
const gp_Dir aDirNorm (aVecPlane1.Crossed (aVecPlane2));
const gp_Pln aPln (myFrustums.First()->myVertices[0], aDirNorm);
Standard_Real aCoefA, aCoefB, aCoefC, aCoefD;
aPln.Coefficients (aCoefA, aCoefB, aCoefC, aCoefD);
const Standard_Real aT = -(aCenter.XYZ().Dot (aDirNorm.XYZ()) + aCoefD) / aDirNorm.Dot (aDirNorm);
const gp_Pnt aCenterProject (aCoefA * aT + aCenter.X(),
aCoefB * aT + aCenter.Y(),
aCoefC * aT + aCenter.Z());
gp_Pnt aVerticesBuf[3];
TColgp_Array1OfPnt aVertices (aVerticesBuf[0], 0, 2);
if (!theIsFilled)
{
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
{
if (!anIter.Value()->OverlapsCircle (theRadius, theTrsf, theIsFilled, theInside))
{
continue;
}
if (myToAllowOverlap)
{
return Standard_True;
}
if (isIntersectBoundary (theRadius, theTrsf, theIsFilled))
{
if (theInside != NULL)
{
*theInside &= Standard_False;
}
return Standard_False;
}
return Standard_True;
}
}
else
{
for (SelectMgr_TriangFrustums::Iterator anIter (myFrustums); anIter.More(); anIter.Next())
{
if (!anIter.Value()->OverlapsCircle (theRadius, theTrsf, theIsFilled, theInside))
{
continue;
}
if (myToAllowOverlap)
{
return Standard_True;
}
if (isIntersectBoundary (theRadius, theTrsf, theIsFilled))
{
return Standard_False;
}
return Standard_True;
}
}
if (theInside != NULL)
{
*theInside &= Standard_False;
}
return Standard_False;
}
// =======================================================================
// function : GetPlanes
// purpose :
@@ -638,6 +748,127 @@ void SelectMgr_TriangularFrustumSet::SetAllowOverlapDetection (const Standard_Bo
myToAllowOverlap = theIsToAllow;
}
//=======================================================================
// function : PointInTriangle
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::pointInTriangle (const gp_Pnt& thePnt,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3)
{
gp_Vec a = theV1.XYZ() - thePnt.XYZ();
gp_Vec b = theV2.XYZ() - thePnt.XYZ();
gp_Vec c = theV3.XYZ() - thePnt.XYZ();
gp_Vec u = b.Crossed (c);
gp_Vec v = c.Crossed (a);
gp_Vec w = a.Crossed (b);
if (u.Dot (v) < 0.0 || u.Dot (w) < 0.0) {
return false;
}
return true;
}
//=======================================================================
// function : segmentSegmentIntersection
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::segmentSegmentIntersection (const gp_Pnt& theStartPnt1,
const gp_Pnt& theEndPnt1,
const gp_Pnt& theStartPnt2,
const gp_Pnt& theEndPnt2)
{
gp_XYZ aVec1 = theEndPnt1.XYZ() - theStartPnt1.XYZ();
gp_XYZ aVec2 = theEndPnt2.XYZ() - theStartPnt2.XYZ();
gp_XYZ aVec21 = theStartPnt2.XYZ() - theStartPnt1.XYZ();
gp_XYZ aVec12 = theStartPnt1.XYZ() - theStartPnt2.XYZ();
if (Abs (aVec21.DotCross (aVec1, aVec2)) > Precision::Confusion() ||
Abs (aVec12.DotCross (aVec2, aVec1)) > Precision::Confusion())
{
// lines are not coplanar
return false;
}
double aValue1 = aVec21.Crossed (aVec2).Dot (aVec1.Crossed (aVec2)) / aVec1.Crossed (aVec2).SquareModulus();
double aValue2 = aVec12.Crossed (aVec1).Dot (aVec2.Crossed (aVec1)) / aVec2.Crossed (aVec1).SquareModulus();
if (aValue1 < 0.0 || aValue1 > 1.0 || aValue2 < 0.0 || aValue2 > 1.0)
{
return false;
}
return true;
}
//=======================================================================
// function : isIntersectBoundary
// purpose :
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::isIntersectBoundary (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled) const
{
Standard_Integer aFacesNb = myBoundaryPoints.Size() / 2;
const gp_Pnt& aCircCenter = theTrsf.TranslationPart();
gp_Ax2 anAxis;
anAxis.Transform (theTrsf);
Handle(Geom_Circle) aCirc = new Geom_Circle (anAxis, theRadius);
gp_Dir aCircNorm = gp_Dir(0, 0, 1).Transformed (theTrsf);
Handle(Geom_Surface) aCircPlane = new Geom_Plane(aCircCenter, aCircNorm);
for (Standard_Integer anIdx = myBoundaryPoints.Lower(); anIdx < aFacesNb + myBoundaryPoints.Lower(); anIdx++)
{
gp_Pnt aFace[4] = { myBoundaryPoints.Value (anIdx),
myBoundaryPoints.Value (anIdx + aFacesNb),
myBoundaryPoints.Value (anIdx % aFacesNb + 1 + aFacesNb),
myBoundaryPoints.Value (anIdx % aFacesNb + 1) };
gp_Dir aBndPlaneNorm = gp_Vec (aFace[0], aFace[1]).Crossed (gp_Vec(aFace[0], aFace[2]));
Handle(Geom_Surface) aBndPlane = new Geom_Plane(aFace[0], aBndPlaneNorm);
GeomInt_IntSS anInterSS (aCircPlane, aBndPlane, Precision::Confusion());
if (!anInterSS.IsDone() || anInterSS.NbLines() == 0)
{
continue;
}
const Handle(Geom_Line)& anInterLine = Handle(Geom_Line)::DownCast (anInterSS.Line(1));
Standard_Real aDistance = anInterLine->Lin().Distance (aCircCenter);
if (aDistance > theRadius)
{
continue;
}
gp_Lin aLine = anInterLine->Lin();
gp_Lin aNormalLine = aLine.Normal (aCircCenter);
gp_Pnt aCrossPoint = aCircCenter.Translated (aNormalLine.Direction().Reversed().XYZ() * aDistance);
Standard_Real anOffset = Sqrt (theRadius * theRadius - aDistance * aDistance);
// Line-circle intersection points
gp_Pnt aP1 = aCrossPoint.Translated (aLine.Direction().XYZ() * anOffset);
gp_Pnt aP2 = aCrossPoint.Translated (aLine.Direction().Reversed().XYZ() * anOffset);
if (pointInTriangle (aP1, aFace[0], aFace[1], aFace[2])
|| pointInTriangle (aP1, aFace[0], aFace[2], aFace[3])
|| pointInTriangle (aP2, aFace[0], aFace[1], aFace[2])
|| pointInTriangle (aP2, aFace[0], aFace[2], aFace[3]))
{
return Standard_True;
}
if (theIsFilled
|| segmentSegmentIntersection (aP1, aP2, aFace[0], aFace[1])
|| segmentSegmentIntersection (aP1, aP2, aFace[1], aFace[2])
|| segmentSegmentIntersection (aP1, aP2, aFace[2], aFace[3])
|| segmentSegmentIntersection (aP1, aP2, aFace[0], aFace[3]))
{
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
// function : isIntersectBoundary
// purpose :
@@ -669,7 +900,7 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::isIntersectBoundary (const gp_P
// purpose : Moller-Trumbore ray-triangle intersection test
//=======================================================================
Standard_Boolean SelectMgr_TriangularFrustumSet::segmentTriangleIntersection (const gp_Pnt& theOrig, const gp_Vec& theDir,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3) const
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3)
{
gp_Vec aPVec, aTVec, aQVec;
Standard_Real aD, aInvD, anU, aV, aT;

View File

@@ -124,6 +124,7 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
@@ -133,8 +134,24 @@ public:
const Standard_Real theTopRad,
const Standard_Real theHeight,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsHollow,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
const SelectMgr_ViewClipRange& theClipRange,
SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
//! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
//! and theTopRad, height theHeight and transformation to apply theTrsf.
Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theBottomRad,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled,
Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
@@ -151,15 +168,34 @@ private:
//! Checks whether the segment intersects with the boundary of the current volume selection
Standard_EXPORT Standard_Boolean isIntersectBoundary (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2) const;
//! Checks whether the circle intersects with the boundary of the current volume selection
Standard_EXPORT Standard_Boolean isIntersectBoundary (const Standard_Real theRadius,
const gp_Trsf& theTrsf,
const Standard_Boolean theIsFilled) const;
//! Checks whether the triangle intersects with a segment
Standard_EXPORT Standard_Boolean segmentTriangleIntersection (const gp_Pnt &theOrig, const gp_Vec& theDir,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3) const;
Standard_EXPORT static Standard_Boolean segmentTriangleIntersection (const gp_Pnt &theOrig, const gp_Vec& theDir,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3);
Standard_EXPORT static Standard_Boolean segmentSegmentIntersection (const gp_Pnt& theStartPnt1,
const gp_Pnt& theEndPnt1,
const gp_Pnt& theStartPnt2,
const gp_Pnt& theEndPnt2);
Standard_EXPORT static Standard_Boolean pointInTriangle (const gp_Pnt& thePnt,
const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3);
private:
SelectMgr_TriangFrustums myFrustums; //!< set of triangular frustums
SelectionPolyline mySelPolyline; //!< parameters of selection polyline (it is used to build triangle frustum set)
TColgp_Array1OfPnt myBoundaryPoints; //!< boundary points
//! 1_____2
//! /| |\ .
//! 4/_|_____|_\3
//! | 5|_____|6 |
//! | / \ |
//! 8|/_________\|7
Standard_Boolean myToAllowOverlap; //!< flag to detect only fully included sensitives or not
};

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@
#include <Standard_Std.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Macro.hxx>
class Standard_Transient;
@@ -71,7 +72,7 @@ namespace opencascade {
}
//! Move constructor
handle (handle&& theHandle) noexcept : entity(theHandle.entity)
handle (handle&& theHandle) Standard_Noexcept : entity(theHandle.entity)
{
theHandle.entity = 0;
}
@@ -112,7 +113,7 @@ namespace opencascade {
}
//! Move operator
handle& operator= (handle&& theHandle) noexcept
handle& operator= (handle&& theHandle) Standard_Noexcept
{
std::swap (this->entity, theHandle.entity);
return *this;

View File

@@ -315,5 +315,21 @@
#define Standard_ATOMIC(theType) theType
#endif
//! @def Standard_Noexcept
//! Definition of Standard_Noexcept:
//! if noexcept is accessible, Standard_Noexcept is "noexcept" and "throw()" otherwise.
#ifdef _MSC_VER
#if _MSC_VER >= 1900
#define Standard_Noexcept noexcept
#else
#define Standard_Noexcept throw()
#endif
#else
#if __cplusplus >= 201103L
#define Standard_Noexcept noexcept
#else
#define Standard_Noexcept throw()
#endif
#endif
#endif

View File

@@ -40,6 +40,7 @@
#include <Select3D_SensitiveFace.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitivePoint.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveSphere.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
@@ -60,7 +61,6 @@
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#define BVH_PRIMITIVE_LIMIT 800000
@@ -249,6 +249,7 @@ void StdSelect_BRepSelectionTool::ComputeSensitive (const TopoDS_Shape& theShape
case TopAbs_FACE:
{
const TopoDS_Face& aFace = TopoDS::Face (theShape);
Select3D_EntitySequence aSensitiveList;
GetSensitiveForFace (aFace, theOwner,
aSensitiveList,
@@ -266,151 +267,15 @@ void StdSelect_BRepSelectionTool::ComputeSensitive (const TopoDS_Shape& theShape
{
TopTools_IndexedMapOfShape aSubfacesMap;
TopExp::MapShapes (theShape, TopAbs_FACE, aSubfacesMap);
if (aSubfacesMap.Extent() == 2) // detect cone
if (!GetSensitiveForCylinder (aSubfacesMap, theOwner, theSelection))
{
const TopoDS_Face* aFaces[2] =
for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
{
&TopoDS::Face (aSubfacesMap.FindKey (1)),
&TopoDS::Face (aSubfacesMap.FindKey (2))
};
TopLoc_Location aLocSurf[2];
const Handle(Geom_Surface)* aSurfaces[2] =
{
&BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
&BRep_Tool::Surface (*aFaces[1], aLocSurf[1])
};
Standard_Integer aConIndex = 0;
Handle(Geom_ConicalSurface) aGeomCone = Handle(Geom_ConicalSurface)::DownCast (*aSurfaces[0]);
Handle(Geom_Plane) aGeomPln;
if (!aGeomCone.IsNull())
{
aGeomPln = Handle(Geom_Plane)::DownCast (*aSurfaces[1]);
ComputeSensitive (aSubfacesMap.FindKey (aShIndex), theOwner,
theSelection,
theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
}
else
{
aConIndex = 1;
aGeomCone = Handle(Geom_ConicalSurface)::DownCast (*aSurfaces[1]);
aGeomPln = Handle(Geom_Plane)::DownCast (*aSurfaces[0]);
}
if (!aGeomCone.IsNull()
&& !aGeomPln.IsNull()
&& aGeomPln->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular()))
{
const gp_Cone aCone = BRepAdaptor_Surface (*aFaces[aConIndex]).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = (aRad1 != 0.0)
? aRad1 / Abs (Tan (aCone.SemiAngle()))
: aCone.Location().Distance (aGeomPln->Location().Transformed (aLocSurf[aConIndex == 0 ? 1 : 0]));
const Standard_Real aRad2 = (aRad1 != 0.0) ? 0.0 : Tan (aCone.SemiAngle()) * aHeight;
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp_Ax3());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
break;
}
}
if (aSubfacesMap.Extent() == 3) // detect cylinder or truncated cone
{
const TopoDS_Face* aFaces[3] =
{
&TopoDS::Face (aSubfacesMap.FindKey (1)),
&TopoDS::Face (aSubfacesMap.FindKey (2)),
&TopoDS::Face (aSubfacesMap.FindKey (3))
};
TopLoc_Location aLocSurf[3];
const Handle(Geom_Surface)* aSurfaces[3] =
{
&BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
&BRep_Tool::Surface (*aFaces[1], aLocSurf[1]),
&BRep_Tool::Surface (*aFaces[2], aLocSurf[2])
};
Standard_Integer aConIndex = -1, aNbPlanes = 0;
Handle(Geom_ConicalSurface) aGeomCone;
Handle(Geom_CylindricalSurface) aGeomCyl;
Handle(Geom_Plane) aGeomPlanes[2];
const TopLoc_Location* aGeomPlanesLoc[2];
for (Standard_Integer aSurfIter = 0; aSurfIter < 3; ++aSurfIter)
{
const Handle(Geom_Surface)& aSurf = *aSurfaces[aSurfIter];
if (aConIndex == -1)
{
aGeomCone = Handle (Geom_ConicalSurface)::DownCast (aSurf);
if (!aGeomCone.IsNull())
{
aConIndex = aSurfIter;
continue;
}
aGeomCyl = Handle (Geom_CylindricalSurface)::DownCast (aSurf);
if (!aGeomCyl.IsNull())
{
aConIndex = aSurfIter;
continue;
}
}
if (aNbPlanes < 2)
{
aGeomPlanes[aNbPlanes] = Handle(Geom_Plane)::DownCast (aSurf);
if (!aGeomPlanes[aNbPlanes].IsNull())
{
aGeomPlanesLoc[aNbPlanes] = &aLocSurf[aSurfIter];
++aNbPlanes;
}
}
}
if (!aGeomCone.IsNull())
{
if (!aGeomPlanes[0].IsNull()
&& !aGeomPlanes[1].IsNull()
&& aGeomPlanes[0]->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular())
&& aGeomPlanes[1]->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular()))
{
const gp_Cone aCone = BRepAdaptor_Surface (*aFaces[aConIndex]).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
.Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp_Ax3());
const Standard_Real aTriangleHeight = (aCone.SemiAngle() > 0.0)
? aRad1 / Tan (aCone.SemiAngle())
: aRad1 / Tan (Abs (aCone.SemiAngle())) - aHeight;
const Standard_Real aRad2 = (aCone.SemiAngle() > 0.0)
? aRad1 * (aTriangleHeight + aHeight) / aTriangleHeight
: aRad1 * aTriangleHeight / (aTriangleHeight + aHeight);
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
break;
}
}
else if (!aGeomCyl.IsNull())
{
if (!aGeomPlanes[0].IsNull()
&& !aGeomPlanes[1].IsNull()
&& aGeomPlanes[0]->Position().Direction().IsEqual (aGeomCyl->Position().Direction(), Precision::Angular())
&& aGeomPlanes[1]->Position().Direction().IsEqual (aGeomCyl->Position().Direction(), Precision::Angular()))
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (*aFaces[aConIndex]).Cylinder();
const Standard_Real aRad = aCyl.Radius();
const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
.Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCyl.Position(), gp_Ax3());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
break;
}
}
}
for (Standard_Integer aShIndex = 1; aShIndex <= aSubfacesMap.Extent(); ++aShIndex)
{
ComputeSensitive (aSubfacesMap.FindKey (aShIndex), theOwner,
theSelection,
theDeflection, theDeviationAngle, theNbPOnEdge, theMaxParam, isAutoTriangulation);
}
break;
}
@@ -625,8 +490,7 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
}
else
{
theSensitive = new Select3D_SensitiveCircle (theOwner, aCircle,
aParamFirst, aParamLast, Standard_False, 16);
theSensitive = new Select3D_SensitivePoly (theOwner, aCircle, aParamFirst, aParamLast, Standard_False);
}
break;
}
@@ -697,6 +561,57 @@ void StdSelect_BRepSelectionTool::GetEdgeSensitive (const TopoDS_Shape& theShape
}
}
//=======================================================================
//function : getCylinderHeight
//purpose :
//=======================================================================
static Standard_Real getCylinderHeight (const Handle(Poly_Triangulation)& theTriangulation,
const TopLoc_Location& theLoc)
{
Bnd_Box aBox;
gp_Trsf aScaleTrsf;
aScaleTrsf.SetScaleFactor (theLoc.Transformation().ScaleFactor());
theTriangulation->MinMax (aBox, aScaleTrsf);
return aBox.CornerMax().Z() - aBox.CornerMin().Z();
}
//=======================================================================
//function : isCylinderOrCone
//purpose :
//=======================================================================
static Standard_Boolean isCylinderOrCone (const TopoDS_Face& theHollowCylinder, const gp_Pnt& theLocation, gp_Dir& theDirection)
{
Standard_Integer aCirclesNb = 0;
Standard_Boolean isCylinder = Standard_False;
gp_Pnt aPos;
TopExp_Explorer anEdgeExp;
for (anEdgeExp.Init (theHollowCylinder, TopAbs_EDGE); anEdgeExp.More(); anEdgeExp.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeExp.Current());
BRepAdaptor_Curve anAdaptor (anEdge);
if (anAdaptor.GetType() == GeomAbs_Circle
&& BRep_Tool::IsClosed (anEdge))
{
aCirclesNb++;
isCylinder = Standard_True;
if (aCirclesNb == 2)
{
// Reverse the direction of the cylinder, relevant if the cylinder was created as a prism
if (aPos.IsEqual (theLocation, Precision::Confusion()))
{
theDirection.Reverse();
}
return Standard_True;
}
aPos = anAdaptor.Circle().Location().XYZ();
}
}
return isCylinder;
}
//=======================================================================
//function : GetSensitiveEntityForFace
//purpose :
@@ -741,6 +656,76 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_
return Standard_True;
}
}
else if (Handle(Geom_ConicalSurface) aGeomCone = Handle(Geom_ConicalSurface)::DownCast (aSurf))
{
gp_Dir aDummyDir;
if (isCylinderOrCone (theFace, gp_Pnt(), aDummyDir))
{
const gp_Cone aCone = BRepAdaptor_Surface (theFace).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = getCylinderHeight (aTriangulation, aLoc);
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp::XOY());
Standard_Real aRad2;
if (aRad1 == 0.0)
{
aRad2 = Tan (aCone.SemiAngle()) * aHeight;
}
else
{
const Standard_Real aTriangleHeight = (aCone.SemiAngle() > 0.0)
? aRad1 / Tan (aCone.SemiAngle())
: aRad1 / Tan (Abs (aCone.SemiAngle())) - aHeight;
aRad2 = (aCone.SemiAngle() > 0.0)
? aRad1 * (aTriangleHeight + aHeight) / aTriangleHeight
: aRad1 * aTriangleHeight / (aTriangleHeight + aHeight);
}
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf, true);
theSensitiveList.Append (aSensSCyl);
return Standard_True;
}
}
else if (Handle(Geom_CylindricalSurface) aGeomCyl = Handle(Geom_CylindricalSurface)::DownCast (aSurf))
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (theFace).Cylinder();
gp_Ax3 aPos = aCyl.Position();
gp_Dir aDirection = aPos.Direction();
if (isCylinderOrCone (theFace, aPos.Location(), aDirection))
{
const Standard_Real aRad = aCyl.Radius();
const Standard_Real aHeight = getCylinderHeight (aTriangulation, aLoc);
gp_Trsf aTrsf;
aPos.SetDirection (aDirection);
aTrsf.SetTransformation (aPos, gp::XOY());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf, true);
theSensitiveList.Append (aSensSCyl);
return Standard_True;
}
}
else if (Handle(Geom_Plane) aGeomPlane = Handle(Geom_Plane)::DownCast (aSurf))
{
TopTools_IndexedMapOfShape aSubfacesMap;
TopExp::MapShapes (theFace, TopAbs_EDGE, aSubfacesMap);
if (aSubfacesMap.Extent() == 1)
{
const TopoDS_Edge& anEdge = TopoDS::Edge (aSubfacesMap.FindKey (1));
BRepAdaptor_Curve anAdaptor (anEdge);
if (anAdaptor.GetType() == GeomAbs_Circle
&& BRep_Tool::IsClosed (anEdge))
{
Handle(Select3D_SensitiveCircle) aSensSCyl = new Select3D_SensitiveCircle (theOwner, anAdaptor.Circle(), theInteriorFlag);
theSensitiveList.Append (aSensSCyl);
return Standard_True;
}
}
}
Handle(Select3D_SensitiveTriangulation) STG = new Select3D_SensitiveTriangulation (theOwner, aTriangulation, aLoc, theInteriorFlag);
theSensitiveList.Append (STG);
return Standard_True;
@@ -869,7 +854,7 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_
}
else
{
theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, cu3d.Circle(), theInteriorFlag, 16));
theSensitiveList.Append (new Select3D_SensitiveCircle (theOwner, cu3d.Circle(), theInteriorFlag));
}
}
}
@@ -939,3 +924,163 @@ Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace (const TopoDS_
}
return Standard_True;
}
//=======================================================================
//function : GetSensitiveForCylinder
//purpose :
//=======================================================================
Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForCylinder (const TopTools_IndexedMapOfShape& theSubfacesMap,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection)
{
if (theSubfacesMap.Extent() == 2) // detect cone
{
const TopoDS_Face* aFaces[2] =
{
&TopoDS::Face (theSubfacesMap.FindKey (1)),
&TopoDS::Face (theSubfacesMap.FindKey (2))
};
TopLoc_Location aLocSurf[2];
const Handle(Geom_Surface)* aSurfaces[2] =
{
&BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
&BRep_Tool::Surface (*aFaces[1], aLocSurf[1])
};
Standard_Integer aConIndex = 0;
Handle(Geom_ConicalSurface) aGeomCone = Handle(Geom_ConicalSurface)::DownCast (*aSurfaces[0]);
Handle(Geom_Plane) aGeomPln;
if (!aGeomCone.IsNull())
{
aGeomPln = Handle(Geom_Plane)::DownCast (*aSurfaces[1]);
}
else
{
aConIndex = 1;
aGeomCone = Handle(Geom_ConicalSurface)::DownCast (*aSurfaces[1]);
aGeomPln = Handle(Geom_Plane)::DownCast (*aSurfaces[0]);
}
if (!aGeomCone.IsNull()
&& !aGeomPln.IsNull()
&& aGeomPln->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular()))
{
const gp_Cone aCone = BRepAdaptor_Surface (*aFaces[aConIndex]).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = (aRad1 != 0.0)
? aRad1 / Abs (Tan (aCone.SemiAngle()))
: aCone.Location().Distance (aGeomPln->Location().Transformed (aLocSurf[aConIndex == 0 ? 1 : 0]));
const Standard_Real aRad2 = (aRad1 != 0.0) ? 0.0 : Tan (aCone.SemiAngle()) * aHeight;
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp::XOY());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
return Standard_True;
}
}
if (theSubfacesMap.Extent() == 3) // detect cylinder or truncated cone
{
const TopoDS_Face* aFaces[3] =
{
&TopoDS::Face (theSubfacesMap.FindKey (1)),
&TopoDS::Face (theSubfacesMap.FindKey (2)),
&TopoDS::Face (theSubfacesMap.FindKey (3))
};
TopLoc_Location aLocSurf[3];
const Handle(Geom_Surface)* aSurfaces[3] =
{
&BRep_Tool::Surface (*aFaces[0], aLocSurf[0]),
&BRep_Tool::Surface (*aFaces[1], aLocSurf[1]),
&BRep_Tool::Surface (*aFaces[2], aLocSurf[2])
};
Standard_Integer aConIndex = -1, aNbPlanes = 0;
Handle(Geom_ConicalSurface) aGeomCone;
Handle(Geom_CylindricalSurface) aGeomCyl;
Handle(Geom_Plane) aGeomPlanes[2];
const TopLoc_Location* aGeomPlanesLoc[2];
for (Standard_Integer aSurfIter = 0; aSurfIter < 3; ++aSurfIter)
{
const Handle(Geom_Surface)& aSurf = *aSurfaces[aSurfIter];
if (aConIndex == -1)
{
aGeomCone = Handle (Geom_ConicalSurface)::DownCast (aSurf);
if (!aGeomCone.IsNull())
{
aConIndex = aSurfIter;
continue;
}
aGeomCyl = Handle (Geom_CylindricalSurface)::DownCast (aSurf);
if (!aGeomCyl.IsNull())
{
aConIndex = aSurfIter;
continue;
}
}
if (aNbPlanes < 2)
{
aGeomPlanes[aNbPlanes] = Handle(Geom_Plane)::DownCast (aSurf);
if (!aGeomPlanes[aNbPlanes].IsNull())
{
aGeomPlanesLoc[aNbPlanes] = &aLocSurf[aSurfIter];
++aNbPlanes;
}
}
}
if (!aGeomCone.IsNull())
{
if (!aGeomPlanes[0].IsNull()
&& !aGeomPlanes[1].IsNull()
&& aGeomPlanes[0]->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular())
&& aGeomPlanes[1]->Position().Direction().IsEqual (aGeomCone->Position().Direction(), Precision::Angular()))
{
const gp_Cone aCone = BRepAdaptor_Surface (*aFaces[aConIndex]).Cone();
const Standard_Real aRad1 = aCone.RefRadius();
const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
.Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
aTrsf.SetTransformation (aCone.Position(), gp::XOY());
const Standard_Real aTriangleHeight = (aCone.SemiAngle() > 0.0)
? aRad1 / Tan (aCone.SemiAngle())
: aRad1 / Tan (Abs (aCone.SemiAngle())) - aHeight;
const Standard_Real aRad2 = (aCone.SemiAngle() > 0.0)
? aRad1 * (aTriangleHeight + aHeight) / aTriangleHeight
: aRad1 * aTriangleHeight / (aTriangleHeight + aHeight);
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad1, aRad2, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
return Standard_True;
}
}
else if (!aGeomCyl.IsNull())
{
if (!aGeomPlanes[0].IsNull()
&& !aGeomPlanes[1].IsNull()
&& aGeomPlanes[0]->Position().Direction().IsParallel (aGeomCyl->Position().Direction(), Precision::Angular())
&& aGeomPlanes[1]->Position().Direction().IsParallel (aGeomCyl->Position().Direction(), Precision::Angular()))
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (*aFaces[aConIndex]).Cylinder();
const Standard_Real aRad = aCyl.Radius();
const Standard_Real aHeight = aGeomPlanes[0]->Location().Transformed (*aGeomPlanesLoc[0])
.Distance (aGeomPlanes[1]->Location().Transformed (*aGeomPlanesLoc[1]));
gp_Trsf aTrsf;
gp_Ax3 aPos = aCyl.Position();
if (aGeomPlanes[0]->Position().IsCoplanar (aGeomPlanes[1]->Position(), Precision::Angular(), Precision::Angular()))
{
// cylinders created as a prism have an inverse vector of the cylindrical surface
aPos.SetDirection (aPos.Direction().Reversed());
}
aTrsf.SetTransformation (aPos, gp::XOY());
Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf);
theSelection->Add (aSensSCyl);
return Standard_True;
}
}
}
return Standard_False;
}

View File

@@ -28,6 +28,7 @@
#include <Select3D_SensitiveEntity.hxx>
#include <Select3D_EntitySequence.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
class SelectMgr_SelectableObject;
class TopoDS_Face;
@@ -124,14 +125,14 @@ public:
}
//! Computes the sensitive primitives, stores them in the SelectMgr_Selection object, and returns this object.
//! @param theShape shape to compute sensitive entities
//! @param theOwner selectable owner object
//! @param theSelection selection to append new sensitive entities
//! @param theDeflection linear deflection
//! @param theDeflAngle angular deflection
//! @param theNbPOnEdge sensitivity parameters for edges and wires
//! @param theMaxiParam sensitivity parameters for infinite objects (the default value is 500)
//! @param theAutoTriang flag to compute triangulation for the faces which have none
//! @param[in] theShape shape to compute sensitive entities
//! @param[in] theOwner selectable owner object
//! @param[in] theSelection selection to append new sensitive entities
//! @param[in] theDeflection linear deflection
//! @param[in] theDeflAngle angular deflection
//! @param[in] theNbPOnEdge sensitivity parameters for edges and wires
//! @param[in] theMaxiParam sensitivity parameters for infinite objects (the default value is 500)
//! @param[in] theAutoTriang flag to compute triangulation for the faces which have none
Standard_EXPORT static void ComputeSensitive (const TopoDS_Shape& theShape,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection,
@@ -142,13 +143,13 @@ public:
const Standard_Boolean theAutoTriang = Standard_True);
//! Creates the 3D sensitive entities for Face selection.
//! @param theFace face to compute sensitive entities
//! @param theOwner selectable owner object
//! @param theOutList output result list to append created entities
//! @param theAutoTriang obsolete flag (has no effect)
//! @param theNbPOnEdge sensitivity parameters
//! @param theMaxiParam sensitivity parameters
//! @param theInteriorFlag flag indicating that face interior (TRUE) or face boundary (FALSE) should be selectable
//! @param[in] theFace face to compute sensitive entities
//! @param[in] theOwner selectable owner object
//! @param[out] theOutList output result list to append created entities
//! @param[in] theAutoTriang obsolete flag (has no effect)
//! @param[in] theNbPOnEdge sensitivity parameters
//! @param[in] theMaxiParam sensitivity parameters
//! @param[in] theInteriorFlag flag indicating that face interior (TRUE) or face boundary (FALSE) should be selectable
Standard_EXPORT static Standard_Boolean GetSensitiveForFace (const TopoDS_Face& theFace,
const Handle(SelectMgr_EntityOwner)& theOwner,
Select3D_EntitySequence& theOutList,
@@ -157,14 +158,22 @@ public:
const Standard_Real theMaxiParam = 500,
const Standard_Boolean theInteriorFlag = Standard_True);
//! Creates a sensitive cylinder.
//! @param[in] theSubfacesMap map of cylinder faces
//! @param[in] theOwner selectable owner object
//! @param[in] theSelection selection to append new sensitive entities
Standard_EXPORT static Standard_Boolean GetSensitiveForCylinder (const TopTools_IndexedMapOfShape& theSubfacesMap,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection);
//! Create a sensitive edge or sensitive wire.
//! @param theShape either TopoDS_Edge or TopoDS_Wire to compute sensitive entities
//! @param theOwner selectable owner object
//! @param theSelection selection to append new sensitive entities
//! @param theDeflection linear deflection
//! @param theDeviationAngle angular deflection
//! @param theNbPOnEdge sensitivity parameters
//! @param theMaxiParam sensitivity parameters
//! @param[in] theShape either TopoDS_Edge or TopoDS_Wire to compute sensitive entities
//! @param[in] theOwner selectable owner object
//! @param[in] theSelection selection to append new sensitive entities
//! @param[in] theDeflection linear deflection
//! @param[in] theDeviationAngle angular deflection
//! @param[in] theNbPOnEdge sensitivity parameters
//! @param[out] theMaxiParam sensitivity parameters
Standard_EXPORT static void GetEdgeSensitive (const TopoDS_Shape& theShape,
const Handle(SelectMgr_EntityOwner)& theOwner,
const Handle(SelectMgr_Selection)& theSelection,

View File

@@ -46,6 +46,7 @@
#include <ShapeAlgo.hxx>
#include <ShapeAlgo_AlgoContainer.hxx>
#include <StdFail_NotDone.hxx>
#include <StepData_GlobalFactors.hxx>
#include <StepGeom_BSplineSurface.hxx>
#include <StepGeom_BSplineSurfaceForm.hxx>
#include <StepGeom_OffsetSurface.hxx>
@@ -488,9 +489,11 @@ StepToTopoDS_TranslateFace::createMesh(const Handle(StepVisual_TriangulatedFace)
const Standard_Boolean aHasNormals = (theTF->NbNormals() > 0);
Handle(Poly_Triangulation) aMesh = new Poly_Triangulation(theTF->NbPnindex(), theTF->NbTriangles(), aHasUVNodes, aHasNormals);
const Standard_Real aLF = StepData_GlobalFactors::Intance().LengthFactor();
for (Standard_Integer j = 1; j <= theTF->NbPnindex(); ++j)
{
aMesh->SetNode(j, aNodes->Value(theTF->PnindexValue(j)));
const gp_XYZ& aPoint = aNodes->Value(theTF->PnindexValue(j));
aMesh->SetNode(j, aPoint * aLF);
}
for (Standard_Integer k = 1; k <= theTF->NbTriangles(); ++k)
@@ -573,9 +576,11 @@ StepToTopoDS_TranslateFace::createMesh(const Handle(StepVisual_ComplexTriangulat
Handle(Poly_Triangulation) aMesh = new Poly_Triangulation(theTF->NbPnindex(),
aNbTriaStrips + aNbTriaFans, aHasUVNodes, aHasNormals);
const Standard_Real aLF = StepData_GlobalFactors::Intance().LengthFactor();
for (Standard_Integer j = 1; j <= theTF->NbPnindex(); ++j)
{
aMesh->SetNode(j, aNodes->Value(theTF->PnindexValue(j)));
const gp_XYZ& aPoint = aNodes->Value(theTF->PnindexValue(j));
aMesh->SetNode(j, aLF * aPoint);
}
Standard_Integer k = 1;

View File

@@ -26,6 +26,7 @@
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <Standard_Macro.hxx>
class TCollection_ExtendedString;
//! Class defines a variable-length sequence of 8-bit characters.
@@ -74,7 +75,7 @@ public:
Standard_EXPORT TCollection_AsciiString(const TCollection_AsciiString& astring);
//! Move constructor
TCollection_AsciiString (TCollection_AsciiString&& theOther) noexcept
TCollection_AsciiString (TCollection_AsciiString&& theOther) Standard_Noexcept
: mystring (theOther.mystring),
mylength (theOther.mylength)
{
@@ -276,7 +277,7 @@ void operator = (const TCollection_AsciiString& fromwhere)
Standard_EXPORT void Swap (TCollection_AsciiString& theOther);
//! Move assignment operator
TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) noexcept { Swap (theOther); return *this; }
TCollection_AsciiString& operator= (TCollection_AsciiString&& theOther) Standard_Noexcept { Swap (theOther); return *this; }
//! Frees memory allocated by AsciiString.
Standard_EXPORT ~TCollection_AsciiString();

View File

@@ -31,6 +31,7 @@
#include <Standard_Real.hxx>
#include <Standard_OStream.hxx>
#include <Standard_PCharacter.hxx>
#include <Standard_Macro.hxx>
class TCollection_AsciiString;
@@ -98,7 +99,7 @@ public:
Standard_EXPORT TCollection_ExtendedString(const TCollection_ExtendedString& astring);
//! Move constructor
TCollection_ExtendedString (TCollection_ExtendedString&& theOther) noexcept
TCollection_ExtendedString (TCollection_ExtendedString&& theOther) Standard_Noexcept
: mystring (theOther.mystring),
mylength (theOther.mylength)
{
@@ -153,7 +154,7 @@ void operator = (const TCollection_ExtendedString& fromwhere)
Standard_EXPORT void Swap (TCollection_ExtendedString& theOther);
//! Move assignment operator
TCollection_ExtendedString& operator= (TCollection_ExtendedString&& theOther) noexcept { Swap (theOther); return *this; }
TCollection_ExtendedString& operator= (TCollection_ExtendedString&& theOther) Standard_Noexcept { Swap (theOther); return *this; }
//! Frees memory allocated by ExtendedString.
Standard_EXPORT ~TCollection_ExtendedString();

View File

@@ -21,6 +21,7 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Macro.hxx>
class TopLoc_SListNodeOfItemLocation;
class TopLoc_ItemLocation;
@@ -69,13 +70,13 @@ public:
}
//! Move constructor
TopLoc_SListOfItemLocation (TopLoc_SListOfItemLocation&& theOther) noexcept
TopLoc_SListOfItemLocation (TopLoc_SListOfItemLocation&& theOther) Standard_Noexcept
: myNode(std::move (theOther.myNode))
{
}
//! Move operator
TopLoc_SListOfItemLocation& operator= (TopLoc_SListOfItemLocation&& theOther) noexcept
TopLoc_SListOfItemLocation& operator= (TopLoc_SListOfItemLocation&& theOther) Standard_Noexcept
{
myNode = std::move (theOther.myNode);
return *this;

View File

@@ -132,6 +132,7 @@
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitivePrimitiveArray.hxx>
#include <Select3D_SensitivePoint.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <StdPrs_Curve.hxx>
@@ -1965,8 +1966,14 @@ public:
// CASCADE RTTI
DEFINE_STANDARD_RTTI_INLINE(FilledCircle, AIS_InteractiveObject);
FilledCircle (const gp_Pnt& theCenter, Standard_Real theRadius);
FilledCircle (Handle(Geom_Circle) theCircle);
FilledCircle (const Handle(Geom_Circle)& theCircle,
const Standard_Real theUStart,
const Standard_Real theUEnd);
FilledCircle (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const Standard_Real theUStart,
const Standard_Real theUEnd);
private:
TopoDS_Face ComputeFace();
@@ -1982,35 +1989,50 @@ private:
protected:
Handle(Geom_Circle) myCircle;
Standard_Boolean myFilledStatus;
Standard_Real myUStart;
Standard_Real myUEnd;
Standard_Boolean myFilledStatus;
};
FilledCircle::FilledCircle (const Handle(Geom_Circle)& theCircle,
const Standard_Real theUStart,
const Standard_Real theUEnd)
: myCircle (theCircle),
myUStart (theUStart),
myUEnd (theUEnd),
myFilledStatus (Standard_True)
{ }
FilledCircle::FilledCircle(const gp_Pnt& theCenter, Standard_Real theRadius)
FilledCircle::FilledCircle (const gp_Pnt& theCenter,
const Standard_Real theRadius,
const Standard_Real theUStart,
const Standard_Real theUEnd)
: FilledCircle (CreateCircle (theCenter, theRadius), theUStart, theUEnd)
{ }
TopoDS_Face FilledCircle::ComputeFace()
{
myCircle = CreateCircle(theCenter, theRadius);
myFilledStatus = Standard_True;
}
// Create edge from myCircle
BRepBuilderAPI_MakeEdge anEdgeMaker (myCircle->Circ(), myUStart, myUEnd);
TopoDS_Edge anEdge = anEdgeMaker.Edge();
FilledCircle::FilledCircle(Handle(Geom_Circle) theCircle)
{
myCircle = theCircle;
myFilledStatus = Standard_True;
}
TopoDS_Face FilledCircle::ComputeFace()
{
// Create edge from myCircle
BRepBuilderAPI_MakeEdge anEdgeMaker(myCircle->Circ());
TopoDS_Edge anEdge = anEdgeMaker.Edge();
// Create wire from anEdge
BRepBuilderAPI_MakeWire aWireMaker(anEdge);
// Create wire from anEdge
BRepBuilderAPI_MakeWire aWireMaker;
if (Abs (Abs (myUEnd - myUStart) - 2.0 * M_PI) > gp::Resolution())
{
TopoDS_Edge anEndCenterEdge = BRepBuilderAPI_MakeEdge (myCircle->Value (myUEnd), myCircle->Location()).Edge();
TopoDS_Edge aStartCenterEdge = BRepBuilderAPI_MakeEdge (myCircle->Location(), myCircle->Value (myUStart)).Edge();
aWireMaker = BRepBuilderAPI_MakeWire (anEdge, anEndCenterEdge, aStartCenterEdge);
}
else
{
aWireMaker = BRepBuilderAPI_MakeWire (anEdge);
}
TopoDS_Wire aWire = aWireMaker.Wire();
// Create face from aWire
BRepBuilderAPI_MakeFace aFaceMaker(aWire);
BRepBuilderAPI_MakeFace aFaceMaker (aWire);
TopoDS_Face aFace = aFaceMaker.Face();
return aFace;
@@ -2030,12 +2052,22 @@ void FilledCircle::Compute (const Handle(PrsMgr_PresentationManager)& ,
StdPrs_ShadedShape::Add (thePrs, aFace, myDrawer);
}
void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelection,
const Standard_Integer /*theMode*/)
void FilledCircle::ComputeSelection (const Handle(SelectMgr_Selection) &theSelection,
const Standard_Integer /*theMode*/)
{
Handle(SelectMgr_EntityOwner) anEntityOwner = new SelectMgr_EntityOwner(this);
Handle(Select3D_SensitiveCircle) aSensitiveCircle = new Select3D_SensitiveCircle (anEntityOwner, myCircle->Circ(), myFilledStatus);
theSelection->Add(aSensitiveCircle);
Handle(Select3D_SensitiveEntity) aSensitiveCircle;
if (Abs (Abs (myUEnd - myUStart) - 2.0 * M_PI) > gp::Resolution())
{
aSensitiveCircle = new Select3D_SensitivePoly (anEntityOwner, myCircle->Circ(), myUStart, myUEnd, myFilledStatus);
}
else
{
aSensitiveCircle = new Select3D_SensitiveCircle (anEntityOwner, myCircle->Circ(), myFilledStatus);
}
theSelection->Add (aSensitiveCircle);
}
//==============================================================================
@@ -2046,51 +2078,63 @@ void FilledCircle::ComputeSelection(const Handle(SelectMgr_Selection) &theSelect
//==============================================================================
//function : VCircleBuilder
//purpose : Build an AIS_Circle
//Draw arg : vcircle CircleName PlaneName PointName Radius IsFilled
// PointName PointName PointName IsFilled
//Draw arg : vcircle CircleName PlaneName PointName Radius IsFilled UStart UEnd
// PointName PointName PointName IsFilled UStart UEnd
//==============================================================================
void DisplayCircle (Handle (Geom_Circle) theGeomCircle,
TCollection_AsciiString theName,
Standard_Boolean isFilled)
void DisplayCircle (const Handle(Geom_Circle)& theGeomCircle,
const TCollection_AsciiString& theName,
const Standard_Boolean isFilled,
const Standard_Real theUStart,
const Standard_Real theUEnd)
{
Handle(AIS_InteractiveObject) aCircle;
if (isFilled)
if (isFilled)
{
aCircle = new FilledCircle(theGeomCircle);
aCircle = new FilledCircle (theGeomCircle, theUStart, theUEnd);
}
else
{
aCircle = new AIS_Circle(theGeomCircle);
Handle(AIS_Circle)::DownCast (aCircle)->SetFilledCircleSens (Standard_False);
aCircle = new AIS_Circle (theGeomCircle, theUStart, theUEnd, Standard_False);
}
// Check if there is an object with given name
// and remove it from context
if (GetMapOfAIS().IsBound2(theName))
if (GetMapOfAIS().IsBound2(theName))
{
Handle(AIS_InteractiveObject) anInterObj = GetMapOfAIS().Find2(theName);
TheAISContext()->Remove(anInterObj, Standard_False);
GetMapOfAIS().UnBind2(theName);
Handle(AIS_InteractiveObject) anInterObj = GetMapOfAIS().Find2 (theName);
TheAISContext()->Remove (anInterObj, Standard_False);
GetMapOfAIS().UnBind2 (theName);
}
// Bind the circle to its name
GetMapOfAIS().Bind(aCircle, theName);
GetMapOfAIS().Bind (aCircle, theName);
// Display the circle
TheAISContext()->Display (aCircle, Standard_True);
}
static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
static int VCircleBuilder (Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
{
if (argc > 6 || argc < 2)
{
if (argc > 8 || argc < 2)
{
Message::SendFail ("Syntax error: wrong number of arguments");
return 1;
}
if (argc == 6)
Standard_Real anUStart = 0, anUEnd = M_PI * 2.0;
if (argc == 8)
{
anUStart = Draw::Atof (argv[6]) * M_PI / 180.0;
anUEnd = Draw::Atof (argv[7]) * M_PI / 180.0;
}
else if (argc == 4)
{
anUStart = Draw::Atof (argv[2]) * M_PI / 180.0;
anUEnd = Draw::Atof (argv[3]) * M_PI / 180.0;
}
if (argc == 6 || argc == 8)
{
TCollection_AsciiString aName (argv[1]);
Standard_Boolean isFilled = Draw::Atoi(argv[5]) != 0;
@@ -2159,7 +2203,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
return 1;
}
DisplayCircle (aGeomCircle, aName, isFilled);
DisplayCircle (aGeomCircle, aName, isFilled, anUStart, anUEnd);
}
// Arguments: AIS_Plane AIS_Point Real
@@ -2203,7 +2247,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
return 1;
}
DisplayCircle (aGeomCircle, aName, isFilled);
DisplayCircle (aGeomCircle, aName, isFilled, anUStart, anUEnd);
}
else
{
@@ -2263,7 +2307,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
return 1;
}
DisplayCircle (aGeomCircle, aName, isFilled);
DisplayCircle (aGeomCircle, aName, isFilled, anUStart, anUEnd);
}
else if (aShapeA.ShapeType() == TopAbs_FACE)
{
@@ -2307,7 +2351,7 @@ static int VCircleBuilder(Draw_Interpretor& /*di*/, Standard_Integer argc, const
return 1;
}
DisplayCircle (aGeomCircle, aName, isFilled);
DisplayCircle (aGeomCircle, aName, isFilled, anUStart, anUEnd);
}
else
{
@@ -2500,6 +2544,11 @@ static int VDrawText (Draw_Interpretor& theDI,
}
aTextFormatter->SetWrapping ((Standard_ShortReal)Draw::Atof(theArgVec[++anArgIt]));
}
else if (aParam == "-wordwrapping")
{
const bool isWordWrapping = Draw::ParseOnOffNoIterator(theArgsNb, theArgVec, anArgIt);
aTextFormatter->SetWordWrapping(isWordWrapping);
}
else if (aParam == "-aspect"
&& anArgIt + 1 < theArgsNb)
{
@@ -6909,8 +6958,8 @@ Creates a line from coordinates, named or interactively selected vertices.
)" /* [vline] */);
addCmd ("vcircle", VCircleBuilder, /* [vcircle] */ R"(
vcircle CircleName [PointName PointName PointName IsFilled]
[PlaneName PointName Radius IsFilled]
vcircle CircleName [PointName PointName PointName IsFilled] [UStart UEnd]
[PlaneName PointName Radius IsFilled] [UStart UEnd]
Creates a circle from named or interactively selected entities.
Parameter IsFilled is defined as 0 or 1.
)" /* [vcircle] */);
@@ -6925,6 +6974,7 @@ vdrawtext name text
[-zoom {0|1}]=0
[-height height]=16
[-wrapping width]=40
[-wordwrapping {0|1}]=1
[-aspect {regular|bold|italic|boldItalic}]=regular
[-font font]=Times
[-2d] [-perspos {X Y Z}]={0 0 0}

View File

@@ -515,7 +515,7 @@ static void rescaleDimensionRefLabels(const TDF_LabelSequence& theRefLabels,
if (aL.FindAttribute(TNaming_NamedShape::GetID(), aNS))
{
TopoDS_Shape aShape = aNS->Get();
theBRepTrsf.Perform(aShape, Standard_True);
theBRepTrsf.Perform(aShape, Standard_True, Standard_True);
if (!theBRepTrsf.IsDone())
{
Standard_SStream aSS;
@@ -664,7 +664,7 @@ Standard_Boolean XCAFDoc_Editor::RescaleGeometry(const TDF_Label& theLabel,
if (aNodeType == XCAFDoc_AssemblyGraph::NodeType_Part)
{
const TopoDS_Shape aShape = aShapeTool->GetShape(aLabel);
aBRepTrsf.Perform(aShape, Standard_True);
aBRepTrsf.Perform(aShape, Standard_True, Standard_True);
if (!aBRepTrsf.IsDone())
{
Standard_SStream aSS;

View File

@@ -1836,7 +1836,7 @@ void XDEDRAW::Init(Draw_Interpretor& di)
"Doc [-names]: Prints number of assembly instances",
__FILE__, XDumpNomenclature, g);
di.Add("XRescaleGeometry",
"Doc -scale factor [-root label]: Applies geometrical scale to assembly",
"Doc factor [-root label] [-force]: Applies geometrical scale to assembly",
__FILE__, XRescaleGeometry, g);
// Specialized commands

View File

@@ -19,7 +19,10 @@
#include <DDocStd.hxx>
#include <Draw.hxx>
#include <gp_Trsf.hxx>
#include <Message.hxx>
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_Tool.hxx>
#include <TDocStd_Document.hxx>
#include <TopoDS_Compound.hxx>
@@ -934,59 +937,140 @@ static Standard_Integer updateAssemblies(Draw_Interpretor& di, Standard_Integer
return 0;
}
static Standard_Integer XGetProperties(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
static Standard_Integer XGetProperties(Draw_Interpretor& theDI,
Standard_Integer theArgc,
const char** theArgv)
{
if (argc != 3)
if (theArgc < 2)
{
di << "Syntax error: wrong number of arguments\nUse: " << argv[0] << " Doc Label\n";
theDI.PrintHelp(theArgv[0]);
return 1;
}
Handle(TDocStd_Document) aDoc;
DDocStd::GetDocument(argv[1], aDoc);
DDocStd::GetDocument(theArgv[1], aDoc);
if (aDoc.IsNull())
{
di << "Syntax error: " << argv[1] << " is not a document\n";
theDI << "Syntax error: " << theArgv[1] << " is not a document\n";
return 1;
}
TDF_Label aLabel;
TDF_Tool::Label(aDoc->GetData(), argv[2], aLabel);
// Get XDE shape tool
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
if (aNamedData.IsNull())
NCollection_IndexedDataMap<TCollection_AsciiString, Handle(TDataStd_NamedData)> aNameDataMap;
for (Standard_Integer anInd = 2; anInd < theArgc; anInd++)
{
di << argv[2] << " has no properties\n";
return 0;
}
aNamedData->LoadDeferredData();
if (aNamedData->HasIntegers())
{
TColStd_DataMapOfStringInteger anIntProperties = aNamedData->GetIntegersContainer();
for (TColStd_DataMapIteratorOfDataMapOfStringInteger anIter(anIntProperties); anIter.More(); anIter.Next())
TDF_Label aLabel;
const TCollection_AsciiString anEntry = theArgv[anInd];
TDF_Tool::Label(aDoc->GetData(), anEntry, aLabel);
if (aLabel.IsNull())
{
di << anIter.Key() << " : " << anIter.Value() << "\n";
TopoDS_Shape aShape = DBRep::Get(theArgv[anInd]);
if (!aShape.IsNull())
{
aLabel = aShapeTool->FindShape(aShape);
}
}
if (!aLabel.IsNull())
{
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
if (!aNamedData.IsNull())
{
aNameDataMap.Add(anEntry, aNamedData);
}
}
else
{
Message::SendWarning() << "Warning: incorrect argument [" << theArgv[anInd] << "]" << " is not a label";
}
}
if (aNamedData->HasReals())
if (theArgc == 2)
{
TDataStd_DataMapOfStringReal aRealProperties = aNamedData->GetRealsContainer();
for (TDataStd_DataMapIteratorOfDataMapOfStringReal anIter(aRealProperties); anIter.More(); anIter.Next())
for (TDF_ChildIterator anIter(aShapeTool->Label(), Standard_True);
anIter.More(); anIter.Next())
{
di << anIter.Key() << " : " << anIter.Value() << "\n";
const TDF_Label& aLabel = anIter.Value();
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
if (!aNamedData.IsNull())
{
aNameDataMap.Add(anEntry, aNamedData);
}
}
}
if (aNamedData->HasStrings())
for (NCollection_IndexedDataMap<TCollection_AsciiString, Handle(TDataStd_NamedData)>::Iterator aNamedDataIter(aNameDataMap);
aNamedDataIter.More(); aNamedDataIter.Next())
{
TDataStd_DataMapOfStringString aStringProperties = aNamedData->GetStringsContainer();
for (TDataStd_DataMapIteratorOfDataMapOfStringString anIter(aStringProperties); anIter.More(); anIter.Next())
if (theArgc != 3)
{
di << anIter.Key() << " : " << anIter.Value() << "\n";
theDI << "Property for [" << aNamedDataIter.Key() << "]:\n";
}
const Handle(TDataStd_NamedData)& aNamedData = aNamedDataIter.Value();
aNamedData->LoadDeferredData();
if (aNamedData->HasIntegers())
{
const TColStd_DataMapOfStringInteger& anIntProperties = aNamedData->GetIntegersContainer();
for (TColStd_DataMapIteratorOfDataMapOfStringInteger anIter(anIntProperties); anIter.More(); anIter.Next())
{
theDI << anIter.Key() << " : " << anIter.Value() << "\n";
}
}
if (aNamedData->HasReals())
{
const TDataStd_DataMapOfStringReal& aRealProperties = aNamedData->GetRealsContainer();
for (TDataStd_DataMapIteratorOfDataMapOfStringReal anIter(aRealProperties); anIter.More(); anIter.Next())
{
theDI << anIter.Key() << " : " << anIter.Value() << "\n";
}
}
if (aNamedData->HasStrings())
{
const TDataStd_DataMapOfStringString& aStringProperties = aNamedData->GetStringsContainer();
for (TDataStd_DataMapIteratorOfDataMapOfStringString anIter(aStringProperties); anIter.More(); anIter.Next())
{
theDI << anIter.Key() << " : " << anIter.Value() << "\n";
}
}
if (aNamedData->HasBytes())
{
const TDataStd_DataMapOfStringByte& aByteProperties = aNamedData->GetBytesContainer();
for (TDataStd_DataMapOfStringByte::Iterator anIter(aByteProperties); anIter.More(); anIter.Next())
{
theDI << anIter.Key() << " : " << anIter.Value() << "\n";
}
}
if (aNamedData->HasArraysOfIntegers())
{
const TDataStd_DataMapOfStringHArray1OfInteger& anArrayIntegerProperties =
aNamedData->GetArraysOfIntegersContainer();
for (TDataStd_DataMapOfStringHArray1OfInteger::Iterator anIter(anArrayIntegerProperties);
anIter.More(); anIter.Next())
{
TCollection_AsciiString aMessage(anIter.Key() + " : ");
for (TColStd_HArray1OfInteger::Iterator anSubIter(anIter.Value()->Array1());
anSubIter.More(); anSubIter.Next())
{
aMessage += " ";
aMessage += anSubIter.Value();
}
theDI << aMessage << "\n";
}
}
if (aNamedData->HasArraysOfReals())
{
const TDataStd_DataMapOfStringHArray1OfReal& anArrayRealsProperties =
aNamedData->GetArraysOfRealsContainer();
for (TDataStd_DataMapOfStringHArray1OfReal::Iterator anIter(anArrayRealsProperties);
anIter.More(); anIter.Next())
{
TCollection_AsciiString aMessage(anIter.Key() + " : ");
for (TColStd_HArray1OfReal::Iterator anSubIter(anIter.Value()->Array1());
anSubIter.More(); anSubIter.Next())
{
aMessage += " ";
aMessage += anSubIter.Value();
}
theDI << aMessage << "\n";
}
}
}
@@ -1142,7 +1226,7 @@ void XDEDRAW_Shapes::InitCommands(Draw_Interpretor& di)
di.Add ("XUpdateAssemblies","Doc \t: updates assembly compounds",
__FILE__, updateAssemblies, g);
di.Add("XGetProperties", "Doc Label \t: prints named properties assigned to the Label",
di.Add("XGetProperties", "Doc [label1, label2, ...] [shape1, shape2, ...]\t: prints named properties assigned to the all document's shape labels or chosen labels of shapes",
__FILE__, XGetProperties, g);
di.Add ("XAutoNaming","Doc [0|1]\t: Disable/enable autonaming to Document",

View File

@@ -383,6 +383,7 @@ static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
bool toForceUVExport = false, toEmbedTexturesInGlb = true;
bool toMergeFaces = false, toSplitIndices16 = false;
bool isParallel = false;
RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct;
RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product;
RWGltf_DracoParameters aDracoParameters;
@@ -556,6 +557,10 @@ static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
{
aDracoParameters.UnifiedQuantization = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
}
else if (anArgCase == "-parallel")
{
isParallel = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
}
else
{
Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
@@ -587,6 +592,7 @@ static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
aWriter.SetToEmbedTexturesInGlb (toEmbedTexturesInGlb);
aWriter.SetMergeFaces (toMergeFaces);
aWriter.SetSplitIndices16 (toSplitIndices16);
aWriter.SetParallel(isParallel);
aWriter.SetCompressionParameters(aDracoParameters);
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aScaleFactorM);
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
@@ -2450,7 +2456,7 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
"\n\t\t: [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product"
"\n\t\t: [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10"
"\n\t\t: [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12"
"\n\t\t: [-unifiedQuantization]=0"
"\n\t\t: [-unifiedQuantization]=0 [-parallel]=0"
"\n\t\t: Write XDE document into glTF file."
"\n\t\t: -trsfFormat preferred transformation format"
"\n\t\t: -systemCoordSys system coordinate system; Zup when not specified"
@@ -2460,7 +2466,7 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
"\n\t\t: -texturesSeparate write textures to separate files"
"\n\t\t: -nodeNameFormat name format for Nodes"
"\n\t\t: -meshNameFormat name format for Meshes"
"\n\t\t: -draco use Draco compression 3D geometric meshes"
"\n\t\t: -draco use Draco compression 3D geometric meshes"
"\n\t\t: -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order"
"\n\t\t: -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)"
"\n\t\t: -quantizeNormalBits quantization bits for normal attribute when using Draco compression (by default 10)"
@@ -2468,7 +2474,8 @@ void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
"\n\t\t: -quantizeColorBits quantization bits for color attribute when using Draco compression (by default 8)"
"\n\t\t: -quantizeGenericBits quantization bits for skinning attribute (joint indices and joint weights)"
"\n and custom attributes when using Draco compression (by default 12)"
"\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false",
"\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false"
"\n\t\t: -parallel use multithreading for Draco compression",
__FILE__, WriteGltf, g);
theCommands.Add ("writegltf",
"writegltf shape file",

View File

@@ -10,7 +10,7 @@ stepread [locate_data_file bug27894_usd_raises_Standard_NullObject.stp] a *
renamevar a_1 a
unifysamedom result a
checknbshapes result -m UnifySameDomain -face 12 -edge 29
checknbshapes result -m UnifySameDomain -face 12 -edge 30
checkshape result

View File

@@ -9,7 +9,7 @@ unifysamedom result a
checkshape result
checknbshapes result -solid 1 -shell 1 -face 21 -wire 22 -edge 58 -vertex 38
checknbshapes result -solid 1 -shell 1 -face 21 -wire 22 -edge 57 -vertex 37
set tolres [checkmaxtol result]

22
tests/bugs/heal/bug33006 Normal file
View File

@@ -0,0 +1,22 @@
puts "========================================="
puts "OCC33006: UnifySameDomain raises exceptio"
puts "========================================="
puts ""
restore [locate_data_file bug33006.brep] a
unifysamedom result a
checkshape result
checknbshapes result -t -solid 1 -shell 1 -face 3 -wire 4 -edge 11 -vertex 4
set tolres [checkmaxtol result]
if { ${tolres} > 0.004416} {
puts "Error: bad tolerance of result"
}
checkprops result -s 77917.5 -v 195647
checkview -display result -2d -path ${imagedir}/${test_image}.png

View File

@@ -1,29 +0,0 @@
puts "============"
puts "OCC30217_1"
puts "============"
puts ""
#########################################################################
# Intersection between a circle and a line not detected (2d)
#########################################################################
2ddrseg s2 -80.461134694338 53.07587187722 -31.501464018476 67.029737602069
circle c2 -18.339655323916 20.849340929486 48.019394466707
# Set tolerance.
set tol_abs 1.0e-7
set tol_rel 1.0e-2
# Set reference data.
set param11 1.8484218380721342
set param12 1.8484627151687805
set param21 50.908401295062035
set param22 50.909328431594709
set info [2dintersect c2 s2 -tol 1e-8]
regexp {Curve 1 first parameter: +([-0-9.+eE]+) last parameter: +([-0-9.+eE]+)} ${info} full curve1p1 curve1p2
regexp {Curve 2 first parameter: +([-0-9.+eE]+) last parameter: +([-0-9.+eE]+)} ${info} full curve2p1 curve2p2
checkreal "Curve 1 param 1" ${curve1p1} ${param11} ${tol_abs} ${tol_rel}
checkreal "Curve 1 param 2" ${curve1p2} ${param12} ${tol_abs} ${tol_rel}
checkreal "Curve 2 param 1" ${curve2p1} ${param21} ${tol_abs} ${tol_rel}
checkreal "Curve 2 param 2" ${curve2p2} ${param22} ${tol_abs} ${tol_rel}

View File

@@ -1,26 +0,0 @@
puts "============"
puts "OCC30217_2"
puts "============"
puts ""
#########################################################################
# Intersection between a circle and a line not detected (3d)
#########################################################################
set tol_abs 2.e-7
drseg s -80.461134694338 53.07587187722 0.0 -31.501464018476 67.029737602069 0.0
circle c -18.339655323916 20.849340929486 0.0 48.019394466707
set info1 [extrema c s]
if {[regexp "ext" ${info1}] != 1} {
puts "Error : No intersection detected"
} else {
puts "OK: Intersection are detected"
}
# Distance check
set info2 [dump ext_1]
regexp "Parameters : 0 +(\[-0-9*\.+eE\]+)" $info2 full extLength
if { ${extLength} > $tol_abs } {
puts "Error: bad distance poins obtained"
} else {
puts "OK: good distance between obtained points"
}

View File

@@ -1,28 +0,0 @@
puts "============"
puts "OCC30217_3"
puts "============"
puts ""
#########################################################################
# Intersection between a circle and a line not detected (3d)
#########################################################################
set tol_abs 2.e-7
drseg s -31.501464018476 67.029737602069 -10.0 -31.501464018476 67.029737602069 0.0
circle c -18.339655323916 20.849340929486 0.0 48.019394466707
set info1 [extrema c s]
if {[regexp "ext" ${info1}] != 1} {
puts "Error : No intersection detected"
} else {
puts "OK: Intersection are detected"
}
# Distance check
set infoext1 [dump ext_1]
regexp "Parameters : 0 +(\[-0-9*\.+eE\]+)" $infoext1 full ext1Length ext2Length
if { $ext1Length > $tol_abs || $ext2Length > $tol_abs } {
puts "Error: bad distance poins obtained"
} else {
puts "OK: good distance between obtained points"
}

View File

@@ -1,20 +0,0 @@
puts "============"
puts "OCC30217_4"
puts "============"
puts ""
#########################################################################
# Intersection between a circle and a line not detected (3d)
#########################################################################
set ExpDist 5
circle c1 0 0 0 0 0 1 5
line c2 0 0 0 0 0 1
trim c2 c2 -1 -5e-8
regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c1 c2] full aDist1
checkreal Distance $aDist1 $ExpDist 1.0e-7 0.0
regexp {Infinite number of extremas, distance = +([-0-9.+eE]+)} [extrema c2 c1] full aDist2
checkreal Distance $aDist2 $ExpDist 1.0e-7 0.0

View File

@@ -0,0 +1,30 @@
puts "================================"
puts "OCC33080: Wrong projection point"
puts "================================"
puts ""
restore [locate_data_file bug33080.brep] a
set log [projface a -0.21115 1.17515 1.4504]
regexp {n0 1 Distance ([0-9+-.eE]*)} $log full dist
if { $dist > 0.1240364 } {
puts "Error distance: projection is wrong"
}
regexp {U = ([0-9+-.eE]*)} $log full uparam
if { $uparam < 869.174321 || $uparam > 869.174322 } {
puts "Error point: projection is wrong"
}
regexp {V = ([0-9+-.eE]*)} $log full vparam
if { $vparam < 732.602489 || $vparam > 732.602490 } {
puts "Error point: projection is wrong"
}
if {![regexp "Found 1 Points" $log]} {
puts "Error number of points: projection is wrong"
}

23
tests/bugs/step/bug33053 Normal file
View File

@@ -0,0 +1,23 @@
puts "===================================="
puts "0033053: Data Exchange, Step Export - Compound with vertex is ignored"
puts "===================================="
puts ""
pload OCAF
Close D_orig -silent
Close D_comp -silent
ReadStep D_orig [locate_data_file bug33053_shapes_2d.stp]
WriteStep D_orig $imagedir/${casename}_D.stp
ReadStep D_comp $imagedir/${casename}_D.stp
file delete $imagedir/${casename}_D.stp
XGetOneShape orig D_orig
XGetOneShape comp D_comp
checkshape comp
checknbshapes orig -ref [nbshapes comp]

32
tests/bugs/step/bug33095 Normal file
View File

@@ -0,0 +1,32 @@
puts "======="
puts "0033095: Data Exchange, Step Import - Wrong PMI values when loading a *.stp file in m"
puts "======="
pload OCAF
catch { Close D_mm }
catch { Close D_m }
# Read file in mm
ReadStep D_mm [locate_data_file bug33095_cad_with_pmi.stp]
set plusMinusTol_mm [XGetDimensionPlusMinusTol D_mm 0:1:4:77]
# Read file in m
XNewDoc D_m
XSetLengthUnit D_m m
ReadStep D_m [locate_data_file bug33095_cad_with_pmi.stp]
set plusMinusTol_m [XGetDimensionPlusMinusTol D_m 0:1:4:77]
# Checking
regexp {lower +([-0-9.+eE]+) +upper +([-0-9.+eE]+)} $plusMinusTol_m full lower_m upper_m
regexp {lower +([-0-9.+eE]+) +upper +([-0-9.+eE]+)} $plusMinusTol_mm full lower_mm upper_mm
set lower_m_to_mm [expr {$lower_m * 1000}]
set upper_m_to_mm [expr {$upper_m * 1000}]
if {[expr {abs($lower_m_to_mm - $lower_mm)}] > 1e-2} {
puts "Error: incorrect scaling lower toleranse value"
}
if {[expr {abs($upper_m_to_mm - $upper_mm)}] > 1e-2} {
puts "Error: incorrect scaling upper toleranse value"
}

15
tests/bugs/xde/bug33100 Normal file
View File

@@ -0,0 +1,15 @@
puts "0033100: Modeling Algorithms - XCAFDoc_Editor::RescaleGeometry does not rescale triangulations"
pload DCAF
Close d -silent
ReadStep d [locate_data_file "bug33100_window.step"]
XGetOneShape a d
set ref_diag [eval distpp [bounding a]]
XRescaleGeometry d 1000
XGetOneShape a d
set diag [eval distpp [bounding a]]
checkreal "bounding box diagonal" $diag [expr $ref_diag * 1000] 0 0.001

Some files were not shown because too many files have changed in this diff Show More