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

Compare commits

..

1 Commits

206 changed files with 1294 additions and 10190 deletions

View File

@@ -633,26 +633,6 @@ else()
OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
endif()
# RapidJSON
# search for CSF_RapidJSON variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_RapidJSON CAN_USE_RAPIDJSON)
if (CAN_USE_RAPIDJSON)
set (USE_RAPIDJSON OFF CACHE BOOL "${USE_RAPIDJSON_DESCR}")
if (USE_RAPIDJSON)
add_definitions (-DHAVE_RAPIDJSON)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/rapidjson")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
endif()
else()
OCCT_CHECK_AND_UNSET ("USE_RAPIDJSON")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_RAPIDJSON")
OCCT_CHECK_AND_UNSET ("INSTALL_RAPIDJSON")
endif()
# EIGEN
if (CAN_USE_EIGEN)
set (USE_EIGEN OFF CACHE BOOL "${USE_EIGEN_DESCR}")

View File

@@ -440,6 +440,4 @@ t TKVCAF
n XCAFView
n XCAFNoteObjects
t TKRWMesh
n RWGltf
n RWMesh
n RWObj

View File

@@ -73,7 +73,7 @@ if (WIN32)
set (CSF_OpenGlLibs "opengl32.lib")
endif()
else()
else()
if (APPLE)
set (CSF_objc "objc")
@@ -117,6 +117,5 @@ else()
endif()
set (CSF_XwLibs "X11 Xext Xmu Xi")
set (CSF_dl "dl")
set (CSF_fontconfig "fontconfig")
endif()
endif()

View File

@@ -1,86 +0,0 @@
# RapidJSON
if (NOT DEFINED INSTALL_RAPIDJSON)
set (INSTALL_RAPIDJSON OFF CACHE BOOL "${INSTALL_RAPIDJSON_DESCR}")
endif()
# RapidJSON directory
if (NOT DEFINED 3RDPARTY_RAPIDJSON_DIR)
set (3RDPARTY_RAPIDJSON_DIR "" CACHE PATH "The directory containing RapidJSON")
endif()
# search for RapidJSON in user defined directory
if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
if (NOT 3RDPARTY_RAPIDJSON_DIR OR NOT EXISTS "${3RDPARTY_RAPIDJSON_DIR}")
FIND_PRODUCT_DIR("${3RDPARTY_DIR}" RapidJSON RAPIDJSON_DIR_NAME)
if (RAPIDJSON_DIR_NAME)
set (3RDPARTY_RAPIDJSON_DIR "${3RDPARTY_DIR}/${RAPIDJSON_DIR_NAME}" CACHE PATH "The directory containing RapidJSON" FORCE)
endif()
endif()
endif()
if (NOT DEFINED 3RDPARTY_RAPIDJSON_INCLUDE_DIR)
set (3RDPARTY_RAPIDJSON_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of the RAPIDJSON")
endif()
if (NOT 3RDPARTY_RAPIDJSON_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_RAPIDJSON_INCLUDE_DIR}")
set (HEADER_NAMES rapidjson/rapidjson.h)
set (3RDPARTY_RAPIDJSON_INCLUDE_DIR "3RDPARTY_RAPIDJSON_INCLUDE_DIR-NOTFOUND" CACHE PATH "the path to RapidJSON header file" FORCE)
if (3RDPARTY_RAPIDJSON_DIR AND EXISTS "${3RDPARTY_RAPIDJSON_DIR}")
find_path (3RDPARTY_RAPIDJSON_INCLUDE_DIR NAMES ${HEADER_NAMES}
PATHS ${3RDPARTY_RAPIDJSON_DIR}
PATH_SUFFIXES include rapidjson
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
else()
find_path (3RDPARTY_RAPIDJSON_INCLUDE_DIR NAMES ${HEADER_NAMES}
PATH_SUFFIXES include rapidjson
CMAKE_FIND_ROOT_PATH_BOTH)
endif()
# use default (CMake) RapidJSON search
if (NOT 3RDPARTY_RAPIDJSON_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_RAPIDJSON_INCLUDE_DIR}")
if (3RDPARTY_RAPIDJSON_DIR AND EXISTS "${3RDPARTY_RAPIDJSON_DIR}")
set (CACHED_RAPIDJSON_DIR $ENV{RapidJSON_DIR})
set (ENV{RapidJSON_DIR} "${3RDPARTY_RAPIDJSON_DIR}")
endif()
find_package(RapidJSON QUIET)
# restore ENV{RapidJSON_DIR}
if (3RDPARTY_RAPIDJSON_DIR AND EXISTS "${3RDPARTY_RAPIDJSON_DIR}")
set (ENV{RapidJSON_DIR} ${CACHED_RAPIDJSON_DIR})
endif()
if (${RAPIDJSON_FOUND})
set (3RDPARTY_RAPIDJSON_INCLUDE_DIR "${RAPIDJSON_INCLUDE_DIR}" CACHE PATH "the path to RapidJSON header file" FORCE)
set (3RDPARTY_RAPIDJSON_DIR "${RAPIDJSON_ROOT_DIR}" CACHE PATH "The directory containing RapidJSON" FORCE)
endif()
endif()
endif()
if (3RDPARTY_RAPIDJSON_INCLUDE_DIR AND EXISTS "${3RDPARTY_RAPIDJSON_INCLUDE_DIR}")
list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_RAPIDJSON_INCLUDE_DIR}")
# Install header files
if (INSTALL_RAPIDJSON)
file(GLOB RAPIDJSON_SUBDIRS "${3RDPARTY_RAPIDJSON_INCLUDE_DIR}/*")
foreach(SUBDIR ${RAPIDJSON_SUBDIRS})
if(IS_DIRECTORY "${SUBDIR}")
install (DIRECTORY "${SUBDIR}" DESTINATION "${INSTALL_DIR_INCLUDE}")
else()
install (FILES "${SUBDIR}" DESTINATION "${INSTALL_DIR_INCLUDE}")
endif()
endforeach()
endif()
else()
list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_RAPIDJSON_INCLUDE_DIR)
set (3RDPARTY_RAPIDJSON_INCLUDE_DIR "" CACHE PATH "the path to RapidJSON header file" FORCE)
endif()
# unset all redundant variables
OCCT_CHECK_AND_UNSET(RapidJSON_DIR)

View File

@@ -94,7 +94,6 @@ INSTALL_MESSAGE (INSTALL_EGL "EGL binaries")
INSTALL_MESSAGE (INSTALL_GLES2 "OpenGL ES 2.0 binaries")
INSTALL_MESSAGE (INSTALL_FREETYPE "FreeType binaries")
INSTALL_MESSAGE (INSTALL_TBB "TBB binaries")
INSTALL_MESSAGE (INSTALL_RAPIDJSON "RapidJSON header files")
INSTALL_MESSAGE (INSTALL_TCL "TCL binaries")
INSTALL_MESSAGE (INSTALL_TK "TK binaries")
INSTALL_MESSAGE (INSTALL_VTK "VTK binaries ")
@@ -162,10 +161,6 @@ set (USE_FREEIMAGE_DESCR
"Indicates whether Freeimage product should be used in OCCT visualization
module for support of popular graphics image formats (PNG, BMP etc)")
set (USE_RAPIDJSON_DESCR
"Indicates whether RapidJSON product should be used in OCCT DataExchange
module for support of JSON-based formats like glTF")
set (USE_EGL_DESCR
"Indicates whether EGL should be used in OCCT visualization
module instead of conventional OpenGL context creation APIs")

View File

@@ -189,9 +189,6 @@ proc wokdep:gui:UpdateList {} {
}
wokdep:SearchStandardLibrary anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs "liblzma" "lzma.h" "$aCheckLib" {"lzma" "xz"}
}
if { "$::HAVE_RAPIDJSON" == "true" } {
wokdep:SearchRapidJson anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
if { "$::CHECK_QT4" == "true" } {
wokdep:SearchQt4 anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
@@ -459,9 +456,6 @@ ttk::label .myFrame.myChecks.myZLibLbl -text "Use zlib"
checkbutton .myFrame.myChecks.myLzmaCheck -offvalue "false" -onvalue "true" -variable HAVE_LIBLZMA -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myLzmaLbl -text "Use liblzma"
checkbutton .myFrame.myChecks.myRapidJsonCheck -offvalue "false" -onvalue "true" -variable HAVE_RAPIDJSON -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myRapidJsonLbl -text "Use RapidJSON"
checkbutton .myFrame.myChecks.myQt4Check -offvalue "false" -onvalue "true" -variable CHECK_QT4 -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myQt4Lbl -text "Search Qt4"
checkbutton .myFrame.myChecks.myJDKCheck -offvalue "false" -onvalue "true" -variable CHECK_JDK -command wokdep:gui:UpdateList
@@ -570,8 +564,8 @@ if { "$::tcl_platform(os)" != "Darwin" } {
grid .myFrame.myChecks.myZLibCheck -row $aCheckRowIter -column 6 -sticky e
grid .myFrame.myChecks.myZLibLbl -row $aCheckRowIter -column 7 -sticky w
grid .myFrame.myChecks.myQt4Check -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myQt4Lbl -row $aCheckRowIter -column 13 -sticky w
grid .myFrame.myChecks.myQt4Check -row $aCheckRowIter -column 10 -sticky e
grid .myFrame.myChecks.myQt4Lbl -row $aCheckRowIter -column 11 -sticky w
incr aCheckRowIter
grid .myFrame.myChecks.myFFmpegCheck -row $aCheckRowIter -column 0 -sticky e
@@ -584,8 +578,8 @@ if { "$::tcl_platform(platform)" == "windows" } {
}
grid .myFrame.myChecks.myLzmaCheck -row $aCheckRowIter -column 6 -sticky e
grid .myFrame.myChecks.myLzmaLbl -row $aCheckRowIter -column 7 -sticky w
grid .myFrame.myChecks.myJDKCheck -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 13 -sticky w
grid .myFrame.myChecks.myJDKCheck -row $aCheckRowIter -column 10 -sticky e
grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 11 -sticky w
incr aCheckRowIter
if { "$::tcl_platform(os)" == "Darwin" } {
@@ -594,10 +588,6 @@ if { "$::tcl_platform(os)" == "Darwin" } {
incr aCheckRowIter
}
grid .myFrame.myChecks.myRapidJsonCheck -row $aCheckRowIter -column 6 -sticky e
grid .myFrame.myChecks.myRapidJsonLbl -row $aCheckRowIter -column 7 -sticky w
incr aCheckRowIter
# Additional headers search paths
grid .myFrame.myIncLbl -row $aRowIter -column 0 -columnspan 10 -sticky w
incr aRowIter

View File

@@ -68,7 +68,7 @@ if { [info exists ::env(SHORTCUT_HEADERS)] } {
}
# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_RAPIDJSON HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo}
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo}
foreach anEnvIter $THE_ENV_VARIABLES {
set ${anEnvIter} "false"
if { [info exists ::env(${anEnvIter})] } {
@@ -858,25 +858,6 @@ proc wokdep:SearchGLES {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin6
return "$isFound"
}
# Search RapidJSON headers
proc wokdep:SearchRapidJson {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
upvar $theErrInc anErrInc
set isFound "true"
set aRJHPath [wokdep:SearchHeader "rapidjson/rapidjson.h"]
if { "$aRJHPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{rapidjson}*] "$::VCVER" "$::ARCH" ]
if { "$aPath" != "" && [file exists "$aPath/include/rapidjson/rapidjson.h"] } {
lappend ::CSF_OPT_INC "$aPath/include"
} else {
lappend anErrInc "Error: 'rapidjson/rapidjson.h' not found (RapidJSON)"
set isFound "false"
}
}
return "$isFound"
}
# Auxiliary function, gets VTK version to set default search directory
proc wokdep:VtkVersion { thePath } {
set aResult "6.1"

View File

@@ -1393,7 +1393,6 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
set aLibsMap(CSF_TclTkLibs) ""
set aLibsMap(CSF_QT) "QtCore QtGui"
} else {
set aLibsMap(CSF_fontconfig) "fontconfig"
if { "$theOS" == "qnx" } {
# CSF_ThreadLibs - pthread API is part of libc on QNX
set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"

View File

@@ -63,7 +63,6 @@ win32 {
CSF_TclTkLibs = -lX11 -ltk8.6
CSF_XwLibs = -lX11 -lXext -lXmu -lXi
CSF_MotifLibs = -lX11
CSF_fontconfig = -lfontconfig
HAVE_GLES2 { CSF_OpenGlLibs = -lEGL -lGLESv2 }
}

View File

@@ -24,7 +24,6 @@ set "HAVE_GLES2=false"
set "HAVE_D3D=false"
set "HAVE_ZLIB=false"
set "HAVE_LIBLZMA=false"
set "HAVE_RAPIDJSON=false"
set "CSF_OPT_INC="
set "CSF_OPT_LIB32="
set "CSF_OPT_LIB64="
@@ -164,7 +163,6 @@ if ["%HAVE_GLES2%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DH
if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_D3D" & set "CSF_DEFINES=HAVE_D3D;%CSF_DEFINES%"
if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
if ["%HAVE_RAPIDJSON%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_RAPIDJSON" & set "CSF_DEFINES=HAVE_RAPIDJSON;%CSF_DEFINES%"
rem Eliminate VS warning
if ["%CSF_DEFINES%"] == [""] set "CSF_DEFINES=;"

View File

@@ -878,18 +878,7 @@ The test grid name is constructed depending on the type of the tested chamfers.
| dist_angle_complex | | Distance from edge and given angle |
| dist_angle_sequence | | Distance from edge and given angle |
@subsubsection testmanual_5_1_7 de
This group tests reading and writing of CAD data files (iges, step) to and from OCCT.
Test cases check transfer status, shape and attributes against expected reference values.
| Grid | Commands | Functionality |
| :---- | :----- | :------- |
| iges_1, iges_2, iges_3 | igesbrep, brepiges, ReadIges, WriteIges | IGES tests |
| step_1, step_2, step_3, step_4, step_5 | stepread, stepwrite, ReadStep, WriteStep | STEP tests |
@subsubsection testmanual_5_1_8 demo
@subsubsection testmanual_5_1_7 demo
This group allows demonstrating how testing cases are created, and testing DRAW commands and the test system as a whole.
@@ -900,7 +889,7 @@ This group allows demonstrating how testing cases are created, and testing DRAW
| samples | | OCCT samples |
@subsubsection testmanual_5_1_9 draft
@subsubsection testmanual_5_1_8 draft
This group allows testing draft operations.
@@ -911,7 +900,7 @@ DRAW module: MODELING.
| Angle | depouille | Drafts with angle (inclined walls) |
@subsubsection testmanual_5_1_10 feat
@subsubsection testmanual_5_1_9 feat
This group allows testing creation of features on a shape.
@@ -925,7 +914,7 @@ DRAW module: MODELING (package *BRepTest*).
| featrevol | | |
| featrf | | |
@subsubsection testmanual_5_1_11 heal
@subsubsection testmanual_5_1_10 heal
This group allows testing the functionality provided by *ShapeHealing* toolkit.
@@ -954,7 +943,7 @@ DRAW module: XSDRAW
| surface_to_revolution_standard | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, simple cases |
| update_tolerance_locked | updatetolerance | Update the tolerance of shape so that it satisfy the rule: toler(face)<=toler(edge)<=toler(vertex) |
@subsubsection testmanual_5_1_12 mesh
@subsubsection testmanual_5_1_11 mesh
This group allows testing shape tessellation (*BRepMesh*) and shading.
@@ -971,7 +960,7 @@ DRAW modules: MODELING (package *MeshTest*), VISUALIZATION (package *ViewerTest*
| advanced_incmesh_parallel | incmesh | Meshing of complex shapes, parallel mode |
| standard_incmesh_parallel | incmesh | Meshing of simple shapes, parallel mode |
@subsubsection testmanual_5_1_13 mkface
@subsubsection testmanual_5_1_12 mkface
This group allows testing creation of simple surfaces.
@@ -986,7 +975,7 @@ DRAW module: MODELING (package *BRepTest*)
| after_revsurf_and_offset | mkface | |
| mkplane | mkplane | |
@subsubsection testmanual_5_1_14 nproject
@subsubsection testmanual_5_1_13 nproject
This group allows testing normal projection of edges and wires onto a face.
@@ -996,7 +985,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Base | nproject | |
@subsubsection testmanual_5_1_15 offset
@subsubsection testmanual_5_1_14 offset
This group allows testing offset functionality for curves and surfaces.
@@ -1012,7 +1001,7 @@ DRAW module: MODELING (package *BRepTest*)
| shape | offsetshape | |
| wire_closed_outside_0_005, wire_closed_outside_0_025, wire_closed_outside_0_075, wire_closed_inside_0_005, wire_closed_inside_0_025, wire_closed_inside_0_075, wire_unclosed_outside_0_005, wire_unclosed_outside_0_025, wire_unclosed_outside_0_075 | mkoffset | 2d offset of closed and unclosed planar wires with different offset step and directions of offset ( inside / outside ) |
@subsubsection testmanual_5_1_16 pipe
@subsubsection testmanual_5_1_15 pipe
This group allows testing construction of pipes (sweeping of a contour along profile).
@@ -1022,7 +1011,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| Standard | pipe | |
@subsubsection testmanual_5_1_17 prism
@subsubsection testmanual_5_1_16 prism
This group allows testing construction of prisms.
@@ -1032,7 +1021,7 @@ DRAW module: MODELING (package *BRepTest*)
| :---- | :----- | :------- |
| seminf | prism | |
@subsubsection testmanual_5_1_18 sewing
@subsubsection testmanual_5_1_17 sewing
This group allows testing sewing of faces by connecting edges.
@@ -1044,7 +1033,7 @@ DRAW module: MODELING (package *BRepTest*)
| tol_1 | sewing | Sewing faces with tolerance 1 |
| tol_100 | sewing | Sewing faces with tolerance 100 |
@subsubsection testmanual_5_1_19 thrusection
@subsubsection testmanual_5_1_18 thrusection
This group allows testing construction of shell or a solid passing through a set of sections in a given sequence (loft).
@@ -1053,7 +1042,7 @@ This group allows testing construction of shell or a solid passing through a set
| solids | thrusection | Lofting with resulting solid |
| not_solids | thrusection | Lofting with resulting shell or face |
@subsubsection testmanual_5_1_20 xcaf
@subsubsection testmanual_5_1_19 xcaf
This group allows testing extended data exchange packages.

View File

@@ -222,7 +222,6 @@ for which OCCT is certified to work.
| Freetype (for text rendering) | FreeType 2.4.11-2.7.1 https://sourceforge.net/projects/freetype/files/ |
| FreeImage (optional, for support of common 2D graphic formats) | FreeImage 3.17.0+ https://sourceforge.net/projects/freeimage/files |
| FFmpeg (optional, for video recording) | FFmpeg 3.1+ https://www.ffmpeg.org/download.html |
| RapidJSON (optional, for reading glTF) | RapidJSON 1.1+ http://rapidjson.org/ |
| Intel TBB (optional, for multithreaded algorithms) | TBB 4.x or 5.x https://www.threadingbuildingblocks.org/ |
| VTK (for VTK Integration Services | VTK 6.1+ http://www.vtk.org/download/ |
| Doxygen (optional for building documentation) | Doxygen 1.8.5+ https://www.stack.nl/~dimitri/doxygen/download.html |

View File

@@ -5595,7 +5595,7 @@ Draw provides command to create curves and surfaces by approximation.
* **appro** fits a curve through 3d points;
* **surfapp** and **grilapp** fit a surface through 3d points by approximation;
* **surfint** fit a surface through 3d points by interpolation;
* **2dinterpole** interpolates a curve.
* **2dinterpolate** interpolates a curve.
@subsubsection occt_draw_6_8_1 appro, dapprox

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1341,26 +1341,7 @@ Further, let us consider the triangle \f$ T_{0}\left \langle p_{0}, p_{1}, p_{2}
<span>10.</span> Compute the center of OBB and its half dimensions.<br>
<span>11.</span> Create OBB using the center, axes and half dimensions.<br>
@subsubsection occt_modat_6_1_1_opt Creation of Optimal OBB from set of points
For creation of the optimal OBB from set of points the same algorithm as described above is used but with some simplifications in logic and increased computation time.
For the optimal OBB it is necessary to check all possible axes which can be created by the extremal points. And since the extremal points are only valid for the initial axes it is necessary to project the whole set of points on each axis.
This approach usually provides much tighter OBB but the performance is lower. The complexity of the algorithm is still linear and with use of BVH for the set of points it is O(N + C*log(N)).
Here is the example of optimal and not optimal OBB for the model using the set of 125K nodes:
<table align="center">
<tr>
<td>@figure{/user_guides/modeling_data/images/modeling_data_obb_125K.png,"Not optimal OBB by DiTo-14",160}</td>
<td>@figure{/user_guides/modeling_data/images/modeling_data_opt_obb_125K.png,"Optimal OBB by DiTo-14",160}</td>
<td>@figure{/user_guides/modeling_data/images/modeling_data_pca_obb_125K.png,"Not optimal OBB by PCA",160}</td>
</tr>
</table>
Computation of the not optimal OBB in this case took 0.007 sec, optimal - 0.1 sec, which is about 14 times slower. Such performance is comparable to creation of the OBB for this shape by PCA approach (see below) which takes about 0.17 sec.
The computation of optimal OBB is controlled by the same *theIsOptimal* flag in the BRepBndLib::AddOBB method as for PCA algorithm.
These algorithms are implemented in the *Bnd_OBB::ReBuild(...)* method.
This algorithm is implemented in the *Bnd_OBB::ReBuild(...)* method.
@subsubsection occt_modat_6_1_2 Creation of OBB based on Axes of inertia

View File

@@ -783,7 +783,6 @@ Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
BRepAdaptor_Surface surf1( aFace );
Handle( Adaptor3d_HSurface ) surf2;
Standard_Boolean isOffset = Standard_False;
Offset = 0.0;
if (surf1.GetType() == GeomAbs_OffsetSurface)
{
@@ -802,6 +801,7 @@ Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
{
aPlane = surf2->Plane();
aSurfType = AIS_KOS_Plane;
Offset = 0.;
Result = Standard_True;
}
@@ -817,6 +817,7 @@ Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
gp_Pln thePlane( LinePos, LineDir ^ ExtrusionDir);
aPlane = thePlane;
aSurfType = AIS_KOS_Plane;
Offset = 0.;
Result = Standard_True;
}
}
@@ -825,6 +826,7 @@ Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
{
aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Surface();
aPlane = (Handle( Geom_Plane )::DownCast( aSurf ))->Pln();
Offset = 0.0e0;
}
if (Result == Standard_False)
{
@@ -837,6 +839,7 @@ Standard_Boolean AIS::GetPlaneFromFace(const TopoDS_Face& aFace,
TheType == STANDARD_TYPE(Geom_ToroidalSurface))
{
aSurf = (Handle( Geom_OffsetSurface )::DownCast( aSurf ))->Surface();
Offset = 0.0e0;
}
else
{
@@ -896,18 +899,20 @@ gp_Pnt AIS::ProjectPointOnLine( const gp_Pnt & aPoint, const gp_Lin & aLine )
//function : InitFaceLength
//purpose :
//=======================================================================
void AIS::InitFaceLength (const TopoDS_Face& theFace,
gp_Pln& thePlane,
Handle(Geom_Surface)& theSurface,
AIS_KindOfSurface& theSurfaceType,
Standard_Real& theOffset)
void AIS::InitFaceLength (const TopoDS_Face& aFace,
gp_Pln & aPlane,
Handle(Geom_Surface) & aSurface,
AIS_KindOfSurface & aSurfaceType,
Standard_Real & anOffset)
{
if (AIS::GetPlaneFromFace (theFace, thePlane, theSurface, theSurfaceType, theOffset)
&& Abs (theOffset) > Precision::Confusion())
{
theSurface = new Geom_OffsetSurface (theSurface, theOffset);
theOffset = 0.0e0;
}
AIS::GetPlaneFromFace( aFace, aPlane, aSurface, aSurfaceType, anOffset );
if (Abs( anOffset ) > Precision::Confusion())
{
aSurface = new Geom_OffsetSurface( aSurface, anOffset );
anOffset = 0.0e0;
}
}
//=======================================================================

View File

@@ -1035,21 +1035,15 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
{
return;
}
aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
if (anOwner->Mode() == AIS_MM_TranslationPlane)
{
Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
aStyle->SetColor (myAxes[anOwner->Index()].Color());
aStyle->SetTransparency (0.5);
aPresentation->Highlight (aStyle);
aStyle->SetColor(myAxes[anOwner->Index()].Color());
aStyle->SetTransparency(0.5);
aPresentation->Highlight(aStyle);
}
else
{
aPresentation->Highlight (theStyle);
}
aPresentation->Highlight(theStyle);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{

View File

@@ -93,8 +93,9 @@ public:
//! be ignored at all.
//! If theIsShapeToleranceUsed == TRUE then resulting box will be
//! extended on the tolerance of the shape.
//! theIsOptimal flag defines whether to look for the more tight
//! OBB for the cost of performance or not.
//! theIsOptimal flag defines the algorithm for construction of initial
//! Bnd_Box for the second method (if theIsOptimal == TRUE then
//! this box will be created by AddOptimal(...) method).
Standard_EXPORT static
void AddOBB(const TopoDS_Shape& theS,
Bnd_OBB& theOBB,

View File

@@ -293,7 +293,6 @@ static Standard_Integer IsWCS(const gp_Dir& theDir)
//=======================================================================
static Standard_Boolean CheckPoints(const TopoDS_Shape& theS,
const Standard_Boolean theIsTriangulationUsed,
const Standard_Boolean theIsOptimal,
const Standard_Boolean theIsShapeToleranceUsed,
Bnd_OBB& theOBB)
{
@@ -330,7 +329,7 @@ static Standard_Boolean CheckPoints(const TopoDS_Shape& theS,
}
#endif
theOBB.ReBuild(anArrPnts, aPtrArrTol, theIsOptimal);
theOBB.ReBuild(anArrPnts, aPtrArrTol);
return (!theOBB.IsVoid());
}
@@ -499,7 +498,7 @@ void BRepBndLib::AddOBB(const TopoDS_Shape& theS,
const Standard_Boolean theIsOptimal,
const Standard_Boolean theIsShapeToleranceUsed)
{
if (CheckPoints(theS, theIsTriangulationUsed, theIsOptimal, theIsShapeToleranceUsed, theOBB))
if(CheckPoints(theS, theIsTriangulationUsed, theIsShapeToleranceUsed, theOBB))
return;
ComputePCA(theS, theOBB, theIsTriangulationUsed, theIsOptimal, theIsShapeToleranceUsed);

View File

@@ -1437,13 +1437,16 @@ Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList
gp_Pnt2d ap = aCurve->Value(f);
Standard_Boolean bFirstFound = Standard_False;
Standard_Boolean bLastFound = Standard_False;
Standard_Boolean bforward = Standard_True;
if(ap.Distance(theFirstPoint) < aTolerance1) {
bforward = Standard_True;
if(theOrientedList.IsEmpty())
theOrientedList.Append(aEPrev.Oriented(TopAbs_FORWARD));
bFirstFound = Standard_True;
}
else if(ap.Distance(theLastPoint) < aTolerance1) {
bforward = Standard_False;
if(theOrientedList.IsEmpty())
theOrientedList.Append(aEPrev.Oriented(TopAbs_REVERSED));
bLastFound = Standard_True;
@@ -1451,31 +1454,36 @@ Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList
ap = aCurve->Value(l);
if(ap.Distance(theLastPoint) < aTolerance2) {
bforward = Standard_True;
if(theOrientedList.IsEmpty())
theOrientedList.Append(aEPrev.Oriented(TopAbs_FORWARD));
bLastFound = Standard_True;
}
else if(ap.Distance(theFirstPoint) < aTolerance2) {
bforward = Standard_False;
if(theOrientedList.IsEmpty())
theOrientedList.Append(aEPrev.Oriented(TopAbs_REVERSED));
bFirstFound = Standard_True;
}
if (!theOrientedList.IsEmpty())
aEPrev = TopoDS::Edge (theOrientedList.Last());
for(; anIt.More(); anIt.Next()) {
const TopoDS_Edge& aE = TopoDS::Edge(anIt.Value());
TopoDS_Vertex aV11, aV12;
TopExp::Vertices(aEPrev, aV11, aV12, Standard_True);
TopExp::Vertices(aEPrev, aV11, aV12);
TopoDS_Vertex aV21, aV22;
TopExp::Vertices(aE, aV21, aV22, Standard_False);
TopExp::Vertices(aE, aV21, aV22);
TopAbs_Orientation anOri = TopAbs_FORWARD;
TopAbs_Orientation anOri =
(aV12.IsSame (aV21) || aV11.IsSame (aV22)) ? TopAbs_FORWARD : TopAbs_REVERSED;
if(aV12.IsSame(aV21) || aV11.IsSame(aV22)) {
anOri = (bforward) ? TopAbs_FORWARD : TopAbs_REVERSED;
}
else {
anOri = (bforward) ? TopAbs_REVERSED : TopAbs_FORWARD;
}
theOrientedList.Append(aE.Oriented(anOri));
aEPrev = TopoDS::Edge (theOrientedList.Last());
aEPrev = aE;
aTolerance1 = (aV21.IsNull()) ? Precision::Confusion() : BRep_Tool::Tolerance(aV21);
aTolerance2 = (aV22.IsNull()) ? Precision::Confusion() : BRep_Tool::Tolerance(aV22);
utol = aBAS.UResolution(aTolerance1);
@@ -1503,7 +1511,9 @@ Standard_Boolean CheckAndOrientEdges(const TopTools_ListOfShape& theOrderedList
}
}
return bFirstFound && bLastFound;
if(!bFirstFound || !bLastFound)
return Standard_False;
return Standard_True;
}
// ----------------------------------------------------------------------------------------------------

View File

@@ -55,8 +55,6 @@ static Standard_Boolean findNearestValidPoint(
//
// the general step is computed using general curve resolution
Standard_Real aStep = theCurve.Resolution(theTol) * 1.01;
if (aStep < theEps)
aStep = theEps;
// aD1Mag is a threshold to consider local derivative magnitude too small
// and to accelerate going out of sphere
// (inverse of resolution is the maximal derivative);
@@ -161,19 +159,11 @@ Standard_Boolean BRepLib::FindValidRange
if (theParV2 - theParV1 < Precision::PConfusion())
return Standard_False;
Standard_Boolean isInfParV1 = Precision::IsInfinite (theParV1),
isInfParV2 = Precision::IsInfinite (theParV2);
Standard_Real anEps = Max(Max(theCurve.Resolution(theTolE) * 0.1,
Epsilon(Max(Abs(theParV1), Abs(theParV2)))),
Precision::PConfusion());
Standard_Real aMaxPar = 0.0;
if (!isInfParV1)
aMaxPar = Abs (theParV1);
if (!isInfParV2)
aMaxPar = Max (aMaxPar, Abs (theParV2));
Standard_Real anEps = Max (Max (theCurve.Resolution (theTolE) * 0.1, Epsilon (aMaxPar)),
Precision::PConfusion());
if (isInfParV1)
if (Precision::IsInfinite(theParV1))
theFirst = theParV1;
else
{
@@ -184,7 +174,7 @@ Standard_Boolean BRepLib::FindValidRange
return Standard_False;
}
if (isInfParV2)
if (Precision::IsInfinite(theParV2))
theLast = theParV2;
else
{

View File

@@ -65,7 +65,7 @@ void BRepMesh_BaseMeshAlgo::Perform(
commitSurfaceTriangulation();
}
}
catch (Standard_Failure const& /*theExeption*/)
catch (Standard_Failure& /*theExeption*/)
{
}

View File

@@ -83,12 +83,6 @@ public:
myFaceMax = theMax;
}
//! Retruns true if cell filter contains no circle.
inline Standard_Boolean IsEmpty () const
{
return mySelector.Circles ().IsEmpty ();
}
//! Binds the circle to the tool.
//! @param theIndex index a circle should be bound with.
//! @param theCircle circle to be bound.

View File

@@ -1,60 +0,0 @@
// Created on: 2019-07-08
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_ConstrainedBaseMeshAlgo_HeaderFile
#define _BRepMesh_ConstrainedBaseMeshAlgo_HeaderFile
#include <BRepMesh_BaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using Dealunay approach.
//! Performs generation of mesh using raw data from model.
class BRepMesh_ConstrainedBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
{
public:
//! Constructor.
BRepMesh_ConstrainedBaseMeshAlgo ()
{
}
//! Destructor.
virtual ~BRepMesh_ConstrainedBaseMeshAlgo ()
{
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ConstrainedBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
protected:
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
{
return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
}
//! Perfroms processing of generated mesh.
//! By default does nothing.
//! Expected to be called from method generateMesh() in successor classes.
virtual void postProcessMesh (BRepMesh_Delaun& /*theMesher*/)
{
}
};
#endif

View File

@@ -26,7 +26,6 @@
#include <Adaptor3d_HCurveOnSurface.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <Standard_Failure.hxx>
#include <GCPnts_AbscissaPoint.hxx>
//=======================================================================
//function : Constructor
@@ -80,28 +79,21 @@ void BRepMesh_CurveTessellator::init()
aPreciseLinDef *= 0.5;
}
aPreciseLinDef = Max (aPreciseLinDef, Precision::Confusion());
aPreciseAngDef = Max (aPreciseAngDef, Precision::Angular());
Standard_Real aMinSize = myParameters.MinSize;
if (myParameters.AdjustMinSize)
{
aMinSize = Min (aMinSize, myParameters.RelMinSize() * GCPnts_AbscissaPoint::Length (
myCurve, myCurve.FirstParameter(), myCurve.LastParameter(), aPreciseLinDef));
}
aPreciseLinDef = Max(aPreciseLinDef, Precision::Confusion());
aPreciseAngDef = Max(aPreciseAngDef, Precision::Angular());
mySquareEdgeDef = aPreciseLinDef * aPreciseLinDef;
mySquareMinSize = Max (mySquareEdgeDef, aMinSize * aMinSize);
mySquareMinSize = Max(mySquareEdgeDef, myParameters.MinSize * myParameters.MinSize);
myEdgeSqTol = BRep_Tool::Tolerance (myEdge);
myEdgeSqTol = BRep_Tool::Tolerance(myEdge);
myEdgeSqTol *= myEdgeSqTol;
const Standard_Integer aMinPntNb = (myCurve.GetType() == GeomAbs_Circle) ? 4 : 2; //OCC287
myDiscretTool.Initialize (myCurve,
myCurve.FirstParameter(), myCurve.LastParameter(),
aPreciseAngDef, aPreciseLinDef, aMinPntNb,
Precision::PConfusion(), aMinSize);
myDiscretTool.Initialize(myCurve,
myCurve.FirstParameter(), myCurve.LastParameter(),
aPreciseAngDef, aPreciseLinDef, aMinPntNb,
Precision::PConfusion(), myParameters.MinSize);
if (myCurve.IsCurveOnSurface())
{

View File

@@ -1,70 +0,0 @@
// Created on: 2019-06-07
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_CustomBaseMeshAlgo_HeaderFile
#define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRepMesh_MeshTool.hxx>
class BRepMesh_DataStructureOfDelaun;
//! Class provides base fuctionality to build face triangulation using custom triangulation algorithm.
//! Performs generation of mesh using raw data from model.
class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
{
public:
//! Constructor.
Standard_EXPORT BRepMesh_CustomBaseMeshAlgo ()
{
}
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_CustomBaseMeshAlgo ()
{
}
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
protected:
//! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh () Standard_OVERRIDE
{
const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
buildBaseTriangulation ();
std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
aMesher.ProcessConstraints ();
BRepMesh_MeshTool aCleaner (aStructure);
aCleaner.EraseFreeLinks ();
postProcessMesh (aMesher);
}
protected:
//! Builds base triangulation using custom triangulation algorithm.
Standard_EXPORT virtual void buildBaseTriangulation() = 0;
};
#endif

View File

@@ -1,53 +0,0 @@
// Created on: 2019-06-07
// Copyright (c) 2019 OPEN CASCADE SAS
// Created by: Oleg AGASHIN
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_CustomDelaunayBaseMeshAlgo_HeaderFile
#define _BRepMesh_CustomDelaunayBaseMeshAlgo_HeaderFile
class BRepMesh_DataStructureOfDelaun;
class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using custom
//! triangulation algorithm with possibility to modify final mesh.
//! Performs generation of mesh using raw data from model.
template<class BaseAlgo>
class BRepMesh_CustomDelaunayBaseMeshAlgo : public BaseAlgo
{
public:
//! Constructor.
BRepMesh_CustomDelaunayBaseMeshAlgo ()
{
}
//! Destructor.
virtual ~BRepMesh_CustomDelaunayBaseMeshAlgo ()
{
}
protected:
//! Perfroms processing of generated mesh.
virtual void postProcessMesh(BRepMesh_Delaun& theMesher)
{
BaseAlgo::postProcessMesh (theMesher);
const Handle(BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure();
std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes());
theMesher.InitCirclesTool (aCellsCount.first, aCellsCount.second);
}
};
#endif

View File

@@ -78,25 +78,6 @@ namespace {
}
} // anonymous namespace
//=======================================================================
//function : BRepMesh_Delaun
//purpose :
//=======================================================================
BRepMesh_Delaun::BRepMesh_Delaun (
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV,
const Standard_Boolean isFillCircles)
: myMeshData ( theOldMesh ),
myCircles (new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
{
if (isFillCircles)
{
InitCirclesTool (theCellsCountU, theCellsCountV);
}
}
//=======================================================================
//function : BRepMesh_Delaun
//purpose : Creates the triangulation with an empty Mesh data structure
@@ -122,8 +103,7 @@ BRepMesh_Delaun::BRepMesh_Delaun(
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
IMeshData::Array1OfVertexOfDelaun& theVertices)
: myMeshData( theOldMesh ),
myCircles ( theVertices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
myCircles ( theVertices.Length(), theOldMesh->Allocator() )
{
if ( theVertices.Length() > 2 )
{
@@ -139,8 +119,7 @@ BRepMesh_Delaun::BRepMesh_Delaun(
const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
IMeshData::VectorOfInteger& theVertexIndices)
: myMeshData( theOldMesh ),
myCircles ( theVertexIndices.Length(), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
myCircles ( theVertexIndices.Length(), theOldMesh->Allocator() )
{
perform(theVertexIndices);
}
@@ -154,8 +133,7 @@ BRepMesh_Delaun::BRepMesh_Delaun (const Handle (BRepMesh_DataStructureOfDelaun)&
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
: myMeshData (theOldMesh),
myCircles (theVertexIndices.Length (), new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE))
myCircles (theVertexIndices.Length (), theOldMesh->Allocator ())
{
perform (theVertexIndices, theCellsCountU, theCellsCountV);
}
@@ -179,63 +157,6 @@ void BRepMesh_Delaun::Init(IMeshData::Array1OfVertexOfDelaun& theVertices)
perform( aVertexIndexes );
}
//=======================================================================
//function : InitCirclesTool
//purpose :
//=======================================================================
void BRepMesh_Delaun::InitCirclesTool (const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
{
Bnd_Box2d aBox;
for (Standard_Integer aNodeIt = 1; aNodeIt <= myMeshData->NbNodes(); ++aNodeIt)
{
aBox.Add (gp_Pnt2d (GetVertex (aNodeIt).Coord ()));
}
aBox.Enlarge (Precision);
initCirclesTool (aBox, theCellsCountU, theCellsCountV);
IMeshData::IteratorOfMapOfInteger aTriangleIt (myMeshData->ElementsOfDomain());
for (; aTriangleIt.More(); aTriangleIt.Next())
{
Standard_Integer aNodesIndices[3];
const BRepMesh_Triangle& aTriangle = myMeshData->GetElement (aTriangleIt.Key());
myMeshData->ElementNodes (aTriangle, aNodesIndices);
myCircles.Bind (aTriangleIt.Key(),
GetVertex( aNodesIndices[0] ).Coord(),
GetVertex( aNodesIndices[1] ).Coord(),
GetVertex( aNodesIndices[2] ).Coord());
}
}
//=======================================================================
//function : initCirclesTool
//purpose :
//=======================================================================
void BRepMesh_Delaun::initCirclesTool (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
{
Standard_Real aMinX, aMinY, aMaxX, aMaxY;
theBox.Get ( aMinX, aMinY, aMaxX, aMaxY );
const Standard_Real aDeltaX = aMaxX - aMinX;
const Standard_Real aDeltaY = aMaxY - aMinY;
Standard_Integer aScaler = 2;
if ( myMeshData->NbNodes() > 100 )
{
aScaler = 5;
}
else if( myMeshData->NbNodes() > 1000 )
{
aScaler = 7;
}
myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
myCircles.SetCellSize ( aDeltaX / Max (theCellsCountU, aScaler),
aDeltaY / Max (theCellsCountV, aScaler));
}
//=======================================================================
//function : perform
//purpose : Create super mesh and run triangulation procedure
@@ -259,8 +180,18 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
aBox.Enlarge (Precision);
initCirclesTool (aBox, theCellsCountU, theCellsCountV);
superMesh (aBox);
Standard_Integer aScaler = 2;
if ( myMeshData->NbNodes() > 100 )
{
aScaler = 5;
}
else if( myMeshData->NbNodes() > 1000 )
{
aScaler = 7;
}
superMesh (aBox, Max (theCellsCountU, aScaler),
Max (theCellsCountV, aScaler));
ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData);
std::make_heap(theVertexIndices.begin(), theVertexIndices.end(), aCmp);
@@ -273,7 +204,9 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
//function : superMesh
//purpose : Build the super mesh
//=======================================================================
void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV)
{
Standard_Real aMinX, aMinY, aMaxX, aMaxY;
theBox.Get ( aMinX, aMinY, aMaxX, aMaxY );
@@ -284,6 +217,9 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
Standard_Real aDeltaMax = Max( aDeltaX, aDeltaY );
Standard_Real aDelta = aDeltaX + aDeltaY;
myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
myCircles.SetCellSize( aDeltaX / theCellsCountU, aDeltaY / theCellsCountV);
mySupVert[0] = myMeshData->AddNode(
BRepMesh_Vertex( ( aMinX + aMaxX ) / 2, aMaxY + aDeltaMax, BRepMesh_Free ) );
@@ -318,10 +254,7 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex,
IMeshData::MapOfIntegerInteger& theLoopEdges )
{
if (!myCircles.IsEmpty())
{
myCircles.Delete (theIndex);
}
myCircles.Delete( theIndex );
const BRepMesh_Triangle& aElement = GetTriangle(theIndex);
const Standard_Integer(&e)[3] = aElement.myEdges;
@@ -346,11 +279,8 @@ void BRepMesh_Delaun::deleteTriangle(const Standard_Integer theIndex,
//=======================================================================
void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
{
// Insertion of edges of super triangles in the list of free edges:
Handle(NCollection_IncAllocator) aAllocator = new NCollection_IncAllocator(
IMeshData::MEMORY_BLOCK_SIZE_HUGE);
IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
// Insertion of edges of super triangles in the list of free edges:
IMeshData::MapOfIntegerInteger aLoopEdges(10, myMeshData->Allocator());
const Standard_Integer(&e)[3] = mySupTrian.myEdges;
aLoopEdges.Bind( e[0], Standard_True );
@@ -601,7 +531,10 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
}
}
ProcessConstraints();
insertInternalEdges();
// Adjustment of meshes to boundary edges
frontierAdjust();
}
//=======================================================================

View File

@@ -41,12 +41,6 @@ public:
DEFINE_STANDARD_ALLOC
//! Creates instance of triangulator, but do not run the algorithm automatically.
Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV,
const Standard_Boolean isFillCircles);
//! Creates the triangulation with an empty Mesh data structure.
Standard_EXPORT BRepMesh_Delaun (IMeshData::Array1OfVertexOfDelaun& theVertices);
@@ -67,10 +61,6 @@ public:
//! Initializes the triangulation with an array of vertices.
Standard_EXPORT void Init (IMeshData::Array1OfVertexOfDelaun& theVertices);
//! Forces initialization of circles cell filter using working structure.
Standard_EXPORT void InitCirclesTool (const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
//! Removes a vertex from the triangulation.
Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
@@ -87,15 +77,6 @@ public:
return myMeshData;
}
//! Forces insertion of constraint edges into the base triangulation.
inline void ProcessConstraints()
{
insertInternalEdges();
// Adjustment of meshes to boundary edges
frontierAdjust();
}
//! Gives the list of frontier edges.
inline Handle(IMeshData::MapOfInteger) Frontier() const
{
@@ -158,11 +139,6 @@ private:
typedef NCollection_DataMap<Standard_Integer, IMeshData::MapOfInteger> DataMapOfMap;
//! Performs initialization of circles cell filter tool.
void initCirclesTool (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
//! Add boundig box for edge defined by start & end point to
//! the given vector of bounding boxes for triangulation edges.
void fillBndBox (IMeshData::SequenceOfBndB2d& theBoxes,
@@ -180,7 +156,9 @@ private:
const Standard_Integer theCellsCountV = -1);
//! Build the super mesh.
void superMesh (const Bnd_Box2d& theBox);
void superMesh (const Bnd_Box2d& theBox,
const Standard_Integer theCellsCountU,
const Standard_Integer theCellsCountV);
//! Computes the triangulation and adds the vertices,
//! edges and triangles to the Mesh data structure.

View File

@@ -16,7 +16,7 @@
#ifndef _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
#define _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
#include <BRepMesh_BaseMeshAlgo.hxx>
#include <NCollection_Shared.hxx>
#include <IMeshTools_Parameters.hxx>
@@ -25,7 +25,7 @@ class BRepMesh_Delaun;
//! Class provides base fuctionality to build face triangulation using Dealunay approach.
//! Performs generation of mesh using raw data from model.
class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
{
public:
@@ -35,12 +35,24 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_DelaunayBaseMeshAlgo();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
protected:
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
{
return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
}
//! Generates mesh for the contour stored in data structure.
Standard_EXPORT virtual void generateMesh() Standard_OVERRIDE;
//! Perfroms processing of generated mesh.
//! By default does nothing.
virtual void postProcessMesh(BRepMesh_Delaun& /*theMesher*/)
{
}
};
#endif

View File

@@ -22,12 +22,12 @@
//! Extends node insertion Delaunay meshing algo in order to control
//! deflection of generated trianges. Splits triangles failing the check.
template<class RangeSplitter, class BaseAlgo>
class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
template<class RangeSplitter>
class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter>
{
private:
// Typedef for OCCT RTTI
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> DelaunayInsertionBaseClass;
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> DelaunayInsertionBaseClass;
public:

View File

@@ -21,18 +21,17 @@
//! Extends base Delaunay meshing algo in order to enable possibility
//! of addition of free vertices and internal nodes into the mesh.
template<class RangeSplitter, class BaseAlgo>
class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
template<class RangeSplitter>
class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo>
{
private:
// Typedef for OCCT RTTI
typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> InsertionBaseClass;
typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> InsertionBaseClass;
public:
//! Constructor.
BRepMesh_DelaunayNodeInsertionMeshAlgo()
: myIsPreProcessSurfaceNodes (Standard_False)
{
}
@@ -41,41 +40,8 @@ public:
{
}
//! Returns PreProcessSurfaceNodes flag.
inline Standard_Boolean IsPreProcessSurfaceNodes () const
{
return myIsPreProcessSurfaceNodes;
}
//! Sets PreProcessSurfaceNodes flag.
//! If TRUE, registers surface nodes before generation of base mesh.
//! If FALSE, inserts surface nodes after generation of base mesh.
inline void SetPreProcessSurfaceNodes (const Standard_Boolean isPreProcessSurfaceNodes)
{
myIsPreProcessSurfaceNodes = isPreProcessSurfaceNodes;
}
protected:
//! Performs initialization of data structure using existing model data.
virtual Standard_Boolean initDataStructure() Standard_OVERRIDE
{
if (!InsertionBaseClass::initDataStructure())
{
return Standard_False;
}
if (myIsPreProcessSurfaceNodes)
{
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
registerSurfaceNodes (aSurfaceNodes);
}
return Standard_True;
}
//! Returns size of cell to be used by acceleration circles grid structure.
virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer theVerticesNb) Standard_OVERRIDE
{
@@ -89,13 +55,10 @@ protected:
{
InsertionBaseClass::postProcessMesh(theMesher);
if (!myIsPreProcessSurfaceNodes)
{
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
insertNodes(aSurfaceNodes, theMesher);
}
insertNodes(aSurfaceNodes, theMesher);
}
//! Inserts nodes into mesh.
@@ -123,37 +86,6 @@ protected:
theMesher.AddVertices(aVertexIndexes);
return !aVertexIndexes.IsEmpty();
}
private:
//! Registers surface nodes in data structure.
Standard_Boolean registerSurfaceNodes(
const Handle(IMeshData::ListOfPnt2d)& theNodes)
{
if (theNodes.IsNull() || theNodes->IsEmpty())
{
return Standard_False;
}
Standard_Boolean isAdded = Standard_False;
IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
{
const gp_Pnt2d& aPnt2d = aNodesIt.Value();
if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
{
isAdded = Standard_True;
this->registerNode(this->getRangeSplitter().Point(aPnt2d),
aPnt2d, BRepMesh_Free, Standard_False);
}
}
return isAdded;
}
private:
Standard_Boolean myIsPreProcessSurfaceNodes;
};
#endif

View File

@@ -83,7 +83,7 @@ Handle(IMeshTools_CurveTessellator) BRepMesh_EdgeDiscret::CreateEdgeTessellation
// Function: Perform
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_EdgeDiscret::performInternal (
Standard_Boolean BRepMesh_EdgeDiscret::Perform (
const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
{
@@ -108,78 +108,69 @@ Standard_Boolean BRepMesh_EdgeDiscret::performInternal (
void BRepMesh_EdgeDiscret::process (const Standard_Integer theEdgeIndex) const
{
const IMeshData::IEdgeHandle& aDEdge = myModel->GetEdge (theEdgeIndex);
try
{
OCC_CATCH_SIGNALS
BRepMesh_Deflection::ComputeDeflection (aDEdge, myModel->GetMaxSize (), myParameters);
BRepMesh_Deflection::ComputeDeflection (aDEdge, myModel->GetMaxSize (), myParameters);
Handle (IMeshTools_CurveTessellator) aEdgeTessellator;
if (!aDEdge->IsFree ())
Handle (IMeshTools_CurveTessellator) aEdgeTessellator;
if (!aDEdge->IsFree ())
{
// Iterate over pcurves and check deflection on corresponding face.
Standard_Real aMinDeflection = RealLast ();
Standard_Integer aMinPCurveIndex = -1;
for (Standard_Integer aPCurveIt = 0; aPCurveIt < aDEdge->PCurvesNb (); ++aPCurveIt)
{
// Iterate over pcurves and check deflection on corresponding face.
Standard_Real aMinDeflection = RealLast ();
Standard_Integer aMinPCurveIndex = -1;
for (Standard_Integer aPCurveIt = 0; aPCurveIt < aDEdge->PCurvesNb (); ++aPCurveIt)
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve (aPCurveIt);
const Standard_Real aTmpDeflection = checkExistingPolygonAndUpdateStatus(aDEdge, aPCurve);
if (aTmpDeflection < aMinDeflection)
{
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve (aPCurveIt);
const Standard_Real aTmpDeflection = checkExistingPolygonAndUpdateStatus(aDEdge, aPCurve);
if (aTmpDeflection < aMinDeflection)
{
// Identify pcurve with the smallest deflection in order to
// retrieve polygon that represents the most smooth discretization.
aMinDeflection = aTmpDeflection;
aMinPCurveIndex = aPCurveIt;
}
BRepMesh_ShapeTool::CheckAndUpdateFlags (aDEdge, aPCurve);
}
if (aMinPCurveIndex != -1)
{
aDEdge->SetDeflection (aMinDeflection);
const IMeshData::IFaceHandle aDFace = aDEdge->GetPCurve(aMinPCurveIndex)->GetFace();
aEdgeTessellator = CreateEdgeTessellationExtractor(aDEdge, aDFace);
}
else
{
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(0);
const IMeshData::IFaceHandle aDFace = aPCurve->GetFace();
aEdgeTessellator = BRepMesh_EdgeDiscret::CreateEdgeTessellator(
aDEdge, aPCurve->GetOrientation(), aDFace, myParameters);
// Identify pcurve with the smallest deflection in order to
// retrieve polygon that represents the most smooth discretization.
aMinDeflection = aTmpDeflection;
aMinPCurveIndex = aPCurveIt;
}
BRepMesh_ShapeTool::CheckAndUpdateFlags (aDEdge, aPCurve);
}
if (aMinPCurveIndex != -1)
{
aDEdge->SetDeflection (aMinDeflection);
const IMeshData::IFaceHandle aDFace = aDEdge->GetPCurve(aMinPCurveIndex)->GetFace();
aEdgeTessellator = CreateEdgeTessellationExtractor(aDEdge, aDFace);
}
else
{
TopLoc_Location aLoc;
const Handle (Poly_Polygon3D)& aPoly3D = BRep_Tool::Polygon3D (aDEdge->GetEdge (), aLoc);
if (!aPoly3D.IsNull ())
{
if (aPoly3D->HasParameters () &&
aPoly3D->Deflection () < 1.1 * aDEdge->GetDeflection ())
{
// Edge already has suitable 3d polygon.
aDEdge->SetStatus(IMeshData_Reused);
return;
}
else
{
aDEdge->SetStatus(IMeshData_Outdated);
}
}
aEdgeTessellator = CreateEdgeTessellator(aDEdge, myParameters);
}
Tessellate3d (aDEdge, aEdgeTessellator, Standard_True);
if (!aDEdge->IsFree())
{
Tessellate2d(aDEdge, Standard_True);
const IMeshData::IPCurveHandle& aPCurve = aDEdge->GetPCurve(0);
const IMeshData::IFaceHandle aDFace = aPCurve->GetFace();
aEdgeTessellator = BRepMesh_EdgeDiscret::CreateEdgeTessellator(
aDEdge, aPCurve->GetOrientation(), aDFace, myParameters);
}
}
catch (Standard_Failure const&)
else
{
aDEdge->SetStatus (IMeshData_Failure);
TopLoc_Location aLoc;
const Handle (Poly_Polygon3D)& aPoly3D = BRep_Tool::Polygon3D (aDEdge->GetEdge (), aLoc);
if (!aPoly3D.IsNull ())
{
if (aPoly3D->HasParameters () &&
aPoly3D->Deflection () < 1.1 * aDEdge->GetDeflection ())
{
// Edge already has suitable 3d polygon.
aDEdge->SetStatus(IMeshData_Reused);
return;
}
else
{
aDEdge->SetStatus(IMeshData_Outdated);
}
}
aEdgeTessellator = CreateEdgeTessellator(aDEdge, myParameters);
}
Tessellate3d (aDEdge, aEdgeTessellator, Standard_True);
if (!aDEdge->IsFree())
{
Tessellate2d(aDEdge, Standard_True);
}
}

View File

@@ -52,6 +52,11 @@ public:
const IMeshData::IEdgeHandle& theDEdge,
const IMeshData::IFaceHandle& theDFace);
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean Perform (
const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
//! Functor API to discretize the given edge.
inline void operator() (const Standard_Integer theEdgeIndex) const {
process (theEdgeIndex);
@@ -70,13 +75,6 @@ public:
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_EdgeDiscret, IMeshTools_ModelAlgo)
protected:
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
private:
//! Checks existing discretization of the edge and updates data model.

View File

@@ -94,6 +94,8 @@ namespace
Handle(BRepMesh_FaceChecker::ArrayOfBndBoxTree)& myWiresBndBoxTree;
};
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
//! Selector.
//! Used to identify segments with overlapped bounding boxes.
class BndBox2dTreeSelector : public IMeshData::BndBox2dTree::Selector

View File

@@ -43,7 +43,7 @@ BRepMesh_FaceDiscret::~BRepMesh_FaceDiscret()
// Function: Perform
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_FaceDiscret::performInternal(
Standard_Boolean BRepMesh_FaceDiscret::Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
{
@@ -73,23 +73,14 @@ void BRepMesh_FaceDiscret::process(const Standard_Integer theFaceIndex) const
return;
}
try
{
OCC_CATCH_SIGNALS
Handle(IMeshTools_MeshAlgo) aMeshingAlgo =
myAlgoFactory->GetAlgo(aDFace->GetSurface()->GetType(), myParameters);
Handle(IMeshTools_MeshAlgo) aMeshingAlgo =
myAlgoFactory->GetAlgo(aDFace->GetSurface()->GetType(), myParameters);
if (aMeshingAlgo.IsNull())
{
aDFace->SetStatus(IMeshData_Failure);
return;
}
aMeshingAlgo->Perform(aDFace, myParameters);
}
catch (Standard_Failure const&)
if (aMeshingAlgo.IsNull())
{
aDFace->SetStatus (IMeshData_Failure);
aDFace->SetStatus(IMeshData_Failure);
return;
}
aMeshingAlgo->Perform(aDFace, myParameters);
}

View File

@@ -23,7 +23,7 @@
//! Class implements functionality starting triangulation of model's faces.
//! Each face is processed separately and can be executed in parallel mode.
//! Uses mesh algo factory passed as initializer to create instance of triangulation
//! Uses mesh algo factory passed as initializer to create instace of triangulation
//! algorithm according to type of surface of target face.
class BRepMesh_FaceDiscret : public IMeshTools_ModelAlgo
{
@@ -36,6 +36,11 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_FaceDiscret();
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
//! Functor API to discretize the given edge.
inline void operator() (const Standard_Integer theFaceIndex) const {
process(theFaceIndex);
@@ -43,13 +48,6 @@ public:
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_FaceDiscret, IMeshTools_ModelAlgo)
protected:
//! Performs processing of faces of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
private:
//! Checks existing discretization of the face and updates data model.

View File

@@ -86,28 +86,19 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Perform()
{
Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
Perform (aContext);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext)
{
initParameters();
theContext->SetShape(Shape());
theContext->ChangeParameters() = myParameters;
theContext->ChangeParameters().CleanModel = Standard_False;
Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
aContext->SetShape(Shape());
aContext->ChangeParameters() = myParameters;
aContext->ChangeParameters().CleanModel = Standard_False;
IMeshTools_MeshBuilder aIncMesh(theContext);
IMeshTools_MeshBuilder aIncMesh(aContext);
aIncMesh.Perform();
myStatus = IMeshData_NoError;
const Handle(IMeshData_Model)& aModel = theContext->GetModel();
const Handle(IMeshData_Model)& aModel = aContext->GetModel();
for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
{
const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);

View File

@@ -16,7 +16,6 @@
#include <BRepMesh_DiscretRoot.hxx>
#include <IMeshTools_Parameters.hxx>
#include <IMeshTools_Context.hxx>
//! Builds the mesh of a shape with respect of their
//! correctly triangulated parts
@@ -52,11 +51,8 @@ public: //! @name mesher API
Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters);
//! Performs meshing ot the shape.
//! Performs meshing ot the shape.
Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
//! Performs meshing using custom context;
Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext);
public: //! @name accessing to parameters.

View File

@@ -35,13 +35,13 @@ namespace
template<class RangeSplitter>
struct NodeInsertionMeshAlgo
{
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> Type;
};
template<class RangeSplitter>
struct DeflectionControlMeshAlgo
{
typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter> Type;
};
}
@@ -82,9 +82,7 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo(
break;
case GeomAbs_Cylinder:
return theParameters.InternalVerticesMode ?
new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type :
new BaseMeshAlgo::Type;
return new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type;
break;
case GeomAbs_Cone:

View File

@@ -18,6 +18,7 @@
#include <BRepMesh_ShapeVisitor.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <IMeshTools_ShapeExplorer.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
@@ -42,42 +43,52 @@ BRepMesh_ModelBuilder::~BRepMesh_ModelBuilder ()
// Function: Perform
// Purpose :
//=======================================================================
Handle (IMeshData_Model) BRepMesh_ModelBuilder::performInternal (
Handle (IMeshData_Model) BRepMesh_ModelBuilder::Perform (
const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters)
{
ClearStatus ();
Handle (BRepMeshData_Model) aModel;
Bnd_Box aBox;
BRepBndLib::Add (theShape, aBox, Standard_False);
if (!aBox.IsVoid ())
try
{
// Build data model for further processing.
aModel = new BRepMeshData_Model (theShape);
OCC_CATCH_SIGNALS
if (theParameters.Relative)
Bnd_Box aBox;
BRepBndLib::Add (theShape, aBox, Standard_False);
if (!aBox.IsVoid ())
{
Standard_Real aMaxSize;
BRepMesh_ShapeTool::BoxMaxDimension (aBox, aMaxSize);
aModel->SetMaxSize(aMaxSize);
// Build data model for further processing.
aModel = new BRepMeshData_Model (theShape);
if (theParameters.Relative)
{
Standard_Real aMaxSize;
BRepMesh_ShapeTool::BoxMaxDimension (aBox, aMaxSize);
aModel->SetMaxSize(aMaxSize);
}
else
{
aModel->SetMaxSize(Max(theParameters.Deflection,
theParameters.DeflectionInterior));
}
Handle (IMeshTools_ShapeVisitor) aVisitor =
new BRepMesh_ShapeVisitor (aModel);
IMeshTools_ShapeExplorer aExplorer (theShape);
aExplorer.Accept (aVisitor);
SetStatus (Message_Done1);
}
else
{
aModel->SetMaxSize(Max(theParameters.Deflection,
theParameters.DeflectionInterior));
SetStatus(Message_Fail1);
}
Handle (IMeshTools_ShapeVisitor) aVisitor =
new BRepMesh_ShapeVisitor (aModel);
IMeshTools_ShapeExplorer aExplorer (theShape);
aExplorer.Accept (aVisitor);
SetStatus (Message_Done1);
}
else
catch (Standard_Failure&)
{
SetStatus (Message_Fail1);
SetStatus (Message_Fail2);
}
return aModel;

View File

@@ -36,15 +36,13 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_ModelBuilder ();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelBuilder, IMeshTools_ModelBuilder)
protected:
//! Creates discrete model for the given shape.
//! Returns nullptr in case of failure.
Standard_EXPORT virtual Handle (IMeshData_Model) performInternal (
Standard_EXPORT virtual Handle (IMeshData_Model) Perform (
const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelBuilder, IMeshTools_ModelBuilder)
};
#endif

View File

@@ -115,7 +115,7 @@ BRepMesh_ModelHealer::~BRepMesh_ModelHealer()
// Function: Perform
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_ModelHealer::performInternal(
Standard_Boolean BRepMesh_ModelHealer::Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
{
@@ -226,30 +226,21 @@ Standard_Boolean BRepMesh_ModelHealer::popEdgesToUpdate(
//=======================================================================
void BRepMesh_ModelHealer::process(const IMeshData::IFaceHandle& theDFace) const
{
try
{
OCC_CATCH_SIGNALS
Handle(IMeshData::MapOfIEdgePtr)& aIntersections = myFaceIntersectingEdges->ChangeFind(theDFace.get());
aIntersections.Nullify();
Handle(IMeshData::MapOfIEdgePtr)& aIntersections = myFaceIntersectingEdges->ChangeFind(theDFace.get());
aIntersections.Nullify();
fixFaceBoundaries(theDFace);
if (!theDFace->IsSet(IMeshData_Failure))
{
BRepMesh_FaceChecker aChecker(theDFace, myParameters);
if (!aChecker.Perform())
{
#ifdef DEBUG_HEALER
std::cout << "Failed : #" << aChecker.GetIntersectingEdges()->Size() << std::endl;
#endif
aIntersections = aChecker.GetIntersectingEdges();
}
}
}
catch (Standard_Failure const&)
fixFaceBoundaries(theDFace);
if (!theDFace->IsSet(IMeshData_Failure))
{
theDFace->SetStatus (IMeshData_Failure);
BRepMesh_FaceChecker aChecker(theDFace, myParameters);
if (!aChecker.Perform())
{
#ifdef DEBUG_HEALER
std::cout << "Failed : #" << aChecker.GetIntersectingEdges()->Size() << std::endl;
#endif
aIntersections = aChecker.GetIntersectingEdges();
}
}
}

View File

@@ -44,6 +44,11 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_ModelHealer();
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
//! Functor API to discretize the given edge.
inline void operator() (const Standard_Integer theEdgeIndex) const {
process(theEdgeIndex);
@@ -56,13 +61,6 @@ public:
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelHealer, IMeshTools_ModelAlgo)
protected:
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
private:
//! Checks existing discretization of the face and updates data model.

View File

@@ -177,7 +177,7 @@ BRepMesh_ModelPostProcessor::~BRepMesh_ModelPostProcessor()
// Function: Perform
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_ModelPostProcessor::performInternal(
Standard_Boolean BRepMesh_ModelPostProcessor::Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& /*theParameters*/)
{

View File

@@ -32,14 +32,12 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_ModelPostProcessor();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelPostProcessor, IMeshTools_ModelAlgo)
protected:
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
Standard_EXPORT virtual Standard_Boolean Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelPostProcessor, IMeshTools_ModelAlgo)
};
#endif

View File

@@ -242,7 +242,7 @@ BRepMesh_ModelPreProcessor::~BRepMesh_ModelPreProcessor()
// Function: Perform
// Purpose :
//=======================================================================
Standard_Boolean BRepMesh_ModelPreProcessor::performInternal(
Standard_Boolean BRepMesh_ModelPreProcessor::Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
{

View File

@@ -33,14 +33,12 @@ public:
//! Destructor.
Standard_EXPORT virtual ~BRepMesh_ModelPreProcessor();
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelPreProcessor, IMeshTools_ModelAlgo)
protected:
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
Standard_EXPORT virtual Standard_Boolean Perform(
const Handle(IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ModelPreProcessor, IMeshTools_ModelAlgo)
};
#endif

View File

@@ -1,6 +1,5 @@
BRepMesh_BaseMeshAlgo.cxx
BRepMesh_BaseMeshAlgo.hxx
BRepMesh_ConstrainedBaseMeshAlgo.hxx
BRepMesh_BoundaryParamsRangeSplitter.hxx
BRepMesh_Circle.hxx
BRepMesh_CircleInspector.hxx
@@ -83,6 +82,4 @@ BRepMesh_UVParamRangeSplitter.hxx
BRepMesh_Vertex.hxx
BRepMesh_VertexInspector.hxx
BRepMesh_VertexTool.cxx
BRepMesh_VertexTool.hxx
BRepMesh_CustomBaseMeshAlgo.hxx
BRepMesh_CustomDelaunayBaseMeshAlgo.hxx
BRepMesh_VertexTool.hxx

View File

@@ -17,7 +17,6 @@
#include <gp_Pnt2d.hxx>
#include <BRepMesh_OrientedEdge.hxx>
#include <BRepMesh_Vertex.hxx>
#include <Standard_OutOfRange.hxx>
//=======================================================================
// Function: Constructor
@@ -75,9 +74,6 @@ void BRepMeshData_PCurve::AddPoint (
//=======================================================================
gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
{
Standard_OutOfRange_Raise_if (
theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myPoints2d.size()),
"BRepMeshData_PCurve::GetPoint");
return myPoints2d[theIndex];
}
@@ -87,9 +83,6 @@ gp_Pnt2d& BRepMeshData_PCurve::GetPoint (const Standard_Integer theIndex)
//=======================================================================
Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
{
Standard_OutOfRange_Raise_if (
theIndex < 0 || theIndex >= static_cast<Standard_Integer>(myIndices.size()),
"BRepMeshData_PCurve::GetIndex");
return myIndices[theIndex];
}
@@ -99,9 +92,6 @@ Standard_Integer& BRepMeshData_PCurve::GetIndex(const Standard_Integer theIndex)
//=======================================================================
Standard_Real& BRepMeshData_PCurve::GetParameter (const Standard_Integer theIndex)
{
Standard_OutOfRange_Raise_if (
theIndex < 0 || theIndex >= ParametersNb(),
"BRepMeshData_PCurve::GetParameter");
return myParameters[theIndex];
}

View File

@@ -1486,9 +1486,7 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands)
"\n\t\t: -noTriangulation Force use of exact geometry for calculation"
"\n\t\t: even if triangulation is present."
"\n\t\t: -optimal Force calculation of optimal (more tight) AABB."
"\n\t\t: In case of OBB:"
"\n\t\t: - for PCA approach applies to initial AABB used in OBB calculation"
"\n\t\t: - for DiTo approach modifies the DiTo algorithm to check more axes."
"\n\t\t: In case of OBB, applies to initial AABB used in OBB calculation."
"\n\t\t: -extToler Include tolerance of the shape in the resulting box."
"\n\t\t:"
"\n\t\t: Output options:"

View File

@@ -14,177 +14,11 @@
#include <Bnd_OBB.hxx>
#include <Bnd_Tools.hxx>
#include <Bnd_Range.hxx>
#include <BVH_BoxSet.hxx>
#include <BVH_LinearBuilder.hxx>
#include <BVH_Traverse.hxx>
#include <Bnd_B3d.hxx>
#include <NCollection_Array1.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
//! Auxiliary class to select from the points stored in
//! BVH tree the two points giving the extreme projection
//! parameters on the axis
class OBB_ExtremePointsSelector :
public BVH_Traverse <Standard_Real, 3, BVH_BoxSet <Standard_Real, 3, gp_XYZ>, Bnd_Range>
{
public:
//! Constructor
OBB_ExtremePointsSelector() :
BVH_Traverse <Standard_Real, 3, BVH_BoxSet <Standard_Real, 3, gp_XYZ>, Bnd_Range>(),
myPrmMin (RealLast()),
myPrmMax (RealFirst())
{}
public: //! @name Set axis for projection
//! Sets the axis
void SetAxis (const gp_XYZ& theAxis) { myAxis = theAxis; }
public: //! @name Clears the points from previous runs
//! Clear
void Clear()
{
myPrmMin = RealLast();
myPrmMax = RealFirst();
}
public: //! @name Getting the results
//! Returns the minimal projection parameter
Standard_Real MinPrm() const { return myPrmMin; }
//! Returns the maximal projection parameter
Standard_Real MaxPrm() const { return myPrmMax; }
//! Returns the minimal projection point
const gp_XYZ& MinPnt() const { return myPntMin; }
//! Returns the maximal projection point
const gp_XYZ& MaxPnt() const { return myPntMax; }
public: //! @name Definition of rejection/acceptance rules
//! Defines the rules for node rejection
virtual Standard_Boolean RejectNode (const BVH_Vec3d& theCMin,
const BVH_Vec3d& theCMax,
Bnd_Range& theMetric) const Standard_OVERRIDE
{
if (myPrmMin > myPrmMax)
// No parameters computed yet
return Standard_False;
Standard_Real aPrmMin = myPrmMin, aPrmMax = myPrmMax;
Standard_Boolean isToReject = Standard_True;
// Check if the current node is between already found parameters
for (Standard_Integer i = 0; i < 2; ++i)
{
Standard_Real x = !i ? theCMin.x() : theCMax.x();
for (Standard_Integer j = 0; j < 2; ++j)
{
Standard_Real y = !j ? theCMin.y() : theCMax.y();
for (Standard_Integer k = 0; k < 2; ++k)
{
Standard_Real z = !k ? theCMin.z() : theCMax.z();
Standard_Real aPrm = myAxis.Dot (gp_XYZ (x, y, z));
if (aPrm < aPrmMin)
{
aPrmMin = aPrm;
isToReject = Standard_False;
}
else if (aPrm > aPrmMax)
{
aPrmMax = aPrm;
isToReject = Standard_False;
}
}
}
}
theMetric = Bnd_Range (aPrmMin, aPrmMax);
return isToReject;
}
//! Rules for node rejection by the metric
virtual Standard_Boolean RejectMetric (const Bnd_Range& theMetric) const Standard_OVERRIDE
{
if (myPrmMin > myPrmMax)
// no parameters computed
return Standard_False;
Standard_Real aMin, aMax;
if (!theMetric.GetBounds (aMin, aMax))
// void metric
return Standard_False;
// Check if the box of the branch is inside of the already computed parameters
return aMin > myPrmMin && aMax < myPrmMax;
}
//! Defines the rules for leaf acceptance
virtual Standard_Boolean Accept (const Standard_Integer theIndex,
const Bnd_Range&) Standard_OVERRIDE
{
const gp_XYZ& theLeaf = myBVHSet->Element (theIndex);
Standard_Real aPrm = myAxis.Dot (theLeaf);
if (aPrm < myPrmMin)
{
myPrmMin = aPrm;
myPntMin = theLeaf;
}
if (aPrm > myPrmMax)
{
myPrmMax = aPrm;
myPntMax = theLeaf;
}
return Standard_True;
}
public: //! @name Choosing the best branch
//! Returns true if the metric of the left branch is better than the metric of the right
virtual Standard_Boolean IsMetricBetter (const Bnd_Range& theLeft,
const Bnd_Range& theRight) const Standard_OVERRIDE
{
if (myPrmMin > myPrmMax)
// no parameters computed
return Standard_True;
Standard_Real aMin[2], aMax[2];
if (!theLeft.GetBounds (aMin[0], aMax[0]) ||
!theRight.GetBounds (aMin[1], aMax[1]))
// void metrics
return Standard_True;
// Choose branch with larger extension over computed parameters
Standard_Real anExt[2] = {0.0, 0.0};
for (int i = 0; i < 2; ++i)
{
if (aMin[i] < myPrmMin) anExt[i] += myPrmMin - aMin[i];
if (aMax[i] > myPrmMax) anExt[i] += aMax[i] - myPrmMax;
}
return anExt[0] > anExt[1];
}
protected: //! @name Fields
gp_XYZ myAxis; //!< Axis to project the points to
Standard_Real myPrmMin; //!< Minimal projection parameter
Standard_Real myPrmMax; //!< Maximal projection parameter
gp_XYZ myPntMin; //!< Minimal projection point
gp_XYZ myPntMax; //!< Maximal projection point
};
//! Tool for OBB construction
class OBBTool
{
public:
@@ -197,8 +31,7 @@ public:
//! must be available during all time of OBB creation
//! (i.e. while the object of OBBTool exists).
OBBTool(const TColgp_Array1OfPnt& theL,
const TColStd_Array1OfReal *theLT = 0,
Standard_Boolean theIsOptimal = Standard_False);
const TColStd_Array1OfReal *theLT = 0);
//! DiTO algorithm for OBB construction
//! (http://www.idt.mdh.se/~tla/publ/FastOBBs.pdf)
@@ -208,10 +41,6 @@ public:
void BuildBox(Bnd_OBB& theBox);
protected:
// Computes the extreme points on the set of Initial axes
void ComputeExtremePoints ();
//! Works with the triangle set by the points in myTriIdx.
//! If theIsBuiltTrg == TRUE, new set of triangles will be
//! recomputed.
@@ -242,106 +71,6 @@ protected:
OBBTool& operator=(const OBBTool&);
private:
//! Params structure stores the two values meaning
//! min and max parameters on the axis
struct Params
{
Params() :
_ParamMin(RealLast()), _ParamMax(RealFirst())
{}
Params(Standard_Real theMin, Standard_Real theMax)
: _ParamMin(theMin), _ParamMax(theMax)
{}
Standard_Real _ParamMin;
Standard_Real _ParamMax;
};
//! Computes the Minimal and maximal parameters on the vector
//! connecting the points myLExtremalPoints[theId1] and myLExtremalPoints[theId2]
void ComputeParams (const Standard_Integer theId1,
const Standard_Integer theId2,
Standard_Real &theMin,
Standard_Real &theMax)
{
theMin = myParams[theId1][theId2]._ParamMin;
theMax = myParams[theId1][theId2]._ParamMax;
if (theMin > theMax)
{
FindMinMax ((myLExtremalPoints[theId1] - myLExtremalPoints[theId2]).Normalized(), theMin, theMax);
myParams[theId1][theId2]._ParamMin = myParams[theId2][theId1]._ParamMin = theMin;
myParams[theId1][theId2]._ParamMax = myParams[theId2][theId1]._ParamMax = theMax;
}
}
//! Looks for the min-max parameters on the axis.
//! For optimal case projects all the points on the axis,
//! for not optimal - only the set of extreme points.
void FindMinMax (const gp_XYZ& theAxis,
Standard_Real &theMin,
Standard_Real &theMax)
{
theMin = RealLast(), theMax = RealFirst();
if (myOptimal)
Project (theAxis, theMin, theMax);
else
{
for (Standard_Integer i = 0; i < myNbExtremalPoints; ++i)
{
Standard_Real aPrm = theAxis.Dot (myLExtremalPoints[i]);
if (aPrm < theMin) theMin = aPrm;
if (aPrm > theMax) theMax = aPrm;
}
}
}
//! Projects the set of points on the axis
void Project (const gp_XYZ& theAxis,
Standard_Real& theMin, Standard_Real& theMax,
gp_XYZ* thePntMin = 0, gp_XYZ* thePntMax = 0)
{
theMin = RealLast(), theMax = RealFirst();
if (myOptimal)
{
// Project BVH
OBB_ExtremePointsSelector anExtremePointsSelector;
anExtremePointsSelector.SetBVHSet (myPointBoxSet.get());
anExtremePointsSelector.SetAxis (theAxis);
anExtremePointsSelector.Select();
theMin = anExtremePointsSelector.MinPrm();
theMax = anExtremePointsSelector.MaxPrm();
if (thePntMin) *thePntMin = anExtremePointsSelector.MinPnt();
if (thePntMax) *thePntMax = anExtremePointsSelector.MaxPnt();
}
else
{
// Project all points
for (Standard_Integer iP = myPntsList.Lower(); iP <= myPntsList.Upper(); ++iP)
{
const gp_XYZ& aPoint = myPntsList(iP).XYZ();
const Standard_Real aPrm = theAxis.Dot (aPoint);
if (aPrm < theMin)
{
theMin = aPrm;
if (thePntMin)
*thePntMin = aPoint;
}
if (aPrm > theMax)
{
theMax = aPrm;
if (thePntMax)
*thePntMax = aPoint;
}
}
}
}
private:
//! Number of the initial axes.
static const Standard_Integer myNbInitAxes = 7;
@@ -367,16 +96,6 @@ private:
//! The surface area of the OBB
Standard_Real myQualityCriterion;
//! Defines if the OBB should be computed more tight.
//! Takes more time, but the volume is less.
Standard_Boolean myOptimal;
//! Point box set organized with BVH
opencascade::handle<BVH_BoxSet <Standard_Real, 3, gp_XYZ>> myPointBoxSet;
//! Stored min/max parameters for the axes between extremal points
Params myParams[myNbExtremalPoints][myNbExtremalPoints];
};
//=======================================================================
@@ -391,7 +110,7 @@ static inline void SetMinMax(Standard_Real* const thePrmArr,
{
thePrmArr[0] = theNewParam;
}
if(theNewParam > thePrmArr[1])
else if(theNewParam > thePrmArr[1])
{
thePrmArr[1] = theNewParam;
}
@@ -403,102 +122,76 @@ static inline void SetMinMax(Standard_Real* const thePrmArr,
//=======================================================================
OBBTool::
OBBTool(const TColgp_Array1OfPnt& theL,
const TColStd_Array1OfReal *theLT,
const Standard_Boolean theIsOptimal) : myPntsList(theL),
myListOfTolers(theLT),
myQualityCriterion(RealLast()),
myOptimal (theIsOptimal)
const TColStd_Array1OfReal *theLT) :myPntsList(theL),
myListOfTolers(theLT),
myQualityCriterion(RealLast())
{
if (myOptimal)
{
// Use linear builder for BVH construction with 30 elements in the leaf
opencascade::handle<BVH_LinearBuilder<Standard_Real, 3> > aLBuilder =
new BVH_LinearBuilder<Standard_Real, 3> (30);
myPointBoxSet = new BVH_BoxSet <Standard_Real, 3, gp_XYZ> (aLBuilder);
myPointBoxSet->SetSize(myPntsList.Length());
// Add the points into Set
for (Standard_Integer iP = 0; iP < theL.Length(); ++iP)
{
const gp_Pnt& aP = theL (iP);
Standard_Real aTol = theLT ? theLT->Value(iP) : Precision::Confusion();
BVH_Box <Standard_Real, 3> aBox (BVH_Vec3d (aP.X() - aTol, aP.Y() - aTol, aP.Z() - aTol),
BVH_Vec3d (aP.X() + aTol, aP.Y() + aTol, aP.Z() + aTol));
myPointBoxSet->Add (aP.XYZ(), aBox);
}
myPointBoxSet->Build();
}
ComputeExtremePoints();
}
//=======================================================================
// Function : ComputeExtremePoints
// purpose :
//=======================================================================
void OBBTool::ComputeExtremePoints()
{
// Six initial axes show great quality on the Optimal OBB, plus
// the performance is better (due to the less number of operations).
// But they show worse quality for the not optimal approach.
//const Standard_Real a = (sqrt(5) - 1) / 2.;
//const gp_XYZ anInitialAxes6[myNbInitAxes] = { gp_XYZ (0, 1, a),
// gp_XYZ (0, 1, -a),
// gp_XYZ (1, a, 0),
// gp_XYZ (1, -a, 0),
// gp_XYZ (a, 0, 1),
// gp_XYZ (a, 0, -1) };
const Standard_Real aSqrt3 = Sqrt(3);
const gp_XYZ anInitialAxes7[myNbInitAxes] = { gp_XYZ (1.0, 0.0, 0.0),
gp_XYZ (0.0, 1.0, 0.0),
gp_XYZ (0.0, 0.0, 1.0),
gp_XYZ (1.0, 1.0, 1.0) / aSqrt3,
gp_XYZ (1.0, 1.0, -1.0) / aSqrt3,
gp_XYZ (1.0, -1.0, 1.0) / aSqrt3,
gp_XYZ (1.0, -1.0, -1.0) / aSqrt3 };
// Origin of all initial axis is (0,0,0).
// All axes must be normalized.
const gp_XYZ anInitialAxesArray[myNbInitAxes] = {gp_XYZ(1.0, 0.0, 0.0),
gp_XYZ(0.0, 1.0, 0.0),
gp_XYZ(0.0, 0.0, 1.0),
gp_XYZ(1.0, 1.0, 1.0) / aSqrt3,
gp_XYZ(1.0, 1.0, -1.0) / aSqrt3,
gp_XYZ(1.0, -1.0, 1.0) / aSqrt3,
gp_XYZ(1.0, -1.0, -1.0) / aSqrt3};
// Set of initial axes
const gp_XYZ *anInitialAxesArray = anInitialAxes7;
// Minimal and maximal point on every axis
const Standard_Integer aNbPoints = 2 * myNbInitAxes;
// Min and Max parameter
Standard_Real aParams[myNbExtremalPoints];
// Look for the extremal points (myLExtremalPoints)
for (Standard_Integer anAxeInd = 0, aPrmInd = -1; anAxeInd < myNbInitAxes; ++anAxeInd)
for(Standard_Integer i = 0; i < 5; i++)
{
Standard_Integer aMinInd = ++aPrmInd, aMaxInd = ++aPrmInd;
aParams[aMinInd] = RealLast();
aParams[aMaxInd] = -RealLast();
Project (anInitialAxesArray[anAxeInd],
aParams[aMinInd], aParams[aMaxInd],
&myLExtremalPoints[aMinInd], &myLExtremalPoints[aMaxInd]);
myTriIdx[i] = INT_MAX;
}
// Min and Max parameter
Standard_Real aParams[aNbPoints];
for(Standard_Integer i = 0; i < aNbPoints; i += 2)
{
aParams[i] = RealLast();
aParams[i + 1] = RealFirst();
}
// For not optimal box it is necessary to compute the max axis
// created by the maximally distant extreme points
if (!myOptimal)
// Look for the extremal points (myLExtremalPoints)
for(Standard_Integer i = myPntsList.Lower() ; i <= myPntsList.Upper(); i++)
{
for(Standard_Integer i = 0; i < 5; i++)
myTriIdx[i] = INT_MAX;
// Compute myTriIdx[0] and myTriIdx[1].
Standard_Real aMaxSqDist = -1.0;
for (Standard_Integer aPrmInd = 0; aPrmInd < myNbExtremalPoints; aPrmInd += 2)
const gp_XYZ &aCurrPoint = myPntsList(i).XYZ();
for(Standard_Integer anAxeInd = 0, aPrmInd = 0; anAxeInd < myNbInitAxes; anAxeInd++, aPrmInd++)
{
const gp_Pnt &aP1 = myLExtremalPoints[aPrmInd],
&aP2 = myLExtremalPoints[aPrmInd + 1];
const Standard_Real aSqDist = aP1.SquareDistance(aP2);
if (aSqDist > aMaxSqDist)
const Standard_Real aParam = aCurrPoint.Dot(anInitialAxesArray[anAxeInd]);
if(aParam < aParams[aPrmInd])
{
aMaxSqDist = aSqDist;
myTriIdx[0] = aPrmInd;
myTriIdx[1] = aPrmInd + 1;
myLExtremalPoints[aPrmInd] = aCurrPoint;
aParams[aPrmInd] = aParam;
}
aPrmInd++;
if(aParam > aParams[aPrmInd])
{
myLExtremalPoints[aPrmInd] = aCurrPoint;
aParams[aPrmInd] = aParam;
}
}
// Compute the maximal axis orthogonal to the found one
FillToTriangle3();
}
// Compute myTriIdx[0] and myTriIdx[1].
Standard_Real aMaxSqDist = -1.0;
for(Standard_Integer aPrmInd = 0; aPrmInd < aNbPoints; aPrmInd += 2)
{
const gp_Pnt &aP1 = myLExtremalPoints[aPrmInd],
&aP2 = myLExtremalPoints[aPrmInd + 1];
const Standard_Real aSqDist = aP1.SquareDistance(aP2);
if(aSqDist > aMaxSqDist)
{
aMaxSqDist = aSqDist;
myTriIdx[0] = aPrmInd;
myTriIdx[1] = aPrmInd + 1;
}
}
FillToTriangle3();
}
//=======================================================================
@@ -540,7 +233,6 @@ void OBBTool::FillToTriangle5(const gp_XYZ& theNormal,
const gp_XYZ& theBarryCenter)
{
Standard_Real aParams[2] = {0.0, 0.0};
Standard_Integer id3 = -1, id4 = -1;
for(Standard_Integer aPtIdx = 0; aPtIdx < myNbExtremalPoints; aPtIdx++)
{
@@ -550,24 +242,28 @@ void OBBTool::FillToTriangle5(const gp_XYZ& theNormal,
const gp_XYZ &aCurrPoint = myLExtremalPoints[aPtIdx];
const Standard_Real aParam = theNormal.Dot(aCurrPoint - theBarryCenter);
if (aParam < aParams[0])
if(aParam < aParams[0])
{
id3 = aPtIdx;
myTriIdx[3] = aPtIdx;
aParams[0] = aParam;
}
else if (aParam > aParams[1])
else if(aParam > aParams[1])
{
id4 = aPtIdx;
myTriIdx[4] = aPtIdx;
aParams[1] = aParam;
}
}
// The points must be in the different sides of the triangle plane.
if (id3 >= 0 && aParams[0] < -Precision::Confusion())
myTriIdx[3] = id3;
if(aParams[0] > -Precision::Confusion())
{
myTriIdx[3] = INT_MAX;
}
if (id4 >= 0 && aParams[1] > Precision::Confusion())
myTriIdx[4] = id4;
if(aParams[1] < Precision::Confusion())
{
myTriIdx[4] = INT_MAX;
}
}
//=======================================================================
@@ -583,60 +279,71 @@ void OBBTool::ProcessTriangle(const Standard_Integer theIdx1,
{
const Standard_Integer aNbAxes = 3;
//Some vertex of the triangle
const gp_XYZ aP0 = myLExtremalPoints[theIdx1];
// All axes must be normalized in order to provide correct area computation
// (see ComputeQuality(...) method).
int ID1[3] = { theIdx2, theIdx3, theIdx1 },
ID2[3] = { theIdx1, theIdx2, theIdx3 };
gp_XYZ aYAxis[aNbAxes] = {(myLExtremalPoints[ID1[0]] - myLExtremalPoints[ID2[0]]),
(myLExtremalPoints[ID1[1]] - myLExtremalPoints[ID2[1]]),
(myLExtremalPoints[ID1[2]] - myLExtremalPoints[ID2[2]])};
gp_XYZ aYAxis[aNbAxes] = {(myLExtremalPoints[theIdx2] - myLExtremalPoints[theIdx1]),
(myLExtremalPoints[theIdx3] - myLExtremalPoints[theIdx2]),
(myLExtremalPoints[theIdx1] - myLExtremalPoints[theIdx3])};
// Normal to the triangle plane
gp_XYZ aZAxis = aYAxis[0].Crossed(aYAxis[1]);
Standard_Real aSqMod = aZAxis.SquareModulus();
if (aSqMod < Precision::SquareConfusion())
if(aSqMod < Precision::SquareConfusion())
return;
aZAxis /= Sqrt(aSqMod);
gp_XYZ aXAxis[aNbAxes];
for (Standard_Integer i = 0; i < aNbAxes; i++)
for(Standard_Integer i = 0; i < aNbAxes; i++)
{
aXAxis[i] = aYAxis[i].Crossed(aZAxis).Normalized();
aYAxis[i].Normalize();
}
if (theIsBuiltTrg)
FillToTriangle5 (aZAxis, myLExtremalPoints[theIdx1]);
if(theIsBuiltTrg)
FillToTriangle5(aZAxis, aP0);
// Min and Max parameter
const Standard_Integer aNbPoints = 2 * aNbAxes;
// Compute Min/Max params for ZAxis
Standard_Real aParams[aNbPoints];
FindMinMax (aZAxis, aParams[4], aParams[5]); // Compute params on ZAxis once
Standard_Integer aMinIdx = -1;
for(Standard_Integer anAxeInd = 0; anAxeInd < aNbAxes; anAxeInd++)
{
const gp_XYZ &aAX = aXAxis[anAxeInd];
// Compute params on XAxis
FindMinMax (aAX, aParams[0], aParams[1]);
// Compute params on YAxis checking for stored values
ComputeParams (ID1[anAxeInd], ID2[anAxeInd], aParams[2], aParams[3]);
const gp_XYZ &aAX = aXAxis[anAxeInd],
&aAY = aYAxis[anAxeInd];
Standard_Real aParams[aNbPoints] = {0.0, 0.0, 0.0,
0.0, 0.0, 0.0};
for(Standard_Integer aPtIdx = 0; aPtIdx < myNbExtremalPoints; aPtIdx++)
{
if(aPtIdx == theIdx1)
continue;
const gp_XYZ aCurrPoint = myLExtremalPoints[aPtIdx] - aP0;
SetMinMax(&aParams[0], aAX.Dot(aCurrPoint));
SetMinMax(&aParams[2], aAY.Dot(aCurrPoint));
SetMinMax(&aParams[4], aZAxis.Dot(aCurrPoint));
}
const Standard_Real anArea = ComputeQuality(aParams);
if (anArea < myQualityCriterion)
if(anArea < myQualityCriterion)
{
myQualityCriterion = anArea;
aMinIdx = anAxeInd;
}
}
if (aMinIdx < 0)
if(aMinIdx < 0)
return;
myAxes[0] = aXAxis[aMinIdx];
myAxes[1] = aYAxis[aMinIdx].Normalized();
myAxes[1] = aYAxis[aMinIdx];
myAxes[2] = aZAxis;
}
//=======================================================================
@@ -645,41 +352,20 @@ void OBBTool::ProcessTriangle(const Standard_Integer theIdx1,
//=======================================================================
void OBBTool::ProcessDiTetrahedron()
{
// To compute the optimal OBB it is necessary to check all possible
// axes created by the extremal points. It is also necessary to project
// all the points on the axis, as for each different axis there will be
// different extremal points.
if (myOptimal)
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[2], Standard_True);
if(myTriIdx[3] <= myNbExtremalPoints)
{
for (Standard_Integer i = 0; i < myNbExtremalPoints - 2; i++)
{
for (Standard_Integer j = i + 1; j < myNbExtremalPoints - 1; j++)
{
for (Standard_Integer k = j + 1; k < myNbExtremalPoints; k++)
{
ProcessTriangle (i, j, k, Standard_False);
}
}
}
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[3], Standard_False);
ProcessTriangle(myTriIdx[1], myTriIdx[2], myTriIdx[3], Standard_False);
ProcessTriangle(myTriIdx[0], myTriIdx[2], myTriIdx[3], Standard_False);
}
else
if(myTriIdx[4] <= myNbExtremalPoints)
{
// Use the standard DiTo approach
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[2], Standard_True);
if (myTriIdx[3] <= myNbExtremalPoints)
{
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[3], Standard_False);
ProcessTriangle(myTriIdx[1], myTriIdx[2], myTriIdx[3], Standard_False);
ProcessTriangle(myTriIdx[0], myTriIdx[2], myTriIdx[3], Standard_False);
}
if (myTriIdx[4] <= myNbExtremalPoints)
{
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[4], Standard_False);
ProcessTriangle(myTriIdx[1], myTriIdx[2], myTriIdx[4], Standard_False);
ProcessTriangle(myTriIdx[0], myTriIdx[2], myTriIdx[4], Standard_False);
}
ProcessTriangle(myTriIdx[0], myTriIdx[1], myTriIdx[4], Standard_False);
ProcessTriangle(myTriIdx[1], myTriIdx[2], myTriIdx[4], Standard_False);
ProcessTriangle(myTriIdx[0], myTriIdx[2], myTriIdx[4], Standard_False);
}
}
@@ -766,8 +452,7 @@ void OBBTool::BuildBox(Bnd_OBB& theBox)
// purpose : http://www.idt.mdh.se/~tla/publ/
// =======================================================================
void Bnd_OBB::ReBuild(const TColgp_Array1OfPnt& theListOfPoints,
const TColStd_Array1OfReal *theListOfTolerances,
const Standard_Boolean theIsOptimal)
const TColStd_Array1OfReal *theListOfTolerances)
{
switch(theListOfPoints.Length())
{
@@ -819,7 +504,7 @@ void Bnd_OBB::ReBuild(const TColgp_Array1OfPnt& theListOfPoints,
break;
}
OBBTool aTool(theListOfPoints, theListOfTolerances, theIsOptimal);
OBBTool aTool(theListOfPoints, theListOfTolerances);
aTool.ProcessDiTetrahedron();
aTool.BuildBox(*this);
}

View File

@@ -95,17 +95,12 @@ public:
myCenter.SetCoord(0.5*(aX2 + aX1), 0.5*(aY2 + aY1), 0.5*(aZ2 + aZ1));
}
//! Creates new OBB covering every point in theListOfPoints.
//! Created new OBB covering every point in theListOfPoints.
//! Tolerance of every such point is set by *theListOfTolerances array.
//! If this array is not void (not null-pointer) then the resulted Bnd_OBB
//! will be enlarged using tolerances of points lying on the box surface.
//! <theIsOptimal> flag defines the mode in which the OBB will be built.
//! Constructing Optimal box takes more time, but the resulting box is usually
//! more tight. In case of construction of Optimal OBB more possible
//! axes are checked.
Standard_EXPORT void ReBuild(const TColgp_Array1OfPnt& theListOfPoints,
const TColStd_Array1OfReal *theListOfTolerances = 0,
const Standard_Boolean theIsOptimal = Standard_False);
const TColStd_Array1OfReal *theListOfTolerances = 0);
//! Sets the center of OBB
void SetCenter(const gp_Pnt& theCenter)

View File

@@ -362,11 +362,6 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
#else
di << "OpenGL: desktop\n";
#endif
#ifdef HAVE_RAPIDJSON
di << "RapidJSON enabled (HAVE_RAPIDJSON)\n";
#else
di << "RapidJSON disabled\n";
#endif
#ifdef HAVE_VTK
di << "VTK enabled (HAVE_VTK)\n";
#else

View File

@@ -310,23 +310,6 @@ proc checkreal {name value expected tol_abs tol_rel} {
return
}
# Procedure to check equality of two 3D points with tolerance
help checkpoint {
Compare two 3D points with given tolerance
Use: checkpoint name {valueX valueY valueZ} {expectedX expectedY expectedZ} tolerance
}
proc checkpoint {theName theValue theExpected theTolerance} {
set e 0.0001
foreach i {0 1 2} {
if { [expr abs([lindex $theValue $i] - [lindex $theExpected $i])] > $theTolerance } {
puts "Error: $theName, ($theValue) is not equal to expected ($theExpected)"
return
}
}
puts "Check of $theName OK: value = ($theValue), expected = ($theExpected)"
return
}
help checkfreebounds {
Compare number of free edges with ref_value

View File

@@ -1298,23 +1298,23 @@ proc _run_test {scriptsdir group gridname casefile echo} {
# execute test scripts
if { [file exists $scriptsdir/$group/begin] } {
puts "Executing $scriptsdir/$group/begin..."; flush stdout
uplevel source -encoding utf-8 $scriptsdir/$group/begin
uplevel source $scriptsdir/$group/begin
}
if { [file exists $scriptsdir/$group/$gridname/begin] } {
puts "Executing $scriptsdir/$group/$gridname/begin..."; flush stdout
uplevel source -encoding utf-8 $scriptsdir/$group/$gridname/begin
uplevel source $scriptsdir/$group/$gridname/begin
}
puts "Executing $casefile..."; flush stdout
uplevel source -encoding utf-8 $casefile
uplevel source $casefile
if { [file exists $scriptsdir/$group/$gridname/end] } {
puts "Executing $scriptsdir/$group/$gridname/end..."; flush stdout
uplevel source -encoding utf-8 $scriptsdir/$group/$gridname/end
uplevel source $scriptsdir/$group/$gridname/end
}
if { [file exists $scriptsdir/$group/end] } {
puts "Executing $scriptsdir/$group/end..."; flush stdout
uplevel source -encoding utf-8 $scriptsdir/$group/end
uplevel source $scriptsdir/$group/end
}
} res] {
puts "Tcl Exception: $res"

View File

@@ -78,19 +78,13 @@ proc dftree { DDF_Browser } {
## ]
set w .$DDF_Browser
toplevel $w -width 700 -height 400 -background bisque3
wm minsize $w 700 400
toplevel $w -height 400 -width 700 -background bisque3
########
# Tree #
########
#set tree1 [ttk::treeview $w.tree -show tree]
set tree1 [ttk::treeview $w.tree -show tree -xscrollcommand "$w.tree.xscroll set" -yscrollcommand "$w.tree.yscroll set"]
set aScrollX [ttk::scrollbar $w.tree.xscroll -command "$w.tree xview" -orient horizontal]
set aScrollY [ttk::scrollbar $w.tree.yscroll -command "$w.tree yview"]
pack $aScrollX -side bottom -fill x
pack $aScrollY -side right -fill y
set tree1 [ttk::treeview $w.tree -show tree]
$tree1 tag bind Label <<TreeviewOpen>> [list DFTREE:Tree:Open $DDF_Browser $w]
$tree1 tag configure Label -font 9x15bold -foreground DarkGreen
#$tree1 tag configure Attribute -font 9x15 -background bisque3

View File

@@ -17,4 +17,3 @@ Font_SystemFont.cxx
Font_SystemFont.hxx
Font_TextFormatter.hxx
Font_TextFormatter.cxx
Font_UnicodeSubset.hxx

View File

@@ -407,7 +407,7 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
{
theShape.Nullify();
if (!loadGlyph (theChar)
|| myActiveFTFace->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
|| myFTFace->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
{
return Standard_False;
}
@@ -416,7 +416,8 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar,
return !theShape.IsNull();
}
const FT_Outline& anOutline = myActiveFTFace->glyph->outline;
FT_Outline& anOutline = myFTFace->glyph->outline;
if (!anOutline.n_contours)
return Standard_False;

View File

@@ -21,8 +21,6 @@
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <algorithm>
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -35,12 +33,9 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FTFont,Standard_Transient)
Font_FTFont::Font_FTFont (const Handle(Font_FTLibrary)& theFTLib)
: myFTLib (theFTLib),
myFTFace (NULL),
myActiveFTFace(NULL),
myFontAspect (Font_FontAspect_Regular),
myWidthScaling(1.0),
myLoadFlags (FT_LOAD_NO_HINTING | FT_LOAD_TARGET_NORMAL),
myUChar (0U),
myToUseUnicodeSubsetFallback (Font_FontMgr::ToUseUnicodeSubsetFallback())
myUChar (0U)
{
if (myFTLib.IsNull())
{
@@ -71,7 +66,6 @@ void Font_FTFont::Release()
FT_Done_Face (myFTFace);
myFTFace = NULL;
}
myActiveFTFace = NULL;
myBuffer.Nullify();
}
@@ -141,7 +135,6 @@ bool Font_FTFont::Init (const Handle(NCollection_Buffer)& theData,
FT_Set_Transform (myFTFace, &aMat, 0);
}
myActiveFTFace = myFTFace;
return true;
}
@@ -168,7 +161,6 @@ Handle(Font_FTFont) Font_FTFont::FindAndCreate (const TCollection_AsciiString& t
Handle(Font_FTFont) aFont = new Font_FTFont();
if (aFont->Init (aPath, aParams))
{
aFont->myFontAspect = aFontAspect;
return aFont;
}
}
@@ -185,61 +177,22 @@ bool Font_FTFont::FindAndInit (const TCollection_AsciiString& theFontName,
Font_StrictLevel theStrictLevel)
{
Font_FTFontParams aParams = theParams;
myFontAspect = theFontAspect;
Font_FontAspect aFontAspect = theFontAspect;
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (theFontName.ToCString(), theStrictLevel, myFontAspect))
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (theFontName.ToCString(), theStrictLevel, aFontAspect))
{
if (aRequestedFont->IsSingleStrokeFont())
{
aParams.IsSingleStrokeFont = true;
}
const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic);
const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (aFontAspect, aParams.ToSynthesizeItalic);
return Init (aPath, aParams);
}
Release();
return false;
}
// =======================================================================
// function : findAndInitFallback
// purpose :
// =======================================================================
bool Font_FTFont::findAndInitFallback (Font_UnicodeSubset theSubset)
{
if (!myFallbackFaces[theSubset].IsNull())
{
return myFallbackFaces[theSubset]->IsValid();
}
myFallbackFaces[theSubset] = new Font_FTFont (myFTLib);
myFallbackFaces[theSubset]->myToUseUnicodeSubsetFallback = false; // no recursion
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
if (Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFallbackFont (theSubset, myFontAspect))
{
Font_FTFontParams aParams = myFontParams;
aParams.IsSingleStrokeFont = aRequestedFont->IsSingleStrokeFont();
const TCollection_AsciiString& aPath = aRequestedFont->FontPathAny (myFontAspect, aParams.ToSynthesizeItalic);
if (myFallbackFaces[theSubset]->Init (aPath, aParams))
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Font_FTFont, using fallback font '") + aRequestedFont->FontName() + "'"
+ " for symbols unsupported by '" + myFTFace->family_name + "'", Message_Trace);
}
}
return myFallbackFaces[theSubset]->IsValid();
}
// =======================================================================
// function : HasSymbol
// purpose :
// =======================================================================
bool Font_FTFont::HasSymbol (Standard_Utf32Char theUChar) const
{
return FT_Get_Char_Index (myFTFace, theUChar) != 0;
}
// =======================================================================
// function : loadGlyph
// purpose :
@@ -253,26 +206,9 @@ bool Font_FTFont::loadGlyph (const Standard_Utf32Char theUChar)
myGlyphImg.Clear();
myUChar = 0;
myActiveFTFace = myFTFace;
if (theUChar == 0)
{
return false;
}
if (myToUseUnicodeSubsetFallback
&& !HasSymbol (theUChar))
{
// try using fallback
const Font_UnicodeSubset aSubset = CharSubset (theUChar);
if (findAndInitFallback (aSubset)
&& myFallbackFaces[aSubset]->HasSymbol (theUChar))
{
myActiveFTFace = myFallbackFaces[aSubset]->myFTFace;
}
}
if (FT_Load_Char (myActiveFTFace, theUChar, FT_Int32(myLoadFlags)) != 0
|| myActiveFTFace->glyph == NULL)
if (theUChar == 0
|| FT_Load_Char (myFTFace, theUChar, FT_Int32(myLoadFlags)) != 0
|| myFTFace->glyph == NULL)
{
return false;
}
@@ -289,67 +225,26 @@ bool Font_FTFont::RenderGlyph (const Standard_Utf32Char theUChar)
{
myGlyphImg.Clear();
myUChar = 0;
myActiveFTFace = myFTFace;
if (theUChar != 0
&& myToUseUnicodeSubsetFallback
&& !HasSymbol (theUChar))
{
// try using fallback
const Font_UnicodeSubset aSubset = CharSubset (theUChar);
if (findAndInitFallback (aSubset)
&& myFallbackFaces[aSubset]->HasSymbol (theUChar))
{
myActiveFTFace = myFallbackFaces[aSubset]->myFTFace;
}
}
if (theUChar == 0
|| FT_Load_Char (myActiveFTFace, theUChar, FT_Int32(myLoadFlags | FT_LOAD_RENDER)) != 0
|| myActiveFTFace->glyph == NULL
|| myActiveFTFace->glyph->format != FT_GLYPH_FORMAT_BITMAP)
|| FT_Load_Char (myFTFace, theUChar, FT_Int32(myLoadFlags | FT_LOAD_RENDER)) != 0
|| myFTFace->glyph == NULL
|| myFTFace->glyph->format != FT_GLYPH_FORMAT_BITMAP)
{
return false;
}
FT_Bitmap aBitmap = myActiveFTFace->glyph->bitmap;
if (aBitmap.buffer == NULL || aBitmap.width == 0 || aBitmap.rows == 0)
FT_Bitmap aBitmap = myFTFace->glyph->bitmap;
if (aBitmap.pixel_mode != FT_PIXEL_MODE_GRAY
|| aBitmap.buffer == NULL || aBitmap.width == 0 || aBitmap.rows == 0)
{
return false;
}
if (aBitmap.pixel_mode == FT_PIXEL_MODE_GRAY)
{
if (!myGlyphImg.InitWrapper (Image_Format_Alpha, aBitmap.buffer,
aBitmap.width, aBitmap.rows, Abs (aBitmap.pitch)))
{
return false;
}
myGlyphImg.SetTopDown (aBitmap.pitch > 0);
}
else if (aBitmap.pixel_mode == FT_PIXEL_MODE_MONO)
{
if (!myGlyphImg.InitTrash (Image_Format_Gray, aBitmap.width, aBitmap.rows))
{
return false;
}
myGlyphImg.SetTopDown (aBitmap.pitch > 0);
const int aNumOfBytesInRow = aBitmap.width / 8 + (aBitmap.width % 8 ? 1 : 0);
for (int aRow = 0; aRow < (int )aBitmap.rows; ++aRow)
{
for (int aCol = 0; aCol < (int )aBitmap.width; ++aCol)
{
const int aBitOn = aBitmap.buffer[aNumOfBytesInRow * aRow + aCol / 8] & (0x80 >> (aCol % 8));
*myGlyphImg.ChangeRawValue (aRow, aCol) = aBitOn ? 255 : 0;
}
}
}
else
if (!myGlyphImg.InitWrapper (Image_Format_Alpha, aBitmap.buffer,
aBitmap.width, aBitmap.rows, Abs (aBitmap.pitch)))
{
return false;
}
myGlyphImg.SetTopDown (aBitmap.pitch > 0);
myUChar = theUChar;
return true;
}
@@ -358,58 +253,24 @@ bool Font_FTFont::RenderGlyph (const Standard_Utf32Char theUChar)
// function : GlyphMaxSizeX
// purpose :
// =======================================================================
unsigned int Font_FTFont::GlyphMaxSizeX (bool theToIncludeFallback) const
unsigned int Font_FTFont::GlyphMaxSizeX() const
{
if (!theToIncludeFallback)
{
float aWidth = (FT_IS_SCALABLE(myFTFace) != 0)
? float(myFTFace->bbox.xMax - myFTFace->bbox.xMin) * (float(myFTFace->size->metrics.x_ppem) / float(myFTFace->units_per_EM))
: fromFTPoints<float> (myFTFace->size->metrics.max_advance);
return (unsigned int)(aWidth + 0.5f);
}
unsigned int aWidth = GlyphMaxSizeX (false);
if (theToIncludeFallback)
{
for (Standard_Integer aFontIter = 0; aFontIter < Font_UnicodeSubset_NB; ++aFontIter)
{
if (!myFallbackFaces[aFontIter].IsNull()
&& myFallbackFaces[aFontIter]->IsValid())
{
aWidth = std::max (aWidth, myFallbackFaces[aFontIter]->GlyphMaxSizeX (false));
}
}
}
return aWidth;
float aWidth = (FT_IS_SCALABLE(myFTFace) != 0)
? float(myFTFace->bbox.xMax - myFTFace->bbox.xMin) * (float(myFTFace->size->metrics.x_ppem) / float(myFTFace->units_per_EM))
: fromFTPoints<float> (myFTFace->size->metrics.max_advance);
return (unsigned int)(aWidth + 0.5f);
}
// =======================================================================
// function : GlyphMaxSizeY
// purpose :
// =======================================================================
unsigned int Font_FTFont::GlyphMaxSizeY (bool theToIncludeFallback) const
unsigned int Font_FTFont::GlyphMaxSizeY() const
{
if (!theToIncludeFallback)
{
float aHeight = (FT_IS_SCALABLE(myFTFace) != 0)
? float(myFTFace->bbox.yMax - myFTFace->bbox.yMin) * (float(myFTFace->size->metrics.y_ppem) / float(myFTFace->units_per_EM))
: fromFTPoints<float> (myFTFace->size->metrics.height);
return (unsigned int)(aHeight + 0.5f);
}
unsigned int aHeight = GlyphMaxSizeY (false);
if (theToIncludeFallback)
{
for (Standard_Integer aFontIter = 0; aFontIter < Font_UnicodeSubset_NB; ++aFontIter)
{
if (!myFallbackFaces[aFontIter].IsNull()
&& myFallbackFaces[aFontIter]->IsValid())
{
aHeight = std::max (aHeight, myFallbackFaces[aFontIter]->GlyphMaxSizeY (false));
}
}
}
return aHeight;
float aHeight = (FT_IS_SCALABLE(myFTFace) != 0)
? float(myFTFace->bbox.yMax - myFTFace->bbox.yMin) * (float(myFTFace->size->metrics.y_ppem) / float(myFTFace->units_per_EM))
: fromFTPoints<float> (myFTFace->size->metrics.height);
return (unsigned int)(aHeight + 0.5f);
}
// =======================================================================
@@ -461,22 +322,18 @@ float Font_FTFont::AdvanceY (Standard_Utf32Char theUChar,
return AdvanceY (theUCharNext);
}
// =======================================================================
// function : getKerning
// purpose :
// =======================================================================
bool Font_FTFont::getKerning (FT_Vector& theKern,
Standard_Utf32Char theUCharCurr,
Standard_Utf32Char theUCharNext) const
{
theKern.x = 0;
theKern.y = 0;
if (theUCharNext != 0 && FT_HAS_KERNING(myActiveFTFace) != 0)
if (theUCharNext != 0 && FT_HAS_KERNING(myFTFace) != 0)
{
const FT_UInt aCharCurr = FT_Get_Char_Index (myActiveFTFace, theUCharCurr);
const FT_UInt aCharNext = FT_Get_Char_Index (myActiveFTFace, theUCharNext);
const FT_UInt aCharCurr = FT_Get_Char_Index (myFTFace, theUCharCurr);
const FT_UInt aCharNext = FT_Get_Char_Index (myFTFace, theUCharNext);
if (aCharCurr == 0 || aCharNext == 0
|| FT_Get_Kerning (myActiveFTFace, aCharCurr, aCharNext, FT_KERNING_UNFITTED, &theKern) != 0)
|| FT_Get_Kerning (myFTFace, aCharCurr, aCharNext, FT_KERNING_UNFITTED, &theKern) != 0)
{
theKern.x = 0;
theKern.y = 0;
@@ -500,7 +357,7 @@ float Font_FTFont::AdvanceX (Standard_Utf32Char theUCharNext) const
FT_Vector aKern;
getKerning (aKern, myUChar, theUCharNext);
return myWidthScaling * fromFTPoints<float> (myActiveFTFace->glyph->advance.x + aKern.x);
return myWidthScaling * fromFTPoints<float> (myFTFace->glyph->advance.x + aKern.x);
}
// =======================================================================
@@ -516,41 +373,29 @@ float Font_FTFont::AdvanceY (Standard_Utf32Char theUCharNext) const
FT_Vector aKern;
getKerning (aKern, myUChar, theUCharNext);
return fromFTPoints<float> (myActiveFTFace->glyph->advance.y + aKern.y);
return fromFTPoints<float> (myFTFace->glyph->advance.y + aKern.y);
}
// =======================================================================
// function : GlyphsNumber
// purpose :
// =======================================================================
Standard_Integer Font_FTFont::GlyphsNumber (bool theToIncludeFallback) const
Standard_Integer Font_FTFont::GlyphsNumber() const
{
Standard_Integer aNbGlyphs = myFTFace->num_glyphs;
if (theToIncludeFallback)
{
for (Standard_Integer aFontIter = 0; aFontIter < Font_UnicodeSubset_NB; ++aFontIter)
{
if (!myFallbackFaces[aFontIter].IsNull()
&& myFallbackFaces[aFontIter]->IsValid())
{
aNbGlyphs += myFallbackFaces[aFontIter]->GlyphsNumber (false);
}
}
}
return aNbGlyphs;
return myFTFace->num_glyphs;
}
// =======================================================================
// function : GlyphRect
// function : theRect
// purpose :
// =======================================================================
void Font_FTFont::GlyphRect (Font_Rect& theRect) const
{
const FT_Bitmap& aBitmap = myActiveFTFace->glyph->bitmap;
theRect.Left = float(myActiveFTFace->glyph->bitmap_left);
theRect.Top = float(myActiveFTFace->glyph->bitmap_top);
theRect.Right = float(myActiveFTFace->glyph->bitmap_left + (int )aBitmap.width);
theRect.Bottom = float(myActiveFTFace->glyph->bitmap_top - (int )aBitmap.rows);
const FT_Bitmap& aBitmap = myFTFace->glyph->bitmap;
theRect.Left = float(myFTFace->glyph->bitmap_left);
theRect.Top = float(myFTFace->glyph->bitmap_top);
theRect.Right = float(myFTFace->glyph->bitmap_left + (int )aBitmap.width);
theRect.Bottom = float(myFTFace->glyph->bitmap_top - (int )aBitmap.rows);
}
// =======================================================================

View File

@@ -19,7 +19,6 @@
#include <Font_FontAspect.hxx>
#include <Font_Rect.hxx>
#include <Font_StrictLevel.hxx>
#include <Font_UnicodeSubset.hxx>
#include <Graphic3d_HorizontalTextAlignment.hxx>
#include <Graphic3d_VerticalTextAlignment.hxx>
#include <Image_PixMap.hxx>
@@ -34,10 +33,10 @@ class Font_FTLibrary;
//! Font initialization parameters.
struct Font_FTFontParams
{
unsigned int PointSize; //!< face size in points (1/72 inch)
unsigned int Resolution; //!< resolution of the target device in dpi for FT_Set_Char_Size()
bool ToSynthesizeItalic; //!< generate italic style (e.g. for font family having no italic style); FALSE by default
bool IsSingleStrokeFont; //!< single-stroke (one-line) font, FALSE by default
unsigned int PointSize; //!< face size in points (1/72 inch)
unsigned int Resolution; //!< resolution of the target device in dpi for FT_Set_Char_Size()
bool ToSynthesizeItalic; //!< generate italic style (e.g. for font family having no italic style); FALSE by default
bool IsSingleStrokeFont; //!< single-stroke (one-line) font, FALSE by default
//! Empty constructor.
Font_FTFontParams() : PointSize (0), Resolution (72u), ToSynthesizeItalic (false), IsSingleStrokeFont (false) {}
@@ -69,69 +68,6 @@ public:
const Font_FTFontParams& theParams,
const Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
//! Return TRUE if specified character is within subset of modern CJK characters.
static bool IsCharFromCJK (Standard_Utf32Char theUChar)
{
return (theUChar >= 0x03400 && theUChar <= 0x04DFF)
|| (theUChar >= 0x04E00 && theUChar <= 0x09FFF)
|| (theUChar >= 0x0F900 && theUChar <= 0x0FAFF)
|| (theUChar >= 0x20000 && theUChar <= 0x2A6DF)
|| (theUChar >= 0x2F800 && theUChar <= 0x2FA1F)
// Hiragana and Katakana (Japanese) are NOT part of CJK, but CJK fonts usually include these symbols
|| IsCharFromHiragana (theUChar)
|| IsCharFromKatakana (theUChar);
}
//! Return TRUE if specified character is within subset of Hiragana (Japanese).
static bool IsCharFromHiragana (Standard_Utf32Char theUChar)
{
return (theUChar >= 0x03040 && theUChar <= 0x0309F);
}
//! Return TRUE if specified character is within subset of Katakana (Japanese).
static bool IsCharFromKatakana (Standard_Utf32Char theUChar)
{
return (theUChar >= 0x030A0 && theUChar <= 0x030FF);
}
//! Return TRUE if specified character is within subset of modern Korean characters (Hangul).
static bool IsCharFromKorean (Standard_Utf32Char theUChar)
{
return (theUChar >= 0x01100 && theUChar <= 0x011FF)
|| (theUChar >= 0x03130 && theUChar <= 0x0318F)
|| (theUChar >= 0x0AC00 && theUChar <= 0x0D7A3);
}
//! Return TRUE if specified character is within subset of Arabic characters.
static bool IsCharFromArabic (Standard_Utf32Char theUChar)
{
return (theUChar >= 0x00600 && theUChar <= 0x006FF);
}
//! Return TRUE if specified character should be displayed in Right-to-Left order.
static bool IsCharRightToLeft (Standard_Utf32Char theUChar)
{
return IsCharFromArabic(theUChar);
}
//! Determine Unicode subset for specified character
static Font_UnicodeSubset CharSubset (Standard_Utf32Char theUChar)
{
if (IsCharFromCJK (theUChar))
{
return Font_UnicodeSubset_CJK;
}
else if (IsCharFromKorean (theUChar))
{
return Font_UnicodeSubset_Korean;
}
else if (IsCharFromArabic (theUChar))
{
return Font_UnicodeSubset_Arabic;
}
return Font_UnicodeSubset_Western;
}
public:
//! Create uninitialized instance.
@@ -183,13 +119,6 @@ public:
const Font_FTFontParams& theParams,
Font_StrictLevel theStrictLevel = Font_StrictLevel_Any);
//! Return flag to use fallback fonts in case if used font does not include symbols from specific Unicode subset; TRUE by default.
//! @sa Font_FontMgr::ToUseUnicodeSubsetFallback()
Standard_Boolean ToUseUnicodeSubsetFallback() const { return myToUseUnicodeSubsetFallback; }
//! Set if fallback fonts should be used in case if used font does not include symbols from specific Unicode subset.
void SetUseUnicodeSubsetFallback (Standard_Boolean theToFallback) { myToUseUnicodeSubsetFallback = theToFallback; }
//! Return TRUE if this is single-stroke (one-line) font, FALSE by default.
//! Such fonts define single-line glyphs instead of closed contours, so that they are rendered incorrectly by normal software.
bool IsSingleStrokeFont() const { return myFontParams.IsSingleStrokeFont; }
@@ -207,10 +136,10 @@ public:
Standard_EXPORT bool RenderGlyph (const Standard_Utf32Char theChar);
//! @return maximal glyph width in pixels (rendered to bitmap).
Standard_EXPORT unsigned int GlyphMaxSizeX (bool theToIncludeFallback = false) const;
Standard_EXPORT unsigned int GlyphMaxSizeX() const;
//! @return maximal glyph height in pixels (rendered to bitmap).
Standard_EXPORT unsigned int GlyphMaxSizeY (bool theToIncludeFallback = false) const;
Standard_EXPORT unsigned int GlyphMaxSizeY() const;
//! @return vertical distance from the horizontal baseline to the highest character coordinate.
Standard_EXPORT float Ascender() const;
@@ -234,9 +163,6 @@ public:
myWidthScaling = theScaleFactor;
}
//! Return TRUE if font contains specified symbol (excluding fallback list).
Standard_EXPORT bool HasSymbol (Standard_Utf32Char theUChar) const;
//! Compute horizontal advance to the next character with kerning applied when applicable.
//! Assuming text rendered horizontally.
//! @param theUCharNext the next character to compute advance from current one
@@ -261,9 +187,8 @@ public:
Standard_EXPORT float AdvanceY (Standard_Utf32Char theUChar,
Standard_Utf32Char theUCharNext);
//! Return glyphs number in this font.
//! @param theToIncludeFallback if TRUE then the number will include fallback list
Standard_EXPORT Standard_Integer GlyphsNumber (bool theToIncludeFallback = false) const;
//! @return glyphs number in this font.
Standard_EXPORT Standard_Integer GlyphsNumber() const;
//! Retrieve glyph bitmap rectangle
Standard_EXPORT void GlyphRect (Font_Rect& theRect) const;
@@ -337,25 +262,18 @@ protected:
Standard_Utf32Char theUCharCurr,
Standard_Utf32Char theUCharNext) const;
//! Initialize fallback font.
Standard_EXPORT bool findAndInitFallback (Font_UnicodeSubset theSubset);
protected:
Handle(Font_FTLibrary) myFTLib; //!< handle to the FT library object
Handle(NCollection_Buffer) myBuffer; //!< memory buffer
Handle(Font_FTFont) myFallbackFaces[Font_UnicodeSubset_NB]; //!< fallback fonts
FT_Face myFTFace; //!< FT face object
FT_Face myActiveFTFace; //!< active FT face object (the main of fallback)
TCollection_AsciiString myFontPath; //!< font path
Font_FTFontParams myFontParams; //!< font initialization parameters
Font_FontAspect myFontAspect; //!< font initialization aspect
float myWidthScaling; //!< scale glyphs along X-axis
int32_t myLoadFlags; //!< default load flags
Image_PixMap myGlyphImg; //!< cached glyph plane
Standard_Utf32Char myUChar; //!< currently loaded unicode character
Standard_Boolean myToUseUnicodeSubsetFallback; //!< use default fallback fonts for extended Unicode sub-sets (Korean, CJK, etc.)
};

View File

@@ -88,10 +88,6 @@ IMPLEMENT_STANDARD_RTTIEXT(Font_FontMgr,Standard_Transient)
"/usr/X11/lib/X11/fs/config",
NULL
};
// Although fontconfig library can be built for various platforms,
// practically it is useful only on desktop Linux distributions, where it is always packaged.
#include <fontconfig/fontconfig.h>
#endif
#ifdef __APPLE__
@@ -197,16 +193,6 @@ Handle(Font_FontMgr) Font_FontMgr::GetInstance()
return _mgr;
}
// =======================================================================
// function : ToUseUnicodeSubsetFallback
// purpose :
// =======================================================================
Standard_Boolean& Font_FontMgr::ToUseUnicodeSubsetFallback()
{
static Standard_Boolean TheToUseUnicodeSubsetFallback = true;
return TheToUseUnicodeSubsetFallback;
}
// =======================================================================
// function : addFontAlias
// purpose :
@@ -253,7 +239,6 @@ Font_FontMgr::Font_FontMgr()
Handle(Font_FontAliasSequence) anIris = new Font_FontAliasSequence();
Handle(Font_FontAliasSequence) aCJK = new Font_FontAliasSequence();
Handle(Font_FontAliasSequence) aKorean = new Font_FontAliasSequence();
Handle(Font_FontAliasSequence) anArab = new Font_FontAliasSequence();
// best matches - pre-installed on Windows, some of them are pre-installed on macOS,
// and sometimes them can be found installed on other systems (by user)
@@ -304,15 +289,6 @@ Font_FontMgr::Font_FontMgr()
aKorean->Append (Font_FontAlias ("noto serif cjk jp")); // Linux
aKorean->Append (Font_FontAlias ("noto sans cjk jp")); // Linux
#if defined(_WIN32)
anArab->Append (Font_FontAlias ("times new roman"));
#elif defined(__APPLE__)
anArab->Append (Font_FontAlias ("decotype naskh"));
#elif defined(__ANDROID__)
anArab->Append (Font_FontAlias ("droid arabic naskh"));
anArab->Append (Font_FontAlias ("noto naskh arabic"));
#endif
addFontAlias ("mono", aMono);
addFontAlias ("courier", aMono); // Font_NOF_ASCII_MONO
addFontAlias ("monospace", aMono); // Font_NOF_MONOSPACE
@@ -332,7 +308,6 @@ Font_FontMgr::Font_FontMgr()
addFontAlias ("korean", aKorean); // Font_NOF_KOREAN
addFontAlias ("cjk", aCJK); // Font_NOF_CJK
addFontAlias ("nsimsun", aCJK);
addFontAlias ("arabic", anArab); // Font_NOF_ARABIC
addFontAlias (Font_NOF_SYMBOL_MONO, aWinDin);
addFontAlias (Font_NOF_ASCII_SCRIPT_SIMPLEX, aScript);
@@ -397,7 +372,7 @@ Standard_Boolean Font_FontMgr::RegisterFont (const Handle(Font_SystemFont)& theF
void Font_FontMgr::InitFontDataBase()
{
myFontMap.Clear();
Handle(Font_FTLibrary) aFtLibrary = new Font_FTLibrary();
Handle(Font_FTLibrary) aFtLibrary;
#if defined(OCCT_UWP)
// system font files are not accessible
@@ -432,6 +407,7 @@ void Font_FontMgr::InitFontDataBase()
aSupportedExtensions.Add (TCollection_AsciiString (anExt));
}
aFtLibrary = new Font_FTLibrary();
static const DWORD aBufferSize = 256;
char aNameBuff[aBufferSize];
char aPathBuff[aBufferSize];
@@ -474,86 +450,61 @@ void Font_FontMgr::InitFontDataBase()
NCollection_Map<TCollection_AsciiString> aMapOfFontsDirs;
#if !defined(__ANDROID__) && !defined(__APPLE__)
if (FcConfig* aFcCfg = FcInitLoadConfig())
{
if (FcStrList* aFcFontDir = FcConfigGetFontDirs (aFcCfg))
{
for (;;)
{
FcChar8* aFcFolder = FcStrListNext (aFcFontDir);
if (aFcFolder == NULL)
{
break;
}
TCollection_AsciiString aPathStr ((const char* )aFcFolder);
OSD_Path aPath (aPathStr);
addDirsRecursively (aPath, aMapOfFontsDirs);
}
FcStrListDone (aFcFontDir);
}
FcConfigDestroy (aFcCfg);
}
const OSD_Protection aProtectRead (OSD_R, OSD_R, OSD_R, OSD_R);
if (aMapOfFontsDirs.IsEmpty())
// read fonts directories from font service config file (obsolete)
for (Standard_Integer anIter = 0; myFontServiceConf[anIter] != NULL; ++anIter)
{
Message::DefaultMessenger()->Send ("Font_FontMgr, fontconfig library returns an empty folder list", Message_Alarm);
// read fonts directories from font service config file (obsolete)
for (Standard_Integer anIter = 0; myFontServiceConf[anIter] != NULL; ++anIter)
const TCollection_AsciiString aFileOfFontsPath (myFontServiceConf[anIter]);
OSD_File aFile (aFileOfFontsPath);
if (!aFile.Exists())
{
const TCollection_AsciiString aFileOfFontsPath (myFontServiceConf[anIter]);
OSD_File aFile (aFileOfFontsPath);
if (!aFile.Exists())
{
continue;
}
aFile.Open (OSD_ReadOnly, aProtectRead);
if (!aFile.IsOpen())
{
continue;
}
Standard_Integer aNByte = 256;
Standard_Integer aNbyteRead;
TCollection_AsciiString aStr; // read string with information
while (!aFile.IsAtEnd())
{
Standard_Integer aLocation = -1;
Standard_Integer aPathLocation = -1;
aFile.ReadLine (aStr, aNByte, aNbyteRead); // reading 1 line (256 bytes)
aLocation = aStr.Search ("catalogue=");
if (aLocation < 0)
{
aLocation = aStr.Search ("catalogue =");
}
aPathLocation = aStr.Search ("/");
if (aLocation > 0 && aPathLocation > 0)
{
aStr = aStr.Split (aPathLocation - 1);
TCollection_AsciiString aFontPath;
Standard_Integer aPathNumber = 1;
do
{
// Getting directory paths, which can be splitted by "," or ":"
aFontPath = aStr.Token (":,", aPathNumber);
aFontPath.RightAdjust();
if (!aFontPath.IsEmpty())
{
OSD_Path aPath(aFontPath);
addDirsRecursively (aPath, aMapOfFontsDirs);
}
aPathNumber++;
}
while (!aFontPath.IsEmpty());
}
}
aFile.Close();
continue;
}
aFile.Open (OSD_ReadOnly, aProtectRead);
if (!aFile.IsOpen())
{
continue;
}
Standard_Integer aNByte = 256;
Standard_Integer aNbyteRead;
TCollection_AsciiString aStr; // read string with information
while (!aFile.IsAtEnd())
{
Standard_Integer aLocation = -1;
Standard_Integer aPathLocation = -1;
aFile.ReadLine (aStr, aNByte, aNbyteRead); // reading 1 line (256 bytes)
aLocation = aStr.Search ("catalogue=");
if (aLocation < 0)
{
aLocation = aStr.Search ("catalogue =");
}
aPathLocation = aStr.Search ("/");
if (aLocation > 0 && aPathLocation > 0)
{
aStr = aStr.Split (aPathLocation - 1);
TCollection_AsciiString aFontPath;
Standard_Integer aPathNumber = 1;
do
{
// Getting directory paths, which can be splitted by "," or ":"
aFontPath = aStr.Token (":,", aPathNumber);
aFontPath.RightAdjust();
if (!aFontPath.IsEmpty())
{
OSD_Path aPath(aFontPath);
addDirsRecursively (aPath, aMapOfFontsDirs);
}
aPathNumber++;
}
while (!aFontPath.IsEmpty());
}
}
aFile.Close();
}
#endif
@@ -573,6 +524,7 @@ void Font_FontMgr::InitFontDataBase()
aSupportedExtensions.Add (TCollection_AsciiString (anExt));
}
aFtLibrary = new Font_FTLibrary();
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
anIter.More(); anIter.Next())
{
@@ -734,24 +686,6 @@ Handle(Font_SystemFont) Font_FontMgr::GetFont (const TCollection_AsciiString& th
return myFontMap.Find (theFontName);
}
// =======================================================================
// function : FindFallbackFont
// purpose :
// =======================================================================
Handle(Font_SystemFont) Font_FontMgr::FindFallbackFont (Font_UnicodeSubset theSubset,
Font_FontAspect theFontAspect) const
{
Font_FontAspect aFontAspect = theFontAspect;
switch (theSubset)
{
case Font_UnicodeSubset_Western: return FindFont (Font_NOF_SANS_SERIF, Font_StrictLevel_Aliases, aFontAspect);
case Font_UnicodeSubset_Korean: return FindFont (Font_NOF_KOREAN, Font_StrictLevel_Aliases, aFontAspect);
case Font_UnicodeSubset_CJK: return FindFont (Font_NOF_CJK, Font_StrictLevel_Aliases, aFontAspect);
case Font_UnicodeSubset_Arabic: return FindFont (Font_NOF_ARABIC, Font_StrictLevel_Aliases, aFontAspect);
}
return Handle(Font_SystemFont)();
}
// =======================================================================
// function : FindFont
// purpose :
@@ -836,8 +770,7 @@ Handle(Font_SystemFont) Font_FontMgr::FindFont (const TCollection_AsciiString& t
}
}
if (aFont.IsNull()
&& theStrictLevel == Font_StrictLevel_Any)
if (aFont.IsNull())
{
// try finding ANY font in case if even default fallback alias myFallbackAlias cannot be found
aFont = myFontMap.Find (TCollection_AsciiString());

View File

@@ -22,7 +22,6 @@
#include <Font_FontAspect.hxx>
#include <Font_NListOfSystemFont.hxx>
#include <Font_StrictLevel.hxx>
#include <Font_UnicodeSubset.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_IndexedMap.hxx>
#include <NCollection_Shared.hxx>
@@ -56,9 +55,6 @@ public:
return "invalid";
}
//! Return flag to use fallback fonts in case if used font does not include symbols from specific Unicode subset; TRUE by default.
Standard_EXPORT static Standard_Boolean& ToUseUnicodeSubsetFallback();
public:
//! Return the list of available fonts.
@@ -110,14 +106,7 @@ public:
{
return FindFont (theFontName, Font_StrictLevel_Any, theFontAspect);
}
//! Tries to find fallback font for specified Unicode subset.
//! Returns NULL in case when fallback font is not found in the system.
//! @param theSubset [in] Unicode subset
//! @param theFontAspect [in] font aspect to find
Standard_EXPORT Handle(Font_SystemFont) FindFallbackFont (Font_UnicodeSubset theSubset,
Font_FontAspect theFontAspect) const;
//! Read font file and retrieve information from it.
Standard_EXPORT Handle(Font_SystemFont) CheckFont (const Standard_CString theFontPath) const;

View File

@@ -16,9 +16,8 @@
#define Font_NOF_MONOSPACE "monospace"
#define Font_NOF_SERIF "serif"
#define Font_NOF_SANS_SERIF "sans-serif"
#define Font_NOF_CJK "cjk" // Font_UnicodeSubset_CJK
#define Font_NOF_KOREAN "korean" // Font_UnicodeSubset_Korean
#define Font_NOF_ARABIC "arabic" // Font_UnicodeSubset_Arabic
#define Font_NOF_CJK "cjk"
#define Font_NOF_KOREAN "korean"
#define Font_NOF_ASCII_MONO "Courier"
#define Font_NOF_ASCII_SIMPLEX "Times-Roman"

View File

@@ -1,28 +0,0 @@
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Font_UnicodeSubset_HeaderFile
#define _Font_UnicodeSubset_HeaderFile
//! Enumeration defining Unicode subsets.
enum Font_UnicodeSubset
{
Font_UnicodeSubset_Western, //!< western letters
Font_UnicodeSubset_Korean, //!< modern Korean letters
Font_UnicodeSubset_CJK, //!< Chinese characters (Chinese, Japanese, Korean and Vietnam)
Font_UnicodeSubset_Arabic, //!< Arabic characters
};
enum { Font_UnicodeSubset_NB = Font_UnicodeSubset_Arabic };
#endif // _Font_UnicodeSubset_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -26,7 +26,6 @@
#include <DrawTrSurf_Curve2d.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
#include <Geom2dAPI_ExtremaCurveCurve.hxx>
#include <Geom2dAPI_Interpolate.hxx>
#include <Geom2dAPI_PointsToBSpline.hxx>
#include <Geom2dAPI_InterCurveCurve.hxx>
#include <Geom2d_Line.hxx>
@@ -179,6 +178,7 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
else {
// test points ou ordonnees
hasPoints = Standard_False;
Standard_Integer nc = n - 3;
if (nc == 2 * Nb) {
// points
@@ -190,7 +190,6 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
}
else if (nc - 2 == Nb) {
// YValues
hasPoints = Standard_False;
nc = 5;
X0 = Draw::Atof(a[3]);
DX = Draw::Atof(a[4]);
@@ -215,44 +214,9 @@ static Standard_Integer appro(Draw_Interpretor& di, Standard_Integer n, const ch
Handle(Geom2d_BSplineCurve) TheCurve;
if (hasPoints)
{
if (!strcmp (a[0], "2dinterpole"))
{
Geom2dAPI_Interpolate anInterpol (new TColgp_HArray1OfPnt2d(Points), Standard_False, Tol2d);
anInterpol.Perform();
if (!anInterpol.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anInterpol.Curve();
}
else
{
Geom2dAPI_PointsToBSpline anApprox (Points, Dmin, Dmax, GeomAbs_C2, Tol2d);
if (!anApprox.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anApprox.Curve();
}
}
TheCurve = Geom2dAPI_PointsToBSpline(Points,Dmin,Dmax,GeomAbs_C2,Tol2d);
else
{
if (!strcmp (a[0], "2dinterpole"))
{
di << "incorrect usage";
return 1;
}
Geom2dAPI_PointsToBSpline anApprox (YValues, X0, DX, Dmin, Dmax, GeomAbs_C2, Tol2d);
if (!anApprox.IsDone())
{
di << "not done";
return 1;
}
TheCurve = anApprox.Curve();
}
TheCurve = Geom2dAPI_PointsToBSpline(YValues,X0,DX,Dmin,Dmax,GeomAbs_C2,Tol2d);
DrawTrSurf::Set(a[1], TheCurve);
di << a[1];

View File

@@ -103,21 +103,6 @@ Graphic3d_Camera::Graphic3d_Camera()
// purpose :
// =======================================================================
Graphic3d_Camera::Graphic3d_Camera (const Handle(Graphic3d_Camera)& theOther)
: myUp (0.0, 1.0, 0.0),
myEye (0.0, 0.0, -1500.0),
myCenter (0.0, 0.0, 0.0),
myAxialScale (1.0, 1.0, 1.0),
myProjType (Projection_Orthographic),
myFOVy (45.0),
myFOVyTan (Tan (DTR_HALF * 45.0)),
myZNear (DEFAULT_ZNEAR),
myZFar (DEFAULT_ZFAR),
myAspect (1.0),
myScale (1000.0),
myZFocus (1.0),
myZFocusType (FocusType_Relative),
myIOD (0.05),
myIODType (IODType_Relative)
{
myWorldViewProjState.Initialize (this);

View File

@@ -16,8 +16,6 @@
#ifndef _IMeshTools_ModelAlgo_HeaderFile
#define _IMeshTools_ModelAlgo_HeaderFile
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
@@ -34,22 +32,10 @@ public:
{
}
//! Exceptions protected processing of the given model.
Standard_Boolean Perform (
//! Performs processing of edges of the given model.
Standard_EXPORT virtual Standard_Boolean Perform (
const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters)
{
try
{
OCC_CATCH_SIGNALS
return performInternal (theModel, theParameters);
}
catch (Standard_Failure const&)
{
return Standard_False;
}
}
const IMeshTools_Parameters& theParameters) = 0;
DEFINE_STANDARD_RTTI_INLINE(IMeshTools_ModelAlgo, Standard_Transient)
@@ -59,11 +45,6 @@ protected:
Standard_EXPORT IMeshTools_ModelAlgo()
{
}
//! Performs processing of the given model.
Standard_EXPORT virtual Standard_Boolean performInternal (
const Handle (IMeshData_Model)& theModel,
const IMeshTools_Parameters& theParameters) = 0;
};
#endif

View File

@@ -17,8 +17,6 @@
#define _IMeshTools_ModelBuilder_HeaderFile
#include <Message_Algorithm.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Shape.hxx>
@@ -40,26 +38,11 @@ public:
{
}
//! Exceptions protected method to create discrete model for the given shape.
//! Creates discrete model for the given shape.
//! Returns nullptr in case of failure.
Handle (IMeshData_Model) Perform (
Standard_EXPORT virtual Handle (IMeshData_Model) Perform (
const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters)
{
ClearStatus ();
try
{
OCC_CATCH_SIGNALS
return performInternal (theShape, theParameters);
}
catch (Standard_Failure const&)
{
SetStatus (Message_Fail2);
return NULL;
}
}
const IMeshTools_Parameters& theParameters) = 0;
DEFINE_STANDARD_RTTI_INLINE(IMeshTools_ModelBuilder, Message_Algorithm)
@@ -69,12 +52,6 @@ protected:
Standard_EXPORT IMeshTools_ModelBuilder()
{
}
//! Creates discrete model for the given shape.
//! Returns nullptr in case of failure.
Standard_EXPORT virtual Handle (IMeshData_Model) performInternal (
const TopoDS_Shape& theShape,
const IMeshTools_Parameters& theParameters) = 0;
};
#endif

View File

@@ -33,8 +33,7 @@ struct IMeshTools_Parameters {
Relative (Standard_False),
InternalVerticesMode (Standard_True),
ControlSurfaceDeflection (Standard_True),
CleanModel (Standard_True),
AdjustMinSize (Standard_False)
CleanModel(Standard_True)
{
}
@@ -79,10 +78,6 @@ struct IMeshTools_Parameters {
//! Cleans temporary data model when algorithm is finished.
Standard_Boolean CleanModel;
//! Enables/disables local adjustment of min size depending on edge size.
//! Disabled by default.
Standard_Boolean AdjustMinSize;
};
#endif

View File

@@ -304,7 +304,7 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
{
Standard_Boolean bIsClosed2;
Standard_Real aT11, aT12, aT21, aT22;
Bnd_Box aB1, aB2;
Bnd_Box aB2;
//
bSplit2 = Standard_False;
myRange1.Range(aT11, aT12);
@@ -313,6 +313,7 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
bIsClosed2 = IsClosed(myGeom2, aT21, aT22, myTol2, myRes2);
//
if (bIsClosed2) {
Bnd_Box aB1;
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
//
gp_Pnt aP = myGeom2->Value(aT21);
@@ -320,9 +321,8 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
}
//
if (!bIsClosed2) {
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
BndBuildBox(myCurve2, aT21, aT22, myTol2, aB2);
FindSolutions(myRange1, aB1, myRange2, aB2, theRanges1, theRanges2);
FindSolutions(myRange1, myRange2, aB2, theRanges1, theRanges2);
return;
}
//
@@ -343,11 +343,10 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
//
for (i = 1; i <= aNb1; ++i) {
const IntTools_Range& aR1 = aSegments1(i);
BndBuildBox(myCurve1, aR1.First(), aR1.Last(), myTol1, aB1);
for (j = 1; j <= aNb2; ++j) {
const IntTools_Range& aR2 = aSegments2(j);
BndBuildBox(myCurve2, aR2.First(), aR2.Last(), myTol2, aB2);
FindSolutions(aR1, aB1, aR2, aB2, theRanges1, theRanges2);
FindSolutions(aR1, aR2, aB2, theRanges1, theRanges2);
}
}
//
@@ -359,7 +358,6 @@ void IntTools_EdgeEdge::FindSolutions(IntTools_SequenceOfRanges& theRanges1,
//purpose :
//=======================================================================
void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
const Bnd_Box& theBox1,
const IntTools_Range& theR2,
const Bnd_Box& theBox2,
IntTools_SequenceOfRanges& theRanges1,
@@ -375,7 +373,6 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
theR1.Range(aT11, aT12);
theR2.Range(aT21, aT22);
//
aB1 = theBox1;
aB2 = theBox2;
//
bThin = Standard_False;
@@ -388,7 +385,9 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
aTB21 = aT21;
aTB22 = aT22;
//
//1. Find parameters of the second edge in the box of first one
//1. Build box for first edge and find parameters
// of the second one in that box
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
bOut = aB1.IsOut(aB2);
if (bOut) {
break;
@@ -436,9 +435,7 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
((aT21 - aTB21) < aSmallStep2) && ((aTB22 - aT22) < aSmallStep2)) {
bStop = Standard_True;
}
else
BndBuildBox (myCurve1, aT11, aT12, myTol1, aB1);
//
} while (!bStop);
//
if (bOut) {
@@ -501,20 +498,13 @@ void IntTools_EdgeEdge::FindSolutions(const IntTools_Range& theR1,
Standard_Integer i, aNb1;
IntTools_SequenceOfRanges aSegments1;
//
// Build box for first curve to compare
// the boxes of the splits with this one
BndBuildBox(myCurve1, aT11, aT12, myTol1, aB1);
const Standard_Real aB1SqExtent = aB1.SquareExtent();
//
IntTools_Range aR2(aT21, aT22);
BndBuildBox(myCurve2, aT21, aT22, myTol2, aB2);
//
aNb1 = SplitRangeOnSegments(aT11, aT12, myRes1, 3, aSegments1);
for (i = 1; i <= aNb1; ++i) {
const IntTools_Range& aR1 = aSegments1(i);
BndBuildBox(myCurve1, aR1.First(), aR1.Last(), myTol1, aB1);
if (!aB1.IsOut(aB2) && (aNb1 == 1 || aB1.SquareExtent() < aB1SqExtent))
FindSolutions(aR1, aB1, aR2, aB2, theRanges1, theRanges2);
FindSolutions(aR1, aR2, aB2, theRanges1, theRanges2);
}
}

View File

@@ -146,8 +146,7 @@ protected:
//! Looking for the exact intersection ranges
Standard_EXPORT void FindSolutions (
const IntTools_Range& theR1, const Bnd_Box& theBox1,
Standard_EXPORT void FindSolutions (const IntTools_Range& theR1,
const IntTools_Range& theR2, const Bnd_Box& theBox2,
IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);

View File

@@ -88,7 +88,7 @@ options:\n\
-surf_def_off disables control of deflection of mesh from real\n\
surface (enabled by default)\n\
-parallel enables parallel execution (switched off by default)\n\
-adjust_min enables local adjustment of min size depending on edge size (switched off by default)\n";
-adaptive enables adaptive computation of minimal value in parametric space\n";
return 0;
}
@@ -121,8 +121,6 @@ options:\n\
aMeshParams.InternalVerticesMode = Standard_False;
else if (aOpt == "-surf_def_off")
aMeshParams.ControlSurfaceDeflection = Standard_False;
else if (aOpt == "-adjust_min")
aMeshParams.AdjustMinSize = Standard_True;
else if (i < nbarg)
{
Standard_Real aVal = Draw::Atof(argv[i++]);

View File

@@ -21,6 +21,7 @@
#include <Standard_Assert.hxx>
#include <TCollection_ExtendedString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Font,OpenGl_Resource)
// =======================================================================
@@ -33,6 +34,8 @@ OpenGl_Font::OpenGl_Font (const Handle(Font_FTFont)& theFont,
myFont (theFont),
myAscender (0.0f),
myDescender (0.0f),
myLineSpacing (0.0f),
myTileSizeX (0),
myTileSizeY (0),
myLastTileId (-1),
myTextureFormat (GL_ALPHA)
@@ -102,9 +105,11 @@ bool OpenGl_Font::Init (const Handle(OpenGl_Context)& theCtx)
return false;
}
myAscender = myFont->Ascender();
myDescender = myFont->Descender();
myTileSizeY = myFont->GlyphMaxSizeY (true);
myAscender = myFont->Ascender();
myDescender = myFont->Descender();
myLineSpacing = myFont->LineSpacing();
myTileSizeX = myFont->GlyphMaxSizeX();
myTileSizeY = myFont->GlyphMaxSizeY();
myLastTileId = -1;
if (!createTexture (theCtx))
@@ -121,16 +126,12 @@ bool OpenGl_Font::Init (const Handle(OpenGl_Context)& theCtx)
// =======================================================================
bool OpenGl_Font::createTexture (const Handle(OpenGl_Context)& theCtx)
{
// Single font might define very wide range of symbols, with very few of them actually used in text.
// Limit single texture with circa 4096 glyphs.
static const Standard_Integer THE_MAX_GLYPHS_PER_TEXTURE = 4096;
const Standard_Integer aMaxSize = theCtx->MaxTextureSize();
myTileSizeY = myFont->GlyphMaxSizeY (true);
const Standard_Integer aGlyphsNb = Min (THE_MAX_GLYPHS_PER_TEXTURE, myFont->GlyphsNumber (true) - myLastTileId + 1);
const Standard_Integer aMaxTileSizeX = myFont->GlyphMaxSizeX (true);
const Standard_Integer aMaxSize = theCtx->MaxTextureSize();
const Standard_Integer aTextureSizeX = OpenGl_Context::GetPowerOfTwo (aGlyphsNb * aMaxTileSizeX, aMaxSize);
const Standard_Integer aTilesPerRow = aTextureSizeX / aMaxTileSizeX;
Standard_Integer aGlyphsNb = myFont->GlyphsNumber() - myLastTileId + 1;
const Standard_Integer aTextureSizeX = OpenGl_Context::GetPowerOfTwo (aGlyphsNb * myTileSizeX, aMaxSize);
const Standard_Integer aTilesPerRow = aTextureSizeX / myTileSizeX;
const Standard_Integer aTextureSizeY = OpenGl_Context::GetPowerOfTwo (GLint((aGlyphsNb / aTilesPerRow) + 1) * myTileSizeY, aMaxSize);
memset (&myLastTilePx, 0, sizeof(myLastTilePx));
@@ -185,18 +186,14 @@ bool OpenGl_Font::renderGlyph (const Handle(OpenGl_Context)& theCtx,
const Standard_Integer aTileId = myLastTileId + 1;
myLastTilePx.Left = myLastTilePx.Right + 3;
myLastTilePx.Right = myLastTilePx.Left + (Standard_Integer )anImg.SizeX();
if (myLastTilePx.Right > aTexture->SizeX()
|| (Standard_Integer )anImg.SizeY() > myTileSizeY)
if (myLastTilePx.Right >= aTexture->SizeX())
{
myTileSizeY = myFont->GlyphMaxSizeY (true);
myLastTilePx.Left = 0;
myLastTilePx.Right = (Standard_Integer )anImg.SizeX();
myLastTilePx.Top += myTileSizeY;
myLastTilePx.Bottom += myTileSizeY;
if (myLastTilePx.Bottom > aTexture->SizeY()
|| myLastTilePx.Right > aTexture->SizeX())
if (myLastTilePx.Bottom >= aTexture->SizeY())
{
if (!createTexture (theCtx))
{

View File

@@ -106,6 +106,12 @@ public:
return myDescender;
}
//! @return default line spacing (the baseline-to-baseline distance)
inline float LineSpacing() const
{
return myLineSpacing;
}
//! Render glyph to texture if not already.
//! @param theCtx active context
//! @param theUChar unicode symbol to render
@@ -129,6 +135,8 @@ protected:
Handle(Font_FTFont) myFont; //!< FreeType font instance
Standard_ShortReal myAscender; //!< ascender provided my FT font
Standard_ShortReal myDescender; //!< descender provided my FT font
Standard_ShortReal myLineSpacing; //!< line spacing provided my FT font
Standard_Integer myTileSizeX; //!< tile width
Standard_Integer myTileSizeY; //!< tile height
Standard_Integer myLastTileId; //!< id of last tile
RectI myLastTilePx;

View File

@@ -204,10 +204,6 @@ void OpenGl_Workspace::ResetAppliedAspect()
ApplyAspects();
myGlContext->SetTypeOfLine (myDefaultAspects.Aspect()->LineType());
myGlContext->SetLineWidth (myDefaultAspects.Aspect()->LineWidth());
if (myGlContext->core15fwd != NULL)
{
myGlContext->core15fwd->glActiveTexture (GL_TEXTURE0);
}
}
// =======================================================================

View File

@@ -14,6 +14,13 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// 26-Mar-96 : xab : inclusion des inlines trop gros
// 15-Oct-96 : alr : extraction des inlines (pas tous ceux inclus par xab)
// 19-Fev-97 : jct : ajout des methodes UVBox et UVConstraints (G1134)
// 10-Dec-97 : jag : Gros debug sur delete, et sur la methode Copy...
// 13-Jan-98 : alr : ajout des derivees pour contraintes G3 et approx. C2
// 28-Avr-98 : alr : Prise en compte des Linear*Constraint, methodes SolveTI1,SolveTI2,SolveTI3
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <math_Gauss.hxx>
@@ -767,7 +774,7 @@ void Plate_Plate::SolveTI3(const Standard_Integer IterationNumber, const Handle(
}
algo_gauss.Solve(sec_member, sol);
// iteration to refine the solution
//alr iteration pour affiner la solution
{
math_Vector sol1(0,n_dimat-1);
math_Vector sec_member1(0,n_dimat-1);
@@ -778,6 +785,7 @@ void Plate_Plate::SolveTI3(const Standard_Integer IterationNumber, const Handle(
sol += sol1;
}
}
//finalr
for(icoor=1; icoor<=3;icoor++){
for(i=0;i<nCC1;i++) Solution(i).SetCoord (icoor, sol((icoor-1)*n_dimsousmat+i));
@@ -1047,7 +1055,7 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
}
//=======================================================================
//function : Plate_Plate::CoefPol
//purpose : give back the array of power basis coefficient of
//purpose :give back the array of power basis coefficient of
// the polynomial part of the Plate function
//=======================================================================
@@ -1060,14 +1068,15 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
{
Coefs->ChangeValue(iu,iv) = Solution(i)*ddu[iu]*ddv[iv];
//Coefs->ChangeValue(idu,idv) = Solution(i);
// it is necessary to reset this line if one remove factors in method Polm.
// il faut remettre cette ligne si on enleve ls facteurs dans
// la methode Polm.
i++;
}
}
//=======================================================================
//function : Plate_Plate::Continuity
//purpose : give back the continuity order of the Plate function
//purpose :give back the continuity order of the Plate function
//=======================================================================
Standard_Integer Plate_Plate::Continuity() const
@@ -1077,7 +1086,7 @@ gp_XYZ Plate_Plate::EvaluateDerivative(const gp_XY& point2d, const Standard_Inte
//=======================================================================
//function : Plate_Plate::SolEm
//purpose : compute the (iu,iv)th derivative of the fundamental solution
//purpose : compute the (iu,iv)th derivative of the fondamental solution
// of Laplcian at the power order
//=======================================================================
@@ -1090,7 +1099,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
if(iv>iu)
{
// SolEm is symmetric in (u<->v) : we swap u and v if iv>iu
// SolEm is symetric in (u<->v) : we swap u and v if iv>iu
// to avoid some code
IU = iv;
IV = iu;
@@ -1126,8 +1135,8 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
//Standard_Real pr = pow(R, mm1 - IU - IV);
// this expression takes a lot of time
//(does not take into account a small integer value of the exponent)
// cette expression prend beaucoup de temps
//(ne tient pas compte de la petite valeur entiere de l'exposant)
//
Standard_Integer expo = mm1 - IU - IV;
@@ -1257,7 +1266,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-100*ru2 + 48*L*ru2 + 140*m*ru2 - 100*L*m*ru2 - 60*m2*ru2 + 70*L*m2*ru2 + 8*m3*ru2 -
20*L*m3*ru2 + 2*L*m4*ru2 - 300*rv2 + 144*L*rv2 + 420*m*rv2 - 300*L*m*rv2 - 180*m2*rv2 + 210*L*m2*rv2 +
@@ -1282,7 +1291,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real u2v2 = v2*U2;
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
1644*ru2 - 720*L*ru2 - 2700*m*ru2 + 1644*L*m*ru2 + 1530*m2*ru2 - 1350*L*m2*ru2 -
360*m3*ru2 + 510*L*m3*ru2 + 30*m4*ru2 - 90*L*m4*ru2 + 6*L*m5*ru2 + 1644*rv2 - 720*L*rv2 - 2700*m*rv2 +
@@ -1326,7 +1335,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru2 = R*U2;
Standard_Real r2 = R*R;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-600*ru2 + 288*L*ru2 + 840*m*ru2 - 600*L*m*ru2 - 360*m2*ru2 + 420*L*m2*ru2 + 48*m3*ru2 -
120*L*m3*ru2 + 12*L*m4*ru2 + 33*r2 - 18*L*r2 - 36*m*r2 + 33*L*m*r2 + 9*m2*r2 - 18*L*m2*r2 + 3*L*m3*r2 +
@@ -1355,7 +1364,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real ru4 = r*u4;
Standard_Real r2v2 = r2*v2;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
6576*ru2v2 - 2880*L*ru2v2 - 10800*m*ru2v2 + 6576*L*m*ru2v2 + 6120*m2*ru2v2 - 5400*L*m2*ru2v2 -
1440*m3*ru2v2 + 2040*L*m3*ru2v2 + 120*m4*ru2v2 - 360*L*m4*ru2v2 + 24*L*m5*ru2v2 + 1096*ru4 - 480*L*ru4 -
@@ -1389,7 +1398,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-42336*ru2v2 + 17280*L*ru2v2 + 77952*m*ru2v2 - 42336*L*m*ru2v2 - 52920*m2*ru2v2 +
38976*L*m2*ru2v2 + 16800*m3*ru2v2 - 17640*L*m3*ru2v2 - 2520*m4*ru2v2 + 4200*L*m4*ru2v2 + 144*m5*ru2v2 -
@@ -1425,7 +1434,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = R*R;
Standard_Real ru2 = R*U2;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-1000*ru2 + 480*L*ru2 + 1400*m*ru2 - 1000*L*m*ru2 - 600*m2*ru2 + 700*L*m2*ru2 + 80*m3*ru2 -
200*L*m3*ru2 + 20*L*m4*ru2 + 165*r2 - 90*L*r2 - 180*m*r2 + 165*L*m*r2 + 45*m2*r2 - 90*L*m2*r2 + 15*L*m3*r2 +
@@ -1448,7 +1457,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2 = r*r;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
5480*ru2 - 2400*L*ru2 - 9000*m*ru2 + 5480*L*m*ru2 + 5100*m2*ru2 - 4500*L*m2*ru2 - 1200*m3*ru2 +
1700*L*m3*ru2 + 100*m4*ru2 - 300*L*m4*ru2 + 20*L*m5*ru2 - 750*r2 + 360*L*r2 + 1050*m*r2 - 750*L*m*r2 -
@@ -1479,7 +1488,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2v2 = r2*v2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
-70560*ru2v2 + 28800*L*ru2v2 + 129920*m*ru2v2 - 70560*L*m*ru2v2 - 88200*m2*ru2v2 +
@@ -1520,7 +1529,7 @@ Standard_Real Plate_Plate::SolEm(const gp_XY& point2d, const Standard_Integer iu
Standard_Real r2u2 = r2*U2;
Standard_Real ru4 = r*u4;
// copy-paste the mathematics
// copier-coller de mathematica
DUV =
16440*ru4 - 7200*L*ru4 - 27000*m*ru4 + 16440*L*m*ru4 + 15300*m2*ru4 - 13500*L*m2*ru4 -
3600*m3*ru4 + 5100*L*m3*ru4 + 300*m4*ru4 - 900*L*m4*ru4 + 60*L*m5*ru4 - 4500*r2u2 + 2160*L*r2u2 + 6300*m*r2u2 -

View File

@@ -76,13 +76,13 @@ void Poly_Connect::Load (const Handle(Poly_Triangulation)& theTriangulation)
mysense = false;
mymore = false;
const Standard_Integer aNbNodes = myTriangulation->NbNodes();
const Standard_Integer aNbTris = myTriangulation->NbTriangles();
const Standard_Integer nbNodes = myTriangulation->NbNodes();
const Standard_Integer nbTriangles = myTriangulation->NbTriangles();
{
const Standard_Integer aNbAdjs = 6 * aNbTris;
if (myTriangles.Size() != aNbNodes)
const Standard_Integer aNbAdjs = 6 * nbTriangles;
if (myTriangles.Size() != nbNodes)
{
myTriangles.Resize (1, aNbNodes, Standard_False);
myTriangles.Resize (1, nbNodes, Standard_False);
}
if (myAdjacents.Size() != aNbAdjs)
{
@@ -95,117 +95,118 @@ void Poly_Connect::Load (const Handle(Poly_Triangulation)& theTriangulation)
// We first build an array of the list of edges connected to the nodes
// create an array to store the edges starting from the vertices
NCollection_Array1<polyedge*> anEdges (1, aNbNodes);
anEdges.Init (NULL);
Standard_Integer i;
// the last node is not used because edges are stored at the lower node index
polyedge** edges = new polyedge*[nbNodes];
for (i = 0; i < nbNodes; i++) edges[i] = 0;
// loop on the triangles
NCollection_Vec3<Standard_Integer> aTriNodes;
NCollection_Vec2<Standard_Integer> anEdgeNodes;
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTris; ++aTriIter)
{
Standard_Integer j,k,n[3],n1,n2;
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
for (i = 1; i <= nbTriangles; i++) {
// get the nodes
myTriangulation->Triangle (aTriIter).Get (aTriNodes[0], aTriNodes[1], aTriNodes[2]);
triangles(i).Get(n[0],n[1],n[2]);
// Update the myTriangles array
myTriangles.SetValue (aTriNodes[0], aTriIter);
myTriangles.SetValue (aTriNodes[1], aTriIter);
myTriangles.SetValue (aTriNodes[2], aTriIter);
myTriangles(n[0]) = i;
myTriangles(n[1]) = i;
myTriangles(n[2]) = i;
// update the edge lists
for (Standard_Integer aNodeInTri = 0; aNodeInTri < 3; ++aNodeInTri)
{
const Standard_Integer aNodeNext = (aNodeInTri + 1) % 3; // the following node of the edge
if (aTriNodes[aNodeInTri] < aTriNodes[aNodeNext])
{
anEdgeNodes[0] = aTriNodes[aNodeInTri];
anEdgeNodes[1] = aTriNodes[aNodeNext];
for (j = 0; j < 3; j++) {
k = (j+1) % 3; // the following node of the edge
if (n[j] <= n[k]) {
n1 = n[j];
n2 = n[k];
}
else
{
anEdgeNodes[0] = aTriNodes[aNodeNext];
anEdgeNodes[1] = aTriNodes[aNodeInTri];
else {
n1 = n[k];
n2 = n[j];
}
// edge from node 0 to node 1 with node 0 < node 1
// insert in the list of node 0
polyedge* ced = anEdges[anEdgeNodes[0]];
for (; ced != NULL; ced = ced->next)
{
// the edge already exists
if (ced->nd == anEdgeNodes[1])
{
// just mark the adjacency if found
ced->nt[1] = aTriIter;
ced->nn[1] = aTriNodes[3 - aNodeInTri - aNodeNext]; // the third node
break;
}
// edge from n1 to n2 with n1 < n2
// insert in the list of n1
polyedge* ced = edges[n1];
while (ced != 0) {
// the edge already exists
if (ced->nd == n2)
break;
else
ced = ced->next;
}
if (ced == NULL)
{
// create the edge if not found
ced = new polyedge();
ced->next = anEdges[anEdgeNodes[0]];
anEdges[anEdgeNodes[0]] = ced;
ced->nd = anEdgeNodes[1];
ced->nt[0] = aTriIter;
ced->nn[0] = aTriNodes[3 - aNodeInTri - aNodeNext]; // the third node
ced->nt[1] = 0;
ced->nn[1] = 0;
if (ced == 0) {
// create the edge if not found
ced = new polyedge;
ced->next = edges[n1];
edges[n1] = ced;
ced->nd = n2;
ced->nt[0] = i;
ced->nn[0] = n[3-j-k]; // the third node
ced->nt[1] = 0;
ced->nn[1] = 0;
}
else {
// just mark the adjacency if found
ced->nt[1] = i;
ced->nn[1] = n[3-j-k]; // the third node
}
}
}
// now complete the myAdjacents array
Standard_Integer anAdjIndex = 1;
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTris; ++aTriIter)
{
Standard_Integer index = 1;
for (i = 1; i <= nbTriangles; i++) {
// get the nodes
myTriangulation->Triangle (aTriIter).Get (aTriNodes[0], aTriNodes[1], aTriNodes[2]);
triangles(i).Get(n[0],n[1],n[2]);
// for each edge in triangle
for (Standard_Integer aNodeInTri = 0; aNodeInTri < 3; ++aNodeInTri)
{
const Standard_Integer aNodeNext = (aNodeInTri + 1) % 3; // the following node of the edge
if (aTriNodes[aNodeInTri] < aTriNodes[aNodeNext])
{
anEdgeNodes[0] = aTriNodes[aNodeInTri];
anEdgeNodes[1] = aTriNodes[aNodeNext];
// fore each edge
for (j = 0; j < 3; j++) {
k = (j+1) % 3; // the following node of the edge
if (n[j] <= n[k]) {
n1 = n[j];
n2 = n[k];
}
else
{
anEdgeNodes[0] = aTriNodes[aNodeNext];
anEdgeNodes[1] = aTriNodes[aNodeInTri];
else {
n1 = n[k];
n2 = n[j];
}
// edge from node 0 to node 1 with node 0 < node 1
// find in the list of node 0
const polyedge* ced = anEdges[anEdgeNodes[0]];
while (ced->nd != anEdgeNodes[1])
{
ced = ced->next;
}
// edge from n1 to n2 with n1 < n2
// find in the list of n1
polyedge* ced = edges[n1];
while (ced->nd != n2)
ced = ced->next;
// Find the adjacent triangle
const Standard_Integer l = ced->nt[0] == aTriIter ? 1 : 0;
myAdjacents.SetValue (anAdjIndex, ced->nt[l]);
myAdjacents.SetValue (anAdjIndex + 3, ced->nn[l]);
++anAdjIndex;
Standard_Integer l = 0;
if (ced->nt[0] == i) l = 1;
myAdjacents(index) = ced->nt[l];
myAdjacents(index+3) = ced->nn[l];
index++;
}
anAdjIndex += 3;
index += 3;
}
// destroy the edges array
for (Standard_Integer aNodeIter = anEdges.Lower(); aNodeIter <= anEdges.Upper(); ++aNodeIter)
{
for (polyedge* anEdgeIter = anEdges[aNodeIter]; anEdgeIter != NULL;)
{
polyedge* aTmp = anEdgeIter->next;
delete anEdgeIter;
anEdgeIter = aTmp;
for (i = 0; i < nbNodes; i++) {
polyedge* ced = edges[i];
while (ced != 0) {
polyedge* tmp = ced->next;
delete ced;
ced = tmp;
}
}
delete [] edges;
}
//=======================================================================

View File

@@ -56,8 +56,7 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject (const PrsMgr_TypeOfPresentat
//
myInfiniteState (Standard_False),
myIsMutable (Standard_False),
myHasOwnPresentations (Standard_True),
myToPropagateVisualState (Standard_True)
myHasOwnPresentations (Standard_True)
{
myDrawer->SetDisplayMode (-1);
}

View File

@@ -528,14 +528,6 @@ public: //! @name deprecated methods
Standard_DEPRECATED("This method is deprecated - TransformPersistence() should be called instead")
Standard_EXPORT gp_Pnt GetTransformPersistencePoint() const;
//! Get value of the flag "propagate visual state"
//! It means that the display/erase/color visual state is propagated automatically to all children;
//! by default, the flag is true
Standard_Boolean ToPropagateVisualState() const { return myToPropagateVisualState; }
//! Change the value of the flag "propagate visual state"
void SetPropagateVisualState(const Standard_Boolean theFlag) { myToPropagateVisualState = theFlag; }
protected:
//! Recomputes all presentations of the object.
@@ -577,7 +569,6 @@ protected:
Standard_Boolean myIsMutable; //!< mutable flag
Standard_Boolean myHasOwnPresentations; //!< flag indicating if object should have own presentations
Standard_Boolean myToPropagateVisualState; //!< flag indicating if visual state (display/erase/color) should be propagated to all children
};
DEFINE_STANDARD_HANDLE(PrsMgr_PresentableObject, Standard_Transient)

View File

@@ -69,12 +69,9 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
thePrsObj->Compute (this, Handle(Prs3d_Presentation)(), theMode);
}
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Display(anIter.Value(), theMode);
}
Display (anIter.Value(), theMode);
}
}
@@ -85,12 +82,9 @@ void PrsMgr_PresentationManager::Display (const Handle(PrsMgr_PresentableObject)
void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Erase(anIter.Value(), theMode);
}
Erase (anIter.Value(), theMode);
}
PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@@ -130,12 +124,9 @@ void PrsMgr_PresentationManager::Erase (const Handle(PrsMgr_PresentableObject)&
void PrsMgr_PresentationManager::Clear (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Clear(anIter.Value(), theMode);
}
Clear (anIter.Value(), theMode);
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@@ -153,12 +144,9 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
const Standard_Integer theMode,
const Standard_Boolean theValue)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetVisibility(anIter.Value(), theMode, theValue);
}
SetVisibility (anIter.Value(), theMode, theValue);
}
if (!thePrsObj->HasOwnPresentations())
{
@@ -178,12 +166,9 @@ void PrsMgr_PresentationManager::SetVisibility (const Handle(PrsMgr_PresentableO
// =======================================================================
void PrsMgr_PresentationManager::Unhighlight (const Handle(PrsMgr_PresentableObject)& thePrsObj)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Unhighlight(anIter.Value());
}
Unhighlight (anIter.Value());
}
const PrsMgr_Presentations& aPrsList = thePrsObj->Presentations();
@@ -207,12 +192,9 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
const Standard_Integer theMode,
const Standard_Integer theNewPrior) const
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetDisplayPriority(anIter.Value(), theMode, theNewPrior);
}
SetDisplayPriority (anIter.Value(), theMode, theNewPrior);
}
const Handle(PrsMgr_Presentation) aPrs = Presentation (thePrsObj, theMode);
@@ -229,15 +211,12 @@ void PrsMgr_PresentationManager::SetDisplayPriority (const Handle(PrsMgr_Present
Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
Standard_Integer aPriority = DisplayPriority (anIter.Value(), theMode);
if (aPriority != 0)
{
Standard_Integer aPriority = DisplayPriority(anIter.Value(), theMode);
if (aPriority != 0)
{
return aPriority;
}
return aPriority;
}
}
@@ -254,14 +233,11 @@ Standard_Integer PrsMgr_PresentationManager::DisplayPriority (const Handle(PrsMg
Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
if (IsDisplayed (anIter.Value(), theMode))
{
if (IsDisplayed(anIter.Value(), theMode))
{
return Standard_True;
}
return Standard_True;
}
}
@@ -277,14 +253,11 @@ Standard_Boolean PrsMgr_PresentationManager::IsDisplayed (const Handle(PrsMgr_Pr
Standard_Boolean PrsMgr_PresentationManager::IsHighlighted (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Standard_Integer theMode) const
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
if (IsHighlighted (anIter.Value(), theMode))
{
if (IsHighlighted(anIter.Value(), theMode))
{
return Standard_True;
}
return Standard_True;
}
}
@@ -550,14 +523,10 @@ Standard_Boolean PrsMgr_PresentationManager::RemovePresentation (const Handle(Pr
void PrsMgr_PresentationManager::SetZLayer (const Handle(PrsMgr_PresentableObject)& thePrsObj,
const Graphic3d_ZLayerId theLayerId)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
SetZLayer(anIter.Value(), theLayerId);
}
SetZLayer (anIter.Value(), theLayerId);
}
if (!thePrsObj->HasOwnPresentations())
{
return;
@@ -610,12 +579,9 @@ void PrsMgr_PresentationManager::Color (const Handle(PrsMgr_PresentableObject)&
const Handle(PrsMgr_PresentableObject)& theSelObj,
const Standard_Integer theImmediateStructLayerId)
{
if (thePrsObj->ToPropagateVisualState())
for (PrsMgr_ListOfPresentableObjectsIter anIter (thePrsObj->Children()); anIter.More(); anIter.Next())
{
for (PrsMgr_ListOfPresentableObjectsIter anIter(thePrsObj->Children()); anIter.More(); anIter.Next())
{
Color(anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
}
Color (anIter.Value(), theStyle, theMode, NULL, theImmediateStructLayerId);
}
if (!thePrsObj->HasOwnPresentations())
{

View File

@@ -1,22 +0,0 @@
RWGltf_GltfAccessor.hxx
RWGltf_GltfAccessorCompType.hxx
RWGltf_GltfAccessorLayout.hxx
RWGltf_GltfArrayType.hxx
RWGltf_GltfBufferView.hxx
RWGltf_GltfBufferViewTarget.hxx
RWGltf_GltfFace.hxx
RWGltf_GltfLatePrimitiveArray.cxx
RWGltf_GltfLatePrimitiveArray.hxx
RWGltf_GltfPrimArrayData.hxx
RWGltf_GltfPrimitiveMode.hxx
RWGltf_GltfRootElement.hxx
RWGltf_MaterialCommon.hxx
RWGltf_MaterialMetallicRoughness.hxx
RWGltf_CafReader.cxx
RWGltf_CafReader.hxx
RWGltf_GltfJsonParser.cxx
RWGltf_GltfJsonParser.pxx
RWGltf_PrimitiveArrayReader.cxx
RWGltf_PrimitiveArrayReader.hxx
RWGltf_TriangulationReader.cxx
RWGltf_TriangulationReader.hxx

View File

@@ -1,300 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <RWGltf_CafReader.hxx>
#include "RWGltf_GltfJsonParser.pxx"
#include <RWGltf_TriangulationReader.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <Message_ProgressSentry.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_ThreadPool.hxx>
#include <fstream>
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_CafReader, RWMesh_CafReader)
//! Functor for parallel execution.
class RWGltf_CafReader::CafReader_GltfReaderFunctor
{
public:
struct GltfReaderTLS
{
Handle(RWGltf_PrimitiveArrayReader) Reader;
};
//! Main constructor.
CafReader_GltfReaderFunctor (RWGltf_CafReader* myCafReader,
NCollection_Vector<TopoDS_Face>& theFaceList,
Message_ProgressSentry& theSentry,
const OSD_ThreadPool::Launcher& theThreadPool,
const TCollection_AsciiString& theErrPrefix)
: myCafReader (myCafReader),
myFaceList (&theFaceList),
mySentry (&theSentry),
myErrPrefix (theErrPrefix),
myThreadPool(theThreadPool),
myTlsData (theThreadPool.LowerThreadIndex(), theThreadPool.UpperThreadIndex())
{
//
}
//! Execute task for a face with specified index.
void operator() (int theThreadIndex,
int theFaceIndex) const
{
GltfReaderTLS& aTlsData = myTlsData.ChangeValue (theThreadIndex);
if (aTlsData.Reader.IsNull())
{
aTlsData.Reader = myCafReader->createMeshReaderContext();
aTlsData.Reader->SetErrorPrefix (myErrPrefix);
aTlsData.Reader->SetCoordinateSystemConverter (myCafReader->myCoordSysConverter);
}
TopLoc_Location aDummyLoc;
TopoDS_Face& aFace = myFaceList->ChangeValue (theFaceIndex);
Handle(RWGltf_GltfLatePrimitiveArray) aLateData = Handle(RWGltf_GltfLatePrimitiveArray)::DownCast (BRep_Tool::Triangulation (aFace, aDummyLoc));
Handle(Poly_Triangulation) aPolyData = aTlsData.Reader->Load (aLateData);
BRep_Builder aBuilder;
aBuilder.UpdateFace (aFace, aPolyData);
if (myThreadPool.HasThreads())
{
Standard_Mutex::Sentry aLock (&myMutex);
mySentry->Next();
}
else
{
mySentry->Next();
}
}
private:
RWGltf_CafReader* myCafReader;
NCollection_Vector<TopoDS_Face>* myFaceList;
Message_ProgressSentry* mySentry;
TCollection_AsciiString myErrPrefix;
mutable Standard_Mutex myMutex;
const OSD_ThreadPool::Launcher& myThreadPool;
mutable NCollection_Array1<GltfReaderTLS>
myTlsData;
};
//================================================================
// Function : Constructor
// Purpose :
//================================================================
RWGltf_CafReader::RWGltf_CafReader()
: myToParallel (false),
myToSkipEmptyNodes (true),
myUseMeshNameAsFallback (true)
{
myCoordSysConverter.SetInputLengthUnit (1.0); // glTF defines model in meters
myCoordSysConverter.SetInputCoordinateSystem (RWMesh_CoordinateSystem_glTF);
}
//================================================================
// Function : performMesh
// Purpose :
//================================================================
Standard_Boolean RWGltf_CafReader::performMesh (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe)
{
std::ifstream aFile;
OSD_OpenStream (aFile, theFile.ToCString(), std::ios::in | std::ios::binary);
if (!aFile.is_open()
|| !aFile.good())
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' is not found!", Message_Fail);
return false;
}
bool isBinaryFile = false;
char aGlbHeader[12] = {};
aFile.read (aGlbHeader, sizeof(aGlbHeader));
int64_t aBinBodyOffset = 0;
int64_t aBinBodyLen = 0;
int64_t aJsonBodyOffset = 0;
int64_t aJsonBodyLen = 0;
if (::strncmp (aGlbHeader, "glTF", 4) == 0)
{
isBinaryFile = true;
const uint32_t* aVer = (const uint32_t* )(aGlbHeader + 4);
const uint32_t* aLen = (const uint32_t* )(aGlbHeader + 8);
if (*aVer == 1)
{
if (*aLen < 20)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' has broken glTF format!", Message_Fail);
return false;
}
char aHeader1[8] = {};
aFile.read (aHeader1, sizeof(aHeader1));
const uint32_t* aSceneLen = (const uint32_t* )(aHeader1 + 0);
const uint32_t* aSceneFormat = (const uint32_t* )(aHeader1 + 4);
aJsonBodyOffset = 20;
aJsonBodyLen = int64_t(*aSceneLen);
aBinBodyOffset = aJsonBodyOffset + aJsonBodyLen;
aBinBodyLen = int64_t(*aLen) - aBinBodyOffset;
if (*aSceneFormat != 0)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' is written using unsupported Scene format!", Message_Fail);
return false;
}
}
else //if (*aVer == 2)
{
if (*aVer != 2)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' is written using unknown version " + int(*aVer) + "!", Message_Warning);
}
for (int aChunkIter = 0; !aFile.eof() && aChunkIter < 2; ++aChunkIter)
{
char aChunkHeader2[8] = {};
if (int64_t(aFile.tellg()) + int64_t(sizeof(aChunkHeader2)) > int64_t(aLen))
{
break;
}
aFile.read (aChunkHeader2, sizeof(aChunkHeader2));
if (!aFile.good())
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' is written using unsupported format!", Message_Fail);
return false;
}
const uint32_t* aChunkLen = (const uint32_t* )(aChunkHeader2 + 0);
const uint32_t* aChunkType = (const uint32_t* )(aChunkHeader2 + 4);
if (*aChunkType == 0x4E4F534A)
{
aJsonBodyOffset = int64_t(aFile.tellg());
aJsonBodyLen = int64_t(*aChunkLen);
}
else if (*aChunkType == 0x004E4942)
{
aBinBodyOffset = int64_t(aFile.tellg());
aBinBodyLen = int64_t(*aChunkLen);
}
if (*aChunkLen != 0)
{
aFile.seekg (*aChunkLen, std::ios_base::cur);
}
}
aFile.seekg ((std::streamoff )aJsonBodyOffset, std::ios_base::beg);
}
}
else
{
aFile.seekg (0, std::ios_base::beg);
}
TCollection_AsciiString anErrPrefix = TCollection_AsciiString ("File '") + theFile + "' defines invalid glTF!\n";
RWGltf_GltfJsonParser aDoc (myRootShapes);
aDoc.SetFilePath (theFile);
aDoc.SetProbeHeader (theToProbe);
aDoc.SetExternalFiles (myExternalFiles);
aDoc.SetMetadata (myMetadata);
aDoc.SetErrorPrefix (anErrPrefix);
aDoc.SetCoordinateSystemConverter (myCoordSysConverter);
aDoc.SetSkipEmptyNodes (myToSkipEmptyNodes);
aDoc.SetMeshNameAsFallback (myUseMeshNameAsFallback);
if (!theToProbe)
{
aDoc.SetAttributeMap (myAttribMap);
}
if (isBinaryFile)
{
aDoc.SetBinaryFormat (aBinBodyOffset, aBinBodyLen);
}
#ifdef HAVE_RAPIDJSON
rapidjson::ParseResult aRes;
rapidjson::IStreamWrapper aFileStream (aFile);
if (isBinaryFile)
{
aRes = aDoc.ParseStream<rapidjson::kParseStopWhenDoneFlag, rapidjson::UTF8<>, rapidjson::IStreamWrapper> (aFileStream);
}
else
{
aRes = aDoc.ParseStream (aFileStream);
}
if (aRes.IsError())
{
if (aRes.Code() == rapidjson::kParseErrorDocumentEmpty)
{
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' is empty!", Message_Fail);
return false;
}
TCollection_AsciiString anErrDesc (RWGltf_GltfJsonParser::FormatParseError (aRes.Code()));
Message::DefaultMessenger()->Send (TCollection_AsciiString ("File '") + theFile + "' defines invalid JSON document!\n"
+ anErrDesc + ".", Message_Fail);
return false;
}
#endif
if (!aDoc.Parse (theProgress))
{
return false;
}
if (!theToProbe
&& !readLateData (aDoc.FaceList(), theFile, theProgress))
{
return false;
}
return true;
}
//================================================================
// Function : createMeshReaderContext
// Purpose :
//================================================================
Handle(RWGltf_PrimitiveArrayReader) RWGltf_CafReader::createMeshReaderContext()
{
Handle(RWGltf_TriangulationReader) aReader = new RWGltf_TriangulationReader();
return aReader;
}
//================================================================
// Function : readLateData
// Purpose :
//================================================================
Standard_Boolean RWGltf_CafReader::readLateData (NCollection_Vector<TopoDS_Face>& theFaces,
const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress)
{
Message_ProgressSentry aPSentryTris (theProgress, "Loading glTF triangulation", 0, Max (1, theFaces.Size()), 1);
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
const int aNbThreads = myToParallel ? Min (theFaces.Size(), aThreadPool->NbDefaultThreadsToLaunch()) : 1;
OSD_ThreadPool::Launcher aLauncher (*aThreadPool, aNbThreads);
CafReader_GltfReaderFunctor aFunctor (this, theFaces, aPSentryTris, aLauncher,
TCollection_AsciiString ("File '") + theFile + "' defines invalid glTF!\n");
aLauncher.Perform (theFaces.Lower(), theFaces.Upper() + 1, aFunctor);
return Standard_True;
}

View File

@@ -1,79 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_CafReader_HeaderFile
#define _RWGltf_CafReader_HeaderFile
#include <NCollection_Vector.hxx>
#include <RWMesh_CafReader.hxx>
#include <TopoDS_Face.hxx>
class RWGltf_PrimitiveArrayReader;
//! The glTF (GL Transmission Format) mesh reader into XDE document.
class RWGltf_CafReader : public RWMesh_CafReader
{
DEFINE_STANDARD_RTTIEXT(RWGltf_CafReader, RWMesh_CafReader)
public:
//! Empty constructor.
Standard_EXPORT RWGltf_CafReader();
//! Return TRUE if multithreaded optimizations are allowed; FALSE by default.
bool ToParallel() const { return myToParallel; }
//! Setup multithreaded execution.
void SetParallel (bool theToParallel) { myToParallel = theToParallel; }
//! Return TRUE if Nodes without Geometry should be ignored, TRUE by default.
bool ToSkipEmptyNodes() { return myToSkipEmptyNodes; }
//! Set flag to ignore nodes without Geometry.
void SetSkipEmptyNodes (bool theToSkip) { myToSkipEmptyNodes = theToSkip; }
//! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
bool ToUseMeshNameAsFallback() { return myUseMeshNameAsFallback; }
//! Set flag to use Mesh name in case if Node name is empty.
void SetMeshNameAsFallback (bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
protected:
//! Read the mesh from specified file.
Standard_EXPORT virtual Standard_Boolean performMesh (const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress,
const Standard_Boolean theToProbe) Standard_OVERRIDE;
//! Create primitive array reader context.
//! Can be overridden by sub-class to read triangulation into application-specific data structures instead of Poly_Triangulation.
//! Default implementation creates RWGltf_TriangulationReader.
Standard_EXPORT virtual Handle(RWGltf_PrimitiveArrayReader) createMeshReaderContext();
//! Read late data from RWGltf_GltfLatePrimitiveArray stored as Poly_Triangulation within faces.
Standard_EXPORT virtual Standard_Boolean readLateData (NCollection_Vector<TopoDS_Face>& theFaces,
const TCollection_AsciiString& theFile,
const Handle(Message_ProgressIndicator)& theProgress);
protected:
class CafReader_GltfReaderFunctor;
protected:
Standard_Boolean myToParallel; //!< flag to use multithreading; FALSE by default
Standard_Boolean myToSkipEmptyNodes; //!< ignore nodes without Geometry; TRUE by default
Standard_Boolean myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
};
#endif // _RWGltf_CafReader_HeaderFile

View File

@@ -1,48 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfAccessor_HeaderFile
#define _RWGltf_GltfAccessor_HeaderFile
#include <Graphic3d_BndBox3d.hxx>
#include <RWGltf_GltfAccessorCompType.hxx>
#include <RWGltf_GltfAccessorLayout.hxx>
#include <Standard_TypeDef.hxx>
//! Low-level glTF data structure defining Accessor.
struct RWGltf_GltfAccessor
{
static const int INVALID_ID = -1;
public:
int Id; //!< identifier
int64_t ByteOffset; //!< byte offset
int64_t Count; //!< size
int32_t ByteStride; //!< [0, 255] for glTF 1.0
RWGltf_GltfAccessorLayout Type; //!< layout type
RWGltf_GltfAccessorCompType ComponentType; //!< component type
Graphic3d_BndBox3d BndBox; //!< bounding box
//! Empty constructor.
RWGltf_GltfAccessor()
: Id (INVALID_ID),
ByteOffset (0),
Count (0),
ByteStride (0),
Type (RWGltf_GltfAccessorLayout_UNKNOWN),
ComponentType (RWGltf_GltfAccessorCompType_UNKNOWN) {}
};
#endif // _RWGltf_GltfAccessor_HeaderFile

View File

@@ -1,30 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfAccessorCompType_HeaderFile
#define _RWGltf_GltfAccessorCompType_HeaderFile
//! Low-level glTF enumeration defining Accessor component type.
enum RWGltf_GltfAccessorCompType
{
RWGltf_GltfAccessorCompType_UNKNOWN, //!< unknown or invalid type
RWGltf_GltfAccessorCompType_Int8 = 5120, //!< GL_BYTE
RWGltf_GltfAccessorCompType_UInt8 = 5121, //!< GL_UNSIGNED_BYTE
RWGltf_GltfAccessorCompType_Int16 = 5122, //!< GL_SHORT
RWGltf_GltfAccessorCompType_UInt16 = 5123, //!< GL_UNSIGNED_SHORT
RWGltf_GltfAccessorCompType_UInt32 = 5125, //!< GL_UNSIGNED_INT
RWGltf_GltfAccessorCompType_Float32 = 5126, //!< GL_FLOAT
};
#endif // _RWGltf_GltfAccessorCompType_HeaderFile

View File

@@ -1,68 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfAccessorLayout_HeaderFile
#define _RWGltf_GltfAccessorLayout_HeaderFile
#include <Standard_CString.hxx>
//! Low-level glTF enumeration defining Accessor layout.
//! Similar to Graphic3d_TypeOfData but does not define actual type and includes matrices.
enum RWGltf_GltfAccessorLayout
{
RWGltf_GltfAccessorLayout_UNKNOWN, //!< unknown or invalid type
RWGltf_GltfAccessorLayout_Scalar, //!< "SCALAR"
RWGltf_GltfAccessorLayout_Vec2, //!< "VEC2"
RWGltf_GltfAccessorLayout_Vec3, //!< "VEC3"
RWGltf_GltfAccessorLayout_Vec4, //!< "VEC4"
RWGltf_GltfAccessorLayout_Mat2, //!< "MAT2"
RWGltf_GltfAccessorLayout_Mat3, //!< "MAT3"
RWGltf_GltfAccessorLayout_Mat4, //!< "MAT4"
};
//! Parse GltfAccessorLayout from string.
inline RWGltf_GltfAccessorLayout RWGltf_GltfParseAccessorType (const char* theType)
{
if (IsEqual ("SCALAR", theType))
{
return RWGltf_GltfAccessorLayout_Scalar;
}
else if (IsEqual ("VEC2", theType))
{
return RWGltf_GltfAccessorLayout_Vec2;
}
else if (IsEqual ("VEC3", theType))
{
return RWGltf_GltfAccessorLayout_Vec3;
}
else if (IsEqual ("VEC4", theType))
{
return RWGltf_GltfAccessorLayout_Vec4;
}
else if (IsEqual ("MAT2", theType))
{
return RWGltf_GltfAccessorLayout_Mat2;
}
else if (IsEqual ("MAT3", theType))
{
return RWGltf_GltfAccessorLayout_Mat3;
}
else if (IsEqual ("MAT4", theType))
{
return RWGltf_GltfAccessorLayout_Mat4;
}
return RWGltf_GltfAccessorLayout_UNKNOWN;
}
#endif // _RWGltf_GltfAccessorLayout_HeaderFile

View File

@@ -1,68 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfArrayType_HeaderFile
#define _RWGltf_GltfArrayType_HeaderFile
#include <Standard_CString.hxx>
//! Low-level glTF enumeration defining Array type.
enum RWGltf_GltfArrayType
{
RWGltf_GltfArrayType_UNKNOWN, //!< unknown or invalid type
RWGltf_GltfArrayType_Indices, //!< "indices" within "primitive" element
RWGltf_GltfArrayType_Position, //!< "POSITION" within "attributes" element
RWGltf_GltfArrayType_Normal, //!< "NORMAL" within "attributes" element
RWGltf_GltfArrayType_Color, //!< "COLOR" within "attributes" element
RWGltf_GltfArrayType_TCoord0, //!< "TEXCOORD_0" within "attributes" element
RWGltf_GltfArrayType_TCoord1, //!< "TEXCOORD_1" within "attributes" element
RWGltf_GltfArrayType_Joint, //!< "JOINT" within "attributes" element
RWGltf_GltfArrayType_Weight, //!< "WEIGHT" within "attributes" element
};
//! Parse GltfArrayType from string.
inline RWGltf_GltfArrayType RWGltf_GltfParseAttribType (const char* theType)
{
if (IsEqual ("POSITION", theType))
{
return RWGltf_GltfArrayType_Position;
}
else if (IsEqual ("NORMAL", theType))
{
return RWGltf_GltfArrayType_Normal;
}
else if (IsEqual ("COLOR", theType))
{
return RWGltf_GltfArrayType_Color;
}
else if (IsEqual ("TEXCOORD_0", theType))
{
return RWGltf_GltfArrayType_TCoord0;
}
else if (IsEqual ("TEXCOORD_1", theType))
{
return RWGltf_GltfArrayType_TCoord1;
}
else if (IsEqual ("JOINT", theType))
{
return RWGltf_GltfArrayType_Joint;
}
else if (IsEqual ("WEIGHT", theType))
{
return RWGltf_GltfArrayType_Weight;
}
return RWGltf_GltfArrayType_UNKNOWN;
}
#endif // _RWGltf_GltfArrayType_HeaderFile

View File

@@ -1,38 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfBufferView_HeaderFile
#define _RWGltf_GltfBufferView_HeaderFile
#include <RWGltf_GltfBufferViewTarget.hxx>
#include <Standard_TypeDef.hxx>
//! Low-level glTF data structure defining BufferView.
struct RWGltf_GltfBufferView
{
static const int INVALID_ID = -1;
public:
int Id;
int64_t ByteOffset;
int64_t ByteLength;
int32_t ByteStride; //!< [0, 255]
RWGltf_GltfBufferViewTarget Target;
RWGltf_GltfBufferView()
: Id (INVALID_ID), ByteOffset (0), ByteLength (0), ByteStride (0), Target (RWGltf_GltfBufferViewTarget_UNKNOWN) {}
};
#endif // _RWGltf_GltfBufferView_HeaderFile

View File

@@ -1,26 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfBufferViewTarget_HeaderFile
#define _RWGltf_GltfBufferViewTarget_HeaderFile
//! Low-level glTF enumeration defining BufferView target.
enum RWGltf_GltfBufferViewTarget
{
RWGltf_GltfBufferViewTarget_UNKNOWN, //!< unknown or invalid type
RWGltf_GltfBufferViewTarget_ARRAY_BUFFER = 34962, //!< GL_ARRAY_BUFFER
RWGltf_GltfBufferViewTarget_ELEMENT_ARRAY_BUFFER = 34963, //!< GL_ELEMENT_ARRAY_BUFFER
};
#endif // _RWGltf_GltfBufferViewTarget_HeaderFile

View File

@@ -1,29 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfFace_HeaderFile
#define _RWGltf_GltfFace_HeaderFile
#include <RWGltf_GltfAccessor.hxx>
//! Low-level glTF data structure holding single Face (one primitive array) definition.
struct RWGltf_GltfFace
{
RWGltf_GltfAccessor NodePos; //!< accessor for nodal positions
RWGltf_GltfAccessor NodeNorm; //!< accessor for nodal normals
RWGltf_GltfAccessor NodeUV; //!< accessor for nodal UV texture coordinates
RWGltf_GltfAccessor Indices; //!< accessor for indexes
};
#endif // _RWGltf_GltfFace_HeaderFile

File diff suppressed because it is too large Load Diff

View File

@@ -1,423 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfJsonParser_HeaderFile
#define _RWGltf_GltfJsonParser_HeaderFile
#include <Graphic3d_Vec.hxx>
#include <Message_Gravity.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_IndexedMap.hxx>
#include <RWGltf_GltfLatePrimitiveArray.hxx>
#include <RWGltf_GltfBufferView.hxx>
#include <RWGltf_GltfRootElement.hxx>
#include <RWGltf_MaterialCommon.hxx>
#include <RWGltf_MaterialMetallicRoughness.hxx>
#include <RWMesh_CoordinateSystemConverter.hxx>
#include <RWMesh_NodeAttributes.hxx>
#include <TColStd_IndexedDataMapOfStringString.hxx>
#include <TopoDS_Face.hxx>
#include <TopTools_SequenceOfShape.hxx>
// workaround name collisions with XLib
#ifdef None
#undef None
#endif
#ifdef Bool
#undef Bool
#endif
#ifdef HAVE_RAPIDJSON
//#define RAPIDJSON_ASSERT
#include <rapidjson/document.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/stringbuffer.h>
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/ostreamwrapper.h>
typedef rapidjson::Document::ValueType RWGltf_JsonValue;
#endif
class Message_ProgressIndicator;
//! INTERNAL tool for parsing glTF document (JSON structure).
class RWGltf_GltfJsonParser
#ifdef HAVE_RAPIDJSON
: public rapidjson::Document
#endif
{
public:
#ifdef HAVE_RAPIDJSON
//! Auxiliary method for formatting error code.
Standard_EXPORT static const char* FormatParseError (rapidjson::ParseErrorCode theCode);
#endif
public:
//! Empty constructor.
Standard_EXPORT RWGltf_GltfJsonParser (TopTools_SequenceOfShape& theRootShapes);
//! Set file path.
Standard_EXPORT void SetFilePath (const TCollection_AsciiString& theFilePath);
//! Set flag for probing file without complete reading.
void SetProbeHeader (bool theToProbe) { myToProbeHeader = theToProbe; }
//! Return prefix for reporting issues.
const TCollection_AsciiString& ErrorPrefix() const { return myErrorPrefix; }
//! Set prefix for reporting issues.
void SetErrorPrefix (const TCollection_AsciiString& theErrPrefix) { myErrorPrefix = theErrPrefix; }
//! Set map for storing node attributes.
void SetAttributeMap (RWMesh_NodeAttributeMap& theAttribMap) { myAttribMap = &theAttribMap; }
//! Set list for storing external files.
void SetExternalFiles (NCollection_IndexedMap<TCollection_AsciiString>& theExternalFiles) { myExternalFiles = &theExternalFiles; }
//! Set metadata map.
void SetMetadata (TColStd_IndexedDataMapOfStringString& theMetadata) { myMetadata = &theMetadata; }
//! Return transformation from glTF to OCCT coordinate system.
const RWMesh_CoordinateSystemConverter& CoordinateSystemConverter() const { return myCSTrsf; }
//! Set transformation from glTF to OCCT coordinate system.
void SetCoordinateSystemConverter (const RWMesh_CoordinateSystemConverter& theConverter) { myCSTrsf = theConverter; }
//! Initialize binary format.
void SetBinaryFormat (int64_t theBinBodyOffset,
int64_t theBinBodyLen)
{
myIsBinary = true;
myBinBodyOffset = theBinBodyOffset;
myBinBodyLen = theBinBodyLen;
}
//! Set flag to ignore nodes without Geometry, TRUE by default.
void SetSkipEmptyNodes (bool theToSkip) { myToSkipEmptyNodes = theToSkip; }
//! Set flag to use Mesh name in case if Node name is empty, TRUE by default.
void SetMeshNameAsFallback (bool theToFallback) { myUseMeshNameAsFallback = theToFallback; }
//! Parse glTF document.
Standard_EXPORT bool Parse (const Handle(Message_ProgressIndicator)& theProgress);
//! Return face list for loading triangulation.
NCollection_Vector<TopoDS_Face>& FaceList() { return myFaceList; }
protected:
#ifdef HAVE_RAPIDJSON
//! Search mandatory root elements in the document.
//! Return FALSE if some mandatory element is missing.
Standard_EXPORT bool gltfParseRoots();
//! Parse default scene.
Standard_EXPORT bool gltfParseScene (const Handle(Message_ProgressIndicator)& theProgress);
//! Parse document metadata.
Standard_EXPORT void gltfParseAsset();
protected:
//! Parse materials defined in the document.
Standard_EXPORT void gltfParseMaterials();
//! Parse standard material.
Standard_EXPORT bool gltfParseStdMaterial (Handle(RWGltf_MaterialCommon)& theMat,
const RWGltf_JsonValue& theMatNode);
//! Parse pbrMetallicRoughness material.
Standard_EXPORT bool gltfParsePbrMaterial (Handle(RWGltf_MaterialMetallicRoughness)& theMat,
const RWGltf_JsonValue& theMatNode);
//! Parse common material (KHR_materials_common extension).
Standard_EXPORT bool gltfParseCommonMaterial (Handle(RWGltf_MaterialCommon)& theMat,
const RWGltf_JsonValue& theMatNode);
//! Parse texture definition.
Standard_EXPORT bool gltfParseTexture (Handle(Image_Texture)& theTexture,
const RWGltf_JsonValue* theTextureId);
protected:
//! Parse scene array of nodes recursively.
Standard_EXPORT bool gltfParseSceneNodes (TopTools_SequenceOfShape& theShapeSeq,
const RWGltf_JsonValue& theSceneNodes,
const Handle(Message_ProgressIndicator)& theProgress);
//! Parse scene node recursively.
Standard_EXPORT bool gltfParseSceneNode (TopoDS_Shape& theNodeShape,
const TCollection_AsciiString& theSceneNodeId,
const RWGltf_JsonValue& theSceneNode,
const Handle(Message_ProgressIndicator)& theProgress);
//! Parse mesh element.
Standard_EXPORT bool gltfParseMesh (TopoDS_Shape& theMeshShape,
const TCollection_AsciiString& theMeshId,
const RWGltf_JsonValue& theMesh,
const Handle(Message_ProgressIndicator)& theProgress);
//! Parse primitive array.
Standard_EXPORT bool gltfParsePrimArray (const Handle(RWGltf_GltfLatePrimitiveArray)& theMeshData,
const TCollection_AsciiString& theMeshName,
const RWGltf_JsonValue& thePrimArray,
const Handle(Message_ProgressIndicator)& theProgress);
//! Parse accessor.
Standard_EXPORT bool gltfParseAccessor (const Handle(RWGltf_GltfLatePrimitiveArray)& theMeshData,
const TCollection_AsciiString& theName,
const RWGltf_JsonValue& theAccessor,
const RWGltf_GltfArrayType theType);
//! Parse buffer view.
Standard_EXPORT bool gltfParseBufferView (const Handle(RWGltf_GltfLatePrimitiveArray)& theMeshData,
const TCollection_AsciiString& theName,
const RWGltf_JsonValue& theBufferView,
const RWGltf_GltfAccessor& theAccessor,
const RWGltf_GltfArrayType theType);
//! Parse buffer.
Standard_EXPORT bool gltfParseBuffer (const Handle(RWGltf_GltfLatePrimitiveArray)& theMeshData,
const TCollection_AsciiString& theName,
const RWGltf_JsonValue& theBuffer,
const RWGltf_GltfAccessor& theAccessor,
const RWGltf_GltfBufferView& theView,
const RWGltf_GltfArrayType theType);
protected:
//! Read vec4 from specified item.
static bool gltfReadVec4 (Graphic3d_Vec4d& theVec4,
const RWGltf_JsonValue* theVal)
{
if (theVal == NULL
|| !theVal->IsArray()
|| theVal->Size() != 4)
{
return false;
}
for (int aCompIter = 0; aCompIter < 4; ++aCompIter)
{
const RWGltf_JsonValue& aGenVal = (*theVal)[aCompIter];
if (!aGenVal.IsNumber())
{
return false;
}
theVec4[aCompIter] = aGenVal.GetDouble();
}
return true;
}
//! Validate color
static bool validateColor4 (const Graphic3d_Vec4d& theVec)
{
return theVec.r() >= 0.0 && theVec.r() <= 1.0
&& theVec.g() >= 0.0 && theVec.g() <= 1.0
&& theVec.b() >= 0.0 && theVec.b() <= 1.0
&& theVec.a() >= 0.0 && theVec.a() <= 1.0;
}
//! Read vec3 from specified item.
static bool gltfReadVec3 (Graphic3d_Vec3d& theVec3,
const RWGltf_JsonValue* theVal)
{
if (theVal == NULL
|| !theVal->IsArray()
|| theVal->Size() != 3)
{
return false;
}
for (int aCompIter = 0; aCompIter < 3; ++aCompIter)
{
const RWGltf_JsonValue& aGenVal = (*theVal)[aCompIter];
if (!aGenVal.IsNumber())
{
return false;
}
theVec3[aCompIter] = aGenVal.GetDouble();
}
return true;
}
//! Validate color
static bool validateColor3 (const Graphic3d_Vec3d& theVec)
{
return theVec.r() >= 0.0 && theVec.r() <= 1.0
&& theVec.g() >= 0.0 && theVec.g() <= 1.0
&& theVec.b() >= 0.0 && theVec.b() <= 1.0;
}
protected:
//! Groups for re-using shapes.
enum ShapeMapGroup
{
ShapeMapGroup_Nodes, //!< nodes
ShapeMapGroup_Meshes, //!< meshes
};
//! Bind name attribute.
void bindNodeShape (TopoDS_Shape& theShape,
const TopLoc_Location& theLoc,
const TCollection_AsciiString& theNodeId,
const RWGltf_JsonValue* theUserName)
{
bindNamedShape (theShape, ShapeMapGroup_Nodes, theLoc, theNodeId, theUserName);
}
//! Bind name attribute.
void bindMeshShape (TopoDS_Shape& theShape,
const TCollection_AsciiString& theMeshId,
const RWGltf_JsonValue* theUserName)
{
bindNamedShape (theShape, ShapeMapGroup_Meshes, TopLoc_Location(), theMeshId, theUserName);
}
//! Find named shape.
bool findNodeShape (TopoDS_Shape& theShape,
const TCollection_AsciiString& theNodeId) const
{
return findNamedShape (theShape, ShapeMapGroup_Nodes, theNodeId);
}
//! Find named shape.
bool findMeshShape (TopoDS_Shape& theShape,
const TCollection_AsciiString& theMeshId) const
{
return findNamedShape (theShape, ShapeMapGroup_Meshes, theMeshId);
}
//! Bind name attribute.
Standard_EXPORT void bindNamedShape (TopoDS_Shape& theShape,
ShapeMapGroup theGroup,
const TopLoc_Location& theLoc,
const TCollection_AsciiString& theId,
const RWGltf_JsonValue* theUserName);
//! Find named shape.
bool findNamedShape (TopoDS_Shape& theShape,
ShapeMapGroup theGroup,
const TCollection_AsciiString& theId) const
{
return myShapeMap[theGroup].Find (theId, theShape);
}
//! Return the string representation of the key.
static TCollection_AsciiString getKeyString (const RWGltf_JsonValue& theValue)
{
if (theValue.IsString())
{
return TCollection_AsciiString (theValue.GetString());
}
else if (theValue.IsInt())
{
return TCollection_AsciiString (theValue.GetInt());
}
return TCollection_AsciiString();
}
protected:
//! Auxiliary structure for fast look-up of document sub-nodes of specified node.
class GltfElementMap
{
public:
//! Empty constructor.
GltfElementMap() : myRoot (NULL) {}
//! Return TRUE if this element is NULL.
bool IsNull() const { return myRoot == NULL; }
//! Access this node.
const RWGltf_JsonValue* Root() const { return myRoot; }
//! Find the child node with specified key.
const RWGltf_JsonValue* FindChild (const TCollection_AsciiString& theKey)
{
const RWGltf_JsonValue* aNode = NULL;
return myChildren.Find (theKey, aNode)
? aNode
: NULL;
}
//! Find the child node with specified key.
const RWGltf_JsonValue* FindChild (const RWGltf_JsonValue& theKey)
{
const TCollection_AsciiString aKey = getKeyString (theKey);
if (aKey.IsEmpty())
{
return NULL;
}
const RWGltf_JsonValue* aNode = NULL;
return myChildren.Find (aKey, aNode)
? aNode
: NULL;
}
//! Initialize the element.
void Init (const TCollection_AsciiString& theRootName,
const RWGltf_JsonValue* theRoot);
private:
NCollection_DataMap<TCollection_AsciiString, const RWGltf_JsonValue*, TCollection_AsciiString> myChildren;
const RWGltf_JsonValue* myRoot;
};
#endif
protected:
//! Print message about invalid glTF syntax.
void reportGltfSyntaxProblem (const TCollection_AsciiString& theMsg, Message_Gravity theGravity);
protected:
TopTools_SequenceOfShape* myRootShapes; //!< sequence of result root shapes
RWMesh_NodeAttributeMap* myAttribMap; //!< shape attributes
NCollection_IndexedMap<TCollection_AsciiString>*
myExternalFiles; //!< list of external file references
RWMesh_CoordinateSystemConverter myCSTrsf; //!< transformation from glTF to OCCT coordinate system
TColStd_IndexedDataMapOfStringString* myMetadata; //!< file metadata
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialMetallicRoughness)> myMaterialsPbr;
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialCommon)> myMaterialsCommon;
NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> myShapeMap[2];
NCollection_DataMap<TCollection_AsciiString, bool> myProbedFiles;
NCollection_DataMap<TCollection_AsciiString, Handle(NCollection_Buffer)> myDecodedBuffers;
NCollection_Vector<TopoDS_Face> myFaceList; //!< face list for loading triangulation
TCollection_AsciiString myFilePath; //!< file path
TCollection_AsciiString myFolder; //!< folder
TCollection_AsciiString myErrorPrefix; //!< invalid syntax error prefix
int64_t myBinBodyOffset; //!< offset to binary body
int64_t myBinBodyLen; //!< binary body length
bool myIsBinary; //!< binary document
bool myIsGltf1; //!< obsolete glTF 1.0 version format
bool myToSkipEmptyNodes; //!< ignore nodes without Geometry
bool myUseMeshNameAsFallback; //!< flag to use Mesh name in case if Node name is empty, TRUE by default
bool myToProbeHeader; //!< flag to probe header without full reading, FALSE by default
#ifdef HAVE_RAPIDJSON
GltfElementMap myGltfRoots[RWGltf_GltfRootElement_NB]; //!< glTF format root elements
#endif
};
#endif // _RWGltf_GltfJsonParser_HeaderFile

View File

@@ -1,133 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2018-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <RWGltf_GltfLatePrimitiveArray.hxx>
#include <RWGltf_MaterialMetallicRoughness.hxx>
#include <RWGltf_MaterialCommon.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OSD_OpenFile.hxx>
#include <Standard_ArrayStreamBuffer.hxx>
#include <fstream>
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_GltfLatePrimitiveArray, Poly_Triangulation)
// =======================================================================
// function : RWGltf_GltfLatePrimitiveArray
// purpose :
// =======================================================================
RWGltf_GltfLatePrimitiveArray::RWGltf_GltfLatePrimitiveArray (const TCollection_AsciiString& theId,
const TCollection_AsciiString& theName)
: Poly_Triangulation (3, 1, false),
myId (theId),
myName (theName),
myPrimMode (RWGltf_GltfPrimitiveMode_UNKNOWN)
{
SetBoundingBox (Bnd_Box());
}
// =======================================================================
// function : ~RWGltf_GltfLatePrimitiveArray
// purpose :
// =======================================================================
RWGltf_GltfLatePrimitiveArray::~RWGltf_GltfLatePrimitiveArray()
{
//
}
// =======================================================================
// function : BaseColor
// purpose :
// =======================================================================
Quantity_ColorRGBA RWGltf_GltfLatePrimitiveArray::BaseColor() const
{
if (!myMaterialPbr.IsNull())
{
return myMaterialPbr->BaseColor;
}
else if (!myMaterialCommon.IsNull())
{
return Quantity_ColorRGBA (myMaterialCommon->DiffuseColor, 1.0f - myMaterialCommon->Transparency);
}
return Quantity_ColorRGBA();
}
// =======================================================================
// function : AddPrimArrayData
// purpose :
// =======================================================================
RWGltf_GltfPrimArrayData& RWGltf_GltfLatePrimitiveArray::AddPrimArrayData (RWGltf_GltfArrayType theType)
{
if (theType == RWGltf_GltfArrayType_Position)
{
// make sure positions go first
myData.Prepend (RWGltf_GltfPrimArrayData (theType));
return myData.ChangeFirst();
}
else if (theType == RWGltf_GltfArrayType_Indices)
{
// make sure indexes go after vertex positions but before any other vertex attributes
if (myData.First().Type == RWGltf_GltfArrayType_Position)
{
myData.InsertAfter (myData.Lower(), RWGltf_GltfPrimArrayData (theType));
return myData.ChangeValue (myData.Lower() + 1);
}
else
{
myData.Prepend (RWGltf_GltfPrimArrayData (theType));
return myData.ChangeFirst();
}
}
else
{
myData.Append (RWGltf_GltfPrimArrayData (theType));
return myData.ChangeLast();
}
}
// =======================================================================
// function : SetBoundingBox
// purpose :
// =======================================================================
void RWGltf_GltfLatePrimitiveArray::SetBoundingBox (const Bnd_Box& theBox)
{
myBox = theBox;
if (theBox.IsVoid())
{
Poly_Triangulation::myNodes = TColgp_Array1OfPnt();
Poly_Triangulation::myTriangles = Poly_Array1OfTriangle();
return;
}
// define 8 nodes so that AABB will be huge enough to include mesh even with transformation applied
Poly_Triangulation::myNodes.Resize (1, 8, false);
const gp_Pnt aMin = theBox.CornerMin();
const gp_Pnt aMax = theBox.CornerMax();
Poly_Triangulation::ChangeNode(1).SetCoord(aMin.X(), aMin.Y(), aMin.Z());
Poly_Triangulation::ChangeNode(2).SetCoord(aMax.X(), aMax.Y(), aMax.Z());
Poly_Triangulation::ChangeNode(3).SetCoord(aMin.X(), aMin.Y(), aMax.Z());
Poly_Triangulation::ChangeNode(4).SetCoord(aMin.X(), aMax.Y(), aMax.Z());
Poly_Triangulation::ChangeNode(5).SetCoord(aMax.X(), aMax.Y(), aMin.Z());
Poly_Triangulation::ChangeNode(6).SetCoord(aMax.X(), aMin.Y(), aMin.Z());
Poly_Triangulation::ChangeNode(7).SetCoord(aMin.X(), aMax.Y(), aMin.Z());
Poly_Triangulation::ChangeNode(8).SetCoord(aMax.X(), aMin.Y(), aMax.Z());
Poly_Triangulation::myTriangles.Resize (1, 1, false);
Poly_Triangulation::ChangeTriangle (1).Set (1, 2, 1);
//Poly_Triangulation::myTriangles = Poly_Array1OfTriangle();
}

View File

@@ -1,102 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2018-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfLatePrimitiveArray_HeaderFile
#define _RWGltf_GltfLatePrimitiveArray_HeaderFile
#include <Bnd_Box.hxx>
#include <NCollection_Sequence.hxx>
#include <Poly_Triangulation.hxx>
#include <RWGltf_GltfPrimArrayData.hxx>
#include <RWGltf_GltfPrimitiveMode.hxx>
#include <Quantity_ColorRGBA.hxx>
class RWGltf_MaterialMetallicRoughness;
class RWGltf_MaterialCommon;
//! Mesh data wrapper for delayed primitive array loading from glTF file.
//! Class inherits Poly_Triangulation so that it can be put temporarily into TopoDS_Face within assembly structure,
//! to be replaced with proper Poly_Triangulation loaded later on.
class RWGltf_GltfLatePrimitiveArray : public Poly_Triangulation
{
DEFINE_STANDARD_RTTIEXT(RWGltf_GltfLatePrimitiveArray, Poly_Triangulation)
public:
//! Constructor.
Standard_EXPORT RWGltf_GltfLatePrimitiveArray (const TCollection_AsciiString& theId,
const TCollection_AsciiString& theName);
//! Destructor.
Standard_EXPORT virtual ~RWGltf_GltfLatePrimitiveArray();
//! Entity id.
const TCollection_AsciiString& Id() const { return myId; }
//! Entity name.
const TCollection_AsciiString& Name() const { return myName; }
//! Assign entity name.
void SetName (const TCollection_AsciiString& theName) { myName = theName; }
//! Return type of primitive array.
RWGltf_GltfPrimitiveMode PrimitiveMode() const { return myPrimMode; }
//! Set type of primitive array.
void SetPrimitiveMode (RWGltf_GltfPrimitiveMode theMode) { myPrimMode = theMode; }
//! Return true if primitive array has assigned material
bool HasStyle() const { return !myMaterialPbr.IsNull() || !myMaterialCommon.IsNull(); }
//! Return base color.
Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
//! Return PBR material definition.
const Handle(RWGltf_MaterialMetallicRoughness)& MaterialPbr() const { return myMaterialPbr; }
//! Set PBR material definition.
void SetMaterialPbr (const Handle(RWGltf_MaterialMetallicRoughness)& theMat) { myMaterialPbr = theMat; }
//! Return common (obsolete) material definition.
const Handle(RWGltf_MaterialCommon)& MaterialCommon() const { return myMaterialCommon; }
//! Set common (obsolete) material definition.
void SetMaterialCommon (const Handle(RWGltf_MaterialCommon)& theMat) { myMaterialCommon = theMat; }
//! Return primitive array data elements.
const NCollection_Sequence<RWGltf_GltfPrimArrayData>& Data() const { return myData; }
//! Add primitive array data element.
Standard_EXPORT RWGltf_GltfPrimArrayData& AddPrimArrayData (RWGltf_GltfArrayType theType);
//! Return bounding box defined within glTF file, or VOID if not specified.
const Bnd_Box& BoundingBox() const { return myBox; }
//! This method sets input bounding box and assigns a FAKE data to underlying Poly_Triangulation
//! as Min/Max corners of bounding box, so that standard tools like BRepBndLib::Add()
//! can be used transparently for computing bounding box of this face.
Standard_EXPORT void SetBoundingBox (const Bnd_Box& theBox);
protected:
NCollection_Sequence<RWGltf_GltfPrimArrayData> myData;
Handle(RWGltf_MaterialMetallicRoughness) myMaterialPbr; //!< PBR material
Handle(RWGltf_MaterialCommon) myMaterialCommon; //!< common (obsolete) material
Bnd_Box myBox; //!< bounding box
TCollection_AsciiString myId; //!< entity id
TCollection_AsciiString myName; //!< entity name
RWGltf_GltfPrimitiveMode myPrimMode; //!< type of primitive array
};
#endif // _RWGltf_GltfLatePrimitiveArray_HeaderFile

View File

@@ -1,41 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2018-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfPrimArrayData_HeaderFile
#define _RWGltf_GltfPrimArrayData_HeaderFile
#include <NCollection_Buffer.hxx>
#include <RWGltf_GltfAccessor.hxx>
#include <RWGltf_GltfArrayType.hxx>
#include <TCollection_AsciiString.hxx>
//! An element within primitive array - vertex attribute or element indexes.
class RWGltf_GltfPrimArrayData
{
public:
Handle(NCollection_Buffer) StreamData;
TCollection_AsciiString StreamUri;
int64_t StreamOffset;
RWGltf_GltfAccessor Accessor;
RWGltf_GltfArrayType Type;
RWGltf_GltfPrimArrayData()
: StreamOffset (0), Type (RWGltf_GltfArrayType_UNKNOWN) {}
RWGltf_GltfPrimArrayData (RWGltf_GltfArrayType theType)
: StreamOffset (0), Type (theType) {}
};
#endif // _RWGltf_GltfPrimArrayData_HeaderFile

View File

@@ -1,32 +0,0 @@
// Author: Kirill Gavrilov
// Copyright (c) 2016-2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _RWGltf_GltfPrimitiveMode_HeaderFile
#define _RWGltf_GltfPrimitiveMode_HeaderFile
//! Low-level glTF enumeration defining Primitive type.
//! Similar to Graphic3d_TypeOfData but does not define actual type and includes matrices.
enum RWGltf_GltfPrimitiveMode
{
RWGltf_GltfPrimitiveMode_UNKNOWN = -1, //!< unknown or invalid type
RWGltf_GltfPrimitiveMode_Points = 0, //!< GL_POINTS
RWGltf_GltfPrimitiveMode_Lines = 1, //!< GL_LINES
RWGltf_GltfPrimitiveMode_LineLoop = 2, //!< GL_LINE_LOOP
RWGltf_GltfPrimitiveMode_LineStrip = 3, //!< GL_LINE_STRIP
RWGltf_GltfPrimitiveMode_Triangles = 4, //!< GL_TRIANGLES
RWGltf_GltfPrimitiveMode_TriangleStrip = 5, //!< GL_TRIANGLE_STRIP
RWGltf_GltfPrimitiveMode_TriangleFan = 6, //!< GL_TRIANGLE_FAN
};
#endif // _RWGltf_GltfPrimitiveMode_HeaderFile

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