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

Compare commits

..

33 Commits

Author SHA1 Message Date
aln
a28be1eb2a Fixed errors 2022-06-30 00:22:19 +03:00
aln
835f8451ac Fixed memleak and va_end_missing issues 2022-06-28 17:03:14 +03:00
azv
63fa56bc83 0032915: Geom2dAPI_InterCurveCurve, The algorithm lost an intersection point.
Get rid of strange code: preliminary check of self-intersections is made on a polygonal representation of a curve, it is able to find possible intersections, but after that it filter out segments neighbor to the pair of non-intersected segments.

Test case de step_4 I1 has been marked BAD, because the self-intersection is treated correctly, but the projection algorithm generates such crooked 2D curve.

Reference data in test cases heal split_angle_advanced ZA5 and ZA6 has been updated, because those shapes have self-intersected edges, which are being detected now.
2022-06-23 20:40:07 +03:00
mgerus
a29bae45f9 0032877: Modeling algorithms - Sweeping issue
Add fix at sweeping algorithm: sweeping happens in the opposite direction as expected
Add test case tests/bugs/modalg_7/bug32877
2022-06-23 20:37:37 +03:00
atychini
6d1a049be7 0032821: DEWrapper - Implementation of a common toolkit for importing and exporting CAD files
Implementing DE_Wrapper and its formats
2022-06-23 20:29:00 +03:00
aml
b1970c8a47 0033022: Coding - get rid of unused headers [ShapeBuild to STEPControl] 2022-06-22 19:26:41 +03:00
mpv
f8c45c2f0d 0032894: Application Framework - Regressions on Ubuntu 20.04
Updated corrupted file reading error management, make memory unit-tests more stable.
2022-06-20 17:45:27 +03:00
aml
94748ad20e 0032653: Modeling Data - misprint in Geom2d_Conic.hxx api SetYAxis(const gp_Ax2d& theAY)
Fix misprint.
2022-06-17 19:28:07 +03:00
aml
2e0b684df3 0033019: Coding - get rid of unused classes 2022-06-15 20:46:16 +03:00
aml
a1f027b66e 0033018: Coding - get rid of unused headers [Plugin to ShapeAnalysis] 2022-06-15 20:41:12 +03:00
kgv
88ff1a3834 0033016: Documentation - Draw Harness User Guide mentions removed commands 'meshdispmode'
Updated description of MeshVS commands in User's Guide.
2022-06-14 21:52:44 +03:00
akondrat
fb30026cf1 0033009: Foundation Classes - Bnd_OBB::ReBuild() expects point array starting from 0
Add test. Update OBBTool constructor for any bounds of array of points.
2022-06-14 21:50:31 +03:00
snn
714fb6b516 0032954: Tool for applying transformation to OCAF document
New XCAFDoc classes:
- XCAFDoc_AssemblyIterator: iterator in depth along the assembly tree
- XCAFDoc_AssemblyGraph: assembly graph with iterator
- XCAFDoc_AssemblyTool: provides generic methods for traversing assembly tree and graph

A method for re-scaling (sub-)assembly geometry is added to XCAFDoc_Editor.

New DRAW commands:
- XDumpAssemblyTree: iterates through the assembly tree in depth up to the specified level, if any
- XDumpAssemblyGraph: prints assembly graph structure
- XDumpNomenclature: prints number of (sub-)assembly/part instances
- XRescaleGeometry: applies geometrical scale to (sub-)assembly
2022-06-10 18:56:40 +03:00
aml
bf8b7e08f1 0030492: Foundation Classes - math_BFGS fails if starting point is exactly the minimum
Fix affects BFGS optimization methods by checking convergence as the first step on each iteration. FRPR works well, but it is updated as well since its logic potentially dangerous.
2022-06-09 20:34:57 +03:00
Charlemagne Lasse
24e4b3c83b 0032929: Modeling Algorithms - Crash in PerformIntersectionAtEnd after deletion of surfdata
When creating a fillet, num is calculated via ChFi3d_IndexOfSurfData. If it
returns just the number of entries in surfdata, it can happen that this
value becomes invalid when handling the case "two faces common to the edge
are found". When both components are on an arc, there will be num removed
from the surfdata.

num would then be larger than the number of entries surfdata. The derived
num1 is therefore also incorrect. The subsequent usage of this
value will either:

* Debug build: cause an out of bounds exception in ChangeValue
  (`SeqFil.ChangeValue(num)`)
* Release build: cause a segfault when retrieving it via index num1
  (`SeqFil(num1)`)

num + num1 must be recalculated after the deletion happens to correctly
calculate the fillet.

Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
2022-06-03 17:51:01 +03:00
Charlemagne Lasse
10a19b2a75 0032930: Modeling Algorithms - Crash in PerformIntersectionAtEnd when no face was found
The PerformIntersectionAtEnd code is currently not handling all the faces
correctly. If it retrieves Face[0] as F, it can happen that the previously
ran code didn't actually retrieve any faces in this array at all.

For example when:

* "if (nface==3)" is true
  - "if (!findonf1)" is true (doesn't assign any faces to this array)
  - "if (!findonf2)" is true (doesn't assign any faces to this array)
  - "if (state == ChFiDS_OnSame)" is not true (because it is
    ChFiDS_AllSame)
  - "if (findonf1 && !isOnSame1)" cannot be true (see above, but would
    handle faces)
  - "if (findonf2 && !isOnSame2)" cannot be true (see above, but would
    handle faces)
  - "if (isOnSame2)" is false (but would also handle faces)

Since no faces were assigned here, F would be a NULL face. As result, the
function will crash when trying to access the Surface behind the face via
`BRep_Tool::Surface(F);`.

While the best approach would be to identify the implementation bug in the
algorithm behind PerformIntersectionAtEnd, a check + exception is used
instead because the actual algorithm is not known.

Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
2022-06-03 17:48:22 +03:00
Charlemagne Lasse
d30f25e6b1 0032931: Modeling Algorithms - Crash in ChFi3d_IsInFront when no face was found
The ChFi3d_IsInFront code is currently not handling all the combinations
correctly. For example, if `if(fd1->IndexOfS2() == fd2->IndexOfS2())` is
true, it can happen that the `TopoDS::Face(DStr.Shape(fd1->Index(jf1)))`
returns a Face with entity == NULL. The subsequent usage of this NULL face
in `BRep_Tool::Parameters( Vtx, face )` will then cause a segfault.

While the best approach would be to identify the implementation bug in the
algorithm behind PChFi3d_IsInFron, a check + exception is used instead
because the actual algorithm is not known.

Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
2022-06-03 17:46:28 +03:00
snn
cec41bb93d 0030024: Data Exchange - STEP, IGES export support of BRep shapes based on tessellated geometry
Support of reading and writing tessellated geometry is added for the following STEP entities:
- triangulated face
- complex triangulated face
- tessellated shell
- tessellated solid
- tessellated shape representation

Models without BRep geometry (mesh formats like STL, OBJ and so on) are supported for writing to STEP.

New parameters are added to enable/disable tessellated geometry reading and writing:
- read.step.tessellated (On/Off/OnNoBRep) (On by default)
- write.step.tessellated (On/Off/OnNoBRep) (OnNoBRep by default)

OnNoBRep - tessellation is read/written only for entities for which there is no BRep representation.

Faces with poly triangulation are written in STEP as triangulated face entities with one coordinates list per face.
Only one poly triangulation per face (returned by BRep_Tool::Triangulation) is written to STEP.
2022-06-03 17:44:17 +03:00
kgv
e9c43fee29 0032989: Data Exchange, RWGltf_CafReader - fill in metadata map from asset.extras 2022-05-31 19:26:25 +03:00
kgv
812afe4edb 0032991: Visualization, TKOpenGl - OpenGl_Window::Resize() ignores window virtual flag on macOS
Added handling of Aspect_Window::IsVirtual() flag on macOS platform.
2022-05-30 20:47:07 +03:00
kgv
48e4aad412 0032990: Configuration - compilation errors since Emscripten 3.1.11 due to time_t redefined long->int
Add std::is_same filter to IsEqual(time_t, time_t) definition.
2022-05-29 12:11:24 +03:00
afokin
23c56fc66a 0032974: Configuration - update environment for VS2022
removing a repeating condition in install.bat

add vc143 in .md files
2022-05-27 19:05:24 +03:00
akaftasev
795c0d5d73 0032447: BRepOffsetAPI_MakePipeShell result in inaccurate shape when using -DT mode and DT_ShapeDivide on the spine
Added new option '-C' with possibility to set value of Angular and linear tolerances to 'mksweep' command to correct input spine by merging smooth connected neighboring edges
2022-05-27 18:21:34 +03:00
akaftasev
fbf9efb8d5 0025309: Modeling Algorithms - Check of shape validity for BOP takes too long
Simplified condition to allow sampling for curve/surface data with depth == 0
Changed sorting method in MergeSolutions() method
2022-05-27 18:14:04 +03:00
atereshi
9b9aac4a7b 0032922: Data Exchange, STEP - The torus is stored incorrectly in STEP format
Problem: the complete surface of the torus is not stored correctly in STEP format due to the fact that the edges are not properly ordered.
Change: added a mode for reordering edges in the wire with simultaneous use of 2d and 3d information (ShapeAnalysis_WireOrder). The new mode is used for torus-like surfaces before saving to STEP format.
 Result: Torus correctly stored.
2022-05-27 18:14:03 +03:00
kgv
86d6c284c2 0032978: Visualization - AIS_ViewController::PickPoint() includes objects invisible in current View
SelectMgr_ViewerSelector::TraverseSensitives() now takes into account object's view affinity.
AIS_InteractiveContext::moveTo() - dropped code SelectMgr_AndOrFilter::SetDisabledObjects()
as filtering is now done by selector itself.

ViewAffinity property has been moved to PrsMgr_PresentableObject for simplicity.
Removed redundant map Graphic3d_CView::HiddenObjects().
2022-05-21 17:25:43 +03:00
ifv
84d39c06fa 0032973: Modeling Algorithms - Regression in BRepExtrema_DistShapeShape compared with 7.5
BRepExtrema/BRepExtrema_ExtCF.cxx - set correct using BRepAdaptor_Curve in Extrema
tests/bugs/modalg_8/bug32973 - new test case added
2022-05-18 19:18:52 +03:00
mgerus
df69c26472 0026697: BRepFeat_MakePrism returns empty compound
Add fix in direction of prism calculation
2022-05-18 19:14:43 +03:00
kgv
b56df3a60a 0032976: Visualization - AIS_InteractiveContext::FitSelected() includes objects invisible in current View 2022-05-17 20:15:55 +03:00
kgv
dcbd679c8b 0032975: Visualization, TKOpenGl - do not blit inactive Subview 2022-05-17 20:13:42 +03:00
aml
b9280b8b27 0032969: Coding - get rid of unused headers [IMeshData to PLib]
Removed unused exception classes OSD_Exception_FLT_DIVIDE_BY_ZERO, OSD_Exception_INT_DIVIDE_BY_ZERO, OSD_Exception_FLT_DENORMAL_OPERAND, OSD_Exception_FLT_INEXACT_RESULT, OSD_Exception_FLT_INVALID_OPERATION, OSD_Exception_FLT_OVERFLOW, OSD_Exception_FLT_STACK_CHECK, OSD_Exception_FLT_UNDERFLOW.
2022-05-17 20:09:12 +03:00
mgerus
2052b04e5b 0032807: Modeling Algorithms - Bad result of sweep operation when the UEdges has more than one intersect points
Add choosing the intersect point taking into account the tangentCross when prev UEdge and next UEdge has more than one intersect points;
Add exact correction of edge tolerance (it fix problems with edge tolerance on Linux);
Add exact check of edge tolerance in testcase
2022-05-16 21:08:21 +03:00
kgv
6036998511 0032970: Visualization, TKOpenGl - fix compilation on Linux: 'False' was not declared 2022-05-15 01:11:06 +03:00
2274 changed files with 27120 additions and 7600 deletions

View File

@@ -3,5 +3,5 @@ ModelingData TKG2d TKG3d TKGeomBase TKBRep
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF
DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh
DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade
Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE

View File

@@ -384,6 +384,8 @@ t TKSTEPBase
t TKSTL
t TKVRML
t TKXCAF
t TKXDE
t TKXDECascade
t TKXDEIGES
t TKXDESTEP
t TKXSBase
@@ -394,6 +396,9 @@ n DBRep
n DDF
n DDataStd
n DDocStd
n DE
n DEXCAFCascade
n DEBRepCascade
n DNaming
n DPrsStd
n Draw

View File

@@ -119,6 +119,8 @@ android-g++ {
# VS2015, vc141
} else:equals(aMsvcVer, 16.0){
# VS2019, vc142
} else:equals(aMsvcVer, 17.0){
# VS2022, vc143
} else {
warning (Unknown msvc version. "$$MY_COMPILER" is used)
}

View File

@@ -23,6 +23,8 @@ if "%VCVER%" == "vc8" (
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc142" (
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc143" (
call "%VS143COMNTOOLS%/vsvars32.bat" > nul
) else (
echo Error: wrong VS identifier
exit /B

View File

@@ -74,6 +74,10 @@ if not "%DevEnvDir%" == "" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "vc143" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[17.0,17.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
@@ -107,6 +111,11 @@ if /I "%VCFMT%" == "vc9" (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=v142"
) else if /I "%VCFMT%" == "vc143" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[17.0,17.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=v142"
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
@@ -126,6 +135,7 @@ if ["%ARCH%"] == ["64"] set VCARCH=amd64
if /I ["%1"] == ["vc141"] set "VCVER=vc14"
if /I ["%1"] == ["vc142"] set "VCVER=vc14"
if /I ["%1"] == ["vc143"] set "VCVER=vc14"
if exist "%CASROOT%\custom.bat" (
call "%CASROOT%\custom.bat" %VCVER% %ARCH% %CASDEB%

View File

@@ -7,6 +7,7 @@ if exist "%~dp0custom.bat" (
call "@INSTALL_DIR_ABSOLUTE@\@INSTALL_DIR_SCRIPT@\env.bat" %1 %2 %3
if /I ["%1"] == ["vc141"] set "VCVER=vc141"
if /I ["%1"] == ["vc142"] set "VCVER=vc142"
if /I ["%1"] == ["vc143"] set "VCVER=vc143"
set "BIN_DIR=win%ARCH%\%VCVER%\bind"
set "LIB_DIR=win%ARCH%\%VCVER%\libd"

View File

@@ -23,6 +23,8 @@ if "%VCVER%" == "vc8" (
call "%VS141COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc142" (
call "%VS142COMNTOOLS%/vsvars32.bat" > nul
) else if "%VCVER%" == "vc143" (
call "%VS143COMNTOOLS%/vsvars32.bat" > nul
) else (
echo Error: wrong VS identifier
exit /B

View File

@@ -324,6 +324,7 @@ The environment is defined in the file *custom.sh* (on Linux and macOS) or *cust
| vc141-uwp | 2017 (15) | UWP (Universal Windows Platform) | vc14-uwp |
| vc142 | 2019 (16) | Desktop (Windows API) | vc14 |
| vc142-uwp | 2019 (16) | UWP (Universal Windows Platform) | vc14-uwp |
| vc143 | 2022 (17) | Desktop (Windows API) | vc14 |
Alternatively, you can launch **genconf**, a GUI tool allowing to configure build options interactively.
That tool will analyze your environment and propose you to choose available options:

View File

@@ -462,7 +462,7 @@ To run any Open CASCADE Technology application you need to set the environment v
You can define the environment variables with env.bat script located in the
$CASROOT folder. This script accepts two arguments to be used:
the version of Visual Studio (vc12 -- vc142) and the architecture (win32 or win64).
the version of Visual Studio (vc12 -- vc143) and the architecture (win32 or win64).
The additional environment settings necessary for compiling OCCT libraries and samples
by Microsoft Visual Studio can be set using script custom.bat located in the same folder.

View File

@@ -2044,43 +2044,47 @@ Creates a *MeshVS_Mesh* object based on STL file data. The object will be displa
meshfromstl mesh myfile.stl
~~~~
@subsubsection occt_draw_4_5_2 meshdispmode
@subsubsection occt_draw_4_5_2 vsetdispmode
Syntax:
~~~~{.php}
meshdispmode meshname displaymode
vsetdispmode meshname displaymode
~~~~
Changes the display mode of object **meshname**. The **displaymode** is integer, which can be:
* *1* for *wireframe*,
Changes the display mode of object **meshname**. The **displaymode** is integer (`MeshVS_DisplayModeFlags`), which can be:
* *1* for *wireframe*,
* *2* for *shading* mode, or
* *3* for *shrink* mode.
* *3* for *shrink* mode.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshdispmode mesh 2
vinit
meshfromstl mesh myfile.stl
vsetdispmode mesh 2
~~~~
@subsubsection occt_draw_4_5_3 meshselmode
@subsubsection occt_draw_4_5_3 vselmode
Syntax:
~~~~{.php}
meshselmode meshname selectionmode
vselmode meshname selectionmode {on|off}
~~~~
Changes the selection mode of object **meshname**. The *selectionmode* is integer OR-combination of mode flags. The basic flags are the following:
Changes the selection mode of object **meshname**.
The *selectionmode* is integer OR-combination of mode flags (`MeshVS_SelectionModeFlags`). The basic flags are the following:
* *0* -- selection of mesh as whole;
* *1* -- node selection;
* *2* -- 0D elements (not supported in STL);
* *4* -- links (not supported in STL);
* *8* -- faces.
**Example:**
* *2* -- 0D elements (not supported in STL);
* *4* -- links (not supported in STL);
* *8* -- faces;
* *16* -- volumes (not supported in STL);
* *256* -- groups (not supported in STL).
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshselmode mesh 1
vinit
meshfromstl mesh myfile.stl
vselmode mesh 1
~~~~
@subsubsection occt_draw_4_5_4 meshshadcolor
@@ -2091,11 +2095,11 @@ meshshadcolor meshname red green blue
~~~~
Changes the face interior color of object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
vinit
meshfromstl mesh myfile.stl
meshshadcolormode mesh 0.5 0.5 0.5
~~~~
@@ -2107,11 +2111,11 @@ meshlinkcolor meshname red green blue
~~~~
Changes the color of face borders for object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
vinit
meshfromstl mesh myfile.stl
meshlinkcolormode mesh 0.5 0.5 0.5
~~~~
@@ -2119,39 +2123,37 @@ meshlinkcolormode mesh 0.5 0.5 0.5
Syntax:
~~~~{.php}
meshmat meshname material
meshmat meshname material [transparency]
~~~~
Changes the material of object **meshname**.
*material* is represented with an integer value as follows (equivalent to enumeration *Graphic3d_NameOfMaterial*):
* *0 -- BRASS,*
* *1 -- BRONZE,*
* *2 -- COPPER,*
* *3 -- GOLD,*
* *4 -- PEWTER,*
* *5 -- PLASTER,*
* *6 -- PLASTIC,*
* *7 -- SILVER,*
* *8 -- STEEL,*
* *9 -- STONE,*
* *10 -- SHINY_PLASTIC,*
* *11 -- SATIN,*
* *12 -- METALIZED,*
* *13 -- NEON_GNC,*
* *14 -- CHROME,*
* *15 -- ALUMINIUM,*
* *16 -- OBSIDIAN,*
* *17 -- NEON_PHC,*
* *18 -- JADE,*
* *19 -- DEFAULT,*
* *20 -- UserDefined*
*material* is represented with an integer value as follows (equivalent to enumeration *Graphic3d_NameOfMaterial*):
* *0 -- BRASS*,
* *1 -- BRONZE*,
* *2 -- COPPER*,
* *3 -- GOLD*,
* *4 -- PEWTER*,
* *5 -- PLASTER*,
* *6 -- PLASTIC*,
* *7 -- SILVER*,
* *8 -- STEEL*,
* *9 -- STONE*,
* *10 -- SHINY_PLASTIC*,
* *11 -- SATIN*,
* *12 -- METALIZED*,
* *13 -- NEON_GNC*,
* *14 -- CHROME*,
* *15 -- ALUMINIUM*,
* *16 -- OBSIDIAN*,
* *17 -- NEON_PHC*,
* *18 -- JADE*.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshmat mesh JADE
vinit
meshfromstl mesh myfile.stl
meshmat mesh 18
~~~~
@subsubsection occt_draw_4_5_7 meshshrcoef
@@ -2161,12 +2163,14 @@ Syntax:
meshshrcoef meshname shrinkcoefficient
~~~~
Changes the value of shrink coefficient used in the shrink mode. In the shrink mode the face is shown as a congruent part of a usual face, so that *shrinkcoefficient* controls the value of this part. The *shrinkcoefficient* is a positive real number.
**Example:**
Changes the value of shrink coefficient used in the shrink mode.
In the shrink mode the face is shown as a congruent part of a usual face, so that *shrinkcoefficient* controls the value of this part.
The *shrinkcoefficient* is a positive real number.
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
vinit
meshfromstl mesh myfile.stl
meshshrcoef mesh 0.05
~~~~
@@ -2178,11 +2182,12 @@ meshshow meshname
~~~~
Displays **meshname** in the viewer (if it is erased).
The same as calling `vdisplay`.
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
vinit
meshfromstl mesh myfile.stl
meshshow mesh
~~~~
@@ -2193,12 +2198,13 @@ Syntax:
meshhide meshname
~~~~
Hides **meshname** in the viewer.
Hides **meshname** in the viewer.
The same as calling `verase`.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
vinit
meshfromstl mesh myfile.stl
meshhide mesh
~~~~
@@ -2209,7 +2215,7 @@ Syntax:
meshhidesel meshname
~~~~
Hides only selected entities. The other part of **meshname** remains visible.
Hides only selected entities. The other part of **meshname** remains visible.
@subsubsection occt_draw_4_5_11 meshshowsel
@@ -2218,7 +2224,7 @@ Syntax:
meshshowsel meshname
~~~~
Shows only selected entities. The other part of **meshname** becomes invisible.
Shows only selected entities. The other part of **meshname** becomes invisible.
@subsubsection occt_draw_4_5_12 meshshowall
@@ -2227,22 +2233,22 @@ Syntax:
meshshowall meshname
~~~~
Changes the state of all entities to visible for **meshname**.
Changes the state of all entities to visible for **meshname**.
@subsubsection occt_draw_4_5_13 meshdelete
@subsubsection occt_draw_4_5_13 vremove
Syntax:
~~~~{.php}
meshdelete meshname
vremove meshname
~~~~
Deletes MeshVS_Mesh object **meshname**.
Deletes MeshVS_Mesh object **meshname**.
**Example:**
**Example:**
~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshdelete mesh
vinit
meshfromstl mesh myfile.stl
vremove mesh
~~~~
@subsection occt_draw_4_6 VIS Viewer commands

View File

@@ -94,6 +94,7 @@ The types of STEP representation entities that are recognized are:
* geometrically_bounded_wireframe_shape_representation
* geometrically_bounded_surface_shape_representation
* hybrid representations (shape_representation containing models of different type)
* tessellated_shape_representation
@subsubsection occt_step_2_2_3 Topological entities
The types of STEP topological entities that can be translated are:
@@ -112,6 +113,7 @@ The types of STEP geometrical entities that can be translated are:
* directions
* curves
* surfaces
* triangulations
For further information see 2.4 Mapping STEP entities to Open CASCADE Technology shapes.
@@ -337,7 +339,7 @@ Specifies preferred type of representation of the shape of the product, in case
* 4 (GBSSR) -- Prefer GEOMETRICALLY_BOUNDED_SURFACE_SHAPE_REPRESENTATION
* 5 (FBSR) -- Prefer FACETTED_BREP_SHAPE_REPRESENTATION
* 6 (EBWSR) -- Prefer EDGE_BASED_WIREFRAME_SHAPE_REPRESENTATION
* 7 (GBWSR) -- Prefer GEOMETRICALLY_BOUNDED_WIREFRAME _SHAPE_REPRESENTATION
* 7 (GBWSR) -- Prefer GEOMETRICALLY_BOUNDED_WIREFRAME_SHAPE_REPRESENTATION
When this option is not equal to 1, for products with multiple representations the representation having a type closest to the selected one in this list will be translated.
@@ -447,6 +449,34 @@ of for each of the two "AXIS2_PLACEMENT_3D" entities referenced by it. as follow
}
~~~~
<h4>read.step.tessellated:</h4>
Boolean flag regulating translation of entities that define tessellated geometry:
* TESSELLATED_SHAPE_REPRESENTATION
* TESSELLATED_SHELL
* TESSELLATED_SOLID
* TRIANGULATED_FACE
* COMPLEX_TRIANGULATED_FACE
Tesselated geometry is attached to shapes as objects of <i>Poly_Triangulation</i> type using STEP links.
* 0 (Off) -- do not translate
* 1 (On) -- translate
* 2 (OnNoBRep) - tessellation is read only for entities for which there is no BRep representation
Read this parameter with:
~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.tessellated");
~~~~
Modify this parameter with:
~~~~{.cpp}
if(!Interface_Static::SetIVal("read.step.tessellated",1))
.. error ..
~~~~
Default value is 0 (On).
@subsubsection occt_step_2_3_4 Performing the STEP file translation
Perform the translation according to what you want to translate. You can choose either root entities (all or selected by the number of root), or select any entity by its number in the STEP file. There is a limited set of types of entities that can be used as starting entities for translation. Only the following entities are recognized as transferable:
@@ -464,6 +494,11 @@ Perform the translation according to what you want to translate. You can choose
* subtypes of face_surface (including advanced_face)
* subtypes of shape_representation_relationship
* context_dependent_shape_representation
* tessellated_shape_representation
* tessellated_shell
* tessellated_solid
* triangulated_face
* complex_triangulated_face
The following methods are used for translation:
@@ -683,6 +718,10 @@ Not all entities defining the assembly structure in the STEP file are translated
| | quasi_uniform_surface | Geom_BSplineSurface | |
| | rectangular_composite_surface | TopoDS_Compound | Contains *TopoDS_Faces* |
| | curve_bounded_surface | TopoDS_Face | |
| Tessellations | tessellated_shell | TopoDS_Shell | |
| | tessellated_solid | TopoDS_Solid | |
| | triangulated_face | TopoDS_Face | Contains *Poly_Triangulation* |
| | complex_triangulated_face | TopoDS_Face | Contains *Poly_Triangulation* |
@subsection occt_step_2_5 Tolerance management
@@ -745,6 +784,7 @@ The following default tolerances are used when creating shapes and how they are
* *StepToTopoDS_TranslatePolyLoop* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *StepToTopoDS_TranslateEdge*. Their tolerances are not modified inside this method.
* *StepToTopoDS_TranslateFace* constructs *TopoDS_Face* with the initial value of tolerance. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of classes *StepToTopoDS_TranslatePolyLoop, StepToTopoDS_TranslateEdgeLoop* or *StepToTopoDS_TranslateVertexLoop*.
* *StepToTopoDS_TranslateShell* calls *StepToTopoDS_TranslateFace::Init* for each face. This class does not modify the tolerance value.
* *StepToTopoDS_TranslateSolid* calls *StepToTopoDS_TranslateFace::Init* for each face. This class does not modify the tolerance value.
* *StepToTopoDS_TranslateCompositeCurve* constructs *TopoDS_Edges* in *TopoDS_Wire* with help of class *BRepAPI_MakeEdge* and have a tolerance 10-7. Pcurves from a STEP file are translated if they are present and if *read.surfacecurve.mode* is not -3. The connection between segments of a composite curve (edges in the wire) is provided by calling method *ShapeFix_Wire::FixConnected()\** with a precision equal to the initial value of tolerance.
* *StepToTopoDS_TranslateCurveBoundedSurface* constructs *TopoDS_Face* with tolerance *Precision::Confusion()*. *TopoDS_Wire* on *TopoDS_Face* is constructed with the help of class *StepToTopoDS_TranslateCompositeCurve*. Missing pcurves are computed using projection algorithm with the help of method *ShapeFix_Face::FixPcurves()*. For resulting face method *ShapeFix::SameParameter()* is called. It calls standard *BRepLib::SameParameter* for each edge in each wire, which can either increase or decrease the tolerances of the edges and vertices. *SameParameter* writes the tolerance corresponding to the real deviation of pcurves from 3D curve which can be less or greater than the tolerance in a STEP file.
* *StepToTopoDS_Builder* a high level class. Its methods perform translation with the help of the classes listed above. If the value of *read.maxprecision.mode* is set to 1 then the tolerance of subshapes of the resulting shape is limited by 0 and *read.maxprecision.val*. Else this class does not change the tolerance value.
@@ -971,6 +1011,34 @@ if(!Interface_Static::SetIVal("write.step.vertex.mode",1))
~~~~
Default value is 0.
<h4>write.step.tessellated:</h4>
Boolean flag regulating writing of entities that define tessellated geometry:
* TESSELLATED_SHAPE_REPRESENTATION
* TESSELLATED_SHELL
* TESSELLATED_SOLID
* TRIANGULATED_FACE
Tesselated geometry is taken as objects of <i>Poly_Triangulation type</i> from the active <i>TopoDS_Face</i> triangulation.
* 0 (Off) -- do not write
* 1 (On) -- write
* 2 (OnNoBRep) - tessellation is written only for entities for which there is no BRep representation
Read this parameter with:
~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("write.step.tessellated");
~~~~
Modify this parameter with:
~~~~{.cpp}
if(!Interface_Static::SetIVal("write.step.tessellated",1))
.. error ..
~~~~
Default value is 2 (OnNoBep).
@subsubsection occt_step_3_3_3 Performing the Open CASCADE Technology shape translation
An OCCT shape can be translated to STEP using one of the following models (shape_representations):
* manifold_solid_brep (advanced_brep_shape_representation)
@@ -1094,6 +1162,7 @@ The table below describes STEP entities, which are created when the assembly str
| | Geom_ToroidalSurface | toroidal_surface or degenerate_toroidal_surface | *degenerate_toroidal_surface* is produced if the minor radius is greater then the major one |
| | Geom_BezierSurface | b_spline_surface_with_knots | |
| | Geom_BsplineSurface | b_spline_surface_with_knots or rational_b_spline_surface | *rational_b_spline_surface* is produced if *Geom_BSplineSurface* is a rational Bspline |
| Triangulations | Poly_Triangulation | *triangulated_face* is produced for face active triangulation | |
@subsection occt_step_3_5 Tolerance management

View File

@@ -7,6 +7,7 @@ if exist "%~dp0custom.bat" (
call "%CASROOT%\env.bat" %1 %2 %3
if /I ["%1"] == ["vc141"] set "VCVER=vc141"
if /I ["%1"] == ["vc142"] set "VCVER=vc142"
if /I ["%1"] == ["vc143"] set "VCVER=vc143"
set "BIN_DIR=win%ARCH%\%VCVER%\bind"
set "LIB_DIR=win%ARCH%\%VCVER%\libd"

View File

@@ -362,7 +362,7 @@ void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO
continue;
}
Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key());
Handle(Graphic3d_ViewAffinity) anAffinity = anObjIter.Key()->ViewAffinity();
const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId);
if (isVisible == theIsVisibleInView)
{
@@ -402,17 +402,9 @@ void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject
return;
}
Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj);
Handle(Graphic3d_ViewAffinity) anAffinity = theIObj->ViewAffinity();
Handle(Graphic3d_CView) aViewImpl = theView->View();
anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True);
if (theIsVisible)
{
theView->View()->ChangeHiddenObjects()->Remove (theIObj.get());
}
else
{
theView->View()->ChangeHiddenObjects()->Add (theIObj.get());
}
}
//=======================================================================
@@ -445,7 +437,8 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
if (!myObjects.IsBound (theIObj))
{
setObjectStatus (theIObj, PrsMgr_DisplayStatus_Displayed, theDispMode, theSelectionMode);
myMainVwr->StructureManager()->RegisterObject (theIObj);
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity());
myMainPM->Display(theIObj, theDispMode);
if (theSelectionMode != -1)
{
@@ -521,7 +514,8 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj,
Standard_Integer aDispMode, aHiMod, aSelModeDef;
GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef);
setObjectStatus (theIObj, PrsMgr_DisplayStatus_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef);
myMainVwr->StructureManager()->RegisterObject (theIObj);
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
myMainVwr->StructureManager()->RegisterObject (theIObj, theIObj->ViewAffinity());
}
// Register theIObj in the selection manager to prepare further activation of selection
@@ -1900,13 +1894,9 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
mgrSelector->Remove (anObj);
setObjectStatus (theIObj, PrsMgr_DisplayStatus_None, -1, -1);
theIObj->ViewAffinity()->SetVisible (true); // reset view affinity mask
myMainVwr->StructureManager()->UnregisterObject (theIObj);
for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next())
{
aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get());
}
if (!myLastPicked.IsNull())
{
if (myLastPicked->IsSameSelectable (theIObj))
@@ -2214,10 +2204,11 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView)
//function : BoundingBoxOfSelection
//purpose :
//=======================================================================
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection (const Handle(V3d_View)& theView) const
{
Bnd_Box aBndSelected;
AIS_MapOfObjectOwners anObjectOwnerMap;
const Standard_Integer aViewId = !theView.IsNull() ? theView->View()->Identification() : -1;
for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
@@ -2227,6 +2218,13 @@ Bnd_Box AIS_InteractiveContext::BoundingBoxOfSelection() const
continue;
}
Handle(Graphic3d_ViewAffinity) anAffinity = anObj->ViewAffinity();
const Standard_Boolean isVisible = aViewId == -1 || anAffinity->IsVisible (aViewId);
if (!isVisible)
{
continue;
}
if (anOwner == anObj->GlobalSelOwner())
{
Bnd_Box aTmpBnd;
@@ -2264,7 +2262,7 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView,
const Standard_Real theMargin,
const Standard_Boolean theToUpdate)
{
Bnd_Box aBndSelected = BoundingBoxOfSelection();
Bnd_Box aBndSelected = BoundingBoxOfSelection (theView);
if (!aBndSelected.IsVoid())
{
theView->FitAll (aBndSelected, theMargin, theToUpdate);
@@ -2674,12 +2672,10 @@ AIS_StatusOfDetection AIS_InteractiveContext::moveTo (const Handle(V3d_View)& th
myDetectedSeq.Clear();
myLastActiveView = theView.get();
// preliminaires
// preliminaries
AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
Standard_Boolean toUpdateViewer = Standard_False;
myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
// filling of myAISDetectedSeq sequence storing information about detected AIS objects
// (the objects must be AIS_Shapes)
const Standard_Integer aDetectedNb = MainSelector()->NbPicked();

View File

@@ -42,6 +42,7 @@
#include <TCollection_AsciiString.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <Quantity_Color.hxx>
class V3d_Viewer;
@@ -502,7 +503,10 @@ public: //! @name Selection management
Standard_EXPORT AIS_StatusOfPick SelectDetected (const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace);
//! Returns bounding box of selected objects.
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
Standard_EXPORT Bnd_Box BoundingBoxOfSelection (const Handle(V3d_View)& theView) const;
Standard_DEPRECATED ("BoundingBoxOfSelection() should be called with View argument")
Bnd_Box BoundingBoxOfSelection() const { return BoundingBoxOfSelection (Handle(V3d_View)()); }
//! Sets list of owner selected/deselected using specified selection scheme.
//! @param theOwners owners to change selection state

View File

@@ -1071,7 +1071,7 @@ void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationMan
return;
}
aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
aPresentation->CStructure()->ViewAffinity = myViewAffinity;
if (anOwner->Mode() == AIS_MM_TranslationPlane)
{

View File

@@ -1969,7 +1969,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
void AIS_ViewController::FitAllAuto (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView)
{
const Bnd_Box aBoxSel = theCtx->BoundingBoxOfSelection();
const Bnd_Box aBoxSel = theCtx->BoundingBoxOfSelection (theView);
const double aFitMargin = 0.01;
if (aBoxSel.IsVoid())
{

View File

@@ -859,7 +859,7 @@ Standard_Boolean AIS_ViewCube::HasAnimation() const
void AIS_ViewCube::viewFitAll (const Handle(V3d_View)& theView,
const Handle(Graphic3d_Camera)& theCamera)
{
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection() : theView->View()->MinMaxValues();
Bnd_Box aBndBox = myToFitSelected ? GetContext()->BoundingBoxOfSelection (theView) : theView->View()->MinMaxValues();
if (aBndBox.IsVoid()
&& myToFitSelected)
{
@@ -1016,7 +1016,7 @@ void AIS_ViewCube::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManage
Handle(Prs3d_Presentation) aHiPrs = GetHilightPresentation (thePrsMgr);
aHiPrs->Clear();
aHiPrs->CStructure()->ViewAffinity = thePrsMgr->StructureManager()->ObjectAffinity (Handle(Standard_Transient)(this));
aHiPrs->CStructure()->ViewAffinity = myViewAffinity;
aHiPrs->SetTransformPersistence (TransformPersistence());
aHiPrs->SetZLayer (aLayer);

View File

@@ -1948,7 +1948,7 @@ int mcrcomm_(integer *kop,
/* Local variables */
intptr_t ideb;
doublereal dtab[32000];
intptr_t itab[160] /* was [4][40] */;
intptr_t itab[160] = {0} /* was [4][40] */;
intptr_t ipre;
integer i__, j, k;
@@ -2522,7 +2522,7 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const
/* Local variables */
char cfmt[1];
doublereal dfmt;
doublereal dfmt = 0.0; // unused
integer ifmt, i__, nufmt, ntotal;
char subrou[7];
@@ -2667,7 +2667,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit,
integer i__1, i__2;
/* Local variables */
doublereal dfmt;
doublereal dfmt = 0.0; // unused
integer ifmt, iver;
char subr[7];
integer ksys , ibyte, irest, ier;

View File

@@ -526,6 +526,8 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
}
myDone = Standard_True;
}
myCurveOnSurface = Handle(Adaptor3d_CurveOnSurface)::DownCast(aData.myCOnS.ShallowCopy());
}
//=======================================================================

View File

@@ -81,6 +81,21 @@ public:
return myCurve2d;
}
//! Returns the 3D curve that has the same parameter as
//! the 3D curve once evaluated on the surface up to the
//! specified tolerance.
Handle(Adaptor3d_Curve) Curve3d() const
{
return myC3d;
}
//! Returns the 3D curve on surface that has the same parameter as
//! the 3D curve up to the specified tolerance.
Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const
{
return myCurveOnSurface;
}
private:
//! Internal data structure to unify access to the most actively used data.
@@ -176,6 +191,7 @@ private:
Handle(Adaptor2d_Curve2d) myHCurve2d;
Handle(Adaptor3d_Curve) myC3d;
Handle(Adaptor3d_Surface) mySurf;
Handle(Adaptor3d_CurveOnSurface) myCurveOnSurface;
};
#endif // _Approx_SameParameter_HeaderFile

View File

@@ -77,7 +77,8 @@ static void ComputeTrsf2d(const Handle(TheWLine)& theline,
for(Standard_Integer i=1; i<=aNbPnts; i++)
{
const IntSurf_PntOn2S POn2S = theline->Point(i);
Standard_Real U,V;
Standard_Real U = 0.0;
Standard_Real V = 0.0;
(POn2S.*pfunc)(U,V);
aUmin = Min(U, aUmin);
aVmin = Min(V, aVmin);

View File

@@ -31,13 +31,11 @@
#include <BRepCheck_ListOfStatus.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <BRepTools.hxx>
#include <ElCLib.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <Geom_Curve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
@@ -116,11 +114,6 @@ static Standard_Boolean GetPnt2d(const TopoDS_Vertex &theVertex,
const TopoDS_Edge &theEdge,
const TopoDS_Face &theFace,
gp_Pnt2d &aPnt);
static void DefinePeriods(const TopoDS_Face& theFace,
Standard_Real& theUperiod,
Standard_Real& theVperiod);
// Modified by Sergey KHROMOV - Wed May 22 10:44:08 2002 End
//=======================================================================
@@ -426,24 +419,12 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
const gp_Pnt2d& thePnt,
const gp_Pnt2d& thePntRef,
const Standard_Real aTol3d,
const Standard_Boolean theIsOnSingularity,
#ifdef OCCT_DEBUG
const Standard_Boolean PrintWarnings = Standard_True)
#else
const Standard_Boolean = Standard_True)
#endif
{
gp_Pnt aP;
gp_Vec aDU, aDV;
Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
aFaceSurface.D1(um, vm, aP, aDU, aDV);
Standard_Real aMDU = aDU.Magnitude();
Standard_Real aMDV = aDV.Magnitude();
if (!theIsOnSingularity ||
(aMDU > Precision::Confusion() && aMDV > Precision::Confusion()))
return Standard_True; //we are not in singularity
Standard_Real dumax = 0.01 * (aFaceSurface.LastUParameter() - aFaceSurface.FirstUParameter());
Standard_Real dvmax = 0.01 * (aFaceSurface.LastVParameter() - aFaceSurface.FirstVParameter());
Standard_Real dumin = Abs(thePnt.X() - thePntRef.X());
@@ -472,17 +453,17 @@ Standard_Boolean IsDistanceIn2DTolerance (const BRepAdaptor_Surface& aFaceSurfac
#endif
dumax = aFaceSurface.UResolution(aTol3d);
dvmax = aFaceSurface.VResolution(aTol3d);
//gp_Pnt aP;
//gp_Vec aDU, aDV;
//Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
//Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
//aFaceSurface.D1(um, vm, aP, aDU, aDV);
//Standard_Real aMDU = aDU.Magnitude();
gp_Pnt aP;
gp_Vec aDU, aDV;
Standard_Real um = (thePnt.X() + thePntRef.X()) / 2.;
Standard_Real vm = (thePnt.Y() + thePntRef.Y()) / 2.;
aFaceSurface.D1(um, vm, aP, aDU, aDV);
Standard_Real aMDU = aDU.Magnitude();
if (aMDU > Precision::Confusion())
{
dumax = Max((aTol3d / aMDU), dumax);
}
//Standard_Real aMDV = aDV.Magnitude();
Standard_Real aMDV = aDV.Magnitude();
if (aMDV > Precision::Confusion())
{
dvmax = Max((aTol3d / aMDV), dvmax);
@@ -695,14 +676,7 @@ BRepCheck_Status BRepCheck_Wire::Closed2d(const TopoDS_Face& theFace,
gp_Pnt aPntRef = BRep_Tool::Pnt(aFirstVertex);
gp_Pnt aPnt = BRep_Tool::Pnt(aWireExp.CurrentVertex());
Standard_Real aUperiod = 0., aVperiod = 0.;
DefinePeriods (theFace, aUperiod, aVperiod);
if ((aUperiod != 0. && Abs(aP_first.X() - aP_last.X()) > aUperiod/2) ||
(aVperiod != 0. && Abs(aP_first.Y() - aP_last.Y()) > aVperiod/2))
aClosedStat = BRepCheck_NotClosed;
if (!(IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d, Standard_True)))
if (!(IsDistanceIn2DTolerance(aFaceSurface, aP_first, aP_last, aTol3d)))
aClosedStat = BRepCheck_NotClosed;
if(!IsDistanceIn3DTolerance(aPntRef, aPnt, aTol3d))
@@ -1736,24 +1710,10 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
if (aVOrientation != anEdgOrientation)
aDerRef.Reverse();
//Check if there is a seam edge in the list
Standard_Real aUperiod = 0., aVperiod = 0.;
DefinePeriods (theFace, aUperiod, aVperiod);
Standard_Boolean anIsOnSingularity = Standard_False;
for (It.Initialize(theLOfShape); It.More(); It.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge (It.Value());
if (BRep_Tool::Degenerated (anEdge))
{
anIsOnSingularity = Standard_True;
break;
}
}
It.Initialize(theLOfShape);
for (; It.More(); It.Next())
{
{
anIndex++;
const TopoDS_Edge& anE=TopoDS::Edge(It.Value());
C2d = BRep_Tool::CurveOnSurface(anE, theFace, aFirstParam, aLastParam);
@@ -1764,11 +1724,7 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
aParam =(aVOrientation != anE.Orientation()) ? aFirstParam : aLastParam;
aPnt = aCA.Value(aParam);
if ((aUperiod != 0. && Abs(aPnt.X() - aPntRef.X()) > aUperiod/2) ||
(aVperiod != 0. && Abs(aPnt.Y() - aPntRef.Y()) > aVperiod/2))
continue;
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, anIsOnSingularity, Standard_False))
if(!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, Standard_False))
continue;
CurveDirForParameter(aCA, aParam, aPnt, aDer);
@@ -1787,22 +1743,22 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
anAngle += 2.*M_PI;
if ( theFace.Orientation() == TopAbs_FORWARD )
{
if ( anAngle < aMinAngle )
{
if ( anAngle < aMinAngle )
{
anIndMin = anIndex;
aMinAngle = anAngle;
}
}
}
else //theFace.Orientation() != TopAbs_FORWARD
{
if ( anAngle > aMaxAngle )
{
if ( anAngle > aMaxAngle )
{
anIndMin = anIndex;
aMaxAngle = anAngle;
}
}
}
}//end of for
}//end of for
// Update edge
if (anIndMin == 0)
@@ -1814,7 +1770,7 @@ void ChoixUV(const TopoDS_Vertex& theVertex,
if(anEFound.IsNull() || BRep_Tool::Degenerated(theEdge) ||
BRep_Tool::Degenerated(anEFound))
IsFound = Standard_False; //bad
else if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d, Standard_True))
else if (!IsDistanceIn2DTolerance(aFaceSurface, aPnt, aPntRef, aTol3d))
IsFound = Standard_False; //bad
else
// clousureness in 3D
@@ -2003,20 +1959,3 @@ static Standard_Boolean IsClosed2dForPeriodicFace
return Standard_True;
}
// Modified by Sergey KHROMOV - Thu Jun 20 10:58:05 2002 End
void DefinePeriods(const TopoDS_Face& theFace,
Standard_Real& theUperiod,
Standard_Real& theVperiod)
{
theUperiod = theVperiod = 0.;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface (theFace);
if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface();
Standard_Real aUmin, aUmax, aVmin, aVmax;
aSurf->Bounds (aUmin, aUmax, aVmin, aVmax);
if (aSurf->IsUClosed())
theUperiod = aUmax - aUmin;
if (aSurf->IsVClosed())
theVperiod = aVmax - aVmin;
}

View File

@@ -30,7 +30,6 @@
#include <TopoDS_Face.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <Precision.hxx>
#include <Bnd_SeqOfBox.hxx>
#include <BRepExtrema_UnCompatibleShape.hxx>
#include <BRep_Tool.hxx>
#include <BRepClass3d_SolidClassifier.hxx>

View File

@@ -81,7 +81,7 @@ void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2)
BRepAdaptor_Curve Curv(E);
Handle(BRepAdaptor_Curve) HC = new BRepAdaptor_Curve(Curv);
myExtCS.Perform(HC->Curve(), U1, U2);
myExtCS.Perform(*HC, U1, U2);
if(!myExtCS.IsDone())
return;

View File

@@ -987,8 +987,8 @@ Standard_Integer SensOfPrism(const Handle(Geom_Curve) C,
ASI1.Perform(scur);
Standard_Integer sens = 1;
if(ASI1.IsDone() && ASI1.NbPoints(1) >= 1) {
if(ASI1.Point(1, 1).Parameter() < 0. &&
ASI1.Point(1, ASI1.NbPoints(1)).Parameter() < 0.) {
if(ASI1.Point(1, 1).Parameter() + Precision::Confusion() < 0. &&
ASI1.Point(1, ASI1.NbPoints(1)).Parameter() + Precision::Confusion() < 0.) {
sens = -1;
}
}

View File

@@ -85,6 +85,7 @@
#include <TopTools_HArray2OfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <GeomLib_CheckCurveOnSurface.hxx>
#include <stdio.h>
//#include <BRepFill_TrimCorner.hxx>
@@ -289,6 +290,34 @@ static Standard_Boolean CheckSameParameter
return Standard_True;
}
//=======================================================================
//function : CheckSameParameterExact
//purpose : Check a posteriori that sameparameter has worked correctly
// with exact calculation method of edge tolerance
//=======================================================================
static Standard_Boolean CheckSameParameterExact
(const Handle(Adaptor3d_Curve)& C3d,
const Handle(Adaptor3d_CurveOnSurface)& curveOnSurface,
const Standard_Real tol3d,
Standard_Real& tolreached)
{
GeomLib_CheckCurveOnSurface aCheckCurveOnSurface(C3d);
aCheckCurveOnSurface.SetParallel(Standard_False);
aCheckCurveOnSurface.Perform(curveOnSurface);
tolreached = aCheckCurveOnSurface.MaxDistance();
if (tolreached > tol3d) {
return Standard_False;
}
else
{
tolreached = Max(tolreached, Precision::Confusion());
tolreached *= 1.05;
}
return Standard_True;
}
//=======================================================================
//function : SameParameter
//purpose : Encapsulation of Sameparameter
@@ -340,8 +369,10 @@ static Standard_Boolean SameParameter(TopoDS_Edge& E,
return Standard_False;
}
ResTol = sp.TolReached();
if(ResTol > tolreached ){
Handle(Adaptor3d_Curve) curve3d = sp.Curve3d();
Handle(Adaptor3d_CurveOnSurface) curveOnSurface = sp.CurveOnSurface();
if (!CheckSameParameterExact(curve3d, curveOnSurface, tol3d, ResTol) && ResTol > tolreached) {
#ifdef OCCT_DEBUG
std::cout<<"SameParameter : Tolerance not reached!"<<std::endl;
std::cout<<"tol visee : "<<tol3d<<" tol obtained : "<<ResTol<<std::endl;
@@ -3253,7 +3284,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
Tang = T1 + T2; //Average direction
gp_Dir NormalOfBisPlane = Tang;
gp_Vec anIntersectPointCrossDirection = T1.Crossed(T2);
if (isTangent) {
Sortant -= Tang.Dot(Tang)*Tang;
}
@@ -3300,7 +3331,7 @@ TopoDS_Shape BRepFill_Sweep::Tape(const Standard_Integer Index) const
}
}
BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane);
BRepFill_TrimShellCorner aTrim(aFaces, Transition, AxeOfBisPlane, anIntersectPointCrossDirection);
aTrim.AddBounds(Bounds);
aTrim.AddUEdges(aUEdges);
aTrim.AddVEdges(myVEdges, Index);

View File

@@ -76,12 +76,14 @@ static Standard_Boolean FindCommonVertex(const TopoDS_Edge& theFirstEdge,
static Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
const Standard_Integer theEIndex1,
const Standard_Integer theEIndex2,
const gp_Vec& theCrossDirection,
TopoDS_Vertex& theCommonVertex,
Standard_Real& theParamOnE1,
Standard_Real& theParamOnE2);
static Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges,
const BOPDS_PDS& theDS,
const gp_Vec& theCrossDirection,
TopTools_DataMapOfShapeListOfShape& theHistMap);
static void StoreVedgeInHistMap(const Handle(TopTools_HArray1OfShape)& theVEdges,
@@ -194,9 +196,11 @@ static void UpdateSectionEdge(TopoDS_Edge& theEdge,
// ===========================================================================================
BRepFill_TrimShellCorner::BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
const BRepFill_TransitionStyle theTransition,
const gp_Ax2& theAxeOfBisPlane) :
const gp_Ax2& theAxeOfBisPlane,
const gp_Vec& theIntPointCrossDir) :
myTransition(theTransition),
myAxeOfBisPlane(theAxeOfBisPlane),
myIntPointCrossDir(theIntPointCrossDir),
myDone(Standard_False),
myHasSection(Standard_False)
{
@@ -309,7 +313,7 @@ void BRepFill_TrimShellCorner::Perform()
BOPDS_VectorOfInterfFF& aFFs = theDS->InterfFF();
Standard_Integer aNbFFs = aFFs.Length();
if(!SplitUEdges(myUEdges, theDS, myHistMap)) {
if(!SplitUEdges(myUEdges, theDS, myIntPointCrossDir, myHistMap)) {
return;
}
@@ -425,7 +429,7 @@ BRepFill_TrimShellCorner::MakeFacesNonSec(const Standard_Integer
Standard_Real apar1 = 0., apar2 = 0.;
Standard_Boolean bvertexfound =
FindCommonVertex(theDS, anIndex1, anIndex2, aCommonVertex, apar1, apar2);
FindCommonVertex(theDS, anIndex1, anIndex2, myIntPointCrossDir, aCommonVertex, apar1, apar2);
// search common vertex between bounds. end
Handle(BRepTools_ReShape) aSubstitutor = new BRepTools_ReShape();
@@ -697,9 +701,9 @@ BRepFill_TrimShellCorner::MakeFacesSec(const Standard_Integer
TopoDS_Vertex FirstVertex, LastVertex;
Standard_Real ParamOnLeftE1, ParamOnLeftE2, ParamOnRightE1, ParamOnRightE2;
FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2,
FindCommonVertex(theDS, IndexOfLeftE1, IndexOfLeftE2, myIntPointCrossDir,
FirstVertex, ParamOnLeftE1, ParamOnLeftE2);
FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2,
FindCommonVertex(theDS, IndexOfRightE1, IndexOfRightE2, myIntPointCrossDir,
LastVertex, ParamOnRightE1, ParamOnRightE2);
TopoDS_Shape SecWire;
@@ -1079,7 +1083,8 @@ Standard_Boolean BRepFill_TrimShellCorner::ChooseSection(const TopoDS_Shape& Com
// purpose:
// ------------------------------------------------------------------------------------------
Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdges,
const BOPDS_PDS& theDS,
const BOPDS_PDS& theDS,
const gp_Vec& theCrossDirection,
TopTools_DataMapOfShapeListOfShape& theHistMap) {
const BOPDS_VectorOfInterfVV& aVVs = theDS->InterfVV();
@@ -1105,7 +1110,7 @@ Standard_Boolean SplitUEdges(const Handle(TopTools_HArray2OfShape)& theUEdge
TopoDS_Vertex aCommonVertex;
Standard_Real apar1 = 0., apar2 = 0.;
Standard_Boolean bvertexfound =
FindCommonVertex(theDS, anEIndex1, anEIndex2, aCommonVertex, apar1, apar2);
FindCommonVertex(theDS, anEIndex1, anEIndex2, theCrossDirection, aCommonVertex, apar1, apar2);
//
if(!bvertexfound) {
TopoDS_Vertex V1 = TopExp::LastVertex(TopoDS::Edge(aE1));
@@ -1217,6 +1222,7 @@ void FindFreeVertices(const TopoDS_Shape& theShape,
Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
const Standard_Integer theEIndex1,
const Standard_Integer theEIndex2,
const gp_Vec& theCrossDirection,
TopoDS_Vertex& theCommonVertex,
Standard_Real& theParamOnE1,
Standard_Real& theParamOnE2) {
@@ -1227,6 +1233,10 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
TopoDS_Vertex aCommonVertex;
Standard_Integer eeit = 0;
TopoDS_Edge theE1 = TopoDS::Edge(theDS->Shape(theEIndex1));
TopoDS_Edge theE2 = TopoDS::Edge(theDS->Shape(theEIndex2));
BRepAdaptor_Curve aBC1(theE1), aBC2(theE2);
Standard_Integer aNbEEs;
aNbEEs = aEEs.Length();
for(eeit = 0; eeit < aNbEEs; ++eeit) {
@@ -1247,10 +1257,21 @@ Standard_Boolean FindCommonVertex(const BOPDS_PDS& theDS,
IntTools_Tools::VertexParameters(aCP, theParamOnE1, theParamOnE2);
else
IntTools_Tools::VertexParameters(aCP, theParamOnE2, theParamOnE1);
//
bvertexfound = Standard_True;
break;
gp_Pnt aPt;
gp_Vec aDirOnE1, aDirOnE2;
gp_Dir aIntersectPointCrossDir;
// intersect point aDirOnE1.cross(aDirOnE2) should same direction with path theCrossDirection
aBC1.D1(theParamOnE1, aPt, aDirOnE1);
aBC2.D1(theParamOnE2, aPt, aDirOnE2);
aIntersectPointCrossDir = aDirOnE1.Crossed(aDirOnE2);
if (aIntersectPointCrossDir.Dot(theCrossDirection) > Precision::SquareConfusion())
{
bvertexfound = Standard_True;
break;
}
}
}
}

View File

@@ -41,9 +41,12 @@ public:
//! Constructor: takes faces to intersect,
//! type of transition (it can be RightCorner or RoundCorner)
//! and axis of bisector plane
//! theIntersectPointCrossDirection : prev path direction at the origin point of theAxeOfBisPlane
//! cross next path direction at the origin point of theAxeOfBisPlane. used when EE has more than one vertices
Standard_EXPORT BRepFill_TrimShellCorner(const Handle(TopTools_HArray2OfShape)& theFaces,
const BRepFill_TransitionStyle theTransition,
const gp_Ax2& theAxeOfBisPlane);
const gp_Ax2& theAxeOfBisPlane,
const gp_Vec& theIntPointCrossDir);
Standard_EXPORT void AddBounds (const Handle(TopTools_HArray2OfShape)& Bounds);
@@ -92,6 +95,7 @@ private:
BRepFill_TransitionStyle myTransition;
gp_Ax2 myAxeOfBisPlane;
gp_Vec myIntPointCrossDir;
TopoDS_Shape myShape1;
TopoDS_Shape myShape2;
Handle(TopTools_HArray2OfShape) myBounds;

View File

@@ -57,6 +57,7 @@ static BRepOffsetAPI_ThruSections* Generator = 0;
#include <Geom_Circle.hxx>
#include <gp_Ax2.hxx>
#include <Message.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
//=======================================================================
// prism
@@ -533,16 +534,50 @@ Standard_Integer thrusections(Draw_Interpretor&, Standard_Integer n, const char*
//=======================================================================
// mksweep
//=======================================================================
static Standard_Integer mksweep(Draw_Interpretor&,
static Standard_Integer mksweep(Draw_Interpretor& di,
Standard_Integer n, const char** a)
{
if (n != 2) return 1;
if (n != 2 && n != 5) return 1;
TopoDS_Shape Spine = DBRep::Get(a[1], TopAbs_WIRE);
if (Spine.IsNull()) return 1;
if (Sweep != 0) {
delete Sweep;
Sweep = 0;
}
if (n > 2 && n <= 5)
{
if (!strcmp(a[2], "-C"))
{
ShapeUpgrade_UnifySameDomain aUnif(Spine, Standard_True, Standard_False, Standard_True);
Standard_Real anAngTol = 5.;
Standard_Real aLinTol = 0.1;
if (n == 5)
{
anAngTol = Draw::Atof(a[3]);
aLinTol = Draw::Atof(a[4]);
}
aUnif.SetAngularTolerance(anAngTol * M_PI / 180.);
aUnif.SetLinearTolerance(aLinTol);
aUnif.Build();
Spine = aUnif.Shape();
if (BRepTest_Objects::IsHistoryNeeded())
{
BRepTest_Objects::SetHistory(aUnif.History());
}
}
else
{
di << "To correct input spine use 'mksweep wire -C [AngTol LinTol]'\n";
di << "By default, AngTol = 5, LinTol = 0.1";
return 1;
}
}
Sweep = new BRepOffsetAPI_MakePipeShell(TopoDS::Wire(Spine));
return 0;
}
@@ -1010,7 +1045,9 @@ void BRepTest::SweepCommands(Draw_Interpretor& theCommands)
"\t\t-safe option allows to prevent the modifying of input shapes",
__FILE__, thrusections, g);
theCommands.Add("mksweep", "mksweep wire",
theCommands.Add("mksweep", "mksweep wire [-C [AngTol LinTol]]\n"
"\t\tthe option -C correct input spine by merging smooth connected neighboring edges\n"
"\t\tthe AngTol is in degrees",
__FILE__, mksweep, g);
theCommands.Add("setsweep", "setsweep no args to get help",

View File

@@ -54,29 +54,6 @@ static Standard_Real GetNextParamOnPC(const Handle(Geom2d_Curve)& aPC,
const Standard_Real& tolV,
const Standard_Boolean& reverse);
static Standard_Real LocalUresol (const TopoDS_Vertex& theVertex,
const TopoDS_Face& theFace,
const gp_Pnt2d& theP2d1,
const gp_Pnt2d& theP2d2)
{
Standard_Real aResol = -1;
BRepAdaptor_Surface aBAsurf (theFace, Standard_False);
if (aBAsurf.GetType() == GeomAbs_Sphere)
{
Standard_Real aRadius = aBAsurf.Sphere().Radius();
Standard_Real aVmid = (theP2d1.Y() + theP2d2.Y())/2.;
Standard_Real aLocalRad = aRadius * Cos(aVmid);
if (aLocalRad > Precision::Confusion())
{
Standard_Real aTolVertex = BRep_Tool::Tolerance (theVertex);
aResol = aTolVertex / aLocalRad;
}
}
return aResol;
}
//=======================================================================
//function : BRepTools_WireExplorer
//purpose :
@@ -559,56 +536,56 @@ void BRepTools_WireExplorer::Next()
it.Initialize(l);
while( it.More() )
{
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
if( E.IsSame(myEdge) )
const TopoDS_Edge& E = TopoDS::Edge(it.Value());
if( E.IsSame(myEdge) )
{
it.Next();
k++;
continue;
}
TopoDS_Vertex aVert1, aVert2;
TopExp::Vertices (E, aVert1, aVert2, Standard_True);
if( aVert1.IsNull() || aVert2.IsNull() )
{
it.Next();
k++;
continue;
}
TopoDS_Vertex aVert1, aVert2;
TopExp::Vertices (E, aVert1, aVert2, Standard_True);
if( aVert1.IsNull() || aVert2.IsNull() )
aPCurve = BRep_Tool::CurveOnSurface (E, myFace, dfFPar, dfLPar);
if( aPCurve.IsNull() )
{
it.Next();
k++;
continue;
}
aPCurve = BRep_Tool::CurveOnSurface (E, myFace, dfFPar, dfLPar);
if( aPCurve.IsNull() )
{
it.Next();
k++;
continue;
}
gp_Pnt2d aPEb, aPEe;
if( aVert1.IsSame(aVert2) == isDegenerated )
{
if( E.Orientation() == TopAbs_REVERSED )
aPCurve->D0(dfLPar, aPEb);
else
aPCurve->D0(dfFPar, aPEb);
if( Abs(dfLPar-dfFPar) > Precision::PConfusion() )
{
isrevese = ( E.Orientation() == TopAbs_REVERSED );
isrevese = !isrevese;
Standard_Real aEPm = GetNextParamOnPC(aPCurve,aPEb,dfFPar,dfLPar,myTolU,myTolV,isrevese);
aPCurve->D0 (aEPm, aPEe);
gp_Pnt2d aPEb, aPEe;
if( aVert1.IsSame(aVert2) == isDegenerated )
{
if( E.Orientation() == TopAbs_REVERSED )
aPCurve->D0(dfLPar, aPEb);
else
aPCurve->D0(dfFPar, aPEb);
if( Abs(dfLPar-dfFPar) > Precision::PConfusion() )
{
isrevese = ( E.Orientation() == TopAbs_REVERSED );
isrevese = !isrevese;
Standard_Real aEPm = GetNextParamOnPC(aPCurve,aPEb,dfFPar,dfLPar,myTolU,myTolV,isrevese);
aPCurve->D0 (aEPm, aPEe);
if(aPEb.SquareDistance(aPEe) <= gp::Resolution())
{
//seems to be very short curve
gp_Vec2d aD;
aPCurve->D1(aEPm, aPEe, aD);
if( E.Orientation() == TopAbs_REVERSED )
if( E.Orientation() == TopAbs_REVERSED )
aPEe.SetXY(aPEb.XY()-aD.XY());
else
else
aPEe.SetXY(aPEb.XY()+aD.XY());
if(aPEb.SquareDistance(aPEe) <= gp::Resolution())
{
it.Next();
@@ -616,39 +593,35 @@ void BRepTools_WireExplorer::Next()
continue;
}
}
gp_Vec2d anEDir(aPEb, aPEe);
dfCurAngle = Abs( anEDir.Angle(anERefDir) );
}
if( dfCurAngle <= dfMinAngle )
{
Standard_Real d = PRef.SquareDistance(aPEb);
if( d <= Precision::PConfusion() )
d = 0.;
//jgv
Standard_Real aLocalUresol = LocalUresol (myVertex, myFace, PRef, aPEb);
aLocalUresol = Max (aLocalUresol, myTolU);
/////
if( Abs(aPEb.X()-PRef.X()) < aLocalUresol && Abs(aPEb.Y()-PRef.Y()) < myTolV )
{
if( d <= dmin )
{
dfMinAngle = dfCurAngle;
kMin = k;
dmin = d;
}
}
}
}
it.Next();
k++;
gp_Vec2d anEDir(aPEb, aPEe);
dfCurAngle = Abs( anEDir.Angle(anERefDir) );
}
if( dfCurAngle <= dfMinAngle )
{
Standard_Real d = PRef.SquareDistance(aPEb);
if( d <= Precision::PConfusion() )
d = 0.;
if( Abs(aPEb.X()-PRef.X()) < myTolU && Abs(aPEb.Y()-PRef.Y()) < myTolV )
{
if( d <= dmin )
{
dfMinAngle = dfCurAngle;
kMin = k;
dmin = d;
}
}
}
}
it.Next();
k++;
}// while it
if( kMin == 0 )
{
isDegenerated = Standard_False;
k = 1;
dmin = RealLast();
isDegenerated = Standard_False;
k = 1;
dmin = RealLast();
}
else
break;

View File

@@ -229,11 +229,12 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
if (aFileVer >= TDocStd_FormatVersion_VERSION_3) {
BinLDrivers_DocumentSection aSection;
do {
BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer);
if (!BinLDrivers_DocumentSection::ReadTOC (aSection, theIStream, aFileVer))
break;
mySections.Append(aSection);
} while (!aSection.Name().IsEqual (aQuickPart ? ENDSECTION_POS : SHAPESECTION_POS) && !theIStream.eof());
if (theIStream.eof()) {
if (mySections.IsEmpty() || theIStream.eof()) {
// There is no shape section in the file.
myMsgDriver->Send (aMethStr + "error: shape section is not found", Message_Fail);
myReaderStatus = PCDM_RS_ReaderException;

View File

@@ -214,14 +214,17 @@ void BinLDrivers_DocumentSection::Write (Standard_OStream& theStream,
//purpose :
//=======================================================================
void BinLDrivers_DocumentSection::ReadTOC
(BinLDrivers_DocumentSection& theSection,
Standard_Boolean BinLDrivers_DocumentSection::ReadTOC (
BinLDrivers_DocumentSection& theSection,
Standard_IStream& theStream,
const TDocStd_FormatVersion theDocFormatVersion)
{
char aBuf[512];
static const int THE_BUF_SIZE = 512;
char aBuf[THE_BUF_SIZE];
Standard_Integer aNameBufferSize;
theStream.read ((char *)&aNameBufferSize, sizeof(Standard_Integer));
if (theStream.eof() || aNameBufferSize > THE_BUF_SIZE)
return Standard_False;
#ifdef DO_INVERSE
aNameBufferSize = InverseSize(aNameBufferSize);
#endif
@@ -260,4 +263,5 @@ void BinLDrivers_DocumentSection::ReadTOC
theSection.myValue[1] = aValue[1];
theSection.myIsPostRead = (aValue[2] != 0);
}
return Standard_True;
}

View File

@@ -73,9 +73,10 @@ public:
const TDocStd_FormatVersion theDocFormatVersion);
//! Fill a DocumentSection instance from the data that are read
//! from TOC.
Standard_EXPORT static void ReadTOC (BinLDrivers_DocumentSection& theSection, Standard_IStream& theIS,
const TDocStd_FormatVersion theDocFormatVersion);
//! from TOC. Returns false in case of the stream reading problem.
Standard_EXPORT static Standard_Boolean ReadTOC (BinLDrivers_DocumentSection& theSection,
Standard_IStream& theIS,
const TDocStd_FormatVersion theDocFormatVersion);

View File

@@ -51,7 +51,7 @@ Standard_Boolean BinMDF_TagSourceDriver::Paste
BinObjMgt_RRelocationTable& ) const
{
Handle(TDF_TagSource) aTag = Handle(TDF_TagSource)::DownCast(theTarget);
Standard_Integer aValue;
const Standard_Integer aValue = -1;
Standard_Boolean ok = theSource >> aValue;
if (ok)
aTag->Set(aValue);

View File

@@ -73,7 +73,7 @@ Standard_Boolean BinMDataStd_IntPackedMapDriver::Paste
}
if(aSize) {
Handle(TColStd_HPackedMapOfInteger) aHMap = new TColStd_HPackedMapOfInteger ();
Standard_Integer aKey;
const Standard_Integer aKey = -1;
for(Standard_Integer i = 0; i< aSize; i++) {
Standard_Boolean ok = Source >> aKey;
if (!ok) {

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_IntegerDriver::Paste
BinObjMgt_RRelocationTable& theRT) const
{
Handle(TDataStd_Integer) anAtt = Handle(TDataStd_Integer)::DownCast(theTarget);
Standard_Integer aValue;
const Standard_Integer aValue = -1;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataStd_RealDriver::Paste
BinObjMgt_RRelocationTable& theRelocTable) const
{
Handle(TDataStd_Real) anAtt= Handle(TDataStd_Real)::DownCast(theTarget);
Standard_Real aValue;
Standard_Real aValue = -1.0;
Standard_Boolean ok = theSource >> aValue;
if (ok)
anAtt->Set(aValue);

View File

@@ -54,7 +54,7 @@ Standard_Boolean BinMDataXtd_GeometryDriver::Paste
Handle(TDataXtd_Geometry) aT =
Handle(TDataXtd_Geometry)::DownCast (theTarget);
Standard_Integer aType;
const Standard_Integer aType = -1;
Standard_Boolean ok = theSource >> aType;
if (ok)
aT->SetType ((TDataXtd_GeometryEnum) aType);

View File

@@ -55,7 +55,7 @@ Standard_Boolean BinMDataXtd_PositionDriver::Paste
BinObjMgt_RRelocationTable& ) const
{
Handle(TDataXtd_Position) anAtt = Handle(TDataXtd_Position)::DownCast(theTarget);
Standard_Real aValue;
Standard_Real aValue = 0.0;
Standard_Boolean ok = theSource >> aValue;
if (!ok) return ok;
gp_Pnt aPosition(0., 0., 0.);

View File

@@ -56,7 +56,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
Handle(TDataXtd_Presentation) anAttribute = Handle(TDataXtd_Presentation)::DownCast(theTarget);
// Display status
Standard_Integer aValue;
const Standard_Integer aValue = -1;
ok = theSource >> aValue;
if (!ok) return ok;
anAttribute->SetDisplayed (aValue != 0);
@@ -92,7 +92,7 @@ Standard_Boolean BinMDataXtd_PresentationDriver::Paste
anAttribute->UnsetMaterial();
// Transparency
Standard_Real aRValue;
Standard_Real aRValue = -1.0;
ok = theSource >> aRValue;
if ( !ok ) return ok;
if ( aRValue != -1. )

View File

@@ -62,7 +62,7 @@ Standard_Boolean BinMFunction_FunctionDriver::Paste
Standard_Boolean ok = theSource >> aGUID;
if (ok) {
anAtt->SetDriverGUID(aGUID);
Standard_Integer aValue;
const Standard_Integer aValue = -1;
ok = theSource >> aValue;
if(ok)
anAtt->SetFailure(aValue);

View File

@@ -117,8 +117,9 @@ static int TranslateFrom (const BinObjMgt_Persistent& theSource,
TopoDS_Shape& theResult,
BinTools_ShapeSet* theShapeSet)
{
Standard_Integer aShapeID, aLocID;
Standard_Character aCharOrient;
const Standard_Integer aShapeID = -1;
const Standard_Integer aLocID = -1;
const Standard_Character aCharOrient = '0';
Standard_Boolean Ok = theSource >> aShapeID; //TShapeID;
if(!Ok) return 1;
// Read TShape and Orientation
@@ -176,11 +177,11 @@ Standard_Boolean BinMNaming_NamedShapeDriver::Paste
theSource >> aNbShapes;
TDF_Label aLabel = theTarget->Label ();
TNaming_Builder aBuilder (aLabel);
Standard_Integer aVer;
const Standard_Integer aVer = -1;
Standard_Boolean ok = theSource >> aVer;
if(!ok) return Standard_False;
aTAtt->SetVersion(aVer); //Version
Standard_Character aCharEvol;
const Standard_Character aCharEvol = '0';
ok = theSource >> aCharEvol;
if(!ok) return Standard_False;
TNaming_Evolution anEvol = EvolutionToEnum (aCharEvol); //Evolution

View File

@@ -152,7 +152,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
TNaming_Name& aName = anAtt->ChangeName();
TCollection_ExtendedString aMsg;
//1. NameType
Standard_Character aValue;
const Standard_Character aValue = '0';
Standard_Boolean ok = theSource >> aValue;
Standard_Boolean aNewF = Standard_False;
if (ok) {
@@ -171,7 +171,7 @@ Standard_Boolean BinMNaming_NamingDriver::Paste
//3. Args
Standard_Integer aNbArgs=0;
Standard_Integer anIndx;
const Standard_Integer anIndx = -1;
Handle(TNaming_NamedShape) aNS;
ok = theSource >> aNbArgs;
if (ok) {

View File

@@ -48,7 +48,9 @@ Standard_Boolean BinMXCAFDoc_CentroidDriver::Paste(const BinObjMgt_Persistent& t
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Centroid) anAtt = Handle(XCAFDoc_Centroid)::DownCast(theTarget);
Standard_Real x, y, z;
Standard_Real x = 0.0;
Standard_Real y = 0.0;
Standard_Real z = 0.0;
Standard_Boolean isOk = theSource >> x >> y >> z;
if(isOk) {
gp_Pnt aPnt(x, y, z);

View File

@@ -48,8 +48,10 @@ Standard_Boolean BinMXCAFDoc_ColorDriver::Paste(const BinObjMgt_Persistent& theS
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
{
Handle(XCAFDoc_Color) anAtt = Handle(XCAFDoc_Color)::DownCast(theTarget);
Standard_Real R, G, B;
Standard_ShortReal alpha;
Standard_Real R = 0.0;
Standard_Real G = 0.0;
Standard_Real B = 0.0;
Standard_ShortReal alpha = 1.0;
Standard_Boolean isOk = theSource >> R >> G >> B;
if(isOk) {
Standard_Boolean isRGBA = theSource >> alpha;

View File

@@ -1,403 +0,0 @@
// Created on: 1993-03-08
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Bnd_Array1OfBox.hxx>
#include <Bnd_BoundSortBox2d.hxx>
#include <Bnd_Box2d.hxx>
#include <Standard_MultiplyDefined.hxx>
#include <Standard_NullValue.hxx>
#include <TColStd_Array1OfListOfInteger.hxx>
#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
//=======================================================================
//function : Bnd_BoundSortBox2d
//purpose :
//=======================================================================
Bnd_BoundSortBox2d::Bnd_BoundSortBox2d()
: discrX(0), discrY(0)
{}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::Initialize(const Bnd_Box2d& CompleteBox,
const Handle(Bnd_HArray1OfBox2d)& SetOfBox)
{
myBox=CompleteBox;
myBndComponents=SetOfBox;
discrX=SetOfBox->Length();
discrY=discrX;
Standard_Real xmin, ymin, xmax, ymax;
Standard_Real middleX=0.;
Standard_Real middleY=0.;
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
Standard_Integer labox;
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
if (!taBox(labox).IsVoid()) {
taBox.Value(labox).Get(xmin, ymin, xmax, ymax);
middleX+=xmax-xmin;
middleY+=ymax-ymin;
}
}
middleX=middleX/taBox.Length();
middleY=middleY/taBox.Length();
Standard_Real Xmax, Ymax;
CompleteBox.Get(Xmin, Ymin, Xmax, Ymax);
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
if (middleX < Epsilon(100.)) {
discrX=1;
deltaX=Xmax-Xmin;
}
else if (middleX > deltaX) {
discrX=(Standard_Integer)((Xmax-Xmin)/middleX);
deltaX=middleX;
discrX++;
}
if (middleY < Epsilon(100.)) {
discrY=1;
deltaY=Ymax-Ymin;
}
else if (middleY > deltaY) {
discrY=(Standard_Integer)((Ymax-Ymin)/middleY + 0.1);
deltaY=middleY;
discrY++;
}
SortBoxes();
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::Initialize(const Handle(Bnd_HArray1OfBox2d)& SetOfBox)
{
myBndComponents=SetOfBox;
discrX=SetOfBox->Length();
discrY=discrX;
Standard_Real xmin, ymin, xmax, ymax;
Standard_Real middleX=0.;
Standard_Real middleY=0.;
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
Standard_Integer labox;
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
if (!taBox(labox).IsVoid()) {
myBox.Add(taBox(labox));
taBox.Value(labox).Get(xmin, ymin, xmax, ymax);
middleX+=xmax-xmin;
middleY+=ymax-ymin;
}
}
middleX=middleX/taBox.Length();
middleY=middleY/taBox.Length();
Standard_Real Xmax, Ymax;
myBox.Get(Xmin, Ymin, Xmax, Ymax);
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
if (middleX < Epsilon(100.)) {
discrX=1;
deltaX=Xmax-Xmin;
}
else if (middleX > deltaX) {
discrX=(Standard_Integer)((Xmax-Xmin)/middleX);
deltaX=middleX;
discrX++;
}
if (middleY < Epsilon(100.)) {
discrY=1;
deltaY=Ymax-Ymin;
}
else if (middleY > deltaY) {
discrY=(Standard_Integer)((Ymax-Ymin)/middleY + 0.1);
deltaY=middleY;
discrY++;
}
SortBoxes();
}
//=======================================================================
//function : SortBoxes
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::SortBoxes()
{
Standard_NullValue_Raise_if (discrX+discrY <=0, "BoundSortBox2d nul!");
Standard_Integer labox, lacase, firstcase, lastcase;
Standard_Real xmin, ymin, xmax, ymax;
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
axisX=new TColStd_HArray1OfListOfInteger(1, discrX);
TColStd_Array1OfListOfInteger & tabListX=axisX->ChangeArray1();
axisY=new TColStd_HArray1OfListOfInteger(1, discrY);
TColStd_Array1OfListOfInteger & tabListY=axisY->ChangeArray1();
for (labox=taBox.Lower(); labox<=taBox.Upper(); labox++) {
if (!taBox(labox).IsVoid()) {
taBox(labox).Get(xmin, ymin, xmax, ymax);
if (discrX>1) {
firstcase=(Standard_Integer ) Max(1.0, (xmin-Xmin)/deltaX);
lastcase=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
for (lacase=firstcase; lacase<=lastcase; lacase++) {
tabListX(lacase).Append(labox);
}
}
if (discrY >1) {
firstcase=(Standard_Integer ) Max(1.0, (ymin-Ymin)/deltaY);
lastcase=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
for (lacase=firstcase; lacase<=lastcase; lacase++) {
tabListY(lacase).Append(labox);
}
}
}
}
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::Initialize(const Bnd_Box2d& CompleteBox,
const Standard_Integer nbComponents)
{
Standard_NullValue_Raise_if (nbComponents <=0, "BoundSortBox nul!");
myBox=CompleteBox;
myBndComponents=new Bnd_HArray1OfBox2d(1, nbComponents);
Bnd_Box2d emptyBox;
myBndComponents->Init( emptyBox );
discrX=nbComponents;
discrY=nbComponents;
Standard_Real Xmax, Ymax;
CompleteBox.Get(Xmin, Ymin, Xmax, Ymax);
deltaX=(Xmax-Xmin)/(Standard_Real)discrX;
deltaY=(Ymax-Ymin)/(Standard_Real)discrY;
if (deltaX < Epsilon(100.)) {
discrX=1;
deltaX=Xmax-Xmin;
}
else axisX=new TColStd_HArray1OfListOfInteger(1, discrX);
if (deltaY < Epsilon(100.)) {
discrY=1;
deltaY=Ymax-Ymin;
}
else axisY=new TColStd_HArray1OfListOfInteger(1, discrY);
}
//=======================================================================
//function : Add
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::Add(const Bnd_Box2d& theBox,
const Standard_Integer boxIndex)
{
Standard_MultiplyDefined_Raise_if
(!(myBndComponents->Value(boxIndex).IsVoid()),
" This box is already defined !");
if (!theBox.IsVoid()) {
Bnd_Array1OfBox2d & taBox=myBndComponents->ChangeArray1();
Standard_Integer theGap, firstGap , lastGap;
Standard_Real xmin, ymin, xmax, ymax;
theBox.Get(xmin, ymin, xmax, ymax);
if (taBox.Lower()<=boxIndex && boxIndex<=taBox.Upper())
taBox(boxIndex).Update(xmin, ymin, xmax, ymax);
TColStd_Array1OfListOfInteger & tabListX=axisX->ChangeArray1();
if (discrX>1) {
firstGap=(Standard_Integer ) Max(1.0, ((xmin-Xmin)/deltaX)+1);
lastGap=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
for (theGap=firstGap; theGap<=lastGap; theGap++) {
tabListX(theGap).Append(boxIndex);
}
}
TColStd_Array1OfListOfInteger & tabListY=axisY->ChangeArray1();
if (discrY >1) {
firstGap=(Standard_Integer ) Max(1.0, ((ymin-Ymin)/deltaY)+1);
lastGap=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
for (theGap=firstGap; theGap<=lastGap; theGap++) {
tabListY(theGap).Append(boxIndex);
}
}
}
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
const TColStd_ListOfInteger& Bnd_BoundSortBox2d::Compare
(const Bnd_Box2d& theBox)
{
Standard_NullValue_Raise_if (discrX+discrY <=0,
"Compare sur 1 BoundSortBox2d nul!");
lastResult.Clear();
if (theBox.IsVoid()) return lastResult;
if (theBox.IsOut(myBox)) return lastResult;
Standard_Integer lacase, firstcase, lastcase;
Standard_Real xmin, ymin, xmax, ymax;
theBox.Get(xmin, ymin, xmax, ymax);
const Bnd_Array1OfBox2d & taBox=myBndComponents->Array1();
Crible.Clear();
theFound=2;
Standard_Integer cardY=0;
if (discrY>1 && (!theBox.IsOpenYmin() || !theBox.IsOpenYmax())) {
const TColStd_Array1OfListOfInteger & tabList=axisY->Array1();
firstcase=(Standard_Integer ) Max(1.0, (ymin-Ymin)/deltaY);
lastcase=(Standard_Integer ) Min((Standard_Real)discrY, ((ymax-Ymin)/deltaY)+1);
for (lacase=firstcase; lacase<=lastcase; lacase++) {
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
for (; theList.More(); theList.Next()) {
cardY++;
Crible.Bind(theList.Value(), 2);
}
}
if (cardY==0) return lastResult;
}
else {
if (ymin > Ymin+deltaY || ymax < Ymin)
return lastResult;
theFound-=2;
}
if (discrX>1 && (!theBox.IsOpenXmin() || !theBox.IsOpenXmax())) {
const TColStd_Array1OfListOfInteger & tabList=axisX->Array1();
firstcase=(Standard_Integer ) Max(1.0, (xmin-Xmin)/deltaX);
lastcase=(Standard_Integer ) Min((Standard_Real)discrX, ((xmax-Xmin)/deltaX)+1);
for (lacase=firstcase; lacase<=lastcase; lacase++) {
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
for (; theList.More(); theList.Next()) {
if (Crible.IsBound(theList.Value())) {
if (Crible(theList.Value())==theFound) {
if (!taBox.Value(theList.Value()).IsOut(theBox)){
lastResult.Append(theList.Value());
Crible(theList.Value())=0;
}
}
}
}
}
return lastResult;
}
else {
if (xmin > Xmin+deltaX || xmax < Xmin) return lastResult;
else if (discrY==1)
{
lacase=1;
for(Standard_Integer i=taBox.Lower();i<=taBox.Upper();i++)
{
lastResult.Append(i);
}
}
else{
TColStd_DataMapIteratorOfDataMapOfIntegerInteger itDM(Crible);
for (; itDM.More(); itDM.Next()) {
if (itDM.Value()==theFound) {
if (taBox.Lower()<=itDM.Key() && itDM.Key()<=taBox.Upper()) {
if (!taBox(itDM.Key()).IsOut(theBox))
lastResult.Append(itDM.Key());
}
else {
lastResult.Append(itDM.Key());
}
}
}
}
}
return lastResult;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void Bnd_BoundSortBox2d::Dump() const
{
Standard_Integer lacase;
std::cout << "axis X : " << discrX << " intervalles de " << deltaX << std::endl;
if (discrX>1) {
const TColStd_Array1OfListOfInteger & tabList=axisX->Array1();
for (lacase=1; lacase<=discrX; lacase++) {
std::cout << " X " << lacase << " : " ;
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
for (; theList.More(); theList.Next()) {
std::cout << theList.Value() << " ";
}
std::cout << "\n";
}
}
std::cout << "axis Y : " << discrY << " intervalles de " << deltaY << std::endl;
if (discrY>1) {
const TColStd_Array1OfListOfInteger & tabList=axisY->Array1();
for (lacase=1; lacase<=discrY; lacase++) {
std::cout << " Y " << lacase << " : " ;
TColStd_ListIteratorOfListOfInteger theList(tabList(lacase));
for (; theList.More(); theList.Next()) {
std::cout << theList.Value() << " ";
}
std::cout << "\n";
}
}
}

View File

@@ -1,129 +0,0 @@
// Created on: 1993-03-05
// Created by: Didier PIFFAULT
// Copyright (c) 1993-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Bnd_BoundSortBox2d_HeaderFile
#define _Bnd_BoundSortBox2d_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Bnd_HArray1OfBox2d.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_HArray1OfListOfInteger.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
//! A tool to compare a 2D bounding box with a set of 2D
//! bounding boxes. It sorts the set of bounding boxes to give
//! the list of boxes which intersect the element being compared.
//! The boxes being sorted generally bound a set of shapes,
//! while the box being compared bounds a shape to be
//! compared. The resulting list of intersecting boxes therefore
//! gives the list of items which potentially intersect the shape to be compared.
class Bnd_BoundSortBox2d
{
public:
DEFINE_STANDARD_ALLOC
//! Constructs an empty comparison algorithm for 2D bounding boxes.
//! The bounding boxes are then defined using the Initialize function.
Standard_EXPORT Bnd_BoundSortBox2d();
//! Initializes this comparison algorithm with
//! - the set of 2D bounding boxes SetOfBox
Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
//! Initializes this comparison algorithm with
//! - the set of 2D bounding boxes SetOfBox, where
//! CompleteBox is given as the global bounding box of SetOfBox.
Standard_EXPORT void Initialize (const Handle(Bnd_HArray1OfBox2d)& SetOfBox);
//! Initializes this comparison algorithm, giving it only
//! - the maximum number nbComponents, and
//! - the global bounding box CompleteBox,
//! of the 2D bounding boxes to be managed. Use the Add
//! function to define the array of bounding boxes to be sorted by this algorithm.
Standard_EXPORT void Initialize (const Bnd_Box2d& CompleteBox, const Standard_Integer nbComponents);
//! Adds the 2D bounding box theBox at position boxIndex in
//! the array of boxes to be sorted by this comparison algorithm.
//! This function is used only in conjunction with the third
//! syntax described in the synopsis of Initialize.
//! Exceptions
//! - Standard_OutOfRange if boxIndex is not in the
//! range [ 1,nbComponents ] where
//! nbComponents is the maximum number of bounding
//! boxes declared for this comparison algorithm at
//! initialization.
//! - Standard_MultiplyDefined if a box still exists at
//! position boxIndex in the array of boxes to be sorted by
//! this comparison algorithm.
Standard_EXPORT void Add (const Bnd_Box2d& theBox, const Standard_Integer boxIndex);
//! Compares the 2D bounding box theBox with the set of
//! bounding boxes to be sorted by this comparison algorithm,
//! and returns the list of intersecting bounding boxes as a list
//! of indexes on the array of bounding boxes used by this algorithm.
Standard_EXPORT const TColStd_ListOfInteger& Compare (const Bnd_Box2d& theBox);
Standard_EXPORT void Dump() const;
protected:
private:
//! Prepares BoundSortBox2d and sorts the rectangles of
//! <SetOfBox> .
Standard_EXPORT void SortBoxes();
Bnd_Box2d myBox;
Handle(Bnd_HArray1OfBox2d) myBndComponents;
Standard_Real Xmin;
Standard_Real Ymin;
Standard_Real deltaX;
Standard_Real deltaY;
Standard_Integer discrX;
Standard_Integer discrY;
Handle(TColStd_HArray1OfListOfInteger) axisX;
Handle(TColStd_HArray1OfListOfInteger) axisY;
Standard_Integer theFound;
TColStd_DataMapOfIntegerInteger Crible;
TColStd_ListOfInteger lastResult;
};
#endif // _Bnd_BoundSortBox2d_HeaderFile

View File

@@ -419,7 +419,7 @@ OBBTool::
myPointBoxSet->SetSize(myPntsList.Length());
// Add the points into Set
for (Standard_Integer iP = 0; iP < theL.Length(); ++iP)
for (Standard_Integer iP = theL.Lower(); iP <= theL.Upper(); ++iP)
{
const gp_Pnt& aP = theL (iP);
Standard_Real aTol = theLT ? theLT->Value(iP) : Precision::Confusion();

View File

@@ -15,8 +15,6 @@ Bnd_B3x.gxx
Bnd_B3x.lxx
Bnd_BoundSortBox.cxx
Bnd_BoundSortBox.hxx
Bnd_BoundSortBox2d.cxx
Bnd_BoundSortBox2d.hxx
Bnd_Box.cxx
Bnd_Box.hxx
Bnd_Box2d.cxx
@@ -28,7 +26,6 @@ Bnd_OBB.cxx
Bnd_OBB.hxx
Bnd_Range.cxx
Bnd_Range.hxx
Bnd_SeqOfBox.hxx
Bnd_Sphere.cxx
Bnd_Sphere.hxx
Bnd_Sphere.lxx

View File

@@ -198,7 +198,7 @@ public:
Standard_Real LowerValue()
{
Standard_Integer a, aResultIndex = 0;
Standard_Real aValue;
Standard_Real aValue = 0.0;
for(a = myV.Length(); a > 0; a--)
{
if (aResultIndex == 0 || Abs(aValue) > Abs(myV.Value(a)))

View File

@@ -732,10 +732,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
if(fd1->IndexOfS1() == fd2->IndexOfS1()) {
jf1 = 1; jf2 = 1;
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
OrSave1 = cd1->Orientation(jf1);
Or = OrFace1 = face.Orientation();
OrSave2 = cd2->Orientation(jf2);
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
OrFace2 = shape2.Orientation();
visavis = Standard_True;
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
// The parameters of the other side are not used for orientation. This would raise problems
@@ -753,10 +756,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
if(fd1->IndexOfS2() == fd2->IndexOfS1()) {
jf1 = 2; jf2 = 1;
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
OrSave1 = cd1->Orientation(jf1);
Or = OrFace1 = face.Orientation();
OrSave2 = cd2->Orientation(jf2);
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
OrFace2 = shape2.Orientation();
visavis = Standard_True;
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
// The parameters of the other side are not used for orientation. This would raise problems
@@ -786,10 +792,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
if(fd1->IndexOfS1() == fd2->IndexOfS2()) {
jf1 = 1; jf2 = 2;
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
OrSave1 = cd1->Orientation(jf1);
Or = OrFace1 = face.Orientation();
OrSave2 = cd2->Orientation(jf2);
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
OrFace2 = shape2.Orientation();
visavis = Standard_True;
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
// The parameters of the other side are not used for orientation.
@@ -819,10 +828,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
if(fd1->IndexOfS2() == fd2->IndexOfS2()) {
jf1 = 2; jf2 = 2;
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
OrSave1 = cd1->Orientation(jf1);
Or = OrFace1 = face.Orientation();
OrSave2 = cd2->Orientation(jf2);
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
OrFace2 = shape2.Orientation();
visavis = Standard_True;
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
// The parameters of the other side are not used for orientation.

View File

@@ -1645,6 +1645,13 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
}
if (compoint1 && compoint2) {
SeqFil.Remove(num);
num = ChFi3d_IndexOfSurfData(Vtx,stripe,sens);
if (isfirst) {
num1=num+1;
}
else {
num1=num-1;
}
reg1=Standard_False; reg2=Standard_False;
}
}
@@ -2115,6 +2122,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
F=Face[nb-1];
if (!prolface[nb-1]) faceprol[nb-1]=F;
}
if (F.IsNull()) throw Standard_NullObject("IntersectionAtEnd : Trying to intersect with NULL face");
Sfacemoins1=BRep_Tool::Surface(F);
Handle(Geom_Curve) cint;
Handle(Geom2d_Curve) C2dint1, C2dint2,cface,cfacemoins1;
@@ -3905,7 +3915,7 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
}
TopoDS_Face FFv;
Standard_Real tol;
Standard_Integer prol;
Standard_Integer prol = 0;
BRep_Builder BRE;
Handle(Geom_Surface ) Sface;
Sface=BRep_Tool::Surface(Fv);

View File

@@ -1780,7 +1780,7 @@ void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& V,
Standard_Integer Sens = 0;
ChFiDS_ListIteratorOfListOfStripe itel(LS);
Standard_Boolean FF = Standard_True;
Standard_Boolean isfirst[2];
Standard_Boolean isfirst[2] = { Standard_True, Standard_True };
Standard_Integer Iedge[2];
Iedge[0] = 1;
Iedge[1] = 1;

View File

@@ -436,15 +436,6 @@ void Cocoa_Window::InvalidateContent (const Handle(Aspect_DisplayConnection)& )
return;
}
if ([NSThread isMainThread])
{
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
[myHView setNeedsDisplay];
#else
[myHView setNeedsDisplay: YES];
#endif
}
else
{
[myHView performSelectorOnMainThread: @selector(invalidateContentOcct:)
withObject: NULL

View File

@@ -0,0 +1,429 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DE_ConfigurationContext.hxx>
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_StreamBuffer.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DE_ConfigurationContext, Standard_Transient)
enum DE_ConfigurationContext_KindOfLine
{
DE_ConfigurationContext_KindOfLine_End,
DE_ConfigurationContext_KindOfLine_Empty,
DE_ConfigurationContext_KindOfLine_Comment,
DE_ConfigurationContext_KindOfLine_Resource,
DE_ConfigurationContext_KindOfLine_Error
};
namespace
{
//=======================================================================
//function : GetLine
//purpose :
//=======================================================================
static Standard_Boolean GetLine(OSD_File& theFile, TCollection_AsciiString& theLine)
{
TCollection_AsciiString aBuffer;
Standard_Integer aBufSize = 10;
Standard_Integer aLen;
theLine.Clear();
do
{
theFile.ReadLine(aBuffer, aBufSize, aLen);
theLine += aBuffer;
if (theFile.IsAtEnd())
{
if (!theLine.Length())
{
return Standard_False;
}
else
{
theLine += "\n";
}
}
} while (theLine.Value(theLine.Length()) != '\n');
return Standard_True;
}
//=======================================================================
//function : WhatKindOfLine
//purpose :
//=======================================================================
static DE_ConfigurationContext_KindOfLine WhatKindOfLine(const TCollection_AsciiString& theLine,
TCollection_AsciiString& theToken1,
TCollection_AsciiString& theToken2)
{
static const TCollection_AsciiString aWhiteSpace = " \t\r\n";
Standard_Integer aPos1 = 0, aPos2 = 0, aPos = 0;
TCollection_AsciiString aLine(theLine);
aLine.LeftAdjust();
aLine.RightAdjust();
if (!aLine.EndsWith(':') && (!aLine.EndsWith(' ') || !aLine.EndsWith('\t') || !aLine.EndsWith('\n')))
{
aLine.InsertAfter(aLine.Length(), " ");
}
if (aLine.Value(1) == '!')
{
return DE_ConfigurationContext_KindOfLine_Comment;
}
aPos1 = aLine.FirstLocationNotInSet(aWhiteSpace, 1, aLine.Length());
if (aLine.Value(aPos1) == '\n')
{
return DE_ConfigurationContext_KindOfLine_Empty;
}
aPos2 = aLine.Location(1, ':', aPos1, aLine.Length());
if (aPos2 == 0 || aPos1 == aPos2)
{
return DE_ConfigurationContext_KindOfLine_Error;
}
for (aPos = aPos2 - 1; aLine.Value(aPos) == '\t' || aLine.Value(aPos) == ' '; aPos--);
theToken1 = aLine.SubString(aPos1, aPos);
if(aPos2 != aLine.Length())
{
aPos2++;
}
aPos = aLine.FirstLocationNotInSet(aWhiteSpace, aPos2, aLine.Length());
if (aPos != 0)
{
if (aLine.Value(aPos) == '\\')
{
switch (aLine.Value(aPos + 1))
{
case '\\':
case ' ':
case '\t':
aPos++;
break;
}
}
}
if (aPos == aLine.Length() || aPos == 0)
{
theToken2.Clear();
}
else
{
aLine.Remove(1, aPos - 1);
aLine.Remove(aLine.Length());
theToken2 = aLine;
}
return DE_ConfigurationContext_KindOfLine_Resource;
}
//=======================================================================
//function : MakeName
//purpose :
//=======================================================================
static TCollection_AsciiString MakeName(const TCollection_AsciiString& theScope,
const TCollection_AsciiString& theParam)
{
TCollection_AsciiString aStr(theScope);
if (!aStr.IsEmpty())
{
aStr += '.';
}
aStr += theParam;
return aStr;
}
}
//=======================================================================
//function : DE_ConfigurationContext
//purpose :
//=======================================================================
DE_ConfigurationContext::DE_ConfigurationContext()
{}
//=======================================================================
//function : Load
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::Load(const TCollection_AsciiString& theConfiguration)
{
OSD_Path aPath = theConfiguration;
OSD_File aFile(aPath);
if (!aFile.Exists())
{
if (!LoadStr(theConfiguration))
{
return false;
}
}
else
{
if (!LoadFile(theConfiguration))
{
return false;
}
}
return true;
}
//=======================================================================
//function : LoadFile
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::LoadFile(const TCollection_AsciiString& theFile)
{
myResource.Clear();
OSD_Path aPath(theFile);
OSD_File aFile = aPath;
TCollection_AsciiString FileName = aPath.Name();
aFile.Open(OSD_ReadOnly, OSD_Protection());
if (aFile.Failed())
{
Message::SendFail("Error: DE Context loading is stopped. Can't open the file");
return Standard_True;
}
TCollection_AsciiString aLine;
while (GetLine(aFile, aLine))
{
if (!load(aLine))
{
Message::SendFail() << "Error: DE Context loading is stopped. Syntax error: " << aLine;
return Standard_False;
}
}
return Standard_True;
}
//=======================================================================
//function : LoadStr
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::LoadStr(const TCollection_AsciiString& theResource)
{
myResource.Clear();
TCollection_AsciiString aLine = "";
const Standard_Integer aLength = theResource.Length();
for (Standard_Integer anInd = 1; anInd <= aLength; anInd++)
{
const Standard_Character aChar = theResource.Value(anInd);
if (aChar != '\n')
aLine += aChar;
if ((aChar == '\n' || anInd == aLength) && !aLine.IsEmpty())
{
if (!load(aLine))
{
Message::SendFail() << "Error: DE Context loading is stopped. Syntax error: " << aLine;
return Standard_False;
}
aLine.Clear();
}
}
return Standard_True;
}
//=======================================================================
//function : IsParamSet
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::IsParamSet(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aResource(MakeName(theScope, theParam));
return myResource.IsBound(aResource);
}
//=======================================================================
//function : RealVal
//purpose :
//=======================================================================
Standard_Real DE_ConfigurationContext::RealVal(const TCollection_AsciiString& theParam,
const Standard_Real theDefValue,
const TCollection_AsciiString& theScope) const
{
Standard_Real aVal = 0.;
return GetReal(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : IntegerVal
//purpose :
//=======================================================================
Standard_Integer DE_ConfigurationContext::IntegerVal(const TCollection_AsciiString& theParam,
const Standard_Integer theDefValue,
const TCollection_AsciiString& theScope) const
{
Standard_Integer aVal = 0;
return GetInteger(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : BooleanVal
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::BooleanVal(const TCollection_AsciiString& theParam,
const Standard_Boolean theDefValue,
const TCollection_AsciiString& theScope) const
{
Standard_Boolean aVal = Standard_False;
return GetBoolean(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : StringVal
//purpose :
//=======================================================================
TCollection_AsciiString DE_ConfigurationContext::StringVal(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theDefValue,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aVal = "";
return GetString(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : GetReal
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetReal(const TCollection_AsciiString& theParam,
Standard_Real& theValue,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aStr;
if (!GetString(theParam, aStr, theScope))
{
return Standard_False;
}
if (aStr.IsRealValue())
{
theValue = aStr.RealValue();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetInteger
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetInteger(const TCollection_AsciiString& theParam,
Standard_Integer& theValue,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aStr;
if (!GetString(theParam, aStr, theScope))
{
return Standard_False;
}
if (aStr.IsIntegerValue())
{
theValue = aStr.IntegerValue();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetBoolean
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetBoolean(const TCollection_AsciiString& theParam,
Standard_Boolean& theValue,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aStr;
if (!GetString(theParam, aStr, theScope))
{
return Standard_False;
}
if (aStr.IsIntegerValue())
{
theValue = aStr.IntegerValue() != 0;
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetString
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetString(const TCollection_AsciiString& theParam,
TCollection_AsciiString& theStr,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aResource = MakeName(theScope, theParam);
return myResource.Find(aResource, theStr);
}
//=======================================================================
//function : GetStringSeq
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetStringSeq(const TCollection_AsciiString& theParam,
TColStd_ListOfAsciiString& theValue,
const TCollection_AsciiString& theScope) const
{
TCollection_AsciiString aStr;
if (!GetString(theParam, aStr, theScope))
{
return Standard_False;
}
theValue.Clear();
TCollection_AsciiString anElem;
const Standard_Integer aLength = aStr.Length();
for (Standard_Integer anInd = 1; anInd <= aLength; anInd++)
{
const Standard_Character aChar = aStr.Value(anInd);
anElem += aChar;
if ((aChar == ' ' || anInd == aLength) && !anElem.IsEmpty())
{
anElem.RightAdjust();
anElem.LeftAdjust();
theValue.Append(anElem);
anElem.Clear();
}
}
return Standard_True;
}
//=======================================================================
//function : load
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::load(const TCollection_AsciiString& theResourceLine)
{
if (theResourceLine.IsEmpty())
{
return Standard_False;
}
TCollection_AsciiString aToken1, aToken2;
DE_ConfigurationContext_KindOfLine aKind = WhatKindOfLine(theResourceLine, aToken1, aToken2);
switch (aKind)
{
case DE_ConfigurationContext_KindOfLine_End:
case DE_ConfigurationContext_KindOfLine_Comment:
case DE_ConfigurationContext_KindOfLine_Empty:
break;
case DE_ConfigurationContext_KindOfLine_Resource:
myResource.Bind(aToken1, aToken2);
break;
case DE_ConfigurationContext_KindOfLine_Error:
break;
}
return Standard_True;
}

View File

@@ -0,0 +1,159 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DE_ConfigurationContext_HeaderFile
#define _DE_ConfigurationContext_HeaderFile
#include <NCollection_DataMap.hxx>
#include <TColStd_ListOfAsciiString.hxx>
typedef NCollection_DataMap<TCollection_AsciiString, TCollection_AsciiString, TCollection_AsciiString> DE_ResourceMap;
//! Provides convenient interface to resource file
//! Allows loading of the resource file and getting attributes'
//! values starting from some scope, for example
//! if scope is defined as "ToV4" and requested parameter
//! is "exec.op", value of "ToV4.exec.op" parameter from
//! the resource file will be returned
class DE_ConfigurationContext : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(DE_ConfigurationContext, Standard_Transient)
//! Creates an empty tool
Standard_EXPORT DE_ConfigurationContext();
//! Import the custom configuration
//! Save all parameters with their values.
//! @param[in] theConfiguration path to configuration file or string value
//! @return true in case of success, false otherwise
Standard_EXPORT Standard_Boolean Load(const TCollection_AsciiString& theConfiguration);
//! Import the resource file.
//! Save all parameters with their values.
//! @param[in] theFile path to the resource file
//! @return true in case of success, false otherwise
Standard_EXPORT Standard_Boolean LoadFile(const TCollection_AsciiString& theFile);
//! Import the resource string.
//! Save all parameters with their values.
//! @param[in] theResource string with resource content
//! @return true in case of success, false otherwise
Standard_EXPORT Standard_Boolean LoadStr(const TCollection_AsciiString& theResource);
//! Checks for existing the parameter name
//! @param[in] theParam complex parameter name
//! @param[in] theScope base parameter name
//! @return Standard_True if parameter is defined in the resource file
Standard_EXPORT Standard_Boolean IsParamSet(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[out] theValue value to get by parameter
//! @param[in] theScope base parameter name
//! @return Standard_False if parameter is not defined or has a wrong type
Standard_EXPORT Standard_Boolean GetReal(const TCollection_AsciiString& theParam,
Standard_Real& theValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[out] theValue value to get by parameter
//! @param[in] theScope base parameter name
//! @return Standard_False if parameter is not defined or has a wrong type
Standard_EXPORT Standard_Boolean GetInteger(const TCollection_AsciiString& theParam,
Standard_Integer& theValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[out] theValue value to get by parameter
//! @param[in] theScope base parameter name
//! @return Standard_False if parameter is not defined or has a wrong type
Standard_EXPORT Standard_Boolean GetBoolean(const TCollection_AsciiString& theParam,
Standard_Boolean& theValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[out] theValue value to get by parameter
//! @param[in] theScope base parameter name
//! @return Standard_False if parameter is not defined or has a wrong type
Standard_EXPORT Standard_Boolean GetString(const TCollection_AsciiString& theParam,
TCollection_AsciiString& theValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[out] theValue value to get by parameter
//! @param[in] theScope base parameter name
//! @return Standard_False if parameter is not defined or has a wrong type
Standard_EXPORT Standard_Boolean GetStringSeq(const TCollection_AsciiString& theParam,
TColStd_ListOfAsciiString& theValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT Standard_Real RealVal(const TCollection_AsciiString& theParam,
const Standard_Real theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT Standard_Integer IntegerVal(const TCollection_AsciiString& theParam,
const Standard_Integer theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT Standard_Boolean BooleanVal(const TCollection_AsciiString& theParam,
const Standard_Boolean theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets value of parameter as being of specific type
//! @param[in] theParam complex parameter name
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT TCollection_AsciiString StringVal(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theDefValue,
const TCollection_AsciiString& theScope = "") const;
//! Gets internal resource map
//! @return map with resource value
Standard_EXPORT const DE_ResourceMap& GetInternalMap() const { return myResource; }
protected:
//! Update the resource with param value from the line
//! @paramp[in] theResourceLine line contains the parameter
//! @return true if theResourceLine has loaded correctly
Standard_Boolean load(const TCollection_AsciiString& theResourceLine);
private:
DE_ResourceMap myResource; //!< Internal parameters map
};
#endif // _DE_ConfigurationContext_HeaderFile

View File

@@ -0,0 +1,149 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DE_ConfigurationNode.hxx>
#include <DE_Provider.hxx>
#include <DE_Wrapper.hxx>
#include <DE_ConfigurationContext.hxx>
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
//=======================================================================
// function : DE_ConfigurationNode
// purpose :
//=======================================================================
DE_ConfigurationNode::DE_ConfigurationNode() :
myIsEnabled(Standard_True)
{}
//=======================================================================
// function : DE_ConfigurationNode
// purpose :
//=======================================================================
DE_ConfigurationNode::DE_ConfigurationNode(const Handle(DE_ConfigurationNode)& theConfigurationNode)
{
GlobalParameters = theConfigurationNode->GlobalParameters;
myIsEnabled = theConfigurationNode->IsEnabled();
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
bool DE_ConfigurationNode::Load(const TCollection_AsciiString& theResourcePath)
{
Handle(DE_ConfigurationContext) aResource = new DE_ConfigurationContext();
aResource->LoadFile(theResourcePath);
return Load(aResource);
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
bool DE_ConfigurationNode::Save(const TCollection_AsciiString& theResourcePath) const
{
OSD_Path aPath = theResourcePath;
OSD_File aFile(aPath);
OSD_Protection aProt;
{
try
{
OCC_CATCH_SIGNALS
aFile.Build(OSD_ReadWrite, aProt);
}
catch (Standard_Failure const&)
{
Message::SendFail() << "Error: Configuration writing process was stopped. Can't build file.";
return false;
}
}
if (aFile.Failed())
{
Message::SendFail() << "Error: Configuration writing process was stopped. Can't build file.";
return false;
}
TCollection_AsciiString aResConfiguration = Save();
aFile.Write(aResConfiguration, aResConfiguration.Length());
aFile.Close();
return true;
}
//=======================================================================
// function : UpdateLoad
// purpose :
//=======================================================================
bool DE_ConfigurationNode::UpdateLoad()
{
return true;
}
//=======================================================================
// function : IsImportSupported
// purpose :
//=======================================================================
bool DE_ConfigurationNode::IsImportSupported() const
{
return false;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool DE_ConfigurationNode::IsExportSupported() const
{
return false;
}
//=======================================================================
// function : CheckForSupport
// purpose :
//=======================================================================
bool DE_ConfigurationNode::CheckExtension(const TCollection_AsciiString& theExtension) const
{
TCollection_AsciiString anExtension(theExtension);
if (anExtension.IsEmpty())
{
return false;
}
if (anExtension.Value(1) == '.')
{
anExtension.Remove(1);
}
const TColStd_ListOfAsciiString& anExtensions = GetExtensions();
for (TColStd_ListOfAsciiString::Iterator anIter(anExtensions);
anIter.More(); anIter.Next())
{
if (TCollection_AsciiString::IsSameString(anIter.Value(), anExtension, Standard_False))
{
return true;
}
}
return false;
}
//=======================================================================
// function : CheckForSupport
// purpose :
//=======================================================================
bool DE_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
{
(void)theBuffer;
return false;
}

View File

@@ -0,0 +1,154 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DE_ConfigurationNode_HeaderFile
#define _DE_ConfigurationNode_HeaderFile
#include <TColStd_ListOfAsciiString.hxx>
class DE_ConfigurationContext;
class DE_Provider;
class NCollection_Buffer;
//! Base class to work with CAD transfer properties.
//! Stores the necessary settings for a single Provider type.
//! Configures and creates special provider to transfer CAD files.
//!
//! Nodes are grouped by Vendor's name and Format type.
//! The Vendor name is not defined by default.
//! The Format type is not defined by default.
//! The supported CAD extensions are not defined by default.
//! The import process is not supported.
//! The export process is not supported.
//!
//! The algorithm for standalone transfer operation:
//! 1) Create new empty Node object
//! 2) Configure the current Node
//! 2.1) Use the external resource file to configure (::Load)
//! 2.2) Change the internal parameters directly:
//! 2.2.1) Change field values of "GlobalParameters"
//! 2.2.2) Change field values of "InternalParameters"
//! 3) Create one-time transfer provider (::BuildProvider)
//! 4) Initiate the transfer process:
//! 4.1) Import (if "::IsImportSupported: returns TRUE)
//! 4.1.1) Validate the support of input format (::CheckContent or ::CheckExtension)
//! 4.1.2) Use created provider's "::Read" method
//! 4.2) Export (if "::IsExportSupported: returns TRUE)
//! 4.2.1) Use created provider's "::Write" method
//! 5) Check the provider's output
class DE_ConfigurationNode : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
public:
//! Initializes all field by default
Standard_EXPORT DE_ConfigurationNode();
//! Copies values of all fields
//! @param[in] theConfigurationNode object to copy
Standard_EXPORT DE_ConfigurationNode(const Handle(DE_ConfigurationNode)& theConfigurationNode);
//! Updates values according the resource file
//! @param[in] theResourcePath file path to resource
//! @return True if Load was successful
Standard_EXPORT virtual bool Load(const TCollection_AsciiString& theResourcePath = "");
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @return True if Load was successful
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) = 0;
//! Writes configuration to the resource file
//! @param[in] theResourcePath file path to resource
//! @return True if Save was successful
Standard_EXPORT bool Save(const TCollection_AsciiString& theResourcePath) const;
//! Writes configuration to the string
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const = 0;
//! Creates new provider for the own format
//! @return new created provider
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() = 0;
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const = 0;
//! Update loading status. Checking for the license.
//! @return Standard_True, if node can be used
Standard_EXPORT virtual bool UpdateLoad();
public:
//! Checks the import supporting
//! @return Standard_True if import is support
Standard_EXPORT virtual bool IsImportSupported() const;
//! Checks the export supporting
//! @return Standard_True if export is support
Standard_EXPORT virtual bool IsExportSupported() const;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const = 0;
//! Gets list of supported file extensions
//! @return list of extensions
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const = 0;
//! Checks the file extension to verify a format
//! @param[in] theExtension input file extension
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckExtension(const TCollection_AsciiString& theExtension) const;
//! Checks the file content to verify a format
//! @param[in] theBuffer read stream buffer to check content
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const;
public:
//! Gets the provider loading status
//! @return Standard_True if the load is correct
Standard_Boolean IsEnabled() const
{
return myIsEnabled;
}
//! Sets the provider loading status
//! @param[in] theIsLoaded input load status
void SetEnabled(const Standard_Boolean theIsLoaded)
{
myIsEnabled = theIsLoaded;
}
public:
//!< Internal parameters for transfer process
struct DE_SectionGlobal
{
Standard_Real LengthUnit = 1.0; //!< Scale length unit value from MM, default 1.0 (MM)
} GlobalParameters;
private:
Standard_Boolean myIsEnabled; //!< Flag to use a current provider for Read or Write process via DE_Wrapper
};
#endif // _DE_ConfigurationNode_HeaderFile

170
src/DE/DE_Provider.cxx Normal file
View File

@@ -0,0 +1,170 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DE_Provider.hxx>
#include <DE_ConfigurationNode.hxx>
#include <Message.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
//=======================================================================
// function : DE_Provider
// purpose :
//=======================================================================
DE_Provider::DE_Provider()
{}
//=======================================================================
// function : DE_Provider
// purpose :
//=======================================================================
DE_Provider::DE_Provider(const Handle(DE_ConfigurationNode)& theNode)
:myNode(theNode)
{}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theDocument;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() <<" doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theDocument;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theDocument;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theDocument;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theShape;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theShape;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theShape;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
(void)thePath;
(void)theShape;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
return Standard_False;
}

167
src/DE/DE_Provider.hxx Normal file
View File

@@ -0,0 +1,167 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DE_Provider_HeaderFile
#define _DE_Provider_HeaderFile
#include <Message_ProgressRange.hxx>
class DE_ConfigurationNode;
class TopoDS_Shape;
class XSControl_WorkSession;
class TDocStd_Document;
//! Base class to make transfer process.
//! Reads or Writes specialized CAD files into/from OCCT.
//! Each operation needs the Configuration Node.
//!
//! Providers are grouped by Vendor's name and Format type.
//! The Vendor name is not defined by default.
//! The Format type is not defined by default.
//! The import process is not supported.
//! The export process is not supported.
//!
//! The algorithm for standalone transfer operation:
//! 1) Create new empty Provider object
//! 2) Configure the current object by special Configuration Node (::SetNode)
//! 3) Initiate the transfer process:
//! 3.1) Call the required Read method (if Read methods are implemented)
//! 3.2) Call the required Write method (if Write methods are implemented)
//! 4) Validate the output values
class DE_Provider : public Standard_Transient
{
public:
DEFINE_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
public:
//! Default constructor
//! Configure translation process with global configuration
Standard_EXPORT DE_Provider();
//! Configure translation process
//! @param[in] theNode object to copy
Standard_EXPORT DE_Provider(const Handle(DE_ConfigurationNode)& theNode);
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const = 0;
//! Gets internal configuration node
//! @return configuration node object
Handle(DE_ConfigurationNode) GetNode() const
{
return myNode;
}
//! Sets internal configuration node
//! @param[in] theNode configuration node to set
void SetNode(const Handle(DE_ConfigurationNode)& theNode)
{
myNode = theNode;
}
private:
Handle(DE_ConfigurationNode) myNode; //!< Internal configuration for the own format
};
#endif // _DE_Provider_HeaderFile

540
src/DE/DE_Wrapper.cxx Normal file
View File

@@ -0,0 +1,540 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DE_Wrapper.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DE_ConfigurationNode.hxx>
#include <DE_Provider.hxx>
#include <Message_ProgressRange.hxx>
#include <NCollection_Buffer.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_FileSystem.hxx>
#include <OSD_Protection.hxx>
#include <Standard_ErrorHandler.hxx>
#include <TopoDS_Shape.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "global";
//=======================================================================
// function : DE_Wrapper
// purpose :
//=======================================================================
DE_Wrapper::DE_Wrapper()
{}
//=======================================================================
// function : DE_Wrapper
// purpose :
//=======================================================================
DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
: DE_Wrapper()
{
if (theWrapper.IsNull())
{
return;
}
GlobalParameters = theWrapper->GlobalParameters;
for (DE_ConfigurationFormatMap::Iterator aFormatIter(theWrapper->Nodes());
aFormatIter.More(); aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
Bind(aVendorIter.Value());
}
}
}
//=======================================================================
// function : GlobalWrapper
// purpose :
//=======================================================================
Handle(DE_Wrapper) DE_Wrapper::GlobalWrapper()
{
static const Handle(DE_Wrapper)& aConfiguration = new DE_Wrapper();
return aConfiguration;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
if (theWS.IsNull())
{
return Read(thePath, theDocument, theProgress);
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theDocument, theWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
if (theWS.IsNull())
{
return Write(thePath, theDocument, theProgress);
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theDocument, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
return Standard_False;
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theWS.IsNull())
{
return Read(thePath, theShape, theProgress);
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theShape, theWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theWS.IsNull())
{
return Write(thePath, theShape, theProgress);
}
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theShape, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_True, aProvider))
{
return Standard_False;
}
return aProvider->Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(DE_Provider) aProvider;
if (!findProvider(thePath, Standard_False, aProvider))
{
return Standard_False;
}
return aProvider->Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Load(const TCollection_AsciiString& theResource,
const Standard_Boolean theIsRecursive)
{
Handle(DE_ConfigurationContext) aResource = new DE_ConfigurationContext();
aResource->Load(theResource);
return Load(aResource, theIsRecursive);
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Load(const Handle(DE_ConfigurationContext)& theResource,
const Standard_Boolean theIsRecursive)
{
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit", GlobalParameters.LengthUnit, THE_CONFIGURATION_SCOPE);
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
aVendorIter.Value()->Load(theResource);
}
}
sort(theResource);
}
return Standard_True;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Save(const TCollection_AsciiString& theResourcePath,
const Standard_Boolean theIsRecursive,
const TColStd_ListOfAsciiString& theFormats,
const TColStd_ListOfAsciiString& theVendors)
{
OSD_Path aPath = theResourcePath;
OSD_File aFile(aPath);
OSD_Protection aProt;
{
try
{
OCC_CATCH_SIGNALS
aFile.Build(OSD_ReadWrite, aProt);
}
catch (Standard_Failure const&)
{
return Standard_False;
}
}
if (aFile.Failed())
{
return Standard_False;
}
TCollection_AsciiString aResConfiguration = Save(theIsRecursive, theFormats, theVendors);
aFile.Write(aResConfiguration, aResConfiguration.Length());
aFile.Close();
return Standard_True;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
const TColStd_ListOfAsciiString& theFormats,
const TColStd_ListOfAsciiString& theVendors)
{
TCollection_AsciiString aResult;
aResult += "!Description of the config file for DE toolkit\n";
aResult += "!*****************************************************************************\n";
aResult += "!\n";
aResult += "!Format of the file is compliant with the standard Open CASCADE resource files\n";
aResult += "!Each key defines a sequence of either further keys.\n";
aResult += "!Keys can be nested down to an arbitrary level.\n";
aResult += "!\n";
aResult += "!*****************************************************************************\n";
aResult += "!DE_Wrapper\n";
aResult += "!Priority vendor list. For every CAD format set indexed list of vendors\n";
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
const TCollection_AsciiString& aFormat = aFormatIter.Key();
aResult += THE_CONFIGURATION_SCOPE + '.' + "priority" + '.' + aFormat + " :\t ";
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
const TCollection_AsciiString& aVendorName = aVendorIter.Value()->GetVendor();
aResult += aVendorName + " ";
}
aResult += "\n";
}
aResult += "!Global parameters. Used for all providers\n";
aResult += "!Length scale unit value. Should be more the 0. Default value: 1.0(MM)\n";
aResult += THE_CONFIGURATION_SCOPE + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
if (!theFormats.IsEmpty() && !theFormats.Contains(aFormatIter.Key()))
{
continue;
}
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
if (!theVendors.IsEmpty() && !theVendors.Contains(aVendorIter.Key()))
{
continue;
}
aResult += "!\n";
aResult += aVendorIter.Value()->Save();
aResult += "!\n";
}
}
}
aResult += "!*****************************************************************************\n";
return aResult;
}
//=======================================================================
// function : Bind
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Bind(const Handle(DE_ConfigurationNode)& theNode)
{
if (theNode.IsNull())
{
return Standard_False;
}
const TCollection_AsciiString aFileFormat = theNode->GetFormat();
const TCollection_AsciiString aVendorName = theNode->GetVendor();
DE_ConfigurationVendorMap* aVendorMap = myConfiguration.ChangeSeek(aFileFormat);
if (aVendorMap == NULL)
{
DE_ConfigurationVendorMap aTmpVendorMap;
aVendorMap = myConfiguration.Bound(aFileFormat, aTmpVendorMap);
}
return aVendorMap->Add(aVendorName, theNode) > 0;
}
//=======================================================================
// function : Find
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::Find(const TCollection_AsciiString& theFormat,
const TCollection_AsciiString& theVendor,
Handle(DE_ConfigurationNode)& theNode) const
{
const DE_ConfigurationVendorMap* aVendorMap = myConfiguration.Seek(theFormat);
return aVendorMap != nullptr && aVendorMap->FindFromKey(theVendor, theNode);
}
//=======================================================================
// function : ChangePriority
// purpose :
//=======================================================================
void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable)
{
DE_ConfigurationVendorMap aVendorMap;
if (!myConfiguration.Find(theFormat, aVendorMap))
{
return;
}
DE_ConfigurationVendorMap aNewVendorMap;
// Sets according to the input priority
for (TColStd_ListOfAsciiString::Iterator aPriorIter(theVendorPriority);
aPriorIter.More(); aPriorIter.Next())
{
const TCollection_AsciiString& aVendorName = aPriorIter.Value();
Handle(DE_ConfigurationNode) aNode;
if (aVendorMap.FindFromKey(aVendorName, aNode))
{
aNode->SetEnabled(Standard_True);
aNode->UpdateLoad();
aNewVendorMap.Add(aVendorName, aNode);
}
}
// Sets not used elements
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aVendorMap);
aVendorIter.More(); aVendorIter.Next())
{
const TCollection_AsciiString& aVendorName = aVendorIter.Key();
if (!theVendorPriority.Contains(aVendorName))
{
Handle(DE_ConfigurationNode) aNode = aVendorIter.Value();
if (theToDisable)
{
aNode->SetEnabled(Standard_False);
}
aNewVendorMap.Add(aVendorName, aNode);
}
}
myConfiguration.Bind(theFormat, aNewVendorMap);
}
//=======================================================================
// function : ChangePriority
// purpose :
//=======================================================================
void DE_Wrapper::ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
ChangePriority(aFormatIter.Key(), theVendorPriority, theToDisable);
}
}
//=======================================================================
// function : Nodes
// purpose :
//=======================================================================
const DE_ConfigurationFormatMap& DE_Wrapper::Nodes() const
{
return myConfiguration;
}
//=======================================================================
// function : Copy
// purpose :
//=======================================================================
Handle(DE_Wrapper) DE_Wrapper::Copy() const
{
return new DE_Wrapper(*this);
}
//=======================================================================
// function : findProvider
// purpose :
//=======================================================================
Standard_Boolean DE_Wrapper::findProvider(const TCollection_AsciiString& thePath,
const Standard_Boolean theToImport,
Handle(DE_Provider)& theProvider) const
{
Handle(NCollection_Buffer) aBuffer;
if (theToImport)
{
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aStream.get() != nullptr)
{
aBuffer = new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), 2048);
aStream->read((char*)aBuffer->ChangeData(), 2048);
aBuffer->ChangeData()[2047] = '\0';
}
}
OSD_Path aPath(thePath);
const TCollection_AsciiString anExtr = aPath.Extension();
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
{
const Handle(DE_ConfigurationNode)& aNode = aVendorIter.Value();
if (aNode->IsEnabled() &&
((theToImport && aNode->IsImportSupported()) ||
(!theToImport && aNode->IsExportSupported())) &&
(aNode->CheckExtension(anExtr) ||
(theToImport && aNode->CheckContent(aBuffer))))
{
theProvider = aNode->BuildProvider();
aNode->GlobalParameters = GlobalParameters;
theProvider->SetNode(aNode);
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
// function : sort
// purpose :
//=======================================================================
void DE_Wrapper::sort(const Handle(DE_ConfigurationContext)& theResource)
{
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE + '.' + "priority");
NCollection_List<Handle(DE_ConfigurationNode)> aVendors;
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
{
TColStd_ListOfAsciiString aVendorPriority;
if (!theResource->GetStringSeq(aFormatIter.Key(), aVendorPriority, aScope))
{
continue;
}
ChangePriority(aFormatIter.Key(), aVendorPriority, Standard_True);
}
}

249
src/DE/DE_Wrapper.hxx Normal file
View File

@@ -0,0 +1,249 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DE_Wrapper_HeaderFile
#define _DE_Wrapper_HeaderFile
#include <Message_ProgressRange.hxx>
#include <DE_ConfigurationNode.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <NCollection_DataMap.hxx>
#include <TColStd_ListOfAsciiString.hxx>
class TopoDS_Shape;
class XSControl_WorkSession;
class TDocStd_Document;
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode), TCollection_AsciiString> DE_ConfigurationVendorMap;
typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap, TCollection_AsciiString> DE_ConfigurationFormatMap;
//! The main class for working with CAD file exchange.
//! Loads and Saves special CAD transfer property.
//! Consolidates all supported Formats and Vendors.
//! Automatically recognizes CAD format and uses the preferred existed Vendor.
//! Note:
//! If Vendor's format is not binded, the configuration loading doesn't affect on its property.
//!
//! Nodes are grouped by Vendor's name and Format's type.
//! The Vendors may have the same supported CAD formats.
//! Use a Vendor's priority for transfer operations.
//!
//! The algorithm for standalone transfer operation:
//! 1) Work with global wrapper directly or make deep copy and work with it
//! 2) Update the supported vendors and formats
//! 2.1) Create and initialize specialized configuration node of the required format and Vendor.
//! 2.2) Bind the created node to the internal map(::Bind)
//! 3) Configure the transfer property by resource string or file (::Load)
//! 3.1) Configuration can disable or enable some Vendors and formats
//! 3.2) Configuration can change the priority of Vendors
//! 4) Initiate the transfer process by calling "::Write" or "::Read" methods
//! 5) Validate the transfer process output
class DE_Wrapper : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
public:
//! Initializes all field by default
Standard_EXPORT DE_Wrapper();
//! Copies values of all fields
//! @param[in] theWrapper object to copy
Standard_EXPORT DE_Wrapper(const Handle(DE_Wrapper)& theWrapper);
//! Gets global configuration singleton
//! @return point to global configuration
Standard_EXPORT static Handle(DE_Wrapper) GlobalWrapper();
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! Updates values according the resource file
//! @param[in] theResource file path to resource or resource value
//! @param[in] theIsRecursive flag to update all nodes
//! @return true if theResource has loaded correctly
Standard_EXPORT Standard_Boolean Load(const TCollection_AsciiString& theResource = "",
const Standard_Boolean theIsRecursive = Standard_True);
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @param[in] theIsRecursive flag to update all nodes
//! @return true if theResource has loaded correctly
Standard_EXPORT Standard_Boolean Load(const Handle(DE_ConfigurationContext)& theResource,
const Standard_Boolean theIsRecursive = Standard_True);
//! Writes configuration to the resource file
//! @param[in] theResourcePath file path to resource
//! @param[in] theIsRecursive flag to write values of all nodes
//! @param[in] theFormats list of formats to save. If empty, saves all available
//! @param[in] theVendors list of providers to save. If empty, saves all available
//! @return true if the Configuration has saved correctly
Standard_EXPORT Standard_Boolean Save(const TCollection_AsciiString& theResourcePath,
const Standard_Boolean theIsRecursive = Standard_True,
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
//! Writes configuration to the string
//! @param[in] theIsRecursive flag to write values of all nodes
//! @param[in] theFormats list of formats to save. If empty, saves all available
//! @param[in] theVendors list of providers to save. If empty, saves all available
//! @return result resource string
Standard_EXPORT TCollection_AsciiString Save(const Standard_Boolean theIsRecursive = Standard_True,
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
//! Creates new node copy and adds to the map
//! @param[in] theNode input node to copy
//! @return Standard_True if binded
Standard_EXPORT Standard_Boolean Bind(const Handle(DE_ConfigurationNode)& theNode);
//! Finds a node associated with input format and vendor
//! @param[in] theFormat input node CAD format
//! @param[in] theVendor input node vendor name
//! @param[out] theNode output node
//! @return Standard_True if the node is found
Standard_EXPORT Standard_Boolean Find(const TCollection_AsciiString& theFormat,
const TCollection_AsciiString& theVendor,
Handle(DE_ConfigurationNode)& theNode) const;
//! Changes provider priority to one format if it exists
//! @param[in] theFormat input node CAD format
//! @param[in] theVendorPriority priority of work with vendors
//! @param[in] theToDisable flag for disabling nodes that are not included in the priority
Standard_EXPORT void ChangePriority(const TCollection_AsciiString& theFormat,
const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable = Standard_False);
//! Changes provider priority to all loaded nodes
//! @param[in] theVendorPriority priority of work with vendors
//! @param[in] theToDisable flag for disabling nodes that are not included in the priority
Standard_EXPORT void ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable = Standard_False);
//! Gets format map, contains vendor map with nodes
//! @return internal map of formats
Standard_EXPORT const DE_ConfigurationFormatMap& Nodes() const;
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT Handle(DE_Wrapper) Copy() const;
protected:
//! Sorts the vendors according to the priority to work
//! Formats omitted from the resource are not modified
//! Vendors omitted from the format scope are disabled
//! @param[in] theResource resource to get priority
void sort(const Handle(DE_ConfigurationContext)& theResource);
//! Find available provider from the configuration.
//! If there are several providers, choose the one with the highest priority.
//! @param[in] thePath path to the CAD file
//! @param[in] theToImport flag to finds for import. Standard_True-import, Standard_False-export
//! @param[out] theProvider created new provider
//! @return Standard_True if provider found and created
Standard_Boolean findProvider(const TCollection_AsciiString& thePath,
const Standard_Boolean theToImport,
Handle(DE_Provider)& theProvider) const;
public:
DE_ConfigurationNode::DE_SectionGlobal GlobalParameters; //!< Internal parameters for the all translators
private:
DE_ConfigurationFormatMap myConfiguration; //!< Internal map of formats
};
#endif // _DE_Wrapper_HeaderFile

8
src/DE/FILES Normal file
View File

@@ -0,0 +1,8 @@
DE_ConfigurationContext.cxx
DE_ConfigurationContext.hxx
DE_ConfigurationNode.cxx
DE_ConfigurationNode.hxx
DE_Provider.cxx
DE_Provider.hxx
DE_Wrapper.cxx
DE_Wrapper.hxx

View File

@@ -0,0 +1,199 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DEBRepCascade_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DEBRepCascade_Provider.hxx>
#include <NCollection_Buffer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
//=======================================================================
// function : DEBRepCascade_ConfigurationNode
// purpose :
//=======================================================================
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode() :
DE_ConfigurationNode()
{
UpdateLoad();
}
//=======================================================================
// function : DEBRepCascade_ConfigurationNode
// purpose :
//=======================================================================
DEBRepCascade_ConfigurationNode::DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode)
:DE_ConfigurationNode(theNode)
{
InternalParameters = theNode->InternalParameters;
UpdateLoad();
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
bool DEBRepCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
InternalParameters.WriteBinary =
theResource->BooleanVal("write.binary", InternalParameters.WriteBinary, aScope);
InternalParameters.WriteVersionBin =
(BinTools_FormatVersion)theResource->IntegerVal("write.version.binary", InternalParameters.WriteVersionBin, aScope);
InternalParameters.WriteVersionAscii =
(TopTools_FormatVersion)theResource->IntegerVal("write.version.ascii", InternalParameters.WriteVersionAscii, aScope);
InternalParameters.WriteTriangles =
theResource->BooleanVal("write.triangles", InternalParameters.WriteTriangles, aScope);
InternalParameters.WriteNormals =
theResource->BooleanVal("write.normals", InternalParameters.WriteNormals, aScope);
return true;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
TCollection_AsciiString DEBRepCascade_ConfigurationNode::Save() const
{
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Write parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the binary file format\n";
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
aResult += aScope + "write.binary :\t " + InternalParameters.WriteBinary + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the format version for the binary format writing\n";
aResult += "!Default value: 4. Available values: 1, 2, 3, 4\n";
aResult += aScope + "write.version.binary :\t " + InternalParameters.WriteVersionBin + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the format version for the ASCII format writing\n";
aResult += "!Default value: 3. Available values: 1, 2, 3\n";
aResult += aScope + "write.version.ascii :\t " + InternalParameters.WriteVersionAscii + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the flag for storing shape with(without) triangles\n";
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
aResult += aScope + "write.triangles :\t " + InternalParameters.WriteTriangles + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the flag for storing shape with(without) normals\n";
aResult += "!Default value: 1. Available values: 0(\"off\"), 1(\"on\")\n";
aResult += aScope + "write.normals :\t " + InternalParameters.WriteNormals + "\n";
aResult += "!\n";
aResult += "!*****************************************************************************\n";
return aResult;
}
//=======================================================================
// function : Copy
// purpose :
//=======================================================================
Handle(DE_ConfigurationNode) DEBRepCascade_ConfigurationNode::Copy() const
{
return new DEBRepCascade_ConfigurationNode(*this);
}
//=======================================================================
// function : BuildProvider
// purpose :
//=======================================================================
Handle(DE_Provider) DEBRepCascade_ConfigurationNode::BuildProvider()
{
return new DEBRepCascade_Provider(this);
}
//=======================================================================
// function : IsImportSupported
// purpose :
//=======================================================================
bool DEBRepCascade_ConfigurationNode::IsImportSupported() const
{
return true;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool DEBRepCascade_ConfigurationNode::IsExportSupported() const
{
return true;
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetFormat() const
{
return TCollection_AsciiString("BREP");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString DEBRepCascade_ConfigurationNode::GetVendor() const
{
return TCollection_AsciiString("OCC");
}
//=======================================================================
// function : GetExtensions
// purpose :
//=======================================================================
TColStd_ListOfAsciiString DEBRepCascade_ConfigurationNode::GetExtensions() const
{
TColStd_ListOfAsciiString anExt;
anExt.Append("brep");
return anExt;
}
//=======================================================================
// function : CheckContent
// purpose :
//=======================================================================
bool DEBRepCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
{
if (theBuffer.IsNull() || theBuffer->Size() < 20)
{
return false;
}
const char* aBytes = (const char*)theBuffer->Data();
if (::strstr(aBytes, "DBRep_DrawableShape") ||
::strstr(aBytes, "CASCADE Topology V1") ||
::strstr(aBytes, "CASCADE Topology V3"))
{
return true;
}
return false;
}

View File

@@ -0,0 +1,102 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DEBRepCascade_ConfigurationNode_HeaderFile
#define _DEBRepCascade_ConfigurationNode_HeaderFile
#include <DE_ConfigurationNode.hxx>
#include <BinTools_FormatVersion.hxx>
#include <TopTools_FormatVersion.hxx>
//! The purpose of this class is to configure the transfer process for BRep format
//! Stores the necessary settings for DEBRepCascade_Provider.
//! Configures and creates special provider to transfer BRep files.
//!
//! Nodes grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "BREP"
//! The supported CAD extension is ".brep"
//! The import process is supported.
//! The export process is supported.
class DEBRepCascade_ConfigurationNode : public DE_ConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(DEBRepCascade_ConfigurationNode, DE_ConfigurationNode)
public:
//! Initializes all field by default
Standard_EXPORT DEBRepCascade_ConfigurationNode();
//! Copies values of all fields
//! @param[in] theNode object to copy
Standard_EXPORT DEBRepCascade_ConfigurationNode(const Handle(DEBRepCascade_ConfigurationNode)& theNode);
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @return true if theResource loading has ended correctly
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
//! Writes configuration to the string
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
//! Creates new provider for the own format
//! @return new created provider
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
public:
//! Checks the import supporting
//! @return true if import is supported
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
//! Checks the export supporting
//! @return true if export is supported
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
//! Gets list of supported file extensions
//! @return list of extensions
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
//! Checks the file content to verify a format
//! @param[in] theBuffer read stream buffer to check content
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
public:
struct DEBRep_InternalSection
{
// Write
bool WriteBinary = true; //!< Defines the binary file format
BinTools_FormatVersion WriteVersionBin = BinTools_FormatVersion_CURRENT; //!< Defines the writer version for the binary format
TopTools_FormatVersion WriteVersionAscii = TopTools_FormatVersion_CURRENT; //!< Defines the writer version for the ASCII format
bool WriteTriangles = true; //!< Defines the flag for storing shape with(without) triangles
bool WriteNormals = true; //!< Defines the flag for storing shape with(without) normals
} InternalParameters;
};
#endif // _DEBRepCascade_ConfigurationNode_HeaderFile

View File

@@ -0,0 +1,295 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DEBRepCascade_Provider.hxx>
#include <BinTools.hxx>
#include <BinXCAFDrivers.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <DEBRepCascade_ConfigurationNode.hxx>
#include <Message.hxx>
#include <OSD_FileSystem.hxx>
#include <TDocStd_Document.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
//=======================================================================
// function : DEBRepCascade_Provider
// purpose :
//=======================================================================
DEBRepCascade_Provider::DEBRepCascade_Provider()
{}
//=======================================================================
// function : DEBRepCascade_Provider
// purpose :
//=======================================================================
DEBRepCascade_Provider::DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
:DE_Provider(theNode)
{}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if(theDocument.IsNull())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
TopoDS_Shape aShape;
if (!Read(thePath, aShape, theProgress))
{
return false;
}
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aShTool->AddShape(aShape);
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
TopoDS_Shape aShape;
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Document contain no shapes";
return false;
}
if (aLabels.Length() == 1)
{
aShape = aSTool->GetShape(aLabels.Value(1));
}
else
{
TopoDS_Compound aComp;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aComp);
for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
{
TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
aBuilder.Add(aComp, aS);
}
aShape = aComp;
}
return Write(thePath, aShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
bool isBinaryFormat = true;
{
// probe file header to recognize format
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aFile.get() == NULL)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
return false;
}
char aStringBuf[255] = {};
aFile->read(aStringBuf, 255);
if (aFile->fail())
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read the file";
return false;
}
isBinaryFormat = !(::strncmp(aStringBuf, "DBRep_DrawableShape", 19) == 0);
}
if (isBinaryFormat)
{
if (!BinTools::Read(theShape, thePath.ToCString(), theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
}
else
{
if (!BRepTools::Read(theShape, thePath.ToCString(), BRep_Builder(), theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during reading the file " <<
thePath << "\t: Cannot read from the file";
return false;
}
}
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEBRepCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEBRepCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(DEBRepCascade_ConfigurationNode) aNode = Handle(DEBRepCascade_ConfigurationNode)::DownCast(GetNode());
if (aNode->InternalParameters.WriteBinary)
{
if (aNode->InternalParameters.WriteVersionBin > static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionBin < static_cast<BinTools_FormatVersion>(BinTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionBin < BinTools_FormatVersion_VERSION_4)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Vertex normals require binary format version 4 or later";
return false;
}
if (!BinTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionBin, theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
return false;
}
}
else
{
if (aNode->InternalParameters.WriteVersionAscii > static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_UPPER) ||
aNode->InternalParameters.WriteVersionAscii < static_cast<TopTools_FormatVersion>(TopTools_FormatVersion_LOWER))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Unknown format version";
return false;
}
if (aNode->InternalParameters.WriteNormals &&
aNode->InternalParameters.WriteVersionAscii < TopTools_FormatVersion_VERSION_3)
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Error: vertex normals require ascii format version 3 or later";
return false;
}
if (!BRepTools::Write(theShape, thePath.ToCString(), aNode->InternalParameters.WriteTriangles,
aNode->InternalParameters.WriteNormals, aNode->InternalParameters.WriteVersionAscii, theProgress))
{
Message::SendFail() << "Error in the DEBRepCascade_Provider during writing the file " <<
thePath << "\t: Cannot write the file";
return false;
}
}
return true;
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString DEBRepCascade_Provider::GetFormat() const
{
return TCollection_AsciiString("BREP");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString DEBRepCascade_Provider::GetVendor() const
{
return TCollection_AsciiString("OCC");
}

View File

@@ -0,0 +1,136 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DEBRepCascade_Provider_HeaderFile
#define _DEBRepCascade_Provider_HeaderFile
#include <DE_Provider.hxx>
//! The class to transfer BRep files.
//! Reads and Writes any BRep files into/from OCCT.
//! Each operation needs configuration node.
//!
//! Providers grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "BREP"
//! The import process is supported.
//! The export process is supported.
class DEBRepCascade_Provider : public DE_Provider
{
public:
DEFINE_STANDARD_RTTIEXT(DEBRepCascade_Provider, DE_Provider)
public:
//! Default constructor
//! Configure translation process with global configuration
Standard_EXPORT DEBRepCascade_Provider();
//! Configure translation process
//! @param[in] theNode object to init the DE_Provider
Standard_EXPORT DEBRepCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
};
#endif // _DEBRepCascade_Provider_HeaderFile

4
src/DEBRepCascade/FILES Normal file
View File

@@ -0,0 +1,4 @@
DEBRepCascade_ConfigurationNode.cxx
DEBRepCascade_ConfigurationNode.hxx
DEBRepCascade_Provider.cxx
DEBRepCascade_Provider.hxx

View File

@@ -0,0 +1,190 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DEXCAFCascade_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DEXCAFCascade_Provider.hxx>
#include <NCollection_Buffer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
//=======================================================================
// function : DEXCAFCascade_ConfigurationNode
// purpose :
//=======================================================================
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode() :
DE_ConfigurationNode()
{
UpdateLoad();
}
//=======================================================================
// function : DEXCAFCascade_ConfigurationNode
// purpose :
//=======================================================================
DEXCAFCascade_ConfigurationNode::DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode)
:DE_ConfigurationNode(theNode)
{
InternalParameters = theNode->InternalParameters;
UpdateLoad();
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
bool DEXCAFCascade_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadAppendMode = (PCDM_ReaderFilter::AppendMode)
theResource->IntegerVal("read.append.mode", InternalParameters.ReadAppendMode, aScope);
theResource->GetStringSeq("read.skip.values", InternalParameters.ReadSkipValues, aScope);
theResource->GetStringSeq("read.values", InternalParameters.ReadValues, aScope);
return true;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::Save() const
{
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Read parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Don't allow append (when the value = 0, it is the default value), ";
aResult += "keeps existing attributes, reads only new ones(when the value = 1), ";
aResult += "overwrites the existing attributes by the loaded ones(when the value = 2)\n";
aResult += "!Default value: 0. Available values: 0, 1, 2\n";
aResult += aScope + "read.append.mode :\t " + InternalParameters.ReadAppendMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Overwrites the existing attributes by the loaded ones";
aResult += "!Default value: empty. Available values: {sequence<string>}\n";
aResult += aScope + "read.skip.values :\t ";
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
{
aResult += anIt.Value() + " ";
}
aResult += "\n!\n";
aResult += "!\n";
aResult += "!1) Adds sub-tree path like \"0:2\"";
aResult += "2) Adds attribute to read by typename. Disables the skipped attributes added. (there shouldn't be '0' after -read)\n";
aResult += "!Default value: empty. Available values: {sequence<string>}\n";
aResult += aScope + "read.values :\t ";
for (TColStd_ListOfAsciiString::Iterator anIt(InternalParameters.ReadValues); anIt.More(); anIt.Next())
{
aResult += anIt.Value() + " ";
}
aResult += "\n!\n";
aResult += "!*****************************************************************************\n";
return aResult;
}
//=======================================================================
// function : Copy
// purpose :
//=======================================================================
Handle(DE_ConfigurationNode) DEXCAFCascade_ConfigurationNode::Copy() const
{
return new DEXCAFCascade_ConfigurationNode(*this);
}
//=======================================================================
// function : BuildProvider
// purpose :
//=======================================================================
Handle(DE_Provider) DEXCAFCascade_ConfigurationNode::BuildProvider()
{
return new DEXCAFCascade_Provider();
}
//=======================================================================
// function : IsImportSupported
// purpose :
//=======================================================================
bool DEXCAFCascade_ConfigurationNode::IsImportSupported() const
{
return true;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool DEXCAFCascade_ConfigurationNode::IsExportSupported() const
{
return true;
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetFormat() const
{
return TCollection_AsciiString("XCAF");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString DEXCAFCascade_ConfigurationNode::GetVendor() const
{
return TCollection_AsciiString("OCC");
}
//=======================================================================
// function : GetExtensions
// purpose :
//=======================================================================
TColStd_ListOfAsciiString DEXCAFCascade_ConfigurationNode::GetExtensions() const
{
TColStd_ListOfAsciiString anExt;
anExt.Append("xbf");
return anExt;
}
//=======================================================================
// function : CheckContent
// purpose :
//=======================================================================
bool DEXCAFCascade_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
{
if (theBuffer.IsNull() || theBuffer->Size() < 8)
{
return false;
}
const char* aBytes = (const char*)theBuffer->Data();
if (!::strncmp(aBytes, "BINFILE", 7))
{
return true;
}
return false;
}

View File

@@ -0,0 +1,99 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DEXCAFCascade_ConfigurationNode_HeaderFile
#define _DEXCAFCascade_ConfigurationNode_HeaderFile
#include <DE_ConfigurationNode.hxx>
#include <PCDM_ReaderFilter.hxx>
#include <TColStd_ListOfAsciiString.hxx>
//! The purpose of this class is to configure the transfer process for XDE Documents
//! Stores the necessary settings for DEXCAFCascade_Provider.
//! Configures and creates special provider to transfer XDE Documents.
//!
//! Nodes grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "XCAF"
//! The supported CAD extension is ".xbf"
//! The import process is supported.
//! The export process is supported.
class DEXCAFCascade_ConfigurationNode : public DE_ConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_ConfigurationNode, DE_ConfigurationNode)
public:
//! Initializes all field by default
Standard_EXPORT DEXCAFCascade_ConfigurationNode();
//! Copies values of all fields
//! @param[in] theNode object to copy
Standard_EXPORT DEXCAFCascade_ConfigurationNode(const Handle(DEXCAFCascade_ConfigurationNode)& theNode);
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @return true if theResource loading has ended correctly
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
//! Writes configuration to the string
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
//! Creates new provider for the own format
//! @return new created provider
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
public:
//! Checks the import supporting
//! @return true if import is supported
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
//! Checks the export supporting
//! @return true if export is supported
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
//! Gets list of supported file extensions
//! @return list of extensions
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
//! Checks the file content to verify a format
//! @param[in] theBuffer read stream buffer to check content
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
public:
struct XCAFDoc_InternalSection
{
// Read
PCDM_ReaderFilter::AppendMode ReadAppendMode = PCDM_ReaderFilter::AppendMode::AppendMode_Forbid; //!< Setting up the append mode
TColStd_ListOfAsciiString ReadSkipValues; //!< Overwrites the existing attributes by the loaded ones
TColStd_ListOfAsciiString ReadValues; //!< Adds sub-tree path or adds attribute to read by typename
} InternalParameters;
};
#endif // _DEXCAFCascade_ConfigurationNode_HeaderFile

View File

@@ -0,0 +1,308 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <DEXCAFCascade_Provider.hxx>
#include <BinDrivers.hxx>
#include <BinLDrivers.hxx>
#include <BinTObjDrivers.hxx>
#include <BinXCAFDrivers.hxx>
#include <StdDrivers.hxx>
#include <StdLDrivers.hxx>
#include <XmlDrivers.hxx>
#include <XmlLDrivers.hxx>
#include <XmlTObjDrivers.hxx>
#include <XmlXCAFDrivers.hxx>
#include <BRep_Builder.hxx>
#include <DEXCAFCascade_ConfigurationNode.hxx>
#include <Message.hxx>
#include <TDocStd_Application.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
IMPLEMENT_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
//=======================================================================
// function : DEXCAFCascade_Provider
// purpose :
//=======================================================================
DEXCAFCascade_Provider::DEXCAFCascade_Provider()
{}
//=======================================================================
// function : DEXCAFCascade_Provider
// purpose :
//=======================================================================
DEXCAFCascade_Provider::DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode)
:DE_Provider(theNode)
{}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(DEXCAFCascade_ConfigurationNode) aNode = Handle(DEXCAFCascade_ConfigurationNode)::DownCast(GetNode());
Handle(TDocStd_Document) aDocument;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinDrivers::DefineFormat(anApp);
BinLDrivers::DefineFormat(anApp);
BinTObjDrivers::DefineFormat(anApp);
BinXCAFDrivers::DefineFormat(anApp);
StdDrivers::DefineFormat(anApp);
StdLDrivers::DefineFormat(anApp);
XmlDrivers::DefineFormat(anApp);
XmlLDrivers::DefineFormat(anApp);
XmlTObjDrivers::DefineFormat(anApp);
XmlXCAFDrivers::DefineFormat(anApp);
Handle(PCDM_ReaderFilter) aFilter = new PCDM_ReaderFilter(aNode->InternalParameters.ReadAppendMode);
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadSkipValues); anIt.More(); anIt.Next())
{
aFilter->AddSkipped(anIt.Value());
}
for (TColStd_ListOfAsciiString::Iterator anIt(aNode->InternalParameters.ReadValues); anIt.More(); anIt.Next())
{
if (anIt.Value().StartsWith("0"))
{
aFilter->AddPath(anIt.Value());
}
else
{
aFilter->AddRead(anIt.Value());
}
}
if (anApp->Open(thePath, aDocument, aFilter, theProgress) != PCDM_RS_OK)
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Cannot open XDE document";
return false;
}
theDocument->SetData(aDocument->GetData());
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
PCDM_StoreStatus aStatus = PCDM_SS_Doc_IsNull;
if (!thePath.IsEmpty())
{
aStatus = anApp->SaveAs(theDocument, thePath, theProgress);
}
else if (!theDocument->IsSaved())
{
Message::SendFail() << "Storage error in the DEXCAFCascade_Provider during writing the file " <<
thePath << "\t: Storage error : this document has never been saved";
return false;
}
else
{
aStatus = anApp->Save(theDocument, theProgress);
}
switch (aStatus)
{
case PCDM_SS_OK:
return true;
case PCDM_SS_DriverFailure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : driver failure";
break;
case PCDM_SS_WriteFailure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during the writing the file : " << thePath
<< "\t: Storage error : write failure";
break;
case PCDM_SS_Failure:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : general failure";
break;
case PCDM_SS_Doc_IsNull:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error :: document is NULL";
break;
case PCDM_SS_No_Obj:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : no object";
break;
case PCDM_SS_Info_Section_Error:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : section error";
break;
case PCDM_SS_UserBreak:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : user break";
break;
case PCDM_SS_UnrecognizedFormat:
Message::SendFail() << "Error in the DEXCAFCascade_Provider during writing the file : " << thePath
<< "\t: Storage error : unrecognized document storage format : " << theDocument->StorageFormat();
break;
}
return false;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
return Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
if (GetNode().IsNull() || !GetNode()->IsKind(STANDARD_TYPE(DEXCAFCascade_ConfigurationNode)))
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file " << thePath
<< "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(TDocStd_Document) aDocument;
Handle(TDocStd_Application) anApp = new TDocStd_Application();
BinXCAFDrivers::DefineFormat(anApp);
anApp->NewDocument("BinXCAF", aDocument);
Read(thePath, aDocument, theProgress);
TDF_LabelSequence aLabels;
Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(aDocument->Main());
aSTool->GetFreeShapes(aLabels);
if (aLabels.Length() <= 0)
{
Message::SendFail() << "Error in the DEXCAFCascade_Provider during reading the file : " << thePath
<< "\t: Document contain no shapes";
return false;
}
if (aLabels.Length() == 1)
{
theShape = aSTool->GetShape(aLabels.Value(1));
}
else
{
TopoDS_Compound aComp;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aComp);
for (Standard_Integer anIndex = 1; anIndex <= aLabels.Length(); anIndex++)
{
TopoDS_Shape aS = aSTool->GetShape(aLabels.Value(anIndex));
aBuilder.Add(aComp, aS);
}
theShape = aComp;
}
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool DEXCAFCascade_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(TDocStd_Document) aDoc = new TDocStd_Document("BinXCAF");
Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShTool->AddShape(theShape);
return Write(thePath, aDoc, theProgress);
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString DEXCAFCascade_Provider::GetFormat() const
{
return TCollection_AsciiString("XCAF");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString DEXCAFCascade_Provider::GetVendor() const
{
return TCollection_AsciiString("OCC");
}

View File

@@ -0,0 +1,136 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _DEXCAFCascade_Provider_HeaderFile
#define _DEXCAFCascade_Provider_HeaderFile
#include <DE_Provider.hxx>
//! The class to transfer XCAF Documents.
//! Reads and Writes any XDE Document files into/from OCCT.
//! Each operation needs configuration node.
//!
//! Providers grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "XCAF"
//! The import process is supported.
//! The export process is supported.
class DEXCAFCascade_Provider : public DE_Provider
{
public:
DEFINE_STANDARD_RTTIEXT(DEXCAFCascade_Provider, DE_Provider)
public:
//! Default constructor
//! Configure translation process with global configuration
Standard_EXPORT DEXCAFCascade_Provider();
//! Configure translation process
//! @param[in] theNode object to copy
Standard_EXPORT DEXCAFCascade_Provider(const Handle(DE_ConfigurationNode)& theNode);
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
};
#endif // _DEXCAFCascade_Provider_HeaderFile

4
src/DEXCAFCascade/FILES Normal file
View File

@@ -0,0 +1,4 @@
DEXCAFCascade_ConfigurationNode.cxx
DEXCAFCascade_ConfigurationNode.hxx
DEXCAFCascade_Provider.cxx
DEXCAFCascade_Provider.hxx

View File

@@ -60,7 +60,7 @@ public:
//! of this conic is recomputed normal to theA, without
//! changing the orientation of the local coordinate
//! system (right-handed or left-handed).
void SetYAxis (const gp_Ax2d& theAY) { pos.SetXAxis(theAY); }
void SetYAxis (const gp_Ax2d& theAY) { pos.SetYAxis(theAY); }
//! Modifies this conic, redefining its local coordinate
//! system partially, by assigning theP as its origin.

View File

@@ -102,41 +102,6 @@ static Standard_Real EvalAngle(const gp_Vec& V1,
return angle;
}
static Standard_Integer NbSamples(const Handle(Geom_Curve)& aCurve)
{
Standard_Real nbs = 100.; //on default
Handle(Geom_Curve) theCurve = aCurve;
if (aCurve->IsInstance(STANDARD_TYPE(Geom_TrimmedCurve)))
theCurve = (Handle(Geom_TrimmedCurve)::DownCast(aCurve))->BasisCurve();
if (theCurve->IsInstance(STANDARD_TYPE(Geom_Line)))
nbs = 1;
else if (theCurve->IsKind(STANDARD_TYPE(Geom_Conic)))
nbs = 4;
else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BezierCurve)))
{
Handle(Geom_BezierCurve) BC = Handle(Geom_BezierCurve)::DownCast(theCurve);
nbs = 3 + BC->NbPoles();
}
else if (theCurve->IsInstance(STANDARD_TYPE(Geom_BSplineCurve)))
{
Handle(Geom_BSplineCurve) BC = Handle(Geom_BSplineCurve)::DownCast(theCurve);
nbs = BC->NbKnots();
nbs *= BC->Degree();
Standard_Real ratio =
(aCurve->LastParameter() - aCurve->FirstParameter())/(BC->LastParameter() - BC->FirstParameter());
nbs *= ratio;
if(nbs < 4.0)
nbs = 4;
}
if (nbs > 300.)
nbs = 300;
return ((Standard_Integer)nbs);
}
//===============================================================
// Function :DistMini
// Purpose : Examine un extrema pour updater <Dist> & <Param>
@@ -495,24 +460,22 @@ void GeomFill_SectionPlacement::Perform(const Handle(Adaptor3d_Curve)& Path,
}
}
}
if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
{
Standard_Integer NbPnts = NbSamples( mySection );
TColgp_Array1OfPnt Pnts( 1, NbPnts+1 );
Standard_Real delta = (mySection->LastParameter()-mySection->FirstParameter())/NbPnts;
for (ii = 0; ii <= NbPnts; ii++)
Pnts(ii+1) = mySection->Value( mySection->FirstParameter() + ii*delta );
gp_Pnt BaryCenter;
gp_Dir Xdir, Ydir;
Standard_Real Xgap, Ygap, Zgap;
GeomLib::Inertia( Pnts, BaryCenter, Xdir, Ydir, Xgap, Ygap, Zgap );
gp_Pnt Pfirst = Path->Value( Path->FirstParameter() );
if (Pfirst.Distance(BaryCenter) < Plast.Distance(BaryCenter))
PathParam = Path->FirstParameter();
else
{
if (!Intersector.IsDone() || Intersector.NbPoints() == 0)
{
// Comparing the distances from the path's endpoints to the best matching plane of the profile.
const gp_Pnt firstPoint = Path->Value(Path->FirstParameter());
const gp_Pnt lastPoint = Path->Value(Path->LastParameter());
const gp_Pln plane = plan->Pln();
Standard_Real firstDistance = plane.SquareDistance(firstPoint);
Standard_Real lastDistance = plane.SquareDistance(lastPoint);
if (((Abs(firstDistance) < Precision::SquareConfusion()) && Abs(lastDistance) < Precision::SquareConfusion()) ||
firstDistance < lastDistance)
{
PathParam = Path->FirstParameter();
}
else
{
PathParam = Path->LastParameter();
Tangente (*Path, PathParam, PonPath, dp1);
PonSec = myAdpSection.Value(SecParam);

View File

@@ -543,7 +543,11 @@ static Standard_Integer tobezier(Draw_Interpretor& di,
if ( C3d.IsNull()) {
Handle(Geom_BSplineSurface) S =
DrawTrSurf::GetBSplineSurface(a[2]);
if ( S.IsNull()) return 1;
if (S.IsNull())
{
delete[] name;
return 1;
}
if (n == 7) {
Standard_Real U1, U2, V1, V2;
U1 = Draw::Atof(a[3]);
@@ -631,6 +635,8 @@ static Standard_Integer tobezier(Draw_Interpretor& di,
}
}
delete[] name;
return 0;
}

View File

@@ -36,7 +36,6 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM
//
myStructureManager (theMgr),
myCamera (new Graphic3d_Camera()),
myHiddenObjects (new Graphic3d_NMapOfTransient()),
myIsInComputedMode (Standard_False),
myIsActive (Standard_False),
myIsRemoved (Standard_False),

View File

@@ -134,12 +134,6 @@ public:
//! Returns number of displayed structures in the view.
virtual Standard_Integer NumberOfDisplayedStructures() const { return myStructsDisplayed.Extent(); }
//! Returns map of objects hidden within this specific view (not viewer-wise).
const Handle(Graphic3d_NMapOfTransient)& HiddenObjects() const { return myHiddenObjects; }
//! Returns map of objects hidden within this specific view (not viewer-wise).
Handle(Graphic3d_NMapOfTransient)& ChangeHiddenObjects() { return myHiddenObjects; }
//! Returns Standard_True in case if the structure with the given <theStructId> is
//! in list of structures to be computed and stores computed struct to <theComputedStruct>.
Standard_EXPORT Standard_Boolean IsComputed (const Standard_Integer theStructId,
@@ -649,7 +643,6 @@ protected:
Graphic3d_SequenceOfStructure myStructsToCompute;
Graphic3d_SequenceOfStructure myStructsComputed;
Graphic3d_MapOfStructure myStructsDisplayed;
Handle(Graphic3d_NMapOfTransient) myHiddenObjects;
Standard_Boolean myIsInComputedMode;
Standard_Boolean myIsActive;
Standard_Boolean myIsRemoved;

View File

@@ -16,6 +16,7 @@
#include <Aspect_PolygonOffsetMode.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Integer.hxx>
//! Polygon offset parameters.
struct Graphic3d_PolygonOffset

View File

@@ -182,29 +182,45 @@ void Graphic3d_StructureManager::RecomputeStructures (const NCollection_Map<Grap
}
}
Handle(Graphic3d_ViewAffinity) Graphic3d_StructureManager::RegisterObject (const Handle(Standard_Transient)& theObject)
// ========================================================================
// function : RegisterObject
// purpose :
// ========================================================================
void Graphic3d_StructureManager::RegisterObject (const Handle(Standard_Transient)& theObject,
const Handle(Graphic3d_ViewAffinity)& theAffinity)
{
Handle(Graphic3d_ViewAffinity) aResult;
if (myRegisteredObjects.Find (theObject.operator->(), aResult))
if (myRegisteredObjects.Find (theObject.operator->(), aResult)
&& aResult == theAffinity)
{
return aResult;
return;
}
aResult = new Graphic3d_ViewAffinity();
myRegisteredObjects.Bind (theObject.operator->(), aResult);
return aResult;
myRegisteredObjects.Bind (theObject.operator->(), theAffinity);
}
// ========================================================================
// function : UnregisterObject
// purpose :
// ========================================================================
void Graphic3d_StructureManager::UnregisterObject (const Handle(Standard_Transient)& theObject)
{
myRegisteredObjects.UnBind (theObject.operator->());
}
Handle(Graphic3d_ViewAffinity) Graphic3d_StructureManager::ObjectAffinity (const Handle(Standard_Transient)& theObject) const
// ========================================================================
// function : ObjectAffinity
// purpose :
// ========================================================================
const Handle(Graphic3d_ViewAffinity)& Graphic3d_StructureManager::ObjectAffinity (const Handle(Standard_Transient)& theObject) const
{
Handle(Graphic3d_ViewAffinity) aResult;
myRegisteredObjects.Find (theObject.operator->(), aResult);
return aResult;
const Handle(Graphic3d_ViewAffinity)* aResult = myRegisteredObjects.Seek (theObject.operator->());
if (aResult == nullptr)
{
static const Handle(Graphic3d_ViewAffinity) aDummy;
return aDummy;
}
return *aResult;
}
// ========================================================================

View File

@@ -151,11 +151,12 @@ public:
//! Recomputes all structures from theStructures.
Standard_EXPORT void RecomputeStructures (const NCollection_Map<Graphic3d_Structure*>& theStructures);
Standard_EXPORT Handle(Graphic3d_ViewAffinity) RegisterObject (const Handle(Standard_Transient)& theObject);
Standard_EXPORT void RegisterObject (const Handle(Standard_Transient)& theObject,
const Handle(Graphic3d_ViewAffinity)& theAffinity);
Standard_EXPORT void UnregisterObject (const Handle(Standard_Transient)& theObject);
Standard_EXPORT Handle(Graphic3d_ViewAffinity) ObjectAffinity (const Handle(Standard_Transient)& theObject) const;
Standard_EXPORT const Handle(Graphic3d_ViewAffinity)& ObjectAffinity (const Handle(Standard_Transient)& theObject) const;
//! Returns TRUE if Device Lost flag has been set and presentation data should be reuploaded onto graphics driver.
Standard_Boolean IsDeviceLost() const { return myDeviceLostFlag; }

View File

@@ -420,7 +420,8 @@ HLRAlgo_PolyInternalData::UpdateLinks (const Standard_Integer ip1,
aSegIndices2->Conex2 = cnx2;
aNodIndices3.NdSg = find;
Standard_Integer iOld,iNew,iTr,skip,ip4,itpk[2];
Standard_Integer iOld,iNew,iTr,skip,ip4;
Standard_Integer itpk[2] = { -1, -1 };
Standard_Integer n1,n2,n3,nOld[3],nNew[3],New[4];
New[0] = cnx1;
New[2] = myNbTData + 1;

View File

@@ -1,5 +1,9 @@
IGESCAFControl.cxx
IGESCAFControl.hxx
IGESCAFControl_ConfigurationNode.cxx
IGESCAFControl_ConfigurationNode.hxx
IGESCAFControl_Provider.cxx
IGESCAFControl_Provider.hxx
IGESCAFControl_Reader.cxx
IGESCAFControl_Reader.hxx
IGESCAFControl_Writer.cxx

View File

@@ -0,0 +1,450 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IGESCAFControl_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <NCollection_Buffer.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
//=======================================================================
// function : IGESCAFControl_ConfigurationNode
// purpose :
//=======================================================================
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode() :
DE_ConfigurationNode()
{
UpdateLoad();
}
//=======================================================================
// function : IGESCAFControl_ConfigurationNode
// purpose :
//=======================================================================
IGESCAFControl_ConfigurationNode::IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode)
:DE_ConfigurationNode(theNode)
{
InternalParameters = theNode->InternalParameters;
UpdateLoad();
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
bool IGESCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
InternalParameters.ReadBSplineContinuity = (ReadMode_BSplineContinuity)
theResource->IntegerVal("read.iges.bspline.continuity", InternalParameters.ReadBSplineContinuity, aScope);
InternalParameters.ReadPrecisionMode = (ReadMode_Precision)
theResource->IntegerVal("read.precision.mode", InternalParameters.ReadPrecisionMode, aScope);
InternalParameters.ReadPrecisionVal =
theResource->RealVal("read.precision.val", InternalParameters.ReadPrecisionVal, aScope);
InternalParameters.ReadMaxPrecisionMode = (ReadMode_MaxPrecision)
theResource->IntegerVal("read.maxprecision.mode", InternalParameters.ReadMaxPrecisionMode, aScope);
InternalParameters.ReadMaxPrecisionVal =
theResource->RealVal("read.maxprecision.val", InternalParameters.ReadMaxPrecisionVal, aScope);
InternalParameters.ReadSameParamMode =
theResource->BooleanVal("read.stdsameparameter.mode", InternalParameters.ReadSameParamMode, aScope);
InternalParameters.ReadSurfaceCurveMode = (ReadMode_SurfaceCurve)
theResource->IntegerVal("read.surfacecurve.mode", InternalParameters.ReadSurfaceCurveMode, aScope);
InternalParameters.EncodeRegAngle =
theResource->RealVal("read.encoderegularity.angle", InternalParameters.EncodeRegAngle, aScope);
InternalParameters.ReadApproxd1 =
theResource->BooleanVal("read.bspline.approxd1.mode", InternalParameters.ReadApproxd1, aScope);
InternalParameters.ReadResourceName =
theResource->StringVal("read.resource.name", InternalParameters.ReadResourceName, aScope);
InternalParameters.ReadSequence =
theResource->StringVal("read.sequence", InternalParameters.ReadSequence, aScope);
InternalParameters.ReadFaultyEntities =
theResource->BooleanVal("read.fau_lty.entities", InternalParameters.ReadFaultyEntities, aScope);
InternalParameters.ReadOnlyVisible =
theResource->BooleanVal("read.onlyvisible", InternalParameters.ReadOnlyVisible, aScope);
InternalParameters.ReadColor =
theResource->BooleanVal("read.color", InternalParameters.ReadColor, aScope);
InternalParameters.ReadName =
theResource->BooleanVal("read.name", InternalParameters.ReadName, aScope);
InternalParameters.ReadLayer =
theResource->BooleanVal("read.layer", InternalParameters.ReadLayer, aScope);
InternalParameters.WriteBRepMode = (WriteMode_BRep)
theResource->IntegerVal("write.brep.mode", InternalParameters.WriteBRepMode, aScope);
InternalParameters.WriteConvertSurfaceMode = (WriteMode_ConvertSurface)
theResource->IntegerVal("write.convertsurface.mode", InternalParameters.WriteConvertSurfaceMode, aScope);
InternalParameters.WriteUnit = (UnitsMethods_LengthUnit)
theResource->IntegerVal("write.unit", InternalParameters.WriteUnit, aScope);
InternalParameters.WriteHeaderAuthor =
theResource->StringVal("write.header.author", InternalParameters.WriteHeaderAuthor, aScope);
InternalParameters.WriteHeaderCompany =
theResource->StringVal("write.header.company", InternalParameters.WriteHeaderCompany, aScope);
InternalParameters.WriteHeaderProduct =
theResource->StringVal("write.header.product", InternalParameters.WriteHeaderProduct, aScope);
InternalParameters.WriteHeaderReciever =
theResource->StringVal("write.header.receiver", InternalParameters.WriteHeaderReciever, aScope);
InternalParameters.WriteResourceName =
theResource->StringVal("write.resource.name", InternalParameters.WriteResourceName, aScope);
InternalParameters.WriteSequence =
theResource->StringVal("write.sequence", InternalParameters.WriteSequence, aScope);
InternalParameters.WritePrecisionMode = (WriteMode_PrecisionMode)
theResource->IntegerVal("write.precision.mode", InternalParameters.WritePrecisionMode, aScope);
InternalParameters.WritePrecisionVal =
theResource->RealVal("write.precision.val", InternalParameters.WritePrecisionVal, aScope);
InternalParameters.WritePlaneMode = (WriteMode_PlaneMode)
theResource->IntegerVal("write.plane.mode", InternalParameters.WritePlaneMode, aScope);
InternalParameters.WriteOffsetMode =
theResource->BooleanVal("write.offset", InternalParameters.WriteOffsetMode, aScope);
InternalParameters.WriteColor =
theResource->BooleanVal("write.color", InternalParameters.WriteColor, aScope);
InternalParameters.WriteName =
theResource->BooleanVal("write.name", InternalParameters.WriteName, aScope);
InternalParameters.WriteLayer =
theResource->BooleanVal("write.layer", InternalParameters.WriteLayer, aScope);
return true;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
TCollection_AsciiString IGESCAFControl_ConfigurationNode::Save() const
{
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Manages the continuity of BSpline curves (IGES entities 106, 112 and 126) ";
aResult += "after translation to Open CASCADE Technology\n";
aResult += "!Default value: 1. Available values: 0, 1, 2\n";
aResult += aScope + "read.iges.bspline.continuity :\t " + InternalParameters.ReadBSplineContinuity + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Reads the precision mode value\n";
aResult += "!Default value: \"File\"(0). Available values: \"File\"(0), \"User\"(1)\n";
aResult += aScope + "read.precision.mode :\t " + InternalParameters.ReadPrecisionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!This parameter gives the precision for shape construction when the ";
aResult += "read.precision.mode parameter value is 1\n";
aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
aResult += aScope + "read.precision.val :\t " + InternalParameters.ReadPrecisionVal + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode of applying the maximum allowed tolerance\n";
aResult += "!Default value: \"Preferred\"(0). Available values: \"Preferred\"(0), \"Forced\"(1)\n";
aResult += aScope + "read.maxprecision.mode :\t " + InternalParameters.ReadMaxPrecisionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the maximum allowable tolerance (in internal units, which are specified in xstep.cascade.unit)";
aResult += " of the shape\n";
aResult += "!Default value: 1. Available values: any real positive (non null) value\n";
aResult += aScope + "read.maxprecision.val :\t " + InternalParameters.ReadMaxPrecisionVal + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the using of BRepLib::SameParameter\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(0)\n";
aResult += aScope + "read.stdsameparameter.mode :\t " + InternalParameters.ReadSameParamMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Preference for the computation of curves in case of 2D/3D inconsistency in an entity ";
aResult += "which has both 2D and 3D representations.\n";
aResult += "!Default value: \"Default\"(0). Available values: \"Default\"(0), \"2DUse_Preferred\"(2), ";
aResult += "\"2DUse_Forced\"(-2), \"3DUse_Preferred\"(3), \"3DUse_Forced\"(-3)\n";
aResult += aScope + "read.surfacecurve.mode :\t " + InternalParameters.ReadSurfaceCurveMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!This parameter is used within the BRepLib::EncodeRegularity() function ";
aResult += "which is called for a shape read ";
aResult += "from an IGES or a STEP file at the end of translation process.This function sets the regularity flag of";
aResult += " an edge in a shell when this edge is shared by two faces.This flag shows the continuity, ";
aResult += "which these two faces are connected with at that edge.\n";
aResult += "!Default value (in degrees): 0.57295779513. Available values: <double>\n";
aResult += aScope + "read.encoderegularity.angle :\t " + InternalParameters.EncodeRegAngle + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Read parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!If set to True, it affects the translation of bspline curves of degree 1 from IGES: ";
aResult += "these curves(which geometrically are polylines) are split by duplicated points, and the translator ";
aResult += "attempts to convert each of the obtained parts to a bspline of a higher continuity\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
aResult += aScope + "read.bspline.approxd1.mode :\t " + InternalParameters.ReadApproxd1 + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the name of the resource file\n";
aResult += "!Default value: \"IGES\". Available values: <string>\n";
aResult += aScope + "read.resource.name :\t " + InternalParameters.ReadResourceName + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the name of the sequence of operators\n";
aResult += "!Default value: \"FromIGES\". Available values: <string>\n";
aResult += aScope + "read.sequence :\t " + InternalParameters.ReadSequence + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Parameter for reading fa-iled entities\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
aResult += aScope + "read.fau_lty.entities :\t " + InternalParameters.ReadFaultyEntities + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Controls transferring invisible sub entities which logically depend on the grouping entities\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
aResult += aScope + "read.onlyvisible :\t " + InternalParameters.ReadOnlyVisible + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the ColorMode parameter which is used to indicate read Colors or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "read.color :\t " + InternalParameters.ReadColor + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the NameMode parameter which is used to indicate read Names or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "read.name :\t " + InternalParameters.ReadName + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the LayerMode parameter which is used to indicate read Layers or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "read.layer :\t " + InternalParameters.ReadLayer + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Write parameters:\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Flag to define entities type to write\n";
aResult += "!Default value: \"Faces\"(0). Available values: \"Faces\"(0), \"BRep\"(1)\n";
aResult += aScope + "write.brep.mode :\t " + InternalParameters.WriteBRepMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!When writing to IGES in the BRep mode, this parameter indicates whether elementary surfaces";
aResult += "(cylindrical, conical, spherical, and toroidal) are converted into corresponding IGES 5.3 entities";
aResult += "(if the value of a parameter value is On), or written as surfaces of revolution(by default)\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
aResult += aScope + "write.convertsurface.mode :\t " + InternalParameters.WriteConvertSurfaceMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Allows choosing the unit. The default unit for Open CASCADE Technology is \"MM\" (millimeter).";
aResult += "You can choose to write a file into any unit accepted by IGES\n";
aResult += "!Default value: MM(2). Available values: \"INCH\"(1), \"MM\"(2), \"??\"(3), \"FT\"(4), \"MI\"(5), ";
aResult += "\"M\"(6), \"KM\"(7), \"MIL\"(8), \"UM\"(9), \"CM\"(10), \"UIN\"(11)\n";
aResult += aScope + "write.unit :\t " + InternalParameters.WriteUnit + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Gives the name of the author of the file\n";
aResult += "!Default value: {System name of the user}. Available values: <string>\n";
aResult += aScope + "write.header.author :\t " + InternalParameters.WriteHeaderAuthor + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Gives the name of the sending company\n";
aResult += "!Default value: ""(empty). Available values: <string>\n";
aResult += aScope + "write.header.company :\t " + InternalParameters.WriteHeaderCompany + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Gives the name of the sending product\n";
aResult += "!Default value: \"CAS.CADE IGES processor Vx.x\"";
aResult += "(where x.x means the current version of Open CASCADE Technology)";
aResult += "Available values : <string>\n";
aResult += aScope + "write.header.product :\t " + InternalParameters.WriteHeaderProduct + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Gives the name of the receiving company\n";
aResult += "!Default value: ""(empty). Available values: <string>\n";
aResult += aScope + "write.header.receiver :\t " + InternalParameters.WriteHeaderReciever + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the name of the resource file\n";
aResult += "!Default value: \"IGES\". Available values: <string>\n";
aResult += aScope + "write.resource.name :\t " + InternalParameters.WriteResourceName + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the name of the sequence of operators\n";
aResult += "!Default value: \"To\". Available values: <string>\n";
aResult += aScope + "write.sequence :\t " + InternalParameters.WriteSequence + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Specifies the mode of writing the resolution value into the IGES file\n";
aResult += "!Default value: Average(0). Available values: \"Least\"(-1), \"Average\"(0), ";
aResult += "\"Greatest\"(1), \"Session\"(2)\n";
aResult += aScope + "write.precision.mode :\t " + InternalParameters.WritePrecisionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!This parameter gives the resolution value for an IGES file when the write.precision.mode parameter value is 1\n";
aResult += "!Default value: 0.0001. Available values: any real positive (non null) value\n";
aResult += aScope + "write.precision.val :\t " + InternalParameters.WritePrecisionVal + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Writing planes mode\n";
aResult += "!Default value: \"Plane\"(0). Available values: \"Plane\"(0), \"BSpline\"(1)\n";
aResult += aScope + "write.plane.mode :\t " + InternalParameters.WritePlaneMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Writing offset curves like BSplines\n";
aResult += "!Default value: \"Off\"(0). Available values: \"Off\"(0), \"On\"(1)\n";
aResult += aScope + "write.offset :\t " + InternalParameters.WriteOffsetMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the ColorMode parameter which is used to indicate write Colors or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "write.color :\t " + InternalParameters.WriteColor + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the NameMode parameter which is used to indicate write Names or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "write.name :\t " + InternalParameters.WriteName + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Setting up the LayerMode parameter which is used to indicate write Layers or not\n";
aResult += "!Default value: 1. Available values: 0, 1\n";
aResult += aScope + "write.layer :\t " + InternalParameters.WriteLayer + "\n";
aResult += "!\n";
aResult += "!*****************************************************************************\n";
return aResult;
}
//=======================================================================
// function : Copy
// purpose :
//=======================================================================
Handle(DE_ConfigurationNode) IGESCAFControl_ConfigurationNode::Copy() const
{
return new IGESCAFControl_ConfigurationNode(*this);
}
//=======================================================================
// function : BuildProvider
// purpose :
//=======================================================================
Handle(DE_Provider) IGESCAFControl_ConfigurationNode::BuildProvider()
{
return new IGESCAFControl_Provider(this);
}
//=======================================================================
// function : IsImportSupported
// purpose :
//=======================================================================
bool IGESCAFControl_ConfigurationNode::IsImportSupported() const
{
return true;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
bool IGESCAFControl_ConfigurationNode::IsExportSupported() const
{
return true;
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetFormat() const
{
return TCollection_AsciiString("IGES");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString IGESCAFControl_ConfigurationNode::GetVendor() const
{
return TCollection_AsciiString("OCC");
}
//=======================================================================
// function : GetExtensions
// purpose :
//=======================================================================
TColStd_ListOfAsciiString IGESCAFControl_ConfigurationNode::GetExtensions() const
{
TColStd_ListOfAsciiString anExt;
anExt.Append("igs");
anExt.Append("iges");
return anExt;
}
//=======================================================================
// function : CheckContent
// purpose :
//=======================================================================
bool IGESCAFControl_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
{
if (theBuffer.IsNull() || theBuffer->Size() < 83)
{
return false;
}
const char* aBytes = (const char*)theBuffer->Data();
if (aBytes[72] == 'S')
{
const char* aPtr = aBytes + 73;
while (aPtr < aBytes + 80 && (*aPtr == ' ' || *aPtr == '0'))
{
aPtr++;
}
if (*aPtr == '1' && !::isalnum((unsigned char)*++aPtr))
{
return true;
}
}
return false;
}

View File

@@ -0,0 +1,178 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IGESCAFControl_ConfigurationNode_HeaderFile
#define _IGESCAFControl_ConfigurationNode_HeaderFile
#include <DE_ConfigurationNode.hxx>
#include <UnitsMethods_LengthUnit.hxx>
//! The purpose of this class is to configure the transfer process for IGES format
//! Stores the necessary settings for IGESCAFControl_Provider.
//! Configures and creates special provider to transfer IGES files.
//!
//! Nodes grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "IGES"
//! The supported CAD extensions are ".igs", ".iges"
//! The import process is supported.
//! The export process is supported.
class IGESCAFControl_ConfigurationNode : public DE_ConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(IGESCAFControl_ConfigurationNode, DE_ConfigurationNode)
public:
//! Initializes all fields by default
Standard_EXPORT IGESCAFControl_ConfigurationNode();
//! Copies values of all fields
//! @param[in] theNode object to copy
Standard_EXPORT IGESCAFControl_ConfigurationNode(const Handle(IGESCAFControl_ConfigurationNode)& theNode);
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @return true if theResource loading has ended correctly
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
//! Writes configuration to the string
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
//! Copies values of all fields
//! @return new object with the same field values
Standard_EXPORT virtual Handle(DE_ConfigurationNode) Copy() const Standard_OVERRIDE;
//! Creates new provider for the own format
//! @return new created provider
Standard_EXPORT virtual Handle(DE_Provider) BuildProvider() Standard_OVERRIDE;
public:
//! Checks the import supporting
//! @return true if import is supported
Standard_EXPORT virtual bool IsImportSupported() const Standard_OVERRIDE;
//! Checks the export supporting
//! @return true if export is supported
Standard_EXPORT virtual bool IsExportSupported() const Standard_OVERRIDE;
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
//! Gets list of supported file extensions
//! @return list of extensions
Standard_EXPORT virtual TColStd_ListOfAsciiString GetExtensions() const Standard_OVERRIDE;
//! Checks the file content to verify a format
//! @param[in] theBuffer read stream buffer to check content
//! @return Standard_True if file is supported by a current provider
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const Standard_OVERRIDE;
public:
enum ReadMode_BSplineContinuity
{
ReadMode_BSplineContinuity_C0 = 0,
ReadMode_BSplineContinuity_C1,
ReadMode_BSplineContinuity_C2
};
enum ReadMode_Precision
{
ReadMode_Precision_File = 0,
ReadMode_Precision_User
};
enum ReadMode_MaxPrecision
{
ReadMode_MaxPrecision_Preferred = 0,
ReadMode_MaxPrecision_Forced
};
enum ReadMode_SurfaceCurve
{
ReadMode_SurfaceCurve_Default = 0,
ReadMode_SurfaceCurve_2DUse_Preferred = 2,
ReadMode_SurfaceCurve_2DUse_Forced = -2,
ReadMode_SurfaceCurve_3DUse_Preferred = 3,
ReadMode_SurfaceCurve_3DUse_Forced = -3
};
enum WriteMode_BRep
{
WriteMode_BRep_Faces = 0,
WriteMode_BRep_BRep
};
enum WriteMode_ConvertSurface
{
WriteMode_ConvertSurface_Off = 0,
WriteMode_ConvertSurface_On
};
enum WriteMode_PrecisionMode
{
WriteMode_PrecisionMode_Least = -1,
WriteMode_PrecisionMode_Average = 0,
WriteMode_PrecisionMode_Greatest = 1,
WriteMode_PrecisionMode_Session = 2
};
enum WriteMode_PlaneMode
{
WriteMode_PlaneMode_Plane = 0,
WriteMode_PlaneMode_BSpline
};
struct IGESCAFControl_InternalSection
{
// Common
ReadMode_BSplineContinuity ReadBSplineContinuity = ReadMode_BSplineContinuity_C1; //<! Manages the continuity of BSpline curves
ReadMode_Precision ReadPrecisionMode = ReadMode_Precision_File; //<! Reads the precision mode value
double ReadPrecisionVal = 0.0001; //<! ReadMode_Precision for shape construction (if enabled user mode)
ReadMode_MaxPrecision ReadMaxPrecisionMode = ReadMode_MaxPrecision_Preferred; //<! Defines the mode of applying the maximum allowed tolerance
double ReadMaxPrecisionVal = 1; //<! Defines the maximum allowable tolerance
bool ReadSameParamMode = false; //<! Defines the using of BRepLib::SameParameter
ReadMode_SurfaceCurve ReadSurfaceCurveMode = ReadMode_SurfaceCurve_Default; //<! reference for the computation of curves in case of 2D/3D
double EncodeRegAngle = 0.57295779513; //<! Continuity which these two faces are connected with at that edge
//Read
bool ReadApproxd1 = false; //<! Flag to split bspline curves of degree 1
TCollection_AsciiString ReadResourceName = "IGES"; //<! Defines the name of the resource file to read
TCollection_AsciiString ReadSequence = "FromIGES"; //<! Defines the name of the sequence of operators to read
bool ReadFaultyEntities = false; //<! Parameter for reading failed entities
bool ReadOnlyVisible = false; //<! Parameter for reading invisible entities
bool ReadColor = true; //<! ColorMode is used to indicate read Colors or not
bool ReadName = true; //<! NameMode is used to indicate read Name or not
bool ReadLayer = true; //<! LayerMode is used to indicate read Layers or not
// Write
WriteMode_BRep WriteBRepMode = WriteMode_BRep_Faces; //<! Flag to define entities type to write
WriteMode_ConvertSurface WriteConvertSurfaceMode = WriteMode_ConvertSurface_Off; //<! Flag to convert surface to elementary
UnitsMethods_LengthUnit WriteUnit = UnitsMethods_LengthUnit_Millimeter; //<! Define unit to write IGES file
TCollection_AsciiString WriteHeaderAuthor; //<! Name of the author of the file
TCollection_AsciiString WriteHeaderCompany; //<! Name of the sending company
TCollection_AsciiString WriteHeaderProduct; //<! Name of the sending product
TCollection_AsciiString WriteHeaderReciever; //<! Name of the receiving company
TCollection_AsciiString WriteResourceName = "IGES"; //<! Defines the name of the resource file to write
TCollection_AsciiString WriteSequence = "ToIGES"; //<! Defines the name of the sequence of operators to write
WriteMode_PrecisionMode WritePrecisionMode = WriteMode_PrecisionMode_Average; //<! Specifies the mode of writing the resolution value into the IGES file
double WritePrecisionVal = 0.0001; //<! Resolution value for an IGES file when WriteMode_PrecisionMode is Greatest
WriteMode_PlaneMode WritePlaneMode = WriteMode_PlaneMode_Plane; //<! Flag to convert plane to the BSline
bool WriteOffsetMode = false; //<! Writing offset curves like BSplines
bool WriteColor = true; //<! ColorMode is used to indicate write Colors or not
bool WriteName = true; //<! NameMode is used to indicate write Name or not
bool WriteLayer = true; //<! LayerMode is used to indicate write Layers or not
} InternalParameters;
};
#endif // _IGESCAFControl_ConfigurationNode_HeaderFile

View File

@@ -0,0 +1,394 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IGESCAFControl_Provider.hxx>
#include <BinXCAFDrivers.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
#include <IGESCAFControl_Reader.hxx>
#include <IGESCAFControl_Writer.hxx>
#include <IGESData.hxx>
#include <IGESData_IGESModel.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <UnitsMethods.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
//=======================================================================
// function : IGESCAFControl_Provider
// purpose :
//=======================================================================
IGESCAFControl_Provider::IGESCAFControl_Provider()
{}
//=======================================================================
// function : IGESCAFControl_Provider
// purpose :
//=======================================================================
IGESCAFControl_Provider::IGESCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode)
: DE_Provider(theNode)
{}
//=======================================================================
// function : initStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::initStatic(const Handle(DE_ConfigurationNode)& theNode)
{
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(theNode);
IGESData::Init();
// Get previous values
myOldValues.ReadBSplineContinuity = (IGESCAFControl_ConfigurationNode::ReadMode_BSplineContinuity)Interface_Static::IVal("read.iges.bspline.continuity");
myOldValues.ReadPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_Precision)Interface_Static::IVal("read.precision.mode");
myOldValues.ReadPrecisionVal = Interface_Static::RVal("read.precision.val");
myOldValues.ReadMaxPrecisionMode = (IGESCAFControl_ConfigurationNode::ReadMode_MaxPrecision)Interface_Static::IVal("read.maxprecision.mode");
myOldValues.ReadMaxPrecisionVal = Interface_Static::RVal("read.maxprecision.val");
myOldValues.ReadSameParamMode = Interface_Static::IVal("read.stdsameparameter.mode") == 1;
myOldValues.ReadSurfaceCurveMode = (IGESCAFControl_ConfigurationNode::ReadMode_SurfaceCurve)Interface_Static::IVal("read.surfacecurve.mode");
myOldValues.EncodeRegAngle = Interface_Static::RVal("read.encoderegularity.angle") * 180.0 / M_PI;
myOldValues.ReadApproxd1 = Interface_Static::IVal("read.iges.bspline.approxd1.mode") == 1;
myOldValues.ReadResourceName = Interface_Static::CVal("read.iges.resource.name");
myOldValues.ReadSequence = Interface_Static::CVal("read.iges.sequence");
myOldValues.ReadFaultyEntities = Interface_Static::IVal("read.iges.faulty.entities");
myOldValues.ReadOnlyVisible = Interface_Static::IVal("read.iges.onlyvisible") == 1;
myOldValues.WriteBRepMode = (IGESCAFControl_ConfigurationNode::WriteMode_BRep)Interface_Static::IVal("write.iges.brep.mode");
myOldValues.WriteConvertSurfaceMode = (IGESCAFControl_ConfigurationNode::WriteMode_ConvertSurface)Interface_Static::IVal("write.convertsurface.mode");
myOldValues.WriteUnit = (UnitsMethods_LengthUnit)Interface_Static::IVal("write.iges.unit");
myOldValues.WriteHeaderAuthor = Interface_Static::CVal("write.iges.header.author");
myOldValues.WriteHeaderCompany = Interface_Static::CVal("write.iges.header.company");
myOldValues.WriteHeaderProduct = Interface_Static::CVal("write.iges.header.product");
myOldValues.WriteHeaderReciever = Interface_Static::CVal("write.iges.header.receiver");
myOldValues.WriteResourceName = Interface_Static::CVal("write.iges.resource.name");
myOldValues.WriteSequence = Interface_Static::CVal("write.iges.sequence");
myOldValues.WritePrecisionMode = (IGESCAFControl_ConfigurationNode::WriteMode_PrecisionMode)Interface_Static::IVal("write.precision.mode");
myOldValues.WritePrecisionVal = Interface_Static::RVal("write.precision.val");
myOldValues.WritePlaneMode = (IGESCAFControl_ConfigurationNode::WriteMode_PlaneMode)Interface_Static::IVal("write.iges.plane.mode");
myOldValues.WriteOffsetMode = Interface_Static::IVal("write.iges.offset.mode") == 1;
myOldLengthUnit = Interface_Static::IVal("xstep.cascade.unit");
// Set new values
UnitsMethods::SetCasCadeLengthUnit(aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
TCollection_AsciiString aStrUnit(UnitsMethods::DumpLengthUnit(aNode->GlobalParameters.LengthUnit));
aStrUnit.UpperCase();
Interface_Static::SetCVal("xstep.cascade.unit", aStrUnit.ToCString());
setStatic(aNode->InternalParameters);
}
//=======================================================================
// function : setStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter)
{
Interface_Static::SetIVal("read.iges.bspline.continuity", theParameter.ReadBSplineContinuity);
Interface_Static::SetIVal("read.precision.mode", theParameter.ReadPrecisionMode);
Interface_Static::SetRVal("read.precision.val", theParameter.ReadPrecisionVal);
Interface_Static::SetIVal("read.maxprecision.mode", theParameter.ReadMaxPrecisionMode);
Interface_Static::SetRVal("read.maxprecision.val", theParameter.ReadMaxPrecisionVal);
Interface_Static::SetIVal("read.stdsameparameter.mode", theParameter.ReadSameParamMode);
Interface_Static::SetIVal("read.surfacecurve.mode", theParameter.ReadSurfaceCurveMode);
Interface_Static::SetRVal("read.encoderegularity.angle", theParameter.EncodeRegAngle * M_PI / 180.0);
Interface_Static::SetIVal("read.iges.bspline.approxd1.mode", theParameter.ReadApproxd1);
Interface_Static::SetCVal("read.iges.resource.name", theParameter.ReadResourceName.ToCString());
Interface_Static::SetCVal("read.iges.sequence", theParameter.ReadSequence.ToCString());
Interface_Static::SetIVal("read.iges.faulty.entities", theParameter.ReadFaultyEntities);
Interface_Static::SetIVal("read.iges.onlyvisible", theParameter.ReadOnlyVisible);
Interface_Static::SetIVal("write.iges.brep.mode", theParameter.WriteBRepMode);
Interface_Static::SetIVal("write.convertsurface.mode", theParameter.WriteConvertSurfaceMode);
Interface_Static::SetIVal("write.iges.unit", theParameter.WriteUnit);
Interface_Static::SetCVal("write.iges.header.author", theParameter.WriteHeaderAuthor.ToCString());
Interface_Static::SetCVal("write.iges.header.company", theParameter.WriteHeaderCompany.ToCString());
Interface_Static::SetCVal("write.iges.header.product", theParameter.WriteHeaderProduct.ToCString());
Interface_Static::SetCVal("write.iges.header.receiver", theParameter.WriteHeaderReciever.ToCString());
Interface_Static::SetCVal("write.iges.resource.name", theParameter.WriteResourceName.ToCString());
Interface_Static::SetCVal("write.iges.sequence", theParameter.WriteSequence.ToCString());
Interface_Static::SetIVal("write.precision.mode", theParameter.WritePrecisionMode);
Interface_Static::SetRVal("write.precision.val", theParameter.WritePrecisionVal);
Interface_Static::SetIVal("write.iges.plane.mode", theParameter.WritePlaneMode);
Interface_Static::SetIVal("write.iges.offset.mode", theParameter.WriteOffsetMode);
}
//=======================================================================
// function : resetStatic
// purpose :
//=======================================================================
void IGESCAFControl_Provider::resetStatic()
{
Interface_Static::SetIVal("xstep.cascade.unit", myOldLengthUnit);
UnitsMethods::SetCasCadeLengthUnit(myOldLengthUnit);
setStatic(myOldValues);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (theDocument.IsNull())
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: theDocument shouldn't be null";
return false;
}
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->GlobalParameters.LengthUnit, UnitsMethods_LengthUnit_Millimeter);
IGESCAFControl_Reader aReader;
if (!theWS.IsNull())
{
aReader.SetWS(theWS);
}
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
aReader.SetColorMode(aNode->InternalParameters.ReadColor);
aReader.SetNameMode(aNode->InternalParameters.ReadName);
aReader.SetLayerMode(aNode->InternalParameters.ReadLayer);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: abandon, no model loaded";
resetStatic();
return false;
}
if (!aReader.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
resetStatic();
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
XCAFDoc_DocumentTool::SetLengthUnit(theDocument, aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter);
IGESCAFControl_Writer aWriter;
if (!theWS.IsNull())
{
aWriter = IGESCAFControl_Writer(theWS);
}
aWriter.SetColorMode(aNode->InternalParameters.WriteColor);
aWriter.SetNameMode(aNode->InternalParameters.WriteName);
aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer);
if (!aWriter.Transfer(theDocument, theProgress))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: The document cannot be translated or gives no result";
resetStatic();
return false;
}
if (!aWriter.Write(thePath.ToCString()))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Write failed";
resetStatic();
return false;
}
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theDocument, aWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
IGESControl_Reader aReader;
if (!theWS.IsNull())
{
aReader.SetWS(theWS);
}
aReader.SetReadVisible(aNode->InternalParameters.ReadOnlyVisible);
IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
aReadStat = aReader.ReadFile(thePath.ToCString());
if (aReadStat != IFSelect_RetDone)
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Could not read file, no model loaded";
resetStatic();
return false;
}
if (aReader.TransferRoots() <= 0)
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Cannot read any relevant data from the IGES file";
resetStatic();
return false;
}
theShape = aReader.OneShape();
resetStatic();
return true;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress)
{
(void)theWS;
(void)theProgress;
if (!GetNode()->IsKind(STANDARD_TYPE(IGESCAFControl_ConfigurationNode)))
{
Message::SendFail() << "Error in the IGESCAFControl_Provider during reading the file " <<
thePath << "\t: Incorrect or empty Configuration Node";
return false;
}
Handle(IGESCAFControl_ConfigurationNode) aNode = Handle(IGESCAFControl_ConfigurationNode)::DownCast(GetNode());
initStatic(aNode);
TCollection_AsciiString aUnit(UnitsMethods::DumpLengthUnit(aNode->InternalParameters.WriteUnit));
aUnit.UpperCase();
IGESControl_Writer aWriter(aUnit.ToCString(),
aNode->InternalParameters.WriteBRepMode);
Standard_Boolean aIsOk = aWriter.AddShape(theShape);
if (!aIsOk)
{
Message::SendFail() << "IGESCAFControl_Provider: Shape not written";
resetStatic();
return false;
}
if (!(aWriter.Write(thePath.ToCString())))
{
Message::SendFail() << "IGESCAFControl_Provider: Error on writing file " << thePath;
resetStatic();
return false;
}
resetStatic();
return true;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Read(thePath, theShape, aWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
bool IGESCAFControl_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
{
Handle(XSControl_WorkSession) aWS;
return Write(thePath, theShape, aWS, theProgress);
}
//=======================================================================
// function : GetFormat
// purpose :
//=======================================================================
TCollection_AsciiString IGESCAFControl_Provider::GetFormat() const
{
return TCollection_AsciiString("IGES");
}
//=======================================================================
// function : GetVendor
// purpose :
//=======================================================================
TCollection_AsciiString IGESCAFControl_Provider::GetVendor() const
{
return TCollection_AsciiString("OCC");
}

View File

@@ -0,0 +1,152 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IGESCAFControl_Provider_HeaderFile
#define _IGESCAFControl_Provider_HeaderFile
#include <DE_Provider.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
//! The class to transfer IGES files.
//! Reads and Writes any IGES files into/from OCCT.
//! Each operation needs configuration node.
//!
//! Providers grouped by Vendor name and Format type.
//! The Vendor name is "OCC"
//! The Format type is "IGES"
//! The import process is supported.
//! The export process is supported.
class IGESCAFControl_Provider : public DE_Provider
{
public:
DEFINE_STANDARD_RTTIEXT(IGESCAFControl_Provider, DE_Provider)
public:
//! Default constructor
//! Configure translation process with global configuration
Standard_EXPORT IGESCAFControl_Provider();
//! Configure translation process
//! @param[in] theNode object to copy
Standard_EXPORT IGESCAFControl_Provider(const Handle(DE_ConfigurationNode)& theNode);
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theDocument document to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param[in] theWS current work session
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theShape shape to save result
//! @param theProgress[in] progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT virtual bool Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
//! Writes a CAD file, according internal configuration
//! @param[in] thePath path to the export CAD file
//! @param[out] theShape shape to export
//! @param theProgress[in] progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT virtual bool Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange()) Standard_OVERRIDE;
public:
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const Standard_OVERRIDE;
//! Gets provider's vendor name of associated provider
//! @return provider's vendor name
Standard_EXPORT virtual TCollection_AsciiString GetVendor() const Standard_OVERRIDE;
private:
//! Initialize static variables
void initStatic(const Handle(DE_ConfigurationNode)& theNode);
//! Initialize static variables
void setStatic(const IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection theParameter);
//! Reset used interface static variables
void resetStatic();
IGESCAFControl_ConfigurationNode::IGESCAFControl_InternalSection myOldValues;
int myOldLengthUnit = 1;
};
#endif // _IGESCAFControl_Provider_HeaderFile

View File

@@ -147,7 +147,7 @@ static void AddCompositeShape (const Handle(XCAFDoc_ShapeTool)& theSTool,
//function : Transfer
//purpose : basic working method
//=======================================================================
Standard_Boolean IGESCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc,
Standard_Boolean IGESCAFControl_Reader::Transfer (const Handle(TDocStd_Document) &doc,
const Message_ProgressRange& theProgress)
{
// read all shapes
@@ -349,7 +349,7 @@ Standard_Boolean IGESCAFControl_Reader::Transfer (Handle(TDocStd_Document) &doc,
//=======================================================================
Standard_Boolean IGESCAFControl_Reader::Perform (const Standard_CString filename,
Handle(TDocStd_Document) &doc,
const Handle(TDocStd_Document) &doc,
const Message_ProgressRange& theProgress)
{
if ( ReadFile ( filename ) != IFSelect_RetDone ) return Standard_False;

View File

@@ -68,18 +68,18 @@ class IGESCAFControl_Reader : public IGESControl_Reader
//! Translates currently loaded IGES file into the document
//! Returns True if succeeded, and False in case of fail
Standard_EXPORT Standard_Boolean Transfer (Handle(TDocStd_Document)& theDoc,
Standard_EXPORT Standard_Boolean Transfer (const Handle(TDocStd_Document)& theDoc,
const Message_ProgressRange& theProgress = Message_ProgressRange());
Standard_Boolean Perform (const TCollection_AsciiString& theFileName,
Handle(TDocStd_Document)& theDoc,
const Handle(TDocStd_Document)& theDoc,
const Message_ProgressRange& theProgress = Message_ProgressRange())
{ return Perform (theFileName.ToCString(), theDoc, theProgress); }
//! Translate IGES file given by filename into the document
//! Return True if succeeded, and False in case of fail
Standard_EXPORT Standard_Boolean Perform (const Standard_CString theFileName,
Handle(TDocStd_Document)& theDoc,
const Handle(TDocStd_Document)& theDoc,
const Message_ProgressRange& theProgress = Message_ProgressRange());
//! Set ColorMode for indicate read Colors or not.

View File

@@ -16,11 +16,7 @@
#ifndef _IMeshData_Edge_HeaderFile
#define _IMeshData_Edge_HeaderFile
#include <IMeshData_TessellatedShape.hxx>
#include <IMeshData_StatusOwner.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <IMeshData_Curve.hxx>
#include <IMeshData_PCurve.hxx>
#include <IMeshData_Types.hxx>

View File

@@ -19,7 +19,6 @@
#include <IMeshData_TessellatedShape.hxx>
#include <IMeshData_StatusOwner.hxx>
#include <Standard_Type.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <IMeshData_Status.hxx>
#include <IMeshData_Types.hxx>

View File

@@ -17,8 +17,6 @@
#define _IMeshData_ParametersListArrayAdaptor_HeaderFile
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <IMeshData_ParametersList.hxx>
//! Auxiliary tool representing adaptor interface for child classes of
//! IMeshData_ParametersList to be used in tools working on NCollection_Array structure.

View File

@@ -16,7 +16,6 @@
#ifndef _IMeshData_Shape_HeaderFile
#define _IMeshData_Shape_HeaderFile
#include <Standard_Type.hxx>
#include <TopoDS_Shape.hxx>
//! Interface class representing model with associated TopoDS_Shape.

View File

@@ -17,8 +17,6 @@
#define _IMeshData_StatusOwner_HeaderFile
#include <IMeshData_Status.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
//! Extension interface class providing status functionality.
class IMeshData_StatusOwner

View File

@@ -16,8 +16,6 @@
#ifndef _IMeshData_Types_HeaderFile
#define _IMeshData_Types_HeaderFile
#include <NCollection_DataMap.hxx>
#include <NCollection_Vector.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_List.hxx>
#include <NCollection_Shared.hxx>
@@ -26,16 +24,13 @@
#include <NCollection_DefineAlloc.hxx>
#include <NCollection_StdAllocator.hxx>
#include <IMeshData_ParametersListArrayAdaptor.hxx>
#include <TColStd_PackedMapOfInteger.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <Precision.hxx>
#include <NCollection_EBTree.hxx>
#include <Bnd_Box2d.hxx>
#include <NCollection_CellFilter.hxx>
#include <NCollection_IndexedDataMap.hxx>
#include <NCollection_UBTreeFiller.hxx>
#include <NCollection_IndexedMap.hxx>
#include <BRepMesh_OrientedEdge.hxx>
#include <BRepMesh_Vertex.hxx>
#include <Bnd_B2d.hxx>
#include <BRepMesh_Circle.hxx>
@@ -45,7 +40,6 @@
#include <memory>
#include <queue>
#include <list>
class IMeshData_Shape;
class IMeshData_Face;

View File

@@ -16,7 +16,6 @@
#ifndef _IMeshTools_Context_HeaderFile
#define _IMeshTools_Context_HeaderFile
#include <IMeshData_Shape.hxx>
#include <Standard_Type.hxx>
#include <IMeshTools_ModelBuilder.hxx>
#include <IMeshData_Model.hxx>

View File

@@ -17,7 +17,6 @@
#define _IMeshTools_MeshAlgo_HeaderFile
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <IMeshData_Types.hxx>
#include <Message_ProgressRange.hxx>

View File

@@ -17,7 +17,6 @@
#define _IMeshTools_MeshAlgoFactory_HeaderFile
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <IMeshTools_MeshAlgo.hxx>

View File

@@ -16,7 +16,6 @@
#ifndef _IMeshTools_MeshBuilder_HeaderFile
#define _IMeshTools_MeshBuilder_HeaderFile
#include <Message_Algorithm.hxx>
#include <IMeshTools_Context.hxx>
#include <Standard_Type.hxx>
#include <Message_ProgressRange.hxx>

View File

@@ -16,10 +16,7 @@
#ifndef _IMeshTools_ModelAlgo_HeaderFile
#define _IMeshTools_ModelAlgo_HeaderFile
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <Standard_Transient.hxx>
#include <Standard_Type.hxx>
#include <Message_ProgressRange.hxx>
class IMeshData_Model;

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