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

Compare commits

..

63 Commits

Author SHA1 Message Date
iko
7860770232 0031275: Visualization, TKOpenGl - handle normal-map texture with Path-Tracing
Base normal map support has been implemented in path tracing (just geometry normal replacement).
Smooth normal adaptation has been implemeneted in order to avoid black areas artefacts during path tracing.
Tangent normal space calcuation has been moved to separate unified function.
Tangent space orthogonalization algorithm has been changed in order to handle all orientations and combinations of UV coordinates.
2020-01-24 16:35:41 +03:00
kgv
6216ed573e 0031312: Data Exchange - RWGltf_CafReader fails reading texture embedded into base64 bufferView
RWGltf_GltfJsonParser::gltfParseTexture() now handles images embedded into bufferView of non-glb file.
2020-01-23 18:13:19 +03:00
oan
973f7d55bd 0031258: Mesh - OCCT 7.4.0 VIS get wrong render data
Check intervals for infinite value causing exception in GeomLib::NormEstim
2020-01-22 10:16:28 +03:00
emv
0c74168c42 0031306: Modeling Algorithms - Incomplete result of Cut operation
The problem is fixed by #0029323. Integrating test case only.
2020-01-22 10:15:21 +03:00
kgv
3eba1c72ef 0031309: Data Exchange - RWObj_Reader fails to read mh03.obj with multi-line syntax
Standard_ReadLineBuffer::SetMultilineMode() now accepts a flag to put gap space while joining lines, enabled by default.
2020-01-21 13:04:46 +03:00
kgv
e83d440f92 0031304: Configuration - TKACIS building failure due to duplicated symbol GeomFillFusInt()
Added missing "static" to internal methods of GeomFill package.
2020-01-18 12:30:59 +03:00
iko
6558400123 0031302: Visualization, TKOpenGl - wrong tangent space calculation for normal maps
The normal after tangent space calculation has been reverted in order to be in right orientation.
The tangent space calculation has been modified in order to handle back faces with inverted normal.
2020-01-16 18:48:56 +03:00
ifv
389f5b59dd 0031260: Geom2dGcc_Circ2d2TanRad fails in this case (720)
Adaptor2d/Adaptor2d_OffsetCurve.cxx:
Function nbPoints(...) is modified

Test case added
2020-01-16 18:20:01 +03:00
ifv
08353e37cf 0031294: Modeling Algorithms - Regression relatively 7.3.0. Crash in method BRepPrimAPI_MakePrism::Generated(...)
BRepSweep_NumLinearRegularSweep.cxx: raising exeption is removed

Test case is added

QABugs_20.cxx - test command is added
2020-01-14 18:26:50 +03:00
iko
c8bead4752 0031293: Visualization, TKOpenGl - broken capping when PBR shading is ON
Division by 'w' component has been added in texture coordinates calculations in PBR functions.
2020-01-13 16:21:56 +03:00
osa
9df71488b3 0031295: Foundation Classes, BVH_Tools - incorrect detection of ray-box intersection 2020-01-13 16:18:55 +03:00
msv
ef59b5e064 0031292: Data Exchange - SIGSEGV on reading STEP file with references to invalid entities
Changes:

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

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

- in StepData_UndefinedEntity::ReadRecord, consider the case when the entity number is positive but refers to non-existing entity. In this case literal value will be used instead of null entity for the problematic parameter.
2020-01-13 16:16:48 +03:00
oan
0c061f3d9d 0025287: BRepMesh_IncrementalMesh produces (way) out of tolerance mesh Added test case 2020-01-13 16:13:24 +03:00
iko
88b312d3a4 0031099: Visualization, TKOpenGl - support Point light source with artistic full cut-off distance
"Range" parameter of point light sources (positional and spot) concidering in PBR has been added.
Angular attenuation parameter of spot light in PBR has been reimplemented based on existing "concentration" parameter.
2020-01-13 16:07:19 +03:00
kgv
0858125fd4 0031284: Visualization - XCAFDoc_VisMaterialPBR lacks Index of Refraction
Added missing parameter.
2019-12-27 16:35:31 +03:00
mzernova
89d855ba58 0031225: Visualization, TKOpenGl - support cubemap for environment texture within Ray-Tracing
Ray-Tracing now handles IBL and background cubemaps in similar way as PBR.
Ambient light source is handled by Ray-Tracing in similar way as PBR,
e.g. as coefficient for environment map (IBL) or as constant light source.

Test script generating PBR spheres has been moved to Samples
and now shared by PBR and Path-Tracing tests.
2019-12-27 16:26:48 +03:00
kgv
d415125a68 0031274: Data Exchange - RWObj_Reader ignores usemtl with empty name
Fixed out of range access within pushMaterial().
2019-12-26 17:19:31 +03:00
razmyslovich
0da2ecac41 0031251: Add a new meshing parameter to enforce face linear deflection
Parameter has been renamed to ForceFaceDeflection. Added test case.

New parameter -force_face_def has been added to incmesh command.
2019-12-25 15:25:43 +03:00
ifv
bdd09cfaf4 0031242: Scaling with different coefficients along axes produces invalid shape
GeomConvert_1.cxx:
Creation periodic BSpline surfaces from trimmed periodic surface if trim is boundaries of periodic domain is allowed

BRepTools_NurbsConvertModification.cxx:
Checking domain of 2dCurves if surfaces are periodic is added

Test case tests/bugs/mesh/bug30008_2 is modified according to current behavior

Test case tests/bugs/modalg_7/bug31242 is added
2019-12-23 11:49:04 +03:00
kgv
9504a30d15 0031253: Visualization, TKOpenGl - phong shading GLSL compilation fail on Adreno 308
Removed initialization of global Normal variable outside of main() block.
occLight_IsHeadlight() flag is now packed into occLight_Position().w
2019-12-19 16:55:21 +03:00
jgv
9a1701fbcb 0030597: Result of BRepOffsetAPI_MakePipeShell doesn't match the given profiles
Modify the local function EdgeToBSpline of BRepFill_NSections to build a BSpline curve of general type for each curve of profile.
2019-12-19 16:53:36 +03:00
mzernova
c68c346d2b 0030600: Visualization, TKOpenGl - include GLES3/gl3.h instead of GLES2/gl2.h
Changed GLES2/gl2.h to GLES3/gl3.h.

OpenGl_Window_1.mm has been updated, now it is trying to create kEAGLRenderingAPIOpenGLES3 before trying to create kEAGLRenderingAPIOpenGLES2.
2019-12-19 16:50:16 +03:00
ifv
e2447a80ea 0031203: Test harness command "bsection" on the planar faces return only one vertex instead edge representing intersection line
BRepClass/BRepClass_FaceExplorer.cxx:
Protection against intersection of test ray with almost parallel edges is added.

SWDRAW/SWDRAW_ShapeFix.cxx: add tolerance as parameter in command checkfclass2d

tests/bugs/modalg_7/bug31203:
test case is added
2019-12-19 16:45:54 +03:00
oan
936ce1f273 0031199: BRepMesh fails on thin faces
Use real tolerance of a face to define threshold for tolerance of discrete model instead of empirical values based on discrete model itself
2019-12-19 16:30:06 +03:00
jgv
6ef7a1f9e5 0031187: Modeling Algorithms - Regression relatively 7.3.0. Unify same domain algorithm produces invalid shape.
Modify the local function ReconstructMissedSeam to build new seam edges correctly.
2019-12-18 19:42:50 +03:00
msv
23c2ae55c7 0031120: Memory leak in BRepOffsetAPI_MakeOffset
Add destructor of MAT2d_Mat2d - full removal of edges and bisectors.
2019-12-17 15:51:06 +03:00
abk
8bfae263c1 0031168: JT Import - cannot see properties attached to objects
Draw command GetNDStrings was improved to sort the properties by the keys and
skip conversions of the strings to type TCollection_AsciiString.

Certain Draw commands were corrected to use the Draw interpreter instead of "std::cout".

A Tcl procedure was created to compare two multi-line strings.
2019-12-14 13:52:16 +03:00
ma haidong
1c2ddf5612 0031231: Samples - the command "donl" in ModelingDemo.tcl should be "donly"
Fixed misprint in Tcl sample script.
2019-12-14 13:51:03 +03:00
kgv
5a8d30b87b 0030945: JT Import, JtProperty_LateLoaded - expose type of Deferred object
RWMesh_NodeAttributes has been extended with NamedData property for passing Metadata.

RWMesh_CafReader::addShapeIntoDoc() has been corrected to avoid
adding calling XCAFDoc_ShapeTool::AddSubShape() for sub-shape labels.
Attributes for Products and Instances are now set independently to shape labels.
Sharing of Compounds (previously always duplicated) as sub-Components has been fixed.

TDataStd_NamedData has been extended with interface for deferred data loading.
Setters have been corrected to avoid duplicating lookups within map.
2019-12-06 19:38:01 +03:00
kgv
b7b22996bb 0031227: Tests - log number of compared images into report 2019-12-06 19:32:37 +03:00
anv
552a74d829 0030889: ACIS Import - Incorrect result reading SAT and SAB files
Adapting CR30932 fix for a GeomLib approximator.
2019-12-06 19:32:36 +03:00
mzernova
c37bd936c3 0031213: Coding Rules, RWStl_Reader - misnamed variable THE_BUFFER
Renamed THE_BUFFER variable.
2019-12-06 19:32:35 +03:00
anv
4e8c1d8666 0031202: Shape Healing - FixMissingSeam creates degenerated edge
Adding tolerance to prevent degenerated cuts in cases where all vertex tolerance is covered by distance of the edge curve from vertex point.
2019-12-06 19:32:34 +03:00
iko
72f6dc612c 0031096: Visualization, TKOpenGl - support metallic-roughness texture mapping
OpenGl_ShaderManager - metallic-roughness, emissive, occlusion
and normal texture maps are now supported by PBR.
Emissive, occlusion and normal texture maps are now supported by Phong shading model.
Path-Tracing now handles metallic-roughness and emissive texture maps.

Graphic3d_TextureUnit enumeration has been extended by
new values corresponding to supported texture maps.

OpenGl_TextureSet and OpenGl_ShaderProgram have been extended with
bitmask Graphic3d_TextureSetBits identifying texture slots read from GLSL Program
and slots defined within Texture Set to avoid undefined behavior by binding mock textures.

OpenGl_TextureSet now duplicates texture unit information to handle
textures shared across multiple slots (like Occlusion [R] + Metallic-Roughness [GB]).

OpenGl_Context::BindTextures() has been extended with active GLSL program paramter
to set mock textures to texture units used by program but undefined by texture set.
OpenGl_Workspace::ApplyAspects() has been extended with parameter to avoid bining texture set.
2019-11-29 20:36:23 +03:00
mzernova
f051908edc 0030982: Visualization, OpenGl_View::MinMaxValues() - do not add background quad into depth range
Deleted adding background quad into depth range. Background is drawn in 2D coordinates. Fixed problem with using gradient background in tiles.
2019-11-29 20:19:42 +03:00
emv
420b38fde9 0031148: Modeling Algorithms - Offset adjacent co-planar faces with different offset values
Extend the Offset operation (Join Type "Intersection", mode "Complete") to allow different offset values on adjacent co-planar faces.
The gap between adjacent faces is closed by creating artificial face perpendicular to the face.

Adding test cases.
2019-11-29 10:06:22 +03:00
emv
34e7ac6817 0031201: Modeling Algorithms - Result of a section operation is incomplete
Fixing misprint - use the boundaries of the cylinder for Plane/Cylinder intersection.
Test cases for the issue.
2019-11-29 09:59:01 +03:00
osa
2b5a58a33c 0031186: Foundation Classes - add additional useful methods to BVH_Box.
Add Transform() and Transformed() methods by Mat4 for BVH_Box (only for 3D dimension).
Add PointBoxProjection() method to project point to box and RayBoxIntersection() method to compute hit time of ray-box intersection to BVH_Tools.
Add BVH_Ray class to define ray object.
2019-11-26 18:36:55 +03:00
kgv
e513a6c538 0031188: Draw Harness - enable colorized messages output to console by default
Message_PrinterOStream now uses colorized output by default.
DRAWEXE has been corrected to disabled colorized output
when it is called with -f argument to avoid spoiling testgrid HTML logs.
2019-11-26 18:35:38 +03:00
kgv
8c2d331426 0031007: Coding - eliminate warnings issued while compiling with -pedantic flag
Removed duplicating semicolons ;;.
Removed redundant semicolon at namespace closure.
2019-11-26 18:29:13 +03:00
mzernova
caee80f39f 0030697: Draw Harness - Draw_Printer should not be set to Message::DefaultMessenger() by default
Fixed bugs that occurred when using the default std::cout from Message::DefaultMessenger() instead of Draw_Printer

A dedicated option was added to Draw_ProgressIndicator, for outputting data to the tcl when performing tests

Added -tclOutput parameter to XProgress command
2019-11-23 16:09:07 +03:00
kgv
01b2f506d6 0030953: Data Exchange - implement export of mesh data into glTF 2.0 format
Added new class RWGltf_CafWriter for exporting XCAF document into glTF file
as well as Draw Harness command WriteGltf.

Added auxiliary method OSD_Path::FileNameAndExtension() splitting file name into Name and Extension.
2019-11-23 16:03:19 +03:00
vsv
df8c7e3e18 0031153: Visualization - Non clear highlighting of selected trihedron elements
AIS_Trihedron - removed extra fields holding highlight styles; standard styles are now used instead;
fixed unexpected modification of global aspects;
fixed unhighligting of selected plane within Shaded trihedron.

AIS_InteractiveContext now sets highlight color to highlight aspects, not only base color to drawer itself.
2019-11-21 17:43:07 +03:00
kgv
3f1675c941 0031174: Visualization - support user-provided stipple line patterns 2019-11-21 17:40:58 +03:00
kgv
6a56fe9240 0031178: Configuration, genproj - fix searching for zlib on Linux platform
zlib library is called libz on Linux.
2019-11-21 17:24:12 +03:00
mzernova
51ee6a7dbb 0030964: Data Exchange - use Standard_ReadLineBuffer within OBJ reader
Standard_ReadLineBuffer now supports a processing of the special multi-line case with \ at the end of the line.

Standard_RedLineBuffer was used to load Stl files
2019-11-20 17:08:31 +03:00
kgv
14a356b178 0031015: Visualization, TKOpenGl - OpenGl_WorldViewState does not cache inverted matrix
Implementation has been fixed to proprely set myInverseNeedUpdate flag.
2019-11-19 18:58:54 +03:00
kgv
4eff0c0480 0031175: Visualization - support dumping RED channel as grayscale image
Graphic3d_BufferType has been extended by Graphic3d_BT_Red.
2019-11-19 10:37:54 +03:00
abv
8f00325d73 0031171: Draw - support Unicode input / output in console on Windows
System console is configured at DRAW start to use UTF-8 encoding, for cout and cin to deal correctly with Unicode symbols.
Use of std::wcout is avoided as it leads to corrupted output.

Command testgrid is improved to enforce UTF-8 encoding in child DRAW processes to preserve Unicode symbols in captured output.

Test bugs fclasses bug22125 is refactored:
- avoid dependency on external data file
- avoid producing snapshot
- check that Unicode name of the file created by OCCT procedure matches the name interpreted by Tcl functions
2019-11-17 17:52:38 +03:00
kgv
9a90a4524e 0031159: Visualization - Font_FontMgr skips sub-faces within .ttc font collections
Font_SystemFont now defines Face Id in addition to file path.
Font_FontMgr::CheckFont() has been extended to return the list of Faces from font collections.
2019-11-15 16:51:15 +03:00
abv
31a5a359bb 0031144: Shape Healing - ShapeAnalysis::OuterWire() infinite loop on solid obtained from IFC
Implementation of ShapeAnalysis::OuterWire() is revised to avoid infinite cycle if face contains internal vertex.
2019-11-15 16:37:25 +03:00
jgv
bf97419a18 0030958: BRepOffsetAPI_ThruSections operation raises an exception while building history
Correct methods Build and Generated:
use BRepTools_WireExplorer instead of TopExp_Explorer or TopoDS_Iterator, for compatibility with previous computations.
2019-11-14 22:40:01 +03:00
gka
4c26106f76 0031140: Draw command "cirtang" raises exception on the parallel curves
Exception in the algorithm Geom2dGcc_Circ2dTanOnRadGeo raised because the number of solutions exceeded the size of reserved array for solutions. A check has been added to forbid adding solutions outside of allocated place.

The similar protection has been done in other algorithms of this package.
2019-11-13 18:38:28 +03:00
kgv
15e4e6a23e 0031118: Visualization - Font_FontMgr skips fonts with unknown styles like Narrow or Black
Extended Style name is now appended to Family name for unique identification of the font.
vfont -find now accepts mask to search the font and returns family name.
2019-11-13 18:34:33 +03:00
kgv
6b467e52bb 0031137: Modeling Data, BinTools_ShapeSet - avoid allocation of temporary arrays
BinTools_ShapeSet now defines maps with proper types instead of Standard_Transient.
BinTools_ShapeSet now avoids allocation of temporary arrays while reading
triangulation and polygonal data.

Classes Poly_Triangle, Poly_PolygonOnTriangulation, Poly_Polygon3D and Poly_Polygon2D
have been cleared from .lxx files and extended by new methods for preallocating and filling array,
as alternative to passing arrays by copy.

wavefront command - export "f" instead of obsolete "fo" keys into file.
BinTools - added missing tools for reading/writing short reals.
2019-11-09 19:12:47 +03:00
kgv
08b438b076 0031138: Visualization - Image_AlienPixMap fails to load PNG image with palette
Added fallback code converting unsupported pixel format into RGB24 using FreeImage itself.
2019-11-07 20:19:38 +03:00
kgv
a14f2b4722 0031139: Data Exchange - fix misprint in RWObj_CafReader
RWObj_CafReader::BindNamedShape(), added missing bind to material map.
XCAFDoc_VisMaterial::ConvertToCommonMaterial()/::ConvertToPbrMaterial(), added copying of base color texture.
XCAFPrs_DocumentExplorer now properly fills XCAFDoc_VisMaterial property of XCAFPrs_Style.
2019-11-07 20:18:25 +03:00
kgv
a1a9b24952 0031135: Visualization, TKOpenGl - texture sRGB -> linear conversion is applied twice by Path Tracer
Removed from PathtraceBase.fs redundant gamma correction applied to texture.
2019-11-06 19:33:36 +03:00
abv
f979709590 0031038: Draw - adaptations for running tests with CLang address sanitizer
New optional environment variable CSF_CPULIMIT_FACTOR is introduced, allowing scaling the argument given to DRAW command cpulimit by specified factor.

Command testgrid is extended by two new options:
- -skipped: to re-run tests skipped in specified log
- -skip: to skip specified number of tests in the beginning of test sequence

Temporary Tcl scripts generated by test system are now removed from the test log directories immediately after the test execution, to save disk space.

Advises on use of CLang sanitizers are added in guide "Debugging hints and tips".
2019-11-06 19:22:33 +03:00
oan
e9d05765c2 0031131: [REGRESSION] Mesh - location of Wire affects Poly_Polygon3D
Use TopoDS_Edge without location in case of free edges to produce Poly_Polygon3D without offset.
2019-11-06 19:19:47 +03:00
oan
7756fc599d 0031125: BRepMesh_IncrementalMesh crash in constructor for empty compound shape
Added check for cases of empty shapes producing null models.
NoError status is returned as far as empty compounds are generally coorect shapes.
2019-11-06 19:17:24 +03:00
abv
b31fbc832d 0031124: Configuration - linker errors when building with CLang on Windows
Standard_EXPORT is added in declaration of virtual methods where it was missing, to allow creation of sub-classes in other DLLs.
In some classes in OpenGl package Standard_EXPORT is added for all methods to make these classes usable in other DLLs.
2019-11-04 14:08:18 +03:00
abv
1bd04b5a02 0031060: Configuration - Support building with CLang compiler under VS 2019
Build tools are updated to support building with Visual Studion 2019 toolset ClangCL (LLVM clang-cl):
- In CMake builds, use of unsupported option "-std=c++0x" is avoided
- Tool genconf recognizes availability of ClangCL toolset and proposes it in the list
- Tool genproj recognizes new compiler specification VCVER=vclang and generates VS 2019 projects for it

Note that vclang configuration puts binaries to folder "vc14" as it is compatible with vc14 CRT.

Code is updated to build with Clang for Windows without errors and warnings:
- In BVH classes, pure virtual destructors are replaced by empty ones, to avoid bogus compiler warning
- In .lex files, pragmas are added to disable warnings in parser code
- In OSD, signature of function _osd_wnt_set_error() is corrected to avoid warning on incorrect use of va_args (undefined behavior)
- In OSD_Host, OSD_Parallel_TBB, warnings on usage of deprecated function are disabled
- In Quantity_ColorRGBA and ViewerTest_CmdParser, incorrect use of predefined macro __FUNCTION__ assuming it was a string literal is avoided
- In Standard_Macro.hxx, code is reordered to handle Clang for Windows appropriately
- In AdvApp2Var_SysBase.hxx, inclusion of obsolete (MSVC-specific) header file is replaced by Standard_TypeDef.hxx
- In Standard_ErrorHandler.hxx, empty statements added to avoid warning on unused class fields
- In IVtkDraw and ViewerTest, interface is corrected to use actual type avoiding unnecessary type casts

Off-topic: corrections of some errors (uninitialized class fields) reported by VS Code Analysis in TKernel
2019-11-03 21:47:59 +03:00
508 changed files with 13744 additions and 4583 deletions

View File

@@ -130,7 +130,9 @@ elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
if (APPLE)
# CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated.
set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
else()
elseif(NOT WIN32)
# CLang for Windows (at least CLang 8.0 distributed with VS 2019)
# does not support option "-std=c++0x"
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
endif()
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)

View File

@@ -82,6 +82,11 @@ if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Micr
lappend ::SYS_VC_LIST "vc142-uwp"
lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat"
}
if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Microsoft.VisualStudio.Component.VC.ClangCL -property installationPath} res] } {
lappend ::SYS_VS_LIST "Visual Studio 2019 (16, toolset ClangCL)"
lappend ::SYS_VC_LIST "vclang"
lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat"
}
# detect installed Visual Studio instances from global environment
if { [info exists ::env(VS140COMNTOOLS)] } {
@@ -193,7 +198,11 @@ proc wokdep:gui:UpdateList {} {
}
if { "$::HAVE_ZLIB" == "true" } {
wokdep:SearchStandardLibrary anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs "zlib" "zlib.h" "zlib" {"zlib"}
set aCheckLib "z"
if { "$::tcl_platform(platform)" == "windows" } {
set aCheckLib "zlib"
}
wokdep:SearchStandardLibrary anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs "zlib" "zlib.h" "$aCheckLib" {"zlib"}
}
if { "$::HAVE_LIBLZMA" == "true" } {
set aCheckLib "lzma"

View File

@@ -241,7 +241,11 @@ proc wokdep:Preferred {theList theCmpl theArch} {
# keep only two first digits in "vc141"
if { ! [regexp {^vc[0-9][0-9]} $theCmpl aCmpl] } {
set aCmpl $theCmpl
if { [regexp {^vclang} $theCmpl] } {
set aCmpl vc14
} else {
set aCmpl $theCmpl
}
}
set aShortList {}
@@ -631,7 +635,11 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
# keep only two first digits in "vc141"
if { ! [regexp {^vc[0-9][0-9]} ${::VCVER} aVcLib] } {
set aVcLib ${::VCVER}
if { [regexp {^vclang} ${::VCVER}] } {
set aVcLib vc14
} else {
set aVcLib ${::VCVER}
}
}
set isFound "true"

View File

@@ -256,7 +256,7 @@ proc genAllResources {} {
# Wrapper-function to generate VS project files
proc genproj {theFormat args} {
set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "cbp" "xcd" "pro"}
set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "vclang" "cbp" "xcd" "pro"}
set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" }
set isHelpRequire false
@@ -320,6 +320,7 @@ proc genproj {theFormat args} {
vc14 - Visual Studio 2015
vc141 - Visual Studio 2017
vc142 - Visual Studio 2019
vclang - Visual Studio with ClangCL toolset
cbp - CodeBlocks
xcd - XCode
pro - Qt Creator
@@ -529,7 +530,8 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution }
"vc12" -
"vc14" -
"vc141" -
"vc142" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP}
"vc142" -
"vclang" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP}
"cbp" { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl }
"xcd" {
set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
@@ -984,7 +986,8 @@ proc osutils:vcsolution:header { vcversion } {
append var \
"Microsoft Visual Studio Solution File, Format Version 12.00\n" \
"# Visual Studio 2013\n"
} elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" || "$vcversion" == "vc142" } {
} elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" ||
"$vcversion" == "vc142" || "$vcversion" == "vclang" } {
append var \
"Microsoft Visual Studio Solution File, Format Version 12.00\n" \
"# Visual Studio 14\n"
@@ -1225,6 +1228,9 @@ proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} {
} elseif { $theVcVer == "vc142" } {
set aVCRTVer "vc14"
set aToolset "v142"
} elseif { $theVcVer == "vclang" } {
set aVCRTVer "vc14"
set aToolset "ClangCL"
}
set what "$theVcVer"
@@ -1365,7 +1371,7 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
}
}
if { "$::HAVE_ZLIB" == "true" } {
set aLibsMap(CSF_ZLIB) "zlib"
set aLibsMap(CSF_ZLIB) "z"
}
if { "$::HAVE_LIBLZMA" == "true" } {
set aLibsMap(CSF_LIBLZMA) "liblzma"
@@ -1402,6 +1408,10 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
# tbb headers define different pragma lib depending on debug/release
set aLibsMap(CSF_TBB) ""
if { "$::HAVE_ZLIB" == "true" } {
set aLibsMap(CSF_ZLIB) "zlib"
}
} else {
set aLibsMap(CSF_dl) "dl"
if { "$theOS" == "mac" || "$theOS" == "ios" } {

View File

@@ -77,6 +77,9 @@ if "%VCVER:~-4%" == "-uwp" (
set VCLIB=%VCLIB%-uwp
set VCPROP=Universal
)
if "%VCFMT%" == "vclang" (
set VCLIB=vc14
)
rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
rem ----- Parsing of Visual Studio platform -----
@@ -106,6 +109,10 @@ if not "%DevEnvDir%" == "" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "vclang" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
@@ -118,6 +125,7 @@ if not "%DevEnvDir%" == "" (
echo vc14 = VS 2015
echo vc141 = VS 2017
echo vc142 = VS 2019
echo vclang = VS 2019 with ClangCL toolset
exit /B
)
@@ -147,6 +155,11 @@ if /I "%VCFMT%" == "vc9" (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=v142"
) else if /I "%VCFMT%" == "vclang" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=ClangCL"
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (

View File

@@ -64,7 +64,7 @@ Then makefiles will appear in the build folder (e.g. <i> D:/occt/build-android <
Alternatively one may specify the values without a toolchain file:
> cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=D:/DevTools/android-ndk-r13b -DCMAKE_ANDROID_STL_TYPE=gnustl_shared -DCMAKE_SYSTEM_VERSION=15 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_MAKE_PROGRAM=D:/DevTools/MinGW/bin/mingw32-make.exe -D3RDPARTY_DIR=D:/occt-3rdparty D:/occt
> cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=D:/DevTools/android-ndk-r13b -DCMAKE_ANDROID_STL_TYPE=gnustl_shared -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_MAKE_PROGRAM=D:/DevTools/MinGW/bin/mingw32-make.exe -D3RDPARTY_DIR=D:/occt-3rdparty D:/occt
@figure{/dev_guides/building/android/images/android_image006.png}

View File

@@ -368,3 +368,53 @@ Each counter has its name shown when the collected statistics are printed.
In DRAW, use command *dperf* to print all performance statistics.
Note that performance counters are not thread-safe.
@section occt_debug_sanitizers Use of compiler sanitizers
GCC and Clang compilers provide options for instrumenting the code with the tools intended for detection of run-time errors, called sanitizers.
This section provides some hints for using sanitizers for detecting possible errors in OCCT code.
@subsection occt_debug_sanitizers_linux Linux
Example of configuration steps for Ubuntu:
1. In CMake configuration:
- Use up-to-date version of the GCC or CLang compiler; make sure that if CMAKE_CXX_COMPILER is set to C++ compiler (e.g. "clang++-6.0") and CMAKE_C_COMPILER is set to C compiler (e.g. "clang-6.0")
- Ensure that CMAKE_LINKER is set to the C++ linker bundled with compiler (e.g. clang++-6.0); this is important to avoid linking problems
- For building with Address sanitizer, set CMAKE_CXX_FLAGS and CMAKE_C_FLAGS to "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls"
- For building with Undefined Behavior sanitizer, set CMAKE_CXX_FLAGS and CMAKE_C_FLAGS to "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
- Set CMAKE_BUILD_TYPE to RelWithDebInfo to get more informative stack traces on errors
2. Build as usual (make)
Be prepared that it works much slower than normal build and consumes more disk space.
3. Before running executable, make sure that "llvm-symbolizer" is in PATH; this is necessary to get human-readable stack traces. The tool must have exactly that name.
If it is installed in common folder (/usr/bin or similar) with different name, one option is to create a symlink, for instance:
> sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer
Alternatively, add directory where actual llvm-symbolizer is located (such as /usr/lib/llvm-6.0/bin) to the PATH variable.
4. Set environment variable to disable memory leaks detection (they seem to be reported for every global variable at exit, not much useful):
> export ASAN_OPTIONS=detect_leaks=0
5. Set environment variable CSF_CPULIMIT_FACTOR to reasonably large number to increase the time limits for program execution (used by OCCT tests) to compensate the performance penalty introduced by sanitizers:
> export CSF_CPULIMIT_FACTOR=20
6. When using UBSan, set environment variable UBSAN_OPTIONS to get stack traces:
> export UBSAN_OPTIONS=print_stacktrace=1
7. Run DRAW and perform tests as usual, keeping in mind that running with sanitizer is much heavier than normal build:
> ./draw.sh relwithdeb <br>
> Draw[]> testgrid -parallel 0
Note that when running tests under sanitizers, behavior may be different.
Known problems (as of CLang 6.0) are:
- Software signals (access violation etc.) are not handled
- Heap memory usage always reports zero
@subsection occt_debug_sanitizers_windows Windows
Though CLang toolset is available in Visual Studio 2015 and newer, sanitizer do not seem to be available out of the box (last tested with VS 2019 16.2.3).

View File

@@ -210,7 +210,7 @@ for which OCCT is certified to work.
| OS | Compiler |
| --------- | ----------- |
| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 <sup>1</sup>, 2019 <br> GCC 4.3+ (Mingw-w64)|
| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 <sup>1</sup>, 2019 <br>, LLVM (ClangCL), GCC 4.3+ (Mingw-w64)|
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
| OS X / macOS | XCode 6 or newer |
| Android | NDK r10, GNU gcc 4.8 or newer |

View File

@@ -86,7 +86,7 @@ sage " Fusion of this prism with the original part "
sage " fuse result rr result"
sage " "
fuse result rr result
donl result
donly result
nexplode result f
erase result
fit
@@ -108,13 +108,13 @@ ttranslate cyl cyl 0 7.5 0
sage " Display the Shape on Hidden Line Mode "
sage " hlr hid r"
sage ""
donl r
donly r
hlr hid r
sage " Display the Shape on HLR Mode "
sage " hlr nohid r"
sage " hlr hlr r"
sage ""
donl r
donly r
hlr nohid r
hlr hlr r
sage "Demo completed"

View File

@@ -57,11 +57,10 @@ for {set i 0} {$i < 12} {incr i} {
}
# Configure light sources
vlight del 1
vlight change 0 head 0
vlight change 0 direction -0.25 -1 -1
vlight change 0 sm 0.3
vlight change 0 int 10
vlight -change 0 -head 0
vlight -change 0 -direction -0.25 -1 -1
vlight -change 0 -sm 0.3
vlight -change 0 -int 10.0
# Load environment map
vtextureenv on 1

View File

@@ -12,11 +12,8 @@ vinit name=View1 w=512 h=512
vglinfo
# setup light sources
vlight del 0
vlight del 1
vlight add positional head 0 pos 0.5 0.5 0.85
vlight change 0 sm 0.06
vlight change 0 int 30.0
vlight -clear
vlight -add positional -head 0 -pos 0.5 0.5 0.85 -sm 0.06 -int 30.0
vvbo 0
vsetdispmode 1

View File

@@ -208,8 +208,9 @@ vviewparams -eye 139.412 -1.62643 178.037
vviewparams -size 170.508
# Restore light source parameters
vlight clear
vlight add directional direction -0.303949 -0.434084 -0.848048 smoothness 0.3 intensity 12
vlight -clear
vlight -add ambient
vlight -add directional -direction -0.303949 -0.434084 -0.848048 -smoothness 0.3 -intensity 12
# Load environment map
vtextureenv on 1

View File

@@ -0,0 +1,91 @@
# Script demonstrating PBR metallic-roughness material properties
#Category: Visualization
#Title: PBR metallic-rougness spheres
pload XDE OCAF MODELING VISUALIZATION
psphere s 0.35
catch { Close D }
XNewDoc D
# grid of spheres
set THE_UPPER 6
foreach i [list 0 3] {
set aPrefix ""
set aColor "GRAY80"
if { $i != 0 } {
set aPrefix "g_";
set aColor "CCB11D"
}
set aColShapes {}
for { set m 0 } { $m <= $THE_UPPER } { incr m } {
set aRowShapes {}
for { set r 0 } { $r <= $THE_UPPER } { incr r } {
set aName ${aPrefix}m${m}r${r}
copy s $aName
lappend aRowShapes $aName
ttranslate $aName ${r} ${i} ${m}
}
set aName ${aPrefix}m${m}
compound {*}$aRowShapes $aName
lappend aColShapes $aName
}
set aName ${aPrefix}spheres
compound {*}$aColShapes $aName
set aLabName "Gray Spheres"
if { $i != 0 } { set aLabName "Golden Spheres" }
set aLabComp [XAddShape D $aName 0]
SetName D $aLabComp $aLabName
for { set m 0 } { $m <= $THE_UPPER } { incr m } {
set aMet [expr 100 * ${m}/$THE_UPPER]
set aName ${aPrefix}m${m}
XAddComponent D $aLabComp $aName
set aLabCompCol [XFindShape D $aName]
SetName D $aLabCompCol "${aPrefix}m${aMet}%"
SetName D {*}[XFindComponent D $aName] "${aPrefix}m${aMet}%"
for { set r 0 } { $r <= $THE_UPPER } { incr r } {
set aRoug [expr 100 * ${r}/$THE_UPPER]
set aName ${aPrefix}m${m}r${r}
XAddComponent D $aLabCompCol $aName
set aLab [XFindComponent D $aName]
SetName D {*}$aLab "${aPrefix}m${aMet}%_r${aRoug}%"
XAddVisMaterial D $aName -baseColor $aColor -metallic ${m}/$THE_UPPER -roughness ${r}/$THE_UPPER
XSetVisMaterial D {*}$aLab $aName
}
}
}
set aLab [XFindShape D s]
SetName D {*}$aLab "Sphere"
XGetAllVisMaterials D
# labels
text2brep tm "Metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 6.5 -halign left -valign top -font monospace
text2brep tnm "Non-metal" -plane 0 -1 0 0 0 -1 -height 0.5 -pos -0.5 0 -0.5 -halign right -valign top -font monospace
text2brep ts "Smooth" -plane 0 -1 0 1 0 0 -height 0.5 -pos -0.5 0 -0.5 -halign left -valign top -font monospace
text2brep tr "Rough" -plane 0 -1 0 1 0 0 -height 0.5 -pos 6.5 0 -0.5 -halign right -valign top -font monospace
compound tm tnm ts tr labs
set aLab [XAddShape D labs 0]
SetName D $aLab "Labels"
XAddComponent D $aLab tm
XAddComponent D $aLab tnm
XAddComponent D $aLab ts
XAddComponent D $aLab tr
SetName D {*}[XFindComponent D tm] "Metal"
SetName D [XFindShape D tm] "Metal"
SetName D {*}[XFindComponent D tnm] "Non-metal"
SetName D [XFindShape D tnm] "Non-metal"
SetName D {*}[XFindComponent D ts] "Smooth"
SetName D [XFindShape D ts] "Smooth"
SetName D {*}[XFindComponent D tr] "Rough"
SetName D [XFindShape D tr] "Rough"
vclear
vinit View1 -width 768 -height 768
vfront
vrenderparams -shadingModel PBR
vlight -change 0 -intensity 2.5
XDisplay -dispMode 1 D
vcamera -ortho
vfit

View File

@@ -197,7 +197,7 @@ void AIS_Circle::UnsetColor()
}
else
{
Quantity_Color CC = Quantity_NOC_YELLOW;;
Quantity_Color CC = Quantity_NOC_YELLOW;
if( HasColor() ) CC = myDrawer->Color();
else if (myDrawer->HasLink()) AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
myDrawer->LineAspect()->SetColor(CC);

View File

@@ -300,7 +300,7 @@ void AIS_FixRelation::ComputeVertex(const TopoDS_Vertex& /*FixVertex*/,
gp_Pln pln(myPlane->Pln());
gp_Dir dir(pln.XAxis().Direction());
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myPntAttach.Translated(transvec);;
curpos = myPntAttach.Translated(transvec);
myPosition = curpos;
myAutomaticPosition = Standard_True;
}

View File

@@ -65,7 +65,7 @@ public:
//! Returns true if the Interactive Objects in the relation
//! are movable.
virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
//! computes the presentation according to a point of view
//! given by <aProjector>.
@@ -109,6 +109,4 @@ private:
};
#include <AIS_FixRelation.lxx>
#endif // _AIS_FixRelation_HeaderFile

View File

@@ -1,24 +0,0 @@
// Created on: 1997-02-28
// Created by: Jean-Pierre COMBE
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_FixRelation::IsMovable() const
{
return Standard_True;
}

View File

@@ -92,7 +92,7 @@ Aspect_TypeOfLine AIS_GraphicTool::GetLineType (const Handle(Prs3d_Drawer)& Dr,
const AIS_TypeOfAttribute Att)
{
Handle(Prs3d_LineAspect) LA = GetLineAspect(Dr,Att);
return LA->Aspect()->Type();;
return LA->Aspect()->Type();
}

View File

@@ -560,7 +560,7 @@ void AIS_IdenticRelation::ComputeTwoLinesPresentation(const Handle(Prs3d_Present
gp_Pln pln(myPlane->Pln());
gp_Dir dir(pln.XAxis().Direction());
gp_Vec transvec = gp_Vec(dir)*myArrowSize;
curpos = myFAttach.Translated(transvec);;
curpos = myFAttach.Translated(transvec);
myPosition = curpos;
myAutomaticPosition = Standard_True;
}

View File

@@ -58,7 +58,7 @@ public:
void ClearUsers() { myUsers.Clear(); }
//! Returns true if the interactive object is movable.
virtual Standard_Boolean IsMovable() const Standard_OVERRIDE;
virtual Standard_Boolean IsMovable() const Standard_OVERRIDE { return Standard_True; }
//! computes the presentation according to a point of view
//! given by <aProjector>.
@@ -134,11 +134,4 @@ private:
};
#include <AIS_IdenticRelation.lxx>
#endif // _AIS_IdenticRelation_HeaderFile

View File

@@ -1,24 +0,0 @@
// Created on: 1997-03-04
// Created by: Jean-Pierre COMBE
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
//function : IsMovable
//purpose :
//=======================================================================
inline Standard_Boolean AIS_IdenticRelation::IsMovable() const
{
return Standard_True;
}

View File

@@ -65,13 +65,15 @@ namespace
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners;
//! Initialize default highlighting attributes.
static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer)
static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer,
const Quantity_Color& theColor)
{
theDrawer->SetMethod (Aspect_TOHM_COLOR);
theDrawer->SetDisplayMode (0);
theDrawer->SetColor (theColor);
theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
*theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
theDrawer->SetupOwnShadingAspect();
theDrawer->SetupOwnPointAspect();
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
@@ -82,6 +84,24 @@ namespace
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
theDrawer->SetDatumAspect (new Prs3d_DatumAspect());
theDrawer->ShadingAspect()->SetColor (theColor);
theDrawer->WireAspect()->SetColor (theColor);
theDrawer->LineAspect()->SetColor (theColor);
theDrawer->PlaneAspect()->ArrowAspect()->SetColor (theColor);
theDrawer->PlaneAspect()->IsoAspect()->SetColor (theColor);
theDrawer->PlaneAspect()->EdgesAspect()->SetColor (theColor);
theDrawer->FreeBoundaryAspect()->SetColor (theColor);
theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
theDrawer->PointAspect()->SetColor (theColor);
for (Standard_Integer aPartIter = 0; aPartIter < Prs3d_DP_None; ++aPartIter)
{
if (Handle(Prs3d_LineAspect) aLineAsp = theDrawer->DatumAspect()->LineAspect ((Prs3d_DatumParts )aPartIter))
{
aLineAsp->SetColor (theColor);
}
}
theDrawer->WireAspect()->SetWidth (2.0);
theDrawer->LineAspect()->SetWidth (2.0);
@@ -130,30 +150,26 @@ myIsAutoActivateSelMode(Standard_True)
{
const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic];
aStyle->Link (myDefaultDrawer);
initDefaultHilightAttributes (aStyle);
initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1);
aStyle->SetZLayer(Graphic3d_ZLayerId_Top);
aStyle->SetColor (Quantity_NOC_CYAN1);
}
{
const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic];
aStyle->Link (myDefaultDrawer);
initDefaultHilightAttributes (aStyle);
initDefaultHilightAttributes (aStyle, Quantity_NOC_CYAN1);
aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost);
aStyle->SetColor (Quantity_NOC_CYAN1);
}
{
const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected];
aStyle->Link (myDefaultDrawer);
initDefaultHilightAttributes (aStyle);
initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80);
aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
aStyle->SetColor (Quantity_NOC_GRAY80);
}
{
const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected];
aStyle->Link (myDefaultDrawer);
initDefaultHilightAttributes (aStyle);
initDefaultHilightAttributes (aStyle, Quantity_NOC_GRAY80);
aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN);
aStyle->SetColor (Quantity_NOC_GRAY80);
}
{
const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity];

View File

@@ -30,7 +30,8 @@
#include <V3d_View.hxx>
#include <Standard_Version.hxx>
#include <Standard_DefineHandle.hxx>
NCOLLECTION_HSEQUENCE(AIS_ManipulatorObjectSequence, Handle(AIS_InteractiveObject));
NCOLLECTION_HSEQUENCE(AIS_ManipulatorObjectSequence, Handle(AIS_InteractiveObject))
DEFINE_STANDARD_HANDLE (AIS_Manipulator, AIS_InteractiveObject)

View File

@@ -168,7 +168,7 @@ void AIS_OffsetDimension::ComputeSelection(const Handle(SelectMgr_Selection)& aS
gp_Pnt myTSAttach = mySAttach.Transformed (myRelativePos);
gp_Dir myTDirAttach = myDirAttach.Transformed (myRelativePos);
gp_Dir myTDirAttach2 = myDirAttach2.Transformed (myRelativePos);
gp_Pnt Tcurpos = myPosition.Transformed (myRelativePos);;
gp_Pnt Tcurpos = myPosition.Transformed (myRelativePos);
gp_Lin L1 (myTFAttach,myTDirAttach);
gp_Lin L2 (myTSAttach,myTDirAttach2);

View File

@@ -32,6 +32,7 @@
#include <Prs3d_DatumAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Projector.hxx>
#include <Prs3d_ShadingAspect.hxx>
@@ -59,6 +60,8 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent)
myTrihDispMode (Prs3d_DM_WireFrame),
myComponent (theComponent)
{
myAutoHilight = Standard_False;
// selection priorities
mySelectionPriority.Bind (Prs3d_DP_None, 5); // complete triedron: priority 5 (same as faces)
mySelectionPriority.Bind (Prs3d_DP_Origin, 8); // origin: priority 8
@@ -70,6 +73,7 @@ AIS_Trihedron::AIS_Trihedron (const Handle(Geom_Axis2Placement)& theComponent)
{
mySelectionPriority.Bind ((Prs3d_DatumParts )aPartIter, 5); // planes: priority: 5
}
myHiddenLineAspect = new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_EMPTY, 1.0f);
// trihedron labels
myLabel.Bind (Prs3d_DP_XAxis, "X");
@@ -135,7 +139,6 @@ void AIS_Trihedron::SetSize(const Standard_Real aValue)
myDrawer->DatumAspect()->SetAxisLength(aValue, aValue, aValue);
SetToUpdate();
UpdatePresentations();
UpdateSelection();
}
@@ -163,7 +166,6 @@ void AIS_Trihedron::UnsetSize()
else
{
SetToUpdate();
UpdatePresentations();
}
UpdateSelection();
}
@@ -310,36 +312,37 @@ void AIS_Trihedron::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManag
aPresentation->Clear();
const Prs3d_DatumParts aPart = anOwner->DatumPart();
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (aPresentation);
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
if (aPart >= Prs3d_DP_XOYAxis && aPart <= Prs3d_DP_XOZAxis)
{
// planes selection is equal in both shading and wireframe mode
aGroup->SetGroupPrimitivesAspect (getHighlightLineAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (theStyle->LineAspect()->Aspect());
}
else
{
if (myTrihDispMode == Prs3d_DM_Shaded)
{
aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect(aPart)->Aspect());
aGroup->SetGroupPrimitivesAspect (theStyle->ShadingAspect()->Aspect());
}
else
{
if (aPart == Prs3d_DP_Origin)
{
aGroup->SetGroupPrimitivesAspect (getHighlightPointAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (theStyle->PointAspect()->Aspect());
}
else
{
aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect(aPart)->Aspect());
aGroup->SetGroupPrimitivesAspect(theStyle->LineAspect()->Aspect());
}
}
}
aGroup->AddPrimitiveArray (arrayOfPrimitives(aPart));
if (aPresentation->GetZLayer() != theStyle->ZLayer())
const Graphic3d_ZLayerId aLayer = theStyle->ZLayer() != Graphic3d_ZLayerId_UNKNOWN ? theStyle->ZLayer() : myDrawer->ZLayer();
if (aPresentation->GetZLayer() != aLayer)
{
aPresentation->SetZLayer (theStyle->ZLayer());
aPresentation->SetZLayer (aLayer);
}
aPresentation->Highlight (theStyle);
thePM->AddToImmediateList (aPresentation);
}
@@ -356,25 +359,22 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&
return;
}
Handle(Prs3d_DatumAspect) anAspect = myDrawer->DatumAspect();
const bool isShadingMode = myTrihDispMode == Prs3d_DM_Shaded;
const Handle(Prs3d_Drawer)& aContextSelStyle = GetContext()->SelectionStyle();
const Quantity_Color& aSelectionColor = aContextSelStyle->Color();
Handle(Prs3d_Drawer) anAspect = !myHilightDrawer.IsNull() ? myHilightDrawer : GetContext()->SelectionStyle();
for (SelectMgr_SequenceOfOwner::Iterator anIterator (theOwners); anIterator.More(); anIterator.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = anIterator.Value();
Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(anOwner);
if (aTrihedronOwner.IsNull())
{
thePM->Color (this, aContextSelStyle, 0);
thePM->Color (this, anAspect, 0);
continue;
}
const Prs3d_DatumParts aPart = aTrihedronOwner->DatumPart();
Handle(Graphic3d_Group) aGroup;
if (mySelectedParts.Contains (aPart)
|| !myPartToGroup.Find (aPart, aGroup))
if (mySelectedParts.Contains (aPart) || !myPartToGroup.Find (aPart, aGroup))
{
continue;
}
@@ -382,27 +382,23 @@ void AIS_Trihedron::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&
if (aPart >= Prs3d_DP_XOYAxis
&& aPart <= Prs3d_DP_XOZAxis)
{
getHighlightLineAspect()->SetColor (aSelectionColor);
aGroup->SetGroupPrimitivesAspect (getHighlightLineAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect()->Aspect());
}
else
{
if (isShadingMode)
{
getHighlightAspect()->SetColor (aSelectionColor);
aGroup->SetGroupPrimitivesAspect (getHighlightAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect()->Aspect());
}
else
{
if (aPart == Prs3d_DP_Origin)
{
getHighlightPointAspect()->SetColor (aSelectionColor);
aGroup->SetGroupPrimitivesAspect (getHighlightPointAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (anAspect->PointAspect()->Aspect());
}
else
{
getHighlightLineAspect()->SetColor (aSelectionColor);
aGroup->SetGroupPrimitivesAspect (getHighlightLineAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect()->Aspect());
}
}
}
@@ -426,9 +422,9 @@ void AIS_Trihedron::ClearSelected()
if (aPart >= Prs3d_DP_XOYAxis
&& aPart <= Prs3d_DP_XOZAxis)
{
aGroup->SetGroupPrimitivesAspect (anAspect->LineAspect (aPart)->Aspect());
aGroup->SetGroupPrimitivesAspect (myHiddenLineAspect);
}
if (isShadingMode)
else if (isShadingMode)
{
aGroup->SetGroupPrimitivesAspect (anAspect->ShadingAspect (aPart)->Aspect());
}
@@ -553,11 +549,8 @@ void AIS_Trihedron::computePresentation (const Handle(PrsMgr_PresentationManager
Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup (thePrs);
myPartToGroup.Bind (aPart, aGroup);
const Handle(Graphic3d_AspectLine3d)& aLineAspect = anAspect->LineAspect (aPart)->Aspect();
aLineAspect->SetType (Aspect_TOL_EMPTY);
aGroup->AddPrimitiveArray (arrayOfPrimitives (aPart));
aGroup->SetGroupPrimitivesAspect (aLineAspect);
aGroup->SetGroupPrimitivesAspect (myHiddenLineAspect);
}
}
@@ -933,65 +926,3 @@ void AIS_Trihedron::updatePrimitives(const Handle(Prs3d_DatumAspect)& theAspect,
myPrimitives.Bind(aPart, aPrims);
}
}
// =======================================================================
// function : getHighlightAspect
// purpose :
// =======================================================================
Handle(Prs3d_ShadingAspect) AIS_Trihedron::getHighlightAspect()
{
if (!myHighlightAspect.IsNull())
return myHighlightAspect;
Quantity_Color aHighlightColor = Quantity_NOC_GRAY80;
if (!myHilightDrawer.IsNull())
aHighlightColor = myHilightDrawer->Color();
myHighlightAspect = new Prs3d_ShadingAspect();
myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
myHighlightAspect->SetColor (aHighlightColor);
Graphic3d_MaterialAspect aHighlightMaterial;
aHighlightMaterial.SetColor (aHighlightColor);
myHighlightAspect->SetMaterial (aHighlightMaterial);
return myHighlightAspect;
}
// =======================================================================
// function : getHighlightLineAspect
// purpose :
// =======================================================================
Handle(Prs3d_LineAspect) AIS_Trihedron::getHighlightLineAspect()
{
if (!myHighlightLineAspect.IsNull())
return myHighlightLineAspect;
Quantity_Color aHighlightColor = Quantity_NOC_GRAY80;
if (!myHilightDrawer.IsNull())
aHighlightColor = myHilightDrawer->Color();
Handle(Prs3d_DatumAspect) aDatumAspect = Attributes()->DatumAspect();
Handle(Prs3d_LineAspect) aLineAspect = aDatumAspect->LineAspect(Prs3d_DP_XAxis);
myHighlightLineAspect = new Prs3d_LineAspect (aHighlightColor, aLineAspect->Aspect()->Type(),
aLineAspect->Aspect()->Width());
return myHighlightLineAspect;
}
// =======================================================================
// function : getHighlightPointAspect
// purpose :
// =======================================================================
Handle(Prs3d_PointAspect) AIS_Trihedron::getHighlightPointAspect()
{
if (!myHighlightPointAspect.IsNull())
return myHighlightPointAspect;
Quantity_Color aHighlightColor = Quantity_NOC_GRAY80;
if (!myHilightDrawer.IsNull())
aHighlightColor = myHilightDrawer->Color();
myHighlightPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, aHighlightColor, 1.0);
return myHighlightPointAspect;
}

View File

@@ -186,9 +186,6 @@ public:
public:
//! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return false; }
//! Method which clear all selected owners belonging
//! to this selectable object ( for fast presentation draw ).
Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
@@ -248,13 +245,6 @@ protected:
const gp_Dir& theYDir,
const gp_Dir& theZDir);
//! Returns highlight line aspect , create if it is the first call
Handle(Prs3d_ShadingAspect) getHighlightAspect();
//! Returns highlight line aspect , create if it is the first call
Handle(Prs3d_LineAspect) getHighlightLineAspect();
//! Returns highlight line aspect , create if it is the first call
Handle(Prs3d_PointAspect) getHighlightPointAspect();
protected:
Standard_Boolean myHasOwnSize;
Standard_Boolean myHasOwnTextColor;
@@ -269,10 +259,7 @@ protected:
NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
NCollection_List<Prs3d_DatumParts> mySelectedParts;
Handle(Prs3d_ShadingAspect) myHighlightAspect;
Handle(Prs3d_LineAspect) myHighlightLineAspect;
Handle(Prs3d_PointAspect) myHighlightPointAspect;
Handle(Graphic3d_AspectLine3d) myHiddenLineAspect;
NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
};

View File

@@ -69,14 +69,12 @@ AIS_ExclusionFilter.hxx
AIS_ExclusionFilter.lxx
AIS_FixRelation.cxx
AIS_FixRelation.hxx
AIS_FixRelation.lxx
AIS_GlobalStatus.cxx
AIS_GlobalStatus.hxx
AIS_GraphicTool.cxx
AIS_GraphicTool.hxx
AIS_IdenticRelation.cxx
AIS_IdenticRelation.hxx
AIS_IdenticRelation.lxx
AIS_IndexedDataMapOfOwnerPrs.hxx
AIS_InteractiveContext.cxx
AIS_InteractiveContext.hxx

View File

@@ -530,7 +530,7 @@ gp_Circ2d Adaptor2d_OffsetCurve::Circle() const
gp_Elips2d Adaptor2d_OffsetCurve::Ellipse() const
{
if (myCurve->GetType() == GeomAbs_Ellipse && myOffset == 0.) {
return myCurve->Ellipse();;
return myCurve->Ellipse();
}
else {
throw Standard_NoSuchObject("Adaptor2d_OffsetCurve:Ellipse");
@@ -656,19 +656,16 @@ static Standard_Integer nbPoints(const Handle(Adaptor2d_HCurve2d)& theCurve)
Standard_Integer nbs = 20;
if (theCurve->GetType() == GeomAbs_Line)
nbs = 2;
else if (theCurve->GetType() == GeomAbs_BezierCurve)
if (theCurve->GetType() == GeomAbs_BezierCurve)
{
nbs = 3 + theCurve->NbPoles();
nbs = Max(nbs, 3 + theCurve->NbPoles());
}
else if (theCurve->GetType() == GeomAbs_BSplineCurve) {
nbs = theCurve->NbKnots();
nbs *= theCurve->Degree();
nbs = Max(nbs, theCurve->NbKnots() * theCurve->Degree());
}
if (nbs > 200)
nbs = 200;
if (nbs > 300)
nbs = 300;
return nbs;
}

View File

@@ -540,7 +540,7 @@ Standard_Boolean Adaptor3d_TopolTool::IsThePointOn(const gp_Pnt2d& P,
if (surumin || survmin || surumax || survmax) {
return(Standard_True);
}
return(Standard_False);;
return Standard_False;
}
}

View File

@@ -16,12 +16,8 @@
#define AdvApp2Var_SysBase_HeaderFile
#include <Standard_Macro.hxx>
#include <Standard_TypeDef.hxx>
#include <AdvApp2Var_Data_f2c.hxx>
#if _MSC_VER
#include <stddef.h>
#else
#include <stdint.h>
#endif
class AdvApp2Var_SysBase {
public:

View File

@@ -374,7 +374,7 @@ void AppBlend_AppSurf::InternalPerform(const Handle(TheLine)& Lin,
Standard_Real Uf = F.Parameter(Lin->Point(1));
Standard_Real Ul = F.Parameter(Lin->Point(NbPoint))-Uf;
for (i=2; i<NbPoint; i++) {
theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;;
theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;
}
AppDef_Compute theAppDef(theParams,dmin,dmax,tol3d,tol2d,nbit,
Standard_True, Standard_True);
@@ -426,7 +426,7 @@ void AppBlend_AppSurf::InternalPerform(const Handle(TheLine)& Lin,
Standard_Real Uf = F.Parameter(Lin->Point(1));
Standard_Real Ul = F.Parameter(Lin->Point(NbPoint))-Uf;
for (i=2; i<NbPoint; i++) {
theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;;
theParams(i) = (F.Parameter(Lin->Point(i))-Uf)/Ul;
}
theapprox.Init(dmin,dmax,tol3d,tol2d,nbit,Standard_True,

View File

@@ -452,7 +452,7 @@ AppCont_LeastSquare::AppCont_LeastSquare(const AppCont_Function& SSP,
myDone = Standard_True;
for (i = bdeb; i <= bfin; i++) {
for (j = bdeb; j <= bfin; j++) {
IBPij = IBP(i, j);;
IBPij = IBP(i, j);
for (k = 1; k<= nbcol; k++) {
myPoles(i, k) += IBPij * B2(j, k);
}

View File

@@ -65,7 +65,7 @@ void AppParCurves::Bernstein(const Standard_Integer NbPoles,
math_Matrix& DA) {
Standard_Integer i, j, id, Ndeg = NbPoles-1;
Standard_Real u0, u1, y0, y1, xs, bj, bj1;;
Standard_Real u0, u1, y0, y1, xs, bj, bj1;
Standard_Integer first = U.Lower(), last = U.Upper();
math_Vector B(1, NbPoles-1);

View File

@@ -1272,7 +1272,7 @@ const AppParCurves_MultiBSpCurve& AppParCurves_LeastSquare::BSplineValue()
{
if (!done) {throw StdFail_NotDone();}
Standard_Integer i, j, j2, npoints = nbP+nbP2d;;
Standard_Integer i, j, j2, npoints = nbP+nbP2d;
gp_Pnt Pt;
gp_Pnt2d Pt2d;
Standard_Integer ideb = resinit, ifin = resfin;

View File

@@ -27,6 +27,7 @@
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx>
@@ -611,15 +612,69 @@ Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d
gp_Pnt2d aF2d = theC2D->Value(theC2D->FirstParameter());
gp_Pnt2d aL2d = theC2D->Value(theC2D->LastParameter());
Standard_Boolean isToTrim = Standard_True;
Standard_Real U1, U2, V1, V2;
aSurf->Bounds(U1, U2, V1, V2);
if (theIsU)
{
Standard_Real aV1Param = Min(aF2d.Y(), aL2d.Y());
Standard_Real aV2Param = Max(aF2d.Y(), aL2d.Y());
if (aV2Param < V1 - myTol || aV1Param > V2 + myTol)
{
return Standard_False;
}
else if (Precision::IsInfinite(V1) || Precision::IsInfinite(V2))
{
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
{
return Standard_False;
}
aSurf = new Geom_RectangularTrimmedSurface(aSurf, U1, U2, aV1Param, aV2Param);
isToTrim = Standard_False;
}
else
{
aV1Param = Max(aV1Param, V1);
aV2Param = Min(aV2Param, V2);
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
{
return Standard_False;
}
}
aC3d = aSurf->UIso(theParam);
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.Y(), aL2d.Y());
if (isToTrim)
aC3d = new Geom_TrimmedCurve(aC3d, aV1Param, aV2Param);
}
else
{
Standard_Real aU1Param = Min(aF2d.X(), aL2d.X());
Standard_Real aU2Param = Max(aF2d.X(), aL2d.X());
if (aU2Param < U1 - myTol || aU1Param > U2 + myTol)
{
return Standard_False;
}
else if (Precision::IsInfinite(U1) || Precision::IsInfinite(U2))
{
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
{
return Standard_False;
}
aSurf = new Geom_RectangularTrimmedSurface(aSurf, aU1Param, aU2Param, V1, V2);
isToTrim = Standard_False;
}
else
{
aU1Param = Max(aU1Param, U1);
aU2Param = Min(aU2Param, U2);
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
{
return Standard_False;
}
}
aC3d = aSurf->VIso(theParam);
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.X(), aL2d.X());
if (isToTrim)
aC3d = new Geom_TrimmedCurve(aC3d, aU1Param, aU2Param);
}
// Convert arbitrary curve type to the b-spline.

View File

@@ -462,7 +462,7 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
myC3d->D0(pc3d[ii],Pc3d);
dist2 = Pcons.SquareDistance(Pc3d);
use_parameter = (dist2 <= Tol2 && (pc3d[ii] > pc3d[count-1] + deltamin)) ;
Standard_Real aDistMin = RealLast();;
Standard_Real aDistMin = RealLast();
if(use_parameter) {
if(dist2 > dmax2) dmax2 = dist2;

View File

@@ -17,6 +17,7 @@
#include <BOPTest.hxx>
#include <BRepTest.hxx>
#include <DBRep.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <GeometryTest.hxx>
@@ -136,7 +137,8 @@ void BOPTest::ReportAlerts(const Handle(Message_Report)& theReport)
}
// output message with list of shapes
Message::DefaultMessenger()->Send (aText, anAlertTypes[iGravity]);
Draw_Interpretor& aDrawInterpretor = Draw::GetInterpretor();
aDrawInterpretor << aText << "\n";
}
}
}

View File

@@ -813,7 +813,7 @@ void CorrectEdgeTolerance (const TopoDS_Edge& myShape,
{
if (myCref.IsNull())
return;
Standard_Boolean ok=Standard_True;;
Standard_Boolean ok = Standard_True;
Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));

View File

@@ -361,7 +361,7 @@ static void BuildFaceIn( TopoDS_Face& F,
else {
TopoDS_Shape aLocalShape = Faces.First().EmptyCopied();
TopoDS_Face NF = TopoDS::Face(aLocalShape);
// TopoDS_Face NF = TopoDS::Face(Faces.First().EmptyCopied());;
// TopoDS_Face NF = TopoDS::Face(Faces.First().EmptyCopied());
B.Add (NF,WI);
Faces.Append (NF);
BuildFaceIn (NF, WI, KeyContains, KeyIsIn, TopAbs_FORWARD,Faces);

View File

@@ -309,3 +309,55 @@ void BRepAlgo_Image::Filter(const TopoDS_Shape& S,
}
//=======================================================================
//function : RemoveRoot
//purpose :
//=======================================================================
void BRepAlgo_Image::RemoveRoot (const TopoDS_Shape& Root)
{
Standard_Boolean isRemoved = Standard_False;
for (TopTools_ListOfShape::Iterator it (roots); it.More(); it.Next())
{
if (Root.IsSame (it.Value()))
{
roots.Remove (it);
isRemoved = Standard_True;
break;
}
}
if (!isRemoved)
return;
const TopTools_ListOfShape* pNewS = down.Seek (Root);
if (pNewS)
{
for (TopTools_ListOfShape::Iterator it (*pNewS); it.More(); it.Next())
{
const TopoDS_Shape *pOldS = up.Seek (it.Value());
if (pOldS && pOldS->IsSame (Root))
up.UnBind (it.Value());
}
down.UnBind (Root);
}
}
//=======================================================================
//function : ReplaceRoot
//purpose :
//=======================================================================
void BRepAlgo_Image::ReplaceRoot (const TopoDS_Shape& OldRoot,
const TopoDS_Shape& NewRoot)
{
if (!HasImage (OldRoot))
return;
const TopTools_ListOfShape& aLImage = Image (OldRoot);
if (HasImage (NewRoot))
Add (NewRoot, aLImage);
else
Bind (NewRoot, aLImage);
SetRoot (NewRoot);
RemoveRoot (OldRoot);
}

View File

@@ -60,6 +60,14 @@ public:
//! Remove <S> to set of images.
Standard_EXPORT void Remove (const TopoDS_Shape& S);
//! Removes the root <theRoot> from the list of roots and up and down maps.
Standard_EXPORT void RemoveRoot (const TopoDS_Shape& Root);
//! Replaces the <OldRoot> with the <NewRoot>, so all images
//! of the <OldRoot> become the images of the <NewRoot>.
//! The <OldRoot> is removed.
Standard_EXPORT void ReplaceRoot (const TopoDS_Shape& OldRoot, const TopoDS_Shape& NewRoot);
Standard_EXPORT const TopTools_ListOfShape& Roots() const;
Standard_EXPORT Standard_Boolean IsImage (const TopoDS_Shape& S) const;

View File

@@ -280,7 +280,7 @@ void BRepAlgoAPI_DumpOper::Dump(const TopoDS_Shape& theShape1,
fprintf(afile,"%s\n","# Result is Null ");
fprintf(afile, "%s %s %s\n","restore", aName1.ToCString(), "arg1");
fprintf(afile, "%s %s %s\n","restore", aName2.ToCString(), "arg2");;
fprintf(afile, "%s %s %s\n","restore", aName2.ToCString(), "arg2");
TCollection_AsciiString aBopString;
switch (theOperation)
{

View File

@@ -878,7 +878,7 @@ Standard_Boolean BRepBlend_SurfRstConstRad::Section
gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
gp_Vec ns,ns2,dnplan,dnw,dn2w; //,np2,dnp2;
gp_Vec ncrossns;;
gp_Vec ncrossns;
gp_Vec resulu,resulv,temp,tgct,resul;
gp_Vec d1urst,d1vrst;
gp_Pnt Center,bid;

View File

@@ -887,7 +887,7 @@ TColStd_Array1OfReal& DWeigths)
gp_Vec d1u1,d1v1,d2u1,d2v1,d2uv1,d1;
gp_Vec ns,ns2,dnplan,dnw,dn2w;//,np2,dnp2;
gp_Vec ncrossns;;
gp_Vec ncrossns;
gp_Vec resulu,resulv,temp,tgct,resul;
gp_Vec d1urst,d1vrst;
gp_Pnt Center,bid;

View File

@@ -653,7 +653,7 @@ Standard_Boolean IsModifySize(const BRepAdaptor_Surface& theBS,
{
if(anExtr.NbExt() > 0)
{
Standard_Integer i, imin = 0;;
Standard_Integer i, imin = 0;
Standard_Real dmin = RealLast();
Standard_Real uextr = 0., vextr = 0.;
Extrema_POnSurf P1, P2;

View File

@@ -27,6 +27,7 @@
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <Geom2dAPI_ProjectPointOnCurve.hxx>
static const Standard_Real Probing_Start = 0.123;
static const Standard_Real Probing_End = 0.7;
@@ -140,7 +141,7 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
gp_Lin2d& L,
Standard_Real& Par)
{
TopExp_Explorer anExpF(myFace,TopAbs_EDGE);
TopExp_Explorer anExpF(myFace, TopAbs_EDGE);
Standard_Integer i;
Standard_Real aFPar;
Standard_Real aLPar;
@@ -153,7 +154,7 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
if (i != myCurEdgeInd)
continue;
const TopoDS_Shape &aLocalShape = anExpF.Current();
const TopoDS_Shape &aLocalShape = anExpF.Current();
const TopAbs_Orientation anOrientation = aLocalShape.Orientation();
if (anOrientation == TopAbs_FORWARD || anOrientation == TopAbs_REVERSED) {
@@ -162,27 +163,29 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
aC2d = BRep_Tool::CurveOnSurface(anEdge, myFace, aFPar, aLPar);
if (!aC2d.IsNull()) {
// Treatment of infinite cases.
if (Precision::IsNegativeInfinite(aFPar)) {
if (Precision::IsPositiveInfinite(aLPar)) {
aFPar = -1.;
aLPar = 1.;
} else {
aFPar = aLPar - 1.;
}
} else if (Precision::IsPositiveInfinite(aLPar))
aLPar = aFPar + 1.;
// Treatment of infinite cases.
if (Precision::IsNegativeInfinite(aFPar)) {
if (Precision::IsPositiveInfinite(aLPar)) {
aFPar = -1.;
aLPar = 1.;
}
else {
aFPar = aLPar - 1.;
}
}
else if (Precision::IsPositiveInfinite(aLPar))
aLPar = aFPar + 1.;
for (; myCurEdgePar < Probing_End ;myCurEdgePar += Probing_Step) {
aParamIn = myCurEdgePar*aFPar + (1. - myCurEdgePar)*aLPar;
for (; myCurEdgePar < Probing_End; myCurEdgePar += Probing_Step) {
aParamIn = myCurEdgePar*aFPar + (1. - myCurEdgePar)*aLPar;
gp_Vec2d aTanVec;
aC2d->D1(aParamIn, aPOnC, aTanVec);
Par = aPOnC.SquareDistance(P);
aC2d->D1(aParamIn, aPOnC, aTanVec);
Par = aPOnC.SquareDistance(P);
if (Par > aTolParConf2) {
gp_Vec2d aLinVec(P, aPOnC);
gp_Dir2d aLinDir(aLinVec);
if (Par > aTolParConf2) {
gp_Vec2d aLinVec(P, aPOnC);
gp_Dir2d aLinDir(aLinVec);
Standard_Real aTanMod = aTanVec.SquareMagnitude();
if (aTanMod < aTolParConf2)
@@ -190,8 +193,10 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
aTanVec /= Sqrt(aTanMod);
Standard_Real aSinA = aTanVec.Crossed(aLinDir.XY());
const Standard_Real SmallAngle = 0.001;
Standard_Boolean isSmallAngle = Standard_False;
if (Abs(aSinA) < SmallAngle)
{
isSmallAngle = Standard_True;
// The line from the input point P to the current point on edge
// is tangent to the edge curve. This condition is bad for classification.
// Therefore try to go to another point in the hope that there will be
@@ -201,28 +206,66 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
continue;
}
L = gp_Lin2d(P, aLinDir);
L = gp_Lin2d(P, aLinDir);
// Check if ends of a curve lie on a line.
aC2d->D0(aFPar, aPOnC);
// Check if ends of a curve lie on a line.
aC2d->D0(aFPar, aPOnC);
gp_Pnt2d aFPOnC = aPOnC;
if (L.SquareDistance(aPOnC) > aTolParConf2) {
aC2d->D0(aLPar, aPOnC);
if (L.SquareDistance(aPOnC) > aTolParConf2) {
if (L.SquareDistance(aPOnC) > aTolParConf2) {
aC2d->D0(aLPar, aPOnC);
if (isSmallAngle)
{
//Try to find minimal distance between curve and line
if (L.SquareDistance(aPOnC) > aTolParConf2) {
myCurEdgePar += Probing_Step;
Geom2dAPI_ProjectPointOnCurve aProj;
aProj.Init(P, aC2d, aFPar, aLPar);
if (aProj.NbPoints() > 0)
{
gp_Pnt2d aLPOnC = aPOnC;
Standard_Real aFDist = P.SquareDistance(aFPOnC);
Standard_Real aLDist = P.SquareDistance(aLPOnC);
Standard_Real aMinDist = aProj.LowerDistance();
aMinDist *= aMinDist;
aPOnC = aProj.NearestPoint();
if (aMinDist > aFDist)
{
aMinDist = aFDist;
aPOnC = aFPOnC;
}
//
if (aMinDist > aLDist)
{
aMinDist = aLDist;
aPOnC = aLPOnC;
}
//
if (aMinDist < Par)
{
Par = aMinDist;
if (Par < aTolParConf2)
{
continue;
}
aLinVec.SetXY((aPOnC.XY() - P.XY()));
aLinDir.SetXY(aLinVec.XY());
L = gp_Lin2d(P, aLinDir);
}
}
}
myCurEdgePar += Probing_Step;
if (myCurEdgePar >= Probing_End) {
myCurEdgeInd++;
myCurEdgePar = Probing_Start;
}
if (myCurEdgePar >= Probing_End) {
myCurEdgeInd++;
myCurEdgePar = Probing_Start;
}
Par = Sqrt(Par);
return Standard_True;
}
}
}
}
Par = Sqrt(Par);
return Standard_True;
}
}
}
}
} // if (!aC2d.IsNull()) {
} // if (anOrientation == TopAbs_FORWARD ...
@@ -233,7 +276,7 @@ Standard_Boolean BRepClass_FaceExplorer::OtherSegment(const gp_Pnt2d& P,
// nothing found, return an horizontal line
Par = RealLast();
L = gp_Lin2d(P,gp_Dir2d(1,0));
L = gp_Lin2d(P, gp_Dir2d(1, 0));
return Standard_False;
}

View File

@@ -96,21 +96,21 @@ public:
protected:
//! Filter out correct adjacent mesh elements.
virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1,
const Standard_Integer theIndex2);
Standard_EXPORT virtual BRepExtrema_ElementFilter::FilterResult PreCheckElements (const Standard_Integer theIndex1,
const Standard_Integer theIndex2);
//! Checks if the given triangles have only single common vertex.
BRepExtrema_ElementFilter::FilterResult isRegularSharedVertex (const BVH_Vec3d& theSharedVert,
const BVH_Vec3d& theTrng1Vtxs1,
const BVH_Vec3d& theTrng1Vtxs2,
const BVH_Vec3d& theTrng2Vtxs1,
const BVH_Vec3d& theTrng2Vtxs2);
Standard_EXPORT BRepExtrema_ElementFilter::FilterResult isRegularSharedVertex (const BVH_Vec3d& theSharedVert,
const BVH_Vec3d& theTrng1Vtxs1,
const BVH_Vec3d& theTrng1Vtxs2,
const BVH_Vec3d& theTrng2Vtxs1,
const BVH_Vec3d& theTrng2Vtxs2);
//! Checks if the given triangles have only single common edge.
BRepExtrema_ElementFilter::FilterResult isRegularSharedEdge (const BVH_Vec3d& theTrng1Vtxs0,
const BVH_Vec3d& theTrng1Vtxs1,
const BVH_Vec3d& theTrng1Vtxs2,
const BVH_Vec3d& theTrng2Vtxs2);
Standard_EXPORT BRepExtrema_ElementFilter::FilterResult isRegularSharedEdge (const BVH_Vec3d& theTrng1Vtxs0,
const BVH_Vec3d& theTrng1Vtxs1,
const BVH_Vec3d& theTrng1Vtxs2,
const BVH_Vec3d& theTrng2Vtxs2);
private:

View File

@@ -676,7 +676,7 @@ Standard_OStream& BRepFeat::Print(const BRepFeat_StatusError se,
break;
case BRepFeat_EmptyCutResult :
s << "Failure in Cut : Empty resulting shape";
break;;
break;
case BRepFeat_FalseSide :
s << "Verify plane and wire orientation";
break;

View File

@@ -105,20 +105,15 @@ static Handle(Geom_BSplineCurve) EdgeToBSpline (const TopoDS_Edge& theEdge)
Handle(Geom_Curve) aCurve = BRep_Tool::Curve (theEdge, aLoc, aFirst, aLast);
// convert its part used by edge to bspline; note that if edge curve is bspline,
// conversion made via trimmed curve is still needed -- it will copy it, segment
// as appropriate, and remove periodicity if it is periodic (deadly for approximator)
// approximation or conversion made via trimmed curve is still needed -- it will copy it,
// segment as appropriate, and remove periodicity if it is periodic (deadly for approximator)
Handle(Geom_TrimmedCurve) aTrimCurve = new Geom_TrimmedCurve (aCurve, aFirst, aLast);
// special treatment of conic curve
if (aTrimCurve->BasisCurve()->IsKind(STANDARD_TYPE(Geom_Conic)))
{
const Handle(Geom_Curve)& aCurveTemp = aTrimCurve; // to avoid ambiguity
GeomConvert_ApproxCurve anAppr (aCurveTemp, Precision::Confusion(), GeomAbs_C1, 16, 14);
if (anAppr.HasResult())
aBSCurve = anAppr.Curve();
}
const Handle(Geom_Curve)& aCurveTemp = aTrimCurve; // to avoid ambiguity
GeomConvert_ApproxCurve anAppr (aCurveTemp, Precision::Confusion(), GeomAbs_C1, 16, 14);
if (anAppr.HasResult())
aBSCurve = anAppr.Curve();
// general case
if (aBSCurve.IsNull())
aBSCurve = GeomConvert::CurveToBSplineCurve (aTrimCurve);

View File

@@ -434,7 +434,7 @@ TopoDS_Face BRepFill_Pipe::Face(const TopoDS_Edge& ESpine,
TopoDS_Edge BRepFill_Pipe::Edge(const TopoDS_Edge& ESpine,
const TopoDS_Vertex& VProfile)
{
Standard_Integer ii, ispin = 0, iprof = 0, count = 0;;
Standard_Integer ii, ispin = 0, iprof = 0, count = 0;
// *************************************************
// Search if VProfile is a Vertex of myProfile

View File

@@ -1619,7 +1619,7 @@ static void UpdateEdge(TopoDS_Edge& E,
// Control direction & Range
Standard_Real R, First, Last, Tol=1.e-4;
Standard_Boolean reverse = Standard_False;;
Standard_Boolean reverse = Standard_False;
// Class BRep_Tool without fields and without Constructor :

View File

@@ -468,7 +468,7 @@ Standard_Boolean BRepLib_MakeFace::IsDegenerated(
else if (Type == GeomAbs_BezierCurve) {
Handle(Geom_BezierCurve) BZ = AC.Bezier();
Standard_Integer NbPoles = BZ->NbPoles();
Standard_Real aMaxPoleDist2 = 0.0, aMaxTol2 = theMaxTol*theMaxTol;;
Standard_Real aMaxPoleDist2 = 0.0, aMaxTol2 = theMaxTol*theMaxTol;
gp_Pnt P1,P2;
P1 = BZ->Pole(1);
for (Standard_Integer i = 2; i <= NbPoles; i++) {

View File

@@ -18,6 +18,7 @@
#include <GCPnts_AbscissaPoint.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAbs_IsoType.hxx>
#include <BRep_Tool.hxx>
//=======================================================================
// Function: Reset
@@ -125,9 +126,14 @@ void BRepMesh_DefaultRangeSplitter::computeTolerance(
const Standard_Real aDiffU = myRangeU.second - myRangeU.first;
const Standard_Real aDiffV = myRangeV.second - myRangeV.first;
const Standard_Real aTolerance = BRep_Tool::Tolerance (myDFace->GetFace());
const Adaptor3d_Surface& aSurface = GetSurface()->Surface();
const Standard_Real aResU = aSurface.UResolution (aTolerance);
const Standard_Real aResV = aSurface.VResolution (aTolerance);
const Standard_Real aDeflectionUV = 1.e-05;
myTolerance.first = Max(Min(aDeflectionUV, 0.1 * aDiffU), 1e-7 * aDiffU);
myTolerance.second = Max(Min(aDeflectionUV, 0.1 * aDiffV), 1e-7 * aDiffV);
myTolerance.first = Max(Min(aDeflectionUV, aResU), 1e-7 * aDiffU);
myTolerance.second = Max(Min(aDeflectionUV, aResV), 1e-7 * aDiffV);
}
//=======================================================================

View File

@@ -78,14 +78,10 @@ public:
protected:
//! Computes parametric tolerance taking length along U and V into account.
virtual void computeTolerance(
const Standard_Real theLenU,
const Standard_Real theLenV);
Standard_EXPORT virtual void computeTolerance (const Standard_Real theLenU, const Standard_Real theLenV);
//! Computes parametric delta taking length along U and V and value of tolerance into account.
virtual void computeDelta(
const Standard_Real theLengthU,
const Standard_Real theLengthV);
Standard_EXPORT virtual void computeDelta (const Standard_Real theLengthU, const Standard_Real theLengthV);
public:
//! Returns face model.

View File

@@ -145,18 +145,22 @@ void BRepMesh_Deflection::ComputeDeflection (
}
Standard_Real aFaceDeflection = 0.0;
if (theDFace->WiresNb () > 0)
if (!theParameters.ForceFaceDeflection)
{
for (Standard_Integer aWireIt = 0; aWireIt < theDFace->WiresNb(); ++aWireIt)
if (theDFace->WiresNb () > 0)
{
aFaceDeflection += theDFace->GetWire(aWireIt)->GetDeflection();
for (Standard_Integer aWireIt = 0; aWireIt < theDFace->WiresNb (); ++aWireIt)
{
aFaceDeflection += theDFace->GetWire (aWireIt)->GetDeflection ();
}
aFaceDeflection /= theDFace->WiresNb ();
}
aFaceDeflection /= theDFace->WiresNb ();
aFaceDeflection = Max (2. * BRepMesh_ShapeTool::MaxFaceTolerance (
theDFace->GetFace ()), aFaceDeflection);
}
aFaceDeflection = Max (aDeflection, aFaceDeflection);
aFaceDeflection = Max(aDeflection, aFaceDeflection);
theDFace->SetDeflection (Max(2.* BRepMesh_ShapeTool::MaxFaceTolerance(
theDFace->GetFace()), aFaceDeflection));
theDFace->SetDeflection (aFaceDeflection);
}

View File

@@ -610,7 +610,7 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
//=======================================================================
void BRepMesh_Delaun::insertInternalEdges()
{
Handle(IMeshData::MapOfInteger) anInternalEdges = InternalEdges();;
Handle(IMeshData::MapOfInteger) anInternalEdges = InternalEdges();
// Destruction of triancles intersecting internal edges
// and their replacement by makeshift triangles
@@ -2434,9 +2434,8 @@ BRepMesh_GeomTool::IntFlag BRepMesh_Delaun::intSegSeg(
p3 = GetVertex( theEdg2.FirstNode() ).Coord();
p4 = GetVertex( theEdg2.LastNode() ).Coord();
Standard_Real aIntParams[2];
return BRepMesh_GeomTool::IntSegSeg(p1, p2, p3, p4,
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt, aIntParams);
isConsiderEndPointTouch, isConsiderPointOnEdge, theIntPnt);
}
//=============================================================================

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -108,15 +108,18 @@ void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theCont
myStatus = IMeshData_NoError;
const Handle(IMeshData_Model)& aModel = theContext->GetModel();
for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
if (!aModel.IsNull())
{
const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);
myStatus |= aDFace->GetStatusMask();
for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt)
for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
{
const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt);
myStatus |= aDWire->GetStatusMask();
const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);
myStatus |= aDFace->GetStatusMask();
for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt)
{
const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt);
myStatus |= aDWire->GetStatusMask();
}
}
}

View File

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

View File

@@ -269,11 +269,17 @@ namespace
for (; aIntervalU <= theIntervals[0].Upper (); ++aIntervalU)
{
const Standard_Real aParamU = theIntervals[0].Value(aIntervalU);
if (Precision::IsInfinite (aParamU))
continue;
Standard_Integer aIntervalV = theIntervals[1].Lower ();
for (; aIntervalV <= theIntervals[1].Upper (); ++aIntervalV)
{
gp_Dir aNorm;
const Standard_Real aParamV = theIntervals[1].Value(aIntervalV);
if (Precision::IsInfinite (aParamV))
continue;
if (GeomLib::NormEstim (theSurf, gp_Pnt2d (aParamU, aParamV), Precision::Confusion (), aNorm) != 0)
{
return Standard_True;

View File

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

View File

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

View File

@@ -72,7 +72,7 @@ Standard_Real BRepMesh_ShapeTool::MaxFaceTolerance(const TopoDS_Face& theFace)
Standard_Real aMaxTolerance = BRep_Tool::Tolerance(theFace);
Standard_Real aTolerance = Max(
MaxTolerance<TopAbs_EDGE, EdgeTolerance >(theFace),
MaxTolerance<TopAbs_EDGE, EdgeTolerance >(theFace),
MaxTolerance<TopAbs_VERTEX, VertexTolerance>(theFace));
return Max(aMaxTolerance, aTolerance);

View File

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

View File

@@ -16,6 +16,8 @@
#include <Adaptor3d_Surface.hxx>
#include <BOPTools_AlgoTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
@@ -24,6 +26,7 @@
#include <BRepOffset_Interval.hxx>
#include <BRepOffset_ListIteratorOfListOfInterval.hxx>
#include <BRepOffset_Tool.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepTools.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
@@ -33,6 +36,7 @@
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <IntTools_Context.hxx>
#include <Precision.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
@@ -60,19 +64,17 @@ static void CorrectOrientationOfTangent(gp_Vec& TangVec,
//=======================================================================
BRepOffset_Analyse::BRepOffset_Analyse()
:myDone(Standard_False)
: myOffset (0.0), myDone (Standard_False)
{
}
//=======================================================================
//function : BRepOffset_Analyse
//purpose :
//=======================================================================
BRepOffset_Analyse::BRepOffset_Analyse(const TopoDS_Shape& S,
const Standard_Real Angle)
:myDone(Standard_False)
const Standard_Real Angle)
: myOffset (0.0), myDone (Standard_False)
{
Perform( S, Angle);
}
@@ -81,7 +83,6 @@ BRepOffset_Analyse::BRepOffset_Analyse(const TopoDS_Shape& S,
//function : EdgeAnlyse
//purpose :
//=======================================================================
static void EdgeAnalyse(const TopoDS_Edge& E,
const TopoDS_Face& F1,
const TopoDS_Face& F2,
@@ -117,7 +118,6 @@ static void EdgeAnalyse(const TopoDS_Edge& E,
//function : BuildAncestors
//purpose :
//=======================================================================
static void BuildAncestors (const TopoDS_Shape& S,
TopTools_IndexedDataMapOfShapeListOfShape& MA)
{
@@ -126,60 +126,58 @@ static void BuildAncestors (const TopoDS_Shape& S,
TopExp::MapShapesAndUniqueAncestors(S,TopAbs_EDGE ,TopAbs_FACE,MA);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepOffset_Analyse::IsDone() const
{
return myDone;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepOffset_Analyse::Perform (const TopoDS_Shape& S,
const Standard_Real Angle)
const Standard_Real Angle)
{
myShape = S;
myNewFaces .Clear();
myGenerated.Clear();
myReplacement.Clear();
myDescendants.Clear();
angle = Angle;
Standard_Real SinTol = Sin(Angle);
myAngle = Angle;
Standard_Real SinTol = Abs (Sin(Angle));
// Build ancestors.
BuildAncestors (S,ancestors);
BuildAncestors (S,myAncestors);
TopTools_ListOfShape aLETang;
TopExp_Explorer Exp(S.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
for ( ; Exp.More(); Exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(Exp.Current());
if (!mapEdgeType.IsBound(E)) {
if (!myMapEdgeType.IsBound(E)) {
BRepOffset_ListOfInterval LI;
mapEdgeType.Bind(E,LI);
myMapEdgeType.Bind(E,LI);
const TopTools_ListOfShape& L = Ancestors(E);
if ( L.IsEmpty())
continue;
continue;
if (L.Extent() == 2) {
const TopoDS_Face& F1 = TopoDS::Face(L.First());
const TopoDS_Face& F2 = TopoDS::Face(L.Last ());
EdgeAnalyse(E,F1,F2,SinTol,mapEdgeType(E));
const TopoDS_Face& F1 = TopoDS::Face (L.First());
const TopoDS_Face& F2 = TopoDS::Face (L.Last());
EdgeAnalyse (E, F1, F2, SinTol, myMapEdgeType (E));
// For tangent faces add artificial perpendicular face
// to close the gap between them (if they have different offset values)
if (myMapEdgeType(E).Last().Type() == ChFiDS_Tangential)
aLETang.Append (E);
}
else if (L.Extent() == 1) {
Standard_Real U1,U2;
const TopoDS_Face& F = TopoDS::Face(L.First());
BRep_Tool::Range(E,F,U1,U2);
BRepOffset_Interval Inter(U1,U2,ChFiDS_Other);
if (! BRepTools::IsReallyClosed(E,F)) {
Inter.Type(ChFiDS_FreeBound);
}
mapEdgeType(E).Append(Inter);
Standard_Real U1, U2;
const TopoDS_Face& F = TopoDS::Face (L.First());
BRep_Tool::Range (E, F, U1, U2);
BRepOffset_Interval Inter (U1, U2, ChFiDS_Other);
if (!BRepTools::IsReallyClosed (E, F)) {
Inter.Type (ChFiDS_FreeBound);
}
myMapEdgeType (E).Append (Inter);
}
else {
#ifdef OCCT_DEBUG
@@ -188,47 +186,472 @@ void BRepOffset_Analyse::Perform (const TopoDS_Shape& S,
}
}
}
TreatTangentFaces (aLETang);
myDone = Standard_True;
}
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
void BRepOffset_Analyse::TreatTangentFaces (const TopTools_ListOfShape& theLE)
{
if (theLE.IsEmpty() || myFaceOffsetMap.IsEmpty())
{
// Noting to do: either there are no tangent faces in the shape or
// the face offset map has not been provided
return;
}
// Select the edges which connect faces with different offset values
TopoDS_Compound aCETangent;
BRep_Builder().MakeCompound (aCETangent);
// Bind to each tangent edge a max offset value of its faces
TopTools_DataMapOfShapeReal anEdgeOffsetMap;
// Bind vertices of the tangent edges with connected edges
// of the face with smaller offset value
TopTools_DataMapOfShapeShape aDMVEMin;
for (TopTools_ListOfShape::Iterator it (theLE); it.More(); it.Next())
{
const TopoDS_Shape& aE = it.Value();
const TopTools_ListOfShape& aLA = Ancestors (aE);
const TopoDS_Shape& aF1 = aLA.First(), aF2 = aLA.Last();
const Standard_Real *pOffsetVal1 = myFaceOffsetMap.Seek (aF1);
const Standard_Real *pOffsetVal2 = myFaceOffsetMap.Seek (aF2);
const Standard_Real anOffsetVal1 = pOffsetVal1 ? Abs (*pOffsetVal1) : myOffset;
const Standard_Real anOffsetVal2 = pOffsetVal2 ? Abs (*pOffsetVal2) : myOffset;
if (anOffsetVal1 != anOffsetVal2)
{
BRep_Builder().Add (aCETangent, aE);
anEdgeOffsetMap.Bind (aE, Max (anOffsetVal1, anOffsetVal2));
const TopoDS_Shape& aFMin = anOffsetVal1 < anOffsetVal2 ? aF1 : aF2;
for (TopoDS_Iterator itV (aE); itV.More(); itV.Next())
{
const TopoDS_Shape& aV = itV.Value();
if (Ancestors (aV).Extent() == 3)
{
for (TopExp_Explorer expE (aFMin, TopAbs_EDGE); expE.More(); expE.Next())
{
const TopoDS_Shape& aEMin = expE.Current();
if (aEMin.IsSame (aE))
continue;
for (TopoDS_Iterator itV1 (aEMin); itV1.More(); itV1.Next())
{
const TopoDS_Shape& aVx = itV1.Value();
if (aV.IsSame (aVx))
aDMVEMin.Bind (aV, aEMin);
}
}
}
}
}
}
if (anEdgeOffsetMap.IsEmpty())
return;
// Create map of Face ancestors for the vertices on tangent edges
TopTools_DataMapOfShapeListOfShape aDMVFAnc;
for (TopTools_ListOfShape::Iterator itE (theLE); itE.More(); itE.Next())
{
const TopoDS_Shape& aE = itE.Value();
if (!anEdgeOffsetMap.IsBound (aE))
continue;
TopTools_MapOfShape aMFence;
{
const TopTools_ListOfShape& aLEA = Ancestors (aE);
for (TopTools_ListOfShape::Iterator itLEA (aLEA); itLEA.More(); itLEA.Next())
aMFence.Add (itLEA.Value());
}
for (TopoDS_Iterator itV (aE); itV.More(); itV.Next())
{
const TopoDS_Shape& aV = itV.Value();
TopTools_ListOfShape* pLFA = aDMVFAnc.Bound (aV, TopTools_ListOfShape());
const TopTools_ListOfShape& aLVA = Ancestors (aV);
for (TopTools_ListOfShape::Iterator itLVA (aLVA); itLVA.More(); itLVA.Next())
{
const TopoDS_Edge& aEA = TopoDS::Edge (itLVA.Value());
const BRepOffset_ListOfInterval* pIntervals = myMapEdgeType.Seek (aEA);
if (!pIntervals || pIntervals->IsEmpty())
continue;
if (pIntervals->First().Type() == ChFiDS_Tangential)
continue;
const TopTools_ListOfShape& aLEA = Ancestors (aEA);
for (TopTools_ListOfShape::Iterator itLEA (aLEA); itLEA.More(); itLEA.Next())
{
const TopoDS_Shape& aFA = itLEA.Value();
if (aMFence.Add (aFA))
pLFA->Append (aFA);
}
}
}
}
Handle(IntTools_Context) aCtx = new IntTools_Context();
// Tangency criteria
Standard_Real aSinTol = Abs (Sin (myAngle));
// Make blocks of connected edges
TopTools_ListOfListOfShape aLCB;
TopTools_IndexedDataMapOfShapeListOfShape aMVEMap;
BOPTools_AlgoTools::MakeConnexityBlocks (aCETangent, TopAbs_VERTEX, TopAbs_EDGE, aLCB, aMVEMap);
// Analyze each block to find co-planar edges
for (TopTools_ListOfListOfShape::Iterator itLCB (aLCB); itLCB.More(); itLCB.Next())
{
const TopTools_ListOfShape& aCB = itLCB.Value();
TopTools_MapOfShape aMFence;
for (TopTools_ListOfShape::Iterator itCB1 (aCB); itCB1.More(); itCB1.Next())
{
const TopoDS_Edge& aE1 = TopoDS::Edge (itCB1.Value());
if (!aMFence.Add (aE1))
continue;
TopoDS_Compound aBlock;
BRep_Builder().MakeCompound (aBlock);
BRep_Builder().Add (aBlock, aE1.Oriented (TopAbs_FORWARD));
Standard_Real anOffset = anEdgeOffsetMap.Find (aE1);
const TopTools_ListOfShape& aLF1 = Ancestors (aE1);
gp_Dir aDN1;
BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE1, TopoDS::Face (aLF1.First()), aDN1);
TopTools_ListOfShape::Iterator itCB2 = itCB1;
for (itCB2.Next(); itCB2.More(); itCB2.Next())
{
const TopoDS_Edge& aE2 = TopoDS::Edge (itCB2.Value());
if (aMFence.Contains (aE2))
continue;
const TopTools_ListOfShape& aLF2 = Ancestors (aE2);
gp_Dir aDN2;
BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE2, TopoDS::Face (aLF2.First()), aDN2);
if (aDN1.XYZ().Crossed (aDN2.XYZ()).Modulus() < aSinTol)
{
BRep_Builder().Add (aBlock, aE2.Oriented (TopAbs_FORWARD));
aMFence.Add (aE2);
anOffset = Max (anOffset, anEdgeOffsetMap.Find (aE2));
}
}
// Make the prism
BRepPrimAPI_MakePrism aMP (aBlock, gp_Vec (aDN1.XYZ()) * anOffset);
if (!aMP.IsDone())
continue;
TopTools_IndexedDataMapOfShapeListOfShape aPrismAncestors;
TopExp::MapShapesAndAncestors (aMP.Shape(), TopAbs_EDGE, TopAbs_FACE, aPrismAncestors);
TopExp::MapShapesAndAncestors (aMP.Shape(), TopAbs_VERTEX, TopAbs_EDGE, aPrismAncestors);
for (TopoDS_Iterator itE (aBlock); itE.More(); itE.Next())
{
const TopoDS_Edge& aE = TopoDS::Edge (itE.Value());
const TopTools_ListOfShape& aLG = aMP.Generated (aE);
TopoDS_Face aFNew = TopoDS::Face (aLG.First());
TopTools_ListOfShape& aLA = myAncestors.ChangeFromKey (aE);
TopoDS_Shape aF1 = aLA.First();
TopoDS_Shape aF2 = aLA.Last();
const Standard_Real *pOffsetVal1 = myFaceOffsetMap.Seek (aF1);
const Standard_Real *pOffsetVal2 = myFaceOffsetMap.Seek (aF2);
const Standard_Real anOffsetVal1 = pOffsetVal1 ? Abs (*pOffsetVal1) : myOffset;
const Standard_Real anOffsetVal2 = pOffsetVal2 ? Abs (*pOffsetVal2) : myOffset;
const TopoDS_Shape& aFToRemove = anOffsetVal1 > anOffsetVal2 ? aF1 : aF2;
const TopoDS_Shape& aFOpposite = anOffsetVal1 > anOffsetVal2 ? aF2 : aF1;
// Orient the face so its normal is directed to smaller offset face
{
// get normal of the new face
gp_Dir aDN;
BOPTools_AlgoTools3D::GetNormalToFaceOnEdge (aE, aFNew, aDN);
// get bi-normal for the aFOpposite
TopoDS_Edge aEInF;
for (TopExp_Explorer aExpE (aFOpposite, TopAbs_EDGE); aExpE.More(); aExpE.Next())
{
if (aE.IsSame (aExpE.Current()))
{
aEInF = TopoDS::Edge (aExpE.Current());
break;
}
}
gp_Pnt2d aP2d;
gp_Pnt aPInF;
Standard_Real f, l;
const Handle(Geom_Curve)& aC3D = BRep_Tool::Curve (aEInF, f, l);
gp_Pnt aPOnE = aC3D->Value ((f + l) / 2.);
BOPTools_AlgoTools3D::PointNearEdge (aEInF, TopoDS::Face (aFOpposite), (f + l) / 2., 1.e-5, aP2d, aPInF);
gp_Vec aBN (aPOnE, aPInF);
if (aBN.Dot (aDN) < 0)
aFNew.Reverse();
}
// Remove the face with bigger offset value from edge ancestors
for (TopTools_ListOfShape::Iterator itA (aLA); itA.More();itA.Next())
{
if (itA.Value().IsSame (aFToRemove))
{
aLA.Remove (itA);
break;
}
}
aLA.Append (aFNew);
myMapEdgeType (aE).Clear();
// Analyze edge again
EdgeAnalyse (aE, TopoDS::Face (aFOpposite), aFNew, aSinTol, myMapEdgeType (aE));
// Analyze vertices
TopTools_MapOfShape aFNewEdgeMap;
aFNewEdgeMap.Add (aE);
for (TopoDS_Iterator itV (aE); itV.More(); itV.Next())
{
const TopoDS_Shape& aV = itV.Value();
// Add Side edge to map of Ancestors with the correct orientation
TopoDS_Edge aEG = TopoDS::Edge (aMP.Generated (aV).First());
myGenerated.Bind (aV, aEG);
{
for (TopExp_Explorer anExpEg (aFNew, TopAbs_EDGE); anExpEg.More(); anExpEg.Next())
{
if (anExpEg.Current().IsSame (aEG))
{
aEG = TopoDS::Edge (anExpEg.Current());
break;
}
}
}
if (aDMVEMin.IsBound (aV))
{
const TopTools_ListOfShape* pSA = aDMVFAnc.Seek (aV);
if (pSA && pSA->Extent() == 1)
{
// Adjust orientation of generated edge to its new ancestor
TopoDS_Edge aEMin = TopoDS::Edge (aDMVEMin.Find (aV));
for (TopExp_Explorer expEx (pSA->First(), TopAbs_EDGE); expEx.More(); expEx.Next())
{
if (expEx.Current().IsSame (aEMin))
{
aEMin = TopoDS::Edge (expEx.Current());
break;
}
}
TopAbs_Orientation anOriInEMin (TopAbs_FORWARD), anOriInEG (TopAbs_FORWARD);
for (TopoDS_Iterator itx (aEMin); itx.More(); itx.Next())
{
if (itx.Value().IsSame (aV))
{
anOriInEMin = itx.Value().Orientation();
break;
}
}
for (TopoDS_Iterator itx (aEG); itx.More(); itx.Next())
{
if (itx.Value().IsSame (aV))
{
anOriInEG = itx.Value().Orientation();
break;
}
}
if (anOriInEG == anOriInEMin)
aEG.Reverse();
}
}
TopTools_ListOfShape& aLVA = myAncestors.ChangeFromKey (aV);
if (!aLVA.Contains (aEG))
aLVA.Append (aEG);
aFNewEdgeMap.Add (aEG);
TopTools_ListOfShape& aLEGA =
myAncestors (myAncestors.Add (aEG, aPrismAncestors.FindFromKey (aEG)));
{
// Add ancestors from the shape
const TopTools_ListOfShape* pSA = aDMVFAnc.Seek (aV);
if (pSA && !pSA->IsEmpty())
{
TopTools_ListOfShape aLSA = *pSA;
aLEGA.Append (aLSA);
}
}
myMapEdgeType.Bind (aEG, BRepOffset_ListOfInterval());
if (aLEGA.Extent() == 2)
{
EdgeAnalyse (aEG, TopoDS::Face (aLEGA.First()), TopoDS::Face (aLEGA.Last()),
aSinTol, myMapEdgeType (aEG));
}
}
// Find an edge opposite to tangential one and add ancestors for it
TopoDS_Edge aEOpposite;
for (TopExp_Explorer anExpE (aFNew, TopAbs_EDGE); anExpE.More(); anExpE.Next())
{
if (!aFNewEdgeMap.Contains (anExpE.Current()))
{
aEOpposite = TopoDS::Edge (anExpE.Current());
break;
}
}
{
// Find it in aFOpposite
for (TopExp_Explorer anExpE (aFToRemove, TopAbs_EDGE); anExpE.More(); anExpE.Next())
{
const TopoDS_Shape& aEInFToRem = anExpE.Current();
if (aE.IsSame (aEInFToRem))
{
if (BOPTools_AlgoTools::IsSplitToReverse (aEOpposite, aEInFToRem, aCtx))
aEOpposite.Reverse();
break;
}
}
}
TopTools_ListOfShape aLFOpposite;
aLFOpposite.Append (aFNew);
aLFOpposite.Append (aFToRemove);
myAncestors.Add (aEOpposite, aLFOpposite);
myMapEdgeType.Bind (aEOpposite, BRepOffset_ListOfInterval());
EdgeAnalyse (aEOpposite, aFNew, TopoDS::Face (aFToRemove), aSinTol, myMapEdgeType (aEOpposite));
TopTools_DataMapOfShapeShape* pEEMap = myReplacement.ChangeSeek (aFToRemove);
if (!pEEMap)
pEEMap = myReplacement.Bound (aFToRemove, TopTools_DataMapOfShapeShape());
pEEMap->Bind (aE, aEOpposite);
// Add ancestors for the vertices
for (TopoDS_Iterator itV (aEOpposite); itV.More(); itV.Next())
{
const TopoDS_Shape& aV = itV.Value();
const TopTools_ListOfShape& aLVA = aPrismAncestors.FindFromKey (aV);
myAncestors.Add (aV, aLVA);
}
myNewFaces.Append (aFNew);
myGenerated.Bind (aE, aFNew);
}
}
}
}
//=======================================================================
//function : EdgeReplacement
//purpose :
//=======================================================================
const TopoDS_Edge& BRepOffset_Analyse::EdgeReplacement (const TopoDS_Face& theF,
const TopoDS_Edge& theE) const
{
const TopTools_DataMapOfShapeShape* pEE = myReplacement.Seek (theF);
if (!pEE)
return theE;
const TopoDS_Shape* pE = pEE->Seek (theE);
if (!pE)
return theE;
return TopoDS::Edge (*pE);
}
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
TopoDS_Shape BRepOffset_Analyse::Generated (const TopoDS_Shape& theS) const
{
static TopoDS_Shape aNullShape;
const TopoDS_Shape* pGenS = myGenerated.Seek (theS);
return pGenS ? *pGenS : aNullShape;
}
//=======================================================================
//function : Descendants
//purpose :
//=======================================================================
const TopTools_ListOfShape* BRepOffset_Analyse::Descendants (const TopoDS_Shape& theS,
const Standard_Boolean theUpdate) const
{
if (myDescendants.IsEmpty() || theUpdate)
{
myDescendants.Clear();
const Standard_Integer aNbA = myAncestors.Extent();
for (Standard_Integer i = 1; i <= aNbA; ++i)
{
const TopoDS_Shape& aSS = myAncestors.FindKey (i);
const TopTools_ListOfShape& aLA = myAncestors (i);
for (TopTools_ListOfShape::Iterator it (aLA); it.More(); it.Next())
{
const TopoDS_Shape& aSA = it.Value();
TopTools_ListOfShape* pLD = myDescendants.ChangeSeek (aSA);
if (!pLD)
pLD = myDescendants.Bound (aSA, TopTools_ListOfShape());
if (!pLD->Contains (aSS))
pLD->Append (aSS);
}
}
}
return myDescendants.Seek (theS);
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void BRepOffset_Analyse::Clear()
{
myDone = Standard_False;
myShape .Nullify();
mapEdgeType.Clear();
ancestors .Clear();
myMapEdgeType.Clear();
myAncestors .Clear();
myFaceOffsetMap.Clear();
myReplacement.Clear();
myDescendants.Clear();
myNewFaces .Clear();
myGenerated.Clear();
}
//=======================================================================
//function : BRepOffset_ListOfInterval&
//purpose :
//=======================================================================
const BRepOffset_ListOfInterval& BRepOffset_Analyse::Type(const TopoDS_Edge& E)
const
const BRepOffset_ListOfInterval& BRepOffset_Analyse::Type(const TopoDS_Edge& E) const
{
return mapEdgeType (E);
return myMapEdgeType (E);
}
//=======================================================================
//function : Edges
//purpose :
//=======================================================================
void BRepOffset_Analyse::Edges(const TopoDS_Vertex& V,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& LE)
const
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& LE) const
{
LE.Clear();
const TopTools_ListOfShape& L = Ancestors (V);
@@ -236,15 +659,19 @@ const
for ( ;it.More(); it.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
TopoDS_Vertex V1,V2;
BRepOffset_Tool::EdgeVertices (E,V1,V2);
if (V1.IsSame(V)) {
if (mapEdgeType(E).Last().Type() == T)
LE.Append(E);
}
if (V2.IsSame(V)) {
if (mapEdgeType(E).First().Type() == T)
LE.Append(E);
const BRepOffset_ListOfInterval *pIntervals = myMapEdgeType.Seek (E);
if (pIntervals && pIntervals->Extent() > 0)
{
TopoDS_Vertex V1,V2;
BRepOffset_Tool::EdgeVertices (E,V1,V2);
if (V1.IsSame(V)) {
if (pIntervals->Last().Type() == T)
LE.Append (E);
}
if (V2.IsSame(V)) {
if (pIntervals->First().Type() == T)
LE.Append (E);
}
}
}
}
@@ -254,15 +681,13 @@ const
//function : Edges
//purpose :
//=======================================================================
void BRepOffset_Analyse::Edges(const TopoDS_Face& F,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& LE)
const
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& LE) const
{
LE.Clear();
TopExp_Explorer exp(F, TopAbs_EDGE);
for ( ;exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
@@ -278,14 +703,12 @@ const
//function : TangentEdges
//purpose :
//=======================================================================
void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge ,
const TopoDS_Vertex& Vertex,
TopTools_ListOfShape& Edges ) const
{
gp_Vec V,VRef;
Standard_Real U,URef;
BRepAdaptor_Curve C3d, C3dRef;
@@ -307,49 +730,23 @@ void BRepOffset_Analyse::TangentEdges(const TopoDS_Edge& Edge ,
V = C3d.DN(U,1);
CorrectOrientationOfTangent(V, Vertex, CurE);
if (V.SquareMagnitude() < gp::Resolution()) continue;
if (V.IsOpposite(VRef,angle)) {
if (V.IsOpposite(VRef,myAngle)) {
Edges.Append(CurE);
}
}
}
//=======================================================================
//function : HasAncestor
//purpose :
//=======================================================================
Standard_Boolean BRepOffset_Analyse::HasAncestor (const TopoDS_Shape& S) const
{
return ancestors.Contains(S);
}
//=======================================================================
//function : Ancestors
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepOffset_Analyse::Ancestors
(const TopoDS_Shape& S) const
{
return ancestors.FindFromKey(S);
}
//=======================================================================
//function : Explode
//purpose :
//=======================================================================
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T ) const
void BRepOffset_Analyse::Explode (TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T) const
{
List.Clear();
BRep_Builder B;
TopTools_MapOfShape Map;
TopExp_Explorer Fexp;
for (Fexp.Init(myShape,TopAbs_FACE); Fexp.More(); Fexp.Next()) {
if ( Map.Add(Fexp.Current())) {
@@ -369,10 +766,9 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
//function : Explode
//purpose :
//=======================================================================
void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
void BRepOffset_Analyse::Explode (TopTools_ListOfShape& List,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
{
List.Clear();
BRep_Builder B;
@@ -393,67 +789,70 @@ void BRepOffset_Analyse::Explode( TopTools_ListOfShape& List,
}
}
//=======================================================================
//function : AddFaces
//purpose :
//=======================================================================
void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T) const
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T) const
{
BRep_Builder B;
TopExp_Explorer exp(Face,TopAbs_EDGE);
for ( ; exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
const TopTools_ListOfShape *pLE = Descendants (Face);
if (!pLE)
return;
for (TopTools_ListOfShape::Iterator it (*pLE); it.More(); it.Next())
{
const TopoDS_Edge& E = TopoDS::Edge (it.Value());
const BRepOffset_ListOfInterval& LI = Type(E);
if (!LI.IsEmpty() && LI.First().Type() == T) {
// so <NewFace> is attached to G1 by <Face>
const TopTools_ListOfShape& L = Ancestors(E);
if (L.Extent() == 2) {
TopoDS_Face F1 = TopoDS::Face(L.First());
if ( F1.IsSame(Face))
F1 = TopoDS::Face(L.Last ());
if ( Map.Add(F1)) {
B.Add(Co,F1);
AddFaces(F1,Co,Map,T);
}
TopoDS_Face F1 = TopoDS::Face (L.First());
if (F1.IsSame (Face))
F1 = TopoDS::Face (L.Last());
if (Map.Add (F1)) {
B.Add (Co, F1);
AddFaces (F1, Co, Map, T);
}
}
}
}
}
//=======================================================================
//function : AddFaces
//purpose :
//=======================================================================
void BRepOffset_Analyse::AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity T1,
const ChFiDS_TypeOfConcavity T2) const
{
BRep_Builder B;
TopExp_Explorer exp(Face,TopAbs_EDGE);
for ( ; exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
const TopTools_ListOfShape *pLE = Descendants (Face);
if (!pLE)
return;
for (TopTools_ListOfShape::Iterator it (*pLE); it.More(); it.Next())
{
const TopoDS_Edge& E = TopoDS::Edge (it.Value());
const BRepOffset_ListOfInterval& LI = Type(E);
if (!LI.IsEmpty() &&
(LI.First().Type() == T1 || LI.First().Type() == T2)) {
(LI.First().Type() == T1 || LI.First().Type() == T2)) {
// so <NewFace> is attached to G1 by <Face>
const TopTools_ListOfShape& L = Ancestors(E);
if (L.Extent() == 2) {
TopoDS_Face F1 = TopoDS::Face(L.First());
if ( F1.IsSame(Face))
F1 = TopoDS::Face(L.Last ());
if ( Map.Add(F1)) {
B.Add(Co,F1);
AddFaces(F1,Co,Map,T1,T2);
}
TopoDS_Face F1 = TopoDS::Face (L.First());
if (F1.IsSame (Face))
F1 = TopoDS::Face (L.Last());
if (Map.Add (F1)) {
B.Add (Co, F1);
AddFaces (F1, Co, Map, T1, T2);
}
}
}
}
}

View File

@@ -28,6 +28,9 @@
#include <Standard_Real.hxx>
#include <BRepOffset_ListOfInterval.hxx>
#include <ChFiDS_TypeOfConcavity.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeReal.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
class TopoDS_Shape;
@@ -36,102 +39,164 @@ class TopoDS_Vertex;
class TopoDS_Face;
class TopoDS_Compound;
//! Analyse of a shape consit to
//! Find the part of edges convex concave tangent.
//! Analyses the shape to find the parts of edges
//! connecting the convex, concave or tangent faces.
class BRepOffset_Analyse
{
public:
DEFINE_STANDARD_ALLOC
public: //! @name Constructors
//! Empty c-tor
Standard_EXPORT BRepOffset_Analyse();
//! C-tor performing the job inside
Standard_EXPORT BRepOffset_Analyse (const TopoDS_Shape& theS,
const Standard_Real theAngle);
Standard_EXPORT BRepOffset_Analyse(const TopoDS_Shape& S, const Standard_Real Angle);
Standard_EXPORT void Perform (const TopoDS_Shape& S, const Standard_Real Angle);
Standard_EXPORT Standard_Boolean IsDone() const;
Standard_EXPORT void Clear();
Standard_EXPORT const BRepOffset_ListOfInterval& Type (const TopoDS_Edge& E) const;
public: //! @name Performing analysis
//! Performs the analysis
Standard_EXPORT void Perform (const TopoDS_Shape& theS,
const Standard_Real theAngle);
public: //! @name Results
//! Returns status of the algorithm
Standard_Boolean IsDone() const
{
return myDone;
}
//! Returns the connectivity type of the edge
Standard_EXPORT const BRepOffset_ListOfInterval& Type (const TopoDS_Edge& theE) const;
//! Stores in <L> all the edges of Type <T>
//! on the vertex <V>.
Standard_EXPORT void Edges (const TopoDS_Vertex& V,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& L) const;
Standard_EXPORT void Edges (const TopoDS_Vertex& theV,
const ChFiDS_TypeOfConcavity theType,
TopTools_ListOfShape& theL) const;
//! Stores in <L> all the edges of Type <T>
//! on the face <F>.
Standard_EXPORT void Edges (const TopoDS_Face& F,
const ChFiDS_TypeOfConcavity T,
TopTools_ListOfShape& L) const;
Standard_EXPORT void Edges (const TopoDS_Face& theF,
const ChFiDS_TypeOfConcavity theType,
TopTools_ListOfShape& theL) const;
//! set in <Edges> all the Edges of <Shape> which are
//! tangent to <Edge> at the vertex <Vertex>.
Standard_EXPORT void TangentEdges (const TopoDS_Edge& Edge,
const TopoDS_Vertex& Vertex,
TopTools_ListOfShape& Edges) const;
Standard_EXPORT Standard_Boolean HasAncestor (const TopoDS_Shape& S) const;
Standard_EXPORT const TopTools_ListOfShape& Ancestors (const TopoDS_Shape& S) const;
Standard_EXPORT void TangentEdges (const TopoDS_Edge& theEdge,
const TopoDS_Vertex& theVertex,
TopTools_ListOfShape& theEdges) const;
//! Checks if the given shape has ancestors
Standard_Boolean HasAncestor (const TopoDS_Shape& theS) const
{
return myAncestors.Contains (theS);
}
//! Returns ancestors for the shape
const TopTools_ListOfShape& Ancestors (const TopoDS_Shape& theS) const
{
return myAncestors.FindFromKey (theS);
}
//! Explode in compounds of faces where
//! all the connex edges are of type <Side>
Standard_EXPORT void Explode (TopTools_ListOfShape& L,
const ChFiDS_TypeOfConcavity Type) const;
Standard_EXPORT void Explode (TopTools_ListOfShape& theL,
const ChFiDS_TypeOfConcavity theType) const;
//! Explode in compounds of faces where
//! all the connex edges are of type <Side1> or <Side2>
Standard_EXPORT void Explode (TopTools_ListOfShape& L,
const ChFiDS_TypeOfConcavity Type1,
const ChFiDS_TypeOfConcavity Type2) const;
Standard_EXPORT void Explode (TopTools_ListOfShape& theL,
const ChFiDS_TypeOfConcavity theType1,
const ChFiDS_TypeOfConcavity theType2) const;
//! Add in <CO> the faces of the shell containing <Face>
//! where all the connex edges are of type <Side>.
Standard_EXPORT void AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity Type) const;
Standard_EXPORT void AddFaces (const TopoDS_Face& theFace,
TopoDS_Compound& theCo,
TopTools_MapOfShape& theMap,
const ChFiDS_TypeOfConcavity theType) const;
//! Add in <CO> the faces of the shell containing <Face>
//! where all the connex edges are of type <Side1> or <Side2>.
Standard_EXPORT void AddFaces (const TopoDS_Face& Face,
TopoDS_Compound& Co,
TopTools_MapOfShape& Map,
const ChFiDS_TypeOfConcavity Type1,
const ChFiDS_TypeOfConcavity Type2) const;
Standard_EXPORT void AddFaces (const TopoDS_Face& theFace,
TopoDS_Compound& theCo,
TopTools_MapOfShape& theMap,
const ChFiDS_TypeOfConcavity theType1,
const ChFiDS_TypeOfConcavity theType2) const;
void SetOffsetValue (const Standard_Real theOffset)
{
myOffset = theOffset;
}
//! Sets the face-offset data map to analyze tangential cases
void SetFaceOffsetMap (const TopTools_DataMapOfShapeReal& theMap)
{
myFaceOffsetMap = theMap;
}
//! Returns the new faces constructed between tangent faces
//! having different offset values on the shape
const TopTools_ListOfShape& NewFaces() const { return myNewFaces; }
protected:
//! Returns the new face constructed for the edge connecting
//! the two tangent faces having different offset values
Standard_EXPORT TopoDS_Shape Generated (const TopoDS_Shape& theS) const;
//! Checks if the edge has generated a new face.
Standard_Boolean HasGenerated (const TopoDS_Shape& theS) const
{
return myGenerated.Seek (theS) != NULL;
}
//! Returns the replacement of the edge in the face.
//! If no replacement exists, returns the edge
Standard_EXPORT const TopoDS_Edge& EdgeReplacement (const TopoDS_Face& theFace,
const TopoDS_Edge& theEdge) const;
//! Returns the shape descendants.
Standard_EXPORT const TopTools_ListOfShape* Descendants (const TopoDS_Shape& theS,
const Standard_Boolean theUpdate = Standard_False) const;
public: //! @name Clearing the content
private:
//! Clears the content of the algorithm
Standard_EXPORT void Clear();
private: //! @name Treatment of tangential cases
//! Treatment of the tangential cases.
//! @param theEdges List of edges connecting tangent faces
Standard_EXPORT void TreatTangentFaces (const TopTools_ListOfShape& theEdges);
Standard_Boolean myDone;
TopoDS_Shape myShape;
BRepOffset_DataMapOfShapeListOfInterval mapEdgeType;
TopTools_IndexedDataMapOfShapeListOfShape ancestors;
Standard_Real angle;
private: //! @name Fields
// Inputs
TopoDS_Shape myShape; //!< Input shape to analyze
Standard_Real myAngle; //!< Criteria angle to check tangency
Standard_Real myOffset; //!< Offset value
TopTools_DataMapOfShapeReal myFaceOffsetMap; //!< Map to store offset values for the faces.
//! Should be set by the calling algorithm.
// Results
Standard_Boolean myDone; //!< Status of the algorithm
BRepOffset_DataMapOfShapeListOfInterval myMapEdgeType; //!< Map containing the list of intervals on the edge
TopTools_IndexedDataMapOfShapeListOfShape myAncestors; //!< Ancestors map
NCollection_DataMap<TopoDS_Shape,
TopTools_DataMapOfShapeShape,
TopTools_ShapeMapHasher> myReplacement; //!< Replacement of an edge in the face
mutable TopTools_DataMapOfShapeListOfShape myDescendants; //!< Map of shapes descendants built on the base of
//!< Ancestors map. Filled on the first query.
TopTools_ListOfShape myNewFaces; //!< New faces generated to close the gaps between adjacent
//! tangential faces having different offset values
TopTools_DataMapOfShapeShape myGenerated; //!< Binding between edge and face generated from the edge
};
#endif // _BRepOffset_Analyse_HeaderFile

View File

@@ -34,6 +34,7 @@
#include <BRepAlgo_AsDes.hxx>
#include <BRepLib.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <BRepOffset_Analyse.hxx>
#include <BRepOffset_Inter2d.hxx>
#include <BRepOffset_Offset.hxx>
#include <BRepOffset_Tool.hxx>
@@ -1451,6 +1452,7 @@ void BRepOffset_Inter2d::ConnexIntByInt
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Offset,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedMapOfShape& FacesWithVerts,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
@@ -1523,6 +1525,9 @@ void BRepOffset_Inter2d::ConnexIntByInt
TopoDS_Vertex Vref = CommonVertex(CurE, NextE);
gp_Pnt Pref = BRep_Tool::Pnt(Vref);
CurE = Analyse.EdgeReplacement (FI, CurE);
NextE = Analyse.EdgeReplacement (FI, NextE);
TopoDS_Shape aLocalShape = OFI.Generated(CurE);
TopoDS_Edge CEO = TopoDS::Edge(aLocalShape);
aLocalShape = OFI.Generated(NextE);
@@ -1582,18 +1587,20 @@ void BRepOffset_Inter2d::ConnexIntByInt
}
}
else {
if (MES.IsBound(CEO)) {
TopoDS_Vertex V = CommonVertex(CEO,NEO);
UpdateVertex (V,CEO,TopoDS::Edge(MES(CEO)),Tol);
AsDes2d->Add (MES(CEO),V);
}
else if (MES.IsBound(NEO)) {
TopoDS_Vertex V = CommonVertex(CEO,NEO);
UpdateVertex (V,NEO,TopoDS::Edge(MES(NEO)),Tol);
AsDes2d->Add (MES(NEO),V);
TopoDS_Vertex V = CommonVertex(CEO,NEO);
if (!V.IsNull())
{
if (MES.IsBound(CEO)) {
UpdateVertex (V,CEO,TopoDS::Edge(MES(CEO)),Tol);
AsDes2d->Add (MES(CEO),V);
}
if (MES.IsBound(NEO)) {
UpdateVertex (V,NEO,TopoDS::Edge(MES(NEO)),Tol);
AsDes2d->Add (MES(NEO),V);
}
}
}
CurE = NextE;
CurE = wexp.Current();
ToReverse1 = ToReverse2;
}
}
@@ -1611,6 +1618,7 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
const Handle(BRepAlgo_AsDes)& AsDes,
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV)
{
TopoDS_Face FIO = TopoDS::Face(OFI.Face());
@@ -1657,7 +1665,10 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
CurE = NextE;
continue;
}
//
CurE = Analyse.EdgeReplacement (FI, CurE);
NextE = Analyse.EdgeReplacement (FI, NextE);
TopoDS_Shape aLocalShape = OFI.Generated(CurE);
TopoDS_Edge CEO = TopoDS::Edge(aLocalShape);
aLocalShape = OFI.Generated(NextE);
@@ -1678,7 +1689,7 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
NE2 = MES(CEO);
}
else {
CurE = NextE;
CurE = wexp.Current();
continue;
}
//
@@ -1731,7 +1742,7 @@ void BRepOffset_Inter2d::ConnexIntByIntInVert
}
}
}
CurE = NextE;
CurE = wexp.Current();
}
}
}

View File

@@ -27,6 +27,7 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
class BRepAlgo_AsDes;
class TopoDS_Face;
class BRepOffset_Analyse;
class BRepOffset_Offset;
@@ -63,6 +64,7 @@ public:
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Offset,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedMapOfShape& FacesWithVerts,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV);
@@ -79,6 +81,7 @@ public:
const Handle(BRepAlgo_AsDes)& AsDes,
const Handle(BRepAlgo_AsDes)& AsDes2d,
const Standard_Real Tol,
const BRepOffset_Analyse& Analyse,
TopTools_IndexedDataMapOfShapeListOfShape& theDMVV);
//! Fuses the chains of vertices in the theDMVV

View File

@@ -296,7 +296,7 @@ void BRepOffset_Inter3d::ConnexIntByArc(const TopTools_ListOfShape& /*SetOfFaces
//---------------------------
// E1 generated a tube.
//---------------------------
F1 = TopoDS::Face(InitOffsetFace.Image(E1).First());;
F1 = TopoDS::Face(InitOffsetFace.Image(E1).First());
TopExp::Vertices(E1,V[0],V[1]);
const TopTools_ListOfShape& AncE1 = Analyse.Ancestors(E1);
@@ -399,88 +399,148 @@ void BRepOffset_Inter3d::ConnexIntByInt
TopTools_ListOfShape& Failed,
const Standard_Boolean bIsPlanar)
{
//TopExp_Explorer Exp(SI,TopAbs_EDGE);
TopTools_IndexedMapOfShape VEmap;
TopTools_IndexedDataMapOfShapeListOfShape aMVF;
TopoDS_Face F1,F2,OF1,OF2,NF1,NF2;
TopAbs_State CurSide = mySide;
BRep_Builder B;
Standard_Boolean bEdge;
Standard_Integer i, aNb;
Standard_Integer i, aNb = 0;
TopTools_ListIteratorOfListOfShape it, it1, itF1, itF2;
//
TopExp::MapShapes(SI, TopAbs_EDGE , VEmap);
// map the shape for vertices
if (bIsPlanar) {
TopExp::MapShapes (SI, TopAbs_EDGE, VEmap);
// Take the vertices for treatment
if (bIsPlanar)
{
aNb = VEmap.Extent();
for (i = 1; i <= aNb; ++i)
{
const TopoDS_Edge& aE = TopoDS::Edge (VEmap (i));
TopoDS_Shape aFGen = Analyse.Generated (aE);
if (!aFGen.IsNull())
TopExp::MapShapes (aFGen, TopAbs_EDGE, VEmap);
}
// Add vertices for treatment
TopExp::MapShapes(SI, TopAbs_VERTEX, VEmap);
//
// make vertex-faces connexity map with unique ancestors
TopExp::MapShapesAndUniqueAncestors(SI, TopAbs_VERTEX, TopAbs_FACE, aMVF);
for (TopTools_ListOfShape::Iterator itNF (Analyse.NewFaces()); itNF.More(); itNF.Next())
TopExp::MapShapes (itNF.Value(), TopAbs_VERTEX, VEmap);
}
//
TopTools_DataMapOfShapeListOfShape aDMVLF1, aDMVLF2, aDMIntFF;
TopTools_IndexedDataMapOfShapeListOfShape aDMIntE;
//
if (bIsPlanar) {
aNb = VEmap.Extent();
for (i = 1; i <= aNb; ++i) {
if (bIsPlanar)
{
// Find internal edges in the faces to skip them while preparing faces
// for intersection through vertices
NCollection_DataMap<TopoDS_Shape, TopTools_MapOfShape, TopTools_ShapeMapHasher> aDMFEI;
{
for (TopExp_Explorer expF (SI, TopAbs_FACE); expF.More(); expF.Next())
{
const TopoDS_Shape& aFx = expF.Current();
TopTools_MapOfShape aMEI;
for (TopExp_Explorer expE (aFx, TopAbs_EDGE); expE.More(); expE.Next())
{
const TopoDS_Shape& aEx = expE.Current();
if (aEx.Orientation() != TopAbs_FORWARD &&
aEx.Orientation() != TopAbs_REVERSED)
aMEI.Add (aEx);
}
if (!aMEI.IsEmpty())
aDMFEI.Bind (aFx, aMEI);
}
}
// Analyze faces connected through vertices
for (i = aNb + 1, aNb = VEmap.Extent(); i <= aNb; ++i)
{
const TopoDS_Shape& aS = VEmap(i);
if (aS.ShapeType() != TopAbs_VERTEX) {
if (aS.ShapeType() != TopAbs_VERTEX)
continue;
// Find faces connected to the vertex
TopTools_ListOfShape aLF;
{
const TopTools_ListOfShape& aLE = Analyse.Ancestors (aS);
for (TopTools_ListOfShape::Iterator itLE (aLE); itLE.More(); itLE.Next())
{
const TopTools_ListOfShape& aLEA = Analyse.Ancestors (itLE.Value());
for (TopTools_ListOfShape::Iterator itLEA (aLEA); itLEA.More(); itLEA.Next())
{
if (!aLF.Contains (itLEA.Value()))
aLF.Append (itLEA.Value());
}
}
}
//
// faces connected by the vertex
const TopTools_ListOfShape& aLF = aMVF.FindFromKey(aS);
if (aLF.Extent() < 2) {
if (aLF.Extent() < 2)
continue;
}
// build lists of faces connected to the same vertex by looking for
// the pairs in which the vertex is alone (not connected to shared edges)
TopTools_ListOfShape aLF1, aLF2;
//
it.Initialize(aLF);
for (; it.More(); it.Next()) {
for (; it.More(); it.Next())
{
const TopoDS_Shape& aFV1 = it.Value();
//
// get edges of first face connected to current vertex
TopTools_MapOfShape aME;
TopExp_Explorer aExp(aFV1, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE = aExp.Current();
if (aE.Orientation() != TopAbs_FORWARD &&
aE.Orientation() != TopAbs_REVERSED)
// Face is connected to the vertex through internal edge
const TopTools_MapOfShape *pF1Internal = aDMFEI.Seek (aFV1);
const TopTools_ListOfShape* pLE1 = Analyse.Descendants (aFV1);
if (!pLE1)
continue;
TopTools_ListOfShape::Iterator itLE1 (*pLE1);
for (; itLE1.More(); itLE1.Next())
{
const TopoDS_Shape& aE = itLE1.Value();
if (pF1Internal && pF1Internal->Contains (aE))
break;
TopoDS_Iterator aItV(aE);
for (; aItV.More(); aItV.Next()) {
if (aS.IsSame(aItV.Value())) {
for (TopoDS_Iterator aItV(aE); aItV.More(); aItV.Next())
{
if (aS.IsSame (aItV.Value()))
{
aME.Add(aE);
break;
}
}
}
if (aExp.More())
if (itLE1.More())
continue;
// get to the next face in the list
it1 = it;
for (it1.Next(); it1.More(); it1.Next()) {
const TopoDS_Shape& aFV2 = it1.Value();
//
aExp.Init(aFV2, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aEV2 = aExp.Current();
if (aME.Contains(aEV2) &&
(Analyse.Ancestors(aEV2).Extent() == 2 || // Multi-connexity is not supported in Analyzer
(aEV2.Orientation() != TopAbs_FORWARD && // Avoid intersection of faces connected by internal edge
aEV2.Orientation() != TopAbs_REVERSED))) {
const TopoDS_Face& aFV2 = TopoDS::Face (it1.Value());
const TopTools_MapOfShape *pF2Internal = aDMFEI.Seek (aFV2);
const TopTools_ListOfShape* pLE2 = Analyse.Descendants (aFV2);
if (!pLE2)
continue;
TopTools_ListOfShape::Iterator itLE2 (*pLE2);
for (; itLE2.More(); itLE2.Next())
{
const TopoDS_Shape& aEV2 = itLE2.Value();
if (!aME.Contains (aEV2))
continue;
if (pF2Internal && pF2Internal->Contains (aEV2))
// Avoid intersection of faces connected by internal edge
break;
if (Analyse.HasAncestor (aEV2) &&
Analyse.Ancestors (aEV2).Extent() == 2)
// Faces will be intersected through the edge
break;
}
}
//
if (!aExp.More()) {
// faces share only vertex - make pair for intersection
if (!itLE2.More())
{
aLF1.Append(aFV1);
aLF2.Append(aFV2);
}

View File

@@ -245,7 +245,7 @@ static void DEBVerticesControl (const TopTools_IndexedMapOfShape& NewEdges,
// static methods
//=======================================================================
static
void GetEnlargedFaces(const TopoDS_Shape& theShape,
void GetEnlargedFaces(const TopTools_ListOfShape& theFaces,
const BRepOffset_DataMapOfShapeOffset& theMapSF,
const TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theFacesOrigins,
@@ -292,6 +292,7 @@ static
static
void TrimEdges(const TopoDS_Shape& theShape,
const Standard_Real theOffset,
const BRepOffset_Analyse& Analyse,
BRepOffset_DataMapOfShapeOffset& theMapSF,
TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theBuild,
@@ -648,6 +649,8 @@ void BRepOffset_MakeOffset::Clear()
myFaceOffset .Clear();
myAsDes ->Clear();
myDone = Standard_False;
myGenerated.Clear();
myResMap.Clear();
}
//=======================================================================
@@ -805,6 +808,11 @@ void BRepOffset_MakeOffset::MakeOffsetShape()
// There are possible second variant: analytical continuation of arcsin.
Standard_Real TolAngleCoeff = Min(myTol / (Abs(myOffset * 0.5) + Precision::Confusion()), 1.0);
Standard_Real TolAngle = 4*ASin(TolAngleCoeff);
if ((myJoin == GeomAbs_Intersection) && myInter && myIsPlanar)
{
myAnalyse.SetOffsetValue (myOffset);
myAnalyse.SetFaceOffsetMap (myFaceOffset);
}
myAnalyse.Perform(myShape,TolAngle);
//---------------------------------------------------
// Construction of Offset from preanalysis.
@@ -870,6 +878,10 @@ void BRepOffset_MakeOffset::MakeOffsetShape()
// Coding of regularities.
//----------------------------------
EncodeRegularity();
//----------------------------------
// Replace roots in history maps
//----------------------------------
ReplaceRoots();
//----------------------
// Creation of solids.
//----------------------
@@ -1054,7 +1066,7 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the
TopTools_ListIteratorOfListOfShape itl(Let);
for (; itl.More(); itl.Next()) {
const TopoDS_Edge& Cur = TopoDS::Edge(itl.Value());
if ( !ShapeTgt.IsBound(Cur)) {
if ( !ShapeTgt.IsBound(Cur) && !myAnalyse.HasGenerated (Cur)) {
TopoDS_Shape aLocalShape = OF.Generated(Cur);
const TopoDS_Edge& OTE = TopoDS::Edge(aLocalShape);
ShapeTgt.Bind(Cur,OF.Generated(Cur));
@@ -1079,6 +1091,14 @@ void BRepOffset_MakeOffset::MakeOffsetFaces(BRepOffset_DataMapOfShapeOffset& the
}
theMapSF.Bind(aF,OF);
}
//
const TopTools_ListOfShape& aNewFaces = myAnalyse.NewFaces();
for (TopTools_ListOfShape::Iterator it (aNewFaces); it.More(); it.Next())
{
const TopoDS_Face& aF = TopoDS::Face (it.Value());
BRepOffset_Offset OF(aF, 0.0, ShapeTgt, OffsetOutside, myJoin);
theMapSF.Bind (aF, OF);
}
}
//=======================================================================
@@ -1126,12 +1146,18 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
// Intersection with caps.
Inter3.ContextIntByInt(myFaces,ExtentContext,MapSF,myAnalyse,MES,Build,Failed,myIsPlanar);
TopTools_ListOfShape aLFaces;
for (Exp.Init(myShape,TopAbs_FACE) ; Exp.More(); Exp.Next())
aLFaces.Append (Exp.Current());
for (TopTools_ListOfShape::Iterator it (myAnalyse.NewFaces()); it.More(); it.Next())
aLFaces.Append (it.Value());
//---------------------------------------------------------------------------------
// Extension of neighbor edges of new edges and intersection between neighbors.
//--------------------------------------------------------------------------------
Handle(BRepAlgo_AsDes) AsDes2d = new BRepAlgo_AsDes();
IntersectEdges(myShape, MapSF, MES, Build, AsDes, AsDes2d);
IntersectEdges(aLFaces, MapSF, MES, Build, AsDes, AsDes2d);
//-----------------------------------------------------------
// Great restriction of new edges and update of AsDes.
//------------------------------------------ ----------------
@@ -1142,7 +1168,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
//Map of edges obtained after FACE-FACE (offsetted) intersection.
//Key1 is edge trimmed by intersection points with other edges;
//Item is not-trimmed edge.
TrimEdges(myShape, myOffset, MapSF, MES, Build, AsDes, AsDes2d, NewEdges, aETrimEInf, anEdgesOrigins);
TrimEdges(myShape, myOffset, myAnalyse, MapSF, MES, Build, AsDes, AsDes2d, NewEdges, aETrimEInf, anEdgesOrigins);
//
//---------------------------------
// Intersection 2D on //
@@ -1151,7 +1177,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
TopTools_DataMapOfShapeShape aFacesOrigins; // offset face - initial face
TopTools_ListOfShape LFE;
BRepAlgo_Image IMOE;
GetEnlargedFaces(myShape, MapSF, MES, aFacesOrigins, IMOE, LFE);
GetEnlargedFaces(aLFaces, MapSF, MES, aFacesOrigins, IMOE, LFE);
//
TopTools_ListIteratorOfListOfShape itLFE(LFE);
for (; itLFE.More(); itLFE.Next())
@@ -1179,7 +1205,7 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
TopTools_MapOfShape aMFDone;
//
if ((myJoin == GeomAbs_Intersection) && myInter && myIsPlanar) {
BuildSplitsOfExtendedFaces(LFE, AsDes, anEdgesOrigins, aFacesOrigins, aETrimEInf, IMOE);
BuildSplitsOfExtendedFaces(LFE, myAnalyse, AsDes, anEdgesOrigins, aFacesOrigins, aETrimEInf, IMOE);
//
TopTools_ListIteratorOfListOfShape aItLF(LFE);
for (; aItLF.More(); aItLF.Next()) {
@@ -1197,8 +1223,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
//---------------------------
// MAJ SD. for faces //
//---------------------------
for (Exp.Init(myShape,TopAbs_FACE) ; Exp.More(); Exp.Next()) {
const TopoDS_Shape& FI = Exp.Current();
for (TopTools_ListOfShape::Iterator it (aLFaces); it.More(); it.Next())
{
const TopoDS_Shape& FI = it.Value();
myInitOffsetFace.SetRoot(FI);
TopoDS_Face OF = MapSF(FI).Face();
if (MES.IsBound(OF)) {
@@ -1327,9 +1354,9 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
// Add methods for supporting history.
TopTools_MapOfShape aMapEdges;
for (Exp.Init(myShape,TopAbs_FACE) ; Exp.More(); Exp.Next()) {
const TopoDS_Shape& aFaceRef = Exp.Current();
for (TopTools_ListOfShape::Iterator it (aLFaces); it.More(); it.Next())
{
const TopoDS_Shape& aFaceRef = it.Value();
Exp2.Init(aFaceRef.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
for (; Exp2.More(); Exp2.Next()) {
@@ -1435,6 +1462,46 @@ void BRepOffset_MakeOffset::BuildOffsetByInter()
DEBVerticesControl (COES,myAsDes);
if ( ChronBuild) Clock.Show();
#endif
}
//=======================================================================
//function : ReplaceRoots
//purpose :
//=======================================================================
void BRepOffset_MakeOffset::ReplaceRoots()
{
// Replace the artificial faces and edges in InitOffset maps with the original ones.
TopTools_MapOfShape View;
for (TopExp_Explorer anExpF (myShape, TopAbs_EDGE); anExpF.More(); anExpF.Next())
{
const TopoDS_Shape& aF = anExpF.Current();
for (TopExp_Explorer anExpE (aF, TopAbs_EDGE); anExpE.More(); anExpE.Next())
{
const TopoDS_Shape& aE = anExpE.Current();
if (!View.Add (aE))
continue;
TopoDS_Shape aFGen = myAnalyse.Generated (aE);
if (aFGen.IsNull())
continue;
myInitOffsetFace.ReplaceRoot (aFGen, aE);
for (TopoDS_Iterator itV (aE); itV.More(); itV.Next())
{
const TopoDS_Shape& aV = itV.Value();
if (!View.Add (aV))
continue;
TopoDS_Shape aEGen = myAnalyse.Generated (aV);
if (aEGen.IsNull())
continue;
myInitOffsetEdge.ReplaceRoot (aEGen, aV);
}
}
}
}
//=======================================================================
@@ -3822,7 +3889,7 @@ void UpdateHistory(const TopTools_ListOfShape& theLF,
//function : IntersectEdges
//purpose :
//=======================================================================
void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
void BRepOffset_MakeOffset::IntersectEdges(const TopTools_ListOfShape& theFaces,
BRepOffset_DataMapOfShapeOffset& theMapSF,
TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theBuild,
@@ -3831,14 +3898,14 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
{
Standard_Real aTolF;
TopTools_IndexedDataMapOfShapeListOfShape aDMVV;
TopExp_Explorer aExp(theShape, TopAbs_FACE);
// intersect edges created from edges
TopTools_IndexedMapOfShape aMFV;
for (; aExp.More(); aExp.Next()) {
const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
aTolF = BRep_Tool::Tolerance(aF);
for (TopTools_ListOfShape::Iterator it (theFaces); it.More(); it.Next())
{
const TopoDS_Face& aF = TopoDS::Face (it.Value());
aTolF = BRep_Tool::Tolerance (aF);
BRepOffset_Inter2d::ConnexIntByInt
(aF, theMapSF(aF), theMES, theBuild, theAsDes2d, myOffset, aTolF, aMFV, aDMVV);
(aF, theMapSF (aF), theMES, theBuild, theAsDes2d, myOffset, aTolF, myAnalyse, aMFV, aDMVV);
}
// intersect edges created from vertices
Standard_Integer i, aNbF = aMFV.Extent();
@@ -3846,7 +3913,7 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
const TopoDS_Face& aF = TopoDS::Face(aMFV(i));
aTolF = BRep_Tool::Tolerance(aF);
BRepOffset_Inter2d::ConnexIntByIntInVert
(aF, theMapSF(aF), theMES, theBuild, theAsDes, theAsDes2d, aTolF, aDMVV);
(aF, theMapSF(aF), theMES, theBuild, theAsDes, theAsDes2d, aTolF, myAnalyse, aDMVV);
}
//
// fuse vertices on edges
@@ -3859,6 +3926,7 @@ void BRepOffset_MakeOffset::IntersectEdges(const TopoDS_Shape& theShape,
//=======================================================================
void TrimEdges(const TopoDS_Shape& theShape,
const Standard_Real theOffset,
const BRepOffset_Analyse& Analyse,
BRepOffset_DataMapOfShapeOffset& theMapSF,
TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theBuild,
@@ -3872,9 +3940,24 @@ void TrimEdges(const TopoDS_Shape& theShape,
TopoDS_Shape NE;
TopoDS_Edge TNE;
TopoDS_Face NF;
//
for (Exp.Init(theShape,TopAbs_FACE) ; Exp.More(); Exp.Next()) {
const TopoDS_Face& FI = TopoDS::Face(Exp.Current());
TopTools_ListOfShape aLFaces;
for (Exp.Init (theShape, TopAbs_FACE); Exp.More(); Exp.Next())
aLFaces.Append (Exp.Current());
TopTools_MapOfShape aMFGenerated;
TopTools_IndexedDataMapOfShapeListOfShape aDMEF;
for (TopTools_ListOfShape::Iterator it (Analyse.NewFaces()); it.More(); it.Next())
{
const TopoDS_Shape& aFG = it.Value();
aLFaces.Append (aFG);
aMFGenerated.Add (aFG);
TopExp::MapShapesAndUniqueAncestors (aFG, TopAbs_EDGE, TopAbs_FACE, aDMEF);
}
for (TopTools_ListOfShape::Iterator it (aLFaces); it.More(); it.Next())
{
const TopoDS_Face& FI = TopoDS::Face (it.Value());
NF = theMapSF(FI).Face();
if (theMES.IsBound(NF)) {
NF = TopoDS::Face(theMES(NF));
@@ -3937,7 +4020,9 @@ void TrimEdges(const TopoDS_Shape& theShape,
if (aS.ShapeType() != TopAbs_EDGE) {
continue;
}
//
if (aMFGenerated.Contains (FI) && aDMEF.FindFromKey (aS).Extent() == 1)
continue;
NE = theMapSF(FI).Generated(aS);
//// modified by jgv, 19.12.03 for OCC4455 ////
NE.Orientation(aS.Orientation());
@@ -4068,22 +4153,21 @@ void TrimEdge(TopoDS_Edge& NE,
//function : GetEnlargedFaces
//purpose :
//=======================================================================
void GetEnlargedFaces(const TopoDS_Shape& theShape,
void GetEnlargedFaces(const TopTools_ListOfShape& theFaces,
const BRepOffset_DataMapOfShapeOffset& theMapSF,
const TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theFacesOrigins,
BRepAlgo_Image& theImage,
TopTools_ListOfShape& theLSF)
{
TopExp_Explorer aExp(theShape, TopAbs_FACE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& FI = aExp.Current();
for (TopTools_ListOfShape::Iterator it (theFaces); it.More(); it.Next())
{
const TopoDS_Shape& FI = it.Value();
const TopoDS_Shape& OFI = theMapSF(FI).Face();
if (theMES.IsBound(OFI)) {
const TopoDS_Face& aLocalFace = TopoDS::Face(theMES(OFI));
theLSF.Append(aLocalFace);
theImage.SetRoot(aLocalFace);
//
theFacesOrigins.Bind(aLocalFace, FI);
}
}
@@ -4246,6 +4330,113 @@ Standard_Boolean BuildShellsCompleteInter(const TopTools_ListOfShape& theLF,
return GetSubShapes(aResult3, TopAbs_SHELL, theShells);
}
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepOffset_MakeOffset::Generated (const TopoDS_Shape& theS)
{
myGenerated.Clear();
const TopAbs_ShapeEnum aType = theS.ShapeType();
switch (aType)
{
case TopAbs_VERTEX:
{
if (myAnalyse.HasAncestor (theS))
{
TopTools_MapOfShape aMFence;
const TopTools_ListOfShape& aLA = myAnalyse.Ancestors (theS);
TopTools_ListOfShape::Iterator itLA (aLA);
for (; myGenerated.IsEmpty() && itLA.More(); itLA.Next())
{
const TopoDS_Shape& aE = itLA.Value();
if (!myInitOffsetEdge.HasImage (aE))
continue;
TopTools_ListOfShape aLEIm;
myInitOffsetEdge.LastImage (aE, aLEIm);
TopTools_ListOfShape::Iterator itLEIm (aLEIm);
for (; myGenerated.IsEmpty() && itLEIm.More(); itLEIm.Next())
{
TopoDS_Iterator itV (itLEIm.Value());
for (; itV.More(); itV.Next())
{
if (!aMFence.Add (itV.Value()))
{
myGenerated.Append (itV.Value());
break;
}
}
}
}
}
}
Standard_FALLTHROUGH
case TopAbs_EDGE:
{
if (myInitOffsetEdge.HasImage (theS))
{
myInitOffsetEdge.LastImage (theS, myGenerated);
}
}
Standard_FALLTHROUGH
case TopAbs_FACE:
{
if (myInitOffsetFace.HasImage (theS))
{
myInitOffsetFace.LastImage (theS, myGenerated);
}
break;
}
case TopAbs_SOLID:
{
if (theS.IsSame (myShape))
myGenerated.Append (myOffsetShape);
break;
}
default:
break;
}
if (myResMap.IsEmpty())
TopExp::MapShapes (myOffsetShape, myResMap);
for (TopTools_ListOfShape::Iterator it (myGenerated); it.More();)
{
if (myResMap.Contains (it.Value()))
it.Next();
else
myGenerated.Remove (it);
}
return myGenerated;
}
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepOffset_MakeOffset::Modified (const TopoDS_Shape&)
{
myGenerated.Clear();
return myGenerated;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepOffset_MakeOffset::IsDeleted (const TopoDS_Shape& theS)
{
if (myResMap.IsEmpty())
TopExp::MapShapes (myOffsetShape, myResMap);
if (myResMap.Contains (theS))
return Standard_False;
return Generated (theS).IsEmpty()
&& Modified (theS).IsEmpty();
}
//=======================================================================
//function : GetSubShapes
//purpose :

View File

@@ -92,6 +92,11 @@ public:
Standard_EXPORT const TopoDS_Shape& Shape() const;
const TopoDS_Shape& InitShape() const
{
return myShape;
}
//! returns information about offset state.
Standard_EXPORT BRepOffset_Error Error() const;
@@ -121,6 +126,17 @@ public:
//! Return bad shape, which obtained in CheckInputData.
Standard_EXPORT const TopoDS_Shape& GetBadShape() const;
public: //! @name History methods
//! Returns the list of shapes generated from the shape <S>.
Standard_EXPORT const TopTools_ListOfShape& Generated (const TopoDS_Shape& theS);
//! Returns the list of shapes modified from the shape <S>.
Standard_EXPORT const TopTools_ListOfShape& Modified (const TopoDS_Shape& theS);
//! Returns true if the shape S has been deleted.
Standard_EXPORT Standard_Boolean IsDeleted (const TopoDS_Shape& S);
protected:
@@ -152,6 +168,9 @@ private:
Standard_EXPORT void EncodeRegularity();
//! Replace roots in history maps
Standard_EXPORT void ReplaceRoots();
Standard_EXPORT void MakeSolid();
Standard_EXPORT void ToContext (BRepOffset_DataMapOfShapeOffset& MapSF);
@@ -169,7 +188,7 @@ private:
Standard_EXPORT void RemoveInternalEdges();
//! Intersects edges
Standard_EXPORT void IntersectEdges (const TopoDS_Shape& theShape,
Standard_EXPORT void IntersectEdges (const TopTools_ListOfShape& theFaces,
BRepOffset_DataMapOfShapeOffset& theMapSF,
TopTools_DataMapOfShapeShape& theMES,
TopTools_DataMapOfShapeShape& theBuild,
@@ -181,6 +200,7 @@ private:
//! for BRepOffset_MakeLoops::Build method.
//! Currently the Complete intersection mode is limited to work only on planar cases.
Standard_EXPORT void BuildSplitsOfExtendedFaces(const TopTools_ListOfShape& theLF,
const BRepOffset_Analyse& theAnalyse,
Handle(BRepAlgo_AsDes)& theAsDes,
TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
TopTools_DataMapOfShapeShape& theFacesOrigins,
@@ -217,7 +237,8 @@ private:
Standard_Boolean myIsPerformSewing; // Handle bad walls in thicksolid mode.
Standard_Boolean myIsPlanar;
TopoDS_Shape myBadShape;
TopTools_ListOfShape myGenerated;
TopTools_MapOfShape myResMap;
};
#endif // _BRepOffset_MakeOffset_HeaderFile

View File

@@ -107,6 +107,7 @@ static
void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
const TopTools_MapOfShape& theModifiedEdges,
const TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
const BRepOffset_Analyse* theAnalyse,
Handle(BRepAlgo_AsDes)& theAsDes,
TopTools_DataMapOfShapeShape& theFacesOrigins,
TopTools_DataMapOfShapeListOfShape& theOEImages,
@@ -155,6 +156,7 @@ static
const TopTools_ListOfShape& theLFImages,
const TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
const TopTools_DataMapOfShapeShape& theFacesOrigins,
const BRepOffset_Analyse* theAnalyse,
const TopTools_DataMapOfShapeListOfShape& theOEImages,
const TopTools_DataMapOfShapeListOfShape& theOEOrigins,
TopTools_IndexedMapOfShape& theInvEdges,
@@ -594,6 +596,7 @@ static
static
Standard_Boolean FindShape(const TopoDS_Shape& theSWhat,
const TopoDS_Shape& theSWhere,
const BRepOffset_Analyse* theAnalyse,
TopoDS_Shape& theRes);
static
@@ -667,6 +670,7 @@ void BRepOffset_MakeOffset::BuildSplitsOfTrimmedFaces(const TopTools_ListOfShape
// these invalidities will be rebuilt.
//=======================================================================
void BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces(const TopTools_ListOfShape& theLF,
const BRepOffset_Analyse& theAnalyse,
Handle(BRepAlgo_AsDes)& theAsDes,
TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
TopTools_DataMapOfShapeShape& theFacesOrigins,
@@ -704,7 +708,7 @@ void BRepOffset_MakeOffset::BuildSplitsOfExtendedFaces(const TopTools_ListOfShap
// solid build from the new splits
TopoDS_Shape aSolids;
// now we can split the faces
BuildSplitsOfFaces(theLF, aNewEdges, theEdgesOrigins, theAsDes, theFacesOrigins,
BuildSplitsOfFaces(theLF, aNewEdges, theEdgesOrigins, &theAnalyse, theAsDes, theFacesOrigins,
anOEImages, anOEOrigins, aLastInvEdges, anEdgesToAvoid, anInvEdges, aValidEdges,
anInvertedEdges, anAlreadyInvFaces, anInvFaces, anArtInvFaces, aFImages,
aDMFNewHoles, aSolids, aSSInterfs);
@@ -778,7 +782,7 @@ void BuildSplitsOfInvFaces(const TopTools_IndexedDataMapOfShapeListOfShape& theF
//
TopoDS_Shape aSolids;
//
BuildSplitsOfFaces(aLF, theModifiedEdges, theEdgesOrigins, theAsDes, theFacesOrigins,
BuildSplitsOfFaces(aLF, theModifiedEdges, theEdgesOrigins, NULL, theAsDes, theFacesOrigins,
theOEImages, theOEOrigins, theLastInvEdges, theEdgesToAvoid, anInvEdges, theValidEdges,
anInvertedEdges, theAlreadyInvFaces, anInvFaces, anArtInvFaces, theFImages,
theDMFNewHoles, aSolids, aSSInterfs);
@@ -805,6 +809,7 @@ void BuildSplitsOfInvFaces(const TopTools_IndexedDataMapOfShapeListOfShape& theF
void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
const TopTools_MapOfShape& theModifiedEdges,
const TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
const BRepOffset_Analyse* theAnalyse,
Handle(BRepAlgo_AsDes)& theAsDes,
TopTools_DataMapOfShapeShape& theFacesOrigins,
TopTools_DataMapOfShapeListOfShape& theOEImages,
@@ -961,7 +966,7 @@ void BuildSplitsOfFaces(const TopTools_ListOfShape& theLF,
}
//
// find invalid edges
FindInvalidEdges(aF, aLFImages, theEdgesOrigins, theFacesOrigins, theOEImages,
FindInvalidEdges(aF, aLFImages, theEdgesOrigins, theFacesOrigins, theAnalyse, theOEImages,
theOEOrigins, theInvEdges, theValidEdges, aDMFLVE, aDMFLNE, aDMFLIE,
aDMFLVIE, aDMEOrLEIm, theInvertedEdges, aMEdgeInvalidByVertex);
//
@@ -1552,6 +1557,7 @@ void FindInvalidEdges(const TopoDS_Face& theF,
const TopTools_ListOfShape& theLFImages,
const TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
const TopTools_DataMapOfShapeShape& theFacesOrigins,
const BRepOffset_Analyse* theAnalyse,
const TopTools_DataMapOfShapeListOfShape& theOEImages,
const TopTools_DataMapOfShapeListOfShape& theOEOrigins,
TopTools_IndexedMapOfShape& theInvEdges,
@@ -1655,9 +1661,9 @@ void FindInvalidEdges(const TopoDS_Face& theF,
}
}
//
TopTools_MapOfShape aME, aMV;
TopTools_MapOfShape aME, aMV, aMF;
Standard_Boolean bInvalid = Standard_False, bChecked = Standard_False;
Standard_Integer aNbP = NbPoints(aEIm);
Standard_Integer aNbP = NbPoints(aEIm), aNbInv = 0;
Standard_Boolean bUseVertex = !aNbVOr ? Standard_False :
(aNbVOr == 1 &&
aDMEF.FindFromKey(aEIm).Extent() == 1 &&
@@ -1693,7 +1699,7 @@ void FindInvalidEdges(const TopoDS_Face& theF,
}
}
else {
FindShape(aSOr, aFOr, aEOrF);
FindShape(aSOr, aFOr, theAnalyse, aEOrF);
//
TopTools_ListOfShape *pLEIm = theDMEOrLEIm.ChangeSeek(aSOr);
if (!pLEIm) {
@@ -1732,10 +1738,17 @@ void FindInvalidEdges(const TopoDS_Face& theF,
const TopoDS_Shape& aV = aExpE.Current();
aMV.Add(aV);
}
if (theAnalyse)
{
for (TopTools_ListOfShape::Iterator itFA (theAnalyse->Ancestors (aEOrF));
itFA.More(); itFA.Next())
aMF.Add (itFA.Value());
}
}
//
if (aCos < Precision::Confusion()) {
bInvalid = Standard_True;
aNbInv++;
if (bVertex) {
theEdgesInvalidByVertex.Add(aEIm);
}
@@ -1747,25 +1760,55 @@ void FindInvalidEdges(const TopoDS_Face& theF,
continue;
}
//
Standard_Boolean bLocalOnly = Standard_False;
Standard_Integer aNbE = aME.Extent(), aNbV = aMV.Extent();
if ((aNbE > 1) && (aNbV == 2*aNbE)) {
continue;
if (aNbE > 1 && aNbV == 2*aNbE)
{
Standard_Boolean bSkip = Standard_True;
// Allow the edge to be analyzed if it is:
// * originated from more than two faces
// * unanimously considered valid or invalid
// * not a boundary edge in the splits
if (aMF.Extent () > 2 && (aNbInv == 0 || aNbInv == aNbE))
{
if (theLFImages.Extent() > 2)
{
TopoDS_Iterator itV (aEIm);
for (; itV.More(); itV.Next())
{
TopTools_ListOfShape::Iterator itE (aDMVE.FindFromKey (itV.Value()));
for (; itE.More(); itE.Next())
if (aDMEF.FindFromKey (itE.Value()).Extent() < 2)
break;
if (itE.More())
break;
}
bSkip = itV.More();
}
}
if (bSkip)
continue;
else
bLocalOnly = Standard_True;
}
//
if (bInvalid) {
theInvEdges.Add(aEIm);
if (!bLocalOnly)
theInvEdges.Add(aEIm);
aLIE.Append(aEIm);
aMEInv.Add(aEIm);
continue;
}
//
// check if the edge has been inverted
Standard_Boolean bInverted = !aNbE ? Standard_False :
Standard_Boolean bInverted = !aNbE || bLocalOnly ? Standard_False :
CheckInverted(aEIm, aFOr, theOEImages, theOEOrigins,
theEdgesOrigins, aDMVE, aMEdges, theMEInverted);
//
if (!bInverted || !aNbVOr) {
theValidEdges.Add(aEIm);
if (!bLocalOnly)
theValidEdges.Add(aEIm);
aLVE.Append(aEIm);
aMEVal.Add(aEIm);
}
@@ -1927,8 +1970,9 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
//
bValid = theValidEdges.Contains(aEIm);
bInvalid = theInvEdges.Contains(aEIm);
bNeutral = aMEN.Contains(aEIm);
//
if (!bValid && !bInvalid) {
if (!bValid && !bInvalid && !bNeutral) {
// edge has not been checked for some reason
continue;
}
@@ -1936,16 +1980,15 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
++aNbChecked;
//
bInvalidLoc = aMIE.Contains(aEIm);
bHasReallyInvalid = bInvalidLoc && !bValid && !theEdgesInvalidByVertex.Contains(aEIm);
bHasReallyInvalid = bInvalid && bInvalidLoc && !bValid && !theEdgesInvalidByVertex.Contains(aEIm);
if (bHasReallyInvalid) {
break;
}
//
bNeutral = aMEN.Contains(aEIm);
bValidLoc = aMVE.Contains(aEIm);
//
bInverted = theMEInverted.Contains(aEIm);
if (!bInvalid && bTreatInvertedAsInvalid) {
if (!bInvalid && !bInvalidLoc && bTreatInvertedAsInvalid) {
bInvalid = bInverted;
}
//
@@ -1954,7 +1997,7 @@ void FindInvalidFaces(TopTools_ListOfShape& theLFImages,
}
//
bAllValid &= bValidLoc;
bAllInvalid &= bInvalid;
bAllInvalid &= (bInvalid || bInvalidLoc);
bAllInvNeutral &= (bAllInvalid && bNeutral);
bIsInvalidByInverted &= (bInvalidLoc || bInverted);
}
@@ -2399,7 +2442,7 @@ Standard_Boolean CheckInverted(const TopoDS_Edge& theEIm,
const TopoDS_Shape& aEO = aItLOE.Value();
if (aEO.ShapeType() == TopAbs_EDGE && aMFence.Add(aEO)) {
TopoDS_Shape aEOin;
if (FindShape(aEO, theFOr, aEOin)) {
if (FindShape(aEO, theFOr, NULL, aEOin)) {
AppendToList(aLOE, aEO);
}
}
@@ -3105,7 +3148,7 @@ void RemoveInsideFaces(TopTools_IndexedDataMapOfShapeListOfShape& theFImages,
const TopoDS_Shape& aFSol = pLSols->First();
//
TopoDS_Shape aFx;
if (!FindShape(aFInvIm, aFSol, aFx)) {
if (!FindShape(aFInvIm, aFSol, NULL, aFx)) {
continue;
}
//
@@ -7118,6 +7161,7 @@ Standard_Integer NbPoints(const TopoDS_Edge& theEdge)
//=======================================================================
Standard_Boolean FindShape(const TopoDS_Shape& theSWhat,
const TopoDS_Shape& theSWhere,
const BRepOffset_Analyse* theAnalyse,
TopoDS_Shape& theRes)
{
Standard_Boolean bFound = Standard_False;
@@ -7131,6 +7175,25 @@ Standard_Boolean FindShape(const TopoDS_Shape& theSWhat,
break;
}
}
if (!bFound && theAnalyse)
{
const TopTools_ListOfShape *pLD = theAnalyse->Descendants (theSWhere);
if (pLD)
{
for (TopTools_ListOfShape::Iterator it (*pLD); it.More(); it.Next())
{
const TopoDS_Shape& aS = it.Value();
if (aS.IsSame (theSWhat))
{
theRes = aS;
bFound = Standard_True;
break;
}
}
}
}
return bFound;
}

View File

@@ -1613,50 +1613,52 @@ TopoDS_Shape BRepOffset_Offset::Generated(const TopoDS_Shape& Shape) const
{
TopoDS_Shape aShape;
switch ( myShape.ShapeType()) {
case TopAbs_FACE:
switch ( myShape.ShapeType())
{
case TopAbs_FACE:
{
TopExp_Explorer exp (myShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
TopExp_Explorer expo(myFace .Oriented(TopAbs_FORWARD), TopAbs_EDGE);
for ( ; exp.More() && expo.More(); exp.Next(), expo.Next()) {
if ( Shape.IsSame(exp.Current())) {
if ( myShape.Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
}
TopExp_Explorer exp (myShape.Oriented(TopAbs_FORWARD), TopAbs_EDGE);
TopExp_Explorer expo (myFace .Oriented(TopAbs_FORWARD), TopAbs_EDGE);
for (; exp.More() && expo.More(); exp.Next(), expo.Next())
{
if (Shape.IsSame (exp.Current()))
{
if (myShape.Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
break;
}
}
}
break;
case TopAbs_EDGE:
case TopAbs_EDGE:
// have generate a pipe.
{
TopoDS_Vertex V1, V2;
TopExp::Vertices(TopoDS::Edge(myShape), V1, V2);
TopExp_Explorer expf(myFace .Oriented(TopAbs_FORWARD), TopAbs_WIRE);
TopExp_Explorer expo(expf.Current().Oriented(TopAbs_FORWARD),
TopAbs_EDGE);
TopExp_Explorer expf(myFace.Oriented(TopAbs_FORWARD), TopAbs_WIRE);
TopExp_Explorer expo(expf.Current().Oriented(TopAbs_FORWARD), TopAbs_EDGE);
expo.Next();
expo.Next();
if ( V2.IsSame(Shape)) {
if ( expf.Current().Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
if (expf.Current().Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
}
else {
expo.Next();
if ( expf.Current().Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
expo.Next();
if (expf.Current().Orientation() == TopAbs_REVERSED)
aShape = expo.Current().Reversed();
else
aShape = expo.Current();
}
if ( myFace.Orientation() == TopAbs_REVERSED)
aShape.Reverse();
if (myFace.Orientation() == TopAbs_REVERSED)
aShape.Reverse();
}
break;
default:

View File

@@ -2948,7 +2948,11 @@ static void CompactUVBounds (const TopoDS_Face& F,
C.D0(U2,P);
B.Add(P);
}
B.Get(UMin,VMin,UMax,VMax);
if (!B.IsVoid())
B.Get(UMin,VMin,UMax,VMax);
else
BRep_Tool::Surface(F)->Bounds (UMin, UMax, VMin, VMax);
}
//=======================================================================

View File

@@ -118,24 +118,14 @@ void BRepOffsetAPI_MakeOffsetShape::Build()
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::Generated (const TopoDS_Shape& S)
{
myGenerated.Clear();
if (myLastUsedAlgo == OffsetAlgo_JOIN && !myOffsetShape.ClosingFaces().Contains(S))
if (myLastUsedAlgo == OffsetAlgo_JOIN)
{
myOffsetShape.OffsetFacesFromShapes ().LastImage (S, myGenerated);
if (!myOffsetShape.ClosingFaces().IsEmpty())
{
// Reverse generated shapes in case of small solids.
// Useful only for faces without influence on others.
TopTools_ListIteratorOfListOfShape it(myGenerated);
for (; it.More(); it.Next())
it.Value().Reverse();
}
myGenerated = myOffsetShape.Generated (S);
}
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
{
TopoDS_Shape aGenShape = mySimpleOffsetShape.Generated(S);
if (!aGenShape.IsNull())
if (!aGenShape.IsNull() && !aGenShape.IsSame (S))
myGenerated.Append(aGenShape);
}
@@ -143,33 +133,39 @@ const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::Generated (const Topo
}
//=======================================================================
//function : GeneratedEdge
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::GeneratedEdge (const TopoDS_Shape& S)
const TopTools_ListOfShape& BRepOffsetAPI_MakeOffsetShape::Modified (const TopoDS_Shape& S)
{
myGenerated.Clear();
if (myLastUsedAlgo == OffsetAlgo_JOIN)
{
myOffsetShape.OffsetEdgesFromShapes().LastImage (S, myGenerated);
if (!myGenerated.IsEmpty())
{
if (S.IsSame(myGenerated.First()))
myGenerated.RemoveFirst();
}
myGenerated = myOffsetShape.Modified (S);
}
else if (myLastUsedAlgo == OffsetAlgo_SIMPLE)
{
TopoDS_Shape aGenShape = mySimpleOffsetShape.Generated(S);
if (!aGenShape.IsNull())
TopoDS_Shape aGenShape = mySimpleOffsetShape.Modified(S);
if (!aGenShape.IsNull() && !aGenShape.IsSame (S))
myGenerated.Append(aGenShape);
}
return myGenerated;
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepOffsetAPI_MakeOffsetShape::IsDeleted (const TopoDS_Shape& S)
{
if (myLastUsedAlgo == OffsetAlgo_JOIN)
{
return myOffsetShape.IsDeleted(S);
}
return Standard_False;
}
//=======================================================================
//function : GetJoinType
//purpose : Query offset join type.

View File

@@ -133,12 +133,15 @@ public:
//! Does nothing.
Standard_EXPORT virtual void Build() Standard_OVERRIDE;
//! Returns the list of shapes generated from the shape <S>.
//! Returns the list of shapes generated from the shape <S>.
Standard_EXPORT virtual const TopTools_ListOfShape& Generated (const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns the list of edges generated from the shape <S>.
Standard_EXPORT const TopTools_ListOfShape& GeneratedEdge (const TopoDS_Shape& S);
//! Returns the list of shapes Modified from the shape <S>.
Standard_EXPORT virtual const TopTools_ListOfShape& Modified (const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns true if the shape has been removed from the result.
Standard_EXPORT virtual Standard_Boolean IsDeleted (const TopoDS_Shape& S) Standard_OVERRIDE;
//! Returns offset join type.
Standard_EXPORT GeomAbs_JoinType GetJoinType() const;

View File

@@ -397,29 +397,30 @@ void BRepOffsetAPI_ThruSections::Build()
Standard_Integer IndFirstSec = 1;
if (Georges.IsDegeneratedFirstSection())
IndFirstSec = 2;
TopoDS_Shape aWorkingSection = WorkingSections(IndFirstSec);
TopoDS_Wire aWorkingSection = TopoDS::Wire(WorkingSections(IndFirstSec));
myNbEdgesInSection += aWorkingSection.NbChildren();
for (Standard_Integer ii = 1; ii <= myWires.Length(); ii++)
{
TopExp_Explorer Explo(myWires(ii), TopAbs_EDGE);
for (; Explo.More(); Explo.Next())
TopoDS_Iterator itw(myWires(ii));
for (; itw.More(); itw.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value());
Standard_Integer aSign = 1;
TopoDS_Vertex Vfirst, Vlast;
TopExp::Vertices(anEdge, Vfirst, Vlast);
TopTools_ListOfShape aNewEdges = Georges.GeneratedShapes(anEdge);
TColStd_ListOfInteger IList;
aWorkingSection = WorkingSections(ii);
aWorkingSection = TopoDS::Wire(WorkingSections(ii));
Standard_Integer NbNewEdges = aNewEdges.Extent();
TopTools_ListIteratorOfListOfShape itl(aNewEdges);
for (Standard_Integer kk = 1; itl.More(); itl.Next(),kk++)
{
const TopoDS_Edge& aNewEdge = TopoDS::Edge(itl.Value());
Standard_Integer inde = 1;
for (TopoDS_Iterator itw (aWorkingSection); itw.More(); itw.Next(), inde++)
BRepTools_WireExplorer wexp(aWorkingSection);
for (; wexp.More(); wexp.Next(), inde++)
{
const TopoDS_Shape& aWorkingEdge = itw.Value();
const TopoDS_Shape& aWorkingEdge = wexp.Current();
if (aWorkingEdge.IsSame(aNewEdge))
{
aSign = (aWorkingEdge.Orientation() == TopAbs_FORWARD)? 1 : -1;
@@ -1295,12 +1296,14 @@ BRepOffsetAPI_ThruSections::Generated(const TopoDS_Shape& S)
Standard_Integer Eindex = myVertexIndex(S);
Standard_Integer Vindex = (Eindex > 0)? 0 : 1;
Eindex = Abs(Eindex);
const TopoDS_Shape& FirstSection = myWires(1);
const TopoDS_Wire& FirstSection = TopoDS::Wire(myWires(1));
TopoDS_Edge FirstEdge;
TopoDS_Iterator itw(FirstSection);
for (Standard_Integer inde = 1; itw.More(); itw.Next(),inde++)
TopoDS_Vertex FirstVertexOfFirstEdge;
BRepTools_WireExplorer wexp(FirstSection);
for (Standard_Integer inde = 1; wexp.More(); wexp.Next(),inde++)
{
FirstEdge = TopoDS::Edge(itw.Value());
FirstEdge = wexp.Current();
FirstVertexOfFirstEdge = wexp.CurrentVertex();
if (inde == Eindex)
break;
}
@@ -1330,7 +1333,20 @@ BRepOffsetAPI_ThruSections::Generated(const TopoDS_Shape& S)
FirstEdgeInFace = Explo.Current();
TopoDS_Vertex VV [2];
TopExp::Vertices(FirstEdge, VV[0], VV[1]);
FirstVertex = VV[Vindex];
if (Vindex == 0)
{
if (VV[0].IsSame(FirstVertexOfFirstEdge))
FirstVertex = VV[0];
else
FirstVertex = VV[1];
}
else //Vindex == 1
{
if (VV[0].IsSame(FirstVertexOfFirstEdge))
FirstVertex = VV[1];
else
FirstVertex = VV[0];
}
const TopTools_ListOfShape& Elist = VEmap.FindFromKey(FirstVertex);
TopTools_ListIteratorOfListOfShape itl(Elist);
TopAbs_Orientation anEdgeOr = (Vindex == 0)? TopAbs_REVERSED : TopAbs_FORWARD;

View File

@@ -523,8 +523,10 @@ TopoDS_Shape BRepSweep_NumLinearRegularSweep::SplitShell(const TopoDS_Shape& aNe
Standard_Boolean BRepSweep_NumLinearRegularSweep::IsUsed(const TopoDS_Shape& aGenS) const
{
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
Standard_OutOfRange_Raise_if(iGenS == 0,
"BRepSweep_NumLinearRegularSweep::IsUsed: shape index = 0")
if (iGenS == 0)
{
return Standard_False;
}
Standard_Integer j;
Standard_Boolean isBuilt = Standard_False;
Standard_Boolean isUsed = Standard_False;
@@ -576,8 +578,10 @@ Standard_Boolean BRepSweep_NumLinearRegularSweep::IsUsed(const TopoDS_Shape& aGe
Standard_Boolean BRepSweep_NumLinearRegularSweep::GenIsUsed(const TopoDS_Shape& aGenS) const
{
Standard_Integer iGenS = myGenShapeTool.Index(aGenS);
Standard_OutOfRange_Raise_if(iGenS == 0,
"BRepSweep_NumLinearRegularSweep::GenIsUsed: shape index = 0")
if (iGenS == 0)
{
return Standard_False;
}
if (iGenS == 1)
{
return myBuiltShapes(iGenS, 1);

View File

@@ -1132,6 +1132,14 @@ Standard_Integer offsetperform(Draw_Interpretor& theCommands,
reportOffsetState(theCommands, aRetCode);
}
// Store the history of Boolean operation into the session
if (BRepTest_Objects::IsHistoryNeeded())
{
TopTools_ListOfShape aLA;
aLA.Append (TheOffset.InitShape());
BRepTest_Objects::SetHistory<BRepOffset_MakeOffset>(aLA, TheOffset);
}
return 0;
}

View File

@@ -609,7 +609,7 @@ static Standard_Integer setsweep(Draw_Interpretor& di,
return 1;
}
gp_Dir D(Draw::Atof(a[2]), Draw::Atof(a[3]), Draw::Atof(a[4]));
Sweep->SetMode(D);;
Sweep->SetMode(D);
}
else if (!strcmp(a[1], "-FX")) {
if ((n != 5) && (n != 8)) {

View File

@@ -482,6 +482,8 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
}
return Standard_True;
}
//
GeomAdaptor_Surface GAS(S,Uinf-u,Usup+u,Vinf-v,Vsup+v);
Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(GAS);
@@ -490,6 +492,19 @@ Standard_Boolean BRepTools_NurbsConvertModification::NewCurve2d
if(ProjOnCurve.IsDone()) {
Curve2d = ProjOnCurve.BSpline();
if (S->IsUPeriodic() || S->IsVPeriodic())
{
//Surface is periodic, checking curve2d domain
//Old domain
gp_Pnt2d aPf = C2d->Value(f2d);
//New domain
gp_Pnt2d aNewPf = Curve2d->Value(f2d);
gp_Vec2d aT(aNewPf, aPf);
if (aT.SquareMagnitude() > Precision::SquarePConfusion())
{
Curve2d = Handle(Geom2d_Curve)::DownCast(Curve2d->Translated(aT));
}
}
Standard_Real newTol = BRepTools::EvalAndUpdateTol(newE, C3d, Curve2d, S, f3d, l3d);
if(newTol > Tol)
{

View File

@@ -23,11 +23,84 @@
#include <limits>
//! Base class for BVH_Box (CRTP idiom is used).
//! @tparam T Numeric data type
//! @tparam N Vector dimension
//! @tparam TheDerivedBox Template of derived class that defined axis aligned bounding box.
template <class T, int N, template <class /*T*/, int /*N*/> class TheDerivedBox>
class BVH_BaseBox {};
// forward declaration
template <class T, int N> class BVH_Box;
//! Partial template specialization for BVH_Box when N = 3.
template <class T>
class BVH_BaseBox<T, 3, BVH_Box>
{
public:
//! Transforms this box with given transformation.
void Transform (const NCollection_Mat4<T>& theTransform)
{
if (theTransform.IsIdentity())
{
return;
}
BVH_Box<T, 3> *aThis = static_cast<BVH_Box<T, 3>*>(this);
if (!aThis->IsValid())
{
return;
}
BVH_Box<T, 3> aBox = Transformed (theTransform);
aThis->CornerMin() = aBox.CornerMin();
aThis->CornerMax() = aBox.CornerMax();
}
//! Returns a box which is the result of applying the
//! given transformation to this box.
BVH_Box<T, 3> Transformed (const NCollection_Mat4<T>& theTransform) const
{
BVH_Box<T, 3> aResultBox;
if (theTransform.IsIdentity())
{
return aResultBox;
}
const BVH_Box<T, 3> *aThis = static_cast<const BVH_Box<T, 3>*>(this);
if (!aThis->IsValid())
{
return aResultBox;
}
for (size_t aX = 0; aX <= 1; ++aX)
{
for (size_t aY = 0; aY <= 1; ++aY)
{
for (size_t aZ = 0; aZ <= 1; ++aZ)
{
typename BVH::VectorType<T, 4>::Type aPnt =
theTransform * typename BVH::VectorType<T, 4>::Type (aX ? aThis->CornerMax().x() : aThis->CornerMin().x(),
aY ? aThis->CornerMax().y() : aThis->CornerMin().y(),
aZ ? aThis->CornerMax().z() : aThis->CornerMin().z(),
static_cast<T> (1.0));
aResultBox.Add (aPnt.xyz());
}
}
}
return aResultBox;
}
};
//! Defines axis aligned bounding box (AABB) based on BVH vectors.
//! \tparam T Numeric data type
//! \tparam N Vector dimension
template<class T, int N>
class BVH_Box
class BVH_Box : public BVH_BaseBox<T, N, BVH_Box>
{
public:

View File

@@ -62,7 +62,7 @@ public:
BVH_Object() {}
//! Releases resources of geometric object.
virtual ~BVH_Object() = 0;
virtual ~BVH_Object() {}
public:
@@ -71,14 +71,4 @@ public:
};
// =======================================================================
// function : ~BVH_Object
// purpose :
// =======================================================================
template<class T, int N>
BVH_Object<T, N>::~BVH_Object()
{
//
}
#endif // _BVH_Object_Header

View File

@@ -44,7 +44,7 @@ public:
myNumOfThreads (theNumOfThreads) {}
//! Releases resources of BVH queue based builder.
virtual ~BVH_QueueBuilder() = 0;
virtual ~BVH_QueueBuilder() {}
public:
@@ -288,14 +288,4 @@ void BVH_QueueBuilder<T, N>::Build (BVH_Set<T, N>* theSet,
}
}
// =======================================================================
// function : ~BVH_QueueBuilder
// purpose :
// =======================================================================
template<class T, int N>
BVH_QueueBuilder<T, N>::~BVH_QueueBuilder()
{
//
}
#endif // _BVH_QueueBuilder_Header

View File

@@ -1,5 +1,6 @@
// Copyright (c) 1996-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Created by: Olga Suryaninova
// Created on: 2019-11-25
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -12,13 +13,27 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
#ifndef _BVH_Ray_Header
#define _BVH_Ray_Header
inline Standard_Integer Poly_PolygonOnTriangulation::NbNodes() const
//! Describes a ray based on BVH vectors.
template<class T, int N>
class BVH_Ray
{
return myNodes.Length();
}
public:
typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
public:
BVH_VecNt Origin;
BVH_VecNt Direct;
public:
BVH_Ray (const BVH_VecNt& theOrigin,
const BVH_VecNt& theDirect) : Origin (theOrigin),
Direct (theDirect) { }
};
#endif // _BVH_Ray_Header

View File

@@ -35,7 +35,7 @@ public:
BVH_Set() {}
//! Releases resources of set of objects.
virtual ~BVH_Set() = 0;
virtual ~BVH_Set() {}
//! Returns AABB of the entire set of objects.
virtual BVH_Box<T, N> Box() const
@@ -67,14 +67,4 @@ public:
};
// =======================================================================
// function : ~BVH_Set
// purpose :
// =======================================================================
template<class T, int N>
BVH_Set<T, N>::~BVH_Set()
{
//
}
#endif // _BVH_Set_Header

View File

@@ -17,6 +17,7 @@
#define _BVH_Tools_Header
#include <BVH_Box.hxx>
#include <BVH_Ray.hxx>
#include <BVH_Types.hxx>
//! Defines a set of static methods operating with points and bounding boxes.
@@ -35,6 +36,10 @@ public: //! @name Box-Box Square distance
static T BoxBoxSquareDistance (const BVH_Box<T, N>& theBox1,
const BVH_Box<T, N>& theBox2)
{
if (!theBox1.IsValid() || !theBox2.IsValid())
{
return static_cast<T>(0);
}
return BoxBoxSquareDistance (theBox1.CornerMin(), theBox1.CornerMax(),
theBox2.CornerMin(), theBox2.CornerMax());
}
@@ -60,6 +65,10 @@ public: //! @name Point-Box Square distance
static T PointBoxSquareDistance (const BVH_VecNt& thePoint,
const BVH_Box<T, N>& theBox)
{
if (!theBox.IsValid())
{
return static_cast<T>(0);
}
return PointBoxSquareDistance (thePoint,
theBox.CornerMin(),
theBox.CornerMax());
@@ -79,6 +88,29 @@ public: //! @name Point-Box Square distance
return aDist;
}
public: //! @name Point-Box projection
//! Computes projection of point on bounding box
static BVH_VecNt PointBoxProjection (const BVH_VecNt& thePoint,
const BVH_Box<T, N>& theBox)
{
if (!theBox.IsValid())
{
return thePoint;
}
return PointBoxProjection (thePoint,
theBox.CornerMin(),
theBox.CornerMax());
}
//! Computes projection of point on bounding box
static BVH_VecNt PointBoxProjection (const BVH_VecNt& thePoint,
const BVH_VecNt& theCMin,
const BVH_VecNt& theCMax)
{
return thePoint.cwiseMax (theCMin).cwiseMin (theCMax);
}
public: //! @name Point-Triangle Square distance
//! Computes square distance between point and triangle
@@ -160,6 +192,92 @@ public: //! @name Point-Triangle Square distance
return (aDirect.Dot(aDirect));
}
public: //! @name Ray-Box Intersection
//! Computes hit time of ray-box intersection
static Standard_Boolean RayBoxIntersection (const BVH_Ray<T, N>& theRay,
const BVH_Box<T, N>& theBox,
T& theTimeEnter,
T& theTimeLeave)
{
if (!theBox.IsValid())
{
return Standard_False;
}
return RayBoxIntersection (theRay, theBox.CornerMin(), theBox.CornerMax(), theTimeEnter, theTimeLeave);
}
//! Computes hit time of ray-box intersection
static Standard_Boolean RayBoxIntersection (const BVH_Ray<T, N>& theRay,
const BVH_VecNt& theBoxCMin,
const BVH_VecNt& theBoxCMax,
T& theTimeEnter,
T& theTimeLeave)
{
return RayBoxIntersection (theRay.Origin, theRay.Direct,
theBoxCMin, theBoxCMax, theTimeEnter, theTimeLeave);
}
//! Computes hit time of ray-box intersection
static Standard_Boolean RayBoxIntersection (const BVH_VecNt& theRayOrigin,
const BVH_VecNt& theRayDirection,
const BVH_Box<T, N>& theBox,
T& theTimeEnter,
T& theTimeLeave)
{
if (!theBox.IsValid())
{
return Standard_False;
}
return RayBoxIntersection (theRayOrigin, theRayDirection,
theBox.CornerMin(), theBox.CornerMax(),
theTimeEnter, theTimeLeave);
}
//! Computes hit time of ray-box intersection
static Standard_Boolean RayBoxIntersection (const BVH_VecNt& theRayOrigin,
const BVH_VecNt& theRayDirection,
const BVH_VecNt& theBoxCMin,
const BVH_VecNt& theBoxCMax,
T& theTimeEnter,
T& theTimeLeave)
{
BVH_VecNt aNodeMin, aNodeMax;
for (int i = 0; i < N; ++i)
{
if (theRayDirection[i] == 0)
{
aNodeMin[i] = (theBoxCMin[i] - theRayOrigin[i]) < 0 ?
(std::numeric_limits<T>::min)() : (std::numeric_limits<T>::max)();
aNodeMax[i] = (theBoxCMax[i] - theRayOrigin[i]) < 0 ?
(std::numeric_limits<T>::min)() : (std::numeric_limits<T>::max)();
}
else
{
aNodeMin[i] = (theBoxCMin[i] - theRayOrigin[i]) / theRayDirection[i];
aNodeMax[i] = (theBoxCMax[i] - theRayOrigin[i]) / theRayDirection[i];
}
}
BVH_VecNt aTimeMin, aTimeMax;
for (int i = 0; i < N; ++i)
{
aTimeMin[i] = Min (aNodeMin[i], aNodeMax[i]);
aTimeMax[i] = Max (aNodeMin[i], aNodeMax[i]);
}
T aTimeEnter = Max (aTimeMin[0], Max (aTimeMin[1], aTimeMin[2]));
T aTimeLeave = Min (aTimeMax[0], Min (aTimeMax[1], aTimeMax[2]));
Standard_Boolean hasIntersection = aTimeEnter <= aTimeLeave && aTimeLeave >= 0;
if (hasIntersection)
{
theTimeEnter = aTimeEnter;
theTimeLeave = aTimeLeave;
}
return hasIntersection;
}
};
#endif

View File

@@ -22,6 +22,7 @@ BVH_PrimitiveSet3d.hxx
BVH_Properties.cxx
BVH_Properties.hxx
BVH_QueueBuilder.hxx
BVH_Ray.hxx
BVH_Set.hxx
BVH_Sorter.hxx
BVH_QuickSorter.hxx

View File

@@ -2216,7 +2216,7 @@ void BiTgte_Blend::ComputeSurfaces()
if (OF2isEdge) { // Update CutEdges.
exp.Next();
const TopoDS_Edge& EOnF2 = TopoDS::Edge(exp.Current());
TopExp::Vertices(EOnF2,V1,V2);;
TopExp::Vertices(EOnF2,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
Projector.Init(P1,GC2);

View File

@@ -223,7 +223,7 @@ void BinLDrivers_DocumentStorageDriver::WriteSubTree
// Write attributes
TDF_AttributeIterator itAtt (theLabel);
for ( ; itAtt.More() && theOS; itAtt.Next()) {
const Handle(TDF_Attribute)& tAtt = itAtt.Value();
const Handle(TDF_Attribute) tAtt = itAtt.Value();
const Handle(Standard_Type)& aType = tAtt->DynamicType();
// Get type ID and driver
Handle(BinMDF_ADriver) aDriver;

View File

@@ -204,6 +204,7 @@ void BinMDataStd_NamedDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
if(S.IsNull()) return;
// Standard_Integer i=0;
S->LoadDeferredData();
if(S->HasIntegers() && !S->GetIntegersContainer().IsEmpty()) {
theTarget.PutInteger(1) << S->GetIntegersContainer().Extent(); //dim
TColStd_DataMapIteratorOfDataMapOfStringInteger itr(S->GetIntegersContainer());

View File

@@ -163,12 +163,10 @@ Standard_Boolean BinMXCAFDoc_VisMaterialDriver::Paste (const BinObjMgt_Persisten
aMat->SetDoubleSided (isDoubleSided == '1');
aMat->SetAlphaMode (alphaModeFromChar (anAlphaMode), anAlphaCutOff);
bool hasPbrMat = false;
theSource.GetBoolean (hasPbrMat);
if (hasPbrMat)
XCAFDoc_VisMaterialPBR aPbrMat;
theSource.GetBoolean (aPbrMat.IsDefined);
if (aPbrMat.IsDefined)
{
XCAFDoc_VisMaterialPBR aPbrMat;
aPbrMat.IsDefined = true;
readColor (theSource, aPbrMat.BaseColor);
readVec3 (theSource, aPbrMat.EmissiveFactor);
theSource.GetShortReal (aPbrMat.Metallic);
@@ -196,6 +194,22 @@ Standard_Boolean BinMXCAFDoc_VisMaterialDriver::Paste (const BinObjMgt_Persisten
readTexture (theSource, aComMat.DiffuseTexture);
aMat->SetCommonMaterial (aComMat);
}
if (aVerMaj > MaterialVersionMajor_1
|| (aVerMaj == MaterialVersionMajor_1
&& aVerMin >= MaterialVersionMinor_1))
{
if (aPbrMat.IsDefined)
{
theSource.GetShortReal (aPbrMat.RefractionIndex);
}
}
if (aPbrMat.IsDefined)
{
aMat->SetPbrMaterial (aPbrMat);
}
return Standard_True;
}
@@ -242,4 +256,9 @@ void BinMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSourc
theTarget.PutShortReal (aComMat.Transparency);
writeTexture (theTarget, aComMat.DiffuseTexture);
}
if (aMat->HasPbrMaterial())
{
theTarget.PutShortReal (aMat->PbrMaterial().RefractionIndex);
}
}

View File

@@ -27,7 +27,15 @@ class BinMXCAFDoc_VisMaterialDriver : public BinMDF_ADriver
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_VisMaterialDriver, BinMDF_ADriver)
//! Persistence version (major for breaking changes, minor for adding new fields at end).
enum { MaterialVersionMajor = 1, MaterialVersionMinor = 0 };
enum
{
MaterialVersionMajor_1 = 1,
MaterialVersionMinor_0 = 0,
MaterialVersionMinor_1 = 1, //!< added IOR
MaterialVersionMajor = MaterialVersionMajor_1,
MaterialVersionMinor = MaterialVersionMinor_1
};
public:
//! Main constructor.

View File

@@ -49,17 +49,34 @@ Standard_OStream& BinTools::PutInteger(Standard_OStream& OS, const Standard_Inte
//=======================================================================
//function : PutReal
//purpose :
//purpose :
//=======================================================================
Standard_OStream& BinTools::PutReal(Standard_OStream& OS, const Standard_Real aValue)
Standard_OStream& BinTools::PutReal (Standard_OStream& theOS,
const Standard_Real& theValue)
{
Standard_Real aRValue = aValue;
#if DO_INVERSE
aRValue = InverseReal (aValue);
const Standard_Real aRValue = InverseReal (theValue);
theOS.write((char*)&aRValue, sizeof(Standard_Real));
#else
theOS.write((char*)&theValue, sizeof(Standard_Real));
#endif
OS.write((char*)&aRValue, sizeof(Standard_Real));
return OS;
return theOS;
}
//=======================================================================
//function : PutShortReal
//purpose :
//=======================================================================
Standard_OStream& BinTools::PutShortReal (Standard_OStream& theOS,
const Standard_ShortReal& theValue)
{
#if DO_INVERSE
const Standard_ShortReal aValue = InverseShortReal (theValue);
theOS.write ((char*)&aValue, sizeof(Standard_ShortReal));
#else
theOS.write ((char*)&theValue, sizeof(Standard_ShortReal));
#endif
return theOS;
}
//=======================================================================
@@ -76,19 +93,39 @@ Standard_OStream& BinTools::PutExtChar(Standard_OStream& OS, const Standard_ExtC
OS.write((char*)&aSValue, sizeof(Standard_ExtCharacter));
return OS;
}
//=======================================================================
//function : GetReal
//purpose :
//purpose :
//=======================================================================
Standard_IStream& BinTools::GetReal(Standard_IStream& IS, Standard_Real& aValue)
Standard_IStream& BinTools::GetReal (Standard_IStream& theIS,
Standard_Real& theValue)
{
if(!IS.read ((char*)&aValue, sizeof(Standard_Real)))
if (!theIS.read ((char*)&theValue, sizeof(Standard_Real)))
{
throw Storage_StreamTypeMismatchError();
}
#if DO_INVERSE
aValue = InverseReal (aValue);
theValue = InverseReal (theValue);
#endif
return IS;
return theIS;
}
//=======================================================================
//function : GetShortReal
//purpose :
//=======================================================================
Standard_IStream& BinTools::GetShortReal (Standard_IStream& theIS,
Standard_ShortReal& theValue)
{
if (!theIS.read ((char*)&theValue, sizeof(Standard_ShortReal)))
{
throw Storage_StreamTypeMismatchError();
}
#if DO_INVERSE
theValue = InverseShortReal (theValue);
#endif
return theIS;
}
//=======================================================================
@@ -99,7 +136,7 @@ Standard_IStream& BinTools::GetReal(Standard_IStream& IS, Standard_Real& aValue)
Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, Standard_Integer& aValue)
{
if(!IS.read ((char*)&aValue, sizeof(Standard_Integer)))
throw Storage_StreamTypeMismatchError();;
throw Storage_StreamTypeMismatchError();
#if DO_INVERSE
aValue = InverseInt (aValue);
#endif
@@ -114,7 +151,7 @@ Standard_IStream& BinTools::GetInteger(Standard_IStream& IS, Standard_Integer& a
Standard_IStream& BinTools::GetExtChar(Standard_IStream& IS, Standard_ExtCharacter& theValue)
{
if(!IS.read ((char*)&theValue, sizeof(Standard_ExtCharacter)))
throw Storage_StreamTypeMismatchError();;
throw Storage_StreamTypeMismatchError();
#if DO_INVERSE
theValue = InverseExtChar (theValue);
#endif

View File

@@ -42,9 +42,10 @@ public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static Standard_OStream& PutReal (Standard_OStream& OS, const Standard_Real theValue);
Standard_EXPORT static Standard_OStream& PutReal (Standard_OStream& OS, const Standard_Real& theValue);
Standard_EXPORT static Standard_OStream& PutShortReal (Standard_OStream& OS, const Standard_ShortReal& theValue);
Standard_EXPORT static Standard_OStream& PutInteger (Standard_OStream& OS, const Standard_Integer theValue);
Standard_EXPORT static Standard_OStream& PutBool (Standard_OStream& OS, const Standard_Boolean theValue);
@@ -52,7 +53,9 @@ public:
Standard_EXPORT static Standard_OStream& PutExtChar (Standard_OStream& OS, const Standard_ExtCharacter theValue);
Standard_EXPORT static Standard_IStream& GetReal (Standard_IStream& IS, Standard_Real& theValue);
Standard_EXPORT static Standard_IStream& GetShortReal (Standard_IStream& IS, Standard_ShortReal& theValue);
Standard_EXPORT static Standard_IStream& GetInteger (Standard_IStream& IS, Standard_Integer& theValue);
Standard_EXPORT static Standard_IStream& GetBool (Standard_IStream& IS, Standard_Boolean& theValue);

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