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

Compare commits

..

20 Commits

Author SHA1 Message Date
akaftasev
9d78134ce9 0033450: Modeling algorithm - HLR algorightm stucks
Selecting the middle point between XInf and XSup leads situation, where X values almost does not change.
To prevent this situation, select shifted point instead of middle.
2023-09-04 12:09:19 +01:00
dpasukhi
8f4cd4793a TL: OCC preprocessing fail (#354)
Fixed problem with empty edge list in the edge loop.
2023-01-11 11:29:08 +00:00
jgv
4bdfdea4cb Cherry-pick from CR32747 2022-01-10 12:41:25 +03:00
jgv
e72c88f15c Correction for successful compilation 2021-12-27 10:20:13 +03:00
gka
e54df8ac57 0029269: Improvement for thread safety of the STEP translator
Modification for loading a few STEP files in the model.
Protected by Mutex
1. Loading STEP file in the model with using yacc and lex.
2. Message management
3. Registration in static structure Interface_GeneralLib, Interface_ReaderLib, Interface_Writer_Lib for each StepData_Procotol.

Modifications:
STEPControl_Controller, STEPCAFControl_Controller were created as not static objects when STEPControl_Reader or STEP_Control_Writes were initialized.
Parameters used for translation from Interface::Static were made not static. Map to keep parameters was added in the Interface::InterfaceModel. For STEP translation parameters were initialized during initializing STEPData_STEPModel. model.
Static variables were removed.
Redundant classes were removed from STEP translator.

# Conflicts:
#	src/RWStepVisual/RWStepVisual_RWPresentationLayerAssignment.cxx
#	src/StepAP214/StepAP214_Protocol.cxx
#	src/StepData/StepData_StepReaderData.cxx
#	src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx
#	tests/de/step_1/R9
2020-10-01 19:32:05 +03:00
osa
3a24d5e81c Update scripts occ_build_prods_wasm.bat and occ_build_prods_wasm.sh to build using latest Emscripten 2020-07-24 15:43:43 +03:00
Igor Khozhanov
dd62ec9e70 0031550: Data Exchange, STEP Import - surface transparency is ignored (SURFACE_STYLE_TRANSPARENT)
Implemented reading and writing transparency to/from step files
2020-06-01 14:52:40 +03:00
msv
b3a1dc7c7f Add batch files for cmake build 2020-04-01 22:04:21 +03:00
kgv
80c4c42abd 0031467: Foundation Classes, OSD_MemInfo - disable reading /proc/%d/status with Emscripten
OSD_MemInfo::Update() no more uses procfs with Emscripten.
OSD_MemInfo::MemVirtual counter is now set to WebAssembly module heap length.
2020-04-01 19:37:04 +03:00
nds
eeeb58738f 0030904: Visualization - OSD_MemInfo provide Update with parameter of computation kind
Added method OSD_MemInfo::SetActive() for disabling specific counter.
2020-04-01 19:36:34 +03:00
oan
8247e04688 0031378: Modeling algorithms - brep incremental mesh is frozen during STEP file loading
Refactoring of BRepMesh_Delaun::isBoundToFrontier() to unwind the recursion loop.
2020-03-31 20:23:17 +03:00
osa
5f16893ffb Add building of visualization packages and required FreeType path to .bat files (for wasm) 2020-03-27 10:42:31 +03:00
kgv
716fd8e08e 0031079: Visualization - embed minimal fallback font
Font_FTFont::FindAndCreate() now loads embedded fallback font within Font_StrictLevel_Any level.
Font_FontMgr::FindFont() - fixed misprint in message, and customized message for range fallback error.
Font_FontMgr - added one more fallback Korean font for Linux.

vfont command has been extended with options to clear Font Manager content.
2020-03-27 10:42:31 +03:00
bugmaster
1523a69d88 Update service files for Viewer wasm 2020-02-05 12:18:57 +03:00
osa
c2fc2f376d 0031295: Foundation Classes, BVH_Tools - incorrect detection of ray-box intersection 2020-01-13 15:08:29 +03:00
msv
068969acef 0031292: Data Exchange - SIGSEGV on reading STEP file with references to invalid entities
Changes:

- in StepData_StepReaderData::ReadEntity, make sure that entity handle is not null before calling IsKind() of it.

- in StepData_StepReaderData::SetEntityNumbers, do not invert the sign of entity number of referenced parameter if the second pass is not required. Otherwise, the number -1 (obviously invalid) becomes 1 (invalid, but not obviously) without further correction of it.

- in StepData_UndefinedEntity::ReadRecord, consider the case when the entity number is positive but refers to non-existing entity. In this case literal value will be used instead of null entity for the problematic parameter.
2020-01-10 22:28:48 +03:00
osa
56609574c6 0031186: Foundation Classes - add additional useful methods to BVH_Box.
Add Transform() and Transformed() methods by Mat4 for BVH_Box (only for 3D dimension).
Add PointBoxProjection() method to project point to box and RayBoxIntersection() method to compute hit time of ray-box intersection to BVH_Tools.
Add BVH_Ray class to define ray object.
2019-11-26 18:03:47 +03:00
osa
0154021f86 Add occ_build_occt_wasm.bat to build OCCT by Emscripten 2019-11-19 12:57:40 +03:00
kgv
48839a4046 0031070: Configuration - fix building issues when using Emscripten toolchain
Handled __EMSCRIPTEN__ macros to:
- Workaround atomics (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is undefined, but GCC atomics are provided).
- Suppress non-standard header <sys/signal.h> warning.
- Return OSD_LinuxREDHAT.
- Avoid inclusion of XLib headers.
- Skip fontconfig library.
- Enable EGL+GLES path (translated by Emscripten into WebGL).
- Skip eglCreatePbufferSurface() not implemented by Emscripten EGL.

Fixed Graphic3d_Vec4.hxx usage within Quantity_ColorRGBA.hxx.

OpenGl_ShaderManager::defaultGlslVersion() now prefers GLSL 300 es when WebGL 2.0 is available,
as there no any OpenGL ES greater than 3.0 emulation so far.

Shaders_Declarations.glsl - added workaround for GLSL compilation on WebGL 1.0
by defining Light properties accessors as macros instead of functions
('[]' : Index expression must be constant).

OpenGl_FrameBuffer::Init() - added workaround for initialization of GL_DEPTH24_STENCIL8
depth-stencil attachment on WebGL 1.0 + GL_WEBGL_depth_texture extension.

OpenGl_Context::Vec4FromQuantityColor() now considers myIsSRgbActive flag
to handle use case, when Immediate Layer is drawn directly into window buffer,
which is not sRGB-ready.

Added new sample - OCCT WebGL viewer.
2019-11-01 10:09:17 +03:00
msv
48b498d4e1 Temporary fix for 0029872: Express Mesh - instrument the algorithm with progress indicator
Make ProgressSentry thread safe. It will update indicator only when it is executed in the thread where it was created.
2019-10-04 13:49:28 +03:00
1059 changed files with 14067 additions and 20372 deletions

5
.gitignore vendored
View File

@@ -46,7 +46,6 @@ Release
/*.am
/*.m4
/*.ac
/*.sh
/codeblocks.bat
/custom.bat
/autom4te.cache
@@ -59,3 +58,7 @@ Release
/stamp*
/build*
/install
env_custom.bat
env_custom.sh
cmake_gen_custom.bat
cmake_gen_custom.sh

View File

@@ -108,7 +108,6 @@ else()
elseif (ANDROID)
set (CSF_ThreadLibs "c")
set (CSF_OpenGlLibs "EGL GLESv2")
set (CSF_androidlog "log")
elseif (UNIX)
set (CSF_ThreadLibs "pthread rt stdc++")
if (USE_GLES2)

View File

@@ -12,12 +12,18 @@ macro (OCCT_CHECK_AND_UNSET VARNAME)
endif()
endmacro()
macro (OCCT_CHECK_AND_UNSET_GROUP GROUPNAME)
get_cmake_property(VARS VARIABLES)
string (REGEX MATCHALL "(^|;)${GROUPNAME}[A-Za-z0-9_]*" GROUPNAME_VARS "${VARS}")
foreach(GROUPNAME_VAR ${GROUPNAME_VARS})
OCCT_CHECK_AND_UNSET(${GROUPNAME_VAR})
endforeach()
macro (OCCT_CHECK_AND_UNSET_GROUP VARNAME)
OCCT_CHECK_AND_UNSET ("${VARNAME}_DIR")
OCCT_CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY_DIR")
if (WIN32)
OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL")
OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL_DIR")
endif()
endmacro()
macro (OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS)

View File

@@ -1419,9 +1419,6 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
set aFrmsMap(CSF_TclTkLibs) "Tk"
set aLibsMap(CSF_TclTkLibs) ""
set aLibsMap(CSF_QT) "QtCore QtGui"
} elseif { "$theOS" == "android" } {
set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
set aLibsMap(CSF_androidlog) "log"
} else {
set aLibsMap(CSF_fontconfig) "fontconfig"
if { "$theOS" == "qnx" } {

37
cmake_gen.bat Normal file
View File

@@ -0,0 +1,37 @@
@echo off
setlocal
if exist "%~dp0cmake_gen_custom.bat" call "%~dp0cmake_gen_custom.bat"
if "%VS%"=="" set VS=14
if "%VSDATA%"=="" set VSDATA=2015
if "%VSPLATFORM%"=="" set VSPLATFORM=Win64
if "%BUILD_DIR%"=="" set BUILD_DIR=build
if "%OCCT3RDPARTY%"=="" set "OCCT3RDPARTY=%~dp0..\3rdparty"
if "%INSTALL_DIR%"=="" set "INSTALL_DIR=%~dp0install"
set BUILD_DOC=OFF
set USE_FPE_SIGNAL=ON
set USE_OCCT_DEBUG=OFF
set USE_FREEIMAGE=OFF
set USE_TBB=ON
set USE_VTK=OFF
set USE_PCH=OFF
if not "%VSPLATFORM%"=="" set "arch_compile=Visual Studio %VS% %VSDATA% %VSPLATFORM%"
if "%VSPLATFORM%"=="" set "arch_compile=Visual Studio %VS% %VSDATA%"
set "INSTALL_DIR=%INSTALL_DIR:\=/%"
set "OCCT3RDPARTY=%OCCT3RDPARTY:\=/%"
if not exist %BUILD_DIR% mkdir %BUILD_DIR%
cd %BUILD_DIR%
cmake -G "%arch_compile%" -D3RDPARTY_DIR:STRING=%OCCT3RDPARTY% ^
-DBUILD_DOC_Overview:BOOL=%BUILD_DOC% -DINSTALL_DIR:STRING=%INSTALL_DIR% ^
-DBUILD_WITH_DEBUG:BOOL=%USE_OCCT_DEBUG% -DBUILD_ENABLE_FPE_SIGNAL_HANDLER:BOOL=%USE_FPE_SIGNAL% ^
-DUSE_FREEIMAGE:BOOL=%USE_FREEIMAGE% ^
-DUSE_TBB:BOOL=%USE_TBB% -DUSE_VTK:BOOL=%USE_VTK% -DBUILD_USE_PCH:BOOL=%USE_PCH% ^
..
endlocal

36
cmake_gen.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
if [ -f cmake_gen_custom.sh ]; then
. cmake_gen_custom.sh
fi
DEB=
if [ -z "$BUILD_DIR" ]; then BUILD_DIR=build; fi
if [ -z "$GENERATOR" ]; then GENERATOR="Unix Makefiles"; fi
if [ -z "$OCCT3RDPARTY" ]; then OCCT3RDPARTY=`pwd`/../3rdparty; fi
if [ -z "$INSTALL_DIR" ]; then INSTALL_DIR=$OCCT3RDPARTY/occt740; fi
if [ -z "$FREETYPE_DIR" ]; then FREETYPE_DIR=$OCCT3RDPARTY/freetype-2.7.1; fi
CMAKE_BUILD_TYPE=Release
if [ "$1" = "-d" ]; then
DEB=d
BUILD_DIR=${BUILD_DIR}-deb
BUILD_TYPE=Debug
fi
if [ -z "$USE_TBB" ]; then USE_TBB=ON; fi
if [ -z "$DIR_BIN" ]; then DIR_BIN=lin64/gcc/bin$DEB; fi
if [ -z "$DIR_LIB" ]; then DIR_LIB=lin64/gcc/lib$DEB; fi
USE_FPE_SIGNAL=ON
BUILD_DOC=OFF
if [ ! -d $BUILD_DIR ]; then mkdir $BUILD_DIR; fi
cd $BUILD_DIR
cmake -G "$GENERATOR" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DINSTALL_DIR_BIN:STRING=$DIR_BIN \
-DINSTALL_DIR_LIB:STRING=$DIR_LIB -D3RDPARTY_DIR:STRING=$OCCT3RDPARTY \
-DINSTALL_DIR_LAYOUT:STRING=Windows -DINSTALL_DIR:STRING=$INSTALL_DIR \
-DBUILD_ENABLE_FPE_SIGNAL_HANDLER:BOOL=$USE_FPE_SIGNAL -DUSE_TBB:BOOL=$USE_TBB \
-D3RDPARTY_FREETYPE_DIR:PATH=$FREETYPE_DIR -DBUILD_DOC_Overview:BOOL=$BUILD_DOC \
$AUX_ARGS ..

View File

@@ -0,0 +1,8 @@
rem Copy this file to cmake_gen_custom.bat and tune to your local needs
set "OCCT3RDPARTY=%~dp0..\3rdparty"
set "INSTALL_DIR=%~dp0install"
set BUILD_DIR=build
set VS=14
set VSDATA=2015
set VSPLATFORM=Win64

View File

@@ -0,0 +1,9 @@
# Copy this file to cmake_gen_custom.sh and tune to your local needs
OCCT3RDPARTY=`pwd`/../3rdparty
INSTALL_DIR=$OCCT3RDPARTY/occt740
BUILD_DIR=build
FREETYPE_DIR=$OCCT3RDPARTY/freetype-2.7.1
# This is to avoid cmake DEV warnings about TCL
AUX_ARGS=-Wno-dev

View File

@@ -1857,34 +1857,3 @@ The following API changes have been made:
@subsection upgrade_740_stdnamespace Standard_Stream.hxx no more has "using std::" statements
*Standard_Stream.hxx* header, commonly included by other OCCT header files, does no more add entities from *std namespace* related to streams (like *std::cout*, *std::istream* and others) into global namespace.
The application code relying on this matter should be updated to either specify std namespace explicitly (like std::cout) or add "using std::" statements locally.
@section upgrade_occt750 Upgrade to OCCT 7.5.0
@subsection upgrade_750_srgb_color RGB color definition
OCCT 3D Viewer has been improved to properly perform lighting using in linear RGB color space and then convert result into non-linear gamma-shifted sRGB color space before displaying on display.
This change affects texture mapping, material definition and color definition.
Previously *Quantity_Color* definition was provided with unspecified RGB color space.
In practice, mixed color spaces have been actually used, with non-linear sRGB prevailing in general.
Since OCCT 7.5.0, *Quantity_Color* now specifies that components are defined in linear RGB color space.
This change affects following parts:
* Standard colors defined by *Quantity_NameOfColor* enumeration have been converted into linear RGB values within Quantity_Color construction.
* Application may use new enumeration value *Quantity_TOC_sRGB* for passing/fetching colors in sRGB color space,
which can be useful for interoperation with color picking widgets (returning 8-bit integer values within [0..255] range)
or for porting colors constants within old application code without manual conversion.
* *Graphic3d_MaterialAspect* color components are now expected in linear RGB color space,
and standard OCCT materials within *Graphic3d_NameOfMaterial* enumeration have been updated accordingly.
* Texture mapping now handles new *Graphic3d_TextureRoot::IsColorMap()* for interpreting content in linear RGB or sRGB color space.
It is responsibility of user specifying this flag correctly. The flag value is TRUE by default.
* Method *Image_PixMap::PixelColor()* has been extended with a new Boolean flag for performing linearization of non-linear sRGB.
This flag is FALSE by default; application should consider passing TRUE instead for further handling *Quantity_Color* properly as linear RGB values.
@subsection upgrade_750_aspectwindow Aspect_Window interface change
Unexpected const-ness of Aspect_Window::DoResize() method has been removed, so that application classes implementing this interface should be updated accordingly.
@subsection upgrade_750_rename Renaming of types
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.

19
env_custom.bat.template Normal file
View File

@@ -0,0 +1,19 @@
set aNbJobs=%NUMBER_OF_PROCESSORS%
set "aFreeType=%~dp0..\3rdparty\freetype-2.7.1-wasm"
set "EMSDK_ROOT=%~dp0..\occ-web3d\fips\fips-sdks\emsdk"
set "PATH=C:\Program Files\CMake\bin;%PATH%"
set "aBuildRoot=work"
set "toCMake=1"
set "toClean=0"
set "toMake=1"
set "toInstall=1"
set "toPack=0"
set BUILD_AppFramework=OFF
set BUILD_DataExchange=OFF
set BUILD_Draw=OFF
set BUILD_FndClasses=ON
set BUILD_ModAlg=OFF
set BUILD_ModData=OFF
set BUILD_Viz=ON

18
env_custom.sh.template Normal file
View File

@@ -0,0 +1,18 @@
export aNbJobs=${NUMBER_OF_PROCESSORS}
export aFreeType=$PWD/../3rdparty/freetype-2.7.1-wasm
export EMSDK_ROOT=`pwd`/fips/fips-sdks/emsdk
export aBuildRoot=work
export toCMake=1
export toClean=0
export toMake=1
export toInstall=1
export toPack=0
export BUILD_AppFramework=OFF
export BUILD_DataExchange=OFF
export BUILD_Draw=OFF
export BUILD_FndClasses=ON
export BUILD_ModAlg=OFF
export BUILD_ModData=OFF
export BUILD_Viz=ON

154
occ_build_occt_wasm.bat Normal file
View File

@@ -0,0 +1,154 @@
@echo OFF
rem Auxiliary script for semi-automated building of OCCT for WASM platform.
rem Script should be placed into root of OCCT repository, edited with paths
rem to CMake, 3rd-parties and Emscripten SDK.
rem FreeType and RapidJSON should be specified as mandatory dependency (should be manually build or taken from earlier builds).
set "aCasSrc=%~dp0"
if exist env_custom.bat call env_custom.bat
call "%EMSDK_ROOT%\emsdk_env.bat"
set "aToolchain=%EMSDK%/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
set "anOcctVerSuffix="
set "anOcctVersion=0.0.0"
set "aGitBranch="
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_DEVELOPMENT" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVerSuffix=%%i" )
for /f tokens^=2^ delims^=^" %%i in ('findstr /b /c:"#define OCC_VERSION_COMPLETE" "%aCasSrc%\src\Standard\Standard_Version.hxx"') do ( set "anOcctVersion=%%i" )
for /f %%i in ('git symbolic-ref --short HEAD') do ( set "aGitBranch=%%i" )
call :cmakeGenerate
if not ["%1"] == ["-nopause"] (
pause
)
goto :eof
:cmakeGenerate
set "aPlatformAndCompiler=wasm"
set "aWorkDir=%~dp0%aBuildRoot%\%aPlatformAndCompiler%-make"
set "aDestDir=%~dp0%aBuildRoot%\%aPlatformAndCompiler%"
set "aLogFile=%~dp0build-%aPlatformAndCompiler%.log"
if not exist "%aWorkDir%" ( mkdir "%aWorkDir%" )
if exist "%aLogFile%" ( del "%aLogFile%" )
rem include some information about OCCT into archive
echo ^<pre^>> "%aWorkDir%\VERSION.html"
git status >> "%aWorkDir%\VERSION.html"
git log -n 100 >> "%aWorkDir%\VERSION.html"
echo ^</pre^>>> "%aWorkDir%\VERSION.html"
echo Start building OCCT for %aPlatformAndCompiler%
echo Start building OCCT for %aPlatformAndCompiler%>> %aLogFile%
pushd "%aWorkDir%"
set aTimeZERO=%TIME%
if ["%toCMake%"] == ["1"] (
echo "Configuring OCCT for WASM..."
cmake -G "MinGW Makefiles" ^
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="%aToolchain%" ^
-D CMAKE_BUILD_TYPE:STRING="Release" ^
-D BUILD_LIBRARY_TYPE:STRING="Static" ^
-D INSTALL_DIR:PATH="%aDestDir%" ^
-D INSTALL_DIR_INCLUDE:STRING="inc" ^
-D INSTALL_DIR_RESOURCE:STRING="src" ^
-D 3RDPARTY_FREETYPE_DIR:PATH="%aFreeType%" ^
-D 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2:FILEPATH="%aFreeType%/include" ^
-D 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build:FILEPATH="%aFreeType%/include" ^
-D BUILD_MODULE_ApplicationFramework:BOOL="%BUILD_AppFramework%" ^
-D BUILD_MODULE_DataExchange:BOOL="%BUILD_DataExchange%" ^
-D BUILD_MODULE_Draw:BOOL="%BUILD_Draw%" ^
-D BUILD_MODULE_FoundationClasses:BOOL="%BUILD_FndClasses%" ^
-D BUILD_MODULE_ModelingAlgorithms:BOOL="%BUILD_ModAlg%" ^
-D BUILD_MODULE_ModelingData:BOOL="%BUILD_ModData%" ^
-D BUILD_MODULE_Visualization:BOOL="%BUILD_Viz%" ^
-D BUILD_DOC_Overview:BOOL="OFF" ^
"%aCasSrc%"
if errorlevel 1 (
popd
pause
exit /B
goto :eof
)
)
set aTimeGEN=%TIME%
call :computeDuration %aTimeZERO% %aTimeGEN%
if ["%toCMake%"] == ["1"] (
echo Generation time: %DURATION%
echo Generation time: %DURATION%>> %aLogFile%
)
if "%toClean%"=="1" (
mingw32-make clean
)
if "%toMake%"=="1" (
echo Building...
mingw32-make -j %aNbJobs% 2>> %aLogFile%
if errorlevel 1 (
popd
pause
exit /B
goto :eof
)
type %aLogFile%
)
set aTimeBUILD=%TIME%
call :computeDuration %aTimeGEN% %aTimeBUILD%
if "%toMake%"=="1" (
echo Building time: %DURATION%
echo Building time: %DURATION%>> %aLogFile%
)
call :computeDuration %aTimeZERO% %aTimeBUILD%
if "%toMake%"=="1" (
echo Total building time: %DURATION%
echo Total building time: %DURATION%>> %aLogFile%
)
if "%toInstall%"=="1" (
echo Installing into %aDestDir%...
mingw32-make install 2>> %aLogFile%
copy /Y "%aWorkDir%\VERSION.html" "%aDestDir%\VERSION.html"
)
set aTimeINSTALL=%TIME%
call :computeDuration %aTimeBUILD% %aTimeINSTALL%
if "%toInstall%"=="1" (
echo Install time: %DURATION%
echo Install time: %DURATION%>> %aLogFile%
)
call :computeDuration %aTimeZERO% %aTimeINSTALL%
echo Total time: %DURATION%
echo Total time: %DURATION%>> %aLogFile%
popd
goto :eof
:computeDuration
set aTimeFrom=%1
set aTimeEnd=%2
rem handle time before 10AM (win10 - remove empty space at the beginning)
if "%aTimeFrom:~0,1%"==" " set "aTimeFrom=%aTimeFrom:~1%"
if "%aTimeEnd:~0,1%"==" " set "aTimeEnd=%aTimeEnd:~1%"
rem handle time before 10AM (win7 - add 0 at the beginning)
if "%aTimeFrom:~1,1%"==":" set "aTimeFrom=0%aTimeFrom%"
if "%aTimeEnd:~1,1%"==":" set "aTimeEnd=0%aTimeEnd%"
rem convert hours:minutes:seconds:ms into duration
set /A aTimeFrom=(1%aTimeFrom:~0,2%-100)*360000 + (1%aTimeFrom:~3,2%-100)*6000 + (1%aTimeFrom:~6,2%-100)*100 + (1%aTimeFrom:~9,2%-100)
set /A aTimeEnd= (1%aTimeEnd:~0,2%-100)*360000 + (1%aTimeEnd:~3,2%-100)*6000 + (1%aTimeEnd:~6,2%-100)*100 + (1%aTimeEnd:~9,2%-100)
set /A aDurTotalSec=%aTimeEnd%-%aTimeFrom%
if %aTimeEnd% LSS %aTimeFrom% set set /A aDurTotalSec=%aTimeFrom%-%aTimeEnd%
set /A aDurHH=%aDurTotalSec% / 360000
set /A aDurMM=(%aDurTotalSec% - %aDurHH%*360000) / 6000
set /A aDurSS=(%aDurTotalSec% - %aDurHH%*360000 - %aDurMM%*6000) / 100
if %aDurHH% LSS 10 set aDurHH=0%aDurHH%
if %aDurMM% LSS 10 set aDurMM=0%aDurMM%
if %aDurSS% LSS 10 set aDurSS=0%aDurSS%
set "DURATION=%aDurHH%:%aDurMM%:%aDurSS%"
goto :eof

117
occ_build_occt_wasm.sh Executable file
View File

@@ -0,0 +1,117 @@
#!/bin/bash
# Auxiliary script for semi-automated building of OCCT for WASM platform.
# Script should be placed into root of OCCT repository, edited with paths
# to CMake, 3rd-parties and Emscripten SDK.
# FreeType and RapidJSON should be specified as mandatory dependency (should be manually build or taken from earlier builds).
export aCasSrc="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ -f ${aCasSrc}/env_custom.sh ] ; then
. ${aCasSrc}/env_custom.sh
fi
if [ ! -d "${aBuildRoot}" ] ; then
mkdir -p "${aBuildRoot}"
else
rm -rf "${aBuildRoot}"
mkdir -p "${aBuildRoot}"
fi
. ${EMSDK_ROOT}/emsdk_env.sh
export aToolchain="${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
export aGitBranch=`git symbolic-ref --short HEAD`
echo "Compilation OCCT branch : $aGitBranch"
export aPlatformAndCompiler=wasm
export aWorkDir=${aCasSrc}/${aBuildRoot}/${aPlatformAndCompiler}-make
if [ ! -d "${aWorkDir}" ] ; then
mkdir "${aWorkDir}"
fi
export aDestDir=${aCasSrc}/${aBuildRoot}/${aPlatformAndCompiler}
if [ ! -d "${aDestDir}" ];then
mkdir "${aDestDir}"
fi
export aLogFile=${aCasSrc}/${aBuildRoot}/build-${aPlatformAndCompiler}.log
if [ ! -f "${aLogFile}" ];then
touch "${aLogFile}"
fi
echo Start building OCCT for ${aPlatformAndCompiler}
echo Start building OCCT for ${aPlatformAndCompiler}>> ${aLogFile}
cd ${aWorkDir}
pwd
echo toCMake=${toCMake}
if [ "${toCMake}" = "1" ] ; then
echo "Configuring OCCT for WASM..."
echo cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE:FILEPATH="${aToolchain}" \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DBUILD_LIBRARY_TYPE:STRING="Static" \
-DINSTALL_DIR:PATH="${aDestDir}" \
-DINSTALL_DIR_INCLUDE:STRING="inc" \
-DINSTALL_DIR_RESOURCE:STRING="src" \
-D3RDPARTY_FREETYPE_DIR:PATH="$aFreeType" \
-D3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2:FILEPATH="$aFreeType/include" \
-D3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build:FILEPATH="$aFreeType/include" \
-DBUILD_MODULE_ApplicationFramework:BOOL="${BUILD_AppFramework}" \
-DBUILD_MODULE_DataExchange:BOOL="${BUILD_DataExchange}" \
-DBUILD_MODULE_Draw:BOOL="${BUILD_Draw}" \
-DBUILD_MODULE_FoundationClasses:BOOL="${BUILD_FndClasses}" \
-DBUILD_MODULE_ModelingAlgorithms:BOOL="${BUILD_ModAlg}" \
-DBUILD_MODULE_ModelingData:BOOL="${BUILD_ModData}" \
-DBUILD_MODULE_Visualization:BOOL="${BUILD_Viz}" \
-DBUILD_DOC_Overview:BOOL="OFF" "${aCasSrc}"
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE:FILEPATH="${aToolchain}" \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DBUILD_LIBRARY_TYPE:STRING="Static" \
-DINSTALL_DIR:PATH="${aDestDir}" \
-DINSTALL_DIR_INCLUDE:STRING="inc" \
-DINSTALL_DIR_RESOURCE:STRING="src" \
-D3RDPARTY_FREETYPE_DIR:PATH="$aFreeType" \
-D3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2:FILEPATH="$aFreeType/include" \
-D3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build:FILEPATH="$aFreeType/include" \
-DBUILD_MODULE_ApplicationFramework:BOOL="${BUILD_AppFramework}" \
-DBUILD_MODULE_DataExchange:BOOL="${BUILD_DataExchange}" \
-DBUILD_MODULE_Draw:BOOL="${BUILD_Draw}" \
-DBUILD_MODULE_FoundationClasses:BOOL="${BUILD_FndClasses}" \
-DBUILD_MODULE_ModelingAlgorithms:BOOL="${BUILD_ModAlg}" \
-DBUILD_MODULE_ModelingData:BOOL="${BUILD_ModData}" \
-DBUILD_MODULE_Visualization:BOOL="${BUILD_Viz}" \
-DBUILD_DOC_Overview:BOOL="OFF" "${aCasSrc}"
if [ $? -ne 0 ] ; then
echo "Problem during configuration"
exit 1
fi
fi
if [ "${toClean}" = "1" ] ; then
make clean
fi
if [ "${toMake}" = "1" ] ; then
echo Building...
make -j ${aNbJobs} 2>> ${aLogFile}
if [ $? -ne 0 ] ; then
echo "Problem during make operation"
exit 1
fi
echo ${aLogFile}
fi
if [ "${toInstall}" = "1" ] ; then
echo Installing into ${aDestDir}
make install 2>> ${aLogFile}
fi

View File

@@ -35,49 +35,13 @@
#include <GLFW/glfw3.h>
namespace
{
//! Convert GLFW mouse button into Aspect_VKeyMouse.
static Aspect_VKeyMouse mouseButtonFromGlfw (int theButton)
{
switch (theButton)
{
case GLFW_MOUSE_BUTTON_LEFT: return Aspect_VKeyMouse_LeftButton;
case GLFW_MOUSE_BUTTON_RIGHT: return Aspect_VKeyMouse_RightButton;
case GLFW_MOUSE_BUTTON_MIDDLE: return Aspect_VKeyMouse_MiddleButton;
}
return Aspect_VKeyMouse_NONE;
}
//! Convert GLFW key modifiers into Aspect_VKeyFlags.
static Aspect_VKeyFlags keyFlagsFromGlfw (int theFlags)
{
Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
if ((theFlags & GLFW_MOD_SHIFT) != 0)
{
aFlags |= Aspect_VKeyFlags_SHIFT;
}
if ((theFlags & GLFW_MOD_CONTROL) != 0)
{
aFlags |= Aspect_VKeyFlags_CTRL;
}
if ((theFlags & GLFW_MOD_ALT) != 0)
{
aFlags |= Aspect_VKeyFlags_ALT;
}
if ((theFlags & GLFW_MOD_SUPER) != 0)
{
aFlags |= Aspect_VKeyFlags_META;
}
return aFlags;
}
}
// ================================================================
// Function : GlfwOcctView
// Purpose :
// ================================================================
GlfwOcctView::GlfwOcctView()
: myCurAction3d (CurAction3d_Nothing),
myToRedraw (true)
{
}
@@ -229,7 +193,15 @@ void GlfwOcctView::mainloop()
glfwWaitEvents();
if (!myView.IsNull())
{
FlushViewEvents (myContext, myView, true);
if (myView->IsInvalidated())
{
myView->Redraw();
}
else if (myToRedraw)
{
myView->RedrawImmediate();
}
myToRedraw = false;
}
}
}
@@ -265,6 +237,7 @@ void GlfwOcctView::onResize (int theWidth, int theHeight)
myView->MustBeResized();
myView->Invalidate();
myView->Redraw();
//myToRedraw = true;
}
}
@@ -274,10 +247,13 @@ void GlfwOcctView::onResize (int theWidth, int theHeight)
// ================================================================
void GlfwOcctView::onMouseScroll (double theOffsetX, double theOffsetY)
{
if (!myView.IsNull())
{
UpdateZoom (Aspect_ScrollDelta (myOcctWindow->CursorPosition(), int(theOffsetY * 8.0)));
}
if (myView.IsNull()) { return; }
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
myView->StartZoomAtPoint (aPos.x(), aPos.y());
myView->ZoomAtPoint (0, 0, int(theOffsetY * 4.0), int(theOffsetY * 4.0));
myView->Invalidate();
myToRedraw = true;
}
// ================================================================
@@ -289,13 +265,27 @@ void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
if (myView.IsNull()) { return; }
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
if (theAction == GLFW_PRESS)
if (theAction != GLFW_PRESS)
{
PressMouseButton (aPos, mouseButtonFromGlfw (theButton), keyFlagsFromGlfw (theMods), false);
myCurAction3d = CurAction3d_Nothing;
return;
}
else
myMouseMin = aPos;
myMouseMax = aPos;
switch (theButton)
{
ReleaseMouseButton (aPos, mouseButtonFromGlfw (theButton), keyFlagsFromGlfw (theMods), false);
case GLFW_MOUSE_BUTTON_RIGHT:
{
myCurAction3d = CurAction3d_DynamicRoation;
myView->StartRotation (aPos.x(), aPos.y());
break;
}
case GLFW_MOUSE_BUTTON_MIDDLE:
{
myCurAction3d = CurAction3d_DynamicPanning;
break;
}
}
}
@@ -305,9 +295,30 @@ void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
// ================================================================
void GlfwOcctView::onMouseMove (int thePosX, int thePosY)
{
const Graphic3d_Vec2i aNewPos (thePosX, thePosY);
if (!myView.IsNull())
if (myView.IsNull()) { return; }
switch (myCurAction3d)
{
UpdateMousePosition (aNewPos, PressedMouseButtons(), LastMouseFlags(), false);
case CurAction3d_DynamicRoation:
{
myView->Rotation (thePosX, thePosY);
myView->Invalidate();
myToRedraw = true;
break;
}
case CurAction3d_DynamicPanning:
{
myView->Pan (thePosX - myMouseMax.x(), -(thePosY - myMouseMax.y()));
myView->Invalidate();
myToRedraw = true;
myMouseMax.SetValues (thePosX, thePosY);
break;
}
default:
{
myContext->MoveTo (thePosX, thePosY, myView, false);
myToRedraw = true;
break;
}
}
}

View File

@@ -25,12 +25,20 @@
#include "GlfwOcctWindow.h"
#include <AIS_InteractiveContext.hxx>
#include <AIS_ViewController.hxx>
#include <V3d_View.hxx>
//! Sample class creating 3D Viewer within GLFW window.
class GlfwOcctView : protected AIS_ViewController
class GlfwOcctView
{
public:
enum CurAction3d
{
CurAction3d_Nothing,
CurAction3d_DynamicZooming,
CurAction3d_DynamicPanning,
CurAction3d_DynamicRoation
};
public:
//! Default constructor.
GlfwOcctView();
@@ -107,6 +115,11 @@ private:
Handle(V3d_View) myView;
Handle(AIS_InteractiveContext) myContext;
CurAction3d myCurAction3d;
Graphic3d_Vec2i myMouseMin;
Graphic3d_Vec2i myMouseMax;
bool myToRedraw;
};
#endif // _GlfwOcctView_Header

View File

@@ -134,17 +134,17 @@ void GlfwOcctWindow::Unmap() const
// Function : DoResize
// Purpose :
// ================================================================
Aspect_TypeOfResize GlfwOcctWindow::DoResize()
Aspect_TypeOfResize GlfwOcctWindow::DoResize() const
{
if (glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) == 1)
{
int anXPos = 0, anYPos = 0, aWidth = 0, aHeight = 0;
glfwGetWindowPos (myGlfwWindow, &anXPos, &anYPos);
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
myXLeft = anXPos;
myXRight = anXPos + aWidth;
myYTop = anYPos;
myYBottom = anYPos + aHeight;
*const_cast<Standard_Integer*>(&myXLeft ) = anXPos;
*const_cast<Standard_Integer*>(&myXRight ) = anXPos + aWidth;
*const_cast<Standard_Integer*>(&myYTop ) = anYPos;
*const_cast<Standard_Integer*>(&myYBottom) = anYPos + aHeight;
}
return Aspect_TOR_UNKNOWN;
}

View File

@@ -65,7 +65,7 @@ public:
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
//! Returns True if the window <me> is opened and False if the window is closed.
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;

View File

@@ -44,7 +44,7 @@ public:
virtual void Unmap() const Standard_OVERRIDE {}
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
//! Apply the mapping change to the window <me>
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }

View File

@@ -216,7 +216,8 @@ void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
void GeomSources::ResetView(CGeometryDoc* aDoc)
{
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveViews().First();
aDoc->GetAISContext()->CurrentViewer()->InitActiveViews();
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveView();
aView->Reset();
}

View File

@@ -68,7 +68,8 @@ void TexturesExt_Presentation::DoSample()
void TexturesExt_Presentation::Init()
{
// initialize v3d_view so it displays TexturesExt well
Handle(V3d_View) aView = getViewer()->ActiveViews().First();
getViewer()->InitActiveViews();
Handle(V3d_View) aView = getViewer()->ActiveView();
aView->SetSize(ZVIEW_SIZE);
// getDocument()->UpdateResultMessageDlg("Textured Shape",

View File

@@ -1020,7 +1020,8 @@ void CViewer3dDoc::OnDumpView()
pView->UpdateWindow();
}
Handle(V3d_View) aView = myViewer->ActiveViews().First();
myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
ExportView (aView);
}

View File

@@ -1012,61 +1012,65 @@ aParams.NbMsaaSamples = aParams.NbMsaaSamples == 0 ? 8 : 0;\n\
GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
}
void CViewer3dView::OnClearLights()
void CViewer3dView::OnClearLights()
{
// Setting Off all viewer active lights
V3d_ListOfLight lights;
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())
// Setting Off all viewer active lights
TColStd_ListOfTransient lights;
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())
{
lights.Append (anIter.Value());
lights.Append(myView->Viewer()->ActiveLight());
}
V3d_ListOfLightIterator itrLights(lights);
TColStd_ListIteratorOfListOfTransient itrLights(lights);
for (; itrLights.More(); itrLights.Next())
{
myView->Viewer()->SetLightOff (itrLights.Value());
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
myView->Viewer()->SetLightOff(light);
}
// Setting Off all view active lights
// Setting Off all view active lights
lights.Clear();
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())
{
lights.Append (anIter.Value());
lights.Append(myView->ActiveLight());
}
itrLights.Initialize (lights);
itrLights.Initialize(lights);
for (; itrLights.More(); itrLights.Next())
{
myView->SetLightOff (itrLights.Value());
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
myView->SetLightOff(light);
}
myView->Viewer()->SetDefaultLights(); // Setting the default lights on
myView->Viewer()->SetDefaultLights();// Setting the default lights on
NbActiveLights = 2; // There are 2 default active lights
NbActiveLights = 2;// There are 2 default active lights
myView->Update();
myView->Update();
TCollection_AsciiString Message("\
// Setting Off all viewer active lights\n\
V3d_ListOfLight lights;\n\
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
// Setting Off all viewer active lights\n\
TColStd_ListOfTransient lights;\n\
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())\n\
{\n\
lights.Append (anIter.Value());\n\
lights.Append(myView->Viewer()->ActiveLight());\n\
}\n\
V3d_ListOfLightIterator itrLights(lights);\n\
TColStd_ListIteratorOfListOfTransient itrLights(lights);\n\
for (; itrLights.More(); itrLights.Next())\n\
{\n\
myView->Viewer()->SetLightOff (itrLights.Value())\n\
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
myView->Viewer()->SetLightOff(light);\n\
}\n\
\n\
// Setting Off all view active lights\n\
// Setting Off all view active lights\n\
lights.Clear();\n\
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())\n\
{\n\
lights.Append (anIter.Value());\n\
lights.Append(myView->ActiveLight());\n\
}\n\
itrLights.Initialize(lights);\n\
for (; itrLights.More(); itrLights.Next())\n\
{\n\
myView->SetLightOff (itrLights.Value());\n\
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
myView->SetLightOff(light);\n\
}\n\
\n\
myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\

View File

@@ -413,7 +413,8 @@ void CTriangulationDoc::OnDumpView()
pView->UpdateWindow();
}
Handle(V3d_View) aView = myViewer->ActiveViews().First();
myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
ExportView (aView);
}

View File

@@ -230,7 +230,8 @@ void COCCDemoDoc::OnDumpView()
pView->UpdateWindow();
}
Handle(V3d_View) aView = myViewer->ActiveViews().First();
myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
ExportView (aView);
}

View File

@@ -489,7 +489,8 @@ void OCC_3dBaseDoc::OnUpdateV3dButtons (CCmdUI* pCmdUI)
// Common function to change raytracing params and redraw view
void OCC_3dBaseDoc::OnObjectRayTracingAction()
{
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveViews().First();
myAISContext->CurrentViewer()->InitActiveViews();
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveView();
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
if (myRayTracingIsOn)
aParams.Method = Graphic3d_RM_RAYTRACING;

View File

@@ -44,7 +44,7 @@ public:
virtual void Unmap() const {}
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize() { return Aspect_TOR_UNKNOWN; }
virtual Aspect_TypeOfResize DoResize() const { return Aspect_TOR_UNKNOWN; }
//! Apply the mapping change to the window <me>
virtual Standard_Boolean DoMapping() const { return Standard_True; }

View File

@@ -81,7 +81,7 @@ void OcctWindow::Unmap() const
// function : DoResize
// purpose :
// =======================================================================
Aspect_TypeOfResize OcctWindow::DoResize()
Aspect_TypeOfResize OcctWindow::DoResize() const
{
int aMask = 0;
Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
@@ -126,10 +126,10 @@ Aspect_TypeOfResize OcctWindow::DoResize()
break;
} // end switch
myXLeft = myWidget->rect().left();
myXRight = myWidget->rect().right();
myYTop = myWidget->rect().top();
myYBottom = myWidget->rect().bottom();
*( ( Standard_Integer* )&myXLeft ) = myWidget->rect().left();
*( ( Standard_Integer* )&myXRight ) = myWidget->rect().right();
*( ( Standard_Integer* )&myYTop ) = myWidget->rect().top();
*( ( Standard_Integer* )&myYBottom) = myWidget->rect().bottom();
}
return aMode;

View File

@@ -51,7 +51,7 @@ public:
virtual Aspect_Drawable NativeParentHandle() const;
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize();
virtual Aspect_TypeOfResize DoResize() const;
//! Returns True if the window <me> is opened
//! and False if the window is closed.

View File

@@ -276,7 +276,7 @@ blend result _model 2 _model_161
# Show result
pload VISUALIZATION
vinit Driver1/Viewer1/View1
vbackground -color C8C8FF
vbackground -color 0.784314 0.784314 1
vdisplay -dispMode 1 result
vfit
vaspects result -setFaceBoundaryDraw 1 -mostContinuity c2

View File

@@ -262,7 +262,7 @@ unifysamedom result p_1
# Show result
pload VISUALIZATION
vinit Driver1/Viewer1/View1
vbackground -color C8C8FF
vbackground -color 0.784314 0.784314 1
vdisplay -dispMode 1 result
vfit
vaspects result -setFaceBoundaryDraw 1

View File

@@ -68,18 +68,18 @@ vlight add directional direction 0 -10 0 head 1 color white
vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
# set colors like in boxes of on OCC logo
vsetcolor b1 DD0029
vsetcolor b2 F6DD00
vsetcolor b3 98F918
vsetcolor b4 E9007A
vsetcolor b5 007ABC
vsetcolor b6 93007A
vsetcolor b7 EE9800
vsetcolor b8 00B489
vsetcolor b9 00A47A
vsetcolor b10 007ABC
vsetcolor b1 0.8671875 0 0.16015625
vsetcolor b2 0.96484375 0.8671875 0
vsetcolor b3 0.609375 0.97734375 0.09375
vsetcolor b4 0.90234375 0 0.48046875
vsetcolor b5 0 0.48046875 0.73828125
vsetcolor b6 0.578125 0 0.48046875
vsetcolor b7 0.93359375 0.609375 0
vsetcolor b8 0 0.70703125 0.9296875
vsetcolor b9 0 0.64453125 0.48046875
vsetcolor b10 0 0.48046875 0.73828125
# set material to plastic for better look
for {set i 1} {$i <= 10} {incr i} {vsetmaterial b$i plastic}
vdrawtext label "Which\nbox\nis\ncloser\nto\nyou?" -pos 0 -6 -2 -color BLACK -halign left -valign bottom -angle 0 -zoom 0 -height 40
vdrawtext label "Which\nbox\nis\ncloser\nto\nyou?" -pos 0 -6 -2 -color 0 0 0 -halign left -valign bottom -angle 0 -zoom 0 -height 40

View File

@@ -255,27 +255,27 @@ if [info exists i7_show_3dview] {
vlight add directional direction 1 -1 -2 head 1
vdisplay case
vsetcolor case GRAY70
vsetcolor case 0.7 0.7 0.7
vdisplay title
vsetcolor title GRAY10
vsetcolor title 0.1 0.1 0.1
# board is mostly yellow (edges, triangle markers)
foreach f [explode board f] { vdisplay $f; vsetcolor $f B3803D }
foreach f [explode board f] { vdisplay $f; vsetcolor $f 0.7 0.5 0.3 }
# top and bottom faces are light-green (outside) and dark-green (inside)
vsetcolor board_4 00998C
vsetcolor board_5 00998C
vsetcolor board_12 004D54
vsetcolor board_14 004D54
vsetcolor board_4 0 0.6 0.55
vsetcolor board_5 0 0.6 0.55
vsetcolor board_12 0 0.3 0.33
vsetcolor board_14 0 0.3 0.33
vdisplay rpads
vsetcolor rpads B39966
vsetcolor rpads 0.7 0.6 0.4
vdisplay bpads
vsetcolor bpads B39966
vsetcolor bpads 0.7 0.6 0.4
vdisplay brpk
vsetcolor brpk 80664D
vsetcolor brpk 0.5 0.4 0.3
donly board case rpads brpk; fit
}
@@ -287,17 +287,17 @@ pload OCAF XDE
NewDocument D MDTV-XCAF
SetName D [XAddShape D board 0] "Board"
foreach f [explode board f] { XSetColor D $f B3803D }
XSetColor D board_4 00998C
XSetColor D board_5 00998C
XSetColor D board_12 004D54
XSetColor D board_14 004D54
foreach f [explode board f] { XSetColor D $f 0.7 0.5 0.3 }
XSetColor D board_4 0 0.6 0.55
XSetColor D board_5 0 0.6 0.55
XSetColor D board_12 0 0.3 0.33
XSetColor D board_14 0 0.3 0.33
SetName D [XAddShape D case 0] "Case"
XSetColor D case GRAY70
XSetColor D case 0.7 0.7 0.7
SetName D [XAddShape D title 0] "Case title"
XSetColor D title GRAY10
XSetColor D title 0.1 0.1 0.1
SetName D [XAddShape D rpads 1] "Top side contact pads"
SetName D [XAddShape D bpads 1] "Bottom contact pads"
@@ -306,17 +306,17 @@ SetName D [XFindShape D rpad] "Round pad"
SetName D [XFindShape D Rpad] "Big round pad"
SetName D [XFindShape D spad_1] "Square pad 1"
SetName D [XFindShape D spad_2] "Square pad 2"
XSetColor D rpad B39966
XSetColor D Rpad B39966
XSetColor D bpad B39966
XSetColor D spad_1 B39966
XSetColor D spad_2 B39966
XSetColor D rpad 0.7 0.6 0.4
XSetColor D Rpad 0.7 0.6 0.4
XSetColor D bpad 0.7 0.6 0.4
XSetColor D spad_1 0.7 0.6 0.4
XSetColor D spad_2 0.7 0.6 0.4
SetName D [XAddShape D brpk 1] "Bottom packages"
SetName D [XFindShape D rpk] "Bottom package"
XSetColor D rpk1 GRAY70
XSetColor D rpk2 80664D
XSetColor D rpk3 GRAY70
XSetColor D rpk1 0.7 0.7 0.7
XSetColor D rpk2 0.5 0.4 0.3
XSetColor D rpk3 0.7 0.7 0.7
XShow D
vlight clear

View File

@@ -36,7 +36,9 @@ set anArrAngle [expr 3.14 * 12.0 / 180.0]
# Form dimension names list to set parameters with vdimparam command
set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
for {set i 1} {$i <= 10} {incr i} { lappend aList ld_$i }
for {set i 1} {$i <= 10} {incr i} {
lappend aList ld_$i
}
puts "Creating dimensions..."
vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
@@ -65,14 +67,29 @@ foreach i $aList {
vfit
puts "Displaying exported shapes..."
vdisplay -dispMode 1 a b
vdisplay a b
vsetdispmode a 1
vsetdispmode b 1
vaspects a -setmaterial steel
vaspects b -setmaterial bronze
puts "Clipping shapes for better view..."
vclipplane create pa
vclipplane change pa equation 0 0 1 0
vclipplane change pa capping on
vclipplane change pa capping color 0.9 0.9 0.9
vclipplane set pa object a
vclipplane pa -set a -equation 0 0 1 0 -capping on -color GRAY90 -texName $aHatch -texScale 0.05 -0.05
vclipplane pb -set b -equation 0 0 1 0 -capping on -color GOLD -texName $aHatch -texScale 0.05 -0.05
vclipplane create pb
vclipplane change pb equation 0 0 1 0
vclipplane change pb capping on
vclipplane change pb capping color 1.0 0.8 0.0
vclipplane set pb object b
vclipplane change pa capping texname $aHatch
vclipplane change pa capping texscale 0.05 -0.05
vclipplane change pb capping texname $aHatch
vclipplane change pb capping texscale 0.05 0.05
vbottom
vrotate -0.3 -0.3 0

View File

@@ -77,13 +77,14 @@ SetName D $main "OCC Logo 2019"
SetName D [XFindShape D sb] "Core"
SetName D [XFindShape D tp] "Loop"
SetName D [XFindShape D rs] "Connector"
XSetColor D sb FF3652
XSetColor D tp 00AADA
XSetColor D rs 0073B0
XSetColor D sb 1 0.21 0.32
XSetColor D tp 0 0.667 0.855
XSetColor D rs 0 0.45 0.69
# display
vinit View1
vbackground -color WHITE
XDisplay -dispMode 1 D
vinit
vsetcolorbg 1 1 1
vsetdispmode 1
XDisplay D
vtop
vfit

View File

@@ -56,7 +56,7 @@ for { set aMarkerType 0 } { $aMarkerType <= 13 } { incr aMarkerType } {
set aRow [expr $aMarkerType - 7]
set aCol 5
set aName [lindex $aMarkerTypeNames $aMarkerType]
vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 7FFFFF -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont -noupdate
vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 0.5 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont -noupdate
vdisplay -top -noupdate "$aName"
if { $aMarkerType == 13 } {
vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1

View File

@@ -4,22 +4,36 @@
#Title: Material properties in viewer
set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
set THE_COLORS {default red green blue}
set THE_COLORS {default red green blue1}
set THE_ROW_DIST 35
proc drawLabels {} {
set x 20
set y 15
set r 0.098
set g 0.098
set b 0.098
foreach aMatIter $::THE_MATERIALS {
vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color GRAY10 -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color $r $g $b -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
incr y 10
}
set x 40
set y 5
foreach aColIter $::THE_COLORS {
set aLabColor "$aColIter"
if { "$aColIter" == "default" } { set aLabColor BLACK }
vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color "$aLabColor" -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
if { $aColIter == "red" } {
set r 1.0
set g 0.0
set b 0
} elseif { $aColIter == "green" } {
set r 0.0
set g 1.0
set b 0.0
} elseif { $aColIter == "blue1" } {
set r 0.0
set g 0.0
set b 1.0
}
vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color $r $g $b -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
incr x $::THE_ROW_DIST
}
}
@@ -55,7 +69,7 @@ vclose ALL
vinit View1 w=768 h=768
vtop
vglinfo
vbackground -gradient B4C8FF B4B4B4 -gradientMode VERTICAL
vbackground -gradient 0.705882 0.784314 1 0.705882 0.705882 0.705882 -gradientMode VERTICAL
vlight -change 0 -dir 0.577 -0.577 -0.577
vrenderparams -msaa 8

View File

@@ -46,17 +46,18 @@ NewDocument D
XAddShape D body_1
XAddShape D core_1
for {set i 1} {$i <= 26} {incr i} {XSetColor D body_1_$i BLUE}
XSetColor D body_1_1 E68066
XSetColor D body_1_9 E68066
for {set i 10} {$i <= 22} {incr i} {XSetColor D body_1_$i 99B300}
XSetColor D core_1 1A1AFF
foreach ff [explode core_1 f] { XSetColor D $ff 1A1AFF ; puts "set color $ff" }
#XSetColor D body_1 0. 0. 1.
for {set i 1} {$i <= 26} {incr i} {XSetColor D body_1_$i 0. 0. 1.}
XSetColor D body_1_1 0.9 0.5 0.4
XSetColor D body_1_9 0.9 0.5 0.4
for {set i 10} {$i <= 22} {incr i} {XSetColor D body_1_$i 0.6 0.7 0.0}
XSetColor D core_1 0.1 0.1 1.
foreach ff [explode core_1 f] { XSetColor D $ff 0.1 0.1 1. ; puts "set color $ff" }
XShow D
vclear
vinit View1
XDisplay -dispMode 1 D -explore
vfit
vsetdispmode 1
vrenderparams -msaa 8
vbackground -color WHITE

View File

@@ -28,20 +28,19 @@ SetName D [XFindShape D link]:2 "Nut instance 1"
SetName D [XFindShape D link]:3 "Nut instance 2"
puts "- Pin will be white"
XSetColor D [XFindShape D pin] WHITE
XSetColor D [XFindShape D pin] 1 1 1
puts "- Nut itself will be dark gray"
XSetColor D [XFindShape D nut] GRAY10
XSetColor D [XFindShape D nut] 0.1 0.1 0.1
puts "- Nut instance #1 will be red"
XSetColor D [XFindShape D link]:2 RED
XSetColor D [XFindShape D link]:2 1 0 0
puts "- Nut instance #2 will be green"
XSetColor D [XFindShape D link]:3 GREEN
XSetColor D [XFindShape D link]:3 0 1 0
puts "Starting DF browser..."
DFBrowse D
puts "Expand the document tree to see its structure and assigned names"
puts "Showing assembly in 3d view..."
vclear
vinit View1
XDisplay -dispMode 1 D -explore
XShow D
vfit
vsetdispmode 1

View File

@@ -415,6 +415,11 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
//=======================================================================
Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const
{
{
Handle(V3d_Viewer) aViewer = GetContext()->CurrentViewer();
aViewer->InitActiveViews(); // for AIS_ColorScale::TextSize()
}
Standard_Integer aWidthMax = 0;
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theLabels); aLabIter.More(); aLabIter.Next())
{

View File

@@ -26,7 +26,6 @@ public:
//! Default constructor.
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
: myIsHidden (false),
myHasOwnMaterial(false),
myHasOwnColor (false),
myHasOwnTransp(false),
myHasOwnWidth (false)
@@ -37,10 +36,6 @@ public:
bool IsHidden() const { return myIsHidden; }
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
bool HasOwnMaterial() const { return myHasOwnMaterial; }
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
void SetOwnMaterial() { myHasOwnMaterial = true; }
bool HasOwnColor() const { return myHasOwnColor; }
void UnsetOwnColor() { myHasOwnColor = false; }
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
@@ -56,7 +51,6 @@ public:
public: //! @name list of overridden properties
bool myIsHidden;
bool myHasOwnMaterial;
bool myHasOwnColor;
bool myHasOwnTransp;
bool myHasOwnWidth;

View File

@@ -333,11 +333,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
if (aDrawer->HasOwnMaterial())
{
continue;
}
//if (aDrawer->HasOwnMaterial()) continue;
if (aDrawer->HasOwnShadingAspect())
{
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());

View File

@@ -79,12 +79,6 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
if (!myReference.IsNull())
{
if (myReference->HasInteractiveContext()
&& myReference->GetContext()->DisplayStatus (myReference) != AIS_DS_None)
{
myReference.Nullify();
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context");
}
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
}
setLocalTransformation (theLocation);

View File

@@ -44,7 +44,8 @@ AIS_TextLabel::AIS_TextLabel()
myHasFlipping (Standard_False)
{
myDrawer->SetTextAspect (new Prs3d_TextAspect());
myDrawer->SetDisplayMode (0);
SetDisplayMode (0);
}
//=======================================================================

View File

@@ -32,9 +32,6 @@ public:
//! Default constructor
Standard_EXPORT AIS_TextLabel();
//! Return TRUE for supported display mode.
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Setup color of entire text.
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;

View File

@@ -69,7 +69,6 @@ AIS_ViewController::AIS_ViewController()
myMousePressed (Aspect_VKeyMouse_NONE),
myMouseModifiers (Aspect_VKeyFlags_NONE),
myMouseSingleButton (-1),
myMouseStopDragOnUnclick (false),
//
myTouchToleranceScale (1.0f),
myTouchRotationThresholdPx (6.0f),
@@ -612,7 +611,6 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
{
myMouseClickTimer.Stop();
myMouseClickCounter = 0;
myMouseStopDragOnUnclick = false;
myUI.Dragging.ToStop = true;
toUpdateView = true;
}
@@ -621,12 +619,6 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
else if (theButtons == Aspect_VKeyMouse_NONE)
{
myMouseSingleButton = -1;
if (myMouseStopDragOnUnclick)
{
myMouseStopDragOnUnclick = false;
myUI.Dragging.ToStop = true;
toUpdateView = true;
}
}
else if (myMouseSingleButton == -1)
{
@@ -777,7 +769,6 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
myMouseClickTimer.Stop();
myMouseClickCounter = 0;
myMouseSingleButton = -1;
myMouseStopDragOnUnclick = true;
}
}

View File

@@ -647,7 +647,6 @@ protected: //! @name mouse input variables
Aspect_VKeyMouse myMousePressed; //!< active mouse buttons
Aspect_VKeyFlags myMouseModifiers; //!< active key modifiers passed with last mouse event
Standard_Integer myMouseSingleButton; //!< index of mouse button pressed alone (>0)
Standard_Boolean myMouseStopDragOnUnclick; //!< queue stop dragging even with at next mouse unclick
protected: //! @name multi-touch input variables

View File

@@ -137,9 +137,6 @@ AIS_ViewCube::AIS_ViewCube()
myBoxEdgeGap (0.0),
myBoxFacetExtension (1.0),
myAxesPadding (1.0),
myAxesRadius (1.0),
myAxesConeRadius (3.0),
myAxesSphereRadius (4.0),
myCornerMinSize (2.0),
myRoundRadius (0.0),
myToDisplayAxes (true),
@@ -602,7 +599,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
const Standard_Real anArrowLength = 0.2 * anAxisSize;
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, myAxesRadius, anAxisSize, myAxesConeRadius, anArrowLength, THE_NB_ARROW_FACETTES);
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, 1.0, anAxisSize, 3.0, anArrowLength, THE_NB_ARROW_FACETTES);
anAxisGroup->AddPrimitiveArray (aTriangleArray);
TCollection_AsciiString anAxisLabel;
@@ -624,7 +621,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
anAspectCen->SetColor (Quantity_NOC_WHITE);
aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
Prs3d_ToolSphere aTool (myAxesSphereRadius, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
Prs3d_ToolSphere aTool (4.0, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
gp_Trsf aTrsf;
aTrsf.SetTranslation (gp_Vec (gp::Origin(), aLocation));
Handle(Graphic3d_ArrayOfTriangles) aCenterArray;

View File

@@ -189,45 +189,6 @@ public: //! @name Geometry management API
//! The value should be within [0, 0.5] range.
Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
//! Returns radius of axes of the trihedron; 1.0 by default.
Standard_Real AxesRadius() const { return myAxesRadius; }
//! Sets radius of axes of the trihedron.
void SetAxesRadius (const Standard_Real theRadius)
{
if (Abs (myAxesRadius - theRadius) > Precision::Confusion())
{
myAxesRadius = theRadius;
SetToUpdate();
}
}
//! Returns radius of cone of axes of the trihedron; 3.0 by default.
Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
//! Sets radius of cone of axes of the trihedron.
void SetAxesConeRadius (Standard_Real theRadius)
{
if (Abs (myAxesConeRadius - theRadius) > Precision::Confusion())
{
myAxesConeRadius = theRadius;
SetToUpdate();
}
}
//! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
//! Sets radius of sphere (central point) of the trihedron.
void SetAxesSphereRadius (Standard_Real theRadius)
{
if (Abs (myAxesSphereRadius - theRadius) > Precision::Confusion())
{
myAxesSphereRadius = theRadius;
SetToUpdate();
}
}
//! @return TRUE if trihedron is drawn; TRUE by default.
Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
@@ -660,9 +621,6 @@ protected:
Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
Standard_Real myBoxFacetExtension; //!< box facet extension
Standard_Real myAxesPadding; //!< Padding between box and axes
Standard_Real myAxesRadius; //!< radius of axes of the trihedron; 1.0 by default
Standard_Real myAxesConeRadius; //!< radius of cone of axes of the trihedron; 3.0 by default
Standard_Real myAxesSphereRadius; //!< radius of sphere (central point) of the trihedron; 4.0 by default
Standard_Real myCornerMinSize; //!< minimal size of box corner
Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
Standard_Boolean myToDisplayAxes; //!< trihedron visibility

View File

@@ -37,100 +37,100 @@ static Handle(TCollection_HAsciiString) nulstr;
static Handle(Interface_HArray1OfHAsciiString) nularr;
APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader
(const Handle(StepData_StepModel)& model)
(const Handle(StepData_StepModel)& model)
{
done = Standard_True;
if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileName))) {
if (model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileName))) {
fn = GetCasted(HeaderSection_FileName,
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileName)));
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileName)));
}
else done = Standard_False;
if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileSchema))) {
if (model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))) {
fs = GetCasted(HeaderSection_FileSchema,
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)));
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)));
}
else done = Standard_False;
if (model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileDescription))) {
if (model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription))) {
fd = GetCasted(HeaderSection_FileDescription,
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription)));
model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription)));
}
else done = Standard_False;
}
APIHeaderSection_MakeHeader::APIHeaderSection_MakeHeader
(const Standard_Integer shapetype)
(const Standard_Integer shapetype)
{
switch(shapetype) {
case 1 : Init ("Open CASCADE Facetted BRep Model"); break;
case 2 : Init ("Open CASCADE Face Based Surface Model"); break;
case 3 : Init ("Open CASCADE Shell Based Surface Model"); break;
case 4 : Init ("Open CASCADE Manifold Solid Brep Model"); break;
default: Init ("Open CASCADE Shape Model"); break;
switch (shapetype) {
case 1: Init("Open CASCADE Facetted BRep Model"); break;
case 2: Init("Open CASCADE Face Based Surface Model"); break;
case 3: Init("Open CASCADE Shell Based Surface Model"); break;
case 4: Init("Open CASCADE Manifold Solid Brep Model"); break;
default: Init("Open CASCADE Shape Model"); break;
}
}
void APIHeaderSection_MakeHeader::Init (const Standard_CString nameval)
void APIHeaderSection_MakeHeader::Init(const Standard_CString nameval)
{
done = Standard_True;
// - File Name
char timestamp[50];
if (fn.IsNull()) fn = new HeaderSection_FileName;
Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(nameval);
fn->SetName(name);
Interface_MSG::TDate (timestamp,0,0,0,0,0,1,"C:%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d"); // actually
Handle(TCollection_HAsciiString) tst =
Interface_MSG::TDate(timestamp, 0, 0, 0, 0, 0, 1, "C:%4.4d-%2.2d-%2.2dT%2.2d:%2.2d:%2.2d"); // actually
Handle(TCollection_HAsciiString) tst =
new TCollection_HAsciiString(timestamp);
fn->SetTimeStamp(tst);
Handle(Interface_HArray1OfHAsciiString) authors =
new Interface_HArray1OfHAsciiString(1,1);
Handle(TCollection_HAsciiString) a1 =
Handle(Interface_HArray1OfHAsciiString) authors =
new Interface_HArray1OfHAsciiString(1, 1);
Handle(TCollection_HAsciiString) a1 =
new TCollection_HAsciiString("Author");
authors->SetValue(1,a1);
authors->SetValue(1, a1);
fn->SetAuthor(authors);
Handle(Interface_HArray1OfHAsciiString) org =
new Interface_HArray1OfHAsciiString(1,1);
Handle(TCollection_HAsciiString) org1 =
Handle(Interface_HArray1OfHAsciiString) org =
new Interface_HArray1OfHAsciiString(1, 1);
Handle(TCollection_HAsciiString) org1 =
new TCollection_HAsciiString("Open CASCADE");
org->SetValue(1,org1);
org->SetValue(1, org1);
fn->SetOrganization(org);
char procver[80];
sprintf (procver, XSTEP_PROCESSOR_VERSION, "STEP");
Handle(TCollection_HAsciiString) pv = new TCollection_HAsciiString (procver);
sprintf(procver, XSTEP_PROCESSOR_VERSION, "STEP");
Handle(TCollection_HAsciiString) pv = new TCollection_HAsciiString(procver);
//Handle(TCollection_HAsciiString) pv =
//new TCollection_HAsciiString(XSTEP_VERSION);
fn->SetPreprocessorVersion(pv);
Handle(TCollection_HAsciiString) sys =
Handle(TCollection_HAsciiString) sys =
new TCollection_HAsciiString(XSTEP_SYSTEM_VERSION);//#58 rln
fn->SetOriginatingSystem(sys);
Handle(TCollection_HAsciiString) auth =
Handle(TCollection_HAsciiString) auth =
new TCollection_HAsciiString("Unknown");
fn->SetAuthorisation(auth);
// - File Description
if (fd.IsNull()) fd = new HeaderSection_FileDescription;
Handle(Interface_HArray1OfHAsciiString) descr =
new Interface_HArray1OfHAsciiString(1,1);
Handle(TCollection_HAsciiString) descr1 =
new Interface_HArray1OfHAsciiString(1, 1);
Handle(TCollection_HAsciiString) descr1 =
new TCollection_HAsciiString("Open CASCADE Model");
descr->SetValue(1,descr1);
descr->SetValue(1, descr1);
fd->SetDescription(descr);
Handle(TCollection_HAsciiString) il =
Handle(TCollection_HAsciiString) il =
new TCollection_HAsciiString("2;1");
fd->SetImplementationLevel(il);
// - File Schema
if (fs.IsNull()) fs = new HeaderSection_FileSchema;
if (fs.IsNull()) fs = new HeaderSection_FileSchema;
Handle(Interface_HArray1OfHAsciiString) schid =
new Interface_HArray1OfHAsciiString(1,1);
Handle(TCollection_HAsciiString) schid1 =
new Interface_HArray1OfHAsciiString(1, 1);
Handle(TCollection_HAsciiString) schid1 =
new TCollection_HAsciiString("");
schid->SetValue(1,schid1);
schid->SetValue(1, schid1);
fs->SetSchemaIdentifiers(schid);
}
@@ -141,30 +141,31 @@ Standard_Boolean APIHeaderSection_MakeHeader::IsDone() const
}
void APIHeaderSection_MakeHeader::Apply
(const Handle(StepData_StepModel)& model) const
(const Handle(StepData_StepModel)& model) const
{
Interface_EntityIterator header = model->Header();
if (HasFd() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileDescription)))
if (HasFd() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileDescription)))
header.AddItem(fd);
if (HasFn() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileName)))
if (HasFn() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileName)))
header.AddItem(fn);
if (HasFs() && !model->HasHeaderEntity (STANDARD_TYPE(HeaderSection_FileSchema))) {
if (HasFs() && !model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema))) {
// Schema defined? If not take it from the protocole
// Schema defined? If not take it from the protocole
Handle(TCollection_HAsciiString) sch;
Handle(Interface_HArray1OfHAsciiString) schid = fs->SchemaIdentifiers();
if (!schid.IsNull()) sch = schid->Value(1);
else {
schid = new Interface_HArray1OfHAsciiString(1,1);
schid = new Interface_HArray1OfHAsciiString(1, 1);
fs->SetSchemaIdentifiers(schid);
}
if (!sch.IsNull()) { if (sch->Length() < 2) sch.Nullify(); } // not defined
if (sch.IsNull()) {
Handle(StepData_Protocol) stepro = Handle(StepData_Protocol)::DownCast
( model->Protocol());
if (!stepro.IsNull()) sch = new TCollection_HAsciiString
(stepro->SchemaName());
if (!sch.IsNull()) schid->SetValue (1,sch);
(model->Protocol());
Handle(Interface_Static) aParam = model->GetParam("write.step.schema");
if (!aParam.IsNull() && !stepro.IsNull())
sch = new TCollection_HAsciiString(stepro->SchemaName(aParam->IntegerValue()));
if (!sch.IsNull()) schid->SetValue(1, sch);
}
header.AddItem(fs);
}
@@ -179,12 +180,12 @@ void APIHeaderSection_MakeHeader::Apply
// ========
Handle(StepData_StepModel) APIHeaderSection_MakeHeader::NewModel
(const Handle(Interface_Protocol)& protocol) const
(const Handle(Interface_Protocol)& protocol) const
{
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
stepmodel->SetProtocol (protocol);
stepmodel->SetProtocol(protocol);
// - Make Header information
// - Make Header information
Apply(stepmodel);
return stepmodel;
@@ -197,7 +198,9 @@ Handle(StepData_StepModel) APIHeaderSection_MakeHeader::NewModel
// ========
Standard_Boolean APIHeaderSection_MakeHeader::HasFn() const
{ return (!fn.IsNull()); }
{
return (!fn.IsNull());
}
Handle(HeaderSection_FileName) APIHeaderSection_MakeHeader::FnValue() const
{
@@ -208,23 +211,23 @@ Handle(HeaderSection_FileName) APIHeaderSection_MakeHeader::FnValue() const
void APIHeaderSection_MakeHeader::SetNameFromShapeType(const Standard_Integer shapetype)
{
Handle(TCollection_HAsciiString) name;
switch(shapetype)
switch(shapetype)
{
case 1: // face_based_surface_model
name = new TCollection_HAsciiString
("Euclid Face Based Surface Model");
("Euclid Face Based Surface Model");
break;
case 2: // manifold_solid_brep
name = new TCollection_HAsciiString
("Euclid Manifold Solid Brep Model");
name = new TCollection_HAsciiString
("Euclid Manifold Solid Brep Model");
break;
case 3: // facetted_brep
name = new TCollection_HAsciiString
("Euclid Facetted Brep Model");
("Euclid Facetted Brep Model");
break;
default : // others ?
name = new TCollection_HAsciiString
("Euclid Shape Model");
("Euclid Shape Model");
break;
}
SetName(aName);
@@ -233,106 +236,106 @@ void APIHeaderSection_MakeHeader::SetNameFromShapeType(const Standard_Integer sh
void APIHeaderSection_MakeHeader::SetName(const Handle(TCollection_HAsciiString)& aName)
{
if (!fn.IsNull()) fn->SetName(aName);
if (!fn.IsNull()) fn->SetName(aName);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::Name() const
{
return (fn.IsNull() ? nulstr : fn->Name());
return (fn.IsNull() ? nulstr : fn->Name());
}
void APIHeaderSection_MakeHeader::SetTimeStamp(const Handle(TCollection_HAsciiString)& aTimeStamp)
{
if (!fn.IsNull()) fn->SetTimeStamp(aTimeStamp);
if (!fn.IsNull()) fn->SetTimeStamp(aTimeStamp);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::TimeStamp() const
{
return (fn.IsNull() ? nulstr : fn->TimeStamp());
return (fn.IsNull() ? nulstr : fn->TimeStamp());
}
void APIHeaderSection_MakeHeader::SetAuthor(const Handle(Interface_HArray1OfHAsciiString)& aAuthor)
{
if (!fn.IsNull()) fn->SetAuthor(aAuthor);
if (!fn.IsNull()) fn->SetAuthor(aAuthor);
}
void APIHeaderSection_MakeHeader::SetAuthorValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aAuthor)
{
if (fn.IsNull()) return;
Handle(Interface_HArray1OfHAsciiString) li = fn->Author();
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aAuthor);
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num, aAuthor);
}
Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Author() const
{
return (fn.IsNull() ? nularr : fn->Author());
return (fn.IsNull() ? nularr : fn->Author());
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::AuthorValue(const Standard_Integer num) const
{
return (fn.IsNull() ? nulstr : fn->AuthorValue(num));
return (fn.IsNull() ? nulstr : fn->AuthorValue(num));
}
Standard_Integer APIHeaderSection_MakeHeader::NbAuthor () const
Standard_Integer APIHeaderSection_MakeHeader::NbAuthor() const
{
return (fn.IsNull() ? 0 : fn->NbAuthor());
return (fn.IsNull() ? 0 : fn->NbAuthor());
}
void APIHeaderSection_MakeHeader::SetOrganization(const Handle(Interface_HArray1OfHAsciiString)& aOrganization)
{
if (!fn.IsNull()) fn->SetOrganization(aOrganization);
if (!fn.IsNull()) fn->SetOrganization(aOrganization);
}
void APIHeaderSection_MakeHeader::SetOrganizationValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aOrgan)
{
if (fn.IsNull()) return;
Handle(Interface_HArray1OfHAsciiString) li = fn->Organization();
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aOrgan);
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num, aOrgan);
}
Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Organization() const
{
return (fn.IsNull() ? nularr : fn->Organization());
return (fn.IsNull() ? nularr : fn->Organization());
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::OrganizationValue(const Standard_Integer num) const
{
return (fn.IsNull() ? nulstr : fn->OrganizationValue(num));
return (fn.IsNull() ? nulstr : fn->OrganizationValue(num));
}
Standard_Integer APIHeaderSection_MakeHeader::NbOrganization () const
Standard_Integer APIHeaderSection_MakeHeader::NbOrganization() const
{
return (fn.IsNull() ? 0 : fn->NbOrganization());
return (fn.IsNull() ? 0 : fn->NbOrganization());
}
void APIHeaderSection_MakeHeader::SetPreprocessorVersion(const Handle(TCollection_HAsciiString)& aPreprocessorVersion)
{
if (!fn.IsNull()) fn->SetPreprocessorVersion(aPreprocessorVersion);
if (!fn.IsNull()) fn->SetPreprocessorVersion(aPreprocessorVersion);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::PreprocessorVersion() const
{
return (fn.IsNull() ? nulstr : fn->PreprocessorVersion());
return (fn.IsNull() ? nulstr : fn->PreprocessorVersion());
}
void APIHeaderSection_MakeHeader::SetOriginatingSystem(const Handle(TCollection_HAsciiString)& aOriginatingSystem)
{
if (!fn.IsNull()) fn->SetOriginatingSystem(aOriginatingSystem);
if (!fn.IsNull()) fn->SetOriginatingSystem(aOriginatingSystem);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::OriginatingSystem() const
{
return (fn.IsNull() ? nulstr : fn->OriginatingSystem());
return (fn.IsNull() ? nulstr : fn->OriginatingSystem());
}
void APIHeaderSection_MakeHeader::SetAuthorisation(const Handle(TCollection_HAsciiString)& aAuthorisation)
{
if (!fn.IsNull()) fn->SetAuthorisation(aAuthorisation);
if (!fn.IsNull()) fn->SetAuthorisation(aAuthorisation);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::Authorisation() const
{
return (fn.IsNull() ? nulstr : fn->Authorisation());
return (fn.IsNull() ? nulstr : fn->Authorisation());
}
// ===========
@@ -340,7 +343,9 @@ Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::Authorisation() co
// ===========
Standard_Boolean APIHeaderSection_MakeHeader::HasFs() const
{ return (!fs.IsNull()); }
{
return (!fs.IsNull());
}
Handle(HeaderSection_FileSchema) APIHeaderSection_MakeHeader::FsValue() const
{
@@ -349,29 +354,29 @@ Handle(HeaderSection_FileSchema) APIHeaderSection_MakeHeader::FsValue() const
void APIHeaderSection_MakeHeader::SetSchemaIdentifiers(const Handle(Interface_HArray1OfHAsciiString)& aSchemaIdentifiers)
{
if (!fs.IsNull()) fs->SetSchemaIdentifiers(aSchemaIdentifiers);
if (!fs.IsNull()) fs->SetSchemaIdentifiers(aSchemaIdentifiers);
}
void APIHeaderSection_MakeHeader::SetSchemaIdentifiersValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aSchem)
{
if (fs.IsNull()) return;
Handle(Interface_HArray1OfHAsciiString) li = fs->SchemaIdentifiers();
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aSchem);
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num, aSchem);
}
Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::SchemaIdentifiers() const
{
return (fs.IsNull() ? nularr : fs->SchemaIdentifiers());
return (fs.IsNull() ? nularr : fs->SchemaIdentifiers());
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::SchemaIdentifiersValue(const Standard_Integer num) const
{
return (fs.IsNull() ? nulstr : fs->SchemaIdentifiersValue(num));
return (fs.IsNull() ? nulstr : fs->SchemaIdentifiersValue(num));
}
Standard_Integer APIHeaderSection_MakeHeader::NbSchemaIdentifiers () const
Standard_Integer APIHeaderSection_MakeHeader::NbSchemaIdentifiers() const
{
return (fs.IsNull() ? 0 : fs->NbSchemaIdentifiers());
return (fs.IsNull() ? 0 : fs->NbSchemaIdentifiers());
}
//=======================================================================
@@ -381,24 +386,24 @@ Standard_Integer APIHeaderSection_MakeHeader::NbSchemaIdentifiers () const
void APIHeaderSection_MakeHeader::AddSchemaIdentifier(const Handle(TCollection_HAsciiString)& aSchem)
{
if ( fs.IsNull() ) fs = new HeaderSection_FileSchema;
if (fs.IsNull()) fs = new HeaderSection_FileSchema;
Handle(Interface_HArray1OfHAsciiString) idents = fs->SchemaIdentifiers();
// check that requested subschema is already in the list
Standard_Integer i;
for ( i=1; ! idents.IsNull() && i <= idents->Length(); i++ ) {
if ( aSchem->IsSameString ( idents->Value(i) ) ) return;
for (i = 1; !idents.IsNull() && i <= idents->Length(); i++) {
if (aSchem->IsSameString(idents->Value(i))) return;
}
// add a subshema
Handle(Interface_HArray1OfHAsciiString) ids =
new Interface_HArray1OfHAsciiString ( 1, ( idents.IsNull() ? 1 : idents->Length() + 1 ) );
for ( i=1; ! idents.IsNull() && i <= idents->Length(); i++ ) {
ids->SetValue ( i, idents->Value(i) );
Handle(Interface_HArray1OfHAsciiString) ids =
new Interface_HArray1OfHAsciiString(1, (idents.IsNull() ? 1 : idents->Length() + 1));
for (i = 1; !idents.IsNull() && i <= idents->Length(); i++) {
ids->SetValue(i, idents->Value(i));
}
ids->SetValue ( i, aSchem );
fs->SetSchemaIdentifiers ( ids );
ids->SetValue(i, aSchem);
fs->SetSchemaIdentifiers(ids);
}
// ================
@@ -406,7 +411,9 @@ void APIHeaderSection_MakeHeader::AddSchemaIdentifier(const Handle(TCollection_H
// ================
Standard_Boolean APIHeaderSection_MakeHeader::HasFd() const
{ return (!fd.IsNull()); }
{
return (!fd.IsNull());
}
Handle(HeaderSection_FileDescription) APIHeaderSection_MakeHeader::FdValue() const
{
@@ -415,37 +422,37 @@ Handle(HeaderSection_FileDescription) APIHeaderSection_MakeHeader::FdValue() con
void APIHeaderSection_MakeHeader::SetDescription(const Handle(Interface_HArray1OfHAsciiString)& aDescription)
{
if (!fs.IsNull()) fd->SetDescription(aDescription);
if (!fs.IsNull()) fd->SetDescription(aDescription);
}
void APIHeaderSection_MakeHeader::SetDescriptionValue(const Standard_Integer num, const Handle(TCollection_HAsciiString)& aDescr)
{
if (fd.IsNull()) return;
Handle(Interface_HArray1OfHAsciiString) li = fd->Description();
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num,aDescr);
if (num >= li->Lower() && num <= li->Upper()) li->SetValue(num, aDescr);
}
Handle(Interface_HArray1OfHAsciiString) APIHeaderSection_MakeHeader::Description() const
{
return (fd.IsNull() ? nularr : fd->Description());
return (fd.IsNull() ? nularr : fd->Description());
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::DescriptionValue(const Standard_Integer num) const
{
return (fd.IsNull() ? nulstr : fd->DescriptionValue(num));
return (fd.IsNull() ? nulstr : fd->DescriptionValue(num));
}
Standard_Integer APIHeaderSection_MakeHeader::NbDescription () const
Standard_Integer APIHeaderSection_MakeHeader::NbDescription() const
{
return (fd.IsNull() ? 0 : fd->NbDescription());
return (fd.IsNull() ? 0 : fd->NbDescription());
}
void APIHeaderSection_MakeHeader::SetImplementationLevel(const Handle(TCollection_HAsciiString)& aImplementationLevel)
{
if (!fd.IsNull()) fd->SetImplementationLevel(aImplementationLevel);
if (!fd.IsNull()) fd->SetImplementationLevel(aImplementationLevel);
}
Handle(TCollection_HAsciiString) APIHeaderSection_MakeHeader::ImplementationLevel() const
{
return (fd.IsNull() ? nulstr : fd->ImplementationLevel());
return (fd.IsNull() ? nulstr : fd->ImplementationLevel());
}

View File

@@ -27,10 +27,8 @@
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include <GeomConvert.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
@@ -302,10 +300,6 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
}
}
//=============================================================================
//function : Approx_CurveOnSurface
//purpose : Constructor
//=============================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D,
const Handle(Adaptor3d_HSurface)& Surf,
const Standard_Real First,
@@ -316,75 +310,14 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
const Standard_Integer MaxSegments,
const Standard_Boolean only3d,
const Standard_Boolean only2d)
: myC2D(C2D),
mySurf(Surf),
myFirst(First),
myLast(Last),
myTol(Tol),
myIsDone(Standard_False),
myHasResult(Standard_False),
myError3d(0.0),
myError2dU(0.0),
myError2dV(0.0)
{
Perform(MaxSegments, MaxDegree, S, only3d, only2d);
}
//=============================================================================
//function : Approx_CurveOnSurface
//purpose : Constructor
//=============================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
const Handle(Adaptor3d_HSurface)& theSurf,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTol)
: myC2D(theC2D),
mySurf(theSurf),
myFirst(theFirst),
myLast(theLast),
myTol(theTol),
myIsDone(Standard_False),
myHasResult(Standard_False),
myError3d(0.0),
myError2dU(0.0),
myError2dV(0.0)
{
}
//=============================================================================
//function : Perform
//purpose :
//=============================================================================
void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
const Standard_Integer theMaxDegree,
const GeomAbs_Shape theContinuity,
const Standard_Boolean theOnly3d,
const Standard_Boolean theOnly2d)
{
myIsDone = Standard_False;
myHasResult = Standard_False;
myError2dU = 0.0;
myError2dV = 0.0;
myError3d = 0.0;
if(only3d && only2d) throw Standard_ConstructionError();
GeomAbs_Shape Order = S;
if(theOnly3d && theOnly2d) throw Standard_ConstructionError();
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = C2D->Trim( First, Last, Precision::PConfusion() );
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = myC2D->Trim( myFirst, myLast, Precision::PConfusion() );
Standard_Boolean isU, isForward;
Standard_Real aParam;
if (theOnly3d && isIsoLine(TrimmedC2D, isU, aParam, isForward))
{
if (buildC3dOnIsoLine(TrimmedC2D, isU, aParam, isForward))
{
myIsDone = Standard_True;
myHasResult = Standard_True;
return;
}
}
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, mySurf );
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, Surf );
Handle(Adaptor3d_HCurveOnSurface) HCOnS = new Adaptor3d_HCurveOnSurface();
HCOnS->Set(COnS);
@@ -394,34 +327,37 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
Handle(TColStd_HArray1OfReal) ThreeDTol;
// create evaluators and choose appropriate one
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, myFirst, myLast);
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, myFirst, myLast);
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, myFirst, myLast);
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, First, Last);
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, First, Last);
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, First, Last);
AdvApprox_EvaluatorFunction* EvalPtr;
if ( theOnly3d ) EvalPtr = &Eval3dCvOnSurf;
else if ( theOnly2d ) EvalPtr = &Eval2dCvOnSurf;
if ( only3d ) EvalPtr = &Eval3dCvOnSurf;
else if ( only2d ) EvalPtr = &Eval2dCvOnSurf;
else EvalPtr = &EvalCvOnSurf;
// Initialization for 2d approximation
if(!theOnly3d) {
if(!only3d) {
Num1DSS = 2;
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
Standard_Real TolU, TolV;
TolU = mySurf->UResolution(myTol)/2;
TolV = mySurf->VResolution(myTol)/2;
TolU = Surf->UResolution(Tol)/2;
TolV = Surf->VResolution(Tol)/2;
OneDTol->SetValue(1,TolU);
OneDTol->SetValue(2,TolV);
}
if(!theOnly2d) {
if(!only2d) {
Num3DSS=1;
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
ThreeDTol->Init(myTol/2);
ThreeDTol->Init(Tol/2);
}
myError2dU = 0;
myError2dV = 0;
myError3d = 0;
Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
@@ -433,8 +369,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTol,
myFirst, myLast, theContinuity,
theMaxDegree, theMaxSegments,
First, Last, Order,
MaxDegree, MaxSegments,
*EvalPtr, CutTool);
myIsDone = aApprox.IsDone();
@@ -445,14 +381,14 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
Standard_Integer Degree = aApprox.Degree();
if(!theOnly2d)
if(!only2d)
{
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
aApprox.Poles(1,Poles);
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
myError3d = aApprox.MaxError(3, 1);
}
if(!theOnly3d)
if(!only3d)
{
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
@@ -468,6 +404,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
}
}
// }
}
Standard_Boolean Approx_CurveOnSurface::IsDone() const
@@ -505,161 +443,3 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
return myError2dV;
}
//=============================================================================
//function : isIsoLine
//purpose :
//=============================================================================
Standard_Boolean Approx_CurveOnSurface::isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
Standard_Boolean& theIsU,
Standard_Real& theParam,
Standard_Boolean& theIsForward) const
{
// These variables are used to check line state (vertical or horizontal).
Standard_Boolean isAppropriateType = Standard_False;
gp_Pnt2d aLoc2d;
gp_Dir2d aDir2d;
// Test type.
const GeomAbs_CurveType aType = theC2D->GetType();
if (aType == GeomAbs_Line)
{
gp_Lin2d aLin2d = theC2D->Line();
aLoc2d = aLin2d.Location();
aDir2d = aLin2d.Direction();
isAppropriateType = Standard_True;
}
else if (aType == GeomAbs_BSplineCurve)
{
Handle(Geom2d_BSplineCurve) aBSpline2d = theC2D->BSpline();
if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2)
return Standard_False; // Not a line or uneven parameterization.
aLoc2d = aBSpline2d->Pole(1);
// Vector should be non-degenerated.
gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2));
if (aVec2d.SquareMagnitude() < Precision::Confusion())
return Standard_False; // Degenerated spline.
aDir2d = aVec2d;
isAppropriateType = Standard_True;
}
else if (aType == GeomAbs_BezierCurve)
{
Handle(Geom2d_BezierCurve) aBezier2d = theC2D->Bezier();
if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2)
return Standard_False; // Not a line or uneven parameterization.
aLoc2d = aBezier2d->Pole(1);
// Vector should be non-degenerated.
gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2));
if (aVec2d.SquareMagnitude() < Precision::Confusion())
return Standard_False; // Degenerated spline.
aDir2d = aVec2d;
isAppropriateType = Standard_True;
}
if (!isAppropriateType)
return Standard_False;
// Check line to be vertical or horizontal.
if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular()))
{
// Horizontal line. V = const.
theIsU = Standard_False;
theParam = aLoc2d.Y();
theIsForward = aDir2d.Dot(gp::DX2d()) > 0.0;
return Standard_True;
}
else if (aDir2d.IsParallel(gp::DY2d(), Precision::Angular()))
{
// Vertical line. U = const.
theIsU = Standard_True;
theParam = aLoc2d.X();
theIsForward = aDir2d.Dot(gp::DY2d()) > 0.0;
return Standard_True;
}
return Standard_False;
}
#include <GeomLib.hxx>
//=============================================================================
//function : buildC3dOnIsoLine
//purpose :
//=============================================================================
Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
const Standard_Boolean theIsU,
const Standard_Real theParam,
const Standard_Boolean theIsForward)
{
// Convert adapter to the appropriate type.
Handle(GeomAdaptor_HSurface) aGeomAdapter = Handle(GeomAdaptor_HSurface)::DownCast(mySurf);
if (aGeomAdapter.IsNull())
return Standard_False;
if (mySurf->GetType() == GeomAbs_Sphere)
return Standard_False;
// Extract isoline
Handle(Geom_Surface) aSurf = aGeomAdapter->ChangeSurface().Surface();
Handle(Geom_Curve) aC3d;
gp_Pnt2d aF2d = theC2D->Value(theC2D->FirstParameter());
gp_Pnt2d aL2d = theC2D->Value(theC2D->LastParameter());
if (theIsU)
{
aC3d = aSurf->UIso(theParam);
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.Y(), aL2d.Y());
}
else
{
aC3d = aSurf->VIso(theParam);
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.X(), aL2d.X());
}
// Convert arbitrary curve type to the b-spline.
myCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular);
if (!theIsForward)
myCurve3d->Reverse();
// Rebuild parameterization for the 3d curve to have the same parameterization with
// a two-dimensional curve.
TColStd_Array1OfReal aKnots = myCurve3d->Knots();
BSplCLib::Reparametrize(theC2D->FirstParameter(), theC2D->LastParameter(), aKnots);
myCurve3d->SetKnots(aKnots);
// Evaluate error.
myError3d = 0.0;
const Standard_Real aParF = myFirst;
const Standard_Real aParL = myLast;
const Standard_Integer aNbPnt = 23;
for(Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
{
const Standard_Real aPar = aParF + ((aParL - aParF) * anIdx) / aNbPnt;
const gp_Pnt2d aPnt2d = theC2D->Value(aPar);
const gp_Pnt aPntC3D = myCurve3d->Value(aPar);
const gp_Pnt aPntC2D = mySurf->Value(aPnt2d.X(), aPnt2d.Y());
const Standard_Real aSqDeviation = aPntC3D.SquareDistance(aPntC2D);
myError3d = Max(aSqDeviation, myError3d);
}
myError3d = Sqrt(myError3d);
// Target tolerance is not obtained. This situation happens for isolines on the sphere.
// OCCT is unable to convert it keeping original parameterization, while the geometric
// form of the result is entirely identical. In that case, it is better to utilize
// a general-purpose approach.
if (myError3d > myTol)
return Standard_False;
return Standard_True;
}

View File

@@ -40,22 +40,9 @@ public:
DEFINE_STANDARD_ALLOC
//! This constructor calls perform method. This constructor is deprecated.
Standard_DEPRECATED("This constructor is deprecated. Use other constructor and perform method instead.")
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D, const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
//! This constructor does not call perform method.
//! @param theC2D 2D Curve to be approximated in 3D.
//! @param theSurf Surface where 2D curve is located.
//! @param theFirst First parameter of resulting curve.
//! @param theFirst Last parameter of resulting curve.
//! @param theTol Computation tolerance.
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
const Handle(Adaptor3d_HSurface)& theSurf,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTol);
Standard_EXPORT Standard_Boolean IsDone() const;
Standard_EXPORT Standard_Boolean HasResult() const;
@@ -72,64 +59,18 @@ public:
//! 2d Curve
Standard_EXPORT Standard_Real MaxError2dV() const;
//! Constructs the 3d curve. Input parameters are ignored when the input curve is
//! U-isoline or V-isoline.
//! @param theMaxSegments Maximal number of segments in the resulting spline.
//! @param theMaxDegree Maximal degree of the result.
//! @param theContinuity Resulting continuity.
//! @param theOnly3d Determines building only 3D curve.
//! @param theOnly2d Determines building only 2D curve.
Standard_EXPORT void Perform(const Standard_Integer theMaxSegments,
const Standard_Integer theMaxDegree,
const GeomAbs_Shape theContinuity,
const Standard_Boolean theOnly3d = Standard_False,
const Standard_Boolean theOnly2d = Standard_False);
protected:
//! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
//! or geometric line. This line should have natural parameterization.
//! @param theC2D Trimmed curve to be checked.
//! @param theIsU Flag indicating that line is u const.
//! @param theParam Line parameter.
//! @param theIsForward Flag indicating forward parameterization on a isoline.
//! @return Standard_True when 2d curve is a line and Standard_False otherwise.
Standard_Boolean isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
Standard_Boolean& theIsU,
Standard_Real& theParam,
Standard_Boolean& theIsForward) const;
//! Builds 3D curve for a isoline. This method takes corresponding isoline from
//! the input surface.
//! @param theC2D Trimmed curve to be approximated.
//! @param theIsU Flag indicating that line is u const.
//! @param theParam Line parameter.
//! @param theIsForward Flag indicating forward parameterization on a isoline.
//! @return Standard_True when 3d curve is built and Standard_False otherwise.
Standard_Boolean buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
const Standard_Boolean theIsU,
const Standard_Real theParam,
const Standard_Boolean theIsForward);
private:
Approx_CurveOnSurface& operator= (const Approx_CurveOnSurface&);
private:
//! Input curve.
const Handle(Adaptor2d_HCurve2d) myC2D;
//! Input surface.
const Handle(Adaptor3d_HSurface) mySurf;
//! First parameter of the result.
const Standard_Real myFirst;
//! Last parameter of the result.
const Standard_Real myLast;
//! Tolerance.
Standard_Real myTol;
Handle(Geom2d_BSplineCurve) myCurve2d;
Handle(Geom_BSplineCurve) myCurve3d;

View File

@@ -59,7 +59,7 @@ public:
virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; }
//! Resize window - do nothing.
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
//! Map window - do nothing.
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }

View File

@@ -58,7 +58,7 @@ public:
Standard_EXPORT virtual void Unmap() const = 0;
//! Apply the resizing to the window <me>.
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const = 0;
//! Apply the mapping change to the window <me>.
//! and returns TRUE if the window is mapped at screen.

View File

@@ -89,63 +89,28 @@ class BOPAlgo_EdgeEdge :
Handle(BOPDS_PaveBlock)& PaveBlock2() {
return myPB2;
}
//
void SetBoxes (const Bnd_Box& theBox1,
const Bnd_Box& theBox2)
{
myBox1 = theBox1;
myBox2 = theBox2;
}
//
//
void SetFuzzyValue(const Standard_Real theFuzz) {
IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
}
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
TopoDS_Edge anE1 = myEdge1, anE2 = myEdge2;
Standard_Boolean hasTrsf = false;
try
{
OCC_CATCH_SIGNALS
gp_Trsf aTrsf;
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
{
// Shapes are located far from origin, move the shapes to the origin,
// to increase the accuracy of intersection.
TopLoc_Location aLoc (aTrsf);
myEdge1.Move (aLoc);
myEdge2.Move (aLoc);
hasTrsf = Standard_True;
}
IntTools_EdgeEdge::Perform();
}
catch (Standard_Failure const&)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
myEdge1 = anE1;
myEdge2 = anE2;
if (hasTrsf)
{
for (Standard_Integer i = 1; i <= myCommonParts.Length(); ++i)
{
IntTools_CommonPrt& aCPart = myCommonParts (i);
aCPart.SetEdge1 (myEdge1);
aCPart.SetEdge2 (myEdge2);
}
}
}
//
protected:
Handle(BOPDS_PaveBlock) myPB1;
Handle(BOPDS_PaveBlock) myPB2;
Bnd_Box myBox1;
Bnd_Box myBox2;
};
//
//=======================================================================
@@ -251,7 +216,6 @@ void BOPAlgo_PaveFiller::PerformEE()
//
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
anEdgeEdge.SetBoxes (aBB1, aBB2);
anEdgeEdge.SetFuzzyValue(myFuzzyValue);
anEdgeEdge.SetProgressIndicator(myProgressIndicator);
}//for (; aIt2.More(); aIt2.Next()) {
@@ -960,8 +924,6 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
if (!aNbPB)
return;
const Standard_Boolean bSICheckMode = (myArguments.Extent() == 1);
// Prepare pave blocks with the same vertices for intersection.
BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
@@ -978,12 +940,10 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
// Use the max tolerance of vertices as Fuzzy value for intersection of edges.
// In the Self-Interference check mode we are interested in real
// intersections only, so use only the real tolerance of edges,
// no need to use the extended tolerance.
Standard_Real aTolAdd = (bSICheckMode ? myFuzzyValue :
2 * Max(BRep_Tool::Tolerance(aV1), BRep_Tool::Tolerance(aV2)));
// Use the max tolerance of vertices as Fuzzy value for intersection
// of edges
Standard_Real aTolAdd = 2 * Max(BRep_Tool::Tolerance(aV1),
BRep_Tool::Tolerance(aV2));
// All possible pairs combined from the list <aLPB> should be checked
BOPDS_ListIteratorOfListOfPaveBlock aItLPB1(aLPB);
@@ -1062,7 +1022,6 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
anEdgeEdge.SetPaveBlock2(aPB2);
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
anEdgeEdge.SetBoxes (myDS->ShapeInfo(nE1).Box(), myDS->ShapeInfo (nE2).Box());
if (bUseAddTol)
anEdgeEdge.SetFuzzyValue(myFuzzyValue + aTolAdd);
else

View File

@@ -105,50 +105,18 @@ class BOPAlgo_EdgeFace :
IntTools_EdgeFace::SetFuzzyValue(theFuzz);
}
//
void SetBoxes (const Bnd_Box& theBox1,
const Bnd_Box& theBox2)
{
myBox1 = theBox1;
myBox2 = theBox2;
}
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
TopoDS_Face aFace = myFace;
TopoDS_Edge anEdge = myEdge;
Standard_Boolean hasTrsf = false;
try
{
OCC_CATCH_SIGNALS
gp_Trsf aTrsf;
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
{
// Shapes are located far from origin, move the shapes to the origin,
// to increase the accuracy of intersection.
TopLoc_Location aLoc (aTrsf);
myEdge.Move (aLoc);
myFace.Move (aLoc);
hasTrsf = Standard_True;
}
IntTools_EdgeFace::Perform();
}
catch (Standard_Failure const&)
{
AddError(new BOPAlgo_AlertIntersectionFailed);
}
myFace = aFace;
myEdge = anEdge;
if (hasTrsf)
{
for (Standard_Integer i = 1; i <= mySeqOfCommonPrts.Length(); ++i)
{
IntTools_CommonPrt& aCPart = mySeqOfCommonPrts (i);
aCPart.SetEdge1 (myEdge);
}
}
}
//
protected:
@@ -156,8 +124,6 @@ class BOPAlgo_EdgeFace :
Standard_Integer myIF;
IntTools_Range myNewSR;
Handle(BOPDS_PaveBlock) myPB;
Bnd_Box myBox1;
Bnd_Box myBox2;
};
//
//=======================================================================
@@ -265,7 +231,6 @@ void BOPAlgo_PaveFiller::PerformEF()
//
aEdgeFace.SetEdge (aE);
aEdgeFace.SetFace (aF);
aEdgeFace.SetBoxes (myDS->ShapeInfo(nE).Box(), myDS->ShapeInfo (nF).Box());
aEdgeFace.SetFuzzyValue(myFuzzyValue);
aEdgeFace.UseQuickCoincidenceCheck(bExpressCompute);
//
@@ -791,8 +756,6 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
// Shake the tree
aBBTree.Build();
const Standard_Boolean bSICheckMode = (myArguments.Extent() == 1);
// Find pairs of Face/PaveBlock containing the same vertices
// and prepare those pairs for intersection.
BOPAlgo_VectorOfEdgeFace aVEdgeFace;
@@ -911,12 +874,8 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
// tolerance as the criteria.
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
// In the Self-Interference check mode we are interested in real
// intersections only, so use only the real tolerance of edges,
// no need to use the extended tolerance.
Standard_Real aTolCheck = (bSICheckMode ? myFuzzyValue :
2 * Max(BRep_Tool::Tolerance(aV1), BRep_Tool::Tolerance(aV2)));
Standard_Real aTolCheck = 2 * Max(BRep_Tool::Tolerance(aV1),
BRep_Tool::Tolerance(aV2));
if (aProjPS.LowerDistance() > aTolCheck + myFuzzyValue)
continue;
@@ -981,7 +940,6 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
aEdgeFace.SetPaveBlock(aPB);
aEdgeFace.SetEdge(aE);
aEdgeFace.SetFace(aF);
aEdgeFace.SetBoxes (myDS->ShapeInfo(nE).Box(), myDS->ShapeInfo (nF).Box());
aEdgeFace.SetFuzzyValue(myFuzzyValue + aTolAdd);
aEdgeFace.UseQuickCoincidenceCheck(Standard_True);
aEdgeFace.SetRange(IntTools_Range(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()));

View File

@@ -122,12 +122,6 @@ class BOPAlgo_FaceFace :
myF2=aF2;
}
//
void SetBoxes(const Bnd_Box& theBox1,
const Bnd_Box& theBox2) {
myBox1 = theBox1;
myBox2 = theBox2;
}
//
const TopoDS_Face& Face1()const {
return myF1;
}
@@ -148,37 +142,13 @@ class BOPAlgo_FaceFace :
IntTools_FaceFace::SetFuzzyValue(theFuzz);
}
//
const gp_Trsf& Trsf() const { return myTrsf; }
//
virtual void Perform() {
BOPAlgo_Algo::UserBreak();
try
{
OCC_CATCH_SIGNALS
gp_Trsf aTrsf;
TopoDS_Face aF1 = myF1, aF2 = myF2;
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
{
// Shapes are located far from origin, move the shapes to the origin,
// to increase the accuracy of intersection.
TopLoc_Location aLoc (aTrsf);
aF1.Move (aLoc);
aF2.Move (aLoc);
// The starting point is initialized only with the UV parameters
// on the faces - 3D point is not set (see GetEFPnts method),
// so no need to transform anything.
//for (IntSurf_ListOfPntOn2S::Iterator it (myListOfPnts); it.More(); it.Next())
//{
// IntSurf_PntOn2S& aP2S = it.ChangeValue();
// aP2S.SetValue (aP2S.Value().Transformed (aTrsf));
//}
myTrsf = aTrsf.Inverted();
}
IntTools_FaceFace::Perform (aF1, aF2);
IntTools_FaceFace::Perform(myF1, myF2);
}
catch (Standard_Failure const&)
{
@@ -186,39 +156,12 @@ class BOPAlgo_FaceFace :
}
}
//
void ApplyTrsf()
{
if (IsDone())
{
// Update curves
for (Standard_Integer i = 1; i <= mySeqOfCurve.Length(); ++i)
{
IntTools_Curve& aIC = mySeqOfCurve (i);
aIC.Curve()->Transform (myTrsf);
}
// Update points
for (Standard_Integer i = 1; i <= myPnts.Length(); ++i)
{
IntTools_PntOn2Faces& aP2F = myPnts (i);
IntTools_PntOnFace aPOnF1 = aP2F.P1(), aPOnF2 = aP2F.P2();
aPOnF1.SetPnt (aPOnF1.Pnt().Transformed (myTrsf));
aPOnF2.SetPnt (aPOnF2.Pnt().Transformed (myTrsf));
aP2F.SetP1 (aPOnF1);
aP2F.SetP2 (aPOnF2);
}
}
}
//
protected:
Standard_Integer myIF1;
Standard_Integer myIF2;
Standard_Real myTolFF;
TopoDS_Face myF1;
TopoDS_Face myF2;
Bnd_Box myBox1;
Bnd_Box myBox2;
gp_Trsf myTrsf;
};
//
//=======================================================================
@@ -292,7 +235,6 @@ void BOPAlgo_PaveFiller::PerformFF()
//
aFaceFace.SetIndices(nF1, nF2);
aFaceFace.SetFaces(aF1, aF2);
aFaceFace.SetBoxes (myDS->ShapeInfo (nF1).Box(), myDS->ShapeInfo (nF2).Box());
// compute minimal tolerance for the curves
Standard_Real aTolFF = ToleranceFF(aBAS1, aBAS2);
aFaceFace.SetTolFF(aTolFF);
@@ -340,8 +282,6 @@ void BOPAlgo_PaveFiller::PerformFF()
//
aFaceFace.PrepareLines3D(bSplitCurve);
//
aFaceFace.ApplyTrsf();
//
const IntTools_SequenceOfCurves& aCvsX = aFaceFace.Lines();
const IntTools_SequenceOfPntOn2Faces& aPntsX = aFaceFace.Points();
//
@@ -1771,16 +1711,12 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
getBoundPaves(myDS, aNC, aBndNV);
//
Standard_Real aTolVnew = Precision::Confusion();
Standard_Boolean isClosed = aP[1].IsEqual (aP[0], aTolVnew);
if (isClosed && (aBndNV[0] > 0 || aBndNV[1] > 0))
return;
for (Standard_Integer j = 0; j<2; ++j)
{
if (aBndNV[j] < 0)
{
// no vertex on this end
if (j && isClosed) {
if (j && aP[1].IsEqual(aP[0], aTolVnew)) {
//if curve is closed, process only one bound
continue;
}

View File

@@ -215,15 +215,11 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
//
// use only connected faces
TopTools_ListOfShape aLFConnected;
// Boundary faces
TopTools_MapOfShape aBoundaryFaces;
aItF.Initialize (myShapes);
for (; aItF.More(); aItF.Next()) {
const TopoDS_Shape& aF = aItF.Value();
if (aMFaces.Contains(aF)) {
aLFConnected.Append(aF);
if (!aBoundaryFaces.Add (aF))
aBoundaryFaces.Remove (aF);
}
}
//
@@ -258,7 +254,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
aItS.Initialize(aShell);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
Standard_Boolean isBoundary = aBoundaryFaces.Contains (aF);
//
// loop on edges of aF; find a good neighbor face of aF by aE
aExp.Init(aF, TopAbs_EDGE);
@@ -294,8 +289,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
// take only not-processed faces as a candidates
BOPTools_ListOfCoupleOfShape aLCSOff;
//
Standard_Integer aNbWaysInside = 0;
TopoDS_Face aSelF;
TopTools_ListIteratorOfListOfShape aItLF(aLF);
for (; aItLF.More(); aItLF.Next()) {
const TopoDS_Face& aFL = (*(TopoDS_Face*)(&aItLF.Value()));
@@ -308,11 +301,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
continue;
}
//
if (isBoundary && !aBoundaryFaces.Contains (aFL))
{
++aNbWaysInside;
aSelF = aFL;
}
aCSOff.SetShape1(aEL);
aCSOff.SetShape2(aFL);
aLCSOff.Append(aCSOff);
@@ -325,14 +313,12 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
//
// among all the adjacent faces chose one with the minimal
// angle to the current one
if (!isBoundary || aNbWaysInside != 1)
{
if (aNbOff == 1) {
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
}
else if (aNbOff > 1) {
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
}
TopoDS_Face aSelF;
if (aNbOff == 1) {
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
}
else if (aNbOff > 1) {
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
}
//
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {

View File

@@ -1756,30 +1756,3 @@ void BOPAlgo_Tools::FillInternals(const TopTools_ListOfShape& theSolids,
}
}
}
//=======================================================================
//function : TrsfToPoint
//purpose :
//=======================================================================
Standard_Boolean BOPAlgo_Tools::TrsfToPoint (const Bnd_Box& theBox1,
const Bnd_Box& theBox2,
gp_Trsf& theTrsf,
const gp_Pnt& thePoint,
const Standard_Real theCriteria)
{
// Unify two boxes
Bnd_Box aBox = theBox1;
aBox.Add (theBox2);
gp_XYZ aBCenter = (aBox.CornerMin().XYZ() + aBox.CornerMax().XYZ()) / 2.;
Standard_Real aPBDist = (thePoint.XYZ() - aBCenter).Modulus();
if (aPBDist < theCriteria)
return Standard_False;
Standard_Real aBSize = Sqrt (aBox.SquareExtent());
if ((aBSize / aPBDist) > (1. / theCriteria))
return Standard_False;
theTrsf.SetTranslation (gp_Vec (aBox.CornerMin(), thePoint));
return Standard_True;
}

View File

@@ -205,20 +205,6 @@ public:
const TopTools_DataMapOfShapeListOfShape& theImages,
const Handle(IntTools_Context)& theContext);
//! Computes the transformation needed to move the objects
//! to the given point to increase the quality of computations.
//! Returns true if the objects are located far from the given point
//! (relatively given criteria), false otherwise.
//! @param theBox1 the AABB of the first object
//! @param theBox2 the AABB of the second object
//! @param theTrsf the computed transformation
//! @param thePoint the Point to compute transformation to
//! @param theCriteria the Criteria to check whether thranformation is required
Standard_EXPORT static Standard_Boolean TrsfToPoint (const Bnd_Box& theBox1,
const Bnd_Box& theBox2,
gp_Trsf& theTrsf,
const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0),
const Standard_Real theCriteria = 1.e+5);
};
#endif // _BOPAlgo_Tools_HeaderFile

View File

@@ -27,9 +27,7 @@ class BOPAlgo_EdgeInfo {
BOPAlgo_EdgeInfo() :
myPassed(Standard_False),
myInFlag(Standard_False),
myIsInside (Standard_False),
myAngle (-1.)
{
myAngle (-1.) {
};
//
void SetEdge(const TopoDS_Edge& theE) {
@@ -64,19 +62,10 @@ class BOPAlgo_EdgeInfo {
return myAngle;
};
//
Standard_Boolean IsInside() const {
return myIsInside;
};
//
void SetIsInside (const Standard_Boolean theIsInside) {
myIsInside = theIsInside;
};
//
protected:
TopoDS_Edge myEdge;
Standard_Boolean myPassed;
Standard_Boolean myInFlag;
Standard_Boolean myIsInside;
Standard_Real myAngle;
};

View File

@@ -166,8 +166,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
MyDataMapOfShapeBoolean aVertMap;
//
const TopTools_ListOfShape& myEdges=aCB.Shapes();
TopTools_MapOfShape aMS;
//
// 1.Filling mySmartMap
aIt.Initialize(myEdges);
@@ -179,10 +177,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
//
bIsClosed = BRep_Tool::Degenerated(aE) ||
BRep_Tool::IsClosed(aE, myFace);
if (!aMS.Add (aE) && !bIsClosed)
aMS.Remove (aE);
//
aItS.Initialize(aE);
for(i = 0; aItS.More(); aItS.Next(), ++i) {
@@ -224,7 +218,7 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
for (i=1; i<=aNb; i++) {
aCntIn=0;
aCntOut=0;
const BOPAlgo_ListOfEdgeInfo& aLEInfo = mySmartMap(i);
const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i);
BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo);
for (; anIt.More(); anIt.Next()) {
const BOPAlgo_EdgeInfo& aEI=anIt.Value();
@@ -310,7 +304,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
for (; aItLEI.More(); aItLEI.Next()) {
BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
const TopoDS_Edge& aE=aEI.Edge();
aEI.SetIsInside (!aMS.Contains (aE));
//
aVV = aV;
bIsIN = aEI.IsIn();
@@ -373,7 +366,7 @@ void Path (const GeomAdaptor_Surface& aGAS,
Standard_Integer i, j, aNb, aNbj;
Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
Standard_Boolean anIsSameV2d, anIsSameV, anIsOut, anIsNotPassed;
Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed;
Standard_Boolean bIsClosed;
TopoDS_Vertex aVa, aVb;
TopoDS_Edge aEOuta;
@@ -508,12 +501,8 @@ void Path (const GeomAdaptor_Surface& aGAS,
//
anAngleIn = AngleIn(aEOuta, aLEInfo);
aMinAngle = 100.;
anIsFound = Standard_False;
Standard_Integer iCnt = NbWaysOut(aLEInfo);
Standard_Boolean isBoundary = !anEdgeInfo->IsInside();
Standard_Integer aNbWaysInside = 0;
BOPAlgo_EdgeInfo *pOnlyWayIn = NULL;
Standard_Integer aCurIndexE = 0;
anIt.Initialize(aLEInfo);
for (; anIt.More(); anIt.Next()) {
@@ -536,6 +525,7 @@ void Path (const GeomAdaptor_Surface& aGAS,
if (iCnt==1) {
// the one and only way to go out .
pEdgeInfo=&anEI;
anIsFound=Standard_True;
break;
}
//
@@ -558,25 +548,15 @@ void Path (const GeomAdaptor_Surface& aGAS,
anAngleOut=anEI.Angle();
anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
}
if (isBoundary && anEI.IsInside())
{
++aNbWaysInside;
pOnlyWayIn = &anEI;
}
if (anAngle < aMinAngle - eps) {
aMinAngle=anAngle;
pEdgeInfo=&anEI;
anIsFound=Standard_True;
}
}
} // for (; anIt.More(); anIt.Next())
if (aNbWaysInside == 1)
{
pEdgeInfo = pOnlyWayIn;
}
//
if (!pEdgeInfo) {
if (!anIsFound) {
// no way to go . (Error)
return;
}

View File

@@ -525,7 +525,6 @@ namespace {
struct EdgeData {
const TopoDS_Edge* Edge; // Edge
Standard_Real VParameter; // Parameter of the vertex on the edge
Standard_Boolean IsClosed; // Closed flag of the edge
Geom2dAdaptor_Curve GAdaptor; // 2D adaptor for PCurve of the edge on the face
Standard_Real First; // First parameter in the range
Standard_Real Last; // Last parameter in the rage
@@ -611,9 +610,9 @@ static
continue;
}
//
if ((!theEData1.IsClosed && Abs (aTint1 - aT1) > aHalfR1) ||
(!theEData2.IsClosed && Abs (aTint2 - aT2) > aHalfR2)) {
// intersection is on the other end of the edge
if (Abs(aTint1 - aT1) > aHalfR1 ||
Abs(aTint2 - aT2) > aHalfR2) {
// intersection on the other end of the closed edge
continue;
}
//
@@ -635,7 +634,7 @@ void CorrectWires(const TopoDS_Face& aFx,
const TopTools_IndexedMapOfShape& aMapToAvoid)
{
Standard_Integer i, aNbV;
Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2;
Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2, aT;
gp_Pnt aP, aPV;
gp_Pnt2d aP2D;
TopoDS_Face aF;
@@ -645,9 +644,11 @@ void CorrectWires(const TopoDS_Face& aFx,
aF=aFx;
aF.Orientation(TopAbs_FORWARD);
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aFx);
TopExp::MapShapesAndUniqueAncestors (aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE, Standard_True);
//
TopExp::MapShapesAndAncestors(aF,
TopAbs_VERTEX,
TopAbs_EDGE,
aMVE);
NCollection_DataMap<TopoDS_Shape, Standard_Real> aMapEdgeLen;
aNbV=aMVE.Extent();
for (i=1; i<=aNbV; ++i) {
@@ -665,13 +666,7 @@ void CorrectWires(const TopoDS_Face& aFx,
const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aIt.Value());
const Handle(Geom2d_Curve)& aC2D=
BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
Standard_Real aT = BRep_Tool::Parameter (aV, aE);
Standard_Boolean isClosed = Standard_False;
{
TopoDS_Vertex aV1, aV2;
TopExp::Vertices (aE, aV1, aV2);
isClosed = aV1.IsSame (aV2);
}
aT=BRep_Tool::Parameter(aV, aE);
//
aC2D->D0(aT, aP2D);
aS->D0(aP2D.X(), aP2D.Y(), aP);
@@ -679,7 +674,7 @@ void CorrectWires(const TopoDS_Face& aFx,
if (aD2>aD2max) {
aD2max=aD2;
}
EdgeData anEData = {&aE, aT, isClosed, Geom2dAdaptor_Curve(aC2D), aT1, aT2};
EdgeData anEData = {&aE, aT, Geom2dAdaptor_Curve(aC2D), aT1, aT2};
aLEPars.Append(anEData);
}
//

View File

@@ -363,8 +363,9 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_approx);
#endif
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
myContinuity, myMaxDegree, myMaxSeg,
Only3d, Only2d);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_approx,t_approx);
approx_count++;

View File

@@ -126,8 +126,8 @@ Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index)
return approx.TolCurveOnSurf(Index);
}
void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
Standard_Real& Tol2d) const
inline void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
Standard_Real& Tol2d) const
{
Tol3d = approx.MaxErrorOnSurf();
Tol2d = 0;

View File

@@ -1055,7 +1055,6 @@ void BRepFeat_MakeRevolutionForm::Perform()
if(ex1.Current().IsSame(e1)) {
myLFMap(iter.Key()).Clear();
myLFMap(iter.Key()).Append(ex2.Current());
break; // break the cycle (e1 became a dead reference)
}
ex2.Next();
}
@@ -1063,14 +1062,16 @@ void BRepFeat_MakeRevolutionForm::Perform()
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
for(; iter1.More(); iter1.Next()) {
const TopoDS_Shape& f1 = iter1.Key();
const TopoDS_Shape& e1 = iter1.Value().First();
TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
for(; ex1.More(); ex1.Next()) {
if(ex1.Current().IsSame(e1)) {
mySlface(iter1.Key()).Clear();
mySlface(iter1.Key()).Append(ex2.Current());
break; // break the cycle (e1 became a dead reference)
const TopoDS_Shape& E1 = ex1.Current();
const TopoDS_Shape& E2 = ex2.Current();
if(E1.IsSame(e1)) {
mySlface(f1).Clear();
mySlface(f1).Append(E2);
}
ex2.Next();
}
@@ -1157,9 +1158,9 @@ void BRepFeat_MakeRevolutionForm::Perform()
const TopoDS_Shape& sh = it1.Value().First();
exx.Init(VraiForm, TopAbs_FACE);
for(; exx.More(); exx.Next()) {
TopoDS_Face fac = TopoDS::Face(exx.Current());
const TopoDS_Face& fac = TopoDS::Face(exx.Current());
TopExp_Explorer exx1(fac, TopAbs_WIRE);
TopoDS_Wire thew = TopoDS::Wire(exx1.Current());
const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
if(thew.IsSame(myFShape)) {
const TopTools_ListOfShape& desfaces = trP.Modified(f2);
myMap(myFShape) = desfaces;
@@ -1171,13 +1172,13 @@ void BRepFeat_MakeRevolutionForm::Perform()
continue;
}
if(fac.IsSame(sh)) {
if (! trP.IsDeleted(fac))
{
if (trP.IsDeleted(fac)) {
}
else {
const TopTools_ListOfShape& desfaces = trP.Modified(fac);
if(!desfaces.IsEmpty()) {
myMap(orig).Clear();
myMap(orig) = trP.Modified(fac);
break; // break the cycle (sh became a dead reference)
}
}
}

View File

@@ -149,6 +149,9 @@ static void TrimEdge (const TopoDS_Edge& Edge,
TColStd_SequenceOfReal& ThePar,
TopTools_SequenceOfShape& S);
static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
const TopoDS_Face& F);
static Standard_Integer PosOnFace (Standard_Real d1,
Standard_Real d2,
Standard_Real d3);
@@ -983,8 +986,8 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
// skin => same orientation E[0] , inverted orientation E[2]
// if contreskin it is inverted.
//--------------------------------------------------------------
E[0].Orientation(BRepTools::OriEdgeInFace(E[0],F[0]));
E[2].Orientation(BRepTools::OriEdgeInFace(E[2],F[1]));
E[0].Orientation(OriEdgeInFace(E[0],F[0]));
E[2].Orientation(OriEdgeInFace(E[2],F[1]));
if (DistanceToOZ(VF) < DistanceToOZ(VL) ) {
// Skin
@@ -1196,14 +1199,14 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
TopTools_ListIteratorOfListOfShape itl;
const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF);
TopAbs_Orientation Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LF.First()),
TopAbs_Orientation Ori = OriEdgeInFace(TopoDS::Edge(LF.First()),
CurrentFace);
for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) {
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
MapBis(CurrentFace).Append(RE.Oriented(Ori));
}
const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL);
Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
Ori = OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) {
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
MapBis(CurrentFace).Append(RE.Oriented(Ori));
@@ -2917,6 +2920,26 @@ static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
return TopAbs_REVERSED;
}
//=======================================================================
//function : OriEdgeInFace
//purpose :
//=======================================================================
TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
const TopoDS_Face& F )
{
TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for (; Exp.More() ;Exp.Next()) {
if (Exp.Current().IsSame(E)) {
return Exp.Current().Orientation();
}
}
throw Standard_ConstructionError("BRepFill_Evolved::OriEdgeInFace");
}
//=======================================================================
//function : IsOnFace

View File

@@ -451,12 +451,7 @@ void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
Standard_Boolean BRepFill_LocationLaw::IsClosed() const
{
if (myPath.Closed())
return Standard_True;
TopoDS_Vertex V1, V2;
TopExp::Vertices(myPath, V1, V2);
return (V1.IsSame(V2));
return myPath.Closed();
}
//=======================================================================

View File

@@ -1377,7 +1377,7 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
BB.Add(aWire, CurEdge);
} //for (jj = 2; jj <= SeqEdges.Length(); jj++)
//case of closed wire
if (myLocation->IsClosed() &&
if (mySection->IsVClosed() &&
!CurVertex.IsSame(FirstVertex))
{
const TopTools_ListOfShape& Elist = VEmap.FindFromKey(CurVertex);

View File

@@ -330,9 +330,8 @@ static Standard_Boolean SameParameter(TopoDS_Edge& E,
if (!HasPCurves(E))
{
Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( Pcurv );
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
Precision::Confusion());
AppCurve.Perform(10, 10, GeomAbs_C1, Standard_True);
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
Precision::Confusion(), GeomAbs_C1, 10, 10, Standard_True);
if (AppCurve.IsDone() && AppCurve.HasResult())
{
C3d = AppCurve.Curve3d();

View File

@@ -1347,13 +1347,15 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
}
// Eval tol2d to compute SameRange
Standard_Real TolSameRange = Max(GAC.Resolution(theTolerance), Precision::PConfusion());
Standard_Real UResol = Max(GAS.UResolution(theTolerance), Precision::PConfusion());
Standard_Real VResol = Max(GAS.VResolution(theTolerance), Precision::PConfusion());
Standard_Real Tol2d = Min(UResol, VResol);
for(Standard_Integer i = 0; i < 2; i++){
Handle(Geom2d_Curve) curPC = PC[i];
Standard_Boolean updatepc = 0;
if(curPC.IsNull()) break;
if(!SameRange){
GeomLib::SameRange(TolSameRange,
GeomLib::SameRange(Tol2d,
PC[i],GCurve->First(),GCurve->Last(),
f3d,l3d,curPC);
@@ -1373,17 +1375,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
if(GAC2d.GetType() == GeomAbs_BSplineCurve &&
GAC2d.Continuity() == GeomAbs_C0) {
Standard_Real UResol = GAS.UResolution(theTolerance);
Standard_Real VResol = GAS.VResolution(theTolerance);
Standard_Real TolConf2d = Min(UResol, VResol);
TolConf2d = Max(TolConf2d, Precision::PConfusion());
Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
Handle(Geom2d_BSplineCurve) bs2dsov = bs2d;
Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter();
Standard_Boolean repar = Standard_True;
gp_Pnt2d OriginPoint;
bs2d->D0(fC0, OriginPoint);
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, TolConf2d);
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, Tol2d);
isBSP = Standard_True;
if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000
@@ -1427,7 +1425,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
}
d = sqrt(d)*.1;
Tol2dbail = Max(Min(Tol2dbail,d), TolConf2d);
Tol2dbail = Max(Min(Tol2dbail,d),Tol2d);
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail);
@@ -1533,8 +1531,8 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
GAC2d.Load(bs2d,f3d,l3d);
curPC = bs2d;
if(Abs(bs2d->FirstParameter() - fC0) > TolSameRange ||
Abs(bs2d->LastParameter() - lC0) > TolSameRange) {
if(Abs(bs2d->FirstParameter() - fC0) > Tol2d ||
Abs(bs2d->LastParameter() - lC0) > Tol2d ) {
Standard_Integer NbKnots = bs2d->NbKnots();
TColStd_Array1OfReal Knots(1,NbKnots);
bs2d->Knots(Knots);
@@ -1587,7 +1585,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
//Approx_SameParameter has failed.
//Consequently, the situation might be,
//when 3D and 2D-curve do not have same-range.
GeomLib::SameRange( TolSameRange, PC[i],
GeomLib::SameRange( Tol2d, PC[i],
GCurve->First(), GCurve->Last(),
f3d,l3d,curPC);
@@ -1833,12 +1831,6 @@ void BRepLib::UpdateInnerTolerances(const TopoDS_Shape& aShape)
for (Standard_Integer i = 1; i <= EFmap.Extent(); i++)
{
TopoDS_Edge anEdge = TopoDS::Edge(EFmap.FindKey(i));
if (!BRep_Tool::IsGeometric(anEdge))
{
continue;
}
TopoDS_Vertex V1, V2;
TopExp::Vertices(anEdge, V1, V2);
Standard_Real fpar, lpar;

View File

@@ -55,7 +55,6 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <NCollection_Vector.hxx>
//=======================================================================
//function : Controle
@@ -175,70 +174,6 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
{
Init(S,Tol,OnlyPlane,OnlyClosed);
}
namespace
{
static void fillParams (const TColStd_Array1OfReal& theKnots,
Standard_Integer theDegree,
Standard_Real theParMin,
Standard_Real theParMax,
NCollection_Vector<Standard_Real>& theParams)
{
Standard_Real aPrevPar = theParMin;
theParams.Append (aPrevPar);
Standard_Integer aNbP = Max (theDegree, 1);
for (Standard_Integer i = 1;
(i < theKnots.Length()) && (theKnots (i) < (theParMax - Precision::PConfusion())); ++i)
{
if (theKnots (i + 1) < theParMin + Precision::PConfusion())
continue;
Standard_Real aStep = (theKnots (i + 1) - theKnots (i)) / aNbP;
for (Standard_Integer k = 1; k <= aNbP ; ++k)
{
Standard_Real aPar = theKnots (i) + k * aStep;
if (aPar > theParMax - Precision::PConfusion())
break;
if (aPar > aPrevPar + Precision::PConfusion())
{
theParams.Append (aPar);
aPrevPar = aPar;
}
}
}
theParams.Append (theParMax);
}
static void fillPoints (const BRepAdaptor_Curve& theCurve,
const NCollection_Vector<Standard_Real> theParams,
TColgp_SequenceOfPnt& thePoints,
TColStd_SequenceOfReal& theWeights)
{
Standard_Real aDistPrev = 0., aDistNext;
gp_Pnt aPPrev (theCurve.Value (theParams (0))), aPNext;
for (Standard_Integer iP = 1; iP <= theParams.Length(); ++iP)
{
if (iP < theParams.Length())
{
Standard_Real aParam = theParams (iP);
aPNext = theCurve.Value (aParam);
aDistNext = aPPrev.Distance (aPNext);
}
else
aDistNext = 0.0;
thePoints.Append (aPPrev);
theWeights.Append (aDistPrev + aDistNext);
aDistPrev = aDistNext;
aPPrev = aPNext;
}
}
}
//=======================================================================
//function : Init
//purpose :
@@ -347,57 +282,117 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
}
Standard_Integer iNbPoints=0;
// Fill the parameters of the sampling points
NCollection_Vector<Standard_Real> aParams;
// Add the points with weights to the sequences
switch (c.GetType())
{
case GeomAbs_BezierCurve:
case GeomAbs_BezierCurve:
{
// Put all poles for bezier
Handle(Geom_BezierCurve) GC = c.Bezier();
TColStd_Array1OfReal aKnots (1, 2);
aKnots.SetValue (1, GC->FirstParameter());
aKnots.SetValue (2, GC->LastParameter());
fillParams (aKnots, GC->Degree(), dfUf, dfUl, aParams);
break;
Standard_Integer iNbPol = GC->NbPoles();
Standard_Real tf = GC->FirstParameter();
Standard_Real tl = GC->LastParameter();
Standard_Real r = (dfUl - dfUf) / (tl - tf);
r *= iNbPol;
if ( iNbPol < 2 || r < 1.)
// Degenerate
continue;
else
{
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
{
if (iPol<iNbPol)
{
aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
}
case GeomAbs_BSplineCurve:
break;
case GeomAbs_BSplineCurve:
{
// Put all poles for bspline
Handle(Geom_BSplineCurve) GC = c.BSpline();
fillParams (GC->Knots(), GC->Degree(), dfUf, dfUl, aParams);
break;
Standard_Integer iNbPol = GC->NbPoles();
Standard_Real tf = GC->FirstParameter();
Standard_Real tl = GC->LastParameter();
Standard_Real r = (dfUl - dfUf) / (tl - tf);
r *= iNbPol;
if ( iNbPol < 2 || r < 1.)
// Degenerate
continue;
else
{
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
GC->Poles(aPoles->ChangeArray1());
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
{
if (iPol<iNbPol)
{
aPoleNext = aPoles->Value(iPol+1);
dfDistNext = aPolePrev.Distance(aPoleNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPolePrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPolePrev = aPoleNext;
}
}
}
case GeomAbs_Line:
{
// Two points on a straight segment
aParams.Append (dfUf);
aParams.Append (dfUl);
break;
}
case GeomAbs_Circle:
case GeomAbs_Ellipse:
case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
// Four points on other analytical curves
iNbPoints = 4;
Standard_FALLTHROUGH
default:
break;
case GeomAbs_Line:
case GeomAbs_Circle:
case GeomAbs_Ellipse:
case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
// Two points on straight segment, Four points on otheranalitical curves
iNbPoints = (c.GetType() == GeomAbs_Line ? 2 : 4);
Standard_FALLTHROUGH
default:
{
// Put some points on other curves
if (iNbPoints == 0)
iNbPoints = 15 + c.NbIntervals (GeomAbs_C3);
TColStd_Array1OfReal aBounds (1, 2);
aBounds.SetValue (1, dfUf);
aBounds.SetValue (2, dfUl);
fillParams (aBounds, iNbPoints - 1, dfUf, dfUl, aParams);
}
}
// Add the points with weights to the sequences
fillPoints (c, aParams, aPoints, aWeight);
}
if (iNbPoints==0)
iNbPoints = 15 + c.NbIntervals(GeomAbs_C3);
Standard_Real dfDelta = (dfUl-dfUf)/(iNbPoints-1);
Standard_Integer iPoint;
Standard_Real dfU;
gp_Pnt aPointPrev = c.Value(dfUf), aPointNext;
Standard_Real dfDistPrev = 0., dfDistNext;
for (iPoint=1, dfU=dfUf+dfDelta;
iPoint<=iNbPoints;
iPoint++, dfU+=dfDelta)
{
if (iPoint<iNbPoints)
{
aPointNext = c.Value(dfU);
dfDistNext = aPointPrev.Distance(aPointNext);
}
else
dfDistNext = 0.;
aPoints.Append (aPointPrev);
aWeight.Append (dfDistPrev+dfDistNext);
dfDistPrev = dfDistNext;
aPointPrev = aPointNext;
}
} // default:
} // switch (c.GetType()) ...
} // for (ex.Init(S,TopAbs_EDGE); ex.More() && control; ex.Next()) ...
if (aPoints.Length() < 3) {
return;
@@ -510,33 +505,79 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
}
}
}
//
// let us be more tolerant (occ415)
Standard_Real dfDist = RealLast();
Handle(Geom_Plane) aPlane;
//
if (isSolved) {
//Plane normal can have two directions, direction is chosen
//according to direction of eigenvector
gp_Vec anN(aVec(1), aVec(2), aVec(3));
aPlane = new Geom_Plane(aBaryCenter,anN);
dfDist = Controle (aPoints, aPlane);
}
//
if (!isSolved || myTolerance < dfDist) {
gp_Pnt aFirstPnt=aPoints(1);
for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) {
gp_Vec aDir(aFirstPnt,aPoints(iPoint));
Standard_Real dfSide=aDir.Magnitude();
if (dfSide<myTolerance) {
continue; // degeneration
}
for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
if (!isSolved)
return;
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
gp_Vec aN (aVec (1), aVec (2), aVec (3));
Handle(Geom_Plane) aPlane = new Geom_Plane (aBaryCenter, aN);
myTolReached = Controle (aPoints, aPlane);
const Standard_Real aWeakness = 5.0;
if (myTolReached <= myTolerance || (Tol < 0 && myTolReached < myTolerance * aWeakness))
{
mySurface = aPlane;
//If S is wire, try to orient surface according to orientation of wire.
if (S.ShapeType() == TopAbs_WIRE && S.Closed())
{
TopoDS_Wire aW = TopoDS::Wire (S);
TopoDS_Face aTmpFace = BRepLib_MakeFace (mySurface, Precision::Confusion());
BRep_Builder BB;
BB.Add (aTmpFace, aW);
BRepTopAdaptor_FClass2d FClass (aTmpFace, 0.);
if (FClass.PerformInfinitePoint() == TopAbs_IN)
{
gp_Dir aNorm = aPlane->Position().Direction();
aNorm.Reverse();
mySurface = new Geom_Plane (aPlane->Position().Location(), aNorm);
if (aCross.Magnitude() > dfSide*myTolerance) {
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aBaryCenter, aCross);
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
if (dfDist2 < myTolerance) {
myTolReached = dfDist2;
mySurface = aPlane2;
return;
}
if (dfDist2 < dfDist) {
dfDist = dfDist2;
aPlane = aPlane2;
}
}
}
}
}
//
//XXf
//static Standard_Real weakness = 5.0;
Standard_Real weakness = 5.0;
//XXf
if(dfDist <= myTolerance || (dfDist < myTolerance*weakness && Tol<0)) {
//XXf
//myTolReached = dfDist;
//XXt
mySurface = aPlane;
//If S is wire, try to orient surface according to orientation of wire.
if(S.ShapeType() == TopAbs_WIRE && S.Closed())
{
//
TopoDS_Wire aW = TopoDS::Wire(S);
TopoDS_Face aTmpFace = BRepLib_MakeFace(mySurface, Precision::Confusion());
BRep_Builder BB;
BB.Add(aTmpFace, aW);
BRepTopAdaptor_FClass2d FClass(aTmpFace, 0.);
if ( FClass.PerformInfinitePoint() == TopAbs_IN )
{
gp_Dir aN = aPlane->Position().Direction();
aN.Reverse();
mySurface = new Geom_Plane(aPlane->Position().Location(), aN);
}
}
}
//XXf
myTolReached = dfDist;
//XXt
}
//=======================================================================
//function : Found

View File

@@ -34,6 +34,7 @@
#include <NCollection_Vector.hxx>
#include <algorithm>
#include <stack>
const Standard_Real AngDeviation1Deg = M_PI/180.;
const Standard_Real AngDeviation90Deg = 90 * AngDeviation1Deg;
@@ -652,53 +653,56 @@ void BRepMesh_Delaun::insertInternalEdges()
//=======================================================================
//function : isBoundToFrontier
//purpose : Goes through the neighbour triangles around the given node
// started from the given link, returns TRUE if some triangle
// has a bounding frontier edge or FALSE elsewhere.
// Stop link is used to prevent cycles.
// Previous element Id is used to identify next neighbor element.
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_Delaun::isBoundToFrontier(
const Standard_Integer theRefNodeId,
const Standard_Integer theRefLinkId,
const Standard_Integer theStopLinkId,
const Standard_Integer thePrevElementId)
const Standard_Integer theRefLinkId)
{
const BRepMesh_PairOfIndex& aPair =
myMeshData->ElementsConnectedTo( theRefLinkId );
if ( aPair.IsEmpty() )
return Standard_False;
std::stack<Standard_Integer> aLinkStack;
TColStd_PackedMapOfInteger aVisitedLinks;
Standard_Integer aNbElements = aPair.Extent();
for ( Standard_Integer anElemIt = 1; anElemIt <= aNbElements; ++anElemIt )
aLinkStack.push (theRefLinkId);
while (!aLinkStack.empty ())
{
const Standard_Integer aTriId = aPair.Index(anElemIt);
if ( aTriId < 0 || aTriId == thePrevElementId )
continue;
const Standard_Integer aCurrentLinkId = aLinkStack.top ();
aLinkStack.pop ();
const BRepMesh_Triangle& aElement = GetTriangle(aTriId);
const Standard_Integer(&anEdges)[3] = aElement.myEdges;
const BRepMesh_PairOfIndex& aPair = myMeshData->ElementsConnectedTo (aCurrentLinkId);
if (aPair.IsEmpty ())
return Standard_False;
for ( Standard_Integer anEdgeIt = 0; anEdgeIt < 3; ++anEdgeIt )
const Standard_Integer aNbElements = aPair.Extent ();
for (Standard_Integer anElemIt = 1; anElemIt <= aNbElements; ++anElemIt)
{
const Standard_Integer anEdgeId = anEdges[anEdgeIt];
if ( anEdgeId == theRefLinkId )
const Standard_Integer aTriId = aPair.Index (anElemIt);
if (aTriId < 0)
continue;
if ( anEdgeId == theStopLinkId )
return Standard_False;
const BRepMesh_Triangle& aElement = GetTriangle (aTriId);
const Standard_Integer (&anEdges)[3] = aElement.myEdges;
const BRepMesh_Edge& anEdge = GetEdge( anEdgeId );
if ( anEdge.FirstNode() != theRefNodeId &&
anEdge.LastNode() != theRefNodeId )
for (Standard_Integer anEdgeIt = 0; anEdgeIt < 3; ++anEdgeIt)
{
continue;
const Standard_Integer anEdgeId = anEdges[anEdgeIt];
if (anEdgeId == aCurrentLinkId)
continue;
const BRepMesh_Edge& anEdge = GetEdge (anEdgeId);
if (anEdge.FirstNode () != theRefNodeId &&
anEdge.LastNode () != theRefNodeId)
{
continue;
}
if (anEdge.Movability () != BRepMesh_Free)
return Standard_True;
if (aVisitedLinks.Add (anEdgeId))
{
aLinkStack.push (anEdgeId);
}
}
if ( anEdge.Movability() != BRepMesh_Free )
return Standard_True;
return isBoundToFrontier( theRefNodeId, anEdgeId, theStopLinkId, aTriId );
}
}
@@ -792,8 +796,7 @@ void BRepMesh_Delaun::cleanupMesh()
for ( Standard_Integer aLinkNodeIt = 0; aLinkNodeIt < 2; ++aLinkNodeIt )
{
isConnected[aLinkNodeIt] = isBoundToFrontier( ( aLinkNodeIt == 0 ) ?
anEdge.FirstNode() : anEdge.LastNode(),
aFreeEdgeId, aFreeEdgeId, -1);
anEdge.FirstNode() : anEdge.LastNode(), aFreeEdgeId);
}
if ( !isConnected[0] || !isConnected[1] )
@@ -1224,9 +1227,9 @@ Standard_Boolean BRepMesh_Delaun::checkIntersection(
//function : addTriangle
//purpose : Add a triangle based on the given oriented edges into mesh
//=======================================================================
void BRepMesh_Delaun::addTriangle( const Standard_Integer (&theEdgesId)[3],
const Standard_Boolean (&theEdgesOri)[3],
const Standard_Integer (&theNodesId)[3] )
inline void BRepMesh_Delaun::addTriangle( const Standard_Integer (&theEdgesId)[3],
const Standard_Boolean (&theEdgesOri)[3],
const Standard_Integer (&theNodesId)[3] )
{
Standard_Integer aNewTriangleId =
myMeshData->AddElement(BRepMesh_Triangle(theEdgesId,
@@ -1890,7 +1893,7 @@ void BRepMesh_Delaun::meshPolygon(IMeshData::SequenceOfInteger& thePolygon,
//function : meshElementaryPolygon
//purpose : Triangulation of closed polygon containing only three edges.
//=======================================================================
Standard_Boolean BRepMesh_Delaun::meshElementaryPolygon(
inline Standard_Boolean BRepMesh_Delaun::meshElementaryPolygon(
const IMeshData::SequenceOfInteger& thePolygon)
{
Standard_Integer aPolyLen = thePolygon.Length();
@@ -2434,9 +2437,8 @@ BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg(
p3 = GetVertex( theEdg2.FirstNode() ).Coord();
p4 = GetVertex( theEdg2.LastNode() ).Coord();
Standard_Real aIntParams[2];
return BRepMesh_GeomTool::IntSegSeg(p1, p2, p3, p4,
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt, aIntParams);
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt);
}
//=============================================================================

View File

@@ -292,12 +292,8 @@ private:
//! Goes through the neighbour triangles around the given node started
//! from the given link, returns TRUE if some triangle has a bounding
//! frontier edge or FALSE elsewhere.
//! Stop link is used to prevent cycles.
//! Previous element Id is used to identify next neighbor element.
Standard_Boolean isBoundToFrontier (const Standard_Integer theRefNodeId,
const Standard_Integer theRefLinkId,
const Standard_Integer theStopLinkId,
const Standard_Integer thePrevElementId);
const Standard_Integer theRefLinkId);
//! Remove internal triangles from the given polygon.
void cleanupPolygon (const IMeshData::SequenceOfInteger& thePolygon,

View File

@@ -19,6 +19,191 @@
#include <OSD_Parallel.hxx>
#include <BRepMesh_GeomTool.hxx>
namespace
{
const Standard_Real MaxTangentAngle = 5. * M_PI / 180.;
//! Functor to be used to fill segments and bounding box tree in parallel.
class SegmentsFiller
{
public:
//! Constructor.
SegmentsFiller(const IMeshData::IFaceHandle& theDFace,
Handle(BRepMesh_FaceChecker::ArrayOfSegments)& theWiresSegments,
Handle(BRepMesh_FaceChecker::ArrayOfBndBoxTree)& theWiresBndBoxTree)
: myDFace(theDFace),
myWiresSegments(theWiresSegments),
myWiresBndBoxTree(theWiresBndBoxTree)
{
myWiresSegments = new BRepMesh_FaceChecker::ArrayOfSegments (0, myDFace->WiresNb() - 1);
myWiresBndBoxTree = new BRepMesh_FaceChecker::ArrayOfBndBoxTree (0, myDFace->WiresNb() - 1);
}
//! Performs initialization of wire with the given index.
void operator()(const Standard_Integer theWireIndex) const
{
const IMeshData::IWireHandle& aDWire = myDFace->GetWire(theWireIndex);
Handle(NCollection_IncAllocator) aTmpAlloc1 = new NCollection_IncAllocator();
Handle(BRepMesh_FaceChecker::Segments) aSegments =
new BRepMesh_FaceChecker::Segments(aDWire->EdgesNb(), aTmpAlloc1);
Handle(IMeshData::BndBox2dTree) aBndBoxTree = new IMeshData::BndBox2dTree(aTmpAlloc1);
myWiresSegments ->ChangeValue(theWireIndex) = aSegments;
myWiresBndBoxTree->ChangeValue(theWireIndex) = aBndBoxTree;
Handle(NCollection_IncAllocator) aTmpAlloc2 = new NCollection_IncAllocator();
IMeshData::BndBox2dTreeFiller aBndBoxTreeFiller(*aBndBoxTree, aTmpAlloc2);
for (Standard_Integer aEdgeIt = 0; aEdgeIt < aDWire->EdgesNb(); ++aEdgeIt)
{
// TODO: check 2d wire for consistency.
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge(aEdgeIt);
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(myDFace.get(), aDWire->GetEdgeOrientation(aEdgeIt));
for (Standard_Integer aPointIt = 1; aPointIt < aPCurve->ParametersNb(); ++aPointIt)
{
gp_Pnt2d& aPnt1 = aPCurve->GetPoint(aPointIt - 1);
gp_Pnt2d& aPnt2 = aPCurve->GetPoint(aPointIt);
Bnd_Box2d aBox;
aBox.Add(aPnt1);
aBox.Add(aPnt2);
aBox.Enlarge(Precision::Confusion());
aBndBoxTreeFiller.Add(aSegments->Size(), aBox);
aSegments->Append(BRepMesh_FaceChecker::Segment(aDEdge, &aPnt1, &aPnt2));
}
}
aBndBoxTreeFiller.Fill();
}
private:
SegmentsFiller (const SegmentsFiller& theOther);
void operator=(const SegmentsFiller& theOther);
private:
const IMeshData::IFaceHandle& myDFace;
Handle(BRepMesh_FaceChecker::ArrayOfSegments)& myWiresSegments;
Handle(BRepMesh_FaceChecker::ArrayOfBndBoxTree)& myWiresBndBoxTree;
};
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
class BndBox2dTreeSelector : public IMeshData::BndBox2dTree::Selector
{
public:
//! Constructor.
BndBox2dTreeSelector(const Standard_Real theTolerance)
: myMaxLoopSize(M_PI * theTolerance * theTolerance),
mySelfSegmentIndex(-1),
myIndices(256, new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
}
//! Sets working set of segments.
void SetSegments(const Handle(BRepMesh_FaceChecker::Segments)& theSegments)
{
mySegments = theSegments;
}
//! Resets current selector.
void Reset(const BRepMesh_FaceChecker::Segment* theSegment,
const Standard_Integer theSelfSegmentIndex)
{
myIndices.Clear();
mySelfSegmentIndex = theSelfSegmentIndex;
mySegment = theSegment;
myBox.SetVoid();
myBox.Add(*mySegment->Point1);
myBox.Add(*mySegment->Point2);
myBox.Enlarge(Precision::Confusion());
}
//! Indicates should the given box be rejected or not.
virtual Standard_Boolean Reject(const Bnd_Box2d& theBox) const
{
return myBox.IsOut(theBox);
}
//! Accepts segment with the given index in case if it fits conditions.
virtual Standard_Boolean Accept(const Standard_Integer& theSegmentIndex)
{
const BRepMesh_FaceChecker::Segment& aSegment = mySegments->Value(theSegmentIndex);
gp_Pnt2d aIntPnt;
const BRepMesh_GeomTool::IntFlag aIntStatus = BRepMesh_GeomTool::IntSegSeg(
mySegment->Point1->XY(), mySegment->Point2->XY(),
aSegment.Point1->XY(), aSegment.Point2->XY(),
Standard_False, Standard_False, aIntPnt);
if (aIntStatus == BRepMesh_GeomTool::Cross)
{
const Standard_Real aAngle = gp_Vec2d(mySegment->Point1->XY(), mySegment->Point2->XY()).Angle(
gp_Vec2d(aSegment.Point1->XY(), aSegment.Point2->XY()));
if (Abs(aAngle) < MaxTangentAngle)
{
return Standard_False;
}
if (mySelfSegmentIndex != -1)
{
gp_XY aPrevVec;
Standard_Real aSumS = 0.;
const gp_XY& aRefPnt = aIntPnt.Coord();
for (Standard_Integer i = mySelfSegmentIndex; i < theSegmentIndex; ++i)
{
const BRepMesh_FaceChecker::Segment& aCurrSegment = mySegments->Value(i);
gp_XY aCurVec = aCurrSegment.Point2->XY() - aRefPnt;
if (aCurVec.SquareModulus() < gp::Resolution())
continue;
if (aPrevVec.SquareModulus() > gp::Resolution())
aSumS += aPrevVec ^ aCurVec;
aPrevVec = aCurVec;
}
if (Abs(aSumS / 2.) < myMaxLoopSize)
{
return Standard_False;
}
}
myIndices.Append(theSegmentIndex);
return Standard_True;
}
return Standard_False;
}
//! Returns indices of intersecting segments.
const IMeshData::VectorOfInteger& Indices() const
{
return myIndices;
}
private:
Standard_Real myMaxLoopSize;
Standard_Integer mySelfSegmentIndex;
Handle(BRepMesh_FaceChecker::Segments) mySegments;
const BRepMesh_FaceChecker::Segment* mySegment;
Bnd_Box2d myBox;
IMeshData::VectorOfInteger myIndices;
};
}
//=======================================================================
//function : Constructor
//purpose :
@@ -26,7 +211,8 @@
BRepMesh_FaceChecker::BRepMesh_FaceChecker(
const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters)
: BRepMesh_SegmentedFace (theFace, theParameters)
: myDFace(theFace),
myParameters(theParameters)
{
}
@@ -44,39 +230,50 @@ BRepMesh_FaceChecker::~BRepMesh_FaceChecker()
//=======================================================================
Standard_Boolean BRepMesh_FaceChecker::Perform()
{
myIntersectingEdges = new IMeshData::MapOfIEdgePtr;
collectSegments();
myIntersectingEdges = new IMeshData::MapOfIEdgePtr;
myWiresIntersectingEdges = new ArrayOfMapOfIEdgePtr(0, myDFace->WiresNb() - 1);
OSD_Parallel::For(0, myDFace->WiresNb(), *this, !isParallel());
collectResult();
myWiresBndBoxTree .Nullify();
myWiresSegments .Nullify();
myWiresBndBoxTree.Nullify();
myWiresSegments.Nullify();
myWiresIntersectingEdges.Nullify();
return myIntersectingEdges->IsEmpty();
}
//=======================================================================
//function : collectSegments
//purpose :
//=======================================================================
void BRepMesh_FaceChecker::collectSegments()
{
SegmentsFiller aSegmentsFiller(myDFace, myWiresSegments, myWiresBndBoxTree);
OSD_Parallel::For(0, myDFace->WiresNb(), aSegmentsFiller, !isParallel());
myWiresIntersectingEdges = new ArrayOfMapOfIEdgePtr(0, myDFace->WiresNb() - 1);
}
//=======================================================================
//function : perform
//purpose :
//=======================================================================
void BRepMesh_FaceChecker::perform(const Standard_Integer theWireIndex) const
{
const Handle(Segments)& aSegments1 = myWiresSegments ->Value (theWireIndex);
const Handle(Segments)& aSegments1 = myWiresSegments->Value(theWireIndex);
Handle(IMeshData::MapOfIEdgePtr)& aIntersections = myWiresIntersectingEdges->ChangeValue(theWireIndex);
BRepMesh_SegmentedFace::BndBox2dTreeSelector aSelector (Standard_False);
// TODO: Tolerance is set to twice value of face deflection in order to fit regressions.
BndBox2dTreeSelector aSelector(2 * myDFace->GetDeflection());
for (Standard_Integer aWireIt = theWireIndex; aWireIt < myDFace->WiresNb(); ++aWireIt)
{
const Handle(IMeshData::BndBox2dTree)& aBndBoxTree2 = myWiresBndBoxTree->Value(aWireIt);
const Handle(Segments)& aSegments2 = myWiresSegments ->Value(aWireIt);
const Handle(Segments)& aSegments2 = myWiresSegments->Value(aWireIt);
aSelector.SetSegments(aSegments2);
for (Standard_Integer aSegmentIt = 0; aSegmentIt < aSegments1->Size(); ++aSegmentIt)
{
const BRepMesh_SegmentedFace::Segment& aSegment1 = aSegments1->Value(aSegmentIt);
const BRepMesh_FaceChecker::Segment& aSegment1 = aSegments1->Value(aSegmentIt);
aSelector.Reset(&aSegment1, (aWireIt == theWireIndex) ? aSegmentIt : -1);
if (aBndBoxTree2->Select(aSelector) != 0)
{
@@ -90,7 +287,7 @@ void BRepMesh_FaceChecker::perform(const Standard_Integer theWireIndex) const
const IMeshData::VectorOfInteger& aSegments = aSelector.Indices();
for (Standard_Integer aSelIt = 0; aSelIt < aSegments.Size(); ++aSelIt)
{
const BRepMesh_SegmentedFace::Segment& aSegment2 = aSegments2->Value(aSegments(aSelIt));
const BRepMesh_FaceChecker::Segment& aSegment2 = aSegments2->Value(aSegments(aSelIt));
aIntersections->Add(aSegment2.EdgePtr);
}
}

View File

@@ -16,18 +16,49 @@
#ifndef _BRepMesh_FaceChecker_HeaderFile
#define _BRepMesh_FaceChecker_HeaderFile
#include <BRepMesh_SegmentedFace.hxx>
#include <IMeshTools_Parameters.hxx>
#include <Standard_Transient.hxx>
#include <IMeshData_Face.hxx>
#include <Standard_Type.hxx>
#include <NCollection_Shared.hxx>
//! Auxiliary class checking wires of target face for self-intersections.
//! Explodes wires of discrete face on sets of segments using tessellation
//! data stored in model. Each segment is then checked for intersection with
//! other ones. All collisions are registerd and returned as result of check.
class BRepMesh_FaceChecker : public BRepMesh_SegmentedFace
class BRepMesh_FaceChecker : public Standard_Transient
{
public: //! @name mesher API
//! Identifies segment inside face.
struct Segment
{
IMeshData::IEdgePtr EdgePtr;
gp_Pnt2d* Point1; // \ Use explicit pointers to points instead of accessing
gp_Pnt2d* Point2; // / using indices.
Segment()
: Point1(NULL)
, Point2(NULL)
{
}
Segment(const IMeshData::IEdgePtr& theEdgePtr,
gp_Pnt2d* thePoint1,
gp_Pnt2d* thePoint2)
: EdgePtr(theEdgePtr)
, Point1(thePoint1)
, Point2(thePoint2)
{
}
};
typedef NCollection_Shared<NCollection_Vector<Segment> > Segments;
typedef NCollection_Shared<NCollection_Array1<Handle(Segments)> > ArrayOfSegments;
typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)> > ArrayOfBndBoxTree;
typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::MapOfIEdgePtr)> > ArrayOfMapOfIEdgePtr;
//! Default constructor
Standard_EXPORT BRepMesh_FaceChecker(const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters);
@@ -51,10 +82,19 @@ public: //! @name mesher API
perform(theWireIndex);
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceChecker, BRepMesh_SegmentedFace)
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceChecker, Standard_Transient)
private:
//! Returns True in case if check can be performed in parallel mode.
inline Standard_Boolean isParallel() const
{
return (myParameters.InParallel && myDFace->WiresNb() > 1);
}
//! Collects face segments.
void collectSegments();
//! Collects intersecting edges.
void collectResult();
@@ -69,6 +109,11 @@ private:
private:
IMeshData::IFaceHandle myDFace;
const IMeshTools_Parameters& myParameters;
Handle(ArrayOfSegments) myWiresSegments;
Handle(ArrayOfBndBoxTree) myWiresBndBoxTree;
Handle(ArrayOfMapOfIEdgePtr) myWiresIntersectingEdges;
Handle(IMeshData::MapOfIEdgePtr) myIntersectingEdges;

View File

@@ -1,100 +0,0 @@
// Created on: 2016-07-04
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_FaceIntersectionsSplitter.hxx>
#include <IMeshData_Wire.hxx>
#include <IMeshData_Edge.hxx>
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_FaceIntersectionsSplitter::BRepMesh_FaceIntersectionsSplitter(
const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters)
: BRepMesh_SegmentedFace (theFace, theParameters)
{
}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
BRepMesh_FaceIntersectionsSplitter::~BRepMesh_FaceIntersectionsSplitter()
{
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_FaceIntersectionsSplitter::Perform()
{
for (Standard_Integer aWireIt = 0; aWireIt < myDFace->WiresNb(); ++aWireIt)
{
Standard_Boolean isSplit = Standard_True;
while (isSplit)
{
collectSegments();
isSplit = perform(aWireIt);
myWiresSegments .Nullify();
myWiresBndBoxTree.Nullify();
}
}
return Standard_False;
}
//=======================================================================
//function : perform
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_FaceIntersectionsSplitter::perform(
const Standard_Integer theWireIndex)
{
const Handle(Segments)& aSegments1 = myWiresSegments->Value (theWireIndex);
BRepMesh_SegmentedFace::BndBox2dTreeSelector aSelector (Standard_True);
for (Standard_Integer aWireIt = theWireIndex; aWireIt < myDFace->WiresNb(); ++aWireIt)
{
const Handle(IMeshData::BndBox2dTree)& aBndBoxTree2 = myWiresBndBoxTree->Value(aWireIt);
const Handle(Segments)& aSegments2 = myWiresSegments ->Value(aWireIt);
aSelector.SetSegments(aSegments2);
for (Standard_Integer aSegmentIt = 0; aSegmentIt < aSegments1->Size(); ++aSegmentIt)
{
const BRepMesh_SegmentedFace::Segment& aSegment1 = aSegments1->Value(aSegmentIt);
aSelector.Reset(&aSegment1, (aWireIt == theWireIndex) ? aSegmentIt : -1);
if (aBndBoxTree2->Select(aSelector) != 0)
{
const IMeshData::VectorOfInteger& aSegments = aSelector.Indices();
const BRepMesh_SegmentedFace::VectorOfIntersectionParams& aIntParams = aSelector.IntParams();
for (Standard_Integer aSelIt = 0; aSelIt < aSegments.Size(); ++aSelIt)
{
const BRepMesh_SegmentedFace::Segment& aSegment2 = aSegments2->Value(aSegments(aSelIt));
//aIntersections->Add(aSegment1.EdgePtr);
//aIntersections->Add(aSegment2.EdgePtr);
}
//return Standard_False;
}
}
}
return Standard_False;
}

View File

@@ -1,55 +0,0 @@
// Created on: 2016-07-04
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_FaceIntersectionsSplitter_HeaderFile
#define _BRepMesh_FaceIntersectionsSplitter_HeaderFile
#include <BRepMesh_SegmentedFace.hxx>
//! Auxiliary class splitting intersecting segments of wires of target face.
//! Explodes wires of discrete face on sets of segments using tessellation
//! data stored in model. Each segment is then checked for intersection with
//! other ones and split on intersection point.
class BRepMesh_FaceIntersectionsSplitter : public BRepMesh_SegmentedFace
{
public: //! @name mesher API
//! Default constructor
Standard_EXPORT BRepMesh_FaceIntersectionsSplitter(
const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters);
//! Destructor
Standard_EXPORT virtual ~BRepMesh_FaceIntersectionsSplitter();
//! Performs split of intersecting segments of wires of the face.
//! @return True if there is no intersection, False elsewhere.
Standard_EXPORT Standard_Boolean Perform();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceIntersectionsSplitter, BRepMesh_SegmentedFace)
private:
//! Splits wire with the given index at first intersection point with others.
Standard_Boolean perform(const Standard_Integer theWireIndex);
private:
BRepMesh_FaceIntersectionsSplitter (const BRepMesh_FaceIntersectionsSplitter& theOther);
void operator=(const BRepMesh_FaceIntersectionsSplitter& theOther);
};
#endif

View File

@@ -333,8 +333,7 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt,
Standard_Real (&theParamOnSegment)[2])
gp_Pnt2d& theIntPnt)
{
Standard_Integer aPointHash[] = {
classifyPoint(theStartPnt1, theEndPnt1, theStartPnt2),
@@ -394,8 +393,9 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(
else if ( aPosHash == 2 )
return BRepMesh_GeomTool::Glued;
Standard_Real aParam[2];
IntFlag aIntFlag = IntLinLin(theStartPnt1, theEndPnt1,
theStartPnt2, theEndPnt2, theIntPnt.ChangeCoord(), theParamOnSegment);
theStartPnt2, theEndPnt2, theIntPnt.ChangeCoord(), aParam);
if (aIntFlag == BRepMesh_GeomTool::NoIntersection)
return BRepMesh_GeomTool::NoIntersection;
@@ -416,7 +416,7 @@ BRepMesh_GeomTool::IntFlag BRepMesh_GeomTool::IntSegSeg(
const Standard_Real aEndPrec = 1 - aPrec;
for (Standard_Integer i = 0; i < 2; ++i)
{
if(theParamOnSegment[i] < aPrec || theParamOnSegment[i] > aEndPrec )
if(aParam[i] < aPrec || aParam[i] > aEndPrec )
return BRepMesh_GeomTool::NoIntersection;
}

View File

@@ -194,8 +194,7 @@ public: //! @name static API
const gp_XY& theEndPnt2,
const Standard_Boolean isConsiderEndPointTouch,
const Standard_Boolean isConsiderPointOnSegment,
gp_Pnt2d& theIntPnt,
Standard_Real (&theParamOnSegment)[2]);
gp_Pnt2d& theIntPnt);
//! Compute deflection of the given segment.
static Standard_Real SquareDeflectionOfSegment(

View File

@@ -17,7 +17,6 @@
#include <BRepMesh_Deflection.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <BRepMesh_FaceChecker.hxx>
#include <BRepMesh_FaceIntersectionsSplitter.hxx>
#include <BRepMesh_EdgeDiscret.hxx>
#include <IMeshData_Face.hxx>
#include <IMeshData_Wire.hxx>
@@ -151,12 +150,7 @@ Standard_Boolean BRepMesh_ModelHealer::performInternal(
{
const IMeshData::IFaceHandle aDFace = aFaceIt.Key();
aDFace->SetStatus(IMeshData_SelfIntersectingWire);
BRepMesh_FaceIntersectionsSplitter aSplitter (aDFace, myParameters);
if (!aSplitter.Perform())
{
aDFace->SetStatus(IMeshData_Failure);
}
aDFace->SetStatus(IMeshData_Failure);
}
}

View File

@@ -1,204 +0,0 @@
// Created on: 2016-07-04
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepMesh_SegmentedFace.hxx>
#include <IMeshData_Wire.hxx>
#include <IMeshData_Edge.hxx>
#include <OSD_Parallel.hxx>
namespace
{
//! Functor to be used to fill segments and bounding box tree in parallel.
class SegmentsFiller
{
public:
//! Constructor.
SegmentsFiller(const IMeshData::IFaceHandle& theDFace,
Handle(BRepMesh_SegmentedFace::ArrayOfSegments)& theWiresSegments,
Handle(BRepMesh_SegmentedFace::ArrayOfBndBoxTree)& theWiresBndBoxTree)
: myDFace(theDFace),
myWiresSegments(theWiresSegments),
myWiresBndBoxTree(theWiresBndBoxTree)
{
myWiresSegments = new BRepMesh_SegmentedFace::ArrayOfSegments (0, myDFace->WiresNb() - 1);
myWiresBndBoxTree = new BRepMesh_SegmentedFace::ArrayOfBndBoxTree (0, myDFace->WiresNb() - 1);
}
//! Performs initialization of wire with the given index.
void operator()(const Standard_Integer theWireIndex) const
{
const IMeshData::IWireHandle& aDWire = myDFace->GetWire(theWireIndex);
Handle(NCollection_IncAllocator) aTmpAlloc1 = new NCollection_IncAllocator();
Handle(BRepMesh_SegmentedFace::Segments) aSegments =
new BRepMesh_SegmentedFace::Segments(aDWire->EdgesNb(), aTmpAlloc1);
Handle(IMeshData::BndBox2dTree) aBndBoxTree = new IMeshData::BndBox2dTree(aTmpAlloc1);
myWiresSegments ->ChangeValue(theWireIndex) = aSegments;
myWiresBndBoxTree->ChangeValue(theWireIndex) = aBndBoxTree;
Handle(NCollection_IncAllocator) aTmpAlloc2 = new NCollection_IncAllocator();
IMeshData::BndBox2dTreeFiller aBndBoxTreeFiller(*aBndBoxTree, aTmpAlloc2);
for (Standard_Integer aEdgeIt = 0; aEdgeIt < aDWire->EdgesNb(); ++aEdgeIt)
{
// TODO: check 2d wire for consistency.
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge(aEdgeIt);
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(myDFace.get(), aDWire->GetEdgeOrientation(aEdgeIt));
for (Standard_Integer aPointIt = 1; aPointIt < aPCurve->ParametersNb(); ++aPointIt)
{
gp_Pnt2d& aPnt1 = aPCurve->GetPoint(aPointIt - 1);
gp_Pnt2d& aPnt2 = aPCurve->GetPoint(aPointIt);
Bnd_Box2d aBox;
aBox.Add(aPnt1);
aBox.Add(aPnt2);
aBox.Enlarge(Precision::Confusion());
aBndBoxTreeFiller.Add(aSegments->Size(), aBox);
aSegments->Append(BRepMesh_SegmentedFace::Segment(
aDEdge, aPCurve.get(),
&aPnt1, aPointIt - 1,
&aPnt2, aPointIt));
}
}
aBndBoxTreeFiller.Fill();
}
private:
SegmentsFiller (const SegmentsFiller& theOther);
void operator=(const SegmentsFiller& theOther);
private:
const IMeshData::IFaceHandle& myDFace;
Handle(BRepMesh_SegmentedFace::ArrayOfSegments)& myWiresSegments;
Handle(BRepMesh_SegmentedFace::ArrayOfBndBoxTree)& myWiresBndBoxTree;
};
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_SegmentedFace::BndBox2dTreeSelector::BndBox2dTreeSelector(
const Standard_Boolean isCollectIntersectionParams)
: myCollectIntersectionParams (isCollectIntersectionParams)
, mySelfSegmentIndex(-1)
, myIndices(256, new NCollection_IncAllocator(IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
}
//=======================================================================
//function : Reset
//purpose :
//=======================================================================
void BRepMesh_SegmentedFace::BndBox2dTreeSelector::Reset(
const BRepMesh_SegmentedFace::Segment* theSegment,
const Standard_Integer theSelfSegmentIndex)
{
myIndices .Clear();
myIntParams.Clear();
mySelfSegmentIndex = theSelfSegmentIndex;
mySegment = theSegment;
myBox.SetVoid();
myBox.Add(*mySegment->Point1);
myBox.Add(*mySegment->Point2);
myBox.Enlarge(Precision::Confusion());
}
//=======================================================================
//function : Reject
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_SegmentedFace::BndBox2dTreeSelector::Reject(
const Bnd_Box2d& theBox) const
{
return myBox.IsOut(theBox);
}
//=======================================================================
//function : Accept
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_SegmentedFace::BndBox2dTreeSelector::Accept(
const Standard_Integer& theSegmentIndex)
{
const BRepMesh_SegmentedFace::Segment& aSegment = mySegments->Value(theSegmentIndex);
IntersectionParams aIntNode;
aIntNode.Type = BRepMesh_GeomTool::IntSegSeg(
mySegment->Point1->XY(), mySegment->Point2->XY(),
aSegment .Point1->XY(), aSegment .Point2->XY(),
Standard_False, Standard_False,
aIntNode.Point, aIntNode.Params);
if (aIntNode.Type == BRepMesh_GeomTool::Cross ||
aIntNode.Type == BRepMesh_GeomTool::PointOnSegment ||
aIntNode.Type == BRepMesh_GeomTool::Glued)
{
myIndices.Append(theSegmentIndex);
if (myCollectIntersectionParams)
{
myIntParams.Append(aIntNode);
}
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepMesh_SegmentedFace::BRepMesh_SegmentedFace(
const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters)
: myDFace (theFace),
myParameters(theParameters)
{
}
//=======================================================================
//function : Destructor
//purpose :
//=======================================================================
BRepMesh_SegmentedFace::~BRepMesh_SegmentedFace()
{
}
//=======================================================================
//function : collectSegments
//purpose :
//=======================================================================
void BRepMesh_SegmentedFace::collectSegments()
{
SegmentsFiller aSegmentsFiller(myDFace, myWiresSegments, myWiresBndBoxTree);
OSD_Parallel::For(0, myDFace->WiresNb(), aSegmentsFiller, !isParallel());
}

View File

@@ -1,169 +0,0 @@
// Created on: 2016-07-04
// Copyright (c) 2016 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_SegmentedFace_HeaderFile
#define _BRepMesh_SegmentedFace_HeaderFile
#include <IMeshTools_Parameters.hxx>
#include <Standard_Transient.hxx>
#include <IMeshData_Face.hxx>
#include <Standard_Type.hxx>
#include <NCollection_Shared.hxx>
#include <BRepMesh_GeomTool.hxx>
//! Auxiliary class providing common functionality for exploding wires of
//! discrete face on sets of segments using tessellation data stored in model.
class BRepMesh_SegmentedFace : public Standard_Transient
{
public: //! @name mesher API
//! Identifies segment inside face.
//! Uses explicit pointers to points instead of accessing using indices.
struct Segment
{
IMeshData::IEdgePtr EdgePtr;
IMeshData::IPCurvePtr PCurvePtr;
gp_Pnt2d* Point1;
Standard_Integer Param1;
gp_Pnt2d* Point2;
Standard_Integer Param2;
Segment()
: EdgePtr (NULL)
, PCurvePtr(NULL)
, Point1 (NULL)
, Param1 (0)
, Point2 (NULL)
, Param2 (0)
{
}
Segment(const IMeshData::IEdgePtr& theEdgePtr,
const IMeshData::IPCurvePtr& thePCurvePtr,
gp_Pnt2d* thePoint1,
const Standard_Integer theParam1,
gp_Pnt2d* thePoint2,
const Standard_Integer theParam2)
: EdgePtr (theEdgePtr)
, PCurvePtr(thePCurvePtr)
, Point1 (thePoint1)
, Param1 (theParam1)
, Point2 (thePoint2)
, Param2 (theParam2)
{
}
};
//! Keeps parameters of intersection of two segments.
//! Params are in range relative to distance between points of corresponding segment.
struct IntersectionParams
{
BRepMesh_GeomTool::IntFlag Type;
gp_Pnt2d Point;
Standard_Real Params[2];
};
typedef NCollection_Vector<IntersectionParams> VectorOfIntersectionParams;
typedef NCollection_Shared<NCollection_Vector<Segment> > Segments;
typedef NCollection_Shared<NCollection_Array1<Handle(Segments)> > ArrayOfSegments;
typedef NCollection_Shared<NCollection_Array1<Handle(IMeshData::BndBox2dTree)> > ArrayOfBndBoxTree;
//! Default constructor
Standard_EXPORT BRepMesh_SegmentedFace(const IMeshData::IFaceHandle& theFace,
const IMeshTools_Parameters& theParameters);
//! Destructor
Standard_EXPORT virtual ~BRepMesh_SegmentedFace();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_SegmentedFace, Standard_Transient)
protected:
//! Returns True in case if check can be performed in parallel mode.
inline Standard_Boolean isParallel() const
{
return (myParameters.InParallel && myDFace->WiresNb() > 1);
}
//! Collects face segments.
void collectSegments();
private:
BRepMesh_SegmentedFace (const BRepMesh_SegmentedFace& theOther);
void operator=(const BRepMesh_SegmentedFace& theOther);
protected:
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
class BndBox2dTreeSelector : public IMeshData::BndBox2dTree::Selector
{
public:
//! Constructor.
BndBox2dTreeSelector(const Standard_Boolean isCollectIntersectionParams);
//! Sets working set of segments.
inline void SetSegments(const Handle(BRepMesh_SegmentedFace::Segments)& theSegments)
{
mySegments = theSegments;
}
//! Returns indices of intersecting segments.
inline const IMeshData::VectorOfInteger& Indices() const
{
return myIndices;
}
//! Returns intersection parameters.
inline const BRepMesh_SegmentedFace::VectorOfIntersectionParams& IntParams() const
{
return myIntParams;
}
//! Resets current selector.
void Reset(const BRepMesh_SegmentedFace::Segment* theSegment,
const Standard_Integer theSelfSegmentIndex);
//! Indicates should the given box be rejected or not.
virtual Standard_Boolean Reject(const Bnd_Box2d& theBox) const;
//! Accepts segment with the given index in case if it fits conditions.
virtual Standard_Boolean Accept(const Standard_Integer& theSegmentIndex);
private:
Standard_Boolean myCollectIntersectionParams;
Standard_Integer mySelfSegmentIndex;
Handle(BRepMesh_SegmentedFace::Segments) mySegments;
const BRepMesh_SegmentedFace::Segment* mySegment;
Bnd_Box2d myBox;
IMeshData::VectorOfInteger myIndices;
BRepMesh_SegmentedFace::VectorOfIntersectionParams myIntParams;
};
protected:
IMeshData::IFaceHandle myDFace;
const IMeshTools_Parameters& myParameters;
Handle(ArrayOfSegments) myWiresSegments;
Handle(ArrayOfBndBoxTree) myWiresBndBoxTree;
};
#endif

View File

@@ -41,8 +41,6 @@ BRepMesh_EdgeTessellationExtractor.cxx
BRepMesh_EdgeTessellationExtractor.hxx
BRepMesh_FaceChecker.cxx
BRepMesh_FaceChecker.hxx
BRepMesh_FaceIntersectionsSplitter.cxx
BRepMesh_FaceIntersectionsSplitter.hxx
BRepMesh_FaceDiscret.cxx
BRepMesh_FaceDiscret.hxx
BRepMesh_FactoryError.hxx
@@ -70,8 +68,6 @@ BRepMesh_OrientedEdge.hxx
BRepMesh_PairOfIndex.hxx
BRepMesh_PluginEntryType.hxx
BRepMesh_PluginMacro.hxx
BRepMesh_SegmentedFace.cxx
BRepMesh_SegmentedFace.hxx
BRepMesh_SelectorOfDataStructureOfDelaun.cxx
BRepMesh_SelectorOfDataStructureOfDelaun.hxx
BRepMesh_ShapeTool.cxx

View File

@@ -44,8 +44,16 @@
#include <TopoDS_Vertex.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <ChFi3d.hxx>
//
static void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d);
//
static BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
const Standard_Boolean CorrectPoint);
//
static void CorrectOrientationOfTangent(gp_Vec& TangVec,
const TopoDS_Vertex& aVertex,
const TopoDS_Edge& anEdge)
@@ -97,17 +105,16 @@ static void EdgeAnalyse(const TopoDS_Edge& E,
// Tangent if the regularity is at least G1.
if (BRep_Tool::HasContinuity(E,F1,F2)) {
if (BRep_Tool::Continuity(E,F1,F2) > GeomAbs_C0) {
I.Type(ChFiDS_Tangential);
I.Type(BRepOffset_Tangent);
LI.Append(I);
return;
}
}
//
ChFiDS_TypeOfConcavity aType = ChFi3d::DefineConnectType(E, F1, F2,
SinTol, Standard_False);
if(aType != ChFiDS_Tangential)
BRepOffset_Type aType = DefineConnectType(E, F1, F2, SinTol, Standard_False);
if(aType != BRepOffset_Tangent)
{
aType = ChFi3d::DefineConnectType(E, F1, F2, SinTol, Standard_True);
aType = DefineConnectType(E, F1, F2, SinTol, Standard_True);
}
I.Type(aType);
LI.Append(I);
@@ -174,10 +181,10 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S,
Standard_Real U1,U2;
const TopoDS_Face& F = TopoDS::Face(L.First());
BRep_Tool::Range(E,F,U1,U2);
BRepOffset_Interval Inter(U1,U2,ChFiDS_Other);
BRepOffset_Interval Inter(U1,U2,BRepOffset_Other);
if (! BRepTools::IsReallyClosed(E,F)) {
Inter.Type(ChFiDS_FreeBound);
Inter.Type(BRepOffset_FreeBoundary);
}
mapEdgeType(E).Append(Inter);
}
@@ -226,7 +233,7 @@ const
//=======================================================================
void BRepOffset_Analyse::Edges(const TopoDS_Vertex& V,
const ChFiDS_TypeOfConcavity T,
const BRepOffset_Type T,
TopTools_ListOfShape& LE)
const
{
@@ -256,7 +263,7 @@ const
//=======================================================================
void BRepOffset_Analyse::Edges(const TopoDS_Face& F,
const ChFiDS_TypeOfConcavity T,
const BRepOffset_Type T,
TopTools_ListOfShape& LE)
const
{
@@ -343,8 +350,8 @@ const TopTools_ListOfShape& BRepOffset_Analyse::Ancestors
//purpose :
//=======================================================================
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T ) const
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const BRepOffset_Type T ) const
{
List.Clear();
BRep_Builder B;
@@ -370,9 +377,9 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
//purpose :
//=======================================================================
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const BRepOffset_Type T1,
const BRepOffset_Type T2) const
{
List.Clear();
BRep_Builder B;
@@ -402,7 +409,7 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T) const
const BRepOffset_Type T) const
{
BRep_Builder B;
TopExp_Explorer exp(Face,TopAbs_EDGE);
@@ -432,8 +439,8 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
const BRepOffset_Type T1,
const BRepOffset_Type T2) const
{
BRep_Builder B;
TopExp_Explorer exp(Face,TopAbs_EDGE);
@@ -457,3 +464,135 @@ void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
}
}
//=======================================================================
//function : Correct2dPoint
//purpose :
//=======================================================================
void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d)
{
BRepAdaptor_Surface aBAS(theF, Standard_False);
if (aBAS.GetType() < GeomAbs_BezierSurface) {
return;
}
//
const Standard_Real coeff = 0.01;
Standard_Real eps;
Standard_Real u1, u2, v1, v2;
//
aBAS.Initialize(theF, Standard_True);
u1 = aBAS.FirstUParameter();
u2 = aBAS.LastUParameter();
v1 = aBAS.FirstVParameter();
v2 = aBAS.LastVParameter();
if (!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2)))
{
eps = Max(coeff*(u2 - u1), Precision::PConfusion());
if (Abs(theP2d.X() - u1) < eps)
{
theP2d.SetX(u1 + eps);
}
if (Abs(theP2d.X() - u2) < eps)
{
theP2d.SetX(u2 - eps);
}
}
if (!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2)))
{
eps = Max(coeff*(v2 - v1), Precision::PConfusion());
if (Abs(theP2d.Y() - v1) < eps)
{
theP2d.SetY(v1 + eps);
}
if (Abs(theP2d.Y() - v2) < eps)
{
theP2d.SetY(v2 - eps);
}
}
}
//=======================================================================
//function : DefineConnectType
//purpose :
//=======================================================================
BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
const Standard_Real SinTol,
const Standard_Boolean CorrectPoint)
{
TopLoc_Location L;
Standard_Real f,l;
const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1);
const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2);
//
Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l);
Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l);
BRepAdaptor_Curve C(E);
f = C.FirstParameter();
l = C.LastParameter();
//
Standard_Real ParOnC = 0.5*(f+l);
gp_Vec T1 = C.DN(ParOnC,1).Transformed(L.Transformation());
if (T1.SquareMagnitude() > gp::Resolution()) {
T1.Normalize();
}
if (BRepOffset_Tool::OriEdgeInFace(E,F1) == TopAbs_REVERSED) {
T1.Reverse();
}
if (F1.Orientation() == TopAbs_REVERSED) T1.Reverse();
gp_Pnt2d P = C1->Value(ParOnC);
gp_Pnt P3;
gp_Vec D1U,D1V;
if(CorrectPoint)
Correct2dPoint(F1, P);
//
S1->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN1(D1U^D1V);
if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse();
P = C2->Value(ParOnC);
if(CorrectPoint)
Correct2dPoint(F2, P);
S2->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN2(D1U^D1V);
if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse();
DN1.Normalize();
DN2.Normalize();
gp_Vec ProVec = DN1^DN2;
Standard_Real NormProVec = ProVec.Magnitude();
if (Abs(NormProVec) < SinTol) {
// plane
if (DN1.Dot(DN2) > 0) {
//Tangent
return BRepOffset_Tangent;
}
else {
//Mixed not finished!
#ifdef OCCT_DEBUG
std::cout <<" faces locally mixed"<<std::endl;
#endif
return BRepOffset_Convex;
}
}
else {
if (NormProVec > gp::Resolution())
ProVec.Normalize();
Standard_Real Prod = T1.Dot(DN1^DN2);
if (Prod > 0.) {
//
return BRepOffset_Convex;
}
else {
//reenters
return BRepOffset_Concave;
}
}
}

View File

@@ -27,7 +27,7 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Standard_Real.hxx>
#include <BRepOffset_ListOfInterval.hxx>
#include <ChFiDS_TypeOfConcavity.hxx>
#include <BRepOffset_Type.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
class TopoDS_Shape;
@@ -60,21 +60,15 @@ public:
//! Stores in <L> all the edges of Type <T>
//! on the vertex <V>.
Standard_EXPORT void Edges (const TopoDS_Vertex& V,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& L) const;
Standard_EXPORT void Edges (const TopoDS_Vertex& V, const BRepOffset_Type T, TopTools_ListOfShape& L) const;
//! Stores in <L> all the edges of Type <T>
//! on the face <F>.
Standard_EXPORT void Edges (const TopoDS_Face& F,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& L) const;
Standard_EXPORT void Edges (const TopoDS_Face& F, const BRepOffset_Type T, TopTools_ListOfShape& L) const;
//! set in <Edges> all the Edges of <Shape> which are
//! tangent to <Edge> at the vertex <Vertex>.
Standard_EXPORT void TangentEdges (const TopoDS_Edge& Edge,
const TopoDS_Vertex& Vertex,
TopTools_ListOfShape& Edges) const;
Standard_EXPORT void TangentEdges (const TopoDS_Edge& Edge, const TopoDS_Vertex& Vertex, TopTools_ListOfShape& Edges) const;
Standard_EXPORT Standard_Boolean HasAncestor (const TopoDS_Shape& S) const;
@@ -82,29 +76,19 @@ public:
//! Explode in compounds of faces where
//! all the connex edges are of type <Side>
Standard_EXPORT void Explode (TopTools_ListOfShape& L,
const ChFiDS_TypeOfConcavity Type) const;
Standard_EXPORT void Explode (TopTools_ListOfShape& L, const BRepOffset_Type Type) const;
//! Explode in compounds of faces where
//! all the connex edges are of type <Side1> or <Side2>
Standard_EXPORT void Explode (TopTools_ListOfShape& L,
const ChFiDS_TypeOfConcavity Type1,
const ChFiDS_TypeOfConcavity Type2) const;
Standard_EXPORT void Explode (TopTools_ListOfShape& L, const BRepOffset_Type Type1, const BRepOffset_Type Type2) const;
//! Add in <CO> the faces of the shell containing <Face>
//! where all the connex edges are of type <Side>.
Standard_EXPORT void AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity Type) const;
Standard_EXPORT void AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, const BRepOffset_Type Type) const;
//! Add in <CO> the faces of the shell containing <Face>
//! where all the connex edges are of type <Side1> or <Side2>.
Standard_EXPORT void AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity Type1,
const ChFiDS_TypeOfConcavity Type2) const;
Standard_EXPORT void AddFaces (const TopoDS_Face& Face, TopoDS_Compound& Co, TopTools_MapOfShape& Map, const BRepOffset_Type Type1, const BRepOffset_Type Type2) const;

View File

@@ -253,8 +253,8 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
const BRepOffset_Analyse& Analyse,
const BRepAlgo_Image& InitOffsetFace)
{
ChFiDS_TypeOfConcavity OT = ChFiDS_Concave;
if (mySide == TopAbs_OUT) OT = ChFiDS_Convex;
BRepOffset_Type OT = BRepOffset_Concave;
if (mySide == TopAbs_OUT) OT = BRepOffset_Convex;
TopExp_Explorer Exp(ShapeInit,TopAbs_EDGE);
TopTools_ListOfShape LInt1,LInt2;
TopoDS_Face F1,F2;
@@ -349,7 +349,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
// to the tube or if E2 is not a tangent edge.
//-------------------------------------------------------
const BRepOffset_ListOfInterval& L = Analyse.Type(E2);
if (!L.IsEmpty() && L.First().Type() == ChFiDS_Tangential) {
if (!L.IsEmpty() && L.First().Type() == BRepOffset_Tangent) {
continue;
}
const TopTools_ListOfShape& AncE2 = Analyse.Ancestors(E2);
@@ -511,13 +511,13 @@ void BRepOffset_Inter3d::ConnexIntByInt
continue;
}
//
ChFiDS_TypeOfConcavity OT = L.First().Type();
if (OT != ChFiDS_Convex && OT != ChFiDS_Concave) {
BRepOffset_Type OT = L.First().Type();
if (OT != BRepOffset_Convex && OT != BRepOffset_Concave) {
continue;
}
//
if (OT == ChFiDS_Concave) CurSide = TopAbs_IN;
else CurSide = TopAbs_OUT;
if (OT == BRepOffset_Concave) CurSide = TopAbs_IN;
else CurSide = TopAbs_OUT;
//-----------------------------------------------------------
// edge is of the proper type, return adjacent faces.
//-----------------------------------------------------------

View File

@@ -33,7 +33,7 @@ BRepOffset_Interval::BRepOffset_Interval()
BRepOffset_Interval::BRepOffset_Interval(const Standard_Real U1,
const Standard_Real U2,
const ChFiDS_TypeOfConcavity Type):
const BRepOffset_Type Type):
f(U1),
l(U2),
type(Type)

View File

@@ -22,7 +22,7 @@
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <ChFiDS_TypeOfConcavity.hxx>
#include <BRepOffset_Type.hxx>
@@ -35,21 +35,19 @@ public:
Standard_EXPORT BRepOffset_Interval();
Standard_EXPORT BRepOffset_Interval(const Standard_Real U1,
const Standard_Real U2,
const ChFiDS_TypeOfConcavity Type);
Standard_EXPORT BRepOffset_Interval(const Standard_Real U1, const Standard_Real U2, const BRepOffset_Type Type);
void First (const Standard_Real U);
void Last (const Standard_Real U);
void Type (const ChFiDS_TypeOfConcavity T);
void Type (const BRepOffset_Type T);
Standard_Real First() const;
Standard_Real Last() const;
ChFiDS_TypeOfConcavity Type() const;
BRepOffset_Type Type() const;
@@ -66,7 +64,7 @@ private:
Standard_Real f;
Standard_Real l;
ChFiDS_TypeOfConcavity type;
BRepOffset_Type type;
};

View File

@@ -41,7 +41,7 @@ inline void BRepOffset_Interval::Last(const Standard_Real U)
//purpose :
//=======================================================================
inline void BRepOffset_Interval::Type(const ChFiDS_TypeOfConcavity T)
inline void BRepOffset_Interval::Type(const BRepOffset_Type T)
{
type = T;
}
@@ -74,7 +74,7 @@ inline Standard_Real BRepOffset_Interval::Last() const
//purpose :
//=======================================================================
inline ChFiDS_TypeOfConcavity BRepOffset_Interval::Type() const
inline BRepOffset_Type BRepOffset_Interval::Type() const
{
return type;
}

View File

@@ -509,26 +509,26 @@ static void FillContours(const TopoDS_Shape& aShape,
BRepTools_WireExplorer Wexp;
for (; Explo.More(); Explo.Next())
{
TopoDS_Face aFace = TopoDS::Face(Explo.Current());
TopoDS_Iterator itf(aFace);
for (; itf.More(); itf.Next())
{
TopoDS_Wire aWire = TopoDS::Wire(itf.Value());
for (Wexp.Init(aWire, aFace); Wexp.More(); Wexp.Next())
{
TopoDS_Edge anEdge = Wexp.Current();
if (BRep_Tool::Degenerated(anEdge))
continue;
const BRepOffset_ListOfInterval& Lint = Analyser.Type(anEdge);
if (!Lint.IsEmpty() && Lint.First().Type() == ChFiDS_FreeBound)
TopoDS_Face aFace = TopoDS::Face(Explo.Current());
TopoDS_Iterator itf(aFace);
for (; itf.More(); itf.Next())
{
MapEF.Bind(anEdge, aFace);
Edges.Append(anEdge);
TopoDS_Wire aWire = TopoDS::Wire(itf.Value());
for (Wexp.Init(aWire, aFace); Wexp.More(); Wexp.Next())
{
TopoDS_Edge anEdge = Wexp.Current();
if (BRep_Tool::Degenerated(anEdge))
continue;
const BRepOffset_ListOfInterval& Lint = Analyser.Type(anEdge);
if (!Lint.IsEmpty() && Lint.First().Type() == BRepOffset_FreeBoundary)
{
MapEF.Bind(anEdge, aFace);
Edges.Append(anEdge);
}
}
}
}
}
}
TopTools_ListIteratorOfListOfShape itl;
while (!Edges.IsEmpty())
@@ -1050,7 +1050,7 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the
aCurOffset = myFaceOffset.IsBound(aF) ? myFaceOffset(aF) : myOffset;
BRepOffset_Offset OF(aF, aCurOffset, ShapeTgt, OffsetOutside, myJoin);
TopTools_ListOfShape Let;
myAnalyse.Edges(aF,ChFiDS_Tangential,Let);
myAnalyse.Edges(aF,BRepOffset_Tangent,Let);
TopTools_ListIteratorOfListOfShape itl(Let);
for (; itl.More(); itl.Next()) {
const TopoDS_Edge& Cur = TopoDS::Edge(itl.Value());
@@ -1063,14 +1063,14 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the
TopExp::Vertices (OTE,OV1,OV2);
TopTools_ListOfShape LE;
if (!ShapeTgt.IsBound(V1)) {
myAnalyse.Edges(V1,ChFiDS_Tangential,LE);
myAnalyse.Edges(V1,BRepOffset_Tangent,LE);
const TopTools_ListOfShape& LA =myAnalyse.Ancestors(V1);
if (LE.Extent() == LA.Extent())
ShapeTgt.Bind(V1,OV1);
}
if (!ShapeTgt.IsBound(V2)) {
LE.Clear();
myAnalyse.Edges(V2,ChFiDS_Tangential,LE);
myAnalyse.Edges(V2,BRepOffset_Tangent,LE);
const TopTools_ListOfShape& LA =myAnalyse.Ancestors(V2);
if (LE.Extent() == LA.Extent())
ShapeTgt.Bind(V2,OV2);
@@ -1463,8 +1463,8 @@ void BRepOffset_MakeOffset::BuildOffsetByArc()
//--------------------------------------------------------
// Construction of tubes on edge.
//--------------------------------------------------------
ChFiDS_TypeOfConcavity OT = ChFiDS_Convex;
if (myOffset < 0.) OT = ChFiDS_Concave;
BRepOffset_Type OT = BRepOffset_Convex;
if (myOffset < 0.) OT = BRepOffset_Concave;
for (Exp.Init(myShape,TopAbs_EDGE); Exp.More(); Exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
@@ -1566,7 +1566,7 @@ void BRepOffset_MakeOffset::BuildOffsetByArc()
// Particular processing if V is at least a free border.
//-------------------------------------------------------------
TopTools_ListOfShape LBF;
myAnalyse.Edges(V,ChFiDS_FreeBound,LBF);
myAnalyse.Edges(V,BRepOffset_FreeBoundary,LBF);
if (!LBF.IsEmpty()) {
Standard_Boolean First = Standard_True;
for (it.Initialize(LE) ; it.More(); it.Next()) {
@@ -1592,8 +1592,8 @@ void BRepOffset_MakeOffset::BuildOffsetByArc()
//------------------------------------------------------
// MAJ SD.
//------------------------------------------------------
ChFiDS_TypeOfConcavity RT = ChFiDS_Concave;
if (myOffset < 0.) RT = ChFiDS_Convex;
BRepOffset_Type RT = BRepOffset_Concave;
if (myOffset < 0.) RT = BRepOffset_Convex;
BRepOffset_DataMapIteratorOfDataMapOfShapeOffset It(MapSF);
for ( ; It.More(); It.Next()) {
const TopoDS_Shape& SI = It.Key();
@@ -1737,8 +1737,8 @@ void BRepOffset_MakeOffset::ToContext (BRepOffset_DataMapOfShapeOffset& MapSF)
// Reconstruction of faces.
//---------------------------
TopoDS_Face F,NF;
ChFiDS_TypeOfConcavity RT = ChFiDS_Concave;
if (myOffset < 0.) RT = ChFiDS_Convex;
BRepOffset_Type RT = BRepOffset_Concave;
if (myOffset < 0.) RT = BRepOffset_Convex;
TopoDS_Shape OE,NE;
TopAbs_Orientation Or;
@@ -1825,8 +1825,8 @@ void BRepOffset_MakeOffset::UpdateFaceOffset()
CopiedMap.Assign(myFaceOffset);
TopTools_DataMapIteratorOfDataMapOfShapeReal it(CopiedMap);
ChFiDS_TypeOfConcavity RT = ChFiDS_Convex;
if (myOffset < 0.) RT = ChFiDS_Concave;
BRepOffset_Type RT = BRepOffset_Convex;
if (myOffset < 0.) RT = BRepOffset_Concave;
for ( ; it.More(); it.Next()) {
const TopoDS_Face& F = TopoDS::Face(it.Key());
@@ -1838,9 +1838,9 @@ void BRepOffset_MakeOffset::UpdateFaceOffset()
TopTools_MapOfShape Dummy;
Build.Add(Co,F);
if (myJoin == GeomAbs_Arc)
myAnalyse.AddFaces(F,Co,Dummy,ChFiDS_Tangential,RT);
myAnalyse.AddFaces(F,Co,Dummy,BRepOffset_Tangent,RT);
else
myAnalyse.AddFaces(F,Co,Dummy,ChFiDS_Tangential);
myAnalyse.AddFaces(F,Co,Dummy,BRepOffset_Tangent);
TopExp_Explorer exp(Co,TopAbs_FACE);
for (; exp.More(); exp.Next()) {
@@ -3133,7 +3133,7 @@ void BRepOffset_MakeOffset::SelectShells ()
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
const TopTools_ListOfShape& LA = myAnalyse.Ancestors(E);
if (LA.Extent() < 2) {
if (myAnalyse.Type(E).First().Type() == ChFiDS_FreeBound) {
if (myAnalyse.Type(E).First().Type() == BRepOffset_FreeBoundary) {
FreeEdges.Add(E);
}
}
@@ -3334,7 +3334,7 @@ void BRepOffset_MakeOffset::EncodeRegularity ()
if ( myAnalyse.HasAncestor(Ed)) {
const BRepOffset_ListOfInterval& LI = myAnalyse.Type(Ed);
if (LI.Extent() == 1 &&
LI.First().Type() == ChFiDS_Tangential) {
LI.First().Type() == BRepOffset_Tangent) {
B.Continuity(OE,F1,F2,GeomAbs_G1);
}
}

View File

@@ -180,6 +180,26 @@ void BRepOffset_Tool::EdgeVertices (const TopoDS_Edge& E,
}
}
//=======================================================================
//function : OriEdgeInFace
//purpose :
//=======================================================================
TopAbs_Orientation BRepOffset_Tool::OriEdgeInFace (const TopoDS_Edge& E,
const TopoDS_Face& F )
{
TopExp_Explorer Exp;
Exp.Init(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for (; Exp.More() ;Exp.Next()) {
if (Exp.Current().IsSame(E)) {
return Exp.Current().Orientation();
}
}
throw Standard_ConstructionError("BRepOffset_Tool::OriEdgeInFace");
}
//=======================================================================
//function : FindPeriod
//purpose :
@@ -2988,8 +3008,8 @@ void BRepOffset_Tool::CheckBounds(const TopoDS_Face& F,
const BRepOffset_ListOfInterval& L = Analyse.Type(anEdge);
if (!L.IsEmpty() || BRep_Tool::Degenerated(anEdge))
{
ChFiDS_TypeOfConcavity OT = L.First().Type();
if (OT == ChFiDS_Tangential || BRep_Tool::Degenerated(anEdge))
BRepOffset_Type OT = L.First().Type();
if (OT == BRepOffset_Tangent || BRep_Tool::Degenerated(anEdge))
{
Standard_Real fpar, lpar;
Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface(anEdge, F, fpar, lpar);

View File

@@ -53,6 +53,10 @@ public:
//! taking account the orientation of Edge.
Standard_EXPORT static void EdgeVertices (const TopoDS_Edge& E, TopoDS_Vertex& V1, TopoDS_Vertex& V2);
//! returns the cumul of the orientation of <Edge>
//! and thc containing wire in <Face>
Standard_EXPORT static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E, const TopoDS_Face& F);
//! <E> is a section between <F1> and <F2>. Computes
//! <O1> the orientation of <E> in <F1> influenced by <F2>.
//! idem for <O2>.

View File

@@ -14,17 +14,17 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _ChFiDS_TypeOfConcavity_HeaderFile
#define _ChFiDS_TypeOfConcavity_HeaderFile
#ifndef _BRepOffset_Type_HeaderFile
#define _BRepOffset_Type_HeaderFile
enum ChFiDS_TypeOfConcavity
enum BRepOffset_Type
{
ChFiDS_Concave,
ChFiDS_Convex,
ChFiDS_Tangential,
ChFiDS_FreeBound,
ChFiDS_Other
BRepOffset_Concave,
BRepOffset_Convex,
BRepOffset_Tangent,
BRepOffset_FreeBoundary,
BRepOffset_Other
};
#endif // _ChFiDS_TypeOfConcavity_HeaderFile
#endif // _BRepOffset_Type_HeaderFile

View File

@@ -34,3 +34,4 @@ BRepOffset_Offset.lxx
BRepOffset_Status.hxx
BRepOffset_Tool.cxx
BRepOffset_Tool.hxx
BRepOffset_Type.hxx

View File

@@ -578,12 +578,5 @@ Standard_Boolean BRepSweep_NumLinearRegularSweep::GenIsUsed(const TopoDS_Shape&
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
Standard_OutOfRange_Raise_if(iGenS == 0,
"BRepSweep_NumLinearRegularSweep::GenIsUsed: shape index = 0")
if (iGenS == 1)
{
return myBuiltShapes(iGenS, 1);
}
else
{
return myBuiltShapes(iGenS, 1) && myUsedShapes(iGenS, 1);
}
return myBuiltShapes(iGenS, 1) && myUsedShapes(iGenS, 1);
}

View File

@@ -1082,16 +1082,11 @@ static Standard_Integer shapeG1continuity (Draw_Interpretor& di, Standard_Intege
face1=TopoDS::Face(It.Value());
It.Next();
face2=TopoDS::Face(It.Value());
Standard_Boolean IsSeam = face1.IsEqual(face2);
// calcul des deux pcurves
const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face1,f1,l1);
if (c1.IsNull()) return 1;
if (IsSeam)
edge.Reverse();
const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face2,f2,l2);
if (c2.IsNull()) return 1;
@@ -1217,15 +1212,10 @@ static Standard_Integer shapeG0continuity (Draw_Interpretor& di, Standard_Intege
It.Next();
face2=TopoDS::Face(It.Value());
Standard_Boolean IsSeam = face1.IsEqual(face2);
// calcul des deux pcurves
const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face1,f1,l1);
if (c1.IsNull()) return 1;
if (IsSeam)
edge.Reverse();
const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face2,f2,l2);
if (c2.IsNull()) return 1;
@@ -1345,16 +1335,10 @@ static Standard_Integer shapeG2continuity (Draw_Interpretor& di, Standard_Intege
face1=TopoDS::Face(It.Value());
It.Next();
face2=TopoDS::Face(It.Value());
Standard_Boolean IsSeam = face1.IsEqual(face2);
// calcul des deux pcurves
const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face1,f1,l1);
if (c1.IsNull()) return 1;
if (IsSeam)
edge.Reverse();
const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface
(TopoDS::Edge(edge),face2,f2,l2);
if (c2.IsNull()) return 1;

View File

@@ -247,10 +247,6 @@ static Standard_Integer geompipe(Draw_Interpretor&,
std::cout << "GeomFill_Pipe cannot make a surface" << std::endl;
return 1;
}
Standard_Real Accuracy = aPipe.ErrorOnSurf();
std::cout << "Accuracy of approximation = " << Accuracy << std::endl;
Handle(Geom_Surface) Sur = aPipe.Surface();
TopoDS_Face F;
if (!Sur.IsNull())

View File

@@ -1068,21 +1068,4 @@ Standard_Real BRepTools::EvalAndUpdateTol(const TopoDS_Edge& theE,
}
//=======================================================================
//function : OriEdgeInFace
//purpose :
//=======================================================================
TopAbs_Orientation BRepTools::OriEdgeInFace (const TopoDS_Edge& E,
const TopoDS_Face& F )
{
TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for (; Exp.More() ;Exp.Next()) {
if (Exp.Current().IsSame(E)) {
return Exp.Current().Orientation();
}
}
throw Standard_ConstructionError("BRepTools::OriEdgeInFace");
}

View File

@@ -223,10 +223,6 @@ public:
const Standard_Real theF,
const Standard_Real theL);
//! returns the cumul of the orientation of <Edge>
//! and thc containing wire in <Face>
Standard_EXPORT static TopAbs_Orientation OriEdgeInFace(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace);
protected:

View File

@@ -215,7 +215,7 @@ void BRepTools_ShapeSet::AddGeometry(const TopoDS_Shape& S)
Handle(BRep_TFace) TF = Handle(BRep_TFace)::DownCast(S.TShape());
if (!TF->Surface().IsNull()) mySurfaces.Add(TF->Surface());
if (myWithTriangles || TF->Surface().IsNull()) { // for XML Persistence
if (myWithTriangles) { // for XML Persistence
Handle(Poly_Triangulation) Tr = TF->Triangulation();
if (!Tr.IsNull()) myTriangulations.Add(Tr);
}
@@ -751,7 +751,7 @@ void BRepTools_ShapeSet::WriteGeometry(const TopoDS_Shape& S,
OS << " " << 0;
OS << "\n";
}
if (myWithTriangles || TF->Surface().IsNull()) { // for XML Persistence
if (myWithTriangles) { // for XML Persistence
if (!(TF->Triangulation()).IsNull()) {
OS << 2;
OS << " ";

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