mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
// testing
This commit is contained in:
@@ -22,15 +22,16 @@
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
|
||||
class IFSelect_SessionPilot;
|
||||
class XSControl_WorkSession;
|
||||
class XSControl_Controller;
|
||||
class Interface_Protocol;
|
||||
class Interface_InterfaceModel;
|
||||
class Standard_Transient;
|
||||
class TCollection_AsciiString;
|
||||
class TDocStd_Document;
|
||||
class Transfer_TransientProcess;
|
||||
class Transfer_FinderProcess;
|
||||
class XSControl_Controller;
|
||||
class XSControl_TransferReader;
|
||||
class TCollection_AsciiString;
|
||||
class XSControl_WorkSession;
|
||||
|
||||
//! Basic package to work functions of X-STEP (IFSelect & Co)
|
||||
//! under control of DRAW
|
||||
@@ -176,6 +177,15 @@ public:
|
||||
//! 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 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
|
||||
//! name for variables. Returns resulting file name and variable
|
||||
//! name plus status "file to read"(True) or "already read"(False)
|
||||
|
@@ -11,40 +11,24 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XSDRAWDEWrapper.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 <IFSelect_SessionPilot.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <De_ConfigurationNode.hxx>
|
||||
#include <DE_ConfigurationContext.hxx>
|
||||
#include <DE_Provider.hxx>
|
||||
#include <DE_Wrapper.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 <XSDRAW.hxx>
|
||||
#include <XSDRAWDEWrapper.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <XSDRAWBase.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Application.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DumpConfiguration
|
||||
@@ -279,13 +263,13 @@ static Standard_Integer ReadFile(Draw_Interpretor& theDI,
|
||||
if (aStat)
|
||||
{
|
||||
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);
|
||||
if (isNoDoc && aStat)
|
||||
{
|
||||
DBRep::Set(aDocShapeName.ToCString(), aShape);
|
||||
}
|
||||
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
}
|
||||
if (!aStat)
|
||||
{
|
||||
@@ -358,7 +342,7 @@ static Standard_Integer WriteFile(Draw_Interpretor& theDI,
|
||||
{
|
||||
aStat = aConf->Load(aConfString);
|
||||
}
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (aStat)
|
||||
{
|
||||
if (isNoDoc)
|
||||
@@ -380,11 +364,11 @@ static Standard_Integer WriteFile(Draw_Interpretor& theDI,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XSDRAWDEWrapper::InitCommands(Draw_Interpretor& theDI)
|
||||
void XSDRAWDEWrapper::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
static Standard_Boolean initactor = Standard_False;
|
||||
if (initactor)
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
@@ -13,96 +13,19 @@
|
||||
|
||||
#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 <DDocStd.hxx>
|
||||
#include <DDocStd_DrawDocument.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_PluginMacro.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
|
||||
#include <MeshVS_DeformedDataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_ElementalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshEntityOwner.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_NodalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_PrsBuilder.hxx>
|
||||
#include <MeshVS_TextPrsBuilder.hxx>
|
||||
#include <MeshVS_VectorPrsBuilder.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
//#include <Quantity_HArray1OfColor.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <RWGltf_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_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 <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.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_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
|
||||
@@ -189,25 +112,6 @@ static bool parseCoordinateSystem(const char* theArg,
|
||||
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
|
||||
//purpose : Reads glTF file
|
||||
@@ -220,14 +124,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
Handle(RWGltf_ConfigurationNode) aNode =
|
||||
new RWGltf_ConfigurationNode();
|
||||
Standard_Boolean toUseExistingDoc = Standard_False;
|
||||
//Standard_Boolean toListExternalFiles = Standard_False;
|
||||
//Standard_Boolean isParallel = Standard_False;
|
||||
//Standard_Boolean isDoublePrec = Standard_False;
|
||||
//Standard_Boolean toSkipLateDataLoading = Standard_False;
|
||||
//Standard_Boolean toKeepLateData = Standard_True;
|
||||
//Standard_Boolean toPrintDebugInfo = Standard_False;
|
||||
//Standard_Boolean toLoadAllScenes = Standard_False;
|
||||
//Standard_Boolean toPrintAssetInfo = Standard_False;
|
||||
Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf");
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
@@ -278,19 +174,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
aNode->InternalParameters.ReadPrintDebugMessages =
|
||||
Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter);
|
||||
}
|
||||
//else if (anArgCase == "-listexternalfiles"
|
||||
// || anArgCase == "-listexternals"
|
||||
// || anArgCase == "-listexternal"
|
||||
// || anArgCase == "-external"
|
||||
// || anArgCase == "-externalfiles")
|
||||
//{
|
||||
// toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
|
||||
//}
|
||||
//else if (anArgCase == "-assetinfo"
|
||||
// || anArgCase == "-metadata")
|
||||
//{
|
||||
// toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter);
|
||||
//}
|
||||
else if (aDestName.IsEmpty())
|
||||
{
|
||||
aDestName = theArgVec[anArgIter];
|
||||
@@ -305,13 +188,6 @@ static Standard_Integer ReadGltf(Draw_Interpretor& theDI,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//if (aFilePath.IsEmpty() && !aDestName.IsEmpty())
|
||||
//{
|
||||
// if (toListExternalFiles || toPrintAssetInfo)
|
||||
// {
|
||||
// std::swap (aFilePath, aDestName);
|
||||
// }
|
||||
//}
|
||||
if (aFilePath.IsEmpty() || aDestName.IsEmpty())
|
||||
{
|
||||
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 =
|
||||
new RWGltf_Provider(aNode);
|
||||
Standard_Boolean aReadStat = Standard_False;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (isNoDoc)
|
||||
{
|
||||
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";
|
||||
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;
|
||||
}
|
||||
@@ -413,15 +265,6 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
|
||||
Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
|
||||
Handle(RWGltf_ConfigurationNode) aNode =
|
||||
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)
|
||||
{
|
||||
TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
|
||||
@@ -615,11 +458,11 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
|
||||
|
||||
TCollection_AsciiString anExt = aGltfFilePath;
|
||||
anExt.LowerCase();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
|
||||
Handle(RWGltf_Provider) aProvider =
|
||||
new RWGltf_Provider(aNode);
|
||||
Standard_Boolean aWriteStat = Standard_False;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (!aDoc.IsNull())
|
||||
{
|
||||
aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start());
|
||||
@@ -637,15 +480,14 @@ static Standard_Integer WriteGltf(Draw_Interpretor& theDI,
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitCommands
|
||||
//function : Factory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAWGLTF::InitCommands(Draw_Interpretor& theCommands)
|
||||
void XSDRAWGLTF::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
|
||||
//XSDRAW::LoadDraw(theCommands);
|
||||
|
||||
theCommands.Add("ReadGltf",
|
||||
theDI.Add("ReadGltf",
|
||||
"ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]"
|
||||
"\n\t\t: Read glTF file into XDE document."
|
||||
"\n\t\t: -listExternalFiles do not read mesh and only list external files"
|
||||
@@ -660,11 +502,11 @@ void XSDRAWGLTF::InitCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -toPrintDebugInfo print additional debug information during data reading"
|
||||
"\n\t\t: -assetInfo print asset information",
|
||||
__FILE__, ReadGltf, g);
|
||||
theCommands.Add("readgltf",
|
||||
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);
|
||||
theCommands.Add("WriteGltf",
|
||||
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]"
|
||||
@@ -694,24 +536,11 @@ void XSDRAWGLTF::InitCommands(Draw_Interpretor& theCommands)
|
||||
"\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",
|
||||
theDI.Add("writegltf",
|
||||
"writegltf shape file",
|
||||
__FILE__, WriteGltf, g);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Factory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAWGLTF::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
XSDRAWIGES::InitSelect();
|
||||
XSDRAWIGES::InitToBRep(theDI);
|
||||
XSDRAWIGES::InitFromBRep(theDI);
|
||||
XSDRAWSTEP::InitCommands(theDI);
|
||||
XSDRAWGLTF::InitCommands(theDI);
|
||||
XSDRAW::LoadDraw(theDI);
|
||||
XSDRAWBase::LoadDraw(theDI);
|
||||
#ifdef OCCT_DEBUG
|
||||
theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n";
|
||||
theDI << "Draw Plugin : All XSDRAWGLTF commands are loaded\n";
|
||||
#endif
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
@@ -11,130 +11,63 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <BRepTools.hxx>
|
||||
#include <XSDRAWIGES.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 <DrawTrSurf.hxx>
|
||||
#include <IFSelect_Functions.hxx>
|
||||
#include <IFSelect_SessionPilot.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <IGESCAFControl_ConfigurationNode.hxx>
|
||||
#include <IGESCAFControl_Provider.hxx>
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESControl_Reader.hxx>
|
||||
#include <IGESControl_Writer.hxx>
|
||||
#include <IGESData_IGESEntity.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESSelect_Activator.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message_ProgressScope.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <TColStd_MapOfTransient.hxx>
|
||||
#include <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 <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 <XDEDRAW_Common.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.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 <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Application.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)
|
||||
{
|
||||
char fname[110];
|
||||
sprintf(fname, "Shape_%d", number);
|
||||
std::ofstream f(fname, std::ios::out | std::ios::binary);
|
||||
std::cout << "Output file name : " << fname << std::endl;
|
||||
f << "DBRep_DrawableShape\n";
|
||||
|
||||
BRepTools::Write(shape, f);
|
||||
f.close();
|
||||
}
|
||||
|
||||
TCollection_AsciiString XSDRAW_CommandPart
|
||||
(Standard_Integer argc, const char** argv, const Standard_Integer argf)
|
||||
{
|
||||
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)
|
||||
//function : igesbrep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer igesbrep(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
DeclareAndCast(IGESControl_Controller, ctl, XSDRAW::Controller());
|
||||
if (ctl.IsNull()) XSDRAW::SetNorm("IGES");
|
||||
DeclareAndCast(IGESControl_Controller, ctl, XSDRAWBase::Controller());
|
||||
if (ctl.IsNull()) XSDRAWBase::SetNorm("IGES");
|
||||
|
||||
// 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);
|
||||
|
||||
IGESControl_Reader Reader(XSDRAW::Session(), Standard_False);
|
||||
IGESControl_Reader Reader(XSDRAWBase::Session(), Standard_False);
|
||||
Standard_Boolean aFullMode = Standard_True;
|
||||
Reader.WS()->SetModeStat(aFullMode);
|
||||
if (ctl.IsNull())
|
||||
ctl = Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller());
|
||||
ctl = Handle(IGESControl_Controller)::DownCast(XSDRAWBase::Controller());
|
||||
|
||||
TCollection_AsciiString fnom, rnom;
|
||||
|
||||
Standard_Boolean modfic = XSDRAW::FileAndVar
|
||||
(argv[1], argv[2], "IGESBREP", fnom, rnom);
|
||||
if (modfic) di << " File IGES to read : " << fnom.ToCString() << "\n";
|
||||
else di << " Model taken from the session : " << fnom.ToCString() << "\n";
|
||||
di << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
|
||||
Standard_Boolean modfic = XSDRAWBase::FileAndVar
|
||||
(theArgVec[1], theArgVec[2], "IGESBREP", fnom, rnom);
|
||||
if (modfic) theDI << " File IGES to read : " << fnom.ToCString() << "\n";
|
||||
else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
|
||||
theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
|
||||
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
|
||||
|
||||
#ifdef CHRONOMESURE
|
||||
@@ -148,7 +81,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
progress->Show(aPSRoot);
|
||||
|
||||
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%
|
||||
if (aPSRoot.UserBreak())
|
||||
@@ -156,12 +89,12 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
if (readstat != IFSelect_RetDone)
|
||||
{
|
||||
if (modfic) di << "Could not read file " << fnom.ToCString() << " , abandon\n";
|
||||
else di << "No model loaded\n";
|
||||
if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
|
||||
else theDI << "No model loaded\n";
|
||||
return 1;
|
||||
}
|
||||
// Choice of treatment
|
||||
Standard_Boolean fromtcl = (argc > 3);
|
||||
Standard_Boolean fromtcl = (theNbArgs > 3);
|
||||
Standard_Integer modepri = 1, nent, nbs;
|
||||
if (fromtcl) modepri = 4;
|
||||
|
||||
@@ -183,18 +116,18 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
if (modepri == 0)
|
||||
{ //fin
|
||||
di << "Bye and good luck! \n";
|
||||
theDI << "Bye and good luck! \n";
|
||||
break;
|
||||
}
|
||||
|
||||
else if (modepri <= 2)
|
||||
{ // 1 : Visible Roots, 2 : All Roots
|
||||
di << "All Geometry Transfer\n";
|
||||
di << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
di << " To modify : command param read.iges.bspline.continuity\n";
|
||||
theDI << "All Geometry Transfer\n";
|
||||
theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
theDI << " To modify : command param read.iges.bspline.continuity\n";
|
||||
const Handle(XSControl_WorkSession)& thesession = Reader.WS();
|
||||
thesession->TransferReader()->Context().Clear();
|
||||
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
|
||||
aPSRoot.SetName("Translation");
|
||||
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
|
||||
// or in one shape for one root.
|
||||
di << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
Standard_Integer answer = 1;
|
||||
if (Reader.NbShapes() > 1)
|
||||
{
|
||||
@@ -223,10 +156,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
{
|
||||
TopoDS_Shape shape = Reader.OneShape();
|
||||
// save the shape
|
||||
if (shape.IsNull()) { di << "No Shape produced\n"; continue; }
|
||||
if (shape.IsNull()) { theDI << "No Shape produced\n"; continue; }
|
||||
char fname[110];
|
||||
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);
|
||||
try
|
||||
{
|
||||
@@ -235,10 +168,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
di << "** Exception : ";
|
||||
di << anException.GetMessageString();
|
||||
di << " ** Skip\n";
|
||||
di << "Saving shape in variable Draw : " << fname << "\n";
|
||||
theDI << "** Exception : ";
|
||||
theDI << anException.GetMessageString();
|
||||
theDI << " ** Skip\n";
|
||||
theDI << "Saving shape in variable Draw : " << fname << "\n";
|
||||
WriteShape(shape, 1);
|
||||
}
|
||||
}
|
||||
@@ -250,10 +183,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
{
|
||||
// save all the shapes
|
||||
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];
|
||||
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);
|
||||
try
|
||||
{
|
||||
@@ -262,9 +195,9 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
di << "** Exception : ";
|
||||
di << anException.GetMessageString();
|
||||
di << " ** Skip\n";
|
||||
theDI << "** Exception : ";
|
||||
theDI << anException.GetMessageString();
|
||||
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 << " To modify : command param read.iges.bspline.continuity" << std::endl;
|
||||
std::cout << " give the number of the Entity : " << std::flush;
|
||||
nent = XSDRAW::GetEntityNumber();
|
||||
nent = XSDRAWBase::GetEntityNumber();
|
||||
|
||||
if (!Reader.TransferOne(nent))
|
||||
di << "Transfer entity n0 " << nent << " : no result\n";
|
||||
theDI << "Transfer entity n0 " << nent << " : no result\n";
|
||||
else
|
||||
{
|
||||
nbs = Reader.NbShapes();
|
||||
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nent);
|
||||
di << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
|
||||
di << "Now, " << nbs << " Shapes produced\n";
|
||||
theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
|
||||
theDI << "Now, " << nbs << " Shapes produced\n";
|
||||
TopoDS_Shape sh = Reader.Shape(nbs);
|
||||
DBRep::Set(shname, sh);
|
||||
}
|
||||
@@ -301,14 +234,14 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
// * donne iges-visible + xst-transferrable-roots
|
||||
// *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";
|
||||
di << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
di << " To modify : command param read.iges.bspline.continuity\n";
|
||||
theDI << "All Geometry Transfer\n";
|
||||
theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
theDI << " To modify : command param read.iges.bspline.continuity\n";
|
||||
const Handle(XSControl_WorkSession)& thesession = Reader.WS();
|
||||
thesession->TransferReader()->Context().Clear();
|
||||
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
|
||||
aPSRoot.SetName("Translation");
|
||||
progress->Show(aPSRoot);
|
||||
@@ -324,7 +257,7 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
// save the shape
|
||||
char fname[110];
|
||||
Sprintf(fname, "%s", rnom.ToCString());
|
||||
di << "Saving shape in variable Draw : " << fname << "\n";
|
||||
theDI << "Saving shape in variable Draw : " << fname << "\n";
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
@@ -332,10 +265,10 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
di << "** Exception : ";
|
||||
di << anException.GetMessageString();
|
||||
di << " ** Skip\n";
|
||||
di << "Saving shape in variable Draw : " << fname << "\n";
|
||||
theDI << "** Exception : ";
|
||||
theDI << anException.GetMessageString();
|
||||
theDI << " ** Skip\n";
|
||||
theDI << "Saving shape in variable Draw : " << fname << "\n";
|
||||
WriteShape(shape, 1);
|
||||
}
|
||||
return 0;
|
||||
@@ -344,32 +277,32 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
if (fromtcl)
|
||||
{
|
||||
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 : ";
|
||||
list = XSDRAW::GetList("xst-model-roots");
|
||||
theDI << "All Roots : ";
|
||||
list = XSDRAWBase::GetList("xst-model-roots");
|
||||
}
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString compart = XSDRAW_CommandPart(argc, argv, 3);
|
||||
di << "List given by " << compart.ToCString() << " : ";
|
||||
list = XSDRAW::GetList(compart.ToCString());
|
||||
TCollection_AsciiString compart = XSDRAW_CommandPart(theNbArgs, theArgVec, 3);
|
||||
theDI << "List given by " << compart.ToCString() << " : ";
|
||||
list = XSDRAWBase::GetList(compart.ToCString());
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Name of Selection :" << std::flush;
|
||||
list = XSDRAW::GetList();
|
||||
list = XSDRAWBase::GetList();
|
||||
if (list.IsNull()) { std::cout << "No list defined" << std::endl; continue; }
|
||||
}
|
||||
|
||||
Standard_Integer nbl = list->Length();
|
||||
di << "Nb entities selected : " << nbl << "\n";
|
||||
theDI << "Nb entities selected : " << nbl << "\n";
|
||||
if (nbl == 0) continue;
|
||||
while (answer)
|
||||
{
|
||||
@@ -388,16 +321,16 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
for (Standard_Integer ill = 1; ill <= nbl; 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)
|
||||
{
|
||||
Standard_Integer nbt = 0;
|
||||
Handle(XSControl_WorkSession) thesession = Reader.WS();
|
||||
|
||||
XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
XSDRAWBase::SetTransferProcess(thesession->TransferReader()->TransientProcess());
|
||||
aPSRoot.SetName("Translation");
|
||||
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));
|
||||
if (nent == 0) continue;
|
||||
if (!Reader.TransferOne(nent, aPS.Next()))
|
||||
di << "Transfer entity n0 " << nent << " : no result\n";
|
||||
theDI << "Transfer entity n0 " << nent << " : no result\n";
|
||||
else
|
||||
{
|
||||
nbs = Reader.NbShapes();
|
||||
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
|
||||
di << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
|
||||
di << "Now, " << nbs << " Shapes produced\n";
|
||||
theDI << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n";
|
||||
theDI << "Now, " << nbs << " Shapes produced\n";
|
||||
TopoDS_Shape sh = Reader.Shape(nbs);
|
||||
DBRep::Set(shname, sh);
|
||||
nbt++;
|
||||
@@ -421,55 +354,58 @@ static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
}
|
||||
if (aPSRoot.UserBreak())
|
||||
return 1;
|
||||
di << "Nb Shapes successfully produced : " << nbt << "\n";
|
||||
theDI << "Nb Shapes successfully produced : " << nbt << "\n";
|
||||
answer = 0; // on ne reboucle pas
|
||||
}
|
||||
}
|
||||
}
|
||||
else di << "Unknown mode n0 " << modepri << "\n";
|
||||
else theDI << "Unknown mode n0 " << modepri << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Function : testreadiges
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
static Standard_Integer testread(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
//function : testread
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer testread(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (argc != 3)
|
||||
if (theNbArgs != 3)
|
||||
{
|
||||
di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
|
||||
di << " Usage : " << argv[0] << " file_name shape_name\n";
|
||||
theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
|
||||
theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
|
||||
return 1;
|
||||
}
|
||||
IGESControl_Reader Reader;
|
||||
Standard_CString filename = argv[1];
|
||||
Standard_CString filename = theArgVec[1];
|
||||
IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
|
||||
di << "Status from reading IGES file " << filename << " : ";
|
||||
theDI << "Status from reading IGES file " << filename << " : ";
|
||||
switch (readstat)
|
||||
{
|
||||
case IFSelect_RetVoid: { di << "empty file\n"; return 1; }
|
||||
case IFSelect_RetDone: { di << "file read\n"; break; }
|
||||
case IFSelect_RetError: { di << "file not found\n"; return 1; }
|
||||
case IFSelect_RetFail: { di << "error during read\n"; return 1; }
|
||||
default: { di << "failure\n"; return 1; }
|
||||
case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
|
||||
case IFSelect_RetDone: { theDI << "file read\n"; break; }
|
||||
case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
|
||||
case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
|
||||
default: { theDI << "failure\n"; return 1; }
|
||||
}
|
||||
Reader.TransferRoots();
|
||||
TopoDS_Shape shape = Reader.OneShape();
|
||||
DBRep::Set(argv[2], shape);
|
||||
di << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
DBRep::Set(theArgVec[2], shape);
|
||||
theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Function : brepiges
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
static Standard_Integer brepiges(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
//=======================================================================
|
||||
//function : brepiges
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer brepiges(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
XSDRAW::SetNorm("IGES");
|
||||
XSDRAWBase::SetNorm("IGES");
|
||||
// ecriture dans le model d'une entite :
|
||||
// - model_AddEntity(ent) : ecriture de l`entite seule
|
||||
// - model->AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement
|
||||
@@ -478,115 +414,117 @@ static Standard_Integer brepiges(Draw_Interpretor& di, Standard_Integer n, const
|
||||
|
||||
IGESControl_Writer ICW(Interface_Static::CVal("write.iges.unit"),
|
||||
Interface_Static::IVal("write.iges.brep.mode"));
|
||||
di << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
|
||||
di << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
|
||||
di << " To modify : command param\n";
|
||||
theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
|
||||
theDI << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
|
||||
theDI << " To modify : command param\n";
|
||||
|
||||
// Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic
|
||||
// c a d tant qu il y a des + on ajoute ce qui suit
|
||||
const char* nomfic = NULL;
|
||||
Standard_Integer npris = 0;
|
||||
|
||||
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1);
|
||||
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
|
||||
Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
|
||||
progress->Show(aPSRoot);
|
||||
|
||||
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];
|
||||
if (a[i][0] == '+') nomvar = &(a[i])[1];
|
||||
else if (i > 1) { nomfic = a[i]; break; }
|
||||
const char* nomvar = theArgVec[i];
|
||||
if (theArgVec[i][0] == '+') nomvar = &(theArgVec[i])[1];
|
||||
else if (i > 1) { nomfic = theArgVec[i]; break; }
|
||||
TopoDS_Shape Shape = DBRep::Get(nomvar);
|
||||
if (ICW.AddShape(Shape, aPS.Next())) npris++;
|
||||
else if (ICW.AddGeom(DrawTrSurf::GetCurve(nomvar))) npris++;
|
||||
else if (ICW.AddGeom(DrawTrSurf::GetSurface(nomvar))) npris++;
|
||||
}
|
||||
ICW.ComputeModel();
|
||||
XSDRAW::SetModel(ICW.Model());
|
||||
XSDRAW::SetTransferProcess(ICW.TransferProcess());
|
||||
XSDRAWBase::SetModel(ICW.Model());
|
||||
XSDRAWBase::SetTransferProcess(ICW.TransferProcess());
|
||||
|
||||
if (aPSRoot.UserBreak())
|
||||
return 1;
|
||||
aPSRoot.SetName("Writing");
|
||||
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
|
||||
{
|
||||
di << " Now, to write a file, command : writeall filename\n";
|
||||
theDI << " Now, to write a file, command : writeall filename\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// write file
|
||||
if (!ICW.Write(nomfic)) di << " Error: could not write file " << nomfic;
|
||||
else di << " File " << nomfic << " written";
|
||||
if (!ICW.Write(nomfic)) theDI << " Error: could not write file " << nomfic;
|
||||
else theDI << " File " << nomfic << " written";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Function : testwriteiges
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
//=======================================================================
|
||||
//function : testwrite
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer testwrite(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (n != 3)
|
||||
if (theNbArgs != 3)
|
||||
{
|
||||
di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n";
|
||||
di << " Usage : " << a[0] << " file_name shape_name\n";
|
||||
theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
|
||||
theDI << " Usage : " << theArgVec[0] << " file_name shape_name\n";
|
||||
return 1;
|
||||
}
|
||||
IGESControl_Writer Writer;
|
||||
Standard_CString filename = a[1];
|
||||
TopoDS_Shape shape = DBRep::Get(a[2]);
|
||||
Standard_CString filename = theArgVec[1];
|
||||
TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
|
||||
Standard_Boolean ok = Writer.AddShape(shape);
|
||||
if (!ok)
|
||||
{
|
||||
di << "Shape not add\n";
|
||||
theDI << "Shape not add\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(Writer.Write(filename)))
|
||||
{
|
||||
di << "Error on writing file\n";
|
||||
theDI << "Error on writing file\n";
|
||||
return 1;
|
||||
}
|
||||
di << "File Is Written\n";
|
||||
theDI << "File Is Written\n";
|
||||
return 0;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
// Function : igesparam
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
|
||||
static Standard_Integer igesparam(Draw_Interpretor& di, Standard_Integer, const char**)
|
||||
//=======================================================================
|
||||
//function : igesparam
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer igesparam(Draw_Interpretor& theDI,
|
||||
Standard_Integer,
|
||||
const char**)
|
||||
{
|
||||
// liste des parametres
|
||||
di << "List of parameters which control IGES :\n";
|
||||
di << " unit : write.iges.unit\n mode write : write.iges.brep.mode\n spline_continuity (read) : read.iges.bspline.continuity\nSee definition by defparam, read/edit value by param\n";
|
||||
di << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
|
||||
di << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
|
||||
di << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
di << "\n To modifier, param nom_param new_val\n";
|
||||
theDI << "List of parameters which control IGES :\n";
|
||||
theDI << " unit : write.iges.unit\n mode write : write.iges.brep.mode\n spline_continuity (read) : read.iges.bspline.continuity\nSee definition by defparam, read/edit value by param\n";
|
||||
theDI << "unit (write) : " << Interface_Static::CVal("write.iges.unit") << "\n";
|
||||
theDI << "mode write : " << Interface_Static::CVal("write.iges.brep.mode") << "\n";
|
||||
theDI << "spline_continuity (read) : " << Interface_Static::IVal("read.iges.bspline.continuity") << " (0 : no modif, 1 : C1, 2 : C2)\n";
|
||||
theDI << "\n To modifier, param nom_param new_val\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------
|
||||
// Function : tplosttrim
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
|
||||
static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
//=======================================================================
|
||||
//function : XSDRAWIGES_tplosttrim
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
|
||||
|
||||
// Standard_Integer narg = pilot->NbWords();
|
||||
Standard_Integer narg = n;
|
||||
Standard_Integer narg = theNbArgs;
|
||||
|
||||
const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
|
||||
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(2, "IGESGeom_BoundedSurface");
|
||||
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;
|
||||
Handle(IFSelect_WorkSession) WS = pilot->Session();
|
||||
Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult();
|
||||
@@ -605,13 +543,13 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
|
||||
if (narg > 1)
|
||||
{
|
||||
// TCollection_AsciiString Arg = pilot->Word(1);
|
||||
TCollection_AsciiString Arg(a[1]);
|
||||
TCollection_AsciiString Arg(theArgVec[1]);
|
||||
for (k = 1; k <= 3; k++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
TColStd_MapOfTransient aMap;
|
||||
@@ -620,7 +558,7 @@ static Standard_Integer XSDRAWIGES_tplosttrim(Draw_Interpretor& di, Standard_Int
|
||||
if (!list.IsNull()) itrp.Filter(list);
|
||||
else
|
||||
{
|
||||
di << "No untrimmed faces\n";
|
||||
theDI << "No untrimmed faces\n";
|
||||
return 0;
|
||||
}
|
||||
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 (j == 1) di << "Number of untrimmed faces: \n";
|
||||
if (j == 1) theDI << "Number of untrimmed faces: \n";
|
||||
switch (k)
|
||||
{
|
||||
case 1:
|
||||
di << "Trimmed Surface: \n"; break;
|
||||
theDI << "Trimmed Surface: \n"; break;
|
||||
case 2:
|
||||
di << "Bounded Surface: \n"; break;
|
||||
theDI << "Bounded Surface: \n"; break;
|
||||
case 3:
|
||||
di << "Face: \n"; break;
|
||||
theDI << "Face: \n"; break;
|
||||
}
|
||||
|
||||
TColStd_MapIteratorOfMapOfTransient itmap;
|
||||
Standard_SStream aTmpStream;
|
||||
for (itmap.Initialize(aMap); itmap.More(); itmap.Next())
|
||||
{
|
||||
XSDRAW::Model()->Print(itmap.Key(), aTmpStream);
|
||||
XSDRAWBase::Model()->Print(itmap.Key(), aTmpStream);
|
||||
aTmpStream << " ";
|
||||
}
|
||||
di << aTmpStream.str().c_str();
|
||||
di << "\n";
|
||||
di << "\nNumber:" << nbFaces << "\n";
|
||||
theDI << aTmpStream.str().c_str();
|
||||
theDI << "\n";
|
||||
theDI << "\nNumber:" << nbFaces << "\n";
|
||||
totFaces += nbFaces;
|
||||
}
|
||||
if (narg > 1) break;
|
||||
nbFaces = 0;
|
||||
}
|
||||
|
||||
if (totFaces == 0) di << "No untrimmed faces\n";
|
||||
else di << "Total number :" << totFaces << "\n";
|
||||
if (totFaces == 0) theDI << "No untrimmed faces\n";
|
||||
else theDI << "Total number :" << totFaces << "\n";
|
||||
return 0;
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
//--------------------------------------------------------------
|
||||
// Function : TPSTAT
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||
|
||||
//=======================================================================
|
||||
//function : XSDRAWIGES_TPSTAT
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
|
||||
Standard_Integer argc = n;//= pilot->NbWords();
|
||||
const Standard_CString arg1 = a[1];//pilot->Arg(1);
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
|
||||
Standard_Integer theNbArgs = theNbArgs;//= pilot->NbWords();
|
||||
const Standard_CString arg1 = theArgVec[1];//pilot->Arg(1);
|
||||
const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess();
|
||||
IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False);
|
||||
// **** tpent ****
|
||||
Handle(Interface_InterfaceModel) model = TP->Model();
|
||||
if (model.IsNull()) { di << "No Transfer Read\n"; return -1; }
|
||||
if (model.IsNull()) { theDI << "No Transfer Read\n"; return -1; }
|
||||
Handle(XSControl_WorkSession) thesession = read.WS();
|
||||
thesession->SetMapReader(TP);
|
||||
Standard_Integer mod1 = 0;
|
||||
if (argc > 1)
|
||||
if (theNbArgs > 1)
|
||||
{
|
||||
char a2 = arg1[1]; if (a2 == '\0') a2 = '!';
|
||||
switch (arg1[0])
|
||||
@@ -705,10 +645,10 @@ static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer
|
||||
default: mod1 = -2; break;
|
||||
}
|
||||
}
|
||||
if (mod1 < -1) di << "Unknown Mode\n";
|
||||
if (mod1 < -1) theDI << "Unknown Mode\n";
|
||||
if (mod1 < 0)
|
||||
{
|
||||
di << "Modes available :\n"
|
||||
theDI << "Modes available :\n"
|
||||
<< "g : general c : checks (count) C (list)\n"
|
||||
<< "r : number of CasCade resulting shapes\n"
|
||||
<< "s : mapping between IGES entities and CasCade shapes\n";
|
||||
@@ -718,45 +658,28 @@ static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer
|
||||
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;
|
||||
}
|
||||
IGESControl_Reader aReader;
|
||||
aReader.ReadFile(a[1]);
|
||||
aReader.ReadFile(theArgVec[1]);
|
||||
aReader.SetReadVisible(Standard_True);
|
||||
aReader.TransferRoots();
|
||||
TopoDS_Shape shape = aReader.OneShape();
|
||||
DBRep::Set(a[2], shape);
|
||||
DBRep::Set(theArgVec[2], shape);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static void cleanpilot()
|
||||
{
|
||||
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
|
||||
//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);
|
||||
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(IGESCAFControl_Provider) aProvider =
|
||||
new IGESCAFControl_Provider(aNode);
|
||||
aProvider->SetToUpdateStaticParameters(false);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start()))
|
||||
{
|
||||
theDI << "Error: Can't read IGES file\n";
|
||||
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];
|
||||
return 0;
|
||||
}
|
||||
@@ -848,19 +771,19 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI,
|
||||
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(IGESCAFControl_Provider) aProvider =
|
||||
new IGESCAFControl_Provider(aNode);
|
||||
aProvider->SetToUpdateStaticParameters(false);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
const TCollection_AsciiString aPath = theArgVec[2];
|
||||
if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start()))
|
||||
{
|
||||
theDI << "Error: Can't write IGES file\n";
|
||||
return 1;
|
||||
}
|
||||
CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -869,31 +792,20 @@ static Standard_Integer WriteIges(Draw_Interpretor& theDI,
|
||||
//function : InitToBRep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XSDRAWIGES::InitToBRep(Draw_Interpretor& theCommands)
|
||||
void XSDRAWIGES::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
const char* g = "DE: IGES";
|
||||
theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
|
||||
theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g);
|
||||
theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
|
||||
theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
|
||||
theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
|
||||
theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
|
||||
theCommands.Add("etest", "test of eviewer", __FILE__, etest, g);
|
||||
theDI.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
|
||||
theDI.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g);
|
||||
theDI.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g);
|
||||
theDI.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g);
|
||||
theDI.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g);
|
||||
theDI.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g);
|
||||
theDI.Add("etest", "test of eviewer", __FILE__, etest, g);
|
||||
|
||||
theCommands.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("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, 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);
|
||||
}
|
||||
|
@@ -13,157 +13,22 @@
|
||||
|
||||
#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 <DDocStd.hxx>
|
||||
#include <DDocStd_DrawDocument.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_PluginMacro.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
|
||||
#include <MeshVS_DeformedDataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_ElementalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshEntityOwner.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_NodalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_PrsBuilder.hxx>
|
||||
#include <MeshVS_TextPrsBuilder.hxx>
|
||||
#include <MeshVS_VectorPrsBuilder.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
//#include <Quantity_HArray1OfColor.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <RWGltf_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_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_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;
|
||||
}
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Application.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <UnitsAPI.hxx>
|
||||
|
||||
//=============================================================================
|
||||
//function : parseCoordinateSystem
|
||||
@@ -189,25 +54,6 @@ static bool parseCoordinateSystem(const char* theArg,
|
||||
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
|
||||
//purpose : Reads OBJ file
|
||||
@@ -218,11 +64,8 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
|
||||
{
|
||||
TCollection_AsciiString aDestName, aFilePath;
|
||||
Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
Standard_Boolean toUseExistingDoc = Standard_False;
|
||||
//Standard_Real aFileUnitFactor = -1.0;
|
||||
//RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
|
||||
//Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False;
|
||||
Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj");
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
@@ -293,14 +136,6 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
|
||||
++anArgIter;
|
||||
}
|
||||
}
|
||||
//else if (anArgCase == "-listexternalfiles"
|
||||
// || anArgCase == "-listexternals"
|
||||
// || anArgCase == "-listexternal"
|
||||
// || anArgCase == "-external"
|
||||
// || anArgCase == "-externalfiles")
|
||||
//{
|
||||
// toListExternalFiles = Standard_True;
|
||||
//}
|
||||
else if (aDestName.IsEmpty())
|
||||
{
|
||||
aDestName = theArgVec[anArgIter];
|
||||
@@ -342,8 +177,8 @@ static Standard_Integer ReadObj(Draw_Interpretor& theDI,
|
||||
}
|
||||
}
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
|
||||
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(RWObj_Provider) aProvider = new RWObj_Provider(aNode);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
Standard_Boolean aReadStat = Standard_False;
|
||||
if (isNoDoc)
|
||||
{
|
||||
@@ -382,12 +217,10 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
|
||||
{
|
||||
TCollection_AsciiString anObjFilePath;
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
TopoDS_Shape aShape;
|
||||
Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
|
||||
//TColStd_IndexedDataMapOfStringString aFileInfo;
|
||||
//Standard_Real aFileUnitFactor = -1.0;
|
||||
//RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup;
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
|
||||
@@ -445,15 +278,12 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
|
||||
DDocStd::GetDocument(aNameVar, aDoc, false);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
TopoDS_Shape aShape = DBRep::Get(aNameVar);
|
||||
aShape = DBRep::Get(aNameVar);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n";
|
||||
return 1;
|
||||
}
|
||||
anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc);
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
|
||||
aShapeTool->AddShape(aShape);
|
||||
}
|
||||
}
|
||||
else if (anObjFilePath.IsEmpty())
|
||||
@@ -472,11 +302,21 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
|
||||
return 1;
|
||||
}
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1);
|
||||
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start()))
|
||||
Handle(RWObj_Provider) aProvider = new RWObj_Provider(aNode);
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
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;
|
||||
}
|
||||
@@ -485,10 +325,10 @@ static Standard_Integer WriteObj(Draw_Interpretor& theDI,
|
||||
//function : InitCommands
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAWOBJ::InitCommands(Draw_Interpretor& theCommands)
|
||||
void XSDRAWOBJ::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
const char* g = "XSTEP-STL/VRML"; // Step transfer file commands
|
||||
theCommands.Add("ReadObj",
|
||||
theDI.Add("ReadObj",
|
||||
"ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
|
||||
"\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
|
||||
"\n\t\t: [-listExternalFiles] [-noCreateDoc]"
|
||||
@@ -500,14 +340,14 @@ void XSDRAWOBJ::InitCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -listExternalFiles do not read mesh and only list external files."
|
||||
"\n\t\t: -noCreateDoc read into existing XDE document.",
|
||||
__FILE__, ReadObj, g);
|
||||
theCommands.Add("readobj",
|
||||
theDI.Add("readobj",
|
||||
"readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
|
||||
"\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]"
|
||||
"\n\t\t: [-singleFace]"
|
||||
"\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document."
|
||||
"\n\t\t: -singleFace merge OBJ content into a single triangulation Face.",
|
||||
__FILE__, ReadObj, g);
|
||||
theCommands.Add("WriteObj",
|
||||
theDI.Add("WriteObj",
|
||||
"WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]"
|
||||
"\n\t\t: [-systemCoordSys {Zup|Yup}]"
|
||||
"\n\t\t: [-comments Text] [-author Name]"
|
||||
@@ -516,7 +356,7 @@ void XSDRAWOBJ::InitCommands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified."
|
||||
"\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.",
|
||||
__FILE__, WriteObj, g);
|
||||
theCommands.Add("writeobj",
|
||||
theDI.Add("writeobj",
|
||||
"writeobj shape file",
|
||||
__FILE__, WriteObj, g);
|
||||
}
|
||||
|
@@ -11,17 +11,20 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XSDRAWSTEP.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 <IFSelect_SessionPilot.hxx>
|
||||
#include <Interface_Macros.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_ProgressScope.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <STEPCAFControl_ConfigurationNode.hxx>
|
||||
#include <STEPCAFControl_Provider.hxx>
|
||||
#include <STEPControl_ActorWrite.hxx>
|
||||
#include <STEPControl_Controller.hxx>
|
||||
#include <STEPControl_Reader.hxx>
|
||||
@@ -33,125 +36,45 @@
|
||||
#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 <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.hxx>
|
||||
#include <XSAlgo.hxx>
|
||||
#include <XSAlgo_AlgoContainer.hxx>
|
||||
#include <XSControl_Controller.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAW.hxx>
|
||||
#include <XSDRAWSTEP.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
#include <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 <TDataStd_Name.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 <Interface_Static.hxx>
|
||||
#include <UnitsAPI.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
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
static Standard_Integer stepread(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (argc < 3)
|
||||
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;
|
||||
}
|
||||
// On admet le controller AP214 ou une variante
|
||||
DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller());
|
||||
if (ctl.IsNull()) XSDRAW::SetNorm("STEP");
|
||||
DeclareAndCast(STEPControl_Controller, ctl, XSDRAWBase::Controller());
|
||||
if (ctl.IsNull()) XSDRAWBase::SetNorm("STEP");
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
STEPControl_Reader sr(XSDRAW::Session(), Standard_False);
|
||||
STEPControl_Reader sr(XSDRAWBase::Session(), Standard_False);
|
||||
TCollection_AsciiString fnom, rnom;
|
||||
Standard_Boolean modfic = XSDRAW::FileAndVar
|
||||
(argv[1], argv[2], "STEP", fnom, rnom);
|
||||
if (modfic) di << " File STEP to read : " << fnom.ToCString() << "\n";
|
||||
else di << " Model taken from the session : " << fnom.ToCString() << "\n";
|
||||
di << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
|
||||
Standard_Boolean modfic = XSDRAWBase::FileAndVar
|
||||
(theArgVec[1], theArgVec[2], "STEP", fnom, rnom);
|
||||
if (modfic) theDI << " File STEP to read : " << fnom.ToCString() << "\n";
|
||||
else theDI << " Model taken from the session : " << fnom.ToCString() << "\n";
|
||||
theDI << " -- Names of variables BREP-DRAW prefixed by : " << rnom.ToCString() << "\n";
|
||||
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
|
||||
|
||||
aPSRoot.SetName("Loading");
|
||||
@@ -160,14 +83,14 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
Standard_Boolean fromtcl = Standard_False;
|
||||
Standard_Boolean aFullMode = Standard_False;
|
||||
Standard_Integer k = 3;
|
||||
if (argc > k)
|
||||
if (theNbArgs > k)
|
||||
{
|
||||
if (argv[k][0] == 'f' || argv[3][0] == 'F')
|
||||
if (theArgVec[k][0] == 'f' || theArgVec[3][0] == 'F')
|
||||
{
|
||||
aFullMode = Standard_True;
|
||||
k++;
|
||||
}
|
||||
else if (argv[k][0] == 'r' || argv[3][0] == 'R')
|
||||
else if (theArgVec[k][0] == 'r' || theArgVec[3][0] == 'R')
|
||||
{
|
||||
aFullMode = Standard_False;
|
||||
k++;
|
||||
@@ -177,7 +100,7 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
}
|
||||
if (!fromtcl)
|
||||
fromtcl = argc > k;
|
||||
fromtcl = theNbArgs > k;
|
||||
if (aFullMode)
|
||||
std::cout << "Full model for translation with additional info will be used \n" << std::flush;
|
||||
else
|
||||
@@ -187,7 +110,7 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
|
||||
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%
|
||||
if (aPSRoot.UserBreak())
|
||||
@@ -195,8 +118,8 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
|
||||
if (readstat != IFSelect_RetDone)
|
||||
{
|
||||
if (modfic) di << "Could not read file " << fnom.ToCString() << " , abandon\n";
|
||||
else di << "No model loaded\n";
|
||||
if (modfic) theDI << "Could not read file " << fnom.ToCString() << " , abandon\n";
|
||||
else theDI << "No model loaded\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -211,21 +134,21 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
num = sr.NbRootsForTransfer();
|
||||
if (!fromtcl)
|
||||
{
|
||||
di << "NbRootsForTransfer=" << num << " :\n";
|
||||
theDI << "NbRootsForTransfer=" << num << " :\n";
|
||||
for (i = 1; i <= num; i++)
|
||||
{
|
||||
di << "Root." << i << ", Ent. ";
|
||||
theDI << "Root." << i << ", Ent. ";
|
||||
Standard_SStream aTmpStream;
|
||||
sr.Model()->Print(sr.RootForTransfer(i), aTmpStream);
|
||||
di << aTmpStream.str().c_str();
|
||||
di << " Type:" << sr.RootForTransfer(i)->DynamicType()->Name() << "\n";
|
||||
theDI << aTmpStream.str().c_str();
|
||||
theDI << " Type:" << sr.RootForTransfer(i)->DynamicType()->Name() << "\n";
|
||||
}
|
||||
|
||||
std::cout << "Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : " << std::flush;
|
||||
std::cin >> modepri;
|
||||
}
|
||||
|
||||
if (modepri == 0) { di << "End Reading STEP\n"; return 0; }
|
||||
if (modepri == 0) { theDI << "End Reading STEP\n"; return 0; }
|
||||
if (modepri <= 2)
|
||||
{
|
||||
num = 1;
|
||||
@@ -237,13 +160,13 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
progress->Show(aPSRoot);
|
||||
|
||||
if (!sr.TransferRoot(num, aPSRoot.Next(80)))
|
||||
di << "Transfer root n0 " << num << " : no result\n";
|
||||
theDI << "Transfer root n0 " << num << " : no result\n";
|
||||
else
|
||||
{
|
||||
nbs = sr.NbShapes();
|
||||
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
|
||||
di << "Transfer root n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
di << "Now, " << nbs << " Shapes produced\n";
|
||||
theDI << "Transfer root n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
theDI << "Now, " << nbs << " Shapes produced\n";
|
||||
TopoDS_Shape sh = sr.Shape(nbs);
|
||||
DBRep::Set(shname, sh);
|
||||
}
|
||||
@@ -252,15 +175,15 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
}
|
||||
else if (modepri == 3)
|
||||
{
|
||||
std::cout << "Entity : " << std::flush; num = XSDRAW::GetEntityNumber();
|
||||
std::cout << "Entity : " << std::flush; num = XSDRAWBase::GetEntityNumber();
|
||||
if (!sr.TransferOne(num))
|
||||
di << "Transfer entity n0 " << num << " : no result\n";
|
||||
theDI << "Transfer entity n0 " << num << " : no result\n";
|
||||
else
|
||||
{
|
||||
nbs = sr.NbShapes();
|
||||
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), num);
|
||||
di << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
di << "Now, " << nbs << " Shapes produced\n";
|
||||
theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
theDI << "Now, " << nbs << " Shapes produced\n";
|
||||
TopoDS_Shape sh = sr.Shape(nbs);
|
||||
DBRep::Set(shname, sh);
|
||||
}
|
||||
@@ -275,32 +198,32 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
if (fromtcl)
|
||||
{
|
||||
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 : ";
|
||||
list = XSDRAW::GetList("xst-transferrable-roots");
|
||||
theDI << "Transferrable Roots : ";
|
||||
list = XSDRAWBase::GetList("xst-transferrable-roots");
|
||||
//list = new TColStd_HSequenceOfTransient;
|
||||
//for(Standard_Integer j=1; j<=num; j++)
|
||||
// list->Append(sr.RootForTransfer(j));
|
||||
}
|
||||
else
|
||||
{
|
||||
di << "List given by " << argv[k];
|
||||
if (argc > k + 1) di << " " << argv[k + 1];
|
||||
di << " : ";
|
||||
list = XSDRAW::GetList(argv[k], (argc > (k + 1) ? argv[k + 1] : 0));
|
||||
theDI << "List given by " << theArgVec[k];
|
||||
if (theNbArgs > k + 1) theDI << " " << theArgVec[k + 1];
|
||||
theDI << " : ";
|
||||
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
|
||||
{
|
||||
std::cout << "Name of Selection :" << std::flush;
|
||||
list = XSDRAW::GetList();
|
||||
if (list.IsNull()) { di << "No list defined\n"; continue; }
|
||||
list = XSDRAWBase::GetList();
|
||||
if (list.IsNull()) { theDI << "No list defined\n"; continue; }
|
||||
}
|
||||
|
||||
Standard_Integer ill, nbl = list->Length();
|
||||
di << "Nb entities selected : " << nbl << "\n";
|
||||
theDI << "Nb entities selected : " << nbl << "\n";
|
||||
if (nbl == 0) continue;
|
||||
|
||||
aPSRoot.SetName("Translation");
|
||||
@@ -312,13 +235,13 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
num = sr.Model()->Number(list->Value(ill));
|
||||
if (num == 0) continue;
|
||||
if (!sr.TransferOne(num, aPS.Next()))
|
||||
di << "Transfer entity n0 " << num << " : no result\n";
|
||||
theDI << "Transfer entity n0 " << num << " : no result\n";
|
||||
else
|
||||
{
|
||||
nbs = sr.NbShapes();
|
||||
char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs);
|
||||
di << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
di << "Now, " << nbs << " Shapes produced\n";
|
||||
theDI << "Transfer entity n0 " << num << " OK -> DRAW Shape: " << shname << "\n";
|
||||
theDI << "Now, " << nbs << " Shapes produced\n";
|
||||
TopoDS_Shape sh = sr.Shape(nbs);
|
||||
DBRep::Set(shname, sh);
|
||||
}
|
||||
@@ -326,7 +249,7 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
if (aPSRoot.UserBreak())
|
||||
return 1;
|
||||
}
|
||||
else di << "Unknown mode n0 " << modepri << "\n";
|
||||
else theDI << "Unknown mode n0 " << modepri << "\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -335,20 +258,22 @@ static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, co
|
||||
//function : testreadstep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer testreadstep(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
static Standard_Integer testreadstep(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (argc < 3 || argc > 4)
|
||||
if (theNbArgs < 3 || theNbArgs > 4)
|
||||
{
|
||||
di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
|
||||
di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n";
|
||||
di << " Option -stream forces usage of API accepting stream\n";
|
||||
theDI << "ERROR in " << theArgVec[0] << "Wrong Number of Arguments.\n";
|
||||
theDI << " Usage : " << theArgVec[0] << " file_name shape_name [-stream]\n";
|
||||
theDI << " Option -stream forces usage of API accepting stream\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Boolean useStream = (argc > 3 && !strcasecmp(argv[3], "-stream"));
|
||||
Standard_Boolean useStream = (theNbArgs > 3 && !strcasecmp(theArgVec[3], "-stream"));
|
||||
|
||||
STEPControl_Reader Reader;
|
||||
Standard_CString filename = argv[1];
|
||||
Standard_CString filename = theArgVec[1];
|
||||
IFSelect_ReturnStatus readstat;
|
||||
if (useStream)
|
||||
{
|
||||
@@ -362,57 +287,57 @@ static Standard_Integer testreadstep(Draw_Interpretor& di, Standard_Integer argc
|
||||
{
|
||||
readstat = Reader.ReadFile(filename);
|
||||
}
|
||||
di << "Status from reading STEP file " << filename << " : ";
|
||||
theDI << "Status from reading STEP file " << filename << " : ";
|
||||
switch (readstat)
|
||||
{
|
||||
case IFSelect_RetVoid: { di << "empty file\n"; return 1; }
|
||||
case IFSelect_RetDone: { di << "file read\n"; break; }
|
||||
case IFSelect_RetError: { di << "file not found\n"; return 1; }
|
||||
case IFSelect_RetFail: { di << "error during read\n"; return 1; }
|
||||
default: { di << "failure\n"; return 1; }
|
||||
case IFSelect_RetVoid: { theDI << "empty file\n"; return 1; }
|
||||
case IFSelect_RetDone: { theDI << "file read\n"; break; }
|
||||
case IFSelect_RetError: { theDI << "file not found\n"; return 1; }
|
||||
case IFSelect_RetFail: { theDI << "error during read\n"; return 1; }
|
||||
default: { theDI << "failure\n"; return 1; }
|
||||
}
|
||||
XSAlgo::AlgoContainer()->PrepareForTransfer(); // update unit info
|
||||
Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit());
|
||||
Reader.TransferRoots();
|
||||
TopoDS_Shape shape = Reader.OneShape();
|
||||
DBRep::Set(argv[2], shape);
|
||||
di << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
DBRep::Set(theArgVec[2], shape);
|
||||
theDI << "Count of shapes produced : " << Reader.NbShapes() << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ######## COMMANDE steptrans : teste les transformations #########
|
||||
//=======================================================================
|
||||
//function : steptrans
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer steptrans(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
static Standard_Integer steptrans(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
if (argc < 5)
|
||||
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;
|
||||
}
|
||||
TopoDS_Shape shape = DBRep::Get(argv[1]);
|
||||
if (shape.IsNull()) { di << "Not a shape : " << argv[1] << "\n"; return 1; }
|
||||
TopoDS_Shape shape = DBRep::Get(theArgVec[1]);
|
||||
if (shape.IsNull()) { theDI << "Not a shape : " << theArgVec[1] << "\n"; return 1; }
|
||||
Handle(StepGeom_Axis2Placement3d) ax1, ax2;
|
||||
Standard_Integer n1 = 0, n2 = 0;
|
||||
n1 = XSDRAW::GetEntityNumber(argv[3]);
|
||||
if (argc > 4) n2 = XSDRAW::GetEntityNumber(argv[4]);
|
||||
n1 = XSDRAWBase::GetEntityNumber(theArgVec[3]);
|
||||
if (theNbArgs > 4) n2 = XSDRAWBase::GetEntityNumber(theArgVec[4]);
|
||||
if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast
|
||||
(XSDRAW::Entity(n1));
|
||||
(XSDRAWBase::Entity(n1));
|
||||
if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast
|
||||
(XSDRAW::Entity(n2));
|
||||
(XSDRAWBase::Entity(n2));
|
||||
StepToTopoDS_MakeTransformed mktrans;
|
||||
if (mktrans.Compute(ax1, ax2))
|
||||
{
|
||||
TopLoc_Location loc(mktrans.Transformation());
|
||||
shape.Move(loc);
|
||||
// mktrans.Transform (shape);
|
||||
DBRep::Set(argv[2], shape);
|
||||
di << "Transformed Shape as " << argv[2] << "\n";
|
||||
DBRep::Set(theArgVec[2], shape);
|
||||
theDI << "Transformed Shape as " << theArgVec[2] << "\n";
|
||||
}
|
||||
else di << "No transformation computed\n";
|
||||
else theDI << "No transformation computed\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -422,26 +347,27 @@ static Standard_Integer steptrans(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
//function : stepwrite
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
static Standard_Integer stepwrite(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
// On admet le controller AP214 ou une variante
|
||||
DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller());
|
||||
DeclareAndCast(STEPControl_Controller, ctl, XSDRAWBase::Controller());
|
||||
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
|
||||
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";
|
||||
di << "f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
|
||||
theDI << "Give mode[1-4] and Shape name + optional file. Mode possible\n";
|
||||
theDI << "f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n"
|
||||
<< "m ou 3 : ManifoldSolidBrep w ou 4 : GeometricCurveSet/WireFrame\n";
|
||||
return 1;
|
||||
}
|
||||
char modeshape = argv[1][0];
|
||||
char modeshape = theArgVec[1][0];
|
||||
STEPControl_StepModelType mode;
|
||||
switch (modeshape)
|
||||
{
|
||||
@@ -455,7 +381,7 @@ static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
case '3': mode = STEPControl_ManifoldSolidBrep; break;
|
||||
case 'w':
|
||||
case '4': mode = STEPControl_GeometricCurveSet; break;
|
||||
default: di << "1st arg = mode, incorrect [give fsmw]\n"; return 1;
|
||||
default: theDI << "1st arg = mode, incorrect [give fsmw]\n"; return 1;
|
||||
}
|
||||
|
||||
//: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())
|
||||
ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly"));
|
||||
|
||||
TopoDS_Shape shape = DBRep::Get(argv[2]);
|
||||
STEPControl_Writer sw(XSDRAW::Session(), Standard_False);
|
||||
TopoDS_Shape shape = DBRep::Get(theArgVec[2]);
|
||||
STEPControl_Writer sw(XSDRAWBase::Session(), Standard_False);
|
||||
Handle(Interface_InterfaceModel) stepmodel = sw.Model();
|
||||
Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
|
||||
|
||||
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1);
|
||||
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(theDI, 1);
|
||||
Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100);
|
||||
progress->Show(aPSRoot);
|
||||
|
||||
Standard_Integer stat = sw.Transfer(shape, mode, Standard_True, aPSRoot.Next(90));
|
||||
if (stat == IFSelect_RetDone)
|
||||
{
|
||||
di << "Translation: OK\n";
|
||||
theDI << "Translation: OK\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
di << "Error: translation failed, status = " << stat << "\n";
|
||||
theDI << "Error: translation failed, status = " << stat << "\n";
|
||||
}
|
||||
|
||||
if (aPSRoot.UserBreak())
|
||||
@@ -491,40 +417,43 @@ static Standard_Integer stepwrite(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
// Que s est-il passe
|
||||
stepmodel = sw.Model();
|
||||
Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
|
||||
if (nbavant > 0) di << "Beware : Model not empty before transferring\n";
|
||||
if (nbapres <= nbavant) di << "Beware : No data produced by this transfer\n";
|
||||
if (nbapres == 0) { di << "No data to write\n"; return 0; }
|
||||
if (nbavant > 0) theDI << "Beware : Model not empty before transferring\n";
|
||||
if (nbapres <= nbavant) theDI << "Beware : No data produced by this transfer\n";
|
||||
if (nbapres == 0) { theDI << "No data to write\n"; return 0; }
|
||||
|
||||
if (argc <= 3)
|
||||
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;
|
||||
}
|
||||
|
||||
const char* nomfic = argv[3];
|
||||
const char* nomfic = theArgVec[3];
|
||||
stat = sw.Write(nomfic);
|
||||
switch (stat)
|
||||
{
|
||||
case IFSelect_RetVoid: di << "Error: No file written\n"; break;
|
||||
case IFSelect_RetDone: di << "File " << nomfic << " written\n"; break;
|
||||
case IFSelect_RetStop: di << "Error on writing file: no space on disk or destination is write protected\n"; break;
|
||||
default: di << "Error: File " << nomfic << " written with fail messages\n"; break;
|
||||
case IFSelect_RetVoid: theDI << "Error: No file written\n"; break;
|
||||
case IFSelect_RetDone: theDI << "File " << nomfic << " written\n"; break;
|
||||
case IFSelect_RetStop: theDI << "Error on writing file: no space on disk or destination is write protected\n"; break;
|
||||
default: theDI << "Error: File " << nomfic << " written with fail messages\n"; break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : testwritestep
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
static Standard_Integer testwrite(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
TCollection_AsciiString aFilePath;
|
||||
TopoDS_Shape aShape;
|
||||
bool toTestStream = false;
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter)
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArgCase(argv[anArgIter]);
|
||||
TCollection_AsciiString anArgCase(theArgVec[anArgIter]);
|
||||
anArgCase.LowerCase();
|
||||
if (anArgCase == "-stream")
|
||||
{
|
||||
@@ -532,26 +461,26 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
}
|
||||
else if (aFilePath.IsEmpty())
|
||||
{
|
||||
aFilePath = argv[anArgIter];
|
||||
aFilePath = theArgVec[anArgIter];
|
||||
}
|
||||
else if (aShape.IsNull())
|
||||
{
|
||||
aShape = DBRep::Get(argv[anArgIter]);
|
||||
aShape = DBRep::Get(theArgVec[anArgIter]);
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
di << "Syntax error: '" << argv[anArgIter] << "' is not a shape";
|
||||
theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a shape";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
di << "Syntax error: unknown argument '" << argv[anArgIter] << "'";
|
||||
theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (aShape.IsNull())
|
||||
{
|
||||
di << "Syntax error: wrong number of arguments";
|
||||
theDI << "Syntax error: wrong number of arguments";
|
||||
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);
|
||||
if (aStat != IFSelect_RetDone)
|
||||
{
|
||||
di << "Error on transferring shape";
|
||||
theDI << "Error on transferring shape";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -581,10 +510,10 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
}
|
||||
if (aStat != IFSelect_RetDone)
|
||||
{
|
||||
di << "Error on writing file";
|
||||
theDI << "Error on writing file";
|
||||
return 1;
|
||||
}
|
||||
di << "File Is Written";
|
||||
theDI << "File Is Written";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -592,11 +521,11 @@ static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer argc, c
|
||||
//function : countexpected
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
static Standard_Integer countexpected
|
||||
(Draw_Interpretor& di, Standard_Integer /*argc*/, const char** /*argv*/)
|
||||
static Standard_Integer countexpected(Draw_Interpretor& theDI,
|
||||
Standard_Integer /*theNbArgs*/,
|
||||
const char** /*theArgVec*/)
|
||||
{
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
|
||||
Handle(IFSelect_WorkSession) WS = pilot->Session();
|
||||
const Interface_Graph& graph = WS->Graph();
|
||||
|
||||
@@ -608,25 +537,30 @@ static Standard_Integer countexpected
|
||||
cnt.Count(graph, roots->Value(i));
|
||||
}
|
||||
|
||||
di << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n";
|
||||
di << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n";
|
||||
di << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n";
|
||||
di << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n";
|
||||
di << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n";
|
||||
theDI << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n";
|
||||
theDI << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n";
|
||||
theDI << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n";
|
||||
theDI << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n";
|
||||
theDI << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n";
|
||||
|
||||
di << "Source Faces \t: " << cnt.NbSourceFaces() << "\n";
|
||||
di << "Source Shells\t: " << cnt.NbSourceShells() << "\n";
|
||||
di << "Source Solids\t: " << cnt.NbSourceSolids() << "\n";
|
||||
di << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n";
|
||||
di << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n";
|
||||
theDI << "Source Faces \t: " << cnt.NbSourceFaces() << "\n";
|
||||
theDI << "Source Shells\t: " << cnt.NbSourceShells() << "\n";
|
||||
theDI << "Source Solids\t: " << cnt.NbSourceSolids() << "\n";
|
||||
theDI << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n";
|
||||
theDI << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n";
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static Standard_Integer dumpassembly
|
||||
(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char** /*argv*/)
|
||||
//=======================================================================
|
||||
//function : dumpassembly
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer dumpassembly(Draw_Interpretor& /*theDI*/,
|
||||
Standard_Integer /*theNbArgs*/,
|
||||
const char** /*theArgVec*/)
|
||||
{
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot();
|
||||
Handle(IFSelect_SessionPilot) pilot = XSDRAWBase::Pilot();
|
||||
Handle(IFSelect_WorkSession) WS = pilot->Session();
|
||||
const Interface_Graph& graph = WS->Graph();
|
||||
|
||||
@@ -635,23 +569,29 @@ static Standard_Integer dumpassembly
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Standard_Integer stepfileunits(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
//=======================================================================
|
||||
//function : stepfileunits
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static Standard_Integer stepfileunits(Draw_Interpretor& theDI,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
|
||||
if (argc < 2)
|
||||
if (theNbArgs < 2)
|
||||
{
|
||||
di << "Error: Invalid number of parameters. Should be: getfileunits name_file\n";
|
||||
theDI << "Error: Invalid number of parameters. Should be: getfileunits name_file\n";
|
||||
return 1;
|
||||
}
|
||||
STEPControl_Reader aStepReader;
|
||||
|
||||
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
|
||||
readstat = aStepReader.ReadFile(argv[1]);
|
||||
readstat = aStepReader.ReadFile(theArgVec[1]);
|
||||
|
||||
if (readstat != IFSelect_RetDone)
|
||||
{
|
||||
|
||||
di << "No model loaded\n";
|
||||
theDI << "No model loaded\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -661,24 +601,23 @@ static Standard_Integer stepfileunits(Draw_Interpretor& di, Standard_Integer arg
|
||||
aStepReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
|
||||
|
||||
Standard_Integer i = 1;
|
||||
di << "=====================================================\n";
|
||||
di << "LENGTH Unit\n";
|
||||
theDI << "=====================================================\n";
|
||||
theDI << "LENGTH Unit\n";
|
||||
for (; i <= anUnitLengthNames.Length(); i++)
|
||||
di << anUnitLengthNames(i).ToCString() << "\n";
|
||||
theDI << anUnitLengthNames(i).ToCString() << "\n";
|
||||
|
||||
di << "=====================================================\n";
|
||||
di << "Angle Unit\n";
|
||||
theDI << "=====================================================\n";
|
||||
theDI << "Angle Unit\n";
|
||||
for (i = 1; i <= anUnitAngleNames.Length(); i++)
|
||||
di << anUnitAngleNames(i).ToCString() << "\n";
|
||||
theDI << anUnitAngleNames(i).ToCString() << "\n";
|
||||
|
||||
di << "=====================================================\n";
|
||||
di << "Solid Angle Unit\n";
|
||||
theDI << "=====================================================\n";
|
||||
theDI << "Solid Angle Unit\n";
|
||||
for (i = 1; i <= anUnitSolidAngleNames.Length(); i++)
|
||||
di << anUnitSolidAngleNames(i).ToCString() << "\n";
|
||||
theDI << anUnitSolidAngleNames(i).ToCString() << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
// ######## COMMANDE stepwrite : teste le Writer #########
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadStep
|
||||
@@ -750,13 +689,13 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
|
||||
Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
|
||||
Draw::Set(aDocName, aDrawDoc);
|
||||
}
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
|
||||
Handle(STEPCAFControl_Provider) aProvider =
|
||||
new STEPCAFControl_Provider(aNode);
|
||||
aProvider->SetToUpdateStaticParameters(false);
|
||||
Standard_Boolean aReadStat = Standard_False;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (aToTestStream)
|
||||
{
|
||||
std::ifstream aStream;
|
||||
@@ -778,7 +717,7 @@ static Standard_Integer ReadStep(Draw_Interpretor& theDI,
|
||||
}
|
||||
Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc);
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
@@ -885,13 +824,13 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
|
||||
theDI << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
|
||||
Handle(STEPCAFControl_Provider) aProvider =
|
||||
new STEPCAFControl_Provider(aNode);
|
||||
aProvider->SetToUpdateStaticParameters(false);
|
||||
Standard_Boolean aReadStat = Standard_False;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (aToTestStream)
|
||||
{
|
||||
std::ofstream aStream;
|
||||
@@ -911,30 +850,32 @@ static Standard_Integer WriteStep(Draw_Interpretor& theDI,
|
||||
theDI << "Cannot write any relevant data to the STEP file\n";
|
||||
return 1;
|
||||
}
|
||||
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
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
|
||||
XSDRAWSTEP::Init();
|
||||
XSDRAW::LoadDraw(theCommands);
|
||||
theCommands.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
|
||||
theCommands.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
|
||||
theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
|
||||
theDI.Add("testwritestep", "testwritestep filename.stp shape [-stream]",
|
||||
__FILE__, testwrite, g);
|
||||
theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, g);
|
||||
theCommands.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, g);
|
||||
theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
|
||||
theCommands.Add("countexpected", "TEST", __FILE__, countexpected, g);
|
||||
theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);
|
||||
theCommands.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, g);
|
||||
theCommands.Add("ReadStep",
|
||||
theDI.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, g);
|
||||
theDI.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, g);
|
||||
theDI.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
|
||||
theDI.Add("countexpected", "TEST", __FILE__, countexpected, g);
|
||||
theDI.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);
|
||||
theDI.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, g);
|
||||
theDI.Add("ReadStep",
|
||||
"Doc filename [mode] [-stream]"
|
||||
"\n\t\t: Read STEP file to a document."
|
||||
"\n\t\t: -stream read using istream reading interface (testing)",
|
||||
__FILE__, ReadStep, g);
|
||||
theCommands.Add("WriteStep",
|
||||
theDI.Add("WriteStep",
|
||||
"Doc filename [mode=a [multifile_prefix] [label]] [-stream]"
|
||||
"\n\t\t: Write DECAF document to STEP file"
|
||||
"\n\t\t: mode can be: a or 0 : AsIs (default)"
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
@@ -13,200 +13,19 @@
|
||||
|
||||
#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 <DDocStd.hxx>
|
||||
#include <DDocStd_DrawDocument.hxx>
|
||||
#include <Draw.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Draw_PluginMacro.hxx>
|
||||
#include <Draw_ProgressIndicator.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <MeshVS_DataMapOfIntegerAsciiString.hxx>
|
||||
#include <MeshVS_DeformedDataSource.hxx>
|
||||
#include <MeshVS_Drawer.hxx>
|
||||
#include <MeshVS_DrawerAttribute.hxx>
|
||||
#include <MeshVS_ElementalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_Mesh.hxx>
|
||||
#include <MeshVS_MeshEntityOwner.hxx>
|
||||
#include <MeshVS_MeshPrsBuilder.hxx>
|
||||
#include <MeshVS_NodalColorPrsBuilder.hxx>
|
||||
#include <MeshVS_PrsBuilder.hxx>
|
||||
#include <MeshVS_TextPrsBuilder.hxx>
|
||||
#include <MeshVS_VectorPrsBuilder.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
//#include <Quantity_HArray1OfColor.hxx>
|
||||
#include <Quantity_NameOfColor.hxx>
|
||||
#include <RWGltf_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_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 <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.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_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
|
||||
@@ -230,10 +49,10 @@ static Standard_Integer writestl(Draw_Interpretor& theDI,
|
||||
isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0);
|
||||
}
|
||||
Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
|
||||
aNode->InternalParameters.WriteAscii = isASCIIMode;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI);
|
||||
if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
|
||||
{
|
||||
@@ -253,10 +72,7 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
|
||||
{
|
||||
TCollection_AsciiString aShapeName, aFilePath;
|
||||
Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
//bool toCreateCompOfTris = false;
|
||||
//bool anIsMulti = false;
|
||||
//double aMergeAngle = M_PI / 2.0;
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++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(RWStl_Provider) aProvider = new RWStl_Provider(aNode);
|
||||
TopoDS_Shape aShape;
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAW::Session();
|
||||
Handle(XSControl_WorkSession) aWS = XSDRAWBase::Session();
|
||||
if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start()))
|
||||
{
|
||||
theDI << "Cannot read any relevant data from the STL file\n";
|
||||
@@ -346,17 +162,16 @@ static Standard_Integer readstl(Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitCommands
|
||||
//=============================================================================
|
||||
//function : Factory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAWSTL::InitCommands(Draw_Interpretor& theCommands)
|
||||
//=============================================================================
|
||||
void XSDRAWSTL::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
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",
|
||||
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."
|
||||
@@ -364,6 +179,4 @@ void XSDRAWSTL::InitCommands(Draw_Interpretor& theCommands)
|
||||
"\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);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -11,42 +11,46 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XSDRAWVRML.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <DDocStd.hxx>
|
||||
#include <DDocStd_DrawDocument.hxx>
|
||||
#include <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_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_Provider.hxx>
|
||||
|
||||
#include <DBRep.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_Editor.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAWBase.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Application.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <Interface_Static.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
|
||||
@@ -67,7 +71,7 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
|
||||
Standard_Boolean toUseExistingDoc = Standard_False;
|
||||
Standard_CString aDocName = NULL;
|
||||
TCollection_AsciiString aFilePath;
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
|
||||
for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++)
|
||||
{
|
||||
TCollection_AsciiString anArg(theArgVec[anArgIt]);
|
||||
@@ -151,7 +155,7 @@ static Standard_Integer ReadVrml(Draw_Interpretor& theDI,
|
||||
Handle(Vrml_Provider) aProvider =
|
||||
new Vrml_Provider(aNode);
|
||||
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()))
|
||||
{
|
||||
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);
|
||||
Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc);
|
||||
Draw::Set(aDocName, aDD);
|
||||
CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -193,22 +197,21 @@ static Standard_Integer WriteVrml(Draw_Interpretor& theDI,
|
||||
}
|
||||
Handle(Vrml_ConfigurationNode) aNode =
|
||||
new Vrml_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc);
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit(aDoc);
|
||||
Handle(Vrml_Provider) aProvider =
|
||||
new Vrml_Provider(aNode);
|
||||
|
||||
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()))
|
||||
{
|
||||
theDI << "Error: file writing failed '" << theArgVec[2] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
|
||||
XSDRAWBase::CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : loadvrml
|
||||
//purpose :
|
||||
@@ -224,12 +227,12 @@ static Standard_Integer loadvrml(Draw_Interpretor& theDI,
|
||||
}
|
||||
Handle(Vrml_ConfigurationNode) aNode =
|
||||
new Vrml_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
Handle(Vrml_Provider) aProvider =
|
||||
new Vrml_Provider(aNode);
|
||||
TopoDS_Shape aShape;
|
||||
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()))
|
||||
{
|
||||
theDI << "Error: file reading failed '" << theArgVec[2] << "'\n";
|
||||
@@ -269,7 +272,7 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
|
||||
aType = Min(2, aType);
|
||||
Handle(Vrml_ConfigurationNode) aNode =
|
||||
new Vrml_ConfigurationNode();
|
||||
aNode->GlobalParameters.LengthUnit = GetLengthUnit();
|
||||
aNode->GlobalParameters.LengthUnit = XSDRAWBase::GetLengthUnit();
|
||||
Handle(Vrml_Provider) aProvider =
|
||||
new Vrml_Provider(aNode);
|
||||
aNode->InternalParameters.WriterVersion =
|
||||
@@ -277,7 +280,7 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
|
||||
aNode->InternalParameters.WriteRepresentationType =
|
||||
(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);
|
||||
if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start()))
|
||||
{
|
||||
@@ -287,7 +290,11 @@ static Standard_Integer writevrml(Draw_Interpretor& theDI,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XSDRAWVRML::InitCommands(Draw_Interpretor& theDI)
|
||||
//=============================================================================
|
||||
//function : Factory
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void XSDRAWVRML::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
static Standard_Boolean initactor = Standard_False;
|
||||
if (initactor)
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user