Integrated DE plugin functionality.
Reworked DE components:
- TKDESTEP: Handling STEP file format.
- TKDEOBJ: Handling OBJ file format.
- TKDEIGES: Handling IGES file format.
- TKDEGLTF: Handling GLTF file format.
- TKDEVRML: Handling VRML file format.
- TKDEPLY: Handling PLY file format.
- TKDESTL: Handling STL file format.
Reworked DE DRAW components:
TKXSDRAWSTEP: Container for DE command to work with STEP.
TKXSDRAWOBJ: Container for DE command to work with OBJ.
TKXSDRAWIGES: Container for DE command to work with IGES.
TKXSDRAWGLTF: Container for DE command to work with GLTF.
TKXSDRAWVRML: Container for DE command to work with VRML.
TKXSDRAWPLY: Container for DE command to work with PLY.
TKXSDRAWSTL: Container for DE command to work with STL.
TKXSDRAW rework to be base DRAW plugin to keep DE session and utils.
Updated documentation
Updated samples
ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing
Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost
ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF
-DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade
-Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE
+DataExchange TKDE TKXSBase TKDESTEP TKDEIGES TKDESTL TKDEVRML TKDECascade TKDEOBJ TKDEGLTF TKDEPLY TKXCAF TKXmlXCAF TKBinXCAF TKRWMesh
DETools TKExpress ExpToCasExe
+Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE TKXSDRAWDE TKXSDRAWGLTF TKXSDRAWIGES TKXSDRAWOBJ TKXSDRAWPLY TKXSDRAWSTEP TKXSDRAWSTL TKXSDRAWVRML
r XSMessage
r XSTEPResource
t TKBinXCAF
-t TKIGES
-t TKSTEP
-t TKSTEP209
-t TKSTEPAttr
-t TKSTEPBase
-t TKSTL
-t TKVRML
+t TKDESTL
+t TKDEVRML
t TKXCAF
-t TKXDE
-t TKXDECascade
-t TKXDEIGES
-t TKXDESTEP
+t TKDE
+t TKDECascade
+t TKDEIGES
+t TKDESTEP
t TKXSBase
t TKXmlXCAF
n BOPTest
n XSDRAW
n XSDRAWIGES
n XSDRAWSTEP
-n XSDRAWSTLVRML
+n XSDRAWSTL
+n XSDRAWVRML
+n XSDRAWDE
+n XSDRAWGLTF
+n XSDRAWOBJ
+n XSDRAWPLY
r DrawResources
t TKDCAF
t TKDraw
t TKViewerTest
t TKXDEDRAW
t TKXSDRAW
+t TKXSDRAWIGES
+t TKXSDRAWSTEP
+t TKXSDRAWSTL
+t TKXSDRAWVRML
+t TKXSDRAWDE
+t TKXSDRAWGLTF
+t TKXSDRAWOBJ
+t TKXSDRAWPLY
x DRAWEXE
n QADraw
n QANCollection
n XCAFView
n XCAFNoteObjects
t TKRWMesh
+t TKDEGLTF
+t TKDEOBJ
+t TKDEPLY
n RWGltf
n RWMesh
n RWObj
| Draw | TKDraw, TKTopTest, TKViewerTest, TKXSDRAW, TKDCAF, TKXDEDRAW, TKTObjDRAW, TKQADraw, DRAWEXE, Problems of testing system | draw |
| Shape Healing | TKShHealing | heal |
| Mesh | TKMesh, TKXMesh | mesh |
-| Data Exchange | TKIGES | iges |
-| Data Exchange | TKSTEPBase, TKSTEPAttr, TKSTEP209, TKSTEP | step |
-| Data Exchange | TKSTL, TKVRML | stlvrml |
-| Data Exchange | TKXSBase, TKXCAF, TKXCAFSchema, TKXDEIGES, TKXDESTEP, TKXmlXCAF, TKBinXCAF | xde |
+| Data Exchange | TKDEIGES | iges |
+| Data Exchange | TKDESTEP | step |
+| Data Exchange | TKDESTL, TKDEVRML | stlvrml |
+| Data Exchange | TKXSBase, TKXCAF, TKXCAFSchema, TKXmlXCAF, TKBinXCAF | xde |
| Foundation Classes | TKernel, TKMath | fclasses |
| Modeling_algorithms | TKGeomAlgo, TKTopAlgo, TKPrim, TKBO, TKBool, TKHLR, TKFillet, TKOffset, TKFeat, TKXMesh | modalg |
| Modeling Data | TKG2d, TKG3d, TKGeomBase, TKBRep | moddata |
@section occt_step_7 Reading from and writing to STEP
-The *STEPCAFControl* package (TKXDESTEP toolkit) provides tools to read and write STEP files (see XDE User's Guide).
+The *STEPCAFControl* package (TKDESTEP toolkit) provides tools to read and write STEP files (see XDE User's Guide).
In addition to the translation of shapes implemented in basic translator, it provides the following:
* STEP assemblies, read as OCCT compounds by basic translator, are translated to XDE assemblies;
#pragma comment(lib, "TKService.lib")
#pragma comment(lib, "TKV3d.lib")
#pragma comment(lib, "TKOpenGl.lib")
-#pragma comment(lib, "TKIGES.lib")
-#pragma comment(lib, "TKSTEP.lib")
-#pragma comment(lib, "TKStl.lib")
-#pragma comment(lib, "TKVrml.lib")
+#pragma comment(lib, "TKDEIGES.lib")
+#pragma comment(lib, "TKDESTEP.lib")
+#pragma comment(lib, "TKDESTL.lib")
+#pragma comment(lib, "TKDEVRML.lib")
#pragma comment(lib, "TKLCAF.lib")
//! Auxiliary tool for converting C# string into UTF-8 string.
#pragma comment(lib, "TKV3d.lib")
#pragma comment(lib, "TKOpenGl.lib")
#pragma comment(lib, "TKD3dHost.lib")
-#pragma comment(lib, "TKIGES.lib")
-#pragma comment(lib, "TKSTEP.lib")
-#pragma comment(lib, "TKStl.lib")
-#pragma comment(lib, "TKVrml.lib")
+#pragma comment(lib, "TKDEIGES.lib")
+#pragma comment(lib, "TKDESTEP.lib")
+#pragma comment(lib, "TKDESTL.lib")
+#pragma comment(lib, "TKDEVRML.lib")
#pragma comment(lib, "TKLCAF.lib")
#pragma comment(lib, "D3D9.lib")
set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing) # ModelingAlgorithms
set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKService TKV3d TKOpenGl TKMeshVS TKIVtk TKD3DHost) # Visualization
set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF) # ApplicationFramework
-set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh) # DataExchange
+set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKXSBase TKXCAF TKDEIGES TKDESTEP TKDESTL TKDEVRML TKXmlXCAF TKBinXCAF TKRWMesh TKDEGLTF TKDEOBJ TKDEPLY) # DataExchange
set (OpenCASCADE_TKLIST ${OpenCASCADE_TKLIST} TKDraw TKViewerTest) # Draw
# validate location of OCCT libraries and headers
0A7DEDFC1E2D29FF00267B9B /* libTKV3d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEDF71E2D29F800267B9B /* libTKV3d.a */; };
0A7DEDFD1E2D29FF00267B9B /* libTKVCAF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEDF81E2D29FB00267B9B /* libTKVCAF.a */; };
0A7DEE2B1E2D2AE000267B9B /* libTKService.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE0B1E2D2A9D00267B9B /* libTKService.a */; };
- 0A7DEE2E1E2D2AE000267B9B /* libTKSTEP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE0E1E2D2AA800267B9B /* libTKSTEP.a */; };
- 0A7DEE301E2D2AE000267B9B /* libTKSTEPAttr.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE101E2D2AAE00267B9B /* libTKSTEPAttr.a */; };
- 0A7DEE311E2D2AE000267B9B /* libTKSTEPBase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE111E2D2AB200267B9B /* libTKSTEPBase.a */; };
+ 0A7DEE2E1E2D2AE000267B9B /* libTKDESTEP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE0E1E2D2AA800267B9B /* libTKDESTEP.a */; };
0A7DEE351E2D2AE000267B9B /* libTKXCAF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE151E2D2AC000267B9B /* libTKXCAF.a */; };
- 0A7DEE371E2D2AE000267B9B /* libTKXDESTEP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE171E2D2AC700267B9B /* libTKXDESTEP.a */; };
0A7DEE3E1E2D2B8100267B9B /* libTKBO.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE021E2D2A7F00267B9B /* libTKBO.a */; };
0A7DEE3F1E2D2BB000267B9B /* libTKOpenGles.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */; };
- 0A7DEE401E2D2BEA00267B9B /* libTKSTEP209.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE0F1E2D2AAB00267B9B /* libTKSTEP209.a */; };
0A7DEE411E2D2C1500267B9B /* libTKXSBase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A7DEE1D1E2D2ADC00267B9B /* libTKXSBase.a */; };
0AAE0DE61EAF816E00C1F65B /* screw.step in Resources */ = {isa = PBXBuildFile; fileRef = 0AAE0DE51EAF816D00C1F65B /* screw.step */; };
0AE286641EB0D29B00A9D719 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AE286631EB0D29A00A9D719 /* libz.tbd */; };
0A7DEE031E2D2A8200267B9B /* libTKBool.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKBool.a; path = ../occt/lib/libTKBool.a; sourceTree = "<group>"; };
0A7DEE041E2D2A8500267B9B /* libTKFeat.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKFeat.a; path = ../occt/lib/libTKFeat.a; sourceTree = "<group>"; };
0A7DEE051E2D2A8900267B9B /* libTKFillet.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKFillet.a; path = ../occt/lib/libTKFillet.a; sourceTree = "<group>"; };
- 0A7DEE061E2D2A8C00267B9B /* libTKIGES.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKIGES.a; path = ../occt/lib/libTKIGES.a; sourceTree = "<group>"; };
+ 0A7DEE061E2D2A8C00267B9B /* libTKDEIGES.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKDEIGES.a; path = ../occt/lib/libTKDEIGES.a; sourceTree = "<group>"; };
0A7DEE071E2D2A8F00267B9B /* libTKMeshVS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKMeshVS.a; path = ../occt/lib/libTKMeshVS.a; sourceTree = "<group>"; };
0A7DEE081E2D2A9300267B9B /* libTKOffset.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKOffset.a; path = ../occt/lib/libTKOffset.a; sourceTree = "<group>"; };
0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKOpenGles.a; path = ../occt/lib/libTKOpenGles.a; sourceTree = "<group>"; };
0A7DEE0B1E2D2A9D00267B9B /* libTKService.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKService.a; path = ../occt/lib/libTKService.a; sourceTree = "<group>"; };
0A7DEE0C1E2D2AA100267B9B /* libTKStd.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKStd.a; path = ../occt/lib/libTKStd.a; sourceTree = "<group>"; };
0A7DEE0D1E2D2AA400267B9B /* libTKStdL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKStdL.a; path = ../occt/lib/libTKStdL.a; sourceTree = "<group>"; };
- 0A7DEE0E1E2D2AA800267B9B /* libTKSTEP.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKSTEP.a; path = ../occt/lib/libTKSTEP.a; sourceTree = "<group>"; };
- 0A7DEE0F1E2D2AAB00267B9B /* libTKSTEP209.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKSTEP209.a; path = ../occt/lib/libTKSTEP209.a; sourceTree = "<group>"; };
- 0A7DEE101E2D2AAE00267B9B /* libTKSTEPAttr.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKSTEPAttr.a; path = ../occt/lib/libTKSTEPAttr.a; sourceTree = "<group>"; };
- 0A7DEE111E2D2AB200267B9B /* libTKSTEPBase.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKSTEPBase.a; path = ../occt/lib/libTKSTEPBase.a; sourceTree = "<group>"; };
- 0A7DEE121E2D2AB500267B9B /* libTKSTL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKSTL.a; path = ../occt/lib/libTKSTL.a; sourceTree = "<group>"; };
+ 0A7DEE0E1E2D2AA800267B9B /* libTKDESTEP.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKDESTEP.a; path = ../occt/lib/libTKDESTEP.a; sourceTree = "<group>"; };
+ 0A7DEE121E2D2AB500267B9B /* libTKDESTL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKDESTL.a; path = ../occt/lib/libTKDESTL.a; sourceTree = "<group>"; };
0A7DEE131E2D2AB900267B9B /* libTKTObj.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKTObj.a; path = ../occt/lib/libTKTObj.a; sourceTree = "<group>"; };
- 0A7DEE141E2D2ABC00267B9B /* libTKVRML.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKVRML.a; path = ../occt/lib/libTKVRML.a; sourceTree = "<group>"; };
+ 0A7DEE141E2D2ABC00267B9B /* libTKDEVRML.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKDEVRML.a; path = ../occt/lib/libTKDEVRML.a; sourceTree = "<group>"; };
0A7DEE151E2D2AC000267B9B /* libTKXCAF.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXCAF.a; path = ../occt/lib/libTKXCAF.a; sourceTree = "<group>"; };
- 0A7DEE161E2D2AC300267B9B /* libTKXDEIGES.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXDEIGES.a; path = ../occt/lib/libTKXDEIGES.a; sourceTree = "<group>"; };
- 0A7DEE171E2D2AC700267B9B /* libTKXDESTEP.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXDESTEP.a; path = ../occt/lib/libTKXDESTEP.a; sourceTree = "<group>"; };
0A7DEE181E2D2ACA00267B9B /* libTKXMesh.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXMesh.a; path = ../occt/lib/libTKXMesh.a; sourceTree = "<group>"; };
0A7DEE191E2D2ACE00267B9B /* libTKXml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXml.a; path = ../occt/lib/libTKXml.a; sourceTree = "<group>"; };
0A7DEE1A1E2D2AD100267B9B /* libTKXmlL.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libTKXmlL.a; path = ../occt/lib/libTKXmlL.a; sourceTree = "<group>"; };
files = (
0AE286641EB0D29B00A9D719 /* libz.tbd in Frameworks */,
0A7DEE411E2D2C1500267B9B /* libTKXSBase.a in Frameworks */,
- 0A7DEE401E2D2BEA00267B9B /* libTKSTEP209.a in Frameworks */,
0A7DEE3F1E2D2BB000267B9B /* libTKOpenGles.a in Frameworks */,
0A7DEE3E1E2D2B8100267B9B /* libTKBO.a in Frameworks */,
0A7DEE2B1E2D2AE000267B9B /* libTKService.a in Frameworks */,
- 0A7DEE2E1E2D2AE000267B9B /* libTKSTEP.a in Frameworks */,
- 0A7DEE301E2D2AE000267B9B /* libTKSTEPAttr.a in Frameworks */,
- 0A7DEE311E2D2AE000267B9B /* libTKSTEPBase.a in Frameworks */,
+ 0A7DEE2E1E2D2AE000267B9B /* libTKDESTEP.a in Frameworks */,
0A7DEE351E2D2AE000267B9B /* libTKXCAF.a in Frameworks */,
0A7DEE371E2D2AE000267B9B /* libTKXDESTEP.a in Frameworks */,
0A7DEDE71E2D28E300267B9B /* libTKBRep.a in Frameworks */,
0A7DEE031E2D2A8200267B9B /* libTKBool.a */,
0A7DEE041E2D2A8500267B9B /* libTKFeat.a */,
0A7DEE051E2D2A8900267B9B /* libTKFillet.a */,
- 0A7DEE061E2D2A8C00267B9B /* libTKIGES.a */,
+ 0A7DEE061E2D2A8C00267B9B /* libTKDEIGES.a */,
0A7DEE071E2D2A8F00267B9B /* libTKMeshVS.a */,
0A7DEE081E2D2A9300267B9B /* libTKOffset.a */,
0A7DEE091E2D2A9700267B9B /* libTKOpenGles.a */,
0A7DEE0B1E2D2A9D00267B9B /* libTKService.a */,
0A7DEE0C1E2D2AA100267B9B /* libTKStd.a */,
0A7DEE0D1E2D2AA400267B9B /* libTKStdL.a */,
- 0A7DEE0E1E2D2AA800267B9B /* libTKSTEP.a */,
- 0A7DEE0F1E2D2AAB00267B9B /* libTKSTEP209.a */,
- 0A7DEE101E2D2AAE00267B9B /* libTKSTEPAttr.a */,
- 0A7DEE111E2D2AB200267B9B /* libTKSTEPBase.a */,
- 0A7DEE121E2D2AB500267B9B /* libTKSTL.a */,
+ 0A7DEE0E1E2D2AA800267B9B /* libTKDESTEP.a */,
+ 0A7DEE121E2D2AB500267B9B /* libTKDESTL.a */,
0A7DEE131E2D2AB900267B9B /* libTKTObj.a */,
- 0A7DEE141E2D2ABC00267B9B /* libTKVRML.a */,
+ 0A7DEE141E2D2ABC00267B9B /* libTKDEVRML.a */,
0A7DEE151E2D2AC000267B9B /* libTKXCAF.a */,
- 0A7DEE161E2D2AC300267B9B /* libTKXDEIGES.a */,
- 0A7DEE171E2D2AC700267B9B /* libTKXDESTEP.a */,
0A7DEE181E2D2ACA00267B9B /* libTKXMesh.a */,
0A7DEE191E2D2ACE00267B9B /* libTKXml.a */,
0A7DEE1A1E2D2AD100267B9B /* libTKXmlL.a */,
|| !loadLibVerbose ("TKFillet", aLoaded, aFailed)
|| !loadLibVerbose ("TKOffset", aLoaded, aFailed)
|| !loadLibVerbose ("TKXSBase", aLoaded, aFailed)
- || !loadLibVerbose ("TKIGES", aLoaded, aFailed)
- || !loadLibVerbose ("TKSTEPBase", aLoaded, aFailed)
- || !loadLibVerbose ("TKSTEPAttr", aLoaded, aFailed)
- || !loadLibVerbose ("TKSTEP209", aLoaded, aFailed)
- || !loadLibVerbose ("TKSTEP", aLoaded, aFailed)
+ || !loadLibVerbose ("TKDEIGES", aLoaded, aFailed)
+ || !loadLibVerbose ("TKDESTEP", aLoaded, aFailed)
// OCCT Visualization
|| !loadLibVerbose ("TKService", aLoaded, aFailed)
|| !loadLibVerbose ("TKHLR", aLoaded, aFailed)
# exchange
TKPrim TKBO TKBool TKFillet TKOffset
TKXSBase
- TKIGES
- TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP
+ TKDEIGES
+ TKDESTEP
# OCCT Visualization
TKService TKHLR TKV3d TKOpenGles
)
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bin/Geometry.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bin/Geometry.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bind/Geometry.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKMesh.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../..\win64\$(VCFMT)\bind/Geometry.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
${Modeling_SRC_DIR}
${MFC_STANDARD_SAMPLES_DIR}/Common)
-target_link_libraries (Modeling mfcsample TKSTEP209 TKSTEPAttr TKSTEPBase TKBO)
+target_link_libraries (Modeling mfcsample TKDESTEP TKBO)
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBRep.lib;TKIGES.lib;TKShHealing.lib;TKSTEP.lib;TKSTEP209.lib;TKSTEPAttr.lib;TKSTEPBase.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBRep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bind/Modeling.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBRep.lib;TKIGES.lib;TKShHealing.lib;TKSTEP.lib;TKSTEP209.lib;TKSTEPAttr.lib;TKSTEPBase.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBRep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bind/Modeling.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBRep.lib;TKIGES.lib;TKShHealing.lib;TKSTEP.lib;TKSTEP209.lib;TKSTEPAttr.lib;TKSTEPBase.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBRep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bin/Modeling.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBRep.lib;TKIGES.lib;TKShHealing.lib;TKSTEP.lib;TKSTEP209.lib;TKSTEPAttr.lib;TKSTEPBase.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBRep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;mfcsample.lib;TKBO.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bin/Modeling.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bin/ImportExport.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bin/ImportExport.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\lib;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bind/ImportExport.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win32\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;mfcsample.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bind/ImportExport.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\..\win64\$(VCFMT)\libd;$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
${COMMON_RESOURCE2D_DIR})
# OCCT libraries for using
-set (mfcsample_USED_LIBS TKVRML
- TKSTL
+set (mfcsample_USED_LIBS TKDEVRML
+ TKDESTL
TKBRep
- TKIGES
+ TKDEIGES
TKShHealing
- TKSTEP
- TKSTEPBase
- TKSTEP209
- TKSTEPAttr
+ TKDESTEP
TKXSBase
TKBool
TKBO
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bind/mfcsample.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bind/mfcsample.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win32\$(VCFMT)\bin/mfcsample.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ResourceOutputFileName>$(IntDir)%(Filename).res</ResourceOutputFileName>
</ResourceCompile>
<Link>
- <AdditionalDependencies>TKVCAF.lib;TKVrml.lib;TKStl.lib;TKBrep.lib;TKIGES.lib;TKShHealing.lib;TKStep.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>TKVCAF.lib;TKDEVRML.lib;TKDESTL.lib;TKBrep.lib;TKDEIGES.lib;TKShHealing.lib;TKDESTEP.lib;TKXSBase.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPrim.lib;TKService.lib;TKTopAlgo.lib;TKMesh.lib;TKV3d.lib;TKOpenGl.lib;TKLCAF.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>../../../../win64\$(VCFMT)\bin/mfcsample.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>$(CSF_OCCTLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
TKGeomAlgo
TKGeomBase
TKHLR
-TKIGES
+TKDEIGES
TKernel
TKMath
TKMesh
TKPrim
TKShHealing
TKService
-TKSTEP
-TKSTEP209
-TKSTEPAttr
-TKSTEPBase
-TKSTL
+TKDESTEP
+TKDESTL
TKTopAlgo
TKV3d
-TKVRML
+TKDEVRML
TKXSBase
}
LIBS += -lTKernel -lTKMath -lTKService -lTKV3d -lTKOpenGl \
- -lTKBRep -lTKIGES -lTKSTL -lTKVRML -lTKSTEP -lTKSTEPAttr -lTKSTEP209 \
- -lTKSTEPBase -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
+ -lTKBRep -lTKDEIGES -lTKDESTL -lTKDEVRML -lTKDESTEP \
+ -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
-lTKXSBase -lTKShHealing -lTKHLR -lTKTopAlgo -lTKMesh -lTKPrim \
-lTKCDF -lTKBool -lTKBO -lTKFillet -lTKOffset -lTKLCAF \
TKGeomBase
TKernel
TKHLR
-TKIGES
+TKDEIGES
TKMath
TKMesh
TKOffset
TKPrim
TKService
TKShHealing
-TKSTEP
-TKSTEP209
-TKSTEPAttr
-TKSTEPBase
-TKSTL
+TKDESTEP
+TKDESTL
TKTopAlgo
TKV3d
-TKVRML
+TKDEVRML
TKXSBase
TKLCAF
TKCAF
}
LIBS += -lTKernel -lTKMath -lTKService -lTKV3d -lTKOpenGl \
- -lTKBRep -lTKIGES -lTKSTL -lTKVRML -lTKSTEP -lTKSTEPAttr -lTKSTEP209 \
- -lTKSTEPBase -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
+ -lTKBRep -lTKDEIGES -lTKDESTL -lTKDEVRML -lTKDESTEP \
+ -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
-lTKXSBase -lTKShHealing -lTKHLR -lTKTopAlgo -lTKMesh -lTKPrim \
-lTKCDF -lTKBool -lTKBO -lTKFillet -lTKOffset -lTKLCAF -lTKCAF -lTKVCAF \
-lTKBin -lTKXml
TKGeomBase
TKernel
TKHLR
-TKIGES
+TKDEIGES
TKMath
TKMesh
TKOffset
TKPrim
TKService
TKShHealing
-TKSTEP
-TKSTEP209
-TKSTEPAttr
-TKSTEPBase
-TKSTL
+TKDESTEP
+TKDESTL
TKTopAlgo
TKV3d
-TKVRML
+TKDEVRML
TKXSBase
}
LIBS += -lTKernel -lTKMath -lTKService -lTKV3d -lTKOpenGl \
- -lTKBRep -lTKIGES -lTKSTL -lTKVRML -lTKSTEP -lTKSTEPAttr -lTKSTEP209 \
- -lTKSTEPBase -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
+ -lTKBRep -lTKDEIGES -lTKDESTL -lTKDEVRML -lTKDESTEP \
+ -lTKGeomBase -lTKGeomAlgo -lTKG3d -lTKG2d \
-lTKXSBase -lTKShHealing -lTKHLR -lTKTopAlgo -lTKMesh -lTKPrim \
-lTKCDF -lTKBool -lTKBO -lTKFillet -lTKOffset -lTKLCAF \
set(OCCT_BIN_DIR)
endif()
-set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGles TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
+set(OpenCASCADE_LIBS TKRWMesh TKDEGLTF TKDEOBJ TKDEPLY TKBinXCAF TKBin TKBinL TKOpenGles TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
add_executable(${APP_TARGET} ${SOURCES})
target_link_libraries(
TKHLR
TKOffset
TKXMesh
- TKIGES
- TKSTEP
+ TKDEIGES
+ TKDESTEP
TKXSBase
- TKSTL
- TKVRML
+ TKDESTL
+ TKDEVRML
)
target_link_libraries (uwp ${uwp_USED_LIBS})
--- /dev/null
+// Copyright (c) 2023 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_PluginHolder_HeaderFile
+#define _DE_PluginHolder_HeaderFile
+
+#include <DE_Wrapper.hxx>
+
+//! Base class to work with DE_Wrapper global registration of components.
+//! Control life-time of current configuration node.
+//! In creating stage load into global configuration.
+//! On destroying stage unload from global configuration.
+//! Operation to load/unload are thread safety.
+template <class TheConfType>
+class DE_PluginHolder
+{
+public:
+ DE_PluginHolder()
+ {
+ Standard_Mutex::Sentry aLock(DE_Wrapper::GlobalLoadMutex());
+ myInternalConfiguration = new TheConfType;
+ DE_Wrapper::GlobalWrapper()->Bind(myInternalConfiguration);
+ }
+
+ ~DE_PluginHolder()
+ {
+ Standard_Mutex::Sentry aLock(DE_Wrapper::GlobalLoadMutex());
+ DE_Wrapper::GlobalWrapper()->UnBind(myInternalConfiguration);
+ }
+
+private:
+ Handle(TheConfType) myInternalConfiguration; //!< Wrapped object
+};
+
+#endif // _DE_PluginHolder_HeaderFile
return aScope;
}
- //! Global configuration of current DE Session
- static Handle(DE_Wrapper) THE_GLOBAL_CONFIGURATION;
+ static Handle(DE_Wrapper)& THE_GLOBAL_CONFIGURATION()
+ {
+ static Handle(DE_Wrapper) aConf = new DE_Wrapper();
+ return aConf;
+ }
}
//=======================================================================
// function : GlobalWrapper
// purpose :
//=======================================================================
-Handle(DE_Wrapper) DE_Wrapper::GlobalWrapper()
+const Handle(DE_Wrapper)& DE_Wrapper::GlobalWrapper()
{
- if (THE_GLOBAL_CONFIGURATION.IsNull())
- {
- THE_GLOBAL_CONFIGURATION = new DE_Wrapper();
- }
- return THE_GLOBAL_CONFIGURATION;
+ return THE_GLOBAL_CONFIGURATION();
}
//=======================================================================
{
if (!theWrapper.IsNull())
{
- THE_GLOBAL_CONFIGURATION = theWrapper;
+ THE_GLOBAL_CONFIGURATION() = theWrapper;
}
}
+//=======================================================================
+// function : GlobalLoadMutex
+// purpose :
+//=======================================================================
+Standard_Mutex& DE_Wrapper::GlobalLoadMutex()
+{
+ static Standard_Mutex THE_GLOBAL_LOAD_MUTEX;
+ return THE_GLOBAL_LOAD_MUTEX;
+}
+
//=======================================================================
// function : Read
// purpose :
return aVendorMap->Add(aVendorName, theNode) > 0;
}
+//=======================================================================
+// function : UnBind
+// purpose :
+//=======================================================================
+Standard_Boolean DE_Wrapper::UnBind(const Handle(DE_ConfigurationNode)& theNode)
+{
+ if (theNode.IsNull())
+ {
+ return false;
+ }
+ const TCollection_AsciiString aFileFormat = theNode->GetFormat();
+ const TCollection_AsciiString aVendorName = theNode->GetVendor();
+ DE_ConfigurationVendorMap* aVendorMap = myConfiguration.ChangeSeek(aFileFormat);
+ if (aVendorMap == NULL)
+ {
+ return false;
+ }
+ const auto aPrevSize = aVendorMap->Size();
+ aVendorMap->RemoveKey(aVendorName);
+ return aVendorMap->Size() != aPrevSize;
+}
+
//=======================================================================
// function : Find
// purpose :
#ifndef _DE_Wrapper_HeaderFile
#define _DE_Wrapper_HeaderFile
-#include <Message_ProgressRange.hxx>
#include <DE_ConfigurationNode.hxx>
-#include <NCollection_IndexedDataMap.hxx>
+#include <Message_ProgressRange.hxx>
#include <NCollection_DataMap.hxx>
+#include <NCollection_IndexedDataMap.hxx>
+#include <Standard_Mutex.hxx>
#include <TColStd_ListOfAsciiString.hxx>
class TopoDS_Shape;
//! Gets global configuration singleton.
//! If wrapper is not set, create it by default as base class object.
//! @return point to global configuration
- Standard_EXPORT static Handle(DE_Wrapper) GlobalWrapper();
+ Standard_EXPORT static const Handle(DE_Wrapper)& GlobalWrapper();
//! Sets global configuration singleton
//! @param[in] theWrapper object to set as global configuration
Standard_EXPORT static void SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper);
+ Standard_EXPORT static Standard_Mutex& GlobalLoadMutex();
+
public:
//! Reads a CAD file, according internal configuration
//! @return Standard_True if binded
Standard_EXPORT Standard_Boolean Bind(const Handle(DE_ConfigurationNode)& theNode);
+ //! Removes node with the same type from the map
+ //! @param[in] theNode input node to remove the same
+ //! @return Standard_True if removed
+ Standard_EXPORT Standard_Boolean UnBind(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
DE_ConfigurationContext.hxx
DE_ConfigurationNode.cxx
DE_ConfigurationNode.hxx
+DE_PluginHolder.hxx
DE_Provider.cxx
DE_Provider.hxx
DE_Wrapper.cxx
#include <DEBRepCascade_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <DEBRepCascade_Provider.hxx>
#include <NCollection_Buffer.hxx>
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<DEBRepCascade_ConfigurationNode> THE_OCCT_BREP_COMPONENT_PLUGIN;
}
//=======================================================================
#include <DEXCAFCascade_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <DEXCAFCascade_Provider.hxx>
#include <NCollection_Buffer.hxx>
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<DEXCAFCascade_ConfigurationNode> THE_OCCT_XCAF_COMPONENT_PLUGIN;
}
//=======================================================================
#endif
#include <TObjDRAW.hxx>
#include <ViewerTest.hxx>
- #include <XSDRAWSTLVRML.hxx>
+ #include <XSDRAW.hxx>
#include <XDEDRAW.hxx>
+ #include <XSDRAWSTEP.hxx>
+ #include <XSDRAWIGES.hxx>
+ #include <XSDRAWGLTF.hxx>
+ #include <XSDRAWOBJ.hxx>
+ #include <XSDRAWPLY.hxx>
+ #include <XSDRAWVRML.hxx>
+ #include <XSDRAWSTL.hxx>
#endif
Standard_IMPORT Standard_Boolean Draw_Interprete (const char* theCommand);
else if (anArg == "DATAEXCHANGE")
{
aPlugins.Add ("XSDRAW");
+ aPlugins.Add ("XSDRAWSTEP");
+ aPlugins.Add ("XSDRAWIGES");
+ aPlugins.Add ("XSDRAWGLTF");
+ aPlugins.Add ("XSDRAWOBJ");
+ aPlugins.Add ("XSDRAWPLY");
+ aPlugins.Add ("XSDRAWVRML");
+ aPlugins.Add ("XSDRAWSTL");
aPlugins.Add ("XDEDRAW");
aPlugins.Add ("AISV");
}
aPlugins.Add ("XSDRAW");
aPlugins.Add ("XDEDRAW");
aPlugins.Add ("AISV");
+ aPlugins.Add ("XSDRAWSTEP");
+ aPlugins.Add ("XSDRAWIGES");
+ aPlugins.Add ("XSDRAWGLTF");
+ aPlugins.Add ("XSDRAWOBJ");
+ aPlugins.Add ("XSDRAWPLY");
+ aPlugins.Add ("XSDRAWVRML");
+ aPlugins.Add ("XSDRAWSTL");
}
else
{
#endif
else if (aPlugin == "XSDRAW")
{
- XSDRAWSTLVRML::Factory (theDI);
+ XSDRAW::Factory (theDI);
}
else if (aPlugin == "XDEDRAW")
{
XDEDRAW::Factory (theDI);
}
- //else if (aPlugin == "TOBJ") { TObjDRAW::Factory (theDI); }
- //else if (aPlugin == "QACOMMANDS") { QADraw::Factory (theDI); }
+ else if (aPlugin == "STEP")
+ {
+ XSDRAWSTEP::Factory (theDI);
+ }
+ else if (aPlugin == "IGES")
+ {
+ XSDRAWIGES::Factory (theDI);
+ }
+ else if (aPlugin == "PLY")
+ {
+ XSDRAWPLY::Factory (theDI);
+ }
+ else if (aPlugin == "GLTF")
+ {
+ XSDRAWGLTF::Factory (theDI);
+ }
+ else if (aPlugin == "VRML")
+ {
+ XSDRAWVRML::Factory (theDI);
+ }
+ else if (aPlugin == "STL")
+ {
+ XSDRAWSTL::Factory (theDI);
+ }
+ else if (aPlugin == "OBJ")
+ {
+ XSDRAWOBJ::Factory (theDI);
+ }
else
{
theDI << "Error: unknown plugin '" << aPlugin << "'";
TKDCAF
TKXSDRAW
TKXDEDRAW
+TKXSDRAWSTEP
+TKXSDRAWIGES
+TKXSDRAWGLTF
+TKXSDRAWOBJ
+TKXSDRAWPLY
+TKXSDRAWVRML
+TKXSDRAWSTL
TKOpenGlTest
TKOpenGlesTest
TKViewerTest
TKDraw
TKMeshVS
-TKXDECascade
TKTObj
TKBinTObj
TKXmlTObj
-TKXDESTEP
-TKSTEP
-TKSTEPAttr
-TKSTEP209
-TKSTEPBase
-TKXDEIGES
-TKIGES
TKXSBase
-TKVRML
-TKSTL
TKRWMesh
-TKXDE
+TKDE
+TKDESTEP
+TKDEIGES
+TKDEGLTF
+TKDEOBJ
+TKDEPLY
+TKDEVRML
+TKDESTL
+TKDECascade
TKBinXCAF
TKXmlXCAF
TKBin
MODELING : TOPTEST
VISUALIZATION : AISV
OCAFKERNEL : DCAF
-DATAEXCHANGEKERNEL : XSDRAW
+DATAEXCHANGEKERNEL : XSDRAW, DE
OCAF : VISUALIZATION, OCAFKERNEL
DATAEXCHANGE : XDE, VISUALIZATION
-XDE : DATAEXCHANGEKERNEL, XDEDRAW
+XDE : DATAEXCHANGEKERNEL, XDEDRAW, STEP, IGES, GLTF, OBJ, PLY, STL, VRML
ALL : MODELING, OCAFKERNEL, DATAEXCHANGE
TOPTEST : TKTopTest
QAcommands : TKQADraw
VIS : TKIVtkDraw
INSPECTOR : TKToolsDraw
+DE : TKXSDRAWDE
+STEP : TKXSDRAWSTEP
+IGES : TKXSDRAWIGES
+GLTF : TKXSDRAWGLTF
+OBJ : TKXSDRAWOBJ
+PLY : TKXSDRAWPLY
+STL : TKXSDRAWSTL
+VRML : TKXSDRAWVRML
#include <IGESCAFControl_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <NCollection_Buffer.hxx>
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<IGESCAFControl_ConfigurationNode> THE_OCCT_IGES_COMPONENT_PLUGIN;
}
//=======================================================================
;# Liste des toolkits WOK sous forme de full path
;#
proc DataExchange:toolkits { } {
- return [list TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES \
- TKXCAF TKXDEIGES TKXDESTEP \
- TKXDE TKXDECascade \
- TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh]
+ return [list TKXSBase TKXCAF TKDEIGES TKDESTEP \
+ TKDE TKDECascade TKDESTL TKDEVRML \
+ TKXmlXCAF TKBinXCAF TKRWMesh \
+ TKDEGLTF TKDEOBJ TKDEPLY]
}
;#
#include <RWGltf_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <RWGltf_Provider.hxx>
IMPLEMENT_STANDARD_RTTIEXT(RWGltf_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<RWGltf_ConfigurationNode> THE_OCCT_GLTF_COMPONENT_PLUGIN;
}
//=======================================================================
#include <RWObj_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <RWObj_Provider.hxx>
IMPLEMENT_STANDARD_RTTIEXT(RWObj_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<RWObj_ConfigurationNode> THE_OCCT_OBJ_COMPONENT_PLUGIN;
}
//=======================================================================
#include <RWPly_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <NCollection_Buffer.hxx>
#include <RWPly_Provider.hxx>
IMPLEMENT_STANDARD_RTTIEXT(RWPly_ConfigurationNode, DE_ConfigurationNode)
-static const TCollection_AsciiString THE_CONFIGURATION_SCOPE = "provider";
+namespace
+{
+ static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
+ {
+ static const TCollection_AsciiString aScope = "provider";
+ return aScope;
+ }
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<RWPly_ConfigurationNode> THE_OCCT_PLY_COMPONENT_PLUGIN;
+}
//=======================================================================
// function : RWPly_ConfigurationNode
//=======================================================================
bool RWPly_ConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor();
+ TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor();
InternalParameters.FileLengthUnit =
theResource->RealVal("file.length.unit", InternalParameters.FileLengthUnit, aScope);
InternalParameters.SystemCS =
TCollection_AsciiString aResult;
aResult += "!*****************************************************************************\n";
aResult = aResult + "!Configuration Node " + " Vendor: " + GetVendor() + " Format: " + GetFormat() + "\n";
- TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE + "." + GetFormat() + "." + GetVendor() + ".";
+ TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".";
aResult += "!\n";
aResult += "!Common parameters:\n";
#include <RWStl_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <NCollection_Buffer.hxx>
#include <RWStl_Provider.hxx>
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<RWStl_ConfigurationNode> THE_OCCT_STL_COMPONENT_PLUGIN;
}
//=======================================================================
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <NCollection_Buffer.hxx>
#include <STEPCAFControl_Provider.hxx>
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<STEPCAFControl_ConfigurationNode> THE_OCCT_STEP_COMPONENT_PLUGIN;
}
//=======================================================================
--- /dev/null
+project(TKDE)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKDECascade)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBin
+TKBinL
+TKBinTObj
+TKBinXCAF
+TKBRep
+TKStd
+TKXml
+TKXmlL
+TKXmlTObj
+TKXmlXCAF
+TKDE
+TKernel
+TKMath
+TKLCAF
+TKXCAF
+TKStdL
+TKCDF
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+DEBRepCascade
+DEXCAFCascade
--- /dev/null
+project(TKDEGLTF)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKernel
+TKMath
+TKMesh
+TKXCAF
+TKLCAF
+TKV3d
+TKBRep
+TKG3d
+TKDE
+TKService
+TKRWMesh
+CSF_RapidJSON
+CSF_Draco
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKDEIGES)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKDE
+TKernel
+TKMath
+TKTopAlgo
+TKShHealing
+TKXSBase
+TKGeomBase
+TKGeomAlgo
+TKBool
+TKPrim
+TKCDF
+TKLCAF
+TKG2d
+TKG3d
+TKXCAF
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+IGESCAFControl
+IGESData
+IGESFile
+IGESBasic
+IGESGraph
+IGESGeom
+IGESDimen
+IGESDraw
+IGESSolid
+IGESDefs
+IGESAppli
+IGESConvGeom
+IGESSelect
+IGESToBRep
+GeomToIGES
+Geom2dToIGES
+BRepToIGES
+BRepToIGESBRep
+IGESControl
--- /dev/null
+project(TKDEOBJ)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKernel
+TKMath
+TKMesh
+TKXCAF
+TKLCAF
+TKV3d
+TKBRep
+TKG3d
+TKDE
+TKService
+TKRWMesh
+CSF_RapidJSON
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKDEPLY)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKernel
+TKMath
+TKMesh
+TKXCAF
+TKLCAF
+TKV3d
+TKBRep
+TKG3d
+TKDE
+TKService
+TKRWMesh
+CSF_RapidJSON
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKDESTEP)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKDE
+TKBRep
+TKernel
+TKMath
+TKXSBase
+TKTopAlgo
+TKG2d
+TKCAF
+TKCDF
+TKLCAF
+TKG3d
+TKXCAF
+TKShHealing
+TKernel
+TKBRep
+TKMath
+TKG2d
+TKShHealing
+TKTopAlgo
+TKG3d
+TKGeomBase
+TKGeomAlgo
+TKXSBase
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+STEPCAFControl
+StepAP214
+RWStepAP214
+StepAP203
+RWStepAP203
+STEPConstruct
+STEPEdit
+GeomToStep
+StepToGeom
+StepToTopoDS
+TopoDSToStep
+STEPControl
+STEPSelections
+StepAP209
+RWStepAP242
+StepAP242
+StepElement
+StepFEA
+RWStepElement
+RWStepFEA
+StepVisual
+RWStepVisual
+StepDimTol
+RWStepDimTol
+StepKinematics
+RWStepKinematics
+StepBasic
+RWStepBasic
+StepRepr
+RWStepRepr
+StepGeom
+RWStepGeom
+StepShape
+RWStepShape
+StepSelect
+StepData
+StepFile
+RWHeaderSection
+APIHeaderSection
+HeaderSection
\ No newline at end of file
--- /dev/null
+project(TKDESTL)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKDE
+TKernel
+TKMath
+TKBRep
+TKG2d
+TKG3d
+TKTopAlgo
+TKLCAF
+TKXCAF
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+StlAPI
+RWStl
--- /dev/null
+project(TKDEVRML)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKDE
+TKTopAlgo
+TKMath
+TKGeomBase
+TKernel
+TKPrim
+TKG2d
+TKG3d
+TKMesh
+TKHLR
+TKRWMesh
+TKService
+TKGeomAlgo
+TKV3d
+TKLCAF
+TKXCAF
+TKXSBase
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+VrmlConverter
+VrmlAPI
+Vrml
+VrmlData
+++ /dev/null
-project(TKIGES)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKBRep
-TKernel
-TKMath
-TKTopAlgo
-TKShHealing
-TKG2d
-TKG3d
-TKGeomBase
-TKGeomAlgo
-TKPrim
-TKBool
-TKXSBase
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-IGESData
-IGESFile
-IGESBasic
-IGESGraph
-IGESGeom
-IGESDimen
-IGESDraw
-IGESSolid
-IGESDefs
-IGESAppli
-IGESConvGeom
-IGESSelect
-IGESToBRep
-GeomToIGES
-Geom2dToIGES
-BRepToIGES
-BRepToIGESBRep
-IGESControl
TKFeat
TKCAF
TKVCAF
-TKIGES
+TKDEIGES
TKXSBase
TKMesh
TKXCAF
TKBinXCAF
-TKSTEP
-TKSTEPBase
-TKXDESTEP
+TKDESTEP
TKXSDRAW
-TKSTL
+TKDESTL
TKXml
TKTObj
TKXmlL
TKV3d
TKBRep
TKG3d
-TKXDE
+TKDE
TKService
CSF_RapidJSON
CSF_Draco
-RWGltf
RWMesh
-RWObj
-RWPly
+++ /dev/null
-project(TKSTEP)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKernel
-TKSTEPAttr
-TKSTEP209
-TKSTEPBase
-TKBRep
-TKMath
-TKG2d
-TKShHealing
-TKTopAlgo
-TKG3d
-TKGeomBase
-TKGeomAlgo
-TKXSBase
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-StepAP214
-RWStepAP214
-StepAP203
-RWStepAP203
-STEPConstruct
-STEPEdit
-GeomToStep
-StepToGeom
-StepToTopoDS
-TopoDSToStep
-STEPControl
-STEPSelections
-StepAP209
-RWStepAP242
-StepAP242
+++ /dev/null
-project(TKSTEP209)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKernel
-TKXSBase
-TKSTEPBase
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-StepElement
-StepFEA
-RWStepElement
-RWStepFEA
+++ /dev/null
-project(TKSTEPAttr)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKernel
-TKXSBase
-TKSTEPBase
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-StepVisual
-RWStepVisual
-StepDimTol
-RWStepDimTol
-StepKinematics
-RWStepKinematics
+++ /dev/null
-project(TKSTEPBase)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKernel
-TKXSBase
-TKMath
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-StepBasic
-RWStepBasic
-StepRepr
-RWStepRepr
-StepGeom
-RWStepGeom
-StepShape
-RWStepShape
+++ /dev/null
-project(TKSTL)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKXDE
-TKernel
-TKMath
-TKBRep
-TKG2d
-TKG3d
-TKTopAlgo
-TKLCAF
-TKXCAF
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-StlAPI
-RWStl
+++ /dev/null
-project(TKVRML)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKBRep
-TKXDE
-TKTopAlgo
-TKMath
-TKGeomBase
-TKernel
-TKPrim
-TKG2d
-TKG3d
-TKMesh
-TKHLR
-TKRWMesh
-TKService
-TKGeomAlgo
-TKV3d
-TKLCAF
-TKXCAF
-TKXSBase
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-VrmlConverter
-VrmlAPI
-Vrml
-VrmlData
+++ /dev/null
-project(TKXDE)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-project(TKXDECascade)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKBin
-TKBinL
-TKBinTObj
-TKBinXCAF
-TKBRep
-TKStd
-TKXml
-TKXmlL
-TKXmlTObj
-TKXmlXCAF
-TKXDE
-TKernel
-TKMath
-TKLCAF
-TKXCAF
-TKStdL
-TKCDF
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-DEBRepCascade
-DEXCAFCascade
-TKXDE
+TKDE
TKCDF
TKBRep
TKXCAF
TKernel
-TKIGES
TKV3d
TKMath
TKService
TKLCAF
TKG3d
TKRWMesh
-TKSTEPBase
-TKSTEP
-TKSTL
+TKDEOBJ
+TKDEGLTF
+TKDEPLY
+TKDESTL
TKMesh
TKXSDRAW
-TKXDECascade
-TKXDEIGES
-TKXDESTEP
+TKDECascade
+TKDEIGES
+TKDESTEP
TKDCAF
TKViewerTest
TKBinXCAF
TKXmlXCAF
-TKVRML
+TKDEVRML
+++ /dev/null
-project(TKXDEIGES)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKBRep
-TKXDE
-TKernel
-TKMath
-TKXSBase
-TKCDF
-TKLCAF
-TKG2d
-TKG3d
-TKXCAF
-TKIGES
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-IGESCAFControl
+++ /dev/null
-project(TKXDESTEP)
-
-OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
+++ /dev/null
-TKXDE
-TKBRep
-TKSTEPAttr
-TKernel
-TKMath
-TKXSBase
-TKTopAlgo
-TKG2d
-TKCAF
-TKSTEPBase
-TKCDF
-TKLCAF
-TKG3d
-TKXCAF
-TKSTEP
-TKShHealing
+++ /dev/null
-EXTERNLIB
-PACKAGES
+++ /dev/null
-STEPCAFControl
IFSelect
TransferBRep
XSControl
-StepData
-StepFile
-HeaderSection
-RWHeaderSection
-APIHeaderSection
-StepSelect
XSAlgo
LibCtl
MoniTool
TKG3d
TKViewerTest
TKG2d
-TKSTEPBase
TKTopAlgo
TKGeomBase
TKGeomAlgo
TKMesh
TKDraw
-TKSTEP
-TKIGES
-TKSTL
-TKVRML
TKLCAF
TKDCAF
TKXCAF
-TKRWMesh
XSDRAW
-XSDRAWIGES
-XSDRAWSTEP
-XSDRAWSTLVRML
--- /dev/null
+project(TKXSDRAWDE)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKXSBase
+TKDECascade
+TKDE
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKXSDRAWGLTF)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKDEGLTF
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+XSDRAWGLTF
--- /dev/null
+project(TKXSDRAWIGES)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKXSBase
+TKDEIGES
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+XSDRAWIGES
--- /dev/null
+project(TKXSDRAWOBJ)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKDEOBJ
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKXSDRAWPLY)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKDEPLY
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKXSDRAWSTEP)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKXSBase
+TKDESTEP
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+XSDRAWSTEP
--- /dev/null
+project(TKXSDRAWSTL)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKDESTL
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+project(TKXSDRAWVRML)
+
+OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit)
--- /dev/null
+TKBRep
+TKV3d
+TKMath
+TKernel
+TKService
+TKXSBase
+TKMeshVS
+TKG3d
+TKViewerTest
+TKG2d
+TKTopAlgo
+TKGeomBase
+TKGeomAlgo
+TKMesh
+TKDraw
+TKLCAF
+TKDCAF
+TKXCAF
+TKRWMesh
+TKDEVRML
+TKXSDRAW
--- /dev/null
+EXTERNLIB
+PACKAGES
--- /dev/null
+XSDRAWVRML
#include <Vrml_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
+#include <DE_PluginHolder.hxx>
#include <Vrml_Provider.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Vrml_ConfigurationNode, DE_ConfigurationNode)
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
+
+ // Wrapper to auto-load DE component
+ DE_PluginHolder<Vrml_ConfigurationNode> THE_OCCT_VRML_COMPONENT_PLUGIN;
}
//=======================================================================
XDEDRAW_Views::InitCommands(di);
XDEDRAW_Notes::InitCommands(di);
XDEDRAW_Common::InitCommands ( di );//moved from EXE
-
- DE_Wrapper::GlobalWrapper()->Bind(new RWObj_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new RWPly_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new RWGltf_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new IGESCAFControl_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new STEPCAFControl_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new Vrml_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new DEXCAFCascade_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new RWStl_ConfigurationNode());
- DE_Wrapper::GlobalWrapper()->Bind(new DEBRepCascade_ConfigurationNode());
}
-
//==============================================================================
// XDEDRAW::Factory
//==============================================================================
void XDEDRAW::Factory(Draw_Interpretor& theDI)
{
- XSDRAWIGES::InitSelect();
- XSDRAWIGES::InitToBRep(theDI);
- XSDRAWIGES::InitFromBRep(theDI);
-
- XSDRAWSTEP::InitCommands(theDI);
-
- XSDRAW::LoadDraw(theDI);
-
XDEDRAW::Init(theDI);
#ifdef OCCT_DEBUG
#include <Draw_Interpretor.hxx>
-
//! Provides DRAW commands for work with DECAF data structures
class XDEDRAW
{
-public:
-
DEFINE_STANDARD_ALLOC
+public:
-
//! Provides common commands for work XDE
//! Initializes all the functions
Standard_EXPORT static void Init (Draw_Interpretor& di);
//! Loads all Draw commands of TKXDEDRAW. Used for plugin.
Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
-
};
#endif // _XDEDRAW_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <XDEDRAW_Common.hxx>
+
+#include <DBRep.hxx>
#include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
-#include <DE_ConfigurationContext.hxx>
-#include <DE_Wrapper.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <Message.hxx>
-#include <IFSelect_SessionPilot.hxx>
-#include <IGESCAFControl_Reader.hxx>
-#include <IGESCAFControl_Writer.hxx>
-#include <IGESControl_Controller.hxx>
-#include <Interface_Macros.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
-#include <STEPCAFControl_ExternFile.hxx>
-#include <STEPCAFControl_Reader.hxx>
-#include <STEPCAFControl_Writer.hxx>
-#include <STEPControl_Controller.hxx>
-#include <TDF_Data.hxx>
+#include <TDF_Tool.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
-#include <XDEDRAW_Common.hxx>
-#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
-#include <XSControl_WorkSession.hxx>
-#include <XSDRAW.hxx>
-#include <XSDRAW_Vars.hxx>
-#include <VrmlAPI_CafReader.hxx>
-#include <VrmlAPI_Writer.hxx>
-#include <DDF.hxx>
-
-#include <DBRep.hxx>
+#include <TopoDS_Shape.hxx>
#include <XCAFDoc_DocumentTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_Editor.hxx>
-#include <TDF_Tool.hxx>
-#include <TopoDS_Shape.hxx>
-#include <Interface_Static.hxx>
-#include <UnitsAPI.hxx>
-#include <UnitsMethods.hxx>
-
-#include <stdio.h>
-
-//============================================================
-// Support for several models in DRAW
-//============================================================
-static NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> thedictws;
-
-//=======================================================================
-//function : parseCoordinateSystem
-//purpose : Parse RWMesh_CoordinateSystem enumeration.
-//=======================================================================
-static bool parseCoordinateSystem(const char* theArg,
- RWMesh_CoordinateSystem& theSystem)
-{
- TCollection_AsciiString aCSStr(theArg);
- aCSStr.LowerCase();
- if (aCSStr == "zup")
- {
- theSystem = RWMesh_CoordinateSystem_Zup;
- }
- else if (aCSStr == "yup")
- {
- theSystem = RWMesh_CoordinateSystem_Yup;
- }
- else
- {
- return Standard_False;
- }
- return Standard_True;
-}
-
-static Standard_Boolean ClearDicWS()
-{
- thedictws.Clear();
- return Standard_True;
-}
-
-static void AddWS(const TCollection_AsciiString& filename,
- const Handle(XSControl_WorkSession)& WS)
-{
- WS->SetVars(new XSDRAW_Vars); // support of DRAW variables
- thedictws.Bind(filename, WS);
-}
-
-
-static Standard_Boolean FillDicWS(NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>& dicFile)
-{
- ClearDicWS();
- if (dicFile.IsEmpty())
- {
- return Standard_False;
- }
- Handle(STEPCAFControl_ExternFile) EF;
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>::Iterator DicEFIt(dicFile);
- for (; DicEFIt.More(); DicEFIt.Next())
- {
- const TCollection_AsciiString& filename = DicEFIt.Key();
- EF = DicEFIt.Value();
- AddWS(filename, EF->GetWS());
- }
- return Standard_True;
-}
-
-static Standard_Boolean SetCurrentWS(const TCollection_AsciiString& filename)
-{
- if (!thedictws.IsBound(filename)) return Standard_False;
- Handle(XSControl_WorkSession) CurrentWS =
- Handle(XSControl_WorkSession)::DownCast(thedictws.ChangeFind(filename));
- XSDRAW::Pilot()->SetSession(CurrentWS);
-
- return Standard_True;
-}
-
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XSDRAW.hxx>
//=======================================================================
//function : SetCurWS
//purpose : Set current file if many files are read
//=======================================================================
-
-static Standard_Integer SetCurWS(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer SetCurWS(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 2)
+ if (theNbArgs < 2)
+ {
+ theDI << "Use: " << theArgVec[0] << " filename \n";
+ return 1;
+ }
+ const TCollection_AsciiString aSessionName(theArgVec[1]);
+ Handle(XSControl_WorkSession) aSession;
+ const XSControl_WorkSessionMap& aWSList = XSDRAW::WorkSessionList();
+ if (!aWSList.Find(aSessionName, aSession))
{
- di << "Use: " << argv[0] << " filename \n";
+ TCollection_AsciiString aWSs;
+ for (XSControl_WorkSessionMap::Iterator anIter(aWSList);
+ anIter.More(); anIter.Next())
+ {
+ aWSs += "\"";
+ aWSs += anIter.Key();
+ aWSs += "\"\n";
+ }
+ theDI << "Error: Can't find active session. Active sessions list:\n" << aWSs;
return 1;
}
- TCollection_AsciiString filename(argv[1]);
- SetCurrentWS(filename);
+ XSDRAW::SetSession(aSession);
return 0;
}
-
//=======================================================================
//function : GetDicWSList
//purpose : List all files recorded after translation
//=======================================================================
-
-static Standard_Integer GetDicWSList(Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
+static Standard_Integer GetDicWSList(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> DictWS = thedictws;
- if (DictWS.IsEmpty()) return 1;
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator DicIt(DictWS);
- di << " The list of last translated files:\n";
- Standard_Integer num = 0;
- for (; DicIt.More(); DicIt.Next(), num++)
+ (void)theNbArgs;
+ (void)theArgVec;
+ Message::SendInfo() << "Active sessions list:";
+ TCollection_AsciiString aWSs;
+ for (XSControl_WorkSessionMap::Iterator anIter(XSDRAW::WorkSessionList());
+ anIter.More(); anIter.Next())
{
- const TCollection_AsciiString& strng(DicIt.Key());
- if (num) di << "\n";
- di << "\"" << strng.ToCString() << "\"";
+ theDI << "\"" << anIter.Key() << "\"\n";
}
return 0;
}
//function : GetCurWS
//purpose : Return name of file which is current
//=======================================================================
-
-static Standard_Integer GetCurWS(Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
+static Standard_Integer GetCurWS(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
+ (void)theNbArgs;
+ (void)theArgVec;
Handle(XSControl_WorkSession) WS = XSDRAW::Session();
- di << "\"" << WS->LoadedFile() << "\"";
+ theDI << "\"" << WS->LoadedFile() << "\"";
return 0;
}
//function : FromShape
//purpose : Apply fromshape command to all the loaded WSs
//=======================================================================
-
-static Standard_Integer FromShape(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer FromShape(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 2)
+ if (theNbArgs < 2)
{
- di << argv[0] << " shape: search for shape origin among all last tranalated files\n";
+ theDI << theArgVec[0] << " shape: search for shape origin among all last tranalated files\n";
return 0;
}
char command[256];
- Sprintf(command, "fromshape %.200s -1", argv[1]);
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> DictWS = thedictws;
- if (DictWS.IsEmpty()) return di.Eval(command);
-
- Handle(XSControl_WorkSession) WS = XSDRAW::Session();
-
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>::Iterator DicIt(DictWS);
- // di << "Searching for shape among all the loaded files:\n";
- Standard_Integer num = 0;
- for (; DicIt.More(); DicIt.Next(), num++)
- {
- Handle(XSControl_WorkSession) CurrentWS =
- Handle(XSControl_WorkSession)::DownCast(DicIt.Value());
- XSDRAW::Pilot()->SetSession(CurrentWS);
- di.Eval(command);
- }
-
- XSDRAW::Pilot()->SetSession(WS);
- return 0;
-}
-
-//=======================================================================
-//function : ReadIges
-//purpose : Read IGES to DECAF document
-//=======================================================================
-
-static Standard_Integer ReadIges(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc < 3)
- {
- di << "Use: " << argv[0] << " Doc filename [mode]: read IGES file to a document\n";
- return 0;
- }
-
- DeclareAndCast(IGESControl_Controller, ctl, XSDRAW::Controller());
- if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
-
- TCollection_AsciiString fnom, rnom;
- Standard_Boolean modfic = XSDRAW::FileAndVar(argv[2], argv[1], "IGES", fnom, rnom);
- if (modfic) di << " File IGES to read : " << fnom.ToCString() << "\n";
- else di << " Model taken from the session : " << fnom.ToCString() << "\n";
- // di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom<<"\n";
-
- IGESCAFControl_Reader reader(XSDRAW::Session(), modfic);
- Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible");
- reader.SetReadVisible(onlyvisible == 1);
-
- if (argc == 4)
- {
- Standard_Boolean mode = Standard_True;
- for (Standard_Integer i = 0; argv[3][i]; i++)
- switch (argv[3][i])
- {
- case '-': mode = Standard_False; break;
- case '+': mode = Standard_True; break;
- case 'c': reader.SetColorMode(mode); break;
- case 'n': reader.SetNameMode(mode); break;
- case 'l': reader.SetLayerMode(mode); break;
- }
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
- Message_ProgressScope aRootScope(aProgress->Start(), "IGES import", modfic ? 2 : 1);
-
- IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
- if (modfic)
- {
- Message_ProgressScope aReadScope(aRootScope.Next(), "File reading", 1);
- aReadScope.Show();
- readstat = reader.ReadFile(fnom.ToCString());
- }
- else if (XSDRAW::Session()->NbStartingEntities() > 0)
- {
- readstat = IFSelect_RetDone;
- }
- if (readstat != IFSelect_RetDone)
- {
- if (modfic)
- {
- di << "Could not read file " << fnom.ToCString() << " , abandon\n";
- }
- else
- {
- di << "No model loaded\n";
- }
- return 1;
- }
-
- Handle(TDocStd_Document) doc;
- if (!DDocStd::GetDocument(argv[1], doc, Standard_False))
- {
- Handle(TDocStd_Application) A = DDocStd::GetApplication();
- A->NewDocument("BinXCAF", doc);
- TDataStd_Name::Set(doc->GetData()->Root(), argv[1]);
- Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc);
- Draw::Set(argv[1], DD);
- // di << "Document saved with name " << argv[1];
- }
- if (!reader.Transfer(doc, aRootScope.Next()))
- {
- di << "Cannot read any relevant data from the IGES file\n";
- return 1;
- }
-
- // Handle(DDocStd_DrawDocument) DD = new DDocStd_DrawDocument(doc);
- // Draw::Set(argv[1],DD);
- di << "Document saved with name " << argv[1];
-
- return 0;
-}
-
-//=======================================================================
-//function : WriteIges
-//purpose : Write DECAF document to IGES
-//=======================================================================
-
-static Standard_Integer WriteIges(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc < 3)
- {
- di << "Use: " << argv[0] << " Doc filename [mode]: write document to IGES file\n";
- return 0;
- }
-
- Handle(TDocStd_Document) Doc;
- DDocStd::GetDocument(argv[1], Doc);
- if (Doc.IsNull())
- {
- di << argv[1] << " is not a document\n";
- return 1;
- }
-
- XSDRAW::SetNorm("IGES");
-
- TCollection_AsciiString fnom, rnom;
- const Standard_Boolean modfic = XSDRAW::FileAndVar(argv[2], argv[1], "IGES", fnom, rnom);
-
- // IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
- // Interface_Static::IVal("write.iges.brep.mode"));
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di);
- Message_ProgressScope aRootScope(aProgress->Start(), "IGES export", modfic ? 2 : 1);
-
- IGESCAFControl_Writer writer(XSDRAW::Session(), Standard_True);
- if (argc == 4)
- {
- Standard_Boolean mode = Standard_True;
- for (Standard_Integer i = 0; argv[3][i]; i++)
- switch (argv[3][i])
- {
- case '-': mode = Standard_False; break;
- case '+': mode = Standard_True; break;
- case 'c': writer.SetColorMode(mode); break;
- case 'n': writer.SetNameMode(mode); break;
- case 'l': writer.SetLayerMode(mode); break;
- }
- }
- writer.Transfer(Doc, aRootScope.Next());
-
- if (modfic)
- {
- Message_ProgressScope aWriteScope(aRootScope.Next(), "File writing", 1);
- aWriteScope.Show();
- di << "Writing IGES model to file " << argv[2] << "\n";
- if (writer.Write(argv[2]))
- {
- di << " Write OK\n";
- }
- else
- {
- di << " Write failed\n";
- }
- }
- else
- {
- di << "Document has been translated into the session";
- }
- return 0;
-}
-
-//=======================================================================
-//function : ReadStep
-//purpose : Read STEP file to DECAF document
-//=======================================================================
-static Standard_Integer ReadStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller());
- if (ctl.IsNull())
- {
- XSDRAW::SetNorm ("STEP");
- }
-
- Standard_CString aDocName = NULL;
- TCollection_AsciiString aFilePath, aModeStr;
- bool toTestStream = false;
- for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
- {
- TCollection_AsciiString anArgCase(argv[anArgIter]);
- anArgCase.LowerCase();
- if (anArgCase == "-stream")
- {
- toTestStream = true;
- }
- else if (aDocName == NULL)
- {
- aDocName = argv[anArgIter];
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = argv[anArgIter];
- }
- else if (aModeStr.IsEmpty())
- {
- aModeStr = argv[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << argv[anArgIter] << "'";
- return 1;
- }
- }
-
- TCollection_AsciiString aFileName, anOldVarName;
- Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName, "STEP", aFileName, anOldVarName);
- if (isFileMode) di << " File STEP to read : " << aFileName << "\n";
- else di << " Model taken from the session : " << aFileName << "\n";
- // di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom<<"\n";
-
- STEPCAFControl_Reader aReader (XSDRAW::Session(), isFileMode);
- if (!aModeStr.IsEmpty())
- {
- Standard_Boolean aMode = Standard_True;
- for (Standard_Integer i = 1; aModeStr.Value (i); ++i)
- {
- switch (aModeStr.Value (i))
- {
- case '-' : aMode = Standard_False; break;
- case '+' : aMode = Standard_True; break;
- case 'c' : aReader.SetColorMode (aMode); break;
- case 'n' : aReader.SetNameMode (aMode); break;
- case 'l' : aReader.SetLayerMode (aMode); break;
- case 'v' : aReader.SetPropsMode (aMode); break;
- default:
- {
- Message::SendFail() << "Syntax error at '" << aModeStr << "'\n";
- return 1;
- }
- }
- }
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
- Message_ProgressScope aRootScope (aProgress->Start(), "STEP import", isFileMode ? 2 : 1);
-
- IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
- if (isFileMode)
- {
- Message_ProgressScope aReadScope (aRootScope.Next(), "File reading", 1);
- aReadScope.Show();
- if (toTestStream)
- {
- std::ifstream aStream;
- OSD_OpenStream (aStream, aFileName.ToCString(), std::ios::in | std::ios::binary);
- TCollection_AsciiString aFolder, aFileNameShort;
- OSD_Path::FolderAndFileFromPath (aFileName, aFolder, aFileNameShort);
- aReadStat = aReader.ReadStream (aFileNameShort.ToCString(), aStream);
- }
- else
- {
- aReadStat = aReader.ReadFile (aFileName.ToCString());
- }
- }
- else if (XSDRAW::Session()->NbStartingEntities() > 0)
- {
- aReadStat = IFSelect_RetDone;
- }
- if (aReadStat != IFSelect_RetDone)
- {
- if (isFileMode)
- {
- di << "Could not read file " << aFileName << " , abandon\n";
- }
- else
- {
- di << "No model loaded\n";
- }
- return 1;
- }
-
- Handle(TDocStd_Document) aDoc;
- if (!DDocStd::GetDocument (aDocName, aDoc, Standard_False))
- {
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- anApp->NewDocument("BinXCAF", aDoc);
- TDataStd_Name::Set (aDoc->GetData()->Root(), aDocName);
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
- Draw::Set (aDocName, aDrawDoc);
- // di << "Document saved with name " << aDocName;
- }
- if (!aReader.Transfer (aDoc, aRootScope.Next()))
- {
- di << "Cannot read any relevant data from the STEP file\n";
- return 1;
- }
-
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
- Draw::Set (aDocName, aDrawDoc);
- di << "Document saved with name " << aDocName;
-
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aReader.ExternFiles();
- FillDicWS (aDicFile);
- AddWS (aFileName, XSDRAW::Session());
- return 0;
-}
-
-//=======================================================================
-//function : WriteStep
-//purpose : Write DECAF document to STEP
-//=======================================================================
-static Standard_Integer WriteStep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
- if (ctl.IsNull())
- {
- XSDRAW::SetNorm ("STEP");
- }
- STEPCAFControl_Writer aWriter (XSDRAW::Session(), Standard_True);
-
- Handle(TDocStd_Document) aDoc;
- TCollection_AsciiString aDocName, aFilePath;
- STEPControl_StepModelType aMode = STEPControl_AsIs;
- bool hasModeArg = false, toTestStream = false;
- TCollection_AsciiString aMultiFilePrefix, aLabelName;
- TDF_Label aLabel;
- for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
- {
- TCollection_AsciiString anArgCase (argv[anArgIter]);
- anArgCase.LowerCase();
- if (anArgCase == "-stream")
- {
- toTestStream = true;
- }
- else if (aDocName.IsEmpty())
- {
- Standard_CString aDocNameStr = argv[anArgIter];
- DDocStd::GetDocument (aDocNameStr, aDoc);
- if (aDoc.IsNull())
- {
- di << "Syntax error: '" << argv[anArgIter] << "' is not a document";
- return 1;
- }
- aDocName = aDocNameStr;
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = argv[anArgIter];
- }
- else if (!hasModeArg)
- {
- hasModeArg = true;
- switch (anArgCase.Value (1))
- {
- case 'a':
- case '0': aMode = STEPControl_AsIs; break;
- case 'f':
- case '1': aMode = STEPControl_FacetedBrep; break;
- case 's':
- case '2': aMode = STEPControl_ShellBasedSurfaceModel; break;
- case 'm':
- case '3': aMode = STEPControl_ManifoldSolidBrep; break;
- case 'w':
- case '4': aMode = STEPControl_GeometricCurveSet; break;
- default:
- {
- di << "Syntax error: mode '" << argv[anArgIter] << "' is incorrect [give fsmw]";
- return 1;
- }
- }
- Standard_Boolean wrmode = Standard_True;
- for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i)
- {
- switch (anArgCase.Value (i))
- {
- case '-' : wrmode = Standard_False; break;
- case '+' : wrmode = Standard_True; break;
- case 'c' : aWriter.SetColorMode (wrmode); break;
- case 'n' : aWriter.SetNameMode (wrmode); break;
- case 'l' : aWriter.SetLayerMode (wrmode); break;
- case 'v' : aWriter.SetPropsMode (wrmode); break;
- }
- }
- }
- else if (aMultiFilePrefix.IsEmpty()
- && anArgCase.Search (":") == -1)
- {
- aMultiFilePrefix = argv[anArgIter];
- }
- else if (aLabel.IsNull())
- {
- if (!DDF::FindLabel (aDoc->Main().Data(), argv[anArgIter], aLabel)
- || aLabel.IsNull())
- {
- di << "Syntax error: No label for entry '" << argv[anArgIter] << "'";
- return 1;
- }
- aLabelName = argv[anArgIter];
- }
- else
- {
- di << "Syntax error: unknown argument '" << argv[anArgIter] << "'";
- return 1;
- }
- }
- if (aFilePath.IsEmpty())
- {
- di << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- TCollection_AsciiString aFileName, anOldVarName;
- const Standard_Boolean isFileMode = XSDRAW::FileAndVar (aFilePath.ToCString(), aDocName.ToCString(), "STEP", aFileName, anOldVarName);
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
- Message_ProgressScope aRootScope (aProgress->Start(), "STEP export", isFileMode ? 2 : 1);
- if (!aLabel.IsNull())
- {
- di << "Translating label " << aLabelName << " of document " << aDocName << " to STEP\n";
- if (!aWriter.Transfer (aLabel, aMode,
- !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
- aRootScope.Next()))
- {
- di << "Error: the label of document cannot be translated or gives no result";
- return 1;
- }
- }
- else
- {
- di << "Translating document " << aDocName << " to STEP\n";
- if (!aWriter.Transfer (aDoc, aMode,
- !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
- aRootScope.Next()))
- {
- di << "Error: The document cannot be translated or gives no result\n";
- }
- }
-
- if (!isFileMode)
- {
- di << "Document has been translated into the session";
- return 0;
- }
-
- Message_ProgressScope aWriteScope (aRootScope.Next(), "File writing", 1);
- aWriteScope.Show();
- di << "Writing STEP file " << aFilePath << "\n";
-
- IFSelect_ReturnStatus aStat = IFSelect_RetVoid;
- if (toTestStream)
- {
- std::ofstream aStream;
- OSD_OpenStream (aStream, aFilePath, std::ios::out | std::ios::binary);
- aStat = aWriter.WriteStream (aStream);
- aStream.close();
- if (!aStream.good()
- && aStat == IFSelect_RetDone)
- {
- aStat = IFSelect_RetFail;
- }
- }
- else
- {
- aStat = aWriter.Write (aFilePath.ToCString());
- }
+ Sprintf(command, "fromshape %.200s -1", theArgVec[1]);
+ const XSControl_WorkSessionMap& DictWS = XSDRAW::WorkSessionList();
+ if (DictWS.IsEmpty())
+ return theDI.Eval(command);
- switch (aStat)
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ for (XSControl_WorkSessionMap::Iterator DicIt(DictWS);
+ DicIt.More(); DicIt.Next())
{
- case IFSelect_RetVoid:
- {
- di << "Error: no file written";
- break;
- }
- case IFSelect_RetDone:
- {
- di << "File " << aFilePath << " written\n";
-
- NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)> aDicFile = aWriter.ExternFiles();
- FillDicWS (aDicFile);
- AddWS (aFilePath, XSDRAW::Session());
- break;
- }
- default:
+ Handle(XSControl_WorkSession) CurrentWS = Handle(XSControl_WorkSession)::DownCast(DicIt.Value());
+ if (!CurrentWS.IsNull())
{
- di << "Error on writing file";
- break;
+ XSDRAW::SetSession(CurrentWS);
+ theDI.Eval(command);
}
}
+ XSDRAW::SetSession(aWS);
return 0;
}
//function : Expand
//purpose :
//=======================================================================
-static Standard_Integer Expand(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer Expand(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 3)
+ if (theNbArgs < 3)
{
- di << "Use: " << argv[0] << " Doc recurs(0/1) or Doc recurs(0/1) label1 label2 ... or Doc recurs(0/1 shape1 shape2 ...\n";
+ theDI << "Use: " << theArgVec[0]
+ << " Doc recurs(0/1) or Doc recurs(0/1) label1 label2 ... or Doc recurs(0/1 shape1 shape2 ...\n";
return 1;
}
Handle(TDocStd_Document) Doc;
- DDocStd::GetDocument(argv[1], Doc);
+ DDocStd::GetDocument(theArgVec[1], Doc);
if (Doc.IsNull())
{
- di << argv[1] << " is not a document\n"; return 1;
+ theDI << theArgVec[1] << " is not a document\n"; return 1;
}
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
Standard_Boolean recurs = Standard_False;
- if (atoi(argv[2]) != 0)
+ if (atoi(theArgVec[2]) != 0)
recurs = Standard_True;
- if (argc == 3)
+ if (theNbArgs == 3)
{
if (!XCAFDoc_Editor::Expand(Doc->Main(), recurs))
{
- di << "No suitable labels to expand\n";
+ theDI << "No suitable labels to expand\n";
return 1;
}
}
else
{
- for (Standard_Integer i = 3; i < argc; i++)
+ for (Standard_Integer i = 3; i < theNbArgs; i++)
{
TDF_Label aLabel;
- TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
+ TDF_Tool::Label(Doc->GetData(), theArgVec[i], aLabel);
if (aLabel.IsNull())
{
TopoDS_Shape aShape;
- aShape = DBRep::Get(argv[i]);
+ aShape = DBRep::Get(theArgVec[i]);
aLabel = aShapeTool->FindShape(aShape);
}
{
if (!XCAFDoc_Editor::Expand(Doc->Main(), aLabel, recurs))
{
- di << "The shape is assembly or not compound\n";
+ theDI << "The shape is assembly or not compound\n";
return 1;
}
}
else
{
- di << argv[i] << " is not a shape\n"; return 1;
+ theDI << theArgVec[i] << " is not a shape\n"; return 1;
}
}
}
//function : Extract
//purpose :
//=======================================================================
-static Standard_Integer Extract(Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv)
+static Standard_Integer Extract(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 4)
+ if (theNbArgs < 4)
{
- di << "Use: " << argv[0] << "dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\n";
+ theDI << "Use: " << theArgVec[0] << "dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\n";
return 1;
}
Handle(TDocStd_Document) aSrcDoc, aDstDoc;
- DDocStd::GetDocument(argv[1], aDstDoc);
+ DDocStd::GetDocument(theArgVec[1], aDstDoc);
if (aDstDoc.IsNull())
{
- di << "Error " << argv[1] << " is not a document\n";
+ theDI << "Error " << theArgVec[1] << " is not a document\n";
return 1;
}
TDF_Label aDstLabel;
Standard_Integer anArgInd = 3;
- TDF_Tool::Label(aDstDoc->GetData(), argv[2], aDstLabel);
+ TDF_Tool::Label(aDstDoc->GetData(), theArgVec[2], aDstLabel);
Handle(XCAFDoc_ShapeTool) aDstShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDstDoc->Main());
if (aDstLabel.IsNull())
{
aDstLabel = aDstShapeTool->Label();
anArgInd = 2; // to get Src Doc
}
- DDocStd::GetDocument(argv[anArgInd++], aSrcDoc);
+ DDocStd::GetDocument(theArgVec[anArgInd++], aSrcDoc);
if (aSrcDoc.IsNull())
{
- di << "Error " << argv[anArgInd] << " is not a document\n";
+ theDI << "Error " << theArgVec[anArgInd] << " is not a document\n";
return 1;
}
TDF_LabelSequence aSrcShapes;
- for (; anArgInd < argc; anArgInd++)
+ for (; anArgInd < theNbArgs; anArgInd++)
{
TDF_Label aSrcLabel;
- TDF_Tool::Label(aSrcDoc->GetData(), argv[anArgInd], aSrcLabel);
+ TDF_Tool::Label(aSrcDoc->GetData(), theArgVec[anArgInd], aSrcLabel);
if (aSrcLabel.IsNull())
{
- di << "[" << argv[anArgInd] << "] is not valid Src label\n";
+ theDI << "[" << theArgVec[anArgInd] << "] is not valid Src label\n";
return 1;
}
aSrcShapes.Append(aSrcLabel);
}
if (aSrcShapes.IsEmpty())
{
- di << "Error: No Shapes to extract\n";
+ theDI << "Error: No Shapes to extract\n";
return 1;
}
if (!XCAFDoc_Editor::Extract(aSrcShapes, aDstLabel))
{
- di << "Error: Cannot extract labels\n";
+ theDI << "Error: Cannot extract labels\n";
return 1;
}
return 0;
}
//=======================================================================
-//function : ReadVrml
+//function : InitCommands
//purpose :
//=======================================================================
-static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
- Standard_Integer theArgc,
- const char** theArgv)
-{
- if(theArgc < 3)
- {
- theDI.PrintHelp(theArgv[0]);
- return 1;
- }
-
- Handle(TDocStd_Document) aDoc;
- Standard_Real aFileUnitFactor = 1.0;
- RWMesh_CoordinateSystem aFileCoordSys = RWMesh_CoordinateSystem_Yup, aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
- Standard_Boolean toUseExistingDoc = Standard_False;
- Standard_Boolean toFillIncomplete = Standard_True;
- Standard_CString aDocName = NULL;
- TCollection_AsciiString aFilePath;
-
- for(Standard_Integer anArgIt = 1; anArgIt < theArgc; anArgIt++)
- {
- TCollection_AsciiString anArg(theArgv[anArgIt]);
- anArg.LowerCase();
- if(anArgIt + 1 < theArgc && anArg == "-fileunit")
- {
- const TCollection_AsciiString aUnitStr(theArgv[++anArgIt]);
- aFileUnitFactor = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString());
- if (aFileUnitFactor <= 0.0)
- {
- Message::SendFail() << "Error: wrong length unit '" << aUnitStr << "'";
- return 1;
- }
- }
- else if (anArgIt + 1 < theArgc && anArg == "-filecoordsys")
- {
- if (!parseCoordinateSystem(theArgv[++anArgIt], aFileCoordSys))
- {
- Message::SendFail() << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'";
- return 1;
- }
- }
- else if (anArgIt + 1 < theArgc && anArg == "-systemcoordsys")
- {
- if (!parseCoordinateSystem(theArgv[++anArgIt], aSystemCoordSys))
- {
- Message::SendFail() << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'";
- return 1;
- }
- }
- else if (anArg == "-fillincomplete")
- {
- toFillIncomplete = true;
- if (anArgIt + 1 < theArgc && Draw::ParseOnOff(theArgv[anArgIt + 1], toFillIncomplete))
- {
- ++anArgIt;
- }
- }
- else if (anArg == "-nocreatedoc")
- {
- toUseExistingDoc = true;
- }
- else if (aDocName == nullptr)
- {
- aDocName = theArgv[anArgIt];
- DDocStd::GetDocument(aDocName, aDoc, Standard_False);
- }
- else if(aFilePath.IsEmpty())
- {
- aFilePath = theArgv[anArgIt];
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << theArgv[anArgIt] << "'";
- return 1;
- }
- }
-
- if (aFilePath.IsEmpty() || aDocName == nullptr)
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- if (aDoc.IsNull())
- {
- if(toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDocName << " does not exist";
- return 1;
- }
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- anApp->NewDocument("BinXCAF", aDoc);
- }
- else if (!toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDocName << " already exists\n";
- return 1;
- }
-
- Standard_Real aScaleFactor = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactor))
- {
- XSAlgo::AlgoContainer()->PrepareForTransfer();
- aScaleFactor = UnitsMethods::GetCasCadeLengthUnit();
- }
-
- VrmlAPI_CafReader aVrmlReader;
- aVrmlReader.SetDocument(aDoc);
- aVrmlReader.SetFileLengthUnit(aFileUnitFactor);
- aVrmlReader.SetSystemLengthUnit(aScaleFactor);
- aVrmlReader.SetFileCoordinateSystem(aFileCoordSys);
- aVrmlReader.SetSystemCoordinateSystem(aSystemCoordSys);
- aVrmlReader.SetFillIncompleteDocument(toFillIncomplete);
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
- if (!aVrmlReader.Perform(aFilePath, aProgress->Start()))
- {
- if (aVrmlReader.ExtraStatus() != RWMesh_CafReaderStatusEx_Partial)
- {
- Message::SendFail() << "Error: file reading failed '" << aFilePath << "'";
- return 1;
- }
- Message::SendWarning() <<
- "Warning: file has been read paratially (due to unexpected EOF, syntax error, memory limit) " << aFilePath;
- }
-
- TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName);
- Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc);
- Draw::Set(aDocName, aDD);
-
- return 0;
-}
-
-//=======================================================================
-//function : WriteVrml
-//purpose : Write DECAF document to Vrml
-//=======================================================================
-
-static Standard_Integer WriteVrml(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc < 3)
- {
- di << "Use: " << argv[0] << " Doc filename: write document to Vrml file\n";
- return 0;
- }
-
- Handle(TDocStd_Document) aDoc;
- DDocStd::GetDocument(argv[1], aDoc);
- if (aDoc.IsNull())
- {
- di << argv[1] << " is not a document\n";
- return 1;
- }
-
- if (argc < 3 || argc > 5)
- {
- di << "wrong number of parameters\n";
- return 0;
- }
-
- VrmlAPI_Writer writer;
- writer.SetRepresentation(VrmlAPI_ShadedRepresentation);
- Standard_Real aScaleFactorM = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM))
- {
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
- }
- if (!writer.WriteDoc(aDoc, argv[2], aScaleFactorM))
- {
- di << "Error: File " << argv[2] << " was not written\n";
- }
-
- return 0;
-}
-
-//=======================================================================
-//function : DumpConfiguration
-//purpose :
-//=======================================================================
-static Standard_Integer DumpConfiguration(Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
+void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI)
{
- Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper();
- TCollection_AsciiString aPath;
- Standard_Boolean aIsRecursive = Standard_True;
- Standard_Boolean isHandleFormat = Standard_False;
- Standard_Boolean isHandleVendors = Standard_False;
- TColStd_ListOfAsciiString aFormats;
- TColStd_ListOfAsciiString aVendors;
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArg(theArgVec[anArgIter]);
- anArg.LowerCase();
- if ((anArg == "-path") &&
- (anArgIter + 1 < theNbArgs))
- {
- ++anArgIter;
- aPath = theArgVec[anArgIter];
- }
- else if ((anArg == "-recursive") &&
- (anArgIter + 1 < theNbArgs) &&
- Draw::ParseOnOff(theArgVec[anArgIter + 1], aIsRecursive))
- {
- ++anArgIter;
- }
- else if (anArg == "-format")
- {
- isHandleFormat = Standard_True;
- isHandleVendors = Standard_False;
- }
- else if (anArg == "-vendor")
- {
- isHandleFormat = Standard_False;
- isHandleVendors = Standard_True;
- }
- else if (isHandleFormat)
- {
- aFormats.Append(theArgVec[anArgIter]);
- }
- else if (isHandleVendors)
- {
- aVendors.Append(theArgVec[anArgIter]);
- }
- else if (!isHandleFormat && !isHandleVendors)
- {
- Message::SendFail() << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n";
- return 1;
- }
- }
- Standard_Boolean aStat = Standard_True;
- if (!aPath.IsEmpty())
- {
- aStat = aConf->Save(aPath, aIsRecursive, aFormats ,aVendors);
- }
- else
- {
- theDI << aConf->Save(aIsRecursive, aFormats, aVendors) << "\n";
- }
- if (!aStat)
- {
- return 1;
- }
- return 0;
-}
-
-//=======================================================================
-//function : CompareConfiguration
-//purpose :
-//=======================================================================
-static Standard_Integer CompareConfiguration(Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- if (theNbArgs > 5)
- {
- theDI.PrintHelp(theArgVec[0]);
- return 1;
- }
- Handle(DE_ConfigurationContext) aResourceFirst = new DE_ConfigurationContext();
- if (!aResourceFirst->Load(theArgVec[1]))
- {
- Message::SendFail() << "Error: Can't load first configuration";
- return 1;
- }
- Handle(DE_ConfigurationContext) aResourceSecond = new DE_ConfigurationContext();
- if (!aResourceSecond->Load(theArgVec[2]))
- {
- Message::SendFail() << "Error: Can't load second configuration";
- return 1;
- }
- const DE_ResourceMap& aResourceMapFirst = aResourceFirst->GetInternalMap();
- const DE_ResourceMap& aResourceMapSecond = aResourceSecond->GetInternalMap();
- Standard_Integer anDiffers = 0;
- for (DE_ResourceMap::Iterator anOrigIt(aResourceMapFirst);
- anOrigIt.More(); anOrigIt.Next())
- {
- const TCollection_AsciiString& anOrigValue = anOrigIt.Value();
- const TCollection_AsciiString& anOrigKey = anOrigIt.Key();
- TCollection_AsciiString aCompValue;
- if (!aResourceMapSecond.Find(anOrigKey, aCompValue))
- {
- Message::SendWarning() << "Second configuration don't have the next scope : " << anOrigKey;
- anDiffers++;
- }
- if (!aCompValue.IsEqual(anOrigValue))
- {
- Message::SendWarning() << "Configurations have differs value with the next scope :" << anOrigKey
- << " First value : " << anOrigValue << " Second value : " << aCompValue;
- anDiffers++;
- }
- }
- TCollection_AsciiString aMessage;
- if (aResourceMapFirst.Extent() != aResourceMapSecond.Extent() || anDiffers > 0)
- {
- Message::SendFail() << "Error: Configurations are not same : " << " Differs count : " << anDiffers << " Count of first's scopes : " << aResourceMapFirst.Extent()
- << " Count of second's scopes : " << aResourceMapSecond.Extent();
- return 1;
- }
- return 0;
-}
-
-//=======================================================================
-//function : LoadConfiguration
-//purpose :
-//=======================================================================
-static Standard_Integer LoadConfiguration(Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- if (theNbArgs > 4)
- {
- theDI.PrintHelp(theArgVec[0]);
- return 1;
- }
- Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper();
- TCollection_AsciiString aString = theArgVec[1];
- Standard_Boolean aIsRecursive = Standard_True;
- if (theNbArgs == 4)
- {
- TCollection_AsciiString anArg = theArgVec[2];
- anArg.LowerCase();
- if (!(anArg == "-recursive") ||
- !Draw::ParseOnOff(theArgVec[3], aIsRecursive))
- {
- Message::SendFail() << "Syntax error at argument '" << theArgVec[3] << "'";
- return 1;
- }
- }
- if (!aConf->Load(aString, aIsRecursive))
- {
- Message::SendFail() << "Error: configuration is incorrect";
- return 1;
- }
- return 0;
-}
-
-//=======================================================================
-//function : ReadFile
-//purpose :
-//=======================================================================
-static Standard_Integer ReadFile(Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- if (theNbArgs > 6)
- {
- theDI.PrintHelp(theArgVec[0]);
- return 1;
- }
- TCollection_AsciiString aDocShapeName;
- TCollection_AsciiString aFilePath;
- Handle(TDocStd_Document) aDoc;
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- TCollection_AsciiString aConfString;
- Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readfile");
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArg(theArgVec[anArgIter]);
- anArg.LowerCase();
- if ((anArg == "-conf") &&
- (anArgIter + 1 < theNbArgs))
- {
- ++anArgIter;
- aConfString = theArgVec[anArgIter];
- }
- else if (aDocShapeName.IsEmpty())
- {
- aDocShapeName = theArgVec[anArgIter];
- Standard_CString aNameVar = aDocShapeName.ToCString();
- if(!isNoDoc)
- {
- DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
- }
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgVec[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at argument '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
- if (aDoc.IsNull() && !isNoDoc)
- {
- anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
- TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]);
- Draw::Set(theArgVec[1], aDrawDoc);
- }
-
- Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
- Standard_Boolean aStat = Standard_True;
- if (!aConfString.IsEmpty())
- {
- aStat = aConf->Load(aConfString);
- }
- if (aStat)
- {
- TopoDS_Shape aShape;
- aStat = isNoDoc ? aConf->Read(aFilePath, aShape) : aConf->Read(aFilePath, aDoc);
- if(isNoDoc && aStat)
- {
- DBRep::Set(aDocShapeName.ToCString(), aShape);
- }
- }
- if (!aStat)
- {
- return 1;
- }
- return 0;
-}
-
-//=======================================================================
-//function : WriteFile
-//purpose :
-//=======================================================================
-static Standard_Integer WriteFile(Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- if (theNbArgs > 6)
- {
- theDI.PrintHelp(theArgVec[0]);
- return 1;
- }
- TCollection_AsciiString aDocShapeName;
- TCollection_AsciiString aFilePath;
- Handle(TDocStd_Document) aDoc;
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- TCollection_AsciiString aConfString;
- Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "writefile");
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArg(theArgVec[anArgIter]);
- anArg.LowerCase();
- if ((anArg == "-conf") &&
- (anArgIter + 1 < theNbArgs))
- {
- ++anArgIter;
- aConfString = theArgVec[anArgIter];
- }
- else if (aDocShapeName.IsEmpty())
- {
- aDocShapeName = theArgVec[anArgIter];
- Standard_CString aNameVar = aDocShapeName.ToCString();
- if (!isNoDoc)
- {
- DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
- }
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgVec[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at argument '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
- if (aDoc.IsNull() && !isNoDoc)
- {
- Message::SendFail() << "Error: incorrect document";
- }
- Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
- Standard_Boolean aStat = Standard_True;
- if (!aConfString.IsEmpty())
- {
- aStat = aConf->Load(aConfString);
- }
- if (aStat)
- {
- if(isNoDoc)
- {
- TopoDS_Shape aShape = DBRep::Get(aDocShapeName);
- if(aShape.IsNull())
- {
- Message::SendFail() << "Error: incorrect shape";
- return 1;
- }
- aStat = aConf->Write(aFilePath, aShape);
- }
- else
- {
- aStat = aConf->Write(aFilePath, aDoc);
- }
- }
- if (!aStat)
- {
- return 1;
- }
- return 0;
-}
-
-void XDEDRAW_Common::InitCommands(Draw_Interpretor& di)
-{
- static Standard_Boolean initactor = Standard_False;
- if (initactor)
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
{
return;
}
- initactor = Standard_True;
-
- Standard_CString g = "XDE translation commands";
-
- di.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g);
- di.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g);
- di.Add("ReadStep",
- "Doc filename [mode] [-stream]"
- "\n\t\t: Read STEP file to a document."
- "\n\t\t: -stream read using istream reading interface (testing)",
- __FILE__, ReadStep, g);
- di.Add("WriteStep" ,
- "Doc filename [mode=a [multifile_prefix] [label]] [-stream]"
- "\n\t\t: Write DECAF document to STEP file"
- "\n\t\t: mode can be: a or 0 : AsIs (default)"
- "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel"
- "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame"
- "\n\t\t: multifile_prefix: triggers writing assembly components as separate files,"
- "\n\t\t: and defines common prefix for their names"
- "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly"
- "\n\t\t: -stream read using ostream writing interface (testing)",
- __FILE__, WriteStep, g);
+ aIsActivated = Standard_True;
- di.Add("XFileList", "Print list of files that was transferred by the last transfer", __FILE__, GetDicWSList, g);
- di.Add("XFileCur", ": returns name of file which is set as current", __FILE__, GetCurWS, g);
- di.Add("XFileSet", "filename: Set the specified file to be the current one", __FILE__, SetCurWS, g);
- di.Add("XFromShape", "shape: do fromshape command for all the files", __FILE__, FromShape, g);
+ Standard_CString aGroup = "XDE translation commands";
- di.Add("XExpand", "XExpand Doc recursively(0/1) or XExpand Doc recursively(0/1) label1 label2 ..."
- "or XExpand Doc recursively(0/1) shape1 shape2 ...", __FILE__, Expand, g);
- di.Add("XExtract", "XExtract dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\t"
- "Extracts given srcLabel1 srcLabel2 ... from srcDoc into given Doc or assembly shape",
- __FILE__, Extract, g);
+ theDI.Add("XFileList", "Print list of files that was transferred by the last transfer", __FILE__, GetDicWSList, aGroup);
+ theDI.Add("XFileCur", ": returns name of file which is set as current", __FILE__, GetCurWS, aGroup);
+ theDI.Add("XFileSet", "filename: Set the specified file to be the current one", __FILE__, SetCurWS, aGroup);
+ theDI.Add("XFromShape", "shape: do fromshape command for all the files", __FILE__, FromShape, aGroup);
- di.Add("ReadVrml",
- "ReadVrml docName filePath [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
- "\n\t\t: [-systemCoordSys {Zup|Yup}] [-noCreateDoc] [-fillIncomplete {ON|OFF}]"
- "\n\t\t: Read Vrml file into XDE document."
- "\n\t\t: -fileCoordSys coordinate system defined by Vrml file; Yup when not specified."
- "\n\t\t: -fileUnit length unit of Vrml file content."
- "\n\t\t: -systemCoordSys result coordinate system; Zup when not specified."
- "\n\t\t: -noCreateDoc read into existing XDE document."
- "\n\t\t: -fillIncomplete fill the document with partially retrieved data even if reader has failed with "
- "error; true when not specified",
- __FILE__, ReadVrml, g);
- di.Add("WriteVrml",
- "WriteVrml Doc filename [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 0 by default]",
- __FILE__, WriteVrml, g);
+ theDI.Add("XExpand", "XExpand Doc recursively(0/1) or XExpand Doc recursively(0/1) label1 label2 ..."
+ "or XExpand Doc recursively(0/1) shape1 shape2 ...", __FILE__, Expand, aGroup);
+ theDI.Add("XExtract", "XExtract dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\t"
+ "Extracts given srcLabel1 srcLabel2 ... from srcDoc into given Doc or assembly shape",
+ __FILE__, Extract, aGroup);
- di.Add("DumpConfiguration",
- "DumpConfiguration [-path <path>] [-recursive {on|off}] [-format fmt1 fmt2 ...] [-vendor vend1 vend2 ...]\n"
- "\n\t\t: Dump special resource generated from global configuration."
- "\n\t\t: '-path' - save resource configuration to the file"
- "\n\t\t: '-recursive' - flag to generate a resource from providers. Default is On. Off disables other options"
- "\n\t\t: '-format' - flag to generate a resource for choosen formats. If list is empty, generate it for all"
- "\n\t\t: '-vendor' - flag to generate a resource for choosen vendors. If list is empty, generate it for all",
- __FILE__, DumpConfiguration, g);
- di.Add("LoadConfiguration",
- "LoadConfiguration conf [-recursive {on|off}]\n"
- "\n\t\t: 'conf' - path to the resouce file or string value in the special format"
- "\n\t\t: '-recursive' - flag to generate a resource for all providers. Default is true"
- "\n\t\t: Configure global configuration according special resource",
- __FILE__, LoadConfiguration, g);
- di.Add("CompareConfiguration",
- "CompareConfiguration conf1 conf2\n"
- "\n\t\t: 'conf1' - path to the first resouce file or string value in the special format"
- "\n\t\t: 'conf2' - path to the second resouce file or string value in the special format"
- "\n\t\t: Compare two configurations",
- __FILE__, CompareConfiguration, g);
- di.Add("ReadFile",
- "ReadFile docName filePath [-conf <value|path>]\n"
- "\n\t\t: Read CAD file to document with registered format's providers. Use global configuration by default.",
- __FILE__, ReadFile, g);
- di.Add("readfile",
- "readfile shapeName filePath [-conf <value|path>]\n"
- "\n\t\t: Read CAD file to shape with registered format's providers. Use global configuration by default.",
- __FILE__, ReadFile, g);
- di.Add("WriteFile",
- "WriteFile docName filePath [-conf <value|path>]\n"
- "\n\t\t: Write CAD file to document with registered format's providers. Use global configuration by default.",
- __FILE__, WriteFile, g);
- di.Add("writefile",
- "writefile shapeName filePath [-conf <value|path>]\n"
- "\n\t\t: Write CAD file to shape with registered format's providers. Use global configuration by default.",
- __FILE__, WriteFile, g);
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
}
#include <Draw_Interpretor.hxx>
-
-
class XDEDRAW_Common
{
-public:
-
DEFINE_STANDARD_ALLOC
-
-
+public:
+
Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
};
-
-
-
-
-
-
#endif // _XDEDRAW_Common_HeaderFile
if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone;
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout<<"No new Model produced"<<std::endl;
- return IFSelect_RetFail;
+ return IFSelect_RetDone;
}
class XSControl_WorkSession;
DEFINE_STANDARD_HANDLE(XSControl_WorkSession, IFSelect_WorkSession)
+using XSControl_WorkSessionMap = NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>;
+
//! This WorkSession completes the basic one, by adding :
//! - use of Controller, with norm selection...
//! - management of transfers (both ways) with auxiliary classes
//! Returns the current Context List, Null if not defined
//! The Context is given to the TransientProcess for TransferRead
- const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> & Context() const
+ const XSControl_WorkSessionMap& Context() const
{ return myContext; }
//! Sets the current Context List, as a whole
//! Sets it to the TransferReader
- Standard_EXPORT void SetAllContext (const NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)>& theContext);
+ Standard_EXPORT void SetAllContext (const XSControl_WorkSessionMap& theContext);
//! Clears the whole current Context (nullifies it)
Standard_EXPORT void ClearContext();
Handle(XSControl_Controller) myController;
Handle(XSControl_TransferReader) myTransferReader;
Handle(XSControl_TransferWriter) myTransferWriter;
- NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> myContext;
+ XSControl_WorkSessionMap myContext;
Handle(XSControl_Vars) myVars;
};
#include <DBRep.hxx>
#include <Draw_Appli.hxx>
#include <Draw_Printer.hxx>
+#include <Draw_PluginMacro.hxx>
#include <IFSelect_Functions.hxx>
#include <IFSelect_SessionPilot.hxx>
#include <Interface_InterfaceModel.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_TransientProcess.hxx>
#include <TransferBRep.hxx>
+#include <XSAlgo.hxx>
#include <XSControl.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_FuncShape.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
#include <XSDRAW_Vars.hxx>
+#include <UnitsMethods.hxx>
+#include <Interface_Static.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
#include <iostream>
#include <string>
-//#include <XSDRAW_Shape.hxx>
-static int deja = 0, dejald = 0;
-//unused variable
-//static int okxset = 0;
+namespace
+{
+ static int deja = 0, dejald = 0;
-static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theolds;
-static Handle(TColStd_HSequenceOfAsciiString) thenews;
+ static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theolds;
+ static Handle(TColStd_HSequenceOfAsciiString) thenews;
-static Handle(IFSelect_SessionPilot) thepilot; // detient Session, Model
+ static Handle(IFSelect_SessionPilot) thepilot; // detient Session, Model
+
+ //=======================================================================
+ //function : collectActiveWorkSessions
+ //purpose :
+ //=======================================================================
+ static void collectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
+ const TCollection_AsciiString& theName,
+ XSControl_WorkSessionMap& theMap,
+ const Standard_Boolean theIsFirst)
+ {
+ if (theIsFirst)
+ {
+ theMap.Clear();
+ }
+ if (theWS.IsNull())
+ {
+ return;
+ }
+ if (theMap.IsBound(theName))
+ {
+ return;
+ }
+ theMap.Bind(theName, theWS);
+ for (XSControl_WorkSessionMap::Iterator anIter(theWS->Context());
+ anIter.More(); anIter.Next())
+ {
+ Handle(XSControl_WorkSession) aWS = Handle(XSControl_WorkSession)::DownCast(anIter.Value());
+ collectActiveWorkSessions(aWS, anIter.Key(), theMap, Standard_False);
+ }
+ }
+}
static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
IFSelect_Functions::Init();
XSControl_Functions::Init();
XSControl_FuncShape::Init();
+ XSAlgo::Init();
// XSDRAW_Shape::Init(); passe a present par theCommands
return Standard_True;
}
Handle(IFSelect_SessionPilot) XSDRAW::Pilot ()
{ return thepilot; }
- Handle(XSControl_WorkSession) XSDRAW::Session ()
+ void XSDRAW::SetSession(const Handle(XSControl_WorkSession)& theSession)
+ { Pilot()->SetSession(theSession); }
+
+ const Handle(XSControl_WorkSession) XSDRAW::Session ()
{ return XSControl::Session(thepilot); }
void XSDRAW::SetController (const Handle(XSControl_Controller)& control)
(Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name)
{ return XSControl_FuncShape::MoreShapes (XSDRAW::Session(),list,name); }
+//=======================================================================
+//function : GetLengthUnit
+//purpose :
+//=======================================================================
+Standard_Real XSDRAW::GetLengthUnit(const Handle(TDocStd_Document)& theDoc)
+{
+ if (!theDoc.IsNull())
+ {
+ Standard_Real aUnit = 1.;
+ if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
+ UnitsMethods_LengthUnit_Millimeter))
+ {
+ return aUnit;
+ }
+ }
+ if (Interface_Static::IsPresent("xstep.cascade.unit"))
+ {
+ UnitsMethods::SetCasCadeLengthUnit(Interface_Static::IVal("xstep.cascade.unit"));
+ }
+ return UnitsMethods::GetCasCadeLengthUnit();
+}
+
+//=======================================================================
+//function : WorkSessionList
+//purpose :
+//=======================================================================
+XSControl_WorkSessionMap& XSDRAW::WorkSessionList()
+{
+ static std::shared_ptr<XSControl_WorkSessionMap> THE_PREVIOUS_WORK_SESSIONS;
+ if (THE_PREVIOUS_WORK_SESSIONS == nullptr)
+ {
+ THE_PREVIOUS_WORK_SESSIONS =
+ std::make_shared<XSControl_WorkSessionMap>();
+ }
+ return *THE_PREVIOUS_WORK_SESSIONS;
+}
+
+//=======================================================================
+//function : CollectActiveWorkSessions
+//purpose :
+//=======================================================================
+void XSDRAW::CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
+ const TCollection_AsciiString& theName,
+ XSControl_WorkSessionMap& theMap)
+{
+ collectActiveWorkSessions(theWS, theName, theMap, Standard_True);
+}
-// FONCTION POUR LE DEBUG
+//=======================================================================
+//function : CollectActiveWorkSessions
+//purpose :
+//=======================================================================
+void XSDRAW::CollectActiveWorkSessions(const TCollection_AsciiString& theName)
+{
+ collectActiveWorkSessions(Session(), theName, WorkSessionList(), Standard_True);
+}
-Standard_Integer XSDRAW_WHAT (const Handle(Standard_Transient)& ent)
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAW::Factory(Draw_Interpretor& theDI)
{
- if (ent.IsNull()) { std::cout<<"(Null Handle)"<<std::endl; return 0; }
- Handle(Interface_InterfaceModel) model = XSDRAW::Model();
- if (model.IsNull()) { std::cout<<"(No model) Type:"<<ent->DynamicType()->Name()<<std::endl; return 0; }
- std::cout<<" Num/Id :";
- model->Print (ent, std::cout, 0);
- std::cout<<" -- Recorded Type:"<<model->TypeName (ent)<<std::endl;
- return model->Number(ent);
+ XSDRAW::LoadDraw(theDI);
}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAW)
#include <Draw_Interpretor.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
+#include <XSControl_WorkSession.hxx>
#include <TopTools_HSequenceOfShape.hxx>
class IFSelect_SessionPilot;
class XSControl_WorkSession;
class Transfer_FinderProcess;
class XSControl_TransferReader;
class TCollection_AsciiString;
+class TDocStd_Document;
//! Basic package to work functions of X-STEP (IFSelect & Co)
//! Returns the SessionPilot (can be used for direct call)
Standard_EXPORT static Handle(IFSelect_SessionPilot) Pilot();
+
+ //! Updates the WorkSession defined in AddDraw (through Pilot)
+ //! It is from XSControl, it brings functionalities for Transfers
+ Standard_EXPORT static void SetSession(const Handle(XSControl_WorkSession)& theSession);
//! Returns the WorkSession defined in AddDraw (through Pilot)
//! It is from XSControl, it brings functionalities for Transfers
- Standard_EXPORT static Handle(XSControl_WorkSession) Session();
+ Standard_EXPORT static const Handle(XSControl_WorkSession) Session();
//! Defines a Controller for the command "xinit" and applies it
//! (i.e. calls its method Customise)
//! completed (Append without Clear) by the Shapes found
//! Returns 0 if no Shape could be found
Standard_EXPORT static Standard_Integer MoreShapes (Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name);
+
+ //! Extracts length unit from the static interface or document.
+ //! Document unit has the highest priority.
+ //! @return length unit in MM. 1.0 by default
+ Standard_EXPORT static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr);
+
+ //! Returns avaliable work sessions with their associated files.
+ Standard_EXPORT static XSControl_WorkSessionMap& WorkSessionList();
+
+ //! Binds session and name into map recursively.
+ //! Recursively means extract sub-sessions from main session.
+ //! @param[in] theWS the session object
+ //! @param[in] theName the session file name
+ //! @param[out] theMap collection to keep session info
+ Standard_EXPORT static void CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
+ const TCollection_AsciiString& theName,
+ XSControl_WorkSessionMap& theMap);
+
+ //! Binds current session with input name.
+ //! @param[in] theName the session file name
+ Standard_EXPORT static void CollectActiveWorkSessions(const TCollection_AsciiString& theName);
+
+ //! Loads all Draw commands of XSDRAW. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
};
#endif // _XSDRAW_HeaderFile
--- /dev/null
+XSDRAWDE.cxx
+XSDRAWDE.hxx
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWDE.hxx>
+
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <DE_ConfigurationContext.hxx>
+#include <DE_Provider.hxx>
+#include <DE_Wrapper.hxx>
+#include <DEBRepCascade_ConfigurationNode.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <Message.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+
+//=======================================================================
+//function : DumpConfiguration
+//purpose :
+//=======================================================================
+static Standard_Integer DumpConfiguration(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper();
+ TCollection_AsciiString aPath;
+ Standard_Boolean aIsRecursive = Standard_True;
+ Standard_Boolean isHandleFormat = Standard_False;
+ Standard_Boolean isHandleVendors = Standard_False;
+ TColStd_ListOfAsciiString aFormats;
+ TColStd_ListOfAsciiString aVendors;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg(theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if ((anArg == "-path") &&
+ (anArgIter + 1 < theNbArgs))
+ {
+ ++anArgIter;
+ aPath = theArgVec[anArgIter];
+ }
+ else if ((anArg == "-recursive") &&
+ (anArgIter + 1 < theNbArgs) &&
+ Draw::ParseOnOff(theArgVec[anArgIter + 1], aIsRecursive))
+ {
+ ++anArgIter;
+ }
+ else if (anArg == "-format")
+ {
+ isHandleFormat = Standard_True;
+ isHandleVendors = Standard_False;
+ }
+ else if (anArg == "-vendor")
+ {
+ isHandleFormat = Standard_False;
+ isHandleVendors = Standard_True;
+ }
+ else if (isHandleFormat)
+ {
+ aFormats.Append(theArgVec[anArgIter]);
+ }
+ else if (isHandleVendors)
+ {
+ aVendors.Append(theArgVec[anArgIter]);
+ }
+ else if (!isHandleFormat && !isHandleVendors)
+ {
+ theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
+ }
+ Standard_Boolean aStat = Standard_True;
+ if (!aPath.IsEmpty())
+ {
+ aStat = aConf->Save(aPath, aIsRecursive, aFormats, aVendors);
+ }
+ else
+ {
+ theDI << aConf->Save(aIsRecursive, aFormats, aVendors) << "\n";
+ }
+ if (!aStat)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : CompareConfiguration
+//purpose :
+//=======================================================================
+static Standard_Integer CompareConfiguration(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs > 5)
+ {
+ theDI.PrintHelp(theArgVec[0]);
+ return 1;
+ }
+ Handle(DE_ConfigurationContext) aResourceFirst = new DE_ConfigurationContext();
+ if (!aResourceFirst->Load(theArgVec[1]))
+ {
+ theDI << "Error: Can't load first configuration\n";
+ return 1;
+ }
+ Handle(DE_ConfigurationContext) aResourceSecond = new DE_ConfigurationContext();
+ if (!aResourceSecond->Load(theArgVec[2]))
+ {
+ theDI << "Error: Can't load second configuration\n";
+ return 1;
+ }
+ const DE_ResourceMap& aResourceMapFirst = aResourceFirst->GetInternalMap();
+ const DE_ResourceMap& aResourceMapSecond = aResourceSecond->GetInternalMap();
+ Standard_Integer anDiffers = 0;
+ for (DE_ResourceMap::Iterator anOrigIt(aResourceMapFirst);
+ anOrigIt.More(); anOrigIt.Next())
+ {
+ const TCollection_AsciiString& anOrigValue = anOrigIt.Value();
+ const TCollection_AsciiString& anOrigKey = anOrigIt.Key();
+ TCollection_AsciiString aCompValue;
+ if (!aResourceMapSecond.Find(anOrigKey, aCompValue))
+ {
+ Message::SendWarning() << "Second configuration don't have the next scope : " << anOrigKey;
+ anDiffers++;
+ }
+ if (!aCompValue.IsEqual(anOrigValue))
+ {
+ Message::SendWarning() << "Configurations have differs value with the next scope :" << anOrigKey
+ << " First value : " << anOrigValue << " Second value : " << aCompValue;
+ anDiffers++;
+ }
+ }
+ TCollection_AsciiString aMessage;
+ if (aResourceMapFirst.Extent() != aResourceMapSecond.Extent() || anDiffers > 0)
+ {
+ theDI << "Error: Configurations are not same : " << " Differs count : "
+ << anDiffers << " Count of first's scopes : " << aResourceMapFirst.Extent()
+ << " Count of second's scopes : " << aResourceMapSecond.Extent() << "\n";
+ return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : LoadConfiguration
+//purpose :
+//=======================================================================
+static Standard_Integer LoadConfiguration(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs > 4)
+ {
+ theDI.PrintHelp(theArgVec[0]);
+ return 1;
+ }
+ Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper();
+ TCollection_AsciiString aString = theArgVec[1];
+ Standard_Boolean aIsRecursive = Standard_True;
+ if (theNbArgs == 4)
+ {
+ TCollection_AsciiString anArg = theArgVec[2];
+ anArg.LowerCase();
+ if (!(anArg == "-recursive") ||
+ !Draw::ParseOnOff(theArgVec[3], aIsRecursive))
+ {
+ theDI << "Syntax error at argument '" << theArgVec[3] << "'\n";
+ return 1;
+ }
+ }
+ if (!aConf->Load(aString, aIsRecursive))
+ {
+ theDI << "Error: configuration is incorrect\n";
+ return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : ReadFile
+//purpose :
+//=======================================================================
+static Standard_Integer ReadFile(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs > 6)
+ {
+ theDI.PrintHelp(theArgVec[0]);
+ return 1;
+ }
+ TCollection_AsciiString aDocShapeName;
+ TCollection_AsciiString aFilePath;
+ Handle(TDocStd_Document) aDoc;
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ TCollection_AsciiString aConfString;
+ Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readfile");
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg(theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if ((anArg == "-conf") &&
+ (anArgIter + 1 < theNbArgs))
+ {
+ ++anArgIter;
+ aConfString = theArgVec[anArgIter];
+ }
+ else if (aDocShapeName.IsEmpty())
+ {
+ aDocShapeName = theArgVec[anArgIter];
+ Standard_CString aNameVar = aDocShapeName.ToCString();
+ if (!isNoDoc)
+ {
+ DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
+ }
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else
+ {
+ theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
+ }
+ if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty())
+ {
+ theDI << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+ if (aDoc.IsNull() && !isNoDoc)
+ {
+ anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
+ TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]);
+ Draw::Set(theArgVec[1], aDrawDoc);
+ }
+
+ Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
+ Standard_Boolean aStat = Standard_True;
+ if (!aConfString.IsEmpty())
+ {
+ aStat = aConf->Load(aConfString);
+ }
+ if (aStat)
+ {
+ TopoDS_Shape aShape;
+ aStat = isNoDoc ? aConf->Read(aFilePath, aShape) : aConf->Read(aFilePath, aDoc);
+ if (isNoDoc && aStat)
+ {
+ DBRep::Set(aDocShapeName.ToCString(), aShape);
+ }
+ }
+ if (!aStat)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : WriteFile
+//purpose :
+//=======================================================================
+static Standard_Integer WriteFile(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs > 6)
+ {
+ theDI.PrintHelp(theArgVec[0]);
+ return 1;
+ }
+ TCollection_AsciiString aDocShapeName;
+ TCollection_AsciiString aFilePath;
+ Handle(TDocStd_Document) aDoc;
+ TCollection_AsciiString aConfString;
+ Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "writefile");
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg(theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if ((anArg == "-conf") &&
+ (anArgIter + 1 < theNbArgs))
+ {
+ ++anArgIter;
+ aConfString = theArgVec[anArgIter];
+ }
+ else if (aDocShapeName.IsEmpty())
+ {
+ aDocShapeName = theArgVec[anArgIter];
+ Standard_CString aNameVar = aDocShapeName.ToCString();
+ if (!isNoDoc)
+ {
+ DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
+ }
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else
+ {
+ theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n";
+ return 1;
+ }
+ }
+ if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty())
+ {
+ theDI << "Syntax error: wrong number of arguments\n";
+ return 1;
+ }
+ if (aDoc.IsNull() && !isNoDoc)
+ {
+ theDI << "Error: incorrect document\n";
+ return 1;
+ }
+ Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy();
+ Standard_Boolean aStat = Standard_True;
+ if (!aConfString.IsEmpty())
+ {
+ aStat = aConf->Load(aConfString);
+ }
+ if (aStat)
+ {
+ if (isNoDoc)
+ {
+ TopoDS_Shape aShape = DBRep::Get(aDocShapeName);
+ if (aShape.IsNull())
+ {
+ theDI << "Error: incorrect shape " << aDocShapeName << "\n";
+ return 1;
+ }
+ aStat = aConf->Write(aFilePath, aShape);
+ }
+ else
+ {
+ aStat = aConf->Write(aFilePath, aDoc);
+ }
+ }
+ if (!aStat)
+ {
+ return 1;
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAWDE::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ Standard_CString aGroup = "XDE translation commands";
+ theDI.Add("DumpConfiguration",
+ "DumpConfiguration [-path <path>] [-recursive {on|off}] [-format fmt1 fmt2 ...] [-vendor vend1 vend2 ...]\n"
+ "\n\t\t: Dump special resource generated from global configuration."
+ "\n\t\t: '-path' - save resource configuration to the file"
+ "\n\t\t: '-recursive' - flag to generate a resource from providers. Default is On. Off disables other options"
+ "\n\t\t: '-format' - flag to generate a resource for choosen formats. If list is empty, generate it for all"
+ "\n\t\t: '-vendor' - flag to generate a resource for choosen vendors. If list is empty, generate it for all",
+ __FILE__, DumpConfiguration, aGroup);
+ theDI.Add("LoadConfiguration",
+ "LoadConfiguration conf [-recursive {on|off}]\n"
+ "\n\t\t: 'conf' - path to the resouce file or string value in the special format"
+ "\n\t\t: '-recursive' - flag to generate a resource for all providers. Default is true"
+ "\n\t\t: Configure global configuration according special resource",
+ __FILE__, LoadConfiguration, aGroup);
+ theDI.Add("CompareConfiguration",
+ "CompareConfiguration conf1 conf2\n"
+ "\n\t\t: 'conf1' - path to the first resouce file or string value in the special format"
+ "\n\t\t: 'conf2' - path to the second resouce file or string value in the special format"
+ "\n\t\t: Compare two configurations",
+ __FILE__, CompareConfiguration, aGroup);
+ theDI.Add("ReadFile",
+ "ReadFile docName filePath [-conf <value|path>]\n"
+ "\n\t\t: Read CAD file to document with registered format's providers. Use global configuration by default.",
+ __FILE__, ReadFile, aGroup);
+ theDI.Add("readfile",
+ "readfile shapeName filePath [-conf <value|path>]\n"
+ "\n\t\t: Read CAD file to shape with registered format's providers. Use global configuration by default.",
+ __FILE__, ReadFile, aGroup);
+ theDI.Add("WriteFile",
+ "WriteFile docName filePath [-conf <value|path>]\n"
+ "\n\t\t: Write CAD file to document with registered format's providers. Use global configuration by default.",
+ __FILE__, WriteFile, aGroup);
+ theDI.Add("writefile",
+ "writefile shapeName filePath [-conf <value|path>]\n"
+ "\n\t\t: Write CAD file to shape with registered format's providers. Use global configuration by default.",
+ __FILE__, WriteFile, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+
+ // Workaround to force load TKDECascade lib
+ DEBRepCascade_ConfigurationNode aTmpObj;
+ (void)aTmpObj;
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWDE)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWDE_HeaderFile
+#define _XSDRAWDE_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWDE
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWDE. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWDE_HeaderFile
--- /dev/null
+XSDRAWGLTF.cxx
+XSDRAWGLTF.hxx
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWGLTF.hxx>
+
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <RWGltf_CafReader.hxx>
+#include <RWGltf_CafWriter.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+
+//=============================================================================
+//function : parseNameFormat
+//purpose : Parse RWMesh_NameFormat enumeration
+//=============================================================================
+static bool parseNameFormat(const char* theArg,
+ RWMesh_NameFormat& theFormat)
+{
+ TCollection_AsciiString aName(theArg);
+ aName.LowerCase();
+ if (aName == "empty")
+ {
+ theFormat = RWMesh_NameFormat_Empty;
+ }
+ else if (aName == "product"
+ || aName == "prod")
+ {
+ theFormat = RWMesh_NameFormat_Product;
+ }
+ else if (aName == "instance"
+ || aName == "inst")
+ {
+ theFormat = RWMesh_NameFormat_Instance;
+ }
+ else if (aName == "instanceorproduct"
+ || aName == "instance||product"
+ || aName == "instance|product"
+ || aName == "instorprod"
+ || aName == "inst||prod"
+ || aName == "inst|prod")
+ {
+ theFormat = RWMesh_NameFormat_InstanceOrProduct;
+ }
+ else if (aName == "productorinstance"
+ || aName == "product||instance"
+ || aName == "product|instance"
+ || aName == "prodorinst"
+ || aName == "prod||inst"
+ || aName == "prod|inst")
+ {
+ theFormat = RWMesh_NameFormat_ProductOrInstance;
+ }
+ else if (aName == "productandinstance"
+ || aName == "prodandinst"
+ || aName == "product&instance"
+ || aName == "prod&inst")
+ {
+ theFormat = RWMesh_NameFormat_ProductAndInstance;
+ }
+ else if (aName == "productandinstanceandocaf"
+ || aName == "verbose"
+ || aName == "debug")
+ {
+ theFormat = RWMesh_NameFormat_ProductAndInstanceAndOcaf;
+ }
+ else
+ {
+ return false;
+ }
+ return true;
+}
+
+//=============================================================================
+//function : parseCoordinateSystem
+//purpose : Parse RWMesh_CoordinateSystem enumeration
+//=============================================================================
+static bool parseCoordinateSystem(const char* theArg,
+ RWMesh_CoordinateSystem& theSystem)
+{
+ TCollection_AsciiString aCSStr(theArg);
+ aCSStr.LowerCase();
+ if (aCSStr == "zup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Zup;
+ }
+ else if (aCSStr == "yup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Yup;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=============================================================================
+//function : ReadGltf
+//purpose : Reads glTF file
+//=============================================================================
+static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ TCollection_AsciiString aDestName, aFilePath;
+ Standard_Boolean toUseExistingDoc = Standard_False;
+ Standard_Boolean toListExternalFiles = Standard_False;
+ Standard_Boolean isParallel = Standard_False;
+ Standard_Boolean isDoublePrec = Standard_False;
+ Standard_Boolean toSkipLateDataLoading = Standard_False;
+ Standard_Boolean toKeepLateData = Standard_True;
+ Standard_Boolean toPrintDebugInfo = Standard_False;
+ Standard_Boolean toLoadAllScenes = Standard_False;
+ Standard_Boolean toPrintAssetInfo = Standard_False;
+ Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (!isNoDoc
+ && (anArgCase == "-nocreate"
+ || anArgCase == "-nocreatedoc"))
+ {
+ toUseExistingDoc = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-parallel")
+ {
+ isParallel = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-doubleprec"
+ || anArgCase == "-doubleprecision"
+ || anArgCase == "-singleprec"
+ || anArgCase == "-singleprecision")
+ {
+ isDoublePrec = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ if (anArgCase.StartsWith("-single"))
+ {
+ isDoublePrec = !isDoublePrec;
+ }
+ }
+ else if (anArgCase == "-skiplateloading")
+ {
+ toSkipLateDataLoading = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-keeplate")
+ {
+ toKeepLateData = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-allscenes")
+ {
+ toLoadAllScenes = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-toprintinfo"
+ || anArgCase == "-toprintdebuginfo")
+ {
+ toPrintDebugInfo = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-listexternalfiles"
+ || anArgCase == "-listexternals"
+ || anArgCase == "-listexternal"
+ || anArgCase == "-external"
+ || anArgCase == "-externalfiles")
+ {
+ toListExternalFiles = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-assetinfo"
+ || anArgCase == "-metadata")
+ {
+ toPrintAssetInfo = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (aDestName.IsEmpty())
+ {
+ aDestName = theArgVec[anArgIter];
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
+ {
+ if (toListExternalFiles || toPrintAssetInfo)
+ {
+ std::swap(aFilePath, aDestName);
+ }
+ }
+ if (aFilePath.IsEmpty())
+ {
+ Message::SendFail() << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+ Handle(TDocStd_Document) aDoc;
+ if (!aDestName.IsEmpty()
+ && !isNoDoc)
+ {
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ Standard_CString aNameVar = aDestName.ToCString();
+ DDocStd::GetDocument(aNameVar, aDoc, Standard_False);
+ if (aDoc.IsNull())
+ {
+ if (toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
+ return 1;
+ }
+ anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
+ }
+ else if (!toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDestName << " already exists";
+ return 1;
+ }
+ }
+
+ const Standard_Real aScaleFactorM = XSDRAW::GetLengthUnit(aDoc) / 1000;
+
+ RWGltf_CafReader aReader;
+ aReader.SetSystemLengthUnit(aScaleFactorM);
+ aReader.SetSystemCoordinateSystem(RWMesh_CoordinateSystem_Zup);
+ aReader.SetDocument(aDoc);
+ aReader.SetParallel(isParallel);
+ aReader.SetDoublePrecision(isDoublePrec);
+ aReader.SetToSkipLateDataLoading(toSkipLateDataLoading);
+ aReader.SetToKeepLateData(toKeepLateData);
+ aReader.SetToPrintDebugMessages(toPrintDebugInfo);
+ aReader.SetLoadAllScenes(toLoadAllScenes);
+ if (aDestName.IsEmpty())
+ {
+ aReader.ProbeHeader(aFilePath);
+ }
+ else
+ {
+ aReader.Perform(aFilePath, aProgress->Start());
+ if (isNoDoc)
+ {
+ DBRep::Set(aDestName.ToCString(), aReader.SingleShape());
+ }
+ else
+ {
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
+ TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName);
+ Draw::Set(aDestName.ToCString(), aDrawDoc);
+ }
+ }
+
+ bool isFirstLine = true;
+ if (toPrintAssetInfo)
+ {
+ for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter(aReader.Metadata()); aKeyIter.More(); aKeyIter.Next())
+ {
+ if (!isFirstLine)
+ {
+ theDI << "\n";
+ }
+ isFirstLine = false;
+ theDI << aKeyIter.Key() << ": " << aKeyIter.Value();
+ }
+ }
+ if (toListExternalFiles)
+ {
+ if (!isFirstLine)
+ {
+ theDI << "\n";
+ }
+ for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter(aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
+ {
+ theDI << "\"" << aFileIter.Value() << "\" ";
+ }
+ }
+ return 0;
+}
+
+//=============================================================================
+//function : WriteGltf
+//purpose : Writes glTF file
+//=============================================================================
+static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ TCollection_AsciiString aGltfFilePath;
+ Handle(TDocStd_Document) aDoc;
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
+ RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
+ bool toForceUVExport = false, toEmbedTexturesInGlb = true;
+ bool toMergeFaces = false, toSplitIndices16 = false;
+ bool isParallel = false;
+ RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct;
+ RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product;
+ RWGltf_DracoParameters aDracoParameters;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anArgCase == "-comments"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add("Comments", theArgVec[++anArgIter]);
+ }
+ else if (anArgCase == "-author"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add("Author", theArgVec[++anArgIter]);
+ }
+ else if (anArgCase == "-forceuvexport"
+ || anArgCase == "-forceuv")
+ {
+ toForceUVExport = true;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff(theArgVec[anArgIter + 1], toForceUVExport))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArgCase == "-mergefaces")
+ {
+ toMergeFaces = true;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff(theArgVec[anArgIter + 1], toMergeFaces))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArgCase == "-splitindices16"
+ || anArgCase == "-splitindexes16"
+ || anArgCase == "-splitindices"
+ || anArgCase == "-splitindexes"
+ || anArgCase == "-splitind")
+ {
+ toSplitIndices16 = true;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff(theArgVec[anArgIter + 1], toSplitIndices16))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-systemcoordinatesystem"
+ || anArgCase == "-systemcoordsystem"
+ || anArgCase == "-systemcoordsys"
+ || anArgCase == "-syscoordsys"))
+ {
+ if (!parseCoordinateSystem(theArgVec[++anArgIter], aSystemCoordSys))
+ {
+ Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ else if (anArgCase == "-trsfformat"
+ && anArgIter + 1 < theNbArgs)
+ {
+ TCollection_AsciiString aTrsfStr(theArgVec[++anArgIter]);
+ aTrsfStr.LowerCase();
+ if (aTrsfStr == "compact")
+ {
+ aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
+ }
+ else if (aTrsfStr == "mat4")
+ {
+ aTrsfFormat = RWGltf_WriterTrsfFormat_Mat4;
+ }
+ else if (aTrsfStr == "trs")
+ {
+ aTrsfFormat = RWGltf_WriterTrsfFormat_TRS;
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+ return 1;
+ }
+ }
+ else if (anArgCase == "-nodenameformat"
+ || anArgCase == "-nodename")
+ {
+ ++anArgIter;
+ if (anArgIter >= theNbArgs
+ || !parseNameFormat(theArgVec[anArgIter], aNodeNameFormat))
+ {
+ Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+ return 1;
+ }
+ }
+ else if (anArgCase == "-meshnameformat"
+ || anArgCase == "-meshname")
+ {
+ ++anArgIter;
+ if (anArgIter >= theNbArgs
+ || !parseNameFormat(theArgVec[anArgIter], aMeshNameFormat))
+ {
+ Message::SendFail() << "Syntax error at '" << anArgCase << "'";
+ return 1;
+ }
+ }
+ else if (aDoc.IsNull())
+ {
+ Standard_CString aNameVar = theArgVec[anArgIter];
+ DDocStd::GetDocument(aNameVar, aDoc, false);
+ if (aDoc.IsNull())
+ {
+ TopoDS_Shape aShape = DBRep::Get(aNameVar);
+ if (aShape.IsNull())
+ {
+ Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
+ return 1;
+ }
+
+ anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
+ // auto-naming doesn't generate meaningful instance names
+ //aShapeTool->SetAutoNaming (false);
+ aNodeNameFormat = RWMesh_NameFormat_Product;
+ aShapeTool->AddShape(aShape);
+ }
+ }
+ else if (aGltfFilePath.IsEmpty())
+ {
+ aGltfFilePath = theArgVec[anArgIter];
+ }
+ else if (anArgCase == "-texturesSeparate")
+ {
+ toEmbedTexturesInGlb = false;
+ }
+ else if (anArgCase == "-draco")
+ {
+ aDracoParameters.DracoCompression = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-compressionlevel" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.CompressionLevel))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-quantizepositionbits" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizePositionBits))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-quantizenormalbits" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeNormalBits))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-quantizetexcoordbits" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeTexcoordBits))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-quantizecolorbits" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeColorBits))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-quantizegenericbits" && (anArgIter + 1) < theNbArgs
+ && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeGenericBits))
+ {
+ ++anArgIter;
+ }
+ else if (anArgCase == "-unifiedquantization")
+ {
+ aDracoParameters.UnifiedQuantization = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArgCase == "-parallel")
+ {
+ isParallel = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (aGltfFilePath.IsEmpty())
+ {
+ Message::SendFail() << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+
+ TCollection_AsciiString anExt = aGltfFilePath;
+ anExt.LowerCase();
+
+ const Standard_Real aScaleFactorM = XSDRAW::GetLengthUnit(aDoc) / 1000;
+
+ RWGltf_CafWriter aWriter(aGltfFilePath, anExt.EndsWith(".glb"));
+ aWriter.SetTransformationFormat(aTrsfFormat);
+ aWriter.SetNodeNameFormat(aNodeNameFormat);
+ aWriter.SetMeshNameFormat(aMeshNameFormat);
+ aWriter.SetForcedUVExport(toForceUVExport);
+ aWriter.SetToEmbedTexturesInGlb(toEmbedTexturesInGlb);
+ aWriter.SetMergeFaces(toMergeFaces);
+ aWriter.SetSplitIndices16(toSplitIndices16);
+ aWriter.SetParallel(isParallel);
+ aWriter.SetCompressionParameters(aDracoParameters);
+ aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit(aScaleFactorM);
+ aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem(aSystemCoordSys);
+ aWriter.Perform(aDoc, aFileInfo, aProgress->Start());
+ return 0;
+}
+
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAWGLTF::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands
+ theDI.Add("ReadGltf",
+ "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
+ "\n\t\t: Read glTF file into XDE document."
+ "\n\t\t: -listExternalFiles do not read mesh and only list external files"
+ "\n\t\t: -noCreateDoc read into existing XDE document"
+ "\n\t\t: -doublePrecision store triangulation with double or single floating point"
+ "\n\t\t: precision (single by default)"
+ "\n\t\t: -skipLateLoading data loading is skipped and can be performed later"
+ "\n\t\t: (false by default)"
+ "\n\t\t: -keepLate data is loaded into itself with preservation of information"
+ "\n\t\t: about deferred storage to load/unload this data later."
+ "\n\t\t: -allScenes load all scenes defined in the document instead of default one (false by default)"
+ "\n\t\t: -toPrintDebugInfo print additional debug information during data reading"
+ "\n\t\t: -assetInfo print asset information",
+ __FILE__, ReadGltf, aGroup);
+ theDI.Add("readgltf",
+ "readgltf shape file"
+ "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.",
+ __FILE__, ReadGltf, aGroup);
+ theDI.Add("WriteGltf",
+ "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact"
+ "\n\t\t: [-systemCoordSys {Zup|Yup}]=Zup"
+ "\n\t\t: [-comments Text] [-author Name]"
+ "\n\t\t: [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0"
+ "\n\t\t: [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd"
+ "\n\t\t: [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product"
+ "\n\t\t: [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10"
+ "\n\t\t: [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12"
+ "\n\t\t: [-unifiedQuantization]=0 [-parallel]=0"
+ "\n\t\t: Write XDE document into glTF file."
+ "\n\t\t: -trsfFormat preferred transformation format"
+ "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified"
+ "\n\t\t: -mergeFaces merge Faces within the same Mesh"
+ "\n\t\t: -splitIndices16 split Faces to keep 16-bit indices when -mergeFaces is enabled"
+ "\n\t\t: -forceUVExport always export UV coordinates"
+ "\n\t\t: -texturesSeparate write textures to separate files"
+ "\n\t\t: -nodeNameFormat name format for Nodes"
+ "\n\t\t: -meshNameFormat name format for Meshes"
+ "\n\t\t: -draco use Draco compression 3D geometric meshes"
+ "\n\t\t: -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order"
+ "\n\t\t: -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)"
+ "\n\t\t: -quantizeNormalBits quantization bits for normal attribute when using Draco compression (by default 10)"
+ "\n\t\t: -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)"
+ "\n\t\t: -quantizeColorBits quantization bits for color attribute when using Draco compression (by default 8)"
+ "\n\t\t: -quantizeGenericBits quantization bits for skinning attribute (joint indices and joint weights)"
+ "\n and custom attributes when using Draco compression (by default 12)"
+ "\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false"
+ "\n\t\t: -parallel use multithreading for Draco compression",
+ __FILE__, WriteGltf, aGroup);
+ theDI.Add("writegltf",
+ "writegltf shape file",
+ __FILE__, WriteGltf, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWGLTF)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWGLTF_HeaderFile
+#define _XSDRAWGLTF_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWGLTF
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWGLTF. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWGLTF_HeaderFile
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//gka 06.01.99 S3767 new function TPSTAT (first version)
-//pdn 11.01.99 putting "return" statement for compilation on NT
+#include <XSDRAWIGES.hxx>
#include <BRepTools.hxx>
#include <DBRep.hxx>
-#include <Draw_Appli.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.hxx>
#include <DrawTrSurf.hxx>
-#include <IFSelect_Functions.hxx>
-#include <IFSelect_SessionPilot.hxx>
+#include <IGESCAFControl_Reader.hxx>
+#include <IGESCAFControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <IGESControl_Writer.hxx>
#include <IGESSelect_Activator.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
-#include <Message_ProgressScope.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TColStd_HSequenceOfTransient.hxx>
-#include <TColStd_MapOfTransient.hxx>
+#include <Message.hxx>
+#include <OSD_OpenFile.hxx>
+#include <OSD_Path.hxx>
+#include <TColStd_Array1OfAsciiString.hxx>
+#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
#include <TopoDS_Shape.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
-#include <XSControl.hxx>
-#include <XSControl_WorkSession.hxx>
+#include <XSAlgo.hxx>
+#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_TransferReader.hxx>
+#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
-#include <XSDRAWIGES.hxx>
-#include <stdio.h>
-
-namespace {
-
- //=======================================================================
+//=======================================================================
//function : WriteShape
//purpose : Creates a file Shape_'number'
//=======================================================================
-void WriteShape(const TopoDS_Shape& shape, const Standard_Integer number)
+void WriteShape(const TopoDS_Shape& shape,
+ const Standard_Integer number)
{
char fname[110];
- sprintf(fname, "Shape_%d",number);
- std::ofstream f(fname,std::ios::out | std::ios::binary);
+ sprintf(fname, "Shape_%d", number);
+ std::ofstream f(fname, std::ios::out | std::ios::binary);
std::cout << "Output file name : " << fname << std::endl;
f << "DBRep_DrawableShape\n";
-
+
BRepTools::Write(shape, f);
f.close();
}
-TCollection_AsciiString XSDRAW_CommandPart
- (Standard_Integer argc, const char** argv, const Standard_Integer argf)
+//=======================================================================
+//function : XSDRAW_CommandPart
+//purpose :
+//=======================================================================
+TCollection_AsciiString XSDRAW_CommandPart(Standard_Integer argc,
+ const char** argv,
+ const Standard_Integer argf)
{
TCollection_AsciiString res;
- for (Standard_Integer i = argf; i < argc; i ++) {
+ for (Standard_Integer i = argf; i < argc; i++)
+ {
if (i > argf) res.AssignCat(" ");
- res.AssignCat (argv[i]);
+ res.AssignCat(argv[i]);
}
return res;
}
+
+//=======================================================================
+//function : GiveEntityNumber
+//purpose :
+//=======================================================================
+static Standard_Integer GiveEntityNumber(const Handle(XSControl_WorkSession)& WS,
+ const Standard_CString name)
+{
+ Standard_Integer num = 0;
+ if (!name || name[0] == '\0')
+ {
+ char ligne[80]; ligne[0] = '\0';
+ std::cin >> ligne;
+ // std::cin.clear(); std::cin.getline (ligne,79);
+ if (ligne[0] == '\0') return 0;
+ num = WS->NumberFromLabel(ligne);
+ }
+ else num = WS->NumberFromLabel(name);
+ return num;
}
-//--------------------------------------------------------------
-// Function : igesbrep
-//--------------------------------------------------------------
-static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=======================================================================
+//function : FileAndVar
+//purpose :
+//=======================================================================
+Standard_Boolean FileAndVar(const Handle(XSControl_WorkSession)& session,
+ const Standard_CString file,
+ const Standard_CString var,
+ const Standard_CString def,
+ TCollection_AsciiString& resfile,
+ TCollection_AsciiString& resvar)
{
- DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller());
- if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
+ Standard_Boolean iafic = Standard_True;
+ resfile.Clear(); resvar.Clear();
+ if (file)
+ if (file[0] == '\0' ||
+ (file[0] == '.' && file[1] == '\0')) iafic = Standard_False;
+ if (!iafic) resfile.AssignCat(session->LoadedFile());
+ else resfile.AssignCat(file);
+
+ if (var && var[0] != '\0' && (var[0] != '.' || var[1] != '\0'))
+ resvar.AssignCat(var);
+ else if (resfile.Length() == 0) resvar.AssignCat(def);
+ else
+ {
+ Standard_Integer nomdeb, nomfin;
+ nomdeb = resfile.SearchFromEnd("/");
+ if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT
+ if (nomdeb < 0) nomdeb = 0;
+ nomfin = resfile.SearchFromEnd(".");
+ if (nomfin < nomdeb) nomfin = resfile.Length() + 1;
+ resvar = resfile.SubString(nomdeb + 1, nomfin - 1);
+ }
+ return iafic;
+}
+
+//=======================================================================
+//function : igesbrep
+//purpose :
+//=======================================================================
+static Standard_Integer igesbrep(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ Handle(IGESControl_Controller) aCtl =
+ Handle(IGESControl_Controller)::DownCast(aWS->NormAdaptor());
+ if (aCtl.IsNull())
+ {
+ aWS->SelectNorm("IGES");
+ }
// Progress indicator
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100);
-
- IGESControl_Reader Reader (XSDRAW::Session(),Standard_False);
+ Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
+ Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100);
+
+ IGESControl_Reader Reader(XSDRAW::Session(), Standard_False);
Standard_Boolean aFullMode = Standard_True;
Reader.WS()->SetModeStat(aFullMode);
- if (ctl.IsNull())
- ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
- TCollection_AsciiString fnom,rnom;
+ TCollection_AsciiString fnom, rnom;
- Standard_Boolean modfic = XSDRAW::FileAndVar
- (argv[1],argv[2],"IGESBREP",fnom,rnom);
- if (modfic) di<<" File IGES to read : "<<fnom.ToCString()<<"\n";
- else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
- di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
+ Standard_Boolean modfic = FileAndVar
+ (aWS, theArgVec[1], theArgVec[2], "IGESBREP", fnom, rnom);
+ if (modfic) theDI << " File IGES to read : " << fnom.ToCString() << "\n";
+ else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
+ theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
#ifdef CHRONOMESURE
IDT_SetLevel(3);
#endif
-
-// Reading the file
+ // Reading the file
aPSRoot.SetName("Loading");
progress->Show(aPSRoot);
- if (modfic) readstat = Reader.ReadFile (fnom.ToCString());
+ if (modfic) readstat = Reader.ReadFile(fnom.ToCString());
else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
aPSRoot.Next(20); // On average loading takes 20%
if (aPSRoot.UserBreak())
return 1;
- if (readstat != IFSelect_RetDone) {
- if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
- else di<<"No model loaded\n";
+ if (readstat != IFSelect_RetDone)
+ {
+ if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
+ else theDI << "No model loaded\n";
return 1;
}
-// Choice of treatment
- Standard_Boolean fromtcl = (argc > 3);
+ // Choice of treatment
+ Standard_Boolean fromtcl = (theNbArgs > 3);
Standard_Integer modepri = 1, nent, nbs;
if (fromtcl) modepri = 4;
- while (modepri) {
+ while (modepri)
+ {
//Roots for transfer are defined before setting mode ALL or OnlyVisible - gka
//mode OnlyVisible does not work.
// nent = Reader.NbRootsForTransfer();
- if (!fromtcl) {
- std::cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<<std::flush;
+ if (!fromtcl)
+ {
+ std::cout << "Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :" << std::flush;
modepri = -1;
-
-// amv 26.09.2003 : this is used to avoid error of enter's simbol
- char str[80];
- std::cin>>str;
- modepri = Draw::Atoi(str);
+
+ // amv 26.09.2003 : this is used to avoid error of enter's simbol
+ char str[80];
+ std::cin >> str;
+ modepri = Draw::Atoi(str);
}
- if (modepri == 0) { //fin
- di << "Bye and good luck! \n";
+ if (modepri == 0)
+ { //fin
+ theDI << "Bye and good luck! \n";
break;
- }
+ }
- else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots
- di << "All Geometry Transfer\n";
- di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
- di<<" To modify : command param read.iges.bspline.continuity\n";
- Handle(XSControl_WorkSession) thesession = Reader.WS();
- thesession->ClearContext();
- XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
+ else if (modepri <= 2)
+ { // 1 : Visible Roots, 2 : All Roots
+ theDI << "All Geometry Transfer\n";
+ theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
+ theDI << " To modify : command param read.iges.bspline.continuity\n";
+ const Handle(XSControl_WorkSession)& thesession = Reader.WS();
+ thesession->TransferReader()->Context().Clear();
aPSRoot.SetName("Translation");
progress->Show(aPSRoot);
-
- if (modepri == 1) Reader.SetReadVisible (Standard_True);
+
+ if (modepri == 1) Reader.SetReadVisible(Standard_True);
Reader.TransferRoots(aPSRoot.Next(80));
-
+
if (aPSRoot.UserBreak())
return 1;
// result in only one shape for all the roots
// or in one shape for one root.
- di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
+ theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
Standard_Integer answer = 1;
- if (Reader.NbShapes() > 1) {
- std::cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << std::flush;
+ if (Reader.NbShapes() > 1)
+ {
+ std::cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << std::flush;
answer = -1;
//amv 26.09.2003
- char str_a[80];
- std::cin >> str_a;
- answer = Draw::Atoi(str_a);
+ char str_a[80];
+ std::cin >> str_a;
+ answer = Draw::Atoi(str_a);
}
- if ( answer == 0) continue;
- if ( answer == 1 || answer == 3) {
- TopoDS_Shape shape = Reader.OneShape();
- // save the shape
- if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
- char fname[110];
- Sprintf(fname, "%s", rnom.ToCString());
- di << "Saving shape in variable Draw : " << fname << "\n";
- if (answer == 3) WriteShape (shape,1);
- try {
- OCC_CATCH_SIGNALS
- DBRep::Set(fname,shape);
- }
- catch(Standard_Failure const& anException) {
- di << "** Exception : ";
- di << anException.GetMessageString();
- di<<" ** Skip\n";
- di << "Saving shape in variable Draw : " << fname << "\n";
- WriteShape (shape,1);
- }
+ if (answer == 0) continue;
+ if (answer == 1 || answer == 3)
+ {
+ TopoDS_Shape shape = Reader.OneShape();
+ // save the shape
+ if (shape.IsNull()) { theDI << "No Shape produced\n"; continue; }
+ char fname[110];
+ Sprintf(fname, "%s", rnom.ToCString());
+ theDI << "Saving shape in variable Draw : " << fname << "\n";
+ if (answer == 3) WriteShape(shape, 1);
+ try
+ {
+ OCC_CATCH_SIGNALS
+ DBRep::Set(fname, shape);
+ }
+ catch (Standard_Failure const& anException)
+ {
+ theDI << "** Exception : ";
+ theDI << anException.GetMessageString();
+ theDI << " ** Skip\n";
+ theDI << "Saving shape in variable Draw : " << fname << "\n";
+ WriteShape(shape, 1);
+ }
}
-
- else if (answer == 2 || answer == 4) {
- Standard_Integer numshape = Reader.NbShapes();
- for (Standard_Integer inum = 1; inum <= numshape; inum++) {
- // save all the shapes
- TopoDS_Shape shape = Reader.Shape(inum);
- if (shape.IsNull()) { di<<"No Shape produced\n"; continue; }
- char fname[110];
- Sprintf(fname, "%s_%d", rnom.ToCString(),inum);
- di << "Saving shape in variable Draw : " << fname << "\n";
- if (answer == 4) WriteShape (shape,inum);
- try {
- OCC_CATCH_SIGNALS
- DBRep::Set(fname,shape);
- }
- catch(Standard_Failure const& anException) {
- di << "** Exception : ";
- di << anException.GetMessageString();
- di<<" ** Skip\n";
- }
- }
+
+ else if (answer == 2 || answer == 4)
+ {
+ Standard_Integer numshape = Reader.NbShapes();
+ for (Standard_Integer inum = 1; inum <= numshape; inum++)
+ {
+ // save all the shapes
+ TopoDS_Shape shape = Reader.Shape(inum);
+ if (shape.IsNull()) { theDI << "No Shape produced\n"; continue; }
+ char fname[110];
+ Sprintf(fname, "%s_%d", rnom.ToCString(), inum);
+ theDI << "Saving shape in variable Draw : " << fname << "\n";
+ if (answer == 4) WriteShape(shape, inum);
+ try
+ {
+ OCC_CATCH_SIGNALS
+ DBRep::Set(fname, shape);
+ }
+ catch (Standard_Failure const& anException)
+ {
+ theDI << "** Exception : ";
+ theDI << anException.GetMessageString();
+ theDI << " ** Skip\n";
+ }
+ }
}
else return 0;
}
- else if (modepri == 3) { // One Entity
- std::cout << "Only One Entity"<<std::endl;
- std::cout<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)"<<std::endl;
- std::cout<<" To modify : command param read.iges.bspline.continuity"<<std::endl;
+ else if (modepri == 3)
+ { // One Entity
+ std::cout << "Only One Entity" << std::endl;
+ std::cout << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)" << std::endl;
+ std::cout << " To modify : command param read.iges.bspline.continuity" << std::endl;
std::cout << " give the number of the Entity : " << std::flush;
- nent = XSDRAW::GetEntityNumber();
-
- if (!Reader.TransferOne (nent))
- di<<"Transfer entity n0 "<<nent<<" : no result\n";
- else {
- nbs = Reader.NbShapes();
- char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nent);
- di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
- di<<"Now, "<<nbs<<" Shapes produced\n";
- TopoDS_Shape sh = Reader.Shape(nbs);
- DBRep::Set (shname,sh);
+ nent = GiveEntityNumber(aWS, "");
+
+ if (!Reader.TransferOne(nent))
+ theDI << "Transfer entity n0 " << nent << " : no result\n";
+ else
+ {
+ nbs = Reader.NbShapes();
+ char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nent);
+ theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
+ theDI << "Now, " << nbs << " Shapes produced\n";
+ TopoDS_Shape sh = Reader.Shape(nbs);
+ DBRep::Set(shname, sh);
}
}
- else if (modepri == 4) { // Selection
+ else if (modepri == 4)
+ { // Selection
Standard_Integer answer = 1;
Handle(TColStd_HSequenceOfTransient) list;
-// Selection, nommee ou via tcl. tcl : raccourcis admis
-// * donne iges-visible + xst-transferrable-roots
-// *r donne xst-model-roots (TOUTES racines)
+ // Selection, nommee ou via tcl. tcl : raccourcis admis
+ // * donne iges-visible + xst-transferrable-roots
+ // *r donne xst-model-roots (TOUTES racines)
- if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) {
- di << "All Geometry Transfer\n";
- di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
- di<<" To modify : command param read.iges.bspline.continuity\n";
- Handle(XSControl_WorkSession) thesession = Reader.WS();
- thesession->ClearContext();
- XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
+ if (fromtcl && theArgVec[3][0] == '*' && theArgVec[3][1] == '\0')
+ {
+ theDI << "All Geometry Transfer\n";
+ theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
+ theDI << " To modify : command param read.iges.bspline.continuity\n";
+ const Handle(XSControl_WorkSession)& thesession = Reader.WS();
+ thesession->TransferReader()->Context().Clear();
aPSRoot.SetName("Translation");
progress->Show(aPSRoot);
-
- Reader.SetReadVisible (Standard_True);
+
+ Reader.SetReadVisible(Standard_True);
Reader.TransferRoots(aPSRoot.Next(80));
-
+
if (aPSRoot.UserBreak())
return 1;
// save the shape
char fname[110];
Sprintf(fname, "%s", rnom.ToCString());
- di << "Saving shape in variable Draw : " << fname << "\n";
- try {
+ theDI << "Saving shape in variable Draw : " << fname << "\n";
+ try
+ {
OCC_CATCH_SIGNALS
- DBRep::Set(fname,shape);
+ DBRep::Set(fname, shape);
+ }
+ catch (Standard_Failure const& anException)
+ {
+ theDI << "** Exception : ";
+ theDI << anException.GetMessageString();
+ theDI << " ** Skip\n";
+ theDI << "Saving shape in variable Draw : " << fname << "\n";
+ WriteShape(shape, 1);
}
- catch(Standard_Failure const& anException) {
- di << "** Exception : ";
- di << anException.GetMessageString();
- di<<" ** Skip\n";
- di << "Saving shape in variable Draw : " << fname << "\n";
- WriteShape (shape,1);
- }
return 0;
}
-
- if(fromtcl) {
- modepri = 0; // d office, une seule passe
- if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') {
- di<<"All Roots : ";
- list = XSDRAW::GetList ("xst-model-roots");
- }
- else {
- TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3);
- di<<"List given by "<<compart.ToCString()<<" : ";
- list = XSDRAW::GetList (compart.ToCString());
- }
- if (list.IsNull()) {
- di<<"No list defined. Give a selection name or * for all visible transferrable roots\n";
+
+ if (fromtcl)
+ {
+ modepri = 0; // d office, une seule passe
+ if (theArgVec[3][0] == '*' && theArgVec[3][1] == 'r' && theArgVec[3][2] == '\0')
+ {
+ theDI << "All Roots : ";
+ list = XSDRAW::Session()->GiveList("xst-model-roots");
+ }
+ else
+ {
+ TCollection_AsciiString compart = XSDRAW_CommandPart(theNbArgs, theArgVec, 3);
+ theDI << "List given by " << compart.ToCString() << " : ";
+ list = XSDRAW::Session()->GiveList(compart.ToCString());
+ }
+ if (list.IsNull())
+ {
+ theDI << "No list defined. Give a selection name or * for all visible transferrable roots\n";
continue;
}
}
- else {
- std::cout<<"Name of Selection :"<<std::flush;
- list = XSDRAW::GetList();
- if (list.IsNull()) { std::cout<<"No list defined"<<std::endl; continue; }
+ else
+ {
+ std::cout << "Name of Selection :" << std::flush;
+ list = XSDRAW::Session()->GiveList("");
+ if (list.IsNull()) { std::cout << "No list defined" << std::endl; continue; }
}
Standard_Integer nbl = list->Length();
- di<<"Nb entities selected : "<<nbl<<"\n";
+ theDI << "Nb entities selected : " << nbl << "\n";
if (nbl == 0) continue;
- while (answer) {
- if (!fromtcl) {
- std::cout<<"Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :"<<std::flush;
+ while (answer)
+ {
+ if (!fromtcl)
+ {
+ std::cout << "Choice: 0 abandon 1 transfer all 2 with confirmation 3 list n0s ents :" << std::flush;
answer = -1;
// anv 26.09.2003
- char str_answer[80];
- std::cin>>str_answer;
- answer = Draw::Atoi(str_answer);
- }
- if (answer <= 0 || answer > 3) continue;
- if (answer == 3) {
- for (Standard_Integer ill = 1; ill <= nbl; ill ++) {
- Handle(Standard_Transient) ent = list->Value(ill);
- di<<" ";// model->Print(ent,di);
- }
- di<<"\n";
- }
- if (answer == 1 || answer == 2) {
- Standard_Integer nbt = 0;
- Handle(XSControl_WorkSession) thesession = Reader.WS();
-
- XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess());
+ char str_answer[80];
+ std::cin >> str_answer;
+ answer = Draw::Atoi(str_answer);
+ }
+ if (answer <= 0 || answer > 3) continue;
+ if (answer == 3)
+ {
+ for (Standard_Integer ill = 1; ill <= nbl; ill++)
+ {
+ Handle(Standard_Transient) ent = list->Value(ill);
+ theDI << " ";// model->Print(ent,theDI);
+ }
+ theDI << "\n";
+ }
+ if (answer == 1 || answer == 2)
+ {
+ Standard_Integer nbt = 0;
+ Handle(XSControl_WorkSession) thesession = Reader.WS();
+
aPSRoot.SetName("Translation");
progress->Show(aPSRoot);
Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl);
for (Standard_Integer ill = 1; ill <= nbl && aPS.More(); ill++)
{
- nent = Reader.Model()->Number(list->Value(ill));
- if (nent == 0) continue;
- if (!Reader.TransferOne(nent, aPS.Next()))
- di<<"Transfer entity n0 "<<nent<<" : no result\n";
- else {
- nbs = Reader.NbShapes();
- char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
- di<<"Transfer entity n0 "<<nent<<" OK -> DRAW Shape: "<<shname<<"\n";
- di<<"Now, "<<nbs<<" Shapes produced\n";
- TopoDS_Shape sh = Reader.Shape(nbs);
- DBRep::Set (shname,sh);
+ nent = Reader.Model()->Number(list->Value(ill));
+ if (nent == 0) continue;
+ if (!Reader.TransferOne(nent, aPS.Next()))
+ theDI << "Transfer entity n0 " << nent << " : no result\n";
+ else
+ {
+ nbs = Reader.NbShapes();
+ char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
+ theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
+ theDI << "Now, " << nbs << " Shapes produced\n";
+ TopoDS_Shape sh = Reader.Shape(nbs);
+ DBRep::Set(shname, sh);
nbt++;
- }
- }
+ }
+ }
if (aPSRoot.UserBreak())
return 1;
- di<<"Nb Shapes successfully produced : "<<nbt<<"\n";
- answer = 0; // on ne reboucle pas
- }
+ theDI << "Nb Shapes successfully produced : " << nbt << "\n";
+ answer = 0; // on ne reboucle pas
+ }
}
}
- else di<<"Unknown mode n0 "<<modepri<<"\n";
+ else theDI << "Unknown mode n0 " << modepri << "\n";
}
return 0;
}
-//--------------------------------------------------------------
-// Function : testreadiges
-//
-//--------------------------------------------------------------
-static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=======================================================================
+//function : testread
+//purpose :
+//=======================================================================
+static Standard_Integer testread(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc != 3)
- {
- di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
- di << " Usage : " << argv[0] <<" file_name shape_name\n";
- return 1;
- }
+ if (theNbArgs != 3)
+ {
+ theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
+ theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
+ return 1;
+ }
IGESControl_Reader Reader;
- Standard_CString filename = argv[1];
- IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
- di<<"Status from reading IGES file "<<filename<<" : ";
- switch(readstat) {
- case IFSelect_RetVoid : { di<<"empty file\n"; return 1; }
- case IFSelect_RetDone : { di<<"file read\n"; break; }
- case IFSelect_RetError : { di<<"file not found\n"; return 1; }
- case IFSelect_RetFail : { di<<"error during read\n"; return 1; }
- default : { di<<"failure\n"; return 1; }
- }
+ Standard_CString filename = theArgVec[1];
+ IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
+ theDI << "Status from reading IGES file " << filename << " : ";
+ switch (readstat)
+ {
+ case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
+ case IFSelect_RetDone: { theDI << "file read\n"; break; }
+ case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
+ case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
+ default: { theDI << "failure\n"; return 1; }
+ }
Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape();
- DBRep::Set(argv[2],shape);
- di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
- return 0;
+ DBRep::Set(theArgVec[2], shape);
+ theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
+ return 0;
}
-
-//--------------------------------------------------------------
-// Function : brepiges
-//
-//--------------------------------------------------------------
-static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, const char** a)
+//=======================================================================
+//function : brepiges
+//purpose :
+//=======================================================================
+static Standard_Integer brepiges(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- XSDRAW::SetNorm ("IGES");
- // ecriture dans le model d'une entite :
- // - model_AddEntity(ent) : ecriture de l`entite seule
- // - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
- // . de sa matrice de transformation
- // . de ses sous-elements
-
- IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"),
- Interface_Static::IVal("write.iges.brep.mode"));
- di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
- di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
- di<<" To modify : command param\n";
-
-// Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
-// c a d tant qu il y a des + on ajoute ce qui suit
- const char* nomfic = NULL;
- Standard_Integer npris = 0;
-
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100);
- progress->Show(aPSRoot);
+ Handle(XSControl_WorkSession) aWorkSession = XSDRAW::Session();
+ aWorkSession->SelectNorm("IGES");
- Message_ProgressScope aPS(aPSRoot.Next(90), NULL, n);
- for ( Standard_Integer i = 1; i < n && aPS.More(); i++) {
- const char* nomvar = a[i];
- if (a[i][0] == '+') nomvar = &(a[i])[1];
- else if (i > 1) { nomfic = a[i]; break; }
- TopoDS_Shape Shape = DBRep::Get(nomvar);
- if (ICW.AddShape (Shape, aPS.Next())) npris ++;
- else if (ICW.AddGeom (DrawTrSurf::GetCurve (nomvar)) ) npris ++;
- else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++;
- }
- ICW.ComputeModel();
- XSDRAW::SetModel(ICW.Model());
- XSDRAW::SetTransferProcess (ICW.TransferProcess());
-
- if (aPSRoot.UserBreak())
+ IGESControl_Writer anIgesWriter(Interface_Static::CVal("write.iges.unit"),
+ Interface_Static::IVal("write.iges.brep.mode"));
+ theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
+ theDI << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
+ theDI << " To modify : command param\n";
+
+ const char* aFileName = nullptr;
+ Standard_Integer aNumShapesProcessed = 0;
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+ Message_ProgressScope aRootProgress(aProgress->Start(), "Translating", 100);
+ aProgress->Show(aRootProgress);
+
+ Message_ProgressScope aStepProgress(aRootProgress.Next(90), NULL, theNbArgs);
+ for (Standard_Integer i = 1; i < theNbArgs && aStepProgress.More(); i++)
+ {
+ const char* aVariableName = theArgVec[i];
+ if (theArgVec[i][0] == '+') aVariableName = &(theArgVec[i])[1];
+ else if (i > 1) {
+ aFileName = theArgVec[i]; break;
+ }
+
+ TopoDS_Shape aShape = DBRep::Get(aVariableName);
+ if (anIgesWriter.AddShape(aShape, aStepProgress.Next())) aNumShapesProcessed++;
+ else if (anIgesWriter.AddGeom(DrawTrSurf::GetCurve(aVariableName))) aNumShapesProcessed++;
+ else if (anIgesWriter.AddGeom(DrawTrSurf::GetSurface(aVariableName))) aNumShapesProcessed++;
+ }
+ anIgesWriter.ComputeModel();
+
+ if (aRootProgress.UserBreak())
return 1;
- aPSRoot.SetName("Writing");
- progress->Show(aPSRoot);
- di<<npris<<" Shapes written, giving "<<XSDRAW::Model()->NbEntities()<<" Entities\n";
+ aRootProgress.SetName("Writing");
+ aProgress->Show(aRootProgress);
+
+ theDI << aNumShapesProcessed << " Shapes written, giving " << anIgesWriter.Model()->NbEntities() << " Entities\n";
- if ( ! nomfic ) // delayed write
+ if (!aFileName) // delayed write
{
- di<<" Now, to write a file, command : writeall filename\n";
+ theDI << " Now, to write a file, command : writeall filename\n";
return 0;
}
// write file
- if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic;
- else di<<" File " << nomfic << " written";
+ if (!anIgesWriter.Write(aFileName))
+ {
+ theDI << " Error: could not write file " << aFileName << "\n";
+ return 1;
+ }
+ theDI << " File " << aFileName << " written\n";
+ aWorkSession->SetModel(anIgesWriter.Model());
return 0;
}
-//--------------------------------------------------------------
-// Function : testwriteiges
-//
-//--------------------------------------------------------------
-
-static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a)
+//=======================================================================
+//function : testwrite
+//purpose :
+//=======================================================================
+static Standard_Integer testwrite(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (n != 3)
- {
- di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n";
- di << " Usage : " << a[0] <<" file_name shape_name\n";
- return 1;
- }
+ if (theNbArgs != 3)
+ {
+ theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
+ theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
+ return 1;
+ }
IGESControl_Writer Writer;
- Standard_CString filename = a[1];
- TopoDS_Shape shape = DBRep::Get(a[2]);
+ Standard_CString filename = theArgVec[1];
+ TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
Standard_Boolean ok = Writer.AddShape(shape);
- if(!ok){
- di<<"Shape not add\n";
+ if (!ok)
+ {
+ theDI << "Shape not add\n";
return 1;
}
-
- if(!(Writer.Write(filename))){
- di<<"Error on writing file\n";
+
+ if (!(Writer.Write(filename)))
+ {
+ theDI << "Error on writing file\n";
return 1;
}
- di<<"File Is Written\n";
+ theDI << "File Is Written\n";
return 0;
}
-//--------------------------------------------------------------
-// Function : igesparam
-//
-//--------------------------------------------------------------
-
-static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** )
+//=======================================================================
+//function : igesparam
+//purpose :
+//=======================================================================
+static Standard_Integer igesparam(Draw_Interpretor& theDI,
+ Standard_Integer,
+ const char**)
{
-// liste des parametres
- di<<"List of parameters which control IGES :\n";
- di<<" unit : write.iges.unit\n mode write : write.iges.brep.mode\n spline_continuity (read) : read.iges.bspline.continuity\nSee definition by defparam, read/edit value by param\n";
- di<<"unit (write) : "<<Interface_Static::CVal("write.iges.unit")<<"\n";
- di<<"mode write : "<<Interface_Static::CVal("write.iges.brep.mode")<<"\n";
- di<<"spline_continuity (read) : "<<Interface_Static::IVal("read.iges.bspline.continuity")<<" (0 : no modif, 1 : C1, 2 : C2)\n";
- di<<"\n To modifier, param nom_param new_val\n";
+ // liste des parametres
+ theDI << "List of parameters which control IGES :\n";
+ theDI << " unit : write.iges.unit\n mode write : write.iges.brep.mode\n spline_continuity (read) : read.iges.bspline.continuity\nSee definition by defparam, read/edit value by param\n";
+ theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
+ theDI << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
+ theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
+ theDI << "\n To modifier, param nom_param new_val\n";
return 0;
}
+//=======================================================================
+//function : XSDRAWIGES_tplosttrim
+//purpose :
+//=======================================================================
+static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ Handle(XSControl_WorkSession) aWorkSession = XSDRAW::Session();
+ const Handle(Transfer_TransientProcess)& anTransientProcess = aWorkSession->TransferReader()->TransientProcess();
+ TColStd_Array1OfAsciiString aTypeStrings(1, 3);
+ TColStd_Array1OfAsciiString aKindStrings(1, 3);
+ aTypeStrings.SetValue(1, "xst-type(CurveOnSurface)");
+ aTypeStrings.SetValue(2, "xst-type(Boundary)");
+ aTypeStrings.SetValue(3, "xst-type(Loop)");
+ aKindStrings.SetValue(1, "IGESGeom_TrimmedSurface");
+ aKindStrings.SetValue(2, "IGESGeom_BoundedSurface");
+ aKindStrings.SetValue(3, "IGESSolid_Face");
+ if (anTransientProcess.IsNull())
+ {
+ theDI << "No Transfer Read\n";
+ return 1;
+ }
+ Standard_Integer anNumFaces = 0, aTotalFaces = 0;
+ Transfer_IteratorOfProcessForTransient anIterator = anTransientProcess->AbnormalResult();
+ Standard_Integer anIndex = 0;
+ if (theNbArgs > 1)
+ {
+ TCollection_AsciiString anArg(theArgVec[1]);
+ for (anIndex = 1; anIndex <= 3; anIndex++)
+ {
+ if (aKindStrings.Value(anIndex).Location(anArg, 1, aKindStrings.Value(anIndex).Length()) != 0)
+ {
+ break;
+ }
+ }
+ }
-//--------------------------------------------------------------
-// Function : tplosttrim
-//
-//--------------------------------------------------------------
+ if (anIndex == 4)
+ {
+ theDI << "Invalid argument\n";
+ return 0;
+ }
-static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_Integer n, const char** a)
-{
- Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
-
-// Standard_Integer narg = pilot->NbWords();
- Standard_Integer narg = n;
-
- const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
- TColStd_Array1OfAsciiString strarg(1, 3);
- TColStd_Array1OfAsciiString typarg(1, 3);
- strarg.SetValue(1,"xst-type(CurveOnSurface)");
- strarg.SetValue(2,"xst-type(Boundary)");
- strarg.SetValue(3,"xst-type(Loop)");
- typarg.SetValue(1,"IGESGeom_TrimmedSurface");
- typarg.SetValue(2,"IGESGeom_BoundedSurface");
- typarg.SetValue(3,"IGESSolid_Face");
- if (TP.IsNull()) { di<<"No Transfer Read\n"; return 1; }
- Standard_Integer nbFaces = 0, totFaces = 0 ;
- Handle(IFSelect_WorkSession) WS = pilot->Session();
- Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
- Standard_Integer k=0;
- if(narg > 1) {
-// TCollection_AsciiString Arg = pilot->Word(1);
- TCollection_AsciiString Arg(a[1]);
- for(k=1 ; k<=3;k++ ) {
- if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break;
+ for (Standard_Integer j = 1; j <= 3; j++)
+ {
+ TColStd_MapOfTransient aFaceMap;
+
+ if (theNbArgs == 1)
+ {
+ anIndex = j;
}
- }
- if( k == 4) {di<< "Invalid argument\n"; return 0; }
- for(Standard_Integer j = 1 ; j <= 3; j++) {
- TColStd_MapOfTransient aMap;
- if(narg == 1) k=j;
- Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString());
- if (!list.IsNull()) itrp.Filter (list);
- else {
- di << "No untrimmed faces\n";
+ Handle(TColStd_HSequenceOfTransient) aFaceList = aWorkSession->GiveList(aTypeStrings.Value(anIndex).ToCString());
+ if (!aFaceList.IsNull())
+ {
+ anIterator.Filter(aFaceList);
+ }
+ else
+ {
+ theDI << "No untrimmed faces\n";
return 0;
}
- for (itrp.Start(); itrp.More(); itrp.Next()) {
- const Handle(Standard_Transient)& ent = itrp.Starting();
- Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent);
- if (!super.IsNull()) {
- Standard_Integer nb = super->Length();
- if (nb > 0) {
- for (Standard_Integer i = 1; i <= nb; i++)
- if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) {
- if(aMap.Add(super->Value(i))) nbFaces++;
- }
- }
+ for (anIterator.Start(); anIterator.More(); anIterator.Next())
+ {
+ Handle(Standard_Transient) anEntity = anIterator.Starting();
+ Handle(TColStd_HSequenceOfTransient) aSharingEntities = aWorkSession->Sharings(anEntity);
+ if (!aSharingEntities.IsNull())
+ {
+ Standard_Integer aNumSharingEntities = aSharingEntities->Length();
+ if (aNumSharingEntities > 0)
+ {
+ for (Standard_Integer i = 1; i <= aNumSharingEntities; i++)
+ {
+ if (aSharingEntities->Value(i)->IsKind(aKindStrings.Value(anIndex).ToCString()))
+ {
+ if (aFaceMap.Add(aSharingEntities->Value(i)))
+ {
+ anNumFaces++;
+ }
+ }
+ }
+ }
}
}
- if(nbFaces != 0) {
- if( j == 1 ) di << "Number of untrimmed faces: \n";
- switch(k){
- case 1:
- di << "Trimmed Surface: \n"; break;
+ if (anNumFaces != 0)
+ {
+ if (j == 1)
+ {
+ theDI << "Number of untrimmed faces: \n";
+ }
+ switch (anIndex)
+ {
+ case 1:
+ theDI << "Trimmed Surface: \n";
+ break;
case 2:
- di << "Bounded Surface: \n"; break;
+ theDI << "Bounded Surface: \n";
+ break;
case 3:
- di << "Face: \n"; break;
+ theDI << "Face: \n";
+ break;
}
-
- TColStd_MapIteratorOfMapOfTransient itmap;
+ TColStd_MapIteratorOfMapOfTransient anMapIterator;
Standard_SStream aTmpStream;
- for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) {
- XSDRAW::Model()->Print (itmap.Key(), aTmpStream);
+ for (anMapIterator.Initialize(aFaceMap); anMapIterator.More(); anMapIterator.Next())
+ {
+ aWorkSession->Model()->Print(anMapIterator.Key(), aTmpStream);
aTmpStream << " ";
}
- di << aTmpStream.str().c_str();
- di << "\n";
- di << "\nNumber:"<< nbFaces << "\n";
- totFaces += nbFaces;
+ theDI << aTmpStream.str().c_str();
+ theDI << "\n";
+ theDI << "\nNumber:" << anNumFaces << "\n";
+ aTotalFaces += anNumFaces;
+ }
+ if (theNbArgs > 1)
+ {
+ break;
}
- if(narg > 1) break;
- nbFaces = 0;
+ anNumFaces = 0;
+ }
+ if (aTotalFaces == 0)
+ {
+ theDI << "No untrimmed faces\n";
+ }
+ else
+ {
+ theDI << "Total number :" << aTotalFaces << "\n";
}
-
- if(totFaces == 0) di << "No untrimmed faces\n";
- else di << "Total number :" << totFaces << "\n";
return 0;
}
-//-------------------------------------------------------------------
-//--------------------------------------------------------------
-// Function : TPSTAT
-//
-//--------------------------------------------------------------
-static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a)
+
+
+//=======================================================================
+//function : XSDRAWIGES_TPSTAT
+//purpose :
+//=======================================================================
+static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
- Standard_Integer argc = n;//= pilot->NbWords();
- const Standard_CString arg1 = a[1];//pilot->Arg(1);
- const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
- IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
-// **** tpent ****
- Handle(Interface_InterfaceModel) model = TP->Model();
- if (model.IsNull()) {di<<"No Transfer Read\n"; return -1;}
- Handle(XSControl_WorkSession) thesession = read.WS();
- thesession->SetMapReader(TP);
- Standard_Integer mod1 = 0;
- if (argc > 1) {
- char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
- switch (arg1[0]) {
- case 'g' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_GeneralInfo);break;
- case 'c' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_CountByItem); break;
- case 'C' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); break;
- case 'r' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ResultCount);break;
- case 's' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_Mapping);break;
- case '?' : mod1 = -1; break;
- default : mod1 = -2; break;
+ Handle(XSControl_WorkSession) aWorkSession = XSDRAW::Session();
+ const Standard_CString anArg1 = theArgVec[1];
+ const Handle(Transfer_TransientProcess)& aTransientProcess = aWorkSession->TransferReader()->TransientProcess();
+ IGESControl_Reader aReader;
+ Handle(Interface_InterfaceModel) aModel = aTransientProcess->Model();
+ if (aModel.IsNull()) { theDI << "No Transfer Read\n"; return -1; }
+ Handle(XSControl_WorkSession) aSession = aReader.WS();
+ aSession->SetMapReader(aTransientProcess);
+ Standard_Integer aMode = 0;
+ if (theNbArgs > 1)
+ {
+ char a2 = anArg1[1]; if (a2 == '\0') a2 = '!';
+ switch (anArg1[0])
+ {
+ case 'g': aReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_GeneralInfo); break;
+ case 'c': aReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_CountByItem); break;
+ case 'C': aReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_ListByItem); break;
+ case 'r': aReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_ResultCount); break;
+ case 's': aReader.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_Mapping); break;
+ case '?': aMode = -1; break;
+ default: aMode = -2; break;
}
}
- if (mod1 < -1) di<<"Unknown Mode\n";
- if (mod1 < 0) {
- di<<"Modes available :\n"
- <<"g : general c : checks (count) C (list)\n"
- <<"r : number of CasCade resulting shapes\n"
- <<"s : mapping between IGES entities and CasCade shapes\n";
- if (mod1 < -1) return -1;
+ if (aMode < -1) theDI << "Unknown Mode\n";
+ if (aMode < 0)
+ {
+ theDI << "Modes available :\n"
+ << "g : general c : checks (count) C (list)\n"
+ << "r : number of CasCade resulting shapes\n"
+ << "s : mapping between IGES entities and CasCade shapes\n";
+ if (aMode < -1) return -1;
return 0;
}
return 0;
}
-static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const char** a)
+
+//=======================================================================
+//function : etest
+//purpose :
+//=======================================================================
+static Standard_Integer etest(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if(argc < 3) {
- di<<"etest igesfile shape\n";
+ if (theNbArgs < 3)
+ {
+ theDI << "etest igesfile shape\n";
return 0;
}
IGESControl_Reader aReader;
- aReader.ReadFile(a[1]);
+ aReader.ReadFile(theArgVec[1]);
aReader.SetReadVisible(Standard_True);
aReader.TransferRoots();
TopoDS_Shape shape = aReader.OneShape();
- DBRep::Set(a[2],shape);
+ DBRep::Set(theArgVec[2], shape);
return 0;
}
-extern "C" {
-static void cleanpilot ()
+//=======================================================================
+//function : ReadIges
+//purpose : Read IGES to DECAF document
+//=======================================================================
+static Standard_Integer ReadIges(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- XSDRAW::Session()->ClearData(1);
-}
-}
+ if (theNbArgs < 3)
+ {
+ theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: read IGES file to a document\n";
+ return 0;
+ }
+ DeclareAndCast(IGESControl_Controller, aController, XSDRAW::Controller());
+ if (aController.IsNull()) XSDRAW::SetNorm("IGES");
-//--------------------------------------------------------------
-// Function : Init(s)
-//
-//--------------------------------------------------------------
+ TCollection_AsciiString aFileName, aModelName;
+ Standard_Boolean isModified = XSDRAW::FileAndVar(theArgVec[2], theArgVec[1], "IGES", aFileName, aModelName);
+ if (isModified) theDI << " File IGES to read : " << aFileName.ToCString() << "\n";
+ else theDI << " Model taken from the session : " << aModelName.ToCString() << "\n";
-void XSDRAWIGES::InitSelect ()
-{
- Handle(IGESSelect_Activator) igesact = new IGESSelect_Activator;
- IGESControl_Controller::Init();
-// XSDRAW::SetNorm ("IGES"); trop tot
- XSDRAW::SetController (XSControl_Controller::Recorded("iges"));
-
- atexit (cleanpilot);
-}
+ IGESCAFControl_Reader aReader(XSDRAW::Session(), isModified);
+ Standard_Integer onlyVisible = Interface_Static::IVal("read.iges.onlyvisible");
+ aReader.SetReadVisible(onlyVisible == 1);
+
+ if (theNbArgs == 4)
+ {
+ Standard_Boolean mode = Standard_True;
+ for (Standard_Integer i = 0; theArgVec[3][i]; i++)
+ switch (theArgVec[3][i])
+ {
+ case '-': mode = Standard_False; break;
+ case '+': mode = Standard_True; break;
+ case 'c': aReader.SetColorMode(mode); break;
+ case 'n': aReader.SetNameMode(mode); break;
+ case 'l': aReader.SetLayerMode(mode); break;
+ }
+ }
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
+ Message_ProgressScope aRootScope(aProgress->Start(), "IGES import", isModified ? 2 : 1);
+
+ IFSelect_ReturnStatus aReadStatus = IFSelect_RetVoid;
+ if (isModified)
+ {
+ Message_ProgressScope aReadScope(aRootScope.Next(), "File reading", 1);
+ aReadScope.Show();
+ aReadStatus = aReader.ReadFile(aFileName.ToCString());
+ }
+ else if (XSDRAW::Session()->NbStartingEntities() > 0)
+ {
+ aReadStatus = IFSelect_RetDone;
+ }
+ if (aReadStatus != IFSelect_RetDone)
+ {
+ if (isModified)
+ {
+ theDI << "Could not read file " << aFileName.ToCString() << " , abandon\n";
+ }
+ else
+ {
+ theDI << "No model loaded\n";
+ }
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDocument;
+ if (!DDocStd::GetDocument(theArgVec[1], aDocument, Standard_False))
+ {
+ Handle(TDocStd_Application) anApplication = DDocStd::GetApplication();
+ anApplication->NewDocument("BinXCAF", aDocument);
+ TDataStd_Name::Set(aDocument->GetData()->Root(), theArgVec[1]);
+ Handle(DDocStd_DrawDocument) aDrawDocument = new DDocStd_DrawDocument(aDocument);
+ Draw::Set(theArgVec[1], aDrawDocument);
+ }
+ if (!aReader.Transfer(aDocument, aRootScope.Next()))
+ {
+ theDI << "Cannot read any relevant data from the IGES file\n";
+ return 1;
+ }
+ theDI << "Document saved with name " << theArgVec[1];
+ return 0;
+}
//=======================================================================
-//function : InitToBRep
-//purpose :
+//function : WriteIges
+//purpose : Write DECAF document to IGES
//=======================================================================
-
-void XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands)
+static Standard_Integer WriteIges(Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
{
- const char* g = "DE: IGES";
- theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
- theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g);
- theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
- theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
- theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
- theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
- theCommands.Add("etest", "test of eviewer", __FILE__, etest, g);
+ if (theNbArgs < 3)
+ {
+ theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: write document to IGES file\n";
+ return 0;
+ }
-}
+ Handle(TDocStd_Document) aDocument;
+ DDocStd::GetDocument(theArgVec[1], aDocument);
+ if (aDocument.IsNull())
+ {
+ theDI << theArgVec[1] << " is not a document\n";
+ return 1;
+ }
+ XSDRAW::SetNorm("IGES");
+
+ TCollection_AsciiString aFileName, aModelName;
+ const Standard_Boolean isModified = XSDRAW::FileAndVar(theArgVec[2], theArgVec[1], "IGES", aFileName, aModelName);
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
+ Message_ProgressScope aRootScope(aProgress->Start(), "IGES export", isModified ? 2 : 1);
+
+ IGESCAFControl_Writer aWriter(XSDRAW::Session(), Standard_True);
+ if (theNbArgs == 4)
+ {
+ Standard_Boolean mode = Standard_True;
+ for (Standard_Integer i = 0; theArgVec[3][i]; i++)
+ switch (theArgVec[3][i])
+ {
+ case '-': mode = Standard_False; break;
+ case '+': mode = Standard_True; break;
+ case 'c': aWriter.SetColorMode(mode); break;
+ case 'n': aWriter.SetNameMode(mode); break;
+ case 'l': aWriter.SetLayerMode(mode); break;
+ }
+ }
+ aWriter.Transfer(aDocument, aRootScope.Next());
+
+ if (isModified)
+ {
+ Message_ProgressScope aWriteScope(aRootScope.Next(), "File writing", 1);
+ aWriteScope.Show();
+ theDI << "Writing IGES model to file " << theArgVec[2] << "\n";
+ if (aWriter.Write(aFileName.ToCString()))
+ {
+ theDI << " Write OK\n";
+ }
+ else
+ {
+ theDI << " Write failed\n";
+ }
+ }
+ else
+ {
+ theDI << "Document has been translated into the session";
+ }
+ return 0;
+}
//=======================================================================
-//function : InitFromBRep
-//purpose :
+//function : Factory
+//purpose :
//=======================================================================
-
-void XSDRAWIGES::InitFromBRep (Draw_Interpretor& theCommands)
+void XSDRAWIGES::Factory(Draw_Interpretor& theDI)
{
- const char* g = "DE: IGES";
- theCommands.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g);
- theCommands.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g);
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ IGESControl_Controller::Init();
+
+ const char* aGroup = "DE: IGES";
+
+ theDI.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, aGroup);
+ theDI.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, aGroup);
+ theDI.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, aGroup);
+ theDI.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, aGroup);
+ theDI.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, aGroup);
+ theDI.Add("etest", "test of eviewer", __FILE__, etest, aGroup);
+
+ theDI.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, aGroup);
+ theDI.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, aGroup);
+ theDI.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, aGroup);
+ theDI.Add("igeswrite", "igesread [file else already loaded model] [name DRAW]", __FILE__, brepiges, aGroup);
+ theDI.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, aGroup);
+ theDI.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWIGES)
-// Created on: 1995-03-15
-// Created by: Christian CAILLET
-// Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#include <Draw_Interpretor.hxx>
-
-//! XSDRAW for IGES : commands IGESSelect, Controller, transfer
-class XSDRAWIGES
+class XSDRAWIGES
{
-public:
-
DEFINE_STANDARD_ALLOC
+public:
-
- //! Inits IGESSelect commands, for DRAW
- Standard_EXPORT static void InitSelect();
-
- //! Inits IGESToBRep for DRAW
- Standard_EXPORT static void InitToBRep (Draw_Interpretor& theCommands);
-
- //! Inits BRepToIGES for DRAW
- Standard_EXPORT static void InitFromBRep (Draw_Interpretor& theCommands);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ //! Loads all Draw commands of XSDRAWIGES. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
};
-
-
-
-
-
-
#endif // _XSDRAWIGES_HeaderFile
--- /dev/null
+XSDRAWOBJ.cxx
+XSDRAWOBJ.hxx
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWOBJ.hxx>
+
+#include <BRep_Builder.hxx>
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <RWObj_CafReader.hxx>
+#include <RWObj_CafWriter.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <UnitsAPI.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+
+//=============================================================================
+//function : parseCoordinateSystem
+//purpose : Parse RWMesh_CoordinateSystem enumeration
+//=============================================================================
+static bool parseCoordinateSystem(const char* theArg,
+ RWMesh_CoordinateSystem& theSystem)
+{
+ TCollection_AsciiString aCSStr(theArg);
+ aCSStr.LowerCase();
+ if (aCSStr == "zup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Zup;
+ }
+ else if (aCSStr == "yup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Yup;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=============================================================================
+//function : ReadObj
+//purpose : Reads OBJ file
+//=============================================================================
+static Standard_Integer ReadObj (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ TCollection_AsciiString aDestName, aFilePath;
+ Standard_Boolean toUseExistingDoc = Standard_False;
+ Standard_Real aFileUnitFactor = -1.0;
+ RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
+ Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False;
+ Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj");
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-unit"
+ || anArgCase == "-units"
+ || anArgCase == "-fileunit"
+ || anArgCase == "-fileunits"))
+ {
+ const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
+ aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
+ if (aFileUnitFactor <= 0.0)
+ {
+ Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
+ return 1;
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-filecoordinatesystem"
+ || anArgCase == "-filecoordsystem"
+ || anArgCase == "-filecoordsys"))
+ {
+ if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
+ {
+ Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-resultcoordinatesystem"
+ || anArgCase == "-resultcoordsystem"
+ || anArgCase == "-resultcoordsys"
+ || anArgCase == "-rescoordsys"))
+ {
+ if (!parseCoordinateSystem (theArgVec[++anArgIter], aResultCoordSys))
+ {
+ Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ else if (anArgCase == "-singleprecision"
+ || anArgCase == "-singleprec")
+ {
+ isSinglePrecision = Standard_True;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], isSinglePrecision))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (isNoDoc
+ && (anArgCase == "-singleface"
+ || anArgCase == "-singletriangulation"))
+ {
+ isSingleFace = Standard_True;
+ }
+ else if (!isNoDoc
+ && (anArgCase == "-nocreate"
+ || anArgCase == "-nocreatedoc"))
+ {
+ toUseExistingDoc = Standard_True;
+ if (anArgIter + 1 < theNbArgs
+ && Draw::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArgCase == "-listexternalfiles"
+ || anArgCase == "-listexternals"
+ || anArgCase == "-listexternal"
+ || anArgCase == "-external"
+ || anArgCase == "-externalfiles")
+ {
+ toListExternalFiles = Standard_True;
+ }
+ else if (aDestName.IsEmpty())
+ {
+ aDestName = theArgVec[anArgIter];
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (aFilePath.IsEmpty())
+ {
+ Message::SendFail() << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+ Handle(TDocStd_Document) aDoc;
+ if (!isNoDoc
+ && !toListExternalFiles)
+ {
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ Standard_CString aNameVar = aDestName.ToCString();
+ DDocStd::GetDocument (aNameVar, aDoc, Standard_False);
+ if (aDoc.IsNull())
+ {
+ if (toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
+ return 1;
+ }
+ anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
+ }
+ else if (!toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDestName << " already exists";
+ return 1;
+ }
+ }
+ const Standard_Real aScaleFactorM = XSDRAW::GetLengthUnit() / 1000;
+
+ RWObj_CafReader aReader;
+ aReader.SetSinglePrecision (isSinglePrecision);
+ aReader.SetSystemLengthUnit (aScaleFactorM);
+ aReader.SetSystemCoordinateSystem (aResultCoordSys);
+ aReader.SetFileLengthUnit (aFileUnitFactor);
+ aReader.SetFileCoordinateSystem (aFileCoordSys);
+ aReader.SetDocument (aDoc);
+ if (isSingleFace)
+ {
+ RWObj_TriangulationReader aSimpleReader;
+ aSimpleReader.SetSinglePrecision (isSinglePrecision);
+ aSimpleReader.SetCreateShapes (Standard_False);
+ aSimpleReader.SetTransformation (aReader.CoordinateSystemConverter());
+ aSimpleReader.Read (aFilePath.ToCString(), aProgress->Start());
+
+ Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
+ TopoDS_Face aFace;
+ BRep_Builder aBuiler;
+ aBuiler.MakeFace (aFace);
+ aBuiler.UpdateFace (aFace, aTriangulation);
+ DBRep::Set (aDestName.ToCString(), aFace);
+ return 0;
+ }
+
+ if (toListExternalFiles)
+ {
+ aReader.ProbeHeader (aFilePath);
+ for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
+ {
+ theDI << "\"" << aFileIter.Value() << "\" ";
+ }
+ }
+ else
+ {
+ aReader.Perform (aFilePath, aProgress->Start());
+ if (isNoDoc)
+ {
+ DBRep::Set (aDestName.ToCString(), aReader.SingleShape());
+ }
+ else
+ {
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
+ TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName);
+ Draw::Set (aDestName.ToCString(), aDrawDoc);
+ }
+ }
+ return 0;
+}
+
+///=============================================================================
+//function : WriteObj
+//purpose : Writes OBJ file
+//=============================================================================
+static Standard_Integer WriteObj (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ TCollection_AsciiString anObjFilePath;
+ Handle(TDocStd_Document) aDoc;
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ Standard_Real aFileUnitFactor = -1.0;
+ RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+ if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-unit"
+ || anArgCase == "-units"
+ || anArgCase == "-fileunit"
+ || anArgCase == "-fileunits"))
+ {
+ const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
+ aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
+ if (aFileUnitFactor <= 0.0)
+ {
+ Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
+ return 1;
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-filecoordinatesystem"
+ || anArgCase == "-filecoordsystem"
+ || anArgCase == "-filecoordsys"))
+ {
+ if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
+ {
+ Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ else if (anArgIter + 1 < theNbArgs
+ && (anArgCase == "-systemcoordinatesystem"
+ || anArgCase == "-systemcoordsystem"
+ || anArgCase == "-systemcoordsys"
+ || anArgCase == "-syscoordsys"))
+ {
+ if (!parseCoordinateSystem (theArgVec[++anArgIter], aSystemCoordSys))
+ {
+ Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ else if (anArgCase == "-comments"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
+ }
+ else if (anArgCase == "-author"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add ("Author", theArgVec[++anArgIter]);
+ }
+ else if (aDoc.IsNull())
+ {
+ Standard_CString aNameVar = theArgVec[anArgIter];
+ DDocStd::GetDocument (aNameVar, aDoc, false);
+ if (aDoc.IsNull())
+ {
+ TopoDS_Shape aShape = DBRep::Get (aNameVar);
+ if (aShape.IsNull())
+ {
+ Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
+ return 1;
+ }
+
+ anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
+ aShapeTool->AddShape (aShape);
+ }
+ }
+ else if (anObjFilePath.IsEmpty())
+ {
+ anObjFilePath = theArgVec[anArgIter];
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (anObjFilePath.IsEmpty())
+ {
+ Message::SendFail() << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+
+ const Standard_Real aSystemUnitFactor = XSDRAW::GetLengthUnit() * 0.001;
+ RWObj_CafWriter aWriter (anObjFilePath);
+ aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aSystemUnitFactor);
+ aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
+ aWriter.ChangeCoordinateSystemConverter().SetOutputLengthUnit (aFileUnitFactor);
+ aWriter.ChangeCoordinateSystemConverter().SetOutputCoordinateSystem (aFileCoordSys);
+ aWriter.Perform (aDoc, aFileInfo, aProgress->Start());
+ return 0;
+}
+
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAWOBJ::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands
+ theDI.Add("ReadObj",
+ "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+ "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
+ "\n\t\t: [-listExternalFiles] [-noCreateDoc]"
+ "\n\t\t: Read OBJ file into XDE document."
+ "\n\t\t: -fileUnit length unit of OBJ file content;"
+ "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
+ "\n\t\t: -resultCoordSys result coordinate system; Zup when not specified."
+ "\n\t\t: -singlePrecision truncate vertex data to single precision during read; FALSE by default."
+ "\n\t\t: -listExternalFiles do not read mesh and only list external files."
+ "\n\t\t: -noCreateDoc read into existing XDE document.",
+ __FILE__, ReadObj, aGroup);
+ theDI.Add("readobj",
+ "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+ "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
+ "\n\t\t: [-singleFace]"
+ "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document."
+ "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.",
+ __FILE__, ReadObj, aGroup);
+ theDI.Add("WriteObj",
+ "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+ "\n\t\t: [-systemCoordSys {Zup|Yup}]"
+ "\n\t\t: [-comments Text] [-author Name]"
+ "\n\t\t: Write XDE document into OBJ file."
+ "\n\t\t: -fileUnit length unit of OBJ file content;"
+ "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
+ "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.",
+ __FILE__, WriteObj, aGroup);
+ theDI.Add("writeobj",
+ "writeobj shape file",
+ __FILE__, WriteObj, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWOBJ)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWOBJ_HeaderFile
+#define _XSDRAWOBJ_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWOBJ
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWOBJ. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWOBJ_HeaderFile
--- /dev/null
+XSDRAWPLY.cxx
+XSDRAWPLY.hxx
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWPLY.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepLib_PointCloudShape.hxx>
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <RWMesh_FaceIterator.hxx>
+#include <RWPly_CafWriter.hxx>
+#include <RWPly_PlyWriterContext.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Shape.hxx>
+#include <UnitsAPI.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFPrs_DocumentExplorer.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+
+//=======================================================================
+//function : writeply
+//purpose : write PLY file
+//=======================================================================
+static Standard_Integer WritePly (Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ Handle(TDocStd_Document) aDoc;
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ TCollection_AsciiString aShapeName, aFileName;
+
+ Standard_Real aDist = 0.0;
+ Standard_Real aDens = Precision::Infinite();
+ Standard_Real aTol = Precision::Confusion();
+ bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false;
+ bool isPntSet = false, isDensityPoints = false;
+ TColStd_IndexedDataMapOfStringString aFileInfo;
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgVec[anArgIter]);
+ anArg.LowerCase();
+ if (anArg == "-normal")
+ {
+ hasNormals = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArg == "-nonormal")
+ {
+ hasNormals = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArg == "-color"
+ || anArg == "-nocolor"
+ || anArg == "-colors"
+ || anArg == "-nocolors")
+ {
+ hasColors = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArg == "-uv"
+ || anArg == "-nouv")
+ {
+ hasTexCoords = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+ }
+ else if (anArg == "-partid")
+ {
+ hasPartId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+ hasFaceId = hasFaceId && !hasPartId;
+ }
+ else if (anArg == "-surfid"
+ || anArg == "-surfaceid"
+ || anArg == "-faceid")
+ {
+ hasFaceId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
+ hasPartId = hasPartId && !hasFaceId;
+ }
+ else if (anArg == "-pntset"
+ || anArg == "-pntcloud"
+ || anArg == "-pointset"
+ || anArg == "-pointcloud"
+ || anArg == "-cloud"
+ || anArg == "-points")
+ {
+ isPntSet = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
+ }
+ else if ((anArg == "-dist"
+ || anArg == "-distance")
+ && anArgIter + 1 < theNbArgs
+ && Draw::ParseReal (theArgVec[anArgIter + 1], aDist))
+ {
+ ++anArgIter;
+ isPntSet = true;
+ if (aDist < 0.0)
+ {
+ theDI << "Syntax error: -distance value should be >= 0.0";
+ return 1;
+ }
+ aDist = Max (aDist, Precision::Confusion());
+ }
+ else if ((anArg == "-dens"
+ || anArg == "-density")
+ && anArgIter + 1 < theNbArgs
+ && Draw::ParseReal (theArgVec[anArgIter + 1], aDens))
+ {
+ ++anArgIter;
+ isDensityPoints = Standard_True;
+ isPntSet = true;
+ if (aDens <= 0.0)
+ {
+ theDI << "Syntax error: -density value should be > 0.0";
+ return 1;
+ }
+ }
+ else if ((anArg == "-tol"
+ || anArg == "-tolerance")
+ && anArgIter + 1 < theNbArgs
+ && Draw::ParseReal (theArgVec[anArgIter + 1], aTol))
+ {
+ ++anArgIter;
+ isPntSet = true;
+ if (aTol < Precision::Confusion())
+ {
+ theDI << "Syntax error: -tol value should be >= " << Precision::Confusion();
+ return 1;
+ }
+ }
+ else if (anArg == "-comments"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
+ }
+ else if (anArg == "-author"
+ && anArgIter + 1 < theNbArgs)
+ {
+ aFileInfo.Add ("Author", theArgVec[++anArgIter]);
+ }
+ else if (aDoc.IsNull())
+ {
+ if (aShapeName.IsEmpty())
+ {
+ aShapeName = theArgVec[anArgIter];
+ }
+
+ Standard_CString aNameVar = theArgVec[anArgIter];
+ DDocStd::GetDocument (aNameVar, aDoc, false);
+ if (aDoc.IsNull())
+ {
+ TopoDS_Shape aShape = DBRep::Get (aNameVar);
+ if (!aShape.IsNull())
+ {
+ anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
+ aShapeTool->AddShape (aShape);
+ }
+ }
+ }
+ else if (aFileName.IsEmpty())
+ {
+ aFileName = theArgVec[anArgIter];
+ }
+ else
+ {
+ theDI << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (aDoc.IsNull()
+ && !aShapeName.IsEmpty())
+ {
+ theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document";
+ return 1;
+ }
+ else if (aDoc.IsNull()
+ || aFileName.IsEmpty())
+ {
+ theDI << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ TDF_LabelSequence aRootLabels;
+ Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
+ aShapeTool->GetFreeShapes (aRootLabels);
+ if (aRootLabels.IsEmpty())
+ {
+ theDI << "Error: empty document";
+ return 1;
+ }
+
+ if (isPntSet)
+ {
+ class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext
+ {
+ public:
+ PointCloudPlyWriter (Standard_Real theTol)
+ : BRepLib_PointCloudShape (TopoDS_Shape(), theTol) {}
+
+ void AddFaceColor (const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
+ { myFaceColor.Bind (theFace, theColor); }
+
+ protected:
+ virtual void addPoint (const gp_Pnt& thePoint,
+ const gp_Vec& theNorm,
+ const gp_Pnt2d& theUV,
+ const TopoDS_Shape& theFace)
+ {
+ Graphic3d_Vec4ub aColor;
+ myFaceColor.Find (theFace, aColor);
+ RWPly_PlyWriterContext::WriteVertex (thePoint,
+ Graphic3d_Vec3 ((float )theNorm.X(), (float )theNorm.Y(), (float )theNorm.Z()),
+ Graphic3d_Vec2 ((float )theUV.X(), (float )theUV.Y()),
+ aColor);
+ }
+
+ private:
+ NCollection_DataMap<TopoDS_Shape, Graphic3d_Vec4ub> myFaceColor;
+ };
+
+ PointCloudPlyWriter aPlyCtx (aTol);
+ aPlyCtx.SetNormals (hasNormals);
+ aPlyCtx.SetColors (hasColors);
+ aPlyCtx.SetTexCoords (hasTexCoords);
+
+ TopoDS_Compound aComp;
+ BRep_Builder().MakeCompound (aComp);
+ for (XCAFPrs_DocumentExplorer aDocExplorer (aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
+ aDocExplorer.More(); aDocExplorer.Next())
+ {
+ const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current();
+ for (RWMesh_FaceIterator aFaceIter (aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
+ {
+ BRep_Builder().Add (aComp, aFaceIter.Face());
+ Graphic3d_Vec4ub aColorVec (255);
+ if (aFaceIter.HasFaceColor())
+ {
+ Graphic3d_Vec4 aColorF = aFaceIter.FaceColor();
+ aColorVec.SetValues ((unsigned char )int(aColorF.r() * 255.0f),
+ (unsigned char )int(aColorF.g() * 255.0f),
+ (unsigned char )int(aColorF.b() * 255.0f),
+ (unsigned char )int(aColorF.a() * 255.0f));
+ }
+ aPlyCtx.AddFaceColor (aFaceIter.Face(), aColorVec);
+ }
+ }
+ aPlyCtx.SetShape (aComp);
+
+ Standard_Integer aNbPoints = isDensityPoints
+ ? aPlyCtx.NbPointsByDensity (aDens)
+ : aPlyCtx.NbPointsByTriangulation();
+ if (aNbPoints <= 0)
+ {
+ theDI << "Error: unable to generate points";
+ return 0;
+ }
+
+ if (!aPlyCtx.Open (aFileName)
+ || !aPlyCtx.WriteHeader (aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
+ {
+ theDI << "Error: unable to create file '" << aFileName << "'";
+ return 0;
+ }
+
+ Standard_Boolean isDone = isDensityPoints
+ ? aPlyCtx.GeneratePointsByDensity (aDens)
+ : aPlyCtx.GeneratePointsByTriangulation();
+ if (!isDone)
+ {
+ theDI << "Error: Point cloud was not generated in file '" << aFileName << "'";
+ }
+ else if (!aPlyCtx.Close())
+ {
+ theDI << "Error: Point cloud file '" << aFileName << "' was not written";
+ }
+ else
+ {
+ theDI << aNbPoints;
+ }
+ }
+ else
+ {
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
+ RWPly_CafWriter aPlyCtx (aFileName);
+ aPlyCtx.SetNormals (hasNormals);
+ aPlyCtx.SetColors (hasColors);
+ aPlyCtx.SetTexCoords (hasTexCoords);
+ aPlyCtx.SetPartId (hasPartId);
+ aPlyCtx.SetFaceId (hasFaceId);
+ aPlyCtx.Perform (aDoc, aFileInfo, aProgress->Start());
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAWPLY::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands
+ //XSDRAW::LoadDraw(theCommands);
+ theDI.Add("WritePly", R"(
+WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0
+ [-pointCloud {0|1}]=0 [-distance Value]=0.0 [-density Value] [-tolerance Value]
+Write document or triangulated shape into PLY file.
+ -normals write per-vertex normals
+ -colors write per-vertex colors
+ -uv write per-vertex UV coordinates
+ -partId write per-element part index (alternative to -faceId)
+ -faceId write per-element face index (alternative to -partId)
+
+Generate point cloud out of the shape and write it into PLY file.
+ -pointCloud write point cloud instead without triangulation indices
+ -distance sets distance from shape into the range [0, Value];
+ -density sets density of points to generate randomly on surface;
+ -tolerance sets tolerance; default value is Precision::Confusion();
+)", __FILE__, WritePly, aGroup);
+ theDI.Add("writeply",
+ "writeply shape file",
+ __FILE__, WritePly, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWPLY)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWPLY_HeaderFile
+#define _XSDRAWPLY_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWPLY
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWPLY. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWPLY_HeaderFile
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-//:k8 abv 6 Jan 98: using parameter "step.group" for writing assemblies/shapes
+#include <XSDRAWSTEP.hxx>
#include <DBRep.hxx>
-#include <Draw_Appli.hxx>
+#include <DDF.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.hxx>
-#include <IFSelect_SessionPilot.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
-#include <Message_ProgressScope.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
+#include <STEPCAFControl_Reader.hxx>
+#include <STEPCAFControl_Writer.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPControl_StepModelType.hxx>
#include <STEPControl_Writer.hxx>
#include <StepData_StepModel.hxx>
-#include <StepData_Factors.hxx>
#include <StepGeom_Axis2Placement3d.hxx>
#include <StepSelect_Activator.hxx>
#include <STEPSelections_AssemblyExplorer.hxx>
#include <STEPSelections_Counter.hxx>
#include <StepToTopoDS_MakeTransformed.hxx>
-#include <TColStd_HSequenceOfTransient.hxx>
-#include <TopExp_Explorer.hxx>
-#include <Transfer_TransientProcess.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <UnitsMethods.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
-#include <XSControl_Controller.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
-#include <XSDRAWSTEP.hxx>
-#include <UnitsMethods.hxx>
-
-#include <stdio.h>
-// Pour le transfert (write)
-// Pour NewModel et Write : definition de produit (temporaire ...)
-// steptrans
-extern "C" {
-static void cleanpilot ()
-{
- XSDRAW::Session()->ClearData(1);
-}
-}
-
-//=======================================================================
-//function : Init
-//purpose :
-//=======================================================================
-
-void XSDRAWSTEP::Init ()
+namespace
{
- Handle(StepSelect_Activator) stepact = new StepSelect_Activator;
- if (STEPControl_Controller::Init()) // XSDRAW::SetNorm("STEP AP-214"); trop tot
- XSDRAW::SetController(XSControl_Controller::Recorded("STEP"));
-
- atexit (cleanpilot);
+ using ExternalFileMap = NCollection_DataMap<TCollection_AsciiString, Handle(STEPCAFControl_ExternFile)>;
}
-// ######## COMMANDE stepread : teste le Reader #########
//=======================================================================
//function : stepread
-//purpose :
+//purpose :
//=======================================================================
-
-static Standard_Integer stepread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer stepread(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 3) {
- di << "Use: stepread [file] [f or r (type of model full or reduced)]\n";
+ if (theNbArgs < 3)
+ {
+ theDI << "Use: stepread [file] [f or r (type of model full or reduced)]\n";
return 1;
}
- // On admet le controller AP214 ou une variante
- DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
- if (ctl.IsNull()) XSDRAW::SetNorm("STEP");
-
// Progress indicator
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100);
-
- STEPControl_Reader sr (XSDRAW::Session(),Standard_False);
- TCollection_AsciiString fnom,rnom;
- Standard_Boolean modfic = XSDRAW::FileAndVar
- (argv[1],argv[2],"STEP",fnom,rnom);
- if (modfic) di<<" File STEP to read : "<<fnom.ToCString()<<"\n";
- else di<<" Model taken from the session : "<<fnom.ToCString()<<"\n";
- di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
+ Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
+ Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100);
+
+ STEPControl_Reader sr(XSDRAW::Session(), Standard_False);
+ TCollection_AsciiString fnom, rnom;
+ Standard_Boolean modfic = XSDRAW::FileAndVar(theArgVec[1], theArgVec[2], "STEP", fnom, rnom);
+ if (modfic) theDI << " File STEP to read : " << fnom.ToCString() << "\n";
+ else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
+ theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
aPSRoot.SetName("Loading");
Standard_Boolean fromtcl = Standard_False;
Standard_Boolean aFullMode = Standard_False;
Standard_Integer k = 3;
- if(argc > k )
+ if (theNbArgs > k)
{
- if(argv[k][0] == 'f' || argv[3][0] == 'F')
+ if (theArgVec[k][0] == 'f' || theArgVec[3][0] == 'F')
{
aFullMode = Standard_True;
k++;
}
- else if(argv[k][0] == 'r' || argv[3][0] == 'R')
+ else if (theArgVec[k][0] == 'r' || theArgVec[3][0] == 'R')
{
aFullMode = Standard_False;
k++;
}
else
fromtcl = Standard_True;
-
}
- if(!fromtcl)
- fromtcl = argc > k;
- if(aFullMode)
- std::cout<<"Full model for translation with additional info will be used \n"<<std::flush;
+ if (!fromtcl)
+ fromtcl = theNbArgs > k;
+ if (aFullMode)
+ std::cout << "Full model for translation with additional info will be used \n" << std::flush;
else
- std::cout<<"Reduced model for translation without additional info will be used \n"<<std::flush;
-
- sr.WS()->SetModeStat(aFullMode);
+ std::cout << "Reduced model for translation without additional info will be used \n" << std::flush;
+ sr.WS()->SetModeStat(aFullMode);
- if (modfic) readstat = sr.ReadFile (fnom.ToCString());
+ if (modfic) readstat = sr.ReadFile(fnom.ToCString());
else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
aPSRoot.Next(20); // On average loading takes 20%
if (aPSRoot.UserBreak())
return 1;
- if (readstat != IFSelect_RetDone) {
- if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
- else di<<"No model loaded\n";
+ if (readstat != IFSelect_RetDone)
+ {
+ if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
+ else theDI << "No model loaded\n";
return 1;
}
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- sr.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
+ sr.SetSystemLengthUnit(XSDRAW::GetLengthUnit());
// nom = "." -> fichier deja lu
Standard_Integer i, num, nbs, modepri = 1;
if (fromtcl) modepri = 4;
- while (modepri) {
+ while (modepri)
+ {
num = sr.NbRootsForTransfer();
- if (!fromtcl) {
- di<<"NbRootsForTransfer="<<num<<" :\n";
- for (i = 1; i <= num; i ++) {
- di<<"Root."<<i<<", Ent. ";
+ if (!fromtcl)
+ {
+ theDI << "NbRootsForTransfer=" << num << " :\n";
+ for (i = 1; i <= num; i++)
+ {
+ theDI << "Root." << i << ", Ent. ";
Standard_SStream aTmpStream;
- sr.Model()->Print (sr.RootForTransfer(i), aTmpStream);
- di << aTmpStream.str().c_str();
- di<<" Type:"<<sr.RootForTransfer(i)->DynamicType()->Name()<<"\n";
+ sr.Model()->Print(sr.RootForTransfer(i), aTmpStream);
+ theDI << aTmpStream.str().c_str();
+ theDI << " Type:" << sr.RootForTransfer(i)->DynamicType()->Name() << "\n";
}
- std::cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<<std::flush;
- std::cin>>modepri;
+ std::cout << "Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : " << std::flush;
+ std::cin >> modepri;
}
- if (modepri == 0) { di<<"End Reading STEP\n"; return 0; }
- if (modepri <= 2) {
+ if (modepri == 0) { theDI << "End Reading STEP\n"; return 0; }
+ if (modepri <= 2)
+ {
num = 1;
- if (modepri == 2) {
- std::cout<<"Root N0 : "<<std::flush; std::cin>>num;
+ if (modepri == 2)
+ {
+ std::cout << "Root N0 : " << std::flush; std::cin >> num;
}
aPSRoot.SetName("Translation");
progress->Show(aPSRoot);
- if (!sr.TransferRoot (num, aPSRoot.Next(80)))
- di<<"Transfer root n0 "<<num<<" : no result\n";
- else {
+ if (!sr.TransferRoot(num, aPSRoot.Next(80)))
+ theDI << "Transfer root n0 " << num << " : no result\n";
+ else
+ {
nbs = sr.NbShapes();
- char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
- di<<"Transfer root n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
- di<<"Now, "<<nbs<<" Shapes produced\n";
+ char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
+ theDI << "Transfer root n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
+ theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs);
- DBRep::Set (shname,sh);
+ DBRep::Set(shname, sh);
}
if (aPSRoot.UserBreak())
return 1;
}
- else if (modepri == 3) {
- std::cout<<"Entity : "<<std::flush; num = XSDRAW::GetEntityNumber();
- if (!sr.TransferOne (num))
- di<<"Transfer entity n0 "<<num<<" : no result\n";
- else {
+ else if (modepri == 3)
+ {
+ std::cout << "Entity : " << std::flush; num = XSDRAW::GetEntityNumber("");
+ if (!sr.TransferOne(num))
+ theDI << "Transfer entity n0 " << num << " : no result\n";
+ else
+ {
nbs = sr.NbShapes();
- char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),num);
- di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
- di<<"Now, "<<nbs<<" Shapes produced\n";
+ char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), num);
+ theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
+ theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs);
- DBRep::Set (shname,sh);
+ DBRep::Set(shname, sh);
}
}
- else if (modepri == 4) {
+ else if (modepri == 4)
+ {
// char snm[100]; Standard_Integer answer = 1;
Handle(TColStd_HSequenceOfTransient) list;
// Selection, nommee ou via tcl. tcl : raccourcis admis
// * donne xst-transferrable-roots
- if (fromtcl) {
+ if (fromtcl)
+ {
modepri = 0; // d ioffice une seule passe
- if (argv[k][0] == '*' && argv[k][1] == '\0') {
- di<<"Transferrable Roots : ";
- list = XSDRAW::GetList("xst-transferrable-roots");
+ if (theArgVec[k][0] == '*' && theArgVec[k][1] == '\0')
+ {
+ theDI << "Transferrable Roots : ";
+ list = XSDRAW::Session()->GiveList("xst-transferrable-roots");
//list = new TColStd_HSequenceOfTransient;
//for(Standard_Integer j=1; j<=num; j++)
// list->Append(sr.RootForTransfer(j));
}
- else {
- di<<"List given by "<<argv[k];
- if (argc > k+1) di<<" "<<argv[k+1];
- di<<" : ";
- list = XSDRAW::GetList (argv[k], ( argc > (k+1) ? argv[k+1] : 0 ) );
+ else
+ {
+ theDI << "List given by " << theArgVec[k];
+ if (theNbArgs > k + 1) theDI << " " << theArgVec[k + 1];
+ theDI << " : ";
+ list = XSDRAW::Session()->GiveList(theArgVec[k], (theNbArgs > (k + 1) ? theArgVec[k + 1] : 0));
}
- if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots\n"; continue; }
- } else {
- std::cout<<"Name of Selection :"<<std::flush;
- list = XSDRAW::GetList();
- if (list.IsNull()) { di<<"No list defined\n"; continue; }
+ if (list.IsNull()) { theDI << "No list defined. Give a selection name or * for all transferrable roots\n"; continue; }
+ }
+ else
+ {
+ std::cout << "Name of Selection :" << std::flush;
+ list = XSDRAW::Session()->GiveList("");
+ if (list.IsNull()) { theDI << "No list defined\n"; continue; }
}
Standard_Integer ill, nbl = list->Length();
- di<<"Nb entities selected : "<<nbl<<"\n";
+ theDI << "Nb entities selected : " << nbl << "\n";
if (nbl == 0) continue;
aPSRoot.SetName("Translation");
progress->Show(aPSRoot);
Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl);
- for (ill = 1; ill <= nbl && aPS.More(); ill++) {
+ for (ill = 1; ill <= nbl && aPS.More(); ill++)
+ {
num = sr.Model()->Number(list->Value(ill));
if (num == 0) continue;
if (!sr.TransferOne(num, aPS.Next()))
- di<<"Transfer entity n0 "<<num<<" : no result\n";
- else {
+ theDI << "Transfer entity n0 " << num << " : no result\n";
+ else
+ {
nbs = sr.NbShapes();
- char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
- di<<"Transfer entity n0 "<<num<<" OK -> DRAW Shape: "<<shname<<"\n";
- di<<"Now, "<<nbs<<" Shapes produced\n";
+ char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
+ theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
+ theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs);
- DBRep::Set (shname,sh);
+ DBRep::Set(shname, sh);
}
}
if (aPSRoot.UserBreak())
return 1;
}
- else di<<"Unknown mode n0 "<<modepri<<"\n";
+ else theDI << "Unknown mode n0 " << modepri << "\n";
}
return 0;
}
//=======================================================================
//function : testreadstep
-//purpose :
+//purpose :
//=======================================================================
-static Standard_Integer testreadstep (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer testreadstep(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 3 || argc > 4)
+ if (theNbArgs < 3 || theNbArgs > 4)
{
- di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
- di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n";
- di << " Option -stream forces usage of API accepting stream\n";
+ theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
+ theDI << " Usage : " << theArgVec[0] << " file_name shape_name [-stream]\n";
+ theDI << " Option -stream forces usage of API accepting stream\n";
return 1;
}
- Standard_Boolean useStream = (argc > 3 && ! strcasecmp (argv[3], "-stream"));
+ Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[3], "-stream"));
STEPControl_Reader Reader;
- Standard_CString filename = argv[1];
+ Standard_CString filename = theArgVec[1];
IFSelect_ReturnStatus readstat;
if (useStream)
{
std::ifstream aStream;
- OSD_OpenStream (aStream, filename, std::ios::in | std::ios::binary);
+ OSD_OpenStream(aStream, filename, std::ios::in | std::ios::binary);
TCollection_AsciiString aFolder, aFileNameShort;
- OSD_Path::FolderAndFileFromPath (filename, aFolder, aFileNameShort);
- readstat = Reader.ReadStream (aFileNameShort.ToCString(), aStream);
+ OSD_Path::FolderAndFileFromPath(filename, aFolder, aFileNameShort);
+ readstat = Reader.ReadStream(aFileNameShort.ToCString(), aStream);
}
else
{
readstat = Reader.ReadFile(filename);
}
- di<<"Status from reading STEP file "<<filename<<" : ";
- switch(readstat) {
- case IFSelect_RetVoid : { di<<"empty file\n"; return 1; }
- case IFSelect_RetDone : { di<<"file read\n"; break; }
- case IFSelect_RetError : { di<<"file not found\n"; return 1; }
- case IFSelect_RetFail : { di<<"error during read\n"; return 1; }
- default : { di<<"failure\n"; return 1; }
+ theDI << "Status from reading STEP file " << filename << " : ";
+ switch (readstat)
+ {
+ case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
+ case IFSelect_RetDone: { theDI << "file read\n"; break; }
+ case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
+ case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
+ default: { theDI << "failure\n"; return 1; }
}
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
+ Reader.SetSystemLengthUnit(XSDRAW::GetLengthUnit());
Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape();
- DBRep::Set(argv[2],shape);
- di<<"Count of shapes produced : "<<Reader.NbShapes()<<"\n";
+ DBRep::Set(theArgVec[2], shape);
+ theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
return 0;
}
-
-// ######## COMMANDE steptrans : teste les transformations #########
+
//=======================================================================
//function : steptrans
-//purpose :
+//purpose :
//=======================================================================
-
-static Standard_Integer steptrans (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer steptrans(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- if (argc < 5) { di<<"give shape-name new-shape + entity-n0 entity-n0: AXIS2\n";
- return 1; }
- TopoDS_Shape shape = DBRep::Get(argv[1]);
- if (shape.IsNull()) { di<<"Not a shape : "<<argv[1]<<"\n"; return 1; }
- Handle(StepGeom_Axis2Placement3d) ax1,ax2;
+ if (theNbArgs < 5)
+ {
+ theDI << "give shape-name new-shape + entity-n0 entity-n0: AXIS2\n";
+ return 1;
+ }
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ TopoDS_Shape shape = DBRep::Get(theArgVec[1]);
+ if (shape.IsNull())
+ {
+ theDI << "Not a shape : " << theArgVec[1] << "\n";
+ return 1;
+ }
+ Handle(StepGeom_Axis2Placement3d) ax1, ax2;
Standard_Integer n1 = 0, n2 = 0;
- n1 = XSDRAW::GetEntityNumber(argv[3]);
- if (argc > 4) n2 = XSDRAW::GetEntityNumber(argv[4]);
+ n1 = XSDRAW::GetEntityNumber(theArgVec[3]);
+ if (theNbArgs > 4) n2 = XSDRAW::GetEntityNumber(theArgVec[4]);
if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast
- (XSDRAW::Entity(n1));
+ (aWS->StartingEntity(n1));
if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast
- (XSDRAW::Entity(n2));
+ (aWS->StartingEntity(n2));
+ StepData_Factors aFactors;
StepToTopoDS_MakeTransformed mktrans;
- StepData_Factors aLocalFactors;
- if (mktrans.Compute (ax1,ax2, aLocalFactors)) {
- TopLoc_Location loc (mktrans.Transformation());
- shape.Move (loc);
-// mktrans.Transform (shape);
- DBRep::Set (argv[2],shape);
- di<<"Transformed Shape as "<<argv[2]<<"\n";
- }
- else di<<"No transformation computed\n";
+ if (mktrans.Compute(ax1, ax2, aFactors))
+ {
+ TopLoc_Location loc(mktrans.Transformation());
+ shape.Move(loc);
+ DBRep::Set(theArgVec[2], shape);
+ theDI << "Transformed Shape as " << theArgVec[2] << "\n";
+ }
+ else
+ theDI << "No transformation computed\n";
return 0;
}
-// ######## COMMANDE stepwrite : teste le Writer #########
-
//=======================================================================
//function : stepwrite
//purpose :
//=======================================================================
-
-static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer stepwrite(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
-// On admet le controller AP214 ou une variante
- DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller());
- if (ctl.IsNull()) {
- XSDRAW::SetNorm("STEP");
- //sln 14.01.2002 OCC51: assign new value to ctl in order to avoid exception during using one in the function
- ctl = Handle(STEPControl_Controller)::DownCast(XSDRAW::Controller());
+ Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
+ Handle(STEPControl_Controller) aCtl =
+ Handle(STEPControl_Controller)::DownCast(aWS->NormAdaptor());
+ if (aCtl.IsNull())
+ {
+ aWS->SelectNorm("STEP");
+ }
+ if (theNbArgs < 3)
+ {
+ theDI << "Error: Give mode[1-4] and Shape name + optional file. Mode possible\n";
+ theDI << "f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
+ << "m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame\n";
+ return 1;
}
-
- if (argc < 3) {
- di<<"Give mode[1-4] and Shape name + optional file. Mode possible\n";
- di<<"f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
- <<"m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame\n";
- return 1; }
- char modeshape = argv[1][0];
STEPControl_StepModelType mode;
- switch (modeshape) {
- case 'a' :
- case '0' : mode = STEPControl_AsIs; break;
- case 'f' :
- case '1' : mode = STEPControl_FacetedBrep; break;
- case 's' :
- case '2' : mode = STEPControl_ShellBasedSurfaceModel; break;
- case 'm' :
- case '3' : mode = STEPControl_ManifoldSolidBrep; break;
- case 'w' :
- case '4' : mode = STEPControl_GeometricCurveSet; break;
- default : di<<"1st arg = mode, incorrect [give fsmw]\n"; return 1;
- }
-
- //:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes)
- Handle(STEPControl_ActorWrite) ActWrite =
- Handle(STEPControl_ActorWrite)::DownCast ( ctl->ActorWrite() );
- if ( ! ActWrite.IsNull() )
- ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly"));
-
- TopoDS_Shape shape = DBRep::Get(argv[2]);
- STEPControl_Writer sw (XSDRAW::Session(),Standard_False);
+ switch (theArgVec[1][0])
+ {
+ case 'a':
+ case '0': mode = STEPControl_AsIs; break;
+ case 'f':
+ case '1': mode = STEPControl_FacetedBrep; break;
+ case 's':
+ case '2': mode = STEPControl_ShellBasedSurfaceModel; break;
+ case 'm':
+ case '3': mode = STEPControl_ManifoldSolidBrep; break;
+ case 'w':
+ case '4': mode = STEPControl_GeometricCurveSet; break;
+ default: theDI << "Error: 1st arg = mode, incorrect [give fsmw]\n"; return 1;
+ }
+ Handle(STEPControl_ActorWrite) ActWrite =
+ Handle(STEPControl_ActorWrite)::DownCast(aWS->NormAdaptor()->ActorWrite());
+ if (!ActWrite.IsNull())
+ ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly"));
+
+ TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
+ STEPControl_Writer sw(aWS, Standard_False);
Handle(Interface_InterfaceModel) stepmodel = sw.Model();
Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
- Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100);
+ Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
+ Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
progress->Show(aPSRoot);
- Standard_Integer stat = sw.Transfer (shape, mode, Standard_True, aPSRoot.Next(90));
+ Standard_Integer stat = sw.Transfer(shape, mode, Standard_True, aPSRoot.Next(90));
if (stat == IFSelect_RetDone)
{
- di << "Translation: OK\n";
- }
- else
+ theDI << "Translation: OK\n";
+ }
+ else
{
- di << "Error: translation failed, status = " << stat << "\n";
+ theDI << "Error: translation failed, status = " << stat << "\n";
}
-
if (aPSRoot.UserBreak())
return 1;
aPSRoot.SetName("Writing");
progress->Show(aPSRoot);
-// Que s est-il passe
+ // Que s est-il passe
stepmodel = sw.Model();
Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
- if (nbavant > 0) di<<"Beware : Model not empty before transferring\n";
- if (nbapres <= nbavant) di<<"Beware : No data produced by this transfer\n";
- if (nbapres == 0) { di<<"No data to write\n"; return 0; }
+ if (nbavant > 0) theDI << "Beware : Model not empty before transferring\n";
+ if (nbapres <= nbavant) theDI << "Beware : No data produced by this transfer\n";
+ if (nbapres == 0) { theDI << "No data to write\n"; return 0; }
- if (argc <= 3) {
- di<<" Now, to write a file, command : writeall filename\n";
+ if (theNbArgs <= 3)
+ {
+ theDI << " Now, to write a file, command : writeall filename\n";
return 0;
}
-
- const char *nomfic = argv[3];
+ const char* nomfic = theArgVec[3];
stat = sw.Write(nomfic);
- switch (stat) {
- case IFSelect_RetVoid : di<<"Error: No file written\n"; break;
- case IFSelect_RetDone : di<<"File "<<nomfic<<" written\n"; break;
- case IFSelect_RetStop : di<<"Error on writing file: no space on disk or destination is write protected\n"; break;
- default : di<<"Error: File "<<nomfic<<" written with fail messages\n"; break;
+ switch (stat)
+ {
+ case IFSelect_RetVoid: theDI << "Error: No file written\n"; return 1;
+ case IFSelect_RetDone: theDI << "File " << nomfic << " written\n"; break;
+ case IFSelect_RetStop: theDI << "Error on writing file: no space on disk or destination is write protected\n"; return 1;
+ default: theDI << "Error: File " << nomfic << " written with fail messages\n"; break;
}
-
+ XSDRAW::CollectActiveWorkSessions(aWS, nomfic, XSDRAW::WorkSessionList());
return 0;
}
+
//=======================================================================
-//function : testwritestep
-//purpose :
+//function : testwrite
+//purpose :
//=======================================================================
-static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer testwrite(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
TCollection_AsciiString aFilePath;
TopoDS_Shape aShape;
bool toTestStream = false;
- for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{
- TCollection_AsciiString anArgCase (argv[anArgIter]);
+ TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
anArgCase.LowerCase();
if (anArgCase == "-stream")
{
}
else if (aFilePath.IsEmpty())
{
- aFilePath = argv[anArgIter];
+ aFilePath = theArgVec[anArgIter];
}
else if (aShape.IsNull())
{
- aShape = DBRep::Get (argv[anArgIter]);
+ aShape = DBRep::Get(theArgVec[anArgIter]);
if (aShape.IsNull())
{
- di << "Syntax error: '" << argv[anArgIter] << "' is not a shape";
+ theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a shape\n";
return 1;
}
}
else
{
- di << "Syntax error: unknown argument '" << argv[anArgIter] << "'";
+ theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n";
return 1;
}
}
if (aShape.IsNull())
{
- di << "Syntax error: wrong number of arguments";
+ theDI << "Syntax error: wrong number of arguments\n";
return 1;
}
STEPControl_Writer aWriter;
- IFSelect_ReturnStatus aStat = aWriter.Transfer (aShape, STEPControl_AsIs);
+ IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape, STEPControl_AsIs);
if (aStat != IFSelect_RetDone)
{
- di << "Error on transferring shape";
+ theDI << "Error on transferring shape\n";
return 1;
}
if (toTestStream)
{
std::ofstream aStream;
- OSD_OpenStream (aStream, aFilePath, std::ios::out | std::ios::binary);
- aStat = aWriter.WriteStream (aStream);
+ OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary);
+ aStat = aWriter.WriteStream(aStream);
aStream.close();
if (!aStream.good()
- && aStat == IFSelect_RetDone)
+ && aStat == IFSelect_RetDone)
{
aStat = IFSelect_RetFail;
}
}
else
{
- aStat = aWriter.Write (aFilePath.ToCString());
+ aStat = aWriter.Write(aFilePath.ToCString());
}
if (aStat != IFSelect_RetDone)
{
- di << "Error on writing file";
- return 1;
+ theDI << "Error on writing file\n";
+ return 1;
}
- di << "File Is Written";
+ theDI << "File Is Written\n";
return 0;
}
//=======================================================================
//function : countexpected
-//purpose :
+//purpose :
//=======================================================================
-
-static Standard_Integer countexpected
- (Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
+static Standard_Integer countexpected(Draw_Interpretor& theDI,
+ Standard_Integer /*theNbArgs*/,
+ const char** /*theArgVec*/)
{
- Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
- Handle(IFSelect_WorkSession) WS = pilot->Session();
- const Interface_Graph& graph = WS->Graph();
-
+ Handle(XSControl_WorkSession) WS = XSDRAW::Session();
+ const Interface_Graph& graph = WS->Graph();
+
Handle(TColStd_HSequenceOfTransient) roots = WS->GiveList("xst-transferrable-roots", "");
STEPSelections_Counter cnt;
-
- for (Standard_Integer i =1 ; i <= roots->Length(); i++) {
- cnt.Count(graph,roots->Value(i));
- }
-
- di<< "Instances of Faces \t: "<<cnt.NbInstancesOfFaces()<<"\n";
- di<< "Instances of Shells\t: "<<cnt.NbInstancesOfShells()<<"\n";
- di<< "Instances of Solids\t: "<<cnt.NbInstancesOfSolids()<<"\n";
- di<< "Instances of Wires in GS\t: "<<cnt.NbInstancesOfWires()<<"\n";
- di<< "Instances of Edges in GS\t: "<<cnt.NbInstancesOfEdges()<<"\n";
-
- di<< "Source Faces \t: "<<cnt.NbSourceFaces()<<"\n";
- di<< "Source Shells\t: "<<cnt.NbSourceShells()<<"\n";
- di<< "Source Solids\t: "<<cnt.NbSourceSolids()<<"\n";
- di<< "Source Wires in GS\t: "<<cnt.NbSourceWires()<<"\n";
- di<< "Source Edges in GS\t: "<<cnt.NbSourceEdges()<<"\n";
-
+
+ for (Standard_Integer i = 1; i <= roots->Length(); i++)
+ {
+ cnt.Count(graph, roots->Value(i));
+ }
+
+ theDI << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n";
+ theDI << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n";
+ theDI << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n";
+ theDI << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n";
+ theDI << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n";
+
+ theDI << "Source Faces \t: " << cnt.NbSourceFaces() << "\n";
+ theDI << "Source Shells\t: " << cnt.NbSourceShells() << "\n";
+ theDI << "Source Solids\t: " << cnt.NbSourceSolids() << "\n";
+ theDI << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n";
+ theDI << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n";
+
return 1;
}
-static Standard_Integer dumpassembly
- (Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char** /*argv*/)
+//=======================================================================
+//function : dumpassembly
+//purpose :
+//=======================================================================
+static Standard_Integer dumpassembly(Draw_Interpretor& /*theDI*/,
+ Standard_Integer /*theNbArgs*/,
+ const char** /*theArgVec*/)
{
- Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
- Handle(IFSelect_WorkSession) WS = pilot->Session();
+ Handle(XSControl_WorkSession) WS = XSDRAW::Session();
const Interface_Graph& graph = WS->Graph();
-
+
STEPSelections_AssemblyExplorer exp(graph);
exp.Dump(std::cout);
return 0;
}
-static Standard_Integer stepfileunits (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+//=======================================================================
+//function : stepfileunits
+//purpose :
+//=======================================================================
+static Standard_Integer stepfileunits(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
-
- if( argc < 2)
+ if (theNbArgs < 2)
{
- di << "Error: Invalid number of parameters. Should be: getfileunits name_file\n";
+ theDI << "Error: Invalid number of parameters. Should be: getfileunits name_file\n";
return 1;
}
STEPControl_Reader aStepReader;
-
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
- readstat = aStepReader.ReadFile (argv[1]);
-
- if (readstat != IFSelect_RetDone) {
-
- di<<"No model loaded\n";
+ readstat = aStepReader.ReadFile(theArgVec[1]);
+ if (readstat != IFSelect_RetDone)
+ {
+ theDI << "No model loaded\n";
return 1;
}
TColStd_SequenceOfAsciiString anUnitLengthNames;
TColStd_SequenceOfAsciiString anUnitAngleNames;
TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
- aStepReader.FileUnits( anUnitLengthNames,anUnitAngleNames,anUnitSolidAngleNames);
-
- Standard_Integer i =1;
- di<<"=====================================================\n";
- di<<"LENGTH Unit\n";
- for( ; i <= anUnitLengthNames.Length() ; i++)
- di<<anUnitLengthNames(i).ToCString()<<"\n";
-
- di<<"=====================================================\n";
- di<<"Angle Unit\n";
- for( i =1 ; i <= anUnitAngleNames.Length() ; i++)
- di<<anUnitAngleNames(i).ToCString()<<"\n";
-
- di<<"=====================================================\n";
- di<<"Solid Angle Unit\n";
- for( i =1 ; i <= anUnitSolidAngleNames.Length() ; i++)
- di<<anUnitSolidAngleNames(i).ToCString()<<"\n";
-
+ aStepReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
+
+ Standard_Integer i = 1;
+ theDI << "=====================================================\n";
+ theDI << "LENGTH Unit\n";
+ for (; i <= anUnitLengthNames.Length(); i++)
+ theDI << anUnitLengthNames(i).ToCString() << "\n";
+
+ theDI << "=====================================================\n";
+ theDI << "Angle Unit\n";
+ for (i = 1; i <= anUnitAngleNames.Length(); i++)
+ theDI << anUnitAngleNames(i).ToCString() << "\n";
+
+ theDI << "=====================================================\n";
+ theDI << "Solid Angle Unit\n";
+ for (i = 1; i <= anUnitSolidAngleNames.Length(); i++)
+ theDI << anUnitSolidAngleNames(i).ToCString() << "\n";
+
+ return 0;
+}
+
+//=======================================================================
+//function : ReadStep
+//purpose : Read STEP file to DECAF document
+//=======================================================================
+static Standard_Integer ReadStep(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ DeclareAndCast(STEPControl_Controller, aController, XSDRAW::Controller());
+ if (aController.IsNull())
+ {
+ XSDRAW::SetNorm("STEP");
+ }
+
+ Standard_CString aDocumentName = NULL;
+ TCollection_AsciiString aFilePath, aModeStr;
+ bool toTestStream = false;
+
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+
+ if (anArgCase == "-stream")
+ {
+ toTestStream = true;
+ }
+ else if (aDocumentName == NULL)
+ {
+ aDocumentName = theArgVec[anArgIter];
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else if (aModeStr.IsEmpty())
+ {
+ aModeStr = theArgVec[anArgIter];
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+
+ TCollection_AsciiString aFileName, anOldVarName;
+ Standard_Boolean isFileMode = XSDRAW::FileAndVar(aFilePath.ToCString(), aDocumentName, "STEP", aFileName, anOldVarName);
+
+ if (isFileMode)
+ {
+ theDI << " File STEP to read : " << aFileName << "\n";
+ }
+ else
+ {
+ theDI << " Model taken from the session : " << aFileName << "\n";
+ }
+
+ STEPCAFControl_Reader aReader(XSDRAW::Session(), isFileMode);
+
+ if (!aModeStr.IsEmpty())
+ {
+ Standard_Boolean aMode = Standard_True;
+
+ for (Standard_Integer i = 1; aModeStr.Value(i); ++i)
+ {
+ switch (aModeStr.Value(i))
+ {
+ case '-':
+ aMode = Standard_False;
+ break;
+ case '+':
+ aMode = Standard_True;
+ break;
+ case 'c':
+ aReader.SetColorMode(aMode);
+ break;
+ case 'n':
+ aReader.SetNameMode(aMode);
+ break;
+ case 'l':
+ aReader.SetLayerMode(aMode);
+ break;
+ case 'v':
+ aReader.SetPropsMode(aMode);
+ break;
+ default:
+ Message::SendFail() << "Syntax error at '" << aModeStr << "'\n";
+ return 1;
+ }
+ }
+ }
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
+ Message_ProgressScope aRootScope(aProgress->Start(), "STEP import", isFileMode ? 2 : 1);
+
+ IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid;
+
+ if (isFileMode)
+ {
+ Message_ProgressScope aReadScope(aRootScope.Next(), "File reading", 1);
+ aReadScope.Show();
+
+ if (toTestStream)
+ {
+ std::ifstream aStream;
+ OSD_OpenStream(aStream, aFileName.ToCString(), std::ios::in | std::ios::binary);
+ TCollection_AsciiString aFolder, aFileNameShort;
+ OSD_Path::FolderAndFileFromPath(aFileName, aFolder, aFileNameShort);
+ aReadStat = aReader.ReadStream(aFileNameShort.ToCString(), aStream);
+ }
+ else
+ {
+ aReadStat = aReader.ReadFile(aFileName.ToCString());
+ }
+ }
+ else if (XSDRAW::Session()->NbStartingEntities() > 0)
+ {
+ aReadStat = IFSelect_RetDone;
+ }
+
+ if (aReadStat != IFSelect_RetDone)
+ {
+ if (isFileMode)
+ {
+ theDI << "Could not read file " << aFileName << " , abandon\n";
+ }
+ else
+ {
+ theDI << "No model loaded\n";
+ }
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDocument;
+
+ if (!DDocStd::GetDocument(aDocumentName, aDocument, Standard_False))
+ {
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ anApp->NewDocument("BinXCAF", aDocument);
+ TDataStd_Name::Set(aDocument->GetData()->Root(), aDocumentName);
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDocument);
+ Draw::Set(aDocumentName, aDrawDoc);
+ }
+
+ if (!aReader.Transfer(aDocument, aRootScope.Next()))
+ {
+ theDI << "Cannot read any relevant data from the STEP file\n";
+ return 1;
+ }
+
+ Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDocument);
+ Draw::Set(aDocumentName, aDrawDoc);
+
+ theDI << "Document saved with name " << aDocumentName;
+
+ XSDRAW::CollectActiveWorkSessions(aFilePath);
+ for (ExternalFileMap::Iterator anIter(aReader.ExternFiles()); anIter.More(); anIter.Next())
+ {
+ XSDRAW::CollectActiveWorkSessions(anIter.Value()->GetWS(), anIter.Key(), XSDRAW::WorkSessionList());
+ }
+
return 0;
}
-// ######## COMMANDE stepwrite : teste le Writer #########
-void XSDRAWSTEP::InitCommands (Draw_Interpretor& theCommands)
+//=======================================================================
+//function : WriteStep
+//purpose : Write DECAF document to STEP
+//=======================================================================
+static Standard_Integer WriteStep(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
{
- const char* g = "DE: STEP"; // Step transfer file commands
- XSDRAWSTEP::Init();
- XSDRAW::LoadDraw(theCommands);
- theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
- theCommands.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
- __FILE__, testwrite, g);
- theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g);
- theCommands.Add("testreadstep", "testreadstep file shape [-stream]",__FILE__, testreadstep, g);
- theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
- theCommands.Add("countexpected","TEST", __FILE__, countexpected, g);
- theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);
- theCommands.Add("stepfileunits" , "stepfileunits name_file", __FILE__, stepfileunits, g);
+ DeclareAndCast(STEPControl_Controller, aController, XSDRAW::Controller());
+ if (aController.IsNull())
+ {
+ XSDRAW::SetNorm("STEP");
+ }
+
+ STEPCAFControl_Writer aWriter(XSDRAW::Session(), Standard_True);
+
+ Handle(TDocStd_Document) aDocument;
+ TCollection_AsciiString aDocumentName, aFilePath;
+ STEPControl_StepModelType aMode = STEPControl_AsIs;
+ bool hasModeArg = false, toTestStream = false;
+ TCollection_AsciiString aMultiFilePrefix, aLabelName;
+ TDF_Label aLabel;
+
+ for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
+ {
+ TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
+ anArgCase.LowerCase();
+
+ if (anArgCase == "-stream")
+ {
+ toTestStream = true;
+ }
+ else if (aDocumentName.IsEmpty())
+ {
+ Standard_CString aDocNameStr = theArgVec[anArgIter];
+ DDocStd::GetDocument(aDocNameStr, aDocument);
+
+ if (aDocument.IsNull())
+ {
+ theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a document";
+ return 1;
+ }
+
+ aDocumentName = aDocNameStr;
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgVec[anArgIter];
+ }
+ else if (!hasModeArg)
+ {
+ hasModeArg = true;
+
+ switch (anArgCase.Value(1))
+ {
+ case 'a':
+ case '0':
+ aMode = STEPControl_AsIs;
+ break;
+ case 'f':
+ case '1':
+ aMode = STEPControl_FacetedBrep;
+ break;
+ case 's':
+ case '2':
+ aMode = STEPControl_ShellBasedSurfaceModel;
+ break;
+ case 'm':
+ case '3':
+ aMode = STEPControl_ManifoldSolidBrep;
+ break;
+ case 'w':
+ case '4':
+ aMode = STEPControl_GeometricCurveSet;
+ break;
+ default:
+ {
+ theDI << "Syntax error: mode '" << theArgVec[anArgIter] << "' is incorrect [give fsmw]";
+ return 1;
+ }
+ }
+
+ Standard_Boolean wrmode = Standard_True;
+
+ for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i)
+ {
+ switch (anArgCase.Value(i))
+ {
+ case '-':
+ wrmode = Standard_False;
+ break;
+ case '+':
+ wrmode = Standard_True;
+ break;
+ case 'c':
+ aWriter.SetColorMode(wrmode);
+ break;
+ case 'n':
+ aWriter.SetNameMode(wrmode);
+ break;
+ case 'l':
+ aWriter.SetLayerMode(wrmode);
+ break;
+ case 'v':
+ aWriter.SetPropsMode(wrmode);
+ break;
+ }
+ }
+ }
+ else if (aMultiFilePrefix.IsEmpty() && anArgCase.Search(":") == -1)
+ {
+ aMultiFilePrefix = theArgVec[anArgIter];
+ }
+ else if (aLabel.IsNull())
+ {
+ if (!DDF::FindLabel(aDocument->Main().Data(), theArgVec[anArgIter], aLabel) || aLabel.IsNull())
+ {
+ theDI << "Syntax error: No label for entry '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+
+ aLabelName = theArgVec[anArgIter];
+ }
+ else
+ {
+ theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
+ return 1;
+ }
+ }
+
+ if (aFilePath.IsEmpty())
+ {
+ theDI << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ TCollection_AsciiString aFileName, anOldVarName;
+ const Standard_Boolean isFileMode = XSDRAW::FileAndVar(aFilePath.ToCString(), aDocumentName.ToCString(), "STEP", aFileName, anOldVarName);
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
+ Message_ProgressScope aRootScope(aProgress->Start(), "STEP export", isFileMode ? 2 : 1);
+
+ if (!aLabel.IsNull())
+ {
+ theDI << "Translating label " << aLabelName << " of document " << aDocumentName << " to STEP\n";
+
+ if (!aWriter.Transfer(aLabel, aMode,
+ !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
+ aRootScope.Next()))
+ {
+ theDI << "Error: the label of document cannot be translated or gives no result";
+ return 1;
+ }
+ }
+ else
+ {
+ theDI << "Translating document " << aDocumentName << " to STEP\n";
+
+ if (!aWriter.Transfer(aDocument, aMode,
+ !aMultiFilePrefix.IsEmpty() ? aMultiFilePrefix.ToCString() : NULL,
+ aRootScope.Next()))
+ {
+ theDI << "Error: The document cannot be translated or gives no result\n";
+ }
+ }
+
+ if (!isFileMode)
+ {
+ theDI << "Document has been translated into the session";
+ return 0;
+ }
+
+ Message_ProgressScope aWriteScope(aRootScope.Next(), "File writing", 1);
+ aWriteScope.Show();
+ theDI << "Writing STEP file " << aFilePath << "\n";
+
+ IFSelect_ReturnStatus aStat = IFSelect_RetVoid;
+
+ if (toTestStream)
+ {
+ std::ofstream aStream;
+ OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary);
+ aStat = aWriter.WriteStream(aStream);
+ aStream.close();
+
+ if (!aStream.good() && aStat == IFSelect_RetDone)
+ {
+ aStat = IFSelect_RetFail;
+ }
+ }
+ else
+ {
+ aStat = aWriter.Write(aFilePath.ToCString());
+ }
+
+ switch (aStat)
+ {
+ case IFSelect_RetVoid:
+ {
+ theDI << "Error: no file written";
+ break;
+ }
+ case IFSelect_RetDone:
+ {
+ theDI << "File " << aFilePath << " written\n";
+
+ XSDRAW::CollectActiveWorkSessions(aFilePath);
+ for (ExternalFileMap::Iterator anIter(aWriter.ExternFiles()); anIter.More(); anIter.Next())
+ {
+ XSDRAW::CollectActiveWorkSessions(anIter.Value()->GetWS(), anIter.Key(), XSDRAW::WorkSessionList());
+ }
+ break;
+ }
+ default:
+ {
+ theDI << "Error on writing file";
+ break;
+ }
+ }
+ return 0;
}
+
+//=======================================================================
+//function : Factory
+//purpose :
+//=======================================================================
+void XSDRAWSTEP::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ const char* aGroup = "DE: STEP"; // Step transfer file commands
+ theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, aGroup);
+ theDI.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
+ __FILE__, testwrite, aGroup);
+ theDI.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, aGroup);
+ theDI.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, aGroup);
+ theDI.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, aGroup);
+ theDI.Add("countexpected", "TEST", __FILE__, countexpected, aGroup);
+ theDI.Add("dumpassembly", "TEST", __FILE__, dumpassembly, aGroup);
+ theDI.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, aGroup);
+ theDI.Add("ReadStep",
+ "Doc filename [mode] [-stream]"
+ "\n\t\t: Read STEP file to a document."
+ "\n\t\t: -stream read using istream reading interface (testing)",
+ __FILE__, ReadStep, aGroup);
+ theDI.Add("WriteStep",
+ "Doc filename [mode=a [multifile_prefix] [label]] [-stream]"
+ "\n\t\t: Write DECAF document to STEP file"
+ "\n\t\t: mode can be: a or 0 : AsIs (default)"
+ "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel"
+ "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame"
+ "\n\t\t: multifile_prefix: triggers writing assembly components as separate files,"
+ "\n\t\t: and defines common prefix for their names"
+ "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly"
+ "\n\t\t: -stream read using ostream writing interface (testing)",
+ __FILE__, WriteStep, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWSTEP)
-// Created on: 1996-01-12
-// Created by: Christian CAILLET
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
+// Copyright (c) 2023 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
#include <Draw_Interpretor.hxx>
-
-//! XSDRAW for STEP AP214 and AP203
-class XSDRAWSTEP
+class XSDRAWSTEP
{
-public:
-
DEFINE_STANDARD_ALLOC
+public:
-
- Standard_EXPORT static void Init();
-
- //! Inits commands to access product data and to write shapes
- Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands);
-
-
-
-
-protected:
-
-
-
-
-
-private:
-
-
-
-
-
+ //! Loads all Draw commands of XSDRAWSTEP. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
};
-
-
-
-
-
-
#endif // _XSDRAWSTEP_HeaderFile
--- /dev/null
+XSDRAWSTL.cxx
+XSDRAWSTL.hxx
+XSDRAWSTL_DataSource.cxx
+XSDRAWSTL_DataSource.hxx
+XSDRAWSTL_DataSource3D.cxx
+XSDRAWSTL_DataSource3D.hxx
+XSDRAWSTL_DrawableMesh.cxx
+XSDRAWSTL_DrawableMesh.hxx
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWSTL.hxx>
+
+#include <AIS_InteractiveContext.hxx>
+#include <BRep_Builder.hxx>
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <MeshVS_DeformedDataSource.hxx>
+#include <MeshVS_Drawer.hxx>
+#include <MeshVS_DrawerAttribute.hxx>
+#include <MeshVS_ElementalColorPrsBuilder.hxx>
+#include <MeshVS_Mesh.hxx>
+#include <MeshVS_MeshEntityOwner.hxx>
+#include <MeshVS_MeshPrsBuilder.hxx>
+#include <MeshVS_NodalColorPrsBuilder.hxx>
+#include <MeshVS_TextPrsBuilder.hxx>
+#include <MeshVS_VectorPrsBuilder.hxx>
+#include <RWStl.hxx>
+#include <StlAPI.hxx>
+#include <StlAPI_Writer.hxx>
+#include <TColStd_HPackedMapOfInteger.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+#include <ViewerTest.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+#include <XSDRAWSTL_DataSource.hxx>
+#include <XSDRAWSTL_DataSource3D.hxx>
+#include <XSDRAWSTL_DrawableMesh.hxx>
+
+extern Standard_Boolean VDisplayAISObject(const TCollection_AsciiString& theName,
+ const Handle(AIS_InteractiveObject)& theAISObj,
+ Standard_Boolean theReplaceIfExists = Standard_True);
+
+//=============================================================================
+//function : writestl
+//purpose :
+//=============================================================================
+static Standard_Integer writestl
+(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3 || argc > 4) {
+ di << "Use: " << argv[0]
+ << " shape file [ascii/binary (0/1) : 1 by default]\n";
+ } else {
+ TopoDS_Shape aShape = DBRep::Get(argv[1]);
+ Standard_Boolean isASCIIMode = Standard_False;
+ if (argc == 4) {
+ isASCIIMode = (Draw::Atoi(argv[3]) == 0);
+ }
+ StlAPI_Writer aWriter;
+ aWriter.ASCIIMode() = isASCIIMode;
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
+ Standard_Boolean isOK = aWriter.Write (aShape, argv[2], aProgress->Start());
+ if (!isOK)
+ di << "** Error **: Mesh writing has been failed.\n";
+ }
+ return 0;
+}
+
+//=============================================================================
+//function : readstl
+//purpose : Reads stl file
+//=============================================================================
+static Standard_Integer readstl(Draw_Interpretor& theDI,
+ Standard_Integer theArgc,
+ const char** theArgv)
+{
+ TCollection_AsciiString aShapeName, aFilePath;
+ bool toCreateCompOfTris = false;
+ bool anIsMulti = false;
+ double aMergeAngle = M_PI / 2.0;
+ for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
+ {
+ TCollection_AsciiString anArg (theArgv[anArgIter]);
+ anArg.LowerCase();
+ if (aShapeName.IsEmpty())
+ {
+ aShapeName = theArgv[anArgIter];
+ }
+ else if (aFilePath.IsEmpty())
+ {
+ aFilePath = theArgv[anArgIter];
+ }
+ else if (anArg == "-brep")
+ {
+ toCreateCompOfTris = true;
+ if (anArgIter + 1 < theArgc
+ && Draw::ParseOnOff (theArgv[anArgIter + 1], toCreateCompOfTris))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArg == "-multi")
+ {
+ anIsMulti = true;
+ if (anArgIter + 1 < theArgc
+ && Draw::ParseOnOff (theArgv[anArgIter + 1], anIsMulti))
+ {
+ ++anArgIter;
+ }
+ }
+ else if (anArg == "-mergeangle"
+ || anArg == "-smoothangle"
+ || anArg == "-nomergeangle"
+ || anArg == "-nosmoothangle")
+ {
+ if (anArg.StartsWith ("-no"))
+ {
+ aMergeAngle = M_PI / 2.0;
+ }
+ else
+ {
+ aMergeAngle = M_PI / 4.0;
+ if (anArgIter + 1 < theArgc
+ && Draw::ParseReal (theArgv[anArgIter + 1], aMergeAngle))
+ {
+ if (aMergeAngle < 0.0 || aMergeAngle > 90.0)
+ {
+ theDI << "Syntax error: angle should be within [0,90] range";
+ return 1;
+ }
+
+ ++anArgIter;
+ aMergeAngle = aMergeAngle * M_PI / 180.0;
+ }
+ }
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'";
+ return 1;
+ }
+ }
+ if (aFilePath.IsEmpty())
+ {
+ Message::SendFail() << "Syntax error: not enough arguments";
+ return 1;
+ }
+
+ TopoDS_Shape aShape;
+ if (!toCreateCompOfTris)
+ {
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI,1);
+ if(anIsMulti)
+ {
+ NCollection_Sequence<Handle(Poly_Triangulation)> aTriangList;
+ // Read STL file to the triangulation list.
+ RWStl::ReadFile(aFilePath.ToCString(),aMergeAngle,aTriangList,aProgress->Start());
+ BRep_Builder aB;
+ TopoDS_Face aFace;
+ if (aTriangList.Size() == 1)
+ {
+ aB.MakeFace (aFace);
+ aB.UpdateFace (aFace,aTriangList.First());
+ aShape = aFace;
+ }
+ else
+ {
+ TopoDS_Compound aCmp;
+ aB.MakeCompound (aCmp);
+
+ NCollection_Sequence<Handle(Poly_Triangulation)>::Iterator anIt (aTriangList);
+ for (; anIt.More(); anIt.Next())
+ {
+ aB.MakeFace (aFace);
+ aB.UpdateFace (aFace,anIt.Value());
+ aB.Add (aCmp,aFace);
+ }
+ aShape = aCmp;
+ }
+ }
+ else
+ {
+ // Read STL file to the triangulation.
+ Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile (aFilePath.ToCString(),aMergeAngle,aProgress->Start());
+
+ TopoDS_Face aFace;
+ BRep_Builder aB;
+ aB.MakeFace (aFace);
+ aB.UpdateFace (aFace,aTriangulation);
+ aShape = aFace;
+ }
+ }
+ else
+ {
+ Standard_DISABLE_DEPRECATION_WARNINGS
+ StlAPI::Read(aShape, aFilePath.ToCString());
+ Standard_ENABLE_DEPRECATION_WARNINGS
+ }
+ DBRep::Set (aShapeName.ToCString(), aShape);
+ return 0;
+}
+
+//=======================================================================
+//function : createmesh
+//purpose :
+//=======================================================================
+static Standard_Integer createmesh(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 3)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use: " << theArgVec[0] << " <mesh name> <stl file>\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ theDI << "No active view. Please call 'vinit' first\n";
+ return 0;
+ }
+
+ // Progress indicator
+ OSD_Path aFile(theArgVec[2]);
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+ Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(aFile, aProgress->Start());
+
+ theDI << "Reading OK...\n";
+ Handle(XSDRAWSTL_DataSource) aDS = new XSDRAWSTL_DataSource(aSTLMesh);
+ theDI << "Data source is created successful\n";
+ Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();
+ theDI << "MeshVS_Mesh is created successful\n";
+
+ aMesh->SetDataSource(aDS);
+ aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);
+
+ aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
+
+ // Hide all nodes by default
+ Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
+ const Standard_Integer aLen = aSTLMesh->NbNodes();
+ for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+ aNodes->ChangeMap().Add(anIndex);
+ aMesh->SetHiddenNodes(aNodes);
+ aMesh->SetSelectableNodes(aNodes);
+
+ VDisplayAISObject(theArgVec[1], aMesh);
+ aContext->Deactivate(aMesh);
+
+ Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh));
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (!aView.IsNull())
+ aView->FitAll();
+
+ return 0;
+}
+
+//=======================================================================
+//function : create3d
+//purpose :
+//=======================================================================
+static Standard_Integer create3d(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ theDI << "No active view. Please call 'vinit' first\n";
+ return 0;
+ }
+
+ Handle(XSDRAWSTL_DataSource3D) aDS = new XSDRAWSTL_DataSource3D();
+ theDI << "Data source is created successful\n";
+ Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();
+ theDI << "MeshVS_Mesh is created successful\n";
+
+ aMesh->SetDataSource(aDS);
+ aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);
+
+ aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW);
+
+ // Hide all nodes by default
+ Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
+ Standard_Integer aLen = aDS->GetAllNodes().Extent();
+ for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+ aNodes->ChangeMap().Add(anIndex);
+ aMesh->SetHiddenNodes(aNodes);
+ aMesh->SetSelectableNodes(aNodes);
+
+ VDisplayAISObject(theArgVec[1], aMesh);
+ aContext->Deactivate(aMesh);
+
+ Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh));
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (!aView.IsNull())
+ aView->FitAll();
+
+ return 0;
+}
+
+//=======================================================================
+//function : getMesh
+//purpose :
+//=======================================================================
+Handle(MeshVS_Mesh) getMesh(const char* theName,
+ Draw_Interpretor& theDI)
+{
+ Handle(XSDRAWSTL_DrawableMesh) aDrawMesh =
+ Handle(XSDRAWSTL_DrawableMesh)::DownCast(Draw::Get(theName));
+
+ if (aDrawMesh.IsNull())
+ {
+ theDI << "There is no such object\n";
+ return NULL;
+ }
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = aDrawMesh->GetMesh();
+ if (aMesh.IsNull())
+ {
+ theDI << "There is invalid mesh\n";
+ return NULL;
+ }
+ else
+ return aMesh;
+ }
+}
+
+//=======================================================================
+//function : setcolor
+//purpose :
+//=======================================================================
+static Standard_Integer setcolor(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec,
+ Standard_Integer theParam)
+{
+ if (theNbArgs < 5)
+ theDI << "Wrong number of parameters\n";
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Standard_Real aRed = Draw::Atof(theArgVec[2]);
+ Standard_Real aGreen = Draw::Atof(theArgVec[3]);
+ Standard_Real aBlue = Draw::Atof(theArgVec[4]);
+ aMesh->GetDrawer()->SetColor((MeshVS_DrawerAttribute)theParam,
+ Quantity_Color(aRed, aGreen, aBlue, Quantity_TOC_RGB));
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : meshcolor
+//purpose :
+//=======================================================================
+static Standard_Integer meshcolor(Draw_Interpretor& theInterp,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_InteriorColor);
+}
+
+//=======================================================================
+//function : linecolor
+//purpose :
+//=======================================================================
+static Standard_Integer linecolor(Draw_Interpretor& theInterp,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_EdgeColor);
+}
+
+//=======================================================================
+//function : meshmat
+//purpose :
+//=======================================================================
+static Standard_Integer meshmat(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 3)
+ theDI << "Wrong number of parameters\n";
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Standard_Integer aMaterial = Draw::Atoi(theArgVec[2]);
+
+ Graphic3d_MaterialAspect aMatAsp =
+ (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial;
+
+ if (theNbArgs == 4)
+ {
+ Standard_Real aTransparency = Draw::Atof(theArgVec[3]);
+ aMatAsp.SetTransparency(Standard_ShortReal(aTransparency));
+ }
+ aMesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, aMatAsp);
+ aMesh->GetDrawer()->SetMaterial(MeshVS_DA_BackMaterial, aMatAsp);
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : shrink
+//purpose :
+//=======================================================================
+static Standard_Integer shrink(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 3)
+ theDI << "Wrong number of parameters\n";
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Standard_Real aShrinkCoeff = Draw::Atof(theArgVec[2]);
+ aMesh->GetDrawer()->SetDouble(MeshVS_DA_ShrinkCoeff, aShrinkCoeff);
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : closed
+//purpose :
+//=======================================================================
+static Standard_Integer closed(Draw_Interpretor& theDI,
+ Standard_Integer theArgc,
+ const char** theArgv)
+{
+ if (theArgc < 3)
+ {
+ theDI << "Wrong number of parameters.\n";
+ }
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgv[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Standard_Boolean aFlag = Draw::Atoi(theArgv[2]) != 0;
+ aMesh->GetDrawer()->SetBoolean(MeshVS_DA_SupressBackFaces, aFlag);
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ if (aContext.IsNull())
+ {
+ theDI << "The context is null\n";
+ }
+ else
+ {
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : mdisplay
+//purpose :
+//=======================================================================
+static Standard_Integer mdisplay(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ theDI << "Wrong number of parameters\n";
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ {
+ aContext->Display(aMesh, Standard_True);
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : merase
+//purpose :
+//=======================================================================
+static Standard_Integer merase(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ theDI << "Wrong number of parameters\n";
+ else
+ {
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (!aMesh.IsNull())
+ {
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ {
+ aContext->Erase(aMesh, Standard_True);
+ }
+ }
+ else
+ theDI << "Mesh is null\n";
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : hidesel
+//purpose :
+//=======================================================================
+static Standard_Integer hidesel(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (aMesh.IsNull())
+ {
+ theDI << "The mesh is invalid\n";
+ return 0;
+ }
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ {
+ Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
+ if (aHiddenNodes.IsNull())
+ {
+ aHiddenNodes = new TColStd_HPackedMapOfInteger();
+ }
+ Handle(TColStd_HPackedMapOfInteger) aHiddenElements = aMesh->GetHiddenElems();
+ if (aHiddenElements.IsNull())
+ {
+ aHiddenElements = new TColStd_HPackedMapOfInteger();
+ }
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ {
+ Handle(MeshVS_MeshEntityOwner) anOwner =
+ Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner());
+ if (!anOwner.IsNull())
+ {
+ if (anOwner->Type() == MeshVS_ET_Node)
+ {
+ aHiddenNodes->ChangeMap().Add(anOwner->ID());
+ }
+ else
+ {
+ aHiddenElements->ChangeMap().Add(anOwner->ID());
+ }
+ }
+ }
+ aContext->ClearSelected(Standard_False);
+ aMesh->SetHiddenNodes(aHiddenNodes);
+ aMesh->SetHiddenElems(aHiddenElements);
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : showonly
+//purpose :
+//=======================================================================
+static Standard_Integer showonly(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (aMesh.IsNull())
+ {
+ theDI << "The mesh is invalid\n";
+ return 0;
+ }
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ {
+ Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
+ new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
+ Handle(TColStd_HPackedMapOfInteger) aHiddenElements =
+ new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements());
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ {
+ Handle(MeshVS_MeshEntityOwner) anOwner =
+ Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner());
+ if (!anOwner.IsNull())
+ {
+ if (anOwner->Type() == MeshVS_ET_Node)
+ {
+ aHiddenNodes->ChangeMap().Remove(anOwner->ID());
+ }
+ else
+ {
+ aHiddenElements->ChangeMap().Remove(anOwner->ID());
+ }
+ }
+ }
+ aMesh->SetHiddenNodes(aHiddenNodes);
+ aMesh->SetHiddenElems(aHiddenElements);
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : showonly
+//purpose :
+//=======================================================================
+static Standard_Integer showall(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use: " << theArgVec[0] << " <mesh name>\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (aMesh.IsNull())
+ {
+ theDI << "The mesh is invalid\n";
+ return 0;
+ }
+
+ if (aContext.IsNull())
+ theDI << "The context is null\n";
+ else
+ {
+ aMesh->SetHiddenNodes(new TColStd_HPackedMapOfInteger());
+ aMesh->SetHiddenElems(new TColStd_HPackedMapOfInteger());
+ aContext->Redisplay(aMesh, Standard_True);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : meshcolors
+//purpose :
+//=======================================================================
+static Standard_Integer meshcolors(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ try
+ {
+ OCC_CATCH_SIGNALS
+ if (theNbArgs < 4)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use : meshcolors <mesh name> <mode> <isreflect>\n";
+ theDI << "mode : {elem1|elem2|nodal|nodaltex|none}\n";
+ theDI << " elem1 - different color for each element\n";
+ theDI << " elem2 - one color for one side\n";
+ theDI << " nodal - different color for each node\n";
+ theDI << " nodaltex - different color for each node with texture interpolation\n";
+ theDI << " none - clear\n";
+ theDI << "isreflect : {0|1} \n";
+
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+ Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+ if (anIC.IsNull())
+ {
+ theDI << "The context is null\n";
+ return 0;
+ }
+ if (!aMesh.IsNull())
+ {
+ TCollection_AsciiString aMode = TCollection_AsciiString(theArgVec[2]);
+ Quantity_Color aColor1(Quantity_NOC_BLUE1);
+ Quantity_Color aColor2(Quantity_NOC_RED1);
+ if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none"))
+ {
+ Handle(MeshVS_PrsBuilder) aTempBuilder;
+ Standard_Integer aReflection = Draw::Atoi(theArgVec[3]);
+
+ for (Standard_Integer aCount = 0; aCount < aMesh->GetBuildersCount(); aCount++)
+ {
+ aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
+ if (!aTempBuilder.IsNull())
+ aMesh->RemoveBuilderById(aTempBuilder->GetId());
+
+ aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
+ if (!aTempBuilder.IsNull())
+ aMesh->RemoveBuilderById(aTempBuilder->GetId());
+ }
+
+ if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2"))
+ {
+ Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
+ aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask);
+ // Color
+ const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
+
+ if (aMode.IsEqual("elem1"))
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements);
+ anIter.More(); anIter.Next())
+ {
+ Quantity_Color aColor((Quantity_NameOfColor)(anIter.Key() % Quantity_NOC_WHITE));
+ aBuilder->SetColor1(anIter.Key(), aColor);
+ }
+ else
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements);
+ anIter.More(); anIter.Next())
+ {
+ aBuilder->SetColor2(anIter.Key(), aColor1, aColor2);
+ }
+
+ aMesh->AddBuilder(aBuilder, Standard_True);
+ }
+
+ if (aMode.IsEqual("nodal"))
+ {
+ Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
+ aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
+ aMesh->AddBuilder(aBuilder, Standard_True);
+
+ // Color
+ const TColStd_PackedMapOfInteger& anAllNodes =
+ aMesh->GetDataSource()->GetAllNodes();
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllNodes);
+ anIter.More(); anIter.Next())
+ {
+ Quantity_Color aColor((Quantity_NameOfColor)(
+ anIter.Key() % Quantity_NOC_WHITE));
+ aBuilder->SetColor(anIter.Key(), aColor);
+ }
+ aMesh->AddBuilder(aBuilder, Standard_True);
+ }
+
+ if (aMode.IsEqual("nodaltex"))
+ {
+ // assign nodal builder to the mesh
+ Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
+ aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
+ aMesh->AddBuilder(aBuilder, Standard_True);
+ aBuilder->UseTexture(Standard_True);
+
+ // prepare color map for texture
+ Aspect_SequenceOfColor aColorMap;
+ aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_RED);
+ aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_YELLOW);
+ aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_BLUE1);
+
+ // prepare scale map for mesh - it will be assigned to mesh as texture coordinates
+ // make mesh color interpolated from minimum X coord to maximum X coord
+ Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource();
+ Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
+
+ // get bounding box for calculations
+ aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
+ Standard_Real aDelta = aMaxX - aMinX;
+
+ // assign color scale map values (0..1) to nodes
+ TColStd_DataMapOfIntegerReal aScaleMap;
+ TColStd_Array1OfReal aCoords(1, 3);
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aType;
+
+ // iterate nodes
+ const TColStd_PackedMapOfInteger& anAllNodes =
+ aMesh->GetDataSource()->GetAllNodes();
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllNodes);
+ anIter.More(); anIter.Next())
+ {
+ //get node coordinates to aCoord variable
+ aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
+
+ Standard_Real aScaleValue;
+ try
+ {
+ OCC_CATCH_SIGNALS
+ aScaleValue = (aCoords.Value(1) - (Standard_Real)aMinX) / aDelta;
+ }
+ catch (Standard_Failure const&)
+ {
+ aScaleValue = 0;
+ }
+
+ aScaleMap.Bind(anIter.Key(), aScaleValue);
+ }
+
+ //set color map for builder and a color for invalid scale value
+ aBuilder->SetColorMap(aColorMap);
+ aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
+ aBuilder->SetTextureCoords(aScaleMap);
+ aMesh->AddBuilder(aBuilder, Standard_True);
+ }
+
+ aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, aReflection != 0);
+
+ anIC->Redisplay(aMesh, Standard_True);
+ }
+ else
+ {
+ theDI << "Wrong mode name\n";
+ return 0;
+ }
+ }
+ }
+ catch (Standard_Failure const&)
+ {
+ theDI << "Error\n";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : meshvectors
+//purpose :
+//=======================================================================
+static Standard_Integer meshvectors(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 3)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n";
+ theDI << "Supported mode values:\n";
+ theDI << " elem - vector per element\n";
+ theDI << " nodal - vector per node\n";
+ theDI << " none - clear\n";
+
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+ Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+ if (anIC.IsNull())
+ {
+ theDI << "The context is null\n";
+ return 0;
+ }
+
+ TCollection_AsciiString aParam;
+ TCollection_AsciiString aMode("none");
+ Standard_Real aMaxlen(1.0);
+ Quantity_Color aColor(Quantity_NOC_ORANGE);
+ Standard_Real anArrowPart(0.1);
+ Standard_Boolean isSimplePrs(Standard_False);
+
+ for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++)
+ {
+ if (!aParam.IsEmpty())
+ {
+ if (aParam == "-mode")
+ {
+ aMode = theArgVec[anIdx];
+ }
+ else if (aParam == "-maxlen")
+ {
+ aMaxlen = Draw::Atof(theArgVec[anIdx]);
+ }
+ else if (aParam == "-color")
+ {
+ if (!Quantity_Color::ColorFromName(theArgVec[anIdx], aColor))
+ {
+ theDI << "Syntax error at " << aParam << "\n";
+ return 1;
+ }
+ }
+ else if (aParam == "-arrowpart")
+ {
+ anArrowPart = Draw::Atof(theArgVec[anIdx]);
+ }
+ else if (aParam == "-issimple")
+ {
+ isSimplePrs = Draw::Atoi(theArgVec[anIdx]) != 0;
+ }
+ aParam.Clear();
+ }
+ else if (theArgVec[anIdx][0] == '-')
+ {
+ aParam = theArgVec[anIdx];
+ }
+ }
+
+ if (!aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none"))
+ {
+ theDI << "Wrong mode name\n";
+ return 0;
+ }
+
+ Handle(MeshVS_PrsBuilder) aTempBuilder;
+
+ aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder");
+ if (!aTempBuilder.IsNull())
+ aMesh->RemoveBuilderById(aTempBuilder->GetId());
+
+ if (!aMode.IsEqual("none"))
+ {
+ Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder(aMesh.operator->(),
+ aMaxlen,
+ aColor,
+ MeshVS_DMF_VectorDataPrs,
+ 0,
+ -1,
+ MeshVS_BP_Vector,
+ isSimplePrs);
+
+ Standard_Boolean anIsElement = aMode.IsEqual("elem");
+ const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() :
+ aMesh->GetDataSource()->GetAllNodes();
+
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aEntType;
+
+ TColStd_Array1OfReal aCoords(1, 3);
+ aCoords.Init(0.);
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllIDs);
+ anIter.More(); anIter.Next())
+ {
+ Standard_Boolean IsValidData = Standard_False;
+ if (anIsElement)
+ {
+ aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType);
+ if (aEntType == MeshVS_ET_Face)
+ IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
+ }
+ else
+ IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
+
+ gp_Vec aNorm;
+ if (IsValidData)
+ {
+ aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
+ if (aNorm.Magnitude() < gp::Resolution())
+ {
+ aNorm = gp_Vec(0, 0, 1); //method GetGeom(...) returns coordinates of nodes
+ }
+ }
+ else
+ {
+ aNorm = gp_Vec(0, 0, 1);
+ }
+ aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
+ }
+
+ aMesh->AddBuilder(aBuilder, Standard_False);
+ aMesh->GetDrawer()->SetDouble(MeshVS_DA_VectorArrowPart, anArrowPart);
+ }
+
+ anIC->Redisplay(aMesh, Standard_True);
+
+ return 0;
+}
+
+//=======================================================================
+//function : meshtext
+//purpose :
+//=======================================================================
+static Standard_Integer meshtext(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 2)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use : meshtext <mesh name>\n";
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+
+ Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+ if (anIC.IsNull())
+ {
+ theDI << "The context is null\n";
+ return 0;
+ }
+
+ // Prepare triangle labels
+ MeshVS_DataMapOfIntegerAsciiString aLabels;
+ Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent();
+ for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++)
+ {
+ aLabels.Bind(anIndex, TCollection_AsciiString(anIndex));
+ }
+
+ Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder(aMesh.operator->(), 20., Quantity_NOC_YELLOW);
+ aTextBuilder->SetTexts(Standard_True, aLabels);
+ aMesh->AddBuilder(aTextBuilder);
+
+ return 0;
+}
+
+//=======================================================================
+//function : meshdeform
+//purpose :
+//=======================================================================
+static Standard_Integer meshdeform(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs < 3)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+ Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+ if (anIC.IsNull())
+ {
+ theDI << "The context is null\n";
+ return 0;
+ }
+
+ TCollection_AsciiString aParam;
+ TCollection_AsciiString aMode("off");
+ Standard_Real aScale(1.0);
+
+ for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++)
+ {
+ if (!aParam.IsEmpty())
+ {
+ if (aParam == "-mode")
+ {
+ aMode = theArgVec[anIdx];
+ }
+ else if (aParam == "-scale")
+ {
+ aScale = Draw::Atof(theArgVec[anIdx]);
+ }
+ aParam.Clear();
+ }
+ else if (theArgVec[anIdx][0] == '-')
+ {
+ aParam = theArgVec[anIdx];
+ }
+ }
+
+ if (!aMode.IsEqual("on") && !aMode.IsEqual("off"))
+ {
+ theDI << "Wrong mode name\n";
+ return 0;
+ }
+
+ Handle(MeshVS_DeformedDataSource) aDefDS =
+ new MeshVS_DeformedDataSource(aMesh->GetDataSource(), aScale);
+
+ const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes();
+
+ Standard_Integer aNbNodes;
+ MeshVS_EntityType aEntType;
+
+ for (TColStd_PackedMapOfInteger::Iterator anIter(anAllIDs);
+ anIter.More(); anIter.Next())
+ {
+ TColStd_Array1OfReal aCoords(1, 3);
+ aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
+
+ gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
+ if (!aNorm.Magnitude())
+ aNorm = gp_Vec(0, 0, 1);
+ aDefDS->SetVector(anIter.Key(), aNorm.Normalized());
+ }
+
+ aMesh->SetDataSource(aDefDS);
+
+ anIC->Redisplay(aMesh, Standard_False);
+
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (!aView.IsNull())
+ aView->FitAll();
+
+ return 0;
+}
+
+//=======================================================================
+//function : mesh_edge_width
+//purpose :
+//=======================================================================
+static Standard_Integer mesh_edge_width(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ try
+ {
+ OCC_CATCH_SIGNALS
+ if (theNbArgs < 3)
+ {
+ theDI << "Wrong number of parameters\n";
+ theDI << "Use : mesh_edge_width <mesh name> <width>\n";
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+
+ const char* aWidthStr = theArgVec[2];
+ if (aWidthStr == 0 || Draw::Atof(aWidthStr) <= 0)
+ {
+ theDI << "Width must be real value more than zero\n";
+ return 0;
+ }
+
+ double aWidth = Draw::Atof(aWidthStr);
+
+ Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
+ if (anIC.IsNull())
+ {
+ theDI << "The context is null\n";
+ return 0;
+ }
+
+ Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
+ if (aDrawer.IsNull())
+ {
+ theDI << "The drawer is null\n";
+ return 0;
+ }
+
+ aDrawer->SetDouble(MeshVS_DA_EdgeWidth, aWidth);
+ anIC->Redisplay(aMesh, Standard_True);
+ }
+ catch (Standard_Failure const&)
+ {
+ theDI << "Error\n";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : meshinfo
+//purpose :
+//=======================================================================
+static Standard_Integer meshinfo(Draw_Interpretor& theDI,
+ Standard_Integer theNbArgs,
+ const char** theArgVec)
+{
+ if (theNbArgs != 2)
+ {
+ theDI << "Wrong number of parameters. Use : meshinfo mesh\n";
+ return 0;
+ }
+
+ Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI);
+ if (aMesh.IsNull())
+ {
+ theDI << "Mesh not found\n";
+ return 0;
+ }
+
+ Handle(XSDRAWSTL_DataSource) stlMeshSource = Handle(XSDRAWSTL_DataSource)::DownCast(aMesh->GetDataSource());
+ if (!stlMeshSource.IsNull())
+ {
+ const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes();
+ const TColStd_PackedMapOfInteger& tris = stlMeshSource->GetAllElements();
+
+ theDI << "Nb nodes = " << nodes.Extent() << "\n";
+ theDI << "Nb triangles = " << tris.Extent() << "\n";
+ }
+
+ return 0;
+}
+
+//=============================================================================
+//function : Factory
+//purpose :
+//=============================================================================
+void XSDRAWSTL::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean aIsActivated = Standard_False;
+ if (aIsActivated)
+ {
+ return;
+ }
+ aIsActivated = Standard_True;
+
+ const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands
+
+ theDI.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, aGroup);
+ theDI.Add("readstl",
+ "readstl shape file [-brep] [-mergeAngle Angle] [-multi]"
+ "\n\t\t: Reads STL file and creates a new shape with specified name."
+ "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces."
+ "\n\t\t: Single triangulation-only Face is created otherwise (default)."
+ "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default."
+ "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.",
+ __FILE__, readstl, aGroup);
+
+ theDI.Add("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, aGroup);
+ theDI.Add("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, aGroup);
+ theDI.Add("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, aGroup);
+ theDI.Add("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, aGroup);
+ theDI.Add("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, aGroup);
+ theDI.Add("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, aGroup);
+ theDI.Add("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, aGroup);
+ theDI.Add("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, aGroup);
+ theDI.Add("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, aGroup);
+ theDI.Add("meshhidesel", "hide selected entities", __FILE__, hidesel, aGroup);
+ theDI.Add("meshshowsel", "show only selected entities", __FILE__, showonly, aGroup);
+ theDI.Add("meshshowall", "show all entities", __FILE__, showall, aGroup);
+ theDI.Add("meshcolors", "display color presentation", __FILE__, meshcolors, aGroup);
+ theDI.Add("meshvectors", "display sample vectors", __FILE__, meshvectors, aGroup);
+ theDI.Add("meshtext", "display text labels", __FILE__, meshtext, aGroup);
+ theDI.Add("meshdeform", "display deformed mesh", __FILE__, meshdeform, aGroup);
+ theDI.Add("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, aGroup);
+ theDI.Add("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWSTL)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWSTL_HeaderFile
+#define _XSDRAWSTL_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWSTL
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWSTL. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWSTL_HeaderFile
--- /dev/null
+// Created on: 2004-06-10
+// Created by: Alexander SOLOVYOV
+// Copyright (c) 2004-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 <XSDRAWSTL_DataSource.hxx>
+
+#include <Precision.hxx>
+#include <Standard_Type.hxx>
+#include <TColStd_DataMapOfIntegerReal.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DataSource,MeshVS_DataSource)
+
+//================================================================
+// Function : Constructor
+// Purpose :
+//================================================================
+XSDRAWSTL_DataSource::XSDRAWSTL_DataSource (const Handle(Poly_Triangulation)& aMesh)
+{
+ myMesh = aMesh;
+
+ if( !myMesh.IsNull() )
+ {
+ const Standard_Integer aNbNodes = myMesh->NbNodes();
+ myNodeCoords = new TColStd_HArray2OfReal (1, aNbNodes, 1, 3);
+ std::cout << "Nodes : " << aNbNodes << std::endl;
+
+ for (Standard_Integer i = 1; i <= aNbNodes; i++)
+ {
+ myNodes.Add( i );
+ gp_Pnt xyz = myMesh->Node (i);
+
+ myNodeCoords->SetValue(i, 1, xyz.X());
+ myNodeCoords->SetValue(i, 2, xyz.Y());
+ myNodeCoords->SetValue(i, 3, xyz.Z());
+ }
+
+ const Standard_Integer aNbTris = myMesh->NbTriangles();
+ myElemNormals = new TColStd_HArray2OfReal(1, aNbTris, 1, 3);
+ myElemNodes = new TColStd_HArray2OfInteger(1, aNbTris, 1, 3);
+
+ std::cout << "Elements : " << aNbTris << std::endl;
+
+ for (Standard_Integer i = 1; i <= aNbTris; i++)
+ {
+ myElements.Add( i );
+
+ const Poly_Triangle aTri = myMesh->Triangle (i);
+
+ Standard_Integer V[3];
+ aTri.Get (V[0], V[1], V[2]);
+
+ const gp_Pnt aP1 = myMesh->Node (V[0]);
+ const gp_Pnt aP2 = myMesh->Node (V[1]);
+ const gp_Pnt aP3 = myMesh->Node (V[2]);
+
+ gp_Vec aV1(aP1, aP2);
+ gp_Vec aV2(aP2, aP3);
+
+ gp_Vec aN = aV1.Crossed(aV2);
+ if (aN.SquareMagnitude() > Precision::SquareConfusion())
+ aN.Normalize();
+ else
+ aN.SetCoord(0.0, 0.0, 0.0);
+
+ for (Standard_Integer j = 0; j < 3; j++)
+ {
+ myElemNodes->SetValue(i, j+1, V[j]);
+ }
+
+ myElemNormals->SetValue (i, 1, aN.X());
+ myElemNormals->SetValue (i, 2, aN.Y());
+ myElemNormals->SetValue (i, 3, aN.Z());
+ }
+ }
+ std::cout << "Construction is finished" << std::endl;
+}
+
+//================================================================
+// Function : GetGeom
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource::GetGeom
+( const Standard_Integer ID, const Standard_Boolean IsElement,
+ TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes,
+ MeshVS_EntityType& Type ) const
+{
+ if( myMesh.IsNull() )
+ return Standard_False;
+
+ if( IsElement )
+ {
+ if( ID>=1 && ID<=myElements.Extent() )
+ {
+ Type = MeshVS_ET_Face;
+ NbNodes = 3;
+
+ for( Standard_Integer i = 1, k = 1; i <= 3; i++ )
+ {
+ Standard_Integer IdxNode = myElemNodes->Value(ID, i);
+ for(Standard_Integer j = 1; j <= 3; j++, k++ )
+ Coords(k) = myNodeCoords->Value(IdxNode, j);
+ }
+
+ return Standard_True;
+ }
+ else
+ return Standard_False;
+ }
+ else
+ if( ID>=1 && ID<=myNodes.Extent() )
+ {
+ Type = MeshVS_ET_Node;
+ NbNodes = 1;
+
+ Coords( 1 ) = myNodeCoords->Value(ID, 1);
+ Coords( 2 ) = myNodeCoords->Value(ID, 2);
+ Coords( 3 ) = myNodeCoords->Value(ID, 3);
+ return Standard_True;
+ }
+ else
+ return Standard_False;
+}
+
+//================================================================
+// Function : GetGeomType
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource::GetGeomType
+( const Standard_Integer,
+ const Standard_Boolean IsElement,
+ MeshVS_EntityType& Type ) const
+{
+ if( IsElement )
+ {
+ Type = MeshVS_ET_Face;
+ return Standard_True;
+ }
+ else
+ {
+ Type = MeshVS_ET_Node;
+ return Standard_True;
+ }
+}
+
+//================================================================
+// Function : GetAddr
+// Purpose :
+//================================================================
+Standard_Address XSDRAWSTL_DataSource::GetAddr
+( const Standard_Integer, const Standard_Boolean ) const
+{
+ return NULL;
+}
+
+//================================================================
+// Function : GetNodesByElement
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource::GetNodesByElement
+( const Standard_Integer ID,
+ TColStd_Array1OfInteger& theNodeIDs,
+ Standard_Integer& /*theNbNodes*/ ) const
+{
+ if( myMesh.IsNull() )
+ return Standard_False;
+
+ if( ID>=1 && ID<=myElements.Extent() && theNodeIDs.Length() >= 3 )
+ {
+ Standard_Integer aLow = theNodeIDs.Lower();
+ theNodeIDs (aLow) = myElemNodes->Value(ID, 1 );
+ theNodeIDs (aLow + 1) = myElemNodes->Value(ID, 2 );
+ theNodeIDs (aLow + 2) = myElemNodes->Value(ID, 3 );
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//================================================================
+// Function : GetAllNodes
+// Purpose :
+//================================================================
+const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource::GetAllNodes() const
+{
+ return myNodes;
+}
+
+//================================================================
+// Function : GetAllElements
+// Purpose :
+//================================================================
+const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource::GetAllElements() const
+{
+ return myElements;
+}
+
+//================================================================
+// Function : GetNormal
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource::GetNormal
+( const Standard_Integer Id, const Standard_Integer Max,
+ Standard_Real& nx, Standard_Real& ny,Standard_Real& nz ) const
+{
+ if( myMesh.IsNull() )
+ return Standard_False;
+
+ if( Id>=1 && Id<=myElements.Extent() && Max>=3 )
+ {
+ nx = myElemNormals->Value(Id, 1);
+ ny = myElemNormals->Value(Id, 2);
+ nz = myElemNormals->Value(Id, 3);
+ return Standard_True;
+ }
+ else
+ return Standard_False;
+}
+
--- /dev/null
+// Created on: 2004-06-10
+// Created by: Alexander SOLOVYOV
+// Copyright (c) 2004-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 _XSDRAWSTL_DataSource_HeaderFile
+#define _XSDRAWSTL_DataSource_HeaderFile
+
+#include <Standard.hxx>
+
+#include <TColStd_HArray2OfInteger.hxx>
+#include <TColStd_HArray2OfReal.hxx>
+#include <MeshVS_DataSource.hxx>
+#include <Standard_Integer.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <MeshVS_EntityType.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <Poly_Triangulation.hxx>
+
+
+class XSDRAWSTL_DataSource;
+DEFINE_STANDARD_HANDLE(XSDRAWSTL_DataSource, MeshVS_DataSource)
+
+//! The sample DataSource for working with STLMesh_Mesh
+class XSDRAWSTL_DataSource : public MeshVS_DataSource
+{
+
+public:
+
+
+ //! Constructor
+ Standard_EXPORT XSDRAWSTL_DataSource(const Handle(Poly_Triangulation)& aMesh);
+
+ //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates.
+ //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and
+ //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element.
+ //! It is recommended to return 1 for node. Type is an element type.
+ Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const Standard_OVERRIDE;
+
+ //! This method is similar to GetGeom, but returns only element or node type. This method is provided for
+ //! a fine performance.
+ Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const Standard_OVERRIDE;
+
+ //! This method returns by number an address of any entity which represents element or node data structure.
+ Standard_EXPORT Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const Standard_OVERRIDE;
+
+ //! This method returns information about what node this element consist of.
+ Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const Standard_OVERRIDE;
+
+ //! This method returns map of all nodes the object consist of.
+ Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE;
+
+ //! This method returns map of all elements the object consist of.
+ Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE;
+
+ //! This method calculates normal of face, which is using for correct reflection presentation.
+ //! There is default method, for advance reflection this method can be redefined.
+ Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const Standard_OVERRIDE;
+
+
+
+
+ DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DataSource,MeshVS_DataSource)
+
+protected:
+
+
+
+
+private:
+
+
+ Handle(Poly_Triangulation) myMesh;
+ TColStd_PackedMapOfInteger myNodes;
+ TColStd_PackedMapOfInteger myElements;
+ Handle(TColStd_HArray2OfInteger) myElemNodes;
+ Handle(TColStd_HArray2OfReal) myNodeCoords;
+ Handle(TColStd_HArray2OfReal) myElemNormals;
+
+
+};
+
+
+
+
+
+
+
+#endif // _XSDRAWSTL_DataSource_HeaderFile
--- /dev/null
+// Created on: 2014-08-04
+// Created by: Artem NOVIKOV
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Standard_Type.hxx>
+#include <TColgp_SequenceOfXYZ.hxx>
+#include <TColStd_DataMapOfIntegerInteger.hxx>
+#include <TColStd_DataMapOfIntegerReal.hxx>
+#include <XSDRAWSTL_DataSource3D.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DataSource3D,MeshVS_DataSource)
+
+//================================================================
+// Function : Constructor
+// Purpose :
+//================================================================
+XSDRAWSTL_DataSource3D::XSDRAWSTL_DataSource3D()
+{
+ for (Standard_Integer aNodeID = 1; aNodeID <= 16; aNodeID++)
+ {
+ myNodes.Add( aNodeID );
+ }
+
+ for (Standard_Integer anElemID = 1; anElemID <= 5; anElemID++)
+ {
+ myElements.Add( anElemID );
+ }
+
+ myNodeCoords = new TColStd_HArray2OfReal(1, 16, 1, 3);
+
+ myNodeCoords->SetValue( 1, 1, 5 );
+ myNodeCoords->SetValue( 1, 2, 5 );
+ myNodeCoords->SetValue( 1, 3, 20 );
+
+ myNodeCoords->SetValue( 2, 1, 0 );
+ myNodeCoords->SetValue( 2, 2, 10 );
+ myNodeCoords->SetValue( 2, 3, 10 );
+
+ myNodeCoords->SetValue( 3, 1, 10 );
+ myNodeCoords->SetValue( 3, 2, 0 );
+ myNodeCoords->SetValue( 3, 3, 10 );
+
+ myNodeCoords->SetValue( 4, 1, 0 );
+ myNodeCoords->SetValue( 4, 2, 0 );
+ myNodeCoords->SetValue( 4, 3, 10 );
+
+ myNodeCoords->SetValue( 5, 1, -10 );
+ myNodeCoords->SetValue( 5, 2, 0 );
+ myNodeCoords->SetValue( 5, 3, 10 );
+
+ myNodeCoords->SetValue( 6, 1, -10 );
+ myNodeCoords->SetValue( 6, 2, 10 );
+ myNodeCoords->SetValue( 6, 3, 10 );
+
+ myNodeCoords->SetValue( 7, 1, -10 );
+ myNodeCoords->SetValue( 7, 2, 10 );
+ myNodeCoords->SetValue( 7, 3, 0 );
+
+ myNodeCoords->SetValue( 8, 1, -10 );
+ myNodeCoords->SetValue( 8, 2, 0 );
+ myNodeCoords->SetValue( 8, 3, 0 );
+
+ myNodeCoords->SetValue( 9, 1, 0 );
+ myNodeCoords->SetValue( 9, 2, 0 );
+ myNodeCoords->SetValue( 9, 3, 0 );
+
+ myNodeCoords->SetValue( 10, 1, 0 );
+ myNodeCoords->SetValue( 10, 2, 10 );
+ myNodeCoords->SetValue( 10, 3, 0 );
+
+ myNodeCoords->SetValue( 11, 1, 0 );
+ myNodeCoords->SetValue( 11, 2, -10 );
+ myNodeCoords->SetValue( 11, 3, 10 );
+
+ myNodeCoords->SetValue( 12, 1, 10 );
+ myNodeCoords->SetValue( 12, 2, -10 );
+ myNodeCoords->SetValue( 12, 3, 10 );
+
+ myNodeCoords->SetValue( 13, 1, 10 );
+ myNodeCoords->SetValue( 13, 2, -10 );
+ myNodeCoords->SetValue( 13, 3, 0 );
+
+ myNodeCoords->SetValue( 14, 1, 0 );
+ myNodeCoords->SetValue( 14, 2, -10 );
+ myNodeCoords->SetValue( 14, 3, 0 );
+
+ myNodeCoords->SetValue( 15, 1, 10 );
+ myNodeCoords->SetValue( 15, 2, 0 );
+ myNodeCoords->SetValue( 15, 3, 0 );
+
+ myNodeCoords->SetValue( 16, 1, 5 );
+ myNodeCoords->SetValue( 16, 2, 5 );
+ myNodeCoords->SetValue( 16, 3, -10 );
+
+ myElemNbNodes = new TColStd_HArray1OfInteger(1, 5);
+
+ myElemNbNodes->SetValue( 1, 4 );
+ myElemNbNodes->SetValue( 2, 8 );
+ myElemNbNodes->SetValue( 3, 6 );
+ myElemNbNodes->SetValue( 4, 8 );
+ myElemNbNodes->SetValue( 5, 4 );
+
+ myElemNodes = new TColStd_HArray2OfInteger(1, 5, 1, 8);
+
+ myElemNodes->SetValue(1, 1, 1);
+ myElemNodes->SetValue(1, 2, 2);
+ myElemNodes->SetValue(1, 3, 3);
+ myElemNodes->SetValue(1, 4, 4);
+
+ myElemNodes->SetValue(2, 1, 2);
+ myElemNodes->SetValue(2, 2, 4);
+ myElemNodes->SetValue(2, 3, 5);
+ myElemNodes->SetValue(2, 4, 6);
+ myElemNodes->SetValue(2, 5, 7);
+ myElemNodes->SetValue(2, 6, 8);
+ myElemNodes->SetValue(2, 7, 9);
+ myElemNodes->SetValue(2, 8, 10);
+
+ myElemNodes->SetValue(3, 1, 2);
+ myElemNodes->SetValue(3, 2, 3);
+ myElemNodes->SetValue(3, 3, 4);
+ myElemNodes->SetValue(3, 4, 10);
+ myElemNodes->SetValue(3, 5, 15);
+ myElemNodes->SetValue(3, 6, 9);
+
+ myElemNodes->SetValue(4, 1, 4);
+ myElemNodes->SetValue(4, 2, 3);
+ myElemNodes->SetValue(4, 3, 12);
+ myElemNodes->SetValue(4, 4, 11);
+ myElemNodes->SetValue(4, 5, 14);
+ myElemNodes->SetValue(4, 6, 13);
+ myElemNodes->SetValue(4, 7, 15);
+ myElemNodes->SetValue(4, 8, 9);
+
+ myElemNodes->SetValue(5, 1, 16);
+ myElemNodes->SetValue(5, 2, 15);
+ myElemNodes->SetValue(5, 3, 10);
+ myElemNodes->SetValue(5, 4, 9);
+}
+
+//================================================================
+// Function : GetGeom
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource3D::GetGeom
+( const Standard_Integer theID, const Standard_Boolean theIsElement,
+ TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes,
+ MeshVS_EntityType& theType ) const
+{
+ if (theIsElement)
+ {
+ if (theID >= 1 && theID <= myElements.Extent())
+ {
+ theType = MeshVS_ET_Volume;
+ theNbNodes = myElemNbNodes->Value(theID);
+
+ for (Standard_Integer aNodeI = 1, aGlobCoordI = 1; aNodeI <= theNbNodes; aNodeI++)
+ {
+ Standard_Integer anIdxNode = myElemNodes->Value(theID, aNodeI);
+ for(Standard_Integer aCoordI = 1; aCoordI <= 3; aCoordI++, aGlobCoordI++ )
+ theCoords(aGlobCoordI) = myNodeCoords->Value(anIdxNode, aCoordI);
+ }
+
+ return Standard_True;
+ }
+ else
+ return Standard_False;
+ }
+ else
+ if (theID >= 1 && theID <= myNodes.Extent())
+ {
+ theType = MeshVS_ET_Node;
+ theNbNodes = 1;
+
+ theCoords( 1 ) = myNodeCoords->Value(theID, 1);
+ theCoords( 2 ) = myNodeCoords->Value(theID, 2);
+ theCoords( 3 ) = myNodeCoords->Value(theID, 3);
+ return Standard_True;
+ }
+ else
+ return Standard_False;
+}
+
+//================================================================
+// Function : Get3DGeom
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource3D::Get3DGeom
+( const Standard_Integer theID, Standard_Integer& theNbNodes,
+ Handle(MeshVS_HArray1OfSequenceOfInteger)& theData ) const
+{
+ Handle(MeshVS_HArray1OfSequenceOfInteger) aMeshData;
+ if (theID == 1 || theID == 5)
+ {
+ aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,4);
+ theNbNodes = 4;
+ for (Standard_Integer anElemI = 1; anElemI <= 4; anElemI++)
+ {
+ aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) % 4 );
+ aMeshData->ChangeValue(anElemI).Append( anElemI % 4 );
+ aMeshData->ChangeValue(anElemI).Append( (anElemI + 1) % 4 );
+ }
+ theData = aMeshData;
+ return Standard_True;
+ }
+
+ if (theID == 2 || theID == 4)
+ {
+ aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,6);
+ theNbNodes = 8;
+ for (Standard_Integer anElemI = 1, k = 1; anElemI <= 4; anElemI++)
+ {
+ aMeshData->ChangeValue(anElemI).Append( (k - 1) % 8 );
+ aMeshData->ChangeValue(anElemI).Append( k % 8 );
+ aMeshData->ChangeValue(anElemI).Append( (k + 1) % 8 );
+ aMeshData->ChangeValue(anElemI).Append( (k + 2) % 8 );
+ k+=2;
+ }
+
+ aMeshData->ChangeValue(5).Append( 0 );
+ aMeshData->ChangeValue(5).Append( 3 );
+ aMeshData->ChangeValue(5).Append( 4 );
+ aMeshData->ChangeValue(5).Append( 7 );
+
+ aMeshData->ChangeValue(6).Append( 1 );
+ aMeshData->ChangeValue(6).Append( 2 );
+ aMeshData->ChangeValue(6).Append( 5 );
+ aMeshData->ChangeValue(6).Append( 6 );
+
+ theData = aMeshData;
+ return Standard_True;
+ }
+
+ if (theID == 3)
+ {
+ aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,5);
+ theNbNodes = 6;
+ for (Standard_Integer anElemI = 1; anElemI <= 2; anElemI++)
+ {
+ aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 );
+ aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 1 );
+ aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 2 );
+ }
+ for (Standard_Integer anElemI = 1; anElemI <= 3; anElemI++)
+ {
+ aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 );
+ aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 );
+ aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 + 3 );
+ aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 + 3 );
+ }
+ theData = aMeshData;
+ return Standard_True;
+ }
+
+ return Standard_False;
+}
+
+//================================================================
+// Function : GetGeomType
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource3D::GetGeomType
+( const Standard_Integer theID,
+ const Standard_Boolean theIsElement,
+ MeshVS_EntityType& theType ) const
+{
+ if (theIsElement)
+ {
+ if (theID >= 1 && theID <= myElements.Extent())
+ {
+ theType = MeshVS_ET_Volume;
+ return Standard_True;
+ }
+ }
+ else
+ if (theID >= 1 && theID <= myNodes.Extent())
+ {
+ theType = MeshVS_ET_Node;
+ return Standard_True;
+ }
+
+ return Standard_False;
+}
+
+//================================================================
+// Function : GetAddr
+// Purpose :
+//================================================================
+Standard_Address XSDRAWSTL_DataSource3D::GetAddr
+( const Standard_Integer, const Standard_Boolean ) const
+{
+ return NULL;
+}
+
+//================================================================
+// Function : GetNodesByElement
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource3D::GetNodesByElement
+( const Standard_Integer theID,
+ TColStd_Array1OfInteger& theNodeIDs,
+ Standard_Integer& theNbNodes ) const
+{
+ Standard_Integer aLow;
+ if (theID == 1 || theID == 5)
+ {
+ theNbNodes = 4;
+ aLow = theNodeIDs.Lower();
+ theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
+ theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
+ theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
+ theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
+ return Standard_True;
+ }
+
+ if (theID == 2 || theID == 4)
+ {
+ theNbNodes = 8;
+ aLow = theNodeIDs.Lower();
+ theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
+ theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
+ theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
+ theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
+ theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 );
+ theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 );
+ theNodeIDs (aLow + 6) = myElemNodes->Value(theID, 7 );
+ theNodeIDs (aLow + 7) = myElemNodes->Value(theID, 8 );
+ return Standard_True;
+ }
+
+ if (theID == 3)
+ {
+ theNbNodes = 6;
+ aLow = theNodeIDs.Lower();
+ theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
+ theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
+ theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
+ theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
+ theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 );
+ theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 );
+ return Standard_True;
+ }
+
+ return Standard_False;
+}
+
+//================================================================
+// Function : GetAllNodes
+// Purpose :
+//================================================================
+const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource3D::GetAllNodes() const
+{
+ return myNodes;
+}
+
+//================================================================
+// Function : GetAllElements
+// Purpose :
+//================================================================
+const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource3D::GetAllElements() const
+{
+ return myElements;
+}
+
+//================================================================
+// Function : GetNormal
+// Purpose :
+//================================================================
+Standard_Boolean XSDRAWSTL_DataSource3D::GetNormal
+( const Standard_Integer /*theID*/, const Standard_Integer /*theMax*/,
+ Standard_Real& /*theNx*/, Standard_Real& /*theNy*/,Standard_Real& /*theNz*/ ) const
+{
+ return Standard_False;
+}
--- /dev/null
+// Created on: 2014-08-04
+// Created by: Artem NOVIKOV
+// Copyright (c) 2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XSDRAWSTL_DataSource3D_HeaderFile
+#define _XSDRAWSTL_DataSource3D_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_HArray2OfReal.hxx>
+#include <TColStd_HArray2OfInteger.hxx>
+#include <MeshVS_DataSource.hxx>
+#include <Standard_Integer.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <MeshVS_EntityType.hxx>
+#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+
+
+class XSDRAWSTL_DataSource3D;
+DEFINE_STANDARD_HANDLE(XSDRAWSTL_DataSource3D, MeshVS_DataSource)
+
+//! The sample DataSource3D for working with STLMesh_Mesh
+class XSDRAWSTL_DataSource3D : public MeshVS_DataSource
+{
+
+public:
+
+
+ //! Constructor
+ Standard_EXPORT XSDRAWSTL_DataSource3D();
+
+ //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates.
+ //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and
+ //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element.
+ //! It is recommended to return 1 for node. Type is an element type.
+ Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer theID, const Standard_Boolean theIsElement, TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, MeshVS_EntityType& theType) const Standard_OVERRIDE;
+
+ //! This method returns topology information about 3D-element
+ //! Returns false if element with ID isn't 3D or because other troubles
+ Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer theID, Standard_Integer& theNbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& theData) const Standard_OVERRIDE;
+
+ //! This method is similar to GetGeom, but returns only element or node type. This method is provided for
+ //! a fine performance.
+ Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer theID, const Standard_Boolean theIsElement, MeshVS_EntityType& theType) const Standard_OVERRIDE;
+
+ //! This method returns by number an address of any entity which represents element or node data structure.
+ Standard_EXPORT Standard_Address GetAddr (const Standard_Integer theID, const Standard_Boolean theIsElement) const Standard_OVERRIDE;
+
+ //! This method returns information about what node this element consist of.
+ Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer theID, TColStd_Array1OfInteger& theNodeIDs, Standard_Integer& theNbNodes) const Standard_OVERRIDE;
+
+ //! This method returns map of all nodes the object consist of.
+ Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE;
+
+ //! This method returns map of all elements the object consist of.
+ Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE;
+
+ //! This method calculates normal of face, which is using for correct reflection presentation.
+ //! There is default method, for advance reflection this method can be redefined.
+ Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer theID, const Standard_Integer theMax, Standard_Real& theNx, Standard_Real& theNy, Standard_Real& theNz) const Standard_OVERRIDE;
+
+
+
+
+ DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DataSource3D,MeshVS_DataSource)
+
+protected:
+
+
+
+
+private:
+
+
+ TColStd_PackedMapOfInteger myNodes;
+ TColStd_PackedMapOfInteger myElements;
+ Handle(TColStd_HArray1OfInteger) myElemNbNodes;
+ Handle(TColStd_HArray2OfReal) myNodeCoords;
+ Handle(TColStd_HArray2OfInteger) myElemNodes;
+
+
+};
+
+
+
+
+
+
+
+#endif // _XSDRAWSTL_DataSource3D_HeaderFile
--- /dev/null
+// Created on: 2004-06-11
+// Created by: Alexander SOLOVYOV
+// Copyright (c) 2004-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 <Draw_Display.hxx>
+#include <MeshVS_Mesh.hxx>
+#include <Standard_Type.hxx>
+#include <XSDRAWSTL_DrawableMesh.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DrawableMesh,Draw_Drawable3D)
+
+//================================================================
+// Function : DrawOn
+// Purpose :
+//================================================================
+XSDRAWSTL_DrawableMesh::XSDRAWSTL_DrawableMesh( const Handle( MeshVS_Mesh )& aMesh )
+{
+ myMesh = aMesh;
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+void XSDRAWSTL_DrawableMesh::DrawOn(Draw_Display& /*d*/) const
+{
+}
+
+//================================================================
+// Function :
+// Purpose :
+//================================================================
+Handle( MeshVS_Mesh ) XSDRAWSTL_DrawableMesh::GetMesh() const
+{
+ return myMesh;
+}
--- /dev/null
+// Created on: 2004-06-11
+// Created by: Alexander SOLOVYOV
+// Copyright (c) 2004-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 _XSDRAWSTL_DrawableMesh_HeaderFile
+#define _XSDRAWSTL_DrawableMesh_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <Draw_Drawable3D.hxx>
+class MeshVS_Mesh;
+class Draw_Display;
+
+
+class XSDRAWSTL_DrawableMesh;
+DEFINE_STANDARD_HANDLE(XSDRAWSTL_DrawableMesh, Draw_Drawable3D)
+
+
+class XSDRAWSTL_DrawableMesh : public Draw_Drawable3D
+{
+
+public:
+
+
+ Standard_EXPORT XSDRAWSTL_DrawableMesh(const Handle(MeshVS_Mesh)& aMesh);
+
+ Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
+
+ Standard_EXPORT Handle(MeshVS_Mesh) GetMesh() const;
+
+
+
+
+ DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DrawableMesh,Draw_Drawable3D)
+
+protected:
+
+
+
+
+private:
+
+
+ Handle(MeshVS_Mesh) myMesh;
+
+
+};
+
+
+
+
+
+
+
+#endif // _XSDRAWSTL_DrawableMesh_HeaderFile
+++ /dev/null
-XSDRAWSTLVRML.cxx
-XSDRAWSTLVRML.hxx
-XSDRAWSTLVRML_CoordsMap.hxx
-XSDRAWSTLVRML_DataMapIteratorOfCoordsMap.hxx
-XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap.hxx
-XSDRAWSTLVRML_DataSource.cxx
-XSDRAWSTLVRML_DataSource.hxx
-XSDRAWSTLVRML_DataSource3D.cxx
-XSDRAWSTLVRML_DataSource3D.hxx
-XSDRAWSTLVRML_DrawableMesh.cxx
-XSDRAWSTLVRML_DrawableMesh.hxx
-XSDRAWSTLVRML_ElemNodesMap.hxx
+++ /dev/null
-// Created on: 2000-05-30
-// Created by: Sergey MOZOKHIN
-// Copyright (c) 2000-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 <XSDRAWSTLVRML.hxx>
-
-#include <AIS_InteractiveContext.hxx>
-#include <Aspect_TypeOfMarker.hxx>
-#include <Bnd_Box.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepLib_PointCloudShape.hxx>
-#include <DBRep.hxx>
-#include <DDocStd.hxx>
-#include <DDocStd_DrawDocument.hxx>
-#include <Draw.hxx>
-#include <Draw_Interpretor.hxx>
-#include <Draw_PluginMacro.hxx>
-#include <Draw_ProgressIndicator.hxx>
-#include <Graphic3d_MaterialAspect.hxx>
-#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
-#include <MeshVS_DeformedDataSource.hxx>
-#include <MeshVS_Drawer.hxx>
-#include <MeshVS_DrawerAttribute.hxx>
-#include <MeshVS_ElementalColorPrsBuilder.hxx>
-#include <MeshVS_Mesh.hxx>
-#include <MeshVS_MeshEntityOwner.hxx>
-#include <MeshVS_MeshPrsBuilder.hxx>
-#include <MeshVS_NodalColorPrsBuilder.hxx>
-#include <MeshVS_PrsBuilder.hxx>
-#include <MeshVS_TextPrsBuilder.hxx>
-#include <MeshVS_VectorPrsBuilder.hxx>
-#include <OSD_Path.hxx>
-#include <Quantity_Color.hxx>
-#include <Quantity_HArray1OfColor.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <RWGltf_DracoParameters.hxx>
-#include <RWGltf_CafReader.hxx>
-#include <RWGltf_CafWriter.hxx>
-#include <RWMesh_FaceIterator.hxx>
-#include <RWStl.hxx>
-#include <RWObj.hxx>
-#include <RWObj_CafReader.hxx>
-#include <RWObj_CafWriter.hxx>
-#include <RWPly_CafWriter.hxx>
-#include <RWPly_PlyWriterContext.hxx>
-#include <SelectMgr_SelectionManager.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <StdSelect_ViewerSelector3d.hxx>
-#include <StlAPI.hxx>
-#include <StlAPI_Writer.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_HPackedMapOfInteger.hxx>
-#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDocStd_Application.hxx>
-#include <TDocStd_Document.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Shape.hxx>
-#include <UnitsAPI.hxx>
-#include <UnitsMethods.hxx>
-#include <V3d_View.hxx>
-#include <ViewerTest.hxx>
-#include <VrmlAPI.hxx>
-#include <VrmlAPI_Writer.hxx>
-#include <VrmlData_DataMapOfShapeAppearance.hxx>
-#include <VrmlData_Scene.hxx>
-#include <VrmlData_ShapeConvert.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFPrs_DocumentExplorer.hxx>
-#include <XSAlgo.hxx>
-#include <XSAlgo_AlgoContainer.hxx>
-#include <XSDRAW.hxx>
-#include <XSDRAWIGES.hxx>
-#include <XSDRAWSTEP.hxx>
-#include <XSDRAWSTLVRML_DataSource.hxx>
-#include <XSDRAWSTLVRML_DataSource3D.hxx>
-#include <XSDRAWSTLVRML_DrawableMesh.hxx>
-
-#ifndef _STDIO_H
-#include <stdio.h>
-#endif
-
-extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
- const Handle(AIS_InteractiveObject)& theAISObj,
- Standard_Boolean theReplaceIfExists = Standard_True);
-
-//! Parse RWMesh_NameFormat enumeration.
-static bool parseNameFormat (const char* theArg,
- RWMesh_NameFormat& theFormat)
-{
- TCollection_AsciiString aName (theArg);
- aName.LowerCase();
- if (aName == "empty")
- {
- theFormat = RWMesh_NameFormat_Empty;
- }
- else if (aName == "product"
- || aName == "prod")
- {
- theFormat = RWMesh_NameFormat_Product;
- }
- else if (aName == "instance"
- || aName == "inst")
- {
- theFormat = RWMesh_NameFormat_Instance;
- }
- else if (aName == "instanceorproduct"
- || aName == "instance||product"
- || aName == "instance|product"
- || aName == "instorprod"
- || aName == "inst||prod"
- || aName == "inst|prod")
- {
- theFormat = RWMesh_NameFormat_InstanceOrProduct;
- }
- else if (aName == "productorinstance"
- || aName == "product||instance"
- || aName == "product|instance"
- || aName == "prodorinst"
- || aName == "prod||inst"
- || aName == "prod|inst")
- {
- theFormat = RWMesh_NameFormat_ProductOrInstance;
- }
- else if (aName == "productandinstance"
- || aName == "prodandinst"
- || aName == "product&instance"
- || aName == "prod&inst")
- {
- theFormat = RWMesh_NameFormat_ProductAndInstance;
- }
- else if (aName == "productandinstanceandocaf"
- || aName == "verbose"
- || aName == "debug")
- {
- theFormat = RWMesh_NameFormat_ProductAndInstanceAndOcaf;
- }
- else
- {
- return false;
- }
- return true;
-}
-
-//! Parse RWMesh_CoordinateSystem enumeration.
-static bool parseCoordinateSystem (const char* theArg,
- RWMesh_CoordinateSystem& theSystem)
-{
- TCollection_AsciiString aCSStr (theArg);
- aCSStr.LowerCase();
- if (aCSStr == "zup")
- {
- theSystem = RWMesh_CoordinateSystem_Zup;
- }
- else if (aCSStr == "yup")
- {
- theSystem = RWMesh_CoordinateSystem_Yup;
- }
- else
- {
- return Standard_False;
- }
- return Standard_True;
-}
-
-//=============================================================================
-//function : ReadGltf
-//purpose : Reads glTF file
-//=============================================================================
-static Standard_Integer ReadGltf (Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- TCollection_AsciiString aDestName, aFilePath;
- Standard_Boolean toUseExistingDoc = Standard_False;
- Standard_Boolean toListExternalFiles = Standard_False;
- Standard_Boolean isParallel = Standard_False;
- Standard_Boolean isDoublePrec = Standard_False;
- Standard_Boolean toSkipLateDataLoading = Standard_False;
- Standard_Boolean toKeepLateData = Standard_True;
- Standard_Boolean toPrintDebugInfo = Standard_False;
- Standard_Boolean toLoadAllScenes = Standard_False;
- Standard_Boolean toPrintAssetInfo = Standard_False;
- Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
- anArgCase.LowerCase();
- if (!isNoDoc
- && (anArgCase == "-nocreate"
- || anArgCase == "-nocreatedoc"))
- {
- toUseExistingDoc = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-parallel")
- {
- isParallel = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-doubleprec"
- || anArgCase == "-doubleprecision"
- || anArgCase == "-singleprec"
- || anArgCase == "-singleprecision")
- {
- isDoublePrec = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- if (anArgCase.StartsWith ("-single"))
- {
- isDoublePrec = !isDoublePrec;
- }
- }
- else if (anArgCase == "-skiplateloading")
- {
- toSkipLateDataLoading = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-keeplate")
- {
- toKeepLateData = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-allscenes")
- {
- toLoadAllScenes = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-toprintinfo"
- || anArgCase == "-toprintdebuginfo")
- {
- toPrintDebugInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-listexternalfiles"
- || anArgCase == "-listexternals"
- || anArgCase == "-listexternal"
- || anArgCase == "-external"
- || anArgCase == "-externalfiles")
- {
- toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-assetinfo"
- || anArgCase == "-metadata")
- {
- toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (aDestName.IsEmpty())
- {
- aDestName = theArgVec[anArgIter];
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgVec[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
- {
- if (toListExternalFiles || toPrintAssetInfo)
- {
- std::swap (aFilePath, aDestName);
- }
- }
- if (aFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
- Handle(TDocStd_Document) aDoc;
- if (!aDestName.IsEmpty()
- && !isNoDoc)
- {
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- Standard_CString aNameVar = aDestName.ToCString();
- DDocStd::GetDocument (aNameVar, aDoc, Standard_False);
- if (aDoc.IsNull())
- {
- if (toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
- return 1;
- }
- anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
- }
- else if (!toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDestName << " already exists";
- return 1;
- }
- }
-
- Standard_Real aScaleFactorM = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
- {
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
- }
-
- RWGltf_CafReader aReader;
- aReader.SetSystemLengthUnit (aScaleFactorM);
- aReader.SetSystemCoordinateSystem (RWMesh_CoordinateSystem_Zup);
- aReader.SetDocument (aDoc);
- aReader.SetParallel (isParallel);
- aReader.SetDoublePrecision (isDoublePrec);
- aReader.SetToSkipLateDataLoading (toSkipLateDataLoading);
- aReader.SetToKeepLateData (toKeepLateData);
- aReader.SetToPrintDebugMessages (toPrintDebugInfo);
- aReader.SetLoadAllScenes (toLoadAllScenes);
- if (aDestName.IsEmpty())
- {
- aReader.ProbeHeader (aFilePath);
- }
- else
- {
- aReader.Perform (aFilePath, aProgress->Start());
- if (isNoDoc)
- {
- DBRep::Set (aDestName.ToCString(), aReader.SingleShape());
- }
- else
- {
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
- TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName);
- Draw::Set (aDestName.ToCString(), aDrawDoc);
- }
- }
-
- bool isFirstLine = true;
- if (toPrintAssetInfo)
- {
- for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter (aReader.Metadata()); aKeyIter.More(); aKeyIter.Next())
- {
- if (!isFirstLine)
- {
- theDI << "\n";
- }
- isFirstLine = false;
- theDI << aKeyIter.Key() << ": " << aKeyIter.Value();
- }
- }
- if (toListExternalFiles)
- {
- if (!isFirstLine)
- {
- theDI << "\n";
- }
- for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
- {
- theDI << "\"" << aFileIter.Value() << "\" ";
- }
- }
-
- return 0;
-}
-
-//=============================================================================
-//function : WriteGltf
-//purpose : Writes glTF file
-//=============================================================================
-static Standard_Integer WriteGltf (Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- TCollection_AsciiString aGltfFilePath;
- Handle(TDocStd_Document) aDoc;
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- TColStd_IndexedDataMapOfStringString aFileInfo;
- RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
- RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
- bool toForceUVExport = false, toEmbedTexturesInGlb = true;
- bool toMergeFaces = false, toSplitIndices16 = false;
- bool isParallel = false;
- RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct;
- RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product;
- RWGltf_DracoParameters aDracoParameters;
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
- anArgCase.LowerCase();
- if (anArgCase == "-comments"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
- }
- else if (anArgCase == "-author"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Author", theArgVec[++anArgIter]);
- }
- else if (anArgCase == "-forceuvexport"
- || anArgCase == "-forceuv")
- {
- toForceUVExport = true;
- if (anArgIter + 1 < theNbArgs
- && Draw::ParseOnOff (theArgVec[anArgIter + 1], toForceUVExport))
- {
- ++anArgIter;
- }
- }
- else if (anArgCase == "-mergefaces")
- {
- toMergeFaces = true;
- if (anArgIter + 1 < theNbArgs
- && Draw::ParseOnOff (theArgVec[anArgIter + 1], toMergeFaces))
- {
- ++anArgIter;
- }
- }
- else if (anArgCase == "-splitindices16"
- || anArgCase == "-splitindexes16"
- || anArgCase == "-splitindices"
- || anArgCase == "-splitindexes"
- || anArgCase == "-splitind")
- {
- toSplitIndices16 = true;
- if (anArgIter + 1 < theNbArgs
- && Draw::ParseOnOff (theArgVec[anArgIter + 1], toSplitIndices16))
- {
- ++anArgIter;
- }
- }
- else if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-systemcoordinatesystem"
- || anArgCase == "-systemcoordsystem"
- || anArgCase == "-systemcoordsys"
- || anArgCase == "-syscoordsys"))
- {
- if (!parseCoordinateSystem (theArgVec[++anArgIter], aSystemCoordSys))
- {
- Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- else if (anArgCase == "-trsfformat"
- && anArgIter + 1 < theNbArgs)
- {
- TCollection_AsciiString aTrsfStr (theArgVec[++anArgIter]);
- aTrsfStr.LowerCase();
- if (aTrsfStr == "compact")
- {
- aTrsfFormat = RWGltf_WriterTrsfFormat_Compact;
- }
- else if (aTrsfStr == "mat4")
- {
- aTrsfFormat = RWGltf_WriterTrsfFormat_Mat4;
- }
- else if (aTrsfStr == "trs")
- {
- aTrsfFormat = RWGltf_WriterTrsfFormat_TRS;
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << anArgCase << "'";
- return 1;
- }
- }
- else if (anArgCase == "-nodenameformat"
- || anArgCase == "-nodename")
- {
- ++anArgIter;
- if (anArgIter >= theNbArgs
- || !parseNameFormat (theArgVec[anArgIter], aNodeNameFormat))
- {
- Message::SendFail() << "Syntax error at '" << anArgCase << "'";
- return 1;
- }
- }
- else if (anArgCase == "-meshnameformat"
- || anArgCase == "-meshname")
- {
- ++anArgIter;
- if (anArgIter >= theNbArgs
- || !parseNameFormat (theArgVec[anArgIter], aMeshNameFormat))
- {
- Message::SendFail() << "Syntax error at '" << anArgCase << "'";
- return 1;
- }
- }
- else if (aDoc.IsNull())
- {
- Standard_CString aNameVar = theArgVec[anArgIter];
- DDocStd::GetDocument (aNameVar, aDoc, false);
- if (aDoc.IsNull())
- {
- TopoDS_Shape aShape = DBRep::Get (aNameVar);
- if (aShape.IsNull())
- {
- Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
- return 1;
- }
-
- anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
- // auto-naming doesn't generate meaningful instance names
- //aShapeTool->SetAutoNaming (false);
- aNodeNameFormat = RWMesh_NameFormat_Product;
- aShapeTool->AddShape (aShape);
- }
- }
- else if (aGltfFilePath.IsEmpty())
- {
- aGltfFilePath = theArgVec[anArgIter];
- }
- else if (anArgCase == "-texturesSeparate")
- {
- toEmbedTexturesInGlb = false;
- }
- else if (anArgCase == "-draco")
- {
- aDracoParameters.DracoCompression = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-compressionlevel" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.CompressionLevel))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-quantizepositionbits" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizePositionBits))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-quantizenormalbits" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeNormalBits))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-quantizetexcoordbits" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeTexcoordBits))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-quantizecolorbits" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeColorBits))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-quantizegenericbits" && (anArgIter + 1) < theNbArgs
- && Draw::ParseInteger(theArgVec[anArgIter + 1], aDracoParameters.QuantizeGenericBits))
- {
- ++anArgIter;
- }
- else if (anArgCase == "-unifiedquantization")
- {
- aDracoParameters.UnifiedQuantization = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
- }
- else if (anArgCase == "-parallel")
- {
- isParallel = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aGltfFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
-
- TCollection_AsciiString anExt = aGltfFilePath;
- anExt.LowerCase();
- Standard_Real aScaleFactorM = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
- {
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
- }
-
- RWGltf_CafWriter aWriter (aGltfFilePath, anExt.EndsWith (".glb"));
- aWriter.SetTransformationFormat (aTrsfFormat);
- aWriter.SetNodeNameFormat (aNodeNameFormat);
- aWriter.SetMeshNameFormat (aMeshNameFormat);
- aWriter.SetForcedUVExport (toForceUVExport);
- aWriter.SetToEmbedTexturesInGlb (toEmbedTexturesInGlb);
- aWriter.SetMergeFaces (toMergeFaces);
- aWriter.SetSplitIndices16 (toSplitIndices16);
- aWriter.SetParallel(isParallel);
- aWriter.SetCompressionParameters(aDracoParameters);
- aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aScaleFactorM);
- aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
- aWriter.Perform (aDoc, aFileInfo, aProgress->Start());
- return 0;
-}
-
-static Standard_Integer writestl
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc < 3 || argc > 4) {
- di << "Use: " << argv[0]
- << " shape file [ascii/binary (0/1) : 1 by default]\n";
- } else {
- TopoDS_Shape aShape = DBRep::Get(argv[1]);
- Standard_Boolean isASCIIMode = Standard_False;
- if (argc == 4) {
- isASCIIMode = (Draw::Atoi(argv[3]) == 0);
- }
- StlAPI_Writer aWriter;
- aWriter.ASCIIMode() = isASCIIMode;
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di);
- Standard_Boolean isOK = aWriter.Write (aShape, argv[2], aProgress->Start());
- if (!isOK)
- di << "** Error **: Mesh writing has been failed.\n";
- }
- return 0;
-}
-
-//=============================================================================
-//function : readstl
-//purpose : Reads stl file
-//=============================================================================
-static Standard_Integer readstl(Draw_Interpretor& theDI,
- Standard_Integer theArgc,
- const char** theArgv)
-{
- TCollection_AsciiString aShapeName, aFilePath;
- bool toCreateCompOfTris = false;
- bool anIsMulti = false;
- double aMergeAngle = M_PI / 2.0;
- for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
- {
- TCollection_AsciiString anArg (theArgv[anArgIter]);
- anArg.LowerCase();
- if (aShapeName.IsEmpty())
- {
- aShapeName = theArgv[anArgIter];
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgv[anArgIter];
- }
- else if (anArg == "-brep")
- {
- toCreateCompOfTris = true;
- if (anArgIter + 1 < theArgc
- && Draw::ParseOnOff (theArgv[anArgIter + 1], toCreateCompOfTris))
- {
- ++anArgIter;
- }
- }
- else if (anArg == "-multi")
- {
- anIsMulti = true;
- if (anArgIter + 1 < theArgc
- && Draw::ParseOnOff (theArgv[anArgIter + 1], anIsMulti))
- {
- ++anArgIter;
- }
- }
- else if (anArg == "-mergeangle"
- || anArg == "-smoothangle"
- || anArg == "-nomergeangle"
- || anArg == "-nosmoothangle")
- {
- if (anArg.StartsWith ("-no"))
- {
- aMergeAngle = M_PI / 2.0;
- }
- else
- {
- aMergeAngle = M_PI / 4.0;
- if (anArgIter + 1 < theArgc
- && Draw::ParseReal (theArgv[anArgIter + 1], aMergeAngle))
- {
- if (aMergeAngle < 0.0 || aMergeAngle > 90.0)
- {
- theDI << "Syntax error: angle should be within [0,90] range";
- return 1;
- }
-
- ++anArgIter;
- aMergeAngle = aMergeAngle * M_PI / 180.0;
- }
- }
- }
- else
- {
- Message::SendFail() << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'";
- return 1;
- }
- }
- if (aFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: not enough arguments";
- return 1;
- }
-
- TopoDS_Shape aShape;
- if (!toCreateCompOfTris)
- {
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI,1);
- if(anIsMulti)
- {
- NCollection_Sequence<Handle(Poly_Triangulation)> aTriangList;
- // Read STL file to the triangulation list.
- RWStl::ReadFile(aFilePath.ToCString(),aMergeAngle,aTriangList,aProgress->Start());
- BRep_Builder aB;
- TopoDS_Face aFace;
- if (aTriangList.Size() == 1)
- {
- aB.MakeFace (aFace);
- aB.UpdateFace (aFace,aTriangList.First());
- aShape = aFace;
- }
- else
- {
- TopoDS_Compound aCmp;
- aB.MakeCompound (aCmp);
-
- NCollection_Sequence<Handle(Poly_Triangulation)>::Iterator anIt (aTriangList);
- for (; anIt.More(); anIt.Next())
- {
- aB.MakeFace (aFace);
- aB.UpdateFace (aFace,anIt.Value());
- aB.Add (aCmp,aFace);
- }
- aShape = aCmp;
- }
- }
- else
- {
- // Read STL file to the triangulation.
- Handle(Poly_Triangulation) aTriangulation = RWStl::ReadFile (aFilePath.ToCString(),aMergeAngle,aProgress->Start());
-
- TopoDS_Face aFace;
- BRep_Builder aB;
- aB.MakeFace (aFace);
- aB.UpdateFace (aFace,aTriangulation);
- aShape = aFace;
- }
- }
- else
- {
- Standard_DISABLE_DEPRECATION_WARNINGS
- StlAPI::Read(aShape, aFilePath.ToCString());
- Standard_ENABLE_DEPRECATION_WARNINGS
- }
- DBRep::Set (aShapeName.ToCString(), aShape);
- return 0;
-}
-
-//=============================================================================
-//function : ReadObj
-//purpose : Reads OBJ file
-//=============================================================================
-static Standard_Integer ReadObj (Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- TCollection_AsciiString aDestName, aFilePath;
- Standard_Boolean toUseExistingDoc = Standard_False;
- Standard_Real aFileUnitFactor = -1.0;
- RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
- Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False;
- Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj");
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
- anArgCase.LowerCase();
- if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-unit"
- || anArgCase == "-units"
- || anArgCase == "-fileunit"
- || anArgCase == "-fileunits"))
- {
- const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
- aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
- if (aFileUnitFactor <= 0.0)
- {
- Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
- return 1;
- }
- }
- else if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-filecoordinatesystem"
- || anArgCase == "-filecoordsystem"
- || anArgCase == "-filecoordsys"))
- {
- if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
- {
- Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- else if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-resultcoordinatesystem"
- || anArgCase == "-resultcoordsystem"
- || anArgCase == "-resultcoordsys"
- || anArgCase == "-rescoordsys"))
- {
- if (!parseCoordinateSystem (theArgVec[++anArgIter], aResultCoordSys))
- {
- Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- else if (anArgCase == "-singleprecision"
- || anArgCase == "-singleprec")
- {
- isSinglePrecision = Standard_True;
- if (anArgIter + 1 < theNbArgs
- && Draw::ParseOnOff (theArgVec[anArgIter + 1], isSinglePrecision))
- {
- ++anArgIter;
- }
- }
- else if (isNoDoc
- && (anArgCase == "-singleface"
- || anArgCase == "-singletriangulation"))
- {
- isSingleFace = Standard_True;
- }
- else if (!isNoDoc
- && (anArgCase == "-nocreate"
- || anArgCase == "-nocreatedoc"))
- {
- toUseExistingDoc = Standard_True;
- if (anArgIter + 1 < theNbArgs
- && Draw::ParseOnOff (theArgVec[anArgIter + 1], toUseExistingDoc))
- {
- ++anArgIter;
- }
- }
- else if (anArgCase == "-listexternalfiles"
- || anArgCase == "-listexternals"
- || anArgCase == "-listexternal"
- || anArgCase == "-external"
- || anArgCase == "-externalfiles")
- {
- toListExternalFiles = Standard_True;
- }
- else if (aDestName.IsEmpty())
- {
- aDestName = theArgVec[anArgIter];
- }
- else if (aFilePath.IsEmpty())
- {
- aFilePath = theArgVec[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
- Handle(TDocStd_Document) aDoc;
- if (!isNoDoc
- && !toListExternalFiles)
- {
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- Standard_CString aNameVar = aDestName.ToCString();
- DDocStd::GetDocument (aNameVar, aDoc, Standard_False);
- if (aDoc.IsNull())
- {
- if (toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDestName << " does not exist";
- return 1;
- }
- anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
- }
- else if (!toUseExistingDoc)
- {
- Message::SendFail() << "Error: document with name " << aDestName << " already exists";
- return 1;
- }
- }
- Standard_Real aScaleFactorM = 1.;
- if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM, UnitsMethods_LengthUnit_Meter))
- {
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
- }
-
- RWObj_CafReader aReader;
- aReader.SetSinglePrecision (isSinglePrecision);
- aReader.SetSystemLengthUnit (aScaleFactorM);
- aReader.SetSystemCoordinateSystem (aResultCoordSys);
- aReader.SetFileLengthUnit (aFileUnitFactor);
- aReader.SetFileCoordinateSystem (aFileCoordSys);
- aReader.SetDocument (aDoc);
- if (isSingleFace)
- {
- RWObj_TriangulationReader aSimpleReader;
- aSimpleReader.SetSinglePrecision (isSinglePrecision);
- aSimpleReader.SetCreateShapes (Standard_False);
- aSimpleReader.SetTransformation (aReader.CoordinateSystemConverter());
- aSimpleReader.Read (aFilePath.ToCString(), aProgress->Start());
-
- Handle(Poly_Triangulation) aTriangulation = aSimpleReader.GetTriangulation();
- TopoDS_Face aFace;
- BRep_Builder aBuiler;
- aBuiler.MakeFace (aFace);
- aBuiler.UpdateFace (aFace, aTriangulation);
- DBRep::Set (aDestName.ToCString(), aFace);
- return 0;
- }
-
- if (toListExternalFiles)
- {
- aReader.ProbeHeader (aFilePath);
- for (NCollection_IndexedMap<TCollection_AsciiString>::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next())
- {
- theDI << "\"" << aFileIter.Value() << "\" ";
- }
- }
- else
- {
- aReader.Perform (aFilePath, aProgress->Start());
- if (isNoDoc)
- {
- DBRep::Set (aDestName.ToCString(), aReader.SingleShape());
- }
- else
- {
- Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument (aDoc);
- TDataStd_Name::Set (aDoc->GetData()->Root(), aDestName);
- Draw::Set (aDestName.ToCString(), aDrawDoc);
- }
- }
- return 0;
-}
-
-//=============================================================================
-//function : WriteObj
-//purpose : Writes OBJ file
-//=============================================================================
-static Standard_Integer WriteObj (Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- TCollection_AsciiString anObjFilePath;
- Handle(TDocStd_Document) aDoc;
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- TColStd_IndexedDataMapOfStringString aFileInfo;
- Standard_Real aFileUnitFactor = -1.0;
- RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArgCase (theArgVec[anArgIter]);
- anArgCase.LowerCase();
- if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-unit"
- || anArgCase == "-units"
- || anArgCase == "-fileunit"
- || anArgCase == "-fileunits"))
- {
- const TCollection_AsciiString aUnitStr (theArgVec[++anArgIter]);
- aFileUnitFactor = UnitsAPI::AnyToSI (1.0, aUnitStr.ToCString());
- if (aFileUnitFactor <= 0.0)
- {
- Message::SendFail() << "Syntax error: wrong length unit '" << aUnitStr << "'";
- return 1;
- }
- }
- else if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-filecoordinatesystem"
- || anArgCase == "-filecoordsystem"
- || anArgCase == "-filecoordsys"))
- {
- if (!parseCoordinateSystem (theArgVec[++anArgIter], aFileCoordSys))
- {
- Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- else if (anArgIter + 1 < theNbArgs
- && (anArgCase == "-systemcoordinatesystem"
- || anArgCase == "-systemcoordsystem"
- || anArgCase == "-systemcoordsys"
- || anArgCase == "-syscoordsys"))
- {
- if (!parseCoordinateSystem (theArgVec[++anArgIter], aSystemCoordSys))
- {
- Message::SendFail() << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- else if (anArgCase == "-comments"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
- }
- else if (anArgCase == "-author"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Author", theArgVec[++anArgIter]);
- }
- else if (aDoc.IsNull())
- {
- Standard_CString aNameVar = theArgVec[anArgIter];
- DDocStd::GetDocument (aNameVar, aDoc, false);
- if (aDoc.IsNull())
- {
- TopoDS_Shape aShape = DBRep::Get (aNameVar);
- if (aShape.IsNull())
- {
- Message::SendFail() << "Syntax error: '" << aNameVar << "' is not a shape nor document";
- return 1;
- }
-
- anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
- aShapeTool->AddShape (aShape);
- }
- }
- else if (anObjFilePath.IsEmpty())
- {
- anObjFilePath = theArgVec[anArgIter];
- }
- else
- {
- Message::SendFail() << "Syntax error at '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (anObjFilePath.IsEmpty())
- {
- Message::SendFail() << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
-
- const Standard_Real aSystemUnitFactor = UnitsMethods::GetCasCadeLengthUnit() * 0.001;
- RWObj_CafWriter aWriter (anObjFilePath);
- aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (aSystemUnitFactor);
- aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (aSystemCoordSys);
- aWriter.ChangeCoordinateSystemConverter().SetOutputLengthUnit (aFileUnitFactor);
- aWriter.ChangeCoordinateSystemConverter().SetOutputCoordinateSystem (aFileCoordSys);
- aWriter.Perform (aDoc, aFileInfo, aProgress->Start());
- return 0;
-}
-
-static Standard_Integer writevrml
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc < 3 || argc > 5)
- {
- di << "wrong number of parameters\n";
- return 0;
- }
-
- TopoDS_Shape aShape = DBRep::Get(argv[1]);
-
- // Get the optional parameters
- Standard_Integer aVersion = 2;
- Standard_Integer aType = 1;
- if (argc >= 4)
- {
- aVersion = Draw::Atoi(argv[3]);
- if (argc == 5)
- aType = Draw::Atoi(argv[4]);
- }
-
- // Bound parameters
- aVersion = Max(1, aVersion);
- aVersion = Min(2, aVersion);
- aType = Max(0, aType);
- aType = Min(2, aType);
-
- VrmlAPI_Writer writer;
-
- switch (aType)
- {
- case 0: writer.SetRepresentation(VrmlAPI_ShadedRepresentation); break;
- case 1: writer.SetRepresentation(VrmlAPI_WireFrameRepresentation); break;
- case 2: writer.SetRepresentation(VrmlAPI_BothRepresentation); break;
- }
-
- if (!writer.Write(aShape, argv[2], aVersion))
- {
- di << "Error: File " << argv[2] << " was not written\n";
- }
-
- return 0;
-}
-
-//=======================================================================
-//function : loadvrml
-//purpose :
-//=======================================================================
-
-static Standard_Integer loadvrml
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc<3) di << "wrong number of parameters" << "\n";
- else {
- TopoDS_Shape aShape ;
- VrmlData_DataMapOfShapeAppearance aShapeAppMap;
-
- //-----------------------------------------------------------
- std::filebuf aFic;
- std::istream aStream (&aFic);
-
- if (aFic.open(argv[2], std::ios::in)) {
-
- // Get path of the VRML file.
- OSD_Path aPath(argv[2]);
- TCollection_AsciiString aVrmlDir(".");
- TCollection_AsciiString aDisk = aPath.Disk();
- TCollection_AsciiString aTrek = aPath.Trek();
- if (!aTrek.IsEmpty())
- {
- if (!aDisk.IsEmpty())
- aVrmlDir = aDisk;
- else
- aVrmlDir.Clear();
- aTrek.ChangeAll('|', '/');
- aVrmlDir += aTrek;
- }
-
- VrmlData_Scene aScene;
- XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
- Standard_Real anOCCUnitMM = UnitsMethods::GetCasCadeLengthUnit();
- aScene.SetLinearScale(1000. / anOCCUnitMM);
-
- aScene.SetVrmlDir (aVrmlDir);
- aScene << aStream;
- const char * aStr = 0L;
- switch (aScene.Status()) {
-
- case VrmlData_StatusOK:
- {
- aShape = aScene.GetShape(aShapeAppMap);
- break;
- }
- case VrmlData_EmptyData: aStr = "EmptyData"; break;
- case VrmlData_UnrecoverableError: aStr = "UnrecoverableError"; break;
- case VrmlData_GeneralError: aStr = "GeneralError"; break;
- case VrmlData_EndOfFile: aStr = "EndOfFile"; break;
- case VrmlData_NotVrmlFile: aStr = "NotVrmlFile"; break;
- case VrmlData_CannotOpenFile: aStr = "CannotOpenFile"; break;
- case VrmlData_VrmlFormatError: aStr = "VrmlFormatError"; break;
- case VrmlData_NumericInputError: aStr = "NumericInputError"; break;
- case VrmlData_IrrelevantNumber: aStr = "IrrelevantNumber"; break;
- case VrmlData_BooleanInputError: aStr = "BooleanInputError"; break;
- case VrmlData_StringInputError: aStr = "StringInputError"; break;
- case VrmlData_NodeNameUnknown: aStr = "NodeNameUnknown"; break;
- case VrmlData_NonPositiveSize: aStr = "NonPositiveSize"; break;
- case VrmlData_ReadUnknownNode: aStr = "ReadUnknownNode"; break;
- case VrmlData_NonSupportedFeature: aStr = "NonSupportedFeature"; break;
- case VrmlData_OutputStreamUndefined:aStr = "OutputStreamUndefined"; break;
- case VrmlData_NotImplemented: aStr = "NotImplemented"; break;
- default:
- break;
- }
- if (aStr) {
- di << " ++ VRML Error: " << aStr << " in line "
- << aScene.GetLineError() << "\n";
- }
- else {
- DBRep::Set(argv[1],aShape);
- }
- }
- else {
- di << "cannot open file\n";
- }
-
-
- //-----------------------------------------------------------
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-static Standard_Integer createmesh
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<3)
- {
- di << "Wrong number of parameters\n";
- di << "Use: " << argv[0] << " <mesh name> <stl file>\n";
- return 0;
- }
-
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if (aContext.IsNull())
- {
- di << "No active view. Please call 'vinit' first\n";
- return 0;
- }
-
- // Progress indicator
- OSD_Path aFile( argv[2] );
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
- Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile (aFile, aProgress->Start());
-
- di << "Reading OK...\n";
- Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( aSTLMesh );
- di << "Data source is created successful\n";
- Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
- di << "MeshVS_Mesh is created successful\n";
-
- aMesh->SetDataSource( aDS );
- aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
-
- aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
-
- // Hide all nodes by default
- Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
- const Standard_Integer aLen = aSTLMesh->NbNodes();
- for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
- aNodes->ChangeMap().Add( anIndex );
- aMesh->SetHiddenNodes( aNodes );
- aMesh->SetSelectableNodes ( aNodes );
-
- VDisplayAISObject(argv[1], aMesh);
- aContext->Deactivate( aMesh );
-
- Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
- Handle( V3d_View ) aView = ViewerTest::CurrentView();
- if ( !aView.IsNull() )
- aView->FitAll();
-
- return 0;
-}
-//-----------------------------------------------------------------------------
-
-static Standard_Integer create3d
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- {
- di << "Wrong number of parameters\n";
- di << "Use: " << argv[0] << " <mesh name>\n";
- return 0;
- }
-
- Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
- if (aContext.IsNull())
- {
- di << "No active view. Please call 'vinit' first\n";
- return 0;
- }
-
- Handle( XSDRAWSTLVRML_DataSource3D ) aDS = new XSDRAWSTLVRML_DataSource3D();
- di << "Data source is created successful\n";
- Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
- di << "MeshVS_Mesh is created successful\n";
-
- aMesh->SetDataSource( aDS );
- aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
-
- aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
-
- // Hide all nodes by default
- Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
- Standard_Integer aLen = aDS->GetAllNodes().Extent();
- for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
- aNodes->ChangeMap().Add( anIndex );
- aMesh->SetHiddenNodes( aNodes );
- aMesh->SetSelectableNodes ( aNodes );
-
- VDisplayAISObject(argv[1], aMesh);
- aContext->Deactivate( aMesh );
-
- Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
- Handle( V3d_View ) aView = ViewerTest::CurrentView();
- if ( !aView.IsNull() )
- aView->FitAll();
-
- return 0;
-}
-
-Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
-{
- Handle( XSDRAWSTLVRML_DrawableMesh ) aDrawMesh =
- Handle( XSDRAWSTLVRML_DrawableMesh )::DownCast( Draw::Get( theName ) );
-
- if( aDrawMesh.IsNull() )
- {
- di << "There is no such object\n";
- return NULL;
- }
- else
- {
- Handle( MeshVS_Mesh ) aMesh = aDrawMesh->GetMesh();
- if( aMesh.IsNull() )
- {
- di << "There is invalid mesh\n";
- return NULL;
- }
- else
- return aMesh;
- }
-}
-
-//-----------------------------------------------------------------------------
-static Standard_Integer setcolor
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv, Standard_Integer theParam )
-{
- if (argc<5)
- di << "Wrong number of parameters\n";
- else
- {
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( !aMesh.IsNull() )
- {
- Standard_Real aRed = Draw::Atof (argv[2]);
- Standard_Real aGreen = Draw::Atof (argv[3]);
- Standard_Real aBlue = Draw::Atof (argv[4]);
- aMesh->GetDrawer()->SetColor( (MeshVS_DrawerAttribute)theParam,
- Quantity_Color( aRed, aGreen, aBlue, Quantity_TOC_RGB ) );
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- aContext->Redisplay (aMesh, Standard_True);
- }
- }
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer meshcolor
-(Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
-{
- return setcolor( theInterp, argc, argv, MeshVS_DA_InteriorColor );
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer linecolor
-(Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
-{
- return setcolor( theInterp, argc, argv, MeshVS_DA_EdgeColor );
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer meshmat
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<3)
- di << "Wrong number of parameters\n";
- else
- {
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( !aMesh.IsNull() )
- {
- Standard_Integer aMaterial = Draw::Atoi (argv[2]);
-
- Graphic3d_MaterialAspect aMatAsp =
- (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial;
-
- if (argc == 4)
- {
- Standard_Real aTransparency = Draw::Atof(argv[3]);
- aMatAsp.SetTransparency (Standard_ShortReal (aTransparency));
- }
- aMesh->GetDrawer()->SetMaterial( MeshVS_DA_FrontMaterial, aMatAsp );
- aMesh->GetDrawer()->SetMaterial( MeshVS_DA_BackMaterial, aMatAsp );
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- aContext->Redisplay (aMesh, Standard_True);
- }
- }
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer shrink
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<3)
- di << "Wrong number of parameters\n";
- else
- {
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( !aMesh.IsNull() )
- {
- Standard_Real aShrinkCoeff = Draw::Atof (argv[2]);
- aMesh->GetDrawer()->SetDouble( MeshVS_DA_ShrinkCoeff, aShrinkCoeff );
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- aContext->Redisplay (aMesh, Standard_True);
- }
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
-{
- if (theArgc < 3)
- {
- theDI << "Wrong number of parameters.\n";
- }
- else
- {
- Handle(MeshVS_Mesh) aMesh = getMesh (theArgv[1], theDI);
- if (!aMesh.IsNull())
- {
- Standard_Boolean aFlag = Draw::Atoi (theArgv[2]) != 0;
- aMesh->GetDrawer()->SetBoolean (MeshVS_DA_SupressBackFaces, aFlag);
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
- if (aContext.IsNull())
- {
- theDI << "The context is null\n";
- }
- else
- {
- aContext->Redisplay (aMesh, Standard_True);
- }
- }
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-static Standard_Integer mdisplay
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- di << "Wrong number of parameters\n";
- else
- {
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( !aMesh.IsNull() )
- {
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- {
- aContext->Display (aMesh, Standard_True);
- }
- }
- }
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer merase
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- di << "Wrong number of parameters\n";
- else
- {
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( !aMesh.IsNull() )
- {
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- {
- aContext->Erase (aMesh, Standard_True);
- }
- }
- else
- di << "Mesh is null\n";
- }
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer hidesel
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- {
- di << "Wrong number of parameters\n";
- di << "Use: " << argv[0] << " <mesh name>\n";
- return 0;
- }
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( aMesh.IsNull() )
- {
- di << "The mesh is invalid\n";
- return 0;
- }
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- {
- Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
- if (aHiddenNodes.IsNull())
- {
- aHiddenNodes = new TColStd_HPackedMapOfInteger();
- }
- Handle(TColStd_HPackedMapOfInteger) aHiddenElements = aMesh->GetHiddenElems();
- if (aHiddenElements.IsNull())
- {
- aHiddenElements = new TColStd_HPackedMapOfInteger();
- }
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- {
- Handle( MeshVS_MeshEntityOwner ) anOwner =
- Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
- if( !anOwner.IsNull() )
- {
- if( anOwner->Type()==MeshVS_ET_Node )
- {
- aHiddenNodes->ChangeMap().Add( anOwner->ID() );
- }
- else
- {
- aHiddenElements->ChangeMap().Add( anOwner->ID() );
- }
- }
- }
- aContext->ClearSelected (Standard_False);
- aMesh->SetHiddenNodes( aHiddenNodes );
- aMesh->SetHiddenElems( aHiddenElements );
- aContext->Redisplay (aMesh, Standard_True);
- }
-
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer showonly
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- {
- di << "Wrong number of parameters\n";
- di << "Use: " << argv[0] << " <mesh name>\n";
- return 0;
- }
-
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( aMesh.IsNull() )
- {
- di << "The mesh is invalid\n";
- return 0;
- }
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- {
- Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
- new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
- Handle(TColStd_HPackedMapOfInteger) aHiddenElements =
- new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements());
- for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
- {
- Handle( MeshVS_MeshEntityOwner ) anOwner =
- Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
- if( !anOwner.IsNull() )
- {
- if( anOwner->Type() == MeshVS_ET_Node )
- {
- aHiddenNodes->ChangeMap().Remove( anOwner->ID() );
- }
- else
- {
- aHiddenElements->ChangeMap().Remove( anOwner->ID() );
- }
- }
- }
- aMesh->SetHiddenNodes( aHiddenNodes );
- aMesh->SetHiddenElems( aHiddenElements );
- aContext->Redisplay (aMesh, Standard_True);
- }
-
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer showall
-(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
-{
- if (argc<2)
- {
- di << "Wrong number of parameters\n";
- di << "Use: " << argv[0] << " <mesh name>\n";
- return 0;
- }
-
- Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
- if( aMesh.IsNull() )
- {
- di << "The mesh is invalid\n";
- return 0;
- }
-
- if( aContext.IsNull() )
- di << "The context is null\n";
- else
- {
- aMesh->SetHiddenNodes( new TColStd_HPackedMapOfInteger() );
- aMesh->SetHiddenElems( new TColStd_HPackedMapOfInteger() );
- aContext->Redisplay (aMesh, Standard_True);
- }
-
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-static Standard_Integer meshcolors( Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv )
-{
- try
- {
- OCC_CATCH_SIGNALS
- if ( argc < 4 )
- {
- di << "Wrong number of parameters\n";
- di << "Use : meshcolors <mesh name> <mode> <isreflect>\n";
- di << "mode : {elem1|elem2|nodal|nodaltex|none}\n";
- di << " elem1 - different color for each element\n";
- di << " elem2 - one color for one side\n";
- di << " nodal - different color for each node\n";
- di << " nodaltex - different color for each node with texture interpolation\n";
- di << " none - clear\n";
- di << "isreflect : {0|1} \n";
-
- return 0;
- }
-
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
-
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
- Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
- if ( anIC.IsNull() )
- {
- di << "The context is null\n";
- return 0;
- }
- if( !aMesh.IsNull() )
- {
- TCollection_AsciiString aMode = TCollection_AsciiString (argv[2]);
- Quantity_Color aColor1(Quantity_NOC_BLUE1);
- Quantity_Color aColor2(Quantity_NOC_RED1);
- if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none") )
- {
- Handle(MeshVS_PrsBuilder) aTempBuilder;
- Standard_Integer aReflection = Draw::Atoi(argv[3]);
-
- for (Standard_Integer aCount = 0 ; aCount < aMesh->GetBuildersCount(); aCount++ ){
- aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
- if( !aTempBuilder.IsNull())
- aMesh->RemoveBuilderById(aTempBuilder->GetId());
-
- aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
- if( !aTempBuilder.IsNull())
- aMesh->RemoveBuilderById(aTempBuilder->GetId());
- }
-
- if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") )
- {
- Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
- aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask );
- // Color
- const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
- TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllElements );
-
- if( aMode.IsEqual("elem1") )
- for ( ; anIter.More(); anIter.Next() )
- {
- Quantity_Color aColor( (Quantity_NameOfColor)( anIter.Key() % Quantity_NOC_WHITE ) );
- aBuilder->SetColor1( anIter.Key(), aColor );
- }
- else
- for ( ; anIter.More(); anIter.Next() )
- aBuilder->SetColor2( anIter.Key(), aColor1, aColor2 );
-
- aMesh->AddBuilder( aBuilder, Standard_True );
- }
-
-
- if( aMode.IsEqual("nodal") )
- {
- Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
- aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask );
- aMesh->AddBuilder( aBuilder, Standard_True );
-
- // Color
- const TColStd_PackedMapOfInteger& anAllNodes =
- aMesh->GetDataSource()->GetAllNodes();
- TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllNodes );
- for ( ; anIter.More(); anIter.Next() )
- {
- Quantity_Color aColor( (Quantity_NameOfColor)(
- anIter.Key() % Quantity_NOC_WHITE ) );
- aBuilder->SetColor( anIter.Key(), aColor );
- }
- aMesh->AddBuilder( aBuilder, Standard_True );
- }
-
- if(aMode.IsEqual("nodaltex"))
- {
- // assign nodal builder to the mesh
- Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
- aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
- aMesh->AddBuilder(aBuilder, Standard_True);
- aBuilder->UseTexture(Standard_True);
-
- // prepare color map for texture
- Aspect_SequenceOfColor aColorMap;
- aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_RED);
- aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_YELLOW);
- aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_BLUE1);
-
- // prepare scale map for mesh - it will be assigned to mesh as texture coordinates
- // make mesh color interpolated from minimum X coord to maximum X coord
- Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource();
- Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
-
- // get bounding box for calculations
- aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
- Standard_Real aDelta = aMaxX - aMinX;
-
- // assign color scale map values (0..1) to nodes
- TColStd_DataMapOfIntegerReal aScaleMap;
- TColStd_Array1OfReal aCoords(1, 3);
- Standard_Integer aNbNodes;
- MeshVS_EntityType aType;
-
- // iterate nodes
- const TColStd_PackedMapOfInteger& anAllNodes =
- aMesh->GetDataSource()->GetAllNodes();
- TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes);
- for (; anIter.More(); anIter.Next())
- {
- //get node coordinates to aCoord variable
- aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
-
- Standard_Real aScaleValue;
- try {
- OCC_CATCH_SIGNALS
- aScaleValue = (aCoords.Value(1) - (Standard_Real) aMinX) / aDelta;
- } catch(Standard_Failure const&) {
- aScaleValue = 0;
- }
-
- aScaleMap.Bind(anIter.Key(), aScaleValue);
- }
-
- //set color map for builder and a color for invalid scale value
- aBuilder->SetColorMap(aColorMap);
- aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
- aBuilder->SetTextureCoords(aScaleMap);
- aMesh->AddBuilder(aBuilder, Standard_True);
- }
-
- aMesh->GetDrawer()->SetBoolean (MeshVS_DA_ColorReflection, aReflection != 0);
-
- anIC->Redisplay (aMesh, Standard_True);
- }
- else
- {
- di << "Wrong mode name\n";
- return 0;
- }
- }
- }
- catch ( Standard_Failure const& )
- {
- di << "Error\n";
- }
-
- return 0;
-}
-//-----------------------------------------------------------------------------
-static Standard_Integer meshvectors( Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv )
-{
- if ( argc < 3 )
- {
- di << "Wrong number of parameters\n";
- di << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n";
- di << "Supported mode values:\n";
- di << " elem - vector per element\n";
- di << " nodal - vector per node\n";
- di << " none - clear\n";
-
- return 0;
- }
-
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
-
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
- Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
- if ( anIC.IsNull() )
- {
- di << "The context is null\n";
- return 0;
- }
-
- TCollection_AsciiString aParam;
- TCollection_AsciiString aMode("none");
- Standard_Real aMaxlen(1.0);
- Quantity_Color aColor(Quantity_NOC_ORANGE);
- Standard_Real anArrowPart(0.1);
- Standard_Boolean isSimplePrs(Standard_False);
-
- for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
- {
- if (!aParam.IsEmpty())
- {
- if (aParam == "-mode")
- {
- aMode = argv[anIdx];
- }
- else if (aParam == "-maxlen")
- {
- aMaxlen = Draw::Atof(argv[anIdx]);
- }
- else if (aParam == "-color")
- {
- if (!Quantity_Color::ColorFromName (argv[anIdx], aColor))
- {
- Message::SendFail() << "Syntax error at " << aParam;
- return 1;
- }
- }
- else if (aParam == "-arrowpart")
- {
- anArrowPart = Draw::Atof(argv[anIdx]);
- }
- else if (aParam == "-issimple")
- {
- isSimplePrs = Draw::Atoi(argv[anIdx]) != 0;
- }
- aParam.Clear();
- }
- else if (argv[anIdx][0] == '-')
- {
- aParam = argv[anIdx];
- }
- }
-
- if( !aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none") )
- {
- di << "Wrong mode name\n";
- return 0;
- }
-
- Handle(MeshVS_PrsBuilder) aTempBuilder;
-
- aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder");
- if( !aTempBuilder.IsNull())
- aMesh->RemoveBuilderById(aTempBuilder->GetId());
-
- if( !aMode.IsEqual("none") )
- {
- Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder( aMesh.operator->(),
- aMaxlen,
- aColor,
- MeshVS_DMF_VectorDataPrs,
- 0,
- -1,
- MeshVS_BP_Vector,
- isSimplePrs);
-
- Standard_Boolean anIsElement = aMode.IsEqual("elem");
- const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() :
- aMesh->GetDataSource()->GetAllNodes();
-
- Standard_Integer aNbNodes;
- MeshVS_EntityType aEntType;
-
- TColStd_Array1OfReal aCoords(1, 3);
- aCoords.Init (0.);
- TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
- for ( ; anIter.More(); anIter.Next() )
- {
- Standard_Boolean IsValidData = Standard_False;
- if (anIsElement) {
- aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType);
- if (aEntType == MeshVS_ET_Face)
- IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
- } else
- IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
-
- gp_Vec aNorm;
- if(IsValidData)
- {
- aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
- if(aNorm.Magnitude() < gp::Resolution())
- {
- aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes
- }
- }
- else
- {
- aNorm = gp_Vec(0,0,1);
- }
- aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
- }
-
- aMesh->AddBuilder( aBuilder, Standard_False );
- aMesh->GetDrawer()->SetDouble ( MeshVS_DA_VectorArrowPart, anArrowPart );
- }
-
- anIC->Redisplay (aMesh, Standard_True);
-
- return 0;
-}
-//-----------------------------------------------------------------------------
-
-static Standard_Integer meshtext( Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv )
-{
- if ( argc < 2 )
- {
- di << "Wrong number of parameters\n";
- di << "Use : meshtext <mesh name>\n";
- return 0;
- }
-
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
-
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
-
- Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
- if ( anIC.IsNull() )
- {
- di << "The context is null\n";
- return 0;
- }
-
- // Prepare triangle labels
- MeshVS_DataMapOfIntegerAsciiString aLabels;
- Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent();
- for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ ){
- aLabels.Bind( anIndex, TCollection_AsciiString( anIndex ) );
- }
-
- Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder( aMesh.operator->(), 20., Quantity_NOC_YELLOW );
- aTextBuilder->SetTexts( Standard_True, aLabels );
- aMesh->AddBuilder( aTextBuilder );
-
- return 0;
-}
-
-static Standard_Integer meshdeform( Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv )
-{
- if ( argc < 3 )
- {
- di << "Wrong number of parameters\n";
- di << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
- return 0;
- }
-
- Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
-
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
- Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
- if ( anIC.IsNull() )
- {
- di << "The context is null\n";
- return 0;
- }
-
- TCollection_AsciiString aParam;
- TCollection_AsciiString aMode("off");
- Standard_Real aScale(1.0);
-
- for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
- {
- if (!aParam.IsEmpty())
- {
- if (aParam == "-mode")
- {
- aMode = argv[anIdx];
- }
- else if (aParam == "-scale")
- {
- aScale = Draw::Atof(argv[anIdx]);
- }
- aParam.Clear();
- }
- else if (argv[anIdx][0] == '-')
- {
- aParam = argv[anIdx];
- }
- }
-
- if(!aMode.IsEqual("on") && !aMode.IsEqual("off"))
- {
- di << "Wrong mode name\n";
- return 0;
- }
-
- Handle ( MeshVS_DeformedDataSource ) aDefDS =
- new MeshVS_DeformedDataSource( aMesh->GetDataSource() , aScale );
-
- const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes();
-
- Standard_Integer aNbNodes;
- MeshVS_EntityType aEntType;
-
- TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
- for ( ; anIter.More(); anIter.Next() )
- {
- TColStd_Array1OfReal aCoords(1, 3);
- aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
-
- gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
- if( !aNorm.Magnitude() )
- aNorm = gp_Vec(0,0,1);
- aDefDS->SetVector(anIter.Key(), aNorm.Normalized());
- }
-
- aMesh->SetDataSource(aDefDS);
-
- anIC->Redisplay (aMesh, Standard_False);
-
- Handle( V3d_View ) aView = ViewerTest::CurrentView();
- if ( !aView.IsNull() )
- aView->FitAll();
-
- return 0;
-}
-
-static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv )
-{
- try
- {
- OCC_CATCH_SIGNALS
- if ( argc < 3 )
- {
- di << "Wrong number of parameters\n";
- di << "Use : mesh_edge_width <mesh name> <width>\n";
- return 0;
- }
-
- Handle(MeshVS_Mesh) aMesh = getMesh( argv[ 1 ], di );
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
-
- const char* aWidthStr = argv[ 2 ];
- if ( aWidthStr == 0 || Draw::Atof( aWidthStr ) <= 0 )
- {
- di << "Width must be real value more than zero\n";
- return 0;
- }
-
- double aWidth = Draw::Atof( aWidthStr );
-
- Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
- if ( anIC.IsNull() )
- {
- di << "The context is null\n";
- return 0;
- }
-
- Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
- if ( aDrawer.IsNull() )
- {
- di << "The drawer is null\n";
- return 0;
- }
-
- aDrawer->SetDouble( MeshVS_DA_EdgeWidth, aWidth );
- anIC->Redisplay (aMesh, Standard_True);
- }
- catch ( Standard_Failure const& )
- {
- di << "Error\n";
- }
-
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-static Standard_Integer meshinfo(Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv)
-{
- if ( argc != 2 )
- {
- di << "Wrong number of parameters. Use : meshinfo mesh\n";
- return 0;
- }
-
- Handle(MeshVS_Mesh) aMesh = getMesh(argv[ 1 ], di);
- if ( aMesh.IsNull() )
- {
- di << "Mesh not found\n";
- return 0;
- }
-
- Handle(XSDRAWSTLVRML_DataSource) stlMeshSource = Handle(XSDRAWSTLVRML_DataSource)::DownCast(aMesh->GetDataSource());
- if (!stlMeshSource.IsNull())
- {
- const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes();
- const TColStd_PackedMapOfInteger& tris = stlMeshSource->GetAllElements();
-
- di << "Nb nodes = " << nodes.Extent() << "\n";
- di << "Nb triangles = " << tris.Extent() << "\n";
- }
-
- return 0;
-}
-
-//=======================================================================
-//function : writeply
-//purpose : write PLY file
-//=======================================================================
-static Standard_Integer WritePly (Draw_Interpretor& theDI,
- Standard_Integer theNbArgs,
- const char** theArgVec)
-{
- Handle(TDocStd_Document) aDoc;
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- TCollection_AsciiString aShapeName, aFileName;
-
- Standard_Real aDist = 0.0;
- Standard_Real aDens = Precision::Infinite();
- Standard_Real aTol = Precision::Confusion();
- bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false;
- bool isPntSet = false, isDensityPoints = false;
- TColStd_IndexedDataMapOfStringString aFileInfo;
- for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
- {
- TCollection_AsciiString anArg (theArgVec[anArgIter]);
- anArg.LowerCase();
- if (anArg == "-normal")
- {
- hasNormals = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArg == "-nonormal")
- {
- hasNormals = !Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArg == "-color"
- || anArg == "-nocolor"
- || anArg == "-colors"
- || anArg == "-nocolors")
- {
- hasColors = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArg == "-uv"
- || anArg == "-nouv")
- {
- hasTexCoords = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if (anArg == "-partid")
- {
- hasPartId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
- hasFaceId = hasFaceId && !hasPartId;
- }
- else if (anArg == "-surfid"
- || anArg == "-surfaceid"
- || anArg == "-faceid")
- {
- hasFaceId = Draw::ParseOnOffNoIterator (theNbArgs, theArgVec, anArgIter);
- hasPartId = hasPartId && !hasFaceId;
- }
- else if (anArg == "-pntset"
- || anArg == "-pntcloud"
- || anArg == "-pointset"
- || anArg == "-pointcloud"
- || anArg == "-cloud"
- || anArg == "-points")
- {
- isPntSet = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
- }
- else if ((anArg == "-dist"
- || anArg == "-distance")
- && anArgIter + 1 < theNbArgs
- && Draw::ParseReal (theArgVec[anArgIter + 1], aDist))
- {
- ++anArgIter;
- isPntSet = true;
- if (aDist < 0.0)
- {
- theDI << "Syntax error: -distance value should be >= 0.0";
- return 1;
- }
- aDist = Max (aDist, Precision::Confusion());
- }
- else if ((anArg == "-dens"
- || anArg == "-density")
- && anArgIter + 1 < theNbArgs
- && Draw::ParseReal (theArgVec[anArgIter + 1], aDens))
- {
- ++anArgIter;
- isDensityPoints = Standard_True;
- isPntSet = true;
- if (aDens <= 0.0)
- {
- theDI << "Syntax error: -density value should be > 0.0";
- return 1;
- }
- }
- else if ((anArg == "-tol"
- || anArg == "-tolerance")
- && anArgIter + 1 < theNbArgs
- && Draw::ParseReal (theArgVec[anArgIter + 1], aTol))
- {
- ++anArgIter;
- isPntSet = true;
- if (aTol < Precision::Confusion())
- {
- theDI << "Syntax error: -tol value should be >= " << Precision::Confusion();
- return 1;
- }
- }
- else if (anArg == "-comments"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Comments", theArgVec[++anArgIter]);
- }
- else if (anArg == "-author"
- && anArgIter + 1 < theNbArgs)
- {
- aFileInfo.Add ("Author", theArgVec[++anArgIter]);
- }
- else if (aDoc.IsNull())
- {
- if (aShapeName.IsEmpty())
- {
- aShapeName = theArgVec[anArgIter];
- }
-
- Standard_CString aNameVar = theArgVec[anArgIter];
- DDocStd::GetDocument (aNameVar, aDoc, false);
- if (aDoc.IsNull())
- {
- TopoDS_Shape aShape = DBRep::Get (aNameVar);
- if (!aShape.IsNull())
- {
- anApp->NewDocument (TCollection_ExtendedString ("BinXCAF"), aDoc);
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
- aShapeTool->AddShape (aShape);
- }
- }
- }
- else if (aFileName.IsEmpty())
- {
- aFileName = theArgVec[anArgIter];
- }
- else
- {
- theDI << "Syntax error at '" << theArgVec[anArgIter] << "'";
- return 1;
- }
- }
- if (aDoc.IsNull()
- && !aShapeName.IsEmpty())
- {
- theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document";
- return 1;
- }
- else if (aDoc.IsNull()
- || aFileName.IsEmpty())
- {
- theDI << "Syntax error: wrong number of arguments";
- return 1;
- }
-
- TDF_LabelSequence aRootLabels;
- Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
- aShapeTool->GetFreeShapes (aRootLabels);
- if (aRootLabels.IsEmpty())
- {
- theDI << "Error: empty document";
- return 1;
- }
-
- if (isPntSet)
- {
- class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext
- {
- public:
- PointCloudPlyWriter (Standard_Real theTol)
- : BRepLib_PointCloudShape (TopoDS_Shape(), theTol) {}
-
- void AddFaceColor (const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor)
- { myFaceColor.Bind (theFace, theColor); }
-
- protected:
- virtual void addPoint (const gp_Pnt& thePoint,
- const gp_Vec& theNorm,
- const gp_Pnt2d& theUV,
- const TopoDS_Shape& theFace)
- {
- Graphic3d_Vec4ub aColor;
- myFaceColor.Find (theFace, aColor);
- RWPly_PlyWriterContext::WriteVertex (thePoint,
- Graphic3d_Vec3 ((float )theNorm.X(), (float )theNorm.Y(), (float )theNorm.Z()),
- Graphic3d_Vec2 ((float )theUV.X(), (float )theUV.Y()),
- aColor);
- }
-
- private:
- NCollection_DataMap<TopoDS_Shape, Graphic3d_Vec4ub> myFaceColor;
- };
-
- PointCloudPlyWriter aPlyCtx (aTol);
- aPlyCtx.SetNormals (hasNormals);
- aPlyCtx.SetColors (hasColors);
- aPlyCtx.SetTexCoords (hasTexCoords);
-
- TopoDS_Compound aComp;
- BRep_Builder().MakeCompound (aComp);
- for (XCAFPrs_DocumentExplorer aDocExplorer (aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes);
- aDocExplorer.More(); aDocExplorer.Next())
- {
- const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current();
- for (RWMesh_FaceIterator aFaceIter (aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next())
- {
- BRep_Builder().Add (aComp, aFaceIter.Face());
- Graphic3d_Vec4ub aColorVec (255);
- if (aFaceIter.HasFaceColor())
- {
- Graphic3d_Vec4 aColorF = aFaceIter.FaceColor();
- aColorVec.SetValues ((unsigned char )int(aColorF.r() * 255.0f),
- (unsigned char )int(aColorF.g() * 255.0f),
- (unsigned char )int(aColorF.b() * 255.0f),
- (unsigned char )int(aColorF.a() * 255.0f));
- }
- aPlyCtx.AddFaceColor (aFaceIter.Face(), aColorVec);
- }
- }
- aPlyCtx.SetShape (aComp);
-
- Standard_Integer aNbPoints = isDensityPoints
- ? aPlyCtx.NbPointsByDensity (aDens)
- : aPlyCtx.NbPointsByTriangulation();
- if (aNbPoints <= 0)
- {
- theDI << "Error: unable to generate points";
- return 0;
- }
-
- if (!aPlyCtx.Open (aFileName)
- || !aPlyCtx.WriteHeader (aNbPoints, 0, TColStd_IndexedDataMapOfStringString()))
- {
- theDI << "Error: unable to create file '" << aFileName << "'";
- return 0;
- }
-
- Standard_Boolean isDone = isDensityPoints
- ? aPlyCtx.GeneratePointsByDensity (aDens)
- : aPlyCtx.GeneratePointsByTriangulation();
- if (!isDone)
- {
- theDI << "Error: Point cloud was not generated in file '" << aFileName << "'";
- }
- else if (!aPlyCtx.Close())
- {
- theDI << "Error: Point cloud file '" << aFileName << "' was not written";
- }
- else
- {
- theDI << aNbPoints;
- }
- }
- else
- {
- Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
- RWPly_CafWriter aPlyCtx (aFileName);
- aPlyCtx.SetNormals (hasNormals);
- aPlyCtx.SetColors (hasColors);
- aPlyCtx.SetTexCoords (hasTexCoords);
- aPlyCtx.SetPartId (hasPartId);
- aPlyCtx.SetFaceId (hasFaceId);
- aPlyCtx.Perform (aDoc, aFileInfo, aProgress->Start());
- }
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-void XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
-{
- const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
- //XSDRAW::LoadDraw(theCommands);
-
- theCommands.Add ("ReadGltf",
- "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
- "\n\t\t: Read glTF file into XDE document."
- "\n\t\t: -listExternalFiles do not read mesh and only list external files"
- "\n\t\t: -noCreateDoc read into existing XDE document"
- "\n\t\t: -doublePrecision store triangulation with double or single floating point"
- "\n\t\t: precision (single by default)"
- "\n\t\t: -skipLateLoading data loading is skipped and can be performed later"
- "\n\t\t: (false by default)"
- "\n\t\t: -keepLate data is loaded into itself with preservation of information"
- "\n\t\t: about deferred storage to load/unload this data later."
- "\n\t\t: -allScenes load all scenes defined in the document instead of default one (false by default)"
- "\n\t\t: -toPrintDebugInfo print additional debug information during data reading"
- "\n\t\t: -assetInfo print asset information",
- __FILE__, ReadGltf, g);
- theCommands.Add ("readgltf",
- "readgltf shape file"
- "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.",
- __FILE__, ReadGltf, g);
- theCommands.Add ("WriteGltf",
- "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact"
- "\n\t\t: [-systemCoordSys {Zup|Yup}]=Zup"
- "\n\t\t: [-comments Text] [-author Name]"
- "\n\t\t: [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0"
- "\n\t\t: [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd"
- "\n\t\t: [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product"
- "\n\t\t: [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10"
- "\n\t\t: [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12"
- "\n\t\t: [-unifiedQuantization]=0 [-parallel]=0"
- "\n\t\t: Write XDE document into glTF file."
- "\n\t\t: -trsfFormat preferred transformation format"
- "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified"
- "\n\t\t: -mergeFaces merge Faces within the same Mesh"
- "\n\t\t: -splitIndices16 split Faces to keep 16-bit indices when -mergeFaces is enabled"
- "\n\t\t: -forceUVExport always export UV coordinates"
- "\n\t\t: -texturesSeparate write textures to separate files"
- "\n\t\t: -nodeNameFormat name format for Nodes"
- "\n\t\t: -meshNameFormat name format for Meshes"
- "\n\t\t: -draco use Draco compression 3D geometric meshes"
- "\n\t\t: -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order"
- "\n\t\t: -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)"
- "\n\t\t: -quantizeNormalBits quantization bits for normal attribute when using Draco compression (by default 10)"
- "\n\t\t: -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)"
- "\n\t\t: -quantizeColorBits quantization bits for color attribute when using Draco compression (by default 8)"
- "\n\t\t: -quantizeGenericBits quantization bits for skinning attribute (joint indices and joint weights)"
- "\n and custom attributes when using Draco compression (by default 12)"
- "\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false"
- "\n\t\t: -parallel use multithreading for Draco compression",
- __FILE__, WriteGltf, g);
- theCommands.Add ("writegltf",
- "writegltf shape file",
- __FILE__, WriteGltf, g);
- theCommands.Add ("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]",__FILE__,writevrml,g);
- theCommands.Add ("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]",__FILE__,writestl,g);
- theCommands.Add ("readstl",
- "readstl shape file [-brep] [-mergeAngle Angle] [-multi]"
- "\n\t\t: Reads STL file and creates a new shape with specified name."
- "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces."
- "\n\t\t: Single triangulation-only Face is created otherwise (default)."
- "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default."
- "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.",
- __FILE__, readstl, g);
- theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
- theCommands.Add ("ReadObj",
- "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
- "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
- "\n\t\t: [-listExternalFiles] [-noCreateDoc]"
- "\n\t\t: Read OBJ file into XDE document."
- "\n\t\t: -fileUnit length unit of OBJ file content;"
- "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
- "\n\t\t: -resultCoordSys result coordinate system; Zup when not specified."
- "\n\t\t: -singlePrecision truncate vertex data to single precision during read; FALSE by default."
- "\n\t\t: -listExternalFiles do not read mesh and only list external files."
- "\n\t\t: -noCreateDoc read into existing XDE document.",
- __FILE__, ReadObj, g);
- theCommands.Add ("readobj",
- "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
- "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
- "\n\t\t: [-singleFace]"
- "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document."
- "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.",
- __FILE__, ReadObj, g);
- theCommands.Add ("WriteObj",
- "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
- "\n\t\t: [-systemCoordSys {Zup|Yup}]"
- "\n\t\t: [-comments Text] [-author Name]"
- "\n\t\t: Write XDE document into OBJ file."
- "\n\t\t: -fileUnit length unit of OBJ file content;"
- "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
- "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.",
- __FILE__, WriteObj, g);
- theCommands.Add ("writeobj",
- "writeobj shape file",
- __FILE__, WriteObj, g);
-
- theCommands.Add ("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, g );
- theCommands.Add ("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, g );
- theCommands.Add ("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, g );
- theCommands.Add ("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, g );
- theCommands.Add ("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, g );
- theCommands.Add ("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, g );
- theCommands.Add ("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g);
- theCommands.Add ("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, g );
- theCommands.Add ("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, g );
- theCommands.Add ("meshhidesel", "hide selected entities", __FILE__, hidesel, g );
- theCommands.Add ("meshshowsel", "show only selected entities", __FILE__, showonly, g );
- theCommands.Add ("meshshowall", "show all entities", __FILE__, showall, g );
- theCommands.Add ("meshcolors", "display color presentation", __FILE__, meshcolors, g );
- theCommands.Add ("meshvectors", "display sample vectors", __FILE__, meshvectors, g );
- theCommands.Add ("meshtext", "display text labels", __FILE__, meshtext, g );
- theCommands.Add ("meshdeform", "display deformed mesh", __FILE__, meshdeform, g );
- theCommands.Add ("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, g );
- theCommands.Add ("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, g );
- theCommands.Add ("WritePly", R"(
-WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0
- [-pointCloud {0|1}]=0 [-distance Value]=0.0 [-density Value] [-tolerance Value]
-Write document or triangulated shape into PLY file.
- -normals write per-vertex normals
- -colors write per-vertex colors
- -uv write per-vertex UV coordinates
- -partId write per-element part index (alternative to -faceId)
- -faceId write per-element face index (alternative to -partId)
-
-Generate point cloud out of the shape and write it into PLY file.
- -pointCloud write point cloud instead without triangulation indices
- -distance sets distance from shape into the range [0, Value];
- -density sets density of points to generate randomly on surface;
- -tolerance sets tolerance; default value is Precision::Confusion();
-)", __FILE__, WritePly, g);
- theCommands.Add ("writeply",
- "writeply shape file",
- __FILE__, WritePly, g);
-}
-
-//==============================================================================
-// XSDRAWSTLVRML::Factory
-//==============================================================================
-void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI)
-{
- XSDRAWIGES::InitSelect();
- XSDRAWIGES::InitToBRep(theDI);
- XSDRAWIGES::InitFromBRep(theDI);
- XSDRAWSTEP::InitCommands(theDI);
- XSDRAWSTLVRML::InitCommands(theDI);
- XSDRAW::LoadDraw(theDI);
-#ifdef OCCT_DEBUG
- theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n";
-#endif
-}
-
-// Declare entry point PLUGINFACTORY
-DPLUGIN(XSDRAWSTLVRML)
-
+++ /dev/null
-// Created on: 2000-05-30
-// Created by: Sergey MOZOKHIN
-// Copyright (c) 2000-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 _XSDRAWSTLVRML_HeaderFile
-#define _XSDRAWSTLVRML_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_DefineAlloc.hxx>
-#include <Standard_Handle.hxx>
-
-#include <Draw_Interpretor.hxx>
-
-
-
-class XSDRAWSTLVRML
-{
-public:
-
- DEFINE_STANDARD_ALLOC
-
- //! Inits commands for writing to STL and VRML formats
- Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands);
-
- //! Loads all Draw commands of TKXSDRAW. Used for plugin.
- Standard_EXPORT static void Factory (Draw_Interpretor& theDI);
-
-};
-
-#endif // _XSDRAWSTLVRML_HeaderFile
+++ /dev/null
-// Created on: 2000-05-30
-// Created by: Sergey MOZOKHIN
-// Copyright (c) 2000-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 XSDRAWSTLVRML_CoordsMap_HeaderFile
-#define XSDRAWSTLVRML_CoordsMap_HeaderFile
-
-#include <TColStd_DataMapOfIntegerReal.hxx>
-#include <NCollection_DataMap.hxx>
-
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal> XSDRAWSTLVRML_CoordsMap;
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerReal>::Iterator XSDRAWSTLVRML_DataMapIteratorOfCoordsMap;
-
-
-#endif
+++ /dev/null
-// Copyright (c) 2015 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 XSDRAWSTLVRML_DataMapIteratorOfCoordsMap_HeaderFile
-#define XSDRAWSTLVRML_DataMapIteratorOfCoordsMap_HeaderFile
-
-#include <XSDRAWSTLVRML_CoordsMap.hxx>
-
-#endif
+++ /dev/null
-// Copyright (c) 2015 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 XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap_HeaderFile
-#define XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap_HeaderFile
-
-#include <XSDRAWSTLVRML_ElemNodesMap.hxx>
-
-#endif
+++ /dev/null
-// Created on: 2004-06-10
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2004-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 <XSDRAWSTLVRML_DataSource.hxx>
-
-#include <Precision.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_DataMapOfIntegerReal.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource,MeshVS_DataSource)
-
-//================================================================
-// Function : Constructor
-// Purpose :
-//================================================================
-XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulation)& aMesh)
-{
- myMesh = aMesh;
-
- if( !myMesh.IsNull() )
- {
- const Standard_Integer aNbNodes = myMesh->NbNodes();
- myNodeCoords = new TColStd_HArray2OfReal (1, aNbNodes, 1, 3);
- std::cout << "Nodes : " << aNbNodes << std::endl;
-
- for (Standard_Integer i = 1; i <= aNbNodes; i++)
- {
- myNodes.Add( i );
- gp_Pnt xyz = myMesh->Node (i);
-
- myNodeCoords->SetValue(i, 1, xyz.X());
- myNodeCoords->SetValue(i, 2, xyz.Y());
- myNodeCoords->SetValue(i, 3, xyz.Z());
- }
-
- const Standard_Integer aNbTris = myMesh->NbTriangles();
- myElemNormals = new TColStd_HArray2OfReal(1, aNbTris, 1, 3);
- myElemNodes = new TColStd_HArray2OfInteger(1, aNbTris, 1, 3);
-
- std::cout << "Elements : " << aNbTris << std::endl;
-
- for (Standard_Integer i = 1; i <= aNbTris; i++)
- {
- myElements.Add( i );
-
- const Poly_Triangle aTri = myMesh->Triangle (i);
-
- Standard_Integer V[3];
- aTri.Get (V[0], V[1], V[2]);
-
- const gp_Pnt aP1 = myMesh->Node (V[0]);
- const gp_Pnt aP2 = myMesh->Node (V[1]);
- const gp_Pnt aP3 = myMesh->Node (V[2]);
-
- gp_Vec aV1(aP1, aP2);
- gp_Vec aV2(aP2, aP3);
-
- gp_Vec aN = aV1.Crossed(aV2);
- if (aN.SquareMagnitude() > Precision::SquareConfusion())
- aN.Normalize();
- else
- aN.SetCoord(0.0, 0.0, 0.0);
-
- for (Standard_Integer j = 0; j < 3; j++)
- {
- myElemNodes->SetValue(i, j+1, V[j]);
- }
-
- myElemNormals->SetValue (i, 1, aN.X());
- myElemNormals->SetValue (i, 2, aN.Y());
- myElemNormals->SetValue (i, 3, aN.Z());
- }
- }
- std::cout << "Construction is finished" << std::endl;
-}
-
-//================================================================
-// Function : GetGeom
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource::GetGeom
-( const Standard_Integer ID, const Standard_Boolean IsElement,
- TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes,
- MeshVS_EntityType& Type ) const
-{
- if( myMesh.IsNull() )
- return Standard_False;
-
- if( IsElement )
- {
- if( ID>=1 && ID<=myElements.Extent() )
- {
- Type = MeshVS_ET_Face;
- NbNodes = 3;
-
- for( Standard_Integer i = 1, k = 1; i <= 3; i++ )
- {
- Standard_Integer IdxNode = myElemNodes->Value(ID, i);
- for(Standard_Integer j = 1; j <= 3; j++, k++ )
- Coords(k) = myNodeCoords->Value(IdxNode, j);
- }
-
- return Standard_True;
- }
- else
- return Standard_False;
- }
- else
- if( ID>=1 && ID<=myNodes.Extent() )
- {
- Type = MeshVS_ET_Node;
- NbNodes = 1;
-
- Coords( 1 ) = myNodeCoords->Value(ID, 1);
- Coords( 2 ) = myNodeCoords->Value(ID, 2);
- Coords( 3 ) = myNodeCoords->Value(ID, 3);
- return Standard_True;
- }
- else
- return Standard_False;
-}
-
-//================================================================
-// Function : GetGeomType
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource::GetGeomType
-( const Standard_Integer,
- const Standard_Boolean IsElement,
- MeshVS_EntityType& Type ) const
-{
- if( IsElement )
- {
- Type = MeshVS_ET_Face;
- return Standard_True;
- }
- else
- {
- Type = MeshVS_ET_Node;
- return Standard_True;
- }
-}
-
-//================================================================
-// Function : GetAddr
-// Purpose :
-//================================================================
-Standard_Address XSDRAWSTLVRML_DataSource::GetAddr
-( const Standard_Integer, const Standard_Boolean ) const
-{
- return NULL;
-}
-
-//================================================================
-// Function : GetNodesByElement
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource::GetNodesByElement
-( const Standard_Integer ID,
- TColStd_Array1OfInteger& theNodeIDs,
- Standard_Integer& /*theNbNodes*/ ) const
-{
- if( myMesh.IsNull() )
- return Standard_False;
-
- if( ID>=1 && ID<=myElements.Extent() && theNodeIDs.Length() >= 3 )
- {
- Standard_Integer aLow = theNodeIDs.Lower();
- theNodeIDs (aLow) = myElemNodes->Value(ID, 1 );
- theNodeIDs (aLow + 1) = myElemNodes->Value(ID, 2 );
- theNodeIDs (aLow + 2) = myElemNodes->Value(ID, 3 );
- return Standard_True;
- }
- return Standard_False;
-}
-
-//================================================================
-// Function : GetAllNodes
-// Purpose :
-//================================================================
-const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource::GetAllNodes() const
-{
- return myNodes;
-}
-
-//================================================================
-// Function : GetAllElements
-// Purpose :
-//================================================================
-const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource::GetAllElements() const
-{
- return myElements;
-}
-
-//================================================================
-// Function : GetNormal
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource::GetNormal
-( const Standard_Integer Id, const Standard_Integer Max,
- Standard_Real& nx, Standard_Real& ny,Standard_Real& nz ) const
-{
- if( myMesh.IsNull() )
- return Standard_False;
-
- if( Id>=1 && Id<=myElements.Extent() && Max>=3 )
- {
- nx = myElemNormals->Value(Id, 1);
- ny = myElemNormals->Value(Id, 2);
- nz = myElemNormals->Value(Id, 3);
- return Standard_True;
- }
- else
- return Standard_False;
-}
-
+++ /dev/null
-// Created on: 2004-06-10
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2004-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 _XSDRAWSTLVRML_DataSource_HeaderFile
-#define _XSDRAWSTLVRML_DataSource_HeaderFile
-
-#include <Standard.hxx>
-
-#include <TColStd_HArray2OfInteger.hxx>
-#include <TColStd_HArray2OfReal.hxx>
-#include <MeshVS_DataSource.hxx>
-#include <Standard_Integer.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <MeshVS_EntityType.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <Poly_Triangulation.hxx>
-
-
-class XSDRAWSTLVRML_DataSource;
-DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DataSource, MeshVS_DataSource)
-
-//! The sample DataSource for working with STLMesh_Mesh
-class XSDRAWSTLVRML_DataSource : public MeshVS_DataSource
-{
-
-public:
-
-
- //! Constructor
- Standard_EXPORT XSDRAWSTLVRML_DataSource(const Handle(Poly_Triangulation)& aMesh);
-
- //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates.
- //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and
- //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element.
- //! It is recommended to return 1 for node. Type is an element type.
- Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const Standard_OVERRIDE;
-
- //! This method is similar to GetGeom, but returns only element or node type. This method is provided for
- //! a fine performance.
- Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const Standard_OVERRIDE;
-
- //! This method returns by number an address of any entity which represents element or node data structure.
- Standard_EXPORT Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const Standard_OVERRIDE;
-
- //! This method returns information about what node this element consist of.
- Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const Standard_OVERRIDE;
-
- //! This method returns map of all nodes the object consist of.
- Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE;
-
- //! This method returns map of all elements the object consist of.
- Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE;
-
- //! This method calculates normal of face, which is using for correct reflection presentation.
- //! There is default method, for advance reflection this method can be redefined.
- Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource,MeshVS_DataSource)
-
-protected:
-
-
-
-
-private:
-
-
- Handle(Poly_Triangulation) myMesh;
- TColStd_PackedMapOfInteger myNodes;
- TColStd_PackedMapOfInteger myElements;
- Handle(TColStd_HArray2OfInteger) myElemNodes;
- Handle(TColStd_HArray2OfReal) myNodeCoords;
- Handle(TColStd_HArray2OfReal) myElemNormals;
-
-
-};
-
-
-
-
-
-
-
-#endif // _XSDRAWSTLVRML_DataSource_HeaderFile
+++ /dev/null
-// Created on: 2014-08-04
-// Created by: Artem NOVIKOV
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-
-#include <Standard_Type.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
-#include <TColStd_DataMapOfIntegerInteger.hxx>
-#include <TColStd_DataMapOfIntegerReal.hxx>
-#include <XSDRAWSTLVRML_DataSource3D.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource3D,MeshVS_DataSource)
-
-//================================================================
-// Function : Constructor
-// Purpose :
-//================================================================
-XSDRAWSTLVRML_DataSource3D::XSDRAWSTLVRML_DataSource3D()
-{
- for (Standard_Integer aNodeID = 1; aNodeID <= 16; aNodeID++)
- {
- myNodes.Add( aNodeID );
- }
-
- for (Standard_Integer anElemID = 1; anElemID <= 5; anElemID++)
- {
- myElements.Add( anElemID );
- }
-
- myNodeCoords = new TColStd_HArray2OfReal(1, 16, 1, 3);
-
- myNodeCoords->SetValue( 1, 1, 5 );
- myNodeCoords->SetValue( 1, 2, 5 );
- myNodeCoords->SetValue( 1, 3, 20 );
-
- myNodeCoords->SetValue( 2, 1, 0 );
- myNodeCoords->SetValue( 2, 2, 10 );
- myNodeCoords->SetValue( 2, 3, 10 );
-
- myNodeCoords->SetValue( 3, 1, 10 );
- myNodeCoords->SetValue( 3, 2, 0 );
- myNodeCoords->SetValue( 3, 3, 10 );
-
- myNodeCoords->SetValue( 4, 1, 0 );
- myNodeCoords->SetValue( 4, 2, 0 );
- myNodeCoords->SetValue( 4, 3, 10 );
-
- myNodeCoords->SetValue( 5, 1, -10 );
- myNodeCoords->SetValue( 5, 2, 0 );
- myNodeCoords->SetValue( 5, 3, 10 );
-
- myNodeCoords->SetValue( 6, 1, -10 );
- myNodeCoords->SetValue( 6, 2, 10 );
- myNodeCoords->SetValue( 6, 3, 10 );
-
- myNodeCoords->SetValue( 7, 1, -10 );
- myNodeCoords->SetValue( 7, 2, 10 );
- myNodeCoords->SetValue( 7, 3, 0 );
-
- myNodeCoords->SetValue( 8, 1, -10 );
- myNodeCoords->SetValue( 8, 2, 0 );
- myNodeCoords->SetValue( 8, 3, 0 );
-
- myNodeCoords->SetValue( 9, 1, 0 );
- myNodeCoords->SetValue( 9, 2, 0 );
- myNodeCoords->SetValue( 9, 3, 0 );
-
- myNodeCoords->SetValue( 10, 1, 0 );
- myNodeCoords->SetValue( 10, 2, 10 );
- myNodeCoords->SetValue( 10, 3, 0 );
-
- myNodeCoords->SetValue( 11, 1, 0 );
- myNodeCoords->SetValue( 11, 2, -10 );
- myNodeCoords->SetValue( 11, 3, 10 );
-
- myNodeCoords->SetValue( 12, 1, 10 );
- myNodeCoords->SetValue( 12, 2, -10 );
- myNodeCoords->SetValue( 12, 3, 10 );
-
- myNodeCoords->SetValue( 13, 1, 10 );
- myNodeCoords->SetValue( 13, 2, -10 );
- myNodeCoords->SetValue( 13, 3, 0 );
-
- myNodeCoords->SetValue( 14, 1, 0 );
- myNodeCoords->SetValue( 14, 2, -10 );
- myNodeCoords->SetValue( 14, 3, 0 );
-
- myNodeCoords->SetValue( 15, 1, 10 );
- myNodeCoords->SetValue( 15, 2, 0 );
- myNodeCoords->SetValue( 15, 3, 0 );
-
- myNodeCoords->SetValue( 16, 1, 5 );
- myNodeCoords->SetValue( 16, 2, 5 );
- myNodeCoords->SetValue( 16, 3, -10 );
-
- myElemNbNodes = new TColStd_HArray1OfInteger(1, 5);
-
- myElemNbNodes->SetValue( 1, 4 );
- myElemNbNodes->SetValue( 2, 8 );
- myElemNbNodes->SetValue( 3, 6 );
- myElemNbNodes->SetValue( 4, 8 );
- myElemNbNodes->SetValue( 5, 4 );
-
- myElemNodes = new TColStd_HArray2OfInteger(1, 5, 1, 8);
-
- myElemNodes->SetValue(1, 1, 1);
- myElemNodes->SetValue(1, 2, 2);
- myElemNodes->SetValue(1, 3, 3);
- myElemNodes->SetValue(1, 4, 4);
-
- myElemNodes->SetValue(2, 1, 2);
- myElemNodes->SetValue(2, 2, 4);
- myElemNodes->SetValue(2, 3, 5);
- myElemNodes->SetValue(2, 4, 6);
- myElemNodes->SetValue(2, 5, 7);
- myElemNodes->SetValue(2, 6, 8);
- myElemNodes->SetValue(2, 7, 9);
- myElemNodes->SetValue(2, 8, 10);
-
- myElemNodes->SetValue(3, 1, 2);
- myElemNodes->SetValue(3, 2, 3);
- myElemNodes->SetValue(3, 3, 4);
- myElemNodes->SetValue(3, 4, 10);
- myElemNodes->SetValue(3, 5, 15);
- myElemNodes->SetValue(3, 6, 9);
-
- myElemNodes->SetValue(4, 1, 4);
- myElemNodes->SetValue(4, 2, 3);
- myElemNodes->SetValue(4, 3, 12);
- myElemNodes->SetValue(4, 4, 11);
- myElemNodes->SetValue(4, 5, 14);
- myElemNodes->SetValue(4, 6, 13);
- myElemNodes->SetValue(4, 7, 15);
- myElemNodes->SetValue(4, 8, 9);
-
- myElemNodes->SetValue(5, 1, 16);
- myElemNodes->SetValue(5, 2, 15);
- myElemNodes->SetValue(5, 3, 10);
- myElemNodes->SetValue(5, 4, 9);
-}
-
-//================================================================
-// Function : GetGeom
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetGeom
-( const Standard_Integer theID, const Standard_Boolean theIsElement,
- TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes,
- MeshVS_EntityType& theType ) const
-{
- if (theIsElement)
- {
- if (theID >= 1 && theID <= myElements.Extent())
- {
- theType = MeshVS_ET_Volume;
- theNbNodes = myElemNbNodes->Value(theID);
-
- for (Standard_Integer aNodeI = 1, aGlobCoordI = 1; aNodeI <= theNbNodes; aNodeI++)
- {
- Standard_Integer anIdxNode = myElemNodes->Value(theID, aNodeI);
- for(Standard_Integer aCoordI = 1; aCoordI <= 3; aCoordI++, aGlobCoordI++ )
- theCoords(aGlobCoordI) = myNodeCoords->Value(anIdxNode, aCoordI);
- }
-
- return Standard_True;
- }
- else
- return Standard_False;
- }
- else
- if (theID >= 1 && theID <= myNodes.Extent())
- {
- theType = MeshVS_ET_Node;
- theNbNodes = 1;
-
- theCoords( 1 ) = myNodeCoords->Value(theID, 1);
- theCoords( 2 ) = myNodeCoords->Value(theID, 2);
- theCoords( 3 ) = myNodeCoords->Value(theID, 3);
- return Standard_True;
- }
- else
- return Standard_False;
-}
-
-//================================================================
-// Function : Get3DGeom
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource3D::Get3DGeom
-( const Standard_Integer theID, Standard_Integer& theNbNodes,
- Handle(MeshVS_HArray1OfSequenceOfInteger)& theData ) const
-{
- Handle(MeshVS_HArray1OfSequenceOfInteger) aMeshData;
- if (theID == 1 || theID == 5)
- {
- aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,4);
- theNbNodes = 4;
- for (Standard_Integer anElemI = 1; anElemI <= 4; anElemI++)
- {
- aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) % 4 );
- aMeshData->ChangeValue(anElemI).Append( anElemI % 4 );
- aMeshData->ChangeValue(anElemI).Append( (anElemI + 1) % 4 );
- }
- theData = aMeshData;
- return Standard_True;
- }
-
- if (theID == 2 || theID == 4)
- {
- aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,6);
- theNbNodes = 8;
- for (Standard_Integer anElemI = 1, k = 1; anElemI <= 4; anElemI++)
- {
- aMeshData->ChangeValue(anElemI).Append( (k - 1) % 8 );
- aMeshData->ChangeValue(anElemI).Append( k % 8 );
- aMeshData->ChangeValue(anElemI).Append( (k + 1) % 8 );
- aMeshData->ChangeValue(anElemI).Append( (k + 2) % 8 );
- k+=2;
- }
-
- aMeshData->ChangeValue(5).Append( 0 );
- aMeshData->ChangeValue(5).Append( 3 );
- aMeshData->ChangeValue(5).Append( 4 );
- aMeshData->ChangeValue(5).Append( 7 );
-
- aMeshData->ChangeValue(6).Append( 1 );
- aMeshData->ChangeValue(6).Append( 2 );
- aMeshData->ChangeValue(6).Append( 5 );
- aMeshData->ChangeValue(6).Append( 6 );
-
- theData = aMeshData;
- return Standard_True;
- }
-
- if (theID == 3)
- {
- aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,5);
- theNbNodes = 6;
- for (Standard_Integer anElemI = 1; anElemI <= 2; anElemI++)
- {
- aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 );
- aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 1 );
- aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 2 );
- }
- for (Standard_Integer anElemI = 1; anElemI <= 3; anElemI++)
- {
- aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 );
- aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 );
- aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 + 3 );
- aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 + 3 );
- }
- theData = aMeshData;
- return Standard_True;
- }
-
- return Standard_False;
-}
-
-//================================================================
-// Function : GetGeomType
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetGeomType
-( const Standard_Integer theID,
- const Standard_Boolean theIsElement,
- MeshVS_EntityType& theType ) const
-{
- if (theIsElement)
- {
- if (theID >= 1 && theID <= myElements.Extent())
- {
- theType = MeshVS_ET_Volume;
- return Standard_True;
- }
- }
- else
- if (theID >= 1 && theID <= myNodes.Extent())
- {
- theType = MeshVS_ET_Node;
- return Standard_True;
- }
-
- return Standard_False;
-}
-
-//================================================================
-// Function : GetAddr
-// Purpose :
-//================================================================
-Standard_Address XSDRAWSTLVRML_DataSource3D::GetAddr
-( const Standard_Integer, const Standard_Boolean ) const
-{
- return NULL;
-}
-
-//================================================================
-// Function : GetNodesByElement
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetNodesByElement
-( const Standard_Integer theID,
- TColStd_Array1OfInteger& theNodeIDs,
- Standard_Integer& theNbNodes ) const
-{
- Standard_Integer aLow;
- if (theID == 1 || theID == 5)
- {
- theNbNodes = 4;
- aLow = theNodeIDs.Lower();
- theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
- theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
- theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
- theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
- return Standard_True;
- }
-
- if (theID == 2 || theID == 4)
- {
- theNbNodes = 8;
- aLow = theNodeIDs.Lower();
- theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
- theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
- theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
- theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
- theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 );
- theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 );
- theNodeIDs (aLow + 6) = myElemNodes->Value(theID, 7 );
- theNodeIDs (aLow + 7) = myElemNodes->Value(theID, 8 );
- return Standard_True;
- }
-
- if (theID == 3)
- {
- theNbNodes = 6;
- aLow = theNodeIDs.Lower();
- theNodeIDs (aLow) = myElemNodes->Value(theID, 1 );
- theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 );
- theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 );
- theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 );
- theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 );
- theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 );
- return Standard_True;
- }
-
- return Standard_False;
-}
-
-//================================================================
-// Function : GetAllNodes
-// Purpose :
-//================================================================
-const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource3D::GetAllNodes() const
-{
- return myNodes;
-}
-
-//================================================================
-// Function : GetAllElements
-// Purpose :
-//================================================================
-const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource3D::GetAllElements() const
-{
- return myElements;
-}
-
-//================================================================
-// Function : GetNormal
-// Purpose :
-//================================================================
-Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetNormal
-( const Standard_Integer /*theID*/, const Standard_Integer /*theMax*/,
- Standard_Real& /*theNx*/, Standard_Real& /*theNy*/,Standard_Real& /*theNz*/ ) const
-{
- return Standard_False;
-}
+++ /dev/null
-// Created on: 2014-08-04
-// Created by: Artem NOVIKOV
-// Copyright (c) 2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#ifndef _XSDRAWSTLVRML_DataSource3D_HeaderFile
-#define _XSDRAWSTLVRML_DataSource3D_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <TColStd_HArray1OfInteger.hxx>
-#include <TColStd_HArray2OfReal.hxx>
-#include <TColStd_HArray2OfInteger.hxx>
-#include <MeshVS_DataSource.hxx>
-#include <Standard_Integer.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <MeshVS_EntityType.hxx>
-#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-
-
-class XSDRAWSTLVRML_DataSource3D;
-DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DataSource3D, MeshVS_DataSource)
-
-//! The sample DataSource3D for working with STLMesh_Mesh
-class XSDRAWSTLVRML_DataSource3D : public MeshVS_DataSource
-{
-
-public:
-
-
- //! Constructor
- Standard_EXPORT XSDRAWSTLVRML_DataSource3D();
-
- //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates.
- //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and
- //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element.
- //! It is recommended to return 1 for node. Type is an element type.
- Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer theID, const Standard_Boolean theIsElement, TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, MeshVS_EntityType& theType) const Standard_OVERRIDE;
-
- //! This method returns topology information about 3D-element
- //! Returns false if element with ID isn't 3D or because other troubles
- Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer theID, Standard_Integer& theNbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& theData) const Standard_OVERRIDE;
-
- //! This method is similar to GetGeom, but returns only element or node type. This method is provided for
- //! a fine performance.
- Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer theID, const Standard_Boolean theIsElement, MeshVS_EntityType& theType) const Standard_OVERRIDE;
-
- //! This method returns by number an address of any entity which represents element or node data structure.
- Standard_EXPORT Standard_Address GetAddr (const Standard_Integer theID, const Standard_Boolean theIsElement) const Standard_OVERRIDE;
-
- //! This method returns information about what node this element consist of.
- Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer theID, TColStd_Array1OfInteger& theNodeIDs, Standard_Integer& theNbNodes) const Standard_OVERRIDE;
-
- //! This method returns map of all nodes the object consist of.
- Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE;
-
- //! This method returns map of all elements the object consist of.
- Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE;
-
- //! This method calculates normal of face, which is using for correct reflection presentation.
- //! There is default method, for advance reflection this method can be redefined.
- Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer theID, const Standard_Integer theMax, Standard_Real& theNx, Standard_Real& theNy, Standard_Real& theNz) const Standard_OVERRIDE;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource3D,MeshVS_DataSource)
-
-protected:
-
-
-
-
-private:
-
-
- TColStd_PackedMapOfInteger myNodes;
- TColStd_PackedMapOfInteger myElements;
- Handle(TColStd_HArray1OfInteger) myElemNbNodes;
- Handle(TColStd_HArray2OfReal) myNodeCoords;
- Handle(TColStd_HArray2OfInteger) myElemNodes;
-
-
-};
-
-
-
-
-
-
-
-#endif // _XSDRAWSTLVRML_DataSource3D_HeaderFile
+++ /dev/null
-// Created on: 2004-06-11
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2004-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 <Draw_Display.hxx>
-#include <MeshVS_Mesh.hxx>
-#include <Standard_Type.hxx>
-#include <XSDRAWSTLVRML_DrawableMesh.hxx>
-
-IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DrawableMesh,Draw_Drawable3D)
-
-//================================================================
-// Function : DrawOn
-// Purpose :
-//================================================================
-XSDRAWSTLVRML_DrawableMesh::XSDRAWSTLVRML_DrawableMesh( const Handle( MeshVS_Mesh )& aMesh )
-{
- myMesh = aMesh;
-}
-
-//================================================================
-// Function :
-// Purpose :
-//================================================================
-void XSDRAWSTLVRML_DrawableMesh::DrawOn(Draw_Display& /*d*/) const
-{
-}
-
-//================================================================
-// Function :
-// Purpose :
-//================================================================
-Handle( MeshVS_Mesh ) XSDRAWSTLVRML_DrawableMesh::GetMesh() const
-{
- return myMesh;
-}
+++ /dev/null
-// Created on: 2004-06-11
-// Created by: Alexander SOLOVYOV
-// Copyright (c) 2004-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 _XSDRAWSTLVRML_DrawableMesh_HeaderFile
-#define _XSDRAWSTLVRML_DrawableMesh_HeaderFile
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <Draw_Drawable3D.hxx>
-class MeshVS_Mesh;
-class Draw_Display;
-
-
-class XSDRAWSTLVRML_DrawableMesh;
-DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DrawableMesh, Draw_Drawable3D)
-
-
-class XSDRAWSTLVRML_DrawableMesh : public Draw_Drawable3D
-{
-
-public:
-
-
- Standard_EXPORT XSDRAWSTLVRML_DrawableMesh(const Handle(MeshVS_Mesh)& aMesh);
-
- Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE;
-
- Standard_EXPORT Handle(MeshVS_Mesh) GetMesh() const;
-
-
-
-
- DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DrawableMesh,Draw_Drawable3D)
-
-protected:
-
-
-
-
-private:
-
-
- Handle(MeshVS_Mesh) myMesh;
-
-
-};
-
-
-
-
-
-
-
-#endif // _XSDRAWSTLVRML_DrawableMesh_HeaderFile
+++ /dev/null
-// Created on: 2000-05-30
-// Created by: Sergey MOZOKHIN
-// Copyright (c) 2000-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 XSDRAWSTLVRML_ElemNodesMap_HeaderFile
-#define XSDRAWSTLVRML_ElemNodesMap_HeaderFile
-
-#include <TColStd_DataMapOfIntegerInteger.hxx>
-#include <NCollection_DataMap.hxx>
-
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger> XSDRAWSTLVRML_ElemNodesMap;
-typedef NCollection_DataMap<Standard_Integer,TColStd_DataMapOfIntegerInteger>::Iterator XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap;
-
-
-#endif
--- /dev/null
+XSDRAWVRML.cxx
+XSDRAWVRML.hxx
--- /dev/null
+// Copyright (c) 2023 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 <XSDRAWVRML.hxx>
+
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <DDocStd_DrawDocument.hxx>
+#include <Draw.hxx>
+#include <Draw_Interpretor.hxx>
+#include <Draw_PluginMacro.hxx>
+#include <Draw_ProgressIndicator.hxx>
+#include <OSD_Path.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TopoDS_Shape.hxx>
+#include <UnitsAPI.hxx>
+#include <UnitsMethods.hxx>
+#include <VrmlAPI_CafReader.hxx>
+#include <VrmlAPI_Writer.hxx>
+#include <VrmlData_DataMapOfShapeAppearance.hxx>
+#include <VrmlData_Scene.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XSAlgo.hxx>
+#include <XSAlgo_AlgoContainer.hxx>
+#include <XSControl_WorkSession.hxx>
+#include <XSDRAW.hxx>
+
+//=============================================================================
+//function : parseCoordinateSystem
+//purpose : Parse RWMesh_CoordinateSystem enumeration
+//=============================================================================
+static bool parseCoordinateSystem(const char* theArg,
+ RWMesh_CoordinateSystem& theSystem)
+{
+ TCollection_AsciiString aCSStr(theArg);
+ aCSStr.LowerCase();
+ if (aCSStr == "zup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Zup;
+ }
+ else if (aCSStr == "yup")
+ {
+ theSystem = RWMesh_CoordinateSystem_Yup;
+ }
+ else
+ {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : ReadVrml
+//purpose :
+//=======================================================================
+static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
+ Standard_Integer theArgc,
+ const char** theArgv)
+{
+ if(theArgc < 3)
+ {
+ theDI.PrintHelp(theArgv[0]);
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ Standard_Real aFileUnitFactor = 1.0;
+ RWMesh_CoordinateSystem aFileCoordSys = RWMesh_CoordinateSystem_Yup, aSystemCoordSys = RWMesh_CoordinateSystem_Zup;
+ Standard_Boolean toUseExistingDoc = Standard_False;
+ Standard_Boolean toFillIncomplete = Standard_True;
+ Standard_CString aDocName = NULL;
+ TCollection_AsciiString aFilePath;
+
+ for(Standard_Integer anArgIt = 1; anArgIt < theArgc; anArgIt++)
+ {
+ TCollection_AsciiString anArg(theArgv[anArgIt]);
+ anArg.LowerCase();
+ if(anArgIt + 1 < theArgc && anArg == "-fileunit")
+ {
+ const TCollection_AsciiString aUnitStr(theArgv[++anArgIt]);
+ aFileUnitFactor = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString());
+ if (aFileUnitFactor <= 0.0)
+ {
+ Message::SendFail() << "Error: wrong length unit '" << aUnitStr << "'";
+ return 1;
+ }
+ }
+ else if (anArgIt + 1 < theArgc && anArg == "-filecoordsys")
+ {
+ if (!parseCoordinateSystem(theArgv[++anArgIt], aFileCoordSys))
+ {
+ Message::SendFail() << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'";
+ return 1;
+ }
+ }
+ else if (anArgIt + 1 < theArgc && anArg == "-systemcoordsys")
+ {
+ if (!parseCoordinateSystem(theArgv[++anArgIt], aSystemCoordSys))
+ {
+ Message::SendFail() << "Error: unknown coordinate system '" << theArgv[anArgIt] << "'";
+ return 1;
+ }
+ }
+ else if (anArg == "-fillincomplete")
+ {
+ toFillIncomplete = true;
+ if (anArgIt + 1 < theArgc && Draw::ParseOnOff(theArgv[anArgIt + 1], toFillIncomplete))
+ {
+ ++anArgIt;
+ }
+ }
+ else if (anArg == "-nocreatedoc")
+ {
+ toUseExistingDoc = true;
+ }
+ else if (aDocName == nullptr)
+ {
+ aDocName = theArgv[anArgIt];
+ DDocStd::GetDocument(aDocName, aDoc, Standard_False);
+ }
+ else if(aFilePath.IsEmpty())
+ {
+ aFilePath = theArgv[anArgIt];
+ }
+ else
+ {
+ Message::SendFail() << "Syntax error at '" << theArgv[anArgIt] << "'";
+ return 1;
+ }
+ }
+
+ if (aFilePath.IsEmpty() || aDocName == nullptr)
+ {
+ Message::SendFail() << "Syntax error: wrong number of arguments";
+ return 1;
+ }
+
+ if (aDoc.IsNull())
+ {
+ if(toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDocName << " does not exist";
+ return 1;
+ }
+ Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
+ anApp->NewDocument("BinXCAF", aDoc);
+ }
+ else if (!toUseExistingDoc)
+ {
+ Message::SendFail() << "Error: document with name " << aDocName << " already exists\n";
+ return 1;
+ }
+
+ Standard_Real aScaleFactor = 1.;
+ if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactor))
+ {
+ XSAlgo::AlgoContainer()->PrepareForTransfer();
+ aScaleFactor = UnitsMethods::GetCasCadeLengthUnit();
+ }
+
+ VrmlAPI_CafReader aVrmlReader;
+ aVrmlReader.SetDocument(aDoc);
+ aVrmlReader.SetFileLengthUnit(aFileUnitFactor);
+ aVrmlReader.SetSystemLengthUnit(aScaleFactor);
+ aVrmlReader.SetFileCoordinateSystem(aFileCoordSys);
+ aVrmlReader.SetSystemCoordinateSystem(aSystemCoordSys);
+ aVrmlReader.SetFillIncompleteDocument(toFillIncomplete);
+
+ Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
+ if (!aVrmlReader.Perform(aFilePath, aProgress->Start()))
+ {
+ if (aVrmlReader.ExtraStatus() != RWMesh_CafReaderStatusEx_Partial)
+ {
+ Message::SendFail() << "Error: file reading failed '" << aFilePath << "'";
+ return 1;
+ }
+ Message::SendWarning() <<
+ "Warning: file has been read paratially (due to unexpected EOF, syntax error, memory limit) " << aFilePath;
+ }
+
+ TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName);
+ Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc);
+ Draw::Set(aDocName, aDD);
+
+ return 0;
+}
+
+//=======================================================================
+//function : WriteVrml
+//purpose : Write DECAF document to Vrml
+//=======================================================================
+static Standard_Integer WriteVrml(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3)
+ {
+ di << "Use: " << argv[0] << " Doc filename: write document to Vrml file\n";
+ return 0;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ DDocStd::GetDocument(argv[1], aDoc);
+ if (aDoc.IsNull())
+ {
+ di << argv[1] << " is not a document\n";
+ return 1;
+ }
+
+ if (argc < 3 || argc > 5)
+ {
+ di << "wrong number of parameters\n";
+ return 0;
+ }
+
+ VrmlAPI_Writer writer;
+ writer.SetRepresentation(VrmlAPI_ShadedRepresentation);
+ Standard_Real aScaleFactorM = 1.;
+ if (!XCAFDoc_DocumentTool::GetLengthUnit(aDoc, aScaleFactorM))
+ {
+ XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
+ aScaleFactorM = UnitsMethods::GetCasCadeLengthUnit(UnitsMethods_LengthUnit_Meter);
+ }
+ if (!writer.WriteDoc(aDoc, argv[2], aScaleFactorM))
+ {
+ di << "Error: File " << argv[2] << " was not written\n";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : loadvrml
+//purpose :
+//=======================================================================
+
+static Standard_Integer loadvrml
+(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc<3) di << "wrong number of parameters" << "\n";
+ else {
+ TopoDS_Shape aShape ;
+ VrmlData_DataMapOfShapeAppearance aShapeAppMap;
+
+ //-----------------------------------------------------------
+ std::filebuf aFic;
+ std::istream aStream (&aFic);
+
+ if (aFic.open(argv[2], std::ios::in)) {
+
+ // Get path of the VRML file.
+ OSD_Path aPath(argv[2]);
+ TCollection_AsciiString aVrmlDir(".");
+ TCollection_AsciiString aDisk = aPath.Disk();
+ TCollection_AsciiString aTrek = aPath.Trek();
+ if (!aTrek.IsEmpty())
+ {
+ if (!aDisk.IsEmpty())
+ aVrmlDir = aDisk;
+ else
+ aVrmlDir.Clear();
+ aTrek.ChangeAll('|', '/');
+ aVrmlDir += aTrek;
+ }
+
+ VrmlData_Scene aScene;
+ const Standard_Real anOCCUnitMM = XSDRAW::GetLengthUnit();
+ aScene.SetLinearScale(1000. / anOCCUnitMM);
+
+ aScene.SetVrmlDir (aVrmlDir);
+ aScene << aStream;
+ const char * aStr = 0L;
+ switch (aScene.Status()) {
+
+ case VrmlData_StatusOK:
+ {
+ aShape = aScene.GetShape(aShapeAppMap);
+ break;
+ }
+ case VrmlData_EmptyData: aStr = "EmptyData"; break;
+ case VrmlData_UnrecoverableError: aStr = "UnrecoverableError"; break;
+ case VrmlData_GeneralError: aStr = "GeneralError"; break;
+ case VrmlData_EndOfFile: aStr = "EndOfFile"; break;
+ case VrmlData_NotVrmlFile: aStr = "NotVrmlFile"; break;
+ case VrmlData_CannotOpenFile: aStr = "CannotOpenFile"; break;
+ case VrmlData_VrmlFormatError: aStr = "VrmlFormatError"; break;
+ case VrmlData_NumericInputError: aStr = "NumericInputError"; break;
+ case VrmlData_IrrelevantNumber: aStr = "IrrelevantNumber"; break;
+ case VrmlData_BooleanInputError: aStr = "BooleanInputError"; break;
+ case VrmlData_StringInputError: aStr = "StringInputError"; break;
+ case VrmlData_NodeNameUnknown: aStr = "NodeNameUnknown"; break;
+ case VrmlData_NonPositiveSize: aStr = "NonPositiveSize"; break;
+ case VrmlData_ReadUnknownNode: aStr = "ReadUnknownNode"; break;
+ case VrmlData_NonSupportedFeature: aStr = "NonSupportedFeature"; break;
+ case VrmlData_OutputStreamUndefined:aStr = "OutputStreamUndefined"; break;
+ case VrmlData_NotImplemented: aStr = "NotImplemented"; break;
+ default:
+ break;
+ }
+ if (aStr) {
+ di << " ++ VRML Error: " << aStr << " in line "
+ << aScene.GetLineError() << "\n";
+ }
+ else {
+ DBRep::Set(argv[1],aShape);
+ }
+ }
+ else {
+ di << "cannot open file\n";
+ }
+
+
+ //-----------------------------------------------------------
+ }
+ return 0;
+}
+
+//=============================================================================
+//function : writevrml
+//purpose :
+//=============================================================================
+static Standard_Integer writevrml
+(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3 || argc > 5)
+ {
+ di << "wrong number of parameters\n";
+ return 0;
+ }
+
+ TopoDS_Shape aShape = DBRep::Get(argv[1]);
+
+ // Get the optional parameters
+ Standard_Integer aVersion = 2;
+ Standard_Integer aType = 1;
+ if (argc >= 4)
+ {
+ aVersion = Draw::Atoi(argv[3]);
+ if (argc == 5)
+ aType = Draw::Atoi(argv[4]);
+ }
+
+ // Bound parameters
+ aVersion = Max(1, aVersion);
+ aVersion = Min(2, aVersion);
+ aType = Max(0, aType);
+ aType = Min(2, aType);
+
+ VrmlAPI_Writer writer;
+
+ switch (aType)
+ {
+ case 0: writer.SetRepresentation(VrmlAPI_ShadedRepresentation); break;
+ case 1: writer.SetRepresentation(VrmlAPI_WireFrameRepresentation); break;
+ case 2: writer.SetRepresentation(VrmlAPI_BothRepresentation); break;
+ }
+
+ if (!writer.Write(aShape, argv[2], aVersion))
+ {
+ di << "Error: File " << argv[2] << " was not written\n";
+ }
+
+ return 0;
+}
+
+//=============================================================================
+//function : Factory
+//purpose :
+//=============================================================================
+void XSDRAWVRML::Factory(Draw_Interpretor& theDI)
+{
+ static Standard_Boolean anInitActor = Standard_False;
+ if (anInitActor)
+ {
+ return;
+ }
+ anInitActor = Standard_True;
+
+ Standard_CString aGroup = "XDE translation commands";
+ theDI.Add("ReadVrml",
+ "ReadVrml docName filePath [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
+ "\n\t\t: [-systemCoordSys {Zup|Yup}] [-noCreateDoc] [-fillIncomplete {ON|OFF}]"
+ "\n\t\t: Read Vrml file into XDE document."
+ "\n\t\t: -fileCoordSys coordinate system defined by Vrml file; Yup when not specified."
+ "\n\t\t: -fileUnit length unit of Vrml file content."
+ "\n\t\t: -systemCoordSys result coordinate system; Zup when not specified."
+ "\n\t\t: -noCreateDoc read into existing XDE document."
+ "\n\t\t: -fillIncomplete fill the document with partially retrieved data even if reader has failed with "
+ "error; true when not specified",
+ __FILE__, ReadVrml, aGroup);
+ theDI.Add("WriteVrml",
+ "WriteVrml Doc filename [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 0 by default]",
+ __FILE__, WriteVrml, aGroup);
+ theDI.Add("loadvrml", "shape file", __FILE__, loadvrml, aGroup);
+ theDI.Add("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]", __FILE__, writevrml, aGroup);
+
+ // Load XSDRAW session for pilot activation
+ XSDRAW::LoadDraw(theDI);
+}
+
+// Declare entry point PLUGINFACTORY
+DPLUGIN(XSDRAWVRML)
--- /dev/null
+// Copyright (c) 2023 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 _XSDRAWVRML_HeaderFile
+#define _XSDRAWVRML_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+class XSDRAWVRML
+{
+ DEFINE_STANDARD_ALLOC
+public:
+
+ //! Loads all Draw commands of XSDRAWVRML. Used for plugin.
+ Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
+};
+
+#endif // _XSDRAWVRML_HeaderFile
puts "# Load IGES file which is known to generate the message, and check it"
puts "REQUIRED 14673 ALL: $message"
-pload XSDRAW
+pload XSDRAW IGES
igesbrep [locate_data_file hammer.iges] a *
tpstat c
# Visualization - randomly directed arrows on test v3d mesh B7
##########################################################################################################
-pload XSDRAW
+pload XSDRAW STL
vinit
vclear
## stack overflow during reading IGES in Test Harness
#############################
+pload IGES
+
restore [locate_data_file bug23722_face.brep]
brepiges bug23722_face ${imagedir}/face.igs
## Faulty shape after IGES translation with xstep.cascade.unit set to M
#######################################################################
-pload DATAEXCHANGEKERNEL
+pload DATAEXCHANGEKERNEL IGES
param xstep.cascade.unit M
puts "0024983: For the incorrect seam edge in STEP file no fix is provided"
puts "========"
+pload STEP
+
stepread [locate_data_file bug24983_111FACE.stp] a *
tpcompound result
# ShapeFix_Wire tweaks for better results
##################################################
+pload STEP
+
stepread [locate_data_file bug25013_25013faces.stp] a *
tpcompound result
# ShapeFix_Wire tweaks for better results
##################################################
+pload STEP
+
stepread [locate_data_file bug25013_25013face.stp] a *
tpcompound result
# Self Intersecting wire translated from STEP file
#######################################################################################
+pload STEP
+
set BugNumber OCC25823
set aFile [locate_data_file bug25823_280612.stp]
# Mechanism 'ShapeFix' is unable to heal a shape
##################################################
+pload STEP
+
stepread [locate_data_file bug26280_1kento13-mld-b-cv-qubit.stp] r *
checkshape r_1
puts "0026671: Infinite loop in ShapeFix_Wire::FixSelfIntersection()"
puts "========================"
+pload IGES
+
cpulimit 20
igesbrep [locate_data_file bug26671.igs] result *
# OCC27078: Exception in ShapeFixIntersectionTool::UnionVertexes()
##################################################################
+pload IGES
+
testreadiges [locate_data_file bug27078.igs] a
# fixshape should not throw an exception
## Crash when calling ShapeUpgrade_UnifySameDomain
###############################
+pload STEP
+
stepread [locate_data_file bug27894_usd_raises_Standard_NullObject.stp] a *
renamevar a_1 a
unifysamedom result a
puts "========================"
puts ""
+pload STEP
+
stepread [locate_data_file bug33028_kalip.stp] s *
set nbsBefore "
puts "========================================="
puts ""
+pload STEP
+
testreadstep [locate_data_file bug33398.step] s
unifysamedom result s
# Mesh generation hangs then crashes
###########################################
-pload DATAEXCHANGEKERNEL
+pload DATAEXCHANGEKERNEL STEP
testreadstep [locate_data_file bug28118_18547.stp] result
vclear
puts "======="
puts ""
-if {[info commands stepread] == ""} {pload XSDRAW}
+if {[info commands stepread] == ""} {pload XSDRAW STEP}
stepread [locate_data_file bug29715_slow.stp] a *
renamevar a_1 a
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
cpulimit 500
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
set BugNumber OCC8842
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload XSDRAW IGES}
proc myoffset {result sh val tan} {
if {$tan == 1} {
# BRepBuilderAPI_Sewing can crash if an edge without 3D curve is presented
###########################################################################
-pload XSDRAW
+pload XSDRAW IGES
igesread [locate_data_file bug25175_3.igs] a *
# Tool for extended check of validity of the curve on the surface
######################################################
-pload XSDRAW
+pload XSDRAW IGES
testreadiges [locate_data_file bug25410_Tank8.igs] b1
puts "==============================================================="
puts ""
-pload XSDRAW
+pload XSDRAW STEP
stepread [locate_data_file bug30595_UC1.stp] s *
incmesh s_1 0.1
puts "========"
puts ""
-pload XSDRAW
+pload XSDRAW STL
box b 10 10 10
pcylinder c 5 10
puts "===================================="
puts ""
-pload OCAF XDEDRAW
+pload OCAF XDEDRAW STEP
box b 1 1 1
reset b
set BugNumber OCC22572
-catch { pload XSDRAW }
+catch { pload XSDRAW STL}
vinit
XProgress -t
set List1 [meshfromstl result [locate_data_file bearing.stl]]
-pload XSDRAW
+pload XSDRAW STL VRML
set subgroup stlvrml
# Test performance of dynamic loading / unloading of large OCCT library
-set libname TKSTEP
+set libname TKDESTEP
switch -nocase [checkplatform] {
windows {set libname ${libname}.dll}
## Slow import of IGES data
###############################
-pload QAcommands
+pload QAcommands IGES
if { [regexp {Debug mode} [dversion]] } {
cpulimit 8500
## Slow import of IGES data
###############################
-pload QAcommands
+pload QAcommands IGES
if { [regexp {Debug mode} [dversion]] } {
cpulimit 8500
# Extrema_GenExtPS needs to be optimized
##########################################
-pload DATAEXCHANGEKERNEL
+pload DATAEXCHANGEKERNEL STEP
# Restore testing shape and get timing characteristics for operation stepread
dchrono perf_h restart
cpulimit 1000
-pload DATAEXCHANGEKERNEL
+pload DATAEXCHANGEKERNEL STEP
# Restore testing shape and get timing characteristics for operation stepread
dchrono perf_h restart
# Recalculation of BSpline cache causes a performance problems
############################################################################
-pload XSDRAW
+pload XSDRAW STEP
dchrono t restart
testreadstep [locate_data_file bug27048.stp] result
puts "============"
puts ""
-pload XDEDRAW VISUALIZATION
+pload XDEDRAW VISUALIZATION STEP
XNewDoc Doc1
ReadStep Doc1 [locate_data_file screw.step]
-pload MODELING VISUALIZATION XSDRAW
+pload MODELING VISUALIZATION XSDRAW STL
vinit View1
puts "========"
puts ""
-pload VISUALIZATION MODELING XSDRAW
+pload VISUALIZATION MODELING XSDRAW STL
vinit View1
# create an object with auto-highlight disabled
puts "0029356: Modeling Algorithms - GCPnts_TangentialDeflection hangs on specific curve"
puts "========"
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload IGES}
testreadiges [locate_data_file bug29356.igs] a
vinit View1
# isolines on infinite prism based on spline edge with poles closed to 1.4e+6
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload IGES}
testreadiges [locate_data_file bug29356.igs] a
mksurface s a
# isolines on finite prism based on spline edge with poles closed to 1.4e+6
-if {[info commands testreadiges] == ""} {pload XSDRAW}
+if {[info commands testreadiges] == ""} {pload IGES}
testreadiges [locate_data_file bug29356.igs] a
mksurface s a
TKView
TKXSBase
TKXCAF
-TKXDESTEP
+TKDESTEP
TKXmlXCAF
TKXml
TKXmlL