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

// testing

This commit is contained in:
dpasukhi
2023-01-08 17:34:11 +00:00
parent 6b4fa7a257
commit 2d201d39d0
14 changed files with 655 additions and 1319 deletions

View File

@@ -22,15 +22,16 @@
#include <TopTools_HSequenceOfShape.hxx> #include <TopTools_HSequenceOfShape.hxx>
class IFSelect_SessionPilot; class IFSelect_SessionPilot;
class XSControl_WorkSession;
class XSControl_Controller;
class Interface_Protocol; class Interface_Protocol;
class Interface_InterfaceModel; class Interface_InterfaceModel;
class Standard_Transient; class Standard_Transient;
class TCollection_AsciiString;
class TDocStd_Document;
class Transfer_TransientProcess; class Transfer_TransientProcess;
class Transfer_FinderProcess; class Transfer_FinderProcess;
class XSControl_Controller;
class XSControl_TransferReader; class XSControl_TransferReader;
class TCollection_AsciiString; class XSControl_WorkSession;
//! Basic package to work functions of X-STEP (IFSelect & Co) //! Basic package to work functions of X-STEP (IFSelect & Co)
//! under control of DRAW //! under control of DRAW
@@ -176,6 +177,15 @@ public:
//! In case of failure, returns a Null Handle //! In case of failure, returns a Null Handle
Standard_EXPORT static Handle(TColStd_HSequenceOfTransient) GetList(const Standard_CString first = "", const Standard_CString second = ""); Standard_EXPORT static Handle(TColStd_HSequenceOfTransient) GetList(const Standard_CString first = "", const Standard_CString second = "");
//!
Standard_EXPORT static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr);
//!
Standard_EXPORT static void CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
const TCollection_AsciiString& theName,
XSControl_WorkSessionMap& theMap,
const Standard_Boolean theIsFirst = Standard_True);
//! Analyses given file name and variable name, with a default //! Analyses given file name and variable name, with a default
//! name for variables. Returns resulting file name and variable //! name for variables. Returns resulting file name and variable
//! name plus status "file to read"(True) or "already read"(False) //! name plus status "file to read"(True) or "already read"(False)

View File

@@ -11,40 +11,24 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <XSDRAWDEWrapper.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
#include <Draw_Appli.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_ProgressIndicator.hxx> #include <Draw_ProgressIndicator.hxx>
#include <IFSelect_SessionPilot.hxx> #include <De_ConfigurationNode.hxx>
#include <Interface_Macros.hxx> #include <DE_ConfigurationContext.hxx>
#include <Interface_Static.hxx> #include <DE_Provider.hxx>
#include <DE_Wrapper.hxx>
#include <Message.hxx> #include <Message.hxx>
#include <Message_ProgressScope.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.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 <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 <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_WorkSession.hxx> #include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx> #include <XSDRAWBase.hxx>
#include <XSDRAWDEWrapper.hxx> #include <TDataStd_Name.hxx>
#include <UnitsMethods.hxx> #include <TDocStd_Application.hxx>
#include <TopoDS_Shape.hxx>
#include <stdio.h>
//======================================================================= //=======================================================================
//function : DumpConfiguration //function : DumpConfiguration
@@ -279,13 +263,13 @@ static Standard_Integer ReadFile(Draw_Interpretor& theDI,
if (aStat) if (aStat)
{ {
TopoDS_Shape aShape; TopoDS_Shape aShape;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS); aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS);
if (isNoDoc && aStat) if (isNoDoc && aStat)
{ {
DBRep::Set(aDocShapeName.ToCString(), aShape); DBRep::Set(aDocShapeName.ToCString(), aShape);
} }
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
} }
if (!aStat) if (!aStat)
{ {
@@ -358,7 +342,7 @@ static Standard_Integer WriteFile(Draw_Interpretor& theDI,
{ {
aStat = aConf->Load(aConfString); aStat = aConf->Load(aConfString);
} }
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (aStat) if (aStat)
{ {
if (isNoDoc) if (isNoDoc)
@@ -380,11 +364,11 @@ static Standard_Integer WriteFile(Draw_Interpretor& theDI,
{ {
return 1; return 1;
} }
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
return 0; return 0;
} }
void XSDRAWDEWrapper::InitCommands(Draw_Interpretor& theDI) void XSDRAWDEWrapper::Factory(Draw_Interpretor& theDI)
{ {
static Standard_Boolean initactor = Standard_False; static Standard_Boolean initactor = Standard_False;
if (initactor) if (initactor)

View File

@@ -26,7 +26,7 @@ public:
Standard_EXPORT static void Init(); Standard_EXPORT static void Init();
//! Loads all Draw commands of XSDRAWSTL. Used for plugin. //! Loads all Draw commands of XSDRAWDEWrapper. Used for plugin.
Standard_EXPORT static void Factory(Draw_Interpretor& theDI); Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
}; };

View File

@@ -13,96 +13,19 @@
#include <XSDRAWGLTF.hxx> #include <XSDRAWGLTF.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 <DBRep.hxx>
#include <DDocStd.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx> #include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx> #include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.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_ConfigurationNode.hxx> #include <RWGltf_ConfigurationNode.hxx>
#include <RWGltf_Provider.hxx> #include <RWGltf_Provider.hxx>
//#include <RWGltf_DracoParameters.hxx> #include <XSControl_WorkSession.hxx>
//#include <RWGltf_CafReader.hxx> #include <XSDRAWBase.hxx>
//#include <RWGltf_CafWriter.hxx>
#include <RWMesh_FaceIterator.hxx>
#include <RWStl.hxx>
#include <RWStl_ConfigurationNode.hxx>
#include <RWStl_Provider.hxx>
//#include <RWObj.hxx>
#include <RWObj_ConfigurationNode.hxx>
#include <RWObj_Provider.hxx>
//#include <RWObj_CafReader.hxx>
//#include <RWObj_CafWriter.hxx>
#include <RWPly_ConfigurationNode.hxx>
#include <RWPly_Provider.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 <TDataStd_Name.hxx>
#include <TDocStd_Application.hxx> #include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <UnitsAPI.hxx>
#include <UnitsMethods.hxx>
#include <V3d_View.hxx>
#include <ViewerTest.hxx>
#include <Vrml_ConfigurationNode.hxx>
#include <Vrml_Provider.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>
#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);
//============================================================================= //=============================================================================
//function : parseNameFormat //function : parseNameFormat
@@ -189,25 +112,6 @@ static bool parseCoordinateSystem(const char* theArg,
return Standard_True; return Standard_True;
} }
//=======================================================================
//function : GetLengthUnit
//purpose : Gets length unit value from static interface and document in M
//=======================================================================
static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr)
{
if (!theDoc.IsNull())
{
Standard_Real aUnit = 1.;
if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
UnitsMethods_LengthUnit_Millimeter))
{
return aUnit;
}
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
return UnitsMethods::GetCasCadeLengthUnit();
}
//============================================================================= //=============================================================================
//function : ReadGltf //function : ReadGltf
//purpose : Reads glTF file //purpose : Reads glTF file
@@ -220,14 +124,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode) aNode =
new RWGltf_ConfigurationNode(); new RWGltf_ConfigurationNode();
Standard_Boolean toUseExistingDoc = Standard_False; 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"); Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{ {
@@ -278,19 +174,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
aNode->InternalParameters.ReadPrintDebugMessages = aNode->InternalParameters.ReadPrintDebugMessages =
Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); 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()) else if (aDestName.IsEmpty())
{ {
aDestName = theArgVec[anArgIter]; aDestName = theArgVec[anArgIter];
@@ -305,13 +188,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
return 1; return 1;
} }
} }
//if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
//{
// if (toListExternalFiles || toPrintAssetInfo)
// {
// std::swap (aFilePath, aDestName);
// }
//}
if (aFilePath.IsEmpty() || aDestName.IsEmpty()) if (aFilePath.IsEmpty() || aDestName.IsEmpty())
{ {
theDI << "Syntax error: wrong number of arguments\n"; theDI << "Syntax error: wrong number of arguments\n";
@@ -342,11 +218,11 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
} }
} }
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(RWGltf_Provider) aProvider = Handle(RWGltf_Provider) aProvider =
new RWGltf_Provider(aNode); new RWGltf_Provider(aNode);
Standard_Boolean aReadStat = Standard_False; Standard_Boolean aReadStat = Standard_False;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (isNoDoc) if (isNoDoc)
{ {
TopoDS_Shape aResShape; TopoDS_Shape aResShape;
@@ -371,30 +247,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
theDI << "Cannot read any relevant data from the GLTF file\n"; theDI << "Cannot read any relevant data from the GLTF file\n";
return 1; return 1;
} }
//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; return 0;
} }
@@ -413,15 +265,6 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
Handle(RWGltf_ConfigurationNode) aNode = Handle(RWGltf_ConfigurationNode) aNode =
new RWGltf_ConfigurationNode(); new RWGltf_ConfigurationNode();
//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) for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{ {
TCollection_AsciiString anArgCase(theArgVec[anArgIter]); TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
@@ -615,11 +458,11 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
TCollection_AsciiString anExt = aGltfFilePath; TCollection_AsciiString anExt = aGltfFilePath;
anExt.LowerCase(); anExt.LowerCase();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(RWGltf_Provider) aProvider = Handle(RWGltf_Provider) aProvider =
new RWGltf_Provider(aNode); new RWGltf_Provider(aNode);
Standard_Boolean aWriteStat = Standard_False; Standard_Boolean aWriteStat = Standard_False;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aDoc.IsNull()) if (!aDoc.IsNull())
{ {
aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start()); aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start());
@@ -636,82 +479,68 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
return 0; return 0;
} }
//=======================================================================
//function : InitCommands
//purpose :
//=======================================================================
void XSDRAWGLTF::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);
}
//======================================================================= //=======================================================================
//function : Factory //function : Factory
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSDRAWGLTF::Factory(Draw_Interpretor& theDI) void XSDRAWGLTF::Factory(Draw_Interpretor& theDI)
{ {
XSDRAWIGES::InitSelect(); const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
XSDRAWIGES::InitToBRep(theDI);
XSDRAWIGES::InitFromBRep(theDI); theDI.Add("ReadGltf",
XSDRAWSTEP::InitCommands(theDI); "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
XSDRAWGLTF::InitCommands(theDI); "\n\t\t: Read glTF file into XDE document."
XSDRAW::LoadDraw(theDI); "\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);
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, g);
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, g);
theDI.Add("writegltf",
"writegltf shape file",
__FILE__, WriteGltf, g);
XSDRAWBase::LoadDraw(theDI);
#ifdef OCCT_DEBUG #ifdef OCCT_DEBUG
theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n"; theDI << "Draw Plugin : All XSDRAWGLTF commands are loaded\n";
#endif #endif
} }

View File

@@ -26,7 +26,7 @@ public:
Standard_EXPORT static void Init(); Standard_EXPORT static void Init();
//! Loads all Draw commands of XSDRAWSTL. Used for plugin. //! Loads all Draw commands of XSDRAWGLTF. Used for plugin.
Standard_EXPORT static void Factory(Draw_Interpretor& theDI); Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
}; };

View File

@@ -11,130 +11,63 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <BRepTools.hxx> #include <XSDRAWIGES.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
#include <Draw_Appli.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx>
#include <Draw_ProgressIndicator.hxx> #include <Draw_ProgressIndicator.hxx>
#include <DrawTrSurf.hxx> #include <OSD_OpenFile.hxx>
#include <IFSelect_Functions.hxx> #include <OSD_Path.hxx>
#include <IFSelect_SessionPilot.hxx> #include <IGESCAFControl_ConfigurationNode.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <IGESControl_Controller.hxx> #include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx> #include <IGESControl_Reader.hxx>
#include <IGESControl_Writer.hxx> #include <IGESControl_Writer.hxx>
#include <IGESData_IGESEntity.hxx> #include <IGESData_IGESEntity.hxx>
#include <IGESData_IGESModel.hxx> #include <IGESData_IGESModel.hxx>
#include <IGESSelect_Activator.hxx> #include <IGESSelect_Activator.hxx>
#include <Interface_Macros.hxx>
#include <Interface_Static.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 <TopoDS_Shape.hxx>
#include <Transfer_FinderProcess.hxx>
#include <Transfer_IteratorOfProcessForTransient.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSControl.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSControl_TransferReader.hxx>
#include <XSDRAW.hxx>
#include <XSDRAWIGES.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 <Message.hxx>
#include <IFSelect_SessionPilot.hxx> #include <XSControl_WorkSession.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx> #include <XSDRAWBase.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Provider.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <XDEDRAW_Common.hxx>
#include <XSAlgo.hxx> #include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx> #include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_WorkSession.hxx> #include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx> #include <TDataStd_Name.hxx>
#include <Vrml_ConfigurationNode.hxx> #include <TDocStd_Application.hxx>
#include <Vrml_Provider.hxx>
#include <DBRep.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_Editor.hxx>
#include <TDF_Tool.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Interface_Static.hxx>
#include <UnitsAPI.hxx>
#include <UnitsMethods.hxx>
#include <stdio.h>
namespace
{
//=======================================================================
//function : WriteShape
//purpose : Creates a file Shape_'number'
//======================================================================= //=======================================================================
void WriteShape(const TopoDS_Shape& shape, const Standard_Integer number) //function : igesbrep
{ //purpose :
char fname[110]; //=======================================================================
sprintf(fname, "Shape_%d", number); static Standard_Integer igesbrep(Draw_Interpretor& theDI,
std::ofstream f(fname, std::ios::out | std::ios::binary); Standard_Integer theNbArgs,
std::cout << "Output file name : " << fname << std::endl; const char** theArgVec)
f << "DBRep_DrawableShape\n";
BRepTools::Write(shape, f);
f.close();
}
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++)
{
if (i > argf) res.AssignCat(" ");
res.AssignCat(argv[i]);
}
return res;
}
}
//--------------------------------------------------------------
// Function : igesbrep
//--------------------------------------------------------------
static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{ {
DeclareAndCast(IGESControl_Controller, ctl, XSDRAW::Controller()); DeclareAndCast(IGESControl_Controller, ctl, XSDRAWBase::Controller());
if (ctl.IsNull()) XSDRAW::SetNorm("IGES"); if (ctl.IsNull()) XSDRAWBase::SetNorm("IGES");
// Progress indicator // Progress indicator
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100); Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100);
IGESControl_Reader Reader(XSDRAW::Session(), Standard_False); IGESControl_Reader Reader(XSDRAWBase::Session(), Standard_False);
Standard_Boolean aFullMode = Standard_True; Standard_Boolean aFullMode = Standard_True;
Reader.WS()->SetModeStat(aFullMode); Reader.WS()->SetModeStat(aFullMode);
if (ctl.IsNull()) if (ctl.IsNull())
ctl = Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller()); ctl = Handle(IGESControl_Controller)::DownCast(XSDRAWBase::Controller());
TCollection_AsciiString fnom, rnom; TCollection_AsciiString fnom, rnom;
Standard_Boolean modfic = XSDRAW::FileAndVar Standard_Boolean modfic = XSDRAWBase::FileAndVar
(argv[1], argv[2], "IGESBREP", fnom, rnom); (theArgVec[1], theArgVec[2], "IGESBREP", fnom, rnom);
if (modfic) di << " File IGES to read : " << fnom.ToCString() << "\n"; if (modfic) theDI << " File IGES to read : " << fnom.ToCString() << "\n";
else di << " Model taken from the session : " << fnom.ToCString() << "\n"; else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
di << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n"; theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
IFSelect_ReturnStatus readstat = IFSelect_RetVoid; IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
#ifdef CHRONOMESURE #ifdef CHRONOMESURE
@@ -148,7 +81,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
progress->Show(aPSRoot); 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; else if (XSDRAWBase::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
aPSRoot.Next(20); // On average loading takes 20% aPSRoot.Next(20); // On average loading takes 20%
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
@@ -156,12 +89,12 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
if (readstat != IFSelect_RetDone) if (readstat != IFSelect_RetDone)
{ {
if (modfic) di << "Could not read file " << fnom.ToCString() << " , abandon\n"; if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
else di << "No model loaded\n"; else theDI << "No model loaded\n";
return 1; return 1;
} }
// Choice of treatment // Choice of treatment
Standard_Boolean fromtcl = (argc > 3); Standard_Boolean fromtcl = (theNbArgs > 3);
Standard_Integer modepri = 1, nent, nbs; Standard_Integer modepri = 1, nent, nbs;
if (fromtcl) modepri = 4; if (fromtcl) modepri = 4;
@@ -183,18 +116,18 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
if (modepri == 0) if (modepri == 0)
{ //fin { //fin
di << "Bye and good luck! \n"; theDI << "Bye and good luck! \n";
break; break;
} }
else if (modepri <= 2) else if (modepri <= 2)
{ // 1 : Visible Roots, 2 : All Roots { // 1 : Visible Roots, 2 : All Roots
di << "All Geometry Transfer\n"; theDI << "All Geometry Transfer\n";
di << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n"; theDI << "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"; theDI << " To modify : command param read.iges.bspline.continuity\n";
const Handle(XSControl_WorkSession)& thesession = Reader.WS(); const Handle(XSControl_WorkSession)& thesession = Reader.WS();
thesession->TransferReader()->Context().Clear(); thesession->TransferReader()->Context().Clear();
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
aPSRoot.SetName("Translation"); aPSRoot.SetName("Translation");
progress->Show(aPSRoot); progress->Show(aPSRoot);
@@ -207,7 +140,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
// result in only one shape for all the roots // result in only one shape for all the roots
// or in one shape for one root. // 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; Standard_Integer answer = 1;
if (Reader.NbShapes() > 1) if (Reader.NbShapes() > 1)
{ {
@@ -223,10 +156,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
{ {
TopoDS_Shape shape = Reader.OneShape(); TopoDS_Shape shape = Reader.OneShape();
// save the shape // save the shape
if (shape.IsNull()) { di << "No Shape produced\n"; continue; } if (shape.IsNull()) { theDI << "No Shape produced\n"; continue; }
char fname[110]; char fname[110];
Sprintf(fname, "%s", rnom.ToCString()); Sprintf(fname, "%s", rnom.ToCString());
di << "Saving shape in variable Draw : " << fname << "\n"; theDI << "Saving shape in variable Draw : " << fname << "\n";
if (answer == 3) WriteShape(shape, 1); if (answer == 3) WriteShape(shape, 1);
try try
{ {
@@ -235,10 +168,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
} }
catch (Standard_Failure const& anException) catch (Standard_Failure const& anException)
{ {
di << "** Exception : "; theDI << "** Exception : ";
di << anException.GetMessageString(); theDI << anException.GetMessageString();
di << " ** Skip\n"; theDI << " ** Skip\n";
di << "Saving shape in variable Draw : " << fname << "\n"; theDI << "Saving shape in variable Draw : " << fname << "\n";
WriteShape(shape, 1); WriteShape(shape, 1);
} }
} }
@@ -250,10 +183,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
{ {
// save all the shapes // save all the shapes
TopoDS_Shape shape = Reader.Shape(inum); TopoDS_Shape shape = Reader.Shape(inum);
if (shape.IsNull()) { di << "No Shape produced\n"; continue; } if (shape.IsNull()) { theDI << "No Shape produced\n"; continue; }
char fname[110]; char fname[110];
Sprintf(fname, "%s_%d", rnom.ToCString(), inum); Sprintf(fname, "%s_%d", rnom.ToCString(), inum);
di << "Saving shape in variable Draw : " << fname << "\n"; theDI << "Saving shape in variable Draw : " << fname << "\n";
if (answer == 4) WriteShape(shape, inum); if (answer == 4) WriteShape(shape, inum);
try try
{ {
@@ -262,9 +195,9 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
} }
catch (Standard_Failure const& anException) catch (Standard_Failure const& anException)
{ {
di << "** Exception : "; theDI << "** Exception : ";
di << anException.GetMessageString(); theDI << anException.GetMessageString();
di << " ** Skip\n"; theDI << " ** Skip\n";
} }
} }
} }
@@ -277,16 +210,16 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
std::cout << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)" << 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 << " To modify : command param read.iges.bspline.continuity" << std::endl;
std::cout << " give the number of the Entity : " << std::flush; std::cout << " give the number of the Entity : " << std::flush;
nent = XSDRAW::GetEntityNumber(); nent = XSDRAWBase::GetEntityNumber();
if (!Reader.TransferOne(nent)) if (!Reader.TransferOne(nent))
di << "Transfer entity n0 " << nent << " : no result\n"; theDI << "Transfer entity n0 " << nent << " : no result\n";
else else
{ {
nbs = Reader.NbShapes(); nbs = Reader.NbShapes();
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nent); char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nent);
di << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n"; theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
di << "Now, " << nbs << " Shapes produced\n"; theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = Reader.Shape(nbs); TopoDS_Shape sh = Reader.Shape(nbs);
DBRep::Set(shname, sh); DBRep::Set(shname, sh);
} }
@@ -301,14 +234,14 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
// * donne iges-visible + xst-transferrable-roots // * donne iges-visible + xst-transferrable-roots
// *r donne xst-model-roots (TOUTES racines) // *r donne xst-model-roots (TOUTES racines)
if (fromtcl && argv[3][0] == '*' && argv[3][1] == '\0') if (fromtcl && theArgVec[3][0] == '*' && theArgVec[3][1] == '\0')
{ {
di << "All Geometry Transfer\n"; theDI << "All Geometry Transfer\n";
di << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n"; theDI << "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"; theDI << " To modify : command param read.iges.bspline.continuity\n";
const Handle(XSControl_WorkSession)& thesession = Reader.WS(); const Handle(XSControl_WorkSession)& thesession = Reader.WS();
thesession->TransferReader()->Context().Clear(); thesession->TransferReader()->Context().Clear();
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
aPSRoot.SetName("Translation"); aPSRoot.SetName("Translation");
progress->Show(aPSRoot); progress->Show(aPSRoot);
@@ -324,7 +257,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
// save the shape // save the shape
char fname[110]; char fname[110];
Sprintf(fname, "%s", rnom.ToCString()); Sprintf(fname, "%s", rnom.ToCString());
di << "Saving shape in variable Draw : " << fname << "\n"; theDI << "Saving shape in variable Draw : " << fname << "\n";
try try
{ {
OCC_CATCH_SIGNALS OCC_CATCH_SIGNALS
@@ -332,10 +265,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
} }
catch (Standard_Failure const& anException) catch (Standard_Failure const& anException)
{ {
di << "** Exception : "; theDI << "** Exception : ";
di << anException.GetMessageString(); theDI << anException.GetMessageString();
di << " ** Skip\n"; theDI << " ** Skip\n";
di << "Saving shape in variable Draw : " << fname << "\n"; theDI << "Saving shape in variable Draw : " << fname << "\n";
WriteShape(shape, 1); WriteShape(shape, 1);
} }
return 0; return 0;
@@ -344,32 +277,32 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
if (fromtcl) if (fromtcl)
{ {
modepri = 0; // d office, une seule passe modepri = 0; // d office, une seule passe
if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') if (theArgVec[3][0] == '*' && theArgVec[3][1] == 'r' && theArgVec[3][2] == '\0')
{ {
di << "All Roots : "; theDI << "All Roots : ";
list = XSDRAW::GetList("xst-model-roots"); list = XSDRAWBase::GetList("xst-model-roots");
} }
else else
{ {
TCollection_AsciiString compart = XSDRAW_CommandPart(argc, argv, 3); TCollection_AsciiString compart = XSDRAW_CommandPart(theNbArgs, theArgVec, 3);
di << "List given by " << compart.ToCString() << " : "; theDI << "List given by " << compart.ToCString() << " : ";
list = XSDRAW::GetList(compart.ToCString()); list = XSDRAWBase::GetList(compart.ToCString());
} }
if (list.IsNull()) if (list.IsNull())
{ {
di << "No list defined. Give a selection name or * for all visible transferrable roots\n"; theDI << "No list defined. Give a selection name or * for all visible transferrable roots\n";
continue; continue;
} }
} }
else else
{ {
std::cout << "Name of Selection :" << std::flush; std::cout << "Name of Selection :" << std::flush;
list = XSDRAW::GetList(); list = XSDRAWBase::GetList();
if (list.IsNull()) { std::cout << "No list defined" << std::endl; continue; } if (list.IsNull()) { std::cout << "No list defined" << std::endl; continue; }
} }
Standard_Integer nbl = list->Length(); Standard_Integer nbl = list->Length();
di << "Nb entities selected : " << nbl << "\n"; theDI << "Nb entities selected : " << nbl << "\n";
if (nbl == 0) continue; if (nbl == 0) continue;
while (answer) while (answer)
{ {
@@ -388,16 +321,16 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
for (Standard_Integer ill = 1; ill <= nbl; ill++) for (Standard_Integer ill = 1; ill <= nbl; ill++)
{ {
Handle(Standard_Transient) ent = list->Value(ill); Handle(Standard_Transient) ent = list->Value(ill);
di << " ";// model->Print(ent,di); theDI << " ";// model->Print(ent,theDI);
} }
di << "\n"; theDI << "\n";
} }
if (answer == 1 || answer == 2) if (answer == 1 || answer == 2)
{ {
Standard_Integer nbt = 0; Standard_Integer nbt = 0;
Handle(XSControl_WorkSession) thesession = Reader.WS(); Handle(XSControl_WorkSession) thesession = Reader.WS();
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
aPSRoot.SetName("Translation"); aPSRoot.SetName("Translation");
progress->Show(aPSRoot); progress->Show(aPSRoot);
@@ -407,13 +340,13 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
nent = Reader.Model()->Number(list->Value(ill)); nent = Reader.Model()->Number(list->Value(ill));
if (nent == 0) continue; if (nent == 0) continue;
if (!Reader.TransferOne(nent, aPS.Next())) if (!Reader.TransferOne(nent, aPS.Next()))
di << "Transfer entity n0 " << nent << " : no result\n"; theDI << "Transfer entity n0 " << nent << " : no result\n";
else else
{ {
nbs = Reader.NbShapes(); nbs = Reader.NbShapes();
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs); char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
di << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n"; theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
di << "Now, " << nbs << " Shapes produced\n"; theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = Reader.Shape(nbs); TopoDS_Shape sh = Reader.Shape(nbs);
DBRep::Set(shname, sh); DBRep::Set(shname, sh);
nbt++; nbt++;
@@ -421,55 +354,58 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
} }
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
return 1; return 1;
di << "Nb Shapes successfully produced : " << nbt << "\n"; theDI << "Nb Shapes successfully produced : " << nbt << "\n";
answer = 0; // on ne reboucle pas answer = 0; // on ne reboucle pas
} }
} }
} }
else di << "Unknown mode n0 " << modepri << "\n"; else theDI << "Unknown mode n0 " << modepri << "\n";
} }
return 0; return 0;
} }
//-------------------------------------------------------------- //=======================================================================
// Function : testreadiges //function : testread
// //purpose :
//-------------------------------------------------------------- //=======================================================================
static Standard_Integer testread(Draw_Interpretor& di, Standard_Integer argc, const char** argv) static Standard_Integer testread(Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
{ {
if (argc != 3) if (theNbArgs != 3)
{ {
di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n"; theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
di << " Usage : " << argv[0] << " file_name shape_name\n"; theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
return 1; return 1;
} }
IGESControl_Reader Reader; IGESControl_Reader Reader;
Standard_CString filename = argv[1]; Standard_CString filename = theArgVec[1];
IFSelect_ReturnStatus readstat = Reader.ReadFile(filename); IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
di << "Status from reading IGES file " << filename << " : "; theDI << "Status from reading IGES file " << filename << " : ";
switch (readstat) switch (readstat)
{ {
case IFSelect_RetVoid: { di << "empty file\n"; return 1; } case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
case IFSelect_RetDone: { di << "file read\n"; break; } case IFSelect_RetDone: { theDI << "file read\n"; break; }
case IFSelect_RetError: { di << "file not found\n"; return 1; } case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
case IFSelect_RetFail: { di << "error during read\n"; return 1; } case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
default: { di << "failure\n"; return 1; } default: { theDI << "failure\n"; return 1; }
} }
Reader.TransferRoots(); Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape(); TopoDS_Shape shape = Reader.OneShape();
DBRep::Set(argv[2], shape); DBRep::Set(theArgVec[2], shape);
di << "Count of shapes produced : " << Reader.NbShapes() << "\n"; theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
return 0; return 0;
} }
//-------------------------------------------------------------- //=======================================================================
// Function : brepiges //function : brepiges
// //purpose :
//-------------------------------------------------------------- //=======================================================================
static Standard_Integer brepiges(Draw_Interpretor& theDI,
static Standard_Integer brepiges(Draw_Interpretor& di, Standard_Integer n, const char** a) Standard_Integer theNbArgs,
const char** theArgVec)
{ {
XSDRAW::SetNorm("IGES"); XSDRAWBase::SetNorm("IGES");
// ecriture dans le model d'une entite : // ecriture dans le model d'une entite :
// - model_AddEntity(ent) : ecriture de l`entite seule // - model_AddEntity(ent) : ecriture de l`entite seule
// - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement // - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
@@ -478,115 +414,117 @@ static Standard_Integer brepiges(Draw_Interpretor& di, Standard_Integer n, const
IGESControl_Writer ICW(Interface_Static::CVal("write.iges.unit"), IGESControl_Writer ICW(Interface_Static::CVal("write.iges.unit"),
Interface_Static::IVal("write.iges.brep.mode")); Interface_Static::IVal("write.iges.brep.mode"));
di << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n"; theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
di << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n"; theDI << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
di << " To modify : command param\n"; theDI << " To modify : command param\n";
// Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic // Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
// c a d tant qu il y a des + on ajoute ce qui suit // c a d tant qu il y a des + on ajoute ce qui suit
const char* nomfic = NULL; const char* nomfic = NULL;
Standard_Integer npris = 0; Standard_Integer npris = 0;
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100); Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
progress->Show(aPSRoot); progress->Show(aPSRoot);
Message_ProgressScope aPS(aPSRoot.Next(90), NULL, n); Message_ProgressScope aPS(aPSRoot.Next(90), NULL, n);
for (Standard_Integer i = 1; i < n && aPS.More(); i++) for (Standard_Integer i = 1; i < theNbArgs && aPS.More(); i++)
{ {
const char* nomvar = a[i]; const char* nomvar = theArgVec[i];
if (a[i][0] == '+') nomvar = &(a[i])[1]; if (theArgVec[i][0] == '+') nomvar = &(theArgVec[i])[1];
else if (i > 1) { nomfic = a[i]; break; } else if (i > 1) { nomfic = theArgVec[i]; break; }
TopoDS_Shape Shape = DBRep::Get(nomvar); TopoDS_Shape Shape = DBRep::Get(nomvar);
if (ICW.AddShape(Shape, aPS.Next())) npris++; if (ICW.AddShape(Shape, aPS.Next())) npris++;
else if (ICW.AddGeom(DrawTrSurf::GetCurve(nomvar))) npris++; else if (ICW.AddGeom(DrawTrSurf::GetCurve(nomvar))) npris++;
else if (ICW.AddGeom(DrawTrSurf::GetSurface(nomvar))) npris++; else if (ICW.AddGeom(DrawTrSurf::GetSurface(nomvar))) npris++;
} }
ICW.ComputeModel(); ICW.ComputeModel();
XSDRAW::SetModel(ICW.Model()); XSDRAWBase::SetModel(ICW.Model());
XSDRAW::SetTransferProcess(ICW.TransferProcess()); XSDRAWBase::SetTransferProcess(ICW.TransferProcess());
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
return 1; return 1;
aPSRoot.SetName("Writing"); aPSRoot.SetName("Writing");
progress->Show(aPSRoot); progress->Show(aPSRoot);
di << npris << " Shapes written, giving " << XSDRAW::Model()->NbEntities() << " Entities\n"; theDI << npris << " Shapes written, giving " << XSDRAWBase::Model()->NbEntities() << " Entities\n";
if (!nomfic) // delayed write if (!nomfic) // delayed write
{ {
di << " Now, to write a file, command : writeall filename\n"; theDI << " Now, to write a file, command : writeall filename\n";
return 0; return 0;
} }
// write file // write file
if (!ICW.Write(nomfic)) di << " Error: could not write file " << nomfic; if (!ICW.Write(nomfic)) theDI << " Error: could not write file " << nomfic;
else di << " File " << nomfic << " written"; else theDI << " File " << nomfic << " written";
return 0; return 0;
} }
//-------------------------------------------------------------- //=======================================================================
// Function : testwriteiges //function : testwrite
// //purpose :
//-------------------------------------------------------------- //=======================================================================
static Standard_Integer testwrite(Draw_Interpretor& theDI,
static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer n, const char** a) Standard_Integer theNbArgs,
const char** theArgVec)
{ {
if (n != 3) if (theNbArgs != 3)
{ {
di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n"; theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
di << " Usage : " << a[0] << " file_name shape_name\n"; theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
return 1; return 1;
} }
IGESControl_Writer Writer; IGESControl_Writer Writer;
Standard_CString filename = a[1]; Standard_CString filename = theArgVec[1];
TopoDS_Shape shape = DBRep::Get(a[2]); TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
Standard_Boolean ok = Writer.AddShape(shape); Standard_Boolean ok = Writer.AddShape(shape);
if (!ok) if (!ok)
{ {
di << "Shape not add\n"; theDI << "Shape not add\n";
return 1; return 1;
} }
if (!(Writer.Write(filename))) if (!(Writer.Write(filename)))
{ {
di << "Error on writing file\n"; theDI << "Error on writing file\n";
return 1; return 1;
} }
di << "File Is Written\n"; theDI << "File Is Written\n";
return 0; 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 // liste des parametres
di << "List of parameters which control IGES :\n"; theDI << "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"; 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";
di << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n"; theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
di << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n"; theDI << "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"; theDI << "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"; theDI << "\n To modifier, param nom_param new_val\n";
return 0; return 0;
} }
//=======================================================================
//-------------------------------------------------------------- //function : XSDRAWIGES_tplosttrim
// Function : tplosttrim //purpose :
// //=======================================================================
//-------------------------------------------------------------- static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Integer n, const char** a) const char** theArgVec)
{ {
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot(); Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
// Standard_Integer narg = pilot->NbWords(); // Standard_Integer narg = pilot->NbWords();
Standard_Integer narg = n; Standard_Integer narg = theNbArgs;
const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
TColStd_Array1OfAsciiString strarg(1, 3); TColStd_Array1OfAsciiString strarg(1, 3);
@@ -597,7 +535,7 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
typarg.SetValue(1, "IGESGeom_TrimmedSurface"); typarg.SetValue(1, "IGESGeom_TrimmedSurface");
typarg.SetValue(2, "IGESGeom_BoundedSurface"); typarg.SetValue(2, "IGESGeom_BoundedSurface");
typarg.SetValue(3, "IGESSolid_Face"); typarg.SetValue(3, "IGESSolid_Face");
if (TP.IsNull()) { di << "No Transfer Read\n"; return 1; } if (TP.IsNull()) { theDI << "No Transfer Read\n"; return 1; }
Standard_Integer nbFaces = 0, totFaces = 0; Standard_Integer nbFaces = 0, totFaces = 0;
Handle(IFSelect_WorkSession) WS = pilot->Session(); Handle(IFSelect_WorkSession) WS = pilot->Session();
Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult(); Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
@@ -605,13 +543,13 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
if (narg > 1) if (narg > 1)
{ {
// TCollection_AsciiString Arg = pilot->Word(1); // TCollection_AsciiString Arg = pilot->Word(1);
TCollection_AsciiString Arg(a[1]); TCollection_AsciiString Arg(theArgVec[1]);
for (k = 1; k <= 3; k++) for (k = 1; k <= 3; k++)
{ {
if (typarg.Value(k).Location(Arg, 1, typarg.Value(k).Length()) != 0) break; if (typarg.Value(k).Location(Arg, 1, typarg.Value(k).Length()) != 0) break;
} }
} }
if (k == 4) { di << "Invalid argument\n"; return 0; } if (k == 4) { theDI << "Invalid argument\n"; return 0; }
for (Standard_Integer j = 1; j <= 3; j++) for (Standard_Integer j = 1; j <= 3; j++)
{ {
TColStd_MapOfTransient aMap; TColStd_MapOfTransient aMap;
@@ -620,7 +558,7 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
if (!list.IsNull()) itrp.Filter(list); if (!list.IsNull()) itrp.Filter(list);
else else
{ {
di << "No untrimmed faces\n"; theDI << "No untrimmed faces\n";
return 0; return 0;
} }
for (itrp.Start(); itrp.More(); itrp.Next()) for (itrp.Start(); itrp.More(); itrp.Next())
@@ -642,56 +580,58 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
} }
if (nbFaces != 0) if (nbFaces != 0)
{ {
if (j == 1) di << "Number of untrimmed faces: \n"; if (j == 1) theDI << "Number of untrimmed faces: \n";
switch (k) switch (k)
{ {
case 1: case 1:
di << "Trimmed Surface: \n"; break; theDI << "Trimmed Surface: \n"; break;
case 2: case 2:
di << "Bounded Surface: \n"; break; theDI << "Bounded Surface: \n"; break;
case 3: case 3:
di << "Face: \n"; break; theDI << "Face: \n"; break;
} }
TColStd_MapIteratorOfMapOfTransient itmap; TColStd_MapIteratorOfMapOfTransient itmap;
Standard_SStream aTmpStream; Standard_SStream aTmpStream;
for (itmap.Initialize(aMap); itmap.More(); itmap.Next()) for (itmap.Initialize(aMap); itmap.More(); itmap.Next())
{ {
XSDRAW::Model()->Print(itmap.Key(), aTmpStream); XSDRAWBase::Model()->Print(itmap.Key(), aTmpStream);
aTmpStream << " "; aTmpStream << " ";
} }
di << aTmpStream.str().c_str(); theDI << aTmpStream.str().c_str();
di << "\n"; theDI << "\n";
di << "\nNumber:" << nbFaces << "\n"; theDI << "\nNumber:" << nbFaces << "\n";
totFaces += nbFaces; totFaces += nbFaces;
} }
if (narg > 1) break; if (narg > 1) break;
nbFaces = 0; nbFaces = 0;
} }
if (totFaces == 0) di << "No untrimmed faces\n"; if (totFaces == 0) theDI << "No untrimmed faces\n";
else di << "Total number :" << totFaces << "\n"; else theDI << "Total number :" << totFaces << "\n";
return 0; return 0;
} }
//-------------------------------------------------------------------
//-------------------------------------------------------------- //=======================================================================
// Function : TPSTAT //function : XSDRAWIGES_TPSTAT
// //purpose :
//-------------------------------------------------------------- //=======================================================================
static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer n, const char** a) static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI,
Standard_Integer theNbArgs,
const char** theArgVec)
{ {
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot(); Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
Standard_Integer argc = n;//= pilot->NbWords(); Standard_Integer theNbArgs = theNbArgs;//= pilot->NbWords();
const Standard_CString arg1 = a[1];//pilot->Arg(1); const Standard_CString arg1 = theArgVec[1];//pilot->Arg(1);
const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False); IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
// **** tpent **** // **** tpent ****
Handle(Interface_InterfaceModel) model = TP->Model(); Handle(Interface_InterfaceModel) model = TP->Model();
if (model.IsNull()) { di << "No Transfer Read\n"; return -1; } if (model.IsNull()) { theDI << "No Transfer Read\n"; return -1; }
Handle(XSControl_WorkSession) thesession = read.WS(); Handle(XSControl_WorkSession) thesession = read.WS();
thesession->SetMapReader(TP); thesession->SetMapReader(TP);
Standard_Integer mod1 = 0; Standard_Integer mod1 = 0;
if (argc > 1) if (theNbArgs > 1)
{ {
char a2 = arg1[1]; if (a2 == '\0') a2 = '!'; char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
switch (arg1[0]) switch (arg1[0])
@@ -705,10 +645,10 @@ static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer
default: mod1 = -2; break; default: mod1 = -2; break;
} }
} }
if (mod1 < -1) di << "Unknown Mode\n"; if (mod1 < -1) theDI << "Unknown Mode\n";
if (mod1 < 0) if (mod1 < 0)
{ {
di << "Modes available :\n" theDI << "Modes available :\n"
<< "g : general c : checks (count) C (list)\n" << "g : general c : checks (count) C (list)\n"
<< "r : number of CasCade resulting shapes\n" << "r : number of CasCade resulting shapes\n"
<< "s : mapping between IGES entities and CasCade shapes\n"; << "s : mapping between IGES entities and CasCade shapes\n";
@@ -718,45 +658,28 @@ static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer
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) if (theNbArgs < 3)
{ {
di << "etest igesfile shape\n"; theDI << "etest igesfile shape\n";
return 0; return 0;
} }
IGESControl_Reader aReader; IGESControl_Reader aReader;
aReader.ReadFile(a[1]); aReader.ReadFile(theArgVec[1]);
aReader.SetReadVisible(Standard_True); aReader.SetReadVisible(Standard_True);
aReader.TransferRoots(); aReader.TransferRoots();
TopoDS_Shape shape = aReader.OneShape(); TopoDS_Shape shape = aReader.OneShape();
DBRep::Set(a[2], shape); DBRep::Set(theArgVec[2], shape);
return 0; return 0;
} }
extern "C" {
static void cleanpilot()
{
XSDRAW::Session()->ClearData(1);
}
}
//--------------------------------------------------------------
// Function : Init(s)
//
//--------------------------------------------------------------
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);
}
//======================================================================= //=======================================================================
//function : ReadIges //function : ReadIges
//purpose : Read IGES to DECAF document //purpose : Read IGES to DECAF document
@@ -796,18 +719,18 @@ static Standard_Integer ReadIges(Draw_Interpretor& theDI,
Handle(DDocStd_DrawDocument) aDrawD = new DDocStd_DrawDocument(aDoc); Handle(DDocStd_DrawDocument) aDrawD = new DDocStd_DrawDocument(aDoc);
Draw::Set(theArgVec[1], aDrawD); Draw::Set(theArgVec[1], aDrawD);
} }
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
Handle(IGESCAFControl_Provider) aProvider = Handle(IGESCAFControl_Provider) aProvider =
new IGESCAFControl_Provider(aNode); new IGESCAFControl_Provider(aNode);
aProvider->SetToUpdateStaticParameters(false); aProvider->SetToUpdateStaticParameters(false);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start())) if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start()))
{ {
theDI << "Error: Can't read IGES file\n"; theDI << "Error: Can't read IGES file\n";
return 1; return 1;
} }
CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
Message::SendInfo() << "Document saved with name " << theArgVec[1]; Message::SendInfo() << "Document saved with name " << theArgVec[1];
return 0; return 0;
} }
@@ -848,52 +771,41 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI,
case 'l': aNode->InternalParameters.WriteLayer = aMode; break; case 'l': aNode->InternalParameters.WriteLayer = aMode; break;
} }
} }
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
Handle(IGESCAFControl_Provider) aProvider = Handle(IGESCAFControl_Provider) aProvider =
new IGESCAFControl_Provider(aNode); new IGESCAFControl_Provider(aNode);
aProvider->SetToUpdateStaticParameters(false); aProvider->SetToUpdateStaticParameters(false);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
const TCollection_AsciiString aPath = theArgVec[2]; const TCollection_AsciiString aPath = theArgVec[2];
if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start())) if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start()))
{ {
theDI << "Error: Can't write IGES file\n"; theDI << "Error: Can't write IGES file\n";
return 1; return 1;
} }
CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS);
return 0; return 0;
} }
//======================================================================= //=======================================================================
//function : InitToBRep //function : InitToBRep
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSDRAWIGES::Factory(Draw_Interpretor& theDI)
void XSDRAWIGES::InitToBRep(Draw_Interpretor& theCommands)
{ {
const char* g = "DE: IGES"; const char* g = "DE: IGES";
theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g); theDI.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); theDI.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); theDI.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); theDI.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g); theDI.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g); theDI.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
theCommands.Add("etest", "test of eviewer", __FILE__, etest, g); theDI.Add("etest", "test of eviewer", __FILE__, etest, g);
theCommands.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g); theDI.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g);
theCommands.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g); theDI.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g);
theDI.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g);
theDI.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g);
} }
//=======================================================================
//function : InitFromBRep
//purpose :
//=======================================================================
void XSDRAWIGES::InitFromBRep(Draw_Interpretor& theCommands)
{
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);
}

View File

@@ -19,7 +19,7 @@
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
class XSDRAWIGES class XSDRAWIGES
{ {
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
public: public:

View File

@@ -13,157 +13,22 @@
#include <XSDRAWOBJ.hxx> #include <XSDRAWOBJ.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 <DBRep.hxx>
#include <DDocStd.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx> #include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx> #include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.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_ConfigurationNode.hxx>
#include <RWGltf_Provider.hxx>
//#include <RWGltf_DracoParameters.hxx>
//#include <RWGltf_CafReader.hxx>
//#include <RWGltf_CafWriter.hxx>
#include <RWMesh_FaceIterator.hxx>
#include <RWStl.hxx>
#include <RWStl_ConfigurationNode.hxx>
#include <RWStl_Provider.hxx>
//#include <RWObj.hxx>
#include <RWObj_ConfigurationNode.hxx> #include <RWObj_ConfigurationNode.hxx>
#include <RWObj_Provider.hxx> #include <RWObj_Provider.hxx>
//#include <RWObj_CafReader.hxx>
//#include <RWObj_CafWriter.hxx>
#include <RWPly_ConfigurationNode.hxx>
#include <RWPly_Provider.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 <Vrml_ConfigurationNode.hxx>
#include <Vrml_Provider.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_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx> #include <XCAFDoc_ShapeTool.hxx>
#include <XCAFPrs_DocumentExplorer.hxx> #include <XSControl_WorkSession.hxx>
#include <XSAlgo.hxx> #include <XSDRAWBase.hxx>
#include <XSAlgo_AlgoContainer.hxx> #include <TDataStd_Name.hxx>
#include <XSDRAW.hxx> #include <TDocStd_Application.hxx>
#include <XSDRAWIGES.hxx> #include <TopoDS_Shape.hxx>
#include <XSDRAWSTEP.hxx> #include <UnitsAPI.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);
//=============================================================================
//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 //function : parseCoordinateSystem
@@ -189,25 +54,6 @@ static bool parseCoordinateSystem(const char* theArg,
return Standard_True; return Standard_True;
} }
//=======================================================================
//function : GetLengthUnit
//purpose : Gets length unit value from static interface and document in M
//=======================================================================
static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr)
{
if (!theDoc.IsNull())
{
Standard_Real aUnit = 1.;
if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
UnitsMethods_LengthUnit_Millimeter))
{
return aUnit;
}
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
return UnitsMethods::GetCasCadeLengthUnit();
}
//============================================================================= //=============================================================================
//function : ReadObj //function : ReadObj
//purpose : Reads OBJ file //purpose : Reads OBJ file
@@ -218,11 +64,8 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
{ {
TCollection_AsciiString aDestName, aFilePath; TCollection_AsciiString aDestName, aFilePath;
Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
Standard_Boolean toUseExistingDoc = Standard_False; 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"); Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj");
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{ {
@@ -293,14 +136,6 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
++anArgIter; ++anArgIter;
} }
} }
//else if (anArgCase == "-listexternalfiles"
// || anArgCase == "-listexternals"
// || anArgCase == "-listexternal"
// || anArgCase == "-external"
// || anArgCase == "-externalfiles")
//{
// toListExternalFiles = Standard_True;
//}
else if (aDestName.IsEmpty()) else if (aDestName.IsEmpty())
{ {
aDestName = theArgVec[anArgIter]; aDestName = theArgVec[anArgIter];
@@ -342,8 +177,8 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
} }
} }
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); Handle(RWObj_Provider) aProvider = new RWObj_Provider(aNode);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
Standard_Boolean aReadStat = Standard_False; Standard_Boolean aReadStat = Standard_False;
if (isNoDoc) if (isNoDoc)
{ {
@@ -382,12 +217,10 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
{ {
TCollection_AsciiString anObjFilePath; TCollection_AsciiString anObjFilePath;
Handle(TDocStd_Document) aDoc; Handle(TDocStd_Document) aDoc;
TopoDS_Shape aShape;
Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); 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) for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
{ {
TCollection_AsciiString anArgCase(theArgVec[anArgIter]); TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
@@ -445,15 +278,12 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
DDocStd::GetDocument(aNameVar, aDoc, false); DDocStd::GetDocument(aNameVar, aDoc, false);
if (aDoc.IsNull()) if (aDoc.IsNull())
{ {
TopoDS_Shape aShape = DBRep::Get(aNameVar); aShape = DBRep::Get(aNameVar);
if (aShape.IsNull()) if (aShape.IsNull())
{ {
theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n"; theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n";
return 1; return 1;
} }
anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
aShapeTool->AddShape(aShape);
} }
} }
else if (anObjFilePath.IsEmpty()) else if (anObjFilePath.IsEmpty())
@@ -472,11 +302,21 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
return 1; return 1;
} }
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); Handle(RWObj_Provider) aProvider = new RWObj_Provider(aNode);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) Standard_Boolean aWriteStatus = Standard_False;
if (aDoc.IsNull())
{ {
theDI << "Error: Mesh writing has been failed.\n"; aWriteStatus = aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start());
}
else
{
aWriteStatus = aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start());
}
if (!aWriteStatus)
{
theDI << "Error: Mesh writing has been failed\n";
return 1;
} }
return 0; return 0;
} }
@@ -485,38 +325,38 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
//function : InitCommands //function : InitCommands
//purpose : //purpose :
//======================================================================= //=======================================================================
void XSDRAWOBJ::InitCommands(Draw_Interpretor& theCommands) void XSDRAWOBJ::Factory(Draw_Interpretor& theDI)
{ {
const char* g = "XSTEP-STL/VRML"; // Step transfer file commands const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
theCommands.Add("ReadObj", theDI.Add("ReadObj",
"ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
"\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
"\n\t\t: [-listExternalFiles] [-noCreateDoc]" "\n\t\t: [-listExternalFiles] [-noCreateDoc]"
"\n\t\t: Read OBJ file into XDE document." "\n\t\t: Read OBJ file into XDE document."
"\n\t\t: -fileUnit length unit of OBJ file content;" "\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: -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: -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: -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: -listExternalFiles do not read mesh and only list external files."
"\n\t\t: -noCreateDoc read into existing XDE document.", "\n\t\t: -noCreateDoc read into existing XDE document.",
__FILE__, ReadObj, g); __FILE__, ReadObj, g);
theCommands.Add("readobj", theDI.Add("readobj",
"readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
"\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
"\n\t\t: [-singleFace]" "\n\t\t: [-singleFace]"
"\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document." "\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.", "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.",
__FILE__, ReadObj, g); __FILE__, ReadObj, g);
theCommands.Add("WriteObj", theDI.Add("WriteObj",
"WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
"\n\t\t: [-systemCoordSys {Zup|Yup}]" "\n\t\t: [-systemCoordSys {Zup|Yup}]"
"\n\t\t: [-comments Text] [-author Name]" "\n\t\t: [-comments Text] [-author Name]"
"\n\t\t: Write XDE document into OBJ file." "\n\t\t: Write XDE document into OBJ file."
"\n\t\t: -fileUnit length unit of OBJ file content;" "\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: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
"\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.", "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.",
__FILE__, WriteObj, g); __FILE__, WriteObj, g);
theCommands.Add("writeobj", theDI.Add("writeobj",
"writeobj shape file", "writeobj shape file",
__FILE__, WriteObj, g); __FILE__, WriteObj, g);
} }

View File

@@ -11,17 +11,20 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <XSDRAWSTEP.hxx>
#include <DBRep.hxx> #include <DBRep.hxx>
#include <Draw_Appli.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_ProgressIndicator.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_OpenFile.hxx>
#include <OSD_Path.hxx> #include <OSD_Path.hxx>
#include <Interface_Static.hxx>
#include <Message.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Provider.hxx>
#include <STEPControl_ActorWrite.hxx> #include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx> #include <STEPControl_Controller.hxx>
#include <STEPControl_Reader.hxx> #include <STEPControl_Reader.hxx>
@@ -33,125 +36,45 @@
#include <STEPSelections_AssemblyExplorer.hxx> #include <STEPSelections_AssemblyExplorer.hxx>
#include <STEPSelections_Counter.hxx> #include <STEPSelections_Counter.hxx>
#include <StepToTopoDS_MakeTransformed.hxx> #include <StepToTopoDS_MakeTransformed.hxx>
#include <TColStd_HSequenceOfTransient.hxx> #include <XSControl_WorkSession.hxx>
#include <TopExp_Explorer.hxx> #include <XSDRAWBase.hxx>
#include <Transfer_TransientProcess.hxx>
#include <XSAlgo.hxx> #include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx> #include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_Controller.hxx>
#include <XSControl_WorkSession.hxx> #include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx> #include <TDataStd_Name.hxx>
#include <XSDRAWSTEP.hxx>
#include <UnitsMethods.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_ConfigurationNode.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Provider.hxx>
#include <TDocStd_Application.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 <Vrml_ConfigurationNode.hxx>
#include <Vrml_Provider.hxx>
#include <DBRep.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_Editor.hxx>
#include <TDF_Tool.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Interface_Static.hxx>
#include <UnitsAPI.hxx>
#include <UnitsMethods.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 : GetLengthUnit
//purpose : Gets length unit value from static interface and document in M
//=======================================================================
static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr)
{
if (!theDoc.IsNull())
{
Standard_Real aUnit = 1.;
if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
UnitsMethods_LengthUnit_Millimeter))
{
return aUnit;
}
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
return UnitsMethods::GetCasCadeLengthUnit();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void XSDRAWSTEP::Init()
{
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);
}
// ######## COMMANDE stepread : teste le Reader #########
//======================================================================= //=======================================================================
//function : stepread //function : stepread
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer stepread(Draw_Interpretor& theDI,
static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, const char** argv) Standard_Integer theNbArgs,
const char** theArgVec)
{ {
if (argc < 3) if (theNbArgs < 3)
{ {
di << "Use: stepread [file] [f or r (type of model full or reduced)]\n"; theDI << "Use: stepread [file] [f or r (type of model full or reduced)]\n";
return 1; return 1;
} }
// On admet le controller AP214 ou une variante // On admet le controller AP214 ou une variante
DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); DeclareAndCast(STEPControl_Controller, ctl, XSDRAWBase::Controller());
if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); if (ctl.IsNull()) XSDRAWBase::SetNorm("STEP");
// Progress indicator // Progress indicator
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100); Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100);
STEPControl_Reader sr(XSDRAW::Session(), Standard_False); STEPControl_Reader sr(XSDRAWBase::Session(), Standard_False);
TCollection_AsciiString fnom, rnom; TCollection_AsciiString fnom, rnom;
Standard_Boolean modfic = XSDRAW::FileAndVar Standard_Boolean modfic = XSDRAWBase::FileAndVar
(argv[1], argv[2], "STEP", fnom, rnom); (theArgVec[1], theArgVec[2], "STEP", fnom, rnom);
if (modfic) di << " File STEP to read : " << fnom.ToCString() << "\n"; if (modfic) theDI << " File STEP to read : " << fnom.ToCString() << "\n";
else di << " Model taken from the session : " << fnom.ToCString() << "\n"; else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
di << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n"; theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
IFSelect_ReturnStatus readstat = IFSelect_RetVoid; IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
aPSRoot.SetName("Loading"); aPSRoot.SetName("Loading");
@@ -160,14 +83,14 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
Standard_Boolean fromtcl = Standard_False; Standard_Boolean fromtcl = Standard_False;
Standard_Boolean aFullMode = Standard_False; Standard_Boolean aFullMode = Standard_False;
Standard_Integer k = 3; 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; aFullMode = Standard_True;
k++; k++;
} }
else if (argv[k][0] == 'r' || argv[3][0] == 'R') else if (theArgVec[k][0] == 'r' || theArgVec[3][0] == 'R')
{ {
aFullMode = Standard_False; aFullMode = Standard_False;
k++; k++;
@@ -177,7 +100,7 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
} }
if (!fromtcl) if (!fromtcl)
fromtcl = argc > k; fromtcl = theNbArgs > k;
if (aFullMode) if (aFullMode)
std::cout << "Full model for translation with additional info will be used \n" << std::flush; std::cout << "Full model for translation with additional info will be used \n" << std::flush;
else else
@@ -187,7 +110,7 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
if (modfic) readstat = sr.ReadFile(fnom.ToCString()); if (modfic) readstat = sr.ReadFile(fnom.ToCString());
else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone; else if (XSDRAWBase::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
aPSRoot.Next(20); // On average loading takes 20% aPSRoot.Next(20); // On average loading takes 20%
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
@@ -195,8 +118,8 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
if (readstat != IFSelect_RetDone) if (readstat != IFSelect_RetDone)
{ {
if (modfic) di << "Could not read file " << fnom.ToCString() << " , abandon\n"; if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
else di << "No model loaded\n"; else theDI << "No model loaded\n";
return 1; return 1;
} }
@@ -211,21 +134,21 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
num = sr.NbRootsForTransfer(); num = sr.NbRootsForTransfer();
if (!fromtcl) if (!fromtcl)
{ {
di << "NbRootsForTransfer=" << num << " :\n"; theDI << "NbRootsForTransfer=" << num << " :\n";
for (i = 1; i <= num; i++) for (i = 1; i <= num; i++)
{ {
di << "Root." << i << ", Ent. "; theDI << "Root." << i << ", Ent. ";
Standard_SStream aTmpStream; Standard_SStream aTmpStream;
sr.Model()->Print(sr.RootForTransfer(i), aTmpStream); sr.Model()->Print(sr.RootForTransfer(i), aTmpStream);
di << aTmpStream.str().c_str(); theDI << aTmpStream.str().c_str();
di << " Type:" << sr.RootForTransfer(i)->DynamicType()->Name() << "\n"; 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::cout << "Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : " << std::flush;
std::cin >> modepri; std::cin >> modepri;
} }
if (modepri == 0) { di << "End Reading STEP\n"; return 0; } if (modepri == 0) { theDI << "End Reading STEP\n"; return 0; }
if (modepri <= 2) if (modepri <= 2)
{ {
num = 1; num = 1;
@@ -237,13 +160,13 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
progress->Show(aPSRoot); progress->Show(aPSRoot);
if (!sr.TransferRoot(num, aPSRoot.Next(80))) if (!sr.TransferRoot(num, aPSRoot.Next(80)))
di << "Transfer root n0 " << num << " : no result\n"; theDI << "Transfer root n0 " << num << " : no result\n";
else else
{ {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs); char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
di << "Transfer root n0 " << num << " OK -> DRAW Shape: " << shname << "\n"; theDI << "Transfer root n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
di << "Now, " << nbs << " Shapes produced\n"; theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set(shname, sh); DBRep::Set(shname, sh);
} }
@@ -252,15 +175,15 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
} }
else if (modepri == 3) else if (modepri == 3)
{ {
std::cout << "Entity : " << std::flush; num = XSDRAW::GetEntityNumber(); std::cout << "Entity : " << std::flush; num = XSDRAWBase::GetEntityNumber();
if (!sr.TransferOne(num)) if (!sr.TransferOne(num))
di << "Transfer entity n0 " << num << " : no result\n"; theDI << "Transfer entity n0 " << num << " : no result\n";
else else
{ {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), num); char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), num);
di << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n"; theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
di << "Now, " << nbs << " Shapes produced\n"; theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set(shname, sh); DBRep::Set(shname, sh);
} }
@@ -275,32 +198,32 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
if (fromtcl) if (fromtcl)
{ {
modepri = 0; // d ioffice une seule passe modepri = 0; // d ioffice une seule passe
if (argv[k][0] == '*' && argv[k][1] == '\0') if (theArgVec[k][0] == '*' && theArgVec[k][1] == '\0')
{ {
di << "Transferrable Roots : "; theDI << "Transferrable Roots : ";
list = XSDRAW::GetList("xst-transferrable-roots"); list = XSDRAWBase::GetList("xst-transferrable-roots");
//list = new TColStd_HSequenceOfTransient; //list = new TColStd_HSequenceOfTransient;
//for(Standard_Integer j=1; j<=num; j++) //for(Standard_Integer j=1; j<=num; j++)
// list->Append(sr.RootForTransfer(j)); // list->Append(sr.RootForTransfer(j));
} }
else else
{ {
di << "List given by " << argv[k]; theDI << "List given by " << theArgVec[k];
if (argc > k + 1) di << " " << argv[k + 1]; if (theNbArgs > k + 1) theDI << " " << theArgVec[k + 1];
di << " : "; theDI << " : ";
list = XSDRAW::GetList(argv[k], (argc > (k + 1) ? argv[k + 1] : 0)); list = XSDRAWBase::GetList(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; } if (list.IsNull()) { theDI << "No list defined. Give a selection name or * for all transferrable roots\n"; continue; }
} }
else else
{ {
std::cout << "Name of Selection :" << std::flush; std::cout << "Name of Selection :" << std::flush;
list = XSDRAW::GetList(); list = XSDRAWBase::GetList();
if (list.IsNull()) { di << "No list defined\n"; continue; } if (list.IsNull()) { theDI << "No list defined\n"; continue; }
} }
Standard_Integer ill, nbl = list->Length(); Standard_Integer ill, nbl = list->Length();
di << "Nb entities selected : " << nbl << "\n"; theDI << "Nb entities selected : " << nbl << "\n";
if (nbl == 0) continue; if (nbl == 0) continue;
aPSRoot.SetName("Translation"); aPSRoot.SetName("Translation");
@@ -312,13 +235,13 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
num = sr.Model()->Number(list->Value(ill)); num = sr.Model()->Number(list->Value(ill));
if (num == 0) continue; if (num == 0) continue;
if (!sr.TransferOne(num, aPS.Next())) if (!sr.TransferOne(num, aPS.Next()))
di << "Transfer entity n0 " << num << " : no result\n"; theDI << "Transfer entity n0 " << num << " : no result\n";
else else
{ {
nbs = sr.NbShapes(); nbs = sr.NbShapes();
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs); char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
di << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n"; theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
di << "Now, " << nbs << " Shapes produced\n"; theDI << "Now, " << nbs << " Shapes produced\n";
TopoDS_Shape sh = sr.Shape(nbs); TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set(shname, sh); DBRep::Set(shname, sh);
} }
@@ -326,29 +249,31 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
return 1; return 1;
} }
else di << "Unknown mode n0 " << modepri << "\n"; else theDI << "Unknown mode n0 " << modepri << "\n";
} }
return 0; return 0;
} }
//======================================================================= //=======================================================================
//function : testreadstep //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"; theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n"; theDI << " Usage : " << theArgVec[0] << " file_name shape_name [-stream]\n";
di << " Option -stream forces usage of API accepting stream\n"; theDI << " Option -stream forces usage of API accepting stream\n";
return 1; return 1;
} }
Standard_Boolean useStream = (argc > 3 && !strcasecmp(argv[3], "-stream")); Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[3], "-stream"));
STEPControl_Reader Reader; STEPControl_Reader Reader;
Standard_CString filename = argv[1]; Standard_CString filename = theArgVec[1];
IFSelect_ReturnStatus readstat; IFSelect_ReturnStatus readstat;
if (useStream) if (useStream)
{ {
@@ -362,57 +287,57 @@ static Standard_Integer testreadstep(Draw_Interpretor& di, Standard_Integer argc
{ {
readstat = Reader.ReadFile(filename); readstat = Reader.ReadFile(filename);
} }
di << "Status from reading STEP file " << filename << " : "; theDI << "Status from reading STEP file " << filename << " : ";
switch (readstat) switch (readstat)
{ {
case IFSelect_RetVoid: { di << "empty file\n"; return 1; } case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
case IFSelect_RetDone: { di << "file read\n"; break; } case IFSelect_RetDone: { theDI << "file read\n"; break; }
case IFSelect_RetError: { di << "file not found\n"; return 1; } case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
case IFSelect_RetFail: { di << "error during read\n"; return 1; } case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
default: { di << "failure\n"; return 1; } default: { theDI << "failure\n"; return 1; }
} }
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit()); Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
Reader.TransferRoots(); Reader.TransferRoots();
TopoDS_Shape shape = Reader.OneShape(); TopoDS_Shape shape = Reader.OneShape();
DBRep::Set(argv[2], shape); DBRep::Set(theArgVec[2], shape);
di << "Count of shapes produced : " << Reader.NbShapes() << "\n"; theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
return 0; return 0;
} }
// ######## COMMANDE steptrans : teste les transformations #########
//======================================================================= //=======================================================================
//function : steptrans //function : steptrans
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer steptrans(Draw_Interpretor& theDI,
static Standard_Integer steptrans(Draw_Interpretor& di, Standard_Integer argc, const char** argv) Standard_Integer theNbArgs,
const char** theArgVec)
{ {
if (argc < 5) if (theNbArgs < 5)
{ {
di << "give shape-name new-shape + entity-n0 entity-n0: AXIS2\n"; theDI << "give shape-name new-shape + entity-n0 entity-n0: AXIS2\n";
return 1; return 1;
} }
TopoDS_Shape shape = DBRep::Get(argv[1]); TopoDS_Shape shape = DBRep::Get(theArgVec[1]);
if (shape.IsNull()) { di << "Not a shape : " << argv[1] << "\n"; return 1; } if (shape.IsNull()) { theDI << "Not a shape : " << theArgVec[1] << "\n"; return 1; }
Handle(StepGeom_Axis2Placement3d) ax1, ax2; Handle(StepGeom_Axis2Placement3d) ax1, ax2;
Standard_Integer n1 = 0, n2 = 0; Standard_Integer n1 = 0, n2 = 0;
n1 = XSDRAW::GetEntityNumber(argv[3]); n1 = XSDRAWBase::GetEntityNumber(theArgVec[3]);
if (argc > 4) n2 = XSDRAW::GetEntityNumber(argv[4]); if (theNbArgs > 4) n2 = XSDRAWBase::GetEntityNumber(theArgVec[4]);
if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast
(XSDRAW::Entity(n1)); (XSDRAWBase::Entity(n1));
if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast
(XSDRAW::Entity(n2)); (XSDRAWBase::Entity(n2));
StepToTopoDS_MakeTransformed mktrans; StepToTopoDS_MakeTransformed mktrans;
if (mktrans.Compute(ax1, ax2)) if (mktrans.Compute(ax1, ax2))
{ {
TopLoc_Location loc(mktrans.Transformation()); TopLoc_Location loc(mktrans.Transformation());
shape.Move(loc); shape.Move(loc);
// mktrans.Transform (shape); // mktrans.Transform (shape);
DBRep::Set(argv[2], shape); DBRep::Set(theArgVec[2], shape);
di << "Transformed Shape as " << argv[2] << "\n"; theDI << "Transformed Shape as " << theArgVec[2] << "\n";
} }
else di << "No transformation computed\n"; else theDI << "No transformation computed\n";
return 0; return 0;
} }
@@ -420,28 +345,29 @@ static Standard_Integer steptrans(Draw_Interpretor& di, Standard_Integer argc, c
//======================================================================= //=======================================================================
//function : stepwrite //function : stepwrite
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer stepwrite(Draw_Interpretor& theDI,
static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, const char** argv) Standard_Integer theNbArgs,
const char** theArgVec)
{ {
// On admet le controller AP214 ou une variante // On admet le controller AP214 ou une variante
DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); DeclareAndCast(STEPControl_Controller, ctl, XSDRAWBase::Controller());
if (ctl.IsNull()) if (ctl.IsNull())
{ {
XSDRAW::SetNorm("STEP"); XSDRAWBase::SetNorm("STEP");
//sln 14.01.2002 OCC51: assign new value to ctl in order to avoid exception during using one in the function //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()); ctl = Handle(STEPControl_Controller)::DownCast(XSDRAWBase::Controller());
} }
if (argc < 3) if (theNbArgs < 3)
{ {
di << "Give mode[1-4] and Shape name + optional file. Mode possible\n"; theDI << "Give mode[1-4] and Shape name + optional file. Mode possible\n";
di << "f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n" theDI << "f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
<< "m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame\n"; << "m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame\n";
return 1; return 1;
} }
char modeshape = argv[1][0]; char modeshape = theArgVec[1][0];
STEPControl_StepModelType mode; STEPControl_StepModelType mode;
switch (modeshape) switch (modeshape)
{ {
@@ -455,7 +381,7 @@ static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, c
case '3': mode = STEPControl_ManifoldSolidBrep; break; case '3': mode = STEPControl_ManifoldSolidBrep; break;
case 'w': case 'w':
case '4': mode = STEPControl_GeometricCurveSet; break; case '4': mode = STEPControl_GeometricCurveSet; break;
default: di << "1st arg = mode, incorrect [give fsmw]\n"; return 1; default: theDI << "1st arg = mode, incorrect [give fsmw]\n"; return 1;
} }
//:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes) //:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes)
@@ -464,23 +390,23 @@ static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, c
if (!ActWrite.IsNull()) if (!ActWrite.IsNull())
ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly")); ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly"));
TopoDS_Shape shape = DBRep::Get(argv[2]); TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
STEPControl_Writer sw(XSDRAW::Session(), Standard_False); STEPControl_Writer sw(XSDRAWBase::Session(), Standard_False);
Handle(Interface_InterfaceModel) stepmodel = sw.Model(); Handle(Interface_InterfaceModel) stepmodel = sw.Model();
Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100); Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
progress->Show(aPSRoot); 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) if (stat == IFSelect_RetDone)
{ {
di << "Translation: OK\n"; theDI << "Translation: OK\n";
} }
else else
{ {
di << "Error: translation failed, status = " << stat << "\n"; theDI << "Error: translation failed, status = " << stat << "\n";
} }
if (aPSRoot.UserBreak()) if (aPSRoot.UserBreak())
@@ -491,40 +417,43 @@ static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, c
// Que s est-il passe // Que s est-il passe
stepmodel = sw.Model(); stepmodel = sw.Model();
Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
if (nbavant > 0) di << "Beware : Model not empty before transferring\n"; if (nbavant > 0) theDI << "Beware : Model not empty before transferring\n";
if (nbapres <= nbavant) di << "Beware : No data produced by this transfer\n"; if (nbapres <= nbavant) theDI << "Beware : No data produced by this transfer\n";
if (nbapres == 0) { di << "No data to write\n"; return 0; } if (nbapres == 0) { theDI << "No data to write\n"; return 0; }
if (argc <= 3) if (theNbArgs <= 3)
{ {
di << " Now, to write a file, command : writeall filename\n"; theDI << " Now, to write a file, command : writeall filename\n";
return 0; return 0;
} }
const char* nomfic = argv[3]; const char* nomfic = theArgVec[3];
stat = sw.Write(nomfic); stat = sw.Write(nomfic);
switch (stat) switch (stat)
{ {
case IFSelect_RetVoid: di << "Error: No file written\n"; break; case IFSelect_RetVoid: theDI << "Error: No file written\n"; break;
case IFSelect_RetDone: di << "File " << nomfic << " written\n"; break; case IFSelect_RetDone: theDI << "File " << nomfic << " written\n"; break;
case IFSelect_RetStop: di << "Error on writing file: no space on disk or destination is write protected\n"; break; case IFSelect_RetStop: theDI << "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; default: theDI << "Error: File " << nomfic << " written with fail messages\n"; break;
} }
return 0; return 0;
} }
//======================================================================= //=======================================================================
//function : testwritestep //function : testwritestep
//purpose : //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; TCollection_AsciiString aFilePath;
TopoDS_Shape aShape; TopoDS_Shape aShape;
bool toTestStream = false; 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(); anArgCase.LowerCase();
if (anArgCase == "-stream") if (anArgCase == "-stream")
{ {
@@ -532,26 +461,26 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
} }
else if (aFilePath.IsEmpty()) else if (aFilePath.IsEmpty())
{ {
aFilePath = argv[anArgIter]; aFilePath = theArgVec[anArgIter];
} }
else if (aShape.IsNull()) else if (aShape.IsNull())
{ {
aShape = DBRep::Get(argv[anArgIter]); aShape = DBRep::Get(theArgVec[anArgIter]);
if (aShape.IsNull()) if (aShape.IsNull())
{ {
di << "Syntax error: '" << argv[anArgIter] << "' is not a shape"; theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a shape";
return 1; return 1;
} }
} }
else else
{ {
di << "Syntax error: unknown argument '" << argv[anArgIter] << "'"; theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
return 1; return 1;
} }
} }
if (aShape.IsNull()) if (aShape.IsNull())
{ {
di << "Syntax error: wrong number of arguments"; theDI << "Syntax error: wrong number of arguments";
return 1; return 1;
} }
@@ -559,7 +488,7 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape, STEPControl_AsIs); IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape, STEPControl_AsIs);
if (aStat != IFSelect_RetDone) if (aStat != IFSelect_RetDone)
{ {
di << "Error on transferring shape"; theDI << "Error on transferring shape";
return 1; return 1;
} }
@@ -581,22 +510,22 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
} }
if (aStat != IFSelect_RetDone) if (aStat != IFSelect_RetDone)
{ {
di << "Error on writing file"; theDI << "Error on writing file";
return 1; return 1;
} }
di << "File Is Written"; theDI << "File Is Written";
return 0; return 0;
} }
//======================================================================= //=======================================================================
//function : countexpected //function : countexpected
//purpose : //purpose :
//======================================================================= //=======================================================================
static Standard_Integer countexpected(Draw_Interpretor& theDI,
static Standard_Integer countexpected Standard_Integer /*theNbArgs*/,
(Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/) const char** /*theArgVec*/)
{ {
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot(); Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
Handle(IFSelect_WorkSession) WS = pilot->Session(); Handle(IFSelect_WorkSession) WS = pilot->Session();
const Interface_Graph& graph = WS->Graph(); const Interface_Graph& graph = WS->Graph();
@@ -608,25 +537,30 @@ static Standard_Integer countexpected
cnt.Count(graph, roots->Value(i)); cnt.Count(graph, roots->Value(i));
} }
di << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n"; theDI << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n";
di << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n"; theDI << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n";
di << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n"; theDI << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n";
di << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n"; theDI << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n";
di << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n"; theDI << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n";
di << "Source Faces \t: " << cnt.NbSourceFaces() << "\n"; theDI << "Source Faces \t: " << cnt.NbSourceFaces() << "\n";
di << "Source Shells\t: " << cnt.NbSourceShells() << "\n"; theDI << "Source Shells\t: " << cnt.NbSourceShells() << "\n";
di << "Source Solids\t: " << cnt.NbSourceSolids() << "\n"; theDI << "Source Solids\t: " << cnt.NbSourceSolids() << "\n";
di << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n"; theDI << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n";
di << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n"; theDI << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n";
return 1; 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_SessionPilot) pilot = XSDRAWBase::Pilot();
Handle(IFSelect_WorkSession) WS = pilot->Session(); Handle(IFSelect_WorkSession) WS = pilot->Session();
const Interface_Graph& graph = WS->Graph(); const Interface_Graph& graph = WS->Graph();
@@ -635,23 +569,29 @@ static Standard_Integer dumpassembly
return 0; 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; return 1;
} }
STEPControl_Reader aStepReader; STEPControl_Reader aStepReader;
IFSelect_ReturnStatus readstat = IFSelect_RetVoid; IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
readstat = aStepReader.ReadFile(argv[1]); readstat = aStepReader.ReadFile(theArgVec[1]);
if (readstat != IFSelect_RetDone) if (readstat != IFSelect_RetDone)
{ {
di << "No model loaded\n"; theDI << "No model loaded\n";
return 1; return 1;
} }
@@ -661,24 +601,23 @@ static Standard_Integer stepfileunits(Draw_Interpretor& di, Standard_Integer arg
aStepReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); aStepReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
Standard_Integer i = 1; Standard_Integer i = 1;
di << "=====================================================\n"; theDI << "=====================================================\n";
di << "LENGTH Unit\n"; theDI << "LENGTH Unit\n";
for (; i <= anUnitLengthNames.Length(); i++) for (; i <= anUnitLengthNames.Length(); i++)
di << anUnitLengthNames(i).ToCString() << "\n"; theDI << anUnitLengthNames(i).ToCString() << "\n";
di << "=====================================================\n"; theDI << "=====================================================\n";
di << "Angle Unit\n"; theDI << "Angle Unit\n";
for (i = 1; i <= anUnitAngleNames.Length(); i++) for (i = 1; i <= anUnitAngleNames.Length(); i++)
di << anUnitAngleNames(i).ToCString() << "\n"; theDI << anUnitAngleNames(i).ToCString() << "\n";
di << "=====================================================\n"; theDI << "=====================================================\n";
di << "Solid Angle Unit\n"; theDI << "Solid Angle Unit\n";
for (i = 1; i <= anUnitSolidAngleNames.Length(); i++) for (i = 1; i <= anUnitSolidAngleNames.Length(); i++)
di << anUnitSolidAngleNames(i).ToCString() << "\n"; theDI << anUnitSolidAngleNames(i).ToCString() << "\n";
return 0; return 0;
} }
// ######## COMMANDE stepwrite : teste le Writer #########
//======================================================================= //=======================================================================
//function : ReadStep //function : ReadStep
@@ -750,13 +689,13 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
Draw::Set(aDocName, aDrawDoc); Draw::Set(aDocName, aDrawDoc);
} }
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
Handle(STEPCAFControl_Provider) aProvider = Handle(STEPCAFControl_Provider) aProvider =
new STEPCAFControl_Provider(aNode); new STEPCAFControl_Provider(aNode);
aProvider->SetToUpdateStaticParameters(false); aProvider->SetToUpdateStaticParameters(false);
Standard_Boolean aReadStat = Standard_False; Standard_Boolean aReadStat = Standard_False;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (aToTestStream) if (aToTestStream)
{ {
std::ifstream aStream; std::ifstream aStream;
@@ -778,7 +717,7 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
} }
Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
Draw::Set(aDocName, aDrawDoc); Draw::Set(aDocName, aDrawDoc);
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
Message::SendInfo() << "Document saved with name " << aDocName; Message::SendInfo() << "Document saved with name " << aDocName;
return 0; return 0;
} }
@@ -885,13 +824,13 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
theDI << "Syntax error: wrong number of arguments\n"; theDI << "Syntax error: wrong number of arguments\n";
return 1; return 1;
} }
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
Handle(STEPCAFControl_Provider) aProvider = Handle(STEPCAFControl_Provider) aProvider =
new STEPCAFControl_Provider(aNode); new STEPCAFControl_Provider(aNode);
aProvider->SetToUpdateStaticParameters(false); aProvider->SetToUpdateStaticParameters(false);
Standard_Boolean aReadStat = Standard_False; Standard_Boolean aReadStat = Standard_False;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (aToTestStream) if (aToTestStream)
{ {
std::ofstream aStream; std::ofstream aStream;
@@ -911,38 +850,40 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
theDI << "Cannot write any relevant data to the STEP file\n"; theDI << "Cannot write any relevant data to the STEP file\n";
return 1; return 1;
} }
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
return 0; return 0;
} }
void XSDRAWSTEP::InitCommands(Draw_Interpretor& theCommands) //=======================================================================
//function : Factory
//purpose :
//=======================================================================
void XSDRAWSTEP::Factory(Draw_Interpretor& theDI)
{ {
const char* g = "DE: STEP"; // Step transfer file commands const char* g = "DE: STEP"; // Step transfer file commands
XSDRAWSTEP::Init(); theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
XSDRAW::LoadDraw(theCommands); theDI.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
theCommands.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); __FILE__, testwrite, g);
theCommands.Add("testwritestep", "testwritestep filename.stp shape [-stream]", theDI.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, g);
__FILE__, testwrite, g); theDI.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, g);
theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, g); theDI.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
theCommands.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, g); theDI.Add("countexpected", "TEST", __FILE__, countexpected, g);
theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g); theDI.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);
theCommands.Add("countexpected", "TEST", __FILE__, countexpected, g); theDI.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, g);
theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g); theDI.Add("ReadStep",
theCommands.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, g); "Doc filename [mode] [-stream]"
theCommands.Add("ReadStep", "\n\t\t: Read STEP file to a document."
"Doc filename [mode] [-stream]" "\n\t\t: -stream read using istream reading interface (testing)",
"\n\t\t: Read STEP file to a document." __FILE__, ReadStep, g);
"\n\t\t: -stream read using istream reading interface (testing)", theDI.Add("WriteStep",
__FILE__, ReadStep, g); "Doc filename [mode=a [multifile_prefix] [label]] [-stream]"
theCommands.Add("WriteStep", "\n\t\t: Write DECAF document to STEP file"
"Doc filename [mode=a [multifile_prefix] [label]] [-stream]" "\n\t\t: mode can be: a or 0 : AsIs (default)"
"\n\t\t: Write DECAF document to STEP file" "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel"
"\n\t\t: mode can be: a or 0 : AsIs (default)" "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame"
"\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel" "\n\t\t: multifile_prefix: triggers writing assembly components as separate files,"
"\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame" "\n\t\t: and defines common prefix for their names"
"\n\t\t: multifile_prefix: triggers writing assembly components as separate files," "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly"
"\n\t\t: and defines common prefix for their names" "\n\t\t: -stream read using ostream writing interface (testing)",
"\n\t\t: label tag of the sub-assembly label to save only that sub-assembly" __FILE__, WriteStep, g);
"\n\t\t: -stream read using ostream writing interface (testing)",
__FILE__, WriteStep, g);
} }

View File

@@ -26,7 +26,7 @@ public:
Standard_EXPORT static void Init(); Standard_EXPORT static void Init();
//! Loads all Draw commands of XSDRAWSTL. Used for plugin. //! Loads all Draw commands of XSDRAWSTEP. Used for plugin.
Standard_EXPORT static void Factory(Draw_Interpretor& theDI); Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
}; };

View File

@@ -13,200 +13,19 @@
#include <XSDRAWSTL.hxx> #include <XSDRAWSTL.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 <DBRep.hxx>
#include <DDocStd.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx> #include <DDocStd_DrawDocument.hxx>
#include <Draw.hxx> #include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_PluginMacro.hxx>
#include <Draw_ProgressIndicator.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_ConfigurationNode.hxx>
#include <RWGltf_Provider.hxx>
//#include <RWGltf_DracoParameters.hxx>
//#include <RWGltf_CafReader.hxx>
//#include <RWGltf_CafWriter.hxx>
#include <RWMesh_FaceIterator.hxx>
#include <RWStl.hxx>
#include <RWStl_ConfigurationNode.hxx> #include <RWStl_ConfigurationNode.hxx>
#include <RWStl_Provider.hxx> #include <RWStl_Provider.hxx>
//#include <RWObj.hxx> #include <XSControl_WorkSession.hxx>
#include <RWObj_ConfigurationNode.hxx> #include <XSDRAWBase.hxx>
#include <RWObj_Provider.hxx>
//#include <RWObj_CafReader.hxx>
//#include <RWObj_CafWriter.hxx>
#include <RWPly_ConfigurationNode.hxx>
#include <RWPly_Provider.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 <TDataStd_Name.hxx>
#include <TDocStd_Application.hxx> #include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <UnitsAPI.hxx>
#include <UnitsMethods.hxx>
#include <V3d_View.hxx>
#include <ViewerTest.hxx>
#include <Vrml_ConfigurationNode.hxx>
#include <Vrml_Provider.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>
#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);
//=============================================================================
//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 : GetLengthUnit
//purpose : Gets length unit value from static interface and document in M
//=======================================================================
static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr)
{
if (!theDoc.IsNull())
{
Standard_Real aUnit = 1.;
if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
UnitsMethods_LengthUnit_Millimeter))
{
return aUnit;
}
}
XSAlgo::AlgoContainer()->PrepareForTransfer();
return UnitsMethods::GetCasCadeLengthUnit();
}
//============================================================================= //=============================================================================
//function : writestl //function : writestl
@@ -230,10 +49,10 @@ static Standard_Integer writestl(Draw_Interpretor& theDI,
isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0); isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0);
} }
Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
aNode->InternalParameters.WriteAscii = isASCIIMode; aNode->InternalParameters.WriteAscii = isASCIIMode;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
{ {
@@ -253,10 +72,7 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
{ {
TCollection_AsciiString aShapeName, aFilePath; TCollection_AsciiString aShapeName, aFilePath;
Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
//bool toCreateCompOfTris = false;
//bool anIsMulti = false;
//double aMergeAngle = M_PI / 2.0;
for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter) for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter)
{ {
TCollection_AsciiString anArg(theArgv[anArgIter]); TCollection_AsciiString anArg(theArgv[anArgIter]);
@@ -336,7 +152,7 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
TopoDS_Shape aShape; TopoDS_Shape aShape;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start())) if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start()))
{ {
theDI << "Cannot read any relevant data from the STL file\n"; theDI << "Cannot read any relevant data from the STL file\n";
@@ -346,24 +162,21 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
return 0; return 0;
} }
//======================================================================= //=============================================================================
//function : InitCommands //function : Factory
//purpose : //purpose :
//======================================================================= //=============================================================================
void XSDRAWSTL::InitCommands(Draw_Interpretor& theCommands) void XSDRAWSTL::Factory(Draw_Interpretor& theDI)
{ {
const char* g = "XSTEP-STL/VRML"; // Step transfer file commands const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
//XSDRAW::LoadDraw(theCommands);
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);
theDI.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, g);
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, g);
} }

View File

@@ -25,7 +25,7 @@ class XSDRAWSTL
public: public:
Standard_EXPORT static void Init(); Standard_EXPORT static void Init();
//! Loads all Draw commands of XSDRAWSTL. Used for plugin. //! Loads all Draw commands of XSDRAWSTL. Used for plugin.
Standard_EXPORT static void Factory(Draw_Interpretor& theDI); Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
}; };

View File

@@ -11,42 +11,46 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <XSDRAWVRML.hxx>
#include <DBRep.hxx>
#include <DDocStd.hxx> #include <DDocStd.hxx>
#include <DDocStd_DrawDocument.hxx> #include <DDocStd_DrawDocument.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DE_Wrapper.hxx>
#include <Draw.hxx> #include <Draw.hxx>
#include <Draw_Interpretor.hxx> #include <Draw_Interpretor.hxx>
#include <Draw_ProgressIndicator.hxx> #include <Draw_ProgressIndicator.hxx>
#include <Message.hxx>
#include <IFSelect_SessionPilot.hxx>
#include <IGESCAFControl_ConfigurationNode.hxx>
#include <IGESCAFControl_Provider.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Path.hxx>
#include <STEPCAFControl_ConfigurationNode.hxx>
#include <STEPCAFControl_Provider.hxx>
#include <TDocStd_Application.hxx>
#include <TDocStd_Document.hxx>
#include <XSDRAWVRML.hxx>
#include <XSAlgo.hxx>
#include <XSAlgo_AlgoContainer.hxx>
#include <XSControl_WorkSession.hxx>
#include <XSDRAW.hxx>
#include <Vrml_ConfigurationNode.hxx> #include <Vrml_ConfigurationNode.hxx>
#include <Vrml_Provider.hxx> #include <Vrml_Provider.hxx>
#include <XSControl_WorkSession.hxx>
#include <DBRep.hxx> #include <XSDRAWBase.hxx>
#include <XCAFDoc_DocumentTool.hxx> #include <TDataStd_Name.hxx>
#include <XCAFDoc_ShapeTool.hxx> #include <TDocStd_Application.hxx>
#include <XCAFDoc_Editor.hxx>
#include <TDF_Tool.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <Interface_Static.hxx>
#include <UnitsAPI.hxx> #include <UnitsAPI.hxx>
#include <UnitsMethods.hxx>
#include <stdio.h> //=============================================================================
//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 //function : ReadVrml
@@ -67,7 +71,7 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
Standard_Boolean toUseExistingDoc = Standard_False; Standard_Boolean toUseExistingDoc = Standard_False;
Standard_CString aDocName = NULL; Standard_CString aDocName = NULL;
TCollection_AsciiString aFilePath; TCollection_AsciiString aFilePath;
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++) for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++)
{ {
TCollection_AsciiString anArg(theArgVec[anArgIt]); TCollection_AsciiString anArg(theArgVec[anArgIt]);
@@ -151,7 +155,7 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
Handle(Vrml_Provider) aProvider = Handle(Vrml_Provider) aProvider =
new Vrml_Provider(aNode); new Vrml_Provider(aNode);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start())) if (!aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()))
{ {
theDI << "Error: file reading failed '" << aFilePath << "'\n"; theDI << "Error: file reading failed '" << aFilePath << "'\n";
@@ -160,7 +164,7 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName); TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName);
Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc); Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc);
Draw::Set(aDocName, aDD); Draw::Set(aDocName, aDD);
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
return 0; return 0;
} }
@@ -193,22 +197,21 @@ static Standard_Integer WriteVrml(Draw_Interpretor& theDI,
} }
Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode) aNode =
new Vrml_ConfigurationNode(); new Vrml_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
Handle(Vrml_Provider) aProvider = Handle(Vrml_Provider) aProvider =
new Vrml_Provider(aNode); new Vrml_Provider(aNode);
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start()))
{ {
theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; theDI << "Error: file writing failed '" << theArgVec[2] << "'\n";
return 1; return 1;
} }
CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); XSDRAWBase::CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
return 0; return 0;
} }
//======================================================================= //=======================================================================
//function : loadvrml //function : loadvrml
//purpose : //purpose :
@@ -224,12 +227,12 @@ static Standard_Integer loadvrml(Draw_Interpretor& theDI,
} }
Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode) aNode =
new Vrml_ConfigurationNode(); new Vrml_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
Handle(Vrml_Provider) aProvider = Handle(Vrml_Provider) aProvider =
new Vrml_Provider(aNode); new Vrml_Provider(aNode);
TopoDS_Shape aShape; TopoDS_Shape aShape;
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
if (!aProvider->Read(theArgVec[2], aShape, aWS, aProgress->Start())) if (!aProvider->Read(theArgVec[2], aShape, aWS, aProgress->Start()))
{ {
theDI << "Error: file reading failed '" << theArgVec[2] << "'\n"; theDI << "Error: file reading failed '" << theArgVec[2] << "'\n";
@@ -269,7 +272,7 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
aType = Min(2, aType); aType = Min(2, aType);
Handle(Vrml_ConfigurationNode) aNode = Handle(Vrml_ConfigurationNode) aNode =
new Vrml_ConfigurationNode(); new Vrml_ConfigurationNode();
aNode->GlobalParameters.LengthUnit = GetLengthUnit(); aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
Handle(Vrml_Provider) aProvider = Handle(Vrml_Provider) aProvider =
new Vrml_Provider(aNode); new Vrml_Provider(aNode);
aNode->InternalParameters.WriterVersion = aNode->InternalParameters.WriterVersion =
@@ -277,7 +280,7 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
aNode->InternalParameters.WriteRepresentationType = aNode->InternalParameters.WriteRepresentationType =
(Vrml_ConfigurationNode::WriteMode_RepresentationType)aType; (Vrml_ConfigurationNode::WriteMode_RepresentationType)aType;
Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
{ {
@@ -287,7 +290,11 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
return 0; return 0;
} }
void XSDRAWVRML::InitCommands(Draw_Interpretor& theDI) //=============================================================================
//function : Factory
//purpose :
//=============================================================================
void XSDRAWVRML::Factory(Draw_Interpretor& theDI)
{ {
static Standard_Boolean initactor = Standard_False; static Standard_Boolean initactor = Standard_False;
if (initactor) if (initactor)

View File

@@ -26,7 +26,7 @@ public:
Standard_EXPORT static void Init(); Standard_EXPORT static void Init();
//! Loads all Draw commands of XSDRAWSTL. Used for plugin. //! Loads all Draw commands of XSDRAWVRML. Used for plugin.
Standard_EXPORT static void Factory(Draw_Interpretor& theDI); Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
}; };