mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +03:00
0033531: Configuration - Rework DataExchange ToolKits organization
Integrated DE plugin functionality. Reworked DE components: - TKDESTEP: Handling STEP file format. - TKDEOBJ: Handling OBJ file format. - TKDEIGES: Handling IGES file format. - TKDEGLTF: Handling GLTF file format. - TKDEVRML: Handling VRML file format. - TKDEPLY: Handling PLY file format. - TKDESTL: Handling STL file format. Reworked DE DRAW components: TKXSDRAWSTEP: Container for DE command to work with STEP. TKXSDRAWOBJ: Container for DE command to work with OBJ. TKXSDRAWIGES: Container for DE command to work with IGES. TKXSDRAWGLTF: Container for DE command to work with GLTF. TKXSDRAWVRML: Container for DE command to work with VRML. TKXSDRAWPLY: Container for DE command to work with PLY. TKXSDRAWSTL: Container for DE command to work with STL. TKXSDRAW rework to be base DRAW plugin to keep DE session and utils. Updated documentation Updated samples
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <DBRep.hxx>
|
||||
#include <Draw_Appli.hxx>
|
||||
#include <Draw_Printer.hxx>
|
||||
#include <Draw_PluginMacro.hxx>
|
||||
#include <IFSelect_Functions.hxx>
|
||||
#include <IFSelect_SessionPilot.hxx>
|
||||
#include <Interface_InterfaceModel.hxx>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <Transfer_FinderProcess.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <TransferBRep.hxx>
|
||||
#include <XSAlgo.hxx>
|
||||
#include <XSControl.hxx>
|
||||
#include <XSControl_Controller.hxx>
|
||||
#include <XSControl_FuncShape.hxx>
|
||||
@@ -39,18 +41,51 @@
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <XSDRAW.hxx>
|
||||
#include <XSDRAW_Vars.hxx>
|
||||
#include <UnitsMethods.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
//#include <XSDRAW_Shape.hxx>
|
||||
static int deja = 0, dejald = 0;
|
||||
//unused variable
|
||||
//static int okxset = 0;
|
||||
namespace
|
||||
{
|
||||
static int deja = 0, dejald = 0;
|
||||
|
||||
static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theolds;
|
||||
static Handle(TColStd_HSequenceOfAsciiString) thenews;
|
||||
static NCollection_DataMap<TCollection_AsciiString, Standard_Integer> theolds;
|
||||
static Handle(TColStd_HSequenceOfAsciiString) thenews;
|
||||
|
||||
static Handle(IFSelect_SessionPilot) thepilot; // detient Session, Model
|
||||
static Handle(IFSelect_SessionPilot) thepilot; // detient Session, Model
|
||||
|
||||
//=======================================================================
|
||||
//function : collectActiveWorkSessions
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static void collectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
|
||||
const TCollection_AsciiString& theName,
|
||||
XSControl_WorkSessionMap& theMap,
|
||||
const Standard_Boolean theIsFirst)
|
||||
{
|
||||
if (theIsFirst)
|
||||
{
|
||||
theMap.Clear();
|
||||
}
|
||||
if (theWS.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (theMap.IsBound(theName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
theMap.Bind(theName, theWS);
|
||||
for (XSControl_WorkSessionMap::Iterator anIter(theWS->Context());
|
||||
anIter.More(); anIter.Next())
|
||||
{
|
||||
Handle(XSControl_WorkSession) aWS = Handle(XSControl_WorkSession)::DownCast(anIter.Value());
|
||||
collectActiveWorkSessions(aWS, anIter.Key(), theMap, Standard_False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
@@ -104,6 +139,7 @@ static Standard_Integer XSTEPDRAWRUN (Draw_Interpretor& di, Standard_Integer arg
|
||||
IFSelect_Functions::Init();
|
||||
XSControl_Functions::Init();
|
||||
XSControl_FuncShape::Init();
|
||||
XSAlgo::Init();
|
||||
// XSDRAW_Shape::Init(); passe a present par theCommands
|
||||
return Standard_True;
|
||||
}
|
||||
@@ -167,7 +203,10 @@ void XSDRAW::LoadDraw (Draw_Interpretor& theCommands)
|
||||
Handle(IFSelect_SessionPilot) XSDRAW::Pilot ()
|
||||
{ return thepilot; }
|
||||
|
||||
Handle(XSControl_WorkSession) XSDRAW::Session ()
|
||||
void XSDRAW::SetSession(const Handle(XSControl_WorkSession)& theSession)
|
||||
{ Pilot()->SetSession(theSession); }
|
||||
|
||||
const Handle(XSControl_WorkSession) XSDRAW::Session ()
|
||||
{ return XSControl::Session(thepilot); }
|
||||
|
||||
void XSDRAW::SetController (const Handle(XSControl_Controller)& control)
|
||||
@@ -289,16 +328,71 @@ void XSDRAW::LoadDraw (Draw_Interpretor& theCommands)
|
||||
(Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name)
|
||||
{ return XSControl_FuncShape::MoreShapes (XSDRAW::Session(),list,name); }
|
||||
|
||||
|
||||
// FONCTION POUR LE DEBUG
|
||||
|
||||
Standard_Integer XSDRAW_WHAT (const Handle(Standard_Transient)& ent)
|
||||
//=======================================================================
|
||||
//function : GetLengthUnit
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real XSDRAW::GetLengthUnit(const Handle(TDocStd_Document)& theDoc)
|
||||
{
|
||||
if (ent.IsNull()) { std::cout<<"(Null Handle)"<<std::endl; return 0; }
|
||||
Handle(Interface_InterfaceModel) model = XSDRAW::Model();
|
||||
if (model.IsNull()) { std::cout<<"(No model) Type:"<<ent->DynamicType()->Name()<<std::endl; return 0; }
|
||||
std::cout<<" Num/Id :";
|
||||
model->Print (ent, std::cout, 0);
|
||||
std::cout<<" -- Recorded Type:"<<model->TypeName (ent)<<std::endl;
|
||||
return model->Number(ent);
|
||||
if (!theDoc.IsNull())
|
||||
{
|
||||
Standard_Real aUnit = 1.;
|
||||
if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit,
|
||||
UnitsMethods_LengthUnit_Millimeter))
|
||||
{
|
||||
return aUnit;
|
||||
}
|
||||
}
|
||||
if (Interface_Static::IsPresent("xstep.cascade.unit"))
|
||||
{
|
||||
UnitsMethods::SetCasCadeLengthUnit(Interface_Static::IVal("xstep.cascade.unit"));
|
||||
}
|
||||
return UnitsMethods::GetCasCadeLengthUnit();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WorkSessionList
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XSControl_WorkSessionMap& XSDRAW::WorkSessionList()
|
||||
{
|
||||
static std::shared_ptr<XSControl_WorkSessionMap> THE_PREVIOUS_WORK_SESSIONS;
|
||||
if (THE_PREVIOUS_WORK_SESSIONS == nullptr)
|
||||
{
|
||||
THE_PREVIOUS_WORK_SESSIONS =
|
||||
std::make_shared<XSControl_WorkSessionMap>();
|
||||
}
|
||||
return *THE_PREVIOUS_WORK_SESSIONS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CollectActiveWorkSessions
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAW::CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
|
||||
const TCollection_AsciiString& theName,
|
||||
XSControl_WorkSessionMap& theMap)
|
||||
{
|
||||
collectActiveWorkSessions(theWS, theName, theMap, Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CollectActiveWorkSessions
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAW::CollectActiveWorkSessions(const TCollection_AsciiString& theName)
|
||||
{
|
||||
collectActiveWorkSessions(Session(), theName, WorkSessionList(), Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Factory
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XSDRAW::Factory(Draw_Interpretor& theDI)
|
||||
{
|
||||
XSDRAW::LoadDraw(theDI);
|
||||
}
|
||||
|
||||
// Declare entry point PLUGINFACTORY
|
||||
DPLUGIN(XSDRAW)
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <TColStd_HSequenceOfTransient.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#include <TopTools_HSequenceOfShape.hxx>
|
||||
class IFSelect_SessionPilot;
|
||||
class XSControl_WorkSession;
|
||||
@@ -33,6 +34,7 @@ class Transfer_TransientProcess;
|
||||
class Transfer_FinderProcess;
|
||||
class XSControl_TransferReader;
|
||||
class TCollection_AsciiString;
|
||||
class TDocStd_Document;
|
||||
|
||||
|
||||
//! Basic package to work functions of X-STEP (IFSelect & Co)
|
||||
@@ -96,10 +98,14 @@ class XSDRAW
|
||||
|
||||
//! Returns the SessionPilot (can be used for direct call)
|
||||
Standard_EXPORT static Handle(IFSelect_SessionPilot) Pilot();
|
||||
|
||||
//! Updates the WorkSession defined in AddDraw (through Pilot)
|
||||
//! It is from XSControl, it brings functionalities for Transfers
|
||||
Standard_EXPORT static void SetSession(const Handle(XSControl_WorkSession)& theSession);
|
||||
|
||||
//! Returns the WorkSession defined in AddDraw (through Pilot)
|
||||
//! It is from XSControl, it brings functionalities for Transfers
|
||||
Standard_EXPORT static Handle(XSControl_WorkSession) Session();
|
||||
Standard_EXPORT static const Handle(XSControl_WorkSession) Session();
|
||||
|
||||
//! Defines a Controller for the command "xinit" and applies it
|
||||
//! (i.e. calls its method Customise)
|
||||
@@ -202,6 +208,30 @@ class XSDRAW
|
||||
//! completed (Append without Clear) by the Shapes found
|
||||
//! Returns 0 if no Shape could be found
|
||||
Standard_EXPORT static Standard_Integer MoreShapes (Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name);
|
||||
|
||||
//! Extracts length unit from the static interface or document.
|
||||
//! Document unit has the highest priority.
|
||||
//! @return length unit in MM. 1.0 by default
|
||||
Standard_EXPORT static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr);
|
||||
|
||||
//! Returns avaliable work sessions with their associated files.
|
||||
Standard_EXPORT static XSControl_WorkSessionMap& WorkSessionList();
|
||||
|
||||
//! Binds session and name into map recursively.
|
||||
//! Recursively means extract sub-sessions from main session.
|
||||
//! @param[in] theWS the session object
|
||||
//! @param[in] theName the session file name
|
||||
//! @param[out] theMap collection to keep session info
|
||||
Standard_EXPORT static void CollectActiveWorkSessions(const Handle(XSControl_WorkSession)& theWS,
|
||||
const TCollection_AsciiString& theName,
|
||||
XSControl_WorkSessionMap& theMap);
|
||||
|
||||
//! Binds current session with input name.
|
||||
//! @param[in] theName the session file name
|
||||
Standard_EXPORT static void CollectActiveWorkSessions(const TCollection_AsciiString& theName);
|
||||
|
||||
//! Loads all Draw commands of XSDRAW. Used for plugin.
|
||||
Standard_EXPORT static void Factory(Draw_Interpretor& theDI);
|
||||
};
|
||||
|
||||
#endif // _XSDRAW_HeaderFile
|
||||
|
Reference in New Issue
Block a user