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

Compare commits

...

48 Commits

Author SHA1 Message Date
razmyslovich
30d665dfb0 0025589: modify the wire interference checker to detect all types of intersections 2014-12-10 14:43:53 +01:00
bugmaster
c0bd0de183 Adjusting new testing cases 2014-12-05 14:39:29 +03:00
dbp
558e68ea11 0025398: Modeling Algorithms - Provide shape proximity detector
Correction of test case for issue CR25398
2014-12-05 12:17:58 +03:00
ink
06696fd835 0025518: Colors are not written to IGES 5.3
Writing of colors to IGES Face (510) and Solid (186) entities allowed since this is used by CAD systems (even if not allowed by IGES standard).
Color assigned to surface, face and solid entities to ensure that different CAD systems will recognize them.

Test-case for issue #25518
2014-12-04 15:49:00 +03:00
ski
0b309a75c4 0023983: Cpulimit doesn't kill test cases
Modified command cpulimit using OSD_Timer and method ElapsedTime()

Enabled elapsed time control on Linux.

Added resetting of elapsed timer.

Unused variables were removed

Definition of OSD_Timer aTimer was replaced.

Correction of thread terminating on linux.
2014-12-04 15:46:42 +03:00
aml
368cdde60e 0024988: Wrong result done by projection algorithm
Wrong border 1.0e-9 jump has deleted. Added periodicity information when projecting to surface.
Period "jump" bug fixes.

AppCont_LeastSquare conversion to non cdl class.
AppCont_Function + AppCont_FunctionTool combined in one class providing the same functionality and converted to non cdl.
Testcase modification.

Test cases for issue CR24988

Fixed incorrect comparison.
2014-12-04 15:46:41 +03:00
nbv
e8feb725a4 0025465: Excess vertex in the result of CUT operation
Branches CR25465 and CR25488 were squashed and rebased on the current MASTER (12/01/2014)
2014-12-04 15:46:40 +03:00
kgv
a6964ce627 0025511: Visualization - drop redundant viewer option V3d_View::Transparency()
Visual3d_ViewManager, activate texturing by default.

Update Qt sample
2014-12-04 15:46:38 +03:00
abv
21087d914b 0024944: New custom-built Tcl is source of distribution problems
Option to link to MS run-time library statically added in description of building of Tcl/Tk from sources

Spelling corrections

Order of sections corrected in "Debug tools and hints"
2014-12-04 15:46:37 +03:00
san
7fd6425dc4 0025528: Visualization - Exception on removing an interactive object from a local context
AIS_LocalContext::Remove() corrected to unbind the argument from
myActiveObjects at the very end. Also some code clean up applied
(e.g. duplicated AddOrRemoveSelected() call removed, formatting corrected).

code formatting
2014-12-04 14:20:18 +03:00
kgv
3ea0a91b70 0025484: Visualization - group sub-shapes with the same style in XCAFPrs_AISObject::Compute() 2014-12-04 14:12:11 +03:00
mkv
e159a66863 Adjusting CPU time for new testing cases. 2014-12-01 12:06:02 +03:00
emv
d2d9e8dc0e 0025470: Wrong result of COMMON operation
Fix for correct splitting of infinite faces.

Test cases for issue CR25470
2014-11-28 13:49:46 +03:00
kgv
7e7bbb3a9e 0025514: TKernel, OSD_Timer - do not accumulate error in timer within queries in running state
Test-case for issue #25514

Update of test-case
2014-11-28 13:49:45 +03:00
aml
150e93a7f2 0025487: Extrema_GenExtPS needs to be optimized
Better caching and cashe usage in Extrema_GenExtPS.

Test-cases for issue #25487

Update of test-cases
2014-11-28 13:49:44 +03:00
msv
4a913f2102 0025503: BRepMesh - IncrementalMesh always re-meshes the shape even if existing triangulation satisfies the given deflection
Test case for issue CR25503

Correction of test cases for issue CR25503
2014-11-28 13:49:43 +03:00
kgv
6c6aadb1ff 0025304: Visualization, TKOpenGl - support texturing within built-in GLSL programs 2014-11-28 13:49:42 +03:00
kgv
abdf0b107e 0025474: Visualization, TKOpenGl - support lighting + colored vertices within built-in GLSL programs 2014-11-28 13:49:41 +03:00
emv
b1d15f53b3 0025477: Boolean Operations with additional tolerance - Fuzzy Boolean operations
Implementation of Fuzzy Boolean operations. Such operations allow to perform Boolean operations on the shapes
with near-coincidence between the entities of these shapes, i.e. between shapes in which some entities from one shape
are intended to be coincide with some entities from the other, but the coincidence is not precise.

API for Boolean operations has been improved to have a possibility to add new options.

Modified entities:
1. New option of setting additional tolerance have been added to the following classes:
class BOPAlgo_ArgumentAnalyzer
class BOPAlgo_BOP
class BOPAlgo_Builder
class BOPAlgo_MakerVolume
class BOPAlgo_PaveFiller
class BOPDS_DS
class BRepAlgoAPI_BooleanOperation
class BRepAlgoAPI_Check
class BRepAlgoAPI_Common
class BRepAlgoAPI_Cut
class BRepAlgoAPI_Fuse
class BRepAlgoAPI_Section

2. Following draw commands have been modified to support new functionality:
BOP commands:
bop b1 b2 [tol]
bcommon r b1 b2 [tol]
bcut r b1 b2 [tol]
bfuse r b1 b2 [tol]
bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]
mkvolume r b1 b2 ... [-c] [-ni] [-s] [tol]
bfillds [-s -t] [tol]

Check commands:
bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol]
bopargcheck [-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF] [-tol tol]

3. Two new classes have been added to API to provide the root interface for algorithms
class BRepAlgoAPI_Algo
class BRepAlgoAPI_BuilderAlgo

Fix to eliminate the warning.

Test-cases for issue #25477
2014-11-28 12:24:39 +03:00
osa
49e1a5c7e9 0025507: Visualization - the method V3d_View::Place() is incorrect
Test was updated

Correction of test case for issue CR25507
2014-11-28 12:21:10 +03:00
apn
aa627f0805 0025339: Draw command "mkoffset" does not take into account "intersection" mode on faces
Added test case bugs/modalg_5/bug25339
2014-11-28 12:16:07 +03:00
kgv
8bcdd6976a 0025527: Documentation - remove redundant references to OpenCL 2014-11-28 12:01:14 +03:00
apn
ee0a5d2528 0023460: Update QT products samples
Rename all generation-vc-projects.bat (in OCCT) to genproj.bat.
Fixed warnings in VoxelDemo.
2014-11-28 11:58:39 +03:00
bugmaster
0059facbbf Incrementation of OCCT version up to 6.8.1 dev 2014-11-21 16:16:50 +03:00
mkv
90a9485514 0025354: Intersection operation
Adding test cases
2014-11-21 16:12:48 +03:00
bugmaster
f70d6437bd 0025494: Wrong result obtained by projection algorithm
Calculation of last parameter of projected curve was changed for the projecting of a curve to surface of revolution, if the curve is intersected with the axis of revolution

Test case for issue CR25494
2014-11-21 16:10:52 +03:00
razmyslovich
9bb81d6ce8 0025498: CMake refuses to build OCCT without any 3rd party libraries
Adding guards for empty CMake variables
2014-11-21 15:46:01 +03:00
kgv
e0608a8d27 0025459: Visualization - AIS_ColoredShape::SetMaterial() should not reset custom colors 2014-11-21 15:43:12 +03:00
pkv
e83c01bfc0 0025505: General Fuse produces self-intersection shape
Changes:
class BOPAlgo_BuilderSolid
method:
void BOPAlgo_BuilderSolid::PerformAreas()

The misprint has been corrected

Test case for issue CR25505
2014-11-21 15:42:31 +03:00
azv
c84d6e55ea 0025504: Exception raised during projection curve on surface
Avoid moving of projected point to a boundary of surface

Test case for CR25504
2014-11-21 15:36:40 +03:00
kgv
a86ce5a64a 0025500: Visualization, TKOpenGl - global trihedron should not inherit transformation from last object
Test case for CR25500
2014-11-21 15:34:50 +03:00
jgv
a791eb69f4 0025491: BRepOffsetAPI_MakeOffset algorithm crashes on customer's shape and big value of offset
Test case for CR25491

Correction of test case for issue CR25491
2014-11-21 15:33:13 +03:00
gka
34e923b5c2 0025455: fixshape works at the second attempt
Added check and fix of tolerances of all vertices after performing all fixes.
It is necessary to avoid situation when point of vertex belonging a few faces was changed for current face
but edges containing this vertex belonging before fixed face are not taking into account.
Mode FixVertexTolMode to manage check tolerance of vertices was added in ShapeFix_Shape
class. (default value is equal to -1)
Method to change FixVertexTolMode mode  FixVertexTolMode() was added in ShapeFix_Shape class

Test case for CR25455
2014-11-21 14:53:03 +03:00
nbv
baf72cd2e7 0025488: Wrong result of two trimmed cylinders intersection
1. Function IsSame(...) for IntSurf_PntOn2S was added (see IntSurf_PntOn2S.cdl for detail information).
2. Inserting additional points is forbidden if existing WLine contains only two points coincided.

Test-case for issue #25488
2014-11-21 14:47:57 +03:00
oan
80d659a5a6 0025469: BRepMesh corrupts triangulation of another not connected shape
Do not clean polygons that are created for different faces not connected with current shape.
Remove old code producing additional points for BSpline curves due to fix #24959.

Test cases fir issue CR25469

Revert changes producing additional points for BSpline curves with C1 continuity

Test cases fir issue CR25469

Correction of test cases for issue CR25469
2014-11-21 14:19:28 +03:00
oan
d0a994c7f1 0025479: BRepTools::Clean() cleans all edge polygons, even related to different shapes 2014-11-21 14:11:43 +03:00
jgv
32a15d12db 0025480: Incorrect result of BRepOffsetAPI_MakePipe
Test case for CR25480
2014-11-21 14:05:24 +03:00
isk
4ca4bbe8bd 0025436: Visualization - AIS_InteractiveContext::HilightPreviousDetected() should switch from first value in the list to the last 2014-11-21 14:02:43 +03:00
kgv
8cf06aa236 0025483: Visualization, TKOpenGl - fix memory leak due to unused stack in OpenGl_StateInterface 2014-11-21 14:00:10 +03:00
pkv
0da4579283 0025456: BOPAlgo_CheckerSI reports an error on the given shape
Changes:
1. class IntTools_FaceFace
         method:
         void IntTools_FaceFace::MakeCurve(const Standard_Integer Index,
                                    const Handle(Adaptor3d_TopolTool)& dom1,
                                    const Handle(Adaptor3d_TopolTool)& dom2)

The value of testing parameter has been changed for the cases of infinite curves

Test case for issue CR25456
2014-11-21 13:58:36 +03:00
jgv
4590b5516c 0025451: BRepFilletAPI_MakeFillet fails on customer's shape when small radius of fillet is given
Test-case for issue #25451

Update of test-cases
2014-11-21 13:56:37 +03:00
pkv
cf2439de58 0025449: Excess vertex in result of General Fuse operation.
Changes:
1. class IntTools_EdgeFace
     method:
     Standard_Boolean IntTools_EdgeFace::CheckTouchVertex
     (const IntTools_CommonPrt& aCP,
     Standard_Real& aTx)

The parametric size of the contact zone between vertex and face has been changed

Test cases for issue CR25449
2014-11-21 13:51:18 +03:00
pkv
ceb31c6156 0025450: Common operation returns wrong shape
Changes:
class BOPAlgo_PaveFiller
 method:
 void BOPAlgo_PaveFiller::PerformEF()

 The index of the face has been added in post-treatment map

Test cases for issue CR25450

Correction of test case for issue CR25450
2014-11-21 13:49:09 +03:00
jgv
93442c6f24 0025460: BRepOffsetAPI_ThruSections fails on customer's shape (wing on 11 sections)
Test-case for issue #25460
2014-11-21 13:47:03 +03:00
pkv
393598ebd6 0025432: Wrong result obtained by MakerVolume operator.
Changes:
class BOPTools_AlgoTools
static function:
Standard_Boolean FindPointInFace(const TopoDS_Face& aF,
                                 const gp_Pnt& aP,
                                 gp_Dir& aDB,
                                 gp_Pnt& aPOut,
                                 Handle(IntTools_Context)& theContext,
                                 GeomAPI_ProjectPointOnSurf& aProjPL,
                                 const Standard_Real aDt,
                                 const Standard_Real aTolE)

Binormal calculation starts from the point located outside the tolerance circle of the edge

Test case for issue CR25432

Correction of test cases for issue CR25432
2014-11-21 13:44:45 +03:00
aml
7da00517d4 0025321: Test case bugs/modalg_5(010)/bug24981 hangs in Debug mode on Debian60-64 platform
Eliminated possible inifite loop when projecting curve on surface.
2014-11-21 13:36:28 +03:00
azv
eb7404bf16 0024697: Exception is raised during projection of the curve on the surface
The curve is trimmed since now in the boundaries of surface

Test case for issue CR24697

Behavior for trimming periodic curves was changed
2014-11-21 13:35:20 +03:00
aba
7a733b194b 0025430: DRAW Test Harness: dimensions demo fails
- corrected vdimparam help string;
- added section model file to prevent changing of subshapes order after explode call
2014-11-21 13:33:11 +03:00
309 changed files with 10549 additions and 4701 deletions

View File

@@ -182,15 +182,19 @@ if (3RDPARTY_NOT_INCLUDED)
message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
endif()
list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
include_directories (${3RDPARTY_INCLUDE_DIRS})
if (3RDPARTY_INCLUDE_DIRS)
list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
include_directories (${3RDPARTY_INCLUDE_DIRS})
endif()
list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
link_directories (${3RDPARTY_LIBRARY_DIRS})
if (3RDPARTY_LIBRARY_DIRS)
list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
link_directories (${3RDPARTY_LIBRARY_DIRS})
endif()
OCCT_MAKE_BUILD_POSTFIX()

View File

@@ -63,11 +63,21 @@ Download the necessary archive from http://www.tcl.tk/software/tcltk/download.ht
This is to avoid extra prefix 't' in the library name, which is not recognized by default by OCCT build tools.
3. In the command prompt, run *buildall.vc.bat*
3. By default, Tcl uses dynamic version of run-time library (MSVCRT), which must be installed on the system where Tcl will be used.
You may wish to link Tcl library with static version of run-time to avoid this dependency.
For that:
* Edit file *makefile.vc* replacing strings "crt = -MD" by "crt = -MT"
* Edit source file *tclMain.c* (located in folder *generic*) commenting out forward declaration of function *isatty()*.
4. In the command prompt, run *buildall.vc.bat*
You might need to run this script twice to have *tclsh* executable installed; check subfolder *bin* of specified installation path to verify this.
4. For convenience of use, we recommend making a copy of *tclsh* executable created in subfolder *bin* of *INSTALLDIR* and named with Tcl version number suffix, as *tclsh.exe* (with no suffix)
5. For convenience of use, we recommend making a copy of *tclsh* executable created in subfolder *bin* of *INSTALLDIR* and named with Tcl version number suffix, as *tclsh.exe* (with no suffix)
> cd D:\OCCT\3rdparty\tcltk-86-32\bin
> cp tclsh86.exe tclsh.exe

View File

@@ -3,6 +3,10 @@ Debugging tools and hints {#occt_dev_guides__debug}
@tableofcontents
@section occt_debug_intro Introduction
This manual describes facilities included in OCCT to support debugging, and provides some hints for more efficient debug.
@section occt_debug_macro Compiler macro to enable extended debug messages
Many OCCT algorithms can produce extended debug messages, usually printed to cout.
@@ -23,10 +27,6 @@ Note that some header files are modified when *OCCT_DEBUG* is enabled, hence bin
On Windows platform when using Visual Studio compiler there is a possibility to start the debugger automatically if an exception is caught in a program running OCCT. For this, set environment variable *CSF_DEBUG* to any value. Note that this feature works only if you enable OCCT exception handler in your application by calling *OSD::SetSignal()*.
@section occt_debug_intro Introduction
This manual describes facilities included in OCCT to support debugging, and provides some hints for more efficient debug.
@section occt_debug_bop Self-diagnostics in Boolean operations algorithm
In real-world applications modeling operations are often performed in a long sequence, while the user sees only the final result of the whole sequence. If the final result is wrong, the first debug step is to identify the offending operation to be debugged further. Boolean operation algorithm in OCCT provides a self-diagnostic feature which can help to do that step.

View File

@@ -58,8 +58,7 @@ OPEN CASCADE S.A.S.
**Windows** is a registered trademark of Microsoft Corporation in the United States and other countries.
**Mac** and the Mac logo, **OpenCL** and the OpenCL logo, are trademarks of
Apple Inc., registered in the U.S. and other countries.
**Mac** and the Mac logo are trademarks of Apple Inc., registered in the U.S. and other countries.
Acknowledgements
------------------
@@ -220,14 +219,14 @@ for which OCCT is certified to work.
@subsection OCCT_OVW_SECTION_5_1 Linux
| Operating System | Mandriva 2010, CentOS 5.5, CentOS 6.3, Fedora 17, Fedora 18, Ubuntu-1304, Debian 6.0\* |
| Operating System | Mandriva 2010, CentOS 5.5, CentOS 6.3, Fedora 17, Fedora 18, Ubuntu 13.04, Debian 6.0\* |
| ----- | ----- |
| Minimum memory | 512 MB, 1 GB recommended |
| Free disk space (complete installation) | 600 MB approx. |
| Video card | See \ref overview_req_graphics |
| Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
| C++ | GNU gcc 4.0. - 4.7.3. |
| TCL (for testing tools) | Tcltk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
| TCL (for testing tools) | Tcl/Tk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
| Qt (for demonstration tools) | Qt 4.8.6 http://qt-project.org/downloads |
| Freetype (for text rendering) | freetype-2.5.3 http://sourceforge.net/projects/freetype/files/ |
| FreeImage (optional, for support of common 2D graphic formats) | FreeImage 3.16.0 http://sourceforge.net/projects/freeimage/files |
@@ -235,17 +234,17 @@ for which OCCT is certified to work.
| Intel TBB (optional, for multithreaded algorithms) | TBB 3.x or 4.x http://www.threadingbuildingblocks.org/ |
| VTK (for VTK Integration Services | VTK 6.1.0 http://www.vtk.org/VTK/resources/software.html |
* Debian 60 64 bit is a platform used for regular testing of contributions
* Debian 6.0 64 bit is a platform used for regular testing of contributions
@subsection OCCT_OVW_SECTION_5_2 Windows
| Operating System | Windows 8 / 7 SP1 / Vista SP2 / XP SP3 |
| Operating System | Windows 8.1 / 7 SP1 / Vista SP2 / XP SP3 |
| ----- | ----- |
| Minimum memory | 512 MB, 1 GB recommended |
| Free disk space (complete installation) | 600 MB approx. |
| Video card | See \ref overview_req_graphics |
| Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
| C++ | Microsoft Visual Studio: 2005 SP1, 2008 SP1\*, 2010 SP1, 2012 Update 3, 2013 <br>Intel C++ Composer XE 2013 SP1 |
| C++ | Microsoft Visual Studio: 2005 SP1, 2008 SP1, 2010 SP1 \*, 2012 Update 3, 2013 <br>Intel C++ Composer XE 2013 SP1 |
| TCL (for testing tools) | Tcl/Tk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
| Qt (for demonstration tools) | Qt 4.8.6 http://qt-project.org/downloads |
| Freetype (OCCT Text rendering) | freetype-2.5.3 http://sourceforge.net/projects/freetype/files/ |
@@ -259,14 +258,12 @@ for which OCCT is certified to work.
@subsection OCCT_OVW_SECTION_5_3 MAC OS X
| Operating System | Mac OS X 10.9 Mavericks / 10.8 Mountain Lion / 10.7 Lion / 10.6.8 Snow Leopard |
| Operating System | OS X 10.10 Yosemite / 10.9 Mavericks / 10.8 Mountain Lion / 10.7 Lion / 10.6.8 Snow Leopard |
| ----- | ----- |
| Minimum memory | 512 MB, 1 GB recommended |
| Free disk space (complete installation) | 600 MB approx. |
| Video card | See \ref overview_req_graphics |
| Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
| C++ | XCode 3.2 or newer (4.x is recommended) |
| TCL (for testing tools) | Tcltk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
| TCL (for testing tools) | Tcl/Tk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
| Qt (for demonstration tools) | Qt 4.8.6 http://qt-project.org/downloads |
| Freetype (OCCT Text rendering) | freetype-2.5.3 http://sourceforge.net/projects/freetype/files/ |
| FreeImage (Support of common graphic formats) | FreeImage 3.16.0 http://sourceforge.net/projects/freeimage/files |
@@ -277,27 +274,31 @@ for which OCCT is certified to work.
| Operating System | Android 4.0.4+ |
| ----- | ----- |
| Minimum memory | 512 MB, 1 GB recommended |
| Minimum memory | 512 MB, 1 GB recommended |
| C++ | NDK r10, GNU gcc 4.8 or newer |
| Qt (for demonstration tools) | Qt 5.3.2 http://qt-project.org/downloads |
| Freetype (for text rendering) | freetype-2.5.3 http://sourceforge.net/projects/freetype/files/ |
@subsection overview_req_graphics Graphic cards
For 3d viewer, graphic card or software implementation supporting OpenGL 1.1
or above is required. OpenGL 2.1+ is highly recommended.
For ray tracing, hardware implementation of OpenCL 1.1+ is required.
On desktop, 3D viewer requires graphic card or software implementation supporting OpenGL 1.1 or above. OpenGL 2.1+ is highly recommended.
Ray tracing requires OpenGL 4.0+ or OpenGL 3.1+ with GL_ARB_texture_buffer_object_rgb32 extension. Textures within ray tracing will be available only when GL_ARB_bindless_texture extension is provided by driver.
On mobile platforms, OpenGL ES 2.0+ is required for 3D viewer. The ray tracing is not yet available on mobile platforms.
Some old hardware might be unable to execute complex GLSL programs (e.g. with high number of light sources, clipping planes).
The following table lists graphic cards tested to work with OCCT.
| Graphic card | Driver/GL/GLSL/CL version | OS | OpenGL (fixed pipeline) | OpenGL (shaders) | OpenCL (ray tracing) |
| Graphic card | Driver | OS | OpenGL (fixed pipeline) | OpenGL (shaders) | OpenGL (ray tracing) |
| ---- | ---- | ---- | :----: | :----: | :----: |
| NVIDIA GeForce GT 610, 630M, 640 | Driver 311.44, GL 4.3.0, GLSL 4.30 | Windows 7 64 bit | OK | OK | OK |
| Intel(R) HD Graphics 3000 | GL 3.1.0, GLSL 1.40 | Windows 7 64 bit | OK | OK | none |
| RadeOn 9600 | GL 2.1.8454, GLSL 1.20 | | OK | bad | none |
| AMD/ATI RadeOn HD 7870 | Driver 6.14.10.12002, GL 4.2.12002, GLSL 4.20 | Windows 7 64-bit | OK | OK | OK |
| Mesa 7.8.2 Windows GDI Driver\* | GL 2.1, GLSL version 1.20 | Mac OS X 10.6 / OS X 10.9 | OK | artifacts | none |
| NVIDIA GeForce 320 | | Mac OS X 10.6 / OS X 10.9 | OK | OK | OK on OSX 10.6, bad on OSX 10.9 |
| NVIDIA GeForce 6600 GT | GL 2.1.2, GLSL 1.20 | Windows XP 32-bit | OK | OK | none |
| Apple software OpenGL | | Mac OS X 10.6 / OS X 10.9 | OK | OK | OK |
| NVIDIA GeForce GTX 650 | Driver 340.52, OpenGL 4.4 | Windows 7 64 bit | OK | OK | OK |
| AMD/ATI RadeOn HD 7870 | Driver 14.100, OpenGL 4.4 | Windows 7 64-bit | OK | OK | OK |
| Intel(R) HD Graphics 2500 | Driver 10.18.10.3621, OpenGL 4.0 | Windows 7 64 bit | OK | OK | limited (no textures) |
| RadeOn 9600 | OpenGL 2.1.8454 | Windows XP 32-bit | OK | bad | unsupported by hardware |
| NVIDIA GeForce 6600 GT | OpenGL 2.1 | Windows XP 32-bit | OK | OK | unsupported by hardware |
| NVIDIA GeForce 320 | N/A | Mac OS X 10.6 / OS X 10.10 | OK | OK | not yet supported by OCCT |
| Apple software OpenGL | N/A | Mac OS X 10.6 / OS X 10.10 | OK | OK | N/A |
| Mesa 10.2.4 \* | "Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits)" OpenGL 3.0 | Windows 7 64 bit | OK | OK | unsupported by software |
* Mesa implementation of OpenGL is used for certification testing of OCCT

View File

@@ -48,7 +48,7 @@
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
/>
<Tool
@@ -123,7 +123,7 @@
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="3"
/>
<Tool

View File

@@ -12,7 +12,7 @@ Timer::Timer():myWriter(0) {}
Timer::Timer(const char* filename)
{
myWriter = fopen(filename, "a");
fopen_s(&myWriter,filename, "a");
}
Timer::~Timer()

View File

@@ -51,7 +51,6 @@ Viewer::Viewer(QWidget* parent):QWidget(parent)
myView->MustBeResized();
myView->SetSurfaceDetail(V3d_TEX_NONE);
myView->SetTransparency(Standard_True);
myView->SetSize(10000.0);
myView->SetZSize(10000.0);
myView->SetViewMappingDefault();

View File

@@ -323,7 +323,7 @@ static void setColor(const Quantity_Color& color, const Standard_Boolean highlig
{
static Quantity_Color highlight_color(Quantity_NOC_BLUE1);
if(highlight)
glColor3f(highlight_color.Red(), highlight_color.Green(), highlight_color.Blue());
glColor3f((GLfloat)highlight_color.Red(), (GLfloat)highlight_color.Green(), (GLfloat)highlight_color.Blue());
else
glColor3d(color.Red(), color.Green(), color.Blue());
}

View File

@@ -1,29 +1,28 @@
# Demo script for dimensions
puts "Dimensions demo: it shows capability of OCC to create different kinds "
puts "of dimensions (linear and angular) with 2D or 3D text."
#Category: Demos
#Title: Dimensions in 3d viewer
set dispScriptFile [file normalize [info script]]
set scriptFolder [file dirname $dispScriptFile]
# Dimensions demo
#
# It shows capability of OCC to create different kinds
# of dimensions (linear and angular) with 2D or 3D text.
set aTopLoc [locate_data_file occ/Top.brep]
set aBotLoc [locate_data_file occ/Bottom.brep]
set aHatch [locate_data_file images/hatch_1.png]
if { ![file exist "$aTopLoc"] || ![file exist "$aBotLoc"] } {
puts "No model file in current directory!"
puts "Please put Bottom.brep and Top.brep in current directory and try again"
}
pload MODELING VISUALIZATION
puts "Importing shapes..."
restore $aTopLoc a
restore $aBotLoc b
vinit View1 w=768 h=768
vclear
vsetdispmode 0
vsetcolorbg 255 255 255
vbottom
# Get cut projection
puts "Getting cut projection..."
box bb -150 -250 0 150 250 100
bsection bs b bb
bsection as a bb
@@ -33,58 +32,58 @@ vfit
set anAEdges [explode as E]
set aBEbges [explode bs E]
#foreach e [concat $anAEdges $aBEbges] { vdisplay $e }
set anArrAngle [expr 3.14 * 12.0 / 180.0]
set aList {das_7 dbs_27 dbs_6 dbs_19 das_25 das_26 dbs_22 das_43 das_12 das_41 dbs_39 dbs_59 das_3944 dbs_1826 das_4843}
# Form dimension names list to set parameters with vdimparam command
set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
for {set i 1} {$i <= 10} {incr i} {
lappend aList ld_$i
}
vdimension dbs_19 -length -shapes bs_27 -plane xoy -color black -flyout -15
vdimension dbs_6 -length -shapes bs_14 -plane xoy -color black -flyout 15
vdimension dbs_27 -length -shapes bs_28 -plane xoy -color black -label right -flyout -27
vdimension das_7 -length -shapes as_7 -plane xoy -color black -flyout -20
vdimension das_25 -length -shapes as_28 -plane xoy -color black -flyout -15
vdimension das_26 -length -shapes as_18 -plane xoy -color black -flyout 30
vdimension dbs_22 -length -shapes bs_20 -plane xoy -color black -flyout -20
vdimension das_43 -length -shapes as_43 -plane xoy -color black -flyout 55 -label right
vdimension das_12 -length -shapes as_12 -plane xoy -color black -flyout 35 -label right
vdimension das_41 -length -shapes as_40 -plane xoy -color black -flyout 15
puts "Creating dimensions..."
vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
vdimension ld_2 -length -shapes bs_14 -plane xoy -color black -flyout 15
vdimension ld_3 -length -shapes bs_28 -plane xoy -color black -label right -flyout -27
vdimension ld_4 -length -shapes as_7 -plane xoy -color black -flyout -20
vdimension ld_5 -length -shapes as_28 -plane xoy -color black -flyout -15
vdimension ld_6 -length -shapes as_18 -plane xoy -color black -flyout 30
vdimension ld_7 -length -shapes bs_20 -plane xoy -color black -flyout -20
vdimension ld_8 -length -shapes as_43 -plane xoy -color black -flyout 55 -label right
vdimension ld_9 -length -shapes as_12 -plane xoy -color black -flyout 35 -label right
vdimension ld_10 -length -shapes as_40 -plane xoy -color black -flyout 15
vdimension dbs_39 -radius -shapes bs_45 -color black -label right
vdimension dbs_59 -radius -shapes bs_63 -color black
vdimension rd_1 -radius -shapes bs_45 -color black -label right
vdimension rd_2 -radius -shapes bs_63 -color black
vdimension das_3944 -angle -shapes as_38 as_49 -color black
vdimension dbs_1826 -angle -shapes bs_24 bs_25 -color black
vdimension das_4843 -angle -shapes as_48 as_43 -color black
vdimension ad_1 -angle -shapes as_38 as_49 -color black
vdimension ad_2 -angle -shapes bs_24 bs_25 -color black
vdimension ad_3 -angle -shapes as_48 as_43 -color black
puts "Changing text and arrow paramaters of dimensions..."
foreach i $aList {
vdimparam $i text=3d textsize=6 textmode=s arlength=4 arangle=$anArrAngle
vdimparam $i -text 3d sh 6 -arrowlength 4 -arrowangle $anArrAngle
}
# Final fit
foreach e [concat $anAEdges $aBEbges] {
vremove $e
}
vfit
puts "Displaying exported shapes..."
vdisplay a b
vsetdispmode a 1
vsetdispmode b 1
vaspects a -setmaterial steel
vaspects b -setmaterial bronze
# set clipping plane
puts "Clipping shapes for better view..."
vclipplane create pa
vclipplane change pa equation 0 0 1 0
vclipplane change pa capping on
vclipplane change pa capping color 0.9 0.9 0.9
#vclipplane change pa capping hatch on
vclipplane set pa object a
vclipplane create pb
vclipplane change pb equation 0 0 1 0
vclipplane change pb capping on
vclipplane change pb capping color 1.0 0.8 0.0
#vclipplane change pb capping hatch on
vclipplane set pb object b
vsettexturemode Driver1/Viewer1/View1 2
@@ -93,8 +92,9 @@ vclipplane change pa capping texscale 0.05 -0.05
vclipplane change pb capping texname $aHatch
vclipplane change pb capping texscale 0.05 0.05
# nice view
vbottom
vrotate -0.3 -0.3 0
vfit
vzoom 1.2
puts "Done."

View File

@@ -269,6 +269,28 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
}
}
//=======================================================================
//function : SetMaterial
//purpose :
//=======================================================================
void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
{
setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
//myOwnMaterial = theMaterial;
hasOwnMaterial = Standard_True;
LoadRecomputable (AIS_Shaded);
for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
{
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
//if (aDrawer->HasOwnMaterial()) continue;
if (aDrawer->HasShadingAspect())
{
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), Standard_False); // aDrawer->IsTransparent()
}
}
}
//=======================================================================
//function : Compute
//purpose :
@@ -425,6 +447,30 @@ Standard_Boolean AIS_ColoredShape::dispatchColors (const TopoDS_Shape& th
return isOverriden || isSubOverride;
}
//! Function to check if specified compound is sub-shape of another one
inline Standard_Boolean isContainCompound (const TopoDS_Shape& theShape,
const TopoDS_Compound& theCompound)
{
if (theShape.ShapeType() != TopAbs_COMPOUND)
{
return Standard_False;
}
for (TopoDS_Iterator aSubShapeIter (theShape); aSubShapeIter.More(); aSubShapeIter.Next())
{
if (aSubShapeIter.Value().ShapeType() != TopAbs_COMPOUND)
{
continue;
}
else if (aSubShapeIter.Value() == theCompound
|| isContainCompound (aSubShapeIter.Value(), theCompound))
{
return Standard_True;
}
}
return Standard_False;
}
//=======================================================================
//function : dispatchColors
//purpose :
@@ -438,11 +484,11 @@ void AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseShape,
// This needed when colored shape is not part of <theBaseShape>
// (but subshapes are) and actually container for subshapes.
DataMapOfShapeShape aSubshapeKeyshapeMap;
for (DataMapOfShapeColor::Iterator anIt (theKeyshapeColorMap);
anIt.More(); anIt.Next())
for (DataMapOfShapeColor::Iterator aKeyShapeIter (theKeyshapeColorMap);
aKeyShapeIter.More(); aKeyShapeIter.Next())
{
const TopoDS_Shape& aSh = anIt.Key();
TopAbs_ShapeEnum aType = aSh.ShapeType();
const TopoDS_Shape& aKeySh = aKeyShapeIter.Key();
const TopAbs_ShapeEnum aType = aKeySh.ShapeType();
TopAbs_ShapeEnum aSubType = (aType == TopAbs_SOLID || aType == TopAbs_SHELL)
? TopAbs_FACE
: (aType == TopAbs_WIRE ? TopAbs_EDGE : TopAbs_SHAPE);
@@ -450,16 +496,30 @@ void AIS_ColoredShape::dispatchColors (const TopoDS_Shape& theBaseShape,
{
case TopAbs_SHAPE:
{
aSubshapeKeyshapeMap.Bind (aSh, aSh);
if (aType == TopAbs_COMPOUND
&& !isContainCompound (theBaseShape, TopoDS::Compound (aKeySh)))
{
for (TopoDS_Iterator aSubShapeIter (aKeySh); aSubShapeIter.More(); aSubShapeIter.Next())
{
if (!aSubshapeKeyshapeMap.IsBound (aSubShapeIter.Value()))
{
aSubshapeKeyshapeMap.Bind (aSubShapeIter.Value(), aKeySh);
}
}
}
else
{
aSubshapeKeyshapeMap.Bind (aKeySh, aKeySh);
}
break;
}
default:
{
for (TopExp_Explorer anExp (aSh, aSubType); anExp.More(); anExp.Next())
for (TopExp_Explorer anExp (aKeySh, aSubType); anExp.More(); anExp.Next())
{
if (!aSubshapeKeyshapeMap.IsBound (anExp.Current()))
{
aSubshapeKeyshapeMap.Bind (anExp.Current(), aSh);
aSubshapeKeyshapeMap.Bind (anExp.Current(), aKeySh);
}
}
}

View File

@@ -104,6 +104,9 @@ public: //! @name global aspects
//! Sets transparency value.
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
//! Sets the material aspect.
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
protected: //! @name override presentation computation
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,

View File

@@ -16,9 +16,6 @@
// Modified by XAB & Serguei Dec 97 (angle &deviation coeffts)
#define BUC60577 //GG_101099 Enable to compute correctly
// transparency with more than one object in the view.
#define BUC60632 //GG 15/03/00 Add protection on SetDisplayMode()
// method, compute only authorized presentation.
@@ -450,9 +447,7 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
}
}
}
if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
myMainVwr->Viewer()->SetTransparency(Standard_True);
if(updateviewer) myMainVwr->Update();
}
@@ -460,11 +455,7 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
else
{
myLocalContexts(myCurLocalIndex)->Display(anIObj,DispMode,anIObj->AcceptShapeDecomposition(),SelMode);
if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
myMainVwr->Viewer()->SetTransparency(Standard_True);
if(updateviewer) myMainVwr->Update();
}
}
@@ -1585,9 +1576,7 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
if(STATUS->IsSubIntensityOn()){
myMainPM->Color(anIObj,mySubIntensity,aMode);
}
if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
myMainVwr->Viewer()->SetTransparency(Standard_True);
if(updateviewer) myMainVwr->Update();
}
anIObj->SetDisplayMode(aMode);
@@ -2159,18 +2148,17 @@ void AIS_InteractiveContext::SetTransparency(const Handle(AIS_InteractiveObject)
if(!anIObj->HasInteractiveContext())
anIObj->SetContext(this);
#ifdef BUC60577 //right optimization
if(!anIObj->IsTransparent() && aValue<=0.05) return;
#else
// if(!anIObj->IsTransparent() && aValue<=0.05) return;
#endif
if (!anIObj->IsTransparent()
&& aValue <= 0.05)
{
return;
}
if(aValue<=0.05){
UnsetTransparency(anIObj,updateviewer);
return;
}
if(!myMainVwr->Viewer()->Transparency())
myMainVwr->Viewer()->SetTransparency(Standard_True);
anIObj->SetTransparency(aValue);
if(anIObj->RecomputeEveryPrs())
anIObj->Redisplay();
@@ -2209,17 +2197,6 @@ void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObjec
anIObj->SetRecomputeOk();
}
// To Unset transparency in the viewer, if no other object is transparent ...(Speed)
AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);
Standard_Boolean FoundTransp(Standard_False);
for(;It.More() && !FoundTransp ;It.Next()){
if(It.Key()->IsTransparent())
FoundTransp = Standard_True;
}
if(!FoundTransp)
myMainVwr->Viewer()->SetTransparency(Standard_False);
if(updateviewer)
UpdateCurrentViewer();
}

View File

@@ -445,65 +445,67 @@ void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectab
Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& aSelectable)
{
if(!myActiveObjects.IsBound(aSelectable)) return Standard_False;
if(!myActiveObjects.IsBound (aSelectable))
{
return Standard_False;
}
if (IsSelected (aSelectable))
{
AddOrRemoveSelected (aSelectable, Standard_False);
}
const Handle(AIS_LocalStatus)& Att = myActiveObjects (aSelectable);
if(IsSelected(aSelectable))
AddOrRemoveSelected(aSelectable,Standard_False);
const Handle(AIS_LocalStatus)& Att = myActiveObjects(aSelectable);
TColStd_ListIteratorOfListOfInteger It;
// it is checked which were the temporary attributes
// and they are set to 0
// desactivate standard modes
if(Att->Decomposed()){
for(It.Initialize(myListOfStandardMode);It.More();It.Next()){
mySM->Deactivate(aSelectable,It.Value(),myMainVS);
// Deactivate standard modes
if (Att->Decomposed())
{
for (It.Initialize (myListOfStandardMode); It.More(); It.Next())
{
mySM->Deactivate (aSelectable, It.Value(), myMainVS);
}
}
// if object or temporary presentations...
if(Att->IsTemporary())
{
if(Att->IsSubIntensityOn())
myMainPM->Unhighlight(aSelectable,Att->HilightMode());
// remove if bug on clear correct...
myMainPM->Erase(aSelectable,Att->DisplayMode());
myMainPM->Clear(aSelectable,Att->DisplayMode());
if(myMainPM->IsDisplayed(aSelectable,Att->HilightMode()))
myMainPM->Erase(aSelectable,Att->HilightMode());
// myMainPM->Clear(aSelectable,Att->HilightMode());
}
// if below intensity
else
{
if(Att->IsSubIntensityOn())
myCTX->SubIntensityOff(aSelectable);
}
// desactivate stored proper modes
for(It.Initialize(Att->SelectionModes());It.More();It.Next()){
mySM->Deactivate(aSelectable,It.Value(),myMainVS);
}
// pop : si je laisses cela plantes dans les elements de construction
// alors a toi de jouer ROB
// RemoveSelected(aSelectable);
if(IsSelected(aSelectable))
AddOrRemoveSelected(aSelectable);
myActiveObjects.UnBind(aSelectable);
// If object or temporary presentations
if (Att->IsTemporary())
{
if (Att->IsSubIntensityOn())
{
myMainPM->Unhighlight (aSelectable, Att->HilightMode());
}
myMainPM->Erase (aSelectable, Att->DisplayMode());
myMainPM->Clear (aSelectable, Att->DisplayMode());
if (myMainPM->IsDisplayed (aSelectable, Att->HilightMode()))
{
myMainPM->Erase (aSelectable, Att->HilightMode());
}
}
// If subintensity used
else if (Att->IsSubIntensityOn())
{
myCTX->SubIntensityOff (aSelectable);
}
// Deactivate stored selection modes
for (It.Initialize (Att->SelectionModes()); It.More(); It.Next())
{
mySM->Deactivate (aSelectable, It.Value(), myMainVS);
}
// Remove the interactive object from selection manager
if (mySM->Contains (aSelectable))
{
mySM->Remove (aSelectable);
}
UpdateSort();
ClearOutdatedSelection (aSelectable, Standard_True);
// This should be done at the very end because most methods use
// myActiveObjects even during clean-up
myActiveObjects.UnBind (aSelectable);
return Standard_True;
}

View File

@@ -1455,9 +1455,10 @@ Standard_Integer AIS_LocalContext::HilightPreviousDetected (const Handle(V3d_Vie
return 0;
}
const Standard_Integer aLen = myDetectedSeq.Length();
if (--myCurDetected < 1)
{
myCurDetected = 1;
myCurDetected = aLen;
}
Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
if (anOwner.IsNull())

View File

@@ -306,6 +306,13 @@ uses
theValue : Real from Standard)
is protected;
setMaterial (me;
theDrawer : Drawer from AIS;
theMaterial : MaterialAspect from Graphic3d;
theToKeepColor : Boolean from Standard;
theToKeepTransp : Boolean from Standard)
is protected;
fields
myshape : Shape from TopoDS is protected;
myBB : Box from Bnd is protected;

View File

@@ -710,6 +710,35 @@ void AIS_Shape::UnsetWidth()
LoadRecomputable (AIS_WireFrame);
}
//=======================================================================
//function : setMaterial
//purpose :
//=======================================================================
void AIS_Shape::setMaterial (const Handle(AIS_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToKeepColor,
const Standard_Boolean theToKeepTransp) const
{
const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
if (!theDrawer->HasShadingAspect())
{
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
}
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
if (theToKeepColor)
{
theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
}
if (theToKeepTransp)
{
theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
}
}
//=======================================================================
//function : SetMaterial
//purpose :
@@ -727,20 +756,9 @@ void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
if (!myDrawer->HasShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
}
setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
if (HasColor())
{
myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
}
myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();

View File

@@ -29,45 +29,22 @@ package AppCont
---Level : Advanced.
-- All methods of all classes will be advanced.
uses AppParCurves, Geom, math, StdFail, TCollection, TColStd, gp,
TColgp, Standard
is
-------------------------------
--- Algorithms:
-------------------------------
generic class LeastSquare;
imported LeastSquare;
------------------------------------------------------
--- Necessary class for approximation a function f(t):
------------------------------------------------------
deferred class Function;
class FunctionTool;
---------------------------------------------------------
--- Necessary class for approximation a 2d function f(t):
---------------------------------------------------------
deferred class Function2d;
class FunctionTool2d;
class FitFunction instantiates LeastSquare from AppCont
(Function from AppCont, FunctionTool from AppCont);
class FitFunction2d instantiates LeastSquare from AppCont
(Function2d from AppCont, FunctionTool2d from AppCont);
imported Function;
end AppCont;

View File

@@ -1,50 +0,0 @@
-- Created on: 1993-09-01
-- Created by: Laurent PAINNOT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
deferred class Function from AppCont
---Purpose: deferred class describing a continous 3d function f(u)
-- This class must be provided by the user to use the
-- approximation algorithm FittingCurve.
uses Pnt from gp,
Vec from gp
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~AppCont_Function(){Delete() ; }"
FirstParameter(me) returns Real
---Purpose: returns the first parameter of the function.
is deferred;
LastParameter(me) returns Real
---Purpose: returns the last parameter of the function.
is deferred;
Value(me; U: Real) returns Pnt
---Purpose: returns the point at parameter <U>.
is deferred;
D1(me; U: Real; P: in out Pnt; V: in out Vec) returns Boolean
---Purpose: returns the point and the derivative values at
-- the parameter <U>.
is deferred;
end Function;

View File

@@ -0,0 +1,91 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef AppCont_Function_HeaderFile
#define AppCont_Function_HeaderFile
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <NCollection_Array1.hxx>
#include <Standard_Integer.hxx>
//! Class describing a continous 3d and/or function f(u).
//! This class must be provided by the user to use the approximation algorithm FittingCurve.
class AppCont_Function
{
public:
Standard_EXPORT AppCont_Function()
{
myNbPnt = -1;
myNbPnt2d = -1;
}
//! Get number of 3d and 2d points returned by "Value" and "D1" functions.
Standard_EXPORT void GetNumberOfPoints(Standard_Integer& theNbPnt,
Standard_Integer& theNbPnt2d) const
{
theNbPnt = myNbPnt;
theNbPnt2d = myNbPnt2d;
}
//! Get number of 3d points returned by "Value" and "D1" functions.
Standard_EXPORT Standard_Integer GetNbOf3dPoints() const
{
return myNbPnt;
}
//! Get number of 2d points returned by "Value" and "D1" functions.
Standard_EXPORT Standard_Integer GetNbOf2dPoints() const
{
return myNbPnt2d;
}
Standard_EXPORT virtual ~AppCont_Function() {}
//! Returns the first parameter of the function.
Standard_EXPORT virtual Standard_Real FirstParameter() const = 0;
//! Returns the last parameter of the function.
Standard_EXPORT virtual Standard_Real LastParameter() const = 0;
//! Returns the point at parameter <theU>.
Standard_EXPORT virtual Standard_Boolean Value(const Standard_Real theU,
NCollection_Array1<gp_Pnt2d>& thePnt2d,
NCollection_Array1<gp_Pnt>& thePnt) const = 0;
//! Returns the derivative at parameter <theU>.
Standard_EXPORT virtual Standard_Boolean D1(const Standard_Real theU,
NCollection_Array1<gp_Vec2d>& theVec2d,
NCollection_Array1<gp_Vec>& theVec) const = 0;
//! Return information about peridicity in output paramateters space.
//! @param theDimIdx Defines index in output parameters space. 1 <= theDimIdx <= 3 * myNbPnt + 2 * myNbPnt2d.
Standard_EXPORT virtual void PeriodInformation(const Standard_Integer /*theDimIdx*/,
Standard_Boolean& IsPeriodic,
Standard_Real& thePeriod) const
{
IsPeriodic = Standard_False;
thePeriod = 0.0;
};
protected:
Standard_Integer myNbPnt;
Standard_Integer myNbPnt2d;
};
#endif

View File

@@ -1,50 +0,0 @@
-- Created on: 1993-09-01
-- Created by: Laurent PAINNOT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
deferred class Function2d from AppCont
---Purpose: deferred class describing a continous 2d function f(u)
-- This class must be provided by the user to use the
-- approximation algorithm FittingCurve2d.
uses Pnt2d from gp,
Vec2d from gp
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~AppCont_Function2d(){Delete() ; }"
FirstParameter(me) returns Real
---Purpose: returns the first parameter of the function.
is deferred;
LastParameter(me) returns Real
---Purpose: returns the last parameter of the function.
is deferred;
Value(me; U: Real) returns Pnt2d
---Purpose: returns the point at parameter <U>.
is deferred;
D1(me; U: Real; P: in out Pnt2d; V: in out Vec2d) returns Boolean
---Purpose: returns the point and the derivative values at
-- the parameter <U>.
is deferred;
end Function2d;

View File

@@ -1,18 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AppCont_Function2d.ixx>
void AppCont_Function2d::Delete()
{}

View File

@@ -1,86 +0,0 @@
-- Created on: 1993-09-01
-- Created by: Laurent PAINNOT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class FunctionTool from AppCont
---Purpose: This class is the inteface between the Function
-- class and the tool asked by LeastSquare.
uses Function from AppCont,
Pnt from gp,
Pnt2d from gp,
Vec from gp,
Vec2d from gp,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
Array1OfVec from TColgp,
Array1OfVec2d from TColgp
is
FirstParameter(myclass; C: Function from AppCont) returns Real;
---Purpose: returns the first parameter of the Function.
LastParameter(myclass; C: Function from AppCont) returns Real;
---Purpose: returns the last parameter of the Function.
NbP2d(myclass; C: Function from AppCont) returns Integer;
---Purpose: Returns 0.
NbP3d(myclass; C: Function from AppCont) returns Integer;
---Purpose: Returns 1. (the approximation will be done only for one
-- function.
Value(myclass; C: Function from AppCont; U: Real; tabPt: out Array1OfPnt);
---Purpose: <tabP> is an array of only 1 element, the point value at
-- the parameter <U>.
D1(myclass; C: Function from AppCont; U: Real; tabV: out Array1OfVec)
returns Boolean;
---Purpose: <tabV> is an array of only 1 element, the derivative
-- value at the parameter <U>.
----------------------------------------------------------
-- the following methods won t be called by the algorithms
-- but the description must exist in the tool.
----------------------------------------------------------
Value(myclass; C: Function from AppCont;U: Real;
tabPt2d: out Array1OfPnt2d);
Value(myclass; C: Function from AppCont; U: Real;
tabPt: out Array1OfPnt;
tabPt2d: out Array1OfPnt2d);
D1(myclass;C: Function from AppCont;U: Real;
tabV2d: out Array1OfVec2d)
returns Boolean;
D1(myclass; C: Function from AppCont; U: Real;
tabV: out Array1OfVec;
tabV2d: out Array1OfVec2d)
returns Boolean;
end FunctionTool;

View File

@@ -1,109 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AppCont_FunctionTool.ixx>
#include <AppCont_Function.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
Standard_Real AppCont_FunctionTool::FirstParameter
(const AppCont_Function& F)
{
return F.FirstParameter();
}
Standard_Real AppCont_FunctionTool::LastParameter
(const AppCont_Function& F)
{
return F.LastParameter();
}
Standard_Integer AppCont_FunctionTool::NbP2d
(const AppCont_Function&)
{
return (0);
}
Standard_Integer AppCont_FunctionTool::NbP3d
(const AppCont_Function&)
{
return (1);
}
void AppCont_FunctionTool::Value(const AppCont_Function& F,
const Standard_Real U,
TColgp_Array1OfPnt& tabPt)
{
tabPt(tabPt.Lower()) = F.Value(U);
}
Standard_Boolean AppCont_FunctionTool::D1
(const AppCont_Function& F,
const Standard_Real U,
TColgp_Array1OfVec& tabV)
{
gp_Pnt P;
gp_Vec V;
Standard_Boolean Ok = F.D1(U, P, V);
tabV(tabV.Lower()) = V;
return Ok;
}
void AppCont_FunctionTool::Value(const AppCont_Function&,
const Standard_Real,
TColgp_Array1OfPnt2d&)
{
}
void AppCont_FunctionTool::Value(const AppCont_Function&,
const Standard_Real,
TColgp_Array1OfPnt&,
TColgp_Array1OfPnt2d&)
{
}
Standard_Boolean AppCont_FunctionTool::D1
(const AppCont_Function&,
const Standard_Real,
TColgp_Array1OfVec2d&)
{
return (Standard_True);
}
Standard_Boolean AppCont_FunctionTool::D1
(const AppCont_Function&,
const Standard_Real,
TColgp_Array1OfVec&,
TColgp_Array1OfVec2d&)
{
return (Standard_True);
}

View File

@@ -1,86 +0,0 @@
-- Created on: 1993-09-01
-- Created by: Laurent PAINNOT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class FunctionTool2d from AppCont
---Purpose: This class is the inteface between the Function2d
-- class and the tool asked by LeastSquare.
uses Function2d from AppCont,
Pnt from gp,
Pnt2d from gp,
Vec from gp,
Vec2d from gp,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
Array1OfVec from TColgp,
Array1OfVec2d from TColgp
is
FirstParameter(myclass; C: Function2d from AppCont) returns Real;
---Purpose: returns the first parameter of the Function.
LastParameter(myclass; C: Function2d from AppCont) returns Real;
---Purpose: returns the last parameter of the Function.
NbP2d(myclass; C: Function2d from AppCont) returns Integer;
---Purpose: Returns 1. (the approximation will be done only for one
-- function.
NbP3d(myclass; C: Function2d from AppCont) returns Integer;
---Purpose: Returns 0.
Value(myclass; C: Function2d from AppCont;
U: Real; tabPt: out Array1OfPnt2d);
---Purpose: <tabP> is an array of only 1 element, the point value at
-- the parameter <U>.
D1(myclass; C: Function2d from AppCont; U: Real; tabV: out Array1OfVec2d)
returns Boolean;
---Purpose: <tabV> is an array of only 1 element, the derivative
-- value at the parameter <U>.
----------------------------------------------------------
-- the following methods won t be called by the algorithms
-- but the description must exist in the tool.
----------------------------------------------------------
Value(myclass; C: Function2d from AppCont;U: Real;
tabPt2d: out Array1OfPnt);
Value(myclass; C: Function2d from AppCont; U: Real;
tabPt: out Array1OfPnt;
tabPt2d: out Array1OfPnt2d);
D1(myclass;C: Function2d from AppCont;U: Real;
tabV2d: out Array1OfVec)
returns Boolean;
D1(myclass; C: Function2d from AppCont; U: Real;
tabV: out Array1OfVec;
tabV2d: out Array1OfVec2d)
returns Boolean;
end FunctionTool2d;

View File

@@ -1,109 +0,0 @@
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AppCont_FunctionTool2d.ixx>
#include <AppCont_Function2d.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
Standard_Real AppCont_FunctionTool2d::FirstParameter
(const AppCont_Function2d& F)
{
return F.FirstParameter();
}
Standard_Real AppCont_FunctionTool2d::LastParameter
(const AppCont_Function2d& F)
{
return F.LastParameter();
}
Standard_Integer AppCont_FunctionTool2d::NbP2d
(const AppCont_Function2d&)
{
return (1);
}
Standard_Integer AppCont_FunctionTool2d::NbP3d
(const AppCont_Function2d&)
{
return (0);
}
void AppCont_FunctionTool2d::Value(const AppCont_Function2d& F,
const Standard_Real U,
TColgp_Array1OfPnt2d& tabPt)
{
tabPt(tabPt.Lower()) = F.Value(U);
}
Standard_Boolean AppCont_FunctionTool2d::D1
(const AppCont_Function2d& F,
const Standard_Real U,
TColgp_Array1OfVec2d& tabV)
{
gp_Pnt2d P;
gp_Vec2d V;
Standard_Boolean Ok = F.D1(U, P, V);
tabV(tabV.Lower()) = V;
return Ok;
}
void AppCont_FunctionTool2d::Value(const AppCont_Function2d&,
const Standard_Real,
TColgp_Array1OfPnt&)
{
}
void AppCont_FunctionTool2d::Value(const AppCont_Function2d&,
const Standard_Real,
TColgp_Array1OfPnt&,
TColgp_Array1OfPnt2d&)
{
}
Standard_Boolean AppCont_FunctionTool2d::D1
(const AppCont_Function2d&,
const Standard_Real,
TColgp_Array1OfVec&)
{
return (Standard_False);
}
Standard_Boolean AppCont_FunctionTool2d::D1
(const AppCont_Function2d&,
const Standard_Real,
TColgp_Array1OfVec&,
TColgp_Array1OfVec2d&)
{
return (Standard_False);
}

View File

@@ -1,108 +0,0 @@
-- Created on: 1993-04-22
-- Created by: Laurent PAINNOT
-- Copyright (c) 1993-1999 Matra Datavision
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
generic class LeastSquare from AppCont(MultiLine as any;
LineTool as any)
---as TheToolLine(MultiLine)
---Purpose: Makes an approximation of a continous Line described by
-- the tool TheLineTool.
-- Minimizing the difference between the approximate result
-- Curve and a continous MultiLine
uses Matrix from math,
Vector from math,
Constraint from AppParCurves,
MultiCurve from AppParCurves
raises NotDone from StdFail,
OutOfRange from Standard,
DimensionError from Standard
is
Create(SSP: MultiLine; U0, U1: Real; FirstCons, LastCons: Constraint;
Deg: Integer; NbPoints: Integer = 24)
---Purpose: given a continous MultiLine, this algorithm computes
-- the approximation into Bezier curves.
-- NbPoints points are taken on the initial MultiLine for
-- minimizing the surface between the MultiLine and the
-- Bezier curves doing the approximation.
-- The first point will be the point of parameter U0 with
-- a constraint FirstCons.
-- The last point will be the point of parameter U1 with
-- a constraint LastCons.
returns LeastSquare from AppCont
raises DimensionError from Standard;
IsDone(me)
---Purpose: returns True if all has been correctly done.
returns Boolean
is static;
Value(me: in out)
---Purpose: returns the result of the approximation, i.e. a
-- MultiCurve.
-- An exception is raised if NotDone.
---C++: return const &
returns MultiCurve from AppParCurves
raises NotDone from StdFail
is static;
NbBColumns(me; SSP: MultiLine)
---Purpose: is internally used by the constuctor.
returns Integer
is static protected;
Error(me; F: in out Real; MaxE3d, MaxE2d: in out Real)
---Purpose: F is the sum of the square errors at each of the
-- NbPoints of the MultiLine.
-- MaxE3d is the maximum 3d value of these errors.
-- MaxE2d is the maximum 2d value of these errors.
-- An exception is raised if NotDone.
raises NotDone from StdFail
is static;
fields
Done: Boolean;
SCU: MultiCurve from AppParCurves;
Degre: Integer;
Nbdiscret: Integer;
nbP: Integer;
nbP2d: Integer;
Points: Matrix;
Poles: Matrix;
myParam: Vector;
VB: Matrix;
end LeastSquare from AppCont;

View File

@@ -0,0 +1,566 @@
// Created on: 1995-03-14
// Created by: Modelistation
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
#define No_Standard_OutOfRange
#define No_Standard_RangeError
#endif
#include <AppCont_LeastSquare.hxx>
#include <math.hxx>
#include <AppParCurves_MultiPoint.hxx>
#include <AppCont_ContMatrices.hxx>
#include <PLib.hxx>
//=======================================================================
//function : AppCont_LeastSquare
//purpose :
//=======================================================================
void AppCont_LeastSquare::FixSingleBorderPoint(const AppCont_Function& theSSP,
const Standard_Real theU,
const Standard_Real theU0,
const Standard_Real theU1,
NCollection_Array1<gp_Pnt2d>& theFix2d,
NCollection_Array1<gp_Pnt>& theFix)
{
Standard_Real aMaxIter = 15.0;
Standard_Integer j, i2;
NCollection_Array1<gp_Pnt> aTabP(1, Max (myNbP, 1)), aPrevP(1, Max (myNbP, 1));
NCollection_Array1<gp_Pnt2d> aTabP2d(1, Max (myNbP2d, 1)), aPrevP2d(1, Max (myNbP2d, 1));
Standard_Real aMult = ((theU - theU0) > (theU1 - theU)) ? 1.0: -1.0;
Standard_Real aStartParam = (theU0 + theU1) / 2.0,
aCurrParam, aPrevDist = 1.0, aCurrDist = 1.0;
for (Standard_Real anIter = 1.0; anIter < aMaxIter; anIter += 1.0)
{
aCurrParam = aStartParam + aMult * (1 - pow(10, -anIter)) * (theU1 - theU0) / 2.0;
theSSP.Value(aCurrParam, aTabP2d, aTabP);
// from second iteration
if (anIter > 1.5)
{
aCurrDist = 0.0;
i2 = 1;
for (j = 1; j <= myNbP; j++)
{
aCurrDist += aTabP(j).Distance(aPrevP(j));
i2 += 3;
}
for (j = 1; j <= myNbP2d; j++)
{
aCurrDist += aTabP2d(j).Distance(aPrevP2d(j));
i2 += 2;
}
// from the third iteration
if (anIter > 2.5 && aCurrDist / aPrevDist > 10.0)
break;
}
aPrevP = aTabP;
aPrevP2d = aTabP2d;
aPrevDist = aCurrDist;
}
theFix2d = aPrevP2d;
theFix = aPrevP;
}
//=======================================================================
//function : AppCont_LeastSquare
//purpose :
//=======================================================================
AppCont_LeastSquare::AppCont_LeastSquare(const AppCont_Function& SSP,
const Standard_Real U0,
const Standard_Real U1,
const AppParCurves_Constraint FirstCons,
const AppParCurves_Constraint LastCons,
const Standard_Integer Deg,
const Standard_Integer myNbPoints)
: mySCU(Deg+1),
myPoints(1, myNbPoints, 1, 3 * SSP.GetNbOf3dPoints() + 2 * SSP.GetNbOf2dPoints()),
myPoles(1, Deg + 1, 1, 3 * SSP.GetNbOf3dPoints() + 2 * SSP.GetNbOf2dPoints(), 0.0),
myParam(1, myNbPoints),
myVB(1, Deg+1, 1, myNbPoints),
myPerInfo(1, 3 * SSP.GetNbOf3dPoints() + 2 * SSP.GetNbOf2dPoints() )
{
myDone = Standard_False;
myDegre = Deg;
math_Matrix InvM(1, Deg+1, 1, Deg + 1);
Standard_Integer i, j, k, c, i2;
Standard_Integer classe = Deg + 1, cl1 = Deg;
Standard_Real U, dU, Coeff, Coeff2;
Standard_Real IBij, IBPij;
Standard_Integer FirstP = 1, LastP = myNbPoints;
Standard_Integer nbcol = 3 * SSP.GetNbOf3dPoints() + 2 * SSP.GetNbOf2dPoints();
math_Matrix B(1, classe, 1, nbcol, 0.0);
Standard_Integer bdeb = 1, bfin = classe;
AppParCurves_Constraint myFirstC = FirstCons, myLastC = LastCons;
SSP.GetNumberOfPoints(myNbP, myNbP2d);
Standard_Integer i2plus1, i2plus2;
myNbdiscret = myNbPoints;
NCollection_Array1<gp_Pnt> aTabP(1, Max (myNbP, 1));
NCollection_Array1<gp_Pnt2d> aTabP2d(1, Max (myNbP2d, 1));
NCollection_Array1<gp_Vec> aTabV(1, Max (myNbP, 1));
NCollection_Array1<gp_Vec2d> aTabV2d(1, Max (myNbP2d, 1));
for(Standard_Integer aDimIdx = 1; aDimIdx <= myNbP * 3 + myNbP2d * 2; aDimIdx++)
{
SSP.PeriodInformation(aDimIdx,
myPerInfo(aDimIdx).isPeriodic,
myPerInfo(aDimIdx).myPeriod);
}
Standard_Boolean Ok;
if (myFirstC == AppParCurves_TangencyPoint)
{
Ok = SSP.D1(U0, aTabV2d, aTabV);
if (!Ok) myFirstC = AppParCurves_PassPoint;
}
if (myLastC == AppParCurves_TangencyPoint)
{
Ok = SSP.D1(U1, aTabV2d, aTabV);
if (!Ok) myLastC = AppParCurves_PassPoint;
}
// Compute control points params on which approximation will be built.
math_Vector GaussP(1, myNbPoints), GaussW(1, myNbPoints);
math::GaussPoints(myNbPoints, GaussP);
math::GaussWeights(myNbPoints, GaussW);
math_Vector TheWeights(1, myNbPoints), VBParam(1, myNbPoints);
dU = 0.5*(U1-U0);
for (i = FirstP; i <= LastP; i++)
{
U = 0.5 * (U1 + U0) + dU * GaussP(i);
if (i <= (myNbPoints+1)/2)
{
myParam(LastP - i + 1) = U;
VBParam(LastP - i + 1) = 0.5 * (1 + GaussP(i));
TheWeights(LastP - i + 1) = 0.5 * GaussW(i);
}
else
{
VBParam(i - (myNbPoints + 1) / 2) = 0.5*(1 + GaussP(i));
myParam(i - (myNbPoints + 1) / 2) = U;
TheWeights(i - (myNbPoints+ 1) / 2) = 0.5 * GaussW(i);
}
}
// Compute control points.
for (i = FirstP; i <= LastP; i++)
{
U = myParam(i);
SSP.Value(U, aTabP2d, aTabP);
i2 = 1;
for (j = 1; j <= myNbP; j++)
{
(aTabP(j)).Coord(myPoints(i, i2), myPoints(i, i2+1), myPoints(i, i2+2));
i2 += 3;
}
for (j = 1; j <= myNbP2d; j++)
{
(aTabP2d(j)).Coord(myPoints(i, i2), myPoints(i, i2+1));
i2 += 2;
}
}
// Fix possible "period jump".
Standard_Integer aMaxDim = 3 * myNbP + 2 * myNbP2d;
for(Standard_Integer aDimIdx = 1; aDimIdx <= aMaxDim; aDimIdx++)
{
if (myPerInfo(aDimIdx).isPeriodic &&
Abs (myPoints(1, aDimIdx) - myPoints(2, aDimIdx)) > myPerInfo(aDimIdx).myPeriod / 2.01 &&
Abs (myPoints(2, aDimIdx) - myPoints(3, aDimIdx)) < myPerInfo(aDimIdx).myPeriod / 2.01)
{
Standard_Real aPeriodMult = (myPoints(1, aDimIdx) < myPoints(2, aDimIdx)) ? 1.0 : -1.0;
Standard_Real aNewParam = myPoints(1, aDimIdx) + aPeriodMult * myPerInfo(aDimIdx).myPeriod;
myPoints(1, aDimIdx) = aNewParam;
}
}
for (Standard_Integer aPntIdx = 1; aPntIdx < myNbPoints; aPntIdx++)
{
for(Standard_Integer aDimIdx = 1; aDimIdx <= aMaxDim; aDimIdx++)
{
if (myPerInfo(aDimIdx).isPeriodic &&
Abs ( myPoints(aPntIdx, aDimIdx) - myPoints(aPntIdx + 1, aDimIdx) ) > myPerInfo(aDimIdx).myPeriod / 2.01)
{
Standard_Real aPeriodMult = (myPoints(aPntIdx, aDimIdx) > myPoints(aPntIdx + 1, aDimIdx)) ? 1.0 : -1.0;
Standard_Real aNewParam = myPoints(aPntIdx + 1, aDimIdx) + aPeriodMult * myPerInfo(aDimIdx).myPeriod;
myPoints(aPntIdx + 1, aDimIdx) = aNewParam;
}
}
}
VBernstein(classe, myNbPoints, myVB);
// Traitement du second membre:
NCollection_Array1<Standard_Real> tmppoints(1, nbcol);
for (c = 1; c <= classe; c++)
{
tmppoints.Init(0.0);
for (i = 1; i <= myNbPoints; i++)
{
Coeff = TheWeights(i) * myVB(c, i);
for (j = 1; j <= nbcol; j++)
{
tmppoints(j) += myPoints(i, j)*Coeff;
}
}
for (k = 1; k <= nbcol; k++)
{
B(c, k) += tmppoints(k);
}
}
if (myFirstC == AppParCurves_NoConstraint &&
myLastC == AppParCurves_NoConstraint) {
math_Matrix InvM(1, classe, 1, classe);
InvMMatrix(classe, InvM);
// Calcul direct des poles:
for (i = 1; i <= classe; i++) {
for (j = 1; j <= classe; j++) {
IBij = InvM(i, j);
for (k = 1; k <= nbcol; k++) {
myPoles(i, k) += IBij * B(j, k);
}
}
}
}
else
{
math_Matrix M(1, classe, 1, classe);
MMatrix(classe, M);
NCollection_Array1<gp_Pnt2d> aFixP2d(1, Max (myNbP2d, 1));
NCollection_Array1<gp_Pnt> aFixP(1, Max (myNbP, 1));
if (myFirstC == AppParCurves_PassPoint ||
myFirstC == AppParCurves_TangencyPoint)
{
SSP.Value(U0, aTabP2d, aTabP);
FixSingleBorderPoint(SSP, U0, U0, U1, aFixP2d, aFixP);
i2 = 1;
for (k = 1; k<= myNbP; k++)
{
if (aFixP(k).Distance(aTabP(k)) > 0.1)
(aFixP(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1), myPoles(1, i2 + 2));
else
(aTabP(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1), myPoles(1, i2 + 2));
i2 += 3;
}
for (k = 1; k<= myNbP2d; k++)
{
if (aFixP2d(k).Distance(aTabP2d(k)) > 0.1)
(aFixP2d(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1));
else
(aTabP2d(k)).Coord(myPoles(1, i2), myPoles(1, i2 + 1));
i2 += 2;
}
for (Standard_Integer aDimIdx = 1; aDimIdx <= aMaxDim; aDimIdx++)
{
if (myPerInfo(aDimIdx).isPeriodic &&
Abs ( myPoles(1, aDimIdx) - myPoints(1, aDimIdx) ) > myPerInfo(aDimIdx).myPeriod / 2.01 )
{
Standard_Real aMult = myPoles(1, aDimIdx) < myPoints(1, aDimIdx)? 1.0: -1.0;
myPoles(1,aDimIdx) += aMult * myPerInfo(aDimIdx).myPeriod;
}
}
}
if (myLastC == AppParCurves_PassPoint ||
myLastC == AppParCurves_TangencyPoint)
{
SSP.Value(U1, aTabP2d, aTabP);
FixSingleBorderPoint(SSP, U1, U0, U1, aFixP2d, aFixP);
i2 = 1;
for (k = 1; k<= myNbP; k++)
{
if (aFixP(k).Distance(aTabP(k)) > 0.1)
(aFixP(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1), myPoles(classe, i2 + 2));
else
(aTabP(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1), myPoles(classe, i2 + 2));
i2 += 3;
}
for (k = 1; k<= myNbP2d; k++)
{
if (aFixP2d(k).Distance(aTabP2d(k)) > 0.1)
(aFixP2d(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1));
else
(aTabP2d(k)).Coord(myPoles(classe, i2), myPoles(classe, i2 + 1));
i2 += 2;
}
for (Standard_Integer aDimIdx = 1; aDimIdx <= 2; aDimIdx++)
{
if (myPerInfo(aDimIdx).isPeriodic &&
Abs ( myPoles(classe, aDimIdx) - myPoints(myNbPoints, aDimIdx) ) > myPerInfo(aDimIdx).myPeriod / 2.01 )
{
Standard_Real aMult = myPoles(classe, aDimIdx) < myPoints(myNbPoints, aDimIdx)? 1.0: -1.0;
myPoles(classe,aDimIdx) += aMult * myPerInfo(aDimIdx).myPeriod;
}
}
}
if (myFirstC == AppParCurves_PassPoint) {
bdeb = 2;
// mise a jour du second membre:
for (i = 1; i <= classe; i++) {
Coeff = M(i, 1);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= myPoles(1, k)*Coeff;
}
}
}
if (myLastC == AppParCurves_PassPoint) {
bfin = cl1;
for (i = 1; i <= classe; i++) {
Coeff = M(i, classe);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= myPoles(classe, k)*Coeff;
}
}
}
if (myFirstC == AppParCurves_TangencyPoint) {
// On fixe le second pole::
bdeb = 3;
SSP.D1(U0, aTabV2d, aTabV);
i2 = 1;
Coeff = (U1-U0)/myDegre;
for (k = 1; k<= myNbP; k++) {
i2plus1 = i2+1; i2plus2 = i2+2;
myPoles(2, i2) = myPoles(1, i2) + aTabV(k).X()*Coeff;
myPoles(2, i2plus1) = myPoles(1, i2plus1) + aTabV(k).Y()*Coeff;
myPoles(2, i2plus2) = myPoles(1, i2plus2) + aTabV(k).Z()*Coeff;
i2 += 3;
}
for (k = 1; k<= myNbP2d; k++) {
i2plus1 = i2+1;
myPoles(2, i2) = myPoles(1, i2) + aTabV2d(k).X()*Coeff;
myPoles(2, i2plus1) = myPoles(1, i2plus1) + aTabV2d(k).Y()*Coeff;
i2 += 2;
}
for (i = 1; i <= classe; i++) {
Coeff = M(i, 1); Coeff2 = M(i, 2);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= myPoles(1, k)*Coeff+myPoles(2, k)*Coeff2;
}
}
}
if (myLastC == AppParCurves_TangencyPoint) {
bfin = classe-2;
SSP.D1(U1, aTabV2d, aTabV);
i2 = 1;
Coeff = (U1-U0)/myDegre;
for (k = 1; k<= myNbP; k++) {
i2plus1 = i2+1; i2plus2 = i2+2;
myPoles(cl1,i2) = myPoles(classe, i2) - aTabV(k).X()*Coeff;
myPoles(cl1,i2plus1) = myPoles(classe, i2plus1) - aTabV(k).Y()*Coeff;
myPoles(cl1,i2plus2) = myPoles(classe, i2plus2) - aTabV(k).Z()*Coeff;
i2 += 3;
}
for (k = 1; k<= myNbP2d; k++) {
i2plus1 = i2+1;
myPoles(cl1,i2) = myPoles(classe, i2) - aTabV2d(k).X()*Coeff;
myPoles(cl1,i2plus1) = myPoles(classe, i2plus1) - aTabV2d(k).Y()*Coeff;
i2 += 2;
}
for (i = 1; i <= classe; i++) {
Coeff = M(i, classe); Coeff2 = M(i, cl1);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= myPoles(classe, k)*Coeff + myPoles(cl1, k)*Coeff2;
}
}
}
if (bdeb <= bfin) {
math_Matrix B2(bdeb, bfin, 1, B.UpperCol(), 0.0);
for (i = bdeb; i <= bfin; i++) {
for (j = 1; j <= classe; j++) {
Coeff = M(i, j);
for (k = 1; k <= nbcol; k++) {
B2(i, k) += B(j, k)*Coeff;
}
}
}
// Resolution:
// ===========
math_Matrix IBP(bdeb, bfin, bdeb, bfin);
// dans IBPMatrix at IBTMatrix ne sont stockees que les resultats pour
// une classe inferieure ou egale a 26 (pour l instant du moins.)
if (bdeb == 2 && bfin == classe-1 && classe <= 26) {
IBPMatrix(classe, IBP);
}
else if (bdeb == 3 && bfin == classe-2 && classe <= 26) {
IBTMatrix(classe, IBP);
}
else {
math_Matrix MP(1, classe, bdeb, bfin);
for (i = 1; i <= classe; i++) {
for (j = bdeb; j <= bfin; j++) {
MP(i, j) = M(i, j);
}
}
math_Matrix IBP1(bdeb, bfin, bdeb, bfin);
IBP1 = MP.Transposed()*MP;
IBP = IBP1.Inverse();
}
myDone = Standard_True;
for (i = bdeb; i <= bfin; i++) {
for (j = bdeb; j <= bfin; j++) {
IBPij = IBP(i, j);;
for (k = 1; k<= nbcol; k++) {
myPoles(i, k) += IBPij * B2(j, k);
}
}
}
}
}
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const AppParCurves_MultiCurve& AppCont_LeastSquare::Value()
{
Standard_Integer i, j, j2;
gp_Pnt Pt;
gp_Pnt2d Pt2d;
Standard_Integer ideb = 1, ifin = myDegre+1;
// On met le resultat dans les curves correspondantes
for (i = ideb; i <= ifin; i++) {
j2 = 1;
AppParCurves_MultiPoint MPole(myNbP, myNbP2d);
for (j = 1; j <= myNbP; j++) {
Pt.SetCoord(myPoles(i, j2), myPoles(i, j2+1), myPoles(i,j2+2));
MPole.SetPoint(j, Pt);
j2 += 3;
}
for (j = myNbP+1;j <= myNbP+myNbP2d; j++) {
Pt2d.SetCoord(myPoles(i, j2), myPoles(i, j2+1));
MPole.SetPoint2d(j, Pt2d);
j2 += 2;
}
mySCU.SetValue(i, MPole);
}
return mySCU;
}
//=======================================================================
//function : Error
//purpose :
//=======================================================================
void AppCont_LeastSquare::Error(Standard_Real& F,
Standard_Real& MaxE3d,
Standard_Real& MaxE2d) const
{
Standard_Integer i, j, k, c, i2, classe = myDegre + 1;
Standard_Real Coeff, err3d = 0.0, err2d = 0.0;
Standard_Integer ncol = myPoints.UpperCol() - myPoints.LowerCol() + 1;
math_Matrix MyPoints(1, myNbdiscret, 1, ncol);
MyPoints = myPoints;
MaxE3d = MaxE2d = F = 0.0;
NCollection_Array1<Standard_Real> tmppoles(1, ncol);
for (c = 1; c <= classe; c++)
{
for (k = 1; k <= ncol; k++)
{
tmppoles(k) = myPoles(c, k);
}
for (i = 1; i <= myNbdiscret; i++)
{
Coeff = myVB(c, i);
for (j = 1; j <= ncol; j++)
{
MyPoints(i, j) -= tmppoles(j) * Coeff;
}
}
}
Standard_Real e1, e2, e3;
for (i = 1; i <= myNbdiscret; i++)
{
i2 = 1;
for (j = 1; j<= myNbP; j++) {
e1 = MyPoints(i, i2);
e2 = MyPoints(i, i2+1);
e3 = MyPoints(i, i2+2);
err3d = e1*e1+e2*e2+e3*e3;
MaxE3d = Max(MaxE3d, err3d);
F += err3d;
i2 += 3;
}
for (j = 1; j<= myNbP2d; j++) {
e1 = MyPoints(i, i2);
e2 = MyPoints(i, i2+1);
err2d = e1*e1+e2*e2;
MaxE2d = Max(MaxE2d, err2d);
F += err2d;
i2 += 2;
}
}
MaxE3d = Sqrt(MaxE3d);
MaxE2d = Sqrt(MaxE2d);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean AppCont_LeastSquare::IsDone() const
{
return myDone;
}

View File

@@ -1,504 +0,0 @@
// Created on: 1995-03-14
// Created by: Modelistation
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OCCT_DEBUG
#define No_Standard_OutOfRange
#define No_Standard_RangeError
#endif
#include <math.hxx>
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Vec2d.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <AppParCurves_MultiPoint.hxx>
#include <AppCont_ContMatrices.hxx>
#include <PLib.hxx>
//=======================================================================
//function : AppCont_LeastSquare
//purpose :
//=======================================================================
AppCont_LeastSquare::AppCont_LeastSquare
(const MultiLine& SSP,
const Standard_Real U0,
const Standard_Real U1,
const AppParCurves_Constraint FirstCons,
const AppParCurves_Constraint LastCons,
const Standard_Integer Deg,
const Standard_Integer NbPoints):
SCU(Deg+1),
Points(1, NbPoints, 1, NbBColumns(SSP)),
Poles(1, Deg+1, 1, NbBColumns(SSP), 0.0),
myParam(1, NbPoints),
VB(1, Deg+1, 1, NbPoints)
{
Done = Standard_False;
Degre = Deg;
math_Matrix InvM(1, Deg+1, 1, Deg+1);
Standard_Integer i, j, k, c, i2;
Standard_Integer classe = Deg+1, cl1 = Deg;
Standard_Real U, dU, Coeff, Coeff2;
Standard_Real IBij, IBPij;
Standard_Integer FirstP = 1, LastP = NbPoints;
Standard_Integer nbcol = NbBColumns(SSP);
math_Matrix B(1, classe, 1, nbcol, 0.0);
Standard_Integer bdeb = 1, bfin = classe;
AppParCurves_Constraint myFirstC = FirstCons, myLastC = LastCons;
nbP = LineTool::NbP3d(SSP);
nbP2d = LineTool::NbP2d(SSP);
Standard_Integer mynbP = nbP, mynbP2d = nbP2d;
if (nbP == 0) mynbP = 1;
if (nbP2d == 0) mynbP2d = 1;
Standard_Integer i2plus1, i2plus2;
Nbdiscret = NbPoints;
TColgp_Array1OfPnt TabP(1, mynbP);
TColgp_Array1OfVec TabV(1, mynbP);
TColgp_Array1OfPnt2d TabP2d(1, mynbP2d);
TColgp_Array1OfVec2d TabV2d(1, mynbP2d);
Standard_Boolean Ok;
if (myFirstC == AppParCurves_TangencyPoint) {
if (nbP != 0 && nbP2d != 0) Ok=LineTool::D1(SSP, U0, TabV, TabV2d);
else if (nbP != 0) Ok=LineTool::D1(SSP, U0, TabV);
else Ok=LineTool::D1(SSP, U0, TabV2d);
if (!Ok) myFirstC = AppParCurves_PassPoint;
}
if (myLastC == AppParCurves_TangencyPoint) {
if (nbP != 0 && nbP2d != 0) Ok=LineTool::D1(SSP, U1, TabV, TabV2d);
else if (nbP != 0) Ok=LineTool::D1(SSP, U1, TabV);
else Ok=LineTool::D1(SSP, U1, TabV2d);
if (!Ok) myLastC = AppParCurves_PassPoint;
}
math_Vector GaussP(1, NbPoints), GaussW(1, NbPoints);
math::GaussPoints(NbPoints, GaussP);
math::GaussWeights(NbPoints, GaussW);
math_Vector TheWeights(1, NbPoints), VBParam(1, NbPoints);
dU = 0.5*(U1-U0);
// calcul et mise en ordre des parametres et des poids:
for (i = FirstP; i <= LastP; i++) {
U = 0.5*(U1+U0) + dU*GaussP(i);
if (i <= (NbPoints+1)/2) {
myParam(LastP-i+1) = U;
VBParam(LastP-i+1) = 0.5*(1 + GaussP(i));
TheWeights(LastP-i+1) = 0.5*GaussW(i);
}
else {
VBParam(i-(NbPoints+1)/2) = 0.5*(1 + GaussP(i));
myParam(i-(NbPoints+1)/2) = U;
TheWeights(i-(NbPoints+1)/2) = 0.5*GaussW(i);
}
}
for (i = FirstP; i <= LastP; i++) {
U = myParam(i);
if (nbP != 0 && nbP2d != 0) LineTool::Value(SSP, U, TabP, TabP2d);
else if (nbP != 0) LineTool::Value(SSP, U, TabP);
else LineTool::Value(SSP, U, TabP2d);
i2 = 1;
for (j = 1; j <= nbP; j++) {
(TabP(j)).Coord(Points(i, i2), Points(i, i2+1), Points(i, i2+2));
i2 += 3;
}
for (j = 1; j <= nbP2d; j++) {
(TabP2d(j)).Coord(Points(i, i2), Points(i, i2+1));
i2 += 2;
}
}
// Calcul du VB ( Valeur des fonctions de Bernstein):
// for (i = 1; i <= classe; i++) {
// for (j = 1; j <= NbPoints; j++) {
// VB(i,j)=PLib::Binomial(cl1,i-1)*Pow((1-VBParam(j)),classe-i)*
// Pow(VBParam(j),i-1);
// }
// }
VBernstein(classe, NbPoints, VB);
// Traitement du second membre:
Standard_Real *tmppoints, *tmpbis;
tmppoints = new Standard_Real[nbcol];
for (c = 1; c <= classe; c++) {
tmpbis = tmppoints;
for (k = 1; k <= nbcol; k++, tmpbis++) {
*tmpbis = 0.0;
}
for (i = 1; i <= NbPoints; i++) {
Coeff = TheWeights(i)*VB(c, i);
tmpbis = tmppoints;
for (j = 1; j <= nbcol; j++, tmpbis++) {
*tmpbis += Points(i, j)*Coeff;
//B(c, j) += Points(i, j)*Coeff;
}
}
tmpbis = tmppoints;
for (k = 1; k <= nbcol; k++, tmpbis++) {
B(c, k) += *tmpbis;
}
}
delete [] tmppoints;
if (myFirstC == AppParCurves_NoConstraint &&
myLastC == AppParCurves_NoConstraint) {
math_Matrix InvM(1, classe, 1, classe);
InvMMatrix(classe, InvM);
// Calcul direct des poles:
for (i = 1; i <= classe; i++) {
for (j = 1; j <= classe; j++) {
IBij = InvM(i, j);
for (k = 1; k <= nbcol; k++) {
Poles(i, k) += IBij * B(j, k);
}
}
}
}
else {
math_Matrix M(1, classe, 1, classe);
MMatrix(classe, M);
if (myFirstC == AppParCurves_PassPoint ||
myFirstC == AppParCurves_TangencyPoint) {
if (nbP != 0 && nbP2d != 0) LineTool::Value(SSP, U0, TabP, TabP2d);
else if (nbP != 0) LineTool::Value(SSP, U0, TabP);
else LineTool::Value(SSP, U0, TabP2d);
i2 =1;
for (k = 1; k<= nbP; k++) {
(TabP(k)).Coord(Poles(1, i2), Poles(1, i2+1), Poles(1, i2+2));
i2 += 3;
}
for (k = 1; k<= nbP2d; k++) {
(TabP2d(k)).Coord(Poles(1, i2), Poles(1, i2+1));
i2 += 2;
}
}
if (myLastC == AppParCurves_PassPoint ||
myLastC == AppParCurves_TangencyPoint) {
i2 = 1;
if (nbP != 0 && nbP2d != 0) LineTool::Value(SSP, U1, TabP, TabP2d);
else if (nbP != 0) LineTool::Value(SSP, U1, TabP);
else LineTool::Value(SSP, U1, TabP2d);
for (k = 1; k<= nbP; k++) {
(TabP(k)).Coord(Poles(classe,i2),
Poles(classe,i2+1),
Poles(classe,i2+2));
i2 += 3;
}
for (k = 1; k<= nbP2d; k++) {
(TabP2d(k)).Coord(Poles(classe, i2), Poles(classe, i2+1));
i2 += 2;
}
}
if (myFirstC == AppParCurves_PassPoint) {
bdeb = 2;
// mise a jour du second membre:
for (i = 1; i <= classe; i++) {
Coeff = M(i, 1);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= Poles(1, k)*Coeff;
}
}
}
if (myLastC == AppParCurves_PassPoint) {
bfin = cl1;
for (i = 1; i <= classe; i++) {
Coeff = M(i, classe);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= Poles(classe, k)*Coeff;
}
}
}
if (myFirstC == AppParCurves_TangencyPoint) {
// On fixe le second pole::
bdeb = 3;
if (nbP != 0 && nbP2d != 0) LineTool::D1(SSP, U0, TabV, TabV2d);
else if (nbP != 0) LineTool::D1(SSP, U0, TabV);
else LineTool::D1(SSP, U0, TabV2d);
i2 = 1;
Coeff = (U1-U0)/Degre;
for (k = 1; k<= nbP; k++) {
i2plus1 = i2+1; i2plus2 = i2+2;
Poles(2, i2) = Poles(1, i2) + TabV(k).X()*Coeff;
Poles(2, i2plus1) = Poles(1, i2plus1) + TabV(k).Y()*Coeff;
Poles(2, i2plus2) = Poles(1, i2plus2) + TabV(k).Z()*Coeff;
i2 += 3;
}
for (k = 1; k<= nbP2d; k++) {
i2plus1 = i2+1;
Poles(2, i2) = Poles(1, i2) + TabV2d(k).X()*Coeff;
Poles(2, i2plus1) = Poles(1, i2plus1) + TabV2d(k).Y()*Coeff;
i2 += 2;
}
for (i = 1; i <= classe; i++) {
Coeff = M(i, 1); Coeff2 = M(i, 2);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= Poles(1, k)*Coeff+Poles(2, k)*Coeff2;
}
}
}
if (myLastC == AppParCurves_TangencyPoint) {
bfin = classe-2;
if (nbP != 0 && nbP2d != 0) LineTool::D1(SSP, U1, TabV, TabV2d);
else if (nbP != 0) LineTool::D1(SSP, U1, TabV);
else LineTool::D1(SSP, U1, TabV2d);
i2 = 1;
Coeff = (U1-U0)/Degre;
for (k = 1; k<= nbP; k++) {
i2plus1 = i2+1; i2plus2 = i2+2;
Poles(cl1,i2) = Poles(classe, i2) - TabV(k).X()*Coeff;
Poles(cl1,i2plus1) = Poles(classe, i2plus1) - TabV(k).Y()*Coeff;
Poles(cl1,i2plus2) = Poles(classe, i2plus2) - TabV(k).Z()*Coeff;
i2 += 3;
}
for (k = 1; k<= nbP2d; k++) {
i2plus1 = i2+1;
Poles(cl1,i2) = Poles(classe, i2) - TabV2d(k).X()*Coeff;
Poles(cl1,i2plus1) = Poles(classe, i2plus1) - TabV2d(k).Y()*Coeff;
i2 += 2;
}
for (i = 1; i <= classe; i++) {
Coeff = M(i, classe); Coeff2 = M(i, cl1);
for (k = 1; k <= nbcol; k++) {
B(i, k) -= Poles(classe, k)*Coeff + Poles(cl1, k)*Coeff2;
}
}
}
if (bdeb <= bfin) {
math_Matrix B2(bdeb, bfin, 1, B.UpperCol(), 0.0);
for (i = bdeb; i <= bfin; i++) {
for (j = 1; j <= classe; j++) {
Coeff = M(i, j);
for (k = 1; k <= nbcol; k++) {
B2(i, k) += B(j, k)*Coeff;
}
}
}
// Resolution:
// ===========
math_Matrix IBP(bdeb, bfin, bdeb, bfin);
// dans IBPMatrix at IBTMatrix ne sont stockees que les resultats pour
// une classe inferieure ou egale a 26 (pour l instant du moins.)
if (bdeb == 2 && bfin == classe-1 && classe <= 26) {
IBPMatrix(classe, IBP);
}
else if (bdeb == 3 && bfin == classe-2 && classe <= 26) {
IBTMatrix(classe, IBP);
}
else {
math_Matrix MP(1, classe, bdeb, bfin);
for (i = 1; i <= classe; i++) {
for (j = bdeb; j <= bfin; j++) {
MP(i, j) = M(i, j);
}
}
math_Matrix IBP1(bdeb, bfin, bdeb, bfin);
IBP1 = MP.Transposed()*MP;
IBP = IBP1.Inverse();
}
Done = Standard_True;
for (i = bdeb; i <= bfin; i++) {
for (j = bdeb; j <= bfin; j++) {
IBPij = IBP(i, j);;
for (k = 1; k<= nbcol; k++) {
Poles(i, k) += IBPij * B2(j, k);
}
}
}
}
}
}
//=======================================================================
//function : NbBColumns
//purpose :
//=======================================================================
Standard_Integer AppCont_LeastSquare::NbBColumns(
const MultiLine& SSP) const
{
Standard_Integer BCol;
BCol = (LineTool::NbP3d(SSP))*3 +
(LineTool::NbP2d(SSP))*2;
return BCol;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const AppParCurves_MultiCurve& AppCont_LeastSquare::Value()
{
Standard_Integer i, j, j2;
gp_Pnt Pt;
gp_Pnt2d Pt2d;
Standard_Integer ideb = 1, ifin = Degre+1;
// On met le resultat dans les curves correspondantes
for (i = ideb; i <= ifin; i++) {
j2 = 1;
AppParCurves_MultiPoint MPole(nbP, nbP2d);
for (j = 1; j <= nbP; j++) {
Pt.SetCoord(Poles(i, j2), Poles(i, j2+1), Poles(i,j2+2));
MPole.SetPoint(j, Pt);
j2 += 3;
}
for (j = nbP+1;j <= nbP+nbP2d; j++) {
Pt2d.SetCoord(Poles(i, j2), Poles(i, j2+1));
MPole.SetPoint2d(j, Pt2d);
j2 += 2;
}
SCU.SetValue(i, MPole);
}
return SCU;
}
//=======================================================================
//function : Error
//purpose :
//=======================================================================
void AppCont_LeastSquare::Error(Standard_Real& F,
Standard_Real& MaxE3d,
Standard_Real& MaxE2d) const
{
Standard_Integer i, j, k, c, i2, classe = Degre+1;
// Standard_Real Coeff, val = 0.0, err3d = 0.0, err2d =0.0;
Standard_Real Coeff, err3d = 0.0, err2d =0.0;
Standard_Integer ncol = Points.UpperCol()-Points.LowerCol()+1;
math_Matrix MyPoints(1, Nbdiscret, 1, ncol);
MyPoints = Points;
MaxE3d = MaxE2d = F = 0.0;
Standard_Real *tmppoles, *tmpbis;
tmppoles = new Standard_Real[ncol];
for (c = 1; c <= classe; c++) {
tmpbis = tmppoles;
for (k = 1; k <= ncol; k++, tmpbis++) {
*tmpbis = Poles(c, k);
}
for (i = 1; i <= Nbdiscret; i++) {
Coeff = VB(c, i);
tmpbis = tmppoles;
for (j = 1; j <= ncol; j++, tmpbis++) {
MyPoints(i, j) -= (*tmpbis)*Coeff; // Poles(c, j)*Coeff;
}
}
}
delete [] tmppoles;
Standard_Real e1, e2, e3;
for (i = 1; i <= Nbdiscret; i++) {
i2 = 1;
for (j = 1; j<= nbP; j++) {
e1 = MyPoints(i, i2);
e2 = MyPoints(i, i2+1);
e3 = MyPoints(i, i2+2);
err3d = e1*e1+e2*e2+e3*e3;
MaxE3d = Max(MaxE3d, err3d);
F += err3d;
i2 += 3;
}
for (j = 1; j<= nbP2d; j++) {
e1 = MyPoints(i, i2);
e2 = MyPoints(i, i2+1);
err2d = e1*e1+e2*e2;
MaxE2d = Max(MaxE2d, err2d);
F += err2d;
i2 += 2;
}
}
MaxE3d = Sqrt(MaxE3d);
MaxE2d = Sqrt(MaxE2d);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean AppCont_LeastSquare::IsDone() const
{
return Done;
}

View File

@@ -0,0 +1,75 @@
// Created on: 1995-03-14
// Created by: Modelistation
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef AppCont_LeastSquare_HeaderFile
#define AppCont_LeastSquare_HeaderFile
#include <AppCont_Function.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <NCollection_Array1.hxx>
#include <AppParCurves_Constraint.hxx>
struct PeriodicityInfo
{
Standard_Boolean isPeriodic;
Standard_Real myPeriod;
};
class AppCont_LeastSquare
{
public:
Standard_EXPORT AppCont_LeastSquare(const AppCont_Function& SSP,
const Standard_Real U0,
const Standard_Real U1,
const AppParCurves_Constraint FirstCons,
const AppParCurves_Constraint LastCons,
const Standard_Integer Deg,
const Standard_Integer NbPoints);
Standard_EXPORT const AppParCurves_MultiCurve& Value();
Standard_EXPORT void Error(Standard_Real& F,
Standard_Real& MaxE3d,
Standard_Real& MaxE2d) const;
Standard_EXPORT Standard_Boolean IsDone() const;
private:
//! Fix border point evaluation.
void FixSingleBorderPoint(const AppCont_Function& theSSP,
const Standard_Real theU,
const Standard_Real theU0,
const Standard_Real theU1,
NCollection_Array1<gp_Pnt2d>& theFix2d,
NCollection_Array1<gp_Pnt>& theFix);
AppParCurves_MultiCurve mySCU;
math_Matrix myPoints;
math_Matrix myPoles;
math_Vector myParam;
math_Matrix myVB;
NCollection_Array1<PeriodicityInfo> myPerInfo;
Standard_Boolean myDone;
Standard_Integer myDegre;
Standard_Integer myNbdiscret, myNbP, myNbP2d;
};
#endif

View File

@@ -4,3 +4,6 @@ AppCont_ContMatrices_1.cxx
AppCont_ContMatrices_2.cxx
AppCont_ContMatrices_3.cxx
AppCont_ContMatrices_4.cxx
AppCont_Function.hxx
AppCont_LeastSquare.hxx
AppCont_LeastSquare.cxx

View File

@@ -62,7 +62,7 @@ end;
generic class ComputeLine, MyGradient;
generic class ComputeCLine, MyLeastSquare;
generic class ComputeCLine;
----------------------------------------------
---Algorithms for BSpline curves construction:
@@ -108,10 +108,10 @@ end;
-----------------------------------------------------------------
class FitAndDivide instantiates ComputeCLine from Approx
(Function from AppCont, FunctionTool from AppCont);
(Function from AppCont);
class FitAndDivide2d instantiates ComputeCLine from Approx
(Function2d from AppCont, FunctionTool2d from AppCont);
(Function from AppCont);
class SameParameter from Approx ;

View File

@@ -15,8 +15,7 @@
-- commercial license or contractual agreement.
generic class ComputeCLine from Approx
(MultiLine as any;
LineTool as any)
(MultiLine as any)
---Purpose: Approximate a continous MultiLine with a cutting.
-- The Tool of the line is the tool from AppCont.
@@ -29,11 +28,6 @@ uses ParametrizationType from Approx,
Vector from math
private class MyLeastSquare instantiates LeastSquare from AppCont
(MultiLine,
LineTool);
is
@@ -160,7 +154,7 @@ currenttol3d: Real;
currenttol2d: Real;
mycut: Boolean;
myfirstC: Constraint;
mylastC: Constraint;
mylastC: Constraint;
end ComputeCLine;

View File

@@ -19,7 +19,7 @@
#include <Approx_ParametrizationType.hxx>
#include Approx_MyLeastSquare_hxx
#include <AppCont_LeastSquare.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <AppParCurves_Constraint.hxx>
#include <Approx_Status.hxx>
@@ -89,15 +89,17 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
Standard_Boolean Finish = Standard_False,
begin = Standard_True, Ok = Standard_False;
Standard_Real thetol3d = Precision::Confusion(), thetol2d = Precision::Confusion();
UFirst = LineTool::FirstParameter(Line);
ULast = LineTool::LastParameter(Line);
UFirst = Line.FirstParameter();
ULast = Line.LastParameter();
Standard_Real TolU = (ULast-UFirst)*1.e-05;
Standard_Real myfirstU = UFirst;
Standard_Real mylastU = ULast;
if (!mycut) {
if (!mycut)
{
alldone = Compute(Line, UFirst, ULast, thetol3d, thetol2d);
if (!alldone) {
if (!alldone)
{
tolreached = Standard_False;
myfirstparam.Append(UFirst);
mylastparam.Append(ULast);
@@ -106,70 +108,69 @@ void Approx_ComputeCLine::Perform(const MultiLine& Line)
Tolers2d.Append(currenttol2d);
}
}
else {
else
{
// previous decision to be taken if we get worse with next cut (eap)
AppParCurves_MultiCurve KeptMultiCurve;
Standard_Real KeptUfirst = 0., KeptUlast = 0., KeptT3d = RealLast(), KeptT2d = 0.;
Standard_Integer NbWorseDecis = 0, NbAllowedBadDecis = 10;
while (!Finish) {
while (!Finish)
{
// Gestion du decoupage de la multiline pour approximer:
if (!begin) {
if (Ok) {
// Calcul de la partie a approximer.
myfirstU = mylastU;
mylastU = ULast;
if (Abs(ULast-myfirstU) <= RealEpsilon()) {
Finish = Standard_True;
alldone = Standard_True;
return;
}
KeptT3d = RealLast(); KeptT2d = 0;
NbWorseDecis = 0;
}
else {
// keep best decison
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d)) {
KeptMultiCurve = TheMultiCurve;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
}
// cut an interval
mylastU = (myfirstU + mylastU)/2;
}
if (!begin)
{
if (Ok)
{
// Calcul de la partie a approximer.
myfirstU = mylastU;
mylastU = ULast;
if (Abs(ULast-myfirstU) <= RealEpsilon())
{
Finish = Standard_True;
alldone = Standard_True;
return;
}
KeptT3d = RealLast(); KeptT2d = 0;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
}
else
{
// keep best decison
if ((thetol3d + thetol2d) < (KeptT3d + KeptT2d))
{
KeptMultiCurve = TheMultiCurve;
KeptUfirst = myfirstU;
KeptUlast = mylastU;
KeptT3d = thetol3d;
KeptT2d = thetol2d;
}
// cut an interval
mylastU = (myfirstU + mylastU)/2;
}
}
if (Abs(myfirstU-mylastU) <= TolU) /*break;*/ // pour ne pas planter
NbAllowedBadDecis /= 2; // la station.
// Calcul des parametres sur ce nouvel intervalle.
Ok = Compute(Line, myfirstU, mylastU, thetol3d, thetol2d);
//cout << myfirstU << " - " << mylastU << " tol : " << thetol3d << " " << thetol2d << endl;
// is new decision better?
if ( !Ok && (thetol3d + thetol2d) > (KeptT3d + KeptT2d) )
if (!Ok && Abs(myfirstU-mylastU) <= TolU)
{
NbWorseDecis++;
Ok = Standard_True; // stop interval cutting, approx the rest part
mylastU = KeptUlast;
if (NbWorseDecis > NbAllowedBadDecis) {
Ok = Standard_True; // stop interval cutting, approx the rest part
mylastU = KeptUlast;
tolreached = Standard_False; // helas
myMultiCurves.Append(KeptMultiCurve);
Tolers3d.Append (KeptT3d);
Tolers2d.Append (KeptT2d);
myfirstparam.Append (KeptUfirst);
mylastparam.Append (KeptUlast);
}
}
tolreached = Standard_False; // helas
myMultiCurves.Append(KeptMultiCurve);
Tolers3d.Append (KeptT3d);
Tolers2d.Append (KeptT2d);
myfirstparam.Append (KeptUfirst);
mylastparam.Append (KeptUlast);
}
begin = Standard_False;
} // while (!Finish)
@@ -218,8 +219,7 @@ Standard_Boolean Approx_ComputeCLine::Compute(const MultiLine& Line,
for (deg = mydegremin; deg <= mydegremax; deg++) {
AppParCurves_MultiCurve mySCU(deg+1);
Approx_MyLeastSquare LSquare(Line, Ufirst, Ulast, myfirstC, mylastC,
deg, NbPoints);
AppCont_LeastSquare LSquare(Line, Ufirst, Ulast, myfirstC, mylastC, deg, NbPoints);
mydone = LSquare.IsDone();
if (mydone) {
LSquare.Error(Fv, TheTol3d, TheTol2d);

View File

@@ -269,6 +269,14 @@ static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
Standard_Real firstborne= 3.*pc3d(1) - 2.*pc3d(nbp);
Standard_Real lastborne = 3.*pc3d(nbp) - 2.*pc3d(1);
// Modified by skv - Wed Jun 2 11:50:03 2004 OCC5898 End
//jgv
Standard_Real FirstPar = cons.FirstParameter();
Standard_Real LastPar = cons.LastParameter();
if (firstborne < FirstPar)
firstborne = FirstPar;
if (lastborne > LastPar)
lastborne = LastPar;
/////
for(i = 0; i <= nn; i++){
Standard_Real t = unsurnn*i;
Standard_Real tc3d = pc3d(1)*(1.-t) + pc3d(nbp)*t;

View File

@@ -14,6 +14,7 @@
-- commercial license or contractual agreement.
class ArgumentAnalyzer from BOPAlgo
inherits Algo from BOPAlgo
---Purpose: check the validity of argument(s) for Boolean Operations
uses
@@ -21,11 +22,13 @@ uses
Operation from BOPAlgo,
CheckStatus from BOPAlgo,
ShapeEnum from TopAbs,
ListOfCheckResult from BOPAlgo
ListOfCheckResult from BOPAlgo,
DataMapOfShapeReal from BOPCol
is
Create
returns ArgumentAnalyzer;
---C++: alias "Standard_EXPORT virtual ~BOPAlgo_ArgumentAnalyzer();"
---Purpose: empty constructor
SetShape1(me: in out; TheShape: Shape from TopoDS);
@@ -167,8 +170,25 @@ is
is protected;
-- TestMergeFace(me: out)
-- is protected;
-- is protected;
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---C++: inline
---Purpose: Sets the additional tolerance
FuzzyValue(me)
returns Real from Standard;
---C++: inline
---Purpose: Returns the additional tolerance
UpdateTolerances(me:out)
is protected;
---Purpose: Updates the shapes tolerance values.
SetDefaultTolerances(me:out)
is protected;
---Purpose: Reverts the tolerance values for all entities to default values.
fields
@@ -186,6 +206,8 @@ fields
myContinuityMode : Boolean from Standard;
myCurveOnSurfaceMode : Boolean from Standard;
myEmpty1, myEmpty2 : Boolean from Standard;
myResult : ListOfCheckResult from BOPAlgo;
myResult : ListOfCheckResult from BOPAlgo;
myFuzzyValue : Real from Standard;
myToleranceMap : DataMapOfShapeReal from BOPCol;
end ArgumentAnalyzer;

View File

@@ -31,6 +31,9 @@
#include <TopoDS_Shell.hxx>
#include <TopoDS_Solid.hxx>
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
@@ -49,6 +52,7 @@
#include <IntTools_Context.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
@@ -64,6 +68,7 @@
// purpose:
// ================================================================================
BOPAlgo_ArgumentAnalyzer::BOPAlgo_ArgumentAnalyzer() :
BOPAlgo_Algo(),
myStopOnFirst(Standard_False),
myOperation(BOPAlgo_UNKNOWN),
myArgumentTypeMode(Standard_False),
@@ -76,9 +81,19 @@ myMergeEdgeMode(Standard_False),
myContinuityMode(Standard_False),
myCurveOnSurfaceMode(Standard_False),
myEmpty1(Standard_False),
myEmpty2(Standard_False)
myEmpty2(Standard_False),
myFuzzyValue(0.)
{
}
//=======================================================================
// function: ~
// purpose:
//=======================================================================
BOPAlgo_ArgumentAnalyzer::~BOPAlgo_ArgumentAnalyzer()
{
myResult.Clear();
myToleranceMap.Clear();
}
// ================================================================================
// function: SetShape1
@@ -157,47 +172,82 @@ void BOPAlgo_ArgumentAnalyzer::Perform()
try {
OCC_CATCH_SIGNALS
myResult.Clear();
//
UserBreak();
//
// 1. Prepare
Prepare();
//
UserBreak();
//
// 2. Update Tolerances according to myFuzzyValue
UpdateTolerances();
//
UserBreak();
//
// 3. Test types
if(myArgumentTypeMode) {
TestTypes();
}
//
UserBreak();
//
// 4. Test self-interference
if(mySelfInterMode) {
TestSelfInterferences();
}
//
UserBreak();
//
// 5. Test small edges
if(mySmallEdgeMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestSmallEdge();
}
//
UserBreak();
//
// 6. Test possibility to rebuild faces
if(myRebuildFaceMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestRebuildFace();
}
//
UserBreak();
//
// 7. Test tangent
if(myTangentMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestTangent();
}
//
UserBreak();
//
// 8. Test merge vertices
if(myMergeVertexMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestMergeVertex();
}
//
UserBreak();
//
// 9. Test merge edges
if(myMergeEdgeMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestMergeEdge();
}
//
UserBreak();
//
// 10. Test shapes continuity
if(myContinuityMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestContinuity();
}
//
UserBreak();
//
// 11. Test validity of the curves on the surfaces
if(myCurveOnSurfaceMode) {
if(!(!myResult.IsEmpty() && myStopOnFirst))
TestCurveOnSurface();
@@ -208,6 +258,8 @@ void BOPAlgo_ArgumentAnalyzer::Perform()
aResult.SetCheckStatus(BOPAlgo_CheckUnknown);
myResult.Append(aResult);
}
//
SetDefaultTolerances();
}
// ================================================================================
@@ -329,6 +381,8 @@ void BOPAlgo_ArgumentAnalyzer::TestSelfInterferences()
anArgs.Append(aS);
aChecker.SetArguments(anArgs);
aChecker.SetNonDestructive(Standard_True);
aChecker.SetRunParallel(myRunParallel);
aChecker.SetProgressIndicator(myProgressIndicator);
//
aChecker.Perform();
iErr=aChecker.ErrorStatus();
@@ -874,3 +928,121 @@ void BOPAlgo_ArgumentAnalyzer::TestCurveOnSurface()
}
}
// ================================================================================
// function: UpdateTolerances
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::UpdateTolerances()
{
if (myFuzzyValue == 0.) {
return;
}
//
BOPCol_MapOfShape aMapShapes;
//
if (!myShape1.IsNull()) {
BOPTools::MapShapes(myShape1, aMapShapes);
}
if (!myShape2.IsNull()) {
BOPTools::MapShapes(myShape2, aMapShapes);
}
//
if (aMapShapes.IsEmpty()) {
return;
}
//
Standard_Real aTol, aFuzz;
TopAbs_ShapeEnum aType;
BOPCol_MapIteratorOfMapOfShape aIt;
//
aFuzz = myFuzzyValue / 2.;
aIt.Initialize(aMapShapes);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Value();
aType = aS.ShapeType();
//
switch (aType) {
case TopAbs_VERTEX: {
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
const Handle(BRep_TVertex)& TV =
*((Handle(BRep_TVertex)*)&aV.TShape());
aTol = TV->Tolerance();
myToleranceMap.Bind(aS, aTol);
TV->Tolerance(aTol + aFuzz);
break;
}
case TopAbs_EDGE: {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
const Handle(BRep_TEdge)& TE =
*((Handle(BRep_TEdge)*)&aE.TShape());
aTol = TE->Tolerance();
myToleranceMap.Bind(aS, aTol);
TE->Tolerance(aTol + aFuzz);
break;
}
case TopAbs_FACE: {
const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
const Handle(BRep_TFace)& TF =
*((Handle(BRep_TFace)*)&aF.TShape());
aTol = TF->Tolerance();
myToleranceMap.Bind(aS, aTol);
TF->Tolerance(aTol + aFuzz);
break;
}
default:
break;
} // switch (aType) {
} // for (; aIt.More(); aIt.Next()) {
}
// ================================================================================
// function: SetDefaultTolerances
// purpose:
// ================================================================================
void BOPAlgo_ArgumentAnalyzer::SetDefaultTolerances()
{
if (myFuzzyValue == 0.) {
return;
}
//
if (myToleranceMap.IsEmpty()) {
return;
}
//
Standard_Real aTol;
TopAbs_ShapeEnum aType;
BOPCol_DataMapIteratorOfDataMapOfShapeReal aIt;
//
aIt.Initialize(myToleranceMap);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS = aIt.Key();
aTol = aIt.Value();
aType = aS.ShapeType();
//
switch (aType) {
case TopAbs_VERTEX: {
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aS;
const Handle(BRep_TVertex)& TV =
*((Handle(BRep_TVertex)*)&aV.TShape());
TV->Tolerance(aTol);
break;
}
case TopAbs_EDGE: {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aS;
const Handle(BRep_TEdge)& TE =
*((Handle(BRep_TEdge)*)&aE.TShape());
TE->Tolerance(aTol);
break;
}
case TopAbs_FACE: {
const TopoDS_Face& aF = *(TopoDS_Face*)&aS;
const Handle(BRep_TFace)& TF =
*((Handle(BRep_TFace)*)&aF.TShape());
TF->Tolerance(aTol);
break;
}
default:
break;
} // switch (aType) {
} // for (; aIt.More(); aIt.Next()) {
}

View File

@@ -61,6 +61,24 @@ inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::CurveOnSurfaceMode()
{
return myCurveOnSurfaceMode;
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
inline void BOPAlgo_ArgumentAnalyzer::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
inline Standard_Real BOPAlgo_ArgumentAnalyzer::FuzzyValue() const
{
return myFuzzyValue;
}
// inline Standard_Boolean& BOPAlgo_ArgumentAnalyzer::MergeFaceMode()
// {
// return myMergeFaceMode;

View File

@@ -350,6 +350,9 @@ void BOPAlgo_BOP::Perform()
//
pPF=new BOPAlgo_PaveFiller(aAllocator);
pPF->SetArguments(aLS);
pPF->SetRunParallel(myRunParallel);
pPF->SetProgressIndicator(myProgressIndicator);
pPF->SetFuzzyValue(myFuzzyValue);
//
pPF->Perform();
//

View File

@@ -219,7 +219,15 @@ is
Splits (me)
returns DataMapOfShapeListOfShape from BOPCol;
---C++: return const &
---Purpose: Returns mySplits.
---Purpose: Returns mySplits.
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---Purpose: Sets the additional tolerance
FuzzyValue(me)
returns Real from Standard;
---Purpose: Returns the additional tolerance
fields
myArguments : ListOfShape from BOPCol is protected;
@@ -233,7 +241,8 @@ fields
myShapesSD : DataMapOfShapeShape from BOPCol is protected;
--
mySplits : DataMapOfShapeListOfShape from BOPCol is protected;
myOrigins : DataMapOfShapeShape from BOPCol is protected;
myOrigins : DataMapOfShapeShape from BOPCol is protected;
myFuzzyValue : Real from Standard is protected;
end Builder;

View File

@@ -42,7 +42,8 @@ BOPAlgo_Builder::BOPAlgo_Builder()
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator)
myOrigins(100, myAllocator),
myFuzzyValue(0.)
{
}
//=======================================================================
@@ -61,7 +62,8 @@ BOPAlgo_Builder::BOPAlgo_Builder
myImages(100, myAllocator),
myShapesSD(100, myAllocator),
mySplits(100, myAllocator),
myOrigins(100, myAllocator)
myOrigins(100, myAllocator),
myFuzzyValue(0.)
{
}
//=======================================================================
@@ -172,6 +174,24 @@ BOPDS_PDS BOPAlgo_Builder::PDS()
return myDS;
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
void BOPAlgo_Builder::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
Standard_Real BOPAlgo_Builder::FuzzyValue() const
{
return myFuzzyValue;
}
//=======================================================================
// function: CheckData
// purpose:
//=======================================================================
@@ -236,6 +256,8 @@ void BOPAlgo_Builder::Perform()
//
pPF->SetArguments(myArguments);
pPF->SetRunParallel(myRunParallel);
pPF->SetProgressIndicator(myProgressIndicator);
pPF->SetFuzzyValue(myFuzzyValue);
//
pPF->Perform();
//

View File

@@ -45,6 +45,10 @@
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
//
#include <Bnd_Box.hxx>
//
#include <BRepBndLib.hxx>
//
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
@@ -451,7 +455,7 @@ void BOPAlgo_BuilderFace::PerformLoops()
void BOPAlgo_BuilderFace::PerformAreas()
{
Standard_Boolean bIsGrowth, bIsHole;
Standard_Integer k, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap;;
Standard_Integer k, aNbS, aNbHoles, aNbDMISB, m, aNbMSH, aNbInOutMap;
Standard_Real aTol;
TopLoc_Location aLoc;
Handle(Geom_Surface) aS;
@@ -469,6 +473,7 @@ void BOPAlgo_BuilderFace::PerformAreas()
NCollection_UBTreeFiller <Standard_Integer, Bnd_Box2d> aTreeFiller(aBBTree);
//
myErrorStatus=0;
aNbHoles=0;
//
aTol=BRep_Tool::Tolerance(myFace);
aS=BRep_Tool::Surface(myFace, aLoc);
@@ -498,8 +503,8 @@ void BOPAlgo_BuilderFace::PerformAreas()
bIsHole=aClsf.IsHole();
if (bIsHole) {
BOPTools::MapShapes(aWire, TopAbs_EDGE, aMHE);
//
bIsHole=Standard_True;
//
bIsHole=Standard_True;
}
else {
bIsHole=Standard_False;
@@ -525,6 +530,7 @@ void BOPAlgo_BuilderFace::PerformAreas()
if (bIsHole) {
const Bnd_Box2d& aBox2D=aSB2D.Box2D();
aTreeFiller.Add(k, aBox2D);
++aNbHoles;
}
}
//
@@ -546,7 +552,10 @@ void BOPAlgo_BuilderFace::PerformAreas()
aSelector.Clear();
aSelector.SetBox(aBox2DF);
//
aNbHoles=aBBTree.Select(aSelector);
aNbS = aBBTree.Select(aSelector);
if (!aNbS) {
continue;
}
//
const BOPCol_ListOfInteger& aLI=aSelector.Indices();
//
@@ -572,7 +581,7 @@ void BOPAlgo_BuilderFace::PerformAreas()
}
}// for (m=1; m<=aNbDMISB; ++m)
//
// 5. Map [Face/Holes] -> aMSH
// 5.1 Map [Face/Holes] -> aMSH
aNbInOutMap=aInOutMap.Extent();
for (m=1; m<=aNbInOutMap; ++m) {
const TopoDS_Shape& aHole=aInOutMap.FindKey(m);
@@ -589,6 +598,41 @@ void BOPAlgo_BuilderFace::PerformAreas()
}
}
//
// 5.2. Add unused holes to the original face
if (aNbHoles != aNbInOutMap) {
Bnd_Box aBoxF;
BRepBndLib::Add(myFace, aBoxF);
if (aBoxF.IsOpenXmin() || aBoxF.IsOpenXmax() ||
aBoxF.IsOpenYmin() || aBoxF.IsOpenYmax() ||
aBoxF.IsOpenZmin() || aBoxF.IsOpenZmax()) {
//
BOPCol_ListOfShape anUnUsedHoles;
for (m = 1; m <= aNbDMISB; ++m) {
const BOPAlgo_ShapeBox2D& aSB2D=aDMISB.FindFromIndex(m);
if (aSB2D.IsHole()) {
const TopoDS_Shape& aHole = aSB2D.Shape();
if (!aInOutMap.Contains(aHole)) {
anUnUsedHoles.Append(aHole);
}
}
}
//
if (anUnUsedHoles.Extent()) {
TopoDS_Face aFace;
aBB.MakeFace(aFace, aS, aLoc, aTol);
aMSH.Add(aFace, anUnUsedHoles);
//
BOPAlgo_ShapeBox2D aSB2D;
//
aSB2D.SetShape(aFace);
aSB2D.SetIsHole(Standard_False);
//
aDMISB.Add(aNbDMISB, aSB2D);
++aNbDMISB;
}
}
}
//
// 6. Add aHoles to Faces
aNbMSH=aMSH.Extent();
for (m=1; m<=aNbMSH; ++m) {

View File

@@ -684,8 +684,8 @@ void BOPAlgo_BuilderSolid::PerformAreas()
}
//
if (aInOutMap.IsBound (aHole)){
const TopoDS_Shape& aHole2=aInOutMap(aHole);
if (IsInside(aHole, aHole2, myContext)) {
const TopoDS_Shape& aSolidWas=aInOutMap(aHole);
if (IsInside(aSolid, aSolidWas, myContext)) {
aInOutMap.UnBind(aHole);
aInOutMap.Bind (aHole, aSolid);
}

View File

@@ -104,6 +104,7 @@ void BOPAlgo_CheckerSI::Init()
// 1. myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
myDS->SetFuzzyValue(myFuzzyValue);
myDS->Init();
//
// 2.myIterator

View File

@@ -43,6 +43,29 @@ static
BOPCol_MapOfShape& aMFence,
BOPCol_ListOfShape& theLS);
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================
void BOPAlgo_MakerVolume::CheckData()
{
if (myArguments.IsEmpty()) {
myErrorStatus = 100; // no arguments to process
return;
}
// myPaveFiller
if (!myPaveFiller) {
myErrorStatus = 101;
return;
}
//
myErrorStatus = myPaveFiller->ErrorStatus();
if (myErrorStatus) {
myErrorStatus = 102; // PaveFiller is failed
return;
}
}
//=======================================================================
//function : Perform
//purpose :
@@ -84,6 +107,8 @@ void BOPAlgo_MakerVolume::Perform()
}
//
pPF->SetRunParallel(myRunParallel);
pPF->SetProgressIndicator(myProgressIndicator);
pPF->SetFuzzyValue(myFuzzyValue);
pPF->Perform();
//
myEntryPoint = 1;

View File

@@ -92,26 +92,3 @@ inline const BOPCol_ListOfShape& BOPAlgo_MakerVolume::Faces()const
{
return myFaces;
}
//=======================================================================
//function : CheckData
//purpose :
//=======================================================================
inline void BOPAlgo_MakerVolume::CheckData()
{
if (myArguments.IsEmpty()) {
myErrorStatus = 100; // no arguments to process
return;
}
// myPaveFiller
if (!myPaveFiller) {
myErrorStatus = 101;
return;
}
//
myErrorStatus = myPaveFiller->ErrorStatus();
if (myErrorStatus) {
myErrorStatus = 102; // PaveFiller is failed
return;
}
}

View File

@@ -463,12 +463,20 @@ is
---Purpose:
-- Updates pave blocks which have the paves with indices contained
-- in the map <theDMI>.
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---Purpose: Sets the additional tolerance
FuzzyValue(me)
returns Real from Standard;
---Purpose: Returns the additional tolerance
fields
myArguments : ListOfShape from BOPCol is protected;
myDS : PDS from BOPDS is protected;
myIterator : PIterator from BOPDS is protected;
myContext : Context from IntTools is protected;
mySectionAttribute : SectionAttribute from BOPAlgo is protected;
myFuzzyValue : Real from Standard is protected;
end PaveFiller;

View File

@@ -33,7 +33,8 @@
//=======================================================================
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
:
BOPAlgo_Algo()
BOPAlgo_Algo(),
myFuzzyValue(0.)
{
myDS=NULL;
myIterator=NULL;
@@ -45,7 +46,8 @@ BOPAlgo_PaveFiller::BOPAlgo_PaveFiller()
BOPAlgo_PaveFiller::BOPAlgo_PaveFiller
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BOPAlgo_Algo(theAllocator)
BOPAlgo_Algo(theAllocator),
myFuzzyValue(0.)
{
myDS=NULL;
myIterator=NULL;
@@ -123,6 +125,24 @@ const BOPCol_ListOfShape& BOPAlgo_PaveFiller::Arguments()const
return myArguments;
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
void BOPAlgo_PaveFiller::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
Standard_Real BOPAlgo_PaveFiller::FuzzyValue() const
{
return myFuzzyValue;
}
//=======================================================================
// function: Init
// purpose:
//=======================================================================
@@ -141,6 +161,7 @@ void BOPAlgo_PaveFiller::Init()
// 1.myDS
myDS=new BOPDS_DS(myAllocator);
myDS->SetArguments(myArguments);
myDS->SetFuzzyValue(myFuzzyValue);
myDS->Init();
//
// 2.myIterator
@@ -170,6 +191,8 @@ void BOPAlgo_PaveFiller::Perform()
catch (Standard_Failure) {
myErrorStatus=11;
}
//
myDS->SetDefaultTolerances();
}
//=======================================================================
// function: PerformInternal
@@ -244,7 +267,6 @@ void BOPAlgo_PaveFiller::PerformInternal()
return;
}
//
//modified by NIZNHY-PKV Fri Sep 12 07:06:50 2014f
// 03
PerformVZ();
if (myErrorStatus) {
@@ -265,5 +287,4 @@ void BOPAlgo_PaveFiller::PerformInternal()
if (myErrorStatus) {
return;
}
//modified by NIZNHY-PKV Fri Sep 12 07:06:52 2014t
}

View File

@@ -267,7 +267,6 @@ void BOPAlgo_PaveFiller::PerformEF()
aPB->Indices(nV[0], nV[1]);
//
BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
////const BOPDS_IndexedMapOfPaveBlock& aMPBF=aFI.PaveBlocksOn();
const BOPCol_MapOfInteger& aMIFOn=aFI.VerticesOn();
const BOPCol_MapOfInteger& aMIFIn=aFI.VerticesIn();
//~~~
@@ -305,7 +304,9 @@ void BOPAlgo_PaveFiller::PerformEF()
aEF.SetIndices(nE, nF);
aEF.SetCommonPart(aCP);
myDS->AddInterf(nE, nF);
// 3
//
aMIEFC.Add(nF);
//
BOPAlgo_Tools::FillMap(aPB, nF, aMPBLI, aAllocator);
break;
}

View File

@@ -24,6 +24,7 @@ uses
is
imported BaseAllocator from BOPCol;
imported DataMapOfShapeInteger from BOPCol;
imported DataMapOfShapeReal from BOPCol;
imported MapOfInteger from BOPCol;
imported ListOfInteger from BOPCol;
imported PInteger from BOPCol;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 1995-1999 Matra Datavision
// Created by: Peter KURNEV
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
@@ -12,7 +12,15 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AppCont_Function.ixx>
#ifndef BOPCol_DataMapOfShapeReal_HeaderFile
#define BOPCol_DataMapOfShapeReal_HeaderFile
void AppCont_Function::Delete()
{}
#include <TopoDS_Shape.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> BOPCol_DataMapOfShapeReal;
typedef BOPCol_DataMapOfShapeReal::Iterator BOPCol_DataMapIteratorOfDataMapOfShapeReal;
#endif

View File

@@ -1,5 +1,6 @@
BOPCol_Array1.hxx
BOPCol_DataMapOfShapeInteger.hxx
BOPCol_DataMapOfShapeReal.hxx
BOPCol_MapOfInteger.hxx
BOPCol_ListOfInteger.hxx
BOPCol_PInteger.hxx

View File

@@ -38,7 +38,8 @@ uses
Shape from TopoDS,
--
ListOfShape from BOPCol,
DataMapOfIntegerInteger from BOPCol,
DataMapOfIntegerInteger from BOPCol,
DataMapOfIntegerReal from BOPCol,
DataMapOfShapeInteger from BOPCol,
ListOfInteger from BOPCol,
MapOfInteger from BOPCol,
@@ -303,7 +304,7 @@ is
IsCommonBlockOnEdge(me;
thePB:PaveBlock from BOPDS)
returns Boolean from Standard;
returns Boolean from Standard;
---Purpose:
--- Query
--- Returns true if common block contains more then one pave block
@@ -500,7 +501,7 @@ is
---C++: inline
---Purpose:
--- Selector/Modifier
--- Returns the collection of interferences Edge/Solid
--- Returns the collection of interferences Edge/Solid
InterfFZ(me:out)
returns VectorOfInterfFZ from BOPDS;
@@ -508,7 +509,7 @@ is
---C++: inline
---Purpose:
--- Selector/Modifier
--- Returns the collection of interferences Face/Solid
--- Returns the collection of interferences Face/Solid
InterfZZ(me:out)
returns VectorOfInterfZZ from BOPDS;
@@ -516,12 +517,12 @@ is
---C++: inline
---Purpose:
--- Selector/Modifier
--- Returns the collection of interferences Solid/Solid
--- Returns the collection of interferences Solid/Solid
NbInterfTypes(myclass)
returns Integer from Standard;
---C++: inline
---Purpose:
returns Integer from Standard;
---C++: inline
---Purpose:
-- Returns the number of types of the interferences
--
@@ -556,14 +557,14 @@ is
HasInterfShapeSubShapes(me;
theI1:Integer from Standard;
theI2:Integer from Standard;
theFlag: Boolean from Standard=Standard_True)
theFlag: Boolean from Standard=Standard_True)
returns Boolean from Standard;
---Purpose:
--- Query
--- Returns true if the shape with index theI1 is interfered
--- with
-- any sub-shape of the shape with index theI2 (theFlag=true)
-- all sub-shapes of the shape with index theI2 (theFlag=false)
-- any sub-shape of the shape with index theI2 (theFlag=true)
-- all sub-shapes of the shape with index theI2 (theFlag=false)
HasInterfSubShapes(me;
theI1:Integer from Standard;
@@ -628,15 +629,26 @@ is
---
BuildBndBoxSolid (me:out;
theIndex:Integer from Standard;
theBox:out Box from Bnd)
is protected;
---Purpose:
theIndex:Integer from Standard;
theBox:out Box from Bnd)
is protected;
---Purpose:
--- Computes bouding box <theBox> for the solid with DS-index <theIndex>
---
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---C++: inline
---Purpose: Sets the extended tolerance
FuzzyValue(me)
returns Real from Standard;
---C++: inline
---Purpose: Returns the extended tolerance
SetDefaultTolerances(me:out);
---Purpose: Reverts the tolerance values of unchanged entities to default values.
fields
myAllocator : BaseAllocator from BOPCol is protected;
myArguments : ListOfShape from BOPCol is protected;
@@ -665,5 +677,10 @@ fields
myInterfVZ : VectorOfInterfVZ from BOPDS is protected;
myInterfEZ : VectorOfInterfEZ from BOPDS is protected;
myInterfFZ : VectorOfInterfFZ from BOPDS is protected;
myInterfZZ : VectorOfInterfZZ from BOPDS is protected;
myInterfZZ : VectorOfInterfZZ from BOPDS is protected;
--
-- extended tolerance for intersection
myFuzzyValue : Real from Standard is protected;
myToleranceMap : DataMapOfIntegerReal from BOPCol is protected;
end DS;

View File

@@ -27,6 +27,10 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
//
#include <BRep_TVertex.hxx>
#include <BRep_TEdge.hxx>
#include <BRep_TFace.hxx>
#include <BRep_Tool.hxx>
//
#include <BRepBndLib.hxx>
@@ -34,6 +38,7 @@
#include <BOPCol_MapOfInteger.hxx>
#include <BOPCol_ListOfInteger.hxx>
#include <BOPCol_DataMapOfShapeInteger.hxx>
#include <BOPCol_DataMapOfIntegerMapOfInteger.hxx>
//
#include <BOPDS_IndexRange.hxx>
#include <BOPDS_ShapeInfo.hxx>
@@ -68,6 +73,16 @@ static
Standard_Real ComputeParameter(const TopoDS_Vertex& aV,
const TopoDS_Edge& aE);
static
void AddShapeAndSubShapes(const Standard_Integer nS,
const BOPDS_ShapeInfo& theSI,
BOPCol_MapOfInteger& theMI);
static
void CollectEdges(const BOPDS_DS& theDS,
const Standard_Integer nF,
BOPCol_MapOfInteger& theMI);
//=======================================================================
//function :
//purpose :
@@ -93,7 +108,9 @@ BOPDS_DS::BOPDS_DS()
myInterfVZ(myAllocator),
myInterfEZ(myAllocator),
myInterfFZ(myAllocator),
myInterfZZ(myAllocator)
myInterfZZ(myAllocator),
myFuzzyValue(0.),
myToleranceMap(100, myAllocator)
{
myNbShapes=0;
myNbSourceShapes=0;
@@ -123,7 +140,9 @@ BOPDS_DS::BOPDS_DS(const Handle(NCollection_BaseAllocator)& theAllocator)
myInterfVZ(myAllocator),
myInterfEZ(myAllocator),
myInterfFZ(myAllocator),
myInterfZZ(myAllocator)
myInterfZZ(myAllocator),
myFuzzyValue(0.),
myToleranceMap(100, myAllocator)
{
myNbShapes=0;
myNbSourceShapes=0;
@@ -144,6 +163,7 @@ void BOPDS_DS::Clear()
{
myNbShapes=0;
myNbSourceShapes=0;
myFuzzyValue=0.;
//
myArguments.Clear();
myRanges.Clear();
@@ -164,6 +184,7 @@ void BOPDS_DS::Clear()
myInterfEZ.Clear();
myInterfFZ.Clear();
myInterfZZ.Clear();
myToleranceMap.Clear();
}
//=======================================================================
//function : SetArguments
@@ -325,7 +346,7 @@ void BOPDS_DS::Init()
{
Standard_Integer i1, i2, j, aI, aNb, aNbS, aNbE, aNbSx;
Standard_Integer n1, n2, n3, nV, nW, nE, aNbF;
Standard_Real aTol;
Standard_Real aTol, aFuzz;
TopAbs_ShapeEnum aTS;
TopoDS_Iterator aItS;
BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3;
@@ -386,6 +407,7 @@ void BOPDS_DS::Init()
i1=i2+1;
}
//
aFuzz = myFuzzyValue / 2.;
myNbSourceShapes=NbShapes();
//
// 2 Bounding Boxes
@@ -403,7 +425,15 @@ void BOPDS_DS::Init()
Bnd_Box& aBox=aSI.ChangeBox();
const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aS);
const gp_Pnt& aP=BRep_Tool::Pnt(aV);
aTol=BRep_Tool::Tolerance(aV);
//
const Handle(BRep_TVertex)& TV =
*((Handle(BRep_TVertex)*)&aV.TShape());
aTol = TV->Tolerance();
//
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TV->Tolerance(aTol);
//
aBox.SetGap(aTol);
aBox.Add(aP);
}
@@ -417,7 +447,14 @@ void BOPDS_DS::Init()
if (aTS==TopAbs_EDGE) {
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS);
aTol=BRep_Tool::Tolerance(aE);
//
const Handle(BRep_TEdge)& TE =
*((Handle(BRep_TEdge)*)&aE.TShape());
aTol = TE->Tolerance();
//
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TE->Tolerance(aTol);
//
if (!BRep_Tool::Degenerated(aE)) {
Standard_Boolean bInf1, bInf2;
@@ -494,7 +531,14 @@ void BOPDS_DS::Init()
if (aTS==TopAbs_FACE) {
const TopoDS_Shape& aS=aSI.Shape();
const TopoDS_Face& aF=*((TopoDS_Face*)&aS);
aTol=BRep_Tool::Tolerance(aF);
//
const Handle(BRep_TFace)& TF =
*((Handle(BRep_TFace)*)&aF.TShape());
aTol = TF->Tolerance();
//
myToleranceMap.Bind(j, aTol);
aTol += aFuzz;
TF->Tolerance(aTol);
//
Bnd_Box& aBox=aSI.ChangeBox();
BRepBndLib::Add(aS, aBox);
@@ -709,12 +753,12 @@ Standard_Boolean BOPDS_DS::HasInterfShapeSubShapes
bRet=HasInterf(theI1, n2);
if (theFlag) {
if(bRet) {
break;
break;
}
}
else {
if(!bRet) {
break;
break;
}
}
}
@@ -2017,3 +2061,236 @@ void BOPDS_DS::BuildBndBoxSolid(const Standard_Integer theIndex,
}
}
}
//=======================================================================
//function : DefaultTolerances
//purpose :
//=======================================================================
void BOPDS_DS::SetDefaultTolerances()
{
if (myFuzzyValue == 0.) {
return;
}
//
Standard_Boolean bAdd;
Standard_Integer i, j, n1, n2, nS, nSOp, nSs;
Standard_Integer anIntType, aNbFF, aNbFIn;
Standard_Real aTolDef;
TopAbs_ShapeEnum aTS1, aTS2;
BOPCol_MapOfInteger aMICh;
BOPCol_DataMapOfIntegerMapOfInteger aDMI;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPDS_MapIteratorMapOfPassKey aItPK;
BOPDS_ListIteratorOfListOfPaveBlock aItPB;
BOPCol_MapIteratorOfMapOfInteger aItMI;
BOPCol_DataMapIteratorOfDataMapOfIntegerReal aItDMIR;
//
// 1. Collect interfered shapes
// 1.1. Interferences V/V, V/E, V/F, E/E and E/F
aItPK.Initialize(myInterfTB);
for (; aItPK.More(); aItPK.Next()) {
const BOPDS_PassKey& aPK = aItPK.Value();
aPK.Ids(n1, n2);
//
const BOPDS_ShapeInfo& aSI1 = ShapeInfo(n1);
const BOPDS_ShapeInfo& aSI2 = ShapeInfo(n2);
//
aTS1 = aSI1.ShapeType();
aTS2 = aSI2.ShapeType();
//
anIntType = BOPDS_Tools::TypeToInteger(aTS1, aTS2);
if (anIntType < 5) {
AddShapeAndSubShapes(n1, aSI1, aMICh);
AddShapeAndSubShapes(n2, aSI2, aMICh);
} // if (anIntType < 5) {
} // for (; aIt.More(); aIt.Next()) {
//
// 1.2 FaceInfo information
aNbFF = myFaceInfoPool.Extent();
for (i = 0; i < aNbFF; ++i) {
const BOPDS_FaceInfo& aFI = myFaceInfoPool(i);
nS = aFI.Index();
if (aMICh.Contains(nS)) {
continue;
}
//
aNbFIn = (aFI.PaveBlocksIn().Extent() +
aFI.VerticesIn().Extent() +
aFI.PaveBlocksSc().Extent() +
aFI.VerticesSc().Extent());
if (aNbFIn > 0) {
AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
} // if (aNbFIn > 0) {
} // for (i = 0; i < aNbFF; ++i) {
//
// 1.3. Empty F/F interferences
aNbFF = myInterfFF.Extent();
for (i = 0; i < aNbFF; ++i) {
BOPDS_InterfFF& aFF = myInterfFF(i);
if ((aFF.Curves().Extent() == 0) &&
(aFF.Points().Extent() == 0)) {
aFF.Indices(n1, n2);
for (j = 0; j < 2; ++j) {
nS = !j ? n1 : n2;
if (aMICh.Contains(nS)) {
continue;
}
nSOp = !j ? n2 : n1;
//
BOPCol_MapOfInteger aME, aMEOp;
//
if (aDMI.IsBound(nS)) {
aME = aDMI.Find(nS);
} else {
CollectEdges(*this, nS, aME);
aDMI.Bind(nS, aME);
}
//
if (aDMI.IsBound(nSOp)) {
aMEOp = aDMI.Find(nSOp);
} else {
CollectEdges(*this, nSOp, aMEOp);
aDMI.Bind(nSOp, aMEOp);
}
//
bAdd = Standard_True;
aItMI.Initialize(aME);
for (; aItMI.More(); aItMI.Next()) {
nSs = aItMI.Value();
if (!aMEOp.Contains(nSs)) {
bAdd = Standard_False;
break;
}
}
//
if (bAdd) {
AddShapeAndSubShapes(nS, ShapeInfo(nS), aMICh);
if (j == 0) {
AddShapeAndSubShapes(nSOp, ShapeInfo(nSOp), aMICh);
}
} // if (bAdd) {
} // for (j = 0; j < 2; ++j) {
} //if ((aFF.Curves().Extent() == 0) &&
} // for (i = 0; i < aNbFF; ++i) {
//
// 2. Back to default tolerance values
aItDMIR.Initialize(myToleranceMap);
for (; aItDMIR.More(); aItDMIR.Next()) {
i = aItDMIR.Key();
//
if (aMICh.Contains(i)) {
continue;
}
//
const BOPDS_ShapeInfo& aSI = ShapeInfo(i);
aTolDef = aItDMIR.Value();
aTS1 = aSI.ShapeType();
switch (aTS1) {
case TopAbs_VERTEX: {
const TopoDS_Vertex& aV = *(TopoDS_Vertex*)&aSI.Shape();
const Handle(BRep_TVertex)& aTV =
*((Handle(BRep_TVertex)*)&aV.TShape());
aTV->Tolerance(aTolDef);
break;
}
case TopAbs_EDGE: {
const TopoDS_Edge& aE = *(TopoDS_Edge*)&aSI.Shape();
const Handle(BRep_TEdge)& aTE =
*((Handle(BRep_TEdge)*)&aE.TShape());
aTE->Tolerance(aTolDef);
//
const BOPDS_ListOfPaveBlock& aLPB = PaveBlocks(i);
aItPB.Initialize(aLPB);
for (; aItPB.More(); aItPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB = aItPB.Value();
nS = aPB->Edge();
const TopoDS_Edge& aEIm = *(TopoDS_Edge*)&Shape(nS);
const Handle(BRep_TEdge)& aTEIm =
*((Handle(BRep_TEdge)*)&aEIm.TShape());
aTEIm->Tolerance(aTolDef);
}
break;
}
case TopAbs_FACE: {
const TopoDS_Face& aF = *(TopoDS_Face*)&aSI.Shape();
const Handle(BRep_TFace)& aTF =
*((Handle(BRep_TFace)*)&aF.TShape());
aTF->Tolerance(aTolDef);
break;
}
default:
break;
} // switch (aTS1) {
} // for (; aItDMIR.More(); aItDMIR.Next()) {
}
//=======================================================================
//function : AddShapeAndSubShapes
//purpose :
//=======================================================================
void AddShapeAndSubShapes(const Standard_Integer nS,
const BOPDS_ShapeInfo& theSI,
BOPCol_MapOfInteger& theMI)
{
Standard_Integer nSs;
if (theMI.Add(nS)) {
const BOPCol_ListOfInteger& aLI = theSI.SubShapes();
BOPCol_ListIteratorOfListOfInteger aItLI(aLI);
for (; aItLI.More(); aItLI.Next()) {
nSs = aItLI.Value();
theMI.Add(nSs);
}
}
}
//=======================================================================
//function : CollectEdges
//purpose :
//=======================================================================
void CollectEdges(const BOPDS_DS& theDS,
const Standard_Integer nF,
BOPCol_MapOfInteger& theMI)
{
Standard_Integer i, j, aNbPB, nE, nEIm;
BOPCol_ListIteratorOfListOfInteger aItLI;
BOPDS_ListIteratorOfListOfPaveBlock aItLPB;
//
// ON edges
const BOPDS_ShapeInfo& aSI = theDS.ShapeInfo(nF);
const BOPCol_ListOfInteger& aLI = aSI.SubShapes();
aItLI.Initialize(aLI);
for (; aItLI.More(); aItLI.Next()) {
nE = aItLI.Value();
const BOPDS_ShapeInfo& aSIE = theDS.ShapeInfo(nE);
if (aSIE.ShapeType() != TopAbs_EDGE) {
continue;
}
//
if (!aSIE.HasReference()) {
theMI.Add(nE);
continue;
}
//
const BOPDS_ListOfPaveBlock& aLPB = theDS.PaveBlocks(nE);
aItLPB.Initialize(aLPB);
for (; aItLPB.More(); aItLPB.Next()) {
const Handle(BOPDS_PaveBlock)& aPB = aItLPB.Value();
nEIm = aPB->Edge();
theMI.Add(nEIm);
}
}
// IN and SC edges
const BOPDS_FaceInfo& aFI = theDS.FaceInfo(nF);
const BOPDS_IndexedMapOfPaveBlock& aMPBIn = aFI.PaveBlocksIn();
const BOPDS_IndexedMapOfPaveBlock& aMPBSc = aFI.PaveBlocksSc();
//
for (i = 0; i < 2; ++i) {
const BOPDS_IndexedMapOfPaveBlock& aMPB = !i ? aMPBIn : aMPBSc;
aNbPB = aMPB.Extent();
for (j = 1; j <= aNbPB; ++j) {
const Handle(BOPDS_PaveBlock)& aPB = aMPB(j);
nE = aPB->Edge();
theMI.Add(nE);
}
}
}

View File

@@ -105,7 +105,7 @@ inline Standard_Integer BOPDS_DS::NbInterfTypes()
//purpose :
//=======================================================================
inline void BOPDS_DS::AddInterf(const Standard_Integer theI1,
const Standard_Integer theI2)
const Standard_Integer theI2)
{
BOPDS_PassKey aPK;
//
@@ -133,3 +133,21 @@ inline const BOPDS_MapOfPassKey& BOPDS_DS::Interferences()const
{
return myInterfTB;
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
inline void BOPDS_DS::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
inline Standard_Real BOPDS_DS::FuzzyValue() const
{
return myFuzzyValue;
}

View File

@@ -24,6 +24,8 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
//
#include <BRep_Builder.hxx>
#include <BOPAlgo_PaveFiller.hxx>
@@ -95,24 +97,26 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
const char* g = "BOP commands";
// Commands
theCommands.Add("bop" , "use bop s1 s2" , __FILE__, bop, g);
theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g);
theCommands.Add("bopfuse" , "use bopfuse r" , __FILE__,bopfuse, g);
theCommands.Add("bopcut" , "use bopcut" , __FILE__,bopcut, g);
theCommands.Add("boptuc" , "use boptuc" , __FILE__,boptuc, g);
theCommands.Add("bopsection", "use bopsection" , __FILE__,bopsection, g);
theCommands.Add("bop" , "use bop s1 s2 [tol]" , __FILE__, bop, g);
theCommands.Add("bopcommon" , "use bopcommon r" , __FILE__, bopcommon, g);
theCommands.Add("bopfuse" , "use bopfuse r" , __FILE__,bopfuse, g);
theCommands.Add("bopcut" , "use bopcut r" , __FILE__,bopcut, g);
theCommands.Add("boptuc" , "use boptuc r" , __FILE__,boptuc, g);
theCommands.Add("bopsection", "use bopsection r" , __FILE__,bopsection, g);
//
theCommands.Add("bcommon" , "use bcommon r s1 s2" , __FILE__,bcommon, g);
theCommands.Add("bfuse" , "use bfuse r s1 s2" , __FILE__,bfuse, g);
theCommands.Add("bcut" , "use bcut r s1 s2" , __FILE__,bcut, g);
theCommands.Add("btuc" , "use btuc r s1 s2" , __FILE__,btuc, g);
theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na]",
theCommands.Add("bcommon" , "use bcommon r s1 s2 [tol]" , __FILE__,bcommon, g);
theCommands.Add("bfuse" , "use bfuse r s1 s2 [tol]" , __FILE__,bfuse, g);
theCommands.Add("bcut" , "use bcut r s1 s2 [tol]" , __FILE__,bcut, g);
theCommands.Add("btuc" , "use btuc r s1 s2 [tol]" , __FILE__,btuc, g);
theCommands.Add("bsection", "Use >bsection r s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d]", __FILE__, bopcurves, g);
theCommands.Add("bopnews", "use bopnews -v[e,f]" , __FILE__, bopnews, g);
theCommands.Add("bparallelmode", "bparallelmode [1/0] : show / set parallel mode for boolean operations", __FILE__, bparallelmode, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-ni (do not intersect)] [-s (run in non parallel mode)]", __FILE__, mkvolume , g);
theCommands.Add("bparallelmode", "bparallelmode [1/0] : show / set parallel mode for boolean operations",
__FILE__, bparallelmode, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-s] [tol]",
__FILE__, mkvolume , g);
}
//=======================================================================
@@ -123,11 +127,12 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
{
char buf[32];
Standard_Integer iErr;
Standard_Real aTol;
TopoDS_Shape aS1, aS2;
BOPCol_ListOfShape aLC;
//
if (n!=3) {
di << " use bop Shape1 Shape2\n";
if (n < 3 || n > 4) {
di << " use bop Shape1 Shape2 [tol]\n";
return 1;
}
//
@@ -139,6 +144,11 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
return 1;
}
//
aTol = 0.;
if (n == 4) {
aTol = Draw::Atof(a[3]);
}
//
aLC.Append(aS1);
aLC.Append(aS2);
//
@@ -150,6 +160,7 @@ Standard_Integer bop (Draw_Interpretor& di, Standard_Integer n, const char** a)
pPF=new BOPAlgo_PaveFiller(aAL);
//
pPF->SetArguments(aLC);
pPF->SetFuzzyValue(aTol);
//
pPF->Perform();
iErr=pPF->ErrorStatus();
@@ -203,7 +214,7 @@ Standard_Integer bopsmt(Draw_Interpretor& di,
const BOPAlgo_Operation aOp)
{
if (n<2) {
di << " use bopsmt r\n";
di << " use bopsmt r\n [tol]";
return 0;
}
//
@@ -349,104 +360,74 @@ Standard_Integer bsection(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na]\n";
const char* usage = " Usage: bsection Result s1 s2 [-n2d/-n2d1/-n2d2] [-na] [tol]\n";
if (n < 4) {
di << usage;
return 1;
}
//
TopoDS_Shape aS1 = DBRep::Get(a[2]);
TopoDS_Shape aS2 = DBRep::Get(a[3]);
//
if (aS1.IsNull() || aS2.IsNull()) {
di << " Null shapes are not allowed \n";
return 1;
}
//
Standard_Boolean bApp, bPC1, bPC2;
Standard_Integer i;
Standard_Real aTol;
//
bApp = Standard_True;
bPC1 = Standard_True;
bPC2 = Standard_True;
Standard_Boolean isbadparameter = Standard_False;
if(n > 4) {
const char* key1 = a[4];
const char* key2 = (n > 5) ? a[5] : NULL;
const char* pcurveconf = NULL;
if (key1 &&
(!strcasecmp(key1,"-n2d") ||
!strcasecmp(key1,"-n2d1") ||
!strcasecmp(key1,"-n2d2"))) {
pcurveconf = key1;
aTol = 0.;
//
for (i = 4; i < n; ++i) {
if (!strcmp(a[i], "-n2d")) {
bPC1 = Standard_False;
bPC2 = Standard_False;
}
else if (!strcmp(a[i], "-n2d1")) {
bPC1 = Standard_False;
}
else if (!strcmp(a[i], "-n2d2")) {
bPC2 = Standard_False;
}
else if (!strcmp(a[i], "-na")) {
bApp = Standard_False;
}
else {
if (!strcasecmp(key1,"-na")) {
bApp = Standard_False;
}
else {
isbadparameter = Standard_True;
}
}
if (key2) {
if(!strcasecmp(key2,"-na")) {
bApp = Standard_False;
}
else {
isbadparameter = Standard_True;
}
}
if(!isbadparameter && pcurveconf) {
if (!strcasecmp(pcurveconf, "-n2d1")) {
bPC1 = Standard_False;
}
else {
if (!strcasecmp(pcurveconf, "-n2d2")) {
bPC2 = Standard_False;
}
else {
if (!strcasecmp(pcurveconf, "-n2d")) {
bPC1 = Standard_False;
bPC2 = Standard_False;
}
}
}
aTol = Draw::Atof(a[i]);
}
}
if(!isbadparameter) {
Standard_Integer iErr;
char buf[80];
//
BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
aSec.Approximation(bApp);
aSec.ComputePCurveOn1(bPC1);
aSec.ComputePCurveOn2(bPC2);
//
aSec.Build();
iErr=aSec.ErrorStatus();
if (!aSec.IsDone()) {
Sprintf(buf, " ErrorStatus : %d\n", iErr);
di << buf;
return 0;
}
//
const TopoDS_Shape& aR=aSec.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
DBRep::Set(a[1], aR);
//
Standard_Integer iErr;
char buf[80];
//
BRepAlgoAPI_Section aSec(aS1, aS2, Standard_False);
aSec.Approximation(bApp);
aSec.ComputePCurveOn1(bPC1);
aSec.ComputePCurveOn2(bPC2);
aSec.SetFuzzyValue(aTol);
//
aSec.Build();
iErr=aSec.ErrorStatus();
if (!aSec.IsDone()) {
Sprintf(buf, " ErrorStatus : %d\n", iErr);
di << buf;
return 0;
}
else {
di << usage;
return 1;
//
const TopoDS_Shape& aR=aSec.Shape();
if (aR.IsNull()) {
di << " null shape\n";
return 0;
}
DBRep::Set(a[1], aR);
return 0;
}
//=======================================================================
//function : bsmt
//purpose :
@@ -460,9 +441,10 @@ Standard_Integer bsmt (Draw_Interpretor& di,
Standard_Integer iErr;
TopoDS_Shape aS1, aS2;
BOPCol_ListOfShape aLC;
Standard_Real aTol;
//
if (n!=4) {
di << " use bx r s1 s2\n";
if (n < 4 || n > 5) {
di << " use bx r s1 s2 [tol]\n";
return 1;
}
//
@@ -473,6 +455,12 @@ Standard_Integer bsmt (Draw_Interpretor& di,
di << " null shapes are not allowed \n";
return 1;
}
//
aTol = 0.;
if (n == 5) {
aTol = Draw::Atof(a[4]);
}
//
aLC.Append(aS1);
aLC.Append(aS2);
//
@@ -480,6 +468,7 @@ Standard_Integer bsmt (Draw_Interpretor& di,
BOPAlgo_PaveFiller aPF(aAL);
//
aPF.SetArguments(aLC);
aPF.SetFuzzyValue(aTol);
//
aPF.Perform();
iErr=aPF.ErrorStatus();
@@ -781,63 +770,81 @@ Standard_Integer bparallelmode(Draw_Interpretor& di, Standard_Integer n, const c
//=======================================================================
Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
const char* usage = "Usage: mkvolume r b1 b2 ... [-ni (do not intersect)] [-s (run in non parallel mode)]\n";
if (n < 3) {
di << usage;
di << "Usage: mkvolume r b1 b2 ... [-c] [-ni] [-s] [tol]\n";
di << "Options:\n";
di << " -c - use this option if the arguments are compounds\n";
di << " containing shapes that should be interfered;\n";
di << " -ni - use this option if the arguments should not be interfered;\n";
di << " -s - use this option to run the operation in non parallel mode;\n";
di << " tol - additional tolerance value (real).\n";
return 1;
}
//
Standard_Boolean bToIntersect, bRunParallel;
Standard_Integer i, aNb;
const char* usage = "Type mkvolume without arguments for the usage of the command.\n";
//
aNb = n;
Standard_Boolean bToIntersect, bRunParallel, bCompounds;
Standard_Integer i;
Standard_Real aTol;
TopoDS_Shape aS;
BOPCol_ListOfShape aLS;
//
aTol = 0.;
bToIntersect = Standard_True;
bRunParallel = Standard_True;
bCompounds = Standard_False;
//
if (!strcmp(a[n-1], "-ni")) {
bToIntersect = Standard_False;
aNb = n-1;
}
else if (!strcmp(a[n-1], "-s")) {
bRunParallel = Standard_False;
aNb = n-1;
}
if (n > 3) {
if (!strcmp(a[n-2], "-ni")) {
bToIntersect = Standard_False;
aNb = n-2;
}
else if (!strcmp(a[n-2], "-s")) {
bRunParallel = Standard_False;
aNb = n-2;
}
}
//
if (aNb < 3) {
di << "no shapes to process.\n";
di << usage;
return 1;
}
//
BOPCol_ListOfShape aLS;
TopoDS_Shape aS;
for (i = 2; i < aNb; ++i) {
for (i = 2; i < n; ++i) {
aS = DBRep::Get(a[i]);
if (!aS.IsNull()) {
aLS.Append(aS);
}
else {
if (!strcmp(a[i], "-c")) {
bCompounds = Standard_True;
}
else if (!strcmp(a[i], "-ni")) {
bToIntersect = Standard_False;
}
else if (!strcmp(a[i], "-s")) {
bRunParallel = Standard_False;
}
else {
aTol = Draw::Atof(a[i]);
}
}
}
//
if (aLS.IsEmpty()) {
di << "no shapes to process.\n";
di << "No shapes to process.\n";
di << usage;
return 1;
}
//
// treat list of arguments for the case of compounds
if (bToIntersect && bCompounds) {
BOPCol_ListOfShape aLSx;
BOPCol_ListIteratorOfListOfShape aItLS;
//
aItLS.Initialize(aLS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSx = aItLS.Value();
TopoDS_Iterator aItS(aSx);
for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aSxS = aItS.Value();
aLSx.Append(aSxS);
}
}
//
aLS.Clear();
aLS.Assign(aLSx);
}
//
BOPAlgo_MakerVolume aMV;
aMV.SetArguments(aLS);
aMV.SetIntersect(bToIntersect);
aMV.SetRunParallel(bRunParallel);
aMV.SetFuzzyValue(aTol);
//
aMV.Perform();
if (aMV.ErrorStatus()) {
@@ -851,4 +858,3 @@ Standard_Integer mkvolume(Draw_Interpretor& di, Standard_Integer n, const char**
//
return 0;
}

View File

@@ -152,7 +152,7 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
const char** a )
{
if (n<2) {
di << " Use > bopcheck Shape [level of check: 0 - 9] [-t -s]" << "\n";
di << " Use > bopcheck Shape [level of check: 0 - 9] [-t -s] [-tol tol]" << "\n";
di << " The level of check defines ";
di << " which interferences will be checked:\n";
di << " 0 - V/V only\n";
@@ -177,13 +177,16 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
//
Standard_Boolean bRunParallel, bShowTime;
Standard_Integer i, aLevel, aNbInterfTypes;
Standard_Real aTolerance;
//
aNbInterfTypes=BOPDS_DS::NbInterfTypes();
//
aLevel=aNbInterfTypes-1;
//
if (n>2) {
aLevel=Draw::Atoi(a[2]);
if (a[2][0] != '-') {
aLevel=Draw::Atoi(a[2]);
}
}
//
if (aLevel < 0 || aLevel > aNbInterfTypes-1) {
@@ -191,15 +194,22 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
return 1;
}
//
aTolerance = 0;
bShowTime=Standard_False;
bRunParallel=Standard_True;
for (i=3; i<n; ++i) {
for (i=2; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
}
else if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
else if (!strcmp(a[i], "-tol")) {
if (i+1 < n) {
++i;
aTolerance = Draw::Atof(a[i]);
}
}
}
//
//aLevel = (n==3) ? Draw::Atoi(a[2]) : aNbInterfTypes-1;
@@ -233,6 +243,7 @@ Standard_Integer bopcheck (Draw_Interpretor& di,
aChecker.SetArguments(aLS);
aChecker.SetLevelOfCheck(aLevel);
aChecker.SetRunParallel(bRunParallel);
aChecker.SetFuzzyValue(aTolerance);
//
aChrono.Start();
//
@@ -331,7 +342,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (n<2) {
di << "\n";
di << " Use >bopargcheck Shape1 [[Shape2] ";
di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF]" << "\n" << "\n";
di << "[-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF] [-tol tol]" << "\n" << "\n";
di << " -<Boolean Operation>" << "\n";
di << " F (fuse)" << "\n";
di << " O (common)" << "\n";
@@ -385,11 +396,19 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
Standard_Integer indxAD = 0;
Standard_Boolean isS2 = Standard_False;
Standard_Integer indxS2 = 0;
Standard_Real aTolerance = 0;
if(n >= 3) {
Standard_Integer iIndex = 0;
for(iIndex = 2; iIndex < n; iIndex++) {
if(a[iIndex][0] == '-')
if(!strcmp(a[iIndex], "-tol"))
{
if ((iIndex+1) < n) {
++iIndex;
aTolerance = Draw::Atof(a[iIndex]);
}
}
else if(a[iIndex][0] == '-')
{
isBO = Standard_True;
indxBO = iIndex;
@@ -411,7 +430,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
}
}
}
// set & test second shape
TopoDS_Shape aS22, aS2;
if(isS2) {
@@ -429,9 +448,10 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
}
}
}
// init checker
BOPAlgo_ArgumentAnalyzer aChecker;
aChecker.SetFuzzyValue(aTolerance);
aChecker.SetShape1(aS1);
// set default options (always tested!) for single and couple shapes
@@ -729,13 +749,13 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_BadType != 0)
CString1="YES";
else
CString1="NO";
CString1=aChecker.ArgumentTypeMode() ? "NO" : "DISABLED";
di << "Shapes are not suppotrted by BOP: " << CString1 << "\n";
Standard_CString CString2;
if (S1_SelfInt != 0)
CString2="YES";
else
CString2="NO";
CString2=aChecker.SelfInterMode() ? "NO" : "DISABLED";
di << "Self-Intersections : " << CString2;
if(S1_SelfInt != 0)
di << " Cases(" << S1_SelfInt << ") Total shapes(" << S1_SelfIntAll << ")" << "\n";
@@ -745,13 +765,13 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_OpAb != 0)
CString13="YES";
else
CString13="NO";
CString13=aChecker.SelfInterMode() ? "NO" : "DISABLED";
di << "Check for SI has been aborted : " << CString13 << "\n";
Standard_CString CString3;
if (S1_SmalE != 0)
CString3="YES";
else
CString3="NO";
CString3=aChecker.SmallEdgeMode() ? "NO" : "DISABLED";
di << "Too small edges : " << CString3;
if(S1_SmalE != 0)
di << " Cases(" << S1_SmalE << ") Total shapes(" << S1_SmalEAll << ")" << "\n";
@@ -761,7 +781,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_BadF != 0)
CString4="YES";
else
CString4="NO";
CString4=aChecker.RebuildFaceMode() ? "NO" : "DISABLED";
di << "Bad faces : " << CString4;
if(S1_BadF != 0)
di << " Cases(" << S1_BadF << ") Total shapes(" << S1_BadFAll << ")" << "\n";
@@ -771,7 +791,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_BadV != 0)
CString5="YES";
else
CString5="NO";
CString5=aChecker.MergeVertexMode() ? "NO" : "DISABLED";
di << "Too close vertices : " << CString5;
if(S1_BadV != 0)
di << " Cases(" << S1_BadV << ") Total shapes(" << S1_BadVAll << ")" << "\n";
@@ -781,7 +801,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_BadE != 0)
CString6="YES";
else
CString6="NO";
CString6=aChecker.MergeEdgeMode() ? "NO" : "DISABLED";
di << "Too close edges : " << CString6;
if(S1_BadE != 0)
di << " Cases(" << S1_BadE << ") Total shapes(" << S1_BadEAll << ")" << "\n";
@@ -791,7 +811,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_C0 != 0)
CString15="YES";
else
CString15="NO";
CString15=aChecker.ContinuityMode() ? "NO" : "DISABLED";
di << "Shapes with Continuity C0 : " << CString15;
if(S1_C0 != 0)
di << " Cases(" << S1_C0 << ") Total shapes(" << S1_C0All << ")" << "\n";
@@ -802,7 +822,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S1_COnS != 0)
CString17="YES";
else
CString17="NO";
CString17=aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED";
di << "Invalid Curve on Surface : " << CString17;
if(S1_COnS != 0)
di << " Cases(" << S1_COnS << ") Total shapes(" << S1_COnSAll << ")" << "\n";
@@ -819,13 +839,13 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_BadType != 0)
CString7="YES";
else
CString7="NO";
CString7=aChecker.ArgumentTypeMode() ? "NO" : "DISABLED";
di << "Shapes are not suppotrted by BOP: " << CString7 << "\n";
Standard_CString CString8;
if (S2_SelfInt != 0)
CString8="YES";
else
CString8="NO";
CString8=aChecker.SelfInterMode() ? "NO" : "DISABLED";
di << "Self-Intersections : " << CString8;
if(S2_SelfInt != 0)
di << " Cases(" << S2_SelfInt << ") Total shapes(" << S2_SelfIntAll << ")" << "\n";
@@ -836,13 +856,13 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_OpAb != 0)
CString14="YES";
else
CString14="NO";
CString14=aChecker.SelfInterMode() ? "NO" : "DISABLED";
di << "Check for SI has been aborted : " << CString14 << "\n";
Standard_CString CString9;
if (S2_SmalE != 0)
CString9="YES";
else
CString9="NO";
CString9=aChecker.SmallEdgeMode() ? "NO" : "DISABLED";
di << "Too small edges : " << CString9;
if(S2_SmalE != 0)
di << " Cases(" << S2_SmalE << ") Total shapes(" << S2_SmalEAll << ")" << "\n";
@@ -852,7 +872,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_BadF != 0)
CString10="YES";
else
CString10="NO";
CString10=aChecker.RebuildFaceMode() ? "NO" : "DISABLED";
di << "Bad faces : " << CString10;
if(S2_BadF != 0)
di << " Cases(" << S2_BadF << ") Total shapes(" << S2_BadFAll << ")" << "\n";
@@ -862,7 +882,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_BadV != 0)
CString11="YES";
else
CString11="NO";
CString11=aChecker.MergeVertexMode() ? "NO" : "DISABLED";
di << "Too close vertices : " << CString11;
if(S2_BadV != 0)
di << " Cases(" << S2_BadV << ") Total shapes(" << S2_BadVAll << ")" << "\n";
@@ -872,7 +892,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_BadE != 0)
CString12="YES";
else
CString12="NO";
CString12=aChecker.MergeEdgeMode() ? "NO" : "DISABLED";
di << "Too close edges : " << CString12;
if(S2_BadE != 0)
di << " Cases(" << S2_BadE << ") Total shapes(" << S2_BadEAll << ")" << "\n";
@@ -882,7 +902,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_C0 != 0)
CString16="YES";
else
CString16="NO";
CString16=aChecker.ContinuityMode() ? "NO" : "DISABLED";
di << "Shapes with Continuity C0 : " << CString16;
if(S2_C0 != 0)
di << " Cases(" << S2_C0 << ") Total shapes(" << S2_C0All << ")" << "\n";
@@ -893,7 +913,7 @@ Standard_Integer bopargcheck (Draw_Interpretor& di,
if (S2_COnS != 0)
CString18="YES";
else
CString18="NO";
CString18=aChecker.CurveOnSurfaceMode() ? "NO" : "DISABLED";
di << "Invalid Curve on Surface : " << CString18;
if(S2_COnS != 0)
di << " Cases(" << S2_COnS << ") Total shapes(" << S2_COnSAll << ")" << "\n";
@@ -975,7 +995,7 @@ Standard_Integer checkcurveonsurf(Draw_Interpretor& di,
}
//
Standard_Integer nE, nF, anECounter, aFCounter;
Standard_Real aT, aTolE, aD, aDMax;
Standard_Real aT, aTolE, aDMax;
TopExp_Explorer aExpF, aExpE;
char buf[200], aFName[10], anEName[10];
NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> aDMETol;
@@ -1002,10 +1022,9 @@ Standard_Integer checkcurveonsurf(Draw_Interpretor& di,
}
//
if (aDMETol.IsBound(aE)) {
aD = aDMETol.Find(aE);
Standard_Real& aD = aDMETol.ChangeFind(aE);
if (aDMax > aD) {
aDMETol.UnBind(aE);
aDMETol.Bind(aE, aDMax);
aD = aDMax;
}
}
else {

View File

@@ -54,10 +54,10 @@ void BOPTest::PartitionCommands(Draw_Interpretor& theCommands)
// Chapter's name
const char* g = "Partition commands";
// Commands
theCommands.Add("bfillds", "use bfillds [-s -t]" , __FILE__, bfillds, g);
theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
theCommands.Add("bbop" , "use bbop r op [-s -t]", __FILE__, bbop, g);
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
theCommands.Add("bfillds", "use bfillds [-s -t] [tol]" , __FILE__, bfillds, g);
theCommands.Add("bbuild" , "use bbuild r [-s -t]" , __FILE__, bbuild, g);
theCommands.Add("bbop" , "use bbop r op [-s -t]" , __FILE__, bbop, g);
theCommands.Add("bclear" , "use bclear" , __FILE__, bclear, g);
}
//=======================================================================
@@ -84,14 +84,15 @@ Standard_Integer bfillds(Draw_Interpretor& di,
Standard_Integer n,
const char** a)
{
if (n>3) {
di << " use bfillds [-s -t]\n";
if (n > 4) {
di << " use bfillds [-s -t] [tol]\n";
return 0;
}
//
char buf[32];
Standard_Boolean bRunParallel, bShowTime;
Standard_Integer i, aNbS, iErr;
Standard_Real aTol;
BOPCol_ListIteratorOfListOfShape aIt;
BOPCol_ListOfShape aLC;
BOPTime_Chronometer aChrono;
@@ -103,8 +104,9 @@ Standard_Integer bfillds(Draw_Interpretor& di,
return 0;
}
//
bShowTime=Standard_False;
bRunParallel=Standard_True;
bShowTime = Standard_False;
bRunParallel = Standard_True;
aTol = 0.;
for (i=1; i<n; ++i) {
if (!strcmp(a[i], "-s")) {
bRunParallel=Standard_False;
@@ -112,6 +114,9 @@ Standard_Integer bfillds(Draw_Interpretor& di,
else if (!strcmp(a[i], "-t")) {
bShowTime=Standard_True;
}
else {
aTol = Draw::Atof(a[i]);
}
}
//
BOPCol_ListOfShape& aLT=BOPTest_Objects::Tools();
@@ -132,6 +137,7 @@ Standard_Integer bfillds(Draw_Interpretor& di,
//
aPF.SetArguments(aLC);
aPF.SetRunParallel(bRunParallel);
aPF.SetFuzzyValue(aTol);
//
aChrono.Start();
//
@@ -318,6 +324,14 @@ Standard_Integer bbop(Draw_Interpretor& di,
//
pBOP->SetOperation(aOp);
}
else {
BOPCol_ListOfShape& aLSTools=BOPTest_Objects::Tools();
aIt.Initialize(aLSTools);
for (; aIt.More(); aIt.Next()) {
const TopoDS_Shape& aS=aIt.Value();
pBuilder->AddArgument(aS);
}
}
//
pBuilder->SetRunParallel(bRunParallel);
//

View File

@@ -99,7 +99,8 @@ static
gp_Pnt& aPOut,
Handle(IntTools_Context)& theContext,
GeomAPI_ProjectPointOnSurf& aProjPL,
const Standard_Real aDt);
const Standard_Real aDt,
const Standard_Real aTolE);
static
Standard_Real MinStep3D(const TopoDS_Edge& theE1,
const TopoDS_Face& theF1,
@@ -1825,14 +1826,18 @@ void GetFaceDir(const TopoDS_Edge& aE,
GeomAPI_ProjectPointOnSurf& aProjPL,
const Standard_Real aDt)
{
Standard_Real aTolE;
gp_Pnt aPx;
//
BOPTools_AlgoTools3D::GetNormalToFaceOnEdge(aE, aF, aT, aDN);
if (aF.Orientation()==TopAbs_REVERSED){
aDN.Reverse();
}
//
aTolE=BRep_Tool::Tolerance(aE);
aDB = aDN^aDTgt;
//
gp_Pnt aPx;
if (!FindPointInFace(aF, aP, aDB, aPx, theContext, aProjPL, aDt)) {
if (!FindPointInFace(aF, aP, aDB, aPx, theContext, aProjPL, aDt, aTolE)) {
BOPTools_AlgoTools3D::GetApproxNormalToFaceOnEdge(aE, aF, aT, aPx,
aDN, theContext);
aProjPL.Perform(aPx);
@@ -1841,7 +1846,6 @@ void GetFaceDir(const TopoDS_Edge& aE,
aDB.SetXYZ(aVec.XYZ());
}
}
//=======================================================================
//function : FindPointInFace
//purpose : Find a point in the face in direction of <aDB>
@@ -1852,12 +1856,13 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF,
gp_Pnt& aPOut,
Handle(IntTools_Context)& theContext,
GeomAPI_ProjectPointOnSurf& aProjPL,
const Standard_Real aDt)
const Standard_Real aDt,
const Standard_Real aTolE)
{
Standard_Integer aNbItMax;
Standard_Real aDist, aDTol, aPM;
Standard_Boolean bRet;
gp_Pnt aP1;
gp_Pnt aP1, aPS;
//
aDTol = Precision::Angular();
aPM = aP.XYZ().Modulus();
@@ -1869,10 +1874,27 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF,
//
GeomAPI_ProjectPointOnSurf& aProj=theContext->ProjPS(aF);
//
aPS=aP;
aProj.Perform(aPS);
if (!aProj.IsDone()) {
return bRet;
}
aPS=aProj.NearestPoint();
aProjPL.Perform(aPS);
aPS=aProjPL.NearestPoint();
//
aPS.SetXYZ(aPS.XYZ()+2.*aTolE*aDB.XYZ());
aProj.Perform(aPS);
if (!aProj.IsDone()) {
return bRet;
}
aPS=aProj.NearestPoint();
aProjPL.Perform(aPS);
aPS=aProjPL.NearestPoint();
//
//
do {
aP1.SetCoord(aP.X()+aDt*aDB.X(),
aP.Y()+aDt*aDB.Y(),
aP.Z()+aDt*aDB.Z());
aP1.SetXYZ(aPS.XYZ()+aDt*aDB.XYZ());
//
aProj.Perform(aP1);
if (!aProj.IsDone()) {
@@ -1884,7 +1906,7 @@ Standard_Boolean FindPointInFace(const TopoDS_Face& aF,
aProjPL.Perform(aPOut);
aPOut = aProjPL.NearestPoint();
//
gp_Vec aV(aP, aPOut);
gp_Vec aV(aPS, aPOut);
aDB.SetXYZ(aV.XYZ());
} while (aDist > aDTol && --aNbItMax);
//
@@ -2006,8 +2028,8 @@ Standard_Boolean BOPTools_AlgoTools::IsOpenShell(const TopoDS_Shell& aSh)
//function : IsInvertedSolid
//purpose :
//=======================================================================
Standard_Boolean
BOPTools_AlgoTools::IsInvertedSolid(const TopoDS_Solid& aSolid)
Standard_Boolean BOPTools_AlgoTools::IsInvertedSolid
(const TopoDS_Solid& aSolid)
{
Standard_Real aTolS;
TopAbs_State aState;

View File

@@ -1191,12 +1191,12 @@ static Standard_Boolean MinComputing( BOPTools_CheckCurveOnSurface& theFunction,
// Function : ComputeTolerance
// purpose :
//=======================================================================
Standard_Boolean BOPTools_AlgoTools::
ComputeTolerance( const Handle(Geom_Curve)& theCurve3D,
const Handle(Geom2d_Curve)& theCurve2D,
const Handle(Geom_Surface)& theSurf,
Standard_Real& theMaxDist,
Standard_Real& theMaxPar)
Standard_Boolean BOPTools_AlgoTools::ComputeTolerance
(const Handle(Geom_Curve)& theCurve3D,
const Handle(Geom2d_Curve)& theCurve2D,
const Handle(Geom_Surface)& theSurf,
Standard_Real& theMaxDist,
Standard_Real& theMaxPar)
{
if (theCurve3D.IsNull() ||
theCurve2D.IsNull() ||

View File

@@ -14,103 +14,33 @@
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-- modified by Peter KURNEV Tue Mar 5 14:01:51 2002
package BRepAlgoAPI
---Purpose: The BRepAlgoAPI package provides a full range of
-- services to perform Boolean Operations on arguments (shapes
-- that are defined in the BRep data structures). The
-- implemented new algorithm is intended to replace the Old
-- Boolean Operations algorithm in the BRepAlgoAPI package.
-- The New algorithm is free of a large number of weak spots
-- and limitations characteristics of the Old algorithm.
-- It is more powerful and flexible.
-- It can process arguments the Old algorithm was not adapted for.
-- The new algorithm is based on a new approach to operations
-- with interfered shapes. The advantages of the new algorithm
-- include an ability to treat arguments that have shared
-- entities. It can properly process two solids with shared
-- faces (in terms of TopoDS_Shape::IsSame()), two
-- faces that have shared edges and so on. Now the New Boolean
-- Operation algorithm can treat a wide range of shapes while the
-- Old one fails on them.
-- A generalization of treatment of same-domain faces
-- was included into the New algorithm. Two faces that share
-- the same domain are processed according to the common rule
-- even if the underlying surfaces are of different types. This
-- allows to execute Boolean Operations properly for the same
-- domain faces. It also concerns solids and shells that have the
-- same domain faces. It is quite frequent when two faces share
-- the same domain. And the New algorithm successfully copes
-- with it in contrast to the Old one.
-- Generalization oftreatment of degenerated edges
-- gives a possibility to process them properly. Although there
-- are still some difficulties with processing faces in areas close
-- to degenerated edges.
-- Now the processing of arguments having internal sub-shapes gives
-- a correct result. Internal sub-shape means a sub-shape of a
-- shape with the orientation TopAbs_INTERNAL and is located
-- inside the shape boundaries. The New algorithm processes faces
-- with internal edges properly. The new API of the Boolean
-- Operations (in addition to the old API) allows to reuse the
-- already computed interference between arguments in different
-- types of Boolean Operations. It is possible to use once computed
-- interference in FUSE, CUT and COMMON operations on given
-- arguments. So there is no need to re-compute the interference
-- between the arguments. It allows to reduce time for more than one
-- operation on given arguments.
-- The shape type of a Boolean Operation result and types of the arguments:
-- - For arguments with the same shape type (e.g. SOLID /
-- SOLID) the type of the resulting shape will be a
-- COMPOUND, containing shapes of this type;
-- - For arguments with different shape types (e.g.
-- SHELL / SOLID) the type of the resulting shape will be a
-- COMPOUND, containing shapes of the type that is the same as
-- that of the low type of the argument. Example: For
-- SHELL/SOLID the result is a COMPOUND of SHELLs.
-- - For arguments with different shape types some of
-- Boolean Operations can not be done using the default
-- implementation, because of a non-manifold type of the
-- result. Example: the FUSE operation for SHELL and SOLID
-- can not be done, but the CUT operation can be done, where
-- SHELL is the object and SOLID is the tool.
-- It is possible to perform Boolean Operations on arguments
-- of the COMPOUND shape type. In this case each compound must not
-- be heterogeneous, i.e. it must contain equidimensional shapes
-- (EDGEs or/and WIREs, FACEs or/and SHELLs, SOLIDs). SOLIDs
-- inside the COMPOUND must not contact (intersect or touch)
-- each other. The same condition is true for SHELLs or FACEs,
-- WIREs or EDGEs.
-- It does not support Boolean Operations for COMPSOLID type of shape.
uses
TopTools,
TopoDS,
TopTools,
TopoDS,
gp,
Geom,
Geom2d,
BOPAlgo,
Geom2d,
Message,
BOPCol,
BOPAlgo,
BOPDS,
BRepBuilderAPI
BRepBuilderAPI
is
deferred class BooleanOperation;
class Fuse;
class Common;
class Cut;
class Section;
deferred class BooleanOperation;
class Fuse;
class Common;
class Cut;
class Section;
class Check;
---Purpose: Check shapes on validity for boolean
--- operation.
---Purpose: Check shapes on validity for boolean
--- operation.
deferred class Algo;
deferred class BuilderAlgo;
DumpOper( theFilePath : CString from Standard;
theShape1 : Shape from TopoDS;
theShape2 : Shape from TopoDS;
@@ -122,3 +52,70 @@ is
end BRepAlgoAPI;
---Purpose: The BRepAlgoAPI package provides a full range of
-- services to perform Boolean Operations on arguments (shapes
-- that are defined in the BRep data structures). The
-- implemented new algorithm is intended to replace the Old
-- Boolean Operations algorithm in the BRepAlgoAPI package.
-- The New algorithm is free of a large number of weak spots
-- and limitations characteristics of the Old algorithm.
-- It is more powerful and flexible.
-- It can process arguments the Old algorithm was not adapted for.
-- The new algorithm is based on a new approach to operations
-- with interfered shapes. The advantages of the new algorithm
-- include an ability to treat arguments that have shared
-- entities. It can properly process two solids with shared
-- faces (in terms of TopoDS_Shape::IsSame()), two
-- faces that have shared edges and so on. Now the New Boolean
-- Operation algorithm can treat a wide range of shapes while the
-- Old one fails on them.
-- A generalization of treatment of same-domain faces
-- was included into the New algorithm. Two faces that share
-- the same domain are processed according to the common rule
-- even if the underlying surfaces are of different types. This
-- allows to execute Boolean Operations properly for the same
-- domain faces. It also concerns solids and shells that have the
-- same domain faces. It is quite frequent when two faces share
-- the same domain. And the New algorithm successfully copes
-- with it in contrast to the Old one.
-- Generalization oftreatment of degenerated edges
-- gives a possibility to process them properly. Although there
-- are still some difficulties with processing faces in areas close
-- to degenerated edges.
-- Now the processing of arguments having internal sub-shapes gives
-- a correct result. Internal sub-shape means a sub-shape of a
-- shape with the orientation TopAbs_INTERNAL and is located
-- inside the shape boundaries. The New algorithm processes faces
-- with internal edges properly. The new API of the Boolean
-- Operations (in addition to the old API) allows to reuse the
-- already computed interference between arguments in different
-- types of Boolean Operations. It is possible to use once computed
-- interference in FUSE, CUT and COMMON operations on given
-- arguments. So there is no need to re-compute the interference
-- between the arguments. It allows to reduce time for more than one
-- operation on given arguments.
-- The shape type of a Boolean Operation result and types of the arguments:
-- - For arguments with the same shape type (e.g. SOLID /
-- SOLID) the type of the resulting shape will be a
-- COMPOUND, containing shapes of this type;
-- - For arguments with different shape types (e.g.
-- SHELL / SOLID) the type of the resulting shape will be a
-- COMPOUND, containing shapes of the type that is the same as
-- that of the low type of the argument. Example: For
-- SHELL/SOLID the result is a COMPOUND of SHELLs.
-- - For arguments with different shape types some of
-- Boolean Operations can not be done using the default
-- implementation, because of a non-manifold type of the
-- result. Example: the FUSE operation for SHELL and SOLID
-- can not be done, but the CUT operation can be done, where
-- SHELL is the object and SOLID is the tool.
-- It is possible to perform Boolean Operations on arguments
-- of the COMPOUND shape type. In this case each compound must not
-- be heterogeneous, i.e. it must contain equidimensional shapes
-- (EDGEs or/and WIREs, FACEs or/and SHELLs, SOLIDs). SOLIDs
-- inside the COMPOUND must not contact (intersect or touch)
-- each other. The same condition is true for SHELLs or FACEs,
-- WIREs or EDGEs.
-- It does not support Boolean Operations for COMPSOLID type of shape.

View File

@@ -0,0 +1,75 @@
-- Created by: Peter KURNEV
-- Copyright (c) 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.
deferred class Algo from BRepAlgoAPI
inherits MakeShape from BRepBuilderAPI
---Purpose: provides the root interface for algorithms
uses
BaseAllocator from BOPCol,
ProgressIndicator from Message,
Shape from TopoDS
--raises
is
Initialize
returns Algo from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Algo();"
Initialize (theAllocator: BaseAllocator from BOPCol)
returns Algo from BRepAlgoAPI;
ErrorStatus (me)
returns Integer from Standard;
WarningStatus (me)
returns Integer from Standard;
Allocator(me)
returns BaseAllocator from BOPCol;
---C++: return const &
SetRunParallel(me:out;
theFlag:Boolean from Standard);
---Purpose: Set the flag of parallel processing
-- if <theFlag> is true the parallel processing is switched on
-- if <theFlag> is false the parallel processing is switched off
--
RunParallel(me)
returns Boolean from Standard;
---Purpose: Returns the flag of parallel processing
SetProgressIndicator(me:out;
theObj: ProgressIndicator from Message);
---Purpose: Set the Progress Indicator object.
UserBreak(me)
is protected;
---Purpose: Breaks the execution if the break signal
-- is indicated by myProgressIndicator.
Shape(me)
returns Shape from TopoDS
is redefined;
---C++: return const &
fields
myAllocator : BaseAllocator from BOPCol is protected;
myErrorStatus : Integer from Standard is protected;
myWarningStatus : Integer from Standard is protected;
myRunParallel : Boolean from Standard is protected;
myProgressIndicator : ProgressIndicator from Message is protected;
end Algo;

View File

@@ -1,7 +1,5 @@
// Created on: 1994-11-14
// Created by: Bruno DUMORTIER
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Created by: Peter KURNEV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@@ -14,134 +12,115 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepFill_MultiLineTool.ixx>
#include <BRepAlgoAPI_Algo.ixx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <Standard_NotImplemented.hxx>
#include <NCollection_BaseAllocator.hxx>
//=======================================================================
//function : FirstParameter
//purpose :
// function:
// purpose:
//=======================================================================
Standard_Real BRepFill_MultiLineTool::FirstParameter
(const BRepFill_MultiLine& ML)
{
return ML.FirstParameter();
}
BRepAlgoAPI_Algo::BRepAlgoAPI_Algo()
:
myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()),
myErrorStatus(1),
myWarningStatus(0),
myRunParallel(Standard_False)
{}
//=======================================================================
// function:
// purpose:
//=======================================================================
BRepAlgoAPI_Algo::BRepAlgoAPI_Algo
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
myAllocator(theAllocator),
myErrorStatus(1),
myWarningStatus(0),
myRunParallel(Standard_False)
{}
//=======================================================================
//function : LastParameter
//purpose :
// function: ~
// purpose:
//=======================================================================
Standard_Real BRepFill_MultiLineTool::LastParameter
(const BRepFill_MultiLine& ML)
{
return ML.LastParameter();
}
//=======================================================================
//function : NbP2d
//purpose :
//=======================================================================
Standard_Integer BRepFill_MultiLineTool::NbP2d
(const BRepFill_MultiLine&)
{
return 2;
}
//=======================================================================
//function : NbP3d
//purpose :
//=======================================================================
Standard_Integer BRepFill_MultiLineTool::NbP3d(const BRepFill_MultiLine&)
{
return 1;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine& ,
const Standard_Real,
TColgp_Array1OfPnt&)
BRepAlgoAPI_Algo::~BRepAlgoAPI_Algo()
{
}
//=======================================================================
//function : Value
//function : Allocator
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfPnt2d&)
const Handle(NCollection_BaseAllocator)& BRepAlgoAPI_Algo::Allocator()const
{
return myAllocator;
}
//=======================================================================
//function : Value
// function: ErrorStatus
// purpose:
//=======================================================================
Standard_Integer BRepAlgoAPI_Algo::ErrorStatus()const
{
return myErrorStatus;
}
//=======================================================================
// function: WarningStatus
// purpose:
//=======================================================================
Standard_Integer BRepAlgoAPI_Algo::WarningStatus()const
{
return myWarningStatus;
}
//=======================================================================
//function : SetRunParallel
//purpose :
//=======================================================================
void BRepFill_MultiLineTool::Value(const BRepFill_MultiLine& ML,
const Standard_Real U,
TColgp_Array1OfPnt& tabPt,
TColgp_Array1OfPnt2d& tabPt2d)
void BRepAlgoAPI_Algo::SetRunParallel(const Standard_Boolean theFlag)
{
tabPt(1) = ML.Value(U);
tabPt2d(1) = ML.ValueOnF1(U);
tabPt2d(2) = ML.ValueOnF2(U);
myRunParallel=theFlag;
}
//=======================================================================
//function : D1
//function : RunParallel
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec&)
Standard_Boolean BRepAlgoAPI_Algo::RunParallel()const
{
return Standard_False;
return myRunParallel;
}
//=======================================================================
//function : D1
//function : SetProgressIndicator
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec2d&)
void BRepAlgoAPI_Algo::SetProgressIndicator
(const Handle(Message_ProgressIndicator)& theObj)
{
return Standard_False;
if (!theObj.IsNull()) {
myProgressIndicator=theObj;
}
}
//=======================================================================
//function : D1
//function : UserBreak
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLineTool::D1(const BRepFill_MultiLine&,
const Standard_Real,
TColgp_Array1OfVec&,
TColgp_Array1OfVec2d&)
void BRepAlgoAPI_Algo::UserBreak() const
{
return Standard_False;
if (myProgressIndicator.IsNull()) {
return;
}
if (myProgressIndicator->UserBreak()) {
Standard_NotImplemented::Raise("");
}
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& BRepAlgoAPI_Algo::Shape() const
{
return myShape;
}
// myErrorStatus
//
// 1 - object is just initialized

View File

@@ -14,12 +14,8 @@
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
-- modified by Peter KURNEV Tue Mar 5 14:01:51 2002
-- modified by Eugeny MALTCHIKOV Wed Jul 04 11:13:01 2012
deferred class BooleanOperation from BRepAlgoAPI
inherits MakeShape from BRepBuilderAPI
inherits BuilderAlgo from BRepAlgoAPI
---Purpose: The abstract class BooleanOperation is the root
-- class of Boolean Operations (see Overview).
@@ -33,30 +29,49 @@ deferred class BooleanOperation from BRepAlgoAPI
uses
Shape from TopoDS,
Shape from TopoDS,
DataMapOfShapeShape from TopTools,
ListOfShape from TopTools,
Operation from BOPAlgo,
Builder from BOPAlgo,
PBuilder from BOPAlgo,
PaveFiller from BOPAlgo,
PPaveFiller from BOPAlgo,
DataMapOfIntegerListOfShape from TopTools,
DataMapOfIntegerShape from TopTools,
DataMapOfShapeShape from TopTools
Operation from BOPAlgo,
PaveFiller from BOPAlgo
is
is
Initialize
returns BooleanOperation from BRepAlgoAPI;
Initialize (S1 :Shape from TopoDS;
S2 :Shape from TopoDS;
anOperation:Operation from BOPAlgo);
S2 :Shape from TopoDS;
anOperation:Operation from BOPAlgo);
---Purpose: Prepares the operations for S1 and S2.
Initialize (S1 :Shape from TopoDS;
S2 :Shape from TopoDS;
aDSF :PaveFiller from BOPAlgo;
anOperation:Operation from BOPAlgo);
S2 :Shape from TopoDS;
aPF :PaveFiller from BOPAlgo;
anOperation:Operation from BOPAlgo);
---Purpose: Prepares the operations for S1 and S2.
SetShape1(me:out;
S:Shape from TopoDS);
SetShape2(me:out;
S:Shape from TopoDS);
Shape1(me)
returns Shape from TopoDS
is static;
---Purpose: Returns the first shape involved in this Boolean operation.
---C++: return const &
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_BooleanOperation();"
Shape2(me)
returns Shape from TopoDS
is static;
---Purpose: Returns the second shape involved in this Boolean operation.
---C++: return const &
SetOperation (me:out;
anOp: Operation from BOPAlgo);
---Purpose: Sets the type of Boolean operation to perform
@@ -65,59 +80,35 @@ is
--- BOPAlgo_FUSE
--- BOPAlgo_CUT
--- BOPAlgo_CUT21
---
Build (me:out)
is redefined virtual;
---Purpose: Provides the algorithm of Boolean Operations
-- - Filling interference Data Structure (if it is necessary)
-- - Building the result of the operation.
Shape1(me)
returns Shape from TopoDS
is static;
---Purpose: Returns the first shape involved in this Boolean operation.
---C++: return const &
Shape2(me)
returns Shape from TopoDS
is static;
---Purpose: Returns the second shape involved in this Boolean operation.
---C++: return const &
---
Operation (me)
returns Operation from BOPAlgo;
---Purpose: Returns the type of Boolean Operation that has been performed.
Build (me:out)
is redefined virtual;
---Purpose: Provides the algorithm of Boolean Operations
-- - Filling interference Data Structure (if it is necessary)
-- - Building the result of the operation.
BuilderCanWork(me)
returns Boolean from Standard;
FuseEdges(me)
returns Boolean from Standard;
---Purpose: Returns the flag of edge refining
returns Boolean from Standard;
---Purpose: Returns the flag of edge refining
RefineEdges(me:out);
---Purpose: Fuse C1 edges
PrepareFiller(me:out)
returns Boolean from Standard
is protected;
---Category: Querying
BuilderCanWork(me)
returns Boolean from Standard;
ErrorStatus(me)
returns Integer from Standard;
---Purpose: Returns the error status of operation.
--- 0 - Ok
--- 1 - The Object is created but Nothing is Done
--- 2 - Null source shapes is not allowed
--- 3 - Check types of the arguments
--- 4 - Can not allocate memory for the DSFiller
--- 5 - The Builder can not work with such types of arguments
--- 6 - Unknown operation is not allowed
--- 7 - Can not allocate memory for the Builder
-- > 100 - See the Builder's ErrorStatus
SectionEdges (me: in out)
returns ListOfShape from TopTools;
--- Purpose: Returns a list of section edges.
-- The edges represent the result of intersection between arguments of
-- Boolean Operation. They are computed during operation execution.
---C++: return const &
Modified (me: in out;
aS : Shape from TopoDS)
returns ListOfShape from TopTools
@@ -157,39 +148,34 @@ is
is virtual;
---Purpose: Returns true if there is at least one deleted shape.
--- For use in BRepNaming.
Destroy (me: in out);
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_BooleanOperation(){Destroy();}"
SectionEdges (me: in out)
returns ListOfShape from TopTools;
--- Purpose: Returns a list of section edges.
-- The edges represent the result of intersection between arguments of
-- Boolean Operation. They are computed during operation execution.
---C++: return const &
--
-- protected
--
PrepareFiller(me:out)
returns Boolean from Standard
is protected;
RefinedList (me: in out;
theL : ListOfShape from TopTools)
returns ListOfShape from TopTools
is private;
is protected;
---Purpose: Returns the list of shapes generated from the shape <S>.
--- For use in BRepNaming.
---C++: return const &
fields
myS1 : Shape from TopoDS is protected;
myS2 : Shape from TopoDS is protected;
myBuilderCanWork : Boolean from Standard is protected;
myOperation : Operation from BOPAlgo is protected;
myErrorStatus : Integer from Standard is protected;
myDSFiller : PPaveFiller from BOPAlgo is protected;
myBuilder : PBuilder from BOPAlgo is protected;
myEntryType : Integer from Standard;
myS1 : Shape from TopoDS is protected;
myS2 : Shape from TopoDS is protected;
myOperation: Operation from BOPAlgo is protected;
--
myEntryType: Integer from Standard is protected;
myBuilderCanWork : Boolean from Standard is protected;
-- for edge refiner
myFuseEdges : Boolean from Standard ;
myModifFaces : DataMapOfShapeShape from TopTools;
myEdgeMap : DataMapOfShapeShape from TopTools;
myFuseEdges : Boolean from Standard ;
myModifFaces : DataMapOfShapeShape from TopTools;
myEdgeMap : DataMapOfShapeShape from TopTools;
end BooleanOperation;

View File

@@ -16,21 +16,42 @@
#include <BRepAlgoAPI_BooleanOperation.ixx>
#include <BRepAlgoAPI.hxx>
#include <BRepAlgoAPI_Check.hxx>
#include <BRepLib_FuseEdges.hxx>
#include <TopExp.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_DataMapOfIntegerListOfShape.hxx>
#include <TopTools_DataMapOfIntegerShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <BRepAlgoAPI_Check.hxx>
#include <BRepAlgoAPI.hxx>
#include <BRepLib_FuseEdges.hxx>
#include <BOPDS_PDS.hxx>
#include <BOPDS_DS.hxx>
#include <BOPDS_VectorOfCurve.hxx>
#include <BOPDS_Interf.hxx>
#include <BOPDS_Curve.hxx>
#include <BOPDS_ListOfPaveBlock.hxx>
#include <BOPAlgo_PaveFiller.hxx>
#include <BOPAlgo_BOP.hxx>
#include <BOPAlgo_Section.hxx>
//=======================================================================
//function : BRepAlgoAPI_BooleanOperation
//purpose :
//=======================================================================
BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation()
:
BRepAlgoAPI_BuilderAlgo(),
myOperation(BOPAlgo_UNKNOWN),
myEntryType(1),
myBuilderCanWork(Standard_False),
myFuseEdges(Standard_False)
{
}
//=======================================================================
//function : BRepAlgoAPI_BooleanOperation
//purpose :
@@ -40,14 +61,12 @@ BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
const TopoDS_Shape& aS2,
const BOPAlgo_Operation anOp)
:
BRepAlgoAPI_BuilderAlgo(),
myS1(aS1),
myS2(aS2),
myBuilderCanWork(Standard_False),
myOperation(anOp),
myErrorStatus(1),
myDSFiller(NULL),
myBuilder(NULL),
myEntryType(1),
myBuilderCanWork(Standard_False),
myFuseEdges(Standard_False)
{
}
@@ -55,40 +74,36 @@ BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
//function : BRepAlgoAPI_BooleanOperation
//purpose :
//=======================================================================
BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
const BOPAlgo_PaveFiller& aDSFiller,
const BOPAlgo_Operation anOp)
BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
const BOPAlgo_PaveFiller& aPF,
const BOPAlgo_Operation anOp)
:
BRepAlgoAPI_BuilderAlgo(),
myS1(aS1),
myS2(aS2),
myBuilderCanWork(Standard_False),
myOperation(anOp),
myErrorStatus(1),
myDSFiller(NULL),
myBuilder(NULL),
myEntryType(0),
myBuilderCanWork(Standard_False),
myFuseEdges(Standard_False)
{
if ((Standard_Address) &aDSFiller!=NULL) {
myDSFiller=(BOPAlgo_PaveFiller*)&aDSFiller;
}
myDSFiller=(BOPAlgo_PaveFiller*)&aPF;
}
//=======================================================================
//function : Destroy
//function : ~
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::Destroy()
BRepAlgoAPI_BooleanOperation::~BRepAlgoAPI_BooleanOperation()
{
if (myBuilder!=NULL) {
if (myBuilder) {
delete myBuilder;
myBuilder=NULL;
}
if (myDSFiller!=NULL && myEntryType) {
if (myDSFiller && myEntryType) {
delete myDSFiller;
myDSFiller=NULL;
}
//
myModifFaces.Clear();
myEdgeMap.Clear();
@@ -97,7 +112,8 @@ BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
//function : SetOperation
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::SetOperation (const BOPAlgo_Operation anOp)
void BRepAlgoAPI_BooleanOperation::SetOperation
(const BOPAlgo_Operation anOp)
{
myOperation=anOp;
}
@@ -105,38 +121,42 @@ BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
//function : Operation
//purpose :
//=======================================================================
BOPAlgo_Operation BRepAlgoAPI_BooleanOperation::Operation ()const
BOPAlgo_Operation BRepAlgoAPI_BooleanOperation::Operation ()const
{
return myOperation;
}
//=======================================================================
//function : FuseEdges
//function : SetShape1
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::FuseEdges ()const
void BRepAlgoAPI_BooleanOperation::SetShape1(const TopoDS_Shape& aS)
{
return myFuseEdges;
}
myS1=aS;
}
//=======================================================================
//function : SetShape2
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::SetShape2(const TopoDS_Shape& aS)
{
myS2=aS;
}
//=======================================================================
//function : Shape1
//purpose :
//=======================================================================
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape1() const
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape1() const
{
return myS1;
}
//=======================================================================
//function : Shape2
//purpose :
//=======================================================================
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape2() const
const TopoDS_Shape& BRepAlgoAPI_BooleanOperation::Shape2() const
{
return myS2;
}
//=======================================================================
//function : BuilderCanWork
//purpose :
@@ -146,54 +166,18 @@ BRepAlgoAPI_BooleanOperation::BRepAlgoAPI_BooleanOperation
return myBuilderCanWork;
}
//=======================================================================
//function : ErrorStatus
//function : FuseEdges
//purpose :
//=======================================================================
Standard_Integer BRepAlgoAPI_BooleanOperation::ErrorStatus()const
Standard_Boolean BRepAlgoAPI_BooleanOperation::FuseEdges ()const
{
return myErrorStatus;
return myFuseEdges;
}
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_Shape& aS)
{
if (myBuilder==NULL) {
myGenerated.Clear();
return myGenerated;
}
else {
myGenerated = myBuilder->Modified(aS);
if(myFuseEdges) {
TopTools_ListOfShape theLS;
theLS.Assign(myGenerated);
//
RefinedList(theLS);
}
return myGenerated;
}
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::IsDeleted(const TopoDS_Shape& aS)
{
Standard_Boolean bDeleted = Standard_True;
if (myBuilder != NULL) {
bDeleted=myBuilder->IsDeleted(aS);
}
return bDeleted;
}
//=======================================================================
//function : PrepareFiller
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::PrepareFiller()
Standard_Boolean BRepAlgoAPI_BooleanOperation::PrepareFiller()
{
Standard_Boolean bIsNewFiller=Standard_False;
myErrorStatus=1;
@@ -223,6 +207,9 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_
aLS.Append(myS2);
//
myDSFiller->SetArguments(aLS);
myDSFiller->SetRunParallel(myRunParallel);
myDSFiller->SetProgressIndicator(myProgressIndicator);
myDSFiller->SetFuzzyValue(myFuzzyValue);
}
return bIsNewFiller;
@@ -231,7 +218,7 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_
//function : Build
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::Build()
void BRepAlgoAPI_BooleanOperation::Build()
{
Standard_Boolean bIsNewFiller;
Standard_Integer iErr;
@@ -288,6 +275,8 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_
pBOP->SetOperation(myOperation);
}
//
myBuilder->SetRunParallel(myRunParallel);
myBuilder->SetProgressIndicator(myProgressIndicator);
myBuilder->PerformWithFiller(*myDSFiller);
iErr = myBuilder->ErrorStatus();
if (!iErr) {
@@ -316,12 +305,99 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified(const TopoDS_
}
}
//
//=======================================================================
//function : RefineEdges
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::RefineEdges ()
{
if(myFuseEdges) return; //Edges have been refined yet
BRepLib_FuseEdges FE(myShape);
FE.SetConcatBSpl(Standard_True);
// avoid fusing old edges
TopTools_IndexedMapOfShape mapOldEdges;
TopExp::MapShapes (myS1, TopAbs_EDGE, mapOldEdges);
TopExp::MapShapes (myS2, TopAbs_EDGE, mapOldEdges);
FE.AvoidEdges (mapOldEdges);
// Get List of edges that have been fused
myFuseEdges = Standard_False;
myModifFaces.Clear();
myEdgeMap.Clear();
TopTools_DataMapOfIntegerListOfShape aFusedEdges;
FE.Edges(aFusedEdges);
Standard_Integer nle = aFusedEdges.Extent();
if (nle != 0) {
FE.Perform();
myShape = FE.Shape();
TopTools_DataMapOfIntegerShape aResultEdges;
FE.ResultEdges(aResultEdges);
FE.Faces(myModifFaces);
myFuseEdges = Standard_True;
Standard_Integer i;
for(i = 1; i <= nle; ++i) {
const TopoDS_Shape& aNewE = aResultEdges(i);
const TopTools_ListOfShape& aListOfOldEdges = aFusedEdges(i);
TopTools_ListIteratorOfListOfShape anIter(aListOfOldEdges);
for(; anIter.More(); anIter.Next()) {
myEdgeMap.Bind(anIter.Value(), aNewE);
}
}
}
}
//=======================================================================
//function : RefinedList
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::RefinedList
(const TopTools_ListOfShape& theL)
{
myGenerated.Clear();
TopTools_MapOfShape aMap;
TopTools_ListIteratorOfListOfShape anIter(theL);
for(; anIter.More(); anIter.Next()) {
const TopoDS_Shape& anS = anIter.Value();
if(anS.ShapeType() == TopAbs_EDGE) {
if(myEdgeMap.IsBound(anS)) {
const TopoDS_Shape& aNewEdge = myEdgeMap.Find(anS);
if(aMap.Add(aNewEdge)) {
myGenerated.Append(aNewEdge);
}
}
else {
myGenerated.Append(anS);
}
}
else if (anS.ShapeType() == TopAbs_FACE) {
if(myModifFaces.IsBound(anS)) {
myGenerated.Append(myModifFaces.Find(anS));
}
else {
myGenerated.Append(anS);
}
}
else {
myGenerated.Append(anS);
}
}
return myGenerated;
}
//=======================================================================
//function : SectionEdges
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges()
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges()
{
if (myBuilder==NULL) {
myGenerated.Clear();
@@ -364,12 +440,12 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::SectionEdges()
//
return myGenerated;
}
// ================================================================================================
// function: Generated
// purpose:
// ================================================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated(const TopoDS_Shape& S)
//=======================================================================
//function : Generated
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated
(const TopoDS_Shape& S)
{
if (myBuilder==NULL) {
myGenerated.Clear();
@@ -384,10 +460,46 @@ const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Generated(const TopoDS
return myBuilder->Generated(S);
}
// ================================================================================================
// function: HasModified
// purpose:
// ================================================================================================
//=======================================================================
//function : Modified
//purpose :
//=======================================================================
const TopTools_ListOfShape& BRepAlgoAPI_BooleanOperation::Modified
(const TopoDS_Shape& aS)
{
if (myBuilder==NULL) {
myGenerated.Clear();
return myGenerated;
}
else {
myGenerated = myBuilder->Modified(aS);
if(myFuseEdges) {
TopTools_ListOfShape theLS;
theLS.Assign(myGenerated);
//
RefinedList(theLS);
}
return myGenerated;
}
}
//=======================================================================
//function : IsDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::IsDeleted
(const TopoDS_Shape& aS)
{
Standard_Boolean bDeleted = Standard_True;
if (myBuilder != NULL) {
bDeleted=myBuilder->IsDeleted(aS);
}
return bDeleted;
}
//=======================================================================
//function : HasModified
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasModified() const
{
if (myBuilder==NULL) {
@@ -395,11 +507,10 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasModified() const
}
return myBuilder->HasModified();
}
// ================================================================================================
// function: HasGenerated
// purpose:
// ================================================================================================
//=======================================================================
//function : HasGenerated
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasGenerated() const
{
if (myBuilder==NULL) {
@@ -407,11 +518,10 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasGenerated() const
}
return myBuilder->HasGenerated();
}
// ================================================================================================
// function: HasDeleted
// purpose:
// ================================================================================================
//=======================================================================
//function : HasDeleted
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const
{
if (myBuilder==NULL) {
@@ -419,93 +529,3 @@ Standard_Boolean BRepAlgoAPI_BooleanOperation::HasDeleted() const
}
return myBuilder->HasDeleted();
}
//=======================================================================
//function : RefineEdges
//purpose :
//=======================================================================
void BRepAlgoAPI_BooleanOperation::RefineEdges ()
{
if(myFuseEdges) return; //Edges have been refined yet
BRepLib_FuseEdges FE(myShape);
FE.SetConcatBSpl(Standard_True);
// avoid fusing old edges
TopTools_IndexedMapOfShape mapOldEdges;
TopExp::MapShapes (myS1, TopAbs_EDGE, mapOldEdges);
TopExp::MapShapes (myS2, TopAbs_EDGE, mapOldEdges);
FE.AvoidEdges (mapOldEdges);
// Get List of edges that have been fused
myFuseEdges = Standard_False;
myModifFaces.Clear();
myEdgeMap.Clear();
TopTools_DataMapOfIntegerListOfShape aFusedEdges;
FE.Edges(aFusedEdges);
Standard_Integer nle = aFusedEdges.Extent();
if (nle != 0) {
FE.Perform();
myShape = FE.Shape();
TopTools_DataMapOfIntegerShape aResultEdges;
FE.ResultEdges(aResultEdges);
FE.Faces(myModifFaces);
myFuseEdges = Standard_True;
Standard_Integer i;
for(i = 1; i <= nle; ++i) {
const TopoDS_Shape& aNewE = aResultEdges(i);
const TopTools_ListOfShape& aListOfOldEdges = aFusedEdges(i);
TopTools_ListIteratorOfListOfShape anIter(aListOfOldEdges);
for(; anIter.More(); anIter.Next()) {
myEdgeMap.Bind(anIter.Value(), aNewE);
}
}
}
}
//=======================================================================
//function : RefinedList
//purpose :
//=======================================================================
const TopTools_ListOfShape&
BRepAlgoAPI_BooleanOperation::RefinedList(const TopTools_ListOfShape& theL)
{
myGenerated.Clear();
TopTools_MapOfShape aMap;
TopTools_ListIteratorOfListOfShape anIter(theL);
for(; anIter.More(); anIter.Next()) {
const TopoDS_Shape& anS = anIter.Value();
if(anS.ShapeType() == TopAbs_EDGE) {
if(myEdgeMap.IsBound(anS)) {
const TopoDS_Shape& aNewEdge = myEdgeMap.Find(anS);
if(aMap.Add(aNewEdge)) {
myGenerated.Append(aNewEdge);
}
}
else {
myGenerated.Append(anS);
}
}
else if (anS.ShapeType() == TopAbs_FACE) {
if(myModifFaces.IsBound(anS)) {
myGenerated.Append(myModifFaces.Find(anS));
}
else {
myGenerated.Append(anS);
}
}
else {
myGenerated.Append(anS);
}
}
return myGenerated;
}

View File

@@ -0,0 +1,47 @@
-- Created by: Peter KURNEV
-- Copyright (c) 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.
deferred class BuilderAlgo from BRepAlgoAPI
inherits Algo from BRepAlgoAPI
---Purpose: provides the root interface for algorithms
uses
BaseAllocator from BOPCol,
PPaveFiller from BOPAlgo,
PBuilder from BOPAlgo
--raises
is
Initialize
returns BuilderAlgo from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_BuilderAlgo();"
Initialize (theAllocator: BaseAllocator from BOPCol)
returns BuilderAlgo from BRepAlgoAPI;
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---Purpose: Sets the additional tolerance
FuzzyValue(me)
returns Real from Standard;
---Purpose: Returns the additional tolerance
fields
myDSFiller : PPaveFiller from BOPAlgo is protected;
myBuilder : PBuilder from BOPAlgo is protected;
myFuzzyValue : Real from Standard is protected;
end BuilderAlgo;

View File

@@ -0,0 +1,67 @@
// Created by: Peter KURNEV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepAlgoAPI_BuilderAlgo.ixx>
#include <NCollection_BaseAllocator.hxx>
//=======================================================================
// function:
// purpose:
//=======================================================================
BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo()
:
BRepAlgoAPI_Algo(),
myDSFiller(NULL),
myBuilder(NULL),
myFuzzyValue(0.)
{}
//=======================================================================
// function:
// purpose:
//=======================================================================
BRepAlgoAPI_BuilderAlgo::BRepAlgoAPI_BuilderAlgo
(const Handle(NCollection_BaseAllocator)& theAllocator)
:
BRepAlgoAPI_Algo(theAllocator),
myDSFiller(NULL),
myBuilder(NULL),
myFuzzyValue(0.)
{}
//=======================================================================
// function: ~
// purpose:
//=======================================================================
BRepAlgoAPI_BuilderAlgo::~BRepAlgoAPI_BuilderAlgo()
{
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
void BRepAlgoAPI_BuilderAlgo::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
Standard_Real BRepAlgoAPI_BuilderAlgo::FuzzyValue() const
{
return myFuzzyValue;
}

View File

@@ -13,7 +13,8 @@
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Check from BRepAlgoAPI
class Check from BRepAlgoAPI
inherits Algo from BRepAlgoAPI
---Purpose:
-- The class Check provides a diagnostic tool for checking
-- single shape or couple of shapes.
@@ -115,11 +116,20 @@ is
returns ListOfCheckResult from BOPAlgo;
---C++: return const&
---Purpose: Returns faulty shapes.
SetFuzzyValue(me:out;
theFuzz : Real from Standard);
---Purpose: Sets the additional tolerance
FuzzyValue(me)
returns Real from Standard;
---Purpose: Returns the additional tolerance
fields
myS1, myS2 : Shape from TopoDS is protected;
myAnalyzer : PArgumentAnalyzer from BOPAlgo is protected;
myResult : ListOfCheckResult from BOPAlgo is protected;
myS1, myS2 : Shape from TopoDS is protected;
myAnalyzer : PArgumentAnalyzer from BOPAlgo is protected;
myResult : ListOfCheckResult from BOPAlgo is protected;
myFuzzyValue : Real from Standard is protected;
end BooleanOperation;

View File

@@ -21,8 +21,11 @@
//function : BRepAlgoAPI_Check
//purpose :
//=======================================================================
BRepAlgoAPI_Check::BRepAlgoAPI_Check()
: myAnalyzer(NULL)
BRepAlgoAPI_Check::BRepAlgoAPI_Check()
:
BRepAlgoAPI_Algo(),
myAnalyzer(NULL),
myFuzzyValue(0.)
{
}
@@ -30,9 +33,11 @@
//function : BRepAlgoAPI_Check
//purpose :
//=======================================================================
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
: BRepAlgoAPI_Algo(),
myFuzzyValue(0.)
{
Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
//
@@ -43,11 +48,13 @@
//function : BRepAlgoAPI_Check
//purpose :
//=======================================================================
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
: BRepAlgoAPI_Algo(),
myFuzzyValue(0.)
{
Init(theS1, theS2, theOp, bTestSE, bTestSI);
//
@@ -58,7 +65,7 @@
//function : ~BRepAlgoAPI_Check
//purpose :
//=======================================================================
BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
{
if(myAnalyzer){
delete myAnalyzer;
@@ -67,13 +74,32 @@
myResult.Clear();
}
//=======================================================================
//function : SetFuzzyValue
//purpose :
//=======================================================================
void BRepAlgoAPI_Check::SetFuzzyValue(const Standard_Real theFuzz)
{
if (theFuzz > 0.) {
myFuzzyValue = theFuzz;
}
}
//=======================================================================
//function : FuzzyValue
//purpose :
//=======================================================================
Standard_Real BRepAlgoAPI_Check::FuzzyValue() const
{
return myFuzzyValue;
}
//=======================================================================
//function : SetData
//purpose :
//=======================================================================
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
{
Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
}
@@ -82,25 +108,23 @@
//function : SetData
//purpose :
//=======================================================================
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
{
Init(theS1, theS2, theOp, bTestSE, bTestSI);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
const TopoDS_Shape& theS2,
const BOPAlgo_Operation theOp,
const Standard_Boolean bTestSE,
const Standard_Boolean bTestSI)
{
myResult.Clear();
myS1 = theS1;
@@ -114,13 +138,17 @@
myAnalyzer->ArgumentTypeMode() = Standard_True;
myAnalyzer->SmallEdgeMode() = bTestSE;
myAnalyzer->SelfInterMode() = bTestSI;
//
myAnalyzer->SetRunParallel(myRunParallel);
myAnalyzer->SetProgressIndicator(myProgressIndicator);
myAnalyzer->SetFuzzyValue(myFuzzyValue);
}
//=======================================================================
//function : Result
//purpose :
//=======================================================================
const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
{
return myResult;
}
@@ -129,7 +157,7 @@
//function : IsValid
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_Check::IsValid()
Standard_Boolean BRepAlgoAPI_Check::IsValid()
{
return myResult.IsEmpty();
}
@@ -138,7 +166,7 @@
//function : Perform
//purpose :
//=======================================================================
void BRepAlgoAPI_Check::Perform()
void BRepAlgoAPI_Check::Perform()
{
Standard_Boolean isS1, isS2;
//incompatibility of shape types, small edges and self-interference
@@ -175,5 +203,3 @@
myResult.Append(aRes);
}
}

View File

@@ -14,26 +14,34 @@
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Common from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
class Common from BRepAlgoAPI
inherits BooleanOperation from BRepAlgoAPI
---Purpose: The class Common provides a
-- Boolean common operation on a pair of arguments (Boolean Intersection).
-- The class Common provides a framework for:
-- - Defining the construction of a common shape;
-- - Implementing the building algorithm
-- - Consulting the result.
---Purpose: The class Common provides a
-- Boolean common operation on a pair of arguments (Boolean Intersection).
-- The class Common provides a framework for:
-- - Defining the construction of a common shape;
-- - Implementing the building algorithm
-- - Consulting the result.
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
is
Create
returns Common from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Common();"
--- Purpose: Empty constructor
Create (S1,S2 : Shape from TopoDS)
returns Common from BRepAlgoAPI;
---Purpose: Constructs a common part for shapes aS1 and aS2 .
returns Common from BRepAlgoAPI;
---Purpose: Constructs a common part for shapes aS1 and aS2 .
Create (S1,S2 : Shape from TopoDS;
aDSF:PaveFiller from BOPAlgo)
returns Common from BRepAlgoAPI;
aDSF:PaveFiller from BOPAlgo)
returns Common from BRepAlgoAPI;
--- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller
end Common;
--- Purpose: Constructs a common part for shapes aS1 and aS2 using aDSFiller

View File

@@ -18,6 +18,23 @@
#include <BRepAlgoAPI_BooleanOperation.hxx>
//=======================================================================
//function : BRepAlgoAPI_Common
//purpose :
//=======================================================================
BRepAlgoAPI_Common::BRepAlgoAPI_Common()
:
BRepAlgoAPI_BooleanOperation()
{
myOperation=BOPAlgo_COMMON;
}
//=======================================================================
//function : ~BRepAlgoAPI_Common
//purpose :
//=======================================================================
BRepAlgoAPI_Common::~BRepAlgoAPI_Common()
{
}
//=======================================================================
//function : BRepAlgoAPI_Common
//purpose :

View File

@@ -14,31 +14,39 @@
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class Cut from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
---Purpose: The class Cut provides a Boolean
-- cut operation on a pair of arguments (Boolean Subtraction).
-- The class Cut provides a framework for:
-- - Defining the construction of a cut shape
-- - Implementing the building algorithm
-- - Consulting the result
class Cut from BRepAlgoAPI
inherits BooleanOperation from BRepAlgoAPI
---Purpose: The class Cut provides a Boolean
-- cut operation on a pair of arguments (Boolean Subtraction).
-- The class Cut provides a framework for:
-- - Defining the construction of a cut shape
-- - Implementing the building algorithm
-- - Consulting the result
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
is
Create
returns Cut from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Cut();"
--- Purpose: Empty constructor
Create (S1,S2 : Shape from TopoDS)
returns Cut from BRepAlgoAPI;
---Purpose: Shape aS2 cuts shape aS1. The
-- resulting shape is a new shape produced by the cut operation.
returns Cut from BRepAlgoAPI;
---Purpose: Shape aS2 cuts shape aS1. The
-- resulting shape is a new shape produced by the cut operation.
Create (S1,S2 : Shape from TopoDS;
aDSF : PaveFiller from BOPAlgo;
bFWD : Boolean from Standard=Standard_True)
returns Cut from BRepAlgoAPI;
--- Purpose: Constructs a new shape cut from
-- shape aS1 by shape aS2 using aDSFiller (see
-- BRepAlgoAPI_BooleanOperation Constructor).
aDSF : PaveFiller from BOPAlgo;
bFWD : Boolean from Standard=Standard_True)
returns Cut from BRepAlgoAPI;
--- Purpose: Constructs a new shape cut from
-- shape aS1 by shape aS2 using aDSFiller (see
-- BRepAlgoAPI_BooleanOperation Constructor).
end Cut;

View File

@@ -22,9 +22,28 @@
//function : BRepAlgoAPI_Cut
//purpose :
//=======================================================================
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut()
:
BRepAlgoAPI_BooleanOperation()
{
myOperation=BOPAlgo_CUT;
}
//=======================================================================
//function : ~BRepAlgoAPI_Cut
//purpose :
//=======================================================================
BRepAlgoAPI_Cut::~BRepAlgoAPI_Cut()
{
}
//=======================================================================
//function : BRepAlgoAPI_Cut
//purpose :
//=======================================================================
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
:
BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_CUT)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
@@ -34,11 +53,12 @@
//function : BRepAlgoAPI_Cut
//purpose :
//=======================================================================
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const BOPAlgo_PaveFiller& aDSF,
const Standard_Boolean bFWD)
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
BRepAlgoAPI_Cut::BRepAlgoAPI_Cut(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const BOPAlgo_PaveFiller& aDSF,
const Standard_Boolean bFWD)
:
BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, (bFWD) ? BOPAlgo_CUT : BOPAlgo_CUT21)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;

View File

@@ -16,26 +16,31 @@
class Fuse from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
---Purpose: The class Fuse provides a
-- Boolean fusion operation on a pair of arguments (Boolean Union).
-- The class Fuse provides a framework for:
-- - Defining the construction of a fused shape;
-- - Implementing the building algorithm
-- - Consulting the result.
---Purpose: The class Fuse provides a
-- Boolean fusion operation on a pair of arguments (Boolean Union).
-- The class Fuse provides a framework for:
-- - Defining the construction of a fused shape;
-- - Implementing the building algorithm
-- - Consulting the result.
uses
Shape from TopoDS,
PaveFiller from BOPAlgo
is
is
Create
returns Fuse from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Fuse();"
--- Purpose: Empty constructor
Create (S1,S2 : Shape from TopoDS)
returns Fuse from BRepAlgoAPI;
---Purpose: Constructs a fuse of shapes aS1 and aS2.
returns Fuse from BRepAlgoAPI;
---Purpose: Constructs a fuse of shapes aS1 and aS2.
Create (S1,S2 : Shape from TopoDS;
aDSF:PaveFiller from BOPAlgo)
returns Fuse from BRepAlgoAPI;
---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller.
aDSF:PaveFiller from BOPAlgo)
returns Fuse from BRepAlgoAPI;
---Purpose: Constructs a new shape that is a fuse of shapes aS1 and aS2 using aDSFiller.
end Fuse;

View File

@@ -22,9 +22,28 @@
//function : BRepAlgoAPI_Fuse
//purpose :
//=======================================================================
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
: BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse()
:
BRepAlgoAPI_BooleanOperation()
{
myOperation=BOPAlgo_FUSE;
}
//=======================================================================
//function : ~BRepAlgoAPI_Fuse
//purpose :
//=======================================================================
BRepAlgoAPI_Fuse::~BRepAlgoAPI_Fuse()
{
}
//=======================================================================
//function : BRepAlgoAPI_Fuse
//purpose :
//=======================================================================
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
:
BRepAlgoAPI_BooleanOperation(S1, S2, BOPAlgo_FUSE)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;
@@ -35,10 +54,11 @@
//function : BRepAlgoAPI_Fuse
//purpose :
//=======================================================================
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const BOPAlgo_PaveFiller& aDSF)
: BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_FUSE)
BRepAlgoAPI_Fuse::BRepAlgoAPI_Fuse(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const BOPAlgo_PaveFiller& aDSF)
:
BRepAlgoAPI_BooleanOperation(S1, S2, aDSF, BOPAlgo_FUSE)
{
BRepAlgoAPI_BooleanOperation* pBO=
(BRepAlgoAPI_BooleanOperation*) (void*) this;

View File

@@ -16,31 +16,32 @@
-- modified by Michael KLOKOV Wed Mar 6 15:01:25 2002
class Section from BRepAlgoAPI inherits BooleanOperation from BRepAlgoAPI
class Section from BRepAlgoAPI
inherits BooleanOperation from BRepAlgoAPI
---Purpose: Computes the intersection of two shapes or geometries.
-- Geometries can be surfaces of planes.
-- Geometries are converted to faces
-- When a geometry has been converted to
-- topology the created shape can be found using
-- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
-- The result (Shape() method) is a compound containing
-- edges built on intersection curves.
-- By default, the section is performed immediatly in
-- class constructors, with default values :
-- - geometries built are NOT approximated.
-- - PCurves are NOT computed on both parts.
-- Example : giving two shapes S1,S2 accessing faces,
-- let compute the section edges R on S1,S2,
-- performing approximation on new curves,
-- performing PCurve on part 1 but not on part 2 :
-- Standard_Boolean PerformNow = Standard_False;
-- BRepBoolAPI_Section S(S1,S2,PerformNow);
-- S.ComputePCurveOn1(Standard_True);
-- S.Approximation(Standard_True);
-- S.Build();
-- TopoDS_Shape R = S.Shape();
-- On Null Shapes of geometries, NotDone() is called.
---Purpose: Computes the intersection of two shapes or geometries.
-- Geometries can be surfaces of planes.
-- Geometries are converted to faces
-- When a geometry has been converted to
-- topology the created shape can be found using
-- the methods Shape1 and Shape2 inherited from the class BooleanOperation.
-- The result (Shape() method) is a compound containing
-- edges built on intersection curves.
-- By default, the section is performed immediatly in
-- class constructors, with default values :
-- - geometries built are NOT approximated.
-- - PCurves are NOT computed on both parts.
-- Example : giving two shapes S1,S2 accessing faces,
-- let compute the section edges R on S1,S2,
-- performing approximation on new curves,
-- performing PCurve on part 1 but not on part 2 :
-- Standard_Boolean PerformNow = Standard_False;
-- BRepBoolAPI_Section S(S1,S2,PerformNow);
-- S.ComputePCurveOn1(Standard_True);
-- S.Approximation(Standard_True);
-- S.Build();
-- TopoDS_Shape R = S.Shape();
-- On Null Shapes of geometries, NotDone() is called.
uses
Pln from gp,
@@ -51,262 +52,289 @@ uses
ListOfShape from TopTools
is
Create (S1,S2 : Shape from TopoDS;
aDSF:PaveFiller from BOPAlgo;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section(){}"
Create
returns Section from BRepAlgoAPI;
---C++: alias "Standard_EXPORT virtual ~BRepAlgoAPI_Section();"
--- Purpose: Empty constructor
Create (S1,S2 : Shape from TopoDS;
aDSF:PaveFiller from BOPAlgo;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
Create(Sh1,Sh2 : Shape from TopoDS;
PerformNow : Boolean = Standard_True)
---Purpose: see upper
---Level: Public
returns Section from BRepAlgoAPI;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---Purpose: see upper
---Level: Public
Create(Sh : Shape from TopoDS; Pl : Pln from gp;
PerformNow : Boolean = Standard_True)
---Purpose: see upper
---Level: Public
returns Section from BRepAlgoAPI;
Create(Sh : Shape from TopoDS;
Pl : Pln from gp;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---Purpose: see upper
---Level: Public
Create(Sh : Shape from TopoDS; Sf : Surface from Geom;
PerformNow : Boolean = Standard_True)
---Purpose: see upper
---Level: Public
returns Section from BRepAlgoAPI;
Create(Sh : Shape from TopoDS;
Sf : Surface from Geom;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---Purpose: see upper
---Level: Public
Create(Sf : Surface from Geom; Sh : Shape from TopoDS;
PerformNow : Boolean = Standard_True)
---Purpose: see upper
---Level: Public
returns Section from BRepAlgoAPI;
Create(Sf1 : Surface from Geom; Sf2 : Surface from Geom;
PerformNow : Boolean = Standard_True)
---Purpose: This and the above classes construct a framework for
-- computing the section lines of:
-- - two shapes Sh1 and Sh2, or
-- - shape Sh and plane Pl, or
-- - shape Sh and surface Sf, or
-- - surface Sf and shape Sh, or
-- - two surfaces Sf1 and Sf2,
-- and builds a result if PerformNow equals true, its
-- default value. If PerformNow equals false, the intersection
-- will be computed later by the function Build.
-- The constructed shape will be returned by the function Shape.
-- This is a compound object composed of edges. These
-- intersection edges may be built:
-- - on new intersection lines, or
-- - on coincident portions of edges in the two intersected shapes.
-- These intersection edges are independent: they are not
-- chained or grouped in wires. If no intersection edge exists, the
-- result is an empty compound object.
-- Note that other objects than TopoDS_Shape shapes involved in
-- these syntaxes are converted into faces or shells before
-- performing the computation of the intersection. A shape
-- resulting from this conversion can be retrieved with the
-- function Shape1 or Shape2.
-- Parametric 2D curves on intersection edges
-- No parametric 2D curve (pcurve) is defined for each elementary
-- edge of the result. To attach such parametric curves to the
-- constructed edges you may use a constructor with the PerformNow
-- flag equal to false; then you use:
-- - the function ComputePCurveOn1 to ask for
-- the additional computation of a pcurve in the parametric
-- space of the first shape,
-- - the function ComputePCurveOn2 to ask for
-- the additional computation of a pcurve in the parametric
-- space of the second shape, in the end,
-- - the function Build to construct the result.
-- Approximation of intersection edges
-- The underlying 3D geometry attached to each elementary edge
-- of the result is:
-- - analytic where possible, provided the corresponding
-- geometry corresponds to a type of analytic curve
-- defined in the Geom package; for example, the intersection
-- of a cylindrical shape with a plane gives an ellipse or a circle;
-- - or elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1.
-- If you prefer to have an attached 3D geometry which is a
-- BSpline approximation of the computed set of points on
-- computed elementary intersection edges whose underlying geometry
-- is not analytic, you may use a constructor with the PerformNow
-- flag equal to false. Then you use:
-- - the function Approximation to ask for this
-- computation option, and
-- - the function Build to construct the result.
-- - Note that as a result, approximations will only be
-- computed on edges built on new intersection lines.
-- - Example
-- You may also combine these computation options. In the following example:
-- - each elementary edge of the computed intersection,
-- built on a new intersection line, which does not
-- correspond to an analytic Geom curve, will be approximated by
-- a BSpline curve whose degree is not greater than 8.
-- - each elementary edge built on a new intersection line, will have:
-- - a pcurve in the parametric space of the intersected face of shape S1,
-- - no pcurve in the parametric space of the intersected face of shape S2.
-- // TopoDS_Shape S1 = ... , S2 = ... ;
-- Standard_Boolean PerformNow = Standard_False;
-- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
-- S.ComputePCurveOn1 (Standard_True);
-- S.Approximation (Standard_True);
-- S.Build();
-- TopoDS_Shape R = S.Shape();
returns Section from BRepAlgoAPI;
Init1(me : out;S1 : Shape from TopoDS);
---Purpose: initialize first part
---Level: Public
Create(Sf : Surface from Geom;
Sh : Shape from TopoDS;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---Purpose: see upper
---Level: Public
Init1(me : out;Pl : Pln from gp);
---Purpose: initialize first part
---Level: Public
Create(Sf1 : Surface from Geom;
Sf2 : Surface from Geom;
PerformNow : Boolean = Standard_True)
returns Section from BRepAlgoAPI;
---Purpose: This and the above classes construct a framework for
-- computing the section lines of:
-- - two shapes Sh1 and Sh2, or
-- - shape Sh and plane Pl, or
-- - shape Sh and surface Sf, or
-- - surface Sf and shape Sh, or
-- - two surfaces Sf1 and Sf2,
-- and builds a result if PerformNow equals true, its
-- default value. If PerformNow equals false, the intersection
-- will be computed later by the function Build.
-- The constructed shape will be returned by the function Shape.
-- This is a compound object composed of edges. These
-- intersection edges may be built:
-- - on new intersection lines, or
-- - on coincident portions of edges in the two intersected shapes.
-- These intersection edges are independent: they are not
-- chained or grouped in wires. If no intersection edge exists, the
-- result is an empty compound object.
-- Note that other objects than TopoDS_Shape shapes involved in
-- these syntaxes are converted into faces or shells before
-- performing the computation of the intersection. A shape
-- resulting from this conversion can be retrieved with the
-- function Shape1 or Shape2.
-- Parametric 2D curves on intersection edges
-- No parametric 2D curve (pcurve) is defined for each elementary
-- edge of the result. To attach such parametric curves to the
-- constructed edges you may use a constructor with the PerformNow
-- flag equal to false; then you use:
-- - the function ComputePCurveOn1 to ask for
-- the additional computation of a pcurve in the parametric
-- space of the first shape,
-- - the function ComputePCurveOn2 to ask for
-- the additional computation of a pcurve in the parametric
-- space of the second shape, in the end,
-- - the function Build to construct the result.
-- Approximation of intersection edges
-- The underlying 3D geometry attached to each elementary edge
-- of the result is:
-- - analytic where possible, provided the corresponding
-- geometry corresponds to a type of analytic curve
-- defined in the Geom package; for example, the intersection
-- of a cylindrical shape with a plane gives an ellipse or a circle;
-- - or elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1.
-- If you prefer to have an attached 3D geometry which is a
-- BSpline approximation of the computed set of points on
-- computed elementary intersection edges whose underlying geometry
-- is not analytic, you may use a constructor with the PerformNow
-- flag equal to false. Then you use:
-- - the function Approximation to ask for this
-- computation option, and
-- - the function Build to construct the result.
-- - Note that as a result, approximations will only be
-- computed on edges built on new intersection lines.
-- - Example
-- You may also combine these computation options. In the following example:
-- - each elementary edge of the computed intersection,
-- built on a new intersection line, which does not
-- correspond to an analytic Geom curve, will be approximated by
-- a BSpline curve whose degree is not greater than 8.
-- - each elementary edge built on a new intersection line, will have:
-- - a pcurve in the parametric space of the intersected face of shape S1,
-- - no pcurve in the parametric space of the intersected face of shape S2.
-- // TopoDS_Shape S1 = ... , S2 = ... ;
-- Standard_Boolean PerformNow = Standard_False;
-- BRepAlgoAPI_Section S ( S1, S2, PerformNow );
-- S.ComputePCurveOn1 (Standard_True);
-- S.Approximation (Standard_True);
-- S.Build();
-- TopoDS_Shape R = S.Shape();
Init1(me : out;Sf : Surface from Geom);
---Purpose: initialize first part
---Level: Public
Init2(me : out;S2 : Shape from TopoDS);
---Purpose: initialize second part
---Level: Public
Init2(me : out;Pl : Pln from gp);
---Purpose: initialize second part
---Level: Public
Init2(me : out;Sf : Surface from Geom);
---Purpose: Reinitializes the first and the
-- second parts on which this algorithm is going to perform
-- the intersection computation. This is done with either: the
-- surface Sf, the plane Pl or the shape Sh.
-- You use the function Build to construct the result.
Approximation(me : out;B : Boolean);
---Level: Public
---Purpose: Defines an option for computation
-- of further intersections. This computation will be performed by
-- the function Build in this framework.
-- By default, the underlying 3D geometry attached to each
-- elementary edge of the result of a computed intersection is:
-- - analytic where possible, provided the corresponding
-- geometry corresponds to a type of analytic curve defined in
-- the Geom package; for example the intersection of a
-- cylindrical shape with a plane gives an ellipse or a circle;
-- - or elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1. If Approx equals
-- true, when further computations are performed in this framework
-- with the function Build, these edges will have an attached 3D
-- geometry which is a BSpline approximation of the computed
-- set of points.
-- Note that as a result, approximations will be computed
-- on edges built only on new intersection lines.
ComputePCurveOn1(me : out;B : Boolean);
---Level: Public
---Purpose:
-- Indicates if the Pcurve must be (or not) performed on first part.
ComputePCurveOn2(me : out;B : Boolean);
---Level: Public
---Purpose: Define options for the computation of further
-- intersections, which will be performed by the function Build
-- in this framework.
-- By default, no parametric 2D curve (pcurve) is defined for the
-- elementary edges of the result. If ComputePCurve1 equals true,
-- further computations performed in this framework with the function
-- Build will attach an additional pcurve in the parametric space of
-- the first shape to the constructed edges.
-- If ComputePCurve2 equals true, the additional pcurve will be
-- attached to the constructed edges in the parametric space of the
-- second shape.
-- These two functions may be used together.
Init1(me : out;
S1 : Shape from TopoDS);
---Purpose: initialize first part
---Level: Public
Build(me : in out)
---Purpose: Performs the computation of
-- section lines between two parts defined at the time of
-- construction of this framework or reinitialized with the Init1 and
-- Init2 functions.
-- The constructed shape will be returned by the function Shape.
-- This is a compound object composed of edges. These
-- intersection edges may be built:
-- - on new intersection lines, or
-- - on coincident portions of edges in the two intersected shapes.
-- These intersection edges are independent: they are not chained
-- or grouped into wires.
-- If no intersection edge exists, the result is an empty compound object.
-- The shapes involved in the construction of section lines can
-- be retrieved with the function Shape1 or Shape2. Note that other
-- objects than TopoDS_Shape shapes given as arguments at the
-- construction time of this framework, or to the Init1 or
-- Init2 function, are converted into faces or shells before
-- performing the computation of the intersection.
-- Parametric 2D curves on intersection edges
-- No parametric 2D curve (pcurve) is defined for the elementary
-- edges of the result. To attach parametric curves like this to
-- the constructed edges you have to use:
-- - the function
-- ComputePCurveOn1 to ask for the additional computation of a
-- pcurve in the parametric space of the first shape,
-- - the function
-- ComputePCurveOn2 to ask for the additional computation of a
-- pcurve in the parametric space of the second shape.
-- This must be done before calling this function.
-- Approximation of intersection edges
-- The underlying 3D geometry attached to each elementary edge of the result is:
-- - analytic (where possible) provided the corresponding
-- geometry corresponds to a type of analytic curve defined in
-- the Geom package; for example, the intersection of a
-- cylindrical shape with a plane gives an ellipse or a circle; or
-- - elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1.
-- If, on computed elementary intersection edges whose
-- underlying geometry is not analytic, you prefer to have an
-- attached 3D geometry which is a Bspline approximation of the
-- computed set of points, you have to use the function Approximation
-- to ask for this computation option before calling this function.
-- You may also have combined these computation options: look at the
-- example given above to illustrate the use of the constructors.
is redefined static;
Init1(me : out;
Pl : Pln from gp);
---Purpose: initialize first part
---Level: Public
Init1(me : out;
Sf : Surface from Geom);
---Purpose: initialize first part
---Level: Public
Init2(me : out;
S2 : Shape from TopoDS);
---Purpose: initialize second part
---Level: Public
Init2(me : out;
Pl : Pln from gp);
---Purpose: initialize second part
---Level: Public
Init2(me : out;
Sf : Surface from Geom);
---Purpose: Reinitializes the first and the
-- second parts on which this algorithm is going to perform
-- the intersection computation. This is done with either: the
-- surface Sf, the plane Pl or the shape Sh.
-- You use the function Build to construct the result.
Approximation(me : out;
B : Boolean from Standard);
---Level: Public
---Purpose: Defines an option for computation
-- of further intersections. This computation will be performed by
-- the function Build in this framework.
-- By default, the underlying 3D geometry attached to each
-- elementary edge of the result of a computed intersection is:
-- - analytic where possible, provided the corresponding
-- geometry corresponds to a type of analytic curve defined in
-- the Geom package; for example the intersection of a
-- cylindrical shape with a plane gives an ellipse or a circle;
-- - or elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1. If Approx equals
-- true, when further computations are performed in this framework
-- with the function Build, these edges will have an attached 3D
-- geometry which is a BSpline approximation of the computed
-- set of points.
-- Note that as a result, approximations will be computed
-- on edges built only on new intersection lines.
ComputePCurveOn1(me : out;
B : Boolean from Standard);
---Level: Public
---Purpose:
-- Indicates if the Pcurve must be (or not) performed on first part.
HasAncestorFaceOn1(me; E : Shape from TopoDS;
F : out Shape from TopoDS)
returns Boolean;
---Level: Public
---Purpose:
-- get the face of the first part giving section edge <E>.
-- Returns True on the 3 following conditions :
-- 1/ <E> is an edge returned by the Shape() method.
-- 2/ First part of section performed is a shape.
-- 3/ <E> is built on a intersection curve (i.e <E>
-- is not the result of common edges)
-- When False, F remains untouched.
ComputePCurveOn2(me : out;
B : Boolean from Standard);
---Level: Public
---Purpose: Define options for the computation of further
-- intersections, which will be performed by the function Build
-- in this framework.
-- By default, no parametric 2D curve (pcurve) is defined for the
-- elementary edges of the result. If ComputePCurve1 equals true,
-- further computations performed in this framework with the function
-- Build will attach an additional pcurve in the parametric space of
-- the first shape to the constructed edges.
-- If ComputePCurve2 equals true, the additional pcurve will be
-- attached to the constructed edges in the parametric space of the
-- second shape.
-- These two functions may be used together.
Build(me : in out)
is redefined;
---Purpose: Performs the computation of
-- section lines between two parts defined at the time of
-- construction of this framework or reinitialized with the Init1 and
-- Init2 functions.
-- The constructed shape will be returned by the function Shape.
-- This is a compound object composed of edges. These
-- intersection edges may be built:
-- - on new intersection lines, or
-- - on coincident portions of edges in the two intersected shapes.
-- These intersection edges are independent: they are not chained
-- or grouped into wires.
-- If no intersection edge exists, the result is an empty compound object.
-- The shapes involved in the construction of section lines can
-- be retrieved with the function Shape1 or Shape2. Note that other
-- objects than TopoDS_Shape shapes given as arguments at the
-- construction time of this framework, or to the Init1 or
-- Init2 function, are converted into faces or shells before
-- performing the computation of the intersection.
-- Parametric 2D curves on intersection edges
-- No parametric 2D curve (pcurve) is defined for the elementary
-- edges of the result. To attach parametric curves like this to
-- the constructed edges you have to use:
-- - the function
-- ComputePCurveOn1 to ask for the additional computation of a
-- pcurve in the parametric space of the first shape,
-- - the function
-- ComputePCurveOn2 to ask for the additional computation of a
-- pcurve in the parametric space of the second shape.
-- This must be done before calling this function.
-- Approximation of intersection edges
-- The underlying 3D geometry attached to each elementary edge of the result is:
-- - analytic (where possible) provided the corresponding
-- geometry corresponds to a type of analytic curve defined in
-- the Geom package; for example, the intersection of a
-- cylindrical shape with a plane gives an ellipse or a circle; or
-- - elsewhere, given as a succession of points grouped
-- together in a BSpline curve of degree 1.
-- If, on computed elementary intersection edges whose
-- underlying geometry is not analytic, you prefer to have an
-- attached 3D geometry which is a Bspline approximation of the
-- computed set of points, you have to use the function Approximation
-- to ask for this computation option before calling this function.
-- You may also have combined these computation options: look at the
-- example given above to illustrate the use of the constructors.
HasAncestorFaceOn2(me; E : Shape from TopoDS;
F : out Shape from TopoDS)
returns Boolean;
---Purpose: Identifies the ancestor faces of
-- the intersection edge E resulting from the last
-- computation performed in this framework, that is, the faces of
-- the two original shapes on which the edge E lies:
-- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and
-- - HasAncestorFaceOn2 gives the ancestor face in the second shape.
-- These functions return true if an ancestor face F is found, or false if not.
-- An ancestor face is identifiable for the edge E if the following
-- conditions are satisfied:
-- - the first part on which this algorithm performed its
-- last computation is a shape, that is, it was not given as
-- a surface or a plane at the time of construction of this
-- algorithm or at a later time by the Init1 function,
-- - E is one of the elementary edges built by the
-- last computation of this section algorithm.
-- To use these functions properly, you have to test the returned
-- Boolean value before using the ancestor face: F is significant
-- only if the returned Boolean value equals true.
HasAncestorFaceOn1(me;
E : Shape from TopoDS;
F : out Shape from TopoDS)
returns Boolean from Standard;
---Level: Public
---Purpose:
-- get the face of the first part giving section edge <E>.
-- Returns True on the 3 following conditions :
-- 1/ <E> is an edge returned by the Shape() method.
-- 2/ First part of section performed is a shape.
-- 3/ <E> is built on a intersection curve (i.e <E>
-- is not the result of common edges)
-- When False, F remains untouched.
InitParameters(me: out)
---Level: Private
is private;
HasAncestorFaceOn2(me;
E : Shape from TopoDS;
F : out Shape from TopoDS)
returns Boolean from Standard;
---Purpose: Identifies the ancestor faces of
-- the intersection edge E resulting from the last
-- computation performed in this framework, that is, the faces of
-- the two original shapes on which the edge E lies:
-- - HasAncestorFaceOn1 gives the ancestor face in the first shape, and
-- - HasAncestorFaceOn2 gives the ancestor face in the second shape.
-- These functions return true if an ancestor face F is found, or false if not.
-- An ancestor face is identifiable for the edge E if the following
-- conditions are satisfied:
-- - the first part on which this algorithm performed its
-- last computation is a shape, that is, it was not given as
-- a surface or a plane at the time of construction of this
-- algorithm or at a later time by the Init1 function,
-- - E is one of the elementary edges built by the
-- last computation of this section algorithm.
-- To use these functions properly, you have to test the returned
-- Boolean value before using the ancestor face: F is significant
-- only if the returned Boolean value equals true.
InitParameters(me: out)
is private;
---Level: Private
fields
myshapeisnull : Boolean from Standard;

View File

@@ -36,18 +36,46 @@
#include <BOPAlgo_BOP.hxx>
#include <BOPDS_DS.hxx>
static TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
//
static
TopoDS_Shape MakeShape(const Handle(Geom_Surface)& );
static
Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller&,
const TopoDS_Shape&,
TopoDS_Shape&,
TopoDS_Shape&);
//=======================================================================
//function : BRepAlgoAPI_Section
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section()
:
BRepAlgoAPI_BooleanOperation()
{
GeomAbs_Shape c = S->Continuity();
if (c >= GeomAbs_C2) return BRepBuilderAPI_MakeFace(S, Precision::Confusion());
else return BRepBuilderAPI_MakeShell(S);
myOperation=BOPAlgo_SECTION;
InitParameters();
}
//=======================================================================
//function : ~BRepAlgoAPI_Section
//purpose :
//=======================================================================
BRepAlgoAPI_Section::~BRepAlgoAPI_Section()
{
}
//=======================================================================
//function : InitParameters
//purpose :
//=======================================================================
void BRepAlgoAPI_Section::InitParameters()
{
myparameterschanged = Standard_False;
myshapeisnull = Standard_False;
myApprox = Standard_False;
myComputePCurve1 = Standard_False;
myComputePCurve2 = Standard_False;
}
static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller,
const TopoDS_Shape& E,
TopoDS_Shape& F1,
TopoDS_Shape& F2);
//=======================================================================
//function : Constructor
//purpose :
@@ -55,31 +83,35 @@ static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller,
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh1,
const TopoDS_Shape& Sh2,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(Sh1, Sh2, BOPAlgo_SECTION)
:
BRepAlgoAPI_BooleanOperation(Sh1, Sh2, BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(myS1.IsNull() || myS2.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
if (PerformNow) {
Build();
}
}
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
const BOPAlgo_PaveFiller& aDSF,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(aS1, aS2, aDSF, BOPAlgo_SECTION)
//=======================================================================
//function : BRepAlgoAPI_Section
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const TopoDS_Shape& aS1,
const TopoDS_Shape& aS2,
const BOPAlgo_PaveFiller& aDSF,
const Standard_Boolean PerformNow)
:
BRepAlgoAPI_BooleanOperation(aS1, aS2, aDSF, BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(myS1.IsNull() || myS2.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
@@ -87,85 +119,87 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& aS1,
Build();
}
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh,
const gp_Pln& Pl,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(new Geom_Plane(Pl)), BOPAlgo_SECTION)
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const TopoDS_Shape& Sh,
const gp_Pln& Pl,
const Standard_Boolean PerformNow)
:
BRepAlgoAPI_BooleanOperation(Sh, MakeShape(new Geom_Plane(Pl)),
BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(Sh.IsNull() || myS2.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
if (PerformNow) {
Build();
}
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const TopoDS_Shape& Sh,
const Handle(Geom_Surface)& Sf,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(Sh, MakeShape(Sf), BOPAlgo_SECTION)
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const TopoDS_Shape& Sh,
const Handle(Geom_Surface)& Sf,
const Standard_Boolean PerformNow)
:
BRepAlgoAPI_BooleanOperation(Sh, MakeShape(Sf), BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(Sh.IsNull() || myS2.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
if (PerformNow) {
Build();
}
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf,
const TopoDS_Shape& Sh,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(MakeShape(Sf), Sh, BOPAlgo_SECTION)
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const Handle(Geom_Surface)& Sf,
const TopoDS_Shape& Sh,
const Standard_Boolean PerformNow)
:
BRepAlgoAPI_BooleanOperation(MakeShape(Sf), Sh, BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(myS1.IsNull() || Sh.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
if (PerformNow) {
Build();
}
}
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf1,
const Handle(Geom_Surface)& Sf2,
const Standard_Boolean PerformNow)
: BRepAlgoAPI_BooleanOperation(MakeShape(Sf1), MakeShape(Sf2), BOPAlgo_SECTION)
BRepAlgoAPI_Section::BRepAlgoAPI_Section
(const Handle(Geom_Surface)& Sf1,
const Handle(Geom_Surface)& Sf2,
const Standard_Boolean PerformNow)
:
BRepAlgoAPI_BooleanOperation(MakeShape(Sf1),
MakeShape(Sf2),
BOPAlgo_SECTION)
{
InitParameters();
myparameterschanged = Standard_True;
if(myS1.IsNull() || myS2.IsNull()) {
// StdFail_NotDone::Raise("BRepAlgoAPI_Section : Shape NULL");
myshapeisnull = Standard_True;
}
@@ -173,7 +207,6 @@ BRepAlgoAPI_Section::BRepAlgoAPI_Section(const Handle(Geom_Surface)& Sf1,
Build();
}
}
//=======================================================================
//function : Init1
//purpose :
@@ -201,7 +234,6 @@ void BRepAlgoAPI_Section::Init1(const TopoDS_Shape& S1)
if(myparameterschanged)
NotDone();
}
//=======================================================================
//function : Init1
//purpose :
@@ -210,7 +242,6 @@ void BRepAlgoAPI_Section::Init1(const gp_Pln& Pl)
{
Init1(MakeShape(new Geom_Plane(Pl)));
}
//=======================================================================
//function : Init1
//purpose :
@@ -219,7 +250,6 @@ void BRepAlgoAPI_Section::Init1(const Handle(Geom_Surface)& Sf)
{
Init1(MakeShape(Sf));
}
//=======================================================================
//function : Init2
//purpose :
@@ -248,7 +278,6 @@ void BRepAlgoAPI_Section::Init2(const TopoDS_Shape& S2)
NotDone();
}
}
//=======================================================================
//function : Init2
//purpose :
@@ -257,7 +286,6 @@ void BRepAlgoAPI_Section::Init2(const gp_Pln& Pl)
{
Init2(MakeShape(new Geom_Plane(Pl)));
}
//=======================================================================
//function : Init2
//purpose :
@@ -266,7 +294,6 @@ void BRepAlgoAPI_Section::Init2(const Handle(Geom_Surface)& Sf)
{
Init2(MakeShape(Sf));
}
//=======================================================================
//function : Approximation
//purpose :
@@ -278,7 +305,6 @@ void BRepAlgoAPI_Section::Approximation(const Standard_Boolean B)
myparameterschanged = Standard_True;
}
}
//=======================================================================
//function : ComputePCurveOn1
//purpose :
@@ -290,7 +316,6 @@ void BRepAlgoAPI_Section::ComputePCurveOn1(const Standard_Boolean B)
myparameterschanged = Standard_True;
}
}
//=======================================================================
//function : ComputePCurveOn2
//purpose :
@@ -302,7 +327,6 @@ void BRepAlgoAPI_Section::ComputePCurveOn2(const Standard_Boolean B)
myparameterschanged = Standard_True;
}
}
//=======================================================================
//function : Build
//purpose :
@@ -325,7 +349,9 @@ void BRepAlgoAPI_Section::Build()
}
//
if (bIsNewFiller) {
BOPAlgo_SectionAttribute theSecAttr(myApprox, myComputePCurve1, myComputePCurve2);
BOPAlgo_SectionAttribute theSecAttr(myApprox,
myComputePCurve1,
myComputePCurve2);
myDSFiller->SetSectionAttribute(theSecAttr);
myDSFiller->Perform();
}
@@ -335,12 +361,13 @@ void BRepAlgoAPI_Section::Build()
myparameterschanged = Standard_False;
}
}
//=======================================================================
//function : HasAncestorFaceOn1
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn1(const TopoDS_Shape& E, TopoDS_Shape& F) const
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn1
(const TopoDS_Shape& E,
TopoDS_Shape& F) const
{
Standard_Boolean aResult = Standard_False;
if(E.IsNull()) {
@@ -359,12 +386,13 @@ Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn1(const TopoDS_Shape& E,
F = F1;
return aResult;
}
//=======================================================================
//function : HasAncestorFaceOn2
//purpose :
//=======================================================================
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn2(const TopoDS_Shape& E,TopoDS_Shape& F) const
Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn2
(const TopoDS_Shape& E,
TopoDS_Shape& F) const
{
Standard_Boolean aResult = Standard_False;
if(E.IsNull()) {
@@ -385,27 +413,15 @@ Standard_Boolean BRepAlgoAPI_Section::HasAncestorFaceOn2(const TopoDS_Shape& E,T
}
//=======================================================================
//function : InitParameters
//function : HasAncestorFaces
//purpose :
//=======================================================================
void BRepAlgoAPI_Section::InitParameters()
Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller,
const TopoDS_Shape& E,
TopoDS_Shape& F1,
TopoDS_Shape&F2)
{
myparameterschanged = Standard_False;
myshapeisnull = Standard_False;
myApprox = Standard_False;
myComputePCurve1 = Standard_False;
myComputePCurve2 = Standard_False;
}
// ------------------------------------------------------------------------
// static function : HasAncestorFaces
// purpose :
// ------------------------------------------------------------------------
static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller,
const TopoDS_Shape& E,
TopoDS_Shape& F1,
TopoDS_Shape& F2) {
Standard_Integer aNb, i, j, nE, nF1, nF2, aNbCurves;
//
const BOPDS_PDS& pDS = theDSFiller->PDS();
@@ -442,3 +458,15 @@ static Standard_Boolean HasAncestorFaces(const BOPAlgo_PPaveFiller& theDSFiller,
}
return Standard_False;
}
//=======================================================================
//function : MakeShape
//purpose :
//=======================================================================
TopoDS_Shape MakeShape(const Handle(Geom_Surface)& S)
{
GeomAbs_Shape c = S->Continuity();
if (c >= GeomAbs_C2) {
return BRepBuilderAPI_MakeFace(S, Precision::Confusion());
}
return BRepBuilderAPI_MakeShell(S);
}

View File

@@ -16,11 +16,11 @@
deferred class MakeShape from BRepBuilderAPI inherits Command from BRepBuilderAPI
---Purpose: This is the root class for all shape
-- constructions. It stores the result.
--
-- It provides deferred methods to trace the history
-- of sub-shapes.
---Purpose: This is the root class for all shape
-- constructions. It stores the result.
--
-- It provides deferred methods to trace the history
-- of sub-shapes.
uses
Shape from TopoDS,
@@ -34,27 +34,28 @@ uses
raises
NotDone from StdFail
is
is
Delete(me:out) is redefined;
---C++: alias "Standard_EXPORT virtual ~BRepBuilderAPI_MakeShape(){Delete() ; }"
Initialize;
Build(me : in out)
---Purpose: This is called by Shape(). It does nothing but
-- may be redefined.
---Level: Public
---Purpose: This is called by Shape(). It does nothing but
-- may be redefined.
---Level: Public
is virtual;
Shape(me) returns Shape from TopoDS
---Purpose: Returns a shape built by the shape construction algorithm.
-- Raises exception StdFail_NotDone if the shape was not built.
---C++: return const &
---C++: alias "Standard_EXPORT operator TopoDS_Shape() const;"
---Level: Public
raises
NotDone from StdFail
is static;
---Purpose: Returns a shape built by the shape construction algorithm.
-- Raises exception StdFail_NotDone if the shape was not built.
---C++: return const &
---C++: alias "Standard_EXPORT operator TopoDS_Shape() const;"
---Level: Public
raises
NotDone from StdFail
is virtual;
--is static;
------------------------------------------------------------------
@@ -64,19 +65,19 @@ is
------------------------------------------------------------------
Generated (me: in out; S : Shape from TopoDS)
---Purpose: Returns the list of shapes generated from the
-- shape <S>.
---C++: return const &
---Level: Public
---Purpose: Returns the list of shapes generated from the
-- shape <S>.
---C++: return const &
---Level: Public
returns ListOfShape from TopTools
is virtual;
Modified (me: in out; S : Shape from TopoDS)
---Purpose: Returns the list of shapes modified from the shape
-- <S>.
---C++: return const &
---Level: Public
---Purpose: Returns the list of shapes modified from the shape
-- <S>.
---C++: return const &
---Level: Public
returns ListOfShape from TopTools
is virtual;
@@ -84,7 +85,7 @@ is
IsDeleted (me: in out; S : Shape from TopoDS)
returns Boolean
is virtual;
---Purpose: Returns true if the shape S has been deleted.
---Purpose: Returns true if the shape S has been deleted.
fields

View File

@@ -0,0 +1,645 @@
// Created on: 2014-10-20
// Created by: Denis BOGOLEPOV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepExtrema_ShapeProximity.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
//=======================================================================
//function : BRepExtrema_ShapeProximity
//purpose : Creates empty proximity tool
//=======================================================================
BRepExtrema_ShapeProximity::BRepExtrema_ShapeProximity (const Standard_Real theTolerance)
: myTolerance (theTolerance),
myPrimitiveSet1 (new BRepExtrema_TriangleSet),
myPrimitiveSet2 (new BRepExtrema_TriangleSet)
{
// Should be initialized later
myIsDone = myIsInitS1 = myIsInitS2 = Standard_False;
}
//=======================================================================
//function : BRepExtrema_ShapeProximity
//purpose : Creates proximity tool for the given two shapes
//=======================================================================
BRepExtrema_ShapeProximity::BRepExtrema_ShapeProximity (const TopoDS_Shape& theShape1,
const TopoDS_Shape& theShape2,
const Standard_Real theTolerance)
: myTolerance (theTolerance),
myPrimitiveSet1 (new BRepExtrema_TriangleSet),
myPrimitiveSet2 (new BRepExtrema_TriangleSet)
{
LoadShape1 (theShape1);
LoadShape2 (theShape2);
}
//=======================================================================
//function : LoadShape1
//purpose : Loads 1st shape into proximity tool
//=======================================================================
Standard_Boolean BRepExtrema_ShapeProximity::LoadShape1 (const TopoDS_Shape& theShape1)
{
myFaceList1.Clear();
for (TopExp_Explorer anIter (theShape1, TopAbs_FACE); anIter.More(); anIter.Next())
{
myFaceList1.Append (static_cast<const TopoDS_Face&> (anIter.Current()));
}
myIsDone = Standard_False;
return myIsInitS1 = myPrimitiveSet1->Init (myFaceList1);
}
//=======================================================================
//function : LoadShape2
//purpose : Loads 2nd shape into proximity tool
//=======================================================================
Standard_Boolean BRepExtrema_ShapeProximity::LoadShape2 (const TopoDS_Shape& theShape2)
{
myFaceList2.Clear();
for (TopExp_Explorer anIter (theShape2, TopAbs_FACE); anIter.More(); anIter.Next())
{
myFaceList2.Append (static_cast<const TopoDS_Face&> (anIter.Current()));
}
myIsDone = Standard_False;
return myIsInitS2 = myPrimitiveSet2->Init (myFaceList2);
}
namespace
{
//! Tool class to describe stack item in traverse function.
struct BRepExtrema_StackItem
{
Standard_Integer Node1;
Standard_Integer Node2;
BRepExtrema_StackItem (const Standard_Integer theNode1 = 0,
const Standard_Integer theNode2 = 0)
: Node1 (theNode1),
Node2 (theNode2)
{
//
}
};
//! Bounding triangular prism for specified triangle.
class BRepExtrema_BoundingPrism
{
public:
//! Vertices of the prism.
BVH_Vec3d Vertices[6];
//! Edges of the prism.
BVH_Vec3d Edges[3];
//! Normal to prism caps.
BVH_Vec3d Normal;
//! Normals to prism edges.
BVH_Vec3d EdgeNormals[3];
//! Is prism initialized?
Standard_Boolean IsInited;
public:
//! Creates uninitialized bounding prism.
BRepExtrema_BoundingPrism() : IsInited (Standard_False)
{
//
}
//! Creates new bounding prism for the given triangle.
BRepExtrema_BoundingPrism (const BVH_Vec3d& theVertex0,
const BVH_Vec3d& theVertex1,
const BVH_Vec3d& theVertex2,
const Standard_Real theDeflect)
{
Init (theVertex0,
theVertex1,
theVertex2,
theDeflect);
}
//! Calculates bounding prism for the given triangle.
void Init (const BVH_Vec3d& theVertex0,
const BVH_Vec3d& theVertex1,
const BVH_Vec3d& theVertex2,
const Standard_Real theDeflect)
{
Edges[0] = theVertex1 - theVertex0;
Edges[1] = theVertex2 - theVertex0;
Edges[2] = theVertex2 - theVertex1;
Normal = BVH_Vec3d::Cross (Edges[0], Edges[1]);
EdgeNormals[0] = BVH_Vec3d::Cross (Edges[0], Normal);
EdgeNormals[1] = BVH_Vec3d::Cross (Edges[1], Normal);
EdgeNormals[2] = BVH_Vec3d::Cross (Edges[2], Normal);
EdgeNormals[0] *= 1.0 / Max (EdgeNormals[0].Modulus(), Precision::Confusion());
EdgeNormals[1] *= 1.0 / Max (EdgeNormals[1].Modulus(), Precision::Confusion());
EdgeNormals[2] *= 1.0 / Max (EdgeNormals[2].Modulus(), Precision::Confusion());
const BVH_Vec3d aDirect01 = EdgeNormals[0] - EdgeNormals[1];
const BVH_Vec3d aDirect02 = EdgeNormals[0] + EdgeNormals[2];
const BVH_Vec3d aDirect12 = EdgeNormals[2] - EdgeNormals[1];
Vertices[0] = Vertices[3] = theVertex0 + aDirect01 * (theDeflect / aDirect01.Dot (EdgeNormals[0]));
Vertices[1] = Vertices[4] = theVertex1 + aDirect02 * (theDeflect / aDirect02.Dot (EdgeNormals[2]));
Vertices[2] = Vertices[5] = theVertex2 + aDirect12 * (theDeflect / aDirect12.Dot (EdgeNormals[2]));
const BVH_Vec3d aNormOffset = Normal * (theDeflect / Max (Normal.Modulus(), Precision::Confusion()));
for (Standard_Integer aVertIdx = 0; aVertIdx < 3; ++aVertIdx)
{
Vertices[aVertIdx + 0] += aNormOffset;
Vertices[aVertIdx + 3] -= aNormOffset;
}
IsInited = Standard_True;
}
//! Checks if two prisms are separated along the given axis.
Standard_Boolean Separated (const BRepExtrema_BoundingPrism& thePrism, const BVH_Vec3d& theAxis) const
{
Standard_Real aMin1 = DBL_MAX;
Standard_Real aMax1 = -DBL_MAX;
Standard_Real aMin2 = DBL_MAX;
Standard_Real aMax2 = -DBL_MAX;
for (Standard_Integer aVertIdx = 0; aVertIdx < 6; ++aVertIdx)
{
const Standard_Real aProj1 = Vertices[aVertIdx].Dot (theAxis);
aMin1 = Min (aMin1, aProj1);
aMax1 = Max (aMax1, aProj1);
const Standard_Real aProj2 = thePrism.Vertices[aVertIdx].Dot (theAxis);
aMin2 = Min (aMin2, aProj2);
aMax2 = Max (aMax2, aProj2);
if (aMin1 <= aMax2 && aMax1 >= aMin2)
{
return Standard_False;
}
}
return aMin1 > aMax2 || aMax1 < aMin2;
}
};
// =======================================================================
// function : Separated
// purpose : Checks if triangles can be separated along the given axis
// (projects vertices on this axis and performs interval test)
// =======================================================================
inline Standard_Boolean SeparateTriangles (const BVH_Vec3d& theTrg1Vert0,
const BVH_Vec3d& theTrg1Vert1,
const BVH_Vec3d& theTrg1Vert2,
const BVH_Vec3d& theTrg2Vert0,
const BVH_Vec3d& theTrg2Vert1,
const BVH_Vec3d& theTrg2Vert2,
const BVH_Vec3d& theSplitAxis)
{
const Standard_Real aA1 = theTrg1Vert0.Dot (theSplitAxis);
const Standard_Real aB1 = theTrg1Vert1.Dot (theSplitAxis);
const Standard_Real aC1 = theTrg1Vert2.Dot (theSplitAxis);
const Standard_Real aA2 = theTrg2Vert0.Dot (theSplitAxis);
const Standard_Real aB2 = theTrg2Vert1.Dot (theSplitAxis);
const Standard_Real aC2 = theTrg2Vert2.Dot (theSplitAxis);
const Standard_Real aMin1 = Min (aA1, Min (aB1, aC1));
const Standard_Real aMax1 = Max (aA1, Max (aB1, aC1));
if (aMax1 < Min (aA2, Min (aB2, aC2)))
{
return Standard_True;
}
return aMin1 > Max (aA2, Max (aB2, aC2));
}
// =======================================================================
// function : TrianglesIntersected
// purpose : Checks if two triangles are intersected
// (test uses SAT - Separating Axis Theorem)
// =======================================================================
Standard_Boolean TrianglesIntersected (const BVH_Vec3d& theTrg1Vert0,
const BVH_Vec3d& theTrg1Vert1,
const BVH_Vec3d& theTrg1Vert2,
const BVH_Vec3d& theTrg2Vert0,
const BVH_Vec3d& theTrg2Vert1,
const BVH_Vec3d& theTrg2Vert2)
{
const BVH_Vec3d aEdges1[3] = { theTrg1Vert1 - theTrg1Vert0,
theTrg1Vert2 - theTrg1Vert0,
theTrg1Vert2 - theTrg1Vert1 };
const BVH_Vec3d aTrg1Normal = BVH_Vec3d::Cross (aEdges1[0], aEdges1[1]);
if (SeparateTriangles (theTrg1Vert0,
theTrg1Vert1,
theTrg1Vert2,
theTrg2Vert0,
theTrg2Vert1,
theTrg2Vert2,
aTrg1Normal))
{
return Standard_False;
}
const BVH_Vec3d aEdges2[3] = { theTrg2Vert1 - theTrg2Vert0,
theTrg2Vert2 - theTrg2Vert0,
theTrg2Vert2 - theTrg2Vert1 };
const BVH_Vec3d aTrg2Normal = BVH_Vec3d::Cross (aEdges2[0], aEdges2[1]);
if (SeparateTriangles (theTrg1Vert0,
theTrg1Vert1,
theTrg1Vert2,
theTrg2Vert0,
theTrg2Vert1,
theTrg2Vert2,
aTrg2Normal))
{
return Standard_False;
}
for (Standard_Integer anIdx1 = 0; anIdx1 < 3; ++anIdx1)
{
for (Standard_Integer anIdx2 = 0; anIdx2 < 3; ++anIdx2)
{
const BVH_Vec3d aSplitAxis = BVH_Vec3d::Cross (aEdges1[anIdx1], aEdges2[anIdx2]);
if (SeparateTriangles (theTrg1Vert0,
theTrg1Vert1,
theTrg1Vert2,
theTrg2Vert0,
theTrg2Vert1,
theTrg2Vert2,
aSplitAxis))
{
return Standard_False;
}
}
}
return Standard_True;
}
// =======================================================================
// function : PrismsIntersected
// purpose : Checks if two triangular prisms are intersected
// (test uses SAT - Separating Axis Theorem)
// =======================================================================
Standard_Boolean PrismsIntersected (const BRepExtrema_BoundingPrism& thePrism1,
const BRepExtrema_BoundingPrism& thePrism2)
{
if (thePrism1.Separated (thePrism2, thePrism1.Normal))
{
return Standard_False;
}
if (thePrism1.Separated (thePrism2, thePrism2.Normal))
{
return Standard_False;
}
for (Standard_Integer anIdx = 0; anIdx < 3; ++anIdx)
{
if (thePrism1.Separated (thePrism2, thePrism1.EdgeNormals[anIdx]))
{
return Standard_False;
}
}
for (Standard_Integer anIdx = 0; anIdx < 3; ++anIdx)
{
if (thePrism1.Separated (thePrism2, thePrism2.EdgeNormals[anIdx]))
{
return Standard_False;
}
}
for (Standard_Integer anIdx1 = 0; anIdx1 < 4; ++anIdx1)
{
const BVH_Vec3d& aEdge1 = (anIdx1 == 3) ? thePrism1.Normal : thePrism1.Edges[anIdx1];
for (Standard_Integer anIdx2 = 0; anIdx2 < 4; ++anIdx2)
{
const BVH_Vec3d& aEdge2 = (anIdx2 == 3) ? thePrism2.Normal : thePrism2.Edges[anIdx2];
if (thePrism1.Separated (thePrism2, BVH_Vec3d::Cross (aEdge1, aEdge2)))
{
return Standard_False;
}
}
}
return Standard_True;
}
// =======================================================================
// function : OverlapBoxes
// purpose : Checks if two boxes (AABBs) are overlapped
// =======================================================================
inline Standard_Boolean OverlapBoxes (const BVH_Vec3d& theBoxMin1,
const BVH_Vec3d& theBoxMax1,
const BVH_Vec3d& theBoxMin2,
const BVH_Vec3d& theBoxMax2,
const Standard_Real theTolerance)
{
// Check for overlap
return !(theBoxMin1.x() > theBoxMax2.x() + theTolerance ||
theBoxMax1.x() < theBoxMin2.x() - theTolerance ||
theBoxMin1.y() > theBoxMax2.y() + theTolerance ||
theBoxMax1.y() < theBoxMin2.y() - theTolerance ||
theBoxMin1.z() > theBoxMax2.z() + theTolerance ||
theBoxMax1.z() < theBoxMin2.z() - theTolerance);
}
//=======================================================================
//function : getSetOfFaces
//purpose :
//=======================================================================
TColStd_PackedMapOfInteger& getSetOfFaces (BRepExtrema_OverlappedSubShapes& theShapes,
const Standard_Integer theFaceIdx)
{
if (!theShapes.IsBound (theFaceIdx))
{
theShapes.Bind (theFaceIdx, TColStd_PackedMapOfInteger());
}
return theShapes.ChangeFind (theFaceIdx);
}
}
//=======================================================================
//function : IntersectLeavesExact
//purpose : Narrow-phase of overlap test (exact intersection)
//=======================================================================
void BRepExtrema_ShapeProximity::IntersectLeavesExact (const BVH_Vec4i& theLeaf1,
const BVH_Vec4i& theLeaf2)
{
for (Standard_Integer aTrgIdx1 = theLeaf1.y(); aTrgIdx1 <= theLeaf1.z(); ++aTrgIdx1)
{
const Standard_Integer aFaceIdx1 = myPrimitiveSet1->GetFaceID (aTrgIdx1);
BVH_Vec3d aTrg1Vert1;
BVH_Vec3d aTrg1Vert2;
BVH_Vec3d aTrg1Vert3;
myPrimitiveSet1->GetVertices (aTrgIdx1,
aTrg1Vert1,
aTrg1Vert2,
aTrg1Vert3);
const Standard_Boolean aIsInSet = myOverlapSubShapes1.IsBound (aFaceIdx1);
for (Standard_Integer aTrgIdx2 = theLeaf2.y(); aTrgIdx2 <= theLeaf2.z(); ++aTrgIdx2)
{
const Standard_Integer aFaceIdx2 = myPrimitiveSet2->GetFaceID (aTrgIdx2);
if (!aIsInSet || !myOverlapSubShapes1.Find (aFaceIdx1).Contains (aFaceIdx2))
{
BVH_Vec3d aTrg2Vert1;
BVH_Vec3d aTrg2Vert2;
BVH_Vec3d aTrg2Vert3;
myPrimitiveSet2->GetVertices (aTrgIdx2, aTrg2Vert1, aTrg2Vert2, aTrg2Vert3);
if (TrianglesIntersected (aTrg1Vert1,
aTrg1Vert2,
aTrg1Vert3,
aTrg2Vert1,
aTrg2Vert2,
aTrg2Vert3))
{
getSetOfFaces (myOverlapSubShapes1, aFaceIdx1).Add (aFaceIdx2);
getSetOfFaces (myOverlapSubShapes2, aFaceIdx2).Add (aFaceIdx1);
}
}
}
}
}
//=======================================================================
//function : IntersectLeavesToler
//purpose : Narrow-phase of overlap test (with non-zero tolerance)
//=======================================================================
void BRepExtrema_ShapeProximity::IntersectLeavesToler (const BVH_Vec4i& theLeaf1,
const BVH_Vec4i& theLeaf2)
{
for (Standard_Integer aTrgIdx1 = theLeaf1.y(); aTrgIdx1 <= theLeaf1.z(); ++aTrgIdx1)
{
const Standard_Integer aFaceIdx1 = myPrimitiveSet1->GetFaceID (aTrgIdx1);
BVH_Vec3d aTrg1Vert1;
BVH_Vec3d aTrg1Vert2;
BVH_Vec3d aTrg1Vert3;
myPrimitiveSet1->GetVertices (aTrgIdx1,
aTrg1Vert1,
aTrg1Vert2,
aTrg1Vert3);
BRepExtrema_BoundingPrism aPrism1; // not initialized
const Standard_Boolean aIsInSet = myOverlapSubShapes1.IsBound (aFaceIdx1);
for (Standard_Integer aTrgIdx2 = theLeaf2.y(); aTrgIdx2 <= theLeaf2.z(); ++aTrgIdx2)
{
const Standard_Integer aFaceIdx2 = myPrimitiveSet2->GetFaceID (aTrgIdx2);
if (!aIsInSet || !myOverlapSubShapes1.Find (aFaceIdx1).Contains (aFaceIdx2))
{
if (!aPrism1.IsInited)
{
aPrism1.Init (aTrg1Vert1, aTrg1Vert2, aTrg1Vert3, myTolerance);
}
BVH_Vec3d aTrg2Vert1;
BVH_Vec3d aTrg2Vert2;
BVH_Vec3d aTrg2Vert3;
myPrimitiveSet2->GetVertices (aTrgIdx2,
aTrg2Vert1,
aTrg2Vert2,
aTrg2Vert3);
BRepExtrema_BoundingPrism aPrism2 (aTrg2Vert1,
aTrg2Vert2,
aTrg2Vert3,
myTolerance);
if (PrismsIntersected (aPrism1, aPrism2))
{
getSetOfFaces (myOverlapSubShapes1, aFaceIdx1).Add (aFaceIdx2);
getSetOfFaces (myOverlapSubShapes2, aFaceIdx2).Add (aFaceIdx1);
}
}
}
}
}
//=======================================================================
//function : Perform
//purpose : Performs search for overlapped faces
//=======================================================================
void BRepExtrema_ShapeProximity::Perform()
{
if (myIsDone || !myIsInitS1 || !myIsInitS2)
{
return;
}
BRepExtrema_StackItem aStack[96];
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& aBVH1 = myPrimitiveSet1->BVH();
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& aBVH2 = myPrimitiveSet2->BVH();
if (aBVH1.IsNull() || aBVH2.IsNull())
{
return;
}
BRepExtrema_StackItem aNodes; // current pair of nodes
Standard_Integer aHead = -1; // stack head position
for (;;)
{
BVH_Vec4i aNodeData1 = aBVH1->NodeInfoBuffer()[aNodes.Node1];
BVH_Vec4i aNodeData2 = aBVH2->NodeInfoBuffer()[aNodes.Node2];
if (aNodeData1.x() != 0 && aNodeData2.x() != 0) // leaves
{
if (myTolerance == 0.0)
{
IntersectLeavesExact (aNodeData1, aNodeData2);
}
else
{
IntersectLeavesToler (aNodeData1, aNodeData2);
}
if (aHead < 0)
break;
aNodes = aStack[aHead--];
}
else
{
BRepExtrema_StackItem aPairsToProcess[4];
Standard_Integer aNbPairs = 0;
if (aNodeData1.x() == 0) // inner node
{
const BVH_Vec3d& aMinPntLft1 = aBVH1->MinPoint (aNodeData1.y());
const BVH_Vec3d& aMaxPntLft1 = aBVH1->MaxPoint (aNodeData1.y());
const BVH_Vec3d& aMinPntRgh1 = aBVH1->MinPoint (aNodeData1.z());
const BVH_Vec3d& aMaxPntRgh1 = aBVH1->MaxPoint (aNodeData1.z());
if (aNodeData2.x() == 0) // inner node
{
const BVH_Vec3d& aMinPntLft2 = aBVH2->MinPoint (aNodeData2.y());
const BVH_Vec3d& aMaxPntLft2 = aBVH2->MaxPoint (aNodeData2.y());
const BVH_Vec3d& aMinPntRgh2 = aBVH2->MinPoint (aNodeData2.z());
const BVH_Vec3d& aMaxPntRgh2 = aBVH2->MaxPoint (aNodeData2.z());
if (OverlapBoxes (aMinPntLft1, aMaxPntLft1, aMinPntLft2, aMaxPntLft2, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.y(), aNodeData2.y());
}
if (OverlapBoxes (aMinPntLft1, aMaxPntLft1, aMinPntRgh2, aMaxPntRgh2, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.y(), aNodeData2.z());
}
if (OverlapBoxes (aMinPntRgh1, aMaxPntRgh1, aMinPntLft2, aMaxPntLft2, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.z(), aNodeData2.y());
}
if (OverlapBoxes (aMinPntRgh1, aMaxPntRgh1, aMinPntRgh2, aMaxPntRgh2, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.z(), aNodeData2.z());
}
}
else
{
const BVH_Vec3d& aMinPntLeaf = aBVH2->MinPoint (aNodes.Node2);
const BVH_Vec3d& aMaxPntLeaf = aBVH2->MaxPoint (aNodes.Node2);
if (OverlapBoxes (aMinPntLft1, aMaxPntLft1, aMinPntLeaf, aMaxPntLeaf, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.y(), aNodes.Node2);
}
if (OverlapBoxes (aMinPntRgh1, aMaxPntRgh1, aMinPntLeaf, aMaxPntLeaf, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodeData1.z(), aNodes.Node2);
}
}
}
else
{
const BVH_Vec3d& aMinPntLeaf = aBVH1->MinPoint (aNodes.Node1);
const BVH_Vec3d& aMaxPntLeaf = aBVH1->MaxPoint (aNodes.Node1);
const BVH_Vec3d& aMinPntLft2 = aBVH2->MinPoint (aNodeData2.y());
const BVH_Vec3d& aMaxPntLft2 = aBVH2->MaxPoint (aNodeData2.y());
const BVH_Vec3d& aMinPntRgh2 = aBVH2->MinPoint (aNodeData2.z());
const BVH_Vec3d& aMaxPntRgh2 = aBVH2->MaxPoint (aNodeData2.z());
if (OverlapBoxes (aMinPntLft2, aMaxPntLft2, aMinPntLeaf, aMaxPntLeaf, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodes.Node1, aNodeData2.y());
}
if (OverlapBoxes (aMinPntRgh2, aMaxPntRgh2, aMinPntLeaf, aMaxPntLeaf, myTolerance))
{
aPairsToProcess[aNbPairs++] = BRepExtrema_StackItem (aNodes.Node1, aNodeData2.z());
}
}
if (aNbPairs > 0)
{
aNodes = aPairsToProcess[0];
for (Standard_Integer anIdx = 1; anIdx < aNbPairs; ++anIdx)
{
aStack[++aHead] = aPairsToProcess[anIdx];
}
}
else
{
if (aHead < 0)
break;
aNodes = aStack[aHead--];
}
}
}
myIsDone = Standard_True;
}

View File

@@ -0,0 +1,154 @@
// Created on: 2014-10-20
// Created by: Denis BOGOLEPOV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepExtrema_ShapeProximity_HeaderFile
#define _BRepExtrema_ShapeProximity_HeaderFile
#include <BVH_Geometry.hxx>
#include <BRepExtrema_TriangleSet.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <NCollection_DataMap.hxx>
//! Set of overlapped sub-shapes.
typedef NCollection_DataMap<Standard_Integer, TColStd_PackedMapOfInteger > BRepExtrema_OverlappedSubShapes;
//! Tool class for shape proximity detection.
//! For two given shapes and given tolerance (offset from the mesh) the algorithm allows
//! to determine whether or not they are overlapped. The algorithm input consists of any
//! shapes which can be decomposed into individual faces (used as basic shape elements).
//! High performance is achieved through the use of existing triangulation of faces. So
//! poly triangulation (with the desired deflection) should already be built. Note that
//! solution is approximate (and corresponds to the deflection used for triangulation).
//!
//! The algorithm can be run in two modes. If tolerance is set to zero, the algorithm
//! will detect only intersecting faces (containing triangles with common points). If
//! tolerance is set to positive value, the algorithm will also detect faces located
//! on distance less than the given tolerance from each other.
class BRepExtrema_ShapeProximity
{
public:
//! Creates empty proximity tool.
Standard_EXPORT BRepExtrema_ShapeProximity (const Standard_Real theTolerance = 0.0);
//! Creates proximity tool for the given two shapes.
Standard_EXPORT BRepExtrema_ShapeProximity (const TopoDS_Shape& theShape1,
const TopoDS_Shape& theShape2,
const Standard_Real theTolerance = 0.0);
public:
//! Returns tolerance value for overlap test (distance between shapes).
Standard_Real Tolerance() const
{
return myTolerance;
}
//! Sets tolerance value for overlap test (distance between shapes).
void SetTolerance (const Standard_Real theTolerance)
{
myTolerance = theTolerance;
}
//! Loads 1st shape into proximity tool.
Standard_EXPORT Standard_Boolean LoadShape1 (const TopoDS_Shape& theShape1);
//! Loads 2nd shape into proximity tool.
Standard_EXPORT Standard_Boolean LoadShape2 (const TopoDS_Shape& theShape2);
//! Performs search for overlapped faces.
Standard_EXPORT void Perform();
//! True if the search is completed.
Standard_Boolean IsDone() const
{
return myIsDone;
}
//! Returns set of all the face triangles of the 1st shape.
const NCollection_Handle<BRepExtrema_TriangleSet>& PrimitiveSet1() const
{
return myPrimitiveSet1;
}
//! Returns set of all the face triangles of the 2nd shape.
const NCollection_Handle<BRepExtrema_TriangleSet>& PrimitiveSet2() const
{
return myPrimitiveSet2;
}
//! Returns set of IDs of overlapped faces of 1st shape.
const BRepExtrema_OverlappedSubShapes& OverlapSubShapes1() const
{
return myOverlapSubShapes1;
}
//! Returns set of IDs of overlapped faces of 2nd shape.
const BRepExtrema_OverlappedSubShapes& OverlapSubShapes2() const
{
return myOverlapSubShapes2;
}
//! Returns sub-shape from 1st shape with the given index.
const TopoDS_Face& GetSubShape1 (const Standard_Integer theID) const
{
return myFaceList1.Value (theID);
}
//! Returns sub-shape from 1st shape with the given index.
const TopoDS_Face& GetSubShape2 (const Standard_Integer theID) const
{
return myFaceList2.Value (theID);
}
protected:
//! Performs narrow-phase of overlap test (exact intersection).
void IntersectLeavesExact (const BVH_Vec4i& theLeaf1, const BVH_Vec4i& theLeaf2);
//! Performs narrow-phase of overlap test (intersection with non-zero tolerance).
void IntersectLeavesToler (const BVH_Vec4i& theLeaf1, const BVH_Vec4i& theLeaf2);
private:
//! Maximum overlapping distance.
Standard_Real myTolerance;
//! Is the 1st shape initialized?
Standard_Boolean myIsInitS1;
//! Is the 2nd shape initialized?
Standard_Boolean myIsInitS2;
//! List of faces of the 1st shape.
BRepExtrema_ShapeList myFaceList1;
//! List of faces of the 2nd shape.
BRepExtrema_ShapeList myFaceList2;
//! Set of all the face triangles of the 1st shape.
NCollection_Handle<BRepExtrema_TriangleSet> myPrimitiveSet1;
//! Set of all the face triangles of the 2nd shape.
NCollection_Handle<BRepExtrema_TriangleSet> myPrimitiveSet2;
//! Set of overlapped faces of 1st shape.
BRepExtrema_OverlappedSubShapes myOverlapSubShapes1;
//! Set of overlapped faces of 2nd shape.
BRepExtrema_OverlappedSubShapes myOverlapSubShapes2;
//! Is overlap test completed?
Standard_Boolean myIsDone;
};
#endif // _BRepExtrema_ShapeProximity_HeaderFile

View File

@@ -0,0 +1,226 @@
// Created on: 2014-10-20
// Created by: Denis BOGOLEPOV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepExtrema_TriangleSet.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BVH_LinearBuilder.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
//=======================================================================
//function : BRepExtrema_TriangleSet
//purpose : Creates empty triangle set
//=======================================================================
BRepExtrema_TriangleSet::BRepExtrema_TriangleSet()
: BVH_PrimitiveSet<Standard_Real, 3>()
{
// Set default builder - linear BVH (LBVH)
myBuilder = new BVH_LinearBuilder<Standard_Real, 3> (5, 32);
}
//=======================================================================
//function : BRepExtrema_TriangleSet
//purpose : Creates triangle set from the given face
//=======================================================================
BRepExtrema_TriangleSet::BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces)
: BVH_PrimitiveSet<Standard_Real, 3>()
{
// Set default builder - linear BVH (LBVH)
myBuilder = new BVH_LinearBuilder<Standard_Real, 3> (5, 32);
Init (theFaces);
}
//=======================================================================
//function : ~BRepExtrema_TriangleSet
//purpose : Releases resources of triangle set
//=======================================================================
BRepExtrema_TriangleSet::~BRepExtrema_TriangleSet()
{
//
}
//=======================================================================
//function : Size
//purpose : Returns total number of triangles
//=======================================================================
Standard_Integer BRepExtrema_TriangleSet::Size() const
{
return static_cast<Standard_Integer> (myTriangles.size());
}
//=======================================================================
//function : Box
//purpose : Returns AABB of the given triangle
//=======================================================================
BVH_Box<Standard_Real, 3> BRepExtrema_TriangleSet::Box (const Standard_Integer theIndex) const
{
const BVH_Vec4i& aTriangle = myTriangles[theIndex];
BVH_Vec3d aMinPnt = myVertexArray[aTriangle.x()].cwiseMin (
myVertexArray[aTriangle.y()].cwiseMin (myVertexArray[aTriangle.z()]));
BVH_Vec3d aMaxPnt = myVertexArray[aTriangle.x()].cwiseMax (
myVertexArray[aTriangle.y()].cwiseMax (myVertexArray[aTriangle.z()]));
return BVH_Box<Standard_Real, 3> (aMinPnt, aMaxPnt);
}
//=======================================================================
//function : Center
//purpose : Returns centroid position along specified axis
//=======================================================================
Standard_Real BRepExtrema_TriangleSet::Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const
{
const BVH_Vec4i& aTriangle = myTriangles[theIndex];
if (theAxis == 0)
{
return (1.0 / 3.0) * (myVertexArray[aTriangle.x()].x() +
myVertexArray[aTriangle.y()].x() +
myVertexArray[aTriangle.z()].x());
}
else if (theAxis == 1)
{
return (1.0 / 3.0) * (myVertexArray[aTriangle.x()].y() +
myVertexArray[aTriangle.y()].y() +
myVertexArray[aTriangle.z()].y());
}
else
{
return (1.0 / 3.0) * (myVertexArray[aTriangle.x()].z() +
myVertexArray[aTriangle.y()].z() +
myVertexArray[aTriangle.z()].z());
}
}
//=======================================================================
//function : Swap
//purpose : Swaps indices of two specified triangles
//=======================================================================
void BRepExtrema_TriangleSet::Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2)
{
std::swap (myTriangles[theIndex1],
myTriangles[theIndex2]);
}
//=======================================================================
//function : GetFaceID
//purpose : Returns face ID of the given triangle
//=======================================================================
Standard_Integer BRepExtrema_TriangleSet::GetFaceID (const Standard_Integer theIndex) const
{
return myTriangles[theIndex].w();
}
//=======================================================================
//function : GetVertices
//purpose : Returns vertices of the given triangle
//=======================================================================
void BRepExtrema_TriangleSet::GetVertices (const Standard_Integer theIndex,
BVH_Vec3d& theVertex1,
BVH_Vec3d& theVertex2,
BVH_Vec3d& theVertex3) const
{
BVH_Vec4i aTriangle = myTriangles[theIndex];
theVertex1 = myVertexArray[aTriangle.x()];
theVertex2 = myVertexArray[aTriangle.y()];
theVertex3 = myVertexArray[aTriangle.z()];
}
//=======================================================================
//function : Clear
//purpose : Clears triangle set data
//=======================================================================
void BRepExtrema_TriangleSet::Clear()
{
BVH_Array4i anEmptyTriangles;
myTriangles.swap (anEmptyTriangles);
BVH_Array2d anEmptyVertUVArray;
myVertUVArray.swap (anEmptyVertUVArray);
BVH_Array3d anEmptyVertexArray;
myVertexArray.swap (anEmptyVertexArray);
}
//=======================================================================
//function : Init
//purpose : Initializes triangle set
//=======================================================================
Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& theFaces)
{
Clear();
for (Standard_Integer aFaceIdx = 0; aFaceIdx < theFaces.Size(); ++aFaceIdx)
{
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aTriangulation =
BRep_Tool::Triangulation (theFaces (aFaceIdx), aLocation);
if (aTriangulation.IsNull())
{
return Standard_False;
}
BRepAdaptor_Surface aFaceAdaptor (theFaces (aFaceIdx), Standard_False);
const Standard_Integer aVertOffset =
static_cast<Standard_Integer> (myVertexArray.size()) - 1;
for (Standard_Integer aVertIdx = 1; aVertIdx <= aTriangulation->NbNodes(); ++aVertIdx)
{
gp_Pnt aVertex = aTriangulation->Nodes().Value (aVertIdx);
aVertex.Transform (aLocation.Transformation());
myVertexArray.push_back (BVH_Vec3d (aVertex.X(),
aVertex.Y(),
aVertex.Z()));
const Standard_Real aU = aTriangulation->UVNodes().Value (aVertIdx).X();
const Standard_Real aV = aTriangulation->UVNodes().Value (aVertIdx).Y();
myVertUVArray.push_back (BVH_Vec2d (aU, aV));
}
for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx)
{
Standard_Integer aVertex1;
Standard_Integer aVertex2;
Standard_Integer aVertex3;
aTriangulation->Triangles().Value (aTriIdx).Get (aVertex1,
aVertex2,
aVertex3);
myTriangles.push_back (BVH_Vec4i (aVertex1 + aVertOffset,
aVertex2 + aVertOffset,
aVertex3 + aVertOffset,
aFaceIdx));
}
}
MarkDirty(); // needs BVH rebuilding
Standard_ASSERT_RETURN (!BVH().IsNull(),
"Error: Failed to build BVH for primitive set", Standard_False);
return Standard_True;
}

View File

@@ -0,0 +1,84 @@
// Created on: 2014-10-20
// Created by: Denis BOGOLEPOV
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepExtrema_TriangleSet_HeaderFile
#define _BRepExtrema_TriangleSet_HeaderFile
#include <TopoDS_Face.hxx>
#include <BVH_PrimitiveSet.hxx>
//! List of shapes and their IDs for collision detection.
typedef NCollection_Vector<TopoDS_Face> BRepExtrema_ShapeList;
//! Triangle set corresponding to specific face.
class BRepExtrema_TriangleSet : public BVH_PrimitiveSet<Standard_Real, 3>
{
public:
//! Creates empty triangle set.
Standard_EXPORT BRepExtrema_TriangleSet();
//! Creates triangle set from the given face.
Standard_EXPORT BRepExtrema_TriangleSet (const BRepExtrema_ShapeList& theFaces);
//! Releases resources of triangle set.
Standard_EXPORT ~BRepExtrema_TriangleSet();
public: //! @name methods implementing BVH set interface
//! Returns total number of triangles.
Standard_Integer Size() const;
//! Returns AABB of the given triangle.
BVH_Box<Standard_Real, 3> Box (const Standard_Integer theIndex) const;
//! Returns centroid position along specified axis.
Standard_Real Center (const Standard_Integer theIndex, const Standard_Integer theAxis) const;
//! Swaps indices of two specified triangles.
void Swap (const Standard_Integer theIndex1, const Standard_Integer theIndex2);
public:
//! Clears triangle set data.
Standard_EXPORT void Clear();
//! Initializes triangle set.
Standard_EXPORT Standard_Boolean Init (const BRepExtrema_ShapeList& theFaces);
//! Returns vertices of the given triangle.
Standard_EXPORT void GetVertices (const Standard_Integer theIndex,
BVH_Vec3d& theVertex1,
BVH_Vec3d& theVertex2,
BVH_Vec3d& theVertex3) const;
//! Returns face ID of the given triangle.
Standard_EXPORT Standard_Integer GetFaceID (const Standard_Integer theIndex) const;
protected:
//! Array of vertex indices.
BVH_Array4i myTriangles;
//! Array of vertex UV params.
BVH_Array2d myVertUVArray;
//! Array of vertex coordinates.
BVH_Array3d myVertexArray;
};
#endif // _BRepExtrema_TriangleSet_HeaderFile

View File

@@ -17,3 +17,7 @@ BRepExtrema_Poly.cxx
BRepExtrema_SeqOfSolution.hxx
BRepExtrema_SolutionElem.hxx
BRepExtrema_SupportType.hxx
BRepExtrema_TriangleSet.hxx
BRepExtrema_TriangleSet.cxx
BRepExtrema_ShapeProximity.hxx
BRepExtrema_ShapeProximity.cxx

View File

@@ -108,12 +108,10 @@ is
List from TCollection (OffsetWire from BRepFill);
private class ApproxSeewing;
private class MultiLine;
private class MultiLineTool;
imported MultiLine;
private class ComputeCLine instantiates
ComputeCLine from Approx ( MultiLine, MultiLineTool);
ComputeCLine from Approx (MultiLine);
private class TrimSurfaceTool;

View File

@@ -1,112 +0,0 @@
-- Created on: 1994-11-14
-- Created by: Bruno DUMORTIER
-- Copyright (c) 1994-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.
private class MultiLine from BRepFill
---Purpose: Private class used to compute the 3d curve and the
-- two 2d curves resulting from the intersection of a
-- surface of linear extrusion( Bissec, Dz) and the 2
-- faces.
-- This 3 curves will have the same parametrization
-- as the Bissectrice.
-- This class is to be send to an approximation
-- routine.
uses
Face from TopoDS,
Edge from TopoDS,
Curve from Geom,
Curve from Geom2d,
Curve from Geom2dAdaptor,
Pnt from gp,
Pnt2d from gp,
Shape from GeomAbs
raises
DomainError from Standard
is
Create;
Create( Face1, Face2 : Face from TopoDS;
Edge1, Edge2 : Edge from TopoDS;
Inv1 , Inv2 : Boolean from Standard;
Bissec : Curve from Geom2d );
IsParticularCase(me)
returns Boolean from Standard
---Purpose: Search if the Projection of the Bissectrice on the
-- faces needs an approximation or not.
-- Returns true if the approximation is not needed.
is static;
Continuity (me) returns Shape from GeomAbs
---Purpose: Returns the continuity betwwen the two faces
-- seShape from GeomAbsparated by myBis.
is static;
Curves(me; Curve : in out Curve from Geom;
PCurve1 : in out Curve from Geom2d;
PCurve2 : in out Curve from Geom2d)
raises
DomainError from Standard
---Purpose: raises if IsParticularCase is <False>.
is static;
FirstParameter(me)
---Purpose: returns the first parameter of the Bissectrice.
returns Real from Standard is static;
LastParameter(me)
---Purpose: returns the last parameter of the Bissectrice.
returns Real from Standard is static;
Value ( me; U : Real from Standard)
---Purpose: Returns the current point on the 3d curve
returns Pnt from gp is static;
ValueOnF1(me; U : Real from Standard)
---Purpose: returns the current point on the PCurve of the
-- first face
returns Pnt2d from gp is static;
ValueOnF2(me; U : Real from Standard)
---Purpose: returns the current point on the PCurve of the
-- first face
returns Pnt2d from gp is static;
Value3dOnF1OnF2(me;
U : Real from Standard;
P3d : in out Pnt from gp;
PF1 : in out Pnt2d from gp;
PF2 : in out Pnt2d from gp)
is static;
fields
myFace1 : Face from TopoDS;
myFace2 : Face from TopoDS;
myU1 : Curve from Geom2dAdaptor;
myV1 : Curve from Geom2dAdaptor;
myU2 : Curve from Geom2dAdaptor;
myV2 : Curve from Geom2dAdaptor;
myIsoU1 : Boolean from Standard;
myIsoU2 : Boolean from Standard;
myBis : Curve from Geom2dAdaptor;
myKPart : Integer from Standard;
myCont : Shape from GeomAbs;
end MultiLine;

View File

@@ -14,7 +14,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BRepFill_MultiLine.ixx>
#include <BRepFill_MultiLine.hxx>
#include <BRepIntCurveSurface_Inter.hxx>
#include <gp.hxx>
@@ -80,8 +80,6 @@ static Standard_Boolean isIsoU(const TopoDS_Face& Face,
}
//=======================================================================
//function : BRepFill_MultiLine
//purpose :
@@ -89,6 +87,8 @@ static Standard_Boolean isIsoU(const TopoDS_Face& Face,
BRepFill_MultiLine::BRepFill_MultiLine()
{
myNbPnt2d = 2;
myNbPnt = 1;
}
@@ -98,17 +98,20 @@ BRepFill_MultiLine::BRepFill_MultiLine()
//=======================================================================
BRepFill_MultiLine::BRepFill_MultiLine(const TopoDS_Face& Face1,
const TopoDS_Face& Face2,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
const Standard_Boolean Inv1,
const Standard_Boolean Inv2,
const Handle(Geom2d_Curve)& Bissec) :
myFace1(Face1 ),
myFace2(Face2 ),
myBis (Bissec),
myKPart(0)
const TopoDS_Face& Face2,
const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2,
const Standard_Boolean Inv1,
const Standard_Boolean Inv2,
const Handle(Geom2d_Curve)& Bissec)
: myFace1(Face1 ),
myFace2(Face2 ),
myBis (Bissec),
myKPart(0)
{
myNbPnt2d = 2;
myNbPnt = 1;
// eval if myedges are IsoU or not
myIsoU1 = isIsoU(Face1, Edge1);
myIsoU2 = isIsoU(Face2, Edge2);
@@ -149,7 +152,6 @@ myKPart(0)
Vmax = Max(Vmax,V);
}
}
// return isos in their domain of restriction.
Handle(Geom_Curve) UU1, UU2, VV1, VV2;
@@ -765,3 +767,30 @@ GeomAbs_Shape BRepFill_MultiLine::Continuity() const
{
return myCont;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLine::Value(const Standard_Real theT,
NCollection_Array1<gp_Pnt2d>& thePnt2d,
NCollection_Array1<gp_Pnt>& thePnt) const
{
thePnt(1) = Value(theT);
thePnt2d(1) = ValueOnF1(theT);
thePnt2d(2) = ValueOnF2(theT);
return Standard_True;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Boolean BRepFill_MultiLine::D1(const Standard_Real /*theT*/,
NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
NCollection_Array1<gp_Vec>& /*theVec*/) const
{
return Standard_False;
}

View File

@@ -0,0 +1,117 @@
// Created on: 1994-11-14
// Created by: Bruno DUMORTIER
// Copyright (c) 1994-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepFill_MultiLine_HeaderFile
#define _BRepFill_MultiLine_HeaderFile
#include <AppCont_Function.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <GeomAbs_Shape.hxx>
#include <Handle_Geom2d_Curve.hxx>
#include <Handle_Geom_Curve.hxx>
#include <Standard_Real.hxx>
class Standard_DomainError;
class TopoDS_Face;
class TopoDS_Edge;
class Geom2d_Curve;
class Geom_Curve;
class gp_Pnt;
class gp_Pnt2d;
//! Class used to compute the 3d curve and the
//! two 2d curves resulting from the intersection of a
//! surface of linear extrusion( Bissec, Dz) and the 2
//! faces.
//! This 3 curves will have the same parametrization
//! as the Bissectrice.
//! This class is to be send to an approximation
//! routine.
class BRepFill_MultiLine : public AppCont_Function
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT BRepFill_MultiLine();
Standard_EXPORT BRepFill_MultiLine(const TopoDS_Face& Face1, const TopoDS_Face& Face2, const TopoDS_Edge& Edge1, const TopoDS_Edge& Edge2, const Standard_Boolean Inv1, const Standard_Boolean Inv2, const Handle(Geom2d_Curve)& Bissec);
//! Search if the Projection of the Bissectrice on the
//! faces needs an approximation or not.
//! Returns true if the approximation is not needed.
Standard_EXPORT Standard_Boolean IsParticularCase() const;
//! Returns the continuity betwwen the two faces
//! seShape from GeomAbsparated by myBis.
Standard_EXPORT GeomAbs_Shape Continuity() const;
//! raises if IsParticularCase is <False>.
Standard_EXPORT void Curves (Handle(Geom_Curve)& Curve, Handle(Geom2d_Curve)& PCurve1, Handle(Geom2d_Curve)& PCurve2) const;
//! returns the first parameter of the Bissectrice.
Standard_EXPORT virtual Standard_Real FirstParameter() const;
//! returns the last parameter of the Bissectrice.
Standard_EXPORT virtual Standard_Real LastParameter() const;
//! Returns the current point on the 3d curve
Standard_EXPORT gp_Pnt Value (const Standard_Real U) const;
//! returns the current point on the PCurve of the
//! first face
Standard_EXPORT gp_Pnt2d ValueOnF1 (const Standard_Real U) const;
//! returns the current point on the PCurve of the
//! first face
Standard_EXPORT gp_Pnt2d ValueOnF2 (const Standard_Real U) const;
Standard_EXPORT void Value3dOnF1OnF2 (const Standard_Real U, gp_Pnt& P3d, gp_Pnt2d& PF1, gp_Pnt2d& PF2) const;
//! Returns the point at parameter <theU>.
Standard_EXPORT virtual Standard_Boolean Value(const Standard_Real theU,
NCollection_Array1<gp_Pnt2d>& thePnt2d,
NCollection_Array1<gp_Pnt>& thePnt) const;
//! Returns the derivative at parameter <theU>.
Standard_EXPORT virtual Standard_Boolean D1(const Standard_Real theU,
NCollection_Array1<gp_Vec2d>& theVec2d,
NCollection_Array1<gp_Vec>& theVec) const;
private:
TopoDS_Face myFace1;
TopoDS_Face myFace2;
Geom2dAdaptor_Curve myU1;
Geom2dAdaptor_Curve myV1;
Geom2dAdaptor_Curve myU2;
Geom2dAdaptor_Curve myV2;
Standard_Boolean myIsoU1;
Standard_Boolean myIsoU2;
Geom2dAdaptor_Curve myBis;
Standard_Integer myKPart;
GeomAbs_Shape myCont;
};
#endif // _BRepFill_MultiLine_HeaderFile

View File

@@ -1,105 +0,0 @@
-- Created on: 1994-11-14
-- Created by: Bruno DUMORTIER
-- Copyright (c) 1994-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.
private class MultiLineTool from BRepFill
---Purpose: private class used to instantiate the continuous
-- approximations routines.
uses
Pnt from gp,
Pnt2d from gp,
Vec from gp,
Vec2d from gp,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
Array1OfVec from TColgp,
Array1OfVec2d from TColgp,
MultiLine from BRepFill
is
FirstParameter(myclass; ML: MultiLine from BRepFill)
---Purpose: returns the first parameter of the Line.
returns Real from Standard;
LastParameter(myclass; ML: MultiLine from BRepFill)
---Purpose: returns the last parameter of the Line.
returns Real from Standard;
NbP2d(myclass; ML: MultiLine from BRepFill)
---Purpose: Returns the number of 2d points of a MLine
returns Integer from Standard;
NbP3d(myclass; ML: MultiLine from BRepFill)
---Purpose: Returns the number of 3d points of a MLine.
returns Integer from Standard;
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt: out Array1OfPnt from TColgp);
---Purpose: returns the 3d points of the multipoint <MPointIndex>
-- when only 3d points exist.
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt2d: out Array1OfPnt2d from TColgp);
---Purpose: returns the 2d points of the multipoint <MPointIndex>
-- when only 2d points exist.
Value(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabPt : out Array1OfPnt from TColgp;
tabPt2d: out Array1OfPnt2d from TColgp);
---Purpose: returns the 3d and 2d points of the multipoint
-- <MPointIndex>.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV: out Array1OfVec from TColgp)
returns Boolean from Standard;
---Purpose: returns the 3d derivative values of the multipoint
-- <MPointIndex> when only 3d points exist.
-- returns False if the derivative cannot be computed.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV2d: out Array1OfVec2d from TColgp)
returns Boolean from Standard;
---Purpose: returns the 2d derivative values of the multipoint
-- <MPointIndex> only when 2d points exist.
-- returns False if the derivative cannot be computed.
D1(myclass; ML : MultiLine from BRepFill;
U : Real from Standard;
tabV : out Array1OfVec from TColgp;
tabV2d: out Array1OfVec2d from TColgp)
returns Boolean from Standard;
---Purpose: returns the 3d and 2d derivative values of the
-- multipoint <MPointIndex>.
-- returns False if the derivative cannot be computed.
end MultiLineTool;

View File

@@ -1253,29 +1253,6 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
const Standard_Boolean EOnE,
const BRepFill_TrimEdgeTool& Trim) const
{
if (myJoinType == GeomAbs_Intersection &&
Vertices.Length() == 1 &&
!EOnE)
{
TopTools_IndexedMapOfShape Vmap1, Vmap2;
TopExp::MapShapes(Shape1, TopAbs_VERTEX, Vmap1);
TopExp::MapShapes(Shape2, TopAbs_VERTEX, Vmap2);
Standard_Boolean Adjacent = Standard_False;
for (Standard_Integer i = 1; i <= Vmap1.Extent(); i++)
for (Standard_Integer j = 1; j <= Vmap2.Extent(); j++)
if (Vmap1(i).IsSame(Vmap2(j)))
{
Adjacent = Standard_True;
break;
}
if (Adjacent)
{
Detromp(Shape1).Append(Vertices.First());
Detromp(Shape2).Append(Vertices.First());
return;
}
}
Standard_Integer ii = 1;
Standard_Real U1,U2;
TopoDS_Vertex V1,V2;
@@ -1294,8 +1271,11 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
U2 = Params.Value(ii).X();
V2 = TopoDS::Vertex(Vertices.Value(ii));
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
if (!Trim.IsInside(P)) {
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
Standard_Boolean IsP_inside = Standard_True;
if (myJoinType == GeomAbs_Arc)
IsP_inside = Trim.IsInside(P);
if (!IsP_inside) {
if (!V1.IsNull()) {
Detromp(Shape1).Append(V1);
Detromp(Shape2).Append(V1);
@@ -1313,7 +1293,10 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
if (!EOnE) {
if (!Precision::IsInfinite(U2)) {
gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
if (!Trim.IsInside(P)) {
Standard_Boolean IsP_inside = Standard_False;
if (myJoinType == GeomAbs_Arc)
IsP_inside = Trim.IsInside(P);
if (!IsP_inside) {
if (!V1.IsNull()) {
Detromp(Shape1).Append(V1);
Detromp(Shape2).Append(V1);

View File

@@ -274,18 +274,9 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
}
ShapeUpgrade_RemoveLocations RemLoc;
RemLoc.SetRemoveLevel(TopAbs_COMPOUND);
RemLoc.Remove(myFirst);
myFirst = RemLoc.GetResult();
TopLoc_Location theLoc = myFirst.Location();
if (!theLoc.IsIdentity())
{
TopoDS_Shape NewMyFirst = BRepBuilderAPI_Copy(myFirst);
RemLoc.Remove(NewMyFirst);
NewMyFirst = RemLoc.GetResult();
TopLoc_Location theIdentity;
NewMyFirst.Location(theIdentity);
myFirst = BRepBuilderAPI_Transform(NewMyFirst, theLoc.Transformation(), Standard_True);
}
myLoc->Law(myLoc->NbLaw())->GetDomain(first, last);
myLoc->Law(myLoc->NbLaw())->D0(last,M, V);
@@ -308,16 +299,6 @@ void BRepFill_Pipe::Perform(const TopoDS_Wire& Spine,
RemLoc.Remove(myLast);
myLast = RemLoc.GetResult();
theLoc = myLast.Location();
if (!theLoc.IsIdentity())
{
TopoDS_Shape NewMyLast = BRepBuilderAPI_Copy(myLast);
RemLoc.Remove(NewMyLast);
NewMyLast = RemLoc.GetResult();
TopLoc_Location theIdentity;
NewMyLast.Location(theIdentity);
myLast = BRepBuilderAPI_Transform(NewMyLast, theLoc.Transformation(), Standard_True);
}
#if DRAW
if (Affich) {

2
src/BRepFill/FILES Normal file
View File

@@ -0,0 +1,2 @@
BRepFill_MultiLine.hxx
BRepFill_MultiLine.cxx

View File

@@ -94,7 +94,7 @@ namespace BRepMesh
//! Maps
typedef NCollection_Map<Standard_Integer> MapOfInteger;
typedef NCollection_Map<Handle(Poly_Triangulation)> MapOfTriangulation;
typedef NCollection_DataMap<Handle(Poly_Triangulation), Standard_Boolean> DMapOfTriangulationBool;
typedef NCollection_Map<TopoDS_Shape, TopTools_ShapeMapHasher> MapOfShape;
typedef NCollection_DataMap<Standard_Integer, Standard_Integer> MapOfIntegerInteger;
@@ -104,7 +104,7 @@ namespace BRepMesh
typedef NCollection_DataMap<Standard_Integer, gp_Pnt> DMapOfIntegerPnt;
typedef NCollection_DataMap<Standard_Integer, ListOfXY> DMapOfIntegerListOfXY;
typedef NCollection_DataMap<Standard_Integer, ListOfInteger> DMapOfIntegerListOfInteger;
typedef NCollection_DataMap<TopoDS_Edge, MapOfTriangulation, TopTools_ShapeMapHasher> DMapOfEdgeListOfTriangulation;
typedef NCollection_DataMap<TopoDS_Edge, DMapOfTriangulationBool, TopTools_ShapeMapHasher> DMapOfEdgeListOfTriangulationBool;
typedef NCollection_IndexedMap<Standard_Integer> IMapOfInteger;
typedef NCollection_IndexedMap<Standard_Real> IMapOfReal;

View File

@@ -1,82 +0,0 @@
// Created on: 2014-05-28
// Created by: Oleg AGASHIN
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_EdgeChecker_HeaderFile
#define _BRepMesh_EdgeChecker_HeaderFile
#include <Standard.hxx>
#include <Standard_Mutex.hxx>
#include <Poly_Triangulation.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Edge.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <BRep_Tool.hxx>
//! Auxilary class implementing functionality for checking consistency
//! of polygon on triangulation of the given edge.
class BRepMesh_EdgeChecker
{
public:
//! Constructor
//! @param theFaceTri Poly triangulation of face the edges relie to.
//! @param theFaceLoc Face location to be used to extract polygon on triangulation.
//! @param theMutex Upper level shared mutex to protect isFailed flag from concurrent write access.
//! @param isFailed Upper level shared flag indicating that polygon on triangulation of checked
//! edge is not consistent. If this flag is set to TRUE, other tasks will not check details of their data.
BRepMesh_EdgeChecker( Handle(Poly_Triangulation)& theFaceTri,
TopLoc_Location& theFaceLoc,
Standard_Mutex& theMutex,
Standard_Boolean& isFailed)
: myMutex(theMutex),
myIsFailed(isFailed),
myFaceLoc(theFaceLoc),
myFaceTri(theFaceTri)
{
}
//! Checker's body.
//! @param theEdge edge to be checked.
void operator ()(const TopoDS_Edge& theEdge) const
{
if (theEdge.IsNull() || myIsFailed)
return;
const Handle(Poly_PolygonOnTriangulation)& aPoly =
BRep_Tool::PolygonOnTriangulation(theEdge, myFaceTri, myFaceLoc);
if (!aPoly.IsNull())
return;
// Trianglulation stored inside a face is different
// than the one an edge data connected to.
Standard_Mutex::Sentry aSentry(myMutex);
myIsFailed = Standard_True;
}
private:
void operator =(const BRepMesh_EdgeChecker& /*theOther*/)
{
}
private:
Standard_Mutex& myMutex;
Standard_Boolean& myIsFailed;
TopLoc_Location& myFaceLoc;
Handle(Poly_Triangulation)& myFaceTri;
};
#endif

View File

@@ -97,7 +97,7 @@ BRepMesh_EdgeTessellator::BRepMesh_EdgeTessellator(
}
}
}
// PTv, chl/922/G9, Take into account internal vertices
// it is necessary for internal edges, which do not split other edges, by their vertex
TopExp_Explorer aVertexIt(theEdge, TopAbs_VERTEX);

View File

@@ -1,98 +0,0 @@
// Created on: 2014-05-28
// Created by: Oleg AGASHIN
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepMesh_FaceChecker_HeaderFile
#define _BRepMesh_FaceChecker_HeaderFile
#include <Standard.hxx>
#include <Standard_Mutex.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopLoc_Location.hxx>
#include <Poly_Triangulation.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepMesh_EdgeChecker.hxx>
#include <vector>
#ifdef HAVE_TBB
// paralleling using Intel TBB
#include <tbb/parallel_for_each.h>
#endif
//! Auxilary class implementing functionality for
//! checking consistency of triangulation on the given face.
class BRepMesh_FaceChecker
{
public:
//! Constructor
//! @param isInParallel Flag indicates that face edges should be checked in parallel.
BRepMesh_FaceChecker(const Standard_Boolean isInParallel)
: myIsFailed(Standard_False),
myIsInParallel(isInParallel)
{
}
//! Checker's body.
//! @param theFace Face to be checked.
void operator ()(const TopoDS_Face& theFace) const
{
if (theFace.IsNull() || myIsFailed)
return;
TopLoc_Location aFaceLoc;
Handle(Poly_Triangulation) aFaceT =
BRep_Tool::Triangulation(theFace, aFaceLoc);
if (aFaceT.IsNull())
return;
std::vector<TopoDS_Edge> aEdges;
TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
for ( ; aEdgeIt.More(); aEdgeIt.Next())
aEdges.push_back(TopoDS::Edge(aEdgeIt.Current()));
BRepMesh_EdgeChecker aEdgeChecker(aFaceT, aFaceLoc, myMutex, myIsFailed);
#ifdef HAVE_TBB
if (myIsInParallel)
{
// check faces in parallel threads using TBB
tbb::parallel_for_each(aEdges.begin(), aEdges.end(), aEdgeChecker);
}
else
{
#endif
for (std::vector<TopoDS_Edge>::iterator it(aEdges.begin()); it != aEdges.end(); it++)
aEdgeChecker(*it);
#ifdef HAVE_TBB
}
#endif
}
//! Returns status of the check.
Standard_Boolean IsValid() const
{
return !myIsFailed;
}
private:
mutable Standard_Mutex myMutex;
mutable Standard_Boolean myIsFailed;
Standard_Boolean myIsInParallel;
};
#endif

View File

@@ -19,7 +19,6 @@
#include <Precision.hxx>
#include <Standard_ErrorHandler.hxx>
#include <BRepMesh_FaceChecker.hxx>
#include <BRepMesh_ShapeTool.hxx>
#include <BRepMesh_Edge.hxx>
#include <BRepMesh_PluginMacro.hxx>
@@ -112,7 +111,7 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
//=======================================================================
void BRepMesh_IncrementalMesh::clear()
{
myEmptyEdges.Clear();
myEdges.Clear();
myEdgeDeflection.Clear();
myFaces.Clear();
myMesh.Nullify();
@@ -130,8 +129,7 @@ void BRepMesh_IncrementalMesh::init()
setDone();
clear();
if (!isCorrectPolyData())
BRepTools::Clean(myShape);
collectFaces();
Bnd_Box aBox;
BRepBndLib::Add(myShape, aBox, Standard_False);
@@ -150,35 +148,6 @@ void BRepMesh_IncrementalMesh::init()
myMesh->InitSharedFaces(myShape);
}
//=======================================================================
//function : isCorrectPolyData
//purpose :
//=======================================================================
Standard_Boolean BRepMesh_IncrementalMesh::isCorrectPolyData()
{
collectFaces();
BRepMesh_FaceChecker aFaceChecker(myInParallel);
#ifdef HAVE_TBB
if (myInParallel)
{
// check faces in parallel threads using TBB
tbb::parallel_for_each(myFaces.begin(), myFaces.end(), aFaceChecker);
}
else
{
#endif
NCollection_Vector<TopoDS_Face>::Iterator aFaceIt(myFaces);
for (; aFaceIt.More(); aFaceIt.Next())
aFaceChecker(aFaceIt.Value());
#ifdef HAVE_TBB
}
#endif
return aFaceChecker.IsValid();
}
//=======================================================================
//function : collectFaces
//purpose :
@@ -357,35 +326,46 @@ Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
//=======================================================================
void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge)
{
Standard_Integer aPolyIndex = 1;
if (!myEdges.IsBound(theEdge))
myEdges.Bind(theEdge, BRepMesh::DMapOfTriangulationBool());
Standard_Real aEdgeDeflection = edgeDeflection(theEdge);
Handle(Poly_PolygonOnTriangulation) aPolygon;
do
// Check that triangulation relies to face of the given shape.
const TopTools_IndexedDataMapOfShapeListOfShape& aMapOfSharedFaces =
myMesh->SharedFaces();
const TopTools_ListOfShape& aSharedFaces =
aMapOfSharedFaces.FindFromKey(theEdge);
TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces);
for (; aSharedFaceIt.More(); aSharedFaceIt.Next())
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation;
BRep_Tool::PolygonOnTriangulation(theEdge, aPolygon,
aTriangulation, aLoc, aPolyIndex++);
const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value());
const Handle(Poly_Triangulation)& aFaceTriangulation =
BRep_Tool::Triangulation(aFace, aLoc);
if (!aTriangulation.IsNull() && !aPolygon.IsNull())
if (aFaceTriangulation.IsNull())
continue;
Standard_Boolean isConsistent = Standard_False;
const Handle(Poly_PolygonOnTriangulation)& aPolygon =
BRep_Tool::PolygonOnTriangulation(theEdge, aFaceTriangulation, aLoc);
if (!aPolygon.IsNull())
{
if (aPolygon->Deflection() < 1.1 * aEdgeDeflection &&
aPolygon->HasParameters())
{
continue;
}
isConsistent = aPolygon->Deflection() < 1.1 * aEdgeDeflection &&
aPolygon->HasParameters();
myModified = Standard_True;
BRepMesh_ShapeTool::NullifyEdge(theEdge, aTriangulation, aLoc);
if (!isConsistent)
{
myModified = Standard_True;
BRepMesh_ShapeTool::NullifyEdge(theEdge, aFaceTriangulation, aLoc);
}
}
if (!myEmptyEdges.IsBound(theEdge))
myEmptyEdges.Bind(theEdge, BRepMesh::MapOfTriangulation());
if (!aTriangulation.IsNull())
myEmptyEdges(theEdge).Add(aTriangulation);
myEdges(theEdge).Bind(aFaceTriangulation, isConsistent);
}
while (!aPolygon.IsNull());
}
//=======================================================================
@@ -397,7 +377,7 @@ Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed(
const Standard_Boolean isWithCheck)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation =
const Handle(Poly_Triangulation)& aTriangulation =
BRep_Tool::Triangulation(theFace, aLoc);
if (aTriangulation.IsNull())
@@ -413,15 +393,33 @@ Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed(
for (; aEdgeIt.More() && isEdgesConsistent; aEdgeIt.Next())
{
const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
if (!myEmptyEdges.IsBound(aEdge))
if (!myEdges.IsBound(aEdge))
continue;
BRepMesh::MapOfTriangulation& aTriMap = myEmptyEdges(aEdge);
isEdgesConsistent &= !aTriMap.IsEmpty() && !aTriMap.Contains(aTriangulation);
BRepMesh::DMapOfTriangulationBool& aTriMap = myEdges(aEdge);
isEdgesConsistent &= aTriMap.IsBound(aTriangulation) &&
aTriMap(aTriangulation);
}
if (isEdgesConsistent)
return Standard_False;
{
// #25080: check that indices of links forming triangles are in range.
Standard_Boolean isTriangulationConsistent = Standard_True;
const Standard_Integer aNodesNb = aTriangulation->NbNodes();
const Poly_Array1OfTriangle& aTriangles = aTriangulation->Triangles();
Standard_Integer i = aTriangles.Lower();
for (; i <= aTriangles.Upper() && isTriangulationConsistent; ++i)
{
const Poly_Triangle& aTriangle = aTriangles(i);
Standard_Integer n[3];
aTriangle.Get(n[0], n[1], n[2]);
for (Standard_Integer j = 0; j < 3 && isTriangulationConsistent; ++j)
isTriangulationConsistent = (n[j] >= 1 && n[j] <= aNodesNb);
}
if (isTriangulationConsistent)
return Standard_False;
}
}
}
@@ -514,7 +512,7 @@ void BRepMesh_IncrementalMesh::commitEdges(const TopoDS_Face& theFace)
return;
}
TopLoc_Location aLoc = aFace.Location();
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
if (aTriangulation.IsNull())

View File

@@ -132,13 +132,6 @@ protected:
private:
//! Checks is the shape to be meshed has correct poly data,
//! i.e. PolygonOnTriangulation of particular edge connected
//! to the same Triangulation data structure as stored inside
//! a parent face.
//! @return TRUE on success, FALSE in case of inconsistencies.
Standard_Boolean isCorrectPolyData();
//! Builds the incremental mesh for the shape.
void update();
@@ -191,15 +184,15 @@ private:
protected:
Standard_Boolean myRelative;
Standard_Boolean myInParallel;
BRepMesh::DMapOfEdgeListOfTriangulation myEmptyEdges;
Handle(BRepMesh_FastDiscret) myMesh;
Standard_Boolean myModified;
TopTools_DataMapOfShapeReal myEdgeDeflection;
Standard_Real myMaxShapeSize;
Standard_Integer myStatus;
NCollection_Vector<TopoDS_Face> myFaces;
Standard_Boolean myRelative;
Standard_Boolean myInParallel;
BRepMesh::DMapOfEdgeListOfTriangulationBool myEdges;
Handle(BRepMesh_FastDiscret) myMesh;
Standard_Boolean myModified;
TopTools_DataMapOfShapeReal myEdgeDeflection;
Standard_Real myMaxShapeSize;
Standard_Integer myStatus;
NCollection_Vector<TopoDS_Face> myFaces;
};
DEFINE_STANDARD_HANDLE(BRepMesh_IncrementalMesh,BRepMesh_DiscretRoot)

View File

@@ -59,6 +59,47 @@ BRepMesh_WireInterferenceChecker::BRepMesh_WireInterferenceChecker(
}
#endif
bool ArePointsOnDifferentSides(const gp_Pnt2d & point1, const gp_Pnt2d & point2, const BRepMesh::Segment & segment1, const BRepMesh::Segment & segment2)
{
return 0 > (((segment1.EndPnt.X()-segment1.StartPnt.X())*(point1.Y()-segment1.StartPnt.Y())-(point1.X()-segment1.StartPnt.X())*(segment1.EndPnt.Y()-segment1.StartPnt.Y())) *
((segment2.EndPnt.X()-segment2.StartPnt.X())*(point2.Y()-segment2.StartPnt.Y())-(point2.X()-segment2.StartPnt.X())*(segment2.EndPnt.Y()-segment2.StartPnt.Y())));
}
const BRepMesh::Segment& GetSegmentFromArray(Standard_Integer idx, const BRepMesh::HArray1OfSegments& segsarray)
{
if (idx < segsarray->Lower())
{
idx = segsarray->Upper();
}
if (idx > segsarray->Upper())
{
idx = segsarray->Lower();
}
return segsarray->Value(idx);
}
bool CheckSelftIntersectArea(Standard_Integer idx1, Standard_Integer idx2, const BRepMesh::HArray1OfSegments& segsarray, const gp_Pnt2d & intPnt)
{
gp_XY aPrevVec;
Standard_Real aSumS = 0.;
const gp_XY& aRefPnt = intPnt.Coord();
for (Standard_Integer i = idx1; i < idx2; ++i)
{
const BRepMesh::Segment& aSeg = segsarray->Value(i);
gp_XY aCurVec = aSeg.EndPnt - aRefPnt;
if (aCurVec.SquareModulus() < gp::Resolution())
continue;
if (aPrevVec.SquareModulus() > gp::Resolution())
aSumS += aPrevVec ^ aCurVec;
aPrevVec = aCurVec;
}
return (Abs(aSumS / 2.) < MIN_LOOP_S);
}
//=======================================================================
//function : Checker's body
//purpose :
@@ -125,33 +166,15 @@ void BRepMesh_WireInterferenceChecker::operator ()(
BRepMesh_GeomTool::IntFlag aIntStatus = BRepMesh_GeomTool::IntSegSeg(
aSegment1.StartPnt, aSegment1.EndPnt,
aSegment2.StartPnt, aSegment2.EndPnt,
Standard_False, Standard_False,
Standard_True, Standard_True,
aIntPnt);
if (aIntStatus == BRepMesh_GeomTool::Cross)
if (aIntStatus == BRepMesh_GeomTool::Cross || aIntStatus == BRepMesh_GeomTool::Glued || aIntStatus == BRepMesh_GeomTool::PointOnSegment)
{
// TODO: remove this block after implementation of LoopChecker2d.
if (isSelfIntCheck)
if (isSelfIntCheck && CheckSelftIntersectArea(aSegmentId1, aSegmentId2, aWireSegments1, aIntPnt))
{
gp_XY aPrevVec;
Standard_Real aSumS = 0.;
const gp_XY& aRefPnt = aIntPnt.Coord();
for (Standard_Integer i = aSegmentId1; i < aSegmentId2; ++i)
{
const BRepMesh::Segment& aSeg = aWireSegments1->Value(i);
gp_XY aCurVec = aSeg.EndPnt - aRefPnt;
if (aCurVec.SquareModulus() < gp::Resolution())
continue;
if (aPrevVec.SquareModulus() > gp::Resolution())
aSumS += aPrevVec ^ aCurVec;
aPrevVec = aCurVec;
}
if (Abs(aSumS / 2.) < MIN_LOOP_S)
continue;
continue;
}
#ifdef HAVE_TBB
@@ -160,6 +183,45 @@ void BRepMesh_WireInterferenceChecker::operator ()(
*myStatus = BRepMesh_SelfIntersectingWire;
return;
}
if (aIntStatus == BRepMesh_GeomTool::EndPointTouch && (!isSelfIntCheck || abs(aSegmentId1 - aSegmentId2) > 2))
{
bool segmentsAreEqual = false;
gp_Pnt2d otherPnt1;
gp_Pnt2d otherPnt2;
const BRepMesh::Segment * refSegment1 = &aSegment2;
const BRepMesh::Segment * refSegment2 = NULL;
Standard_Boolean s1s2 = aSegment1.StartPnt.IsEqual(aSegment2.StartPnt, Precision::PConfusion());
Standard_Boolean s1e2 = aSegment1.StartPnt.IsEqual(aSegment2.EndPnt, Precision::PConfusion());
Standard_Boolean e1e2 = aSegment1.EndPnt.IsEqual(aSegment2.EndPnt, Precision::PConfusion());
Standard_Boolean e1s2 = aSegment1.EndPnt.IsEqual(aSegment2.StartPnt, Precision::PConfusion());
if ((s1s2 && e1e2) || (s1e2 && e1s2))
{
segmentsAreEqual = true;
}
else
{
otherPnt1 = (s1s2 || s1e2)? aSegment1.EndPnt : aSegment1.StartPnt;
otherPnt2 = GetSegmentFromArray(aSegmentId1 + ((s1s2 || s1e2)? -1 : 1), aWireSegments1).StartPnt;
refSegment2 = &(GetSegmentFromArray(aSegmentId2 + ((s1s2 || e1s2)? -1 : 1), aWireSegments2));
}
if (!segmentsAreEqual && NULL != refSegment1 && NULL != refSegment2 && ArePointsOnDifferentSides(otherPnt1, otherPnt2, *refSegment1, *refSegment2))
{
if (isSelfIntCheck && CheckSelftIntersectArea(aSegmentId1, aSegmentId2, aWireSegments1, aIntPnt))
{
continue;
}
#ifdef HAVE_TBB
Standard_Mutex::Sentry aSentry(myMutex);
#endif
*myStatus = BRepMesh_SelfIntersectingWire;
return;
}
}
}
}
}

View File

@@ -33,8 +33,6 @@ BRepMesh_PairOfIndex.hxx
BRepMesh_Status.hxx
BRepMesh_CMPLRS.edl
BRepMesh_VertexInspector.hxx
BRepMesh_EdgeChecker.hxx
BRepMesh_FaceChecker.hxx
BRepMesh_SelectorOfDataStructureOfDelaun.hxx
BRepMesh_SelectorOfDataStructureOfDelaun.cxx
BRepMesh_EdgeParameterProvider.hxx

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