mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9d78134ce9 | ||
|
8f4cd4793a | ||
|
4bdfdea4cb | ||
|
e72c88f15c | ||
|
e54df8ac57 | ||
|
3a24d5e81c | ||
|
dd62ec9e70 | ||
|
b3a1dc7c7f | ||
|
80c4c42abd | ||
|
eeeb58738f | ||
|
8247e04688 | ||
|
5f16893ffb | ||
|
716fd8e08e | ||
|
1523a69d88 | ||
|
c2fc2f376d | ||
|
068969acef | ||
|
56609574c6 | ||
|
0154021f86 | ||
|
48839a4046 | ||
|
48b498d4e1 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -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
|
||||
|
37
cmake_gen.bat
Normal file
37
cmake_gen.bat
Normal 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
36
cmake_gen.sh
Executable 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 ..
|
8
cmake_gen_custom.bat.template
Normal file
8
cmake_gen_custom.bat.template
Normal 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
|
9
cmake_gen_custom.sh.template
Normal file
9
cmake_gen_custom.sh.template
Normal 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
|
@@ -14,6 +14,7 @@ overview/overview.md
|
||||
../samples/qt/AndroidQt/ReadMe.md
|
||||
../samples/java/jniviewer/ReadMe.md
|
||||
../samples/ios/UIKitSample/ReadMe.md
|
||||
../samples/webgl/ReadMe.md
|
||||
|
||||
tutorial/tutorial.md
|
||||
|
||||
|
BIN
dox/overview/images/sample_webgl.png
Normal file
BIN
dox/overview/images/sample_webgl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
@@ -153,6 +153,9 @@ on this tool.
|
||||
**RapidJSON** is an Open Source JSON parser and generator for C++.
|
||||
RapidJSON is optionally used by OCCT for reading glTF files (https://rapidjson.org/).
|
||||
|
||||
**DejaVu** fonts are a font family based on the Vera Fonts under a permissive license (MIT-like, https://dejavu-fonts.github.io/License.html).
|
||||
DejaVu Sans (basic Latin sub-set) is used by OCCT as fallback font when no system font is available.
|
||||
|
||||
Adobe Systems, Inc. provides **Adobe Reader**, which can be used to view files in Portable Document Format (PDF).
|
||||
|
||||
@section OCCT_OVW_SECTION_3 Documentation
|
||||
@@ -211,6 +214,7 @@ for which OCCT is certified to work.
|
||||
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
|
||||
| OS X / macOS | XCode 6 or newer |
|
||||
| Android | NDK r10, GNU gcc 4.8 or newer |
|
||||
| Web | Emscripten SDK 1.39 or newer (CLang) |
|
||||
|
||||
1) VC++ 141 64-bit is used for regular testing and for building binary package of official release of OCCT on Windows.
|
||||
|
||||
@@ -569,3 +573,11 @@ There is a sample demonstrating usage of OCCT on iOS with Apple UIKit framework.
|
||||
@figure{/overview/images/sample_ios_uikit.png}
|
||||
|
||||
See \subpage occt_samples_ios_uikit "iOS sample Readme" for details.
|
||||
|
||||
@subsubsection OCCT_OVW_SECTION_7_3_6 Web
|
||||
|
||||
WebGL Viewer sample demonstrating usage of OCCT 3D Viewer in Web browser with Emscripten SDK can be found in `samples/webgl`.
|
||||
|
||||
@figure{/overview/images/sample_webgl.png}
|
||||
|
||||
See \subpage occt_samples_webgl "WebGL sample Readme" for details.
|
||||
|
19
env_custom.bat.template
Normal file
19
env_custom.bat.template
Normal 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
18
env_custom.sh.template
Normal 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
154
occ_build_occt_wasm.bat
Normal 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
117
occ_build_occt_wasm.sh
Executable 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
|
2
samples/webgl/.gitignore
vendored
Normal file
2
samples/webgl/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
/work
|
66
samples/webgl/CMakeLists.txt
Normal file
66
samples/webgl/CMakeLists.txt
Normal file
@@ -0,0 +1,66 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(occt-webgl-sample)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(APP_VERSION_MAJOR 1)
|
||||
set(APP_VERSION_MINOR 0)
|
||||
set(APP_TARGET occt-webgl-sample)
|
||||
|
||||
# customize build
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_WEBGL2=1")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SAFE_HEAP=1")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_EXIT_RUNTIME=1")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s TOTAL_MEMORY=16MB")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ABORTING_MALLOC=0")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FORCE_FILESYSTEM=1")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --preload-file myFile")
|
||||
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
||||
file(GLOB SOURCES
|
||||
*.h
|
||||
*.cpp
|
||||
)
|
||||
source_group ("Headers" FILES
|
||||
WasmOcctView.h)
|
||||
source_group ("Sources" FILES
|
||||
WasmOcctView.cpp
|
||||
main.cpp)
|
||||
|
||||
# FreeType
|
||||
find_package(freetype REQUIRED NO_DEFAULT_PATH)
|
||||
if(freetype_FOUND)
|
||||
message (STATUS "Using FreeType from \"${freetype_DIR}\"" )
|
||||
else()
|
||||
message(WARNING "Could not find FreeType, please set freetype_DIR variable." )
|
||||
endif()
|
||||
|
||||
# Open CASCADE Technology
|
||||
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
|
||||
if(OpenCASCADE_FOUND)
|
||||
message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
|
||||
INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
|
||||
LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
|
||||
else()
|
||||
message(WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
|
||||
set(OCCT_LIBRARY_DIR)
|
||||
set(OCCT_BIN_DIR)
|
||||
endif()
|
||||
|
||||
set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGl TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
|
||||
|
||||
add_executable(${APP_TARGET} ${SOURCES})
|
||||
target_link_libraries(
|
||||
${APP_TARGET}
|
||||
${OpenCASCADE_LIBS}
|
||||
freetype
|
||||
)
|
||||
set_target_properties(${APP_TARGET} PROPERTIES LINK_FLAGS "-s EXPORTED_FUNCTIONS=['_main','_onFileDataRead'] -s EXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
install(FILES occt-webgl-sample.html DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/OCC_logo.png DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/lamp.ico DESTINATION ${CMAKE_INSTALL_PREFIX})
|
28
samples/webgl/ReadMe.md
Normal file
28
samples/webgl/ReadMe.md
Normal file
@@ -0,0 +1,28 @@
|
||||
OCCT WebGL Viewer sample {#occt_samples_webgl}
|
||||
==================
|
||||
|
||||
This sample demonstrates simple way of using OCCT libraries in Web application written in C++ and translated into WebAssembly module using Emscripten SDK (emsdk):
|
||||
https://emscripten.org/
|
||||
|
||||
Sample consists of the Open CASCADE 3D Viewer with a button for opening a model in BREP format.
|
||||
The sample requires a WebGL 2.0 capable browser supporting WebAssembly 1.0 (Wasm).
|
||||
|
||||
Installation and configuration:
|
||||
1. Install Emscripten SDK and activate minimal configuration (Python, Java and CLang) following *emsdk* documentation. Activate also MinGW when building sample on Windows host.
|
||||
2. Build (using *emsdk*) or download FreeType static library.
|
||||
3. Configure CMake for building Open CASCADE Technology (OCCT) static libraries (BUILD_LIBRARY_TYPE="Static").
|
||||
For this, activate *emsdk* command prompt, configure CMake for building OCCT using cross-compilation toolchain, disable *BUILD_MODULE_Draw*.
|
||||
4. Perform building and installation steps.
|
||||
~~~~~
|
||||
> ${EMSDK}/fastcomp/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
||||
~~~~~
|
||||
5. Configure CMake for building this WebGL sample using *emsdk* with paths to OCCT and FreeType. Perform building and installation steps.
|
||||
6. Copy data/occ/Ball.brep from OCCT into "samples" folder within WebGL sample installation path.
|
||||
7. Navigate to installation folder and start web server from it; Python coming with *emsdk* can be used for this purpose:
|
||||
~~~~~
|
||||
> python -m SimpleHTTPServer 8080
|
||||
~~~~~
|
||||
8. Open compatible browser and enter path taking into account your web server settings:
|
||||
~~~~~
|
||||
> http://localhost:8080/occt-webgl-sample.html
|
||||
~~~~~
|
678
samples/webgl/WasmOcctView.cpp
Normal file
678
samples/webgl/WasmOcctView.cpp
Normal file
@@ -0,0 +1,678 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#include "WasmOcctView.h"
|
||||
|
||||
#include "WasmVKeys.h"
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_ViewCube.hxx>
|
||||
#include <Aspect_Handle.hxx>
|
||||
#include <Aspect_DisplayConnection.hxx>
|
||||
#include <Aspect_NeutralWindow.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OpenGl_GraphicDriver.hxx>
|
||||
#include <Prs3d_DatumAspect.hxx>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define THE_CANVAS_ID "canvas"
|
||||
|
||||
namespace
|
||||
{
|
||||
EM_JS(int, jsCanvasGetWidth, (), {
|
||||
return canvas.width;
|
||||
});
|
||||
|
||||
EM_JS(int, jsCanvasGetHeight, (), {
|
||||
return canvas.height;
|
||||
});
|
||||
|
||||
EM_JS(float, jsDevicePixelRatio, (), {
|
||||
var aDevicePixelRatio = window.devicePixelRatio || 1;
|
||||
return aDevicePixelRatio;
|
||||
});
|
||||
|
||||
//! Return cavas size in pixels.
|
||||
static Graphic3d_Vec2i jsCanvasSize()
|
||||
{
|
||||
return Graphic3d_Vec2i (jsCanvasGetWidth(), jsCanvasGetHeight());
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : WasmOcctView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
WasmOcctView::WasmOcctView()
|
||||
: myDevicePixelRatio (1.0f),
|
||||
myUpdateRequests (0)
|
||||
{
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : ~WasmOcctView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
WasmOcctView::~WasmOcctView()
|
||||
{
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : run
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::run()
|
||||
{
|
||||
initWindow();
|
||||
initViewer();
|
||||
initDemoScene();
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
myView->MustBeResized();
|
||||
myView->Redraw();
|
||||
|
||||
// There is no inifinite message loop, main() will return from here immediately.
|
||||
// Tell that our Module should be left loaded and handle events through callbacks.
|
||||
//emscripten_set_main_loop (redrawView, 60, 1);
|
||||
//emscripten_set_main_loop (redrawView, -1, 1);
|
||||
EM_ASM(Module['noExitRuntime'] = true);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initWindow
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::initWindow()
|
||||
{
|
||||
myDevicePixelRatio = jsDevicePixelRatio();
|
||||
myCanvasId = THE_CANVAS_ID;
|
||||
const char* aTargetId = !myCanvasId.IsEmpty() ? myCanvasId.ToCString() : NULL;
|
||||
const EM_BOOL toUseCapture = EM_TRUE;
|
||||
emscripten_set_resize_callback (NULL, this, toUseCapture, onResizeCallback);
|
||||
|
||||
emscripten_set_mousedown_callback (NULL, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_mouseup_callback (NULL, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_mousemove_callback (NULL, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_dblclick_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_click_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_mouseenter_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_mouseleave_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
||||
emscripten_set_wheel_callback (aTargetId, this, toUseCapture, onWheelCallback);
|
||||
|
||||
emscripten_set_touchstart_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
||||
emscripten_set_touchend_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
||||
emscripten_set_touchmove_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
||||
emscripten_set_touchcancel_callback(aTargetId, this, toUseCapture, onTouchCallback);
|
||||
|
||||
//emscripten_set_keypress_callback (NULL, this, toUseCapture, onKeyCallback);
|
||||
emscripten_set_keydown_callback (NULL, this, toUseCapture, onKeyDownCallback);
|
||||
emscripten_set_keyup_callback (NULL, this, toUseCapture, onKeyUpCallback);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : dumpGlInfo
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::dumpGlInfo (bool theIsBasic)
|
||||
{
|
||||
TColStd_IndexedDataMapOfStringString aGlCapsDict;
|
||||
myView->DiagnosticInformation (aGlCapsDict, theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
|
||||
if (theIsBasic)
|
||||
{
|
||||
TCollection_AsciiString aViewport;
|
||||
aGlCapsDict.FindFromKey ("Viewport", aViewport);
|
||||
aGlCapsDict.Clear();
|
||||
aGlCapsDict.Add ("Viewport", aViewport);
|
||||
}
|
||||
aGlCapsDict.Add ("Display scale", TCollection_AsciiString(myDevicePixelRatio));
|
||||
|
||||
// beautify output
|
||||
{
|
||||
TCollection_AsciiString* aGlVer = aGlCapsDict.ChangeSeek ("GLversion");
|
||||
TCollection_AsciiString* aGlslVer = aGlCapsDict.ChangeSeek ("GLSLversion");
|
||||
if (aGlVer != NULL
|
||||
&& aGlslVer != NULL)
|
||||
{
|
||||
*aGlVer = *aGlVer + " [GLSL: " + *aGlslVer + "]";
|
||||
aGlslVer->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
TCollection_AsciiString anInfo;
|
||||
for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More(); aValueIter.Next())
|
||||
{
|
||||
if (!aValueIter.Value().IsEmpty())
|
||||
{
|
||||
if (!anInfo.IsEmpty())
|
||||
{
|
||||
anInfo += "\n";
|
||||
}
|
||||
anInfo += aValueIter.Key() + ": " + aValueIter.Value();
|
||||
}
|
||||
}
|
||||
|
||||
::Message::DefaultMessenger()->Send (anInfo, Message_Warning);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initPixelScaleRatio
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::initPixelScaleRatio()
|
||||
{
|
||||
SetTouchToleranceScale (myDevicePixelRatio);
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
myView->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * myDevicePixelRatio + 0.5);
|
||||
}
|
||||
if (!myContext.IsNull())
|
||||
{
|
||||
myContext->SetPixelTolerance (int(myDevicePixelRatio * 6.0));
|
||||
if (!myViewCube.IsNull())
|
||||
{
|
||||
static const double THE_CUBE_SIZE = 60.0;
|
||||
myViewCube->SetSize (myDevicePixelRatio * THE_CUBE_SIZE, false);
|
||||
myViewCube->SetBoxFacetExtension (myViewCube->Size() * 0.15);
|
||||
myViewCube->SetAxesPadding (myViewCube->Size() * 0.10);
|
||||
myViewCube->SetFontHeight (THE_CUBE_SIZE * 0.16);
|
||||
if (myViewCube->HasInteractiveContext())
|
||||
{
|
||||
myContext->Redisplay (myViewCube, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initViewer
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
bool WasmOcctView::initViewer()
|
||||
{
|
||||
// Build with "--preload-file MyFontFile.ttf" option
|
||||
// and register font in Font Manager to use custom font(s).
|
||||
/*const char* aFontPath = "MyFontFile.ttf";
|
||||
if (Handle(Font_SystemFont) aFont = Font_FontMgr::GetInstance()->CheckFont (aFontPath))
|
||||
{
|
||||
Font_FontMgr::GetInstance()->RegisterFont (aFont, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: font '") + aFontPath + "' is not found", Message_Fail);
|
||||
}*/
|
||||
|
||||
Handle(Aspect_DisplayConnection) aDisp;
|
||||
Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (aDisp, false);
|
||||
aDriver->ChangeOptions().buffersNoSwap = true; // swap has no effect in WebGL
|
||||
if (!aDriver->InitContext())
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: EGL initialization failed"), Message_Fail);
|
||||
return false;
|
||||
}
|
||||
|
||||
Handle(V3d_Viewer) aViewer = new V3d_Viewer (aDriver);
|
||||
aViewer->SetComputedMode (false);
|
||||
aViewer->SetDefaultShadingModel (Graphic3d_TOSM_FRAGMENT);
|
||||
aViewer->SetDefaultLights();
|
||||
aViewer->SetLightOn();
|
||||
|
||||
Handle(Aspect_NeutralWindow) aWindow = new Aspect_NeutralWindow();
|
||||
Graphic3d_Vec2i aWinSize = jsCanvasSize();
|
||||
if (aWinSize.x() < 10 || aWinSize.y() < 10)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Warning: invalid canvas size"), Message_Warning);
|
||||
}
|
||||
aWindow->SetSize (aWinSize.x(), aWinSize.y());
|
||||
|
||||
myTextStyle = new Prs3d_TextAspect();
|
||||
myTextStyle->SetFont (Font_NOF_ASCII_MONO);
|
||||
myTextStyle->SetHeight (12);
|
||||
myTextStyle->Aspect()->SetColor (Quantity_NOC_GRAY95);
|
||||
myTextStyle->Aspect()->SetColorSubTitle (Quantity_NOC_BLACK);
|
||||
myTextStyle->Aspect()->SetDisplayType (Aspect_TODT_SHADOW);
|
||||
myTextStyle->Aspect()->SetTextFontAspect (Font_FA_Bold);
|
||||
myTextStyle->Aspect()->SetTextZoomable (false);
|
||||
myTextStyle->SetHorizontalJustification (Graphic3d_HTA_LEFT);
|
||||
myTextStyle->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
|
||||
|
||||
myView = new V3d_View (aViewer);
|
||||
myView->SetImmediateUpdate (false);
|
||||
myView->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * myDevicePixelRatio + 0.5);
|
||||
myView->ChangeRenderingParams().ToShowStats = true;
|
||||
myView->ChangeRenderingParams().StatsTextAspect = myTextStyle->Aspect();
|
||||
myView->ChangeRenderingParams().StatsTextHeight = (int )myTextStyle->Height();
|
||||
myView->SetWindow (aWindow);
|
||||
dumpGlInfo (false);
|
||||
|
||||
myContext = new AIS_InteractiveContext (aViewer);
|
||||
initPixelScaleRatio();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : initDemoScene
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::initDemoScene()
|
||||
{
|
||||
if (myContext.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//myView->TriedronDisplay (Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_WIREFRAME);
|
||||
|
||||
myViewCube = new AIS_ViewCube();
|
||||
// presentation parameters
|
||||
initPixelScaleRatio();
|
||||
myViewCube->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_LOWER, Graphic3d_Vec2i (100, 100)));
|
||||
myViewCube->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
|
||||
myViewCube->Attributes()->DatumAspect()->SetTextAspect (myTextStyle);
|
||||
// animation parameters
|
||||
myViewCube->SetViewAnimation (myViewAnimation);
|
||||
myViewCube->SetFixedAnimationLoop (false);
|
||||
myViewCube->SetAutoStartAnimation (true);
|
||||
myContext->Display (myViewCube, false);
|
||||
|
||||
// Build with "--preload-file MySampleFile.brep" option to load some shapes here.
|
||||
}
|
||||
|
||||
|
||||
// ================================================================
|
||||
// Function : updateView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::updateView()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
if (++myUpdateRequests == 1)
|
||||
{
|
||||
emscripten_async_call (onRedrawView, this, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : redrawView
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::redrawView()
|
||||
{
|
||||
if (!myView.IsNull())
|
||||
{
|
||||
FlushViewEvents (myContext, myView, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : handleViewRedraw
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
void WasmOcctView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
myUpdateRequests = 0;
|
||||
AIS_ViewController::handleViewRedraw (theCtx, theView);
|
||||
if (myToAskNextFrame)
|
||||
{
|
||||
// ask more frames
|
||||
++myUpdateRequests;
|
||||
emscripten_async_call (onRedrawView, this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onResizeEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onResizeEvent (int theEventType, const EmscriptenUiEvent* theEvent)
|
||||
{
|
||||
(void )theEventType; // EMSCRIPTEN_EVENT_RESIZE or EMSCRIPTEN_EVENT_CANVASRESIZED
|
||||
(void )theEvent;
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
|
||||
Graphic3d_Vec2i aWinSizeOld, aWinSizeNew (jsCanvasSize());
|
||||
if (aWinSizeNew.x() < 10 || aWinSizeNew.y() < 10)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Warning: invalid canvas size"), Message_Warning);
|
||||
}
|
||||
aWindow->Size (aWinSizeOld.x(), aWinSizeOld.y());
|
||||
const float aPixelRatio = jsDevicePixelRatio();
|
||||
if (aWinSizeNew != aWinSizeOld
|
||||
|| aPixelRatio != myDevicePixelRatio)
|
||||
{
|
||||
if (myDevicePixelRatio != aPixelRatio)
|
||||
{
|
||||
myDevicePixelRatio = aPixelRatio;
|
||||
initPixelScaleRatio();
|
||||
}
|
||||
aWindow->SetSize (aWinSizeNew.x(), aWinSizeNew.y());
|
||||
myView->MustBeResized();
|
||||
myView->Invalidate();
|
||||
myView->Redraw();
|
||||
dumpGlInfo (true);
|
||||
}
|
||||
return EM_TRUE;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onMouseEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onMouseEvent (int theEventType, const EmscriptenMouseEvent* theEvent)
|
||||
{
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (theEvent->canvasX, theEvent->canvasY));
|
||||
Aspect_VKeyFlags aFlags = 0;
|
||||
if (theEvent->ctrlKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_CTRL; }
|
||||
if (theEvent->shiftKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_SHIFT; }
|
||||
if (theEvent->altKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_ALT; }
|
||||
if (theEvent->metaKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_META; }
|
||||
|
||||
const bool isEmulated = false;
|
||||
const Aspect_VKeyMouse aButtons = WasmVKeys_MouseButtonsFromNative (theEvent->buttons);
|
||||
switch (theEventType)
|
||||
{
|
||||
case EMSCRIPTEN_EVENT_MOUSEMOVE:
|
||||
{
|
||||
if ((aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
||||
&& PressedMouseButtons() == Aspect_VKeyMouse_NONE)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
if (UpdateMousePosition (aNewPos, aButtons, aFlags, isEmulated))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_MOUSEDOWN:
|
||||
case EMSCRIPTEN_EVENT_MOUSEUP:
|
||||
{
|
||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
if (UpdateMouseButtons (aNewPos, aButtons, aFlags, isEmulated))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_CLICK:
|
||||
case EMSCRIPTEN_EVENT_DBLCLICK:
|
||||
{
|
||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_MOUSEENTER:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_MOUSELEAVE:
|
||||
{
|
||||
// there is no SetCapture() support, so that mouse unclick events outside canvas will not arrive,
|
||||
// so we have to forget current state...
|
||||
if (UpdateMouseButtons (aNewPos, Aspect_VKeyMouse_NONE, aFlags, isEmulated))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return EM_TRUE;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onWheelEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onWheelEvent (int theEventType, const EmscriptenWheelEvent* theEvent)
|
||||
{
|
||||
if (myView.IsNull()
|
||||
|| theEventType != EMSCRIPTEN_EVENT_WHEEL)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (theEvent->mouse.canvasX, theEvent->mouse.canvasY));
|
||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
double aDelta = 0.0;
|
||||
switch (theEvent->deltaMode)
|
||||
{
|
||||
case DOM_DELTA_PIXEL:
|
||||
{
|
||||
aDelta = theEvent->deltaY / (5.0 * myDevicePixelRatio);
|
||||
break;
|
||||
}
|
||||
case DOM_DELTA_LINE:
|
||||
{
|
||||
aDelta = theEvent->deltaY * 8.0;
|
||||
break;
|
||||
}
|
||||
case DOM_DELTA_PAGE:
|
||||
{
|
||||
aDelta = theEvent->deltaY >= 0.0 ? 24.0 : -24.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (UpdateZoom (Aspect_ScrollDelta (aNewPos, -aDelta)))
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
return EM_TRUE;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onTouchEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onTouchEvent (int theEventType, const EmscriptenTouchEvent* theEvent)
|
||||
{
|
||||
const double aClickTolerance = 5.0;
|
||||
if (myView.IsNull())
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
bool hasUpdates = false;
|
||||
for (int aTouchIter = 0; aTouchIter < theEvent->numTouches; ++aTouchIter)
|
||||
{
|
||||
const EmscriptenTouchPoint& aTouch = theEvent->touches[aTouchIter];
|
||||
if (!aTouch.isChanged)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const Standard_Size aTouchId = (Standard_Size )aTouch.identifier;
|
||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (aTouch.canvasX, aTouch.canvasY));
|
||||
switch (theEventType)
|
||||
{
|
||||
case EMSCRIPTEN_EVENT_TOUCHSTART:
|
||||
{
|
||||
if (aNewPos.x() >= 0 && aNewPos.x() < aWinSize.x()
|
||||
&& aNewPos.y() >= 0 && aNewPos.y() < aWinSize.y())
|
||||
{
|
||||
hasUpdates = true;
|
||||
AddTouchPoint (aTouchId, Graphic3d_Vec2d (aNewPos));
|
||||
myClickTouch.From.SetValues (-1.0, -1.0);
|
||||
if (myTouchPoints.Extent() == 1)
|
||||
{
|
||||
myClickTouch.From = Graphic3d_Vec2d (aNewPos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_TOUCHMOVE:
|
||||
{
|
||||
const int anOldIndex = myTouchPoints.FindIndex (aTouchId);
|
||||
if (anOldIndex != 0)
|
||||
{
|
||||
hasUpdates = true;
|
||||
UpdateTouchPoint (aTouchId, Graphic3d_Vec2d (aNewPos));
|
||||
if (myTouchPoints.Extent() == 1
|
||||
&& (myClickTouch.From - Graphic3d_Vec2d (aNewPos)).cwiseAbs().maxComp() > aClickTolerance)
|
||||
{
|
||||
myClickTouch.From.SetValues (-1.0, -1.0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EMSCRIPTEN_EVENT_TOUCHEND:
|
||||
case EMSCRIPTEN_EVENT_TOUCHCANCEL:
|
||||
{
|
||||
if (RemoveTouchPoint (aTouchId))
|
||||
{
|
||||
if (myTouchPoints.IsEmpty()
|
||||
&& myClickTouch.From.minComp() >= 0.0)
|
||||
{
|
||||
if (myDoubleTapTimer.IsStarted()
|
||||
&& myDoubleTapTimer.ElapsedTime() <= myMouseDoubleClickInt)
|
||||
{
|
||||
myView->FitAll (0.01, false);
|
||||
myView->Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
myDoubleTapTimer.Stop();
|
||||
myDoubleTapTimer.Reset();
|
||||
myDoubleTapTimer.Start();
|
||||
SelectInViewer (Graphic3d_Vec2i (myClickTouch.From), false);
|
||||
}
|
||||
}
|
||||
hasUpdates = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasUpdates)
|
||||
{
|
||||
updateView();
|
||||
}
|
||||
return hasUpdates || !myTouchPoints.IsEmpty() ? EM_TRUE : EM_FALSE;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onKeyDownEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onKeyDownEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent)
|
||||
{
|
||||
if (myView.IsNull()
|
||||
|| theEventType != EMSCRIPTEN_EVENT_KEYDOWN) // EMSCRIPTEN_EVENT_KEYPRESS
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
const double aTimeStamp = EventTime();
|
||||
const Aspect_VKey aVKey = WasmVKeys_VirtualKeyFromNative (theEvent->keyCode);
|
||||
if (aVKey == Aspect_VKey_UNKNOWN)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
if (theEvent->repeat == EM_FALSE)
|
||||
{
|
||||
myKeys.KeyDown (aVKey, aTimeStamp);
|
||||
}
|
||||
|
||||
if (Aspect_VKey2Modifier (aVKey) == 0)
|
||||
{
|
||||
// normal key
|
||||
}
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : onKeyUpEvent
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
EM_BOOL WasmOcctView::onKeyUpEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent)
|
||||
{
|
||||
if (myView.IsNull()
|
||||
|| theEventType != EMSCRIPTEN_EVENT_KEYUP)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
const double aTimeStamp = EventTime();
|
||||
const Aspect_VKey aVKey = WasmVKeys_VirtualKeyFromNative (theEvent->keyCode);
|
||||
if (aVKey == Aspect_VKey_UNKNOWN)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
if (theEvent->repeat == EM_TRUE)
|
||||
{
|
||||
return EM_FALSE;
|
||||
}
|
||||
|
||||
const unsigned int aModif = myKeys.Modifiers();
|
||||
myKeys.KeyUp (aVKey, aTimeStamp);
|
||||
if (Aspect_VKey2Modifier (aVKey) == 0)
|
||||
{
|
||||
// normal key released
|
||||
switch (aVKey | aModif)
|
||||
{
|
||||
case Aspect_VKey_F:
|
||||
{
|
||||
myView->FitAll (0.01, false);
|
||||
myView->Invalidate();
|
||||
updateView();
|
||||
return EM_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EM_FALSE;
|
||||
}
|
157
samples/webgl/WasmOcctView.h
Normal file
157
samples/webgl/WasmOcctView.h
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#ifndef _WasmOcctView_HeaderFile
|
||||
#define _WasmOcctView_HeaderFile
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_ViewController.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
class AIS_ViewCube;
|
||||
|
||||
//! Sample class creating 3D Viewer within Emscripten canvas.
|
||||
class WasmOcctView : protected AIS_ViewController
|
||||
{
|
||||
public:
|
||||
//! Default constructor.
|
||||
WasmOcctView();
|
||||
|
||||
//! Destructor.
|
||||
virtual ~WasmOcctView();
|
||||
|
||||
//! Main application entry point.
|
||||
void run();
|
||||
|
||||
//! Return interactive context.
|
||||
const Handle(AIS_InteractiveContext)& Context() const { return myContext; }
|
||||
|
||||
//! Return view.
|
||||
const Handle(V3d_View)& View() const { return myView; }
|
||||
|
||||
//! Return device pixel ratio for handling high DPI displays.
|
||||
float DevicePixelRatio() const { return myDevicePixelRatio; }
|
||||
|
||||
private:
|
||||
|
||||
//! Create window.
|
||||
void initWindow();
|
||||
|
||||
//! Create 3D Viewer.
|
||||
bool initViewer();
|
||||
|
||||
//! Fill 3D Viewer with a DEMO items.
|
||||
void initDemoScene();
|
||||
|
||||
//! Application event loop.
|
||||
void mainloop();
|
||||
|
||||
//! Request view redrawing.
|
||||
void updateView();
|
||||
|
||||
//! Flush events and redraw view.
|
||||
void redrawView();
|
||||
|
||||
//! Handle view redraw.
|
||||
virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView) override;
|
||||
|
||||
//! Dump WebGL context information.
|
||||
void dumpGlInfo (bool theIsBasic);
|
||||
|
||||
//! Initialize pixel scale ratio.
|
||||
void initPixelScaleRatio();
|
||||
|
||||
//! Return point from logical units to backing store.
|
||||
Graphic3d_Vec2d convertPointToBacking (const Graphic3d_Vec2d& thePnt) const
|
||||
{
|
||||
return thePnt * myDevicePixelRatio;
|
||||
}
|
||||
|
||||
//! Return point from logical units to backing store.
|
||||
Graphic3d_Vec2i convertPointToBacking (const Graphic3d_Vec2i& thePnt) const
|
||||
{
|
||||
Graphic3d_Vec2d aPnt = Graphic3d_Vec2d (thePnt) * myDevicePixelRatio + Graphic3d_Vec2d (0.5);
|
||||
return Graphic3d_Vec2i (aPnt);
|
||||
}
|
||||
|
||||
//! @name Emscripten callbacks
|
||||
private:
|
||||
//! Window resize event.
|
||||
EM_BOOL onResizeEvent (int theEventType, const EmscriptenUiEvent* theEvent);
|
||||
|
||||
//! Mouse event.
|
||||
EM_BOOL onMouseEvent (int theEventType, const EmscriptenMouseEvent* theEvent);
|
||||
|
||||
//! Scroll event.
|
||||
EM_BOOL onWheelEvent (int theEventType, const EmscriptenWheelEvent* theEvent);
|
||||
|
||||
//! Touch event.
|
||||
EM_BOOL onTouchEvent (int theEventType, const EmscriptenTouchEvent* theEvent);
|
||||
|
||||
//! Key down event.
|
||||
EM_BOOL onKeyDownEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent);
|
||||
|
||||
//! Key up event.
|
||||
EM_BOOL onKeyUpEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent);
|
||||
|
||||
//! @name Emscripten callbacks (static functions)
|
||||
private:
|
||||
|
||||
static EM_BOOL onResizeCallback (int theEventType, const EmscriptenUiEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onResizeEvent (theEventType, theEvent); }
|
||||
|
||||
static void onRedrawView (void* theView)
|
||||
{ return ((WasmOcctView* )theView)->redrawView(); }
|
||||
|
||||
static EM_BOOL onMouseCallback (int theEventType, const EmscriptenMouseEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onMouseEvent (theEventType, theEvent); }
|
||||
|
||||
static EM_BOOL onWheelCallback (int theEventType, const EmscriptenWheelEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onWheelEvent (theEventType, theEvent); }
|
||||
|
||||
static EM_BOOL onTouchCallback (int theEventType, const EmscriptenTouchEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onTouchEvent (theEventType, theEvent); }
|
||||
|
||||
static EM_BOOL onKeyDownCallback (int theEventType, const EmscriptenKeyboardEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onKeyDownEvent (theEventType, theEvent); }
|
||||
|
||||
static EM_BOOL onKeyUpCallback (int theEventType, const EmscriptenKeyboardEvent* theEvent, void* theView)
|
||||
{ return ((WasmOcctView* )theView)->onKeyUpEvent (theEventType, theEvent); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(AIS_InteractiveContext) myContext; //!< interactive context
|
||||
Handle(V3d_View) myView; //!< 3D view
|
||||
Handle(Prs3d_TextAspect) myTextStyle; //!< text style for OSD elements
|
||||
Handle(AIS_ViewCube) myViewCube; //!< view cube object
|
||||
TCollection_AsciiString myCanvasId; //!< canvas element id on HTML page
|
||||
Aspect_Touch myClickTouch; //!< single touch position for handling clicks
|
||||
OSD_Timer myDoubleTapTimer; //!< timer for handling double tap
|
||||
float myDevicePixelRatio; //!< device pixel ratio for handling high DPI displays
|
||||
unsigned int myUpdateRequests; //!< counter for unhandled update requests
|
||||
|
||||
};
|
||||
|
||||
#endif // _WasmOcctView_HeaderFile
|
264
samples/webgl/WasmVKeys.h
Normal file
264
samples/webgl/WasmVKeys.h
Normal file
@@ -0,0 +1,264 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of the examples of the Open CASCADE Technology software library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
|
||||
#ifndef _WasmVKeys_HeaderFile
|
||||
#define _WasmVKeys_HeaderFile
|
||||
|
||||
#include <Aspect_VKey.hxx>
|
||||
|
||||
#include <emscripten/key_codes.h>
|
||||
|
||||
//! Convert Emscripten mouse buttons into Aspect_VKeyMouse.
|
||||
inline Aspect_VKeyMouse WasmVKeys_MouseButtonsFromNative (unsigned short theButtons)
|
||||
{
|
||||
Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
|
||||
if ((theButtons & 0x1) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_LeftButton;
|
||||
}
|
||||
if ((theButtons & 0x2) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_RightButton;
|
||||
}
|
||||
if ((theButtons & 0x4) != 0)
|
||||
{
|
||||
aButtons |= Aspect_VKeyMouse_MiddleButton;
|
||||
}
|
||||
return aButtons;
|
||||
}
|
||||
|
||||
//! Convert DOM virtual key into Aspect_VKey.
|
||||
inline Aspect_VKey WasmVKeys_VirtualKeyFromNative (Standard_Integer theKey)
|
||||
{
|
||||
if (theKey >= DOM_VK_0
|
||||
&& theKey <= DOM_VK_9)
|
||||
{
|
||||
// numpad keys
|
||||
return Aspect_VKey((theKey - DOM_VK_0) + Aspect_VKey_0);
|
||||
}
|
||||
if (theKey >= DOM_VK_A
|
||||
&& theKey <= DOM_VK_Z)
|
||||
{
|
||||
// main latin alphabet keys
|
||||
return Aspect_VKey((theKey - DOM_VK_A) + Aspect_VKey_A);
|
||||
}
|
||||
if (theKey >= DOM_VK_F1
|
||||
&& theKey <= DOM_VK_F24)
|
||||
{
|
||||
// special keys
|
||||
if (theKey <= DOM_VK_F12)
|
||||
{
|
||||
return Aspect_VKey((theKey - DOM_VK_F1) + Aspect_VKey_F1);
|
||||
}
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
}
|
||||
if (theKey >= DOM_VK_NUMPAD0
|
||||
&& theKey <= DOM_VK_NUMPAD9)
|
||||
{
|
||||
// numpad keys
|
||||
return Aspect_VKey((theKey - DOM_VK_NUMPAD0) + Aspect_VKey_Numpad0);
|
||||
}
|
||||
|
||||
switch (theKey)
|
||||
{
|
||||
case DOM_VK_CANCEL:
|
||||
case DOM_VK_HELP:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_BACK_SPACE:
|
||||
return Aspect_VKey_Backspace;
|
||||
case DOM_VK_TAB:
|
||||
return Aspect_VKey_Tab;
|
||||
case DOM_VK_CLEAR:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_RETURN:
|
||||
case DOM_VK_ENTER:
|
||||
return Aspect_VKey_Enter;
|
||||
case DOM_VK_SHIFT:
|
||||
return Aspect_VKey_Shift;
|
||||
case DOM_VK_CONTROL:
|
||||
return Aspect_VKey_Control;
|
||||
case DOM_VK_ALT:
|
||||
return Aspect_VKey_Alt;
|
||||
case DOM_VK_PAUSE:
|
||||
case DOM_VK_CAPS_LOCK:
|
||||
case DOM_VK_KANA:
|
||||
//case DOM_VK_HANGUL:
|
||||
case DOM_VK_EISU:
|
||||
case DOM_VK_JUNJA:
|
||||
case DOM_VK_FINAL:
|
||||
case DOM_VK_HANJA:
|
||||
//case DOM_VK_KANJI:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_ESCAPE:
|
||||
return Aspect_VKey_Escape;
|
||||
case DOM_VK_CONVERT:
|
||||
case DOM_VK_NONCONVERT:
|
||||
case DOM_VK_ACCEPT:
|
||||
case DOM_VK_MODECHANGE:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_SPACE:
|
||||
return Aspect_VKey_Space;
|
||||
case DOM_VK_PAGE_UP:
|
||||
return Aspect_VKey_PageUp;
|
||||
case DOM_VK_PAGE_DOWN:
|
||||
return Aspect_VKey_PageDown;
|
||||
case DOM_VK_END:
|
||||
return Aspect_VKey_End;
|
||||
case DOM_VK_HOME:
|
||||
return Aspect_VKey_Home;
|
||||
case DOM_VK_LEFT:
|
||||
return Aspect_VKey_Left;
|
||||
case DOM_VK_UP:
|
||||
return Aspect_VKey_Up;
|
||||
case DOM_VK_RIGHT:
|
||||
return Aspect_VKey_Right;
|
||||
case DOM_VK_DOWN:
|
||||
return Aspect_VKey_Down;
|
||||
case DOM_VK_SELECT:
|
||||
case DOM_VK_PRINT:
|
||||
case DOM_VK_EXECUTE:
|
||||
case DOM_VK_PRINTSCREEN:
|
||||
case DOM_VK_INSERT:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_DELETE:
|
||||
return Aspect_VKey_Delete;
|
||||
case DOM_VK_COLON:
|
||||
return Aspect_VKey_Comma;
|
||||
case DOM_VK_SEMICOLON:
|
||||
return Aspect_VKey_Semicolon;
|
||||
case DOM_VK_LESS_THAN:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_EQUALS:
|
||||
return Aspect_VKey_Equal;
|
||||
case DOM_VK_GREATER_THAN:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_QUESTION_MARK:
|
||||
return Aspect_VKey_Slash;
|
||||
case DOM_VK_AT: // @ key
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_WIN:
|
||||
return Aspect_VKey_Meta;
|
||||
case DOM_VK_CONTEXT_MENU:
|
||||
case DOM_VK_SLEEP:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_MULTIPLY:
|
||||
return Aspect_VKey_NumpadMultiply;
|
||||
case DOM_VK_ADD:
|
||||
return Aspect_VKey_NumpadAdd;
|
||||
case DOM_VK_SEPARATOR:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_SUBTRACT:
|
||||
return Aspect_VKey_NumpadSubtract;
|
||||
case DOM_VK_DECIMAL:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_DIVIDE:
|
||||
return Aspect_VKey_NumpadDivide;
|
||||
case DOM_VK_NUM_LOCK:
|
||||
return Aspect_VKey_Numlock;
|
||||
case DOM_VK_SCROLL_LOCK:
|
||||
return Aspect_VKey_Scroll;
|
||||
case DOM_VK_WIN_OEM_FJ_JISHO:
|
||||
case DOM_VK_WIN_OEM_FJ_MASSHOU:
|
||||
case DOM_VK_WIN_OEM_FJ_TOUROKU:
|
||||
case DOM_VK_WIN_OEM_FJ_LOYA:
|
||||
case DOM_VK_WIN_OEM_FJ_ROYA:
|
||||
case DOM_VK_CIRCUMFLEX:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_EXCLAMATION:
|
||||
case DOM_VK_DOUBLE_QUOTE:
|
||||
//case DOM_VK_HASH:
|
||||
case DOM_VK_DOLLAR:
|
||||
case DOM_VK_PERCENT:
|
||||
case DOM_VK_AMPERSAND:
|
||||
case DOM_VK_UNDERSCORE:
|
||||
case DOM_VK_OPEN_PAREN:
|
||||
case DOM_VK_CLOSE_PAREN:
|
||||
case DOM_VK_ASTERISK:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_PLUS:
|
||||
return Aspect_VKey_Plus;
|
||||
case DOM_VK_PIPE:
|
||||
case DOM_VK_HYPHEN_MINUS:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_OPEN_CURLY_BRACKET:
|
||||
return Aspect_VKey_BracketLeft;
|
||||
case DOM_VK_CLOSE_CURLY_BRACKET:
|
||||
return Aspect_VKey_BracketRight;
|
||||
case DOM_VK_TILDE:
|
||||
return Aspect_VKey_Tilde;
|
||||
case DOM_VK_VOLUME_MUTE:
|
||||
return Aspect_VKey_VolumeMute;
|
||||
case DOM_VK_VOLUME_DOWN:
|
||||
return Aspect_VKey_VolumeDown;
|
||||
case DOM_VK_VOLUME_UP:
|
||||
return Aspect_VKey_VolumeUp;
|
||||
case DOM_VK_COMMA:
|
||||
return Aspect_VKey_Comma;
|
||||
case DOM_VK_PERIOD:
|
||||
return Aspect_VKey_Period;
|
||||
case DOM_VK_SLASH:
|
||||
return Aspect_VKey_Slash;
|
||||
case DOM_VK_BACK_QUOTE:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_OPEN_BRACKET:
|
||||
return Aspect_VKey_BracketLeft;
|
||||
case DOM_VK_BACK_SLASH:
|
||||
return Aspect_VKey_Backslash;
|
||||
case DOM_VK_CLOSE_BRACKET:
|
||||
return Aspect_VKey_BracketRight;
|
||||
case DOM_VK_QUOTE:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_META:
|
||||
return Aspect_VKey_Meta;
|
||||
case DOM_VK_ALTGR:
|
||||
return Aspect_VKey_Alt;
|
||||
case DOM_VK_WIN_ICO_HELP:
|
||||
case DOM_VK_WIN_ICO_00:
|
||||
case DOM_VK_WIN_ICO_CLEAR:
|
||||
case DOM_VK_WIN_OEM_RESET:
|
||||
case DOM_VK_WIN_OEM_JUMP:
|
||||
case DOM_VK_WIN_OEM_PA1:
|
||||
case DOM_VK_WIN_OEM_PA2:
|
||||
case DOM_VK_WIN_OEM_PA3:
|
||||
case DOM_VK_WIN_OEM_WSCTRL:
|
||||
case DOM_VK_WIN_OEM_CUSEL:
|
||||
case DOM_VK_WIN_OEM_ATTN:
|
||||
case DOM_VK_WIN_OEM_FINISH:
|
||||
case DOM_VK_WIN_OEM_COPY:
|
||||
case DOM_VK_WIN_OEM_AUTO:
|
||||
case DOM_VK_WIN_OEM_ENLW:
|
||||
case DOM_VK_WIN_OEM_BACKTAB:
|
||||
case DOM_VK_ATTN:
|
||||
case DOM_VK_CRSEL:
|
||||
case DOM_VK_EXSEL:
|
||||
case DOM_VK_EREOF:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
case DOM_VK_PLAY:
|
||||
return Aspect_VKey_MediaPlayPause;
|
||||
case DOM_VK_ZOOM:
|
||||
case DOM_VK_PA1:
|
||||
case DOM_VK_WIN_OEM_CLEAR:
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
}
|
||||
return Aspect_VKey_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif // _WasmVKeys_HeaderFile
|
66
samples/webgl/main.cpp
Normal file
66
samples/webgl/main.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "WasmOcctView.h"
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OSD_MemInfo.hxx>
|
||||
#include <OSD_Parallel.hxx>
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <Standard_ArrayStreamBuffer.hxx>
|
||||
|
||||
#include <emscripten.h>
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
//! Global viewer instance.
|
||||
static WasmOcctView aViewer;
|
||||
|
||||
//! File data read event.
|
||||
extern "C" void onFileDataRead (void* theOpaque, void* theBuffer, int theDataLen)
|
||||
{
|
||||
const char* aName = theOpaque != NULL ? (const char* )theOpaque : "";
|
||||
{
|
||||
AIS_ListOfInteractive aShapes;
|
||||
aViewer.Context()->DisplayedObjects (AIS_KOI_Shape, -1, aShapes);
|
||||
for (AIS_ListOfInteractive::Iterator aShapeIter (aShapes); aShapeIter.More(); aShapeIter.Next())
|
||||
{
|
||||
aViewer.Context()->Remove (aShapeIter.Value(), false);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_ArrayStreamBuffer aStreamBuffer ((const char* )theBuffer, theDataLen);
|
||||
std::istream aStream (&aStreamBuffer);
|
||||
TopoDS_Shape aShape;
|
||||
BRep_Builder aBuilder;
|
||||
BRepTools::Read (aShape, aStream, aBuilder);
|
||||
|
||||
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape);
|
||||
aShapePrs->SetMaterial (Graphic3d_NOM_SILVER);
|
||||
aViewer.Context()->Display (aShapePrs, AIS_Shaded, 0, false);
|
||||
aViewer.View()->FitAll (0.01, false);
|
||||
aViewer.View()->Redraw();
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Loaded file ") + aName, Message_Info);
|
||||
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
|
||||
}
|
||||
|
||||
//! File read error event.
|
||||
static void onFileReadFailed (void* theOpaque)
|
||||
{
|
||||
const char* aName = (const char* )theOpaque;
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Error: unable to load file ") + aName, Message_Fail);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Message::DefaultMessenger()->Printers().First()->SetTraceLevel (Message_Trace);
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("NbLogicalProcessors: ") + OSD_Parallel::NbLogicalProcessors(), Message_Trace);
|
||||
aViewer.run();
|
||||
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
|
||||
|
||||
// load some file
|
||||
emscripten_async_wget_data ("samples/Ball.brep", (void* )"samples/Ball.brep", onFileDataRead, onFileReadFailed);
|
||||
return 0;
|
||||
}
|
133
samples/webgl/occt-webgl-sample.html
Normal file
133
samples/webgl/occt-webgl-sample.html
Normal file
@@ -0,0 +1,133 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en-us>
|
||||
<head>
|
||||
<meta charset=utf-8><meta content="text/html; charset=utf-8" http-equiv=Content-Type>
|
||||
<link rel="shortcut icon" href="lamp.ico" type="image/x-icon" />
|
||||
<title>OCCT WebGL Viewer Sample</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>OCCT WebGL Viewer Sample</h2>
|
||||
<div>
|
||||
<canvas id=canvas oncontextmenu=event.preventDefault() tabindex=-1 style="border:0 none;background-color:#000" width="409" height="409"></canvas>
|
||||
<img id=occlogo src="OCC_logo.png" style="position: absolute; left: 20px; top: 0px; z-index: 2;" />
|
||||
</div>
|
||||
|
||||
<div><label for="fileInput">Choose BREP file to upload: </label><input type="file" id="fileInput" accept=".brep"></div>
|
||||
<h4>Console output:</h4>
|
||||
<p id="output"></p>
|
||||
<script>
|
||||
//! Resize canvas to fit into window.
|
||||
function updateCanvasSize()
|
||||
{
|
||||
// size of canvas in logical (density-independent) units
|
||||
var aSizeX = Math.min (window.innerWidth, window.screen.availWidth);
|
||||
var aSizeY = Math.min (window.innerHeight, window.screen.availHeight);
|
||||
aSizeX = Math.max (300, aSizeX - 30);
|
||||
aSizeY = Math.max (300, aSizeY / 2);
|
||||
canvas.style.width = aSizeX + "px";
|
||||
canvas.style.height = aSizeY + "px";
|
||||
|
||||
// drawing buffer size (aka backing store)
|
||||
var aDevicePixelRatio = window.devicePixelRatio || 1;
|
||||
canvas.width = aSizeX * aDevicePixelRatio;
|
||||
canvas.height = aSizeY * aDevicePixelRatio;
|
||||
|
||||
occlogo.style.top = (aSizeY - 30) + "px";
|
||||
}
|
||||
window.onresize = updateCanvasSize;
|
||||
updateCanvasSize();
|
||||
|
||||
//! Check browser support.
|
||||
function isWasmSupported()
|
||||
{
|
||||
try {
|
||||
if (typeof WebAssembly === "object"
|
||||
&& typeof WebAssembly.instantiate === "function") {
|
||||
const aDummyModule = new WebAssembly.Module (Uint8Array.of (0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
||||
if (aDummyModule instanceof WebAssembly.Module)
|
||||
{
|
||||
return new WebAssembly.Instance(aDummyModule) instanceof WebAssembly.Instance;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
if (!isWasmSupported())
|
||||
{
|
||||
var anElement = document.getElementById('output');
|
||||
anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
|
||||
}
|
||||
|
||||
//! Define OCCT WebGL Viewer module.
|
||||
var Module =
|
||||
{
|
||||
print: (function() {
|
||||
var anElement = document.getElementById('output');
|
||||
return function(theText) { anElement.innerHTML += theText + "<br>"; };
|
||||
})(),
|
||||
printErr: function(theText) {
|
||||
//var anElement = document.getElementById('output');
|
||||
//anElement.innerHTML += theText + "<br>";
|
||||
},
|
||||
canvas: (function() {
|
||||
var aCanvas = document.getElementById('canvas');
|
||||
return aCanvas;
|
||||
})()
|
||||
};
|
||||
|
||||
//! Handle file uploading.
|
||||
fileInput.onchange = function()
|
||||
{
|
||||
if (fileInput.files.length == 0) { return; }
|
||||
// Warning! Entire file is pre-loaded into memory.
|
||||
var aFile = fileInput.files[0];
|
||||
var aReader = new FileReader();
|
||||
aReader.onload = function()
|
||||
{
|
||||
var aDataArray = new Uint8Array (aReader.result);
|
||||
var aNameArray = new Uint8Array (toUtf8Array (aFile.name));
|
||||
const aDataBuffer = Module._malloc(aDataArray.length);
|
||||
const aNameBuffer = Module._malloc(aNameArray.length);
|
||||
Module.HEAPU8.set(aNameArray, aNameBuffer);
|
||||
Module.HEAPU8.set(aDataArray, aDataBuffer);
|
||||
Module.ccall('onFileDataRead', null, ['number', 'number', 'number'], [aNameBuffer, aDataBuffer, aDataArray.length]);
|
||||
Module._free(aDataBuffer);
|
||||
Module._free(aNameBuffer);
|
||||
fileInput.value = '';
|
||||
};
|
||||
aReader.readAsArrayBuffer(aFile);
|
||||
};
|
||||
|
||||
//! Convert string into UTF-8 array.
|
||||
function toUtf8Array (theText)
|
||||
{
|
||||
var aRes = [];
|
||||
for (var aCharIter = 0; aCharIter < theText.length; ++aCharIter)
|
||||
{
|
||||
var aCharCode = theText.charCodeAt (aCharIter);
|
||||
if (aCharCode < 0x80)
|
||||
{
|
||||
aRes.push (aCharCode);
|
||||
}
|
||||
else if (aCharCode < 0x800)
|
||||
{
|
||||
aRes.push (0xc0 | (aCharCode >> 6), 0x80 | (aCharCode & 0x3f));
|
||||
}
|
||||
else if (aCharCode < 0xd800 || aCharCode >= 0xe000)
|
||||
{
|
||||
aRes.push (0xe0 | (aCharCode >> 12), 0x80 | ((aCharCode>>6) & 0x3f), 0x80 | (aCharCode & 0x3f));
|
||||
}
|
||||
else
|
||||
{
|
||||
++aCharIter;
|
||||
aCharCode = 0x10000 + (((aCharCode & 0x3ff)<<10) | (theText.charCodeAt (aCharIter) & 0x3ff));
|
||||
aRes.push(0xf0 | (aCharCode >>18), 0x80 | ((aCharCode>>12) & 0x3f), 0x80 | ((aCharCode>>6) & 0x3f), 0x80 | (aCharCode & 0x3f));
|
||||
}
|
||||
}
|
||||
return aRes;
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="occt-webgl-sample.js" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
@@ -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());
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection,Standard_Transient)
|
||||
// =======================================================================
|
||||
Aspect_DisplayConnection::Aspect_DisplayConnection()
|
||||
{
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
myDisplay = NULL;
|
||||
myIsOwnDisplay = false;
|
||||
OSD_Environment anEnv ("DISPLAY");
|
||||
@@ -40,7 +40,7 @@ Aspect_DisplayConnection::Aspect_DisplayConnection()
|
||||
// =======================================================================
|
||||
Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
||||
{
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
if (myDisplay != NULL
|
||||
&& myIsOwnDisplay)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
// =======================================================================
|
||||
// function : Aspect_DisplayConnection
|
||||
// purpose :
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
#include <InterfaceGraphic.hxx>
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
//! Destructor. Close opened connection.
|
||||
Standard_EXPORT ~Aspect_DisplayConnection();
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
//! Constructor. Creates connection with display specified in theDisplayName.
|
||||
//! Display name should be in format "hostname:number" or "hostname:number.screen_number", where:
|
||||
//! hostname - Specifies the name of the host machine on which the display is physically attached.
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#ifndef _Aspect_FBConfig_HeaderFile
|
||||
#define _Aspect_FBConfig_HeaderFile
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
typedef struct __GLXFBConfigRec* GLXFBConfig;
|
||||
typedef GLXFBConfig Aspect_FBConfig; // GLXFBConfig* under UNIX
|
||||
#else
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#ifndef __Aspect_WNTXWD_HXX
|
||||
# define __Aspect_WNTXWD_HXX
|
||||
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
# include <X11/XWDFile.h>
|
||||
# else
|
||||
|
||||
|
@@ -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] )
|
||||
|
@@ -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,
|
||||
|
@@ -23,11 +23,84 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
//! Base class for BVH_Box (CRTP idiom is used).
|
||||
//! @tparam T Numeric data type
|
||||
//! @tparam N Vector dimension
|
||||
//! @tparam TheDerivedBox Template of derived class that defined axis aligned bounding box.
|
||||
template <class T, int N, template <class /*T*/, int /*N*/> class TheDerivedBox>
|
||||
class BVH_BaseBox {};
|
||||
|
||||
// forward declaration
|
||||
template <class T, int N> class BVH_Box;
|
||||
|
||||
//! Partial template specialization for BVH_Box when N = 3.
|
||||
template <class T>
|
||||
class BVH_BaseBox<T, 3, BVH_Box>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Transforms this box with given transformation.
|
||||
void Transform (const NCollection_Mat4<T>& theTransform)
|
||||
{
|
||||
if (theTransform.IsIdentity())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BVH_Box<T, 3> *aThis = static_cast<BVH_Box<T, 3>*>(this);
|
||||
if (!aThis->IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BVH_Box<T, 3> aBox = Transformed (theTransform);
|
||||
|
||||
aThis->CornerMin() = aBox.CornerMin();
|
||||
aThis->CornerMax() = aBox.CornerMax();
|
||||
}
|
||||
|
||||
//! Returns a box which is the result of applying the
|
||||
//! given transformation to this box.
|
||||
BVH_Box<T, 3> Transformed (const NCollection_Mat4<T>& theTransform) const
|
||||
{
|
||||
BVH_Box<T, 3> aResultBox;
|
||||
|
||||
if (theTransform.IsIdentity())
|
||||
{
|
||||
return aResultBox;
|
||||
}
|
||||
|
||||
const BVH_Box<T, 3> *aThis = static_cast<const BVH_Box<T, 3>*>(this);
|
||||
if (!aThis->IsValid())
|
||||
{
|
||||
return aResultBox;
|
||||
}
|
||||
|
||||
for (size_t aX = 0; aX <= 1; ++aX)
|
||||
{
|
||||
for (size_t aY = 0; aY <= 1; ++aY)
|
||||
{
|
||||
for (size_t aZ = 0; aZ <= 1; ++aZ)
|
||||
{
|
||||
typename BVH::VectorType<T, 4>::Type aPnt =
|
||||
theTransform * typename BVH::VectorType<T, 4>::Type (aX ? aThis->CornerMax().x() : aThis->CornerMin().x(),
|
||||
aY ? aThis->CornerMax().y() : aThis->CornerMin().y(),
|
||||
aZ ? aThis->CornerMax().z() : aThis->CornerMin().z(),
|
||||
static_cast<T> (1.0));
|
||||
|
||||
aResultBox.Add (aPnt.xyz());
|
||||
}
|
||||
}
|
||||
}
|
||||
return aResultBox;
|
||||
}
|
||||
};
|
||||
|
||||
//! Defines axis aligned bounding box (AABB) based on BVH vectors.
|
||||
//! \tparam T Numeric data type
|
||||
//! \tparam N Vector dimension
|
||||
template<class T, int N>
|
||||
class BVH_Box
|
||||
class BVH_Box : public BVH_BaseBox<T, N, BVH_Box>
|
||||
{
|
||||
public:
|
||||
|
||||
|
39
src/BVH/BVH_Ray.hxx
Normal file
39
src/BVH/BVH_Ray.hxx
Normal file
@@ -0,0 +1,39 @@
|
||||
// Created by: Olga Suryaninova
|
||||
// Created on: 2019-11-25
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BVH_Ray_Header
|
||||
#define _BVH_Ray_Header
|
||||
|
||||
//! Describes a ray based on BVH vectors.
|
||||
template<class T, int N>
|
||||
class BVH_Ray
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
|
||||
|
||||
public:
|
||||
|
||||
BVH_VecNt Origin;
|
||||
BVH_VecNt Direct;
|
||||
|
||||
public:
|
||||
|
||||
BVH_Ray (const BVH_VecNt& theOrigin,
|
||||
const BVH_VecNt& theDirect) : Origin (theOrigin),
|
||||
Direct (theDirect) { }
|
||||
};
|
||||
|
||||
#endif // _BVH_Ray_Header
|
@@ -17,6 +17,7 @@
|
||||
#define _BVH_Tools_Header
|
||||
|
||||
#include <BVH_Box.hxx>
|
||||
#include <BVH_Ray.hxx>
|
||||
#include <BVH_Types.hxx>
|
||||
|
||||
//! Defines a set of static methods operating with points and bounding boxes.
|
||||
@@ -35,6 +36,10 @@ public: //! @name Box-Box Square distance
|
||||
static T BoxBoxSquareDistance (const BVH_Box<T, N>& theBox1,
|
||||
const BVH_Box<T, N>& theBox2)
|
||||
{
|
||||
if (!theBox1.IsValid() || !theBox2.IsValid())
|
||||
{
|
||||
return static_cast<T>(0);
|
||||
}
|
||||
return BoxBoxSquareDistance (theBox1.CornerMin(), theBox1.CornerMax(),
|
||||
theBox2.CornerMin(), theBox2.CornerMax());
|
||||
}
|
||||
@@ -60,6 +65,10 @@ public: //! @name Point-Box Square distance
|
||||
static T PointBoxSquareDistance (const BVH_VecNt& thePoint,
|
||||
const BVH_Box<T, N>& theBox)
|
||||
{
|
||||
if (!theBox.IsValid())
|
||||
{
|
||||
return static_cast<T>(0);
|
||||
}
|
||||
return PointBoxSquareDistance (thePoint,
|
||||
theBox.CornerMin(),
|
||||
theBox.CornerMax());
|
||||
@@ -79,6 +88,29 @@ public: //! @name Point-Box Square distance
|
||||
return aDist;
|
||||
}
|
||||
|
||||
public: //! @name Point-Box projection
|
||||
|
||||
//! Computes projection of point on bounding box
|
||||
static BVH_VecNt PointBoxProjection (const BVH_VecNt& thePoint,
|
||||
const BVH_Box<T, N>& theBox)
|
||||
{
|
||||
if (!theBox.IsValid())
|
||||
{
|
||||
return thePoint;
|
||||
}
|
||||
return PointBoxProjection (thePoint,
|
||||
theBox.CornerMin(),
|
||||
theBox.CornerMax());
|
||||
}
|
||||
|
||||
//! Computes projection of point on bounding box
|
||||
static BVH_VecNt PointBoxProjection (const BVH_VecNt& thePoint,
|
||||
const BVH_VecNt& theCMin,
|
||||
const BVH_VecNt& theCMax)
|
||||
{
|
||||
return thePoint.cwiseMax (theCMin).cwiseMin (theCMax);
|
||||
}
|
||||
|
||||
public: //! @name Point-Triangle Square distance
|
||||
|
||||
//! Computes square distance between point and triangle
|
||||
@@ -160,6 +192,92 @@ public: //! @name Point-Triangle Square distance
|
||||
return (aDirect.Dot(aDirect));
|
||||
}
|
||||
|
||||
public: //! @name Ray-Box Intersection
|
||||
|
||||
//! Computes hit time of ray-box intersection
|
||||
static Standard_Boolean RayBoxIntersection (const BVH_Ray<T, N>& theRay,
|
||||
const BVH_Box<T, N>& theBox,
|
||||
T& theTimeEnter,
|
||||
T& theTimeLeave)
|
||||
{
|
||||
if (!theBox.IsValid())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return RayBoxIntersection (theRay, theBox.CornerMin(), theBox.CornerMax(), theTimeEnter, theTimeLeave);
|
||||
}
|
||||
|
||||
//! Computes hit time of ray-box intersection
|
||||
static Standard_Boolean RayBoxIntersection (const BVH_Ray<T, N>& theRay,
|
||||
const BVH_VecNt& theBoxCMin,
|
||||
const BVH_VecNt& theBoxCMax,
|
||||
T& theTimeEnter,
|
||||
T& theTimeLeave)
|
||||
{
|
||||
return RayBoxIntersection (theRay.Origin, theRay.Direct,
|
||||
theBoxCMin, theBoxCMax, theTimeEnter, theTimeLeave);
|
||||
}
|
||||
|
||||
//! Computes hit time of ray-box intersection
|
||||
static Standard_Boolean RayBoxIntersection (const BVH_VecNt& theRayOrigin,
|
||||
const BVH_VecNt& theRayDirection,
|
||||
const BVH_Box<T, N>& theBox,
|
||||
T& theTimeEnter,
|
||||
T& theTimeLeave)
|
||||
{
|
||||
if (!theBox.IsValid())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return RayBoxIntersection (theRayOrigin, theRayDirection,
|
||||
theBox.CornerMin(), theBox.CornerMax(),
|
||||
theTimeEnter, theTimeLeave);
|
||||
}
|
||||
|
||||
//! Computes hit time of ray-box intersection
|
||||
static Standard_Boolean RayBoxIntersection (const BVH_VecNt& theRayOrigin,
|
||||
const BVH_VecNt& theRayDirection,
|
||||
const BVH_VecNt& theBoxCMin,
|
||||
const BVH_VecNt& theBoxCMax,
|
||||
T& theTimeEnter,
|
||||
T& theTimeLeave)
|
||||
{
|
||||
BVH_VecNt aNodeMin, aNodeMax;
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
if (theRayDirection[i] == 0)
|
||||
{
|
||||
aNodeMin[i] = (theBoxCMin[i] - theRayOrigin[i]) < 0 ?
|
||||
(std::numeric_limits<T>::min)() : (std::numeric_limits<T>::max)();
|
||||
aNodeMax[i] = (theBoxCMax[i] - theRayOrigin[i]) < 0 ?
|
||||
(std::numeric_limits<T>::min)() : (std::numeric_limits<T>::max)();
|
||||
}
|
||||
else
|
||||
{
|
||||
aNodeMin[i] = (theBoxCMin[i] - theRayOrigin[i]) / theRayDirection[i];
|
||||
aNodeMax[i] = (theBoxCMax[i] - theRayOrigin[i]) / theRayDirection[i];
|
||||
}
|
||||
}
|
||||
|
||||
BVH_VecNt aTimeMin, aTimeMax;
|
||||
for (int i = 0; i < N; ++i)
|
||||
{
|
||||
aTimeMin[i] = Min (aNodeMin[i], aNodeMax[i]);
|
||||
aTimeMax[i] = Max (aNodeMin[i], aNodeMax[i]);
|
||||
}
|
||||
|
||||
T aTimeEnter = Max (aTimeMin[0], Max (aTimeMin[1], aTimeMin[2]));
|
||||
T aTimeLeave = Min (aTimeMax[0], Min (aTimeMax[1], aTimeMax[2]));
|
||||
|
||||
Standard_Boolean hasIntersection = aTimeEnter <= aTimeLeave && aTimeLeave >= 0;
|
||||
if (hasIntersection)
|
||||
{
|
||||
theTimeEnter = aTimeEnter;
|
||||
theTimeLeave = aTimeLeave;
|
||||
}
|
||||
|
||||
return hasIntersection;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@@ -22,6 +22,7 @@ BVH_PrimitiveSet3d.hxx
|
||||
BVH_Properties.cxx
|
||||
BVH_Properties.hxx
|
||||
BVH_QueueBuilder.hxx
|
||||
BVH_Ray.hxx
|
||||
BVH_Set.hxx
|
||||
BVH_Sorter.hxx
|
||||
BVH_QuickSorter.hxx
|
||||
|
@@ -1238,8 +1238,11 @@ void ComputeInternalPoints
|
||||
// std::cout << "Changement de signe detecte" << std::endl;
|
||||
solution = Standard_False;
|
||||
while (!solution) {
|
||||
X(1) = (XInf(1) + XSup(1)) /2.;
|
||||
X(2) = (XInf(2) + XSup(2)) /2.;
|
||||
// Selecting the middle point between XInf and XSup leads situation, where X values almost do not change.
|
||||
// To prevent this situation, select shifted point instead of middle.
|
||||
const Standard_Real aCoef = 2. / 3.;
|
||||
X(1) = XInf(1) + aCoef * (XSup(1) - XInf(1));
|
||||
X(2) = XInf(2) + aCoef * (XSup(2) - XInf(2));
|
||||
rsnld.Perform(SFunc,X,infb,supb);
|
||||
|
||||
if (!rsnld.IsDone()) {
|
||||
|
@@ -767,50 +767,64 @@ static int dmeminfo (Draw_Interpretor& theDI,
|
||||
Standard_Integer theArgNb,
|
||||
const char** theArgVec)
|
||||
{
|
||||
OSD_MemInfo aMemInfo;
|
||||
if (theArgNb <= 1)
|
||||
{
|
||||
OSD_MemInfo aMemInfo;
|
||||
theDI << aMemInfo.ToString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
NCollection_Map<OSD_MemInfo::Counter> aCounters;
|
||||
for (Standard_Integer anIter = 1; anIter < theArgNb; ++anIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgVec[anIter]);
|
||||
anArg.LowerCase();
|
||||
if (anArg == "virt" || anArg == "v")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemVirtual)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemVirtual);
|
||||
}
|
||||
else if (anArg == "heap" || anArg == "h")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemHeapUsage)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemHeapUsage);
|
||||
}
|
||||
else if (anArg == "wset" || anArg == "w")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemWorkingSet)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemWorkingSet);
|
||||
}
|
||||
else if (anArg == "wsetpeak")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemWorkingSetPeak)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemWorkingSetPeak);
|
||||
}
|
||||
else if (anArg == "swap")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemSwapUsage)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemSwapUsage);
|
||||
}
|
||||
else if (anArg == "swappeak")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemSwapUsagePeak)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemSwapUsagePeak);
|
||||
}
|
||||
else if (anArg == "private")
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (OSD_MemInfo::MemPrivate)) << " ";
|
||||
aCounters.Add (OSD_MemInfo::MemPrivate);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unknown argument '" << theArgVec[anIter] << "'!\n";
|
||||
}
|
||||
}
|
||||
|
||||
OSD_MemInfo aMemInfo (Standard_False);
|
||||
aMemInfo.SetActive (Standard_False);
|
||||
for (NCollection_Map<OSD_MemInfo::Counter>::Iterator aCountersIt (aCounters); aCountersIt.More(); aCountersIt.Next())
|
||||
{
|
||||
aMemInfo.SetActive (aCountersIt.Value(), Standard_True);
|
||||
}
|
||||
aMemInfo.Update();
|
||||
|
||||
for (NCollection_Map<OSD_MemInfo::Counter>::Iterator aCountersIt (aCounters); aCountersIt.More(); aCountersIt.Next())
|
||||
{
|
||||
theDI << Standard_Real (aMemInfo.Value (aCountersIt.Value())) << " ";
|
||||
}
|
||||
theDI << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
@@ -18,3 +18,4 @@ Font_SystemFont.hxx
|
||||
Font_TextFormatter.hxx
|
||||
Font_TextFormatter.cxx
|
||||
Font_UnicodeSubset.hxx
|
||||
Font_DejavuSans_Latin_woff.pxx
|
||||
|
1649
src/Font/Font_DejavuSans_Latin_woff.pxx
Normal file
1649
src/Font/Font_DejavuSans_Latin_woff.pxx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,8 @@
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
|
||||
#include "Font_DejavuSans_Latin_woff.pxx"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <ft2build.h>
|
||||
@@ -156,9 +158,9 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t
|
||||
{
|
||||
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
||||
Font_FontAspect aFontAspect = theFontAspect;
|
||||
Font_FTFontParams aParams = theParams;
|
||||
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (theFontName, theStrictLevel, aFontAspect))
|
||||
{
|
||||
Font_FTFontParams aParams = theParams;
|
||||
if (aRequestedFont->IsSingleStrokeFont())
|
||||
{
|
||||
aParams.IsSingleStrokeFont = true;
|
||||
@@ -172,6 +174,31 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t
|
||||
return aFont;
|
||||
}
|
||||
}
|
||||
else if (theStrictLevel == Font_StrictLevel_Any)
|
||||
{
|
||||
switch (theFontAspect)
|
||||
{
|
||||
case Font_FontAspect_UNDEFINED:
|
||||
case Font_FontAspect_Regular:
|
||||
case Font_FontAspect_Bold:
|
||||
aFontAspect = Font_FontAspect_Regular;
|
||||
break;
|
||||
case Font_FontAspect_Italic:
|
||||
case Font_FontAspect_BoldItalic:
|
||||
aFontAspect = Font_FontAspect_Italic;
|
||||
aParams.ToSynthesizeItalic = true;
|
||||
break;
|
||||
}
|
||||
Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Handle(NCollection_BaseAllocator)(),
|
||||
Font_DejavuSans_Latin_woff_size,
|
||||
const_cast<Standard_Byte*>(Font_DejavuSans_Latin_woff));
|
||||
Handle(Font_FTFont) aFont = new Font_FTFont();
|
||||
if (aFont->Init (aBuffer, "Embed Fallback Font", aParams))
|
||||
{
|
||||
aFont->myFontAspect = aFontAspect;
|
||||
return aFont;
|
||||
}
|
||||
}
|
||||
return Handle(Font_FTFont)();
|
||||
}
|
||||
|
||||
@@ -197,6 +224,18 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName,
|
||||
const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic);
|
||||
return Init (aPath, aParams);
|
||||
}
|
||||
else if (theStrictLevel == Font_StrictLevel_Any)
|
||||
{
|
||||
if (theFontAspect == Font_FontAspect_Italic
|
||||
|| theFontAspect == Font_FontAspect_BoldItalic)
|
||||
{
|
||||
aParams.ToSynthesizeItalic = true;
|
||||
}
|
||||
Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Handle(NCollection_BaseAllocator)(),
|
||||
Font_DejavuSans_Latin_woff_size,
|
||||
const_cast<Standard_Byte*>(Font_DejavuSans_Latin_woff));
|
||||
return Init (aBuffer, "Embed Fallback Font", aParams);
|
||||
}
|
||||
Release();
|
||||
return false;
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
|
||||
NULL
|
||||
};
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
|
||||
// X11 configuration file in plain text format (obsolete - doesn't exists in modern distributives)
|
||||
static Standard_CString myFontServiceConf[] = {"/etc/X11/fs/config",
|
||||
"/usr/X11R6/lib/X11/fs/config",
|
||||
@@ -303,6 +303,7 @@ Font_FontMgr::Font_FontMgr()
|
||||
aKorean->Append (Font_FontAlias ("nanummyeongjo")); // Linux
|
||||
aKorean->Append (Font_FontAlias ("noto serif cjk jp")); // Linux
|
||||
aKorean->Append (Font_FontAlias ("noto sans cjk jp")); // Linux
|
||||
aKorean->Append (Font_FontAlias ("droid sans fallback")); // Linux
|
||||
|
||||
#if defined(_WIN32)
|
||||
anArab->Append (Font_FontAlias ("times new roman"));
|
||||
@@ -390,6 +391,15 @@ Standard_Boolean Font_FontMgr::RegisterFont (const Handle(Font_SystemFont)& theF
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ClearFontDataBase()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Font_FontMgr::ClearFontDataBase()
|
||||
{
|
||||
myFontMap.Clear();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitFontDataBase
|
||||
// purpose :
|
||||
@@ -473,7 +483,7 @@ void Font_FontMgr::InitFontDataBase()
|
||||
#else
|
||||
|
||||
NCollection_Map<TCollection_AsciiString> aMapOfFontsDirs;
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
|
||||
if (FcConfig* aFcCfg = FcInitLoadConfig())
|
||||
{
|
||||
if (FcStrList* aFcFontDir = FcConfigGetFontDirs (aFcCfg))
|
||||
@@ -576,7 +586,7 @@ void Font_FontMgr::InitFontDataBase()
|
||||
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
|
||||
anIter.More(); anIter.Next())
|
||||
{
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
|
||||
OSD_File aReadFile (anIter.Value() + "/fonts.dir");
|
||||
if (!aReadFile.Exists())
|
||||
{
|
||||
@@ -597,7 +607,7 @@ void Font_FontMgr::InitFontDataBase()
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__)
|
||||
#if !defined(__ANDROID__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -742,14 +752,27 @@ Handle(Font_SystemFont) Font_FontMgr::FindFallbackFont (Font_UnicodeSubset theSu
|
||||
Font_FontAspect theFontAspect) const
|
||||
{
|
||||
Font_FontAspect aFontAspect = theFontAspect;
|
||||
Handle(Font_SystemFont) aFont;
|
||||
switch (theSubset)
|
||||
{
|
||||
case Font_UnicodeSubset_Western: return FindFont (Font_NOF_SANS_SERIF, Font_StrictLevel_Aliases, aFontAspect);
|
||||
case Font_UnicodeSubset_Korean: return FindFont (Font_NOF_KOREAN, Font_StrictLevel_Aliases, aFontAspect);
|
||||
case Font_UnicodeSubset_CJK: return FindFont (Font_NOF_CJK, Font_StrictLevel_Aliases, aFontAspect);
|
||||
case Font_UnicodeSubset_Arabic: return FindFont (Font_NOF_ARABIC, Font_StrictLevel_Aliases, aFontAspect);
|
||||
case Font_UnicodeSubset_Western: aFont = FindFont (Font_NOF_SANS_SERIF, Font_StrictLevel_Aliases, aFontAspect, false); break;
|
||||
case Font_UnicodeSubset_Korean: aFont = FindFont (Font_NOF_KOREAN, Font_StrictLevel_Aliases, aFontAspect, false); break;
|
||||
case Font_UnicodeSubset_CJK: aFont = FindFont (Font_NOF_CJK, Font_StrictLevel_Aliases, aFontAspect, false); break;
|
||||
case Font_UnicodeSubset_Arabic: aFont = FindFont (Font_NOF_ARABIC, Font_StrictLevel_Aliases, aFontAspect, false); break;
|
||||
}
|
||||
return Handle(Font_SystemFont)();
|
||||
if (aFont.IsNull())
|
||||
{
|
||||
const char* aRange = "";
|
||||
switch (theSubset)
|
||||
{
|
||||
case Font_UnicodeSubset_Western: aRange = "Western"; break;
|
||||
case Font_UnicodeSubset_Korean: aRange = "Korean"; break;
|
||||
case Font_UnicodeSubset_CJK: aRange = "CJK"; break;
|
||||
case Font_UnicodeSubset_Arabic: aRange = "Arabic"; break;
|
||||
}
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, error: unable to find ") + aRange + " fallback font!", Message_Fail);
|
||||
}
|
||||
return aFont;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -758,7 +781,8 @@ Handle(Font_SystemFont) Font_FontMgr::FindFallbackFont (Font_UnicodeSubset theSu
|
||||
// =======================================================================
|
||||
Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& theFontName,
|
||||
Font_StrictLevel theStrictLevel,
|
||||
Font_FontAspect& theFontAspect) const
|
||||
Font_FontAspect& theFontAspect,
|
||||
Standard_Boolean theDoFailMsg) const
|
||||
{
|
||||
TCollection_AsciiString aFontName (theFontName);
|
||||
aFontName.LowerCase();
|
||||
@@ -844,7 +868,10 @@ Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& t
|
||||
}
|
||||
if (aFont.IsNull())
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, error: unable to find any font!", Message_Fail));
|
||||
if (theDoFailMsg)
|
||||
{
|
||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Font_FontMgr, error: unable to find any font!"), Message_Fail);
|
||||
}
|
||||
return Handle(Font_SystemFont)();
|
||||
}
|
||||
|
||||
|
@@ -100,9 +100,11 @@ public:
|
||||
//! @param theStrictLevel [in] search strict level for using aliases and fallback
|
||||
//! @param theFontAspect [in] [out] font aspect to find (considered only if family name is not found);
|
||||
//! can be modified if specified font alias refers to another style (compatibility with obsolete aliases)
|
||||
//! @param theDoFailMsg [in] put error message on failure into default messenger
|
||||
Standard_EXPORT Handle(Font_SystemFont) FindFont (const TCollection_AsciiString& theFontName,
|
||||
Font_StrictLevel theStrictLevel,
|
||||
Font_FontAspect& theFontAspect) const;
|
||||
Font_FontAspect& theFontAspect,
|
||||
Standard_Boolean theDoFailMsg = Standard_True) const;
|
||||
|
||||
//! Tries to find font by given parameters.
|
||||
Handle(Font_SystemFont) FindFont (const TCollection_AsciiString& theFontName,
|
||||
@@ -133,13 +135,16 @@ public:
|
||||
//! Can be disabled to avoid redundant messages with Message_Trace level.
|
||||
void SetTraceAliases (Standard_Boolean theToTrace) { myToTraceAliases = theToTrace; }
|
||||
|
||||
//! Collects available fonts paths.
|
||||
Standard_EXPORT void InitFontDataBase();
|
||||
|
||||
//! Clear registry. Can be used for testing purposes.
|
||||
Standard_EXPORT void ClearFontDataBase();
|
||||
|
||||
private:
|
||||
|
||||
//! Creates empty font manager object
|
||||
Standard_EXPORT Font_FontMgr();
|
||||
|
||||
//! Collects available fonts paths.
|
||||
Standard_EXPORT void InitFontDataBase();
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -16,12 +16,12 @@
|
||||
#include <HeaderSection_Protocol.hxx>
|
||||
#include <Interface_Statics.hxx>
|
||||
|
||||
StaticHandle(HeaderSection_Protocol, proto);
|
||||
//StaticHandle(HeaderSection_Protocol, proto);
|
||||
|
||||
Handle(HeaderSection_Protocol) HeaderSection::Protocol()
|
||||
|
||||
{
|
||||
InitHandleVoid(HeaderSection_Protocol, proto);
|
||||
return proto;
|
||||
}
|
||||
{
|
||||
//InitHandleVoid(HeaderSection_Protocol, proto);
|
||||
return new HeaderSection_Protocol;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(HeaderSection_Protocol,StepData_Protocol)
|
||||
|
||||
static Standard_CString schemaName = "header_section";
|
||||
//static Standard_CString schemaName = "header_section";
|
||||
|
||||
HeaderSection_Protocol::HeaderSection_Protocol () { }
|
||||
|
||||
@@ -35,5 +35,5 @@ Handle(Standard_Type)& atype) const
|
||||
else return 0;
|
||||
}
|
||||
|
||||
Standard_CString HeaderSection_Protocol::SchemaName() const
|
||||
{ return schemaName; }
|
||||
Standard_CString HeaderSection_Protocol::SchemaName(Standard_Integer /*theShematype*/)
|
||||
{ return "header_section"; }
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
//! Returns a Case Number for each of the HeaderSection Entities
|
||||
Standard_EXPORT virtual Standard_Integer TypeNumber (const Handle(Standard_Type)& atype) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype) Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
@@ -264,8 +264,8 @@ IFSelect_ModelCopier::IFSelect_ModelCopier () { }
|
||||
{
|
||||
Interface_CheckIterator checks;
|
||||
checks.SetName ("X-STEP WorkSession : Send All");
|
||||
Message::DefaultMessenger() <<
|
||||
"** WorkSession : Sending all data"<<Message_EndLine;
|
||||
//Message::DefaultMessenger() <<
|
||||
// "** WorkSession : Sending all data"<<Message_EndLine;
|
||||
Handle(Interface_InterfaceModel) model = G.Model();
|
||||
if (model.IsNull() || protocol.IsNull() || WL.IsNull()) return checks;
|
||||
|
||||
|
@@ -71,7 +71,6 @@
|
||||
#include <Interface_ReportEntity.hxx>
|
||||
#include <Interface_ShareFlags.hxx>
|
||||
#include <Interface_ShareTool.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
@@ -212,7 +211,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
|
||||
{
|
||||
if (thelibrary.IsNull()) return IFSelect_RetVoid;
|
||||
if (theprotocol.IsNull()) return IFSelect_RetVoid;
|
||||
Handle(Interface_InterfaceModel) model;
|
||||
Handle(Interface_InterfaceModel) model =myModel;
|
||||
IFSelect_ReturnStatus status = IFSelect_RetVoid;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
@@ -1076,30 +1075,6 @@ Standard_Integer IFSelect_WorkSession::NextIdentForLabel
|
||||
// #################################################################
|
||||
// .... Parametres (Int et Text) ....
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Standard_Transient) IFSelect_WorkSession::NewParamFromStatic
|
||||
(const Standard_CString statname, const Standard_CString name)
|
||||
{
|
||||
Handle(Standard_Transient) param;
|
||||
Handle(Interface_Static) stat = Interface_Static::Static(statname);
|
||||
if (stat.IsNull()) return param;
|
||||
if (stat->Type() == Interface_ParamInteger) {
|
||||
Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam;
|
||||
intpar->SetStaticName (statname);
|
||||
param = intpar;
|
||||
} else {
|
||||
param = stat->HStringValue();
|
||||
}
|
||||
if (param.IsNull()) return param;
|
||||
if ( AddNamedItem (name, param) == 0 ) param.Nullify();
|
||||
return param;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
@@ -1701,11 +1676,12 @@ Standard_Integer IFSelect_WorkSession::RunTransformer
|
||||
{
|
||||
Standard_Integer effect = 0;
|
||||
if (transf.IsNull() || !IsLoaded()) return effect;
|
||||
|
||||
Handle(Interface_InterfaceModel) newmod; // Null au depart
|
||||
Interface_CheckIterator checks;
|
||||
checks.SetName("X-STEP WorkSession : RunTransformer");
|
||||
Standard_Boolean res = transf->Perform
|
||||
(thegraph->Graph(),theprotocol,checks,newmod);
|
||||
(thegraph->Graph(),theprotocol,checks,myModel);
|
||||
|
||||
if (!checks.IsEmpty(Standard_False)) {
|
||||
Handle(Message_Messenger) sout = Message::DefaultMessenger();
|
||||
@@ -3055,7 +3031,7 @@ Handle(IFSelect_Selection) IFSelect_WorkSession::GiveSelection
|
||||
}
|
||||
|
||||
Handle(IFSelect_Selection) sel;
|
||||
if (np >= 0)
|
||||
if (np >= 0)
|
||||
{
|
||||
nomsel[np] = 0;
|
||||
}
|
||||
|
@@ -407,13 +407,6 @@ public:
|
||||
//! - other values are ignored
|
||||
Standard_EXPORT Standard_Integer NextIdentForLabel (const Standard_CString label, const Standard_Integer id, const Standard_Integer mode = 0) const;
|
||||
|
||||
//! Creates a parameter as being bound to a Static
|
||||
//! If the Static is Integer, this creates an IntParam bound to
|
||||
//! it by its name. Else this creates a String which is the value
|
||||
//! of the Static.
|
||||
//! Returns a null handle if <statname> is unknown as a Static
|
||||
Standard_EXPORT Handle(Standard_Transient) NewParamFromStatic (const Standard_CString statname, const Standard_CString name = "");
|
||||
|
||||
//! Returns an IntParam, given its Ident in the Session
|
||||
//! Null result if <id> is not suitable for an IntParam
|
||||
//! (undefined, or defined for another kind of variable)
|
||||
|
@@ -22,6 +22,14 @@
|
||||
#define No_Standard_OutOfRange
|
||||
#endif
|
||||
|
||||
static void CutVectorByTolerances (gp_Vec2d& theVector,
|
||||
const math_Vector& theTolerance)
|
||||
{
|
||||
if (Abs(theVector.X()) < theTolerance(1))
|
||||
theVector.SetX (0.);
|
||||
if (Abs(theVector.Y()) < theTolerance(2))
|
||||
theVector.SetY (0.);
|
||||
}
|
||||
|
||||
// _______________________________________________
|
||||
//
|
||||
@@ -141,7 +149,7 @@ Standard_Boolean IntWalk_IWalking::Cadrage
|
||||
}
|
||||
BornSup(1) = BornInf(1); // limit the parameter
|
||||
UVap(1) = BornInf(1);
|
||||
UVap(2) += Step*Duvy*StepSign;;
|
||||
UVap(2) += Step*Duvy*StepSign;
|
||||
return Standard_True;
|
||||
}
|
||||
else if (supu) { // jag 940616
|
||||
@@ -771,8 +779,13 @@ void IntWalk_IWalking::TestArretCadre
|
||||
Line->Value(j).ParametersOnS1(Uc,Vc);
|
||||
}
|
||||
|
||||
Scal = (Up-wd1[i].ustart) * (Uc-wd1[i].ustart) +
|
||||
(Vp-wd1[i].vstart) * (Vc-wd1[i].vstart);
|
||||
gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
|
||||
aVec2 (Uc-wd1[i].ustart, Vc-wd1[i].vstart);
|
||||
CutVectorByTolerances (aVec1, tolerance);
|
||||
CutVectorByTolerances (aVec2, tolerance);
|
||||
|
||||
Scal = aVec1 * aVec2;
|
||||
|
||||
// if a stop point is found: stop the line on this point.
|
||||
if (Scal < 0) {
|
||||
Line->Cut(j); nbp= Line->NbPoints();
|
||||
@@ -791,8 +804,14 @@ void IntWalk_IWalking::TestArretCadre
|
||||
}
|
||||
else if (nbMultiplicities[i] > 0) {
|
||||
for (Standard_Integer k = N+1; k <= N + nbMultiplicities[i]; k++) {
|
||||
Scal = (Up-Umult(k)) * (Uc-Umult(k)) +
|
||||
(Vp-Vmult(k)) * (Vc-Vmult(k));
|
||||
|
||||
aVec1.SetCoord (Up-Umult(k), Vp-Vmult(k)),
|
||||
aVec2.SetCoord (Uc-Umult(k), Vc-Vmult(k));
|
||||
CutVectorByTolerances (aVec1, tolerance);
|
||||
CutVectorByTolerances (aVec2, tolerance);
|
||||
|
||||
Scal = aVec1 * aVec2;
|
||||
|
||||
if (Scal < 0) {
|
||||
Line->Cut(j); nbp= Line->NbPoints();
|
||||
Irang=i;
|
||||
@@ -847,11 +866,13 @@ void IntWalk_IWalking::TestArretCadre
|
||||
// now the last point of the line and the last calculated point are compated.
|
||||
// there will be no need to "Cut"
|
||||
|
||||
Scal = (Up-wd1[i].ustart) * (UV(1)-wd1[i].ustart) +
|
||||
// (Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
|
||||
// modified by NIZHNY-MKK Fri Oct 27 12:29:41 2000
|
||||
(Vp-wd1[i].vstart) * (UV(2)-wd1[i].vstart);
|
||||
|
||||
gp_Vec2d aVec1 (Up-wd1[i].ustart, Vp-wd1[i].vstart),
|
||||
aVec2 (UV(1)-wd1[i].ustart, UV(2)-wd1[i].vstart);
|
||||
CutVectorByTolerances (aVec1, tolerance);
|
||||
CutVectorByTolerances (aVec2, tolerance);
|
||||
|
||||
Scal = aVec1 * aVec2;
|
||||
|
||||
if (Scal < 0) {
|
||||
Irang = i;
|
||||
UV(1) = wd1[Irang].ustart;
|
||||
@@ -867,8 +888,14 @@ void IntWalk_IWalking::TestArretCadre
|
||||
}
|
||||
else if (nbMultiplicities[i] > 0) {
|
||||
for (Standard_Integer j = N+1; j <= N+nbMultiplicities[i]; j++) {
|
||||
Scal = (Up-Umult(j)) * (UV(1)-Umult(j)) +
|
||||
(Vp-Vmult(j)) * (UV(2)-Vmult(j));
|
||||
|
||||
aVec1.SetCoord (Up-Umult(j), Vp-Vmult(j));
|
||||
aVec2.SetCoord (UV(1)-Umult(j), UV(2)-Vmult(j));
|
||||
CutVectorByTolerances (aVec1, tolerance);
|
||||
CutVectorByTolerances (aVec2, tolerance);
|
||||
|
||||
Scal = aVec1 * aVec2;
|
||||
|
||||
if (Scal < 0) {
|
||||
Irang=i;
|
||||
UV(1) = wd1[Irang].ustart;
|
||||
|
@@ -39,10 +39,8 @@
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
static int errh = 1;
|
||||
|
||||
|
||||
static void raisecheck (Standard_Failure& theException,Handle(Interface_Check)& ach)
|
||||
void Interface_CheckTool::raisecheck (Standard_Failure& theException,Handle(Interface_Check)& ach)
|
||||
{
|
||||
char mess[100];
|
||||
sprintf (mess,"** Exception Raised during Check : %s **",
|
||||
@@ -75,6 +73,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
|
||||
theshare (model,protocol)
|
||||
{
|
||||
thestat = 0;
|
||||
errh = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +87,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
|
||||
{
|
||||
thestat = 0;
|
||||
thegtool->Reservate(model->NbEntities());
|
||||
errh = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ Interface_CheckTool::Interface_CheckTool(const Handle(Interface_InterfaceModel)&
|
||||
Interface_CheckTool::Interface_CheckTool(const Interface_Graph& graph)
|
||||
: thegtool(graph.Model()->GTool()) , theshare (graph)
|
||||
{
|
||||
errh = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +111,7 @@ Interface_CheckTool::Interface_CheckTool(const Interface_Graph& graph)
|
||||
Interface_CheckTool::Interface_CheckTool(const Handle(Interface_HGraph)& hgraph)
|
||||
: thegtool(hgraph->Graph().Model()->GTool()) , theshare (hgraph)
|
||||
{
|
||||
errh = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,10 +128,10 @@ void Interface_CheckTool::FillCheck(const Handle(Standard_Transient)& ent,
|
||||
Standard_Integer CN;
|
||||
if (thegtool->Select(ent,module,CN)) {
|
||||
// Sans try/catch (fait par l appelant, evite try/catch en boucle)
|
||||
if (!errh) {
|
||||
module->CheckCase(CN,ent,sh,ach);
|
||||
return;
|
||||
}
|
||||
//if (!errh) {
|
||||
// module->CheckCase(CN,ent,sh,ach);
|
||||
// return;
|
||||
//}
|
||||
// Avec try/catch
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
@@ -200,7 +202,7 @@ Handle(Interface_Check) Interface_CheckTool::Check(const Standard_Integer num)
|
||||
Handle(Interface_InterfaceModel) model = theshare.Model();
|
||||
Handle(Standard_Transient) ent = model->Value(num);
|
||||
Handle(Interface_Check) ach = new Interface_Check(ent); // non filtre par "Warning" : tel quel
|
||||
errh = 1;
|
||||
//errh = 1;
|
||||
FillCheck(ent,theshare,ach);
|
||||
return ach;
|
||||
}
|
||||
@@ -221,13 +223,13 @@ void Interface_CheckTool::CheckSuccess (const Standard_Boolean reset)
|
||||
("Interface Model : Global Check");
|
||||
Handle(Interface_InterfaceModel) model = theshare.Model();
|
||||
if (model->GlobalCheck()->NbFails() > 0) throw Interface_CheckFailure("Interface Model : Global Check");
|
||||
Handle(Interface_Check) modchk = new Interface_Check;
|
||||
model->VerifyCheck(modchk);
|
||||
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),modchk);
|
||||
if (modchk->HasFailed()) throw Interface_CheckFailure("Interface Model : Verify Check");
|
||||
if (thestat == 3) return; // tout teste et ca passe
|
||||
//Handle(Interface_Check) modchk = new Interface_Check;
|
||||
//model->VerifyCheck(modchk);
|
||||
//if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),modchk);
|
||||
//if (modchk->HasFailed()) throw Interface_CheckFailure("Interface Model : Verify Check");
|
||||
//if (thestat == 3) return; // tout teste et ca passe
|
||||
|
||||
errh = 0; // Pas de try/catch, car justement on raise
|
||||
//errh = 0; // Pas de try/catch, car justement on raise
|
||||
Standard_Integer nb = model->NbEntities();
|
||||
for (Standard_Integer i = 1; i <= nb; i ++) {
|
||||
if (model->IsErrorEntity(i)) throw Interface_CheckFailure("Interface Model : an Entity is recorded as Erroneous");
|
||||
@@ -262,13 +264,13 @@ Interface_CheckIterator Interface_CheckTool::CompleteCheckList ()
|
||||
Interface_CheckIterator res;
|
||||
res.SetModel(model);
|
||||
Handle(Interface_Check) globch = model->GlobalCheck(); // GlobalCheck Statique
|
||||
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
|
||||
model->VerifyCheck(globch); // GlobalCheck Dynamique
|
||||
if (globch->HasFailed() || globch->HasWarnings()) res.Add(globch,0);
|
||||
if (globch->HasFailed()) thestat |= 12;
|
||||
//if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
|
||||
//model->VerifyCheck(globch); // GlobalCheck Dynamique
|
||||
//if (globch->HasFailed() || globch->HasWarnings()) res.Add(globch,0);
|
||||
//if (globch->HasFailed()) thestat |= 12;
|
||||
|
||||
Standard_Integer i=0,n0 = 1, nb = model->NbEntities();
|
||||
errh = 0;
|
||||
//errh = 0;
|
||||
while (n0 <= nb) {
|
||||
Handle(Interface_Check) ach = new Interface_Check;
|
||||
Handle(Standard_Transient) ent;
|
||||
@@ -316,11 +318,11 @@ Interface_CheckIterator Interface_CheckTool::CheckList ()
|
||||
res.SetModel(model);
|
||||
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
|
||||
Handle(Interface_Check) globch = model->GlobalCheck();
|
||||
if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
|
||||
model->VerifyCheck(globch);
|
||||
if (globch->HasFailed()) { thestat |= 12; res.Add(globch,0); }
|
||||
//if (!model->Protocol().IsNull()) model->Protocol()->GlobalCheck (theshare.Graph(),globch);
|
||||
//model->VerifyCheck(globch);
|
||||
//if (globch->HasFailed()) { thestat |= 12; res.Add(globch,0); }
|
||||
|
||||
errh = 0;
|
||||
//errh = 0;
|
||||
while (n0 <= nb) {
|
||||
Handle(Interface_Check) ach = new Interface_Check;
|
||||
Handle(Standard_Transient) ent;
|
||||
@@ -368,7 +370,7 @@ Interface_CheckIterator Interface_CheckTool::AnalyseCheckList ()
|
||||
res.SetModel(model);
|
||||
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
|
||||
|
||||
errh = 0;
|
||||
//errh = 0;
|
||||
while (n0 <= nb) {
|
||||
Handle(Interface_Check) ach = new Interface_Check;
|
||||
try {
|
||||
@@ -408,7 +410,7 @@ Interface_CheckIterator Interface_CheckTool::VerifyCheckList ()
|
||||
res.SetModel(model);
|
||||
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
|
||||
|
||||
errh = 0;
|
||||
//errh = 0;
|
||||
while (n0 <= nb) {
|
||||
Handle(Standard_Transient) ent;
|
||||
Handle(Interface_Check) ach = new Interface_Check;
|
||||
@@ -452,7 +454,7 @@ Interface_CheckIterator Interface_CheckTool::WarningCheckList ()
|
||||
res.SetModel(model);
|
||||
Standard_Integer i=0, n0 = 1, nb = model->NbEntities();
|
||||
|
||||
errh = 0;
|
||||
//errh = 0;
|
||||
while (n0 <= nb) {
|
||||
Handle(Interface_Check) ach = new Interface_Check;
|
||||
Handle(Standard_Transient) ent;
|
||||
|
@@ -131,10 +131,12 @@ protected:
|
||||
private:
|
||||
|
||||
|
||||
Standard_EXPORT void raisecheck(Standard_Failure& theException, Handle(Interface_Check)& ach);
|
||||
|
||||
Handle(Interface_GTool) thegtool;
|
||||
Interface_ShareTool theshare;
|
||||
Standard_Integer thestat;
|
||||
Standard_Integer errh;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -1040,3 +1040,75 @@ Handle(TColStd_HSequenceOfHAsciiString) Interface_InterfaceModel::ListTemplates
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetParam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Interface_Static) Interface_InterfaceModel::GetParam
|
||||
(const Standard_CString theParamName) const
|
||||
{
|
||||
Handle(Interface_Static) aParam;
|
||||
if (myParamMap.IsBound(theParamName))
|
||||
{
|
||||
Handle(Standard_Transient) result;
|
||||
myParamMap.Find(theParamName, result);
|
||||
if (!result.IsNull())
|
||||
aParam = Handle(Interface_Static)::DownCast(result);
|
||||
}
|
||||
if (aParam.IsNull())
|
||||
{
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout << "Warning: Incorrect parameter :" << theParamName << std::endl;
|
||||
#endif
|
||||
}
|
||||
return aParam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetParam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Interface_InterfaceModel::AddParam
|
||||
(const Standard_CString theParamName, Handle(Interface_Static)& theParam)
|
||||
{
|
||||
myParamMap.Bind(theParamName, theParam);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : AllParameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& Interface_InterfaceModel::AllParameters()
|
||||
{
|
||||
return myParamMap;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer Interface_InterfaceModel::IVal(const Standard_CString theParamName) const
|
||||
{
|
||||
Handle(Interface_Static) aParam = GetParam(theParamName);
|
||||
return (aParam.IsNull() ? 0 : aParam->IntegerValue());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real Interface_InterfaceModel::RVal(const Standard_CString theParamName) const
|
||||
{
|
||||
Handle(Interface_Static) aParam = GetParam(theParamName);
|
||||
return (aParam.IsNull() ? 0.0 : aParam->RealValue());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString Interface_InterfaceModel::CVal(const Standard_CString theParamName) const
|
||||
{
|
||||
Handle(Interface_Static) aParam = GetParam(theParamName);
|
||||
return (aParam.IsNull() ? "" : aParam->CStringValue());
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Interface_DataState.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <TColStd_HSequenceOfHAsciiString.hxx>
|
||||
class Interface_Check;
|
||||
class TCollection_HAsciiString;
|
||||
@@ -398,17 +399,27 @@ public:
|
||||
//! Returns the complete list of names attached to template models
|
||||
Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) ListTemplates();
|
||||
|
||||
//! Returns parameter for translation by its name
|
||||
Standard_EXPORT Handle(Interface_Static) GetParam(const Standard_CString theParamName) const;
|
||||
|
||||
Standard_EXPORT Standard_Integer IVal(const Standard_CString theParamName) const;
|
||||
Standard_EXPORT Standard_Real RVal(const Standard_CString theParamName) const;
|
||||
Standard_EXPORT Standard_CString CVal(const Standard_CString theParamName) const;
|
||||
|
||||
//! Adds parameters in the mopdel
|
||||
Standard_EXPORT void AddParam(const Standard_CString theParamName, Handle(Interface_Static)& theParam);
|
||||
|
||||
//! Returns all available parameters for translation
|
||||
Standard_EXPORT const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& AllParameters();
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Interface_InterfaceModel,Standard_Transient)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
//! Defines empty InterfaceModel, ready to be filled
|
||||
Standard_EXPORT Interface_InterfaceModel();
|
||||
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myParamMap;
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Interface_Static,Interface_TypedValue)
|
||||
@@ -129,8 +130,6 @@ Standard_Boolean Interface_Static::UpdatedStatus () const
|
||||
return theupdate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// #######################################################################
|
||||
// ######### DICTIONNAIRE DES STATICS (static sur Static) ##########
|
||||
|
||||
@@ -153,7 +152,6 @@ Standard_Boolean Interface_Static::Init
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
Standard_Boolean Interface_Static::Init
|
||||
(const Standard_CString family, const Standard_CString name,
|
||||
const Standard_Character type, const Standard_CString init)
|
||||
@@ -170,30 +168,7 @@ Standard_Boolean Interface_Static::Init
|
||||
case '&' : {
|
||||
Handle(Interface_Static) unstat = Interface_Static::Static(name);
|
||||
if (unstat.IsNull()) return Standard_False;
|
||||
// Editions : init donne un petit texte d edition, en 2 termes "cmd var" :
|
||||
// imin <ival> imax <ival> rmin <rval> rmax <rval> unit <def>
|
||||
// enum <from> ematch <from> eval <cval>
|
||||
Standard_Integer i,iblc = 0;
|
||||
for (i = 0; init[i] != '\0'; i ++) if (init[i] == ' ') iblc = i+1;
|
||||
// Reconnaissance du sous-cas et aiguillage
|
||||
if (init[0] == 'i' && init[2] == 'i')
|
||||
unstat->SetIntegerLimit (Standard_False,atoi(&init[iblc]));
|
||||
else if (init[0] == 'i' && init[2] == 'a')
|
||||
unstat->SetIntegerLimit (Standard_True ,atoi(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'i')
|
||||
unstat->SetRealLimit (Standard_False,Atof(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'a')
|
||||
unstat->SetRealLimit (Standard_True ,Atof(&init[iblc]));
|
||||
else if (init[0] == 'u')
|
||||
unstat->SetUnitDef (&init[iblc]);
|
||||
else if (init[0] == 'e' && init[1] == 'm')
|
||||
unstat->StartEnum (atoi(&init[iblc]),Standard_True);
|
||||
else if (init[0] == 'e' && init[1] == 'n')
|
||||
unstat->StartEnum (atoi(&init[iblc]),Standard_False);
|
||||
else if (init[0] == 'e' && init[1] == 'v')
|
||||
unstat->AddEnum (&init[iblc]);
|
||||
else return Standard_False;
|
||||
return Standard_True;
|
||||
return Interface_Static::InitValues(unstat, init);
|
||||
}
|
||||
default : return Standard_False;
|
||||
}
|
||||
@@ -205,13 +180,44 @@ Standard_Boolean Interface_Static::Init
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Boolean Interface_Static::InitValues(Handle(Interface_Static)& theStatic, const Standard_CString init)
|
||||
{
|
||||
// Editions : init donne un petit texte d edition, en 2 termes "cmd var" :
|
||||
// imin <ival> imax <ival> rmin <rval> rmax <rval> unit <def>
|
||||
// enum <from> ematch <from> eval <cval>
|
||||
Standard_Integer i, iblc = 0;
|
||||
for (i = 0; init[i] != '\0'; i++) if (init[i] == ' ') iblc = i + 1;
|
||||
// Reconnaissance du sous-cas et aiguillage
|
||||
if (init[0] == 'i' && init[2] == 'i')
|
||||
theStatic->SetIntegerLimit(Standard_False, atoi(&init[iblc]));
|
||||
else if (init[0] == 'i' && init[2] == 'a')
|
||||
theStatic->SetIntegerLimit(Standard_True, atoi(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'i')
|
||||
theStatic->SetRealLimit(Standard_False, Atof(&init[iblc]));
|
||||
else if (init[0] == 'r' && init[2] == 'a')
|
||||
theStatic->SetRealLimit(Standard_True, Atof(&init[iblc]));
|
||||
else if (init[0] == 'u')
|
||||
theStatic->SetUnitDef(&init[iblc]);
|
||||
else if (init[0] == 'e' && init[1] == 'm')
|
||||
theStatic->StartEnum(atoi(&init[iblc]), Standard_True);
|
||||
else if (init[0] == 'e' && init[1] == 'n')
|
||||
theStatic->StartEnum(atoi(&init[iblc]), Standard_False);
|
||||
else if (init[0] == 'e' && init[1] == 'v')
|
||||
theStatic->AddEnum(&init[iblc]);
|
||||
else return Standard_False;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Handle(Interface_Static) Interface_Static::Static
|
||||
(const Standard_CString name)
|
||||
{
|
||||
Handle(Standard_Transient) result;
|
||||
MoniTool_TypedValue::Stats().Find(name, result);
|
||||
return Handle(Interface_Static)::DownCast(result);
|
||||
static Standard_Mutex aPars;
|
||||
{
|
||||
Standard_Mutex::Sentry aLock(aPars);
|
||||
Handle(Standard_Transient) result;
|
||||
MoniTool_TypedValue::Stats().Find(name, result);
|
||||
return Handle(Interface_Static)::DownCast(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -130,6 +130,9 @@ public:
|
||||
//! Returns False if <type> does not match this list
|
||||
Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Standard_Character type, const Standard_CString init = "");
|
||||
|
||||
//! Edit current <theStatic> with some parameter <init>
|
||||
Standard_EXPORT static Standard_Boolean InitValues(Handle(Interface_Static)& theStatic, const Standard_CString init);
|
||||
|
||||
//! Returns a Static from its name. Null Handle if not present
|
||||
Standard_EXPORT static Handle(Interface_Static) Static (const Standard_CString name);
|
||||
|
||||
@@ -235,7 +238,7 @@ public:
|
||||
//! Returns False if <name> is not present
|
||||
Standard_EXPORT static Standard_Boolean IsUpdated (const Standard_CString name);
|
||||
|
||||
//! Returns a list of names of statics :
|
||||
//! Returns a list of names of statics:
|
||||
//! <mode> = 0 (D) : criter is for family
|
||||
//! <mode> = 1 : criter is regexp on names, takes final items
|
||||
//! (ignore wild cards)
|
||||
@@ -250,7 +253,8 @@ public:
|
||||
//!
|
||||
//! This allows for instance to set new values after having loaded
|
||||
//! or reloaded a resource, then to update them as required
|
||||
Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0, const Standard_CString criter = "");
|
||||
Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0,
|
||||
const Standard_CString criter = "");
|
||||
|
||||
//! Initializes all standard static parameters, which can be used
|
||||
//! by every function. statics specific of a norm or a function
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#undef DrawText
|
||||
#endif
|
||||
|
||||
#elif !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#elif !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -27,6 +28,8 @@
|
||||
//=======================================================================
|
||||
const Handle(Message_Messenger)& Message::DefaultMessenger ()
|
||||
{
|
||||
static Standard_Mutex aMutex;
|
||||
Standard_Mutex::Sentry aLock(aMutex);
|
||||
static Handle(Message_Messenger) aMessenger = new Message_Messenger;
|
||||
return aMessenger;
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <Message_Printer.hxx>
|
||||
#include <Message_PrinterOStream.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Message_Messenger,Standard_Transient)
|
||||
|
||||
@@ -87,6 +88,8 @@ Standard_Boolean Message_Messenger::RemovePrinter (const Handle(Message_Printer)
|
||||
|
||||
Standard_Integer Message_Messenger::RemovePrinters (const Handle(Standard_Type)& theType)
|
||||
{
|
||||
static Standard_Mutex aMutex;
|
||||
Standard_Mutex::Sentry aLock(aMutex);
|
||||
// remove printers from the list
|
||||
Standard_Integer nb = 0;
|
||||
for (Message_SequenceOfPrinters::Iterator aPrinterIter (myPrinters); aPrinterIter.More();)
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include <Message_MsgFile.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <stdio.h>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
@@ -26,6 +27,9 @@ typedef enum
|
||||
Msg_IndefiniteType
|
||||
} FormatType;
|
||||
|
||||
// mutex used to prevent concurrent access to message registry
|
||||
static Standard_Mutex theMutex;
|
||||
|
||||
//=======================================================================
|
||||
//function : Message_Msg()
|
||||
//purpose : Constructor
|
||||
@@ -42,6 +46,7 @@ Message_Msg::Message_Msg ()
|
||||
|
||||
Message_Msg::Message_Msg (const Message_Msg& theMsg)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
myMessageBody = theMsg.myMessageBody;
|
||||
myOriginal = theMsg.myOriginal;
|
||||
for ( Standard_Integer i = 1, n = theMsg.mySeqOfFormats.Length(); i <=n; i++ )
|
||||
@@ -55,6 +60,7 @@ Message_Msg::Message_Msg (const Message_Msg& theMsg)
|
||||
|
||||
Message_Msg::Message_Msg (const Standard_CString theMsgCode)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
TCollection_AsciiString aKey((char*)theMsgCode);
|
||||
Set ( Message_MsgFile::Msg(aKey) );
|
||||
}
|
||||
@@ -66,6 +72,7 @@ Message_Msg::Message_Msg (const Standard_CString theMsgCode)
|
||||
|
||||
Message_Msg::Message_Msg (const TCollection_ExtendedString& theMsgCode)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
Set ( Message_MsgFile::Msg(theMsgCode) );
|
||||
}
|
||||
|
||||
@@ -76,6 +83,7 @@ Message_Msg::Message_Msg (const TCollection_ExtendedString& theMsgCode)
|
||||
|
||||
void Message_Msg::Set (const Standard_CString theMsg)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
TCollection_AsciiString aMsg((char*)theMsg);
|
||||
Set ( aMsg );
|
||||
}
|
||||
@@ -87,6 +95,7 @@ void Message_Msg::Set (const Standard_CString theMsg)
|
||||
|
||||
void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
myMessageBody = theMsg;
|
||||
|
||||
const Standard_ExtString anExtString = myMessageBody.ToExtString();
|
||||
@@ -157,6 +166,7 @@ void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
|
||||
|
||||
Message_Msg& Message_Msg::Arg (const Standard_CString theString)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// get location and format
|
||||
TCollection_AsciiString aFormat;
|
||||
Standard_Integer aFirst = getFormat ( Msg_StringType, aFormat );
|
||||
@@ -184,6 +194,7 @@ Message_Msg& Message_Msg::Arg (const Standard_CString theString)
|
||||
|
||||
Message_Msg& Message_Msg::Arg (const TCollection_ExtendedString& theString)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// get location and format
|
||||
TCollection_AsciiString aFormat;
|
||||
Standard_Integer aFirst = getFormat ( Msg_StringType, aFormat );
|
||||
@@ -203,6 +214,7 @@ Message_Msg& Message_Msg::Arg (const TCollection_ExtendedString& theString)
|
||||
|
||||
Message_Msg& Message_Msg::Arg (const Standard_Integer theValue)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// get location and format
|
||||
TCollection_AsciiString aFormat;
|
||||
Standard_Integer aFirst = getFormat ( Msg_IntegerType, aFormat );
|
||||
@@ -227,6 +239,7 @@ Message_Msg& Message_Msg::Arg (const Standard_Integer theValue)
|
||||
|
||||
Message_Msg& Message_Msg::Arg (const Standard_Real theValue)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// get location and format
|
||||
TCollection_AsciiString aFormat;
|
||||
Standard_Integer aFirst = getFormat ( Msg_RealType, aFormat );
|
||||
@@ -251,6 +264,7 @@ Message_Msg& Message_Msg::Arg (const Standard_Real theValue)
|
||||
|
||||
const TCollection_ExtendedString& Message_Msg::Get ()
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// remove all non-initialised format specifications
|
||||
Standard_Integer i, anIncrement = 0;
|
||||
static const TCollection_ExtendedString anUnknown ("UNKNOWN");
|
||||
@@ -279,6 +293,7 @@ const TCollection_ExtendedString& Message_Msg::Get ()
|
||||
Standard_Integer Message_Msg::getFormat (const Standard_Integer theType,
|
||||
TCollection_AsciiString &theFormat)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
for (Standard_Integer i = 1; i <= mySeqOfFormats.Length(); i += 3)
|
||||
if (mySeqOfFormats(i) == theType)
|
||||
{
|
||||
@@ -307,6 +322,7 @@ void Message_Msg::replaceText (const Standard_Integer theFirst,
|
||||
const Standard_Integer theNb,
|
||||
const TCollection_ExtendedString &theStr)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
myMessageBody.Remove ( theFirst, theNb );
|
||||
myMessageBody.Insert ( theFirst, theStr );
|
||||
|
||||
|
@@ -215,6 +215,7 @@ static Standard_Integer GetFileSize (FILE *theFile)
|
||||
|
||||
Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
if (theFileName == NULL || * theFileName == '\0') return Standard_False;
|
||||
|
||||
// Open the file
|
||||
@@ -279,6 +280,7 @@ Standard_Boolean Message_MsgFile::LoadFromEnv (const Standard_CString theEnvName
|
||||
const Standard_CString theFileName,
|
||||
const Standard_CString theLangExt)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
TCollection_AsciiString aLangExt (theLangExt != NULL ? theLangExt : "");
|
||||
if (aLangExt.IsEmpty())
|
||||
{
|
||||
@@ -322,6 +324,7 @@ Standard_Boolean Message_MsgFile::LoadFromEnv (const Standard_CString theEnvName
|
||||
Standard_Boolean Message_MsgFile::LoadFromString (const Standard_CString theContent,
|
||||
const Standard_Integer theLength)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
Standard_Integer aStringSize = theLength >= 0 ? theLength : (Standard_Integer )strlen (theContent);
|
||||
NCollection_Buffer aBuffer (NCollection_BaseAllocator::CommonBaseAllocator());
|
||||
if (aStringSize <= 0 || !aBuffer.Allocate (aStringSize + 2))
|
||||
@@ -345,10 +348,8 @@ Standard_Boolean Message_MsgFile::LoadFromString (const Standard_CString theCont
|
||||
Standard_Boolean Message_MsgFile::AddMsg (const TCollection_AsciiString& theKeyword,
|
||||
const TCollection_ExtendedString& theMessage)
|
||||
{
|
||||
Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
|
||||
|
||||
Standard_Mutex::Sentry aSentry (theMutex);
|
||||
aDataMap.Bind (theKeyword, theMessage);
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap(); aDataMap.Bind (theKeyword, theMessage);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -370,7 +371,8 @@ const TCollection_ExtendedString &Message_MsgFile::Msg (const Standard_CString t
|
||||
|
||||
Standard_Boolean Message_MsgFile::HasMsg (const TCollection_AsciiString& theKeyword)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry (theMutex);
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
|
||||
return ::msgsDataMap().IsBound (theKeyword);
|
||||
}
|
||||
|
||||
@@ -381,9 +383,9 @@ Standard_Boolean Message_MsgFile::HasMsg (const TCollection_AsciiString& theKeyw
|
||||
|
||||
const TCollection_ExtendedString &Message_MsgFile::Msg (const TCollection_AsciiString& theKeyword)
|
||||
{
|
||||
Standard_Mutex::Sentry aSentry(theMutex);
|
||||
// find message in the map
|
||||
Message_DataMapOfExtendedString& aDataMap = ::msgsDataMap();
|
||||
Standard_Mutex::Sentry aSentry (theMutex);
|
||||
|
||||
// if message is not found, generate error message and add it to the map to minimize overhead
|
||||
// on consequent calls with the same key
|
||||
|
@@ -27,7 +27,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
|
||||
const Standard_Real step,
|
||||
const Standard_Boolean isInf,
|
||||
const Standard_Real newScopeSpan) :
|
||||
myProgress(progress), myActive(!progress.IsNull())
|
||||
myProgress(progress), myActive(!progress.IsNull()),
|
||||
myThreadId(OSD_Thread::Current())
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
progress->SetName ( name );
|
||||
@@ -47,7 +48,8 @@ Message_ProgressSentry::Message_ProgressSentry (const Handle(Message_ProgressInd
|
||||
const Standard_Real step,
|
||||
const Standard_Boolean isInf,
|
||||
const Standard_Real newScopeSpan) :
|
||||
myProgress(progress), myActive(!progress.IsNull())
|
||||
myProgress(progress), myActive(!progress.IsNull()),
|
||||
myThreadId(OSD_Thread::Current())
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
progress->SetName ( name );
|
||||
|
@@ -23,6 +23,8 @@
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_ThreadId.hxx>
|
||||
#include <OSD_Thread.hxx>
|
||||
class Message_ProgressIndicator;
|
||||
class TCollection_HAsciiString;
|
||||
|
||||
@@ -109,6 +111,7 @@ private:
|
||||
|
||||
Handle(Message_ProgressIndicator) myProgress;
|
||||
Standard_Boolean myActive;
|
||||
Standard_ThreadId myThreadId;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
inline void Message_ProgressSentry::Relieve ()
|
||||
{
|
||||
if ( ! myActive ) return;
|
||||
if (!myActive || myThreadId != OSD_Thread::Current()) return;
|
||||
myProgress->EndScope();
|
||||
myActive = 0;
|
||||
}
|
||||
@@ -32,7 +32,8 @@ inline void Message_ProgressSentry::Relieve ()
|
||||
|
||||
inline void Message_ProgressSentry::Next (const Standard_CString name) const
|
||||
{
|
||||
if ( myActive ) myProgress->NextScope(name);
|
||||
if (myActive && myThreadId == OSD_Thread::Current())
|
||||
myProgress->NextScope(name);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -43,7 +44,8 @@ inline void Message_ProgressSentry::Next (const Standard_CString name) const
|
||||
inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
const Standard_CString name) const
|
||||
{
|
||||
if ( myActive ) myProgress->NextScope(span, name);
|
||||
if (myActive && myThreadId == OSD_Thread::Current())
|
||||
myProgress->NextScope(span, name);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -54,7 +56,7 @@ inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
inline void Message_ProgressSentry::Next (const Standard_Real span,
|
||||
const Handle(TCollection_HAsciiString)& name) const
|
||||
{
|
||||
if ( myActive ) {
|
||||
if (myActive && myThreadId == OSD_Thread::Current()) {
|
||||
myProgress->EndScope();
|
||||
myProgress->NewScope(span, name);
|
||||
}
|
||||
@@ -77,5 +79,6 @@ inline Standard_Boolean Message_ProgressSentry::More () const
|
||||
|
||||
inline void Message_ProgressSentry::Show () const
|
||||
{
|
||||
if ( ! myProgress.IsNull() ) myProgress->Show();
|
||||
if (!myProgress.IsNull() && myThreadId == OSD_Thread::Current())
|
||||
myProgress->Show();
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@
|
||||
void OSD_Chronometer::GetProcessCPU (Standard_Real& theUserSeconds,
|
||||
Standard_Real& theSystemSeconds)
|
||||
{
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
static const long aCLK_TCK = sysconf(_SC_CLK_TCK);
|
||||
#else
|
||||
static const long aCLK_TCK = CLK_TCK;
|
||||
|
@@ -37,12 +37,22 @@
|
||||
|
||||
#include <OSD_MemInfo.hxx>
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include <emscripten.h>
|
||||
|
||||
//! Return WebAssembly heap size in bytes.
|
||||
EM_JS(size_t, OSD_MemInfo_getModuleHeapLength, (), {
|
||||
return Module.HEAP8.length;
|
||||
});
|
||||
#endif
|
||||
|
||||
// =======================================================================
|
||||
// function : OSD_MemInfo
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OSD_MemInfo::OSD_MemInfo (const Standard_Boolean theImmediateUpdate)
|
||||
{
|
||||
SetActive (Standard_True);
|
||||
if (theImmediateUpdate)
|
||||
{
|
||||
Update();
|
||||
@@ -53,6 +63,17 @@ OSD_MemInfo::OSD_MemInfo (const Standard_Boolean theImmediateUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetActive
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void OSD_MemInfo::SetActive (const Standard_Boolean theActive)
|
||||
{
|
||||
for (Standard_Integer anIter = 0; anIter < MemCounter_NB; ++anIter)
|
||||
{
|
||||
SetActive ((Counter)anIter, theActive);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Clear
|
||||
@@ -76,47 +97,103 @@ void OSD_MemInfo::Update()
|
||||
#ifndef OCCT_UWP
|
||||
#if defined(_WIN32)
|
||||
#if (_WIN32_WINNT >= 0x0500)
|
||||
MEMORYSTATUSEX aStatEx;
|
||||
aStatEx.dwLength = sizeof(aStatEx);
|
||||
GlobalMemoryStatusEx (&aStatEx);
|
||||
myCounters[MemVirtual] = Standard_Size(aStatEx.ullTotalVirtual - aStatEx.ullAvailVirtual);
|
||||
if (IsActive (MemVirtual))
|
||||
{
|
||||
MEMORYSTATUSEX aStatEx;
|
||||
aStatEx.dwLength = sizeof(aStatEx);
|
||||
GlobalMemoryStatusEx (&aStatEx);
|
||||
myCounters[MemVirtual] = Standard_Size(aStatEx.ullTotalVirtual - aStatEx.ullAvailVirtual);
|
||||
}
|
||||
#else
|
||||
MEMORYSTATUS aStat;
|
||||
aStat.dwLength = sizeof(aStat);
|
||||
GlobalMemoryStatus (&aStat);
|
||||
myCounters[MemVirtual] = Standard_Size(aStat.dwTotalVirtual - aStat.dwAvailVirtual);
|
||||
if (IsActive (MemVirtual))
|
||||
{
|
||||
MEMORYSTATUS aStat;
|
||||
aStat.dwLength = sizeof(aStat);
|
||||
GlobalMemoryStatus (&aStat);
|
||||
myCounters[MemVirtual] = Standard_Size(aStat.dwTotalVirtual - aStat.dwAvailVirtual);
|
||||
}
|
||||
#endif
|
||||
|
||||
// use Psapi library
|
||||
HANDLE aProcess = GetCurrentProcess();
|
||||
#if (_WIN32_WINNT >= 0x0501)
|
||||
PROCESS_MEMORY_COUNTERS_EX aProcMemCnts;
|
||||
#else
|
||||
PROCESS_MEMORY_COUNTERS aProcMemCnts;
|
||||
#endif
|
||||
if (GetProcessMemoryInfo (aProcess, (PROCESS_MEMORY_COUNTERS* )&aProcMemCnts, sizeof(aProcMemCnts)))
|
||||
if (IsActive (MemPrivate)
|
||||
|| IsActive (MemWorkingSet)
|
||||
|| IsActive (MemWorkingSetPeak)
|
||||
|| IsActive (MemSwapUsage)
|
||||
|| IsActive (MemSwapUsagePeak))
|
||||
{
|
||||
// use Psapi library
|
||||
HANDLE aProcess = GetCurrentProcess();
|
||||
#if (_WIN32_WINNT >= 0x0501)
|
||||
myCounters[MemPrivate] = aProcMemCnts.PrivateUsage;
|
||||
PROCESS_MEMORY_COUNTERS_EX aProcMemCnts;
|
||||
#else
|
||||
PROCESS_MEMORY_COUNTERS aProcMemCnts;
|
||||
#endif
|
||||
myCounters[MemWorkingSet] = aProcMemCnts.WorkingSetSize;
|
||||
myCounters[MemWorkingSetPeak] = aProcMemCnts.PeakWorkingSetSize;
|
||||
myCounters[MemSwapUsage] = aProcMemCnts.PagefileUsage;
|
||||
myCounters[MemSwapUsagePeak] = aProcMemCnts.PeakPagefileUsage;
|
||||
if (GetProcessMemoryInfo (aProcess, (PROCESS_MEMORY_COUNTERS* )&aProcMemCnts, sizeof(aProcMemCnts)))
|
||||
{
|
||||
#if (_WIN32_WINNT >= 0x0501)
|
||||
myCounters[MemPrivate] = aProcMemCnts.PrivateUsage;
|
||||
#endif
|
||||
myCounters[MemWorkingSet] = aProcMemCnts.WorkingSetSize;
|
||||
myCounters[MemWorkingSetPeak] = aProcMemCnts.PeakWorkingSetSize;
|
||||
myCounters[MemSwapUsage] = aProcMemCnts.PagefileUsage;
|
||||
myCounters[MemSwapUsagePeak] = aProcMemCnts.PeakPagefileUsage;
|
||||
}
|
||||
}
|
||||
|
||||
_HEAPINFO hinfo;
|
||||
int heapstatus;
|
||||
hinfo._pentry = NULL;
|
||||
|
||||
myCounters[MemHeapUsage] = 0;
|
||||
while((heapstatus = _heapwalk(&hinfo)) == _HEAPOK)
|
||||
if (IsActive (MemHeapUsage))
|
||||
{
|
||||
if(hinfo._useflag == _USEDENTRY)
|
||||
myCounters[MemHeapUsage] += hinfo._size;
|
||||
_HEAPINFO hinfo;
|
||||
int heapstatus;
|
||||
hinfo._pentry = NULL;
|
||||
|
||||
myCounters[MemHeapUsage] = 0;
|
||||
while((heapstatus = _heapwalk(&hinfo)) == _HEAPOK)
|
||||
{
|
||||
if (hinfo._useflag == _USEDENTRY)
|
||||
{
|
||||
myCounters[MemHeapUsage] += hinfo._size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
if (IsActive (MemHeapUsage)
|
||||
|| IsActive (MemWorkingSet)
|
||||
|| IsActive (MemWorkingSetPeak))
|
||||
{
|
||||
// /proc/%d/status is not emulated - get more info from mallinfo()
|
||||
const struct mallinfo aMI = mallinfo();
|
||||
if (IsActive (MemHeapUsage))
|
||||
{
|
||||
myCounters[MemHeapUsage] = aMI.uordblks;
|
||||
}
|
||||
if (IsActive (MemWorkingSet))
|
||||
{
|
||||
myCounters[MemWorkingSet] = aMI.uordblks;
|
||||
}
|
||||
if (IsActive (MemWorkingSetPeak))
|
||||
{
|
||||
myCounters[MemWorkingSetPeak] = aMI.usmblks;
|
||||
}
|
||||
}
|
||||
if (IsActive (MemVirtual))
|
||||
{
|
||||
myCounters[MemVirtual] = OSD_MemInfo_getModuleHeapLength();
|
||||
}
|
||||
#elif (defined(__linux__) || defined(__linux))
|
||||
if (IsActive (MemHeapUsage))
|
||||
{
|
||||
const struct mallinfo aMI = mallinfo();
|
||||
myCounters[MemHeapUsage] = aMI.uordblks;
|
||||
}
|
||||
|
||||
if (!IsActive (MemVirtual)
|
||||
&& !IsActive (MemWorkingSet)
|
||||
&& !IsActive (MemWorkingSetPeak)
|
||||
&& !IsActive (MemPrivate))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// use procfs on Linux
|
||||
char aBuff[4096];
|
||||
snprintf (aBuff, sizeof(aBuff), "/proc/%d/status", getpid());
|
||||
@@ -136,51 +213,57 @@ void OSD_MemInfo::Update()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp (aBuff, "VmSize:", strlen ("VmSize:")) == 0)
|
||||
if (IsActive (MemVirtual)
|
||||
&& strncmp (aBuff, "VmSize:", strlen ("VmSize:")) == 0)
|
||||
{
|
||||
myCounters[MemVirtual] = atol (aBuff + strlen ("VmSize:")) * 1024;
|
||||
}
|
||||
//else if (strncmp (aBuff, "VmPeak:", strlen ("VmPeak:")) == 0)
|
||||
// myVirtualPeak = atol (aBuff + strlen ("VmPeak:")) * 1024;
|
||||
else if (strncmp (aBuff, "VmRSS:", strlen ("VmRSS:")) == 0)
|
||||
else if (IsActive (MemWorkingSet)
|
||||
&& strncmp (aBuff, "VmRSS:", strlen ("VmRSS:")) == 0)
|
||||
{
|
||||
myCounters[MemWorkingSet] = atol (aBuff + strlen ("VmRSS:")) * 1024; // RSS - resident set size
|
||||
}
|
||||
else if (strncmp (aBuff, "VmHWM:", strlen ("VmHWM:")) == 0)
|
||||
else if (IsActive (MemWorkingSetPeak)
|
||||
&& strncmp (aBuff, "VmHWM:", strlen ("VmHWM:")) == 0)
|
||||
{
|
||||
myCounters[MemWorkingSetPeak] = atol (aBuff + strlen ("VmHWM:")) * 1024; // HWM - high water mark
|
||||
}
|
||||
else if (strncmp (aBuff, "VmData:", strlen ("VmData:")) == 0)
|
||||
else if (IsActive (MemPrivate)
|
||||
&& strncmp (aBuff, "VmData:", strlen ("VmData:")) == 0)
|
||||
{
|
||||
if (myCounters[MemPrivate] == Standard_Size(-1)) ++myCounters[MemPrivate];
|
||||
myCounters[MemPrivate] += atol (aBuff + strlen ("VmData:")) * 1024;
|
||||
}
|
||||
else if (strncmp (aBuff, "VmStk:", strlen ("VmStk:")) == 0)
|
||||
else if (IsActive (MemPrivate)
|
||||
&& strncmp (aBuff, "VmStk:", strlen ("VmStk:")) == 0)
|
||||
{
|
||||
if (myCounters[MemPrivate] == Standard_Size(-1)) ++myCounters[MemPrivate];
|
||||
myCounters[MemPrivate] += atol (aBuff + strlen ("VmStk:")) * 1024;
|
||||
}
|
||||
}
|
||||
aFile.close();
|
||||
|
||||
struct mallinfo aMI = mallinfo();
|
||||
myCounters[MemHeapUsage] = aMI.uordblks;
|
||||
|
||||
#elif (defined(__APPLE__))
|
||||
struct task_basic_info aTaskInfo;
|
||||
mach_msg_type_number_t aTaskInfoCount = TASK_BASIC_INFO_COUNT;
|
||||
if (task_info (mach_task_self(), TASK_BASIC_INFO,
|
||||
(task_info_t )&aTaskInfo, &aTaskInfoCount) == KERN_SUCCESS)
|
||||
if (IsActive (MemVirtual)
|
||||
|| IsActive (MemWorkingSet)
|
||||
|| IsActive (MemHeapUsage))
|
||||
{
|
||||
// On Mac OS X, these values in bytes, not pages!
|
||||
myCounters[MemVirtual] = aTaskInfo.virtual_size;
|
||||
myCounters[MemWorkingSet] = aTaskInfo.resident_size;
|
||||
struct task_basic_info aTaskInfo;
|
||||
mach_msg_type_number_t aTaskInfoCount = TASK_BASIC_INFO_COUNT;
|
||||
if (task_info (mach_task_self(), TASK_BASIC_INFO,
|
||||
(task_info_t )&aTaskInfo, &aTaskInfoCount) == KERN_SUCCESS)
|
||||
{
|
||||
// On Mac OS X, these values in bytes, not pages!
|
||||
myCounters[MemVirtual] = aTaskInfo.virtual_size;
|
||||
myCounters[MemWorkingSet] = aTaskInfo.resident_size;
|
||||
|
||||
//Getting malloc statistics
|
||||
malloc_statistics_t aStats;
|
||||
malloc_zone_statistics (NULL, &aStats);
|
||||
//Getting malloc statistics
|
||||
malloc_statistics_t aStats;
|
||||
malloc_zone_statistics (NULL, &aStats);
|
||||
|
||||
myCounters[MemHeapUsage] = aStats.size_in_use;
|
||||
myCounters[MemHeapUsage] = aStats.size_in_use;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -193,33 +276,33 @@ void OSD_MemInfo::Update()
|
||||
TCollection_AsciiString OSD_MemInfo::ToString() const
|
||||
{
|
||||
TCollection_AsciiString anInfo;
|
||||
if (myCounters[MemPrivate] != Standard_Size(-1))
|
||||
if (hasValue (MemPrivate))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" Private memory: ") + Standard_Integer (ValueMiB (MemPrivate)) + " MiB\n";
|
||||
}
|
||||
if (myCounters[MemWorkingSet] != Standard_Size(-1))
|
||||
if (hasValue (MemWorkingSet))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" Working Set: ") + Standard_Integer (ValueMiB (MemWorkingSet)) + " MiB";
|
||||
if (myCounters[MemWorkingSetPeak] != Standard_Size(-1))
|
||||
if (hasValue (MemWorkingSetPeak))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" (peak: ") + Standard_Integer (ValueMiB (MemWorkingSetPeak)) + " MiB)";
|
||||
}
|
||||
anInfo += "\n";
|
||||
}
|
||||
if (myCounters[MemSwapUsage] != Standard_Size(-1))
|
||||
if (hasValue (MemSwapUsage))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" Pagefile usage: ") + Standard_Integer (ValueMiB (MemSwapUsage)) + " MiB";
|
||||
if (myCounters[MemSwapUsagePeak] != Standard_Size(-1))
|
||||
if (hasValue (MemSwapUsagePeak))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" (peak: ") + Standard_Integer (ValueMiB (MemSwapUsagePeak)) + " MiB)";
|
||||
}
|
||||
anInfo += "\n";
|
||||
}
|
||||
if (myCounters[MemVirtual] != Standard_Size(-1))
|
||||
if (hasValue (MemVirtual))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" Virtual memory: ") + Standard_Integer (ValueMiB (MemVirtual)) + " MiB\n";
|
||||
}
|
||||
if (myCounters[MemHeapUsage] != Standard_Size(-1))
|
||||
if (hasValue (MemHeapUsage))
|
||||
{
|
||||
anInfo += TCollection_AsciiString(" Heap memory: ") + Standard_Integer (ValueMiB (MemHeapUsage)) + " MiB\n";
|
||||
}
|
||||
@@ -232,7 +315,7 @@ TCollection_AsciiString OSD_MemInfo::ToString() const
|
||||
// =======================================================================
|
||||
Standard_Size OSD_MemInfo::Value (const OSD_MemInfo::Counter theCounter) const
|
||||
{
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB)
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB || !IsActive (theCounter))
|
||||
{
|
||||
return Standard_Size(-1);
|
||||
}
|
||||
@@ -245,7 +328,7 @@ Standard_Size OSD_MemInfo::Value (const OSD_MemInfo::Counter theCounter) const
|
||||
// =======================================================================
|
||||
Standard_Size OSD_MemInfo::ValueMiB (const OSD_MemInfo::Counter theCounter) const
|
||||
{
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB)
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB || !IsActive (theCounter))
|
||||
{
|
||||
return Standard_Size(-1);
|
||||
}
|
||||
@@ -259,7 +342,7 @@ Standard_Size OSD_MemInfo::ValueMiB (const OSD_MemInfo::Counter theCounter) cons
|
||||
// =======================================================================
|
||||
Standard_Real OSD_MemInfo::ValuePreciseMiB (const OSD_MemInfo::Counter theCounter) const
|
||||
{
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB)
|
||||
if (theCounter < 0 || theCounter >= MemCounter_NB || !IsActive (theCounter))
|
||||
{
|
||||
return -1.0;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#ifndef _OSD_MemInfo_H__
|
||||
#define _OSD_MemInfo_H__
|
||||
|
||||
#include <NCollection_Map.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
//! This class provide information about memory utilized by current process.
|
||||
@@ -65,9 +66,21 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Create and initialize
|
||||
//! Create and initialize. By default all countes are active
|
||||
Standard_EXPORT OSD_MemInfo (const Standard_Boolean theImmediateUpdate = Standard_True);
|
||||
|
||||
//! Return true if the counter is active
|
||||
Standard_Boolean IsActive (const OSD_MemInfo::Counter theCounter) const { return myActiveCounters[theCounter]; }
|
||||
|
||||
//! Set all counters active. The information is collected for active counters.
|
||||
//! @param theActive state for counters
|
||||
Standard_EXPORT void SetActive (const Standard_Boolean theActive);
|
||||
|
||||
//! Set the counter active. The information is collected for active counters.
|
||||
//! @param theCounter type of counter
|
||||
//! @param theActive state for the counter
|
||||
void SetActive (const OSD_MemInfo::Counter theCounter, const Standard_Boolean theActive) { myActiveCounters[theCounter] = theActive; }
|
||||
|
||||
//! Clear counters
|
||||
Standard_EXPORT void Clear();
|
||||
|
||||
@@ -97,9 +110,16 @@ public:
|
||||
//! Return the string representation for all available counter.
|
||||
Standard_EXPORT static TCollection_AsciiString PrintInfo();
|
||||
|
||||
protected:
|
||||
|
||||
//! Return true if the counter is active and the value is valid
|
||||
Standard_Boolean hasValue (const OSD_MemInfo::Counter theCounter) const
|
||||
{ return IsActive (theCounter) && myCounters[theCounter] != Standard_Size(-1); }
|
||||
|
||||
private:
|
||||
|
||||
Standard_Size myCounters[MemCounter_NB]; //!< Counters' values, in bytes
|
||||
Standard_Boolean myActiveCounters[MemCounter_NB]; //!< container of active state for a counter
|
||||
|
||||
};
|
||||
|
||||
|
@@ -39,6 +39,8 @@ static OSD_SysType whereAmI()
|
||||
return OSD_VMS;
|
||||
#elif defined(__linux__) || defined(__linux)
|
||||
return OSD_LinuxREDHAT;
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
return OSD_LinuxREDHAT;
|
||||
#elif defined(_AIX) || defined(AIX)
|
||||
return OSD_Aix;
|
||||
#else
|
||||
|
@@ -703,7 +703,7 @@ typedef void (* SIG_PFV) (int);
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(__QNX__)
|
||||
#if !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
|
@@ -63,6 +63,29 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Context,Standard_Transient)
|
||||
#include <GL/glx.h> // glXGetProcAddress()
|
||||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/html5.h>
|
||||
|
||||
//! Check if WebGL extension is available and activate it
|
||||
//! (usage of extension without activation will generate errors).
|
||||
static bool checkEnableWebGlExtension (const OpenGl_Context& theCtx,
|
||||
const char* theExtName)
|
||||
{
|
||||
if (!theCtx.CheckExtension (theExtName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE aWebGlCtx = emscripten_webgl_get_current_context())
|
||||
{
|
||||
if (emscripten_webgl_enable_extension (aWebGlCtx, theExtName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Handle(OpenGl_Resource) NULL_GL_RESOURCE;
|
||||
@@ -1361,6 +1384,13 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
|
||||
extAnis = CheckExtension ("GL_EXT_texture_filter_anisotropic");
|
||||
extPDS = IsGlGreaterEqual (3, 0)
|
||||
|| CheckExtension ("GL_OES_packed_depth_stencil");
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (!extPDS
|
||||
&& checkEnableWebGlExtension (*this, "GL_WEBGL_depth_texture"))
|
||||
{
|
||||
extPDS = true; // WebGL 1.0 extension (in WebGL 2.0 core)
|
||||
}
|
||||
#endif
|
||||
|
||||
core11fwd = (OpenGl_GlCore11Fwd* )(&(*myFuncs));
|
||||
if (IsGlGreaterEqual (2, 0))
|
||||
@@ -3047,6 +3077,20 @@ void OpenGl_Context::DiagnosticInformation (TColStd_IndexedDataMapOfStringString
|
||||
ReadGlVersion (aDriverVer[0], aDriverVer[1]);
|
||||
addInfo (theDict, "GLvendor", (const char*)::glGetString (GL_VENDOR));
|
||||
addInfo (theDict, "GLdevice", (const char*)::glGetString (GL_RENDERER));
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (checkEnableWebGlExtension (*this, "GL_WEBGL_debug_renderer_info"))
|
||||
{
|
||||
if (const char* aVendor = (const char*)::glGetString (0x9245))
|
||||
{
|
||||
addInfo (theDict, "GLunmaskedVendor", aVendor);
|
||||
}
|
||||
if (const char* aDevice = (const char*)::glGetString (0x9246))
|
||||
{
|
||||
addInfo (theDict, "GLunmaskedDevice", aDevice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
addInfo (theDict, "GLversion", (const char*)::glGetString (GL_VERSION));
|
||||
if (myGlVerMajor != aDriverVer[0]
|
||||
|| myGlVerMinor != aDriverVer[1])
|
||||
|
@@ -38,6 +38,26 @@ namespace
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Return TRUE if GL_DEPTH_STENCIL_ATTACHMENT can be used.
|
||||
static bool hasDepthStencilAttach (const Handle(OpenGl_Context)& theCtx)
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
// supported since WebGL 2.0,
|
||||
// while WebGL 1.0 + GL_WEBGL_depth_texture needs GL_DEPTH_STENCIL_ATTACHMENT
|
||||
// and NOT separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls which is different to OpenGL ES 2.0 + extension
|
||||
return theCtx->IsGlGreaterEqual (3, 0) || theCtx->extPDS;
|
||||
#elif defined(GL_ES_VERSION_2_0)
|
||||
// supported since OpenGL ES 3.0,
|
||||
// while OpenGL ES 2.0 + GL_EXT_packed_depth_stencil needs separate GL_DEPTH_ATTACHMENT+GL_STENCIL_ATTACHMENT calls
|
||||
return theCtx->IsGlGreaterEqual (3, 0);
|
||||
#else
|
||||
// available on desktop since OpenGL 3.0
|
||||
// or OpenGL 2.0 + GL_ARB_framebuffer_object (GL_EXT_framebuffer_object is unsupported by OCCT)
|
||||
(void )theCtx;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -305,15 +325,18 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
}
|
||||
if (myDepthStencilTexture->IsValid())
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
#else
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
#endif
|
||||
if (hasDepthStencilAttach (theGlContext))
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
}
|
||||
}
|
||||
if (theGlContext->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
@@ -461,32 +484,39 @@ Standard_Boolean OpenGl_FrameBuffer::Init (const Handle(OpenGl_Context)& theGlCo
|
||||
aColorTexture->GetTarget(), aColorTexture->TextureId(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (myDepthStencilTexture->IsValid())
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
#else
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
#endif
|
||||
if (hasDepthStencilAttach (theGlContext))
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
myDepthStencilTexture->GetTarget(), myDepthStencilTexture->TextureId(), 0);
|
||||
}
|
||||
}
|
||||
else if (myGlDepthRBufferId != NO_RENDERBUFFER)
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, hasStencilRB ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
#else
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
if (hasStencilRB)
|
||||
if (hasDepthStencilAttach (theGlContext) && hasStencilRB)
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
if (hasStencilRB)
|
||||
{
|
||||
theGlContext->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (theGlContext->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
@@ -617,18 +647,21 @@ Standard_Boolean OpenGl_FrameBuffer::InitWithRB (const Handle(OpenGl_Context)& t
|
||||
GL_RENDERBUFFER, myGlColorRBufferId);
|
||||
if (myGlDepthRBufferId != NO_RENDERBUFFER)
|
||||
{
|
||||
#ifdef GL_DEPTH_STENCIL_ATTACHMENT
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, hasStencilRB ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
#else
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
if (hasStencilRB)
|
||||
if (hasDepthStencilAttach (theGlCtx) && hasStencilRB)
|
||||
{
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
if (hasStencilRB)
|
||||
{
|
||||
theGlCtx->arbFBO->glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, myGlDepthRBufferId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (theGlCtx->arbFBO->glCheckFramebufferStatus (GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
|
@@ -54,7 +54,7 @@
|
||||
#include <OpenGL/gl.h>
|
||||
#endif
|
||||
#define __X_GL_H // prevent chaotic gl.h inclusions to avoid compile errors
|
||||
#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#elif defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
#if defined(_WIN32)
|
||||
// Angle OpenGL ES headers do not define function prototypes even for core functions,
|
||||
// however OCCT is expected to be linked against libGLESv2
|
||||
@@ -152,6 +152,7 @@
|
||||
#define GL_DEPTH_STENCIL 0x84F9
|
||||
#define GL_UNSIGNED_INT_24_8 0x84FA
|
||||
#define GL_DEPTH24_STENCIL8 0x88F0
|
||||
#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
|
||||
|
||||
// OpenGL ES 3.0+
|
||||
#define GL_DEPTH_COMPONENT24 0x81A6
|
||||
@@ -216,7 +217,7 @@
|
||||
#define GL_PATCHES 0x000E
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_EGL) && (defined(__ANDROID__) || defined(__QNX__) || defined(HAVE_GLES2) || defined(OCCT_UWP))
|
||||
#if !defined(HAVE_EGL) && (defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(HAVE_GLES2) || defined(OCCT_UWP))
|
||||
#define HAVE_EGL
|
||||
#endif
|
||||
|
||||
|
@@ -44,11 +44,11 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_GraphicDriver,Graphic3d_GraphicDriver)
|
||||
#include <Xw_Window.hxx>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#include <X11/Xlib.h> // XOpenDisplay()
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
#include <EGL/egl.h>
|
||||
#ifndef EGL_OPENGL_ES3_BIT
|
||||
#define EGL_OPENGL_ES3_BIT 0x00000040
|
||||
@@ -59,7 +59,7 @@ namespace
|
||||
{
|
||||
static const Handle(OpenGl_Context) TheNullGlCtx;
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
//! Wrapper over eglChooseConfig() called with preferred defaults.
|
||||
static EGLConfig chooseEglSurfConfig (EGLDisplay theDisplay)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
|
||||
const Standard_Boolean theToInitialize)
|
||||
: Graphic3d_GraphicDriver (theDisp),
|
||||
myIsOwnContext (Standard_False),
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
myEglDisplay ((Aspect_Display )EGL_NO_DISPLAY),
|
||||
myEglContext ((Aspect_RenderingContext )EGL_NO_CONTEXT),
|
||||
myEglConfig (NULL),
|
||||
@@ -129,7 +129,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
|
||||
myMapOfView (1, NCollection_BaseAllocator::CommonBaseAllocator()),
|
||||
myMapOfStructure (1, NCollection_BaseAllocator::CommonBaseAllocator())
|
||||
{
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
if (myDisplayConnection.IsNull())
|
||||
{
|
||||
//throw Aspect_GraphicDeviceDefinitionError("OpenGl_GraphicDriver: cannot connect to X server!");
|
||||
@@ -228,7 +228,7 @@ void OpenGl_GraphicDriver::ReleaseContext()
|
||||
aWindow->GetGlContext()->forcedRelease();
|
||||
}
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
if (myIsOwnContext)
|
||||
{
|
||||
if (myEglContext != (Aspect_RenderingContext )EGL_NO_CONTEXT)
|
||||
@@ -263,9 +263,9 @@ void OpenGl_GraphicDriver::ReleaseContext()
|
||||
Standard_Boolean OpenGl_GraphicDriver::InitContext()
|
||||
{
|
||||
ReleaseContext();
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
if (myDisplayConnection.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -337,7 +337,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitContext()
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
// =======================================================================
|
||||
// function : InitEglContext
|
||||
// purpose :
|
||||
@@ -347,7 +347,7 @@ Standard_Boolean OpenGl_GraphicDriver::InitEglContext (Aspect_Display t
|
||||
void* theEglConfig)
|
||||
{
|
||||
ReleaseContext();
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
|
||||
if (myDisplayConnection.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
@@ -731,7 +731,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)&
|
||||
#else
|
||||
NSView* TheSpecifiedWindowId = THEWindow->HView();
|
||||
#endif
|
||||
#elif defined(__ANDROID__) || defined(__QNX__) || defined(OCCT_UWP)
|
||||
#elif defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(OCCT_UWP)
|
||||
(void )AWindow;
|
||||
int TheSpecifiedWindowId = -1;
|
||||
#else
|
||||
@@ -757,7 +757,7 @@ Standard_Boolean OpenGl_GraphicDriver::ViewExists (const Handle(Aspect_Window)&
|
||||
#else
|
||||
NSView* TheWindowIdOfView = theWindow->HView();
|
||||
#endif
|
||||
#elif defined(__ANDROID__) || defined(__QNX__) || defined(OCCT_UWP)
|
||||
#elif defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(OCCT_UWP)
|
||||
int TheWindowIdOfView = 0;
|
||||
#else
|
||||
const Handle(Xw_Window) theWindow = Handle(Xw_Window)::DownCast (AspectWindow);
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
//! Perform initialization of default OpenGL context.
|
||||
Standard_EXPORT Standard_Boolean InitContext();
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
//! Initialize default OpenGL context using existing one.
|
||||
//! @param theEglDisplay EGL connection to the Display
|
||||
//! @param theEglContext EGL rendering context
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
//! any context will be returned otherwise
|
||||
Standard_EXPORT const Handle(OpenGl_Context)& GetSharedContext (bool theBound = false) const;
|
||||
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
Aspect_Display getRawGlDisplay() const { return myEglDisplay; }
|
||||
Aspect_RenderingContext getRawGlContext() const { return myEglContext; }
|
||||
void* getRawGlConfig() const { return myEglConfig; }
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
protected:
|
||||
|
||||
Standard_Boolean myIsOwnContext; //!< indicates that shared context has been created within OpenGl_GraphicDriver
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#if defined(HAVE_EGL) || defined(HAVE_GLES2) || defined(OCCT_UWP) || defined(__ANDROID__) || defined(__QNX__) || defined(__EMSCRIPTEN__)
|
||||
Aspect_Display myEglDisplay; //!< EGL connection to the Display : EGLDisplay
|
||||
Aspect_RenderingContext myEglContext; //!< EGL rendering context : EGLContext
|
||||
void* myEglConfig; //!< EGL configuration : EGLConfig
|
||||
|
@@ -1530,6 +1530,15 @@ int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgr
|
||||
}
|
||||
(void )toUseDerivates;
|
||||
#else
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
if (myContext->IsGlGreaterEqual (3, 0))
|
||||
{
|
||||
// consider this is browser responsibility to provide working WebGL 2.0 implementation
|
||||
// and black-list broken drivers (there is no OpenGL ES greater than 3.0)
|
||||
theProgram->SetHeader ("#version 300 es");
|
||||
}
|
||||
#endif
|
||||
// prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
|
||||
// and "300 es" on OpenGL ES 3.1+ devices
|
||||
if (myContext->IsGlGreaterEqual (3, 1))
|
||||
|
@@ -217,6 +217,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
//throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to retrieve current surface!");
|
||||
if (anEglConfig != NULL)
|
||||
{
|
||||
#if !defined(__EMSCRIPTEN__) // eglCreatePbufferSurface() is not implemented by Emscripten EGL
|
||||
const int aSurfAttribs[] =
|
||||
{
|
||||
EGL_WIDTH, myWidth,
|
||||
@@ -228,6 +229,7 @@ OpenGl_Window::OpenGl_Window (const Handle(OpenGl_GraphicDriver)& theDriver,
|
||||
{
|
||||
throw Aspect_GraphicDeviceDefinitionError("OpenGl_Window, EGL is unable to create off-screen surface!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
myGlContext->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_LOW,
|
||||
"OpenGl_Window::CreateWindow: WARNING, a Window is created without a EGL Surface!");
|
||||
|
@@ -58,7 +58,6 @@
|
||||
#include <OSD_ThreadPool.hxx>
|
||||
#include <STEPCAFControl_Writer.hxx>
|
||||
#include <STEPControl_StepModelType.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TColgp_HArray1OfPnt2d.hxx>
|
||||
@@ -91,6 +90,7 @@
|
||||
#include <BRepFeat_SplitShape.hxx>
|
||||
#include <BRepAlgoAPI_Section.hxx>
|
||||
#include <TColStd_PackedMapOfInteger.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
|
||||
#if ! defined(_WIN32)
|
||||
extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
|
||||
@@ -2561,10 +2561,13 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co
|
||||
shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());
|
||||
shapeTool->AddShape(AddTestStructure(nCount), Standard_True);
|
||||
STEPControl_StepModelType mode = STEPControl_AsIs;
|
||||
if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode
|
||||
Handle(StepData_StepModel) aModel =writer.ChangeWriter().Model();
|
||||
Handle(Interface_Static) aParam = aModel->GetParam("write.step.assembly");
|
||||
if (aParam.IsNull()) { //assembly mode
|
||||
di << "Failed to set assembly mode for step data\n\n";
|
||||
return 0;
|
||||
}
|
||||
aParam->SetIntegerValue(1);
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
if( writer.Transfer(document, mode)) {
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
|
||||
#include <Graphic3d_Vec4.hxx>
|
||||
#include <NCollection_Vec4.hxx>
|
||||
#include <Standard_Dump.hxx>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -69,7 +69,7 @@ namespace
|
||||
Standard_ASSERT_RETURN (theColorComponentBase >= 2,
|
||||
__FUNCTION__ ": 'theColorComponentBase' must be greater than 1.",
|
||||
0.0f);
|
||||
Graphic3d_Vec4 aColor (1.0f);
|
||||
NCollection_Vec4<float> aColor (1.0f);
|
||||
if (hasAlphaComponent)
|
||||
{
|
||||
const Standard_ShortReal anAlphaComponent = takeColorComponentFromInteger (theColorInteger,
|
||||
|
@@ -22,12 +22,14 @@
|
||||
/// #include <EuclidStandard.hxx>
|
||||
static Handle(RWHeaderSection_ReadWriteModule) rwm;
|
||||
static Handle(RWHeaderSection_GeneralModule) rwg;
|
||||
static int THE_RWHeaderSection_init = 0;
|
||||
|
||||
|
||||
|
||||
void RWHeaderSection::Init()
|
||||
{
|
||||
/// EuclidStandard::Init();
|
||||
Handle(HeaderSection_Protocol) proto = HeaderSection::Protocol();
|
||||
|
||||
Handle(HeaderSection_Protocol) proto = new HeaderSection_Protocol;
|
||||
StepData::AddHeaderProtocol(proto);
|
||||
if (rwm.IsNull()) rwm = new RWHeaderSection_ReadWriteModule;
|
||||
if (rwg.IsNull()) rwg = new RWHeaderSection_GeneralModule;
|
||||
|
@@ -35,10 +35,10 @@
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWHeaderSection_ReadWriteModule,StepData_ReadWriteModule)
|
||||
|
||||
// -- General Declarations (Recognize, StepType) ---
|
||||
static TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
|
||||
static TCollection_AsciiString Reco_FileName ("FILE_NAME");
|
||||
static TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
|
||||
static TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
|
||||
TCollection_AsciiString PasReco(""); // neutralise StartEntity de SW
|
||||
TCollection_AsciiString Reco_FileName ("FILE_NAME");
|
||||
TCollection_AsciiString Reco_FileDescription ("FILE_DESCRIPTION");
|
||||
TCollection_AsciiString Reco_FileSchema ("FILE_SCHEMA");
|
||||
|
||||
// -- Definition of the libraries --
|
||||
|
||||
|
@@ -18,22 +18,24 @@
|
||||
#include <RWStepAP214.hxx>
|
||||
#include <RWStepAP214_GeneralModule.hxx>
|
||||
#include <RWStepAP214_ReadWriteModule.hxx>
|
||||
#include <StepAP214.hxx>
|
||||
#include <StepAP214_Protocol.hxx>
|
||||
#include <StepData_WriterLib.hxx>
|
||||
#include <Standard_Mutex.hxx>
|
||||
|
||||
static int THE_RWStepAP214_init = 0;
|
||||
|
||||
void RWStepAP214::Init()
|
||||
void RWStepAP214::Init(const Handle(StepAP214_Protocol)& theProto)
|
||||
{
|
||||
if (THE_RWStepAP214_init)
|
||||
static Standard_Mutex aPars;
|
||||
{
|
||||
return;
|
||||
|
||||
if (THE_RWStepAP214_init)
|
||||
{
|
||||
return;
|
||||
}
|
||||
THE_RWStepAP214_init = 1;
|
||||
RWHeaderSection::Init();
|
||||
Interface_GeneralLib::SetGlobal(new RWStepAP214_GeneralModule, theProto);
|
||||
Interface_ReaderLib::SetGlobal(new RWStepAP214_ReadWriteModule, theProto);
|
||||
StepData_WriterLib::SetGlobal(new RWStepAP214_ReadWriteModule, theProto);
|
||||
}
|
||||
THE_RWStepAP214_init = 1;
|
||||
RWHeaderSection::Init();
|
||||
Handle(StepAP214_Protocol) proto = StepAP214::Protocol();
|
||||
Interface_GeneralLib::SetGlobal (new RWStepAP214_GeneralModule,proto);
|
||||
Interface_ReaderLib::SetGlobal (new RWStepAP214_ReadWriteModule,proto);
|
||||
StepData_WriterLib::SetGlobal (new RWStepAP214_ReadWriteModule,proto);
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <StepAP214_Protocol.hxx>
|
||||
|
||||
class RWStepAP214_ReadWriteModule;
|
||||
class RWStepAP214_GeneralModule;
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
|
||||
|
||||
//! enforced the initialisation of the libraries
|
||||
Standard_EXPORT static void Init();
|
||||
Standard_EXPORT static void Init(const Handle(StepAP214_Protocol)& theProto);
|
||||
|
||||
|
||||
|
||||
|
@@ -532,8 +532,12 @@
|
||||
#include <RWStepVisual_RWSurfaceStyleControlGrid.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleFillArea.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleParameterLine.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleRendering.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleRenderingWithProperties.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleSegmentationCurve.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleSilhouette.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleTransparent.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleUsage.hxx>
|
||||
#include <RWStepVisual_RWTemplate.hxx>
|
||||
#include <RWStepVisual_RWTemplateInstance.hxx>
|
||||
@@ -1084,8 +1088,12 @@
|
||||
#include <StepVisual_SurfaceStyleControlGrid.hxx>
|
||||
#include <StepVisual_SurfaceStyleFillArea.hxx>
|
||||
#include <StepVisual_SurfaceStyleParameterLine.hxx>
|
||||
#include <StepVisual_SurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <StepVisual_SurfaceStyleRendering.hxx>
|
||||
#include <StepVisual_SurfaceStyleRenderingWithProperties.hxx>
|
||||
#include <StepVisual_SurfaceStyleSegmentationCurve.hxx>
|
||||
#include <StepVisual_SurfaceStyleSilhouette.hxx>
|
||||
#include <StepVisual_SurfaceStyleTransparent.hxx>
|
||||
#include <StepVisual_SurfaceStyleUsage.hxx>
|
||||
#include <StepVisual_Template.hxx>
|
||||
#include <StepVisual_TemplateInstance.hxx>
|
||||
@@ -5156,6 +5164,34 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
|
||||
RWStepVisual_RWAnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem tool;
|
||||
tool.Share(anent, iter);
|
||||
}
|
||||
break;
|
||||
case 720:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleTransparent, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleTransparent tool;
|
||||
tool.Share(anent, iter);
|
||||
}
|
||||
break;
|
||||
case 721:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleReflectanceAmbient, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient tool;
|
||||
tool.Share(anent, iter);
|
||||
}
|
||||
break;
|
||||
case 722:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRendering, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRendering tool;
|
||||
tool.Share(anent, iter);
|
||||
}
|
||||
break;
|
||||
case 723:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRenderingWithProperties, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties tool;
|
||||
tool.Share(anent, iter);
|
||||
}
|
||||
break;
|
||||
default : break;
|
||||
}
|
||||
@@ -7169,8 +7205,18 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
|
||||
case 719:
|
||||
ent = new StepVisual_AnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem;
|
||||
break;
|
||||
|
||||
|
||||
case 720:
|
||||
ent = new StepVisual_SurfaceStyleTransparent;
|
||||
break;
|
||||
case 721:
|
||||
ent = new StepVisual_SurfaceStyleReflectanceAmbient;
|
||||
break;
|
||||
case 722:
|
||||
ent = new StepVisual_SurfaceStyleRendering;
|
||||
break;
|
||||
case 723:
|
||||
ent = new StepVisual_SurfaceStyleRenderingWithProperties;
|
||||
break;
|
||||
default:
|
||||
return Standard_False;
|
||||
}
|
||||
@@ -7769,7 +7815,11 @@ Standard_Integer RWStepAP214_GeneralModule::CategoryNumber
|
||||
case 717:
|
||||
case 718: return cataux;
|
||||
case 719: return catdr;
|
||||
|
||||
case 720:
|
||||
case 721:
|
||||
case 722:
|
||||
case 723: return catdr;
|
||||
|
||||
default : break;
|
||||
}
|
||||
return 0;
|
||||
|
@@ -433,6 +433,10 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
|
||||
|
||||
#include <StepShape_ContextDependentShapeRepresentation.hxx>
|
||||
|
||||
#include <StepVisual_SurfaceStyleTransparent.hxx>
|
||||
#include <StepVisual_SurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <StepVisual_SurfaceStyleRendering.hxx>
|
||||
#include <StepVisual_SurfaceStyleRenderingWithProperties.hxx>
|
||||
|
||||
#include <RWStepBasic_RWAddress.hxx>
|
||||
#include <RWStepShape_RWAdvancedBrepShapeRepresentation.hxx>
|
||||
@@ -1405,6 +1409,10 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
|
||||
#include <StepVisual_AnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem.hxx>
|
||||
#include <RWStepVisual_RWAnnotationCurveOccurrenceAndAnnotationOccurrenceAndGeomReprItemAndReprItemAndStyledItem.hxx>
|
||||
|
||||
#include <RWStepVisual_RWSurfaceStyleTransparent.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleRendering.hxx>
|
||||
#include <RWStepVisual_RWSurfaceStyleRenderingWithProperties.hxx>
|
||||
|
||||
// -- General Declarations (Recognize, StepType) ---
|
||||
|
||||
@@ -2046,10 +2054,16 @@ static TCollection_AsciiString Reco_CharacterizedRepresentation("CHARACTERIZED_R
|
||||
static TCollection_AsciiString Reco_CameraModelD3MultiClipping("CAMERA_MODEL_D3_MULTI_CLIPPING");
|
||||
static TCollection_AsciiString Reco_CameraModelD3MultiClippingIntersection("CAMERA_MODEL_D3_MULTI_CLIPPING_INTERSECTION");
|
||||
static TCollection_AsciiString Reco_CameraModelD3MultiClippingUnion("CAMERA_MODEL_D3_MULTI_CLIPPING_UNION");
|
||||
|
||||
static TCollection_AsciiString Reco_SurfaceStyleTransparent("SURFACE_STYLE_TRANSPARENT");
|
||||
static TCollection_AsciiString Reco_SurfaceStyleReflectanceAmbient("SURFACE_STYLE_REFLECTANCE_AMBIENT");
|
||||
static TCollection_AsciiString Reco_SurfaceStyleRendering("SURFACE_STYLE_RENDERING");
|
||||
static TCollection_AsciiString Reco_SurfaceStyleRenderingWithProperties("SURFACE_STYLE_RENDERING_WITH_PROPERTIES");
|
||||
|
||||
// -- Definition of the libraries --
|
||||
|
||||
static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typenums;
|
||||
static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typeshor;
|
||||
//static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typenums;
|
||||
//static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typeshor;
|
||||
|
||||
RWStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule ()
|
||||
{
|
||||
@@ -2703,7 +2717,11 @@ RWStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule ()
|
||||
typenums.Bind ( Reco_CameraModelD3MultiClippingIntersection, 717);
|
||||
typenums.Bind ( Reco_CameraModelD3MultiClippingUnion, 718);
|
||||
|
||||
|
||||
typenums.Bind (Reco_SurfaceStyleTransparent, 720);
|
||||
typenums.Bind (Reco_SurfaceStyleReflectanceAmbient, 721);
|
||||
typenums.Bind (Reco_SurfaceStyleRendering, 722);
|
||||
typenums.Bind (Reco_SurfaceStyleRenderingWithProperties, 723);
|
||||
|
||||
// SHORT NAMES
|
||||
// NB : la liste est celle de AP203
|
||||
// Directement exploite pour les types simples
|
||||
@@ -4558,6 +4576,11 @@ const TCollection_AsciiString& RWStepAP214_ReadWriteModule::StepType
|
||||
case 717 : return Reco_CameraModelD3MultiClippingIntersection;
|
||||
case 718 : return Reco_CameraModelD3MultiClippingUnion;
|
||||
|
||||
case 720 : return Reco_SurfaceStyleTransparent;
|
||||
case 721 : return Reco_SurfaceStyleReflectanceAmbient;
|
||||
case 722 : return Reco_SurfaceStyleRendering;
|
||||
case 723 : return Reco_SurfaceStyleRenderingWithProperties;
|
||||
|
||||
default : return PasReco;
|
||||
}
|
||||
}
|
||||
@@ -9457,7 +9480,34 @@ void RWStepAP214_ReadWriteModule::ReadStep(const Standard_Integer CN,
|
||||
tool.ReadStep(data, num, ach, anent);
|
||||
}
|
||||
break;
|
||||
|
||||
case 720:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleTransparent, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleTransparent tool;
|
||||
tool.ReadStep(data, num, ach, anent);
|
||||
}
|
||||
break;
|
||||
case 721:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleReflectanceAmbient, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient tool;
|
||||
tool.ReadStep(data, num, ach, anent);
|
||||
}
|
||||
break;
|
||||
case 722:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRendering, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRendering tool;
|
||||
tool.ReadStep(data, num, ach, anent);
|
||||
}
|
||||
break;
|
||||
case 723:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRenderingWithProperties, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties tool;
|
||||
tool.ReadStep(data, num, ach, anent);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ach->AddFail("Type Mismatch when reading - Entity");
|
||||
@@ -14314,7 +14364,34 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN,
|
||||
tool.WriteStep(SW, anent);
|
||||
}
|
||||
break;
|
||||
|
||||
case 720:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleTransparent, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleTransparent tool;
|
||||
tool.WriteStep(SW, anent);
|
||||
}
|
||||
break;
|
||||
case 721:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleReflectanceAmbient, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient tool;
|
||||
tool.WriteStep(SW, anent);
|
||||
}
|
||||
break;
|
||||
case 722:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRendering, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRendering tool;
|
||||
tool.WriteStep(SW, anent);
|
||||
}
|
||||
break;
|
||||
case 723:
|
||||
{
|
||||
DeclareAndCast(StepVisual_SurfaceStyleRenderingWithProperties, anent, ent);
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties tool;
|
||||
tool.WriteStep(SW, anent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@@ -24,7 +24,8 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_SequenceOfAsciiString.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
class TCollection_AsciiString;
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
class StepData_StepReaderData;
|
||||
class Interface_Check;
|
||||
class Standard_Transient;
|
||||
@@ -76,7 +77,8 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typenums;
|
||||
NCollection_DataMap<TCollection_AsciiString, Standard_Integer> typeshor;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -106,6 +106,11 @@ void RWStepShape_RWEdgeLoop::Check
|
||||
Standard_Boolean headToTail = Standard_True;
|
||||
//Standard_Boolean noIdentVtx = Standard_True; //szv#4:S4163:12Mar99 unused
|
||||
Standard_Integer nbEdg = ent->NbEdgeList();
|
||||
if (nbEdg == 0)
|
||||
{
|
||||
ach->AddFail("Edge loop contains empty edge list");
|
||||
return;
|
||||
}
|
||||
Handle(StepShape_OrientedEdge) theOE = ent->EdgeListValue(1);
|
||||
Handle(StepShape_Vertex) theVxFrst = theOE->EdgeStart();
|
||||
Handle(StepShape_Vertex) theVxLst = theOE->EdgeEnd();
|
||||
|
@@ -118,10 +118,18 @@ RWStepVisual_RWSurfaceStyleFillArea.cxx
|
||||
RWStepVisual_RWSurfaceStyleFillArea.hxx
|
||||
RWStepVisual_RWSurfaceStyleParameterLine.cxx
|
||||
RWStepVisual_RWSurfaceStyleParameterLine.hxx
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient.cxx
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx
|
||||
RWStepVisual_RWSurfaceStyleRendering.cxx
|
||||
RWStepVisual_RWSurfaceStyleRendering.hxx
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties.cxx
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties.hxx
|
||||
RWStepVisual_RWSurfaceStyleSegmentationCurve.cxx
|
||||
RWStepVisual_RWSurfaceStyleSegmentationCurve.hxx
|
||||
RWStepVisual_RWSurfaceStyleSilhouette.cxx
|
||||
RWStepVisual_RWSurfaceStyleSilhouette.hxx
|
||||
RWStepVisual_RWSurfaceStyleTransparent.cxx
|
||||
RWStepVisual_RWSurfaceStyleTransparent.hxx
|
||||
RWStepVisual_RWSurfaceStyleUsage.cxx
|
||||
RWStepVisual_RWSurfaceStyleUsage.hxx
|
||||
RWStepVisual_RWTemplate.cxx
|
||||
|
@@ -0,0 +1,78 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 <RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <Interface_EntityIterator.hxx>
|
||||
#include <StepData_StepReaderData.hxx>
|
||||
#include <StepData_StepWriter.hxx>
|
||||
#include <StepVisual_SurfaceStyleReflectanceAmbient.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : RWStepVisual_RWSurfaceStyleReflectanceAmbient
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
RWStepVisual_RWSurfaceStyleReflectanceAmbient::RWStepVisual_RWSurfaceStyleReflectanceAmbient() {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleReflectanceAmbient::ReadStep (const Handle(StepData_StepReaderData)& data,
|
||||
const Standard_Integer num,
|
||||
Handle(Interface_Check)& ach,
|
||||
const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ent) const
|
||||
{
|
||||
// Check number of parameters
|
||||
if ( ! data->CheckNbParams(num,1,ach,"surface_style_reflectance_ambient") ) return;
|
||||
|
||||
// Own fields of SurfaceStyleReflectanceAmbient
|
||||
|
||||
Standard_Real aAmbientReflectance;
|
||||
data->ReadReal (num, 1, "ambient_reflectance", ach, aAmbientReflectance);
|
||||
|
||||
// Initialize entity
|
||||
ent->Init(aAmbientReflectance);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleReflectanceAmbient::WriteStep (StepData_StepWriter& SW,
|
||||
const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ent) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleReflectanceAmbient
|
||||
|
||||
SW.Send (ent->AmbientReflectance());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Share
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleReflectanceAmbient::Share (const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ,
|
||||
Interface_EntityIterator& ) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleReflectanceAmbient
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 _RWStepVisual_RWSurfaceStyleReflectanceAmbient_HeaderFile_
|
||||
#define _RWStepVisual_RWSurfaceStyleReflectanceAmbient_HeaderFile_
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
class StepData_StepReaderData;
|
||||
class Interface_Check;
|
||||
class StepData_StepWriter;
|
||||
class Interface_EntityIterator;
|
||||
class StepVisual_SurfaceStyleReflectanceAmbient;
|
||||
|
||||
//! Read & Write tool for SurfaceStyleReflectanceAmbient
|
||||
class RWStepVisual_RWSurfaceStyleReflectanceAmbient
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT RWStepVisual_RWSurfaceStyleReflectanceAmbient();
|
||||
|
||||
Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ent) const;
|
||||
|
||||
Standard_EXPORT void WriteStep(StepData_StepWriter& SW, const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ent) const;
|
||||
|
||||
Standard_EXPORT void Share(const Handle(StepVisual_SurfaceStyleReflectanceAmbient)& ent, Interface_EntityIterator& iter) const;
|
||||
|
||||
};
|
||||
#endif // _RWStepVisual_RWSurfaceStyleReflectanceAmbient_HeaderFile_
|
100
src/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx
Normal file
100
src/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.cxx
Normal file
@@ -0,0 +1,100 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 <RWStepVisual_RWSurfaceStyleRendering.hxx>
|
||||
#include <Interface_EntityIterator.hxx>
|
||||
#include <StepData_StepReaderData.hxx>
|
||||
#include <StepData_StepWriter.hxx>
|
||||
#include <StepVisual_SurfaceStyleRendering.hxx>
|
||||
#include <StepVisual_ShadingSurfaceMethod.hxx>
|
||||
#include <StepVisual_Colour.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : RWStepVisual_RWSurfaceStyleRendering
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
RWStepVisual_RWSurfaceStyleRendering::RWStepVisual_RWSurfaceStyleRendering() {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRendering::ReadStep (const Handle(StepData_StepReaderData)& data,
|
||||
const Standard_Integer num,
|
||||
Handle(Interface_Check)& ach,
|
||||
const Handle(StepVisual_SurfaceStyleRendering)& ent) const
|
||||
{
|
||||
// Check number of parameters
|
||||
if ( ! data->CheckNbParams(num,2,ach,"surface_style_rendering") ) return;
|
||||
|
||||
// Own fields of SurfaceStyleRendering
|
||||
|
||||
StepVisual_ShadingSurfaceMethod aRenderingMethod = StepVisual_ssmNormalShading;
|
||||
if (data->ParamType (num, 1) == Interface_ParamEnum) {
|
||||
Standard_CString text = data->ParamCValue(num, 1);
|
||||
if (strcmp(text, ".CONSTANT_SHADING.")) aRenderingMethod = StepVisual_ssmConstantShading;
|
||||
else if (strcmp(text, ".COLOUR_SHADING.")) aRenderingMethod = StepVisual_ssmColourShading;
|
||||
else if (strcmp(text, ".DOT_SHADING.")) aRenderingMethod = StepVisual_ssmDotShading;
|
||||
else if (strcmp(text, ".NORMAL_SHADING.")) aRenderingMethod = StepVisual_ssmNormalShading;
|
||||
else ach->AddFail("Parameter #1 (rendering_method) has not allowed value");
|
||||
}
|
||||
else ach->AddFail("Parameter #1 (rendering_method) is not enumeration");
|
||||
|
||||
Handle(StepVisual_Colour) aSurfaceColour;
|
||||
data->ReadEntity (num, 2, "surface_colour", ach, STANDARD_TYPE(StepVisual_Colour), aSurfaceColour);
|
||||
|
||||
// Initialize entity
|
||||
ent->Init(aRenderingMethod,
|
||||
aSurfaceColour);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRendering::WriteStep (StepData_StepWriter& SW,
|
||||
const Handle(StepVisual_SurfaceStyleRendering)& ent) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleRendering
|
||||
|
||||
switch (ent->RenderingMethod()) {
|
||||
case StepVisual_ssmConstantShading: SW.SendEnum (".CONSTANT_SHADING."); break;
|
||||
case StepVisual_ssmColourShading: SW.SendEnum (".COLOUR_SHADING."); break;
|
||||
case StepVisual_ssmDotShading: SW.SendEnum (".DOT_SHADING."); break;
|
||||
case StepVisual_ssmNormalShading: SW.SendEnum (".NORMAL_SHADING."); break;
|
||||
}
|
||||
|
||||
SW.Send (ent->SurfaceColour());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Share
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRendering::Share (const Handle(StepVisual_SurfaceStyleRendering)& ent,
|
||||
Interface_EntityIterator& iter) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleRendering
|
||||
|
||||
iter.AddItem (ent->SurfaceColour());
|
||||
}
|
46
src/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.hxx
Normal file
46
src/RWStepVisual/RWStepVisual_RWSurfaceStyleRendering.hxx
Normal file
@@ -0,0 +1,46 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 _RWStepVisual_RWSurfaceStyleRendering_HeaderFile_
|
||||
#define _RWStepVisual_RWSurfaceStyleRendering_HeaderFile_
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
class StepData_StepReaderData;
|
||||
class Interface_Check;
|
||||
class StepData_StepWriter;
|
||||
class Interface_EntityIterator;
|
||||
class StepVisual_SurfaceStyleRendering;
|
||||
|
||||
//! Read & Write tool for SurfaceStyleRendering
|
||||
class RWStepVisual_RWSurfaceStyleRendering
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT RWStepVisual_RWSurfaceStyleRendering();
|
||||
|
||||
Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepVisual_SurfaceStyleRendering)& ent) const;
|
||||
|
||||
Standard_EXPORT void WriteStep(StepData_StepWriter& SW, const Handle(StepVisual_SurfaceStyleRendering)& ent) const;
|
||||
|
||||
Standard_EXPORT void Share(const Handle(StepVisual_SurfaceStyleRendering)& ent, Interface_EntityIterator& iter) const;
|
||||
|
||||
};
|
||||
#endif // _RWStepVisual_RWSurfaceStyleRendering_HeaderFile_
|
@@ -0,0 +1,134 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 <RWStepVisual_RWSurfaceStyleRenderingWithProperties.hxx>
|
||||
#include <Interface_EntityIterator.hxx>
|
||||
#include <StepData_StepReaderData.hxx>
|
||||
#include <StepData_StepWriter.hxx>
|
||||
#include <StepVisual_SurfaceStyleRenderingWithProperties.hxx>
|
||||
#include <StepVisual_ShadingSurfaceMethod.hxx>
|
||||
#include <StepVisual_Colour.hxx>
|
||||
#include <StepVisual_HArray1OfRenderingPropertiesSelect.hxx>
|
||||
#include <StepVisual_RenderingPropertiesSelect.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : RWStepVisual_RWSurfaceStyleRenderingWithProperties
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
RWStepVisual_RWSurfaceStyleRenderingWithProperties::RWStepVisual_RWSurfaceStyleRenderingWithProperties() {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRenderingWithProperties::ReadStep (const Handle(StepData_StepReaderData)& data,
|
||||
const Standard_Integer num,
|
||||
Handle(Interface_Check)& ach,
|
||||
const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent) const
|
||||
{
|
||||
// Check number of parameters
|
||||
if ( ! data->CheckNbParams(num,3,ach,"surface_style_rendering_with_properties") ) return;
|
||||
|
||||
// Inherited fields of SurfaceStyleRendering
|
||||
|
||||
StepVisual_ShadingSurfaceMethod aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmNormalShading;
|
||||
if (data->ParamType (num, 1) == Interface_ParamEnum) {
|
||||
Standard_CString text = data->ParamCValue(num, 1);
|
||||
if (strcmp(text, ".CONSTANT_SHADING.")) aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmConstantShading;
|
||||
else if (strcmp(text, ".COLOUR_SHADING.")) aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmColourShading;
|
||||
else if (strcmp(text, ".DOT_SHADING.")) aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmDotShading;
|
||||
else if (strcmp(text, ".NORMAL_SHADING.")) aSurfaceStyleRendering_RenderingMethod = StepVisual_ssmNormalShading;
|
||||
else ach->AddFail("Parameter #1 (surface_style_rendering.rendering_method) has not allowed value");
|
||||
}
|
||||
else ach->AddFail("Parameter #1 (surface_style_rendering.rendering_method) is not enumeration");
|
||||
|
||||
Handle(StepVisual_Colour) aSurfaceStyleRendering_SurfaceColour;
|
||||
data->ReadEntity (num, 2, "surface_style_rendering.surface_colour", ach, STANDARD_TYPE(StepVisual_Colour), aSurfaceStyleRendering_SurfaceColour);
|
||||
|
||||
// Own fields of SurfaceStyleRenderingWithProperties
|
||||
|
||||
Handle(StepVisual_HArray1OfRenderingPropertiesSelect) aProperties;
|
||||
Standard_Integer sub3 = 0;
|
||||
if ( data->ReadSubList (num, 3, "properties", ach, sub3) ) {
|
||||
Standard_Integer nb0 = data->NbParams(sub3);
|
||||
aProperties = new StepVisual_HArray1OfRenderingPropertiesSelect (1, nb0);
|
||||
Standard_Integer num2 = sub3;
|
||||
for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
|
||||
StepVisual_RenderingPropertiesSelect anIt0;
|
||||
data->ReadEntity (num2, i0, "rendering_properties_select", ach, anIt0);
|
||||
aProperties->SetValue(i0, anIt0);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize entity
|
||||
ent->Init(aSurfaceStyleRendering_RenderingMethod,
|
||||
aSurfaceStyleRendering_SurfaceColour,
|
||||
aProperties);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRenderingWithProperties::WriteStep (StepData_StepWriter& SW,
|
||||
const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleRendering
|
||||
|
||||
switch (ent->RenderingMethod()) {
|
||||
case StepVisual_ssmConstantShading: SW.SendEnum (".CONSTANT_SHADING."); break;
|
||||
case StepVisual_ssmColourShading: SW.SendEnum (".COLOUR_SHADING."); break;
|
||||
case StepVisual_ssmDotShading: SW.SendEnum (".DOT_SHADING."); break;
|
||||
case StepVisual_ssmNormalShading: SW.SendEnum (".NORMAL_SHADING."); break;
|
||||
}
|
||||
|
||||
SW.Send (ent->SurfaceColour());
|
||||
|
||||
// Own fields of SurfaceStyleRenderingWithProperties
|
||||
|
||||
SW.OpenSub();
|
||||
for (Standard_Integer i2=1; i2 <= ent->Properties()->Length(); i2++ ) {
|
||||
StepVisual_RenderingPropertiesSelect Var0 = ent->Properties()->Value(i2);
|
||||
SW.Send (Var0.Value());
|
||||
}
|
||||
SW.CloseSub();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Share
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleRenderingWithProperties::Share (const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent,
|
||||
Interface_EntityIterator& iter) const
|
||||
{
|
||||
|
||||
// Inherited fields of SurfaceStyleRendering
|
||||
|
||||
iter.AddItem (ent->StepVisual_SurfaceStyleRendering::SurfaceColour());
|
||||
|
||||
// Own fields of SurfaceStyleRenderingWithProperties
|
||||
|
||||
for (Standard_Integer i2=1; i2 <= ent->Properties()->Length(); i2++ ) {
|
||||
StepVisual_RenderingPropertiesSelect Var0 = ent->Properties()->Value(i2);
|
||||
iter.AddItem (Var0.Value());
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
// Created on : Thu May 14 15:13:19 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 _RWStepVisual_RWSurfaceStyleRenderingWithProperties_HeaderFile_
|
||||
#define _RWStepVisual_RWSurfaceStyleRenderingWithProperties_HeaderFile_
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
class StepData_StepReaderData;
|
||||
class Interface_Check;
|
||||
class StepData_StepWriter;
|
||||
class Interface_EntityIterator;
|
||||
class StepVisual_SurfaceStyleRenderingWithProperties;
|
||||
|
||||
//! Read & Write tool for SurfaceStyleRenderingWithProperties
|
||||
class RWStepVisual_RWSurfaceStyleRenderingWithProperties
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT RWStepVisual_RWSurfaceStyleRenderingWithProperties();
|
||||
|
||||
Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent) const;
|
||||
|
||||
Standard_EXPORT void WriteStep(StepData_StepWriter& SW, const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent) const;
|
||||
|
||||
Standard_EXPORT void Share(const Handle(StepVisual_SurfaceStyleRenderingWithProperties)& ent, Interface_EntityIterator& iter) const;
|
||||
|
||||
};
|
||||
#endif // _RWStepVisual_RWSurfaceStyleRenderingWithProperties_HeaderFile_
|
79
src/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx
Normal file
79
src/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.cxx
Normal file
@@ -0,0 +1,79 @@
|
||||
// Created on : Tue May 12 14:11:46 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 <RWStepVisual_RWSurfaceStyleTransparent.hxx>
|
||||
#include <Interface_Check.hxx>
|
||||
#include <Interface_EntityIterator.hxx>
|
||||
#include <StepData_StepReaderData.hxx>
|
||||
#include <StepData_StepWriter.hxx>
|
||||
#include <StepVisual_SurfaceStyleTransparent.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : RWStepVisual_RWSurfaceStyleTransparent
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
RWStepVisual_RWSurfaceStyleTransparent::RWStepVisual_RWSurfaceStyleTransparent() {}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
#include <iostream>
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleTransparent::ReadStep (const Handle(StepData_StepReaderData)& data,
|
||||
const Standard_Integer num,
|
||||
Handle(Interface_Check)& ach,
|
||||
const Handle(StepVisual_SurfaceStyleTransparent)& ent) const
|
||||
{
|
||||
// Check number of parameters
|
||||
if ( ! data->CheckNbParams(num,1,ach,"surface_style_transparent") ) return;
|
||||
|
||||
// Own fields of SurfaceStyleTransparent
|
||||
|
||||
Standard_Real aTransparency;
|
||||
data->ReadReal (num, 1, "transparency", ach, aTransparency);
|
||||
|
||||
// Initialize entity
|
||||
ent->Init(aTransparency);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteStep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleTransparent::WriteStep (StepData_StepWriter& SW,
|
||||
const Handle(StepVisual_SurfaceStyleTransparent)& ent) const
|
||||
{
|
||||
|
||||
// Own fields of SurfaceStyleTransparent
|
||||
|
||||
SW.Send (ent->Transparency());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Share
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void RWStepVisual_RWSurfaceStyleTransparent::Share (const Handle(StepVisual_SurfaceStyleTransparent)& ,
|
||||
Interface_EntityIterator& ) const
|
||||
{
|
||||
|
||||
}
|
48
src/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.hxx
Normal file
48
src/RWStepVisual/RWStepVisual_RWSurfaceStyleTransparent.hxx
Normal file
@@ -0,0 +1,48 @@
|
||||
// Created on : Tue May 12 14:11:46 2020
|
||||
// Created by: Igor KHOZHANOV
|
||||
// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V2.0
|
||||
// Copyright (c) Open CASCADE 2020
|
||||
//
|
||||
// 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 _RWStepVisual_RWSurfaceStyleTransparent_HeaderFile_
|
||||
#define _RWStepVisual_RWSurfaceStyleTransparent_HeaderFile_
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
class StepData_StepReaderData;
|
||||
class Interface_Check;
|
||||
class StepData_StepWriter;
|
||||
class Interface_EntityIterator;
|
||||
class StepVisual_SurfaceStyleTransparent;
|
||||
class Interface_EntityIterator;
|
||||
|
||||
//! Read & Write tool for SurfaceStyleTransparent
|
||||
class RWStepVisual_RWSurfaceStyleTransparent
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT RWStepVisual_RWSurfaceStyleTransparent();
|
||||
|
||||
Standard_EXPORT void ReadStep(const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepVisual_SurfaceStyleTransparent)& ent) const;
|
||||
|
||||
Standard_EXPORT void WriteStep(StepData_StepWriter& SW, const Handle(StepVisual_SurfaceStyleTransparent)& ent) const;
|
||||
|
||||
Standard_EXPORT void Share(const Handle(StepVisual_SurfaceStyleTransparent)& ent, Interface_EntityIterator& iter) const;
|
||||
|
||||
};
|
||||
#endif // _RWStepVisual_RWSurfaceStyleTransparent_HeaderFile_
|
@@ -13,8 +13,6 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <STEPCAFControl_ActorWrite.hxx>
|
||||
#include <STEPCAFControl_Controller.hxx>
|
||||
@@ -31,55 +29,3 @@ STEPCAFControl_Controller::STEPCAFControl_Controller ()
|
||||
Handle(STEPCAFControl_ActorWrite) ActWrite = new STEPCAFControl_ActorWrite;
|
||||
myAdaptorWrite = ActWrite;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean STEPCAFControl_Controller::Init ()
|
||||
{
|
||||
static Standard_Boolean inic = Standard_False;
|
||||
if (inic) return Standard_True;
|
||||
inic = Standard_True;
|
||||
// self-registering
|
||||
Handle(STEPCAFControl_Controller) STEPCTL = new STEPCAFControl_Controller;
|
||||
// do XSAlgo::Init, cause it does not called before.
|
||||
XSAlgo::Init();
|
||||
// do something to avoid warnings...
|
||||
STEPCTL->AutoRecord();
|
||||
|
||||
//-----------------------------------------------------------
|
||||
// Few variables for advanced control of translation process
|
||||
//-----------------------------------------------------------
|
||||
|
||||
// Indicates whether to write sub-shape names to 'Name' attributes of
|
||||
// STEP Representation Items
|
||||
Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", 'e', "");
|
||||
Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "enum 0");
|
||||
Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "eval Off"); // 0
|
||||
Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "eval On"); // 1
|
||||
Interface_Static::SetIVal("write.stepcaf.subshapes.name", 0); // Disabled by default
|
||||
|
||||
// Indicates whether to read sub-shape names from 'Name' attributes of
|
||||
// STEP Representation Items
|
||||
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", 'e', "");
|
||||
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "enum 0");
|
||||
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval Off"); // 0
|
||||
Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval On"); // 1
|
||||
Interface_Static::SetIVal("read.stepcaf.subshapes.name", 0); // Disabled by default
|
||||
|
||||
// STEP file encoding for names translation
|
||||
// Note: the numbers should be consistent with Resource_FormatType enumeration
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", 'e', "");
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "enum 0");
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SJIS"); // Resource_FormatType_SJIS
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval EUC"); // Resource_FormatType_EUC
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval ANSI"); // Resource_FormatType_ANSI
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval GB"); // Resource_FormatType_GB
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval UTF8"); // Resource_FormatType_UTF8
|
||||
Interface_Static::Init ("step", "read.stepcaf.codepage", '&', "eval SystemLocale"); // Resource_FormatType_SystemLocale
|
||||
Interface_Static::SetCVal ("read.stepcaf.codepage", "UTF8");
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -38,13 +38,6 @@ public:
|
||||
|
||||
//! Initializes the use of STEP Norm (the first time)
|
||||
Standard_EXPORT STEPCAFControl_Controller();
|
||||
|
||||
//! Standard Initialisation. It creates a Controller for STEP-XCAF
|
||||
//! and records it to various names, available to select it later
|
||||
//! Returns True when done, False if could not be done
|
||||
Standard_EXPORT static Standard_Boolean Init();
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(STEPCAFControl_Controller,STEPControl_Controller)
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
#include <HeaderSection_FileSchema.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
@@ -329,7 +328,7 @@ STEPCAFControl_Reader::STEPCAFControl_Reader()
|
||||
myMatMode(Standard_True),
|
||||
myViewMode(Standard_True)
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
Init(new XSControl_WorkSession, new STEPCAFControl_Controller);
|
||||
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
|
||||
}
|
||||
|
||||
@@ -339,8 +338,8 @@ STEPCAFControl_Reader::STEPCAFControl_Reader()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch)
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& theWS,
|
||||
const Standard_Boolean theScratch)
|
||||
: mySourceCodePage (Resource_FormatType_UTF8),
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
@@ -351,9 +350,27 @@ STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)
|
||||
myMatMode(Standard_True),
|
||||
myViewMode(Standard_True)
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
|
||||
Init(WS, scratch);
|
||||
Init(theWS, new STEPCAFControl_Controller, theScratch);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : STEPCAFControl_Reader
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch) :
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
myLayerMode(Standard_True),
|
||||
myPropsMode(Standard_True),
|
||||
mySHUOMode(Standard_False),
|
||||
myGDTMode(Standard_True),
|
||||
myMatMode(Standard_True),
|
||||
myViewMode(Standard_True)
|
||||
{
|
||||
Init(theWS, theController, theScratch);
|
||||
}
|
||||
|
||||
|
||||
@@ -362,11 +379,14 @@ STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void STEPCAFControl_Reader::Init(const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch)
|
||||
void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch)
|
||||
{
|
||||
// necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" );
|
||||
myReader.SetWS(WS, scratch);
|
||||
myCAFController = Handle(STEPCAFControl_Controller)::DownCast(theController);
|
||||
STEPControl_Reader aReader(theWS, theController, theScratch);
|
||||
myReader = aReader;
|
||||
|
||||
myFiles.Clear();
|
||||
}
|
||||
|
||||
@@ -840,8 +860,7 @@ Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile(const St
|
||||
|
||||
// create new WorkSession and Reader
|
||||
Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession;
|
||||
newWS->SelectNorm("STEP");
|
||||
STEPControl_Reader sr(newWS, Standard_False);
|
||||
STEPControl_Reader sr ( newWS, myCAFController, Standard_False );
|
||||
|
||||
// start to fill the resulting ExternFile structure
|
||||
Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile;
|
||||
@@ -968,10 +987,11 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
|
||||
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol, RenderCol;
|
||||
Standard_Real RenderTransp;
|
||||
// check if it is component style
|
||||
Standard_Boolean IsComponent = Standard_False;
|
||||
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, IsComponent) && IsVisible)
|
||||
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, RenderCol, RenderTransp, IsComponent) && IsVisible)
|
||||
continue;
|
||||
|
||||
// collect styled items
|
||||
@@ -1042,23 +1062,30 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
|
||||
if (S.IsNull())
|
||||
continue;
|
||||
|
||||
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !IsVisible)
|
||||
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull() || !IsVisible)
|
||||
{
|
||||
TDF_Label aL;
|
||||
Standard_Boolean isFound = STool->SearchUsingMap(S, aL, Standard_False, Standard_True);
|
||||
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull())
|
||||
if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull())
|
||||
{
|
||||
Quantity_Color aSCol, aBCol, aCCol;
|
||||
if (!SurfCol.IsNull())
|
||||
Quantity_Color aSCol, aBCol, aCCol, aRCol;
|
||||
Quantity_ColorRGBA aFullSCol;
|
||||
if (!SurfCol.IsNull()) {
|
||||
Styles.DecodeColor(SurfCol, aSCol);
|
||||
aFullSCol = Quantity_ColorRGBA(aSCol);
|
||||
}
|
||||
if (!BoundCol.IsNull())
|
||||
Styles.DecodeColor(BoundCol, aBCol);
|
||||
if (!CurveCol.IsNull())
|
||||
Styles.DecodeColor(CurveCol, aCCol);
|
||||
if (!RenderCol.IsNull()) {
|
||||
Styles.DecodeColor(RenderCol, aRCol);
|
||||
aFullSCol = Quantity_ColorRGBA(aRCol, static_cast<float>(1.0f - RenderTransp));
|
||||
}
|
||||
if (isFound)
|
||||
{
|
||||
if (!SurfCol.IsNull())
|
||||
CTool->SetColor(aL, aSCol, XCAFDoc_ColorSurf);
|
||||
if (!SurfCol.IsNull() || !RenderCol.IsNull())
|
||||
CTool->SetColor(aL, aFullSCol, XCAFDoc_ColorSurf);
|
||||
if (!BoundCol.IsNull())
|
||||
CTool->SetColor(aL, aBCol, XCAFDoc_ColorCurv);
|
||||
if (!CurveCol.IsNull())
|
||||
@@ -1071,8 +1098,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe
|
||||
TDF_Label aL1;
|
||||
if (STool->SearchUsingMap(it.Value(), aL1, Standard_False, Standard_True))
|
||||
{
|
||||
if (!SurfCol.IsNull())
|
||||
CTool->SetColor(aL1, aSCol, XCAFDoc_ColorSurf);
|
||||
if (!SurfCol.IsNull() || !RenderCol.IsNull())
|
||||
CTool->SetColor(aL1, aFullSCol, XCAFDoc_ColorSurf);
|
||||
if (!BoundCol.IsNull())
|
||||
CTool->SetColor(aL1, aBCol, XCAFDoc_ColorCurv);
|
||||
if (!CurveCol.IsNull())
|
||||
@@ -1622,10 +1649,11 @@ Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSes
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol;
|
||||
Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol, RenderCol;
|
||||
Standard_Real RenderTransp;
|
||||
// check if it is component style
|
||||
Standard_Boolean IsComponent = Standard_False;
|
||||
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, IsComponent) && IsVisible)
|
||||
if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, RenderCol, RenderTransp, IsComponent) && IsVisible)
|
||||
continue;
|
||||
if (!IsComponent)
|
||||
continue;
|
||||
@@ -1660,10 +1688,18 @@ Standard_Boolean STEPCAFControl_Reader::ReadSHUOs(const Handle(XSControl_WorkSes
|
||||
continue;
|
||||
}
|
||||
// now set the style to the SHUO main label.
|
||||
if (!SurfCol.IsNull()) {
|
||||
if (!SurfCol.IsNull() || !RenderCol.IsNull()) {
|
||||
Quantity_Color col;
|
||||
Styles.DecodeColor(SurfCol, col);
|
||||
CTool->SetColor(aLabelForStyle, col, XCAFDoc_ColorSurf);
|
||||
Quantity_ColorRGBA colRGBA;
|
||||
if (!SurfCol.IsNull()) {
|
||||
Styles.DecodeColor(SurfCol, col);
|
||||
colRGBA = Quantity_ColorRGBA(col);
|
||||
}
|
||||
if (!RenderCol.IsNull()) {
|
||||
Styles.DecodeColor(RenderCol, col);
|
||||
colRGBA = Quantity_ColorRGBA(col, static_cast<float>(1.0 - RenderTransp));
|
||||
}
|
||||
CTool->SetColor(aLabelForStyle, colRGBA, XCAFDoc_ColorSurf);
|
||||
}
|
||||
if (!BoundCol.IsNull()) {
|
||||
Quantity_Color col;
|
||||
@@ -4478,7 +4514,7 @@ void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& Sha
|
||||
TColStd_MapOfTransient aRepItems;
|
||||
|
||||
// Read translation control variables
|
||||
Standard_Boolean doReadSNames = (Interface_Static::IVal("read.stepcaf.subshapes.name") > 0);
|
||||
Standard_Boolean doReadSNames = (myReader.Model()->IVal("read.stepcaf.subshapes.name") > 0);
|
||||
|
||||
if (!doReadSNames)
|
||||
return;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <IFSelect_ReturnStatus.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <STEPCAFControl_Controller.hxx>
|
||||
#include <STEPCAFControl_DataMapOfShapePD.hxx>
|
||||
#include <STEPCAFControl_DataMapOfPDExternFile.hxx>
|
||||
#include <XCAFDoc_DataMapOfShapeLabel.hxx>
|
||||
@@ -69,12 +70,15 @@ public:
|
||||
|
||||
//! Creates a reader tool and attaches it to an already existing Session
|
||||
//! Clears the session if it was not yet set for STEP
|
||||
Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
|
||||
|
||||
//! Clears the internal data structures and attaches to a new session
|
||||
Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Standard_Boolean theScratch = Standard_True);
|
||||
|
||||
//! Creates a reader tool and attaches it to an already existing Session and controller
|
||||
//! Clears the session if it was not yet set for STEP
|
||||
Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
|
||||
|
||||
Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch = Standard_True);
|
||||
|
||||
//! Loads a file and returns the read status
|
||||
//! Provided for use like single-file reader
|
||||
Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
|
||||
@@ -174,7 +178,12 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
//! Inits a reader with following session and controller
|
||||
Standard_EXPORT void Init(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch = Standard_True);
|
||||
|
||||
//! Translates STEP file already loaded into the reader
|
||||
//! into the document
|
||||
//! If num==0, translates all roots, else only root number num
|
||||
@@ -293,6 +302,7 @@ private:
|
||||
Standard_Boolean myMatMode;
|
||||
Standard_Boolean myViewMode;
|
||||
NCollection_DataMap<Handle(Standard_Transient), TDF_Label> myGDTMap;
|
||||
Handle(STEPCAFControl_Controller) myCAFController;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -280,9 +280,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () :
|
||||
myGDTMode ( Standard_True ),
|
||||
myMatMode ( Standard_True )
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
Handle(XSControl_WorkSession) WS = new XSControl_WorkSession;
|
||||
Init ( WS );
|
||||
Init(new XSControl_WorkSession, new STEPCAFControl_Controller);
|
||||
}
|
||||
|
||||
|
||||
@@ -291,8 +289,8 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch) :
|
||||
STEPCAFControl_Writer::STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Standard_Boolean theScratch) :
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
myLayerMode(Standard_True),
|
||||
@@ -301,21 +299,40 @@ STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession
|
||||
myGDTMode(Standard_True),
|
||||
myMatMode(Standard_True)
|
||||
{
|
||||
STEPCAFControl_Controller::Init();
|
||||
Init ( WS, scratch );
|
||||
Init(theWS, new STEPCAFControl_Controller, theScratch);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : STEPCAFControl_Reader
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
STEPCAFControl_Writer::STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch) :
|
||||
myColorMode(Standard_True),
|
||||
myNameMode(Standard_True),
|
||||
myLayerMode(Standard_True),
|
||||
myPropsMode(Standard_True),
|
||||
mySHUOMode(Standard_True),
|
||||
myGDTMode(Standard_True),
|
||||
myMatMode(Standard_True)
|
||||
{
|
||||
Init(theWS, theController, theScratch);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void STEPCAFControl_Writer::Init (const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch)
|
||||
void STEPCAFControl_Writer::Init(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch)
|
||||
{
|
||||
WS->SelectNorm ( "STEP" );
|
||||
myWriter.SetWS (WS,scratch);
|
||||
myCAFController = Handle(STEPCAFControl_Controller)::DownCast(theController);
|
||||
STEPControl_Writer aWriter(theWS, theController, theScratch);
|
||||
myWriter = aWriter;
|
||||
|
||||
myFiles.Clear();
|
||||
myLabEF.Clear();
|
||||
myLabels.Clear();
|
||||
@@ -510,7 +527,15 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
|
||||
Handle(STEPCAFControl_ActorWrite)::DownCast ( writer.WS()->NormAdaptor()->ActorWrite() );
|
||||
|
||||
// translate free top-level shapes of the DECAF document
|
||||
Standard_Integer ap = Interface_Static::IVal ("write.step.schema");
|
||||
|
||||
|
||||
Handle(StepData_StepModel) aModel = writer.Model();
|
||||
|
||||
if (Actor.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Standard_Integer ap = aModel->IVal("write.step.schema");
|
||||
TDF_LabelSequence sublabels;
|
||||
for ( Standard_Integer i=1; i <= labels.Length(); i++ ) {
|
||||
TDF_Label L = labels.Value(i);
|
||||
@@ -585,7 +610,7 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
|
||||
// translate main assembly structure
|
||||
/*
|
||||
if ( ap == 3 ) { // if AP203, switch to AP214
|
||||
Interface_Static::SetCVal ("write.step.schema", "AP214DIS");
|
||||
myCAFController->GetParam("write.step.schema")->SetCStringValue("AP214DIS");
|
||||
Handle(StepData_StepModel) model =
|
||||
Handle(StepData_StepModel)::DownCast ( writer.WS()->Model() );
|
||||
if ( model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ) {
|
||||
@@ -600,11 +625,22 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
|
||||
}
|
||||
}
|
||||
*/
|
||||
Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly");
|
||||
Interface_Static::SetCVal ("write.step.assembly", "On");
|
||||
Handle(Interface_Static) aParameter = aModel->GetParam("write.step.assembly");
|
||||
Standard_Integer assemblymode = 0;
|
||||
if (!aParameter.IsNull())
|
||||
{
|
||||
assemblymode = aParameter->IntegerValue();
|
||||
aParameter->SetCStringValue("On");
|
||||
}
|
||||
writer.Transfer ( Sass, STEPControl_AsIs );
|
||||
Interface_Static::SetIVal ("write.step.assembly", assemblymode);
|
||||
Interface_Static::SetIVal ("write.step.schema", ap);
|
||||
if (!aParameter.IsNull())
|
||||
aParameter->SetIntegerValue(assemblymode);
|
||||
Handle(Interface_Static) aParamWriteSch = aModel->GetParam("write.step.schema");
|
||||
if (!aParamWriteSch.IsNull())
|
||||
aParamWriteSch->SetIntegerValue(ap);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -656,12 +692,14 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
|
||||
|
||||
// write validation props
|
||||
// if ( multi && ap ==3 ) {
|
||||
// Interface_Static::SetCVal ("write.step.schema", "AP214DIS");
|
||||
// myCAFController->GetParam("write.step.schema")->SetCStringValue("AP214DIS");
|
||||
// }
|
||||
if ( GetPropsMode() )
|
||||
WriteValProps ( writer.WS(), sublabels, multi );
|
||||
|
||||
Interface_Static::SetIVal ("write.step.schema", ap);
|
||||
Handle(Interface_Static) aParam = aModel->GetParam("write.step.schema");
|
||||
if (!aParam.IsNull())
|
||||
aParam->SetIntegerValue(ap);
|
||||
|
||||
// refresh graph
|
||||
writer.WS()->ComputeGraph ( Standard_True );
|
||||
@@ -670,7 +708,8 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
|
||||
* Write names for the sub-shapes
|
||||
* ================================ */
|
||||
|
||||
if (Interface_Static::IVal("write.stepcaf.subshapes.name") != 0)
|
||||
|
||||
if (aModel->IVal("write.stepcaf.subshapes.name") != 0)
|
||||
{
|
||||
const Handle(XSControl_TransferWriter) &TW = this->ChangeWriter().WS()->TransferWriter();
|
||||
const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess();
|
||||
@@ -759,11 +798,17 @@ TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L,
|
||||
EF->SetWS ( newWS );
|
||||
EF->SetName ( name );
|
||||
EF->SetLabel ( L );
|
||||
Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly");
|
||||
Interface_Static::SetCVal ("write.step.assembly", "Off");
|
||||
Handle(Interface_Static) aParameter = sw.Model()->GetParam("write.step.assembly");
|
||||
Standard_Integer assemblymode = 0;
|
||||
if (!aParameter.IsNull())
|
||||
{
|
||||
assemblymode = aParameter->IntegerValue();
|
||||
aParameter->SetCStringValue("Off");
|
||||
}
|
||||
const Standard_CString multi = 0;
|
||||
EF->SetTransferStatus ( Transfer ( sw, Lseq, mode, multi, Standard_True ) );
|
||||
Interface_Static::SetIVal ("write.step.assembly", assemblymode);
|
||||
if (!aParameter.IsNull())
|
||||
aParameter->SetIntegerValue(assemblymode);
|
||||
myLabEF.Bind ( L, EF );
|
||||
myFiles.Bind ( name->ToCString(), EF );
|
||||
|
||||
@@ -812,7 +857,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteExternRefs (const Handle(XSControl_
|
||||
const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter();
|
||||
const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess();
|
||||
STEPConstruct_ExternRefs EFTool ( WS );
|
||||
Standard_Integer schema = Interface_Static::IVal("write.step.schema");
|
||||
Standard_Integer schema = WS->Model()->GetParam("write.step.schema")->IntegerValue();
|
||||
for ( Standard_Integer k=1; k <= labels.Length(); k++ ) {
|
||||
TDF_Label lab = labels(k);
|
||||
if ( XCAFDoc_ShapeTool::IsAssembly ( lab ) ) continue; // skip assemblies
|
||||
@@ -1060,13 +1105,17 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
|
||||
XCAFPrs_Style own = settings.FindFromKey(S);
|
||||
if ( !own.IsVisible() ) style.SetVisibility ( Standard_False );
|
||||
if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
|
||||
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
|
||||
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurfRGBA() );
|
||||
}
|
||||
|
||||
// translate colors to STEP
|
||||
Handle(StepVisual_Colour) surfColor, curvColor;
|
||||
if ( style.IsSetColorSurf() )
|
||||
surfColor = Styles.EncodeColor(style.GetColorSurf(),DPDCs,ColRGBs);
|
||||
Standard_Real RenderTransp = 0.0;
|
||||
if ( style.IsSetColorSurf() ) {
|
||||
Quantity_ColorRGBA sCol = style.GetColorSurfRGBA();
|
||||
RenderTransp = 1.0 - sCol.Alpha();
|
||||
surfColor = Styles.EncodeColor(sCol.GetRGB(),DPDCs,ColRGBs);
|
||||
}
|
||||
if ( style.IsSetColorCurv() )
|
||||
curvColor = Styles.EncodeColor(style.GetColorCurv(),DPDCs,ColRGBs);
|
||||
|
||||
@@ -1094,12 +1143,12 @@ static void MakeSTEPStyles (STEPConstruct_Styles &Styles,
|
||||
Handle(StepRepr_RepresentationItem)::DownCast(seqRI(i));
|
||||
Handle(StepVisual_PresentationStyleAssignment) PSA;
|
||||
if ( style.IsVisible() || !surfColor.IsNull() || !curvColor.IsNull() ) {
|
||||
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
|
||||
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, RenderTransp, isComponent );
|
||||
}
|
||||
else {
|
||||
// default white color
|
||||
surfColor = Styles.EncodeColor(Quantity_Color(1,1,1,Quantity_TOC_RGB),DPDCs,ColRGBs);
|
||||
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
|
||||
PSA = Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, 0.0, isComponent );
|
||||
if ( isComponent )
|
||||
setDefaultInstanceColor( override, PSA);
|
||||
|
||||
@@ -1216,7 +1265,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
for ( Standard_Integer j = 1; j <= seq.Length(); j++ ) {
|
||||
TDF_Label lab = seq.Value(j);
|
||||
XCAFPrs_Style style;
|
||||
Quantity_Color C;
|
||||
Quantity_ColorRGBA C;
|
||||
if ( lab == L ) {
|
||||
// check for invisible status of object on label
|
||||
if ( !CTool->IsVisible( lab ) ) {
|
||||
@@ -1225,13 +1274,13 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
}
|
||||
}
|
||||
if ( CTool->GetColor ( lab, XCAFDoc_ColorGen, C ) ) {
|
||||
style.SetColorCurv ( C );
|
||||
style.SetColorCurv ( C.GetRGB() );
|
||||
style.SetColorSurf ( C );
|
||||
}
|
||||
if ( CTool->GetColor ( lab, XCAFDoc_ColorSurf, C ) )
|
||||
style.SetColorSurf ( C );
|
||||
if ( CTool->GetColor ( lab, XCAFDoc_ColorCurv, C ) )
|
||||
style.SetColorCurv ( C );
|
||||
style.SetColorCurv ( C.GetRGB() );
|
||||
|
||||
// commented, cause we are need to take reference from
|
||||
// if ( isComponent && lab == L && !isVisible)
|
||||
@@ -1265,7 +1314,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
std::cerr << "Error: Current Top-Level shape have MDGPR already " << std::endl;
|
||||
#endif
|
||||
}
|
||||
Styles.CreateMDGPR ( Context, aMDGPR );
|
||||
Styles.CreateMDGPR(Context, aMDGPR, WS->Model());
|
||||
if (!aMDGPR.IsNull())
|
||||
myMapCompMDGPR.Bind( aTopSh, aMDGPR );
|
||||
}
|
||||
@@ -1285,7 +1334,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
// search for MDGPR of the component top-level shape
|
||||
if ( myMapCompMDGPR.IsBound( aTopSh )) {
|
||||
aMDGPR = Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)::DownCast( myMapCompMDGPR.Find( aTopSh ) );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
aMDGPR = new StepVisual_MechanicalDesignGeometricPresentationRepresentation;
|
||||
Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" );
|
||||
aMDGPR->SetName( ReprName );
|
||||
@@ -1848,8 +1898,12 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
|
||||
STEPConstruct_Styles Styles( WS );
|
||||
// translate colors to STEP
|
||||
Handle(StepVisual_Colour) surfColor, curvColor;
|
||||
if ( style.IsSetColorSurf() )
|
||||
surfColor = Styles.EncodeColor ( style.GetColorSurf() );
|
||||
Standard_Real RenderTransp = 0.0;
|
||||
if ( style.IsSetColorSurf() ) {
|
||||
Quantity_ColorRGBA sCol = style.GetColorSurfRGBA();
|
||||
RenderTransp = 1.0 - sCol.Alpha();
|
||||
surfColor = Styles.EncodeColor ( sCol.GetRGB() );
|
||||
}
|
||||
if ( style.IsSetColorCurv() )
|
||||
curvColor = Styles.EncodeColor ( style.GetColorCurv() );
|
||||
Standard_Boolean isComponent = Standard_True;// cause need to get PSBC
|
||||
@@ -1861,7 +1915,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
|
||||
isSetDefaultColor = Standard_True;
|
||||
}
|
||||
Handle(StepVisual_PresentationStyleAssignment) PSA =
|
||||
Styles.MakeColorPSA ( item, surfColor, curvColor, isComponent );
|
||||
Styles.MakeColorPSA ( item, surfColor, curvColor, surfColor, RenderTransp, isComponent );
|
||||
Handle(StepVisual_StyledItem) override; //null styled item
|
||||
|
||||
// find the repr item of the shape
|
||||
@@ -1911,7 +1965,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style,
|
||||
std::cout << "Warning: " << __FILE__ << ": Create new MDGPR for SHUO instance" << std::endl;
|
||||
#endif
|
||||
Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR;
|
||||
Styles.CreateMDGPR ( Context, aMDGPR );
|
||||
Styles.CreateMDGPR(Context, aMDGPR, WS->Model());
|
||||
if (!aMDGPR.IsNull())
|
||||
myMapCompMDGPR.Bind( aTopSh, aMDGPR );
|
||||
}
|
||||
@@ -3717,7 +3771,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_W
|
||||
STEPConstruct_Styles aStyles (WS);
|
||||
Handle(StepVisual_Colour) aCurvColor = aStyles.EncodeColor(Quantity_NOC_WHITE);
|
||||
Handle(StepRepr_RepresentationItem) anItem = NULL;
|
||||
myGDTPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor));
|
||||
myGDTPrsCurveStyle->SetValue(1, aStyles.MakeColorPSA(anItem, aCurvColor, aCurvColor, aCurvColor, 0.0));
|
||||
Interface_EntityIterator aModelIter = aModel->Entities();
|
||||
for (; aModelIter.More() && myGDTCommonPDS.IsNull(); aModelIter.Next())
|
||||
myGDTCommonPDS = Handle(StepRepr_ProductDefinitionShape)::DownCast(aModelIter.Value());
|
||||
@@ -4296,3 +4350,13 @@ Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const
|
||||
{
|
||||
return myMatMode;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetParam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//Handle(Interface_Static) STEPCAFControl_Writer::GetParam
|
||||
//(const Standard_CString theParamName)
|
||||
//{
|
||||
// return myWriter.Model()->GetParam(theParamName);
|
||||
//}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <STEPControl_Writer.hxx>
|
||||
#include <STEPCAFControl_Controller.hxx>
|
||||
#include <STEPCAFControl_DataMapOfLabelShape.hxx>
|
||||
#include <STEPCAFControl_DataMapOfLabelExternFile.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
@@ -64,15 +65,18 @@ public:
|
||||
//! PropsMode to Standard_True.
|
||||
Standard_EXPORT STEPCAFControl_Writer();
|
||||
|
||||
//! Creates a reader tool and attaches it to an already existing Session
|
||||
//! Creates a writer tool and attaches it to an already existing Session
|
||||
//! Clears the session if it was not yet set for STEP
|
||||
//! Clears the internal data structures
|
||||
Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
|
||||
|
||||
//! Clears the internal data structures and attaches to a new session
|
||||
Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS,
|
||||
const Standard_Boolean scratch = Standard_True);
|
||||
|
||||
//! Creates a writer tool and attaches it to an already existing Session and controller
|
||||
//! Clears the session if it was not yet set for STEP
|
||||
Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True);
|
||||
|
||||
Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch = Standard_True);
|
||||
|
||||
//! Writes all the produced models into file
|
||||
//! In case of multimodel with extern references,
|
||||
//! filename will be a name of root file, all other files
|
||||
@@ -149,18 +153,33 @@ public:
|
||||
Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode);
|
||||
|
||||
Standard_EXPORT Standard_Boolean GetMaterialMode() const;
|
||||
|
||||
//! Returns parameter for translation by its name
|
||||
//Standard_EXPORT Handle(Interface_Static) GetParam(const Standard_CString theParamName);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
//! Inits a reader with following session and controller
|
||||
Standard_EXPORT void Init(const Handle(XSControl_WorkSession)& theWS,
|
||||
const Handle(XSControl_Controller)& theController,
|
||||
const Standard_Boolean theScratch = Standard_True);
|
||||
|
||||
//! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
|
||||
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
|
||||
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L,
|
||||
const STEPControl_StepModelType mode = STEPControl_AsIs,
|
||||
const Standard_CString multi = 0);
|
||||
|
||||
//! Transfers labels to a STEP model
|
||||
//! Returns True if translation is OK
|
||||
//! isExternFile setting from TransferExternFiles method
|
||||
Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr, const TDF_LabelSequence& labels, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0, const Standard_Boolean isExternFile = Standard_False) ;
|
||||
Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr,
|
||||
const TDF_LabelSequence& labels,
|
||||
const STEPControl_StepModelType mode = STEPControl_AsIs,
|
||||
const Standard_CString multi = 0,
|
||||
const Standard_Boolean isExternFile = Standard_False) ;
|
||||
|
||||
//! Parses assembly structure of label L, writes all the simple
|
||||
//! shapes each to its own file named by name of its label plus
|
||||
@@ -168,7 +187,9 @@ protected:
|
||||
//! Returns shape representing that assembly structure
|
||||
//! in the form of nested empty compounds (and a sequence of
|
||||
//! labels which are newly written nodes of this assembly)
|
||||
Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, const STEPControl_StepModelType mode, TDF_LabelSequence& Lseq, const Standard_CString prefix = "");
|
||||
Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L,
|
||||
const STEPControl_StepModelType mode,
|
||||
TDF_LabelSequence& Lseq, const Standard_CString prefix = "");
|
||||
|
||||
//! Write external references to STEP
|
||||
Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
|
||||
@@ -237,6 +258,7 @@ private:
|
||||
Handle(StepVisual_DraughtingModel) myGDTPresentationDM;
|
||||
Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle;
|
||||
Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS;
|
||||
Handle(STEPCAFControl_Controller) myCAFController;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <GeomToStep_MakeAxis2Placement3d.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <StepAP203_CcDesignApproval.hxx>
|
||||
#include <StepAP203_CcDesignDateAndTimeAssignment.hxx>
|
||||
#include <StepAP203_CcDesignPersonAndOrganizationAssignment.hxx>
|
||||
@@ -75,13 +74,14 @@ STEPConstruct_ContextTool::STEPConstruct_ContextTool (const Handle(StepData_Step
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void STEPConstruct_ContextTool::SetModel (const Handle(StepData_StepModel)& aStepModel)
|
||||
void STEPConstruct_ContextTool::SetModel (const Handle(Interface_InterfaceModel)& aStepModel)
|
||||
{
|
||||
myModel = aStepModel;
|
||||
theAPD.Nullify(); //thePRPC.Nullify();
|
||||
|
||||
Standard_Integer i, nb = aStepModel->NbEntities();
|
||||
Standard_Integer i, nb = myModel->NbEntities();
|
||||
for(i = 1; i<=nb && theAPD.IsNull(); i ++) {
|
||||
Handle(Standard_Transient) ent = aStepModel->Value(i);
|
||||
Handle(Standard_Transient) ent = myModel->Value(i);
|
||||
if (ent->IsKind(STANDARD_TYPE(StepBasic_ApplicationProtocolDefinition))) {
|
||||
if (theAPD.IsNull()) theAPD = GetCasted(StepBasic_ApplicationProtocolDefinition, ent);
|
||||
}
|
||||
@@ -111,7 +111,8 @@ void STEPConstruct_ContextTool::AddAPD (const Standard_Boolean enforce)
|
||||
Standard_Boolean noapd = theAPD.IsNull();
|
||||
if (noapd || enforce) theAPD = new StepBasic_ApplicationProtocolDefinition;
|
||||
|
||||
switch (Interface_Static::IVal("write.step.schema")) { //j4
|
||||
Standard_Integer aShema = myModel->IVal("write.step.schema");
|
||||
switch (aShema) { //j4
|
||||
default:
|
||||
case 1:
|
||||
theAPD->SetApplicationProtocolYear (1997);
|
||||
@@ -147,7 +148,8 @@ void STEPConstruct_ContextTool::AddAPD (const Standard_Boolean enforce)
|
||||
if (theAPD->Application().IsNull())
|
||||
theAPD->SetApplication (new StepBasic_ApplicationContext);
|
||||
Handle(TCollection_HAsciiString) appl;
|
||||
switch (Interface_Static::IVal("write.step.schema")) { //j4
|
||||
|
||||
switch (aShema) { //j4
|
||||
default:
|
||||
case 1:
|
||||
case 2: appl = new TCollection_HAsciiString ( "core data for automotive mechanical design processes" );
|
||||
@@ -356,7 +358,7 @@ void STEPConstruct_ContextTool::AddPRPC (const Standard_Boolean enforce)
|
||||
Standard_Boolean noprpc = thePRPC.IsNull();
|
||||
if (noprpc || enforce) {
|
||||
//:i3 abv 1 Sep 98: ProSTEP TR9: generate PRODUCT_TYPE (derived) instead of PRPC
|
||||
switch (Interface_Static::IVal("write.step.schema")) { //j4
|
||||
switch (myModel->GetParam("write.step.schema")->IntegerValue()) { //j4
|
||||
default:
|
||||
case 1:
|
||||
thePRPC = new StepBasic_ProductType;
|
||||
@@ -567,8 +569,10 @@ void STEPConstruct_ContextTool::SetIndex (const Standard_Integer ind)
|
||||
Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetProductName () const
|
||||
{
|
||||
Handle(TCollection_HAsciiString) PdtName;
|
||||
if (Interface_Static::IsSet("write.step.product.name"))
|
||||
PdtName = new TCollection_HAsciiString(Interface_Static::CVal("write.step.product.name"));
|
||||
|
||||
TCollection_AsciiString aName = myModel->CVal("write.step.product.name");
|
||||
if(!aName.IsEmpty())
|
||||
PdtName = new TCollection_HAsciiString(aName);
|
||||
else PdtName = new TCollection_HAsciiString("Product");
|
||||
|
||||
for ( Standard_Integer i=1; i <= myLevel.Length(); i++ ) {
|
||||
@@ -596,7 +600,7 @@ Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForPart
|
||||
if ( ! SDRTool.PRPC().IsNull() ) seq->Append ( SDRTool.PRPC() );
|
||||
|
||||
// for AP203, add required product management data
|
||||
if ( Interface_Static::IVal("write.step.schema") == 3 ) {
|
||||
if (myModel->IVal("write.step.schema") == 3 ) {
|
||||
theAP203.Init ( SDRTool );
|
||||
seq->Append (theAP203.GetProductCategoryRelationship());
|
||||
seq->Append (theAP203.GetCreator());
|
||||
@@ -624,9 +628,8 @@ Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForAssem
|
||||
Handle(TColStd_HSequenceOfTransient) seq = new TColStd_HSequenceOfTransient;
|
||||
|
||||
seq->Append ( assembly.ItemValue() );
|
||||
|
||||
// for AP203, write required product management data
|
||||
if ( Interface_Static::IVal("write.step.schema") == 3 ) {
|
||||
if (myModel->IVal("write.step.schema") == 3 ) {
|
||||
theAP203.Init ( assembly.GetNAUO() );
|
||||
seq->Append (theAP203.GetSecurity());
|
||||
seq->Append (theAP203.GetClassificationOfficer());
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <STEPConstruct_AP203Context.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
|
||||
//! Initialize ApplicationProtocolDefinition by the first
|
||||
//! entity of that type found in the model
|
||||
Standard_EXPORT void SetModel (const Handle(StepData_StepModel)& aStepModel);
|
||||
Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& aStepModel);
|
||||
|
||||
Standard_EXPORT Handle(StepBasic_ApplicationProtocolDefinition) GetAPD();
|
||||
|
||||
@@ -141,6 +142,7 @@ private:
|
||||
Handle(StepBasic_ApplicationProtocolDefinition) theAPD;
|
||||
STEPConstruct_AP203Context theAP203;
|
||||
Handle(StepGeom_Axis2Placement3d) myAxis;
|
||||
Handle(Interface_InterfaceModel) myModel;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -16,7 +16,6 @@
|
||||
//:j4 gka 16.03.99 S4134
|
||||
// abv 20.11.99 renamed from StepPDR_SDRtool
|
||||
|
||||
#include <Interface_Static.hxx>
|
||||
#include <StepBasic_ApplicationContext.hxx>
|
||||
#include <StepBasic_DesignContext.hxx>
|
||||
#include <StepBasic_HArray1OfProduct.hxx>
|
||||
@@ -59,12 +58,13 @@ STEPConstruct_Part::STEPConstruct_Part()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(StepBasic_ApplicationContext)& AC)
|
||||
void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& theShape,
|
||||
const Handle(TCollection_HAsciiString)& theName,
|
||||
const Handle(StepBasic_ApplicationContext)& theAppContext,
|
||||
const Handle(Interface_InterfaceModel)& theModel)
|
||||
{
|
||||
// get current schema
|
||||
Standard_Integer schema = Interface_Static::IVal("write.step.schema");
|
||||
Standard_Integer schema = theModel->IVal("write.step.schema");
|
||||
|
||||
// create PC
|
||||
Handle(StepBasic_ProductContext) PC;
|
||||
@@ -82,14 +82,14 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR
|
||||
Handle(TCollection_HAsciiString) PCname = new TCollection_HAsciiString("");
|
||||
Handle(TCollection_HAsciiString) PCdisciplineType =
|
||||
new TCollection_HAsciiString("mechanical");
|
||||
PC->Init(PCname, AC, PCdisciplineType);
|
||||
PC->Init(PCname, theAppContext, PCdisciplineType);
|
||||
|
||||
// create product
|
||||
Handle(StepBasic_Product) P = new StepBasic_Product;
|
||||
Handle(StepBasic_HArray1OfProductContext) PCs = new StepBasic_HArray1OfProductContext(1,1);
|
||||
PCs->SetValue(1,PC);
|
||||
Handle(TCollection_HAsciiString) Pdescription = new TCollection_HAsciiString("");
|
||||
P->Init(aName, aName, Pdescription, PCs);
|
||||
P->Init(theName, theName, Pdescription, PCs);
|
||||
|
||||
// create PDF
|
||||
Handle(StepBasic_ProductDefinitionFormation) PDF;
|
||||
@@ -123,7 +123,7 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR
|
||||
break;
|
||||
}
|
||||
Handle(TCollection_HAsciiString) PDClifeCycleStage = new TCollection_HAsciiString("design");
|
||||
PDC->Init(PDCname, AC, PDClifeCycleStage);
|
||||
PDC->Init(PDCname, theAppContext, PDClifeCycleStage);
|
||||
|
||||
// create PD
|
||||
Handle(StepBasic_ProductDefinition) PD = new StepBasic_ProductDefinition;
|
||||
@@ -143,11 +143,12 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR
|
||||
mySDR = new StepShape_ShapeDefinitionRepresentation;
|
||||
StepRepr_RepresentedDefinition RD;
|
||||
RD.SetValue ( PDS );
|
||||
mySDR->Init(RD, SR);
|
||||
mySDR->Init(RD, theShape);
|
||||
|
||||
// and an associated PRPC
|
||||
Handle(TCollection_HAsciiString) PRPCName;
|
||||
switch (Interface_Static::IVal("write.step.schema")) {
|
||||
|
||||
switch (schema) {
|
||||
default:
|
||||
case 1:
|
||||
myPRPC = new StepBasic_ProductType;
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
class StepShape_ShapeDefinitionRepresentation;
|
||||
class StepBasic_ProductRelatedProductCategory;
|
||||
@@ -48,7 +49,10 @@ public:
|
||||
|
||||
Standard_EXPORT STEPConstruct_Part();
|
||||
|
||||
Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& aShape, const Handle(TCollection_HAsciiString)& aName, const Handle(StepBasic_ApplicationContext)& AC);
|
||||
Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& theShape,
|
||||
const Handle(TCollection_HAsciiString)& theName,
|
||||
const Handle(StepBasic_ApplicationContext)& theAppContext,
|
||||
const Handle(Interface_InterfaceModel)& theModel );
|
||||
|
||||
Standard_EXPORT void ReadSDR (const Handle(StepShape_ShapeDefinitionRepresentation)& aShape);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user