mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
26f0bc0d01 | ||
|
6b9da86201 |
@@ -3,5 +3,5 @@ ModelingData TKG2d TKG3d TKGeomBase TKBRep
|
||||
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
|
||||
Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost
|
||||
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF
|
||||
DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade
|
||||
DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh
|
||||
Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
|
||||
|
@@ -384,8 +384,6 @@ t TKSTEPBase
|
||||
t TKSTL
|
||||
t TKVRML
|
||||
t TKXCAF
|
||||
t TKXDE
|
||||
t TKXDECascade
|
||||
t TKXDEIGES
|
||||
t TKXDESTEP
|
||||
t TKXSBase
|
||||
@@ -396,9 +394,6 @@ n DBRep
|
||||
n DDF
|
||||
n DDataStd
|
||||
n DDocStd
|
||||
n DE
|
||||
n DEXCAFCascade
|
||||
n DEBRepCascade
|
||||
n DNaming
|
||||
n DPrsStd
|
||||
n Draw
|
||||
|
@@ -1,96 +1,4 @@
|
||||
# Draco - a library for a lossy vertex data compression, used as extension to glTF format.
|
||||
# https://github.com/google/draco
|
||||
|
||||
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
|
||||
|
||||
if (NOT DEFINED INSTALL_DRACO)
|
||||
set (INSTALL_DRACO OFF CACHE BOOL "${INSTALL_DRACO_DESCR}")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_DRACO_DIR)
|
||||
set (3RDPARTY_DRACO_DIR "" CACHE PATH "The directory containing Draco")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_DRACO_INCLUDE_DIR)
|
||||
set (3RDPARTY_DRACO_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the Draco")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY OR NOT 3RDPARTY_DRACO_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}")
|
||||
set (3RDPARTY_DRACO_LIBRARY "" CACHE FILEPATH "Draco library" FORCE)
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED 3RDPARTY_DRACO_LIBRARY_DIR)
|
||||
set (3RDPARTY_DRACO_LIBRARY_DIR "" CACHE PATH "The directory containing Draco library")
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
|
||||
if (NOT 3RDPARTY_DRACO_DIR OR NOT EXISTS "${3RDPARTY_DRACO_DIR}")
|
||||
FIND_PRODUCT_DIR("${3RDPARTY_DIR}" draco DRACO_DIR_NAME)
|
||||
if (DRACO_DIR_NAME)
|
||||
set (3RDPARTY_DRACO_DIR "${3RDPARTY_DIR}/${DRACO_DIR_NAME}" CACHE PATH "The directory containing Draco" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}")
|
||||
set (DRACO_INCLUDE_PATH "${3RDPARTY_DRACO_DIR}/include")
|
||||
set (DRACO_LIBRARY_PATH "${3RDPARTY_DRACO_DIR}/lib")
|
||||
endif()
|
||||
|
||||
if (NOT 3RDPARTY_DRACO_INCLUDE_DIR)
|
||||
if (DRACO_INCLUDE_PATH AND EXISTS "${DRACO_INCLUDE_PATH}")
|
||||
set (3RDPARTY_DRACO_INCLUDE_DIR "${DRACO_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of DRACO" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT 3RDPARTY_DRACO_LIBRARY_DIR)
|
||||
if (DRACO_LIBRARY_PATH AND EXISTS "${DRACO_LIBRARY_PATH}")
|
||||
set (3RDPARTY_DRACO_LIBRARY_DIR "${DRACO_LIBRARY_PATH}" CACHE FILEPATH "The directory containing DRACO library" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DRACO_INCLUDE_DIR AND EXISTS "${3RDPARTY_DRACO_INCLUDE_DIR}")
|
||||
list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_DRACO_INCLUDE_DIR}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_DRACO_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DRACO_DIR AND EXISTS "${3RDPARTY_DRACO_DIR}")
|
||||
if (NOT 3RDPARTY_DRACO_LIBRARY OR NOT EXISTS "${3RDPARTY_DRACO_LIBRARY}")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib .a)
|
||||
set (3RDPARTY_DRACO_LIBRARY "3RDPARTY_DRACO_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to Draco library" FORCE)
|
||||
|
||||
find_library (3RDPARTY_DRACO_LIBRARY NAMES ${CSF_Draco}
|
||||
PATHS "${3RDPARTY_DRACO_LIBRARY_DIR}"
|
||||
PATH_SUFFIXES lib
|
||||
CMAKE_FIND_ROOT_PATH_BOTH
|
||||
NO_DEFAULT_PATH)
|
||||
if (3RDPARTY_DRACO_LIBRARY AND EXISTS "${3RDPARTY_DRACO_LIBRARY}")
|
||||
get_filename_component (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY}" PATH)
|
||||
set (3RDPARTY_DRACO_LIBRARY_DIR "${3RDPARTY_DRACO_LIBRARY_DIR}" CACHE FILEPATH "The directory containing Draco library" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (3RDPARTY_DRACO_LIBRARY_DIR AND EXISTS "${3RDPARTY_DRACO_LIBRARY_DIR}")
|
||||
list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_DRACO_LIBRARY_DIR}")
|
||||
else()
|
||||
list (APPEND 3RDPARTY_NO_LIBS 3RDPARTY_DRACO_LIBRARY_DIR)
|
||||
endif()
|
||||
|
||||
if (INSTALL_DRACO)
|
||||
get_filename_component(3RDPARTY_DRACO_LIBRARY_REALPATH ${3RDPARTY_DRACO_LIBRARY} REALPATH)
|
||||
if (SINGLE_GENERATOR)
|
||||
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR_LIB}")
|
||||
else()
|
||||
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
|
||||
CONFIGURATIONS Release
|
||||
DESTINATION "${INSTALL_DIR_LIB}")
|
||||
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
|
||||
CONFIGURATIONS RelWithDebInfo
|
||||
DESTINATION "${INSTALL_DIR_LIB}i")
|
||||
install (FILES ${3RDPARTY_DRACO_LIBRARY_REALPATH}
|
||||
CONFIGURATIONS Debug
|
||||
DESTINATION "${INSTALL_DIR_LIB}d")
|
||||
endif()
|
||||
endif()
|
||||
THIRDPARTY_PRODUCT("DRACO" "draco/compression/decode.h" "CSF_Draco" "")
|
||||
|
@@ -119,8 +119,6 @@ android-g++ {
|
||||
# VS2015, vc141
|
||||
} else:equals(aMsvcVer, 16.0){
|
||||
# VS2019, vc142
|
||||
} else:equals(aMsvcVer, 17.0){
|
||||
# VS2022, vc143
|
||||
} else {
|
||||
warning (Unknown msvc version. "$$MY_COMPILER" is used)
|
||||
}
|
||||
|
@@ -23,8 +23,6 @@ if "%VCVER%" == "vc8" (
|
||||
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else if "%VCVER%" == "vc142" (
|
||||
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else if "%VCVER%" == "vc143" (
|
||||
call "%VS143COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else (
|
||||
echo Error: wrong VS identifier
|
||||
exit /B
|
||||
|
@@ -74,10 +74,6 @@ if not "%DevEnvDir%" == "" (
|
||||
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
|
||||
set "DevEnvDir=%%i\Common7\IDE\"
|
||||
)
|
||||
) else if /I "%VCFMT%" == "vc143" (
|
||||
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[17.0,17.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
|
||||
set "DevEnvDir=%%i\Common7\IDE\"
|
||||
)
|
||||
) else if /I "%VCFMT%" == "gcc" (
|
||||
rem MinGW
|
||||
) else (
|
||||
@@ -111,11 +107,6 @@ if /I "%VCFMT%" == "vc9" (
|
||||
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
)
|
||||
set "VCPlatformToolSet=v142"
|
||||
) else if /I "%VCFMT%" == "vc143" (
|
||||
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[17.0,17.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
|
||||
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
|
||||
)
|
||||
set "VCPlatformToolSet=v142"
|
||||
) else if /I "%VCFMT%" == "gcc" (
|
||||
rem MinGW
|
||||
) else (
|
||||
@@ -135,7 +126,6 @@ if ["%ARCH%"] == ["64"] set VCARCH=amd64
|
||||
|
||||
if /I ["%1"] == ["vc141"] set "VCVER=vc14"
|
||||
if /I ["%1"] == ["vc142"] set "VCVER=vc14"
|
||||
if /I ["%1"] == ["vc143"] set "VCVER=vc14"
|
||||
|
||||
if exist "%CASROOT%\custom.bat" (
|
||||
call "%CASROOT%\custom.bat" %VCVER% %ARCH% %CASDEB%
|
||||
|
@@ -7,7 +7,6 @@ if exist "%~dp0custom.bat" (
|
||||
call "@INSTALL_DIR_ABSOLUTE@\@INSTALL_DIR_SCRIPT@\env.bat" %1 %2 %3
|
||||
if /I ["%1"] == ["vc141"] set "VCVER=vc141"
|
||||
if /I ["%1"] == ["vc142"] set "VCVER=vc142"
|
||||
if /I ["%1"] == ["vc143"] set "VCVER=vc143"
|
||||
set "BIN_DIR=win%ARCH%\%VCVER%\bind"
|
||||
set "LIB_DIR=win%ARCH%\%VCVER%\libd"
|
||||
|
||||
|
@@ -23,8 +23,6 @@ if "%VCVER%" == "vc8" (
|
||||
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else if "%VCVER%" == "vc142" (
|
||||
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else if "%VCVER%" == "vc143" (
|
||||
call "%VS143COMNTOOLS%/vsvars32.bat" > nul
|
||||
) else (
|
||||
echo Error: wrong VS identifier
|
||||
exit /B
|
||||
|
@@ -324,7 +324,6 @@ The environment is defined in the file *custom.sh* (on Linux and macOS) or *cust
|
||||
| vc141-uwp | 2017 (15) | UWP (Universal Windows Platform) | vc14-uwp |
|
||||
| vc142 | 2019 (16) | Desktop (Windows API) | vc14 |
|
||||
| vc142-uwp | 2019 (16) | UWP (Universal Windows Platform) | vc14-uwp |
|
||||
| vc143 | 2022 (17) | Desktop (Windows API) | vc14 |
|
||||
|
||||
Alternatively, you can launch **genconf**, a GUI tool allowing to configure build options interactively.
|
||||
That tool will analyze your environment and propose you to choose available options:
|
||||
|
@@ -462,7 +462,7 @@ To run any Open CASCADE Technology application you need to set the environment v
|
||||
|
||||
You can define the environment variables with env.bat script located in the
|
||||
$CASROOT folder. This script accepts two arguments to be used:
|
||||
the version of Visual Studio (vc12 -- vc143) and the architecture (win32 or win64).
|
||||
the version of Visual Studio (vc12 -- vc142) and the architecture (win32 or win64).
|
||||
|
||||
The additional environment settings necessary for compiling OCCT libraries and samples
|
||||
by Microsoft Visual Studio can be set using script custom.bat located in the same folder.
|
||||
|
@@ -2044,47 +2044,43 @@ Creates a *MeshVS_Mesh* object based on STL file data. The object will be displa
|
||||
meshfromstl mesh myfile.stl
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_draw_4_5_2 vsetdispmode
|
||||
@subsubsection occt_draw_4_5_2 meshdispmode
|
||||
|
||||
Syntax:
|
||||
~~~~{.php}
|
||||
vsetdispmode meshname displaymode
|
||||
meshdispmode meshname displaymode
|
||||
~~~~
|
||||
|
||||
Changes the display mode of object **meshname**. The **displaymode** is integer (`MeshVS_DisplayModeFlags`), which can be:
|
||||
* *1* for *wireframe*,
|
||||
Changes the display mode of object **meshname**. The **displaymode** is integer, which can be:
|
||||
* *1* for *wireframe*,
|
||||
* *2* for *shading* mode, or
|
||||
* *3* for *shrink* mode.
|
||||
* *3* for *shrink* mode.
|
||||
|
||||
**Example:**
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vsetdispmode mesh 2
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshdispmode mesh 2
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_draw_4_5_3 vselmode
|
||||
@subsubsection occt_draw_4_5_3 meshselmode
|
||||
|
||||
Syntax:
|
||||
~~~~{.php}
|
||||
vselmode meshname selectionmode {on|off}
|
||||
meshselmode meshname selectionmode
|
||||
~~~~
|
||||
|
||||
Changes the selection mode of object **meshname**.
|
||||
The *selectionmode* is integer OR-combination of mode flags (`MeshVS_SelectionModeFlags`). The basic flags are the following:
|
||||
* *0* -- selection of mesh as whole;
|
||||
Changes the selection mode of object **meshname**. The *selectionmode* is integer OR-combination of mode flags. The basic flags are the following:
|
||||
* *1* -- node selection;
|
||||
* *2* -- 0D elements (not supported in STL);
|
||||
* *4* -- links (not supported in STL);
|
||||
* *8* -- faces;
|
||||
* *16* -- volumes (not supported in STL);
|
||||
* *256* -- groups (not supported in STL).
|
||||
|
||||
**Example:**
|
||||
* *2* -- 0D elements (not supported in STL);
|
||||
* *4* -- links (not supported in STL);
|
||||
* *8* -- faces.
|
||||
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vselmode mesh 1
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshselmode mesh 1
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_draw_4_5_4 meshshadcolor
|
||||
@@ -2095,11 +2091,11 @@ meshshadcolor meshname red green blue
|
||||
~~~~
|
||||
|
||||
Changes the face interior color of object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
|
||||
|
||||
**Example:**
|
||||
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshshadcolormode mesh 0.5 0.5 0.5
|
||||
~~~~
|
||||
|
||||
@@ -2111,11 +2107,11 @@ meshlinkcolor meshname red green blue
|
||||
~~~~
|
||||
|
||||
Changes the color of face borders for object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
|
||||
|
||||
**Example:**
|
||||
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshlinkcolormode mesh 0.5 0.5 0.5
|
||||
~~~~
|
||||
|
||||
@@ -2123,37 +2119,39 @@ meshlinkcolormode mesh 0.5 0.5 0.5
|
||||
|
||||
Syntax:
|
||||
~~~~{.php}
|
||||
meshmat meshname material [transparency]
|
||||
meshmat meshname material
|
||||
~~~~
|
||||
|
||||
Changes the material of object **meshname**.
|
||||
|
||||
*material* is represented with an integer value as follows (equivalent to enumeration *Graphic3d_NameOfMaterial*):
|
||||
* *0 -- BRASS*,
|
||||
* *1 -- BRONZE*,
|
||||
* *2 -- COPPER*,
|
||||
* *3 -- GOLD*,
|
||||
* *4 -- PEWTER*,
|
||||
* *5 -- PLASTER*,
|
||||
* *6 -- PLASTIC*,
|
||||
* *7 -- SILVER*,
|
||||
* *8 -- STEEL*,
|
||||
* *9 -- STONE*,
|
||||
* *10 -- SHINY_PLASTIC*,
|
||||
* *11 -- SATIN*,
|
||||
* *12 -- METALIZED*,
|
||||
* *13 -- NEON_GNC*,
|
||||
* *14 -- CHROME*,
|
||||
* *15 -- ALUMINIUM*,
|
||||
* *16 -- OBSIDIAN*,
|
||||
* *17 -- NEON_PHC*,
|
||||
* *18 -- JADE*.
|
||||
*material* is represented with an integer value as follows (equivalent to enumeration *Graphic3d_NameOfMaterial*):
|
||||
* *0 -- BRASS,*
|
||||
* *1 -- BRONZE,*
|
||||
* *2 -- COPPER,*
|
||||
* *3 -- GOLD,*
|
||||
* *4 -- PEWTER,*
|
||||
* *5 -- PLASTER,*
|
||||
* *6 -- PLASTIC,*
|
||||
* *7 -- SILVER,*
|
||||
* *8 -- STEEL,*
|
||||
* *9 -- STONE,*
|
||||
* *10 -- SHINY_PLASTIC,*
|
||||
* *11 -- SATIN,*
|
||||
* *12 -- METALIZED,*
|
||||
* *13 -- NEON_GNC,*
|
||||
* *14 -- CHROME,*
|
||||
* *15 -- ALUMINIUM,*
|
||||
* *16 -- OBSIDIAN,*
|
||||
* *17 -- NEON_PHC,*
|
||||
* *18 -- JADE,*
|
||||
* *19 -- DEFAULT,*
|
||||
* *20 -- UserDefined*
|
||||
|
||||
**Example:**
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshmat mesh 18
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshmat mesh JADE
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_draw_4_5_7 meshshrcoef
|
||||
@@ -2163,14 +2161,12 @@ Syntax:
|
||||
meshshrcoef meshname shrinkcoefficient
|
||||
~~~~
|
||||
|
||||
Changes the value of shrink coefficient used in the shrink mode.
|
||||
In the shrink mode the face is shown as a congruent part of a usual face, so that *shrinkcoefficient* controls the value of this part.
|
||||
The *shrinkcoefficient* is a positive real number.
|
||||
|
||||
**Example:**
|
||||
Changes the value of shrink coefficient used in the shrink mode. In the shrink mode the face is shown as a congruent part of a usual face, so that *shrinkcoefficient* controls the value of this part. The *shrinkcoefficient* is a positive real number.
|
||||
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshshrcoef mesh 0.05
|
||||
~~~~
|
||||
|
||||
@@ -2182,12 +2178,11 @@ meshshow meshname
|
||||
~~~~
|
||||
|
||||
Displays **meshname** in the viewer (if it is erased).
|
||||
The same as calling `vdisplay`.
|
||||
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshshow mesh
|
||||
~~~~
|
||||
|
||||
@@ -2198,13 +2193,12 @@ Syntax:
|
||||
meshhide meshname
|
||||
~~~~
|
||||
|
||||
Hides **meshname** in the viewer.
|
||||
The same as calling `verase`.
|
||||
Hides **meshname** in the viewer.
|
||||
|
||||
**Example:**
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshhide mesh
|
||||
~~~~
|
||||
|
||||
@@ -2215,7 +2209,7 @@ Syntax:
|
||||
meshhidesel meshname
|
||||
~~~~
|
||||
|
||||
Hides only selected entities. The other part of **meshname** remains visible.
|
||||
Hides only selected entities. The other part of **meshname** remains visible.
|
||||
|
||||
@subsubsection occt_draw_4_5_11 meshshowsel
|
||||
|
||||
@@ -2224,7 +2218,7 @@ Syntax:
|
||||
meshshowsel meshname
|
||||
~~~~
|
||||
|
||||
Shows only selected entities. The other part of **meshname** becomes invisible.
|
||||
Shows only selected entities. The other part of **meshname** becomes invisible.
|
||||
|
||||
@subsubsection occt_draw_4_5_12 meshshowall
|
||||
|
||||
@@ -2233,22 +2227,22 @@ Syntax:
|
||||
meshshowall meshname
|
||||
~~~~
|
||||
|
||||
Changes the state of all entities to visible for **meshname**.
|
||||
Changes the state of all entities to visible for **meshname**.
|
||||
|
||||
@subsubsection occt_draw_4_5_13 vremove
|
||||
@subsubsection occt_draw_4_5_13 meshdelete
|
||||
|
||||
Syntax:
|
||||
~~~~{.php}
|
||||
vremove meshname
|
||||
meshdelete meshname
|
||||
~~~~
|
||||
|
||||
Deletes MeshVS_Mesh object **meshname**.
|
||||
Deletes MeshVS_Mesh object **meshname**.
|
||||
|
||||
**Example:**
|
||||
**Example:**
|
||||
~~~~{.php}
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
vremove mesh
|
||||
vinit
|
||||
meshfromstl mesh myfile.stl
|
||||
meshdelete mesh
|
||||
~~~~
|
||||
|
||||
@subsection occt_draw_4_6 VIS Viewer commands
|
||||
|
@@ -338,8 +338,7 @@ The <i>GeomConvert</i> package also provides the following:
|
||||
* a splitting algorithm, which determines the curves along which a BSpline surface should be cut in order to obtain patches with the same degree of continuity,
|
||||
* global functions to construct BSpline surfaces created by this splitting algorithm, or by other types of BSpline surface segmentation,
|
||||
* an algorithm, which converts a BSpline surface into a series of adjacent Bezier surfaces,
|
||||
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
|
||||
* algorithms that converts NURBS, Bezier and other general parametrized curves and surface into anaytical curves and surfaces.
|
||||
* an algorithm, which converts a grid of adjacent Bezier surfaces into a BSpline surface.
|
||||
|
||||
@subsection occt_modat_1_4 Points on Curves
|
||||
|
||||
|
@@ -1007,25 +1007,6 @@ Standard_Integer aNbOffsetSurfaces = aCheckContents.NbOffsetSurf();
|
||||
Handle(TopTools_HSequenceOfShape) aSeqFaces = aCheckContents.OffsetSurfaceSec();
|
||||
~~~~
|
||||
|
||||
@subsubsection occt_shg_3_2_4 Analysis of shape underlined geometry
|
||||
|
||||
Class *ShapeAnalysis_CanonicalRecognition* provides tools that analyze geometry of shape and explore the possibility of converting geometry into a canonical form.
|
||||
Canonical forms for curves are lines, circles and ellipses.
|
||||
Canonical forms for surfaces are planar, cylindrical, conical and spherical surfaces.
|
||||
|
||||
Recognition and converting into canonical form is performed according to maximal deviation criterium: maximal distance between initial and canonical geometrical objects must be less, than given value.
|
||||
|
||||
Analysis of curves is allowed for following shapes:
|
||||
* edge - algorithm checks 3d curve of edge
|
||||
* wire - algorithm checks 3d curves of all edges in order to convert them in the same analytical curve
|
||||
|
||||
Analysis of surfaces is allowed for following shapes:
|
||||
* face - algorithm checks surface of face
|
||||
* shell - algorithm checks surfaces of all faces in order to convert them in the same analytical surface
|
||||
* edge - algorithm checks all surfaces that are shared by given edge in order convert one of them in analytical surface, which most close to the input sample surface.
|
||||
* wire - the same as for edge, but algorithm checks all edges of wire in order to find analytical surface, which most close to the input sample surface.
|
||||
|
||||
|
||||
@section occt_shg_4 Upgrading
|
||||
|
||||
Upgrading tools are intended for adaptation of shapes for better use by Open CASCADE Technology or for customization to particular needs, i.e. for export to another system.
|
||||
|
@@ -94,7 +94,6 @@ The types of STEP representation entities that are recognized are:
|
||||
* geometrically_bounded_wireframe_shape_representation
|
||||
* geometrically_bounded_surface_shape_representation
|
||||
* hybrid representations (shape_representation containing models of different type)
|
||||
* tessellated_shape_representation
|
||||
|
||||
@subsubsection occt_step_2_2_3 Topological entities
|
||||
The types of STEP topological entities that can be translated are:
|
||||
@@ -113,7 +112,6 @@ The types of STEP geometrical entities that can be translated are:
|
||||
* directions
|
||||
* curves
|
||||
* surfaces
|
||||
* triangulations
|
||||
|
||||
For further information see 2.4 Mapping STEP entities to Open CASCADE Technology shapes.
|
||||
|
||||
@@ -339,7 +337,7 @@ Specifies preferred type of representation of the shape of the product, in case
|
||||
* 4 (GBSSR) -- Prefer GEOMETRICALLY_BOUNDED_SURFACE_SHAPE_REPRESENTATION
|
||||
* 5 (FBSR) -- Prefer FACETTED_BREP_SHAPE_REPRESENTATION
|
||||
* 6 (EBWSR) -- Prefer EDGE_BASED_WIREFRAME_SHAPE_REPRESENTATION
|
||||
* 7 (GBWSR) -- Prefer GEOMETRICALLY_BOUNDED_WIREFRAME_SHAPE_REPRESENTATION
|
||||
* 7 (GBWSR) -- Prefer GEOMETRICALLY_BOUNDED_WIREFRAME _SHAPE_REPRESENTATION
|
||||
|
||||
When this option is not equal to 1, for products with multiple representations the representation having a type closest to the selected one in this list will be translated.
|
||||
|
||||
@@ -449,34 +447,6 @@ of for each of the two "AXIS2_PLACEMENT_3D" entities referenced by it. as follow
|
||||
}
|
||||
~~~~
|
||||
|
||||
<h4>read.step.tessellated:</h4>
|
||||
|
||||
Boolean flag regulating translation of entities that define tessellated geometry:
|
||||
|
||||
* TESSELLATED_SHAPE_REPRESENTATION
|
||||
* TESSELLATED_SHELL
|
||||
* TESSELLATED_SOLID
|
||||
* TRIANGULATED_FACE
|
||||
* COMPLEX_TRIANGULATED_FACE
|
||||
|
||||
Tesselated geometry is attached to shapes as objects of <i>Poly_Triangulation</i> type using STEP links.
|
||||
|
||||
* 0 (Off) -- do not translate
|
||||
* 1 (On) -- translate
|
||||
* 2 (OnNoBRep) - tessellation is read only for entities for which there is no BRep representation
|
||||
|
||||
Read this parameter with:
|
||||
~~~~{.cpp}
|
||||
Standard_Integer ic = Interface_Static::IVal("read.step.tessellated");
|
||||
~~~~
|
||||
|
||||
Modify this parameter with:
|
||||
~~~~{.cpp}
|
||||
if(!Interface_Static::SetIVal("read.step.tessellated",1))
|
||||
.. error ..
|
||||
~~~~
|
||||
Default value is 0 (On).
|
||||
|
||||
@subsubsection occt_step_2_3_4 Performing the STEP file translation
|
||||
|
||||
Perform the translation according to what you want to translate. You can choose either root entities (all or selected by the number of root), or select any entity by its number in the STEP file. There is a limited set of types of entities that can be used as starting entities for translation. Only the following entities are recognized as transferable:
|
||||
@@ -494,11 +464,6 @@ Perform the translation according to what you want to translate. You can choose
|
||||
* subtypes of face_surface (including advanced_face)
|
||||
* subtypes of shape_representation_relationship
|
||||
* context_dependent_shape_representation
|
||||
* tessellated_shape_representation
|
||||
* tessellated_shell
|
||||
* tessellated_solid
|
||||
* triangulated_face
|
||||
* complex_triangulated_face
|
||||
|
||||
The following methods are used for translation:
|
||||
|
||||
@@ -718,10 +683,6 @@ Not all entities defining the assembly structure in the STEP file are translated
|
||||
| | quasi_uniform_surface | Geom_BSplineSurface | |
|
||||
| | rectangular_composite_surface | TopoDS_Compound | Contains *TopoDS_Faces* |
|
||||
| | curve_bounded_surface | TopoDS_Face | |
|
||||
| Tessellations | tessellated_shell | TopoDS_Shell | |
|
||||
| | tessellated_solid | TopoDS_Solid | |
|
||||
| | triangulated_face | TopoDS_Face | Contains *Poly_Triangulation* |
|
||||
| | complex_triangulated_face | TopoDS_Face | Contains *Poly_Triangulation* |
|
||||
|
||||
|
||||
@subsection occt_step_2_5 Tolerance management
|
||||
@@ -784,7 +745,6 @@ The following default tolerances are used when creating shapes and how they are
|
||||
* *StepToTopoDS_TranslatePolyLoop* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *StepToTopoDS_TranslateEdge*. Their tolerances are not modified inside this method.
|
||||
* *StepToTopoDS_TranslateFace* constructs *TopoDS_Face* with the initial value of tolerance. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of classes *StepToTopoDS_TranslatePolyLoop, StepToTopoDS_TranslateEdgeLoop* or *StepToTopoDS_TranslateVertexLoop*.
|
||||
* *StepToTopoDS_TranslateShell* calls *StepToTopoDS_TranslateFace::Init* for each face. This class does not modify the tolerance value.
|
||||
* *StepToTopoDS_TranslateSolid* calls *StepToTopoDS_TranslateFace::Init* for each face. This class does not modify the tolerance value.
|
||||
* *StepToTopoDS_TranslateCompositeCurve* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *BRepAPI_MakeEdge* and have a tolerance 10-7. Pcurves from a STEP file are translated if they are present and if *read.surfacecurve.mode* is not -3. The connection between segments of a composite curve (edges in the wire) is provided by calling method *ShapeFix_Wire::FixConnected()\** with a precision equal to the initial value of tolerance.
|
||||
* *StepToTopoDS_TranslateCurveBoundedSurface* constructs *TopoDS_Face* with tolerance *Precision::Confusion()*. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of class *StepToTopoDS_TranslateCompositeCurve*. Missing pcurves are computed using projection algorithm with the help of method *ShapeFix_Face::FixPcurves()*. For resulting face method *ShapeFix::SameParameter()* is called. It calls standard *BRepLib::SameParameter* for each edge in each wire, which can either increase or decrease the tolerances of the edges and vertices. *SameParameter* writes the tolerance corresponding to the real deviation of pcurves from 3D curve which can be less or greater than the tolerance in a STEP file.
|
||||
* *StepToTopoDS_Builder* a high level class. Its methods perform translation with the help of the classes listed above. If the value of *read.maxprecision.mode* is set to 1 then the tolerance of subshapes of the resulting shape is limited by 0 and *read.maxprecision.val*. Else this class does not change the tolerance value.
|
||||
@@ -1011,34 +971,6 @@ if(!Interface_Static::SetIVal("write.step.vertex.mode",1))
|
||||
~~~~
|
||||
Default value is 0.
|
||||
|
||||
<h4>write.step.tessellated:</h4>
|
||||
|
||||
Boolean flag regulating writing of entities that define tessellated geometry:
|
||||
|
||||
* TESSELLATED_SHAPE_REPRESENTATION
|
||||
* TESSELLATED_SHELL
|
||||
* TESSELLATED_SOLID
|
||||
* TRIANGULATED_FACE
|
||||
|
||||
Tesselated geometry is taken as objects of <i>Poly_Triangulation type</i> from the active <i>TopoDS_Face</i> triangulation.
|
||||
|
||||
* 0 (Off) -- do not write
|
||||
* 1 (On) -- write
|
||||
* 2 (OnNoBRep) - tessellation is written only for entities for which there is no BRep representation
|
||||
|
||||
Read this parameter with:
|
||||
~~~~{.cpp}
|
||||
Standard_Integer ic = Interface_Static::IVal("write.step.tessellated");
|
||||
~~~~
|
||||
|
||||
Modify this parameter with:
|
||||
~~~~{.cpp}
|
||||
if(!Interface_Static::SetIVal("write.step.tessellated",1))
|
||||
.. error ..
|
||||
~~~~
|
||||
|
||||
Default value is 2 (OnNoBep).
|
||||
|
||||
@subsubsection occt_step_3_3_3 Performing the Open CASCADE Technology shape translation
|
||||
An OCCT shape can be translated to STEP using one of the following models (shape_representations):
|
||||
* manifold_solid_brep (advanced_brep_shape_representation)
|
||||
@@ -1162,7 +1094,6 @@ The table below describes STEP entities, which are created when the assembly str
|
||||
| | Geom_ToroidalSurface | toroidal_surface or degenerate_toroidal_surface | *degenerate_toroidal_surface* is produced if the minor radius is greater then the major one |
|
||||
| | Geom_BezierSurface | b_spline_surface_with_knots | |
|
||||
| | Geom_BsplineSurface | b_spline_surface_with_knots or rational_b_spline_surface | *rational_b_spline_surface* is produced if *Geom_BSplineSurface* is a rational Bspline |
|
||||
| Triangulations | Poly_Triangulation | *triangulated_face* is produced for face active triangulation | |
|
||||
|
||||
|
||||
@subsection occt_step_3_5 Tolerance management
|
||||
|
@@ -7,7 +7,6 @@ if exist "%~dp0custom.bat" (
|
||||
call "%CASROOT%\env.bat" %1 %2 %3
|
||||
if /I ["%1"] == ["vc141"] set "VCVER=vc141"
|
||||
if /I ["%1"] == ["vc142"] set "VCVER=vc142"
|
||||
if /I ["%1"] == ["vc143"] set "VCVER=vc143"
|
||||
set "BIN_DIR=win%ARCH%\%VCVER%\bind"
|
||||
set "LIB_DIR=win%ARCH%\%VCVER%\libd"
|
||||
|
||||
|
@@ -362,7 +362,7 @@ void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ViewAffinity) anAffinity = anObjIter.Key()->ViewAffinity();
|
||||
Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key());
|
||||
const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
|
||||
if (isVisible == theIsVisibleInView)
|
||||
{
|
||||
@@ -402,9 +402,17 @@ void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ViewAffinity) anAffinity = theIObj->ViewAffinity();
|
||||
Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj);
|
||||
Handle(Graphic3d_CView) aViewImpl = theView->View();
|
||||
anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True);
|
||||
if (theIsVisible)
|
||||
{
|
||||
theView->View()->ChangeHiddenObjects()->Remove (theIObj.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
theView->View()->ChangeHiddenObjects()->Add (theIObj.get());
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -437,8 +445,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
|
||||
if (!myObjects.IsBound (theIObj))
|
||||
{
|
||||
setObjectStatus (theIObj, PrsMgr_DisplayStatus_Displayed, theDispMode, theSelectionMode);
|
||||
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
|
||||
myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity());
|
||||
myMainVwr->StructureManager()->RegisterObject (theIObj);
|
||||
myMainPM->Display(theIObj, theDispMode);
|
||||
if (theSelectionMode != -1)
|
||||
{
|
||||
@@ -514,8 +521,7 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
|
||||
Standard_Integer aDispMode, aHiMod, aSelModeDef;
|
||||
GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
|
||||
setObjectStatus (theIObj, PrsMgr_DisplayStatus_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef);
|
||||
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
|
||||
myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity());
|
||||
myMainVwr->StructureManager()->RegisterObject (theIObj);
|
||||
}
|
||||
|
||||
// Register theIObj in the selection manager to prepare further activation of selection
|
||||
@@ -1894,9 +1900,13 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
||||
mgrSelector->Remove (anObj);
|
||||
|
||||
setObjectStatus (theIObj, PrsMgr_DisplayStatus_None, -1, -1);
|
||||
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
|
||||
myMainVwr->StructureManager()->UnregisterObject (theIObj);
|
||||
|
||||
for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next())
|
||||
{
|
||||
aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
|
||||
}
|
||||
|
||||
if (!myLastPicked.IsNull())
|
||||
{
|
||||
if (myLastPicked->IsSameSelectable (theIObj))
|
||||
@@ -2204,11 +2214,10 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
|
||||
//function : BoundingBoxOfSelection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection (const Handle(V3d_View)& theView) const
|
||||
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
|
||||
{
|
||||
Bnd_Box aBndSelected;
|
||||
AIS_MapOfObjectOwners anObjectOwnerMap;
|
||||
const Standard_Integer aViewId = !theView.IsNull() ? theView->View()->Identification() : -1;
|
||||
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
|
||||
{
|
||||
const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
|
||||
@@ -2218,13 +2227,6 @@ Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection (const Handle(V3d_View)&
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(Graphic3d_ViewAffinity) anAffinity = anObj->ViewAffinity();
|
||||
const Standard_Boolean isVisible = aViewId == -1 || anAffinity->IsVisible (aViewId);
|
||||
if (!isVisible)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (anOwner == anObj->GlobalSelOwner())
|
||||
{
|
||||
Bnd_Box aTmpBnd;
|
||||
@@ -2262,7 +2264,7 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
|
||||
const Standard_Real theMargin,
|
||||
const Standard_Boolean theToUpdate)
|
||||
{
|
||||
Bnd_Box aBndSelected = BoundingBoxOfSelection (theView);
|
||||
Bnd_Box aBndSelected = BoundingBoxOfSelection();
|
||||
if (!aBndSelected.IsVoid())
|
||||
{
|
||||
theView->FitAll (aBndSelected, theMargin, theToUpdate);
|
||||
@@ -2672,10 +2674,12 @@ AIS_StatusOfDetection AIS_InteractiveContext::moveTo (const Handle(V3d_View)& th
|
||||
myDetectedSeq.Clear();
|
||||
myLastActiveView = theView.get();
|
||||
|
||||
// preliminaries
|
||||
// preliminaires
|
||||
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
|
||||
Standard_Boolean toUpdateViewer = Standard_False;
|
||||
|
||||
myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
|
||||
|
||||
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
|
||||
// (the objects must be AIS_Shapes)
|
||||
const Standard_Integer aDetectedNb = MainSelector()->NbPicked();
|
||||
|
@@ -42,7 +42,6 @@
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
|
||||
class V3d_Viewer;
|
||||
@@ -503,10 +502,7 @@ public: //! @name Selection management
|
||||
Standard_EXPORT AIS_StatusOfPick SelectDetected (const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
|
||||
|
||||
//! Returns bounding box of selected objects.
|
||||
Standard_EXPORT Bnd_Box BoundingBoxOfSelection (const Handle(V3d_View)& theView) const;
|
||||
|
||||
Standard_DEPRECATED ("BoundingBoxOfSelection() should be called with View argument")
|
||||
Bnd_Box BoundingBoxOfSelection() const { return BoundingBoxOfSelection (Handle(V3d_View)()); }
|
||||
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
|
||||
|
||||
//! Sets list of owner selected/deselected using specified selection scheme.
|
||||
//! @param theOwners owners to change selection state
|
||||
|
@@ -1071,7 +1071,7 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
|
||||
return;
|
||||
}
|
||||
|
||||
aPresentation->CStructure()->ViewAffinity = myViewAffinity;
|
||||
aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
|
||||
|
||||
if (anOwner->Mode() == AIS_MM_TranslationPlane)
|
||||
{
|
||||
|
@@ -1969,7 +1969,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
|
||||
void AIS_ViewController::FitAllAuto (const Handle(AIS_InteractiveContext)& theCtx,
|
||||
const Handle(V3d_View)& theView)
|
||||
{
|
||||
const Bnd_Box aBoxSel = theCtx->BoundingBoxOfSelection (theView);
|
||||
const Bnd_Box aBoxSel = theCtx->BoundingBoxOfSelection();
|
||||
const double aFitMargin = 0.01;
|
||||
if (aBoxSel.IsVoid())
|
||||
{
|
||||
|
@@ -859,7 +859,7 @@ Standard_Boolean AIS_ViewCube::HasAnimation() const
|
||||
void AIS_ViewCube::viewFitAll (const Handle(V3d_View)& theView,
|
||||
const Handle(Graphic3d_Camera)& theCamera)
|
||||
{
|
||||
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection (theView) : theView->View()->MinMaxValues();
|
||||
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection() : theView->View()->MinMaxValues();
|
||||
if (aBndBox.IsVoid()
|
||||
&& myToFitSelected)
|
||||
{
|
||||
@@ -1016,7 +1016,7 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage
|
||||
|
||||
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation (thePrsMgr);
|
||||
aHiPrs->Clear();
|
||||
aHiPrs->CStructure()->ViewAffinity = myViewAffinity;
|
||||
aHiPrs->CStructure()->ViewAffinity = thePrsMgr->StructureManager()->ObjectAffinity (Handle(Standard_Transient)(this));
|
||||
aHiPrs->SetTransformPersistence (TransformPersistence());
|
||||
aHiPrs->SetZLayer (aLayer);
|
||||
|
||||
|
@@ -526,8 +526,6 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
|
||||
}
|
||||
myDone = Standard_True;
|
||||
}
|
||||
|
||||
myCurveOnSurface = Handle(Adaptor3d_CurveOnSurface)::DownCast(aData.myCOnS.ShallowCopy());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -81,21 +81,6 @@ public:
|
||||
return myCurve2d;
|
||||
}
|
||||
|
||||
//! Returns the 3D curve that has the same parameter as
|
||||
//! the 3D curve once evaluated on the surface up to the
|
||||
//! specified tolerance.
|
||||
Handle(Adaptor3d_Curve) Curve3d() const
|
||||
{
|
||||
return myC3d;
|
||||
}
|
||||
|
||||
//! Returns the 3D curve on surface that has the same parameter as
|
||||
//! the 3D curve up to the specified tolerance.
|
||||
Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const
|
||||
{
|
||||
return myCurveOnSurface;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Internal data structure to unify access to the most actively used data.
|
||||
@@ -191,7 +176,6 @@ private:
|
||||
Handle(Adaptor2d_Curve2d) myHCurve2d;
|
||||
Handle(Adaptor3d_Curve) myC3d;
|
||||
Handle(Adaptor3d_Surface) mySurf;
|
||||
Handle(Adaptor3d_CurveOnSurface) myCurveOnSurface;
|
||||
};
|
||||
|
||||
#endif // _Approx_SameParameter_HeaderFile
|
||||
|
@@ -15,8 +15,186 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
#include <BRepTools_Modification.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
|
||||
namespace {
|
||||
|
||||
//! Tool class implementing necessary functionality for copying geometry
|
||||
class BRepBuilderAPI_Copy_Modification : public BRepTools_Modification
|
||||
{
|
||||
public:
|
||||
BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom,
|
||||
const Standard_Boolean copyMesh)
|
||||
: myCopyGeom(copyGeom),
|
||||
myCopyMesh(copyMesh)
|
||||
{
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy face;
|
||||
//! copies surface if requested
|
||||
Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S,
|
||||
TopLoc_Location& L, Standard_Real& Tol,
|
||||
Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
RevWires = RevFace = Standard_False;
|
||||
|
||||
if ( ! S.IsNull() && myCopyGeom )
|
||||
S = Handle(Geom_Surface)::DownCast(S->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy triangulation;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (F))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location L;
|
||||
T = BRep_Tool::Triangulation(F, L);
|
||||
|
||||
if (T.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// mesh is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
T = T->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy edge;
|
||||
//! copies curves if requested
|
||||
Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C,
|
||||
TopLoc_Location& L, Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::Curve (E, L, f, l);
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
|
||||
if ( ! C.IsNull() && myCopyGeom )
|
||||
C = Handle(Geom_Curve)::DownCast(C->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy polygon;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (E))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
P = BRep_Tool::Polygon3D(E, aLoc);
|
||||
|
||||
if (P.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
P = P->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy polygon;
|
||||
//! copies it if required
|
||||
Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F,
|
||||
Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE
|
||||
{
|
||||
if (!myCopyMesh
|
||||
&& BRep_Tool::IsGeometric (E))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(F, aLoc);
|
||||
P = BRep_Tool::PolygonOnTriangulation(E, aTria, aLoc);
|
||||
|
||||
if (P.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
P = P->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy vertex
|
||||
Standard_Boolean NewPoint (const TopoDS_Vertex& V, gp_Pnt& P,
|
||||
Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
P = BRep_Tool::Pnt(V);
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy edge;
|
||||
//! copies pcurve if requested
|
||||
Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F,
|
||||
const TopoDS_Edge& /*NewE*/,
|
||||
const TopoDS_Face& /*NewF*/,
|
||||
Handle(Geom2d_Curve)& C,
|
||||
Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Standard_Real f, l;
|
||||
C = BRep_Tool::CurveOnSurface (E, F, f, l);
|
||||
|
||||
if ( ! C.IsNull() && myCopyGeom )
|
||||
C = Handle(Geom2d_Curve)::DownCast (C->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns true to indicate the need to copy vertex
|
||||
Standard_Boolean NewParameter (const TopoDS_Vertex& V, const TopoDS_Edge& E,
|
||||
Standard_Real& P, Standard_Real& Tol) Standard_OVERRIDE
|
||||
{
|
||||
if (V.IsNull()) return Standard_False; // infinite edge may have Null vertex
|
||||
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
P = BRep_Tool::Parameter (V, E);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//! Returns the continuity of E between F1 and F2
|
||||
GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2, const TopoDS_Edge&,
|
||||
const TopoDS_Face&, const TopoDS_Face&) Standard_OVERRIDE
|
||||
{
|
||||
return BRep_Tool::Continuity (E, F1, F2);
|
||||
}
|
||||
|
||||
public:
|
||||
DEFINE_STANDARD_RTTI_INLINE(BRepBuilderAPI_Copy_Modification,BRepTools_Modification)
|
||||
|
||||
private:
|
||||
Standard_Boolean myCopyGeom;
|
||||
Standard_Boolean myCopyMesh;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepBuilderAPI_Copy
|
||||
@@ -25,7 +203,7 @@
|
||||
|
||||
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
|
||||
{
|
||||
myModification = new BRepTools_CopyModification(Standard_True, Standard_False);
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(Standard_True, Standard_False);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +214,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
|
||||
|
||||
BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
|
||||
{
|
||||
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
|
||||
DoModif(S);
|
||||
}
|
||||
|
||||
@@ -48,7 +226,7 @@ BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_B
|
||||
|
||||
void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom, const Standard_Boolean copyMesh)
|
||||
{
|
||||
myModification = new BRepTools_CopyModification(copyGeom, copyMesh);
|
||||
myModification = new BRepBuilderAPI_Copy_Modification(copyGeom, copyMesh);
|
||||
NotDone(); // on force la copie si on vient deja d`en faire une
|
||||
DoModif(S);
|
||||
}
|
||||
|
@@ -1,247 +0,0 @@
|
||||
// Created on: 2022-06-30
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 2022-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepBuilderAPI_MakeShapeOnMesh.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Structure representing mesh edge.
|
||||
struct Edge
|
||||
{
|
||||
//! Constructor. Sets edge nodes.
|
||||
Edge(const Standard_Integer TheIdx1,
|
||||
const Standard_Integer TheIdx2)
|
||||
: Idx1(Min(TheIdx1, TheIdx2)),
|
||||
Idx2(Max(TheIdx1, TheIdx2))
|
||||
{}
|
||||
|
||||
//! Comparison operator.
|
||||
Standard_Boolean operator<(const Edge& other) const
|
||||
{
|
||||
if (Idx1 < other.Idx1 ||
|
||||
(Idx1 == other.Idx1 && Idx2 < other.Idx2))
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//! First index. It is lower or equal than the second.
|
||||
Standard_Integer Idx1;
|
||||
|
||||
//! Second index.
|
||||
Standard_Integer Idx2;
|
||||
};
|
||||
|
||||
//! Hasher of Edge structure.
|
||||
struct EdgeHasher
|
||||
{
|
||||
|
||||
//! Returns hash code for the given edge.
|
||||
static Standard_Integer HashCode(const Edge& theEdge,
|
||||
const Standard_Integer theUpperBound)
|
||||
{
|
||||
// Circle-based collisions.
|
||||
return ::HashCode(theEdge.Idx1 * theEdge.Idx1 + theEdge.Idx2 * theEdge.Idx2, theUpperBound);
|
||||
}
|
||||
|
||||
//! Returns true if two edges are equal.
|
||||
static Standard_Boolean IsEqual(const Edge& theEdge1,
|
||||
const Edge& theEdge2)
|
||||
{
|
||||
return theEdge1.Idx1 == theEdge2.Idx1 && theEdge1.Idx2 == theEdge2.Idx2;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepBuilderAPI_MakeShapeOnMesh::Build(const Message_ProgressRange& theRange)
|
||||
{
|
||||
// Generally, this method guarantees topology sharing by mapping mesh primitives
|
||||
// into topological counterparts.
|
||||
// mesh points -> topological vertices
|
||||
// mesh edges -> topological edges
|
||||
|
||||
// Cannot reconstruct anything from null or empty mesh.
|
||||
if (myMesh.IsNull() || myMesh->NbNodes() == 0 || myMesh->NbTriangles() == 0)
|
||||
return;
|
||||
|
||||
const Standard_Integer aNbNodes = myMesh->NbNodes();
|
||||
const Standard_Integer aNbTriangles = myMesh->NbTriangles();
|
||||
|
||||
// We are going to have three loops: iterate once over nodes and iterate twice
|
||||
// over triangles of input mesh.
|
||||
Message_ProgressScope aPS(theRange,
|
||||
"Per-facet shape construction",
|
||||
Standard_Real(aNbNodes + 2 * aNbTriangles));
|
||||
|
||||
// Build shared vertices.
|
||||
NCollection_IndexedDataMap<Standard_Integer, TopoDS_Vertex> aPnt2VertexMap;
|
||||
|
||||
for (Standard_Integer i = 1; i <= aNbNodes; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
const gp_Pnt aP = myMesh->Node(i);
|
||||
const TopoDS_Vertex aV = BRepBuilderAPI_MakeVertex(aP);
|
||||
aPnt2VertexMap.Add(i, aV);
|
||||
}
|
||||
|
||||
// Build shared edges.
|
||||
NCollection_IndexedDataMap<Edge, TopoDS_Edge, EdgeHasher> anEdgeToTEgeMap;
|
||||
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
Standard_Integer anIdx[3];
|
||||
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
|
||||
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
|
||||
|
||||
// Skip degenerated triangles.
|
||||
if (anIdx[0] == anIdx[1] || anIdx[0] == anIdx[2] || anIdx[1] == anIdx[2])
|
||||
continue;
|
||||
|
||||
const gp_Pnt aP1 = myMesh->Node(anIdx[0]);
|
||||
const gp_Pnt aP2 = myMesh->Node(anIdx[1]);
|
||||
const gp_Pnt aP3 = myMesh->Node(anIdx[2]);
|
||||
const Standard_Real aD1 = aP1.SquareDistance(aP2);
|
||||
const Standard_Real aD2 = aP1.SquareDistance(aP3);
|
||||
const Standard_Real aD3 = aP2.SquareDistance(aP3);
|
||||
if (aD1 < gp::Resolution() ||
|
||||
aD2 < gp::Resolution() ||
|
||||
aD3 < gp::Resolution())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Edges are constructed in forward order for the existing normals orientation.
|
||||
// In Poly_Triangulation, positive direction is defined as cross product:
|
||||
// (aV1, aV2) x (aV1, aV3).
|
||||
const TopoDS_Vertex& aV1 = aPnt2VertexMap.FindFromKey(anIdx[0]);
|
||||
const TopoDS_Vertex& aV2 = aPnt2VertexMap.FindFromKey(anIdx[1]);
|
||||
const TopoDS_Vertex& aV3 = aPnt2VertexMap.FindFromKey(anIdx[2]);
|
||||
|
||||
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
|
||||
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
|
||||
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
|
||||
|
||||
BRepBuilderAPI_MakeEdge aMaker1(aV1, aV2);
|
||||
BRepBuilderAPI_MakeEdge aMaker2(aV2, aV3);
|
||||
BRepBuilderAPI_MakeEdge aMaker3(aV3, aV1);
|
||||
|
||||
TopoDS_Edge aTE1 = aMaker1.Edge();
|
||||
if (anIdx[1] < anIdx[0])
|
||||
aTE1.Reverse();
|
||||
|
||||
TopoDS_Edge aTE2 = aMaker2.Edge();
|
||||
if (anIdx[2] < anIdx[1])
|
||||
aTE2.Reverse();
|
||||
|
||||
TopoDS_Edge aTE3 = aMaker3.Edge();
|
||||
if (anIdx[0] < anIdx[2])
|
||||
aTE3.Reverse();
|
||||
|
||||
anEdgeToTEgeMap.Add(aMeshEdge1, aTE1);
|
||||
anEdgeToTEgeMap.Add(aMeshEdge2, aTE2);
|
||||
anEdgeToTEgeMap.Add(aMeshEdge3, aTE3);
|
||||
}
|
||||
|
||||
// Construct planar faces using shared topology.
|
||||
TopoDS_Compound aResult;
|
||||
BRep_Builder aBB;
|
||||
aBB.MakeCompound(aResult);
|
||||
for (Standard_Integer i = 1; i <= aNbTriangles; ++i)
|
||||
{
|
||||
aPS.Next();
|
||||
if (aPS.UserBreak())
|
||||
return;
|
||||
|
||||
Standard_Integer anIdx[3];
|
||||
const Poly_Triangle& aTriangle = myMesh->Triangle(i);
|
||||
aTriangle.Get(anIdx[0], anIdx[1], anIdx[2]);
|
||||
|
||||
const Edge aMeshEdge1(anIdx[0], anIdx[1]);
|
||||
const Edge aMeshEdge2(anIdx[1], anIdx[2]);
|
||||
const Edge aMeshEdge3(anIdx[2], anIdx[0]);
|
||||
const Standard_Boolean isReversed1 = anIdx[1] < anIdx[0];
|
||||
const Standard_Boolean isReversed2 = anIdx[2] < anIdx[1];
|
||||
const Standard_Boolean isReversed3 = anIdx[0] < anIdx[2];
|
||||
|
||||
// Edges can be skipped in case of mesh defects - topologically or geometrically
|
||||
// degenerated triangles.
|
||||
const Standard_Boolean aHasAllEdges = anEdgeToTEgeMap.Contains(aMeshEdge1) &&
|
||||
anEdgeToTEgeMap.Contains(aMeshEdge2) &&
|
||||
anEdgeToTEgeMap.Contains(aMeshEdge3) ;
|
||||
if (!aHasAllEdges)
|
||||
continue;
|
||||
|
||||
TopoDS_Edge aTEdge1 = anEdgeToTEgeMap.FindFromKey(aMeshEdge1);
|
||||
if (isReversed1)
|
||||
aTEdge1.Reverse();
|
||||
TopoDS_Edge aTEdge2 = anEdgeToTEgeMap.FindFromKey(aMeshEdge2);
|
||||
if (isReversed2)
|
||||
aTEdge2.Reverse();
|
||||
TopoDS_Edge aTEdge3 = anEdgeToTEgeMap.FindFromKey(aMeshEdge3);
|
||||
if (isReversed3)
|
||||
aTEdge3.Reverse();
|
||||
|
||||
BRepBuilderAPI_MakeWire aWireMaker;
|
||||
aWireMaker.Add(aTEdge1);
|
||||
aWireMaker.Add(aTEdge2);
|
||||
aWireMaker.Add(aTEdge3);
|
||||
const TopoDS_Wire aWire = aWireMaker.Wire();
|
||||
|
||||
// Construct plane explicitly since it is faster than automatic construction
|
||||
// within BRepBuilderAPI_MakeFace.
|
||||
BRepAdaptor_Curve aC1(aTEdge1);
|
||||
BRepAdaptor_Curve aC2(aTEdge2);
|
||||
const gp_Dir aD1 = aC1.Line().Direction();
|
||||
const gp_Dir aD2 = aC2.Line().Direction();
|
||||
gp_XYZ aN = aD1.XYZ().Crossed(aD2.XYZ());
|
||||
if (aN.SquareModulus() < Precision::SquareConfusion())
|
||||
continue;
|
||||
if (aTEdge1.Orientation() == TopAbs_REVERSED)
|
||||
aN.Reverse();
|
||||
if (aTEdge2.Orientation() == TopAbs_REVERSED)
|
||||
aN.Reverse();
|
||||
const gp_Dir aNorm(aN);
|
||||
gp_Pln aPln(myMesh->Node(anIdx[0]), aNorm);
|
||||
|
||||
BRepBuilderAPI_MakeFace aFaceMaker(aPln, aWire);
|
||||
const TopoDS_Face aFace = aFaceMaker.Face();
|
||||
|
||||
aBB.Add(aResult, aFace);
|
||||
}
|
||||
|
||||
this->Done();
|
||||
myShape = aResult;
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
// Created on: 2022-06-30
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 2022-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
||||
#define _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
||||
|
||||
#include <BRepBuilderAPI_MakeShape.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
|
||||
//! Builds shape on per-facet basis on the input mesh. Resulting shape has shared
|
||||
//! edges by construction, but no maximization (unify same domain) is applied.
|
||||
//! No generation history is provided.
|
||||
class BRepBuilderAPI_MakeShapeOnMesh : public BRepBuilderAPI_MakeShape
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Ctor. Sets mesh to process.
|
||||
//! @param theMesh [in] - Mesh to construct shape for.
|
||||
BRepBuilderAPI_MakeShapeOnMesh(const Handle(Poly_Triangulation)& theMesh)
|
||||
: myMesh(theMesh)
|
||||
{}
|
||||
|
||||
//! Builds shape on mesh.
|
||||
Standard_EXPORT virtual void Build(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Handle(Poly_Triangulation) myMesh;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BRepBuilderAPI_MakeShapeOnMesh_HeaderFile
|
@@ -36,14 +36,13 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const gp_Trsf& T) :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& theShape,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theCopyGeom,
|
||||
const Standard_Boolean theCopyMesh)
|
||||
: myTrsf(theTrsf)
|
||||
BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
|
||||
const gp_Trsf& T,
|
||||
const Standard_Boolean Copy) :
|
||||
myTrsf(T)
|
||||
{
|
||||
myModification = new BRepTools_TrsfModification(theTrsf);
|
||||
Perform(theShape, theCopyGeom, theCopyMesh);
|
||||
myModification = new BRepTools_TrsfModification(T);
|
||||
Perform(S,Copy);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,21 +52,19 @@ BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& theSh
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theCopyGeom,
|
||||
const Standard_Boolean theCopyMesh)
|
||||
void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& S,
|
||||
const Standard_Boolean Copy)
|
||||
{
|
||||
myUseModif = theCopyGeom || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
|
||||
myUseModif = Copy || myTrsf.IsNegative() || (Abs(Abs(myTrsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec());
|
||||
if (myUseModif) {
|
||||
Handle(BRepTools_TrsfModification) theModif =
|
||||
Handle(BRepTools_TrsfModification)::DownCast(myModification);
|
||||
theModif->Trsf() = myTrsf;
|
||||
theModif->IsCopyMesh() = theCopyMesh;
|
||||
DoModif(theShape, myModification);
|
||||
DoModif(S,myModification);
|
||||
}
|
||||
else {
|
||||
myLocation = myTrsf;
|
||||
myShape = theShape.Moved(myLocation);
|
||||
myShape = S.Moved(myLocation);
|
||||
Done();
|
||||
}
|
||||
|
||||
|
@@ -50,37 +50,28 @@ public:
|
||||
//! to define the shape to transform.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const gp_Trsf& T);
|
||||
|
||||
//! Creates a transformation from the gp_Trsf <theTrsf>, and
|
||||
//! applies it to the shape <theShape>. If the transformation
|
||||
//! Creates a transformation from the gp_Trsf <T>, and
|
||||
//! applies it to the shape <S>. If the transformation
|
||||
//! is direct and isometric (determinant = 1) and
|
||||
//! <theCopyGeom> = Standard_False, the resulting shape is
|
||||
//! <theShape> on which a new location has been set.
|
||||
//! <Copy> = Standard_False, the resulting shape is
|
||||
//! <S> on which a new location has been set.
|
||||
//! Otherwise, the transformation is applied on a
|
||||
//! duplication of <theShape>.
|
||||
//! If <theCopyMesh> is true, the triangulation will be copied,
|
||||
//! and the copy will be assigned to the result shape.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& theShape,
|
||||
const gp_Trsf& theTrsf,
|
||||
const Standard_Boolean theCopyGeom = Standard_False,
|
||||
const Standard_Boolean theCopyMesh = Standard_False);
|
||||
//! duplication of <S>.
|
||||
Standard_EXPORT BRepBuilderAPI_Transform(const TopoDS_Shape& S, const gp_Trsf& T, const Standard_Boolean Copy = Standard_False);
|
||||
|
||||
//! Applies the geometric transformation defined at the
|
||||
//! pplies the geometric transformation defined at the
|
||||
//! time of construction of this framework to the shape S.
|
||||
//! - If the transformation T is direct and isometric, in
|
||||
//! other words, if the determinant of the vectorial part
|
||||
//! of T is equal to 1., and if theCopyGeom equals false (the
|
||||
//! of T is equal to 1., and if Copy equals false (the
|
||||
//! default value), the resulting shape is the same as
|
||||
//! the original but with a new location assigned to it.
|
||||
//! - In all other cases, the transformation is applied to a duplicate of theShape.
|
||||
//! - If theCopyMesh is true, the triangulation will be copied,
|
||||
//! and the copy will be assigned to the result shape.
|
||||
//! - In all other cases, the transformation is applied to a duplicate of S.
|
||||
//! Use the function Shape to access the result.
|
||||
//! Note: this framework can be reused to apply the same
|
||||
//! geometric transformation to other shapes. You only
|
||||
//! need to specify them by calling the function Perform again.
|
||||
Standard_EXPORT void Perform (const TopoDS_Shape& theShape,
|
||||
const Standard_Boolean theCopyGeom = Standard_False,
|
||||
const Standard_Boolean theCopyMesh = Standard_False);
|
||||
Standard_EXPORT void Perform (const TopoDS_Shape& S, const Standard_Boolean Copy = Standard_False);
|
||||
|
||||
//! Returns the modified shape corresponding to <S>.
|
||||
Standard_EXPORT virtual TopoDS_Shape ModifiedShape (const TopoDS_Shape& S) const Standard_OVERRIDE;
|
||||
|
@@ -26,8 +26,6 @@ BRepBuilderAPI_MakePolygon.cxx
|
||||
BRepBuilderAPI_MakePolygon.hxx
|
||||
BRepBuilderAPI_MakeShape.cxx
|
||||
BRepBuilderAPI_MakeShape.hxx
|
||||
BRepBuilderAPI_MakeShapeOnMesh.cxx
|
||||
BRepBuilderAPI_MakeShapeOnMesh.hxx
|
||||
BRepBuilderAPI_MakeShell.cxx
|
||||
BRepBuilderAPI_MakeShell.hxx
|
||||
BRepBuilderAPI_MakeSolid.cxx
|
||||
|
@@ -31,11 +31,13 @@
|
||||
#include <BRepCheck_ListOfStatus.hxx>
|
||||
#include <BRepCheck_Wire.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2dInt_GInter.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
@@ -114,6 +116,11 @@ static Standard_Boolean GetPnt2d(const TopoDS_Vertex &theVertex,
|
||||
const TopoDS_Edge &theEdge,
|
||||
const TopoDS_Face &theFace,
|
||||
gp_Pnt2d &aPnt);
|
||||
|
||||
static void DefinePeriods(const TopoDS_Face& theFace,
|
||||
Standard_Real& theUperiod,
|
||||
Standard_Real& theVperiod);
|
||||
|
||||
// Modified by Sergey KHROMOV - Wed May 22 10:44:08 2002 End
|
||||
|
||||
//=======================================================================
|
||||
@@ -419,12 +426,24 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
|
||||
const gp_Pnt2d& thePnt,
|
||||
const gp_Pnt2d& thePntRef,
|
||||
const Standard_Real aTol3d,
|
||||
const Standard_Boolean theIsOnSingularity,
|
||||
#ifdef OCCT_DEBUG
|
||||
const Standard_Boolean PrintWarnings = Standard_True)
|
||||
#else
|
||||
const Standard_Boolean = Standard_True)
|
||||
#endif
|
||||
{
|
||||
gp_Pnt aP;
|
||||
gp_Vec aDU, aDV;
|
||||
Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
|
||||
Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
|
||||
aFaceSurface.D1(um, vm, aP, aDU, aDV);
|
||||
Standard_Real aMDU = aDU.Magnitude();
|
||||
Standard_Real aMDV = aDV.Magnitude();
|
||||
if (!theIsOnSingularity ||
|
||||
(aMDU > Precision::Confusion() && aMDV > Precision::Confusion()))
|
||||
return Standard_True; //we are not in singularity
|
||||
|
||||
Standard_Real dumax = 0.01 * (aFaceSurface.LastUParameter() - aFaceSurface.FirstUParameter());
|
||||
Standard_Real dvmax = 0.01 * (aFaceSurface.LastVParameter() - aFaceSurface.FirstVParameter());
|
||||
Standard_Real dumin = Abs(thePnt.X() - thePntRef.X());
|
||||
@@ -453,17 +472,17 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
|
||||
#endif
|
||||
dumax = aFaceSurface.UResolution(aTol3d);
|
||||
dvmax = aFaceSurface.VResolution(aTol3d);
|
||||
gp_Pnt aP;
|
||||
gp_Vec aDU, aDV;
|
||||
Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
|
||||
Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
|
||||
aFaceSurface.D1(um, vm, aP, aDU, aDV);
|
||||
Standard_Real aMDU = aDU.Magnitude();
|
||||
//gp_Pnt aP;
|
||||
//gp_Vec aDU, aDV;
|
||||
//Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
|
||||
//Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
|
||||
//aFaceSurface.D1(um, vm, aP, aDU, aDV);
|
||||
//Standard_Real aMDU = aDU.Magnitude();
|
||||
if (aMDU > Precision::Confusion())
|
||||
{
|
||||
dumax = Max((aTol3d / aMDU), dumax);
|
||||
}
|
||||
Standard_Real aMDV = aDV.Magnitude();
|
||||
//Standard_Real aMDV = aDV.Magnitude();
|
||||
if (aMDV > Precision::Confusion())
|
||||
{
|
||||
dvmax = Max((aTol3d / aMDV), dvmax);
|
||||
@@ -676,7 +695,14 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
|
||||
gp_Pnt aPntRef = BRep_Tool::Pnt(aFirstVertex);
|
||||
gp_Pnt aPnt = BRep_Tool::Pnt(aWireExp.CurrentVertex());
|
||||
|
||||
if (!(IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d)))
|
||||
Standard_Real aUperiod = 0., aVperiod = 0.;
|
||||
DefinePeriods (theFace, aUperiod, aVperiod);
|
||||
|
||||
if ((aUperiod != 0. && Abs(aP_first.X() - aP_last.X()) > aUperiod/2) ||
|
||||
(aVperiod != 0. && Abs(aP_first.Y() - aP_last.Y()) > aVperiod/2))
|
||||
aClosedStat = BRepCheck_NotClosed;
|
||||
|
||||
if (!(IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d, Standard_True)))
|
||||
aClosedStat = BRepCheck_NotClosed;
|
||||
|
||||
if(!IsDistanceIn3DTolerance(aPntRef, aPnt, aTol3d))
|
||||
@@ -1710,10 +1736,24 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
|
||||
if (aVOrientation != anEdgOrientation)
|
||||
aDerRef.Reverse();
|
||||
|
||||
//Check if there is a seam edge in the list
|
||||
Standard_Real aUperiod = 0., aVperiod = 0.;
|
||||
DefinePeriods (theFace, aUperiod, aVperiod);
|
||||
Standard_Boolean anIsOnSingularity = Standard_False;
|
||||
for (It.Initialize(theLOfShape); It.More(); It.Next())
|
||||
{
|
||||
TopoDS_Edge anEdge = TopoDS::Edge (It.Value());
|
||||
if (BRep_Tool::Degenerated (anEdge))
|
||||
{
|
||||
anIsOnSingularity = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
It.Initialize(theLOfShape);
|
||||
|
||||
for (; It.More(); It.Next())
|
||||
{
|
||||
{
|
||||
anIndex++;
|
||||
const TopoDS_Edge& anE=TopoDS::Edge(It.Value());
|
||||
C2d = BRep_Tool::CurveOnSurface(anE, theFace, aFirstParam, aLastParam);
|
||||
@@ -1724,7 +1764,11 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
|
||||
aParam =(aVOrientation != anE.Orientation()) ? aFirstParam : aLastParam;
|
||||
aPnt = aCA.Value(aParam);
|
||||
|
||||
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, Standard_False))
|
||||
if ((aUperiod != 0. && Abs(aPnt.X() - aPntRef.X()) > aUperiod/2) ||
|
||||
(aVperiod != 0. && Abs(aPnt.Y() - aPntRef.Y()) > aVperiod/2))
|
||||
continue;
|
||||
|
||||
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, anIsOnSingularity, Standard_False))
|
||||
continue;
|
||||
|
||||
CurveDirForParameter(aCA, aParam, aPnt, aDer);
|
||||
@@ -1743,22 +1787,22 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
|
||||
anAngle += 2.*M_PI;
|
||||
|
||||
if ( theFace.Orientation() == TopAbs_FORWARD )
|
||||
{
|
||||
{
|
||||
if ( anAngle < aMinAngle )
|
||||
{
|
||||
{
|
||||
anIndMin = anIndex;
|
||||
aMinAngle = anAngle;
|
||||
}
|
||||
}
|
||||
}
|
||||
else //theFace.Orientation() != TopAbs_FORWARD
|
||||
{
|
||||
{
|
||||
if ( anAngle > aMaxAngle )
|
||||
{
|
||||
{
|
||||
anIndMin = anIndex;
|
||||
aMaxAngle = anAngle;
|
||||
}
|
||||
}
|
||||
}//end of for
|
||||
}
|
||||
}//end of for
|
||||
|
||||
// Update edge
|
||||
if (anIndMin == 0)
|
||||
@@ -1770,7 +1814,7 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
|
||||
if(anEFound.IsNull() || BRep_Tool::Degenerated(theEdge) ||
|
||||
BRep_Tool::Degenerated(anEFound))
|
||||
IsFound = Standard_False; //bad
|
||||
else if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d))
|
||||
else if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, Standard_True))
|
||||
IsFound = Standard_False; //bad
|
||||
else
|
||||
// clousureness in 3D
|
||||
@@ -1959,3 +2003,20 @@ static Standard_Boolean IsClosed2dForPeriodicFace
|
||||
return Standard_True;
|
||||
}
|
||||
// Modified by Sergey KHROMOV - Thu Jun 20 10:58:05 2002 End
|
||||
|
||||
void DefinePeriods(const TopoDS_Face& theFace,
|
||||
Standard_Real& theUperiod,
|
||||
Standard_Real& theVperiod)
|
||||
{
|
||||
theUperiod = theVperiod = 0.;
|
||||
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (theFace);
|
||||
if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
|
||||
aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface();
|
||||
Standard_Real aUmin, aUmax, aVmin, aVmax;
|
||||
aSurf->Bounds (aUmin, aUmax, aVmin, aVmax);
|
||||
if (aSurf->IsUClosed())
|
||||
theUperiod = aUmax - aUmin;
|
||||
if (aSurf->IsVClosed())
|
||||
theVperiod = aVmax - aVmin;
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Bnd_SeqOfBox.hxx>
|
||||
#include <BRepExtrema_UnCompatibleShape.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepClass3d_SolidClassifier.hxx>
|
||||
|
@@ -81,7 +81,7 @@ void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2)
|
||||
|
||||
BRepAdaptor_Curve Curv(E);
|
||||
Handle(BRepAdaptor_Curve) HC = new BRepAdaptor_Curve(Curv);
|
||||
myExtCS.Perform(*HC, U1, U2);
|
||||
myExtCS.Perform(HC->Curve(), U1, U2);
|
||||
|
||||
if(!myExtCS.IsDone())
|
||||
return;
|
||||
|
@@ -987,8 +987,8 @@ Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
|
||||
ASI1.Perform(scur);
|
||||
Standard_Integer sens = 1;
|
||||
if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) {
|
||||
if(ASI1.Point(1, 1).Parameter() + Precision::Confusion() < 0. &&
|
||||
ASI1.Point(1, ASI1.NbPoints(1)).Parameter() + Precision::Confusion() < 0.) {
|
||||
if(ASI1.Point(1, 1).Parameter() < 0. &&
|
||||
ASI1.Point(1, ASI1.NbPoints(1)).Parameter() < 0.) {
|
||||
sens = -1;
|
||||
}
|
||||
}
|
||||
|
@@ -1585,7 +1585,7 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
NbSamples = 4;
|
||||
gp_Pln FirstPlane;
|
||||
PlaneOfWire(TopoDS::Wire(myWork(ideb)), FirstPlane);
|
||||
gp_Pnt PrevBary = FirstPlane.Location();
|
||||
gp_Pnt FirstBary = FirstPlane.Location();
|
||||
gp_Vec NormalOfFirstPlane = FirstPlane.Axis().Direction();
|
||||
for (i = ideb+1; i <= ifin; i++)
|
||||
{
|
||||
@@ -1596,10 +1596,10 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
gp_Pln CurPlane;
|
||||
PlaneOfWire(aWire, CurPlane);
|
||||
gp_Pnt CurBary = CurPlane.Location();
|
||||
gp_Vec aVec(PrevBary, CurBary);
|
||||
gp_Vec aVec(FirstBary, CurBary);
|
||||
gp_Vec anOffsetProj = (aVec * NormalOfFirstPlane) * NormalOfFirstPlane;
|
||||
CurBary.Translate(-anOffsetProj); //projected current bary center
|
||||
gp_Vec Offset(CurBary, PrevBary);
|
||||
gp_Vec Offset(CurBary, FirstBary);
|
||||
|
||||
TopoDS_Wire newwire;
|
||||
BRep_Builder BB;
|
||||
@@ -1804,8 +1804,6 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
|
||||
newwire.Closed( Standard_True );
|
||||
newwire.Orientation( TopAbs_FORWARD );
|
||||
myWork(i) = newwire;
|
||||
|
||||
PrevBary = CurBary;
|
||||
}
|
||||
#ifdef OCCT_DEBUG_EFV
|
||||
|
||||
|
@@ -85,7 +85,6 @@
|
||||
#include <TopTools_HArray2OfShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <GeomLib_CheckCurveOnSurface.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
//#include <BRepFill_TrimCorner.hxx>
|
||||
@@ -290,34 +289,6 @@ static Standard_Boolean CheckSameParameter
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CheckSameParameterExact
|
||||
//purpose : Check a posteriori that sameparameter has worked correctly
|
||||
// with exact calculation method of edge tolerance
|
||||
//=======================================================================
|
||||
static Standard_Boolean CheckSameParameterExact
|
||||
(const Handle(Adaptor3d_Curve)& C3d,
|
||||
const Handle(Adaptor3d_CurveOnSurface)& curveOnSurface,
|
||||
const Standard_Real tol3d,
|
||||
Standard_Real& tolreached)
|
||||
{
|
||||
GeomLib_CheckCurveOnSurface aCheckCurveOnSurface(C3d);
|
||||
aCheckCurveOnSurface.SetParallel(Standard_False);
|
||||
aCheckCurveOnSurface.Perform(curveOnSurface);
|
||||
|
||||
tolreached = aCheckCurveOnSurface.MaxDistance();
|
||||
|
||||
if (tolreached > tol3d) {
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
tolreached = Max(tolreached, Precision::Confusion());
|
||||
tolreached *= 1.05;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SameParameter
|
||||
//purpose : Encapsulation of Sameparameter
|
||||
@@ -369,10 +340,8 @@ static Standard_Boolean SameParameter(TopoDS_Edge& E,
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Adaptor3d_Curve) curve3d = sp.Curve3d();
|
||||
Handle(Adaptor3d_CurveOnSurface) curveOnSurface = sp.CurveOnSurface();
|
||||
|
||||
if (!CheckSameParameterExact(curve3d, curveOnSurface, tol3d, ResTol) && ResTol > tolreached) {
|
||||
ResTol = sp.TolReached();
|
||||
if(ResTol > tolreached ){
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout<<"SameParameter : Tolerance not reached!"<<std::endl;
|
||||
std::cout<<"tol visee : "<<tol3d<<" tol obtained : "<<ResTol<<std::endl;
|
||||
@@ -3284,7 +3253,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
|
||||
|
||||
Tang = T1 + T2; //Average direction
|
||||
gp_Dir NormalOfBisPlane = Tang;
|
||||
gp_Vec anIntersectPointCrossDirection = T1.Crossed(T2);
|
||||
|
||||
if (isTangent) {
|
||||
Sortant -= Tang.Dot(Tang)*Tang;
|
||||
}
|
||||
@@ -3331,7 +3300,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
|
||||
}
|
||||
}
|
||||
|
||||
BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane, anIntersectPointCrossDirection);
|
||||
BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane);
|
||||
aTrim.AddBounds(Bounds);
|
||||
aTrim.AddUEdges(aUEdges);
|
||||
aTrim.AddVEdges(myVEdges, Index);
|
||||
|
@@ -76,14 +76,12 @@ static Standard_Boolean FindCommonVertex(const TopoDS_Edge& theFirstEdge,
|
||||
static Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
|
||||
const Standard_Integer theEIndex1,
|
||||
const Standard_Integer theEIndex2,
|
||||
const gp_Vec& theCrossDirection,
|
||||
TopoDS_Vertex& theCommonVertex,
|
||||
Standard_Real& theParamOnE1,
|
||||
Standard_Real& theParamOnE2);
|
||||
|
||||
static Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges,
|
||||
const BOPDS_PDS& theDS,
|
||||
const gp_Vec& theCrossDirection,
|
||||
TopTools_DataMapOfShapeListOfShape& theHistMap);
|
||||
|
||||
static void StoreVedgeInHistMap(const Handle(TopTools_HArray1OfShape)& theVEdges,
|
||||
@@ -196,11 +194,9 @@ static void UpdateSectionEdge(TopoDS_Edge& theEdge,
|
||||
// ===========================================================================================
|
||||
BRepFill_TrimShellCorner::BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
|
||||
const BRepFill_TransitionStyle theTransition,
|
||||
const gp_Ax2& theAxeOfBisPlane,
|
||||
const gp_Vec& theIntPointCrossDir) :
|
||||
const gp_Ax2& theAxeOfBisPlane) :
|
||||
myTransition(theTransition),
|
||||
myAxeOfBisPlane(theAxeOfBisPlane),
|
||||
myIntPointCrossDir(theIntPointCrossDir),
|
||||
myDone(Standard_False),
|
||||
myHasSection(Standard_False)
|
||||
{
|
||||
@@ -313,7 +309,7 @@ void BRepFill_TrimShellCorner::Perform()
|
||||
BOPDS_VectorOfInterfFF& aFFs = theDS->InterfFF();
|
||||
Standard_Integer aNbFFs = aFFs.Length();
|
||||
|
||||
if(!SplitUEdges(myUEdges, theDS, myIntPointCrossDir, myHistMap)) {
|
||||
if(!SplitUEdges(myUEdges, theDS, myHistMap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -429,7 +425,7 @@ BRepFill_TrimShellCorner::MakeFacesNonSec(const Standard_Integer
|
||||
Standard_Real apar1 = 0., apar2 = 0.;
|
||||
|
||||
Standard_Boolean bvertexfound =
|
||||
FindCommonVertex(theDS, anIndex1, anIndex2, myIntPointCrossDir, aCommonVertex, apar1, apar2);
|
||||
FindCommonVertex(theDS, anIndex1, anIndex2, aCommonVertex, apar1, apar2);
|
||||
// search common vertex between bounds. end
|
||||
|
||||
Handle(BRepTools_ReShape) aSubstitutor = new BRepTools_ReShape();
|
||||
@@ -701,9 +697,9 @@ BRepFill_TrimShellCorner::MakeFacesSec(const Standard_Integer
|
||||
|
||||
TopoDS_Vertex FirstVertex, LastVertex;
|
||||
Standard_Real ParamOnLeftE1, ParamOnLeftE2, ParamOnRightE1, ParamOnRightE2;
|
||||
FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2, myIntPointCrossDir,
|
||||
FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2,
|
||||
FirstVertex, ParamOnLeftE1, ParamOnLeftE2);
|
||||
FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2, myIntPointCrossDir,
|
||||
FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2,
|
||||
LastVertex, ParamOnRightE1, ParamOnRightE2);
|
||||
|
||||
TopoDS_Shape SecWire;
|
||||
@@ -1083,8 +1079,7 @@ Standard_Boolean BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Com
|
||||
// purpose:
|
||||
// ------------------------------------------------------------------------------------------
|
||||
Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges,
|
||||
const BOPDS_PDS& theDS,
|
||||
const gp_Vec& theCrossDirection,
|
||||
const BOPDS_PDS& theDS,
|
||||
TopTools_DataMapOfShapeListOfShape& theHistMap) {
|
||||
|
||||
const BOPDS_VectorOfInterfVV& aVVs = theDS->InterfVV();
|
||||
@@ -1110,7 +1105,7 @@ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdge
|
||||
TopoDS_Vertex aCommonVertex;
|
||||
Standard_Real apar1 = 0., apar2 = 0.;
|
||||
Standard_Boolean bvertexfound =
|
||||
FindCommonVertex(theDS, anEIndex1, anEIndex2, theCrossDirection, aCommonVertex, apar1, apar2);
|
||||
FindCommonVertex(theDS, anEIndex1, anEIndex2, aCommonVertex, apar1, apar2);
|
||||
//
|
||||
if(!bvertexfound) {
|
||||
TopoDS_Vertex V1 = TopExp::LastVertex(TopoDS::Edge(aE1));
|
||||
@@ -1222,7 +1217,6 @@ void FindFreeVertices(const TopoDS_Shape& theShape,
|
||||
Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
|
||||
const Standard_Integer theEIndex1,
|
||||
const Standard_Integer theEIndex2,
|
||||
const gp_Vec& theCrossDirection,
|
||||
TopoDS_Vertex& theCommonVertex,
|
||||
Standard_Real& theParamOnE1,
|
||||
Standard_Real& theParamOnE2) {
|
||||
@@ -1233,10 +1227,6 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
|
||||
TopoDS_Vertex aCommonVertex;
|
||||
Standard_Integer eeit = 0;
|
||||
|
||||
TopoDS_Edge theE1 = TopoDS::Edge(theDS->Shape(theEIndex1));
|
||||
TopoDS_Edge theE2 = TopoDS::Edge(theDS->Shape(theEIndex2));
|
||||
BRepAdaptor_Curve aBC1(theE1), aBC2(theE2);
|
||||
|
||||
Standard_Integer aNbEEs;
|
||||
aNbEEs = aEEs.Length();
|
||||
for(eeit = 0; eeit < aNbEEs; ++eeit) {
|
||||
@@ -1257,21 +1247,10 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
|
||||
IntTools_Tools::VertexParameters(aCP, theParamOnE1, theParamOnE2);
|
||||
else
|
||||
IntTools_Tools::VertexParameters(aCP, theParamOnE2, theParamOnE1);
|
||||
|
||||
gp_Pnt aPt;
|
||||
gp_Vec aDirOnE1, aDirOnE2;
|
||||
gp_Dir aIntersectPointCrossDir;
|
||||
|
||||
// intersect point aDirOnE1.cross(aDirOnE2) should same direction with path theCrossDirection
|
||||
aBC1.D1(theParamOnE1, aPt, aDirOnE1);
|
||||
aBC2.D1(theParamOnE2, aPt, aDirOnE2);
|
||||
aIntersectPointCrossDir = aDirOnE1.Crossed(aDirOnE2);
|
||||
|
||||
if (aIntersectPointCrossDir.Dot(theCrossDirection) > Precision::SquareConfusion())
|
||||
{
|
||||
bvertexfound = Standard_True;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bvertexfound = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -41,12 +41,9 @@ public:
|
||||
//! Constructor: takes faces to intersect,
|
||||
//! type of transition (it can be RightCorner or RoundCorner)
|
||||
//! and axis of bisector plane
|
||||
//! theIntersectPointCrossDirection : prev path direction at the origin point of theAxeOfBisPlane
|
||||
//! cross next path direction at the origin point of theAxeOfBisPlane. used when EE has more than one vertices
|
||||
Standard_EXPORT BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
|
||||
const BRepFill_TransitionStyle theTransition,
|
||||
const gp_Ax2& theAxeOfBisPlane,
|
||||
const gp_Vec& theIntPointCrossDir);
|
||||
const gp_Ax2& theAxeOfBisPlane);
|
||||
|
||||
Standard_EXPORT void AddBounds (const Handle(TopTools_HArray2OfShape)& Bounds);
|
||||
|
||||
@@ -95,7 +92,6 @@ private:
|
||||
|
||||
BRepFill_TransitionStyle myTransition;
|
||||
gp_Ax2 myAxeOfBisPlane;
|
||||
gp_Vec myIntPointCrossDir;
|
||||
TopoDS_Shape myShape1;
|
||||
TopoDS_Shape myShape2;
|
||||
Handle(TopTools_HArray2OfShape) myBounds;
|
||||
|
@@ -124,12 +124,10 @@ void BRepMesh_DefaultRangeSplitter::computeTolerance(
|
||||
const Standard_Real aDiffU = myRangeU.second - myRangeU.first;
|
||||
const Standard_Real aDiffV = myRangeV.second - myRangeV.first;
|
||||
|
||||
// Slightly increase exact resolution so to cover links with approximate
|
||||
// length equal to resolution itself on sub-resolution differences.
|
||||
const Standard_Real aTolerance = BRep_Tool::Tolerance (myDFace->GetFace());
|
||||
const Adaptor3d_Surface& aSurface = GetSurface()->Surface();
|
||||
const Standard_Real aResU = aSurface.UResolution (aTolerance) * 1.1;
|
||||
const Standard_Real aResV = aSurface.VResolution (aTolerance) * 1.1;
|
||||
const Standard_Real aResU = aSurface.UResolution (aTolerance);
|
||||
const Standard_Real aResV = aSurface.VResolution (aTolerance);
|
||||
|
||||
const Standard_Real aDeflectionUV = 1.e-05;
|
||||
myTolerance.first = Max(Min(aDeflectionUV, aResU), 1e-7 * aDiffU);
|
||||
|
@@ -46,8 +46,7 @@ namespace
|
||||
void operator()(const Standard_Integer theFaceIndex) const
|
||||
{
|
||||
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
|
||||
if (aDFace->IsSet(IMeshData_Outdated) ||
|
||||
aDFace->GetFace().IsNull())
|
||||
if (aDFace->IsSet(IMeshData_Outdated))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -120,7 +119,7 @@ namespace
|
||||
void operator()(const Standard_Integer theFaceIndex) const
|
||||
{
|
||||
const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
|
||||
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone || aDFace->IsSet(IMeshData_Failure))
|
||||
if (aDFace->GetSurface()->GetType() != GeomAbs_Cone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +128,7 @@ namespace
|
||||
for (Standard_Integer aEdgeIdx = 0; aEdgeIdx < aDWire->EdgesNb() - 1; ++aEdgeIdx)
|
||||
{
|
||||
const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge (aEdgeIdx);
|
||||
|
||||
|
||||
if (aDEdge->GetPCurve(aDFace.get(), TopAbs_FORWARD) != aDEdge->GetPCurve(aDFace.get(), TopAbs_REVERSED))
|
||||
{
|
||||
if (aDEdge->GetCurve()->ParametersNb() == 2)
|
||||
@@ -147,7 +146,7 @@ namespace
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -124,14 +124,7 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
|
||||
Standard_Boolean isBasic = Standard_False;
|
||||
Standard_Boolean isForced = Standard_False;
|
||||
Standard_Boolean isCopy = Standard_False;
|
||||
Standard_Boolean isCopyMesh = Standard_False;
|
||||
|
||||
// Check "copymesh" flag.
|
||||
if (!strcmp(a[n - 1], "-copymesh"))
|
||||
{
|
||||
isCopyMesh = Standard_True;
|
||||
last = --n;
|
||||
}
|
||||
// Check "copy" flag.
|
||||
if (!strcmp(a[n-1], "-copy")) {
|
||||
isCopy = Standard_True;
|
||||
@@ -225,7 +218,7 @@ static Standard_Integer transform(Draw_Interpretor&,Standard_Integer n,const cha
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
trf.Perform(S, isCopy, isCopyMesh);
|
||||
trf.Perform(S, isCopy);
|
||||
if (!trf.IsDone())
|
||||
return 1;
|
||||
DBRep::Set(a[i],trf.Shape());
|
||||
@@ -1494,27 +1487,27 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tmove",
|
||||
"tmove name1 name2 ... name, set location from name [-copy] [-copymesh]",
|
||||
"tmove name1 name2 ... name, set location from name [-copy]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("ttranslate",
|
||||
"ttranslate name1 name2 ... dx dy dz [-copy [-copymesh]]",
|
||||
"ttranslate name1 name2 ... dx dy dz [-copy]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("trotate",
|
||||
"trotate name1 name2 ... x y z dx dy dz angle [-copy [-copymesh]]",
|
||||
"trotate name1 name2 ... x y z dx dy dz angle [-copy]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tmirror",
|
||||
"tmirror name x y z dx dy dz [-copy] [-copymesh]",
|
||||
"tmirror name x y z dx dy dz [-copy]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
theCommands.Add("tscale",
|
||||
"tscale name x y z scale [-copy] [-copymesh]",
|
||||
"tscale name x y z scale [-copy]",
|
||||
__FILE__,
|
||||
transform,g);
|
||||
|
||||
|
@@ -57,7 +57,6 @@ static BRepOffsetAPI_ThruSections* Generator = 0;
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <ShapeUpgrade_UnifySameDomain.hxx>
|
||||
|
||||
//=======================================================================
|
||||
// prism
|
||||
@@ -534,50 +533,16 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char*
|
||||
//=======================================================================
|
||||
// mksweep
|
||||
//=======================================================================
|
||||
static Standard_Integer mksweep(Draw_Interpretor& di,
|
||||
static Standard_Integer mksweep(Draw_Interpretor&,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n != 2 && n != 5) return 1;
|
||||
if (n != 2) return 1;
|
||||
TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE);
|
||||
if (Spine.IsNull()) return 1;
|
||||
if (Sweep != 0) {
|
||||
delete Sweep;
|
||||
Sweep = 0;
|
||||
}
|
||||
|
||||
if (n > 2 && n <= 5)
|
||||
{
|
||||
if (!strcmp(a[2], "-C"))
|
||||
{
|
||||
ShapeUpgrade_UnifySameDomain aUnif(Spine, Standard_True, Standard_False, Standard_True);
|
||||
|
||||
Standard_Real anAngTol = 5.;
|
||||
Standard_Real aLinTol = 0.1;
|
||||
|
||||
if (n == 5)
|
||||
{
|
||||
anAngTol = Draw::Atof(a[3]);
|
||||
aLinTol = Draw::Atof(a[4]);
|
||||
}
|
||||
|
||||
aUnif.SetAngularTolerance(anAngTol * M_PI / 180.);
|
||||
aUnif.SetLinearTolerance(aLinTol);
|
||||
aUnif.Build();
|
||||
Spine = aUnif.Shape();
|
||||
if (BRepTest_Objects::IsHistoryNeeded())
|
||||
{
|
||||
BRepTest_Objects::SetHistory(aUnif.History());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
di << "To correct input spine use 'mksweep wire -C [AngTol LinTol]'\n";
|
||||
di << "By default, AngTol = 5, LinTol = 0.1";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
|
||||
return 0;
|
||||
}
|
||||
@@ -1045,9 +1010,7 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
|
||||
"\t\t-safe option allows to prevent the modifying of input shapes",
|
||||
__FILE__, thrusections, g);
|
||||
|
||||
theCommands.Add("mksweep", "mksweep wire [-C [AngTol LinTol]]\n"
|
||||
"\t\tthe option -C correct input spine by merging smooth connected neighboring edges\n"
|
||||
"\t\tthe AngTol is in degrees",
|
||||
theCommands.Add("mksweep", "mksweep wire",
|
||||
__FILE__, mksweep, g);
|
||||
|
||||
theCommands.Add("setsweep", "setsweep no args to get help",
|
||||
|
@@ -893,8 +893,6 @@ void BRepTools::CleanGeometry(const TopoDS_Shape& theShape)
|
||||
aBuilder.UpdateEdge(anEdge, Handle(Geom_Curve)(),
|
||||
TopLoc_Location(), BRep_Tool::Tolerance(anEdge));
|
||||
}
|
||||
|
||||
RemoveUnusedPCurves(theShape);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,215 +0,0 @@
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepTools_CopyModification
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTools_CopyModification::BRepTools_CopyModification(const Standard_Boolean copyGeom,
|
||||
const Standard_Boolean copyMesh)
|
||||
: myCopyGeom(copyGeom),
|
||||
myCopyMesh(copyMesh)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewSurface(const TopoDS_Face& theFace,
|
||||
Handle(Geom_Surface)& theSurf,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol,
|
||||
Standard_Boolean& theRevWires,
|
||||
Standard_Boolean& theRevFace)
|
||||
{
|
||||
theSurf = BRep_Tool::Surface(theFace, theLoc);
|
||||
theTol = BRep_Tool::Tolerance(theFace);
|
||||
theRevWires = theRevFace = Standard_False;
|
||||
|
||||
if (!theSurf.IsNull() && myCopyGeom)
|
||||
theSurf = Handle(Geom_Surface)::DownCast(theSurf->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theFace))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theTri = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
|
||||
if (theTri.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// mesh is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
theTri = theTri->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewCurve(const TopoDS_Edge& theEdge,
|
||||
Handle(Geom_Curve)& theCurve,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
Standard_Real aFirst, aLast;
|
||||
theCurve = BRep_Tool::Curve(theEdge, theLoc, aFirst, aLast);
|
||||
theTol = BRep_Tool::Tolerance(theEdge);
|
||||
|
||||
if (!theCurve.IsNull() && myCopyGeom)
|
||||
theCurve = Handle(Geom_Curve)::DownCast(theCurve->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
|
||||
|
||||
if (thePoly.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPolygonOnTriangulation(
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
if (!myCopyMesh && BRep_Tool::IsGeometric(theEdge))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aTria = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aTria, aLoc);
|
||||
|
||||
if (thePoly.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
// polygon is copied if and only if the geometry need to be copied too
|
||||
if (myCopyGeom)
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewPoint(const TopoDS_Vertex& theVertex,
|
||||
gp_Pnt& thePnt,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
thePnt = BRep_Tool::Pnt(theVertex);
|
||||
theTol = BRep_Tool::Tolerance(theVertex);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewCurve2d(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge&,
|
||||
const TopoDS_Face&,
|
||||
Handle(Geom2d_Curve)& theCurve,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
theTol = BRep_Tool::Tolerance(theEdge);
|
||||
Standard_Real aFirst, aLast;
|
||||
theCurve = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
|
||||
|
||||
if (!theCurve.IsNull() && myCopyGeom)
|
||||
theCurve = Handle(Geom2d_Curve)::DownCast(theCurve->Copy());
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_CopyModification::NewParameter(const TopoDS_Vertex& theVertex,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& thePnt,
|
||||
Standard_Real& theTol)
|
||||
{
|
||||
if (theVertex.IsNull())
|
||||
return Standard_False; // infinite edge may have Null vertex
|
||||
|
||||
theTol = BRep_Tool::Tolerance(theVertex);
|
||||
thePnt = BRep_Tool::Parameter(theVertex, theEdge);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Continuity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomAbs_Shape BRepTools_CopyModification::Continuity(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace1,
|
||||
const TopoDS_Face& theFace2,
|
||||
const TopoDS_Edge&,
|
||||
const TopoDS_Face&,
|
||||
const TopoDS_Face&)
|
||||
{
|
||||
return BRep_Tool::Continuity(theEdge, theFace1, theFace2);
|
||||
}
|
||||
|
||||
|
@@ -1,124 +0,0 @@
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _BRepTools_CopyModification_HeaderFile
|
||||
#define _BRepTools_CopyModification_HeaderFile
|
||||
|
||||
#include <BRepTools_Modification.hxx>
|
||||
|
||||
class BRepTools_CopyModification;
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
//! Tool class implementing necessary functionality for copying geometry and triangulation.
|
||||
class BRepTools_CopyModification : public BRepTools_Modification
|
||||
{
|
||||
public:
|
||||
//! Constructor.
|
||||
//! \param[in] theCopyGeom indicates that the geomtery (surfaces and curves) should be copied
|
||||
//! \param[in] theCopyMesh indicates that the triangulation should be copied
|
||||
Standard_EXPORT explicit BRepTools_CopyModification(const Standard_Boolean theCopyGeom = Standard_True,
|
||||
const Standard_Boolean theCopyMesh = Standard_True);
|
||||
|
||||
//! Returns true if theFace has been modified.
|
||||
//! If the face has been modified:
|
||||
//! - theSurf is the new geometry of the face,
|
||||
//! - theLoc is its new location, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! theRevWires, theRevFace are always set to false, because the orientaion is not changed.
|
||||
Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& theFace,
|
||||
Handle(Geom_Surface)& theSurf,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol,
|
||||
Standard_Boolean& theRevWires,
|
||||
Standard_Boolean& theRevFace) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theEdge has been modified.
|
||||
//! If the edge has been modified:
|
||||
//! - theCurve is the new geometric support of the edge,
|
||||
//! - theLoc is the new location, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If the edge has not been modified, this function
|
||||
//! returns false, and the values of theCurve, theLoc and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& theEdge,
|
||||
Handle(Geom_Curve)& theCurve,
|
||||
TopLoc_Location& theLoc,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theVertex has been modified.
|
||||
//! If the vertex has been modified:
|
||||
//! - thePnt is the new geometry of the vertex, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If the vertex has not been modified this function
|
||||
//! returns false, and the values of thePnt and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& theVertex, gp_Pnt& thePnt, Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theEdge has a new curve on surface on theFace.
|
||||
//! If a new curve exists:
|
||||
//! - theCurve is the new geometric support of the edge,
|
||||
//! - theTol the new tolerance.
|
||||
//! If no new curve exists, this function returns false, and
|
||||
//! the values of theCurve and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
const TopoDS_Edge& theNewEdge,
|
||||
const TopoDS_Face& theNewFace,
|
||||
Handle(Geom2d_Curve)& theCurve,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if theVertex has a new parameter on theEdge.
|
||||
//! If a new parameter exists:
|
||||
//! - thePnt is the parameter, and
|
||||
//! - theTol is the new tolerance.
|
||||
//! If no new parameter exists, this function returns false,
|
||||
//! and the values of thePnt and theTol are not significant.
|
||||
Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& theVertex,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& thePnt,
|
||||
Standard_Real& theTol) Standard_OVERRIDE;
|
||||
|
||||
//! Returns the continuity of theNewEdge between theNewFace1 and theNewFace2.
|
||||
//!
|
||||
//! theNewEdge is the new edge created from theEdge. theNewFace1
|
||||
//! (resp. theNewFace2) is the new face created from theFace1 (resp. theFace2).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace1,
|
||||
const TopoDS_Face& theFace2,
|
||||
const TopoDS_Edge& theNewEdge,
|
||||
const TopoDS_Face& theNewFace1,
|
||||
const TopoDS_Face& theNewFace2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_CopyModification, BRepTools_Modification)
|
||||
|
||||
private:
|
||||
Standard_Boolean myCopyGeom;
|
||||
Standard_Boolean myCopyMesh;
|
||||
};
|
||||
|
||||
#endif // _BRepTools_CopyModification_HeaderFile
|
@@ -29,7 +29,6 @@
|
||||
#include <GeomLib.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Quaternion.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
@@ -89,13 +88,7 @@ Standard_Boolean BRepTools_GTrsfModification::NewSurface
|
||||
gp_GTrsf gtrsf;
|
||||
gtrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
gtrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
S = BRep_Tool::Surface(F, L);
|
||||
if (S.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
S = Handle(Geom_Surface)::DownCast(S->Copy());
|
||||
S = Handle(Geom_Surface)::DownCast(BRep_Tool::Surface(F,L)->Copy());
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
Tol *= myGScale;
|
||||
@@ -180,7 +173,7 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve
|
||||
C = new Geom_TrimmedCurve(C, f, l);
|
||||
}
|
||||
L.Identity() ;
|
||||
return !C.IsNull();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -221,11 +214,6 @@ Standard_Boolean BRepTools_GTrsfModification::NewCurve2d
|
||||
Tol *= myGScale;
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::CurveOnSurface(E,F,f,l);
|
||||
if (C.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
C = new Geom2d_TrimmedCurve(C, f, l);
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -263,113 +251,4 @@ GeomAbs_Shape BRepTools_GTrsfModification::Continuity
|
||||
return BRep_Tool::Continuity(E,F1,F2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTriangulation)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
if (theTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_GTrsf aGTrsf;
|
||||
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
aGTrsf.Multiply(aLoc.Transformation());
|
||||
|
||||
theTriangulation = theTriangulation->Copy();
|
||||
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
|
||||
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myGScale));
|
||||
// apply transformation to 3D nodes
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt aP = theTriangulation->Node(anInd);
|
||||
aGTrsf.Transforms(aP.ChangeCoord());
|
||||
theTriangulation->SetNode(anInd, aP);
|
||||
}
|
||||
// modify triangles orientation in case of mirror transformation
|
||||
if (myGScale < 0.0)
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
|
||||
Standard_Integer aN1, aN2, aN3;
|
||||
aTria.Get(aN1, aN2, aN3);
|
||||
aTria.Set(aN1, aN3, aN2);
|
||||
theTriangulation->SetTriangle(anInd, aTria);
|
||||
}
|
||||
}
|
||||
// modify normals
|
||||
if (theTriangulation->HasNormals())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
gp_Dir aNormal = theTriangulation->Normal(anInd);
|
||||
aNormal.Transform(aGTrsf.Trsf());
|
||||
theTriangulation->SetNormal(anInd, aNormal);
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
thePoly = BRep_Tool::Polygon3D(theEdge, aLoc);
|
||||
if (thePoly.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_GTrsf aGTrsf;
|
||||
aGTrsf.SetVectorialPart(myGTrsf.VectorialPart());
|
||||
aGTrsf.SetTranslationPart(myGTrsf.TranslationPart());
|
||||
aGTrsf.Multiply(aLoc.Transformation());
|
||||
|
||||
thePoly = thePoly->Copy();
|
||||
thePoly->Deflection(thePoly->Deflection() * Abs(myGScale));
|
||||
// transform nodes
|
||||
TColgp_Array1OfPnt& aNodesArray = thePoly->ChangeNodes();
|
||||
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
|
||||
{
|
||||
gp_Pnt& aP = aNodesArray.ChangeValue(anId);
|
||||
aGTrsf.Transforms(aP.ChangeCoord());
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_GTrsfModification::NewPolygonOnTriangulation
|
||||
(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
if (aT.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
thePoly = BRep_Tool::PolygonOnTriangulation(theEdge, aT, aLoc);
|
||||
if (!thePoly.IsNull())
|
||||
thePoly = thePoly->Copy();
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -101,25 +101,6 @@ public:
|
||||
//! (resp. <F2>).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -20,10 +20,7 @@
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
#include <Extrema_ExtPC2d.hxx>
|
||||
#include <Extrema_GenLocateExtPS.hxx>
|
||||
#include <Extrema_LocateExtPC.hxx>
|
||||
#include <Extrema_LocateExtPC2d.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
@@ -50,163 +47,30 @@
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
|
||||
|
||||
//
|
||||
namespace
|
||||
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newU1,
|
||||
const Standard_Real newU2)
|
||||
{
|
||||
static void GeomLib_ChangeUBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newU1,
|
||||
const Standard_Real newU2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1, aSurface->NbUKnots());
|
||||
aSurface->UKnots(knots);
|
||||
BSplCLib::Reparametrize(newU1, newU2, knots);
|
||||
aSurface->SetUKnots(knots);
|
||||
}
|
||||
|
||||
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newV1,
|
||||
const Standard_Real newV2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1, aSurface->NbVKnots());
|
||||
aSurface->VKnots(knots);
|
||||
BSplCLib::Reparametrize(newV1, newV2, knots);
|
||||
aSurface->SetVKnots(knots);
|
||||
}
|
||||
|
||||
// find 3D curve from theEdge in theMap, and return the transformed curve or NULL
|
||||
static Handle(Geom_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Edge& theEdge,
|
||||
Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
Handle(Geom_Curve) aNewCurve;
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aLoc, theFirst, theLast);
|
||||
if (!aCurve.IsNull() && theMap.Contains(aCurve))
|
||||
{
|
||||
aNewCurve = Handle(Geom_Curve)::DownCast(theMap.FindFromKey(aCurve));
|
||||
aNewCurve = Handle(Geom_Curve)::DownCast(aNewCurve->Transformed(aLoc.Transformation()));
|
||||
}
|
||||
return aNewCurve;
|
||||
}
|
||||
|
||||
// find 2D curve from theEdge on theFace in theMap, and return the transformed curve or NULL
|
||||
static Handle(Geom2d_Curve) newCurve(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Standard_Real& theFirst,
|
||||
Standard_Real& theLast)
|
||||
{
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, theFirst, theLast);
|
||||
return (!aC2d.IsNull() && theMap.Contains(aC2d)) ? Handle(Geom2d_Curve)::DownCast(theMap.FindFromKey(aC2d))
|
||||
: Handle(Geom2d_Curve)();
|
||||
}
|
||||
|
||||
// find surface from theFace in theMap, and return the transformed surface or NULL
|
||||
static Handle(Geom_Surface) newSurface(const TColStd_IndexedDataMapOfTransientTransient& theMap,
|
||||
const TopoDS_Face& theFace)
|
||||
{
|
||||
Handle(Geom_Surface) aNewSurf;
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
if (!aSurf.IsNull() && theMap.Contains(aSurf))
|
||||
{
|
||||
aNewSurf = Handle(Geom_Surface)::DownCast(theMap.FindFromKey(aSurf));
|
||||
aNewSurf = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(aLoc.Transformation()));
|
||||
}
|
||||
return aNewSurf;
|
||||
}
|
||||
|
||||
static Standard_Boolean newParameter(const gp_Pnt& thePoint,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theTol,
|
||||
Standard_Real& theParam)
|
||||
{
|
||||
GeomAdaptor_Curve anAdaptor(theCurve);
|
||||
Extrema_LocateExtPC proj(thePoint, anAdaptor, theParam, theFirst, theLast, Precision::PConfusion());
|
||||
if (proj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = proj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
theParam = proj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
static Standard_Boolean newParameter(const gp_Pnt2d& theUV,
|
||||
const Handle(Geom2d_Curve)& theCurve2d,
|
||||
const Standard_Real theFirst,
|
||||
const Standard_Real theLast,
|
||||
const Standard_Real theTol,
|
||||
Standard_Real& theParam)
|
||||
{
|
||||
Geom2dAdaptor_Curve anAdaptor(theCurve2d);
|
||||
Extrema_LocateExtPC2d aProj(theUV, anAdaptor, theParam, Precision::PConfusion());
|
||||
if (aProj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = aProj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
theParam = aProj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to use general extrema to find the parameter, because Extrema_LocateExtPC2d
|
||||
// sometimes could not find a solution if the parameter's first approach is several
|
||||
// spans away from the expected solution (test bugs/modalg_7/bug28722).
|
||||
Extrema_ExtPC2d anExt(theUV, anAdaptor, theFirst, theLast);
|
||||
if (anExt.IsDone())
|
||||
{
|
||||
Standard_Integer aMinInd = 0;
|
||||
Standard_Real aMinSqDist = Precision::Infinite();
|
||||
for (Standard_Integer anIndex = 1; anIndex <= anExt.NbExt(); ++anIndex)
|
||||
if (anExt.SquareDistance(anIndex) < aMinSqDist)
|
||||
{
|
||||
aMinSqDist = anExt.SquareDistance(anIndex);
|
||||
aMinInd = anIndex;
|
||||
}
|
||||
if (aMinSqDist < theTol * theTol)
|
||||
{
|
||||
theParam = anExt.Point(aMinInd).Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
static Standard_Boolean newUV(const gp_Pnt& thePoint,
|
||||
const Handle(Geom_Surface)& theSurf,
|
||||
const Standard_Real theTol,
|
||||
gp_Pnt2d& theUV)
|
||||
{
|
||||
GeomAdaptor_Surface anAdaptor(theSurf);
|
||||
Extrema_GenLocateExtPS aProj(anAdaptor);
|
||||
aProj.Perform(thePoint, theUV.X(), theUV.Y());
|
||||
if (aProj.IsDone())
|
||||
{
|
||||
Standard_Real aDist2Min = aProj.SquareDistance();
|
||||
if (aDist2Min < theTol * theTol)
|
||||
{
|
||||
gp_XY& aUV = theUV.ChangeCoord();
|
||||
aProj.Point().Parameter(aUV.ChangeCoord(1), aUV.ChangeCoord(2));
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
TColStd_Array1OfReal knots(1,aSurface->NbUKnots()) ;
|
||||
aSurface->UKnots(knots) ;
|
||||
BSplCLib::Reparametrize(newU1,
|
||||
newU2,
|
||||
knots) ;
|
||||
aSurface->SetUKnots(knots) ;
|
||||
}
|
||||
static void GeomLib_ChangeVBounds(Handle(Geom_BSplineSurface)& aSurface,
|
||||
const Standard_Real newV1,
|
||||
const Standard_Real newV2)
|
||||
{
|
||||
TColStd_Array1OfReal knots(1,aSurface->NbVKnots()) ;
|
||||
aSurface->VKnots(knots) ;
|
||||
BSplCLib::Reparametrize(newV1,
|
||||
newV2,
|
||||
knots) ;
|
||||
aSurface->SetVKnots(knots) ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -238,12 +102,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
RevWires = Standard_False;
|
||||
RevFace = Standard_False;
|
||||
Handle(Geom_Surface) SS = BRep_Tool::Surface(F,L);
|
||||
if (SS.IsNull())
|
||||
{
|
||||
//processing the case when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(Standard_Type) TheTypeSS = SS->DynamicType();
|
||||
if ((TheTypeSS == STANDARD_TYPE(Geom_BSplineSurface)) ||
|
||||
(TheTypeSS == STANDARD_TYPE(Geom_BezierSurface))) {
|
||||
@@ -257,7 +115,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
//OCC466(apo)->
|
||||
U1 = curvU1; U2 = curvU2;
|
||||
V1 = curvV1; V2 = curvV2;
|
||||
S->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
|
||||
if (Abs(U1 - surfU1) <= TolPar)
|
||||
U1 = surfU1;
|
||||
@@ -334,10 +192,10 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
|
||||
if (Abs(surfU1-U1) > Tol || Abs(surfU2-U2) > Tol ||
|
||||
Abs(surfV1-V1) > Tol || Abs(surfV2-V2) > Tol)
|
||||
S = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
|
||||
S->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
SS = new Geom_RectangularTrimmedSurface(S, U1, U2, V1, V2);
|
||||
SS->Bounds(surfU1,surfU2,surfV1,surfV2);
|
||||
|
||||
S = GeomConvert::SurfaceToBSplineSurface(S);
|
||||
S = GeomConvert::SurfaceToBSplineSurface(SS);
|
||||
Handle(Geom_BSplineSurface) BS = Handle(Geom_BSplineSurface)::DownCast(S) ;
|
||||
BS->Resolution(Tol, UTol, VTol) ;
|
||||
|
||||
@@ -352,9 +210,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewSurface
|
||||
GeomLib_ChangeVBounds(BS, V1, V2) ;
|
||||
}
|
||||
|
||||
if (!myMap.Contains(SS)) {
|
||||
myMap.Add(SS, S);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -379,41 +234,6 @@ static Standard_Boolean IsConvert(const TopoDS_Edge& E)
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewTriangulation(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTri)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewTriangulation(theFace, theTri))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// convert UV nodes of the mesh
|
||||
if (theTri->HasUVNodes())
|
||||
{
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
|
||||
if (!aSurf.IsNull() && !aNewSurf.IsNull())
|
||||
{
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(theFace);
|
||||
for (Standard_Integer anInd = 1; anInd <= theTri->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt2d aUV = theTri->UVNode(anInd);
|
||||
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
|
||||
if (newUV(aPoint, aNewSurf, aTol, aUV))
|
||||
theTri->SetUVNode(anInd, aUV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
//purpose :
|
||||
@@ -492,40 +312,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve
|
||||
return Standard_True ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygon(const TopoDS_Edge& theEdge,
|
||||
Handle(Poly_Polygon3D)& thePoly)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewPolygon(theEdge, thePoly))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// update parameters of polygon
|
||||
if (thePoly->HasParameters())
|
||||
{
|
||||
Standard_Real aTol = BRep_Tool::Tolerance(theEdge);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aFirst, aLast);
|
||||
Handle(Geom_Curve) aNewCurve = newCurve(myMap, theEdge, aFirst, aLast);
|
||||
if (!aCurve.IsNull() && !aNewCurve.IsNull()) // skip processing degenerated edges
|
||||
{
|
||||
TColStd_Array1OfReal& aParams = thePoly->ChangeParameters();
|
||||
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
|
||||
{
|
||||
Standard_Real& aParam = aParams(anInd);
|
||||
gp_Pnt aPoint = aCurve->Value(aParam);
|
||||
newParameter(aPoint, aNewCurve, aFirst, aLast, aTol, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPoint
|
||||
//purpose :
|
||||
@@ -554,7 +340,7 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Standard_Real f2d,l2d;
|
||||
Handle(Geom2d_Curve) aBaseC2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
|
||||
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
|
||||
Standard_Real f3d,l3d;
|
||||
TopLoc_Location Loc;
|
||||
Handle(Geom_Curve) C3d = BRep_Tool::Curve(E, Loc, f3d,l3d);
|
||||
@@ -562,7 +348,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
!C3d->IsKind(STANDARD_TYPE(Geom_BezierCurve))) ||
|
||||
IsConvert(E));
|
||||
|
||||
Handle(Geom2d_Curve) C2d = aBaseC2d;
|
||||
if(BRep_Tool::Degenerated(E)) {
|
||||
//Curve2d = C2d;
|
||||
if(!C2d->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)))
|
||||
@@ -571,7 +356,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
C2d = aTrimC;
|
||||
}
|
||||
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
if(!BRepTools::IsReallyClosed(E,F)) {
|
||||
@@ -597,11 +381,9 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
if(!newE.IsNull()) {
|
||||
C3d = BRep_Tool::Curve(newE, f3d, l3d);
|
||||
}
|
||||
if (C3d.IsNull()) {
|
||||
else {
|
||||
C3d = BRep_Tool::Curve(E,f3d,l3d);
|
||||
}
|
||||
if (C3d.IsNull())
|
||||
return Standard_False;
|
||||
GeomAdaptor_Curve G3dAC(C3d, f3d, l3d);
|
||||
Handle(GeomAdaptor_Curve) G3dAHC = new GeomAdaptor_Curve(G3dAC);
|
||||
|
||||
@@ -621,16 +403,13 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Handle(Geom_Surface) aNewS = BRep_Tool::Surface(newF);
|
||||
if (!aNewS.IsNull())
|
||||
S = aNewS;
|
||||
S = BRep_Tool::Surface(newF);
|
||||
}
|
||||
S->Bounds(Uinf, Usup, Vinf, Vsup);
|
||||
//Uinf -= 1e-9; Usup += 1e-9; Vinf -= 1e-9; Vsup += 1e-9;
|
||||
@@ -672,7 +451,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
Curve2d = ProjOnCurve.BSpline();
|
||||
@@ -682,7 +460,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
@@ -725,7 +502,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
else {
|
||||
@@ -736,7 +512,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
@@ -782,7 +557,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
@@ -808,7 +582,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
@@ -856,7 +629,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
Tol = newTol;
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
else {
|
||||
@@ -868,7 +640,6 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
myUpdatedEdges.Append(newE);
|
||||
}
|
||||
mylcu.Append(C2dBis);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
@@ -880,58 +651,11 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
|
||||
return Standard_False;
|
||||
}
|
||||
Curve2d = Geom2dConvert::CurveToBSplineCurve(C2d);
|
||||
myMap.Add(aBaseC2d, Curve2d);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTools_NurbsConvertModification::NewPolygonOnTriangulation(
|
||||
const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly)
|
||||
{
|
||||
if (!BRepTools_CopyModification::NewPolygonOnTriangulation(theEdge, theFace, thePoly))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// update parameters of 2D polygon
|
||||
if (thePoly->HasParameters())
|
||||
{
|
||||
Standard_Real aTol = Max(BRep_Tool::Tolerance(theEdge), thePoly->Deflection());
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
Handle(Geom_Surface) aNewSurf = newSurface(myMap, theFace);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theEdge, theFace, aFirst, aLast);
|
||||
Handle(Geom2d_Curve) aNewC2d = newCurve(myMap, theEdge, theFace, aFirst, aLast);
|
||||
if (!aSurf.IsNull() && !aC2d.IsNull() && !aNewSurf.IsNull() && !aNewC2d.IsNull())
|
||||
{
|
||||
// compute 2D tolerance
|
||||
GeomAdaptor_Surface aSurfAdapt(aSurf);
|
||||
Standard_Real aTol2D = Max(aSurfAdapt.UResolution(aTol), aSurfAdapt.VResolution(aTol));
|
||||
|
||||
for (Standard_Integer anInd = 1; anInd <= thePoly->NbNodes(); ++anInd)
|
||||
{
|
||||
Standard_Real aParam = thePoly->Parameter(anInd);
|
||||
gp_Pnt2d aUV = aC2d->Value(aParam);
|
||||
gp_Pnt aPoint = aSurf->Value(aUV.X(), aUV.Y());
|
||||
if (newUV(aPoint, aNewSurf, aTol, aUV) &&
|
||||
newParameter(aUV, aNewC2d, aFirst, aLast, aTol2D, aParam))
|
||||
{
|
||||
thePoly->SetParameter(anInd, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewParameter
|
||||
//purpose :
|
||||
@@ -946,12 +670,30 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewParameter
|
||||
Tol = BRep_Tool::Tolerance(V);
|
||||
if(BRep_Tool::Degenerated(E))
|
||||
return Standard_False;
|
||||
Standard_Real f, l, param = BRep_Tool::Parameter(V,E);
|
||||
TopLoc_Location L;
|
||||
|
||||
Handle(Geom_Curve) gc = BRep_Tool::Curve(E, L, f, l);
|
||||
if(!myMap.Contains(gc))
|
||||
return Standard_False;
|
||||
|
||||
Handle(Geom_BSplineCurve) gcc =
|
||||
Handle(Geom_BSplineCurve)::DownCast(myMap.FindFromKey(gc));
|
||||
|
||||
gcc = Handle(Geom_BSplineCurve)::DownCast(gcc->Transformed(L.Transformation()));
|
||||
|
||||
GeomAdaptor_Curve ac(gcc);
|
||||
gp_Pnt pnt = BRep_Tool::Pnt(V);
|
||||
P = BRep_Tool::Parameter(V,E);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aNewCurve = newCurve(myMap, E, aFirst, aLast);
|
||||
return !aNewCurve.IsNull() && newParameter(pnt, aNewCurve, aFirst, aLast, Tol, P);
|
||||
|
||||
Extrema_LocateExtPC proj(pnt, ac, param, f, l, Tol);
|
||||
if(proj.IsDone()) {
|
||||
Standard_Real Dist2Min = proj.SquareDistance();
|
||||
if (Dist2Min < Tol*Tol) {
|
||||
P = proj.Point().Parameter();
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#include <TopTools_ListOfShape.hxx>
|
||||
#include <TColStd_ListOfTransient.hxx>
|
||||
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
|
||||
#include <BRepTools_CopyModification.hxx>
|
||||
#include <BRepTools_Modification.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
class TopoDS_Face;
|
||||
@@ -36,12 +36,12 @@ class Geom2d_Curve;
|
||||
|
||||
|
||||
class BRepTools_NurbsConvertModification;
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_CopyModification)
|
||||
DEFINE_STANDARD_HANDLE(BRepTools_NurbsConvertModification, BRepTools_Modification)
|
||||
|
||||
//! Defines a modification of the geometry by a Trsf
|
||||
//! from gp. All methods return True and transform the
|
||||
//! geometry.
|
||||
class BRepTools_NurbsConvertModification : public BRepTools_CopyModification
|
||||
class BRepTools_NurbsConvertModification : public BRepTools_Modification
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -100,27 +100,11 @@ public:
|
||||
//! (resp. <F2>).
|
||||
Standard_EXPORT GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const TopoDS_Edge& NewE, const TopoDS_Face& NewF1, const TopoDS_Face& NewF2) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - theTri is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& theFace, Handle(Poly_Triangulation)& theTri) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& theEdge, Handle(Poly_Polygon3D)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - thePoly is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& theEdge,
|
||||
const TopoDS_Face& theFace,
|
||||
Handle(Poly_PolygonOnTriangulation)& thePoly) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT const TopTools_ListOfShape& GetUpdatedEdges() const;
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_CopyModification)
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(BRepTools_NurbsConvertModification,BRepTools_Modification)
|
||||
|
||||
protected:
|
||||
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <GeomLib.hxx>
|
||||
#include <GeomLib_Tool.hxx>
|
||||
#include <gp_GTrsf2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
@@ -44,8 +43,7 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepTools_TrsfModification,BRepTools_Modification)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTools_TrsfModification::BRepTools_TrsfModification(const gp_Trsf& T) :
|
||||
myTrsf(T),
|
||||
myCopyMesh(Standard_False)
|
||||
myTrsf(T)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,16 +58,6 @@ gp_Trsf& BRepTools_TrsfModification::Trsf ()
|
||||
return myTrsf;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsCopyMesh
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean& BRepTools_TrsfModification::IsCopyMesh()
|
||||
{
|
||||
return myCopyMesh;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewSurface
|
||||
//purpose :
|
||||
@@ -84,12 +72,6 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
|
||||
Standard_Boolean& RevFace)
|
||||
{
|
||||
S = BRep_Tool::Surface(F,L);
|
||||
if (S.IsNull())
|
||||
{
|
||||
//processing cases when there is no geometry
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(F);
|
||||
Tol *= Abs(myTrsf.ScaleFactor());
|
||||
RevWires = Standard_False;
|
||||
@@ -105,194 +87,6 @@ Standard_Boolean BRepTools_TrsfModification::NewSurface
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewTriangulation
|
||||
(const TopoDS_Face& theFace,
|
||||
Handle(Poly_Triangulation)& theTriangulation)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theTriangulation = BRep_Tool::Triangulation(theFace, aLoc);
|
||||
|
||||
if (theTriangulation.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf = myTrsf;
|
||||
if (!aLoc.IsIdentity())
|
||||
{
|
||||
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
|
||||
}
|
||||
|
||||
theTriangulation = theTriangulation->Copy();
|
||||
theTriangulation->SetCachedMinMax(Bnd_Box()); // clear bounding box
|
||||
theTriangulation->Deflection(theTriangulation->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
// apply transformation to 3D nodes
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt aP = theTriangulation->Node(anInd);
|
||||
aP.Transform(aTrsf);
|
||||
theTriangulation->SetNode(anInd, aP);
|
||||
}
|
||||
// modify 2D nodes
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theFace, aLoc);
|
||||
if (theTriangulation->HasUVNodes() && !aSurf.IsNull())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbNodes(); ++anInd)
|
||||
{
|
||||
gp_Pnt2d aP2d = theTriangulation->UVNode(anInd);
|
||||
aSurf->TransformParameters(aP2d.ChangeCoord().ChangeCoord(1),
|
||||
aP2d.ChangeCoord().ChangeCoord(2),
|
||||
myTrsf);
|
||||
theTriangulation->SetUVNode(anInd, aP2d);
|
||||
}
|
||||
}
|
||||
// modify triangles orientation in case of mirror transformation
|
||||
if (myTrsf.ScaleFactor() < 0.0)
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
Poly_Triangle aTria = theTriangulation->Triangle(anInd);
|
||||
Standard_Integer aN1, aN2, aN3;
|
||||
aTria.Get(aN1, aN2, aN3);
|
||||
aTria.Set(aN1, aN3, aN2);
|
||||
theTriangulation->SetTriangle(anInd, aTria);
|
||||
}
|
||||
}
|
||||
// modify normals
|
||||
if (theTriangulation->HasNormals())
|
||||
{
|
||||
for (Standard_Integer anInd = 1; anInd <= theTriangulation->NbTriangles(); ++anInd)
|
||||
{
|
||||
gp_Dir aNormal = theTriangulation->Normal(anInd);
|
||||
aNormal.Transform(aTrsf);
|
||||
theTriangulation->SetNormal(anInd, aNormal);
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygon
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewPolygon
|
||||
(const TopoDS_Edge& theE,
|
||||
Handle(Poly_Polygon3D)& theP)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
theP = BRep_Tool::Polygon3D(theE, aLoc);
|
||||
if (theP.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
gp_Trsf aTrsf = myTrsf;
|
||||
if (!aLoc.IsIdentity())
|
||||
{
|
||||
aTrsf = aLoc.Transformation().Inverted() * aTrsf * aLoc.Transformation();
|
||||
}
|
||||
|
||||
theP = theP->Copy();
|
||||
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
TColgp_Array1OfPnt& aNodesArray = theP->ChangeNodes();
|
||||
for (Standard_Integer anId = aNodesArray.Lower(); anId <= aNodesArray.Upper(); ++anId)
|
||||
{
|
||||
//Applying the transformation to each node of polygon
|
||||
aNodesArray.ChangeValue(anId).Transform(aTrsf);
|
||||
}
|
||||
// transform the parametrization
|
||||
if (theP->HasParameters())
|
||||
{
|
||||
TopLoc_Location aCurveLoc;
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theE, aCurveLoc, aFirst, aLast);
|
||||
if (!aCurve.IsNull())
|
||||
{
|
||||
Standard_Real aReparametrization = aCurve->ParametricTransformation(aTrsf);
|
||||
if (Abs(aReparametrization - 1.0) > Precision::PConfusion())
|
||||
{
|
||||
TColStd_Array1OfReal& aParams = theP->ChangeParameters();
|
||||
for (Standard_Integer anInd = aParams.Lower(); anInd <= aParams.Upper(); ++anInd)
|
||||
{
|
||||
aParams(anInd) *= aReparametrization;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewPolygonOnTriangulation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTools_TrsfModification::NewPolygonOnTriangulation
|
||||
(const TopoDS_Edge& theE,
|
||||
const TopoDS_Face& theF,
|
||||
Handle(Poly_PolygonOnTriangulation)& theP)
|
||||
{
|
||||
if (!myCopyMesh)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Poly_Triangulation) aT = BRep_Tool::Triangulation(theF, aLoc);
|
||||
if (aT.IsNull())
|
||||
{
|
||||
theP = Handle(Poly_PolygonOnTriangulation) ();
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theP = BRep_Tool::PolygonOnTriangulation(theE, aT, aLoc);
|
||||
if (theP.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
theP = theP->Copy();
|
||||
theP->Deflection(theP->Deflection() * Abs(myTrsf.ScaleFactor()));
|
||||
|
||||
// transform the parametrization
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(theF, aLoc);
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom2d_Curve) aC2d = BRep_Tool::CurveOnSurface(theE, theF, aFirst, aLast);
|
||||
if (!aSurf.IsNull() && !aC2d.IsNull() && Abs(Abs(myTrsf.ScaleFactor()) - 1.0) > TopLoc_Location::ScalePrec())
|
||||
{
|
||||
gp_GTrsf2d aGTrsf = aSurf->ParametricTransformation(myTrsf);
|
||||
if (aGTrsf.Form() != gp_Identity)
|
||||
{
|
||||
Handle(Geom2d_Curve) aNewC2d = GeomLib::GTransform(aC2d, aGTrsf);
|
||||
for (Standard_Integer anInd = 1; anInd <= theP->NbNodes(); ++anInd)
|
||||
{
|
||||
Standard_Real aParam = theP->Parameter(anInd);
|
||||
gp_Pnt2d aP2d = aC2d->Value(aParam);
|
||||
aGTrsf.Transforms(aP2d.ChangeCoord());
|
||||
GeomLib_Tool::Parameter(aNewC2d, aP2d, theP->Deflection(), aParam);
|
||||
theP->SetParameter(anInd, aParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewCurve
|
||||
@@ -307,10 +101,6 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve
|
||||
{
|
||||
Standard_Real f,l;
|
||||
C = BRep_Tool::Curve(E,L,f,l);
|
||||
if (C.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Tol = BRep_Tool::Tolerance(E);
|
||||
Tol *= Abs(myTrsf.ScaleFactor());
|
||||
@@ -363,12 +153,6 @@ Standard_Boolean BRepTools_TrsfModification::NewCurve2d
|
||||
Standard_Real scale = myTrsf.ScaleFactor();
|
||||
Tol *= Abs(scale);
|
||||
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,loc);
|
||||
|
||||
if (S.IsNull())
|
||||
{
|
||||
// processing the case when the surface (geometry) is deleted
|
||||
return Standard_False;
|
||||
}
|
||||
GeomAdaptor_Surface GAsurf(S);
|
||||
if (GAsurf.GetType() == GeomAbs_Plane)
|
||||
return Standard_False;
|
||||
|
@@ -50,9 +50,6 @@ public:
|
||||
//! Provides access to the gp_Trsf associated with this
|
||||
//! modification. The transformation can be changed.
|
||||
Standard_EXPORT gp_Trsf& Trsf();
|
||||
|
||||
//! Sets a flag to indicate the need to copy mesh.
|
||||
Standard_EXPORT Standard_Boolean& IsCopyMesh();
|
||||
|
||||
//! Returns true if the face F has been modified.
|
||||
//! If the face has been modified:
|
||||
@@ -67,21 +64,6 @@ public:
|
||||
//! associated with this modification is negative.
|
||||
Standard_EXPORT Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S, TopLoc_Location& L, Standard_Real& Tol, Standard_Boolean& RevWires, Standard_Boolean& RevFace) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the face has been modified according to changed triangulation.
|
||||
//! If the face has been modified:
|
||||
//! - T is a new triangulation on the face
|
||||
Standard_EXPORT Standard_Boolean NewTriangulation(const TopoDS_Face& F, Handle(Poly_Triangulation)& T) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon
|
||||
Standard_EXPORT Standard_Boolean NewPolygon(const TopoDS_Edge& E, Handle(Poly_Polygon3D)& P) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge has been modified according to changed polygon on triangulation.
|
||||
//! If the edge has been modified:
|
||||
//! - P is a new polygon on triangulation
|
||||
Standard_EXPORT Standard_Boolean NewPolygonOnTriangulation(const TopoDS_Edge& E, const TopoDS_Face& F, Handle(Poly_PolygonOnTriangulation)& P) Standard_OVERRIDE;
|
||||
|
||||
//! Returns true if the edge E has been modified.
|
||||
//! If the edge has been modified:
|
||||
//! - C is the new geometric support of the edge,
|
||||
@@ -138,7 +120,6 @@ private:
|
||||
|
||||
|
||||
gp_Trsf myTrsf;
|
||||
Standard_Boolean myCopyMesh;
|
||||
|
||||
|
||||
};
|
||||
|
@@ -54,6 +54,29 @@ static Standard_Real GetNextParamOnPC(const Handle(Geom2d_Curve)& aPC,
|
||||
const Standard_Real& tolV,
|
||||
const Standard_Boolean& reverse);
|
||||
|
||||
static Standard_Real LocalUresol (const TopoDS_Vertex& theVertex,
|
||||
const TopoDS_Face& theFace,
|
||||
const gp_Pnt2d& theP2d1,
|
||||
const gp_Pnt2d& theP2d2)
|
||||
{
|
||||
Standard_Real aResol = -1;
|
||||
|
||||
BRepAdaptor_Surface aBAsurf (theFace, Standard_False);
|
||||
if (aBAsurf.GetType() == GeomAbs_Sphere)
|
||||
{
|
||||
Standard_Real aRadius = aBAsurf.Sphere().Radius();
|
||||
Standard_Real aVmid = (theP2d1.Y() + theP2d2.Y())/2.;
|
||||
Standard_Real aLocalRad = aRadius * Cos(aVmid);
|
||||
if (aLocalRad > Precision::Confusion())
|
||||
{
|
||||
Standard_Real aTolVertex = BRep_Tool::Tolerance (theVertex);
|
||||
aResol = aTolVertex / aLocalRad;
|
||||
}
|
||||
}
|
||||
|
||||
return aResol;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepTools_WireExplorer
|
||||
//purpose :
|
||||
@@ -536,56 +559,56 @@ void BRepTools_WireExplorer::Next()
|
||||
it.Initialize(l);
|
||||
while( it.More() )
|
||||
{
|
||||
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
|
||||
if( E.IsSame(myEdge) )
|
||||
{
|
||||
it.Next();
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
TopoDS_Vertex aVert1, aVert2;
|
||||
TopExp::Vertices (E, aVert1, aVert2, Standard_True);
|
||||
if( aVert1.IsNull() || aVert2.IsNull() )
|
||||
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
|
||||
if( E.IsSame(myEdge) )
|
||||
{
|
||||
it.Next();
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
aPCurve = BRep_Tool::CurveOnSurface (E, myFace, dfFPar, dfLPar);
|
||||
if( aPCurve.IsNull() )
|
||||
|
||||
TopoDS_Vertex aVert1, aVert2;
|
||||
TopExp::Vertices (E, aVert1, aVert2, Standard_True);
|
||||
if( aVert1.IsNull() || aVert2.IsNull() )
|
||||
{
|
||||
it.Next();
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
gp_Pnt2d aPEb, aPEe;
|
||||
if( aVert1.IsSame(aVert2) == isDegenerated )
|
||||
{
|
||||
if( E.Orientation() == TopAbs_REVERSED )
|
||||
aPCurve->D0(dfLPar, aPEb);
|
||||
else
|
||||
aPCurve->D0(dfFPar, aPEb);
|
||||
|
||||
if( Abs(dfLPar-dfFPar) > Precision::PConfusion() )
|
||||
{
|
||||
isrevese = ( E.Orientation() == TopAbs_REVERSED );
|
||||
isrevese = !isrevese;
|
||||
Standard_Real aEPm = GetNextParamOnPC(aPCurve,aPEb,dfFPar,dfLPar,myTolU,myTolV,isrevese);
|
||||
|
||||
aPCurve->D0 (aEPm, aPEe);
|
||||
|
||||
aPCurve = BRep_Tool::CurveOnSurface (E, myFace, dfFPar, dfLPar);
|
||||
if( aPCurve.IsNull() )
|
||||
{
|
||||
it.Next();
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
gp_Pnt2d aPEb, aPEe;
|
||||
if( aVert1.IsSame(aVert2) == isDegenerated )
|
||||
{
|
||||
if( E.Orientation() == TopAbs_REVERSED )
|
||||
aPCurve->D0(dfLPar, aPEb);
|
||||
else
|
||||
aPCurve->D0(dfFPar, aPEb);
|
||||
|
||||
if( Abs(dfLPar-dfFPar) > Precision::PConfusion() )
|
||||
{
|
||||
isrevese = ( E.Orientation() == TopAbs_REVERSED );
|
||||
isrevese = !isrevese;
|
||||
Standard_Real aEPm = GetNextParamOnPC(aPCurve,aPEb,dfFPar,dfLPar,myTolU,myTolV,isrevese);
|
||||
|
||||
aPCurve->D0 (aEPm, aPEe);
|
||||
if(aPEb.SquareDistance(aPEe) <= gp::Resolution())
|
||||
{
|
||||
//seems to be very short curve
|
||||
gp_Vec2d aD;
|
||||
aPCurve->D1(aEPm, aPEe, aD);
|
||||
if( E.Orientation() == TopAbs_REVERSED )
|
||||
if( E.Orientation() == TopAbs_REVERSED )
|
||||
aPEe.SetXY(aPEb.XY()-aD.XY());
|
||||
else
|
||||
else
|
||||
aPEe.SetXY(aPEb.XY()+aD.XY());
|
||||
|
||||
|
||||
if(aPEb.SquareDistance(aPEe) <= gp::Resolution())
|
||||
{
|
||||
it.Next();
|
||||
@@ -593,35 +616,39 @@ void BRepTools_WireExplorer::Next()
|
||||
continue;
|
||||
}
|
||||
}
|
||||
gp_Vec2d anEDir(aPEb, aPEe);
|
||||
dfCurAngle = Abs( anEDir.Angle(anERefDir) );
|
||||
}
|
||||
|
||||
if( dfCurAngle <= dfMinAngle )
|
||||
{
|
||||
Standard_Real d = PRef.SquareDistance(aPEb);
|
||||
if( d <= Precision::PConfusion() )
|
||||
d = 0.;
|
||||
if( Abs(aPEb.X()-PRef.X()) < myTolU && Abs(aPEb.Y()-PRef.Y()) < myTolV )
|
||||
{
|
||||
if( d <= dmin )
|
||||
{
|
||||
dfMinAngle = dfCurAngle;
|
||||
kMin = k;
|
||||
dmin = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
it.Next();
|
||||
k++;
|
||||
gp_Vec2d anEDir(aPEb, aPEe);
|
||||
dfCurAngle = Abs( anEDir.Angle(anERefDir) );
|
||||
}
|
||||
|
||||
if( dfCurAngle <= dfMinAngle )
|
||||
{
|
||||
Standard_Real d = PRef.SquareDistance(aPEb);
|
||||
if( d <= Precision::PConfusion() )
|
||||
d = 0.;
|
||||
//jgv
|
||||
Standard_Real aLocalUresol = LocalUresol (myVertex, myFace, PRef, aPEb);
|
||||
aLocalUresol = Max (aLocalUresol, myTolU);
|
||||
/////
|
||||
if( Abs(aPEb.X()-PRef.X()) < aLocalUresol && Abs(aPEb.Y()-PRef.Y()) < myTolV )
|
||||
{
|
||||
if( d <= dmin )
|
||||
{
|
||||
dfMinAngle = dfCurAngle;
|
||||
kMin = k;
|
||||
dmin = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
it.Next();
|
||||
k++;
|
||||
}// while it
|
||||
|
||||
if( kMin == 0 )
|
||||
{
|
||||
isDegenerated = Standard_False;
|
||||
k = 1;
|
||||
dmin = RealLast();
|
||||
isDegenerated = Standard_False;
|
||||
k = 1;
|
||||
dmin = RealLast();
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
BRepTools.cxx
|
||||
BRepTools.hxx
|
||||
BRepTools_CopyModification.cxx
|
||||
BRepTools_CopyModification.hxx
|
||||
BRepTools_DataMapIteratorOfMapOfVertexPnt2d.hxx
|
||||
BRepTools_Debug.cxx
|
||||
BRepTools_GTrsfModification.cxx
|
||||
|
@@ -229,12 +229,11 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
|
||||
if (aFileVer >= TDocStd_FormatVersion_VERSION_3) {
|
||||
BinLDrivers_DocumentSection aSection;
|
||||
do {
|
||||
if (!BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer))
|
||||
break;
|
||||
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer);
|
||||
mySections.Append(aSection);
|
||||
} while (!aSection.Name().IsEqual (aQuickPart ? ENDSECTION_POS : SHAPESECTION_POS) && !theIStream.eof());
|
||||
|
||||
if (mySections.IsEmpty() || theIStream.eof()) {
|
||||
if (theIStream.eof()) {
|
||||
// There is no shape section in the file.
|
||||
myMsgDriver->Send (aMethStr + "error: shape section is not found", Message_Fail);
|
||||
myReaderStatus = PCDM_RS_ReaderException;
|
||||
|
@@ -214,17 +214,14 @@ void BinLDrivers_DocumentSection::Write (Standard_OStream& theStream,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BinLDrivers_DocumentSection::ReadTOC (
|
||||
BinLDrivers_DocumentSection& theSection,
|
||||
void BinLDrivers_DocumentSection::ReadTOC
|
||||
(BinLDrivers_DocumentSection& theSection,
|
||||
Standard_IStream& theStream,
|
||||
const TDocStd_FormatVersion theDocFormatVersion)
|
||||
{
|
||||
static const int THE_BUF_SIZE = 512;
|
||||
char aBuf[THE_BUF_SIZE];
|
||||
char aBuf[512];
|
||||
Standard_Integer aNameBufferSize;
|
||||
theStream.read ((char *)&aNameBufferSize, sizeof(Standard_Integer));
|
||||
if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE)
|
||||
return Standard_False;
|
||||
#ifdef DO_INVERSE
|
||||
aNameBufferSize = InverseSize(aNameBufferSize);
|
||||
#endif
|
||||
@@ -263,5 +260,4 @@ Standard_Boolean BinLDrivers_DocumentSection::ReadTOC (
|
||||
theSection.myValue[1] = aValue[1];
|
||||
theSection.myIsPostRead = (aValue[2] != 0);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -73,10 +73,9 @@ public:
|
||||
const TDocStd_FormatVersion theDocFormatVersion);
|
||||
|
||||
//! Fill a DocumentSection instance from the data that are read
|
||||
//! from TOC. Returns false in case of the stream reading problem.
|
||||
Standard_EXPORT static Standard_Boolean ReadTOC (BinLDrivers_DocumentSection& theSection,
|
||||
Standard_IStream& theIS,
|
||||
const TDocStd_FormatVersion theDocFormatVersion);
|
||||
//! from TOC.
|
||||
Standard_EXPORT static void ReadTOC (BinLDrivers_DocumentSection& theSection, Standard_IStream& theIS,
|
||||
const TDocStd_FormatVersion theDocFormatVersion);
|
||||
|
||||
|
||||
|
||||
|
@@ -54,7 +54,6 @@ static Standard_Byte faceCullToChar (Graphic3d_TypeOfBackfacingModel theMode)
|
||||
{
|
||||
case Graphic3d_TypeOfBackfacingModel_Auto: return '0';
|
||||
case Graphic3d_TypeOfBackfacingModel_BackCulled: return 'B';
|
||||
case Graphic3d_TypeOfBackfacingModel_FrontCulled: return 'F';
|
||||
case Graphic3d_TypeOfBackfacingModel_DoubleSided: return '1';
|
||||
}
|
||||
return '0';
|
||||
@@ -67,7 +66,6 @@ static Graphic3d_TypeOfBackfacingModel faceCullFromChar (Standard_Byte theMode)
|
||||
{
|
||||
case '0': return Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
case 'B': return Graphic3d_TypeOfBackfacingModel_BackCulled;
|
||||
case 'F': return Graphic3d_TypeOfBackfacingModel_FrontCulled;
|
||||
case '1': return Graphic3d_TypeOfBackfacingModel_DoubleSided;
|
||||
}
|
||||
return Graphic3d_TypeOfBackfacingModel_Auto;
|
||||
|
403
src/Bnd/Bnd_BoundSortBox2d.cxx
Normal file
403
src/Bnd/Bnd_BoundSortBox2d.cxx
Normal file
@@ -0,0 +1,403 @@
|
||||
// Created on: 1993-03-08
|
||||
// Created by: Didier PIFFAULT
|
||||
// Copyright (c) 1993-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <Bnd_Array1OfBox.hxx>
|
||||
#include <Bnd_BoundSortBox2d.hxx>
|
||||
#include <Bnd_Box2d.hxx>
|
||||
#include <Standard_MultiplyDefined.hxx>
|
||||
#include <Standard_NullValue.hxx>
|
||||
#include <TColStd_Array1OfListOfInteger.hxx>
|
||||
#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Bnd_BoundSortBox2d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Bnd_BoundSortBox2d::Bnd_BoundSortBox2d()
|
||||
: discrX(0), discrY(0)
|
||||
{}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::Initialize(const Bnd_Box2d& CompleteBox,
|
||||
const Handle(Bnd_HArray1OfBox2d)& SetOfBox)
|
||||
{
|
||||
myBox=CompleteBox;
|
||||
myBndComponents=SetOfBox;
|
||||
discrX=SetOfBox->Length();
|
||||
discrY=discrX;
|
||||
|
||||
Standard_Real xmin, ymin, xmax, ymax;
|
||||
Standard_Real middleX=0.;
|
||||
Standard_Real middleY=0.;
|
||||
|
||||
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
|
||||
|
||||
Standard_Integer labox;
|
||||
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
|
||||
if (!taBox(labox).IsVoid()) {
|
||||
taBox.Value(labox).Get(xmin, ymin, xmax, ymax);
|
||||
middleX+=xmax-xmin;
|
||||
middleY+=ymax-ymin;
|
||||
}
|
||||
}
|
||||
middleX=middleX/taBox.Length();
|
||||
middleY=middleY/taBox.Length();
|
||||
|
||||
Standard_Real Xmax, Ymax;
|
||||
CompleteBox.Get(Xmin, Ymin, Xmax, Ymax);
|
||||
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
|
||||
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
|
||||
|
||||
if (middleX < Epsilon(100.)) {
|
||||
discrX=1;
|
||||
deltaX=Xmax-Xmin;
|
||||
}
|
||||
else if (middleX > deltaX) {
|
||||
discrX=(Standard_Integer)((Xmax-Xmin)/middleX);
|
||||
deltaX=middleX;
|
||||
discrX++;
|
||||
}
|
||||
|
||||
if (middleY < Epsilon(100.)) {
|
||||
discrY=1;
|
||||
deltaY=Ymax-Ymin;
|
||||
}
|
||||
else if (middleY > deltaY) {
|
||||
discrY=(Standard_Integer)((Ymax-Ymin)/middleY + 0.1);
|
||||
deltaY=middleY;
|
||||
discrY++;
|
||||
}
|
||||
|
||||
SortBoxes();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::Initialize(const Handle(Bnd_HArray1OfBox2d)& SetOfBox)
|
||||
{
|
||||
myBndComponents=SetOfBox;
|
||||
discrX=SetOfBox->Length();
|
||||
discrY=discrX;
|
||||
|
||||
Standard_Real xmin, ymin, xmax, ymax;
|
||||
Standard_Real middleX=0.;
|
||||
Standard_Real middleY=0.;
|
||||
|
||||
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
|
||||
|
||||
Standard_Integer labox;
|
||||
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
|
||||
if (!taBox(labox).IsVoid()) {
|
||||
myBox.Add(taBox(labox));
|
||||
taBox.Value(labox).Get(xmin, ymin, xmax, ymax);
|
||||
middleX+=xmax-xmin;
|
||||
middleY+=ymax-ymin;
|
||||
}
|
||||
}
|
||||
middleX=middleX/taBox.Length();
|
||||
middleY=middleY/taBox.Length();
|
||||
|
||||
Standard_Real Xmax, Ymax;
|
||||
myBox.Get(Xmin, Ymin, Xmax, Ymax);
|
||||
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
|
||||
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
|
||||
|
||||
if (middleX < Epsilon(100.)) {
|
||||
discrX=1;
|
||||
deltaX=Xmax-Xmin;
|
||||
}
|
||||
else if (middleX > deltaX) {
|
||||
discrX=(Standard_Integer)((Xmax-Xmin)/middleX);
|
||||
deltaX=middleX;
|
||||
discrX++;
|
||||
}
|
||||
|
||||
if (middleY < Epsilon(100.)) {
|
||||
discrY=1;
|
||||
deltaY=Ymax-Ymin;
|
||||
}
|
||||
else if (middleY > deltaY) {
|
||||
discrY=(Standard_Integer)((Ymax-Ymin)/middleY + 0.1);
|
||||
deltaY=middleY;
|
||||
discrY++;
|
||||
}
|
||||
|
||||
SortBoxes();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SortBoxes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::SortBoxes()
|
||||
{
|
||||
Standard_NullValue_Raise_if (discrX+discrY <=0, "BoundSortBox2d nul!");
|
||||
|
||||
Standard_Integer labox, lacase, firstcase, lastcase;
|
||||
Standard_Real xmin, ymin, xmax, ymax;
|
||||
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
|
||||
|
||||
axisX=new TColStd_HArray1OfListOfInteger(1, discrX);
|
||||
TColStd_Array1OfListOfInteger & tabListX=axisX->ChangeArray1();
|
||||
|
||||
axisY=new TColStd_HArray1OfListOfInteger(1, discrY);
|
||||
TColStd_Array1OfListOfInteger & tabListY=axisY->ChangeArray1();
|
||||
|
||||
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
|
||||
if (!taBox(labox).IsVoid()) {
|
||||
taBox(labox).Get(xmin, ymin, xmax, ymax);
|
||||
|
||||
if (discrX>1) {
|
||||
firstcase=(Standard_Integer ) Max(1.0, (xmin-Xmin)/deltaX);
|
||||
lastcase=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
|
||||
for (lacase=firstcase; lacase<=lastcase; lacase++) {
|
||||
tabListX(lacase).Append(labox);
|
||||
}
|
||||
}
|
||||
|
||||
if (discrY >1) {
|
||||
firstcase=(Standard_Integer ) Max(1.0, (ymin-Ymin)/deltaY);
|
||||
lastcase=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
|
||||
for (lacase=firstcase; lacase<=lastcase; lacase++) {
|
||||
tabListY(lacase).Append(labox);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::Initialize(const Bnd_Box2d& CompleteBox,
|
||||
const Standard_Integer nbComponents)
|
||||
{
|
||||
Standard_NullValue_Raise_if (nbComponents <=0, "BoundSortBox nul!");
|
||||
|
||||
myBox=CompleteBox;
|
||||
myBndComponents=new Bnd_HArray1OfBox2d(1, nbComponents);
|
||||
|
||||
Bnd_Box2d emptyBox;
|
||||
myBndComponents->Init( emptyBox );
|
||||
|
||||
discrX=nbComponents;
|
||||
discrY=nbComponents;
|
||||
|
||||
Standard_Real Xmax, Ymax;
|
||||
CompleteBox.Get(Xmin, Ymin, Xmax, Ymax);
|
||||
|
||||
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
|
||||
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
|
||||
|
||||
if (deltaX < Epsilon(100.)) {
|
||||
discrX=1;
|
||||
deltaX=Xmax-Xmin;
|
||||
}
|
||||
else axisX=new TColStd_HArray1OfListOfInteger(1, discrX);
|
||||
|
||||
if (deltaY < Epsilon(100.)) {
|
||||
discrY=1;
|
||||
deltaY=Ymax-Ymin;
|
||||
}
|
||||
else axisY=new TColStd_HArray1OfListOfInteger(1, discrY);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::Add(const Bnd_Box2d& theBox,
|
||||
const Standard_Integer boxIndex)
|
||||
{
|
||||
Standard_MultiplyDefined_Raise_if
|
||||
(!(myBndComponents->Value(boxIndex).IsVoid()),
|
||||
" This box is already defined !");
|
||||
|
||||
if (!theBox.IsVoid()) {
|
||||
Bnd_Array1OfBox2d & taBox=myBndComponents->ChangeArray1();
|
||||
Standard_Integer theGap, firstGap , lastGap;
|
||||
Standard_Real xmin, ymin, xmax, ymax;
|
||||
theBox.Get(xmin, ymin, xmax, ymax);
|
||||
|
||||
if (taBox.Lower()<=boxIndex && boxIndex<=taBox.Upper())
|
||||
taBox(boxIndex).Update(xmin, ymin, xmax, ymax);
|
||||
|
||||
TColStd_Array1OfListOfInteger & tabListX=axisX->ChangeArray1();
|
||||
|
||||
if (discrX>1) {
|
||||
firstGap=(Standard_Integer ) Max(1.0, ((xmin-Xmin)/deltaX)+1);
|
||||
lastGap=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
|
||||
for (theGap=firstGap; theGap<=lastGap; theGap++) {
|
||||
tabListX(theGap).Append(boxIndex);
|
||||
}
|
||||
}
|
||||
|
||||
TColStd_Array1OfListOfInteger & tabListY=axisY->ChangeArray1();
|
||||
|
||||
if (discrY >1) {
|
||||
firstGap=(Standard_Integer ) Max(1.0, ((ymin-Ymin)/deltaY)+1);
|
||||
lastGap=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
|
||||
for (theGap=firstGap; theGap<=lastGap; theGap++) {
|
||||
tabListY(theGap).Append(boxIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Compare
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
const TColStd_ListOfInteger& Bnd_BoundSortBox2d::Compare
|
||||
(const Bnd_Box2d& theBox)
|
||||
{
|
||||
Standard_NullValue_Raise_if (discrX+discrY <=0,
|
||||
"Compare sur 1 BoundSortBox2d nul!");
|
||||
|
||||
lastResult.Clear();
|
||||
if (theBox.IsVoid()) return lastResult;
|
||||
if (theBox.IsOut(myBox)) return lastResult;
|
||||
|
||||
Standard_Integer lacase, firstcase, lastcase;
|
||||
Standard_Real xmin, ymin, xmax, ymax;
|
||||
theBox.Get(xmin, ymin, xmax, ymax);
|
||||
|
||||
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
|
||||
Crible.Clear();
|
||||
theFound=2;
|
||||
|
||||
Standard_Integer cardY=0;
|
||||
if (discrY>1 && (!theBox.IsOpenYmin() || !theBox.IsOpenYmax())) {
|
||||
const TColStd_Array1OfListOfInteger & tabList=axisY->Array1();
|
||||
firstcase=(Standard_Integer ) Max(1.0, (ymin-Ymin)/deltaY);
|
||||
lastcase=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
|
||||
for (lacase=firstcase; lacase<=lastcase; lacase++) {
|
||||
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
|
||||
for (; theList.More(); theList.Next()) {
|
||||
cardY++;
|
||||
Crible.Bind(theList.Value(), 2);
|
||||
}
|
||||
}
|
||||
if (cardY==0) return lastResult;
|
||||
}
|
||||
else {
|
||||
if (ymin > Ymin+deltaY || ymax < Ymin)
|
||||
return lastResult;
|
||||
theFound-=2;
|
||||
}
|
||||
|
||||
if (discrX>1 && (!theBox.IsOpenXmin() || !theBox.IsOpenXmax())) {
|
||||
const TColStd_Array1OfListOfInteger & tabList=axisX->Array1();
|
||||
firstcase=(Standard_Integer ) Max(1.0, (xmin-Xmin)/deltaX);
|
||||
lastcase=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
|
||||
for (lacase=firstcase; lacase<=lastcase; lacase++) {
|
||||
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
|
||||
for (; theList.More(); theList.Next()) {
|
||||
if (Crible.IsBound(theList.Value())) {
|
||||
if (Crible(theList.Value())==theFound) {
|
||||
if (!taBox.Value(theList.Value()).IsOut(theBox)){
|
||||
lastResult.Append(theList.Value());
|
||||
Crible(theList.Value())=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
else {
|
||||
if (xmin > Xmin+deltaX || xmax < Xmin) return lastResult;
|
||||
else if (discrY==1)
|
||||
{
|
||||
lacase=1;
|
||||
for(Standard_Integer i=taBox.Lower();i<=taBox.Upper();i++)
|
||||
{
|
||||
lastResult.Append(i);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
TColStd_DataMapIteratorOfDataMapOfIntegerInteger itDM(Crible);
|
||||
for (; itDM.More(); itDM.Next()) {
|
||||
if (itDM.Value()==theFound) {
|
||||
if (taBox.Lower()<=itDM.Key() && itDM.Key()<=taBox.Upper()) {
|
||||
if (!taBox(itDM.Key()).IsOut(theBox))
|
||||
lastResult.Append(itDM.Key());
|
||||
}
|
||||
else {
|
||||
lastResult.Append(itDM.Key());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void Bnd_BoundSortBox2d::Dump() const
|
||||
{
|
||||
Standard_Integer lacase;
|
||||
|
||||
std::cout << "axis X : " << discrX << " intervalles de " << deltaX << std::endl;
|
||||
if (discrX>1) {
|
||||
const TColStd_Array1OfListOfInteger & tabList=axisX->Array1();
|
||||
for (lacase=1; lacase<=discrX; lacase++) {
|
||||
std::cout << " X " << lacase << " : " ;
|
||||
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
|
||||
for (; theList.More(); theList.Next()) {
|
||||
std::cout << theList.Value() << " ";
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "axis Y : " << discrY << " intervalles de " << deltaY << std::endl;
|
||||
if (discrY>1) {
|
||||
const TColStd_Array1OfListOfInteger & tabList=axisY->Array1();
|
||||
for (lacase=1; lacase<=discrY; lacase++) {
|
||||
std::cout << " Y " << lacase << " : " ;
|
||||
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
|
||||
for (; theList.More(); theList.Next()) {
|
||||
std::cout << theList.Value() << " ";
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
}
|
129
src/Bnd/Bnd_BoundSortBox2d.hxx
Normal file
129
src/Bnd/Bnd_BoundSortBox2d.hxx
Normal file
@@ -0,0 +1,129 @@
|
||||
// Created on: 1993-03-05
|
||||
// Created by: Didier PIFFAULT
|
||||
// Copyright (c) 1993-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 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 _Bnd_BoundSortBox2d_HeaderFile
|
||||
#define _Bnd_BoundSortBox2d_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Bnd_HArray1OfBox2d.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_HArray1OfListOfInteger.hxx>
|
||||
#include <TColStd_DataMapOfIntegerInteger.hxx>
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
|
||||
|
||||
//! A tool to compare a 2D bounding box with a set of 2D
|
||||
//! bounding boxes. It sorts the set of bounding boxes to give
|
||||
//! the list of boxes which intersect the element being compared.
|
||||
//! The boxes being sorted generally bound a set of shapes,
|
||||
//! while the box being compared bounds a shape to be
|
||||
//! compared. The resulting list of intersecting boxes therefore
|
||||
//! gives the list of items which potentially intersect the shape to be compared.
|
||||
class Bnd_BoundSortBox2d
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Constructs an empty comparison algorithm for 2D bounding boxes.
|
||||
//! The bounding boxes are then defined using the Initialize function.
|
||||
Standard_EXPORT Bnd_BoundSortBox2d();
|
||||
|
||||
//! Initializes this comparison algorithm with
|
||||
//! - the set of 2D bounding boxes SetOfBox
|
||||
Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
|
||||
|
||||
//! Initializes this comparison algorithm with
|
||||
//! - the set of 2D bounding boxes SetOfBox, where
|
||||
//! CompleteBox is given as the global bounding box of SetOfBox.
|
||||
Standard_EXPORT void Initialize (const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
|
||||
|
||||
//! Initializes this comparison algorithm, giving it only
|
||||
//! - the maximum number nbComponents, and
|
||||
//! - the global bounding box CompleteBox,
|
||||
//! of the 2D bounding boxes to be managed. Use the Add
|
||||
//! function to define the array of bounding boxes to be sorted by this algorithm.
|
||||
Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Standard_Integer nbComponents);
|
||||
|
||||
//! Adds the 2D bounding box theBox at position boxIndex in
|
||||
//! the array of boxes to be sorted by this comparison algorithm.
|
||||
//! This function is used only in conjunction with the third
|
||||
//! syntax described in the synopsis of Initialize.
|
||||
//! Exceptions
|
||||
//! - Standard_OutOfRange if boxIndex is not in the
|
||||
//! range [ 1,nbComponents ] where
|
||||
//! nbComponents is the maximum number of bounding
|
||||
//! boxes declared for this comparison algorithm at
|
||||
//! initialization.
|
||||
//! - Standard_MultiplyDefined if a box still exists at
|
||||
//! position boxIndex in the array of boxes to be sorted by
|
||||
//! this comparison algorithm.
|
||||
Standard_EXPORT void Add (const Bnd_Box2d& theBox, const Standard_Integer boxIndex);
|
||||
|
||||
|
||||
//! Compares the 2D bounding box theBox with the set of
|
||||
//! bounding boxes to be sorted by this comparison algorithm,
|
||||
//! and returns the list of intersecting bounding boxes as a list
|
||||
//! of indexes on the array of bounding boxes used by this algorithm.
|
||||
Standard_EXPORT const TColStd_ListOfInteger& Compare (const Bnd_Box2d& theBox);
|
||||
|
||||
Standard_EXPORT void Dump() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//! Prepares BoundSortBox2d and sorts the rectangles of
|
||||
//! <SetOfBox> .
|
||||
Standard_EXPORT void SortBoxes();
|
||||
|
||||
|
||||
Bnd_Box2d myBox;
|
||||
Handle(Bnd_HArray1OfBox2d) myBndComponents;
|
||||
Standard_Real Xmin;
|
||||
Standard_Real Ymin;
|
||||
Standard_Real deltaX;
|
||||
Standard_Real deltaY;
|
||||
Standard_Integer discrX;
|
||||
Standard_Integer discrY;
|
||||
Handle(TColStd_HArray1OfListOfInteger) axisX;
|
||||
Handle(TColStd_HArray1OfListOfInteger) axisY;
|
||||
Standard_Integer theFound;
|
||||
TColStd_DataMapOfIntegerInteger Crible;
|
||||
TColStd_ListOfInteger lastResult;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _Bnd_BoundSortBox2d_HeaderFile
|
@@ -419,7 +419,7 @@ OBBTool::
|
||||
myPointBoxSet->SetSize(myPntsList.Length());
|
||||
|
||||
// Add the points into Set
|
||||
for (Standard_Integer iP = theL.Lower(); iP <= theL.Upper(); ++iP)
|
||||
for (Standard_Integer iP = 0; iP < theL.Length(); ++iP)
|
||||
{
|
||||
const gp_Pnt& aP = theL (iP);
|
||||
Standard_Real aTol = theLT ? theLT->Value(iP) : Precision::Confusion();
|
||||
|
@@ -1,4 +1,7 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
// Created on: 1991-01-08
|
||||
// Created by: Didier Piffault
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
@@ -11,13 +14,14 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _GeomConvert_ConvType_HeaderFile
|
||||
#define _GeomConvert_ConvType_HeaderFile
|
||||
enum GeomConvert_ConvType
|
||||
{
|
||||
GeomConvert_Target,
|
||||
GeomConvert_Simplest,
|
||||
GeomConvert_MinGap
|
||||
};
|
||||
#ifndef Bnd_SeqOfBox_HeaderFile
|
||||
#define Bnd_SeqOfBox_HeaderFile
|
||||
|
||||
#endif // _GeomConvert_ConvType_HeaderFile
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
|
||||
//! This sequence used to store the bounding boxes of sub-Shapes.
|
||||
typedef NCollection_Sequence<Bnd_Box> Bnd_SeqOfBox;
|
||||
|
||||
|
||||
#endif
|
@@ -15,6 +15,8 @@ Bnd_B3x.gxx
|
||||
Bnd_B3x.lxx
|
||||
Bnd_BoundSortBox.cxx
|
||||
Bnd_BoundSortBox.hxx
|
||||
Bnd_BoundSortBox2d.cxx
|
||||
Bnd_BoundSortBox2d.hxx
|
||||
Bnd_Box.cxx
|
||||
Bnd_Box.hxx
|
||||
Bnd_Box2d.cxx
|
||||
@@ -26,6 +28,7 @@ Bnd_OBB.cxx
|
||||
Bnd_OBB.hxx
|
||||
Bnd_Range.cxx
|
||||
Bnd_Range.hxx
|
||||
Bnd_SeqOfBox.hxx
|
||||
Bnd_Sphere.cxx
|
||||
Bnd_Sphere.hxx
|
||||
Bnd_Sphere.lxx
|
||||
|
@@ -732,13 +732,10 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS1() == fd2->IndexOfS1()) {
|
||||
jf1 = 1; jf2 = 1;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation. This would raise problems
|
||||
@@ -756,13 +753,10 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS2() == fd2->IndexOfS1()) {
|
||||
jf1 = 2; jf2 = 1;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation. This would raise problems
|
||||
@@ -792,13 +786,10 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS1() == fd2->IndexOfS2()) {
|
||||
jf1 = 1; jf2 = 2;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation.
|
||||
@@ -828,13 +819,10 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS2() == fd2->IndexOfS2()) {
|
||||
jf1 = 2; jf2 = 2;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation.
|
||||
|
@@ -1645,13 +1645,6 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
|
||||
}
|
||||
if (compoint1 && compoint2) {
|
||||
SeqFil.Remove(num);
|
||||
num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
|
||||
if (isfirst) {
|
||||
num1=num+1;
|
||||
}
|
||||
else {
|
||||
num1=num-1;
|
||||
}
|
||||
reg1=Standard_False; reg2=Standard_False;
|
||||
}
|
||||
}
|
||||
@@ -2122,9 +2115,6 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
|
||||
F=Face[nb-1];
|
||||
if (!prolface[nb-1]) faceprol[nb-1]=F;
|
||||
}
|
||||
|
||||
if (F.IsNull()) throw Standard_NullObject("IntersectionAtEnd : Trying to intersect with NULL face");
|
||||
|
||||
Sfacemoins1=BRep_Tool::Surface(F);
|
||||
Handle(Geom_Curve) cint;
|
||||
Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
|
||||
|
@@ -436,6 +436,15 @@ void Cocoa_Window::InvalidateContent (const Handle(Aspect_DisplayConnection)& )
|
||||
return;
|
||||
}
|
||||
|
||||
if ([NSThread isMainThread])
|
||||
{
|
||||
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
|
||||
[myHView setNeedsDisplay];
|
||||
#else
|
||||
[myHView setNeedsDisplay: YES];
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
[myHView performSelectorOnMainThread: @selector(invalidateContentOcct:)
|
||||
withObject: NULL
|
||||
|
@@ -1,429 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
|
||||
#include <Message.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_StreamBuffer.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TCollection_HAsciiString.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DE_ConfigurationContext, Standard_Transient)
|
||||
|
||||
enum DE_ConfigurationContext_KindOfLine
|
||||
{
|
||||
DE_ConfigurationContext_KindOfLine_End,
|
||||
DE_ConfigurationContext_KindOfLine_Empty,
|
||||
DE_ConfigurationContext_KindOfLine_Comment,
|
||||
DE_ConfigurationContext_KindOfLine_Resource,
|
||||
DE_ConfigurationContext_KindOfLine_Error
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
//=======================================================================
|
||||
//function : GetLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Boolean GetLine(OSD_File& theFile, TCollection_AsciiString& theLine)
|
||||
{
|
||||
TCollection_AsciiString aBuffer;
|
||||
Standard_Integer aBufSize = 10;
|
||||
Standard_Integer aLen;
|
||||
theLine.Clear();
|
||||
do
|
||||
{
|
||||
theFile.ReadLine(aBuffer, aBufSize, aLen);
|
||||
theLine += aBuffer;
|
||||
if (theFile.IsAtEnd())
|
||||
{
|
||||
if (!theLine.Length())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
theLine += "\n";
|
||||
}
|
||||
}
|
||||
} while (theLine.Value(theLine.Length()) != '\n');
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WhatKindOfLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static DE_ConfigurationContext_KindOfLine WhatKindOfLine(const TCollection_AsciiString& theLine,
|
||||
TCollection_AsciiString& theToken1,
|
||||
TCollection_AsciiString& theToken2)
|
||||
{
|
||||
static const TCollection_AsciiString aWhiteSpace = " \t\r\n";
|
||||
Standard_Integer aPos1 = 0, aPos2 = 0, aPos = 0;
|
||||
TCollection_AsciiString aLine(theLine);
|
||||
aLine.LeftAdjust();
|
||||
aLine.RightAdjust();
|
||||
if (!aLine.EndsWith(':') && (!aLine.EndsWith(' ') || !aLine.EndsWith('\t') || !aLine.EndsWith('\n')))
|
||||
{
|
||||
aLine.InsertAfter(aLine.Length(), " ");
|
||||
}
|
||||
|
||||
if (aLine.Value(1) == '!')
|
||||
{
|
||||
return DE_ConfigurationContext_KindOfLine_Comment;
|
||||
}
|
||||
aPos1 = aLine.FirstLocationNotInSet(aWhiteSpace, 1, aLine.Length());
|
||||
if (aLine.Value(aPos1) == '\n')
|
||||
{
|
||||
return DE_ConfigurationContext_KindOfLine_Empty;
|
||||
}
|
||||
|
||||
aPos2 = aLine.Location(1, ':', aPos1, aLine.Length());
|
||||
if (aPos2 == 0 || aPos1 == aPos2)
|
||||
{
|
||||
return DE_ConfigurationContext_KindOfLine_Error;
|
||||
}
|
||||
|
||||
for (aPos = aPos2 - 1; aLine.Value(aPos) == '\t' || aLine.Value(aPos) == ' '; aPos--);
|
||||
|
||||
theToken1 = aLine.SubString(aPos1, aPos);
|
||||
if(aPos2 != aLine.Length())
|
||||
{
|
||||
aPos2++;
|
||||
}
|
||||
aPos = aLine.FirstLocationNotInSet(aWhiteSpace, aPos2, aLine.Length());
|
||||
if (aPos != 0)
|
||||
{
|
||||
if (aLine.Value(aPos) == '\\')
|
||||
{
|
||||
switch (aLine.Value(aPos + 1))
|
||||
{
|
||||
case '\\':
|
||||
case ' ':
|
||||
case '\t':
|
||||
aPos++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aPos == aLine.Length() || aPos == 0)
|
||||
{
|
||||
theToken2.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
aLine.Remove(1, aPos - 1);
|
||||
aLine.Remove(aLine.Length());
|
||||
theToken2 = aLine;
|
||||
}
|
||||
return DE_ConfigurationContext_KindOfLine_Resource;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : MakeName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static TCollection_AsciiString MakeName(const TCollection_AsciiString& theScope,
|
||||
const TCollection_AsciiString& theParam)
|
||||
{
|
||||
TCollection_AsciiString aStr(theScope);
|
||||
if (!aStr.IsEmpty())
|
||||
{
|
||||
aStr += '.';
|
||||
}
|
||||
aStr += theParam;
|
||||
return aStr;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : DE_ConfigurationContext
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
DE_ConfigurationContext::DE_ConfigurationContext()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : Load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::Load(const TCollection_AsciiString& theConfiguration)
|
||||
{
|
||||
OSD_Path aPath = theConfiguration;
|
||||
OSD_File aFile(aPath);
|
||||
if (!aFile.Exists())
|
||||
{
|
||||
if (!LoadStr(theConfiguration))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!LoadFile(theConfiguration))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadFile
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::LoadFile(const TCollection_AsciiString& theFile)
|
||||
{
|
||||
myResource.Clear();
|
||||
OSD_Path aPath(theFile);
|
||||
OSD_File aFile = aPath;
|
||||
TCollection_AsciiString FileName = aPath.Name();
|
||||
aFile.Open(OSD_ReadOnly, OSD_Protection());
|
||||
if (aFile.Failed())
|
||||
{
|
||||
Message::SendFail("Error: DE Context loading is stopped. Can't open the file");
|
||||
return Standard_True;
|
||||
}
|
||||
TCollection_AsciiString aLine;
|
||||
while (GetLine(aFile, aLine))
|
||||
{
|
||||
if (!load(aLine))
|
||||
{
|
||||
Message::SendFail() << "Error: DE Context loading is stopped. Syntax error: " << aLine;
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadStr
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::LoadStr(const TCollection_AsciiString& theResource)
|
||||
{
|
||||
myResource.Clear();
|
||||
TCollection_AsciiString aLine = "";
|
||||
const Standard_Integer aLength = theResource.Length();
|
||||
for (Standard_Integer anInd = 1; anInd <= aLength; anInd++)
|
||||
{
|
||||
const Standard_Character aChar = theResource.Value(anInd);
|
||||
if (aChar != '\n')
|
||||
aLine += aChar;
|
||||
if ((aChar == '\n' || anInd == aLength) && !aLine.IsEmpty())
|
||||
{
|
||||
if (!load(aLine))
|
||||
{
|
||||
Message::SendFail() << "Error: DE Context loading is stopped. Syntax error: " << aLine;
|
||||
return Standard_False;
|
||||
}
|
||||
aLine.Clear();
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsParamSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::IsParamSet(const TCollection_AsciiString& theParam,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aResource(MakeName(theScope, theParam));
|
||||
return myResource.IsBound(aResource);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RealVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real DE_ConfigurationContext::RealVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Real theDefValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
Standard_Real aVal = 0.;
|
||||
return GetReal(theParam, aVal, theScope) ? aVal : theDefValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IntegerVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer DE_ConfigurationContext::IntegerVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Integer theDefValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
Standard_Integer aVal = 0;
|
||||
return GetInteger(theParam, aVal, theScope) ? aVal : theDefValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BooleanVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::BooleanVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Boolean theDefValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
Standard_Boolean aVal = Standard_False;
|
||||
return GetBoolean(theParam, aVal, theScope) ? aVal : theDefValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : StringVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DE_ConfigurationContext::StringVal(const TCollection_AsciiString& theParam,
|
||||
const TCollection_AsciiString& theDefValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aVal = "";
|
||||
return GetString(theParam, aVal, theScope) ? aVal : theDefValue;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetReal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::GetReal(const TCollection_AsciiString& theParam,
|
||||
Standard_Real& theValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aStr;
|
||||
if (!GetString(theParam, aStr, theScope))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
if (aStr.IsRealValue())
|
||||
{
|
||||
theValue = aStr.RealValue();
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetInteger
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::GetInteger(const TCollection_AsciiString& theParam,
|
||||
Standard_Integer& theValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aStr;
|
||||
if (!GetString(theParam, aStr, theScope))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
if (aStr.IsIntegerValue())
|
||||
{
|
||||
theValue = aStr.IntegerValue();
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetBoolean
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::GetBoolean(const TCollection_AsciiString& theParam,
|
||||
Standard_Boolean& theValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aStr;
|
||||
if (!GetString(theParam, aStr, theScope))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
if (aStr.IsIntegerValue())
|
||||
{
|
||||
theValue = aStr.IntegerValue() != 0;
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::GetString(const TCollection_AsciiString& theParam,
|
||||
TCollection_AsciiString& theStr,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aResource = MakeName(theScope, theParam);
|
||||
return myResource.Find(aResource, theStr);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetStringSeq
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::GetStringSeq(const TCollection_AsciiString& theParam,
|
||||
TColStd_ListOfAsciiString& theValue,
|
||||
const TCollection_AsciiString& theScope) const
|
||||
{
|
||||
TCollection_AsciiString aStr;
|
||||
if (!GetString(theParam, aStr, theScope))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
theValue.Clear();
|
||||
TCollection_AsciiString anElem;
|
||||
const Standard_Integer aLength = aStr.Length();
|
||||
for (Standard_Integer anInd = 1; anInd <= aLength; anInd++)
|
||||
{
|
||||
const Standard_Character aChar = aStr.Value(anInd);
|
||||
anElem += aChar;
|
||||
if ((aChar == ' ' || anInd == aLength) && !anElem.IsEmpty())
|
||||
{
|
||||
anElem.RightAdjust();
|
||||
anElem.LeftAdjust();
|
||||
theValue.Append(anElem);
|
||||
anElem.Clear();
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : load
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_ConfigurationContext::load(const TCollection_AsciiString& theResourceLine)
|
||||
{
|
||||
if (theResourceLine.IsEmpty())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
TCollection_AsciiString aToken1, aToken2;
|
||||
DE_ConfigurationContext_KindOfLine aKind = WhatKindOfLine(theResourceLine, aToken1, aToken2);
|
||||
switch (aKind)
|
||||
{
|
||||
case DE_ConfigurationContext_KindOfLine_End:
|
||||
case DE_ConfigurationContext_KindOfLine_Comment:
|
||||
case DE_ConfigurationContext_KindOfLine_Empty:
|
||||
break;
|
||||
case DE_ConfigurationContext_KindOfLine_Resource:
|
||||
myResource.Bind(aToken1, aToken2);
|
||||
break;
|
||||
case DE_ConfigurationContext_KindOfLine_Error:
|
||||
break;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
@@ -1,159 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DE_ConfigurationContext_HeaderFile
|
||||
#define _DE_ConfigurationContext_HeaderFile
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <TColStd_ListOfAsciiString.hxx>
|
||||
|
||||
typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString, TCollection_AsciiString> DE_ResourceMap;
|
||||
|
||||
//! Provides convenient interface to resource file
|
||||
//! Allows loading of the resource file and getting attributes'
|
||||
//! values starting from some scope, for example
|
||||
//! if scope is defined as "ToV4" and requested parameter
|
||||
//! is "exec.op", value of "ToV4.exec.op" parameter from
|
||||
//! the resource file will be returned
|
||||
class DE_ConfigurationContext : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(DE_ConfigurationContext, Standard_Transient)
|
||||
|
||||
//! Creates an empty tool
|
||||
Standard_EXPORT DE_ConfigurationContext();
|
||||
|
||||
//! Import the custom configuration
|
||||
//! Save all parameters with their values.
|
||||
//! @param[in] theConfiguration path to configuration file or string value
|
||||
//! @return true in case of success, false otherwise
|
||||
Standard_EXPORT Standard_Boolean Load(const TCollection_AsciiString& theConfiguration);
|
||||
|
||||
//! Import the resource file.
|
||||
//! Save all parameters with their values.
|
||||
//! @param[in] theFile path to the resource file
|
||||
//! @return true in case of success, false otherwise
|
||||
Standard_EXPORT Standard_Boolean LoadFile(const TCollection_AsciiString& theFile);
|
||||
|
||||
//! Import the resource string.
|
||||
//! Save all parameters with their values.
|
||||
//! @param[in] theResource string with resource content
|
||||
//! @return true in case of success, false otherwise
|
||||
Standard_EXPORT Standard_Boolean LoadStr(const TCollection_AsciiString& theResource);
|
||||
|
||||
//! Checks for existing the parameter name
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_True if parameter is defined in the resource file
|
||||
Standard_EXPORT Standard_Boolean IsParamSet(const TCollection_AsciiString& theParam,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[out] theValue value to get by parameter
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_False if parameter is not defined or has a wrong type
|
||||
Standard_EXPORT Standard_Boolean GetReal(const TCollection_AsciiString& theParam,
|
||||
Standard_Real& theValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[out] theValue value to get by parameter
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_False if parameter is not defined or has a wrong type
|
||||
Standard_EXPORT Standard_Boolean GetInteger(const TCollection_AsciiString& theParam,
|
||||
Standard_Integer& theValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[out] theValue value to get by parameter
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_False if parameter is not defined or has a wrong type
|
||||
Standard_EXPORT Standard_Boolean GetBoolean(const TCollection_AsciiString& theParam,
|
||||
Standard_Boolean& theValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[out] theValue value to get by parameter
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_False if parameter is not defined or has a wrong type
|
||||
Standard_EXPORT Standard_Boolean GetString(const TCollection_AsciiString& theParam,
|
||||
TCollection_AsciiString& theValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[out] theValue value to get by parameter
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return Standard_False if parameter is not defined or has a wrong type
|
||||
Standard_EXPORT Standard_Boolean GetStringSeq(const TCollection_AsciiString& theParam,
|
||||
TColStd_ListOfAsciiString& theValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[in] theDefValue value by default if param is not found or has wrong type
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return specific type value
|
||||
Standard_EXPORT Standard_Real RealVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Real theDefValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[in] theDefValue value by default if param is not found or has wrong type
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return specific type value
|
||||
Standard_EXPORT Standard_Integer IntegerVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Integer theDefValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[in] theDefValue value by default if param is not found or has wrong type
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return specific type value
|
||||
Standard_EXPORT Standard_Boolean BooleanVal(const TCollection_AsciiString& theParam,
|
||||
const Standard_Boolean theDefValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets value of parameter as being of specific type
|
||||
//! @param[in] theParam complex parameter name
|
||||
//! @param[in] theDefValue value by default if param is not found or has wrong type
|
||||
//! @param[in] theScope base parameter name
|
||||
//! @return specific type value
|
||||
Standard_EXPORT TCollection_AsciiString StringVal(const TCollection_AsciiString& theParam,
|
||||
const TCollection_AsciiString& theDefValue,
|
||||
const TCollection_AsciiString& theScope = "") const;
|
||||
|
||||
//! Gets internal resource map
|
||||
//! @return map with resource value
|
||||
Standard_EXPORT const DE_ResourceMap& GetInternalMap() const { return myResource; }
|
||||
|
||||
protected:
|
||||
|
||||
//! Update the resource with param value from the line
|
||||
//! @paramp[in] theResourceLine line contains the parameter
|
||||
//! @return true if theResourceLine has loaded correctly
|
||||
Standard_Boolean load(const TCollection_AsciiString& theResourceLine);
|
||||
|
||||
private:
|
||||
|
||||
DE_ResourceMap myResource; //!< Internal parameters map
|
||||
|
||||
};
|
||||
|
||||
#endif // _DE_ConfigurationContext_HeaderFile
|
@@ -1,149 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
|
||||
#include <DE_Provider.hxx>
|
||||
#include <DE_Wrapper.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_ConfigurationNode::DE_ConfigurationNode() :
|
||||
myIsEnabled(Standard_True)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_ConfigurationNode::DE_ConfigurationNode(const Handle(DE_ConfigurationNode)& theConfigurationNode)
|
||||
{
|
||||
GlobalParameters = theConfigurationNode->GlobalParameters;
|
||||
myIsEnabled = theConfigurationNode->IsEnabled();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::Load(const TCollection_AsciiString& theResourcePath)
|
||||
{
|
||||
Handle(DE_ConfigurationContext) aResource = new DE_ConfigurationContext();
|
||||
aResource->LoadFile(theResourcePath);
|
||||
return Load(aResource);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::Save(const TCollection_AsciiString& theResourcePath) const
|
||||
{
|
||||
OSD_Path aPath = theResourcePath;
|
||||
OSD_File aFile(aPath);
|
||||
OSD_Protection aProt;
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
aFile.Build(OSD_ReadWrite, aProt);
|
||||
}
|
||||
catch (Standard_Failure const&)
|
||||
{
|
||||
Message::SendFail() << "Error: Configuration writing process was stopped. Can't build file.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (aFile.Failed())
|
||||
{
|
||||
Message::SendFail() << "Error: Configuration writing process was stopped. Can't build file.";
|
||||
return false;
|
||||
}
|
||||
TCollection_AsciiString aResConfiguration = Save();
|
||||
aFile.Write(aResConfiguration, aResConfiguration.Length());
|
||||
aFile.Close();
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : UpdateLoad
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::UpdateLoad()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckForSupport
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::CheckExtension(const TCollection_AsciiString& theExtension) const
|
||||
{
|
||||
TCollection_AsciiString anExtension(theExtension);
|
||||
if (anExtension.IsEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (anExtension.Value(1) == '.')
|
||||
{
|
||||
anExtension.Remove(1);
|
||||
}
|
||||
const TColStd_ListOfAsciiString& anExtensions = GetExtensions();
|
||||
for (TColStd_ListOfAsciiString::Iterator anIter(anExtensions);
|
||||
anIter.More(); anIter.Next())
|
||||
{
|
||||
if (TCollection_AsciiString::IsSameString(anIter.Value(), anExtension, Standard_False))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckForSupport
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DE_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
(void)theBuffer;
|
||||
return false;
|
||||
}
|
@@ -1,154 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DE_ConfigurationNode_HeaderFile
|
||||
#define _DE_ConfigurationNode_HeaderFile
|
||||
|
||||
#include <TColStd_ListOfAsciiString.hxx>
|
||||
|
||||
class DE_ConfigurationContext;
|
||||
class DE_Provider;
|
||||
class NCollection_Buffer;
|
||||
|
||||
//! Base class to work with CAD transfer properties.
|
||||
//! Stores the necessary settings for a single Provider type.
|
||||
//! Configures and creates special provider to transfer CAD files.
|
||||
//!
|
||||
//! Nodes are grouped by Vendor's name and Format type.
|
||||
//! The Vendor name is not defined by default.
|
||||
//! The Format type is not defined by default.
|
||||
//! The supported CAD extensions are not defined by default.
|
||||
//! The import process is not supported.
|
||||
//! The export process is not supported.
|
||||
//!
|
||||
//! The algorithm for standalone transfer operation:
|
||||
//! 1) Create new empty Node object
|
||||
//! 2) Configure the current Node
|
||||
//! 2.1) Use the external resource file to configure (::Load)
|
||||
//! 2.2) Change the internal parameters directly:
|
||||
//! 2.2.1) Change field values of "GlobalParameters"
|
||||
//! 2.2.2) Change field values of "InternalParameters"
|
||||
//! 3) Create one-time transfer provider (::BuildProvider)
|
||||
//! 4) Initiate the transfer process:
|
||||
//! 4.1) Import (if "::IsImportSupported: returns TRUE)
|
||||
//! 4.1.1) Validate the support of input format (::CheckContent or ::CheckExtension)
|
||||
//! 4.1.2) Use created provider's "::Read" method
|
||||
//! 4.2) Export (if "::IsExportSupported: returns TRUE)
|
||||
//! 4.2.1) Use created provider's "::Write" method
|
||||
//! 5) Check the provider's output
|
||||
class DE_ConfigurationNode : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Initializes all field by default
|
||||
Standard_EXPORT DE_ConfigurationNode();
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @param[in] theConfigurationNode object to copy
|
||||
Standard_EXPORT DE_ConfigurationNode(const Handle(DE_ConfigurationNode)& theConfigurationNode);
|
||||
|
||||
//! Updates values according the resource file
|
||||
//! @param[in] theResourcePath file path to resource
|
||||
//! @return True if Load was successful
|
||||
Standard_EXPORT virtual bool Load(const TCollection_AsciiString& theResourcePath = "");
|
||||
|
||||
//! Updates values according the resource
|
||||
//! @param[in] theResource input resource to use
|
||||
//! @return True if Load was successful
|
||||
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) = 0;
|
||||
|
||||
//! Writes configuration to the resource file
|
||||
//! @param[in] theResourcePath file path to resource
|
||||
//! @return True if Save was successful
|
||||
Standard_EXPORT bool Save(const TCollection_AsciiString& theResourcePath) const;
|
||||
|
||||
//! Writes configuration to the string
|
||||
//! @return result resource string
|
||||
Standard_EXPORT virtual TCollection_AsciiString Save() const = 0;
|
||||
|
||||
//! Creates new provider for the own format
|
||||
//! @return new created provider
|
||||
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() = 0;
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @return new object with the same field values
|
||||
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const = 0;
|
||||
|
||||
//! Update loading status. Checking for the license.
|
||||
//! @return Standard_True, if node can be used
|
||||
Standard_EXPORT virtual bool UpdateLoad();
|
||||
|
||||
public:
|
||||
|
||||
//! Checks the import supporting
|
||||
//! @return Standard_True if import is support
|
||||
Standard_EXPORT virtual bool IsImportSupported() const;
|
||||
|
||||
//! Checks the export supporting
|
||||
//! @return Standard_True if export is support
|
||||
Standard_EXPORT virtual bool IsExportSupported() const;
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const = 0;
|
||||
|
||||
//! Gets list of supported file extensions
|
||||
//! @return list of extensions
|
||||
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const = 0;
|
||||
|
||||
//! Checks the file extension to verify a format
|
||||
//! @param[in] theExtension input file extension
|
||||
//! @return Standard_True if file is supported by a current provider
|
||||
Standard_EXPORT virtual bool CheckExtension(const TCollection_AsciiString& theExtension) const;
|
||||
|
||||
//! Checks the file content to verify a format
|
||||
//! @param[in] theBuffer read stream buffer to check content
|
||||
//! @return Standard_True if file is supported by a current provider
|
||||
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Gets the provider loading status
|
||||
//! @return Standard_True if the load is correct
|
||||
Standard_Boolean IsEnabled() const
|
||||
{
|
||||
return myIsEnabled;
|
||||
}
|
||||
|
||||
//! Sets the provider loading status
|
||||
//! @param[in] theIsLoaded input load status
|
||||
void SetEnabled(const Standard_Boolean theIsLoaded)
|
||||
{
|
||||
myIsEnabled = theIsLoaded;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
//!< Internal parameters for transfer process
|
||||
struct DE_SectionGlobal
|
||||
{
|
||||
Standard_Real LengthUnit = 1.0; //!< Scale length unit value from MM, default 1.0 (MM)
|
||||
} GlobalParameters;
|
||||
|
||||
private:
|
||||
|
||||
Standard_Boolean myIsEnabled; //!< Flag to use a current provider for Read or Write process via DE_Wrapper
|
||||
|
||||
};
|
||||
|
||||
#endif // _DE_ConfigurationNode_HeaderFile
|
@@ -1,170 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DE_Provider.hxx>
|
||||
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
#include <Message.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_Provider::DE_Provider()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_Provider::DE_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
:myNode(theNode)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theDocument;
|
||||
(void)theWS;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() <<" doesn't support read operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theDocument;
|
||||
(void)theWS;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support write operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theDocument;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support read operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theDocument;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support write operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theShape;
|
||||
(void)theWS;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support read operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theShape;
|
||||
(void)theWS;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support write operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theShape;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support read operation";
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)thePath;
|
||||
(void)theShape;
|
||||
(void)theProgress;
|
||||
Message::SendFail() << "Error: provider " << GetFormat() <<
|
||||
" " << GetVendor() << " doesn't support write operation";
|
||||
return Standard_False;
|
||||
}
|
@@ -1,167 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DE_Provider_HeaderFile
|
||||
#define _DE_Provider_HeaderFile
|
||||
|
||||
#include <Message_ProgressRange.hxx>
|
||||
|
||||
class DE_ConfigurationNode;
|
||||
class TopoDS_Shape;
|
||||
class XSControl_WorkSession;
|
||||
class TDocStd_Document;
|
||||
|
||||
//! Base class to make transfer process.
|
||||
//! Reads or Writes specialized CAD files into/from OCCT.
|
||||
//! Each operation needs the Configuration Node.
|
||||
//!
|
||||
//! Providers are grouped by Vendor's name and Format type.
|
||||
//! The Vendor name is not defined by default.
|
||||
//! The Format type is not defined by default.
|
||||
//! The import process is not supported.
|
||||
//! The export process is not supported.
|
||||
//!
|
||||
//! The algorithm for standalone transfer operation:
|
||||
//! 1) Create new empty Provider object
|
||||
//! 2) Configure the current object by special Configuration Node (::SetNode)
|
||||
//! 3) Initiate the transfer process:
|
||||
//! 3.1) Call the required Read method (if Read methods are implemented)
|
||||
//! 3.2) Call the required Write method (if Write methods are implemented)
|
||||
//! 4) Validate the output values
|
||||
class DE_Provider : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
//! Configure translation process with global configuration
|
||||
Standard_EXPORT DE_Provider();
|
||||
|
||||
//! Configure translation process
|
||||
//! @param[in] theNode object to copy
|
||||
Standard_EXPORT DE_Provider(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
public:
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Read was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Write was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Read was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Write was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Read was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Write was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Read was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return True if Write was successful
|
||||
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
public:
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const = 0;
|
||||
|
||||
//! Gets internal configuration node
|
||||
//! @return configuration node object
|
||||
Handle(DE_ConfigurationNode) GetNode() const
|
||||
{
|
||||
return myNode;
|
||||
}
|
||||
|
||||
//! Sets internal configuration node
|
||||
//! @param[in] theNode configuration node to set
|
||||
void SetNode(const Handle(DE_ConfigurationNode)& theNode)
|
||||
{
|
||||
myNode = theNode;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Handle(DE_ConfigurationNode) myNode; //!< Internal configuration for the own format
|
||||
};
|
||||
|
||||
#endif // _DE_Provider_HeaderFile
|
@@ -1,547 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DE_Wrapper.hxx>
|
||||
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
#include <DE_Provider.hxx>
|
||||
#include <Message_ProgressRange.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <OSD_FileSystem.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
|
||||
{
|
||||
static const TCollection_AsciiString aScope ("global");
|
||||
return aScope;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_Wrapper
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_Wrapper::DE_Wrapper()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : DE_Wrapper
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
|
||||
: DE_Wrapper()
|
||||
{
|
||||
if (theWrapper.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
GlobalParameters = theWrapper->GlobalParameters;
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(theWrapper->Nodes());
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
Bind(aVendorIter.Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GlobalWrapper
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Wrapper) DE_Wrapper::GlobalWrapper()
|
||||
{
|
||||
static const Handle(DE_Wrapper)& aConfiguration = new DE_Wrapper();
|
||||
return aConfiguration;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
|
||||
Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theDocument.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
return Read(thePath, theDocument, theProgress);
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_True, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Read(thePath, theDocument, theWS, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theDocument.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
return Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_False, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Write(thePath, theDocument, theWS, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
|
||||
Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theDocument.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_True, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Read(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theDocument.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_False, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
return Read(thePath, theShape, theProgress);
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_True, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Read(thePath, theShape, theWS, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
return Write(thePath, theShape, theProgress);
|
||||
}
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_False, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Write(thePath, theShape, theWS, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_True, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Read(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(DE_Provider) aProvider;
|
||||
if (!findProvider(thePath, Standard_False, aProvider))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return aProvider->Write(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Load(const TCollection_AsciiString& theResource,
|
||||
const Standard_Boolean theIsRecursive)
|
||||
{
|
||||
Handle(DE_ConfigurationContext) aResource = new DE_ConfigurationContext();
|
||||
aResource->Load(theResource);
|
||||
return Load(aResource, theIsRecursive);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Load(const Handle(DE_ConfigurationContext)& theResource,
|
||||
const Standard_Boolean theIsRecursive)
|
||||
{
|
||||
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit", GlobalParameters.LengthUnit, THE_CONFIGURATION_SCOPE());
|
||||
if (theIsRecursive)
|
||||
{
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
aVendorIter.Value()->Load(theResource);
|
||||
}
|
||||
}
|
||||
sort(theResource);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Save(const TCollection_AsciiString& theResourcePath,
|
||||
const Standard_Boolean theIsRecursive,
|
||||
const TColStd_ListOfAsciiString& theFormats,
|
||||
const TColStd_ListOfAsciiString& theVendors)
|
||||
{
|
||||
OSD_Path aPath = theResourcePath;
|
||||
OSD_File aFile(aPath);
|
||||
OSD_Protection aProt;
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
aFile.Build(OSD_ReadWrite, aProt);
|
||||
}
|
||||
catch (Standard_Failure const&)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
if (aFile.Failed())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
TCollection_AsciiString aResConfiguration = Save(theIsRecursive, theFormats, theVendors);
|
||||
aFile.Write(aResConfiguration, aResConfiguration.Length());
|
||||
aFile.Close();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
|
||||
const TColStd_ListOfAsciiString& theFormats,
|
||||
const TColStd_ListOfAsciiString& theVendors)
|
||||
{
|
||||
TCollection_AsciiString aResult;
|
||||
aResult += "!Description of the config file for DE toolkit\n";
|
||||
aResult += "!*****************************************************************************\n";
|
||||
aResult += "!\n";
|
||||
aResult += "!Format of the file is compliant with the standard Open CASCADE resource files\n";
|
||||
aResult += "!Each key defines a sequence of either further keys.\n";
|
||||
aResult += "!Keys can be nested down to an arbitrary level.\n";
|
||||
aResult += "!\n";
|
||||
aResult += "!*****************************************************************************\n";
|
||||
aResult += "!DE_Wrapper\n";
|
||||
aResult += "!Priority vendor list. For every CAD format set indexed list of vendors\n";
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
const TCollection_AsciiString& aFormat = aFormatIter.Key();
|
||||
aResult += THE_CONFIGURATION_SCOPE() + '.' + "priority" + '.' + aFormat + " :\t ";
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
const TCollection_AsciiString& aVendorName = aVendorIter.Value()->GetVendor();
|
||||
aResult += aVendorName + " ";
|
||||
}
|
||||
aResult += "\n";
|
||||
}
|
||||
aResult += "!Global parameters. Used for all providers\n";
|
||||
aResult += "!Length scale unit value. Should be more the 0. Default value: 1.0(MM)\n";
|
||||
aResult += THE_CONFIGURATION_SCOPE() + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
|
||||
if (theIsRecursive)
|
||||
{
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
if (!theFormats.IsEmpty() && !theFormats.Contains(aFormatIter.Key()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
if (!theVendors.IsEmpty() && !theVendors.Contains(aVendorIter.Key()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
aResult += "!\n";
|
||||
aResult += aVendorIter.Value()->Save();
|
||||
aResult += "!\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
aResult += "!*****************************************************************************\n";
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Bind
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Bind(const Handle(DE_ConfigurationNode)& theNode)
|
||||
{
|
||||
if (theNode.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
const TCollection_AsciiString aFileFormat = theNode->GetFormat();
|
||||
const TCollection_AsciiString aVendorName = theNode->GetVendor();
|
||||
DE_ConfigurationVendorMap* aVendorMap = myConfiguration.ChangeSeek(aFileFormat);
|
||||
if (aVendorMap == NULL)
|
||||
{
|
||||
DE_ConfigurationVendorMap aTmpVendorMap;
|
||||
aVendorMap = myConfiguration.Bound(aFileFormat, aTmpVendorMap);
|
||||
}
|
||||
return aVendorMap->Add(aVendorName, theNode) > 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Find
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::Find(const TCollection_AsciiString& theFormat,
|
||||
const TCollection_AsciiString& theVendor,
|
||||
Handle(DE_ConfigurationNode)& theNode) const
|
||||
{
|
||||
const DE_ConfigurationVendorMap* aVendorMap = myConfiguration.Seek(theFormat);
|
||||
return aVendorMap != nullptr && aVendorMap->FindFromKey(theVendor, theNode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ChangePriority
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
|
||||
const TColStd_ListOfAsciiString& theVendorPriority,
|
||||
const Standard_Boolean theToDisable)
|
||||
{
|
||||
DE_ConfigurationVendorMap aVendorMap;
|
||||
if (!myConfiguration.Find(theFormat, aVendorMap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
DE_ConfigurationVendorMap aNewVendorMap;
|
||||
// Sets according to the input priority
|
||||
for (TColStd_ListOfAsciiString::Iterator aPriorIter(theVendorPriority);
|
||||
aPriorIter.More(); aPriorIter.Next())
|
||||
{
|
||||
const TCollection_AsciiString& aVendorName = aPriorIter.Value();
|
||||
Handle(DE_ConfigurationNode) aNode;
|
||||
if (aVendorMap.FindFromKey(aVendorName, aNode))
|
||||
{
|
||||
aNode->SetEnabled(Standard_True);
|
||||
aNode->UpdateLoad();
|
||||
aNewVendorMap.Add(aVendorName, aNode);
|
||||
}
|
||||
}
|
||||
// Sets not used elements
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aVendorMap);
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
const TCollection_AsciiString& aVendorName = aVendorIter.Key();
|
||||
if (!theVendorPriority.Contains(aVendorName))
|
||||
{
|
||||
Handle(DE_ConfigurationNode) aNode = aVendorIter.Value();
|
||||
if (theToDisable)
|
||||
{
|
||||
aNode->SetEnabled(Standard_False);
|
||||
}
|
||||
aNewVendorMap.Add(aVendorName, aNode);
|
||||
}
|
||||
}
|
||||
myConfiguration.Bind(theFormat, aNewVendorMap);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ChangePriority
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void DE_Wrapper::ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority,
|
||||
const Standard_Boolean theToDisable)
|
||||
{
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
ChangePriority(aFormatIter.Key(), theVendorPriority, theToDisable);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Nodes
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
const DE_ConfigurationFormatMap& DE_Wrapper::Nodes() const
|
||||
{
|
||||
return myConfiguration;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Wrapper) DE_Wrapper::Copy() const
|
||||
{
|
||||
return new DE_Wrapper(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : findProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean DE_Wrapper::findProvider(const TCollection_AsciiString& thePath,
|
||||
const Standard_Boolean theToImport,
|
||||
Handle(DE_Provider)& theProvider) const
|
||||
{
|
||||
Handle(NCollection_Buffer) aBuffer;
|
||||
if (theToImport)
|
||||
{
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
|
||||
if (aStream.get() != nullptr)
|
||||
{
|
||||
aBuffer = new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), 2048);
|
||||
aStream->read((char*)aBuffer->ChangeData(), 2048);
|
||||
aBuffer->ChangeData()[2047] = '\0';
|
||||
}
|
||||
}
|
||||
OSD_Path aPath(thePath);
|
||||
const TCollection_AsciiString anExtr = aPath.Extension();
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
|
||||
aVendorIter.More(); aVendorIter.Next())
|
||||
{
|
||||
const Handle(DE_ConfigurationNode)& aNode = aVendorIter.Value();
|
||||
if (aNode->IsEnabled() &&
|
||||
((theToImport && aNode->IsImportSupported()) ||
|
||||
(!theToImport && aNode->IsExportSupported())) &&
|
||||
(aNode->CheckExtension(anExtr) ||
|
||||
(theToImport && aNode->CheckContent(aBuffer))))
|
||||
{
|
||||
theProvider = aNode->BuildProvider();
|
||||
aNode->GlobalParameters = GlobalParameters;
|
||||
theProvider->SetNode(aNode);
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : sort
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void DE_Wrapper::sort(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE() + '.' + "priority");
|
||||
NCollection_List<Handle(DE_ConfigurationNode)> aVendors;
|
||||
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
|
||||
aFormatIter.More(); aFormatIter.Next())
|
||||
{
|
||||
TColStd_ListOfAsciiString aVendorPriority;
|
||||
if (!theResource->GetStringSeq(aFormatIter.Key(), aVendorPriority, aScope))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ChangePriority(aFormatIter.Key(), aVendorPriority, Standard_True);
|
||||
}
|
||||
}
|
@@ -1,249 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DE_Wrapper_HeaderFile
|
||||
#define _DE_Wrapper_HeaderFile
|
||||
|
||||
#include <Message_ProgressRange.hxx>
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <TColStd_ListOfAsciiString.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class XSControl_WorkSession;
|
||||
class TDocStd_Document;
|
||||
|
||||
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode), TCollection_AsciiString> DE_ConfigurationVendorMap;
|
||||
typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap, TCollection_AsciiString> DE_ConfigurationFormatMap;
|
||||
|
||||
//! The main class for working with CAD file exchange.
|
||||
//! Loads and Saves special CAD transfer property.
|
||||
//! Consolidates all supported Formats and Vendors.
|
||||
//! Automatically recognizes CAD format and uses the preferred existed Vendor.
|
||||
//! Note:
|
||||
//! If Vendor's format is not binded, the configuration loading doesn't affect on its property.
|
||||
//!
|
||||
//! Nodes are grouped by Vendor's name and Format's type.
|
||||
//! The Vendors may have the same supported CAD formats.
|
||||
//! Use a Vendor's priority for transfer operations.
|
||||
//!
|
||||
//! The algorithm for standalone transfer operation:
|
||||
//! 1) Work with global wrapper directly or make deep copy and work with it
|
||||
//! 2) Update the supported vendors and formats
|
||||
//! 2.1) Create and initialize specialized configuration node of the required format and Vendor.
|
||||
//! 2.2) Bind the created node to the internal map(::Bind)
|
||||
//! 3) Configure the transfer property by resource string or file (::Load)
|
||||
//! 3.1) Configuration can disable or enable some Vendors and formats
|
||||
//! 3.2) Configuration can change the priority of Vendors
|
||||
//! 4) Initiate the transfer process by calling "::Write" or "::Read" methods
|
||||
//! 5) Validate the transfer process output
|
||||
class DE_Wrapper : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
|
||||
|
||||
public:
|
||||
|
||||
//! Initializes all field by default
|
||||
Standard_EXPORT DE_Wrapper();
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @param[in] theWrapper object to copy
|
||||
Standard_EXPORT DE_Wrapper(const Handle(DE_Wrapper)& theWrapper);
|
||||
|
||||
//! Gets global configuration singleton
|
||||
//! @return point to global configuration
|
||||
Standard_EXPORT static Handle(DE_Wrapper) GlobalWrapper();
|
||||
|
||||
public:
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange());
|
||||
|
||||
public:
|
||||
|
||||
//! Updates values according the resource file
|
||||
//! @param[in] theResource file path to resource or resource value
|
||||
//! @param[in] theIsRecursive flag to update all nodes
|
||||
//! @return true if theResource has loaded correctly
|
||||
Standard_EXPORT Standard_Boolean Load(const TCollection_AsciiString& theResource = "",
|
||||
const Standard_Boolean theIsRecursive = Standard_True);
|
||||
|
||||
//! Updates values according the resource
|
||||
//! @param[in] theResource input resource to use
|
||||
//! @param[in] theIsRecursive flag to update all nodes
|
||||
//! @return true if theResource has loaded correctly
|
||||
Standard_EXPORT Standard_Boolean Load(const Handle(DE_ConfigurationContext)& theResource,
|
||||
const Standard_Boolean theIsRecursive = Standard_True);
|
||||
|
||||
//! Writes configuration to the resource file
|
||||
//! @param[in] theResourcePath file path to resource
|
||||
//! @param[in] theIsRecursive flag to write values of all nodes
|
||||
//! @param[in] theFormats list of formats to save. If empty, saves all available
|
||||
//! @param[in] theVendors list of providers to save. If empty, saves all available
|
||||
//! @return true if the Configuration has saved correctly
|
||||
Standard_EXPORT Standard_Boolean Save(const TCollection_AsciiString& theResourcePath,
|
||||
const Standard_Boolean theIsRecursive = Standard_True,
|
||||
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
|
||||
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
|
||||
|
||||
//! Writes configuration to the string
|
||||
//! @param[in] theIsRecursive flag to write values of all nodes
|
||||
//! @param[in] theFormats list of formats to save. If empty, saves all available
|
||||
//! @param[in] theVendors list of providers to save. If empty, saves all available
|
||||
//! @return result resource string
|
||||
Standard_EXPORT TCollection_AsciiString Save(const Standard_Boolean theIsRecursive = Standard_True,
|
||||
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
|
||||
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
|
||||
|
||||
//! Creates new node copy and adds to the map
|
||||
//! @param[in] theNode input node to copy
|
||||
//! @return Standard_True if binded
|
||||
Standard_EXPORT Standard_Boolean Bind(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
//! Finds a node associated with input format and vendor
|
||||
//! @param[in] theFormat input node CAD format
|
||||
//! @param[in] theVendor input node vendor name
|
||||
//! @param[out] theNode output node
|
||||
//! @return Standard_True if the node is found
|
||||
Standard_EXPORT Standard_Boolean Find(const TCollection_AsciiString& theFormat,
|
||||
const TCollection_AsciiString& theVendor,
|
||||
Handle(DE_ConfigurationNode)& theNode) const;
|
||||
|
||||
//! Changes provider priority to one format if it exists
|
||||
//! @param[in] theFormat input node CAD format
|
||||
//! @param[in] theVendorPriority priority of work with vendors
|
||||
//! @param[in] theToDisable flag for disabling nodes that are not included in the priority
|
||||
Standard_EXPORT void ChangePriority(const TCollection_AsciiString& theFormat,
|
||||
const TColStd_ListOfAsciiString& theVendorPriority,
|
||||
const Standard_Boolean theToDisable = Standard_False);
|
||||
|
||||
//! Changes provider priority to all loaded nodes
|
||||
//! @param[in] theVendorPriority priority of work with vendors
|
||||
//! @param[in] theToDisable flag for disabling nodes that are not included in the priority
|
||||
Standard_EXPORT void ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority,
|
||||
const Standard_Boolean theToDisable = Standard_False);
|
||||
|
||||
//! Gets format map, contains vendor map with nodes
|
||||
//! @return internal map of formats
|
||||
Standard_EXPORT const DE_ConfigurationFormatMap& Nodes() const;
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @return new object with the same field values
|
||||
Standard_EXPORT Handle(DE_Wrapper) Copy() const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Sorts the vendors according to the priority to work
|
||||
//! Formats omitted from the resource are not modified
|
||||
//! Vendors omitted from the format scope are disabled
|
||||
//! @param[in] theResource resource to get priority
|
||||
void sort(const Handle(DE_ConfigurationContext)& theResource);
|
||||
|
||||
//! Find available provider from the configuration.
|
||||
//! If there are several providers, choose the one with the highest priority.
|
||||
//! @param[in] thePath path to the CAD file
|
||||
//! @param[in] theToImport flag to finds for import. Standard_True-import, Standard_False-export
|
||||
//! @param[out] theProvider created new provider
|
||||
//! @return Standard_True if provider found and created
|
||||
Standard_Boolean findProvider(const TCollection_AsciiString& thePath,
|
||||
const Standard_Boolean theToImport,
|
||||
Handle(DE_Provider)& theProvider) const;
|
||||
|
||||
public:
|
||||
|
||||
DE_ConfigurationNode::DE_SectionGlobal GlobalParameters; //!< Internal parameters for the all translators
|
||||
|
||||
private:
|
||||
|
||||
DE_ConfigurationFormatMap myConfiguration; //!< Internal map of formats
|
||||
};
|
||||
|
||||
#endif // _DE_Wrapper_HeaderFile
|
@@ -1,8 +0,0 @@
|
||||
DE_ConfigurationContext.cxx
|
||||
DE_ConfigurationContext.hxx
|
||||
DE_ConfigurationNode.cxx
|
||||
DE_ConfigurationNode.hxx
|
||||
DE_Provider.cxx
|
||||
DE_Provider.hxx
|
||||
DE_Wrapper.cxx
|
||||
DE_Wrapper.hxx
|
@@ -1,206 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEBRepCascade_ConfigurationNode.hxx>
|
||||
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DEBRepCascade_Provider.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
|
||||
{
|
||||
static const TCollection_AsciiString aScope = "provider";
|
||||
return aScope;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{
|
||||
UpdateLoad();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode)
|
||||
:DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
UpdateLoad();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
|
||||
InternalParameters.WriteBinary =
|
||||
theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
|
||||
InternalParameters.WriteVersionBin =
|
||||
(BinTools_FormatVersion)theResource->IntegerVal("write.version.binary", InternalParameters.WriteVersionBin, aScope);
|
||||
InternalParameters.WriteVersionAscii =
|
||||
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii", InternalParameters.WriteVersionAscii, aScope);
|
||||
InternalParameters.WriteTriangles =
|
||||
theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
|
||||
InternalParameters.WriteNormals =
|
||||
theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
|
||||
{
|
||||
TCollection_AsciiString aResult;
|
||||
aResult += "!*****************************************************************************\n";
|
||||
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Write parameters:\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the binary file format\n";
|
||||
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
|
||||
aResult += aScope + "write.binary :\t " + InternalParameters.WriteBinary + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the format version for the binary format writing\n";
|
||||
aResult += "!Default value: 4. Available values: 1, 2, 3, 4\n";
|
||||
aResult += aScope + "write.version.binary :\t " + InternalParameters.WriteVersionBin + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the format version for the ASCII format writing\n";
|
||||
aResult += "!Default value: 3. Available values: 1, 2, 3\n";
|
||||
aResult += aScope + "write.version.ascii :\t " + InternalParameters.WriteVersionAscii + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the flag for storing shape with(without) triangles\n";
|
||||
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
|
||||
aResult += aScope + "write.triangles :\t " + InternalParameters.WriteTriangles + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Defines the flag for storing shape with(without) normals\n";
|
||||
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
|
||||
aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!*****************************************************************************\n";
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) DEBRepCascade_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new DEBRepCascade_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) DEBRepCascade_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new DEBRepCascade_Provider(this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("BREP");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString DEBRepCascade_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("brep");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 20)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const char* aBytes = (const char*)theBuffer->Data();
|
||||
if (::strstr(aBytes, "DBRep_DrawableShape") ||
|
||||
::strstr(aBytes, "CASCADE Topology V1") ||
|
||||
::strstr(aBytes, "CASCADE Topology V3"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,102 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DEBRepCascade_ConfigurationNode_HeaderFile
|
||||
#define _DEBRepCascade_ConfigurationNode_HeaderFile
|
||||
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
|
||||
#include <BinTools_FormatVersion.hxx>
|
||||
#include <TopTools_FormatVersion.hxx>
|
||||
|
||||
//! The purpose of this class is to configure the transfer process for BRep format
|
||||
//! Stores the necessary settings for DEBRepCascade_Provider.
|
||||
//! Configures and creates special provider to transfer BRep files.
|
||||
//!
|
||||
//! Nodes grouped by Vendor name and Format type.
|
||||
//! The Vendor name is "OCC"
|
||||
//! The Format type is "BREP"
|
||||
//! The supported CAD extension is ".brep"
|
||||
//! The import process is supported.
|
||||
//! The export process is supported.
|
||||
class DEBRepCascade_ConfigurationNode : public DE_ConfigurationNode
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
public:
|
||||
|
||||
//! Initializes all field by default
|
||||
Standard_EXPORT DEBRepCascade_ConfigurationNode();
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @param[in] theNode object to copy
|
||||
Standard_EXPORT DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode);
|
||||
|
||||
//! Updates values according the resource
|
||||
//! @param[in] theResource input resource to use
|
||||
//! @return true if theResource loading has ended correctly
|
||||
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
|
||||
|
||||
//! Writes configuration to the string
|
||||
//! @return result resource string
|
||||
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @return new object with the same field values
|
||||
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Creates new provider for the own format
|
||||
//! @return new created provider
|
||||
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Checks the import supporting
|
||||
//! @return true if import is supported
|
||||
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
|
||||
|
||||
//! Checks the export supporting
|
||||
//! @return true if export is supported
|
||||
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets list of supported file extensions
|
||||
//! @return list of extensions
|
||||
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
|
||||
|
||||
//! Checks the file content to verify a format
|
||||
//! @param[in] theBuffer read stream buffer to check content
|
||||
//! @return Standard_True if file is supported by a current provider
|
||||
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
struct DEBRep_InternalSection
|
||||
{
|
||||
// Write
|
||||
bool WriteBinary = true; //!< Defines the binary file format
|
||||
BinTools_FormatVersion WriteVersionBin = BinTools_FormatVersion_CURRENT; //!< Defines the writer version for the binary format
|
||||
TopTools_FormatVersion WriteVersionAscii = TopTools_FormatVersion_CURRENT; //!< Defines the writer version for the ASCII format
|
||||
bool WriteTriangles = true; //!< Defines the flag for storing shape with(without) triangles
|
||||
bool WriteNormals = true; //!< Defines the flag for storing shape with(without) normals
|
||||
|
||||
} InternalParameters;
|
||||
};
|
||||
|
||||
#endif // _DEBRepCascade_ConfigurationNode_HeaderFile
|
@@ -1,295 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEBRepCascade_Provider.hxx>
|
||||
|
||||
#include <BinTools.hxx>
|
||||
#include <BinXCAFDrivers.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <DEBRepCascade_ConfigurationNode.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <OSD_FileSystem.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_Provider::DEBRepCascade_Provider()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEBRepCascade_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEBRepCascade_Provider::DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
:DE_Provider(theNode)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Read(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if(theDocument.IsNull())
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
|
||||
thePath << "\t: theDocument shouldn't be null";
|
||||
return false;
|
||||
}
|
||||
TopoDS_Shape aShape;
|
||||
if (!Read(thePath, aShape, theProgress))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
|
||||
aShTool->AddShape(aShape);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
TDF_LabelSequence aLabels;
|
||||
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
|
||||
aSTool->GetFreeShapes(aLabels);
|
||||
if (aLabels.Length() <= 0)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Document contain no shapes";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aLabels.Length() == 1)
|
||||
{
|
||||
aShape = aSTool->GetShape(aLabels.Value(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
TopoDS_Compound aComp;
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.MakeCompound(aComp);
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
|
||||
{
|
||||
TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
|
||||
aBuilder.Add(aComp, aS);
|
||||
}
|
||||
aShape = aComp;
|
||||
}
|
||||
return Write(thePath, aShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Read(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Write(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
bool isBinaryFormat = true;
|
||||
{
|
||||
// probe file header to recognize format
|
||||
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
|
||||
std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
|
||||
if (aFile.get() == NULL)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
|
||||
thePath << "\t: Cannot read the file";
|
||||
return false;
|
||||
}
|
||||
|
||||
char aStringBuf[255] = {};
|
||||
aFile->read(aStringBuf, 255);
|
||||
if (aFile->fail())
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
|
||||
thePath << "\t: Cannot read the file";
|
||||
return false;
|
||||
}
|
||||
isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
|
||||
}
|
||||
|
||||
if (isBinaryFormat)
|
||||
{
|
||||
if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
|
||||
thePath << "\t: Cannot read from the file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
|
||||
thePath << "\t: Cannot read from the file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
|
||||
if (aNode->InternalParameters.WriteBinary)
|
||||
{
|
||||
if (aNode->InternalParameters.WriteVersionBin > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
|
||||
aNode->InternalParameters.WriteVersionBin < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Unknown format version";
|
||||
return false;
|
||||
}
|
||||
if (aNode->InternalParameters.WriteNormals &&
|
||||
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Vertex normals require binary format version 4 or later";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BinTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
|
||||
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionBin, theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Cannot write the file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aNode->InternalParameters.WriteVersionAscii > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
|
||||
aNode->InternalParameters.WriteVersionAscii < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Unknown format version";
|
||||
return false;
|
||||
}
|
||||
if (aNode->InternalParameters.WriteNormals &&
|
||||
aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Error: vertex normals require ascii format version 3 or later";
|
||||
return false;
|
||||
}
|
||||
if (!BRepTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
|
||||
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionAscii, theProgress))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Cannot write the file";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_Provider::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("BREP");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEBRepCascade_Provider::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
@@ -1,136 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DEBRepCascade_Provider_HeaderFile
|
||||
#define _DEBRepCascade_Provider_HeaderFile
|
||||
|
||||
#include <DE_Provider.hxx>
|
||||
|
||||
//! The class to transfer BRep files.
|
||||
//! Reads and Writes any BRep files into/from OCCT.
|
||||
//! Each operation needs configuration node.
|
||||
//!
|
||||
//! Providers grouped by Vendor name and Format type.
|
||||
//! The Vendor name is "OCC"
|
||||
//! The Format type is "BREP"
|
||||
//! The import process is supported.
|
||||
//! The export process is supported.
|
||||
class DEBRepCascade_Provider : public DE_Provider
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
//! Configure translation process with global configuration
|
||||
Standard_EXPORT DEBRepCascade_Provider();
|
||||
|
||||
//! Configure translation process
|
||||
//! @param[in] theNode object to init the DE_Provider
|
||||
Standard_EXPORT DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
public:
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // _DEBRepCascade_Provider_HeaderFile
|
@@ -1,4 +0,0 @@
|
||||
DEBRepCascade_ConfigurationNode.cxx
|
||||
DEBRepCascade_ConfigurationNode.hxx
|
||||
DEBRepCascade_Provider.cxx
|
||||
DEBRepCascade_Provider.hxx
|
@@ -1,197 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEXCAFCascade_ConfigurationNode.hxx>
|
||||
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DEXCAFCascade_Provider.hxx>
|
||||
#include <NCollection_Buffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
|
||||
namespace
|
||||
{
|
||||
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
|
||||
{
|
||||
static const TCollection_AsciiString aScope = "provider";
|
||||
return aScope;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode() :
|
||||
DE_ConfigurationNode()
|
||||
{
|
||||
UpdateLoad();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_ConfigurationNode
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode)
|
||||
:DE_ConfigurationNode(theNode)
|
||||
{
|
||||
InternalParameters = theNode->InternalParameters;
|
||||
UpdateLoad();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Load
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
|
||||
{
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
|
||||
|
||||
InternalParameters.ReadAppendMode = (PCDM_ReaderFilter::AppendMode)
|
||||
theResource->IntegerVal("read.append.mode", InternalParameters.ReadAppendMode, aScope);
|
||||
theResource->GetStringSeq("read.skip.values", InternalParameters.ReadSkipValues, aScope);
|
||||
theResource->GetStringSeq("read.values", InternalParameters.ReadValues, aScope);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Save
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
|
||||
{
|
||||
TCollection_AsciiString aResult;
|
||||
aResult += "!*****************************************************************************\n";
|
||||
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
|
||||
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Read parameters:\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Don't allow append (when the value = 0, it is the default value), ";
|
||||
aResult += "keeps existing attributes, reads only new ones(when the value = 1), ";
|
||||
aResult += "overwrites the existing attributes by the loaded ones(when the value = 2)\n";
|
||||
aResult += "!Default value: 0. Available values: 0, 1, 2\n";
|
||||
aResult += aScope + "read.append.mode :\t " + InternalParameters.ReadAppendMode + "\n";
|
||||
aResult += "!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!Overwrites the existing attributes by the loaded ones";
|
||||
aResult += "!Default value: empty. Available values: {sequence<string>}\n";
|
||||
aResult += aScope + "read.skip.values :\t ";
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
|
||||
{
|
||||
aResult += anIt.Value() + " ";
|
||||
}
|
||||
aResult += "\n!\n";
|
||||
|
||||
aResult += "!\n";
|
||||
aResult += "!1) Adds sub-tree path like \"0:2\"";
|
||||
aResult += "2) Adds attribute to read by typename. Disables the skipped attributes added. (there shouldn't be '0' after -read)\n";
|
||||
aResult += "!Default value: empty. Available values: {sequence<string>}\n";
|
||||
aResult += aScope + "read.values :\t ";
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadValues); anIt.More(); anIt.Next())
|
||||
{
|
||||
aResult += anIt.Value() + " ";
|
||||
}
|
||||
aResult += "\n!\n";
|
||||
|
||||
aResult += "!*****************************************************************************\n";
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Copy
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_ConfigurationNode) DEXCAFCascade_ConfigurationNode::Copy() const
|
||||
{
|
||||
return new DEXCAFCascade_ConfigurationNode(*this);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : BuildProvider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider()
|
||||
{
|
||||
return new DEXCAFCascade_Provider();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsImportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::IsImportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : IsExportSupported
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::IsExportSupported() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("XCAF");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetExtensions
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TColStd_ListOfAsciiString DEXCAFCascade_ConfigurationNode::GetExtensions() const
|
||||
{
|
||||
TColStd_ListOfAsciiString anExt;
|
||||
anExt.Append("xbf");
|
||||
return anExt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : CheckContent
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
|
||||
{
|
||||
if (theBuffer.IsNull() || theBuffer->Size() < 8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const char* aBytes = (const char*)theBuffer->Data();
|
||||
if (!::strncmp(aBytes, "BINFILE", 7))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@@ -1,99 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DEXCAFCascade_ConfigurationNode_HeaderFile
|
||||
#define _DEXCAFCascade_ConfigurationNode_HeaderFile
|
||||
|
||||
#include <DE_ConfigurationNode.hxx>
|
||||
#include <PCDM_ReaderFilter.hxx>
|
||||
#include <TColStd_ListOfAsciiString.hxx>
|
||||
|
||||
//! The purpose of this class is to configure the transfer process for XDE Documents
|
||||
//! Stores the necessary settings for DEXCAFCascade_Provider.
|
||||
//! Configures and creates special provider to transfer XDE Documents.
|
||||
//!
|
||||
//! Nodes grouped by Vendor name and Format type.
|
||||
//! The Vendor name is "OCC"
|
||||
//! The Format type is "XCAF"
|
||||
//! The supported CAD extension is ".xbf"
|
||||
//! The import process is supported.
|
||||
//! The export process is supported.
|
||||
class DEXCAFCascade_ConfigurationNode : public DE_ConfigurationNode
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
|
||||
public:
|
||||
|
||||
//! Initializes all field by default
|
||||
Standard_EXPORT DEXCAFCascade_ConfigurationNode();
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @param[in] theNode object to copy
|
||||
Standard_EXPORT DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode);
|
||||
|
||||
//! Updates values according the resource
|
||||
//! @param[in] theResource input resource to use
|
||||
//! @return true if theResource loading has ended correctly
|
||||
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
|
||||
|
||||
//! Writes configuration to the string
|
||||
//! @return result resource string
|
||||
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
|
||||
|
||||
//! Copies values of all fields
|
||||
//! @return new object with the same field values
|
||||
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
|
||||
|
||||
|
||||
//! Creates new provider for the own format
|
||||
//! @return new created provider
|
||||
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Checks the import supporting
|
||||
//! @return true if import is supported
|
||||
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
|
||||
|
||||
//! Checks the export supporting
|
||||
//! @return true if export is supported
|
||||
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets list of supported file extensions
|
||||
//! @return list of extensions
|
||||
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
|
||||
|
||||
//! Checks the file content to verify a format
|
||||
//! @param[in] theBuffer read stream buffer to check content
|
||||
//! @return Standard_True if file is supported by a current provider
|
||||
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
struct XCAFDoc_InternalSection
|
||||
{
|
||||
// Read
|
||||
PCDM_ReaderFilter::AppendMode ReadAppendMode = PCDM_ReaderFilter::AppendMode::AppendMode_Forbid; //!< Setting up the append mode
|
||||
TColStd_ListOfAsciiString ReadSkipValues; //!< Overwrites the existing attributes by the loaded ones
|
||||
TColStd_ListOfAsciiString ReadValues; //!< Adds sub-tree path or adds attribute to read by typename
|
||||
|
||||
} InternalParameters;
|
||||
};
|
||||
|
||||
#endif // _DEXCAFCascade_ConfigurationNode_HeaderFile
|
@@ -1,308 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DEXCAFCascade_Provider.hxx>
|
||||
|
||||
#include <BinDrivers.hxx>
|
||||
#include <BinLDrivers.hxx>
|
||||
#include <BinTObjDrivers.hxx>
|
||||
#include <BinXCAFDrivers.hxx>
|
||||
#include <StdDrivers.hxx>
|
||||
#include <StdLDrivers.hxx>
|
||||
#include <XmlDrivers.hxx>
|
||||
#include <XmlLDrivers.hxx>
|
||||
#include <XmlTObjDrivers.hxx>
|
||||
#include <XmlXCAFDrivers.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <DEXCAFCascade_ConfigurationNode.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <TDocStd_Application.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_Provider::DEXCAFCascade_Provider()
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : DEXCAFCascade_Provider
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
DEXCAFCascade_Provider::DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
|
||||
:DE_Provider(theNode)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Read(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Write(thePath, theDocument, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (theDocument.IsNull())
|
||||
{
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " <<
|
||||
thePath << "\t: theDocument shouldn't be null";
|
||||
return false;
|
||||
}
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
|
||||
<< "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
|
||||
Handle(TDocStd_Document) aDocument;
|
||||
Handle(TDocStd_Application) anApp = new TDocStd_Application();
|
||||
BinDrivers::DefineFormat(anApp);
|
||||
BinLDrivers::DefineFormat(anApp);
|
||||
BinTObjDrivers::DefineFormat(anApp);
|
||||
BinXCAFDrivers::DefineFormat(anApp);
|
||||
StdDrivers::DefineFormat(anApp);
|
||||
StdLDrivers::DefineFormat(anApp);
|
||||
XmlDrivers::DefineFormat(anApp);
|
||||
XmlLDrivers::DefineFormat(anApp);
|
||||
XmlTObjDrivers::DefineFormat(anApp);
|
||||
XmlXCAFDrivers::DefineFormat(anApp);
|
||||
Handle(PCDM_ReaderFilter) aFilter = new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
|
||||
{
|
||||
aFilter->AddSkipped(anIt.Value());
|
||||
}
|
||||
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More(); anIt.Next())
|
||||
{
|
||||
if (anIt.Value().StartsWith("0"))
|
||||
{
|
||||
aFilter->AddPath(anIt.Value());
|
||||
}
|
||||
else
|
||||
{
|
||||
aFilter->AddRead(anIt.Value());
|
||||
}
|
||||
}
|
||||
|
||||
if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
|
||||
<< "\t: Cannot open XDE document";
|
||||
return false;
|
||||
}
|
||||
theDocument->SetData(aDocument->GetData());
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(TDocStd_Application) anApp = new TDocStd_Application();
|
||||
BinXCAFDrivers::DefineFormat(anApp);
|
||||
PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
|
||||
if (!thePath.IsEmpty())
|
||||
{
|
||||
aStatus = anApp->SaveAs(theDocument, thePath, theProgress);
|
||||
}
|
||||
else if (!theDocument->IsSaved())
|
||||
{
|
||||
Message::SendFail() << "Storage error in the DEXCAFCascade_Provider during writing the file " <<
|
||||
thePath << "\t: Storage error : this document has never been saved";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
aStatus = anApp->Save(theDocument, theProgress);
|
||||
}
|
||||
|
||||
switch (aStatus)
|
||||
{
|
||||
case PCDM_SS_OK:
|
||||
return true;
|
||||
case PCDM_SS_DriverFailure:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : driver failure";
|
||||
break;
|
||||
case PCDM_SS_WriteFailure:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during the writing the file : " << thePath
|
||||
<< "\t: Storage error : write failure";
|
||||
break;
|
||||
case PCDM_SS_Failure:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : general failure";
|
||||
break;
|
||||
case PCDM_SS_Doc_IsNull:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error :: document is NULL";
|
||||
break;
|
||||
case PCDM_SS_No_Obj:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : no object";
|
||||
break;
|
||||
case PCDM_SS_Info_Section_Error:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : section error";
|
||||
break;
|
||||
case PCDM_SS_UserBreak:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : user break";
|
||||
break;
|
||||
case PCDM_SS_UnrecognizedFormat:
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
|
||||
<< "\t: Storage error : unrecognized document storage format : " << theDocument->StorageFormat();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Read(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
(void)theWS;
|
||||
return Write(thePath, theShape, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Read
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
|
||||
{
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
|
||||
<< "\t: Incorrect or empty Configuration Node";
|
||||
return false;
|
||||
}
|
||||
Handle(TDocStd_Document) aDocument;
|
||||
Handle(TDocStd_Application) anApp = new TDocStd_Application();
|
||||
BinXCAFDrivers::DefineFormat(anApp);
|
||||
anApp->NewDocument("BinXCAF", aDocument);
|
||||
Read(thePath, aDocument, theProgress);
|
||||
TDF_LabelSequence aLabels;
|
||||
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
|
||||
aSTool->GetFreeShapes(aLabels);
|
||||
if (aLabels.Length() <= 0)
|
||||
{
|
||||
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
|
||||
<< "\t: Document contain no shapes";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aLabels.Length() == 1)
|
||||
{
|
||||
theShape = aSTool->GetShape(aLabels.Value(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
TopoDS_Compound aComp;
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.MakeCompound(aComp);
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
|
||||
{
|
||||
TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
|
||||
aBuilder.Add(aComp, aS);
|
||||
}
|
||||
theShape = aComp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : Write
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress)
|
||||
{
|
||||
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
|
||||
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||
aShTool->AddShape(theShape);
|
||||
return Write(thePath, aDoc, theProgress);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetFormat
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_Provider::GetFormat() const
|
||||
{
|
||||
return TCollection_AsciiString("XCAF");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : GetVendor
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
TCollection_AsciiString DEXCAFCascade_Provider::GetVendor() const
|
||||
{
|
||||
return TCollection_AsciiString("OCC");
|
||||
}
|
@@ -1,136 +0,0 @@
|
||||
// Copyright (c) 2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _DEXCAFCascade_Provider_HeaderFile
|
||||
#define _DEXCAFCascade_Provider_HeaderFile
|
||||
|
||||
#include <DE_Provider.hxx>
|
||||
|
||||
//! The class to transfer XCAF Documents.
|
||||
//! Reads and Writes any XDE Document files into/from OCCT.
|
||||
//! Each operation needs configuration node.
|
||||
//!
|
||||
//! Providers grouped by Vendor name and Format type.
|
||||
//! The Vendor name is "OCC"
|
||||
//! The Format type is "XCAF"
|
||||
//! The import process is supported.
|
||||
//! The export process is supported.
|
||||
class DEXCAFCascade_Provider : public DE_Provider
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
|
||||
|
||||
public:
|
||||
|
||||
//! Default constructor
|
||||
//! Configure translation process with global configuration
|
||||
Standard_EXPORT DEXCAFCascade_Provider();
|
||||
|
||||
//! Configure translation process
|
||||
//! @param[in] theNode object to copy
|
||||
Standard_EXPORT DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
|
||||
|
||||
public:
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theDocument document to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theDocument document to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const Handle(TDocStd_Document)& theDocument,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param[in] theWS current work session
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
Handle(XSControl_WorkSession)& theWS,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Reads a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the import CAD file
|
||||
//! @param[out] theShape shape to save result
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Read operation has ended correctly
|
||||
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
|
||||
TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
//! Writes a CAD file, according internal configuration
|
||||
//! @param[in] thePath path to the export CAD file
|
||||
//! @param[out] theShape shape to export
|
||||
//! @param theProgress[in] progress indicator
|
||||
//! @return true if Write operation has ended correctly
|
||||
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
|
||||
|
||||
public:
|
||||
|
||||
//! Gets CAD format name of associated provider
|
||||
//! @return provider CAD format
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
|
||||
|
||||
//! Gets provider's vendor name of associated provider
|
||||
//! @return provider's vendor name
|
||||
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // _DEXCAFCascade_Provider_HeaderFile
|
@@ -1,4 +0,0 @@
|
||||
DEXCAFCascade_ConfigurationNode.cxx
|
||||
DEXCAFCascade_ConfigurationNode.hxx
|
||||
DEXCAFCascade_Provider.cxx
|
||||
DEXCAFCascade_Provider.hxx
|
@@ -7,10 +7,6 @@ TKOpenGlesTest
|
||||
TKViewerTest
|
||||
TKDraw
|
||||
TKMeshVS
|
||||
TKXDECascade
|
||||
TKTObj
|
||||
TKBinTObj
|
||||
TKXmlTObj
|
||||
TKXDESTEP
|
||||
TKSTEP
|
||||
TKSTEPAttr
|
||||
@@ -22,7 +18,6 @@ TKXSBase
|
||||
TKVRML
|
||||
TKSTL
|
||||
TKRWMesh
|
||||
TKXDE
|
||||
TKBinXCAF
|
||||
TKXmlXCAF
|
||||
TKBin
|
||||
|
@@ -60,7 +60,7 @@ public:
|
||||
//! of this conic is recomputed normal to theA, without
|
||||
//! changing the orientation of the local coordinate
|
||||
//! system (right-handed or left-handed).
|
||||
void SetYAxis (const gp_Ax2d& theAY) { pos.SetYAxis(theAY); }
|
||||
void SetYAxis (const gp_Ax2d& theAY) { pos.SetXAxis(theAY); }
|
||||
|
||||
//! Modifies this conic, redefining its local coordinate
|
||||
//! system partially, by assigning theP as its origin.
|
||||
|
@@ -20,14 +20,3 @@ GeomConvert_CompCurveToBSplineCurve.cxx
|
||||
GeomConvert_CompCurveToBSplineCurve.hxx
|
||||
GeomConvert_Units.cxx
|
||||
GeomConvert_Units.hxx
|
||||
GeomConvert_CurveToAnaCurve.cxx
|
||||
GeomConvert_CurveToAnaCurve.hxx
|
||||
GeomConvert_SurfToAnaSurf.cxx
|
||||
GeomConvert_SurfToAnaSurf.hxx
|
||||
GeomConvert_ConvType.hxx
|
||||
GeomConvert_FuncSphereLSDist.cxx
|
||||
GeomConvert_FuncSphereLSDist.hxx
|
||||
GeomConvert_FuncCylinderLSDist.cxx
|
||||
GeomConvert_FuncCylinderLSDist.hxx
|
||||
GeomConvert_FuncConeLSDist.cxx
|
||||
GeomConvert_FuncConeLSDist.hxx
|
||||
|
@@ -1,768 +0,0 @@
|
||||
// Created: 2001-05-21
|
||||
//
|
||||
// Copyright (c) 2001-2013 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
|
||||
|
||||
#include <ElCLib.hxx>
|
||||
#include <gce_MakeCirc.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_Circle.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <Geom_Ellipse.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Circ.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <GeomConvert_CurveToAnaCurve.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_Array2OfReal.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Gauss.hxx>
|
||||
|
||||
|
||||
GeomConvert_CurveToAnaCurve::GeomConvert_CurveToAnaCurve():
|
||||
myGap(Precision::Infinite()),
|
||||
myConvType(GeomConvert_MinGap),
|
||||
myTarget(GeomAbs_Line)
|
||||
{
|
||||
}
|
||||
|
||||
GeomConvert_CurveToAnaCurve::GeomConvert_CurveToAnaCurve(const Handle(Geom_Curve)& C) :
|
||||
myGap(Precision::Infinite()),
|
||||
myConvType(GeomConvert_MinGap),
|
||||
myTarget(GeomAbs_Line)
|
||||
{
|
||||
myCurve = C;
|
||||
}
|
||||
|
||||
void GeomConvert_CurveToAnaCurve::Init(const Handle(Geom_Curve)& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myGap = Precision::Infinite();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToAnalytical
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean GeomConvert_CurveToAnaCurve::ConvertToAnalytical(const Standard_Real tol,
|
||||
Handle(Geom_Curve)& theResultCurve,
|
||||
const Standard_Real F, const Standard_Real L,
|
||||
Standard_Real& NewF, Standard_Real& NewL)
|
||||
{
|
||||
if(myCurve.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
Handle(Geom_Curve) aCurve = myCurve;
|
||||
while (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
Handle(Geom_TrimmedCurve) aTrimmed = Handle(Geom_TrimmedCurve)::
|
||||
DownCast(aCurve);
|
||||
aCurve = aTrimmed->BasisCurve();
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) C = ComputeCurve(aCurve,tol,F, L, NewF, NewL, myGap, myConvType, myTarget);
|
||||
|
||||
if(C.IsNull()) return Standard_False;
|
||||
theResultCurve = C;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLinear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean GeomConvert_CurveToAnaCurve::IsLinear(const TColgp_Array1OfPnt& aPoles,
|
||||
const Standard_Real tolerance,
|
||||
Standard_Real& Deviation)
|
||||
{
|
||||
Standard_Integer nbPoles = aPoles.Length();
|
||||
if(nbPoles < 2)
|
||||
return Standard_False;
|
||||
|
||||
Standard_Real dMax = 0;
|
||||
Standard_Integer iMax1=0,iMax2=0;
|
||||
|
||||
Standard_Integer i;
|
||||
for(i = 1; i < nbPoles; i++)
|
||||
for(Standard_Integer j = i+1; j <= nbPoles; j++) {
|
||||
Standard_Real dist = aPoles(i).SquareDistance(aPoles(j));
|
||||
if(dist > dMax) {
|
||||
dMax = dist;
|
||||
iMax1 = i;
|
||||
iMax2 = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (dMax < Precision::SquareConfusion())
|
||||
return Standard_False;
|
||||
|
||||
Standard_Real tol2 = tolerance*tolerance;
|
||||
gp_Vec avec (aPoles(iMax1),aPoles(iMax2)); gp_Dir adir (avec); gp_Lin alin (aPoles(iMax1),adir);
|
||||
|
||||
Standard_Real aMax = 0.;
|
||||
for(i = 1; i <= nbPoles; i++) {
|
||||
Standard_Real dist = alin.SquareDistance(aPoles(i));
|
||||
if(dist > tol2)
|
||||
return Standard_False;
|
||||
if(dist > aMax)
|
||||
aMax = dist;
|
||||
}
|
||||
Deviation = sqrt(aMax);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Lin GeomConvert_CurveToAnaCurve::GetLine(const gp_Pnt& P1, const gp_Pnt& P2,
|
||||
Standard_Real& cf, Standard_Real& cl)
|
||||
{
|
||||
gp_Vec avec(P1, P2); gp_Dir adir(avec); gp_Lin alin(P1, adir);
|
||||
cf = ElCLib::Parameter(alin, P1);
|
||||
cl = ElCLib::Parameter(alin, P2);
|
||||
return alin;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ComputeLine
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Line) GeomConvert_CurveToAnaCurve::ComputeLine (const Handle(Geom_Curve)& curve,
|
||||
const Standard_Real tolerance,
|
||||
const Standard_Real c1, const Standard_Real c2,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
Standard_Real& Deviation)
|
||||
{
|
||||
Handle(Geom_Line) line;
|
||||
if (curve.IsNull()) return line;
|
||||
line = Handle(Geom_Line)::DownCast(curve); // qui sait
|
||||
if (!line.IsNull()) {
|
||||
cf = c1;
|
||||
cl = c2;
|
||||
Deviation = 0.;
|
||||
return line;
|
||||
}
|
||||
|
||||
gp_Pnt P1 = curve->Value (c1);
|
||||
gp_Pnt P2 = curve->Value (c2);
|
||||
if(P1.SquareDistance(P2) < Precision::SquareConfusion())
|
||||
return line;
|
||||
cf = c1; cl = c2;
|
||||
|
||||
Handle(TColgp_HArray1OfPnt) Poles;
|
||||
Standard_Integer nbPoles;
|
||||
Handle(Geom_BSplineCurve) bsc = Handle(Geom_BSplineCurve)::DownCast(curve);
|
||||
if (!bsc.IsNull()) {
|
||||
nbPoles = bsc->NbPoles();
|
||||
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
|
||||
bsc->Poles(Poles->ChangeArray1());
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(Geom_BezierCurve) bzc = Handle(Geom_BezierCurve)::DownCast(curve);
|
||||
if (!bzc.IsNull()) {
|
||||
nbPoles = bzc->NbPoles();
|
||||
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
|
||||
bzc->Poles(Poles->ChangeArray1());
|
||||
}
|
||||
else
|
||||
{
|
||||
nbPoles = 23;
|
||||
Poles = new TColgp_HArray1OfPnt(1, nbPoles);
|
||||
Standard_Real dt = (c2 - c1) / (nbPoles - 1);
|
||||
Poles->SetValue(1, P1);
|
||||
Poles->SetValue(nbPoles, P2);
|
||||
Standard_Integer i;
|
||||
for (i = 2; i < nbPoles; ++i)
|
||||
{
|
||||
Poles->SetValue(i, curve->Value(c1 + (i - 1) * dt));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!IsLinear(Poles->Array1(),tolerance,Deviation)) return line; // non
|
||||
gp_Lin alin = GetLine (P1, P2, cf, cl);
|
||||
line = new Geom_Line (alin);
|
||||
return line;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetCircle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean GeomConvert_CurveToAnaCurve::GetCircle (gp_Circ& crc,
|
||||
const gp_Pnt& P0,const gp_Pnt& P1, const gp_Pnt& P2)
|
||||
{
|
||||
// Control if points are not aligned (should be done by MakeCirc
|
||||
Standard_Real aMaxCoord = Sqrt(Precision::Infinite());
|
||||
if (Abs(P0.X()) > aMaxCoord || Abs(P0.Y()) > aMaxCoord || Abs(P0.Z()) > aMaxCoord)
|
||||
return Standard_False;
|
||||
if (Abs(P1.X()) > aMaxCoord || Abs(P1.Y()) > aMaxCoord || Abs(P1.Z()) > aMaxCoord)
|
||||
return Standard_False;
|
||||
if (Abs(P2.X()) > aMaxCoord || Abs(P2.Y()) > aMaxCoord || Abs(P2.Z()) > aMaxCoord)
|
||||
return Standard_False;
|
||||
|
||||
// Building the circle
|
||||
gce_MakeCirc mkc (P0,P1,P2);
|
||||
if (!mkc.IsDone()) return Standard_False;
|
||||
crc = mkc.Value();
|
||||
if (crc.Radius() < gp::Resolution()) return Standard_False;
|
||||
// Recalage sur P0
|
||||
gp_Pnt PC = crc.Location();
|
||||
gp_Ax2 axe = crc.Position();
|
||||
gp_Vec VX (PC,P0);
|
||||
axe.SetXDirection (VX);
|
||||
crc.SetPosition (axe);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeCircle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeCircle (const Handle(Geom_Curve)& c3d,
|
||||
const Standard_Real tol,
|
||||
const Standard_Real c1, const Standard_Real c2,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
Standard_Real& Deviation)
|
||||
{
|
||||
if (c3d->IsKind (STANDARD_TYPE(Geom_Circle))) {
|
||||
cf = c1;
|
||||
cl = c2;
|
||||
Deviation = 0.;
|
||||
Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast(c3d);
|
||||
return aCirc;
|
||||
}
|
||||
|
||||
Handle(Geom_Circle) circ;
|
||||
gp_Pnt P0,P1,P2;
|
||||
Standard_Real ca = (c1+c1+c2) / 3; Standard_Real cb = (c1+c2+c2) / 3;
|
||||
P0 = c3d->Value(c1);
|
||||
P1 = c3d->Value(ca);
|
||||
P2 = c3d->Value(cb);
|
||||
|
||||
gp_Circ crc;
|
||||
if (!GetCircle (crc,P0,P1,P2)) return circ;
|
||||
|
||||
// Reste a controler que c est bien un cercle : prendre 20 points
|
||||
Standard_Real du = (c2-c1)/20;
|
||||
Standard_Integer i;
|
||||
Standard_Real aMax = 0.;
|
||||
for (i = 0; i <= 20; i ++) {
|
||||
Standard_Real u = c1+(du*i);
|
||||
gp_Pnt PP = c3d->Value(u);
|
||||
Standard_Real dist = crc.Distance(PP);
|
||||
if (dist > tol) return circ; // not done
|
||||
if (dist > aMax)
|
||||
aMax = dist;
|
||||
}
|
||||
Deviation = aMax;
|
||||
|
||||
// defining the parameters
|
||||
Standard_Real PI2 = 2 * M_PI;
|
||||
|
||||
cf = ElCLib::Parameter (crc,c3d->Value (c1));
|
||||
cf = ElCLib::InPeriod(cf, 0., PI2);
|
||||
|
||||
//first parameter should be closed to zero
|
||||
|
||||
if(Abs(cf) < Precision::PConfusion() || Abs(PI2-cf) < Precision::PConfusion())
|
||||
cf = 0.;
|
||||
|
||||
Standard_Real cm = ElCLib::Parameter (crc,c3d->Value ((c1+c2)/2.));
|
||||
cm = ElCLib::InPeriod(cm, cf, cf + PI2);
|
||||
|
||||
cl = ElCLib::Parameter (crc,c3d->Value (c2));
|
||||
cl = ElCLib::InPeriod(cl, cm, cm + PI2);
|
||||
|
||||
circ = new Geom_Circle (crc);
|
||||
return circ;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Compute Ellipse
|
||||
//=======================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : IsArrayPntPlanar
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean IsArrayPntPlanar(const Handle(TColgp_HArray1OfPnt)& HAP,
|
||||
gp_Dir& Norm, const Standard_Real prec)
|
||||
{
|
||||
Standard_Integer size = HAP->Length();
|
||||
if(size<3)
|
||||
return Standard_False;
|
||||
gp_Pnt P1 = HAP->Value(1);
|
||||
gp_Pnt P2 = HAP->Value(2);
|
||||
gp_Pnt P3 = HAP->Value(3);
|
||||
Standard_Real dist1 = P1.Distance(P2);
|
||||
Standard_Real dist2 = P1.Distance(P3);
|
||||
if( dist1<prec || dist2<prec )
|
||||
return Standard_False;
|
||||
gp_Vec V1(P1,P2);
|
||||
gp_Vec V2(P1,P3);
|
||||
if(V1.IsParallel(V2,prec))
|
||||
return Standard_False;
|
||||
gp_Vec NV = V1.Crossed(V2);
|
||||
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= 3; ++i)
|
||||
{
|
||||
if (Precision::IsInfinite(NV.Coord(i)))
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if(NV.Magnitude() < gp::Resolution())
|
||||
return Standard_False;
|
||||
|
||||
if(size>3) {
|
||||
for(i=4; i<=size; i++) {
|
||||
gp_Pnt PN = HAP->Value(i);
|
||||
dist1 = P1.Distance(PN);
|
||||
if (dist1 < prec || Precision::IsInfinite(dist1))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
gp_Vec VN(P1,PN);
|
||||
if(!NV.IsNormal(VN,prec))
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
Norm = NV;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConicdDefinition
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Boolean ConicDefinition
|
||||
( const Standard_Real a, const Standard_Real b1, const Standard_Real c,
|
||||
const Standard_Real d1, const Standard_Real e1, const Standard_Real f,
|
||||
const Standard_Boolean IsParab, const Standard_Boolean IsEllip,
|
||||
gp_Pnt& Center, gp_Dir& MainAxis, Standard_Real& Rmin, Standard_Real& Rmax )
|
||||
{
|
||||
Standard_Real Xcen = 0.,Ycen = 0., Xax = 0.,Yax = 0.;
|
||||
Standard_Real b,d,e;
|
||||
// conic : a*x2 + 2*b*x*y + c*y2 + 2*d*x + 2*e*y + f = 0.
|
||||
//Equation (a,b,c,d,e,f);
|
||||
b = b1/2.; d = d1/2.; e = e1/2.; // chgt de variable
|
||||
|
||||
Standard_Real eps = 1.E-08; // ?? comme ComputedForm
|
||||
|
||||
if (IsParab) {
|
||||
|
||||
}
|
||||
else {
|
||||
// -> Conique a centre, cas general
|
||||
// On utilise les Determinants des matrices :
|
||||
// | a b d |
|
||||
// gdet (3x3) = | b c e | et pdet (2X2) = | a b |
|
||||
// | d e f | | b c |
|
||||
|
||||
Standard_Real gdet = a*c*f + 2*b*d*e - c*d*d - a*e*e - b*b*f;
|
||||
Standard_Real pdet = a*c - b*b;
|
||||
|
||||
Xcen = (b*e - c*d) / pdet;
|
||||
Ycen = (b*d - a*e) / pdet;
|
||||
|
||||
Standard_Real term1 = a-c;
|
||||
Standard_Real term2 = 2*b;
|
||||
Standard_Real cos2t;
|
||||
Standard_Real auxil;
|
||||
|
||||
if (Abs(term2) <= eps && Abs(term1) <= eps) {
|
||||
cos2t = 1.;
|
||||
auxil = 0.;
|
||||
}
|
||||
else {
|
||||
if (Abs(term1) < eps)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
Standard_Real t2d = term2/term1; //skl 21.11.2001
|
||||
cos2t = 1./sqrt(1+t2d*t2d);
|
||||
auxil = sqrt (term1*term1 + term2*term2);
|
||||
}
|
||||
|
||||
Standard_Real cost = sqrt ( (1+cos2t)/2. );
|
||||
Standard_Real sint = sqrt ( (1-cos2t)/2. );
|
||||
|
||||
Standard_Real aprim = (a+c+auxil)/2.;
|
||||
Standard_Real cprim = (a+c-auxil)/2.;
|
||||
|
||||
if (Abs(aprim) < gp::Resolution() || Abs(cprim) < gp::Resolution())
|
||||
return Standard_False;
|
||||
|
||||
term1 = -gdet/(aprim*pdet);
|
||||
term2 = -gdet/(cprim*pdet);
|
||||
|
||||
if (IsEllip) {
|
||||
Xax = cost;
|
||||
Yax = sint;
|
||||
Rmin = sqrt ( term1);
|
||||
Rmax = sqrt ( term2);
|
||||
if(Rmax<Rmin){
|
||||
Rmax = sqrt ( term1);
|
||||
Rmin = sqrt ( term2);
|
||||
}
|
||||
}
|
||||
else if (term1 <= eps){
|
||||
Xax = -sint;
|
||||
Yax = cost;
|
||||
Rmin = sqrt (-term1);
|
||||
Rmax = sqrt (term2);
|
||||
}
|
||||
else {
|
||||
Xax = cost;
|
||||
Yax = sint;
|
||||
Rmin = sqrt (-term2);
|
||||
Rmax = sqrt (term1);
|
||||
}
|
||||
}
|
||||
Center.SetCoord (Xcen,Ycen,0.);
|
||||
MainAxis.SetCoord (Xax,Yax,0.);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeEllipse
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeEllipse(const Handle(Geom_Curve)& c3d,
|
||||
const Standard_Real tol,
|
||||
const Standard_Real c1, const Standard_Real c2,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
Standard_Real& Deviation)
|
||||
{
|
||||
if (c3d->IsKind (STANDARD_TYPE(Geom_Ellipse))) {
|
||||
cf = c1;
|
||||
cl = c2;
|
||||
Deviation = 0.;
|
||||
Handle(Geom_Ellipse) anElips = Handle(Geom_Ellipse)::DownCast(c3d);
|
||||
return anElips;
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) res;
|
||||
Standard_Real prec = Precision::PConfusion();
|
||||
|
||||
Standard_Real AF,BF,CF,DF,EF,Q1,Q2,Q3,c2n;
|
||||
Standard_Integer i;
|
||||
|
||||
gp_Pnt PStart = c3d->Value(c1);
|
||||
gp_Pnt PEnd = c3d->Value(c2);
|
||||
|
||||
const Standard_Boolean IsClos = PStart.Distance(PEnd) < prec;
|
||||
if (IsClos)
|
||||
{
|
||||
c2n=c2-(c2-c1)/5;
|
||||
}
|
||||
else
|
||||
c2n=c2;
|
||||
//
|
||||
gp_XYZ aBC;
|
||||
Handle(TColgp_HArray1OfPnt) AP = new TColgp_HArray1OfPnt(1,5);
|
||||
AP->SetValue(1,PStart);
|
||||
aBC += PStart.XYZ();
|
||||
Standard_Real dc=(c2n-c1)/4;
|
||||
for (i = 1; i < 5; i++)
|
||||
{
|
||||
gp_Pnt aP = c3d->Value(c1 + dc*i);
|
||||
AP->SetValue(i + 1, aP);
|
||||
aBC += aP.XYZ();
|
||||
}
|
||||
aBC /= 5;
|
||||
aBC *= -1;
|
||||
gp_Vec aTrans(aBC);
|
||||
for (i = 1; i <= 5; ++i)
|
||||
{
|
||||
AP->ChangeValue(i).Translate(aTrans);
|
||||
}
|
||||
gp_Dir ndir;
|
||||
if(!IsArrayPntPlanar(AP,ndir,prec))
|
||||
return res;
|
||||
|
||||
if (Abs(ndir.X()) < gp::Resolution() && Abs(ndir.Y()) < gp::Resolution()
|
||||
&& Abs(ndir.Z()) < gp::Resolution())
|
||||
return res;
|
||||
|
||||
gp_Ax3 AX(gp_Pnt(0,0,0),ndir);
|
||||
gp_Trsf Tr;
|
||||
Tr.SetTransformation(AX);
|
||||
gp_Trsf Tr2 = Tr.Inverted();
|
||||
|
||||
math_Matrix Dt(1, 5, 1, 5);
|
||||
math_Vector F(1, 5), Sl(1, 5);
|
||||
|
||||
Standard_Real XN,YN,ZN = 0.;
|
||||
gp_Pnt PT,PP;
|
||||
for(i=1; i<=5; i++) {
|
||||
PT = AP->Value(i).Transformed(Tr);
|
||||
PT.Coord(XN,YN,ZN);
|
||||
Dt(i, 1) = XN*XN;
|
||||
Dt(i, 2) = XN*YN;
|
||||
Dt(i, 3) = YN*YN;
|
||||
Dt(i, 4) = XN;
|
||||
Dt(i, 5) = YN;
|
||||
F(i) = -1.;
|
||||
}
|
||||
|
||||
math_Gauss aSolver(Dt);
|
||||
if (!aSolver.IsDone())
|
||||
return res;
|
||||
|
||||
aSolver.Solve(F, Sl);
|
||||
|
||||
AF=Sl(1);
|
||||
BF=Sl(2);
|
||||
CF=Sl(3);
|
||||
DF=Sl(4);
|
||||
EF=Sl(5);
|
||||
|
||||
Q1=AF*CF+BF*EF*DF/4-CF*DF*DF/4-BF*BF/4-AF*EF*EF/4;
|
||||
Q2=AF*CF-BF*BF/4;
|
||||
Q3=AF+CF;
|
||||
|
||||
Standard_Real Rmax, Rmin;
|
||||
gp_Pnt Center;
|
||||
gp_Dir MainAxis;
|
||||
Standard_Boolean IsParab = Standard_False, IsEllip = Standard_False;
|
||||
|
||||
if (Q2 > 0 && Q1*Q3 < 0) {
|
||||
// ellipse
|
||||
IsEllip = Standard_True;
|
||||
if (ConicDefinition(AF, BF, CF, DF, EF, 1., IsParab, IsEllip,
|
||||
Center, MainAxis, Rmin, Rmax)) {
|
||||
// create ellipse
|
||||
if (Rmax - Rmin < Precision::Confusion())
|
||||
{
|
||||
return res; //really it is circle, which must be recognized in other method
|
||||
}
|
||||
aTrans *= -1;
|
||||
Center.SetZ(ZN);
|
||||
gp_Pnt NewCenter = Center.Transformed(Tr2);
|
||||
gp_Pnt Ptmp(Center.X() + MainAxis.X() * 10,
|
||||
Center.Y() + MainAxis.Y() * 10,
|
||||
Center.Z() + MainAxis.Z() * 10);
|
||||
gp_Pnt NewPtmp = Ptmp.Transformed(Tr2);
|
||||
gp_Dir NewMainAxis(NewPtmp.X() - NewCenter.X(),
|
||||
NewPtmp.Y() - NewCenter.Y(),
|
||||
NewPtmp.Z() - NewCenter.Z());
|
||||
gp_Ax2 ax2(NewCenter, ndir, NewMainAxis);
|
||||
|
||||
gp_Elips anEllipse(ax2, Rmax, Rmin);
|
||||
anEllipse.Translate(aTrans);
|
||||
Handle(Geom_Ellipse) gell = new Geom_Ellipse(anEllipse);
|
||||
|
||||
// test for 20 points
|
||||
Standard_Real param2 = 0;
|
||||
dc = (c2 - c1) / 20;
|
||||
for (i = 1; i <= 20; i++) {
|
||||
PP = c3d->Value(c1 + i*dc);
|
||||
Standard_Real aPar = ElCLib::Parameter(anEllipse, PP);
|
||||
Standard_Real dist = gell->Value(aPar).Distance(PP);
|
||||
if (dist > tol) return res; // not done
|
||||
if (dist > param2)
|
||||
param2 = dist;
|
||||
}
|
||||
|
||||
|
||||
Deviation = param2;
|
||||
|
||||
Standard_Real PI2 = 2 * M_PI;
|
||||
cf = ElCLib::Parameter(anEllipse, c3d->Value(c1));
|
||||
cf = ElCLib::InPeriod(cf, 0., PI2);
|
||||
|
||||
//first parameter should be closed to zero
|
||||
|
||||
if (Abs(cf) < Precision::PConfusion() || Abs(PI2 - cf) < Precision::PConfusion())
|
||||
cf = 0.;
|
||||
|
||||
Standard_Real cm = ElCLib::Parameter(anEllipse, c3d->Value((c1 + c2) / 2.));
|
||||
cm = ElCLib::InPeriod(cm, cf, cf + PI2);
|
||||
|
||||
cl = ElCLib::Parameter(anEllipse, c3d->Value(c2));
|
||||
cl = ElCLib::InPeriod(cl, cm, cm + PI2);
|
||||
|
||||
res = gell;
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (Q2 < 0 && Q1 != 0) {
|
||||
// hyberbola
|
||||
}
|
||||
|
||||
if (Q2 == 0 && Q1 != 0) {
|
||||
// parabola
|
||||
}
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Geom_Curve) GeomConvert_CurveToAnaCurve::ComputeCurve(const Handle(Geom_Curve)& theC3d,
|
||||
const Standard_Real tolerance,
|
||||
const Standard_Real c1, const Standard_Real c2,
|
||||
Standard_Real& cf, Standard_Real& cl,
|
||||
Standard_Real& theGap,
|
||||
const GeomConvert_ConvType theConvType, const GeomAbs_CurveType theTarget)
|
||||
{
|
||||
cf = c1; cl = c2;
|
||||
Handle(Geom_Curve) c3d, newc3d[3];
|
||||
Standard_Integer i, imin = -1;
|
||||
c3d = theC3d;
|
||||
if (c3d.IsNull()) return newc3d[imin];
|
||||
gp_Pnt P1 = c3d->Value(c1);
|
||||
gp_Pnt P2 = c3d->Value(c2);
|
||||
gp_Pnt P3 = c3d->Value(c1 + (c2 - c1) / 2);
|
||||
Standard_Real d[3] = { RealLast(), RealLast(), RealLast() };
|
||||
Standard_Real fp[3], lp[3];
|
||||
|
||||
if (c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
|
||||
Handle(Geom_TrimmedCurve) aTc = Handle(Geom_TrimmedCurve)::DownCast(c3d);
|
||||
c3d = aTc->BasisCurve();
|
||||
}
|
||||
|
||||
if (theConvType == GeomConvert_Target)
|
||||
{
|
||||
theGap = RealLast();
|
||||
if (theTarget == GeomAbs_Line)
|
||||
{
|
||||
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], theGap);
|
||||
cf = fp[0];
|
||||
cl = lp[0];
|
||||
return newc3d[0];
|
||||
}
|
||||
if (theTarget == GeomAbs_Circle)
|
||||
{
|
||||
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], theGap);
|
||||
cf = fp[1];
|
||||
cl = lp[1];
|
||||
return newc3d[1];
|
||||
}
|
||||
if (theTarget == GeomAbs_Ellipse)
|
||||
{
|
||||
newc3d[2] = ComputeEllipse(c3d, tolerance, c1, c2, fp[2], lp[2], theGap);
|
||||
cf = fp[2];
|
||||
cl = lp[2];
|
||||
return newc3d[2];
|
||||
}
|
||||
}
|
||||
//
|
||||
if (theConvType == GeomConvert_Simplest)
|
||||
{
|
||||
theGap = RealLast();
|
||||
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], theGap);
|
||||
if (!newc3d[0].IsNull())
|
||||
{
|
||||
cf = fp[0];
|
||||
cl = lp[0];
|
||||
return newc3d[0];
|
||||
}
|
||||
theGap = RealLast();
|
||||
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], theGap);
|
||||
if (!newc3d[1].IsNull())
|
||||
{
|
||||
cf = fp[1];
|
||||
cl = lp[1];
|
||||
return newc3d[1];
|
||||
}
|
||||
theGap = RealLast();
|
||||
newc3d[2] = ComputeEllipse(c3d, tolerance, c1, c2, fp[2], lp[2], theGap);
|
||||
if (!newc3d[2].IsNull())
|
||||
{
|
||||
cf = fp[2];
|
||||
cl = lp[2];
|
||||
return newc3d[2];
|
||||
}
|
||||
// Conversion failed, returns null curve
|
||||
return newc3d[0];
|
||||
}
|
||||
|
||||
// theConvType == GeomConvert_MinGap
|
||||
// recognition in case of small curve
|
||||
imin = -1;
|
||||
if((P1.Distance(P2) < 2*tolerance) && (P1.Distance(P3) < 2*tolerance)) {
|
||||
newc3d[1] = ComputeCircle(c3d, tolerance, c1, c2, fp[1], lp[1], d[1]);
|
||||
newc3d[0] = ComputeLine(c3d, tolerance, c1, c2, fp[0], lp[0], d[0]);
|
||||
imin = 1;
|
||||
if (newc3d[1].IsNull() || d[0] < d[1])
|
||||
{
|
||||
imin = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
d[0] = RealLast();
|
||||
newc3d[0] = ComputeLine (c3d,tolerance,c1,c2,fp[0],lp[0],d[0]);
|
||||
Standard_Real tol = Min(tolerance, d[0]);
|
||||
if (!Precision::IsInfinite(c1) && !Precision::IsInfinite(c2))
|
||||
{
|
||||
d[1] = RealLast();
|
||||
newc3d[1] = ComputeCircle(c3d, tol, c1, c2, fp[1], lp[1], d[1]);
|
||||
tol = Min(tol, d[1]);
|
||||
d[2] = RealLast();
|
||||
newc3d[2] = ComputeEllipse(c3d, tol, c1, c2, fp[2], lp[2], d[2]);
|
||||
}
|
||||
Standard_Real dd = RealLast();
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
if (newc3d[i].IsNull()) continue;
|
||||
if (d[i] < dd)
|
||||
{
|
||||
dd = d[i];
|
||||
imin = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imin >= 0)
|
||||
{
|
||||
cf = fp[imin];
|
||||
cl = lp[imin];
|
||||
theGap = d[imin];
|
||||
return newc3d[imin];
|
||||
}
|
||||
else
|
||||
{
|
||||
cf = c1;
|
||||
cl = c2;
|
||||
theGap = -1.;
|
||||
return newc3d[0]; // must be null curve;
|
||||
}
|
||||
}
|
@@ -1,133 +0,0 @@
|
||||
// Created: 2001-05-21
|
||||
//
|
||||
// Copyright (c) 2001-2013 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
|
||||
#ifndef _GeomConvert_CurveToAnaCurve_HeaderFile
|
||||
#define _GeomConvert_CurveToAnaCurve_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <GeomConvert_ConvType.hxx>
|
||||
#include <GeomAbs_CurveType.hxx>
|
||||
|
||||
class Geom_Curve;
|
||||
class Geom_Line;
|
||||
class gp_Lin;
|
||||
class gp_Pnt;
|
||||
class gp_Circ;
|
||||
|
||||
|
||||
|
||||
class GeomConvert_CurveToAnaCurve
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT GeomConvert_CurveToAnaCurve();
|
||||
|
||||
Standard_EXPORT GeomConvert_CurveToAnaCurve(const Handle(Geom_Curve)& C);
|
||||
|
||||
Standard_EXPORT void Init (const Handle(Geom_Curve)& C);
|
||||
|
||||
//! Converts me to analytical if possible with given
|
||||
//! tolerance. The new first and last parameters are
|
||||
//! returned to newF, newL
|
||||
Standard_EXPORT Standard_Boolean ConvertToAnalytical (const Standard_Real theTol, Handle(Geom_Curve)& theResultCurve, const Standard_Real F, const Standard_Real L, Standard_Real& newF, Standard_Real& newL);
|
||||
|
||||
Standard_EXPORT static Handle(Geom_Curve) ComputeCurve (const Handle(Geom_Curve)& curve, const Standard_Real tolerance,
|
||||
const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl,
|
||||
Standard_Real& theGap, const GeomConvert_ConvType theCurvType = GeomConvert_MinGap, const GeomAbs_CurveType theTarget = GeomAbs_Line);
|
||||
|
||||
//! Tries to convert the given curve to circle with given
|
||||
//! tolerance. Returns NULL curve if conversion is
|
||||
//! not possible.
|
||||
Standard_EXPORT static Handle(Geom_Curve) ComputeCircle (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
|
||||
|
||||
//! Tries to convert the given curve to ellipse with given
|
||||
//! tolerance. Returns NULL curve if conversion is
|
||||
//! not possible.
|
||||
Standard_EXPORT static Handle(Geom_Curve) ComputeEllipse (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
|
||||
|
||||
//! Tries to convert the given curve to line with given
|
||||
//! tolerance. Returns NULL curve if conversion is
|
||||
//! not possible.
|
||||
Standard_EXPORT static Handle(Geom_Line) ComputeLine (const Handle(Geom_Curve)& curve, const Standard_Real tolerance, const Standard_Real c1, const Standard_Real c2, Standard_Real& cf, Standard_Real& cl, Standard_Real& Deviation);
|
||||
|
||||
//! Returns true if the set of points is linear with given
|
||||
//! tolerance
|
||||
Standard_EXPORT static Standard_Boolean IsLinear (const TColgp_Array1OfPnt& aPoints, const Standard_Real tolerance, Standard_Real& Deviation);
|
||||
|
||||
//! Creates line on two points.
|
||||
//! Resulting parameters returned
|
||||
Standard_EXPORT static gp_Lin GetLine(const gp_Pnt& P1, const gp_Pnt& P2, Standard_Real& cf, Standard_Real& cl);
|
||||
|
||||
//! Creates circle on points. Returns true if OK.
|
||||
Standard_EXPORT static Standard_Boolean GetCircle(gp_Circ& Circ, const gp_Pnt& P0, const gp_Pnt& P1, const gp_Pnt& P2);
|
||||
|
||||
//! Returns maximal deviation of converted surface from the original
|
||||
//! one computed by last call to ConvertToAnalytical
|
||||
Standard_Real Gap() const
|
||||
{
|
||||
return myGap;
|
||||
}
|
||||
|
||||
//! Returns conversion type
|
||||
GeomConvert_ConvType GetConvType() const
|
||||
{
|
||||
return myConvType;
|
||||
}
|
||||
|
||||
//! Sets type of convertion
|
||||
void SetConvType(const GeomConvert_ConvType theConvType)
|
||||
{
|
||||
myConvType = theConvType;
|
||||
}
|
||||
|
||||
//! Returns target curve type
|
||||
GeomAbs_CurveType GetTarget() const
|
||||
{
|
||||
return myTarget;
|
||||
}
|
||||
|
||||
//! Sets target curve type
|
||||
void SetTarget(const GeomAbs_CurveType theTarget)
|
||||
{
|
||||
myTarget = theTarget;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Curve) myCurve;
|
||||
Standard_Real myGap;
|
||||
GeomConvert_ConvType myConvType;
|
||||
GeomAbs_CurveType myTarget;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _GeomConvert_CurveToAnaCurve_HeaderFile
|
@@ -1,68 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <GeomConvert_FuncConeLSDist.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GeomConvert_FuncConeLSDist
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomConvert_FuncConeLSDist::GeomConvert_FuncConeLSDist(
|
||||
const Handle(TColgp_HArray1OfXYZ)& thePoints,
|
||||
const gp_Dir& theDir):
|
||||
myPoints(thePoints), myDir(theDir)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbVariables
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GeomConvert_FuncConeLSDist::NbVariables () const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncConeLSDist::Value(const math_Vector& X, Standard_Real& F)
|
||||
{
|
||||
gp_Pnt aLoc(X(1), X(2), X(3));
|
||||
Standard_Real aSemiAngle = X(4), anR = X(5);
|
||||
gp_Ax3 aPos(aLoc, myDir);
|
||||
|
||||
F = 0.;
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
Standard_Real u, v;
|
||||
gp_Pnt aPi(myPoints->Value(i));
|
||||
ElSLib::ConeParameters(aPos, anR, aSemiAngle, aPi, u, v);
|
||||
gp_Pnt aPp;
|
||||
ElSLib::ConeD0(u, v, aPos, anR, aSemiAngle, aPp);
|
||||
F += aPi.SquareDistance(aPp);
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
@@ -1,66 +0,0 @@
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _GeomConvert_FuncConeLSDist_HeaderFile
|
||||
#define _GeomConvert_FuncConeLSDist_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
#include <math_MultipleVarFunction.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
//! Function for search of Cone canonic parameters: coordinates of center local coordinate system,
|
||||
//! direction of axis, radius and semi-angle from set of points
|
||||
//! by least square method.
|
||||
//!
|
||||
//!
|
||||
class GeomConvert_FuncConeLSDist : public math_MultipleVarFunction
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT GeomConvert_FuncConeLSDist() {};
|
||||
|
||||
Standard_EXPORT GeomConvert_FuncConeLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints,
|
||||
const gp_Dir& theDir);
|
||||
|
||||
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
|
||||
{
|
||||
myPoints = thePoints;
|
||||
}
|
||||
|
||||
void SetDir(const gp_Dir& theDir)
|
||||
{
|
||||
myDir = theDir;
|
||||
}
|
||||
|
||||
//! Number of variables.
|
||||
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
|
||||
|
||||
//! Value.
|
||||
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Handle(TColgp_HArray1OfXYZ) myPoints;
|
||||
gp_Dir myDir;
|
||||
|
||||
};
|
||||
#endif // _GeomConvert_FuncConeLSDist_HeaderFile
|
@@ -1,140 +0,0 @@
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <GeomConvert_FuncCylinderLSDist.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GeomConvert_FuncCylinderLSDist
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomConvert_FuncCylinderLSDist::GeomConvert_FuncCylinderLSDist(
|
||||
const Handle(TColgp_HArray1OfXYZ)& thePoints,
|
||||
const gp_Dir& theDir):
|
||||
myPoints(thePoints), myDir(theDir)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbVariables
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GeomConvert_FuncCylinderLSDist::NbVariables () const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncCylinderLSDist::Value(const math_Vector& X,Standard_Real& F)
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR2 = X(4)*X(4);
|
||||
|
||||
F = 0.;
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
gp_Vec aV(myPoints->Value(i) - aLoc);
|
||||
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
|
||||
Standard_Real d = aD2 - anR2;
|
||||
F += d * d;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Gradient
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncCylinderLSDist::Gradient(const math_Vector& X,math_Vector& G)
|
||||
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR = X(4), anR2 = anR * anR;
|
||||
Standard_Real x = myDir.X(), y = myDir.Y(), z = myDir.Z();
|
||||
G.Init(0.);
|
||||
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
gp_Vec aV(myPoints->Value(i) - aLoc);
|
||||
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
|
||||
Standard_Real d = aD2 - anR2;
|
||||
Standard_Real Dx0 = 2.*(aV.Z()*x - aV.X()*z)*z
|
||||
-2.*(aV.X()*y - aV.Y()*x)*y;
|
||||
Standard_Real Dy0 = -2.*(aV.Y()*z - aV.Z()*y)*z
|
||||
+2.*(aV.X()*y - aV.Y()*x)*x;
|
||||
Standard_Real Dz0 = 2.*(aV.Y()*z - aV.Z()*y)*y
|
||||
-2.*(aV.Z()*x - aV.X()*z)*x;
|
||||
|
||||
G(1) += d * Dx0;
|
||||
G(2) += d * Dy0;
|
||||
G(3) += d * Dz0;
|
||||
//
|
||||
G(4) += d;
|
||||
}
|
||||
|
||||
G *= 2;
|
||||
G(6) *= -2.*anR;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Values
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncCylinderLSDist::Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR = X(4), anR2 = anR * anR;
|
||||
Standard_Real x = myDir.X(), y = myDir.Y(), z = myDir.Z();
|
||||
|
||||
F = 0.;
|
||||
G.Init(0.);
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
gp_Vec aV(myPoints->Value(i) - aLoc);
|
||||
Standard_Real aD2 = aV.CrossSquareMagnitude(myDir);
|
||||
Standard_Real d = aD2 - anR2;
|
||||
Standard_Real Dx0 = 2.*(aV.Z()*x - aV.X()*z)*z
|
||||
- 2.*(aV.X()*y - aV.Y()*x)*y;
|
||||
Standard_Real Dy0 = -2.*(aV.Y()*z - aV.Z()*y)*z
|
||||
+ 2.*(aV.X()*y - aV.Y()*x)*x;
|
||||
Standard_Real Dz0 = 2.*(aV.Y()*z - aV.Z()*y)*y
|
||||
- 2.*(aV.Z()*x - aV.X()*z)*x;
|
||||
|
||||
G(1) += d * Dx0;
|
||||
G(2) += d * Dy0;
|
||||
G(3) += d * Dz0;
|
||||
//
|
||||
G(4) += d;
|
||||
//
|
||||
F += d * d;
|
||||
}
|
||||
|
||||
G *= 2;
|
||||
G(4) *= -2.*anR;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,100 +0,0 @@
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _GeomConvert_FuncCylinderLSDist_HeaderFile
|
||||
#define _GeomConvert_FuncCylinderLSDist_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
//! Function for search of cylinder canonic parameters: coordinates of center local coordinate system,
|
||||
//! direction of axis and radius from set of points
|
||||
//! by least square method.
|
||||
//!
|
||||
//! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
|
||||
//! for use in math_BFGS algorithm.
|
||||
//!
|
||||
//! Parametrisation:
|
||||
//! Cylinder is defined by its axis and radius. Axis is defined by 3 cartesian coordinats it location x0, y0, z0
|
||||
//! and direction, which is constant and set by user:
|
||||
//! dir.x, dir.y, dir.z
|
||||
//! The criteria is:
|
||||
//! F(x0, y0, z0, theta, phi, R) = Sum[|(P(i) - Loc)^dir|^2 - R^2]^2 => min
|
||||
//! P(i) is i-th sample point, Loc, dir - axis location and direction, R - radius
|
||||
//!
|
||||
//! The square vector product |(P(i) - Loc)^dir|^2 is:
|
||||
//!
|
||||
//! [(y - y0)*dir.z - (z - z0)*dir.y]^2 +
|
||||
//! [(z - z0)*dir.x - (x - x0)*dir.z]^2 +
|
||||
//! [(x - x0)*dir.y - (y - y0)*dir.x]^2
|
||||
//!
|
||||
//! First derivative of square vector product are:
|
||||
//! Dx0 = 2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.z
|
||||
//! -2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.y
|
||||
//! Dy0 = -2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.z
|
||||
//! +2*[(x - x0)*dir.y - (y - y0)*dir.x]*dir.x
|
||||
//! Dz0 = 2*[(y - y0)*dir.z - (z - z0)*dir.y]*dir.y
|
||||
//! -2*[(z - z0)*dir.x - (x - x0)*dir.z]*dir.x
|
||||
//!
|
||||
//! dF/dx0 : G1(...) = 2*Sum{[...]*Dx0}
|
||||
//! dF/dy0 : G2(...) = 2*Sum{[...]*Dy0}
|
||||
//! dF/dz0 : G3(...) = 2*Sum{[...]*Dz0}
|
||||
//! dF/dR : G4(...) = -4*R*Sum[...]
|
||||
//! [...] = [|(P(i) - Loc)^dir|^2 - R^2]
|
||||
class GeomConvert_FuncCylinderLSDist : public math_MultipleVarFunctionWithGradient
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT GeomConvert_FuncCylinderLSDist() {};
|
||||
|
||||
Standard_EXPORT GeomConvert_FuncCylinderLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints,
|
||||
const gp_Dir& theDir);
|
||||
|
||||
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
|
||||
{
|
||||
myPoints = thePoints;
|
||||
}
|
||||
|
||||
void SetDir(const gp_Dir& theDir)
|
||||
{
|
||||
myDir = theDir;
|
||||
}
|
||||
|
||||
//! Number of variables.
|
||||
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
|
||||
|
||||
//! Value.
|
||||
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
|
||||
|
||||
//! Gradient.
|
||||
Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) Standard_OVERRIDE;
|
||||
|
||||
//! Value and gradient.
|
||||
Standard_EXPORT Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Handle(TColgp_HArray1OfXYZ) myPoints;
|
||||
gp_Dir myDir;
|
||||
|
||||
};
|
||||
#endif // _GeomConvert_FuncCylinderLSDist_HeaderFile
|
@@ -1,115 +0,0 @@
|
||||
// Created on: 2016-05-10
|
||||
// Created by: Alexander MALYSHEV
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2016 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <GeomConvert_FuncSphereLSDist.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GeomConvert_FuncSphereLSDist
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GeomConvert_FuncSphereLSDist::GeomConvert_FuncSphereLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints):
|
||||
myPoints(thePoints)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbVariables
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GeomConvert_FuncSphereLSDist::NbVariables () const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncSphereLSDist::Value(const math_Vector& X,Standard_Real& F)
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR2 = X(4)*X(4);
|
||||
|
||||
F = 0.;
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
Standard_Real d = (myPoints->Value(i) - aLoc).SquareModulus() - anR2;
|
||||
F += d * d;
|
||||
}
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Gradient
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncSphereLSDist::Gradient(const math_Vector& X,math_Vector& G)
|
||||
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR = X(4), anR2 = anR * anR;
|
||||
|
||||
G.Init(0.);
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
gp_XYZ dLoc = myPoints->Value(i) - aLoc;
|
||||
Standard_Real d = dLoc.SquareModulus() - anR2;
|
||||
G(1) += d * dLoc.X();
|
||||
G(2) += d * dLoc.Y();
|
||||
G(3) += d * dLoc.Z();
|
||||
G(4) += d;
|
||||
}
|
||||
G *= -4;
|
||||
G(4) *= anR;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Values
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean GeomConvert_FuncSphereLSDist::Values(const math_Vector& X,Standard_Real& F,math_Vector& G)
|
||||
{
|
||||
gp_XYZ aLoc(X(1), X(2), X(3));
|
||||
Standard_Real anR = X(4), anR2 = anR * anR;
|
||||
|
||||
G.Init(0.);
|
||||
F = 0.;
|
||||
Standard_Integer i;
|
||||
for (i = myPoints->Lower(); i <= myPoints->Upper(); ++i)
|
||||
{
|
||||
gp_XYZ dLoc = myPoints->Value(i) - aLoc;
|
||||
Standard_Real d = dLoc.SquareModulus() - anR2;
|
||||
G(1) += d * dLoc.X();
|
||||
G(2) += d * dLoc.Y();
|
||||
G(3) += d * dLoc.Z();
|
||||
G(4) += d;
|
||||
F += d * d;
|
||||
}
|
||||
G *= -4;
|
||||
G(4) *= anR;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1,77 +0,0 @@
|
||||
|
||||
// Copyright (c) 1991-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2022 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _GeomConvert_FuncSphereLSDist_HeaderFile
|
||||
#define _GeomConvert_FuncSphereLSDist_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
#include <math_MultipleVarFunctionWithGradient.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
//! Function for search of sphere canonic parameters: coordinates of center and radius from set of moints
|
||||
//! by least square method.
|
||||
//! //!
|
||||
//! The class inherits math_MultipleVarFunctionWithGradient and thus is intended
|
||||
//! for use in math_BFGS algorithm.
|
||||
//!
|
||||
//! The criteria is:
|
||||
//! F(x0, y0, z0, R) = Sum[(x(i) - x0)^2 + (y(i) - y0)^2 + (z(i) - z0)^2 - R^2]^2 => min,
|
||||
//! x(i), y(i), z(i) - coordinates of sample points, x0, y0, z0, R - coordinates of center and radius of sphere,
|
||||
//! which must be defined
|
||||
//!
|
||||
//! The first derivative are:
|
||||
//! dF/dx0 : G1(x0, y0, z0, R) = -4*Sum{[...]*(x(i) - x0)}
|
||||
//! dF/dy0 : G2(x0, y0, z0, R) = -4*Sum{[...]*(y(i) - y0)}
|
||||
//! dF/dz0 : G3(x0, y0, z0, R) = -4*Sum{[...]*(z(i) - z0)}
|
||||
//! dF/dR : G4(x0, y0, z0, R) = -4*R*Sum[...]
|
||||
//! [...] = [(x(i) - x0)^2 + (y(i) - y0)^2 + (z(i) - z0)^2 - R^2]
|
||||
//!
|
||||
class GeomConvert_FuncSphereLSDist : public math_MultipleVarFunctionWithGradient
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT GeomConvert_FuncSphereLSDist() {};
|
||||
|
||||
Standard_EXPORT GeomConvert_FuncSphereLSDist(const Handle(TColgp_HArray1OfXYZ)& thePoints);
|
||||
|
||||
void SetPoints(const Handle(TColgp_HArray1OfXYZ)& thePoints)
|
||||
{
|
||||
myPoints = thePoints;
|
||||
}
|
||||
|
||||
//! Number of variables.
|
||||
Standard_EXPORT Standard_Integer NbVariables() const Standard_OVERRIDE;
|
||||
|
||||
//! Value.
|
||||
Standard_EXPORT Standard_Boolean Value(const math_Vector& X,Standard_Real& F) Standard_OVERRIDE;
|
||||
|
||||
//! Gradient.
|
||||
Standard_EXPORT Standard_Boolean Gradient(const math_Vector& X,math_Vector& G) Standard_OVERRIDE;
|
||||
|
||||
//! Value and gradient.
|
||||
Standard_EXPORT Standard_Boolean Values(const math_Vector& X,Standard_Real& F,math_Vector& G) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
Handle(TColgp_HArray1OfXYZ) myPoints;
|
||||
|
||||
};
|
||||
#endif // _GeomConvert_FuncSphereLSDist_HeaderFile
|
File diff suppressed because it is too large
Load Diff
@@ -1,135 +0,0 @@
|
||||
// Created: 1998-06-03
|
||||
//
|
||||
// Copyright (c) 1999-2013 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of commercial software by OPEN CASCADE SAS,
|
||||
// furnished in accordance with the terms and conditions of the contract
|
||||
// and with the inclusion of this copyright notice.
|
||||
// This file or any part thereof may not be provided or otherwise
|
||||
// made available to any third party.
|
||||
//
|
||||
// No ownership title to the software is transferred hereby.
|
||||
//
|
||||
// OPEN CASCADE SAS makes no representation or warranties with respect to the
|
||||
// performance of this software, and specifically disclaims any responsibility
|
||||
// for any damages, special or consequential, connected with its use.
|
||||
|
||||
#ifndef _GeomConvert_SurfToAnaSurf_HeaderFile
|
||||
#define _GeomConvert_SurfToAnaSurf_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <GeomConvert_ConvType.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <TColgp_HArray1OfXYZ.hxx>
|
||||
class Geom_Surface;
|
||||
class Geom_SurfaceOfRevolution;
|
||||
class Geom_Circle;
|
||||
|
||||
//! Converts a surface to the analitical form with given
|
||||
//! precision. Conversion is done only the surface is bspline
|
||||
//! of bezier and this can be approximed by some analytical
|
||||
//! surface with that precision.
|
||||
class GeomConvert_SurfToAnaSurf
|
||||
{
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
Standard_EXPORT GeomConvert_SurfToAnaSurf();
|
||||
|
||||
Standard_EXPORT GeomConvert_SurfToAnaSurf(const Handle(Geom_Surface)& S);
|
||||
|
||||
Standard_EXPORT void Init (const Handle(Geom_Surface)& S);
|
||||
|
||||
void SetConvType(const GeomConvert_ConvType theConvType = GeomConvert_Simplest)
|
||||
{
|
||||
myConvType = theConvType;
|
||||
}
|
||||
void SetTarget(const GeomAbs_SurfaceType theSurfType = GeomAbs_Plane)
|
||||
{
|
||||
myTarget = theSurfType;
|
||||
}
|
||||
|
||||
//! Returns maximal deviation of converted surface from the original
|
||||
//! one computed by last call to ConvertToAnalytical
|
||||
Standard_Real Gap() const
|
||||
{
|
||||
return myGap;
|
||||
}
|
||||
|
||||
//! Tries to convert the Surface to an Analytic form
|
||||
//! Returns the result
|
||||
//! In case of failure, returns a Null Handle
|
||||
//!
|
||||
Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical (const Standard_Real InitialToler);
|
||||
Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical (const Standard_Real InitialToler,
|
||||
const Standard_Real Umin, const Standard_Real Umax,
|
||||
const Standard_Real Vmin, const Standard_Real Vmax);
|
||||
|
||||
//! Returns true if surfaces is same with the given tolerance
|
||||
Standard_EXPORT static Standard_Boolean IsSame (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real tol);
|
||||
|
||||
//! Returns true, if surface is canonical
|
||||
Standard_EXPORT static Standard_Boolean IsCanonical (const Handle(Geom_Surface)& S);
|
||||
|
||||
private:
|
||||
//!static method for checking surface of revolution
|
||||
//!To avoid two-parts cone-like surface
|
||||
static void CheckVTrimForRevSurf(const Handle(Geom_SurfaceOfRevolution)& aRevSurf,
|
||||
Standard_Real& V1, Standard_Real& V2);
|
||||
|
||||
//!static method to try create cylindrical or conical surface
|
||||
static Handle(Geom_Surface) TryCylinerCone(const Handle(Geom_Surface)& theSurf, const Standard_Boolean theVCase,
|
||||
const Handle(Geom_Curve)& theUmidiso, const Handle(Geom_Curve)& theVmidiso,
|
||||
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
|
||||
const Standard_Real theToler);
|
||||
|
||||
//!static method to try create cylinrical surface using least square method
|
||||
static Standard_Boolean GetCylByLS(const Handle(TColgp_HArray1OfXYZ)& thePoints,
|
||||
const Standard_Real theTol,
|
||||
gp_Ax3& thePos, Standard_Real& theR,
|
||||
Standard_Real& theGap);
|
||||
|
||||
//!static method to try create cylinrical surface based on its Gauss field
|
||||
static Handle(Geom_Surface) TryCylinderByGaussField(const Handle(Geom_Surface)& theSurf,
|
||||
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
|
||||
const Standard_Real theToler, const Standard_Integer theNbU = 20, const Standard_Integer theNbV = 20,
|
||||
const Standard_Boolean theLeastSquare = Standard_False);
|
||||
|
||||
//! static method to try create toroidal surface.
|
||||
//! In case <isTryUMajor> = Standard_True try to use V isoline radius as minor radaius.
|
||||
static Handle(Geom_Surface) TryTorusSphere(const Handle(Geom_Surface)& theSurf,
|
||||
const Handle(Geom_Circle)& circle,
|
||||
const Handle(Geom_Circle)& otherCircle,
|
||||
const Standard_Real Param1,
|
||||
const Standard_Real Param2,
|
||||
const Standard_Real aParam1ToCrv,
|
||||
const Standard_Real aParam2ToCrv,
|
||||
const Standard_Real toler,
|
||||
const Standard_Boolean isTryUMajor);
|
||||
|
||||
static Standard_Real ComputeGap(const Handle(Geom_Surface)& theSurf,
|
||||
const Standard_Real theU1, const Standard_Real theU2, const Standard_Real theV1, const Standard_Real theV2,
|
||||
const Handle(Geom_Surface) theNewSurf, const Standard_Real theTol = RealLast());
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
Handle(Geom_Surface) mySurf;
|
||||
Standard_Real myGap;
|
||||
GeomConvert_ConvType myConvType;
|
||||
GeomAbs_SurfaceType myTarget;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _GeomConvert_SurfToAnaSurf_HeaderFile
|
@@ -102,6 +102,41 @@ static Standard_Real EvalAngle(const gp_Vec& V1,
|
||||
return angle;
|
||||
}
|
||||
|
||||
static Standard_Integer NbSamples(const Handle(Geom_Curve)& aCurve)
|
||||
{
|
||||
Standard_Real nbs = 100.; //on default
|
||||
|
||||
Handle(Geom_Curve) theCurve = aCurve;
|
||||
if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
|
||||
theCurve = (Handle(Geom_TrimmedCurve)::DownCast(aCurve))->BasisCurve();
|
||||
|
||||
if (theCurve->IsInstance(STANDARD_TYPE(Geom_Line)))
|
||||
nbs = 1;
|
||||
else if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic)))
|
||||
nbs = 4;
|
||||
else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BezierCurve)))
|
||||
{
|
||||
Handle(Geom_BezierCurve) BC = Handle(Geom_BezierCurve)::DownCast(theCurve);
|
||||
nbs = 3 + BC->NbPoles();
|
||||
}
|
||||
else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BSplineCurve)))
|
||||
{
|
||||
Handle(Geom_BSplineCurve) BC = Handle(Geom_BSplineCurve)::DownCast(theCurve);
|
||||
nbs = BC->NbKnots();
|
||||
nbs *= BC->Degree();
|
||||
Standard_Real ratio =
|
||||
(aCurve->LastParameter() - aCurve->FirstParameter())/(BC->LastParameter() - BC->FirstParameter());
|
||||
nbs *= ratio;
|
||||
if(nbs < 4.0)
|
||||
nbs = 4;
|
||||
}
|
||||
|
||||
if (nbs > 300.)
|
||||
nbs = 300;
|
||||
|
||||
return ((Standard_Integer)nbs);
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
// Function :DistMini
|
||||
// Purpose : Examine un extrema pour updater <Dist> & <Param>
|
||||
@@ -460,22 +495,24 @@ void GeomFill_SectionPlacement::Perform(const Handle(Adaptor3d_Curve)& Path,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
|
||||
{
|
||||
// Comparing the distances from the path's endpoints to the best matching plane of the profile.
|
||||
const gp_Pnt firstPoint = Path->Value(Path->FirstParameter());
|
||||
const gp_Pnt lastPoint = Path->Value(Path->LastParameter());
|
||||
const gp_Pln plane = plan->Pln();
|
||||
Standard_Real firstDistance = plane.SquareDistance(firstPoint);
|
||||
Standard_Real lastDistance = plane.SquareDistance(lastPoint);
|
||||
|
||||
if (((Abs(firstDistance) < Precision::SquareConfusion()) && Abs(lastDistance) < Precision::SquareConfusion()) ||
|
||||
firstDistance < lastDistance)
|
||||
{
|
||||
PathParam = Path->FirstParameter();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
|
||||
{
|
||||
Standard_Integer NbPnts = NbSamples( mySection );
|
||||
TColgp_Array1OfPnt Pnts( 1, NbPnts+1 );
|
||||
Standard_Real delta = (mySection->LastParameter()-mySection->FirstParameter())/NbPnts;
|
||||
for (ii = 0; ii <= NbPnts; ii++)
|
||||
Pnts(ii+1) = mySection->Value( mySection->FirstParameter() + ii*delta );
|
||||
|
||||
gp_Pnt BaryCenter;
|
||||
gp_Dir Xdir, Ydir;
|
||||
Standard_Real Xgap, Ygap, Zgap;
|
||||
GeomLib::Inertia( Pnts, BaryCenter, Xdir, Ydir, Xgap, Ygap, Zgap );
|
||||
|
||||
gp_Pnt Pfirst = Path->Value( Path->FirstParameter() );
|
||||
if (Pfirst.Distance(BaryCenter) < Plast.Distance(BaryCenter))
|
||||
PathParam = Path->FirstParameter();
|
||||
else
|
||||
{
|
||||
PathParam = Path->LastParameter();
|
||||
Tangente (*Path, PathParam, PonPath, dp1);
|
||||
PonSec = myAdpSection.Value(SecParam);
|
||||
|
@@ -432,10 +432,8 @@ static Standard_Integer intersect(Draw_Interpretor& di, Standard_Integer n, cons
|
||||
Standard_Integer aNbSegments = Intersector.NbSegments();
|
||||
for (Standard_Integer i = 1; i <= aNbSegments; i++)
|
||||
{
|
||||
Intersector.Segment(i,S1,S2);
|
||||
di << "Segment #" << i << " found.\n";
|
||||
di << "Curve 1 first parameter: " << S1->FirstParameter() << " last parameter: " << S1->LastParameter() <<"\n";
|
||||
di << "Curve 2 first parameter: " << S2->FirstParameter() << " last parameter: " << S2->LastParameter() <<"\n";
|
||||
Intersector.Segment(i,S1,S2);
|
||||
CD = new DrawTrSurf_Curve2d(S1, Draw_bleu, 30);
|
||||
dout << CD;
|
||||
CD = new DrawTrSurf_Curve2d(S2, Draw_violet, 30);
|
||||
|
@@ -59,9 +59,7 @@
|
||||
#include <Geom2dConvert.hxx>
|
||||
#include <Geom2dConvert_BSplineCurveToBezierCurve.hxx>
|
||||
#include <GeomLProp_SLProps.hxx>
|
||||
#include <GeomConvert_SurfToAnaSurf.hxx>
|
||||
#include <GeomConvert_CurveToAnaCurve.hxx>
|
||||
#include <GeomConvert_ConvType.hxx>
|
||||
|
||||
|
||||
#include <DrawTrSurf_BezierSurface.hxx>
|
||||
#include <DrawTrSurf_BSplineSurface.hxx>
|
||||
@@ -524,111 +522,6 @@ static Standard_Integer converting(Draw_Interpretor& , Standard_Integer n, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : converting to canonical
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer tocanon(Draw_Interpretor& di, Standard_Integer n, const char ** a)
|
||||
{
|
||||
if (n < 3) return 1;
|
||||
|
||||
GeomConvert_ConvType aConvType = GeomConvert_Simplest;
|
||||
GeomAbs_CurveType aCurv = GeomAbs_Line;
|
||||
GeomAbs_SurfaceType aSurf = GeomAbs_Plane;
|
||||
if (n > 4)
|
||||
{
|
||||
if (strcmp(a[4], "sim") == 0) {
|
||||
aConvType = GeomConvert_Simplest;
|
||||
}
|
||||
else if (strcmp(a[4], "gap") == 0) {
|
||||
aConvType = GeomConvert_MinGap;
|
||||
}
|
||||
else if (strcmp(a[4], "lin") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aCurv = GeomAbs_Line;
|
||||
}
|
||||
else if (strcmp(a[4], "cir") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aCurv = GeomAbs_Circle;
|
||||
}
|
||||
else if (strcmp(a[4], "ell") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aCurv = GeomAbs_Ellipse;
|
||||
}
|
||||
else if (strcmp(a[4], "pln") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aSurf = GeomAbs_Plane;
|
||||
}
|
||||
else if (strcmp(a[4], "cyl") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aSurf = GeomAbs_Cylinder;
|
||||
}
|
||||
else if (strcmp(a[4], "con") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aSurf = GeomAbs_Cone;
|
||||
}
|
||||
else if (strcmp(a[4], "sph") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aSurf = GeomAbs_Sphere;
|
||||
}
|
||||
else if (strcmp(a[4], "tor") == 0) {
|
||||
aConvType = GeomConvert_Target;
|
||||
aSurf = GeomAbs_Torus;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real tol = Precision::Confusion();
|
||||
if (n > 3)
|
||||
{
|
||||
tol = Draw::Atof(a[3]);
|
||||
}
|
||||
|
||||
Handle(Geom_Curve) GC = DrawTrSurf::GetCurve(a[2]);
|
||||
if (GC.IsNull()) {
|
||||
Handle(Geom_Surface) GS = DrawTrSurf::GetSurface(a[2]);
|
||||
if (GS.IsNull()) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
GeomConvert_SurfToAnaSurf aSurfToAna(GS);
|
||||
aSurfToAna.SetConvType(aConvType);
|
||||
if(aConvType == GeomConvert_Target)
|
||||
aSurfToAna.SetTarget(aSurf);
|
||||
Handle(Geom_Surface) anAnaSurf = aSurfToAna.ConvertToAnalytical(tol);
|
||||
if (!anAnaSurf.IsNull())
|
||||
{
|
||||
DrawTrSurf::Set(a[1], anAnaSurf);
|
||||
Standard_Real aGap = aSurfToAna.Gap();
|
||||
di << "Gap = " << aGap << "\n";
|
||||
}
|
||||
else
|
||||
di << "Conversion failed" << "\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
GeomConvert_CurveToAnaCurve aCurvToAna(GC);
|
||||
aCurvToAna.SetConvType(aConvType);
|
||||
if (aConvType == GeomConvert_Target)
|
||||
aCurvToAna.SetTarget(aCurv);
|
||||
|
||||
Handle(Geom_Curve) anAnaCurv;
|
||||
Standard_Real tf = GC->FirstParameter(), tl = GC->LastParameter(), ntf, ntl;
|
||||
Standard_Boolean isdone = aCurvToAna.ConvertToAnalytical(tol, anAnaCurv, tf, tl, ntf, ntl);
|
||||
if (isdone)
|
||||
{
|
||||
anAnaCurv = new Geom_TrimmedCurve(anAnaCurv, ntf, ntl);
|
||||
DrawTrSurf::Set(a[1], anAnaCurv);
|
||||
Standard_Real aGap = aCurvToAna.Gap();
|
||||
di << "Gap = " << aGap << "\n";
|
||||
}
|
||||
else
|
||||
di << "Conversion failed" << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : tobezier
|
||||
@@ -1821,11 +1714,6 @@ void GeomliteTest::SurfaceCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__,
|
||||
converting,g);
|
||||
|
||||
theCommands.Add("tocanon",
|
||||
"tocanon result c3d/surf [tol [sim gap lin cir ell pln cyl con sph tor]]",
|
||||
__FILE__,
|
||||
tocanon, g);
|
||||
|
||||
theCommands.Add("tobezier",
|
||||
"tobezier result c2d/c3d/surf [ufirst, ulast / ufirst, ulast, vfirst, vlast]",
|
||||
__FILE__,
|
||||
|
@@ -36,6 +36,7 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM
|
||||
//
|
||||
myStructureManager (theMgr),
|
||||
myCamera (new Graphic3d_Camera()),
|
||||
myHiddenObjects (new Graphic3d_NMapOfTransient()),
|
||||
myIsInComputedMode (Standard_False),
|
||||
myIsActive (Standard_False),
|
||||
myIsRemoved (Standard_False),
|
||||
|
@@ -134,6 +134,12 @@ public:
|
||||
//! Returns number of displayed structures in the view.
|
||||
virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
|
||||
|
||||
//! Returns map of objects hidden within this specific view (not viewer-wise).
|
||||
const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const { return myHiddenObjects; }
|
||||
|
||||
//! Returns map of objects hidden within this specific view (not viewer-wise).
|
||||
Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects() { return myHiddenObjects; }
|
||||
|
||||
//! Returns Standard_True in case if the structure with the given <theStructId> is
|
||||
//! in list of structures to be computed and stores computed struct to <theComputedStruct>.
|
||||
Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
|
||||
@@ -643,6 +649,7 @@ protected:
|
||||
Graphic3d_SequenceOfStructure myStructsToCompute;
|
||||
Graphic3d_SequenceOfStructure myStructsComputed;
|
||||
Graphic3d_MapOfStructure myStructsDisplayed;
|
||||
Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
|
||||
Standard_Boolean myIsInComputedMode;
|
||||
Standard_Boolean myIsActive;
|
||||
Standard_Boolean myIsRemoved;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user