From: dpasukhi Date: Mon, 23 Jan 2023 22:31:28 +0000 (+0000) Subject: // fixing some problems X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=22b4b9c5572656b6a59c64f112f6cae7c7821922;p=occt.git // fixing some problems updating DE Wrapper binding restoring stl mesh visualization Removing LibCtl from XSBase TK Cleaning some classes on the MoniTool folder --- diff --git a/src/DrawResources/DrawPlugin b/src/DrawResources/DrawPlugin index 7c2fac4635..1b2d64a6cb 100755 --- a/src/DrawResources/DrawPlugin +++ b/src/DrawResources/DrawPlugin @@ -33,7 +33,7 @@ DEFAULT : MODELING MODELING : TOPTEST VISUALIZATION : AISV OCAFKERNEL : DCAF -DATAEXCHANGEKERNEL : XSDRAW +DATAEXCHANGEKERNEL : XSDRAW, DEWrapper OCAF : VISUALIZATION, OCAFKERNEL DATAEXCHANGE : XDE, VISUALIZATION XDE : DATAEXCHANGEKERNEL, XDEDRAW, STEP, IGES, GLTF, OBJ, PLY, STL, VRML @@ -49,6 +49,7 @@ OPENGLES : TKOpenGlesTest D3DHOST : TKD3DHostTest XSDRAW : TKXSDRAW XDEDRAW : TKXDEDRAW +DEWrapper : TKXSDRAWDEWrapper TOBJ : TKTObjDRAW DFBROWSER : TKDFBrowser QAcommands : TKQADraw diff --git a/src/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx b/src/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx index 7a7b56fd9c..b8ddc92d9e 100644 --- a/src/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx +++ b/src/IGESData/IGESData_GlobalNodeOfSpecificLib_0.cxx @@ -25,30 +25,56 @@ #include #include - +//======================================================================= +// function : IGESData_GlobalNodeOfSpecificLib +// purpose : +//======================================================================= +IGESData_GlobalNodeOfSpecificLib::IGESData_GlobalNodeOfSpecificLib() {} +//======================================================================= +// function : Add +// purpose : +//======================================================================= +void IGESData_GlobalNodeOfSpecificLib::Add(const Handle(IGESData_SpecificModule)& amodule, + const Handle(IGESData_Protocol)& aprotocol) +{ + if (themod == amodule) return; + if (theprot == aprotocol) themod = amodule; + else if (thenext.IsNull()) + { + if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } + else + { + thenext = new IGESData_GlobalNodeOfSpecificLib; + thenext->Add(amodule, aprotocol); + } + } + else thenext->Add(amodule, aprotocol); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_SpecificModule)& IGESData_GlobalNodeOfSpecificLib::Module() const +{ + return themod; +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_GlobalNodeOfSpecificLib::Protocol() const +{ + return theprot; +} - - - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_SpecificModule) -#define TheModule IGESData_SpecificModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfSpecificLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfSpecificLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfSpecificLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfSpecificLib) -#define LibCtl_Library IGESData_SpecificLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(IGESData_GlobalNodeOfSpecificLib)& IGESData_GlobalNodeOfSpecificLib::Next() const +{ + return thenext; +} diff --git a/src/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx b/src/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx index 088825aeb0..792b82f077 100644 --- a/src/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx +++ b/src/IGESData/IGESData_GlobalNodeOfWriterLib_0.cxx @@ -25,30 +25,56 @@ #include #include - + //======================================================================= +// function : IGESData_GlobalNodeOfWriterLib +// purpose : +//======================================================================= +IGESData_GlobalNodeOfWriterLib::IGESData_GlobalNodeOfWriterLib() {} +//======================================================================= +// function : Add +// purpose : +//======================================================================= +void IGESData_GlobalNodeOfWriterLib::Add(const Handle(IGESData_ReadWriteModule)& amodule, + const Handle(IGESData_Protocol)& aprotocol) +{ + if (themod == amodule) return; + if (theprot == aprotocol) themod = amodule; + else if (thenext.IsNull()) + { + if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } + else + { + thenext = new IGESData_GlobalNodeOfWriterLib; + thenext->Add(amodule, aprotocol); + } + } + else thenext->Add(amodule, aprotocol); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_ReadWriteModule)& IGESData_GlobalNodeOfWriterLib::Module() const +{ + return themod; +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_GlobalNodeOfWriterLib::Protocol() const +{ + return theprot; +} - - - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_ReadWriteModule) -#define TheModule IGESData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfWriterLib) -#define LibCtl_Library IGESData_WriterLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(IGESData_GlobalNodeOfWriterLib)& IGESData_GlobalNodeOfWriterLib::Next() const +{ + return thenext; +} diff --git a/src/IGESData/IGESData_NodeOfSpecificLib_0.cxx b/src/IGESData/IGESData_NodeOfSpecificLib_0.cxx index 14927f2c10..3eebf4cccf 100644 --- a/src/IGESData/IGESData_NodeOfSpecificLib_0.cxx +++ b/src/IGESData/IGESData_NodeOfSpecificLib_0.cxx @@ -25,30 +25,54 @@ #include #include - +//======================================================================= +// function : IGESData_NodeOfSpecificLib +// purpose : +//======================================================================= +IGESData_NodeOfSpecificLib::IGESData_NodeOfSpecificLib() {} +//======================================================================= +// function : AddNode +// purpose : +//======================================================================= +void IGESData_NodeOfSpecificLib::AddNode(const Handle(IGESData_GlobalNodeOfSpecificLib)& anode) +{ + if (thenode == anode) return; + if (thenext.IsNull()) + { + if (thenode.IsNull()) thenode = anode; + else + { + thenext = new IGESData_NodeOfSpecificLib; + thenext->AddNode(anode); + } + } + else thenext->AddNode(anode); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_SpecificModule)& IGESData_NodeOfSpecificLib::Module() const +{ + return thenode->Module(); +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_NodeOfSpecificLib::Protocol() const +{ + return thenode->Protocol(); +} - - - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_SpecificModule) -#define TheModule IGESData_SpecificModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfSpecificLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfSpecificLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfSpecificLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfSpecificLib) -#define LibCtl_Library IGESData_SpecificLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(IGESData_NodeOfSpecificLib)& IGESData_NodeOfSpecificLib::Next() const +{ + return thenext; +} diff --git a/src/IGESData/IGESData_NodeOfWriterLib_0.cxx b/src/IGESData/IGESData_NodeOfWriterLib_0.cxx index 0ee9b8c504..613d6bc920 100644 --- a/src/IGESData/IGESData_NodeOfWriterLib_0.cxx +++ b/src/IGESData/IGESData_NodeOfWriterLib_0.cxx @@ -25,30 +25,54 @@ #include #include - +//======================================================================= +// function : IGESData_NodeOfWriterLib +// purpose : +//======================================================================= +IGESData_NodeOfWriterLib::IGESData_NodeOfWriterLib() {} +//======================================================================= +// function : AddNode +// purpose : +//======================================================================= +void IGESData_NodeOfWriterLib::AddNode(const Handle(IGESData_GlobalNodeOfWriterLib)& anode) +{ + if (thenode == anode) return; + if (thenext.IsNull()) + { + if (thenode.IsNull()) thenode = anode; + else + { + thenext = new IGESData_NodeOfWriterLib; + thenext->AddNode(anode); + } + } + else thenext->AddNode(anode); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_ReadWriteModule)& IGESData_NodeOfWriterLib::Module() const +{ + return thenode->Module(); +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_NodeOfWriterLib::Protocol() const +{ + return thenode->Protocol(); +} - - - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_ReadWriteModule) -#define TheModule IGESData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfWriterLib) -#define LibCtl_Library IGESData_WriterLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(IGESData_NodeOfWriterLib)& IGESData_NodeOfWriterLib::Next() const +{ + return thenext; +} diff --git a/src/IGESData/IGESData_SpecificLib_0.cxx b/src/IGESData/IGESData_SpecificLib_0.cxx index f91251670d..2d029674c9 100644 --- a/src/IGESData/IGESData_SpecificLib_0.cxx +++ b/src/IGESData/IGESData_SpecificLib_0.cxx @@ -23,23 +23,188 @@ #include #include #include - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_SpecificModule) -#define TheModule IGESData_SpecificModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfSpecificLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfSpecificLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfSpecificLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfSpecificLib) -#define LibCtl_Library IGESData_SpecificLib -#define LibCtl_Library_hxx -#include +static Handle(IGESData_GlobalNodeOfSpecificLib) THE_GLOBAL_NODE_OF_LIBS; + +static Handle(IGESData_Protocol) THE_GLOBAL_PROTOCOL; +static Handle(IGESData_NodeOfSpecificLib) THE_LAST_NODE_OF_LIBS; + +//======================================================================= +// function : SetGlobal +// purpose : +//======================================================================= +void IGESData_SpecificLib::SetGlobal(const Handle(IGESData_SpecificModule)& amodule, + const Handle(IGESData_Protocol)& aprotocol) +{ + if (THE_GLOBAL_NODE_OF_LIBS.IsNull()) THE_GLOBAL_NODE_OF_LIBS = new IGESData_GlobalNodeOfSpecificLib; + THE_GLOBAL_NODE_OF_LIBS->Add(amodule, aprotocol); +} + +//======================================================================= +// function : IGESData_SpecificLib +// purpose : +//======================================================================= +IGESData_SpecificLib::IGESData_SpecificLib(const Handle(IGESData_Protocol)& aprotocol) +{ + Standard_Boolean last = Standard_False; + if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE + if (!THE_GLOBAL_PROTOCOL.IsNull()) last = + (THE_GLOBAL_PROTOCOL == aprotocol); + + if (last) thelist = THE_LAST_NODE_OF_LIBS; + // Si Pas d optimisation disponible : construire la liste + else + { + AddProtocol(aprotocol); + // Ceci definit l optimisation (pour la fois suivante) + THE_LAST_NODE_OF_LIBS = thelist; + THE_GLOBAL_PROTOCOL = aprotocol; + } +} + +//======================================================================= +// function : IGESData_SpecificLib +// purpose : +//======================================================================= +IGESData_SpecificLib::IGESData_SpecificLib() {} + +//======================================================================= +// function : AddProtocol +// purpose : +//======================================================================= +void IGESData_SpecificLib::AddProtocol(const Handle(Standard_Transient)& aprotocol) +{ + // DownCast car Protocol->Resources, meme redefini et utilise dans d autres + // librairies, doit toujours renvoyer le type le plus haut + Handle(IGESData_Protocol) aproto = Handle(IGESData_Protocol)::DownCast(aprotocol); + if (aproto.IsNull()) return; + + // D abord, ajouter celui-ci a la liste : chercher le Node + Handle(IGESData_GlobalNodeOfSpecificLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + // Match Protocol ? + if (protocol->DynamicType() == aprotocol->DynamicType()) + { + if (thelist.IsNull()) thelist = new IGESData_NodeOfSpecificLib; + thelist->AddNode(curr); + break; // UN SEUL MODULE PAR PROTOCOLE + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + // Ensuite, Traiter les ressources + Standard_Integer nb = aproto->NbResources(); + for (Standard_Integer i = 1; i <= nb; i++) + { + AddProtocol(aproto->Resource(i)); + } + // Ne pas oublier de desoptimiser + THE_GLOBAL_PROTOCOL.Nullify(); + THE_LAST_NODE_OF_LIBS.Nullify(); +} + +//======================================================================= +// function : Clear +// purpose : +//======================================================================= +void IGESData_SpecificLib::Clear() +{ + thelist = new IGESData_NodeOfSpecificLib; +} + +//======================================================================= +// function : SetComplete +// purpose : +//======================================================================= +void IGESData_SpecificLib::SetComplete() +{ + thelist = new IGESData_NodeOfSpecificLib; + // On prend chacun des Protocoles de la Liste Globale et on l ajoute + Handle(IGESData_GlobalNodeOfSpecificLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + // Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! + if (!protocol.IsNull()) thelist->AddNode(curr); + curr = curr->Next(); // cette formule est refusee dans "for" + } +} + +//======================================================================= +// function : Select +// purpose : +//======================================================================= +Standard_Boolean IGESData_SpecificLib::Select(const Handle(IGESData_IGESEntity)& obj, + Handle(IGESData_SpecificModule)& module, + Standard_Integer& CN) const +{ + module.Nullify(); CN = 0; // Reponse "pas trouve" + if (thelist.IsNull()) return Standard_False; + Handle(IGESData_NodeOfSpecificLib) curr = thelist; + for (curr = thelist; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + CN = protocol->CaseNumber(obj); + if (CN > 0) + { + module = curr->Module(); + return Standard_True; + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + return Standard_False; // ici, pas trouce +} + +//======================================================================= +// function : Start +// purpose : +//======================================================================= +void IGESData_SpecificLib::Start() +{ + thecurr = thelist; +} + +//======================================================================= +// function : More +// purpose : +//======================================================================= +Standard_Boolean IGESData_SpecificLib::More() const +{ + return (!thecurr.IsNull()); +} + +//======================================================================= +// function : Next +// purpose : +//======================================================================= +void IGESData_SpecificLib::Next() +{ + if (!thecurr.IsNull()) thecurr = thecurr->Next(); +} + +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_SpecificModule)& IGESData_SpecificLib::Module() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Module(); +} + +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_SpecificLib::Protocol() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Protocol(); +} diff --git a/src/IGESData/IGESData_WriterLib_0.cxx b/src/IGESData/IGESData_WriterLib_0.cxx index af8fb61335..e2561f6523 100644 --- a/src/IGESData/IGESData_WriterLib_0.cxx +++ b/src/IGESData/IGESData_WriterLib_0.cxx @@ -23,23 +23,188 @@ #include #include #include - - -#define TheObject Handle(IGESData_IGESEntity) -#define TheObject_hxx -#define Handle_TheModule Handle(IGESData_ReadWriteModule) -#define TheModule IGESData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(IGESData_Protocol) -#define TheProtocol IGESData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode IGESData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node IGESData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(IGESData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(IGESData_NodeOfWriterLib) -#define LibCtl_Library IGESData_WriterLib -#define LibCtl_Library_hxx -#include +static Handle(IGESData_GlobalNodeOfWriterLib) THE_GLOBAL_NODE_OF_LIBS; + +static Handle(IGESData_Protocol) THE_GLOBAL_PROTOCOL; +static Handle(IGESData_NodeOfWriterLib) THE_LAST_NODE_OF_LIBS; + +//======================================================================= +// function : SetGlobal +// purpose : +//======================================================================= +void IGESData_WriterLib::SetGlobal(const Handle(IGESData_ReadWriteModule)& amodule, + const Handle(IGESData_Protocol)& aprotocol) +{ + if (THE_GLOBAL_NODE_OF_LIBS.IsNull()) THE_GLOBAL_NODE_OF_LIBS = new IGESData_GlobalNodeOfWriterLib; + THE_GLOBAL_NODE_OF_LIBS->Add(amodule, aprotocol); +} + +//======================================================================= +// function : IGESData_WriterLib +// purpose : +//======================================================================= +IGESData_WriterLib::IGESData_WriterLib(const Handle(IGESData_Protocol)& aprotocol) +{ + Standard_Boolean last = Standard_False; + if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE + if (!THE_GLOBAL_PROTOCOL.IsNull()) last = + (THE_GLOBAL_PROTOCOL == aprotocol); + + if (last) thelist = THE_LAST_NODE_OF_LIBS; + // Si Pas d optimisation disponible : construire la liste + else + { + AddProtocol(aprotocol); + // Ceci definit l optimisation (pour la fois suivante) + THE_LAST_NODE_OF_LIBS = thelist; + THE_GLOBAL_PROTOCOL = aprotocol; + } +} + +//======================================================================= +// function : IGESData_WriterLib +// purpose : +//======================================================================= +IGESData_WriterLib::IGESData_WriterLib() {} + +//======================================================================= +// function : AddProtocol +// purpose : +//======================================================================= +void IGESData_WriterLib::AddProtocol(const Handle(Standard_Transient)& aprotocol) +{ + // DownCast car Protocol->Resources, meme redefini et utilise dans d autres + // librairies, doit toujours renvoyer le type le plus haut + Handle(IGESData_Protocol) aproto = Handle(IGESData_Protocol)::DownCast(aprotocol); + if (aproto.IsNull()) return; + + // D abord, ajouter celui-ci a la liste : chercher le Node + Handle(IGESData_GlobalNodeOfWriterLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + // Match Protocol ? + if (protocol->DynamicType() == aprotocol->DynamicType()) + { + if (thelist.IsNull()) thelist = new IGESData_NodeOfWriterLib; + thelist->AddNode(curr); + break; // UN SEUL MODULE PAR PROTOCOLE + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + // Ensuite, Traiter les ressources + Standard_Integer nb = aproto->NbResources(); + for (Standard_Integer i = 1; i <= nb; i++) + { + AddProtocol(aproto->Resource(i)); + } + // Ne pas oublier de desoptimiser + THE_GLOBAL_PROTOCOL.Nullify(); + THE_LAST_NODE_OF_LIBS.Nullify(); +} + +//======================================================================= +// function : Clear +// purpose : +//======================================================================= +void IGESData_WriterLib::Clear() +{ + thelist = new IGESData_NodeOfWriterLib; +} + +//======================================================================= +// function : SetComplete +// purpose : +//======================================================================= +void IGESData_WriterLib::SetComplete() +{ + thelist = new IGESData_NodeOfWriterLib; + // On prend chacun des Protocoles de la Liste Globale et on l ajoute + Handle(IGESData_GlobalNodeOfWriterLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + // Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! + if (!protocol.IsNull()) thelist->AddNode(curr); + curr = curr->Next(); // cette formule est refusee dans "for" + } +} + +//======================================================================= +// function : Select +// purpose : +//======================================================================= +Standard_Boolean IGESData_WriterLib::Select(const Handle(IGESData_IGESEntity)& obj, + Handle(IGESData_ReadWriteModule)& module, + Standard_Integer& CN) const +{ + module.Nullify(); CN = 0; // Reponse "pas trouve" + if (thelist.IsNull()) return Standard_False; + Handle(IGESData_NodeOfWriterLib) curr = thelist; + for (curr = thelist; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(IGESData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + CN = protocol->CaseNumber(obj); + if (CN > 0) + { + module = curr->Module(); + return Standard_True; + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + return Standard_False; // ici, pas trouce +} + +//======================================================================= +// function : Start +// purpose : +//======================================================================= +void IGESData_WriterLib::Start() +{ + thecurr = thelist; +} + +//======================================================================= +// function : More +// purpose : +//======================================================================= +Standard_Boolean IGESData_WriterLib::More() const +{ + return (!thecurr.IsNull()); +} + +//======================================================================= +// function : Next +// purpose : +//======================================================================= +void IGESData_WriterLib::Next() +{ + if (!thecurr.IsNull()) thecurr = thecurr->Next(); +} + +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(IGESData_ReadWriteModule)& IGESData_WriterLib::Module() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Module(); +} + +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(IGESData_Protocol)& IGESData_WriterLib::Protocol() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Protocol(); +} diff --git a/src/Interface/Interface_GeneralLib_0.cxx b/src/Interface/Interface_GeneralLib_0.cxx index ccaa03aa4d..432ff29e4f 100644 --- a/src/Interface/Interface_GeneralLib_0.cxx +++ b/src/Interface/Interface_GeneralLib_0.cxx @@ -22,23 +22,192 @@ #include #include #include - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_GeneralModule) -#define TheModule Interface_GeneralModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfGeneralLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfGeneralLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfGeneralLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfGeneralLib) -#define LibCtl_Library Interface_GeneralLib -#define LibCtl_Library_hxx -#include +#include + +static Handle(Interface_GlobalNodeOfGeneralLib) THE_GLOBAL_NODE_OF_GEN_LIBS; + +static Handle(Interface_Protocol) THE_GLOBAL_PROTOCOL; +static Handle(Interface_NodeOfGeneralLib) THE_LAST_NODE_OF_GEN_LIBS; + +//======================================================================= +// function : SetGlobal +// purpose : +//======================================================================= +void Interface_GeneralLib::SetGlobal(const Handle(Interface_GeneralModule)& amodule, + const Handle(Interface_Protocol)& aprotocol) +{ + if (THE_GLOBAL_NODE_OF_GEN_LIBS.IsNull()) THE_GLOBAL_NODE_OF_GEN_LIBS = new Interface_GlobalNodeOfGeneralLib; + THE_GLOBAL_NODE_OF_GEN_LIBS->Add(amodule, aprotocol); +} + +//======================================================================= +// function : Interface_GeneralLib +// purpose : +//======================================================================= +Interface_GeneralLib::Interface_GeneralLib(const Handle(Interface_Protocol)& aprotocol) +{ + Standard_Boolean last = Standard_False; + if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE + if (!THE_GLOBAL_PROTOCOL.IsNull()) last = + (THE_GLOBAL_PROTOCOL == aprotocol); + + if (last) thelist = THE_LAST_NODE_OF_GEN_LIBS; + // Si Pas d optimisation disponible : construire la liste + else + { + AddProtocol(aprotocol); + // Ceci definit l optimisation (pour la fois suivante) + THE_LAST_NODE_OF_GEN_LIBS = thelist; + THE_GLOBAL_PROTOCOL = aprotocol; + } +} + +//======================================================================= +// function : Interface_GeneralLib +// purpose : +//======================================================================= +Interface_GeneralLib::Interface_GeneralLib() {} + +//======================================================================= +// function : AddProtocol +// purpose : +//======================================================================= +void Interface_GeneralLib::AddProtocol(const Handle(Standard_Transient)& aprotocol) +{ + // DownCast car Protocol->Resources, meme redefini et utilise dans d autres + // librairies, doit toujours renvoyer le type le plus haut + Handle(Interface_Protocol) aproto = Handle(Interface_Protocol)::DownCast(aprotocol); + if (aproto.IsNull()) return; + + // D abord, ajouter celui-ci a la liste : chercher le Node + Handle(Interface_GlobalNodeOfGeneralLib) curr; + for (curr = THE_GLOBAL_NODE_OF_GEN_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + // Match Protocol ? + if (protocol->DynamicType() == aprotocol->DynamicType()) + { + if (thelist.IsNull()) thelist = new Interface_NodeOfGeneralLib; + thelist->AddNode(curr); + break; // UN SEUL MODULE PAR PROTOCOLE + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + // Ensuite, Traiter les ressources + Standard_Integer nb = aproto->NbResources(); + for (Standard_Integer i = 1; i <= nb; i++) + { + AddProtocol(aproto->Resource(i)); + } + // Ne pas oublier de desoptimiser + THE_GLOBAL_PROTOCOL.Nullify(); + THE_LAST_NODE_OF_GEN_LIBS.Nullify(); +} + +//======================================================================= +// function : Clear +// purpose : +//======================================================================= +void Interface_GeneralLib::Clear() +{ + thelist = new Interface_NodeOfGeneralLib; +} + +//======================================================================= +// function : SetComplete +// purpose : +//======================================================================= +void Interface_GeneralLib::SetComplete() +{ + thelist = new Interface_NodeOfGeneralLib; + // On prend chacun des Protocoles de la Liste Globale et on l ajoute + Handle(Interface_GlobalNodeOfGeneralLib) curr; + for (curr = THE_GLOBAL_NODE_OF_GEN_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + // Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! + if (!protocol.IsNull()) thelist->AddNode(curr); + curr = curr->Next(); // cette formule est refusee dans "for" + } +} + + +//======================================================================= +// function : Select +// purpose : +//======================================================================= +Standard_Boolean Interface_GeneralLib::Select(const Handle(Standard_Transient)& obj, + Handle(Interface_GeneralModule)& module, + Standard_Integer& CN) const +{ + module.Nullify(); CN = 0; // Reponse "pas trouve" + if (thelist.IsNull()) return Standard_False; + Handle(Interface_NodeOfGeneralLib) curr = thelist; + for (curr = thelist; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + CN = protocol->CaseNumber(obj); + if (CN > 0) + { + module = curr->Module(); + return Standard_True; + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + return Standard_False; // ici, pas trouce +} + + +//======================================================================= +// function : Start +// purpose : +//======================================================================= +void Interface_GeneralLib::Start() +{ + thecurr = thelist; +} + +//======================================================================= +// function : More +// purpose : +//======================================================================= +Standard_Boolean Interface_GeneralLib::More() const +{ + return (!thecurr.IsNull()); +} + +//======================================================================= +// function : Next +// purpose : +//======================================================================= +void Interface_GeneralLib::Next() +{ + if (!thecurr.IsNull()) thecurr = thecurr->Next(); +} + +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_GeneralModule)& Interface_GeneralLib::Module() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Module(); +} + +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_GeneralLib::Protocol() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Protocol(); +} diff --git a/src/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx b/src/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx index f3d758b87c..874ddd3858 100644 --- a/src/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx +++ b/src/Interface/Interface_GlobalNodeOfGeneralLib_0.cxx @@ -25,30 +25,56 @@ #include #include - + //======================================================================= +// function : Interface_GlobalNodeOfGeneralLib +// purpose : +//======================================================================= +Interface_GlobalNodeOfGeneralLib::Interface_GlobalNodeOfGeneralLib() {} +//======================================================================= +// function : Add +// purpose : +//======================================================================= +void Interface_GlobalNodeOfGeneralLib::Add(const Handle(Interface_GeneralModule)& amodule, + const Handle(Interface_Protocol)& aprotocol) +{ + if (themod == amodule) return; + if (theprot == aprotocol) themod = amodule; + else if (thenext.IsNull()) + { + if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } + else + { + thenext = new Interface_GlobalNodeOfGeneralLib; + thenext->Add(amodule, aprotocol); + } + } + else thenext->Add(amodule, aprotocol); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_GeneralModule)& Interface_GlobalNodeOfGeneralLib::Module() const +{ + return themod; +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_GlobalNodeOfGeneralLib::Protocol() const +{ + return theprot; +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_GeneralModule) -#define TheModule Interface_GeneralModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfGeneralLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfGeneralLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfGeneralLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfGeneralLib) -#define LibCtl_Library Interface_GeneralLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(Interface_GlobalNodeOfGeneralLib)& Interface_GlobalNodeOfGeneralLib::Next() const +{ + return thenext; +} diff --git a/src/Interface/Interface_GlobalNodeOfReaderLib_0.cxx b/src/Interface/Interface_GlobalNodeOfReaderLib_0.cxx index 38ada70de6..e2f686bd65 100644 --- a/src/Interface/Interface_GlobalNodeOfReaderLib_0.cxx +++ b/src/Interface/Interface_GlobalNodeOfReaderLib_0.cxx @@ -25,30 +25,56 @@ #include #include - +//======================================================================= +// function : Interface_GlobalNodeOfReaderLib +// purpose : +//======================================================================= +Interface_GlobalNodeOfReaderLib::Interface_GlobalNodeOfReaderLib() {} +//======================================================================= +// function : Add +// purpose : +//======================================================================= +void Interface_GlobalNodeOfReaderLib::Add(const Handle(Interface_ReaderModule)& amodule, + const Handle(Interface_Protocol)& aprotocol) +{ + if (themod == amodule) return; + if (theprot == aprotocol) themod = amodule; + else if (thenext.IsNull()) + { + if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } + else + { + thenext = new Interface_GlobalNodeOfReaderLib; + thenext->Add(amodule, aprotocol); + } + } + else thenext->Add(amodule, aprotocol); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_ReaderModule)& Interface_GlobalNodeOfReaderLib::Module() const +{ + return themod; +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_GlobalNodeOfReaderLib::Protocol() const +{ + return theprot; +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_ReaderModule) -#define TheModule Interface_ReaderModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfReaderLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfReaderLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfReaderLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfReaderLib) -#define LibCtl_Library Interface_ReaderLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(Interface_GlobalNodeOfReaderLib)& Interface_GlobalNodeOfReaderLib::Next() const +{ + return thenext; +} diff --git a/src/Interface/Interface_NodeOfGeneralLib_0.cxx b/src/Interface/Interface_NodeOfGeneralLib_0.cxx index 7c7f89420e..03af2515d7 100644 --- a/src/Interface/Interface_NodeOfGeneralLib_0.cxx +++ b/src/Interface/Interface_NodeOfGeneralLib_0.cxx @@ -25,30 +25,55 @@ #include #include - +//======================================================================= +// function : Interface_NodeOfGeneralLib +// purpose : +//======================================================================= +Interface_NodeOfGeneralLib::Interface_NodeOfGeneralLib() {} +//======================================================================= +// function : AddNode +// purpose : +//======================================================================= +void Interface_NodeOfGeneralLib::AddNode(const Handle(Interface_GlobalNodeOfGeneralLib)& anode) +{ + if (thenode == anode) return; + if (thenext.IsNull()) + { + if (thenode.IsNull()) thenode = anode; + else + { + thenext = new Interface_NodeOfGeneralLib; + thenext->AddNode(anode); + } + } + else thenext->AddNode(anode); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_GeneralModule)& Interface_NodeOfGeneralLib::Module() const +{ + return thenode->Module(); +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_NodeOfGeneralLib::Protocol() const +{ + return thenode->Protocol(); +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_GeneralModule) -#define TheModule Interface_GeneralModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfGeneralLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfGeneralLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfGeneralLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfGeneralLib) -#define LibCtl_Library Interface_GeneralLib -#define LibCtl_Library_hxx -#include +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(Interface_NodeOfGeneralLib)& Interface_NodeOfGeneralLib::Next() const +{ + return thenext; +} diff --git a/src/Interface/Interface_NodeOfReaderLib_0.cxx b/src/Interface/Interface_NodeOfReaderLib_0.cxx index 8bbf93d360..ec97ec92d1 100644 --- a/src/Interface/Interface_NodeOfReaderLib_0.cxx +++ b/src/Interface/Interface_NodeOfReaderLib_0.cxx @@ -25,30 +25,54 @@ #include #include - +//======================================================================= +// function : Interface_GlobalNodeOfReaderLib +// purpose : +//======================================================================= +Interface_NodeOfReaderLib::Interface_NodeOfReaderLib() {} +//======================================================================= +// function : AddNode +// purpose : +//======================================================================= +void Interface_NodeOfReaderLib::AddNode(const Handle(Interface_GlobalNodeOfReaderLib)& anode) +{ + if (thenode == anode) return; + if (thenext.IsNull()) + { + if (thenode.IsNull()) thenode = anode; + else + { + thenext = new Interface_NodeOfReaderLib; + thenext->AddNode(anode); + } + } + else thenext->AddNode(anode); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_ReaderModule)& Interface_NodeOfReaderLib::Module() const +{ + return thenode->Module(); +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_NodeOfReaderLib::Protocol() const +{ + return thenode->Protocol(); +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_ReaderModule) -#define TheModule Interface_ReaderModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfReaderLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfReaderLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfReaderLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfReaderLib) -#define LibCtl_Library Interface_ReaderLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(Interface_NodeOfReaderLib)& Interface_NodeOfReaderLib::Next() const +{ + return thenext; +} diff --git a/src/Interface/Interface_ReaderLib_0.cxx b/src/Interface/Interface_ReaderLib_0.cxx index 3c574f2138..51b393d522 100644 --- a/src/Interface/Interface_ReaderLib_0.cxx +++ b/src/Interface/Interface_ReaderLib_0.cxx @@ -22,23 +22,190 @@ #include #include #include - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(Interface_ReaderModule) -#define TheModule Interface_ReaderModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(Interface_Protocol) -#define TheProtocol Interface_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode Interface_GlobalNodeOfReaderLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node Interface_NodeOfReaderLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(Interface_GlobalNodeOfReaderLib) -#define Handle_LibCtl_Node Handle(Interface_NodeOfReaderLib) -#define LibCtl_Library Interface_ReaderLib -#define LibCtl_Library_hxx -#include +#include + +static Handle(Interface_GlobalNodeOfReaderLib) THE_GLOBAL_NODE_OF_READ_LIBS; + +static Handle(Interface_Protocol) THE_GLOBAL_PROTOCOL; +static Handle(Interface_NodeOfReaderLib) THE_LAST_NODE_OF_READ_LIBS; + +//======================================================================= +// function : SetGlobal +// purpose : +//======================================================================= +void Interface_ReaderLib::SetGlobal(const Handle(Interface_ReaderModule)& amodule, + const Handle(Interface_Protocol)& aprotocol) +{ + if (THE_GLOBAL_NODE_OF_READ_LIBS.IsNull()) THE_GLOBAL_NODE_OF_READ_LIBS = new Interface_GlobalNodeOfReaderLib; + THE_GLOBAL_NODE_OF_READ_LIBS->Add(amodule, aprotocol); +} + +//======================================================================= +// function : Interface_ReaderLib +// purpose : +//======================================================================= +Interface_ReaderLib::Interface_ReaderLib(const Handle(Interface_Protocol)& aprotocol) +{ + Standard_Boolean last = Standard_False; + if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE + if (!THE_GLOBAL_PROTOCOL.IsNull()) last = + (THE_GLOBAL_PROTOCOL == aprotocol); + + if (last) thelist = THE_LAST_NODE_OF_READ_LIBS; + // Si Pas d optimisation disponible : construire la liste + else + { + AddProtocol(aprotocol); + // Ceci definit l optimisation (pour la fois suivante) + THE_LAST_NODE_OF_READ_LIBS = thelist; + THE_GLOBAL_PROTOCOL = aprotocol; + } +} + +//======================================================================= +// function : Interface_ReaderLib +// purpose : +//======================================================================= +Interface_ReaderLib::Interface_ReaderLib() {} + +//======================================================================= +// function : AddProtocol +// purpose : +//======================================================================= +void Interface_ReaderLib::AddProtocol(const Handle(Standard_Transient)& aprotocol) +{ + // DownCast car Protocol->Resources, meme redefini et utilise dans d autres + // librairies, doit toujours renvoyer le type le plus haut + Handle(Interface_Protocol) aproto = Handle(Interface_Protocol)::DownCast(aprotocol); + if (aproto.IsNull()) return; + + // D abord, ajouter celui-ci a la liste : chercher le Node + Handle(Interface_GlobalNodeOfReaderLib) curr; + for (curr = THE_GLOBAL_NODE_OF_READ_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + // Match Protocol ? + if (protocol->DynamicType() == aprotocol->DynamicType()) + { + if (thelist.IsNull()) thelist = new Interface_NodeOfReaderLib; + thelist->AddNode(curr); + break; // UN SEUL MODULE PAR PROTOCOLE + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + // Ensuite, Traiter les ressources + Standard_Integer nb = aproto->NbResources(); + for (Standard_Integer i = 1; i <= nb; i++) + { + AddProtocol(aproto->Resource(i)); + } + // Ne pas oublier de desoptimiser + THE_GLOBAL_PROTOCOL.Nullify(); + THE_LAST_NODE_OF_READ_LIBS.Nullify(); +} + +//======================================================================= +// function : Clear +// purpose : +//======================================================================= +void Interface_ReaderLib::Clear() +{ + thelist = new Interface_NodeOfReaderLib; +} + +//======================================================================= +// function : SetComplete +// purpose : +//======================================================================= +void Interface_ReaderLib::SetComplete() +{ + thelist = new Interface_NodeOfReaderLib; + // On prend chacun des Protocoles de la Liste Globale et on l ajoute + Handle(Interface_GlobalNodeOfReaderLib) curr; + for (curr = THE_GLOBAL_NODE_OF_READ_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + // Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! + if (!protocol.IsNull()) thelist->AddNode(curr); + curr = curr->Next(); // cette formule est refusee dans "for" + } +} + +//======================================================================= +// function : Select +// purpose : +//======================================================================= +Standard_Boolean Interface_ReaderLib::Select(const Handle(Standard_Transient)& obj, + Handle(Interface_ReaderModule)& module, + Standard_Integer& CN) const +{ + module.Nullify(); CN = 0; // Reponse "pas trouve" + if (thelist.IsNull()) return Standard_False; + Handle(Interface_NodeOfReaderLib) curr = thelist; + for (curr = thelist; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(Interface_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + CN = protocol->CaseNumber(obj); + if (CN > 0) + { + module = curr->Module(); + return Standard_True; + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + return Standard_False; // ici, pas trouce +} + +//======================================================================= +// function : Start +// purpose : +//======================================================================= +void Interface_ReaderLib::Start() +{ + thecurr = thelist; +} + +//======================================================================= +// function : More +// purpose : +//======================================================================= +Standard_Boolean Interface_ReaderLib::More() const +{ + return (!thecurr.IsNull()); +} + +//======================================================================= +// function : Next +// purpose : +//======================================================================= +void Interface_ReaderLib::Next() +{ + if (!thecurr.IsNull()) thecurr = thecurr->Next(); +} + +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(Interface_ReaderModule)& Interface_ReaderLib::Module() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Module(); +} + +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(Interface_Protocol)& Interface_ReaderLib::Protocol() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Protocol(); +} diff --git a/src/LibCtl/FILES b/src/LibCtl/FILES deleted file mode 100755 index 0f7596edf2..0000000000 --- a/src/LibCtl/FILES +++ /dev/null @@ -1,3 +0,0 @@ -LibCtl_GlobalNode.gxx -LibCtl_Library.gxx -LibCtl_Node.gxx diff --git a/src/LibCtl/LibCtl_GlobalNode.gxx b/src/LibCtl/LibCtl_GlobalNode.gxx deleted file mode 100644 index a989a1dad2..0000000000 --- a/src/LibCtl/LibCtl_GlobalNode.gxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//#include - -// Classe generique imbriquee dans Library : utilisee pour construire les -// listes globales de Modules attaches a une classe instanciee de Library -// (cf Library pour plus de details) - - -LibCtl_GlobalNode::LibCtl_GlobalNode () { } - -// ATTENTION, Add agit en substitution : pour un Protocol donne, c est le -// dernier appel qui l emporte - void LibCtl_GlobalNode::Add - (const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol) -{ - if (themod == amodule) return; - if (theprot == aprotocol) themod = amodule; - else if (thenext.IsNull()) { - if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } - else { - thenext = new LibCtl_GlobalNode; - thenext->Add (amodule,aprotocol); - } - } - else thenext->Add (amodule,aprotocol); -} - - const Handle(TheModule)& LibCtl_GlobalNode::Module () const - { return themod; } - - const Handle(TheProtocol)& LibCtl_GlobalNode::Protocol () const - { return theprot; } - - const Handle(LibCtl_GlobalNode)& LibCtl_GlobalNode::Next () const - { return thenext; } diff --git a/src/LibCtl/LibCtl_Library.gxx b/src/LibCtl/LibCtl_Library.gxx deleted file mode 100644 index d7fcef9f2b..0000000000 --- a/src/LibCtl/LibCtl_Library.gxx +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//#include -#include - - -// Liste Globale des Modules, dans laquelle on va se servir - -static Handle(LibCtl_GlobalNode) theglobal; - -// Donnees pour optimisation (dernier Protocole demande) - -static Handle(TheProtocol) theprotocol; -static Handle(LibCtl_Node) thelast; - - -// Alimentation de la liste globale -// ATTENTION : SetGlobal fait de la substitution, c-a-d que c est le dernier -// qui a raison pour un Protocol donne - void LibCtl_Library::SetGlobal - (const Handle(TheModule)& amodule, const Handle(TheProtocol)& aprotocol) -{ - if (theglobal.IsNull()) theglobal = new LibCtl_GlobalNode; - theglobal->Add(amodule,aprotocol); -} - -// Constructeur d apres Protocole - LibCtl_Library::LibCtl_Library (const Handle(TheProtocol)& aprotocol) -{ - Standard_Boolean last = Standard_False; - if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE - if (!theprotocol.IsNull()) last = - (theprotocol == aprotocol); - - if (last) thelist = thelast; -// Si Pas d optimisation disponible : construire la liste - else { - AddProtocol(aprotocol); -// Ceci definit l optimisation (pour la fois suivante) - thelast = thelist; - theprotocol = aprotocol; - } -} - -// Constructeur vide - LibCtl_Library::LibCtl_Library () { } - - -// Ajout d un Protocol : attention, desoptimise (sinon risque de confusion !) - void LibCtl_Library::AddProtocol - (const Handle(Standard_Transient)& aprotocol) -{ -// DownCast car Protocol->Resources, meme redefini et utilise dans d autres -// librairies, doit toujours renvoyer le type le plus haut - Handle(TheProtocol) aproto = Handle(TheProtocol)::DownCast(aprotocol); - if (aproto.IsNull()) return; - -// D abord, ajouter celui-ci a la liste : chercher le Node - Handle(LibCtl_GlobalNode) curr; - for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin - const Handle(TheProtocol)& protocol = curr->Protocol(); - if (!protocol.IsNull()) { -// Match Protocol ? - if (protocol->DynamicType() == aprotocol->DynamicType()) { - if (thelist.IsNull()) thelist = new LibCtl_Node; - thelist->AddNode(curr); - break; // UN SEUL MODULE PAR PROTOCOLE - } - } - curr = curr->Next(); // cette formule est refusee dans "for" - } -// Ensuite, Traiter les ressources - Standard_Integer nb = aproto->NbResources(); - for (Standard_Integer i = 1; i <= nb; i ++) { - AddProtocol (aproto->Resource(i)); - } -// Ne pas oublier de desoptimiser - theprotocol.Nullify(); - thelast.Nullify(); -} - - void LibCtl_Library::Clear () - { thelist = new LibCtl_Node; } - - void LibCtl_Library::SetComplete () -{ - thelist = new LibCtl_Node; -// On prend chacun des Protocoles de la Liste Globale et on l ajoute - Handle(LibCtl_GlobalNode) curr; - for (curr = theglobal; !curr.IsNull(); ) { // curr->Next : plus loin - const Handle(TheProtocol)& protocol = curr->Protocol(); -// Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! - if (!protocol.IsNull()) thelist->AddNode(curr); - curr = curr->Next(); // cette formule est refusee dans "for" - } -} - - -// Selection : Tres fort, on retourne le Module correspondant a un Type -// (ainsi que le CaseNumber retourne par le protocole correspondant) - - Standard_Boolean LibCtl_Library::Select - (const TheObject& obj, - Handle(TheModule)& module, Standard_Integer& CN) const -{ - module.Nullify(); CN = 0; // Reponse "pas trouve" - if (thelist.IsNull()) return Standard_False; - Handle(LibCtl_Node) curr = thelist; - for (curr = thelist; !curr.IsNull(); ) { // curr->Next : plus loin - const Handle(TheProtocol)& protocol = curr->Protocol(); - if (!protocol.IsNull()) { - CN = protocol->CaseNumber(obj); - if (CN > 0) { - module = curr->Module(); - return Standard_True; - } - } - curr = curr->Next(); // cette formule est refusee dans "for" - } - return Standard_False; // ici, pas trouce -} - - -// .... Iteration .... - - void LibCtl_Library::Start () - { thecurr = thelist; } - - Standard_Boolean LibCtl_Library::More () const - { return (!thecurr.IsNull()); } - - void LibCtl_Library::Next () - { if (!thecurr.IsNull()) thecurr = thecurr->Next(); } - - const Handle(TheModule)& LibCtl_Library::Module () const -{ - if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); - return thecurr->Module(); -} - - const Handle(TheProtocol)& LibCtl_Library::Protocol () const -{ - if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); - return thecurr->Protocol(); -} diff --git a/src/LibCtl/LibCtl_Node.gxx b/src/LibCtl/LibCtl_Node.gxx deleted file mode 100644 index 831defa677..0000000000 --- a/src/LibCtl/LibCtl_Node.gxx +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -//#include - - -// Classe generique imbriquee dans Library : utilisee pour construire la -// listes de Modules d une librairie (cf Library pour plus de details) -// (En fait : Liste de Global Nodes -> Module + Protocol) - -LibCtl_Node::LibCtl_Node () { } - - void LibCtl_Node::AddNode (const Handle(LibCtl_GlobalNode)& anode) -{ - if (thenode == anode) return; - if (thenext.IsNull()) { - if (thenode.IsNull()) thenode = anode; - else { - thenext = new LibCtl_Node; - thenext->AddNode (anode); - } - } - else thenext->AddNode (anode); -} - - - const Handle(TheModule)& LibCtl_Node::Module () const - { return thenode->Module(); } - - const Handle(TheProtocol)& LibCtl_Node::Protocol () const - { return thenode->Protocol(); } - - const Handle(LibCtl_Node)& LibCtl_Node::Next () const - { return thenext; } diff --git a/src/MoniTool/FILES b/src/MoniTool/FILES index 8e1579ecf9..368483dfd1 100755 --- a/src/MoniTool/FILES +++ b/src/MoniTool/FILES @@ -17,9 +17,6 @@ MoniTool_IndexedDataMapOfShapeTransient.hxx MoniTool_IntVal.cxx MoniTool_IntVal.hxx MoniTool_Macros.hxx -MoniTool_MTHasher.cxx -MoniTool_MTHasher.hxx -MoniTool_MTHasher.lxx MoniTool_RealVal.cxx MoniTool_RealVal.hxx MoniTool_SequenceOfElement.hxx @@ -39,6 +36,4 @@ MoniTool_TransientElem.cxx MoniTool_TransientElem.hxx MoniTool_TypedValue.cxx MoniTool_TypedValue.hxx -MoniTool_ValueInterpret.hxx -MoniTool_ValueSatisfies.hxx MoniTool_ValueType.hxx diff --git a/src/MoniTool/MoniTool_DataMapOfTimer.hxx b/src/MoniTool/MoniTool_DataMapOfTimer.hxx index 5d246c2b44..9535304198 100644 --- a/src/MoniTool/MoniTool_DataMapOfTimer.hxx +++ b/src/MoniTool/MoniTool_DataMapOfTimer.hxx @@ -18,12 +18,11 @@ #define MoniTool_DataMapOfTimer_HeaderFile #include -#include #include class MoniTool_Timer; -typedef NCollection_DataMap MoniTool_DataMapOfTimer; -typedef NCollection_DataMap::Iterator MoniTool_DataMapIteratorOfDataMapOfTimer; +typedef NCollection_DataMap MoniTool_DataMapOfTimer; +typedef NCollection_DataMap::Iterator MoniTool_DataMapIteratorOfDataMapOfTimer; #endif diff --git a/src/MoniTool/MoniTool_MTHasher.cxx b/src/MoniTool/MoniTool_MTHasher.cxx deleted file mode 100644 index 104769eae8..0000000000 --- a/src/MoniTool/MoniTool_MTHasher.cxx +++ /dev/null @@ -1,14 +0,0 @@ -// Created on: 2001-12-19 -// Created by: Sergey KUUL -// Copyright (c) 2001-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. diff --git a/src/MoniTool/MoniTool_MTHasher.hxx b/src/MoniTool/MoniTool_MTHasher.hxx deleted file mode 100644 index b314702784..0000000000 --- a/src/MoniTool/MoniTool_MTHasher.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// Created on: 2001-12-19 -// Created by: Sergey KUUL -// Copyright (c) 2001-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _MoniTool_MTHasher_HeaderFile -#define _MoniTool_MTHasher_HeaderFile - -#include -#include -#include - -#include - - - -//! The auxiliary class provides hash code for mapping objects -class MoniTool_MTHasher -{ -public: - - DEFINE_STANDARD_ALLOC - - //! Returns hash code for the given string, in the range [1, theUpperBound] - //! @param theString the string which hash code is to be computed - //! @param theUpperBound the upper bound of the range a computing hash code must be within - //! @return a computed hash code, in the range [1, theUpperBound] - static Standard_Integer HashCode (Standard_CString theString, Standard_Integer theUpperBound); - - //! Returns True when the two CString are the same. Two - //! same strings must have the same hashcode, the - //! contrary is not necessary. - //! Default Str1 == Str2 - static Standard_Boolean IsEqual (const Standard_CString Str1, const Standard_CString Str2); - - - - -protected: - - - - - -private: - - - - - -}; - - -#include - - - - - -#endif // _MoniTool_MTHasher_HeaderFile diff --git a/src/MoniTool/MoniTool_MTHasher.lxx b/src/MoniTool/MoniTool_MTHasher.lxx deleted file mode 100644 index a39f1c6d9f..0000000000 --- a/src/MoniTool/MoniTool_MTHasher.lxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -//======================================================================= -// function : HashCode -// purpose : -//======================================================================= -inline Standard_Integer MoniTool_MTHasher::HashCode (const Standard_CString theString, - const Standard_Integer theUpperBound) -{ - return ::HashCode (theString, theUpperBound); -} - -//======================================================================= -//function : IsEqual -//purpose : -//======================================================================= - -inline Standard_Boolean MoniTool_MTHasher::IsEqual(const Standard_CString Str1, - const Standard_CString Str2) -{ - return ! strcmp(Str1,Str2); -} - - diff --git a/src/MoniTool/MoniTool_TypedValue.hxx b/src/MoniTool/MoniTool_TypedValue.hxx index f5180b114c..d70ef25420 100644 --- a/src/MoniTool/MoniTool_TypedValue.hxx +++ b/src/MoniTool/MoniTool_TypedValue.hxx @@ -25,15 +25,20 @@ #include #include #include -#include -#include #include #include + class TCollection_HAsciiString; class MoniTool_TypedValue; DEFINE_STANDARD_HANDLE(MoniTool_TypedValue, Standard_Transient) +typedef Handle(TCollection_HAsciiString) (*MoniTool_ValueInterpret) (const Handle(MoniTool_TypedValue)& typval, + const Handle(TCollection_HAsciiString)& val, + const Standard_Boolean native); + +typedef Standard_Boolean(*MoniTool_ValueSatisfies) (const Handle(TCollection_HAsciiString)& val); + //! This class allows to dynamically manage .. typed values, i.e. //! values which have an alphanumeric expression, but with //! controls. Such as "must be an Integer" or "Enumerative Text" @@ -51,7 +56,7 @@ class MoniTool_TypedValue : public Standard_Transient public: - + //! Creates a TypedValue, with a name //! //! type gives the type of the parameter, default is free text @@ -62,33 +67,33 @@ public: //! init gives an initial value. If it is not given, the //! TypedValue begins as "not set", its value is empty Standard_EXPORT MoniTool_TypedValue(const Standard_CString name, const MoniTool_ValueType type = MoniTool_ValueText, const Standard_CString init = ""); - + //! Creates a TypedValue from another one, by duplication Standard_EXPORT MoniTool_TypedValue(const Handle(MoniTool_TypedValue)& other); - + //! Access to internal data which have no other access - Standard_EXPORT void Internals (MoniTool_ValueInterpret& interp, MoniTool_ValueSatisfies& satisf, Standard_CString& satisname, NCollection_DataMap& enums) const; - + Standard_EXPORT void Internals(MoniTool_ValueInterpret& interp, MoniTool_ValueSatisfies& satisf, Standard_CString& satisname, NCollection_DataMap& enums) const; + //! Returns the name Standard_EXPORT Standard_CString Name() const; - + //! Returns the type of the value Standard_EXPORT MoniTool_ValueType ValueType() const; - + //! Returns the Definition //! By priority, the enforced one, else an automatic one, computed //! from the specification Standard_EXPORT TCollection_AsciiString Definition() const; - + //! Enforces a Definition - Standard_EXPORT void SetDefinition (const Standard_CString deftext); - + Standard_EXPORT void SetDefinition(const Standard_CString deftext); + //! Prints definition, specification, and actual status and value - Standard_EXPORT virtual void Print (Standard_OStream& S) const; - + Standard_EXPORT virtual void Print(Standard_OStream& S) const; + //! Prints only the Value - Standard_EXPORT void PrintValue (Standard_OStream& S) const; - + Standard_EXPORT void PrintValue(Standard_OStream& S) const; + //! Completes the definition of a TypedValue by command , //! once created with its type //! Returns True if done, False if could not be interpreted @@ -103,109 +108,109 @@ public: //! eval text : add an enumerative value (increments max by 1) //! eval ?? : add a non-authorised enum value (to be skipped) //! tmax l : maximum length for a text - Standard_EXPORT Standard_Boolean AddDef (const Standard_CString initext); - + Standard_EXPORT Standard_Boolean AddDef(const Standard_CString initext); + //! Sets a label, which can then be displayed - Standard_EXPORT void SetLabel (const Standard_CString label); - + Standard_EXPORT void SetLabel(const Standard_CString label); + //! Returns the label, if set; else returns an empty string Standard_EXPORT Standard_CString Label() const; - + //! Sets a maximum length for a text (active only for a free text) - Standard_EXPORT void SetMaxLength (const Standard_Integer max); - + Standard_EXPORT void SetMaxLength(const Standard_Integer max); + //! Returns the maximum length, 0 if not set Standard_EXPORT Standard_Integer MaxLength() const; - + //! Sets an Integer limit (included) to , the upper limit //! if is True, the lower limit if is False - Standard_EXPORT void SetIntegerLimit (const Standard_Boolean max, const Standard_Integer val); - + Standard_EXPORT void SetIntegerLimit(const Standard_Boolean max, const Standard_Integer val); + //! Gives an Integer Limit (upper if True, lower if //! False). Returns True if this limit is defined, False else //! (in that case, gives the natural limit for Integer) - Standard_EXPORT Standard_Boolean IntegerLimit (const Standard_Boolean max, Standard_Integer& val) const; - + Standard_EXPORT Standard_Boolean IntegerLimit(const Standard_Boolean max, Standard_Integer& val) const; + //! Sets a Real limit (included) to , the upper limit //! if is True, the lower limit if is False - Standard_EXPORT void SetRealLimit (const Standard_Boolean max, const Standard_Real val); - + Standard_EXPORT void SetRealLimit(const Standard_Boolean max, const Standard_Real val); + //! Gives an Real Limit (upper if True, lower if //! False). Returns True if this limit is defined, False else //! (in that case, gives the natural limit for Real) - Standard_EXPORT Standard_Boolean RealLimit (const Standard_Boolean max, Standard_Real& val) const; - + Standard_EXPORT Standard_Boolean RealLimit(const Standard_Boolean max, Standard_Real& val) const; + //! Sets (Clears if empty) a unit definition, as an equation //! of dimensions. TypedValue just records this definition, does //! not exploit it, to be done as required by user applications - Standard_EXPORT void SetUnitDef (const Standard_CString def); - + Standard_EXPORT void SetUnitDef(const Standard_CString def); + //! Returns the recorded unit definition, empty if not set Standard_EXPORT Standard_CString UnitDef() const; - + //! For an enumeration, precises the starting value (default 0) //! and the match condition : if True (D), the string value must //! match the definition, else it may take another value : in that //! case, the Integer Value will be Start - 1. //! (empty value remains allowed) - Standard_EXPORT void StartEnum (const Standard_Integer start = 0, const Standard_Boolean match = Standard_True); - + Standard_EXPORT void StartEnum(const Standard_Integer start = 0, const Standard_Boolean match = Standard_True); + //! Adds enumerative definitions. For more than 10, several calls - Standard_EXPORT void AddEnum (const Standard_CString v1 = "", const Standard_CString v2 = "", const Standard_CString v3 = "", const Standard_CString v4 = "", const Standard_CString v5 = "", const Standard_CString v6 = "", const Standard_CString v7 = "", const Standard_CString v8 = "", const Standard_CString v9 = "", const Standard_CString v10 = ""); - + Standard_EXPORT void AddEnum(const Standard_CString v1 = "", const Standard_CString v2 = "", const Standard_CString v3 = "", const Standard_CString v4 = "", const Standard_CString v5 = "", const Standard_CString v6 = "", const Standard_CString v7 = "", const Standard_CString v8 = "", const Standard_CString v9 = "", const Standard_CString v10 = ""); + //! Adds an enumeration definition, by its string and numeric //! values. If it is the first setting for this value, it is //! recorded as main value. Else, it is recognized as alternate //! string for this numeric value - Standard_EXPORT void AddEnumValue (const Standard_CString val, const Standard_Integer num); - + Standard_EXPORT void AddEnumValue(const Standard_CString val, const Standard_Integer num); + //! Gives the Enum definitions : start value, end value, match //! status. Returns True for an Enum, False else. - Standard_EXPORT Standard_Boolean EnumDef (Standard_Integer& startcase, Standard_Integer& endcase, Standard_Boolean& match) const; - + Standard_EXPORT Standard_Boolean EnumDef(Standard_Integer& startcase, Standard_Integer& endcase, Standard_Boolean& match) const; + //! Returns the value of an enumerative definition, from its rank //! Empty string if out of range or not an Enum - Standard_EXPORT Standard_CString EnumVal (const Standard_Integer num) const; - + Standard_EXPORT Standard_CString EnumVal(const Standard_Integer num) const; + //! Returns the case number which corresponds to a string value //! Works with main and additional values //! Returns (StartEnum - 1) if not OK, -1 if not an Enum - Standard_EXPORT Standard_Integer EnumCase (const Standard_CString val) const; - + Standard_EXPORT Standard_Integer EnumCase(const Standard_CString val) const; + //! Sets type of which an Object TypedValue must be kind of //! Error for a TypedValue not an Object (Entity) - Standard_EXPORT void SetObjectType (const Handle(Standard_Type)& typ); - + Standard_EXPORT void SetObjectType(const Handle(Standard_Type)& typ); + //! Returns the type of which an Object TypedValue must be kind of //! Default is Standard_Transient //! Null for a TypedValue not an Object Standard_EXPORT Handle(Standard_Type) ObjectType() const; - + //! Sets a specific Interpret function - Standard_EXPORT void SetInterpret (const MoniTool_ValueInterpret func); - + Standard_EXPORT void SetInterpret(const MoniTool_ValueInterpret func); + //! Tells if a TypedValue has an Interpret Standard_EXPORT virtual Standard_Boolean HasInterpret() const; - + //! Sets a specific Satisfies function : it is added to the //! already defined criteria //! It must match the form : //! satisfies (val : HAsciiString) returns Boolean - Standard_EXPORT void SetSatisfies (const MoniTool_ValueSatisfies func, const Standard_CString name); - + Standard_EXPORT void SetSatisfies(const MoniTool_ValueSatisfies func, const Standard_CString name); + //! Returns name of specific satisfy, empty string if none Standard_EXPORT Standard_CString SatisfiesName() const; - + //! Returns True if the value is set (not empty/not null object) Standard_EXPORT Standard_Boolean IsSetValue() const; - + //! Returns the value, as a cstring. Empty if not set. Standard_EXPORT Standard_CString CStringValue() const; - + //! Returns the value, as a Handle (can then be shared) //! Null if not defined Standard_EXPORT Handle(TCollection_HAsciiString) HStringValue() const; - + //! Interprets a value. //! True : returns a native value //! False : returns a coded value @@ -215,22 +220,22 @@ public: //! STANDARD RETURNS : = hval means no specific interpretation //! Null means senseless //! Can also be redefined - Standard_EXPORT virtual Handle(TCollection_HAsciiString) Interpret (const Handle(TCollection_HAsciiString)& hval, const Standard_Boolean native) const; - + Standard_EXPORT virtual Handle(TCollection_HAsciiString) Interpret(const Handle(TCollection_HAsciiString)& hval, const Standard_Boolean native) const; + //! Returns True if a value statifies the specification //! (remark : does not apply to Entity : see ObjectType, for this //! type, the string is just a comment) - Standard_EXPORT virtual Standard_Boolean Satisfies (const Handle(TCollection_HAsciiString)& hval) const; - + Standard_EXPORT virtual Standard_Boolean Satisfies(const Handle(TCollection_HAsciiString)& hval) const; + //! Clears the recorded Value : it is now unset Standard_EXPORT void ClearValue(); - + //! Changes the value. The new one must satisfy the specification //! Returns False (and did not set) if the new value //! does not satisfy the specification //! Can be redefined to be managed (in a subclass) - Standard_EXPORT virtual Standard_Boolean SetCStringValue (const Standard_CString val); - + Standard_EXPORT virtual Standard_Boolean SetCStringValue(const Standard_CString val); + //! Forces a new Handle for the Value //! It can be empty, else (if Type is not free Text), it must //! satisfy the specification. @@ -240,44 +245,44 @@ public: //! Returns False (and did not set) if the new value //! does not satisfy the specification //! Can be redefined to be managed (in a subclass) - Standard_EXPORT virtual Standard_Boolean SetHStringValue (const Handle(TCollection_HAsciiString)& hval); - + Standard_EXPORT virtual Standard_Boolean SetHStringValue(const Handle(TCollection_HAsciiString)& hval); + //! Returns the value as integer, i.e. : //! For type = Integer, the integer itself; 0 if not set //! For type = Enum, the designated rank (see Enum definition) //! StartEnum - 1 if not set or not in the definition //! Else, returns 0 Standard_EXPORT Standard_Integer IntegerValue() const; - + //! Changes the value as an integer, only for Integer or Enum - Standard_EXPORT virtual Standard_Boolean SetIntegerValue (const Standard_Integer ival); - + Standard_EXPORT virtual Standard_Boolean SetIntegerValue(const Standard_Integer ival); + //! Returns the value as real, for a Real type TypedValue //! Else, returns 0. Standard_EXPORT Standard_Real RealValue() const; - + //! Changes the value as a real, only for Real - Standard_EXPORT virtual Standard_Boolean SetRealValue (const Standard_Real rval); - + Standard_EXPORT virtual Standard_Boolean SetRealValue(const Standard_Real rval); + //! Returns the value as Transient Object, only for Object/Entity //! Remark that the "HString value" is IGNORED here //! Null if not set; remains to be casted Standard_EXPORT Handle(Standard_Transient) ObjectValue() const; - + //! Same as ObjectValue, but avoids DownCast : the receiving //! variable is directly loaded. It is assumed that it complies //! with the definition of ObjectType ! Otherwise, big trouble - Standard_EXPORT void GetObjectValue (Handle(Standard_Transient)& val) const; - + Standard_EXPORT void GetObjectValue(Handle(Standard_Transient)& val) const; + //! Changes the value as Transient Object, only for Object/Entity //! Returns False if DynamicType does not satisfy ObjectType //! Can be redefined to be managed (in a subclass) - Standard_EXPORT virtual Standard_Boolean SetObjectValue (const Handle(Standard_Transient)& obj); - + Standard_EXPORT virtual Standard_Boolean SetObjectValue(const Handle(Standard_Transient)& obj); + //! Returns the type name of the ObjectValue, or an empty string //! if not set Standard_EXPORT Standard_CString ObjectTypeName() const; - + //! Adds a TypedValue in the library. //! It is recorded then will be accessed by its Name //! Its Definition may be imposed, else it is computed as usual @@ -287,34 +292,34 @@ public: //! //! If a TypedValue was already recorded under this name, it is //! replaced - Standard_EXPORT static Standard_Boolean AddLib (const Handle(MoniTool_TypedValue)& tv, const Standard_CString def = ""); - + Standard_EXPORT static Standard_Boolean AddLib(const Handle(MoniTool_TypedValue)& tv, const Standard_CString def = ""); + //! Returns the TypedValue bound with a given Name //! Null Handle if none recorded //! Warning : it is the original, not duplicated - Standard_EXPORT static Handle(MoniTool_TypedValue) Lib (const Standard_CString def); - + Standard_EXPORT static Handle(MoniTool_TypedValue) Lib(const Standard_CString def); + //! Returns a COPY of the TypedValue bound with a given Name //! Null Handle if none recorded - Standard_EXPORT static Handle(MoniTool_TypedValue) FromLib (const Standard_CString def); - + Standard_EXPORT static Handle(MoniTool_TypedValue) FromLib(const Standard_CString def); + //! Returns the list of names of items of the Library of Types //! -- Library of TypedValue as Valued Parameters, -- -- //! accessed by parameter name //! for use by management of Static Parameters Standard_EXPORT static Handle(TColStd_HSequenceOfAsciiString) LibList(); - + //! Returns a static value from its name, null if unknown - Standard_EXPORT static Handle(MoniTool_TypedValue) StaticValue (const Standard_CString name); + Standard_EXPORT static Handle(MoniTool_TypedValue) StaticValue(const Standard_CString name); - DEFINE_STANDARD_RTTIEXT(MoniTool_TypedValue,Standard_Transient) + DEFINE_STANDARD_RTTIEXT(MoniTool_TypedValue, Standard_Transient) protected: - + //! Gives the internal library of static values Standard_EXPORT static NCollection_DataMap& Stats(); diff --git a/src/MoniTool/MoniTool_ValueInterpret.hxx b/src/MoniTool/MoniTool_ValueInterpret.hxx deleted file mode 100644 index c4ac2d7a02..0000000000 --- a/src/MoniTool/MoniTool_ValueInterpret.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 2000-02-28 -// Created by: data exchange team -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef MoniTool_ValueInterpret_HeaderFile -#define MoniTool_ValueInterpret_HeaderFile - -#include - -class MoniTool_TypedValue; -typedef Handle(TCollection_HAsciiString) (*MoniTool_ValueInterpret) (const Handle(MoniTool_TypedValue)& typval, - const Handle(TCollection_HAsciiString)& val, - const Standard_Boolean native); - -#endif diff --git a/src/MoniTool/MoniTool_ValueSatisfies.hxx b/src/MoniTool/MoniTool_ValueSatisfies.hxx deleted file mode 100644 index 499d53e3f9..0000000000 --- a/src/MoniTool/MoniTool_ValueSatisfies.hxx +++ /dev/null @@ -1,23 +0,0 @@ -// Created on: 2000-02-28 -// Created by: data exchange team -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef MoniTool_ValueSatisfies_HeaderFile -#define MoniTool_ValueSatisfies_HeaderFile - -#include - -typedef Standard_Boolean (*MoniTool_ValueSatisfies) (const Handle(TCollection_HAsciiString)& val); - -#endif diff --git a/src/StepData/StepData_GlobalNodeOfWriterLib_0.cxx b/src/StepData/StepData_GlobalNodeOfWriterLib_0.cxx index f6d60688af..c8dcb57a07 100644 --- a/src/StepData/StepData_GlobalNodeOfWriterLib_0.cxx +++ b/src/StepData/StepData_GlobalNodeOfWriterLib_0.cxx @@ -25,30 +25,56 @@ #include #include - +//======================================================================= +// function : StepData_GlobalNodeOfWriterLib +// purpose : +//======================================================================= +StepData_GlobalNodeOfWriterLib::StepData_GlobalNodeOfWriterLib() {} +//======================================================================= +// function : Add +// purpose : +//======================================================================= +void StepData_GlobalNodeOfWriterLib::Add(const Handle(StepData_ReadWriteModule)& amodule, + const Handle(StepData_Protocol)& aprotocol) +{ + if (themod == amodule) return; + if (theprot == aprotocol) themod = amodule; + else if (thenext.IsNull()) + { + if (themod.IsNull()) { themod = amodule; theprot = aprotocol; } + else + { + thenext = new StepData_GlobalNodeOfWriterLib; + thenext->Add(amodule, aprotocol); + } + } + else thenext->Add(amodule, aprotocol); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(StepData_ReadWriteModule)& StepData_GlobalNodeOfWriterLib::Module() const +{ + return themod; +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(StepData_Protocol)& StepData_GlobalNodeOfWriterLib::Protocol() const +{ + return theprot; +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(StepData_ReadWriteModule) -#define TheModule StepData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(StepData_Protocol) -#define TheProtocol StepData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode StepData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node StepData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(StepData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(StepData_NodeOfWriterLib) -#define LibCtl_Library StepData_WriterLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(StepData_GlobalNodeOfWriterLib)& StepData_GlobalNodeOfWriterLib::Next() const +{ + return thenext; +} diff --git a/src/StepData/StepData_NodeOfWriterLib_0.cxx b/src/StepData/StepData_NodeOfWriterLib_0.cxx index 9113976236..3d03e4e9e8 100644 --- a/src/StepData/StepData_NodeOfWriterLib_0.cxx +++ b/src/StepData/StepData_NodeOfWriterLib_0.cxx @@ -25,30 +25,54 @@ #include #include - +//======================================================================= +// function : StepData_NodeOfWriterLib +// purpose : +//======================================================================= +StepData_NodeOfWriterLib::StepData_NodeOfWriterLib() {} +//======================================================================= +// function : AddNode +// purpose : +//======================================================================= +void StepData_NodeOfWriterLib::AddNode(const Handle(StepData_GlobalNodeOfWriterLib)& anode) +{ + if (thenode == anode) return; + if (thenext.IsNull()) + { + if (thenode.IsNull()) thenode = anode; + else + { + thenext = new StepData_NodeOfWriterLib; + thenext->AddNode(anode); + } + } + else thenext->AddNode(anode); +} +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(StepData_ReadWriteModule)& StepData_NodeOfWriterLib::Module() const +{ + return thenode->Module(); +} +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(StepData_Protocol)& StepData_NodeOfWriterLib::Protocol() const +{ + return thenode->Protocol(); +} - - - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(StepData_ReadWriteModule) -#define TheModule StepData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(StepData_Protocol) -#define TheProtocol StepData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode StepData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node StepData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(StepData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(StepData_NodeOfWriterLib) -#define LibCtl_Library StepData_WriterLib -#define LibCtl_Library_hxx -#include - +//======================================================================= +// function : Next +// purpose : +//======================================================================= +const Handle(StepData_NodeOfWriterLib)& StepData_NodeOfWriterLib::Next() const +{ + return thenext; +} diff --git a/src/StepData/StepData_WriterLib_0.cxx b/src/StepData/StepData_WriterLib_0.cxx index 99cb924975..a93ce6ce88 100644 --- a/src/StepData/StepData_WriterLib_0.cxx +++ b/src/StepData/StepData_WriterLib_0.cxx @@ -22,23 +22,188 @@ #include #include #include - - -#define TheObject Handle(Standard_Transient) -#define TheObject_hxx -#define Handle_TheModule Handle(StepData_ReadWriteModule) -#define TheModule StepData_ReadWriteModule -#define TheModule_hxx -#define Handle_TheProtocol Handle(StepData_Protocol) -#define TheProtocol StepData_Protocol -#define TheProtocol_hxx -#define LibCtl_GlobalNode StepData_GlobalNodeOfWriterLib -#define LibCtl_GlobalNode_hxx -#define LibCtl_Node StepData_NodeOfWriterLib -#define LibCtl_Node_hxx -#define Handle_LibCtl_GlobalNode Handle(StepData_GlobalNodeOfWriterLib) -#define Handle_LibCtl_Node Handle(StepData_NodeOfWriterLib) -#define LibCtl_Library StepData_WriterLib -#define LibCtl_Library_hxx -#include +static Handle(StepData_GlobalNodeOfWriterLib) THE_GLOBAL_NODE_OF_LIBS; + +static Handle(StepData_Protocol) THE_GLOBAL_PROTOCOL; +static Handle(StepData_NodeOfWriterLib) THE_LAST_NODE_OF_LIBS; + +//======================================================================= +// function : SetGlobal +// purpose : +//======================================================================= +void StepData_WriterLib::SetGlobal(const Handle(StepData_ReadWriteModule)& amodule, + const Handle(StepData_Protocol)& aprotocol) +{ + if (THE_GLOBAL_NODE_OF_LIBS.IsNull()) THE_GLOBAL_NODE_OF_LIBS = new StepData_GlobalNodeOfWriterLib; + THE_GLOBAL_NODE_OF_LIBS->Add(amodule, aprotocol); +} + +//======================================================================= +// function : StepData_WriterLib +// purpose : +//======================================================================= +StepData_WriterLib::StepData_WriterLib(const Handle(StepData_Protocol)& aprotocol) +{ + Standard_Boolean last = Standard_False; + if (aprotocol.IsNull()) return; // PAS de protocole = Lib VIDE + if (!THE_GLOBAL_PROTOCOL.IsNull()) last = + (THE_GLOBAL_PROTOCOL == aprotocol); + + if (last) thelist = THE_LAST_NODE_OF_LIBS; + // Si Pas d optimisation disponible : construire la liste + else + { + AddProtocol(aprotocol); + // Ceci definit l optimisation (pour la fois suivante) + THE_LAST_NODE_OF_LIBS = thelist; + THE_GLOBAL_PROTOCOL = aprotocol; + } +} + +//======================================================================= +// function : StepData_WriterLib +// purpose : +//======================================================================= +StepData_WriterLib::StepData_WriterLib() {} + +//======================================================================= +// function : AddProtocol +// purpose : +//======================================================================= +void StepData_WriterLib::AddProtocol(const Handle(Standard_Transient)& aprotocol) +{ + // DownCast car Protocol->Resources, meme redefini et utilise dans d autres + // librairies, doit toujours renvoyer le type le plus haut + Handle(StepData_Protocol) aproto = Handle(StepData_Protocol)::DownCast(aprotocol); + if (aproto.IsNull()) return; + + // D abord, ajouter celui-ci a la liste : chercher le Node + Handle(StepData_GlobalNodeOfWriterLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(StepData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + // Match Protocol ? + if (protocol->DynamicType() == aprotocol->DynamicType()) + { + if (thelist.IsNull()) thelist = new StepData_NodeOfWriterLib; + thelist->AddNode(curr); + break; // UN SEUL MODULE PAR PROTOCOLE + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + // Ensuite, Traiter les ressources + Standard_Integer nb = aproto->NbResources(); + for (Standard_Integer i = 1; i <= nb; i++) + { + AddProtocol(aproto->Resource(i)); + } + // Ne pas oublier de desoptimiser + THE_GLOBAL_PROTOCOL.Nullify(); + THE_LAST_NODE_OF_LIBS.Nullify(); +} + +//======================================================================= +// function : Clear +// purpose : +//======================================================================= +void StepData_WriterLib::Clear() +{ + thelist = new StepData_NodeOfWriterLib; +} + +//======================================================================= +// function : SetComplete +// purpose : +//======================================================================= +void StepData_WriterLib::SetComplete() +{ + thelist = new StepData_NodeOfWriterLib; + // On prend chacun des Protocoles de la Liste Globale et on l ajoute + Handle(StepData_GlobalNodeOfWriterLib) curr; + for (curr = THE_GLOBAL_NODE_OF_LIBS; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(StepData_Protocol)& protocol = curr->Protocol(); + // Comme on prend tout tout tout, on ne se preoccupe pas des Ressources ! + if (!protocol.IsNull()) thelist->AddNode(curr); + curr = curr->Next(); // cette formule est refusee dans "for" + } +} + +//======================================================================= +// function : Select +// purpose : +//======================================================================= +Standard_Boolean StepData_WriterLib::Select(const Handle(Standard_Transient)& obj, + Handle(StepData_ReadWriteModule)& module, + Standard_Integer& CN) const +{ + module.Nullify(); CN = 0; // Reponse "pas trouve" + if (thelist.IsNull()) return Standard_False; + Handle(StepData_NodeOfWriterLib) curr = thelist; + for (curr = thelist; !curr.IsNull(); ) + { // curr->Next : plus loin + const Handle(StepData_Protocol)& protocol = curr->Protocol(); + if (!protocol.IsNull()) + { + CN = protocol->CaseNumber(obj); + if (CN > 0) + { + module = curr->Module(); + return Standard_True; + } + } + curr = curr->Next(); // cette formule est refusee dans "for" + } + return Standard_False; // ici, pas trouce +} + +//======================================================================= +// function : Start +// purpose : +//======================================================================= +void StepData_WriterLib::Start() +{ + thecurr = thelist; +} + +//======================================================================= +// function : More +// purpose : +//======================================================================= +Standard_Boolean StepData_WriterLib::More() const +{ + return (!thecurr.IsNull()); +} + +//======================================================================= +// function : Next +// purpose : +//======================================================================= +void StepData_WriterLib::Next() +{ + if (!thecurr.IsNull()) thecurr = thecurr->Next(); +} + +//======================================================================= +// function : Module +// purpose : +//======================================================================= +const Handle(StepData_ReadWriteModule)& StepData_WriterLib::Module() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Module(); +} + +//======================================================================= +// function : Protocol +// purpose : +//======================================================================= +const Handle(StepData_Protocol)& StepData_WriterLib::Protocol() const +{ + if (thecurr.IsNull()) throw Standard_NoSuchObject("Library from LibCtl"); + return thecurr->Protocol(); +} diff --git a/src/TKXSBase/PACKAGES b/src/TKXSBase/PACKAGES index 5e726225c1..c71ff6c343 100755 --- a/src/TKXSBase/PACKAGES +++ b/src/TKXSBase/PACKAGES @@ -5,5 +5,4 @@ IFSelect TransferBRep XSControl XSAlgo -LibCtl MoniTool diff --git a/src/XDEDRAW/XDEDRAW_Common.cxx b/src/XDEDRAW/XDEDRAW_Common.cxx index e97f43d6ea..62b3a01a7b 100644 --- a/src/XDEDRAW/XDEDRAW_Common.cxx +++ b/src/XDEDRAW/XDEDRAW_Common.cxx @@ -13,31 +13,23 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include + #include #include #include #include +#include +#include #include #include #include #include -#include -#include -#include #include #include -#include -#include #include #include -#include -#include -#include -#include -#include #include -#include -#include #include #include @@ -45,11 +37,6 @@ #include #include #include -#include -#include -#include - -#include //======================================================================= //function : SetCurWS @@ -276,6 +263,10 @@ static Standard_Integer Extract(Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : InitCommands +//purpose : +//======================================================================= void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI) { static Standard_Boolean aIsActivated = Standard_False; @@ -285,16 +276,19 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI) } aIsActivated = Standard_True; - Standard_CString g = "XDE translation commands"; + DE_Wrapper::GlobalWrapper()->Bind(new DEBRepCascade_ConfigurationNode()); + DE_Wrapper::GlobalWrapper()->Bind(new DEXCAFCascade_ConfigurationNode()); + + Standard_CString aGroup = "XDE translation commands"; - theDI.Add("XFileList", "Print list of files that was transferred by the last transfer", __FILE__, GetDicWSList, g); - theDI.Add("XFileCur", ": returns name of file which is set as current", __FILE__, GetCurWS, g); - theDI.Add("XFileSet", "filename: Set the specified file to be the current one", __FILE__, SetCurWS, g); - theDI.Add("XFromShape", "shape: do fromshape command for all the files", __FILE__, FromShape, g); + theDI.Add("XFileList", "Print list of files that was transferred by the last transfer", __FILE__, GetDicWSList, aGroup); + theDI.Add("XFileCur", ": returns name of file which is set as current", __FILE__, GetCurWS, aGroup); + theDI.Add("XFileSet", "filename: Set the specified file to be the current one", __FILE__, SetCurWS, aGroup); + theDI.Add("XFromShape", "shape: do fromshape command for all the files", __FILE__, FromShape, aGroup); theDI.Add("XExpand", "XExpand Doc recursively(0/1) or XExpand Doc recursively(0/1) label1 label2 ..." - "or XExpand Doc recursively(0/1) shape1 shape2 ...", __FILE__, Expand, g); + "or XExpand Doc recursively(0/1) shape1 shape2 ...", __FILE__, Expand, aGroup); theDI.Add("XExtract", "XExtract dstDoc [dstAssmblSh] srcDoc srcLabel1 srcLabel2 ...\t" "Extracts given srcLabel1 srcLabel2 ... from srcDoc into given Doc or assembly shape", - __FILE__, Extract, g); + __FILE__, Extract, aGroup); } diff --git a/src/XSDRAWGLTF/XSDRAWGLTF.cxx b/src/XSDRAWGLTF/XSDRAWGLTF.cxx index 0c7a4531d8..68402e3712 100644 --- a/src/XSDRAWGLTF/XSDRAWGLTF.cxx +++ b/src/XSDRAWGLTF/XSDRAWGLTF.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -492,8 +494,9 @@ void XSDRAWGLTF::Factory(Draw_Interpretor& theDI) return; } aIsActivated = Standard_True; - const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands + DE_Wrapper::GlobalWrapper()->Bind(new RWGltf_ConfigurationNode()); + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands theDI.Add("ReadGltf", "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]" "\n\t\t: Read glTF file into XDE document." @@ -548,6 +551,5 @@ void XSDRAWGLTF::Factory(Draw_Interpretor& theDI) __FILE__, WriteGltf, aGroup); } - // Declare entry point PLUGINFACTORY DPLUGIN(XSDRAWGLTF) diff --git a/src/XSDRAWIGES/XSDRAWIGES.cxx b/src/XSDRAWIGES/XSDRAWIGES.cxx index 5c5e244b80..4d1ce1c29d 100644 --- a/src/XSDRAWIGES/XSDRAWIGES.cxx +++ b/src/XSDRAWIGES/XSDRAWIGES.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -40,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -890,9 +893,11 @@ void XSDRAWIGES::Factory(Draw_Interpretor& theDI) { return; } + aIsActivated = Standard_True; + IGESControl_Controller::Init(); + DE_Wrapper::GlobalWrapper()->Bind(new IGESCAFControl_ConfigurationNode()); - aIsActivated = Standard_True; const char* aGroup = "DE: IGES"; theDI.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, aGroup); diff --git a/src/XSDRAWOBJ/XSDRAWOBJ.cxx b/src/XSDRAWOBJ/XSDRAWOBJ.cxx index ad2ed00818..7d7c228975 100644 --- a/src/XSDRAWOBJ/XSDRAWOBJ.cxx +++ b/src/XSDRAWOBJ/XSDRAWOBJ.cxx @@ -13,6 +13,8 @@ #include +#include +#include #include #include #include @@ -334,7 +336,10 @@ void XSDRAWOBJ::Factory(Draw_Interpretor& theDI) return; } aIsActivated = Standard_True; - const char* g = "XSTEP-STL/VRML"; // Step transfer file commands + + DE_Wrapper::GlobalWrapper()->Bind(new RWObj_ConfigurationNode()); + + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands theDI.Add("ReadObj", "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" @@ -346,14 +351,14 @@ void XSDRAWOBJ::Factory(Draw_Interpretor& theDI) "\n\t\t: -singlePrecision truncate vertex data to single precision during read; FALSE by default." "\n\t\t: -listExternalFiles do not read mesh and only list external files." "\n\t\t: -noCreateDoc read into existing XDE document.", - __FILE__, ReadObj, g); + __FILE__, ReadObj, aGroup); theDI.Add("readobj", "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" "\n\t\t: [-singleFace]" "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document." "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.", - __FILE__, ReadObj, g); + __FILE__, ReadObj, aGroup); theDI.Add("WriteObj", "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "\n\t\t: [-systemCoordSys {Zup|Yup}]" @@ -362,10 +367,10 @@ void XSDRAWOBJ::Factory(Draw_Interpretor& theDI) "\n\t\t: -fileUnit length unit of OBJ file content;" "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified." "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.", - __FILE__, WriteObj, g); + __FILE__, WriteObj, aGroup); theDI.Add("writeobj", "writeobj shape file", - __FILE__, WriteObj, g); + __FILE__, WriteObj, aGroup); } // Declare entry point PLUGINFACTORY diff --git a/src/XSDRAWPLY/XSDRAWPLY.cxx b/src/XSDRAWPLY/XSDRAWPLY.cxx index 6007da172d..6ae126dca9 100644 --- a/src/XSDRAWPLY/XSDRAWPLY.cxx +++ b/src/XSDRAWPLY/XSDRAWPLY.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -333,7 +335,10 @@ void XSDRAWPLY::Factory(Draw_Interpretor& theDI) return; } aIsActivated = Standard_True; - const char* g = "XSTEP-STL/VRML"; // Step transfer file commands + + DE_Wrapper::GlobalWrapper()->Bind(new RWPly_ConfigurationNode()); + + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands //XSDRAW::LoadDraw(theCommands); theDI.Add("WritePly", R"( WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0 @@ -350,10 +355,10 @@ Generate point cloud out of the shape and write it into PLY file. -distance sets distance from shape into the range [0, Value]; -density sets density of points to generate randomly on surface; -tolerance sets tolerance; default value is Precision::Confusion(); -)", __FILE__, WritePly, g); +)", __FILE__, WritePly, aGroup); theDI.Add("writeply", "writeply shape file", - __FILE__, WritePly, g); + __FILE__, WritePly, aGroup); } // Declare entry point PLUGINFACTORY diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index e1ad60d43e..4db98351ae 100644 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -905,21 +907,24 @@ void XSDRAWSTEP::Factory(Draw_Interpretor& theDI) return; } aIsActivated = Standard_True; - const char* g = "DE: STEP"; // Step transfer file commands - theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); + + DE_Wrapper::GlobalWrapper()->Bind(new STEPCAFControl_ConfigurationNode()); + + const char* aGroup = "DE: STEP"; // Step transfer file commands + theDI.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, aGroup); theDI.Add("testwritestep", "testwritestep filename.stp shape [-stream]", - __FILE__, testwrite, g); - 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); + __FILE__, testwrite, aGroup); + theDI.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, aGroup); + theDI.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, aGroup); + theDI.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, aGroup); + theDI.Add("countexpected", "TEST", __FILE__, countexpected, aGroup); + theDI.Add("dumpassembly", "TEST", __FILE__, dumpassembly, aGroup); + theDI.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, aGroup); theDI.Add("ReadStep", "Doc filename [mode] [-stream]" "\n\t\t: Read STEP file to a document." "\n\t\t: -stream read using istream reading interface (testing)", - __FILE__, ReadStep, g); + __FILE__, ReadStep, aGroup); theDI.Add("WriteStep", "Doc filename [mode=a [multifile_prefix] [label]] [-stream]" "\n\t\t: Write DECAF document to STEP file" @@ -930,7 +935,7 @@ void XSDRAWSTEP::Factory(Draw_Interpretor& theDI) "\n\t\t: and defines common prefix for their names" "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly" "\n\t\t: -stream read using ostream writing interface (testing)", - __FILE__, WriteStep, g); + __FILE__, WriteStep, aGroup); } // Declare entry point PLUGINFACTORY diff --git a/src/XSDRAWSTL/FILES b/src/XSDRAWSTL/FILES index b8b27c62b0..7a964554ac 100644 --- a/src/XSDRAWSTL/FILES +++ b/src/XSDRAWSTL/FILES @@ -1,2 +1,8 @@ XSDRAWSTL.cxx XSDRAWSTL.hxx +XSDRAWSTL_DataSource.cxx +XSDRAWSTL_DataSource.hxx +XSDRAWSTL_DataSource3D.cxx +XSDRAWSTL_DataSource3D.hxx +XSDRAWSTL_DrawableMesh.cxx +XSDRAWSTL_DrawableMesh.hxx \ No newline at end of file diff --git a/src/XSDRAWSTL/XSDRAWSTL.cxx b/src/XSDRAWSTL/XSDRAWSTL.cxx index b929ca79c7..fdc498ba46 100644 --- a/src/XSDRAWSTL/XSDRAWSTL.cxx +++ b/src/XSDRAWSTL/XSDRAWSTL.cxx @@ -13,21 +13,45 @@ #include +#include #include #include #include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include +#include +#include +#include +#include +#include #include #include +#include #include +extern Standard_Boolean VDisplayAISObject(const TCollection_AsciiString& theName, + const Handle(AIS_InteractiveObject)& theAISObj, + Standard_Boolean theReplaceIfExists = Standard_True); + //============================================================================= //function : writestl //purpose : @@ -163,6 +187,1065 @@ static Standard_Integer readstl(Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : createmesh +//purpose : +//======================================================================= +static Standard_Integer createmesh(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use: " << theArgVec[0] << " \n"; + return 0; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + theDI << "No active view. Please call 'vinit' first\n"; + return 0; + } + + // Progress indicator + OSD_Path aFile(theArgVec[2]); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(aFile, aProgress->Start()); + + theDI << "Reading OK...\n"; + Handle(XSDRAWSTL_DataSource) aDS = new XSDRAWSTL_DataSource(aSTLMesh); + theDI << "Data source is created successful\n"; + Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh(); + theDI << "MeshVS_Mesh is created successful\n"; + + aMesh->SetDataSource(aDS); + aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True); + + aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW); + + // Hide all nodes by default + Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger(); + const Standard_Integer aLen = aSTLMesh->NbNodes(); + for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) + aNodes->ChangeMap().Add(anIndex); + aMesh->SetHiddenNodes(aNodes); + aMesh->SetSelectableNodes(aNodes); + + VDisplayAISObject(theArgVec[1], aMesh); + aContext->Deactivate(aMesh); + + Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh)); + Handle(V3d_View) aView = ViewerTest::CurrentView(); + if (!aView.IsNull()) + aView->FitAll(); + + return 0; +} + +//======================================================================= +//function : create3d +//purpose : +//======================================================================= +static Standard_Integer create3d(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use: " << theArgVec[0] << " \n"; + return 0; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + theDI << "No active view. Please call 'vinit' first\n"; + return 0; + } + + Handle(XSDRAWSTL_DataSource3D) aDS = new XSDRAWSTL_DataSource3D(); + theDI << "Data source is created successful\n"; + Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh(); + theDI << "MeshVS_Mesh is created successful\n"; + + aMesh->SetDataSource(aDS); + aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True); + + aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW); + + // Hide all nodes by default + Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger(); + Standard_Integer aLen = aDS->GetAllNodes().Extent(); + for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) + aNodes->ChangeMap().Add(anIndex); + aMesh->SetHiddenNodes(aNodes); + aMesh->SetSelectableNodes(aNodes); + + VDisplayAISObject(theArgVec[1], aMesh); + aContext->Deactivate(aMesh); + + Draw::Set(theArgVec[1], new XSDRAWSTL_DrawableMesh(aMesh)); + Handle(V3d_View) aView = ViewerTest::CurrentView(); + if (!aView.IsNull()) + aView->FitAll(); + + return 0; +} + +//======================================================================= +//function : getMesh +//purpose : +//======================================================================= +Handle(MeshVS_Mesh) getMesh(const char* theName, + Draw_Interpretor& theDI) +{ + Handle(XSDRAWSTL_DrawableMesh) aDrawMesh = + Handle(XSDRAWSTL_DrawableMesh)::DownCast(Draw::Get(theName)); + + if (aDrawMesh.IsNull()) + { + theDI << "There is no such object\n"; + return NULL; + } + else + { + Handle(MeshVS_Mesh) aMesh = aDrawMesh->GetMesh(); + if (aMesh.IsNull()) + { + theDI << "There is invalid mesh\n"; + return NULL; + } + else + return aMesh; + } +} + +//======================================================================= +//function : setcolor +//purpose : +//======================================================================= +static Standard_Integer setcolor(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec, + Standard_Integer theParam) +{ + if (theNbArgs < 5) + theDI << "Wrong number of parameters\n"; + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (!aMesh.IsNull()) + { + Standard_Real aRed = Draw::Atof(theArgVec[2]); + Standard_Real aGreen = Draw::Atof(theArgVec[3]); + Standard_Real aBlue = Draw::Atof(theArgVec[4]); + aMesh->GetDrawer()->SetColor((MeshVS_DrawerAttribute)theParam, + Quantity_Color(aRed, aGreen, aBlue, Quantity_TOC_RGB)); + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + aContext->Redisplay(aMesh, Standard_True); + } + } + return 0; +} + +//======================================================================= +//function : meshcolor +//purpose : +//======================================================================= +static Standard_Integer meshcolor(Draw_Interpretor& theInterp, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_InteriorColor); +} + +//======================================================================= +//function : linecolor +//purpose : +//======================================================================= +static Standard_Integer linecolor(Draw_Interpretor& theInterp, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_EdgeColor); +} + +//======================================================================= +//function : meshmat +//purpose : +//======================================================================= +static Standard_Integer meshmat(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + theDI << "Wrong number of parameters\n"; + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (!aMesh.IsNull()) + { + Standard_Integer aMaterial = Draw::Atoi(theArgVec[2]); + + Graphic3d_MaterialAspect aMatAsp = + (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial; + + if (theNbArgs == 4) + { + Standard_Real aTransparency = Draw::Atof(theArgVec[3]); + aMatAsp.SetTransparency(Standard_ShortReal(aTransparency)); + } + aMesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, aMatAsp); + aMesh->GetDrawer()->SetMaterial(MeshVS_DA_BackMaterial, aMatAsp); + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + aContext->Redisplay(aMesh, Standard_True); + } + } + return 0; +} + +//======================================================================= +//function : shrink +//purpose : +//======================================================================= +static Standard_Integer shrink(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + theDI << "Wrong number of parameters\n"; + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (!aMesh.IsNull()) + { + Standard_Real aShrinkCoeff = Draw::Atof(theArgVec[2]); + aMesh->GetDrawer()->SetDouble(MeshVS_DA_ShrinkCoeff, aShrinkCoeff); + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + aContext->Redisplay(aMesh, Standard_True); + } + } + return 0; +} + +//======================================================================= +//function : closed +//purpose : +//======================================================================= +static Standard_Integer closed(Draw_Interpretor& theDI, + Standard_Integer theArgc, + const char** theArgv) +{ + if (theArgc < 3) + { + theDI << "Wrong number of parameters.\n"; + } + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgv[1], theDI); + if (!aMesh.IsNull()) + { + Standard_Boolean aFlag = Draw::Atoi(theArgv[2]) != 0; + aMesh->GetDrawer()->SetBoolean(MeshVS_DA_SupressBackFaces, aFlag); + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + if (aContext.IsNull()) + { + theDI << "The context is null\n"; + } + else + { + aContext->Redisplay(aMesh, Standard_True); + } + } + } + return 0; +} + +//======================================================================= +//function : mdisplay +//purpose : +//======================================================================= +static Standard_Integer mdisplay(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + theDI << "Wrong number of parameters\n"; + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (!aMesh.IsNull()) + { + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + { + aContext->Display(aMesh, Standard_True); + } + } + } + return 0; +} + +//======================================================================= +//function : merase +//purpose : +//======================================================================= +static Standard_Integer merase(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + theDI << "Wrong number of parameters\n"; + else + { + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (!aMesh.IsNull()) + { + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + { + aContext->Erase(aMesh, Standard_True); + } + } + else + theDI << "Mesh is null\n"; + } + return 0; +} + +//======================================================================= +//function : hidesel +//purpose : +//======================================================================= +static Standard_Integer hidesel(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use: " << theArgVec[0] << " \n"; + return 0; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (aMesh.IsNull()) + { + theDI << "The mesh is invalid\n"; + return 0; + } + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + { + Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes(); + if (aHiddenNodes.IsNull()) + { + aHiddenNodes = new TColStd_HPackedMapOfInteger(); + } + Handle(TColStd_HPackedMapOfInteger) aHiddenElements = aMesh->GetHiddenElems(); + if (aHiddenElements.IsNull()) + { + aHiddenElements = new TColStd_HPackedMapOfInteger(); + } + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) + { + Handle(MeshVS_MeshEntityOwner) anOwner = + Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner()); + if (!anOwner.IsNull()) + { + if (anOwner->Type() == MeshVS_ET_Node) + { + aHiddenNodes->ChangeMap().Add(anOwner->ID()); + } + else + { + aHiddenElements->ChangeMap().Add(anOwner->ID()); + } + } + } + aContext->ClearSelected(Standard_False); + aMesh->SetHiddenNodes(aHiddenNodes); + aMesh->SetHiddenElems(aHiddenElements); + aContext->Redisplay(aMesh, Standard_True); + } + + return 0; +} + +//======================================================================= +//function : showonly +//purpose : +//======================================================================= +static Standard_Integer showonly(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use: " << theArgVec[0] << " \n"; + return 0; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (aMesh.IsNull()) + { + theDI << "The mesh is invalid\n"; + return 0; + } + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + { + Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = + new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes()); + Handle(TColStd_HPackedMapOfInteger) aHiddenElements = + new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements()); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) + { + Handle(MeshVS_MeshEntityOwner) anOwner = + Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner()); + if (!anOwner.IsNull()) + { + if (anOwner->Type() == MeshVS_ET_Node) + { + aHiddenNodes->ChangeMap().Remove(anOwner->ID()); + } + else + { + aHiddenElements->ChangeMap().Remove(anOwner->ID()); + } + } + } + aMesh->SetHiddenNodes(aHiddenNodes); + aMesh->SetHiddenElems(aHiddenElements); + aContext->Redisplay(aMesh, Standard_True); + } + + return 0; +} + +//======================================================================= +//function : showonly +//purpose : +//======================================================================= +static Standard_Integer showall(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use: " << theArgVec[0] << " \n"; + return 0; + } + + Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (aMesh.IsNull()) + { + theDI << "The mesh is invalid\n"; + return 0; + } + + if (aContext.IsNull()) + theDI << "The context is null\n"; + else + { + aMesh->SetHiddenNodes(new TColStd_HPackedMapOfInteger()); + aMesh->SetHiddenElems(new TColStd_HPackedMapOfInteger()); + aContext->Redisplay(aMesh, Standard_True); + } + + return 0; +} + +//======================================================================= +//function : meshcolors +//purpose : +//======================================================================= +static Standard_Integer meshcolors(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + try + { + OCC_CATCH_SIGNALS + if (theNbArgs < 4) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use : meshcolors \n"; + theDI << "mode : {elem1|elem2|nodal|nodaltex|none}\n"; + theDI << " elem1 - different color for each element\n"; + theDI << " elem2 - one color for one side\n"; + theDI << " nodal - different color for each node\n"; + theDI << " nodaltex - different color for each node with texture interpolation\n"; + theDI << " none - clear\n"; + theDI << "isreflect : {0|1} \n"; + + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); + if (anIC.IsNull()) + { + theDI << "The context is null\n"; + return 0; + } + if (!aMesh.IsNull()) + { + TCollection_AsciiString aMode = TCollection_AsciiString(theArgVec[2]); + Quantity_Color aColor1(Quantity_NOC_BLUE1); + Quantity_Color aColor2(Quantity_NOC_RED1); + if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none")) + { + Handle(MeshVS_PrsBuilder) aTempBuilder; + Standard_Integer aReflection = Draw::Atoi(theArgVec[3]); + + for (Standard_Integer aCount = 0; aCount < aMesh->GetBuildersCount(); aCount++) + { + aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder"); + if (!aTempBuilder.IsNull()) + aMesh->RemoveBuilderById(aTempBuilder->GetId()); + + aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder"); + if (!aTempBuilder.IsNull()) + aMesh->RemoveBuilderById(aTempBuilder->GetId()); + } + + if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2")) + { + Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder( + aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask); + // Color + const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements(); + + if (aMode.IsEqual("elem1")) + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements); + anIter.More(); anIter.Next()) + { + Quantity_Color aColor((Quantity_NameOfColor)(anIter.Key() % Quantity_NOC_WHITE)); + aBuilder->SetColor1(anIter.Key(), aColor); + } + else + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllElements); + anIter.More(); anIter.Next()) + { + aBuilder->SetColor2(anIter.Key(), aColor1, aColor2); + } + + aMesh->AddBuilder(aBuilder, Standard_True); + } + + if (aMode.IsEqual("nodal")) + { + Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( + aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask); + aMesh->AddBuilder(aBuilder, Standard_True); + + // Color + const TColStd_PackedMapOfInteger& anAllNodes = + aMesh->GetDataSource()->GetAllNodes(); + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllNodes); + anIter.More(); anIter.Next()) + { + Quantity_Color aColor((Quantity_NameOfColor)( + anIter.Key() % Quantity_NOC_WHITE)); + aBuilder->SetColor(anIter.Key(), aColor); + } + aMesh->AddBuilder(aBuilder, Standard_True); + } + + if (aMode.IsEqual("nodaltex")) + { + // assign nodal builder to the mesh + Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( + aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask); + aMesh->AddBuilder(aBuilder, Standard_True); + aBuilder->UseTexture(Standard_True); + + // prepare color map for texture + Aspect_SequenceOfColor aColorMap; + aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_RED); + aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_YELLOW); + aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_BLUE1); + + // prepare scale map for mesh - it will be assigned to mesh as texture coordinates + // make mesh color interpolated from minimum X coord to maximum X coord + Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource(); + Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ; + + // get bounding box for calculations + aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ); + Standard_Real aDelta = aMaxX - aMinX; + + // assign color scale map values (0..1) to nodes + TColStd_DataMapOfIntegerReal aScaleMap; + TColStd_Array1OfReal aCoords(1, 3); + Standard_Integer aNbNodes; + MeshVS_EntityType aType; + + // iterate nodes + const TColStd_PackedMapOfInteger& anAllNodes = + aMesh->GetDataSource()->GetAllNodes(); + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllNodes); + anIter.More(); anIter.Next()) + { + //get node coordinates to aCoord variable + aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType); + + Standard_Real aScaleValue; + try + { + OCC_CATCH_SIGNALS + aScaleValue = (aCoords.Value(1) - (Standard_Real)aMinX) / aDelta; + } + catch (Standard_Failure const&) + { + aScaleValue = 0; + } + + aScaleMap.Bind(anIter.Key(), aScaleValue); + } + + //set color map for builder and a color for invalid scale value + aBuilder->SetColorMap(aColorMap); + aBuilder->SetInvalidColor(Quantity_NOC_BLACK); + aBuilder->SetTextureCoords(aScaleMap); + aMesh->AddBuilder(aBuilder, Standard_True); + } + + aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, aReflection != 0); + + anIC->Redisplay(aMesh, Standard_True); + } + else + { + theDI << "Wrong mode name\n"; + return 0; + } + } + } + catch (Standard_Failure const&) + { + theDI << "Error\n"; + } + + return 0; +} + +//======================================================================= +//function : meshvectors +//purpose : +//======================================================================= +static Standard_Integer meshvectors(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use : meshvectors < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n"; + theDI << "Supported mode values:\n"; + theDI << " elem - vector per element\n"; + theDI << " nodal - vector per node\n"; + theDI << " none - clear\n"; + + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); + if (anIC.IsNull()) + { + theDI << "The context is null\n"; + return 0; + } + + TCollection_AsciiString aParam; + TCollection_AsciiString aMode("none"); + Standard_Real aMaxlen(1.0); + Quantity_Color aColor(Quantity_NOC_ORANGE); + Standard_Real anArrowPart(0.1); + Standard_Boolean isSimplePrs(Standard_False); + + for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++) + { + if (!aParam.IsEmpty()) + { + if (aParam == "-mode") + { + aMode = theArgVec[anIdx]; + } + else if (aParam == "-maxlen") + { + aMaxlen = Draw::Atof(theArgVec[anIdx]); + } + else if (aParam == "-color") + { + if (!Quantity_Color::ColorFromName(theArgVec[anIdx], aColor)) + { + theDI << "Syntax error at " << aParam << "\n"; + return 1; + } + } + else if (aParam == "-arrowpart") + { + anArrowPart = Draw::Atof(theArgVec[anIdx]); + } + else if (aParam == "-issimple") + { + isSimplePrs = Draw::Atoi(theArgVec[anIdx]) != 0; + } + aParam.Clear(); + } + else if (theArgVec[anIdx][0] == '-') + { + aParam = theArgVec[anIdx]; + } + } + + if (!aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none")) + { + theDI << "Wrong mode name\n"; + return 0; + } + + Handle(MeshVS_PrsBuilder) aTempBuilder; + + aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder"); + if (!aTempBuilder.IsNull()) + aMesh->RemoveBuilderById(aTempBuilder->GetId()); + + if (!aMode.IsEqual("none")) + { + Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder(aMesh.operator->(), + aMaxlen, + aColor, + MeshVS_DMF_VectorDataPrs, + 0, + -1, + MeshVS_BP_Vector, + isSimplePrs); + + Standard_Boolean anIsElement = aMode.IsEqual("elem"); + const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() : + aMesh->GetDataSource()->GetAllNodes(); + + Standard_Integer aNbNodes; + MeshVS_EntityType aEntType; + + TColStd_Array1OfReal aCoords(1, 3); + aCoords.Init(0.); + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllIDs); + anIter.More(); anIter.Next()) + { + Standard_Boolean IsValidData = Standard_False; + if (anIsElement) + { + aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType); + if (aEntType == MeshVS_ET_Face) + IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); + } + else + IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); + + gp_Vec aNorm; + if (IsValidData) + { + aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); + if (aNorm.Magnitude() < gp::Resolution()) + { + aNorm = gp_Vec(0, 0, 1); //method GetGeom(...) returns coordinates of nodes + } + } + else + { + aNorm = gp_Vec(0, 0, 1); + } + aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized()); + } + + aMesh->AddBuilder(aBuilder, Standard_False); + aMesh->GetDrawer()->SetDouble(MeshVS_DA_VectorArrowPart, anArrowPart); + } + + anIC->Redisplay(aMesh, Standard_True); + + return 0; +} + +//======================================================================= +//function : meshtext +//purpose : +//======================================================================= +static Standard_Integer meshtext(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 2) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use : meshtext \n"; + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + + Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); + if (anIC.IsNull()) + { + theDI << "The context is null\n"; + return 0; + } + + // Prepare triangle labels + MeshVS_DataMapOfIntegerAsciiString aLabels; + Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent(); + for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) + { + aLabels.Bind(anIndex, TCollection_AsciiString(anIndex)); + } + + Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder(aMesh.operator->(), 20., Quantity_NOC_YELLOW); + aTextBuilder->SetTexts(Standard_True, aLabels); + aMesh->AddBuilder(aTextBuilder); + + return 0; +} + +//======================================================================= +//function : meshdeform +//purpose : +//======================================================================= +static Standard_Integer meshdeform(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use : meshdeform < -mode {on|off} > [-scale scalefactor]\n"; + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); + if (anIC.IsNull()) + { + theDI << "The context is null\n"; + return 0; + } + + TCollection_AsciiString aParam; + TCollection_AsciiString aMode("off"); + Standard_Real aScale(1.0); + + for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++) + { + if (!aParam.IsEmpty()) + { + if (aParam == "-mode") + { + aMode = theArgVec[anIdx]; + } + else if (aParam == "-scale") + { + aScale = Draw::Atof(theArgVec[anIdx]); + } + aParam.Clear(); + } + else if (theArgVec[anIdx][0] == '-') + { + aParam = theArgVec[anIdx]; + } + } + + if (!aMode.IsEqual("on") && !aMode.IsEqual("off")) + { + theDI << "Wrong mode name\n"; + return 0; + } + + Handle(MeshVS_DeformedDataSource) aDefDS = + new MeshVS_DeformedDataSource(aMesh->GetDataSource(), aScale); + + const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes(); + + Standard_Integer aNbNodes; + MeshVS_EntityType aEntType; + + for (TColStd_PackedMapOfInteger::Iterator anIter(anAllIDs); + anIter.More(); anIter.Next()) + { + TColStd_Array1OfReal aCoords(1, 3); + aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); + + gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); + if (!aNorm.Magnitude()) + aNorm = gp_Vec(0, 0, 1); + aDefDS->SetVector(anIter.Key(), aNorm.Normalized()); + } + + aMesh->SetDataSource(aDefDS); + + anIC->Redisplay(aMesh, Standard_False); + + Handle(V3d_View) aView = ViewerTest::CurrentView(); + if (!aView.IsNull()) + aView->FitAll(); + + return 0; +} + +//======================================================================= +//function : mesh_edge_width +//purpose : +//======================================================================= +static Standard_Integer mesh_edge_width(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + try + { + OCC_CATCH_SIGNALS + if (theNbArgs < 3) + { + theDI << "Wrong number of parameters\n"; + theDI << "Use : mesh_edge_width \n"; + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + + const char* aWidthStr = theArgVec[2]; + if (aWidthStr == 0 || Draw::Atof(aWidthStr) <= 0) + { + theDI << "Width must be real value more than zero\n"; + return 0; + } + + double aWidth = Draw::Atof(aWidthStr); + + Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); + if (anIC.IsNull()) + { + theDI << "The context is null\n"; + return 0; + } + + Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer(); + if (aDrawer.IsNull()) + { + theDI << "The drawer is null\n"; + return 0; + } + + aDrawer->SetDouble(MeshVS_DA_EdgeWidth, aWidth); + anIC->Redisplay(aMesh, Standard_True); + } + catch (Standard_Failure const&) + { + theDI << "Error\n"; + } + + return 0; +} + +//======================================================================= +//function : meshinfo +//purpose : +//======================================================================= +static Standard_Integer meshinfo(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs != 2) + { + theDI << "Wrong number of parameters. Use : meshinfo mesh\n"; + return 0; + } + + Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); + if (aMesh.IsNull()) + { + theDI << "Mesh not found\n"; + return 0; + } + + Handle(XSDRAWSTL_DataSource) stlMeshSource = Handle(XSDRAWSTL_DataSource)::DownCast(aMesh->GetDataSource()); + if (!stlMeshSource.IsNull()) + { + const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes(); + const TColStd_PackedMapOfInteger& tris = stlMeshSource->GetAllElements(); + + theDI << "Nb nodes = " << nodes.Extent() << "\n"; + theDI << "Nb triangles = " << tris.Extent() << "\n"; + } + + return 0; +} + //============================================================================= //function : Factory //purpose : @@ -175,9 +1258,12 @@ void XSDRAWSTL::Factory(Draw_Interpretor& theDI) return; } aIsActivated = Standard_True; - const char* g = "XSTEP-STL/VRML"; // Step transfer file commands - theDI.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, g); + DE_Wrapper::GlobalWrapper()->Bind(new RWStl_ConfigurationNode()); + + const char* aGroup = "XSTEP-STL/VRML"; // Step transfer file commands + + theDI.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, aGroup); theDI.Add("readstl", "readstl shape file [-brep] [-mergeAngle Angle] [-multi]" "\n\t\t: Reads STL file and creates a new shape with specified name." @@ -185,7 +1271,26 @@ void XSDRAWSTL::Factory(Draw_Interpretor& theDI) "\n\t\t: Single triangulation-only Face is created otherwise (default)." "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default." "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.", - __FILE__, readstl, g); + __FILE__, readstl, aGroup); + + theDI.Add("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, aGroup); + theDI.Add("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, aGroup); + theDI.Add("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, aGroup); + theDI.Add("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, aGroup); + theDI.Add("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, aGroup); + theDI.Add("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, aGroup); + theDI.Add("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, aGroup); + theDI.Add("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, aGroup); + theDI.Add("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, aGroup); + theDI.Add("meshhidesel", "hide selected entities", __FILE__, hidesel, aGroup); + theDI.Add("meshshowsel", "show only selected entities", __FILE__, showonly, aGroup); + theDI.Add("meshshowall", "show all entities", __FILE__, showall, aGroup); + theDI.Add("meshcolors", "display color presentation", __FILE__, meshcolors, aGroup); + theDI.Add("meshvectors", "display sample vectors", __FILE__, meshvectors, aGroup); + theDI.Add("meshtext", "display text labels", __FILE__, meshtext, aGroup); + theDI.Add("meshdeform", "display deformed mesh", __FILE__, meshdeform, aGroup); + theDI.Add("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, aGroup); + theDI.Add("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, aGroup); } // Declare entry point PLUGINFACTORY diff --git a/src/XSDRAWSTL/XSDRAWSTL_DataSource.cxx b/src/XSDRAWSTL/XSDRAWSTL_DataSource.cxx new file mode 100644 index 0000000000..4b79e8070d --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DataSource.cxx @@ -0,0 +1,228 @@ +// Created on: 2004-06-10 +// Created by: Alexander SOLOVYOV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DataSource, MeshVS_DataSource) + +//================================================================ +// Function : Constructor +// Purpose : +//================================================================ +XSDRAWSTL_DataSource::XSDRAWSTL_DataSource(const Handle(Poly_Triangulation)& aMesh) +{ + myMesh = aMesh; + + if (!myMesh.IsNull()) + { + const Standard_Integer aNbNodes = myMesh->NbNodes(); + myNodeCoords = new TColStd_HArray2OfReal(1, aNbNodes, 1, 3); + std::cout << "Nodes : " << aNbNodes << std::endl; + + for (Standard_Integer i = 1; i <= aNbNodes; i++) + { + myNodes.Add(i); + gp_Pnt xyz = myMesh->Node(i); + + myNodeCoords->SetValue(i, 1, xyz.X()); + myNodeCoords->SetValue(i, 2, xyz.Y()); + myNodeCoords->SetValue(i, 3, xyz.Z()); + } + + const Standard_Integer aNbTris = myMesh->NbTriangles(); + myElemNormals = new TColStd_HArray2OfReal(1, aNbTris, 1, 3); + myElemNodes = new TColStd_HArray2OfInteger(1, aNbTris, 1, 3); + + std::cout << "Elements : " << aNbTris << std::endl; + + for (Standard_Integer i = 1; i <= aNbTris; i++) + { + myElements.Add(i); + + const Poly_Triangle aTri = myMesh->Triangle(i); + + Standard_Integer V[3]; + aTri.Get(V[0], V[1], V[2]); + + const gp_Pnt aP1 = myMesh->Node(V[0]); + const gp_Pnt aP2 = myMesh->Node(V[1]); + const gp_Pnt aP3 = myMesh->Node(V[2]); + + gp_Vec aV1(aP1, aP2); + gp_Vec aV2(aP2, aP3); + + gp_Vec aN = aV1.Crossed(aV2); + if (aN.SquareMagnitude() > Precision::SquareConfusion()) + aN.Normalize(); + else + aN.SetCoord(0.0, 0.0, 0.0); + + for (Standard_Integer j = 0; j < 3; j++) + { + myElemNodes->SetValue(i, j + 1, V[j]); + } + + myElemNormals->SetValue(i, 1, aN.X()); + myElemNormals->SetValue(i, 2, aN.Y()); + myElemNormals->SetValue(i, 3, aN.Z()); + } + } + std::cout << "Construction is finished" << std::endl; +} + +//================================================================ +// Function : GetGeom +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource::GetGeom +(const Standard_Integer ID, const Standard_Boolean IsElement, + TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, + MeshVS_EntityType& Type) const +{ + if (myMesh.IsNull()) + return Standard_False; + + if (IsElement) + { + if (ID >= 1 && ID <= myElements.Extent()) + { + Type = MeshVS_ET_Face; + NbNodes = 3; + + for (Standard_Integer i = 1, k = 1; i <= 3; i++) + { + Standard_Integer IdxNode = myElemNodes->Value(ID, i); + for (Standard_Integer j = 1; j <= 3; j++, k++) + Coords(k) = myNodeCoords->Value(IdxNode, j); + } + + return Standard_True; + } + else + return Standard_False; + } + else + if (ID >= 1 && ID <= myNodes.Extent()) + { + Type = MeshVS_ET_Node; + NbNodes = 1; + + Coords(1) = myNodeCoords->Value(ID, 1); + Coords(2) = myNodeCoords->Value(ID, 2); + Coords(3) = myNodeCoords->Value(ID, 3); + return Standard_True; + } + else + return Standard_False; +} + +//================================================================ +// Function : GetGeomType +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource::GetGeomType +(const Standard_Integer, + const Standard_Boolean IsElement, + MeshVS_EntityType& Type) const +{ + if (IsElement) + { + Type = MeshVS_ET_Face; + return Standard_True; + } + else + { + Type = MeshVS_ET_Node; + return Standard_True; + } +} + +//================================================================ +// Function : GetAddr +// Purpose : +//================================================================ +Standard_Address XSDRAWSTL_DataSource::GetAddr +(const Standard_Integer, const Standard_Boolean) const +{ + return NULL; +} + +//================================================================ +// Function : GetNodesByElement +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource::GetNodesByElement +(const Standard_Integer ID, + TColStd_Array1OfInteger& theNodeIDs, + Standard_Integer& /*theNbNodes*/) const +{ + if (myMesh.IsNull()) + return Standard_False; + + if (ID >= 1 && ID <= myElements.Extent() && theNodeIDs.Length() >= 3) + { + Standard_Integer aLow = theNodeIDs.Lower(); + theNodeIDs(aLow) = myElemNodes->Value(ID, 1); + theNodeIDs(aLow + 1) = myElemNodes->Value(ID, 2); + theNodeIDs(aLow + 2) = myElemNodes->Value(ID, 3); + return Standard_True; + } + return Standard_False; +} + +//================================================================ +// Function : GetAllNodes +// Purpose : +//================================================================ +const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource::GetAllNodes() const +{ + return myNodes; +} + +//================================================================ +// Function : GetAllElements +// Purpose : +//================================================================ +const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource::GetAllElements() const +{ + return myElements; +} + +//================================================================ +// Function : GetNormal +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource::GetNormal +(const Standard_Integer Id, const Standard_Integer Max, + Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const +{ + if (myMesh.IsNull()) + return Standard_False; + + if (Id >= 1 && Id <= myElements.Extent() && Max >= 3) + { + nx = myElemNormals->Value(Id, 1); + ny = myElemNormals->Value(Id, 2); + nz = myElemNormals->Value(Id, 3); + return Standard_True; + } + else + return Standard_False; +} + diff --git a/src/XSDRAWSTL/XSDRAWSTL_DataSource.hxx b/src/XSDRAWSTL/XSDRAWSTL_DataSource.hxx new file mode 100644 index 0000000000..4c66a9d132 --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DataSource.hxx @@ -0,0 +1,84 @@ +// Created on: 2004-06-10 +// Created by: Alexander SOLOVYOV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWSTL_DataSource_HeaderFile +#define _XSDRAWSTL_DataSource_HeaderFile + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class XSDRAWSTL_DataSource; +DEFINE_STANDARD_HANDLE(XSDRAWSTL_DataSource, MeshVS_DataSource) + +//! The sample DataSource for working with STLMesh_Mesh +class XSDRAWSTL_DataSource : public MeshVS_DataSource +{ +public: + + + //! Constructor + Standard_EXPORT XSDRAWSTL_DataSource(const Handle(Poly_Triangulation)& aMesh); + + //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates. + //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and + //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element. + //! It is recommended to return 1 for node. Type is an element type. + Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const Standard_OVERRIDE; + + //! This method is similar to GetGeom, but returns only element or node type. This method is provided for + //! a fine performance. + Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const Standard_OVERRIDE; + + //! This method returns by number an address of any entity which represents element or node data structure. + Standard_EXPORT Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const Standard_OVERRIDE; + + //! This method returns information about what node this element consist of. + Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const Standard_OVERRIDE; + + //! This method returns map of all nodes the object consist of. + Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE; + + //! This method returns map of all elements the object consist of. + Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE; + + //! This method calculates normal of face, which is using for correct reflection presentation. + //! There is default method, for advance reflection this method can be redefined. + Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DataSource,MeshVS_DataSource) + +protected: + +private: + + Handle(Poly_Triangulation) myMesh; + TColStd_PackedMapOfInteger myNodes; + TColStd_PackedMapOfInteger myElements; + Handle(TColStd_HArray2OfInteger) myElemNodes; + Handle(TColStd_HArray2OfReal) myNodeCoords; + Handle(TColStd_HArray2OfReal) myElemNormals; + +}; + +#endif // _XSDRAWSTL_DataSource_HeaderFile diff --git a/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx b/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx new file mode 100644 index 0000000000..7f1321a45f --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.cxx @@ -0,0 +1,385 @@ +// Created on: 2014-08-04 +// Created by: Artem NOVIKOV +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DataSource3D, MeshVS_DataSource) + +//================================================================ +// Function : Constructor +// Purpose : +//================================================================ +XSDRAWSTL_DataSource3D::XSDRAWSTL_DataSource3D() +{ + for (Standard_Integer aNodeID = 1; aNodeID <= 16; aNodeID++) + { + myNodes.Add(aNodeID); + } + + for (Standard_Integer anElemID = 1; anElemID <= 5; anElemID++) + { + myElements.Add(anElemID); + } + + myNodeCoords = new TColStd_HArray2OfReal(1, 16, 1, 3); + + myNodeCoords->SetValue(1, 1, 5); + myNodeCoords->SetValue(1, 2, 5); + myNodeCoords->SetValue(1, 3, 20); + + myNodeCoords->SetValue(2, 1, 0); + myNodeCoords->SetValue(2, 2, 10); + myNodeCoords->SetValue(2, 3, 10); + + myNodeCoords->SetValue(3, 1, 10); + myNodeCoords->SetValue(3, 2, 0); + myNodeCoords->SetValue(3, 3, 10); + + myNodeCoords->SetValue(4, 1, 0); + myNodeCoords->SetValue(4, 2, 0); + myNodeCoords->SetValue(4, 3, 10); + + myNodeCoords->SetValue(5, 1, -10); + myNodeCoords->SetValue(5, 2, 0); + myNodeCoords->SetValue(5, 3, 10); + + myNodeCoords->SetValue(6, 1, -10); + myNodeCoords->SetValue(6, 2, 10); + myNodeCoords->SetValue(6, 3, 10); + + myNodeCoords->SetValue(7, 1, -10); + myNodeCoords->SetValue(7, 2, 10); + myNodeCoords->SetValue(7, 3, 0); + + myNodeCoords->SetValue(8, 1, -10); + myNodeCoords->SetValue(8, 2, 0); + myNodeCoords->SetValue(8, 3, 0); + + myNodeCoords->SetValue(9, 1, 0); + myNodeCoords->SetValue(9, 2, 0); + myNodeCoords->SetValue(9, 3, 0); + + myNodeCoords->SetValue(10, 1, 0); + myNodeCoords->SetValue(10, 2, 10); + myNodeCoords->SetValue(10, 3, 0); + + myNodeCoords->SetValue(11, 1, 0); + myNodeCoords->SetValue(11, 2, -10); + myNodeCoords->SetValue(11, 3, 10); + + myNodeCoords->SetValue(12, 1, 10); + myNodeCoords->SetValue(12, 2, -10); + myNodeCoords->SetValue(12, 3, 10); + + myNodeCoords->SetValue(13, 1, 10); + myNodeCoords->SetValue(13, 2, -10); + myNodeCoords->SetValue(13, 3, 0); + + myNodeCoords->SetValue(14, 1, 0); + myNodeCoords->SetValue(14, 2, -10); + myNodeCoords->SetValue(14, 3, 0); + + myNodeCoords->SetValue(15, 1, 10); + myNodeCoords->SetValue(15, 2, 0); + myNodeCoords->SetValue(15, 3, 0); + + myNodeCoords->SetValue(16, 1, 5); + myNodeCoords->SetValue(16, 2, 5); + myNodeCoords->SetValue(16, 3, -10); + + myElemNbNodes = new TColStd_HArray1OfInteger(1, 5); + + myElemNbNodes->SetValue(1, 4); + myElemNbNodes->SetValue(2, 8); + myElemNbNodes->SetValue(3, 6); + myElemNbNodes->SetValue(4, 8); + myElemNbNodes->SetValue(5, 4); + + myElemNodes = new TColStd_HArray2OfInteger(1, 5, 1, 8); + + myElemNodes->SetValue(1, 1, 1); + myElemNodes->SetValue(1, 2, 2); + myElemNodes->SetValue(1, 3, 3); + myElemNodes->SetValue(1, 4, 4); + + myElemNodes->SetValue(2, 1, 2); + myElemNodes->SetValue(2, 2, 4); + myElemNodes->SetValue(2, 3, 5); + myElemNodes->SetValue(2, 4, 6); + myElemNodes->SetValue(2, 5, 7); + myElemNodes->SetValue(2, 6, 8); + myElemNodes->SetValue(2, 7, 9); + myElemNodes->SetValue(2, 8, 10); + + myElemNodes->SetValue(3, 1, 2); + myElemNodes->SetValue(3, 2, 3); + myElemNodes->SetValue(3, 3, 4); + myElemNodes->SetValue(3, 4, 10); + myElemNodes->SetValue(3, 5, 15); + myElemNodes->SetValue(3, 6, 9); + + myElemNodes->SetValue(4, 1, 4); + myElemNodes->SetValue(4, 2, 3); + myElemNodes->SetValue(4, 3, 12); + myElemNodes->SetValue(4, 4, 11); + myElemNodes->SetValue(4, 5, 14); + myElemNodes->SetValue(4, 6, 13); + myElemNodes->SetValue(4, 7, 15); + myElemNodes->SetValue(4, 8, 9); + + myElemNodes->SetValue(5, 1, 16); + myElemNodes->SetValue(5, 2, 15); + myElemNodes->SetValue(5, 3, 10); + myElemNodes->SetValue(5, 4, 9); +} + +//================================================================ +// Function : GetGeom +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource3D::GetGeom +(const Standard_Integer theID, const Standard_Boolean theIsElement, + TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, + MeshVS_EntityType& theType) const +{ + if (theIsElement) + { + if (theID >= 1 && theID <= myElements.Extent()) + { + theType = MeshVS_ET_Volume; + theNbNodes = myElemNbNodes->Value(theID); + + for (Standard_Integer aNodeI = 1, aGlobCoordI = 1; aNodeI <= theNbNodes; aNodeI++) + { + Standard_Integer anIdxNode = myElemNodes->Value(theID, aNodeI); + for (Standard_Integer aCoordI = 1; aCoordI <= 3; aCoordI++, aGlobCoordI++) + theCoords(aGlobCoordI) = myNodeCoords->Value(anIdxNode, aCoordI); + } + + return Standard_True; + } + else + return Standard_False; + } + else + if (theID >= 1 && theID <= myNodes.Extent()) + { + theType = MeshVS_ET_Node; + theNbNodes = 1; + + theCoords(1) = myNodeCoords->Value(theID, 1); + theCoords(2) = myNodeCoords->Value(theID, 2); + theCoords(3) = myNodeCoords->Value(theID, 3); + return Standard_True; + } + else + return Standard_False; +} + +//================================================================ +// Function : Get3DGeom +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource3D::Get3DGeom +(const Standard_Integer theID, Standard_Integer& theNbNodes, + Handle(MeshVS_HArray1OfSequenceOfInteger)& theData) const +{ + Handle(MeshVS_HArray1OfSequenceOfInteger) aMeshData; + if (theID == 1 || theID == 5) + { + aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1, 4); + theNbNodes = 4; + for (Standard_Integer anElemI = 1; anElemI <= 4; anElemI++) + { + aMeshData->ChangeValue(anElemI).Append((anElemI - 1) % 4); + aMeshData->ChangeValue(anElemI).Append(anElemI % 4); + aMeshData->ChangeValue(anElemI).Append((anElemI + 1) % 4); + } + theData = aMeshData; + return Standard_True; + } + + if (theID == 2 || theID == 4) + { + aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1, 6); + theNbNodes = 8; + for (Standard_Integer anElemI = 1, k = 1; anElemI <= 4; anElemI++) + { + aMeshData->ChangeValue(anElemI).Append((k - 1) % 8); + aMeshData->ChangeValue(anElemI).Append(k % 8); + aMeshData->ChangeValue(anElemI).Append((k + 1) % 8); + aMeshData->ChangeValue(anElemI).Append((k + 2) % 8); + k += 2; + } + + aMeshData->ChangeValue(5).Append(0); + aMeshData->ChangeValue(5).Append(3); + aMeshData->ChangeValue(5).Append(4); + aMeshData->ChangeValue(5).Append(7); + + aMeshData->ChangeValue(6).Append(1); + aMeshData->ChangeValue(6).Append(2); + aMeshData->ChangeValue(6).Append(5); + aMeshData->ChangeValue(6).Append(6); + + theData = aMeshData; + return Standard_True; + } + + if (theID == 3) + { + aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1, 5); + theNbNodes = 6; + for (Standard_Integer anElemI = 1; anElemI <= 2; anElemI++) + { + aMeshData->ChangeValue(anElemI).Append((anElemI - 1) * 3); + aMeshData->ChangeValue(anElemI).Append((anElemI - 1) * 3 + 1); + aMeshData->ChangeValue(anElemI).Append((anElemI - 1) * 3 + 2); + } + for (Standard_Integer anElemI = 1; anElemI <= 3; anElemI++) + { + aMeshData->ChangeValue(2 + anElemI).Append((anElemI - 1) % 3); + aMeshData->ChangeValue(2 + anElemI).Append(anElemI % 3); + aMeshData->ChangeValue(2 + anElemI).Append(anElemI % 3 + 3); + aMeshData->ChangeValue(2 + anElemI).Append((anElemI - 1) % 3 + 3); + } + theData = aMeshData; + return Standard_True; + } + + return Standard_False; +} + +//================================================================ +// Function : GetGeomType +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource3D::GetGeomType +(const Standard_Integer theID, + const Standard_Boolean theIsElement, + MeshVS_EntityType& theType) const +{ + if (theIsElement) + { + if (theID >= 1 && theID <= myElements.Extent()) + { + theType = MeshVS_ET_Volume; + return Standard_True; + } + } + else + if (theID >= 1 && theID <= myNodes.Extent()) + { + theType = MeshVS_ET_Node; + return Standard_True; + } + + return Standard_False; +} + +//================================================================ +// Function : GetAddr +// Purpose : +//================================================================ +Standard_Address XSDRAWSTL_DataSource3D::GetAddr +(const Standard_Integer, const Standard_Boolean) const +{ + return NULL; +} + +//================================================================ +// Function : GetNodesByElement +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource3D::GetNodesByElement +(const Standard_Integer theID, + TColStd_Array1OfInteger& theNodeIDs, + Standard_Integer& theNbNodes) const +{ + Standard_Integer aLow; + if (theID == 1 || theID == 5) + { + theNbNodes = 4; + aLow = theNodeIDs.Lower(); + theNodeIDs(aLow) = myElemNodes->Value(theID, 1); + theNodeIDs(aLow + 1) = myElemNodes->Value(theID, 2); + theNodeIDs(aLow + 2) = myElemNodes->Value(theID, 3); + theNodeIDs(aLow + 3) = myElemNodes->Value(theID, 4); + return Standard_True; + } + + if (theID == 2 || theID == 4) + { + theNbNodes = 8; + aLow = theNodeIDs.Lower(); + theNodeIDs(aLow) = myElemNodes->Value(theID, 1); + theNodeIDs(aLow + 1) = myElemNodes->Value(theID, 2); + theNodeIDs(aLow + 2) = myElemNodes->Value(theID, 3); + theNodeIDs(aLow + 3) = myElemNodes->Value(theID, 4); + theNodeIDs(aLow + 4) = myElemNodes->Value(theID, 5); + theNodeIDs(aLow + 5) = myElemNodes->Value(theID, 6); + theNodeIDs(aLow + 6) = myElemNodes->Value(theID, 7); + theNodeIDs(aLow + 7) = myElemNodes->Value(theID, 8); + return Standard_True; + } + + if (theID == 3) + { + theNbNodes = 6; + aLow = theNodeIDs.Lower(); + theNodeIDs(aLow) = myElemNodes->Value(theID, 1); + theNodeIDs(aLow + 1) = myElemNodes->Value(theID, 2); + theNodeIDs(aLow + 2) = myElemNodes->Value(theID, 3); + theNodeIDs(aLow + 3) = myElemNodes->Value(theID, 4); + theNodeIDs(aLow + 4) = myElemNodes->Value(theID, 5); + theNodeIDs(aLow + 5) = myElemNodes->Value(theID, 6); + return Standard_True; + } + + return Standard_False; +} + +//================================================================ +// Function : GetAllNodes +// Purpose : +//================================================================ +const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource3D::GetAllNodes() const +{ + return myNodes; +} + +//================================================================ +// Function : GetAllElements +// Purpose : +//================================================================ +const TColStd_PackedMapOfInteger& XSDRAWSTL_DataSource3D::GetAllElements() const +{ + return myElements; +} + +//================================================================ +// Function : GetNormal +// Purpose : +//================================================================ +Standard_Boolean XSDRAWSTL_DataSource3D::GetNormal +(const Standard_Integer /*theID*/, const Standard_Integer /*theMax*/, + Standard_Real& /*theNx*/, Standard_Real& /*theNy*/, Standard_Real& /*theNz*/) const +{ + return Standard_False; +} diff --git a/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.hxx b/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.hxx new file mode 100644 index 0000000000..91a5f4cabc --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DataSource3D.hxx @@ -0,0 +1,89 @@ +// Created on: 2014-08-04 +// Created by: Artem NOVIKOV +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWSTL_DataSource3D_HeaderFile +#define _XSDRAWSTL_DataSource3D_HeaderFile + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class XSDRAWSTL_DataSource3D; +DEFINE_STANDARD_HANDLE(XSDRAWSTL_DataSource3D, MeshVS_DataSource) + +//! The sample DataSource3D for working with STLMesh_Mesh +class XSDRAWSTL_DataSource3D : public MeshVS_DataSource +{ +public: + + + //! Constructor + Standard_EXPORT XSDRAWSTL_DataSource3D(); + + //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates. + //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and + //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element. + //! It is recommended to return 1 for node. Type is an element type. + Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer theID, const Standard_Boolean theIsElement, TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, MeshVS_EntityType& theType) const Standard_OVERRIDE; + + //! This method returns topology information about 3D-element + //! Returns false if element with ID isn't 3D or because other troubles + Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer theID, Standard_Integer& theNbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& theData) const Standard_OVERRIDE; + + //! This method is similar to GetGeom, but returns only element or node type. This method is provided for + //! a fine performance. + Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer theID, const Standard_Boolean theIsElement, MeshVS_EntityType& theType) const Standard_OVERRIDE; + + //! This method returns by number an address of any entity which represents element or node data structure. + Standard_EXPORT Standard_Address GetAddr (const Standard_Integer theID, const Standard_Boolean theIsElement) const Standard_OVERRIDE; + + //! This method returns information about what node this element consist of. + Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer theID, TColStd_Array1OfInteger& theNodeIDs, Standard_Integer& theNbNodes) const Standard_OVERRIDE; + + //! This method returns map of all nodes the object consist of. + Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE; + + //! This method returns map of all elements the object consist of. + Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE; + + //! This method calculates normal of face, which is using for correct reflection presentation. + //! There is default method, for advance reflection this method can be redefined. + Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer theID, const Standard_Integer theMax, Standard_Real& theNx, Standard_Real& theNy, Standard_Real& theNz) const Standard_OVERRIDE; + + DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DataSource3D,MeshVS_DataSource) + +protected: + +private: + + TColStd_PackedMapOfInteger myNodes; + TColStd_PackedMapOfInteger myElements; + Handle(TColStd_HArray1OfInteger) myElemNbNodes; + Handle(TColStd_HArray2OfReal) myNodeCoords; + Handle(TColStd_HArray2OfInteger) myElemNodes; + +}; + +#endif // _XSDRAWSTL_DataSource3D_HeaderFile diff --git a/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.cxx b/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.cxx new file mode 100644 index 0000000000..5126e89677 --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.cxx @@ -0,0 +1,46 @@ +// Created on: 2004-06-11 +// Created by: Alexander SOLOVYOV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include +#include + +IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTL_DrawableMesh, Draw_Drawable3D) + +//================================================================ +// Function : DrawOn +// Purpose : +//================================================================ +XSDRAWSTL_DrawableMesh::XSDRAWSTL_DrawableMesh(const Handle(MeshVS_Mesh)& aMesh) +{ + myMesh = aMesh; +} + +//================================================================ +// Function : +// Purpose : +//================================================================ +void XSDRAWSTL_DrawableMesh::DrawOn(Draw_Display& /*d*/) const +{} + +//================================================================ +// Function : +// Purpose : +//================================================================ +Handle(MeshVS_Mesh) XSDRAWSTL_DrawableMesh::GetMesh() const +{ + return myMesh; +} diff --git a/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.hxx b/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.hxx new file mode 100644 index 0000000000..c744470a32 --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_DrawableMesh.hxx @@ -0,0 +1,50 @@ +// Created on: 2004-06-11 +// Created by: Alexander SOLOVYOV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWSTL_DrawableMesh_HeaderFile +#define _XSDRAWSTL_DrawableMesh_HeaderFile + +#include +#include + +#include +class MeshVS_Mesh; +class Draw_Display; + +class XSDRAWSTL_DrawableMesh; +DEFINE_STANDARD_HANDLE(XSDRAWSTL_DrawableMesh, Draw_Drawable3D) + +class XSDRAWSTL_DrawableMesh : public Draw_Drawable3D +{ +public: + + + Standard_EXPORT XSDRAWSTL_DrawableMesh(const Handle(MeshVS_Mesh)& aMesh); + + Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE; + + Standard_EXPORT Handle(MeshVS_Mesh) GetMesh() const; + + DEFINE_STANDARD_RTTIEXT(XSDRAWSTL_DrawableMesh,Draw_Drawable3D) + +protected: + +private: + + Handle(MeshVS_Mesh) myMesh; + +}; + +#endif // _XSDRAWSTL_DrawableMesh_HeaderFile diff --git a/src/XSDRAWSTL/XSDRAWSTL_ElemNodesMap.hxx b/src/XSDRAWSTL/XSDRAWSTL_ElemNodesMap.hxx new file mode 100644 index 0000000000..bf225b5849 --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL_ElemNodesMap.hxx @@ -0,0 +1,26 @@ +// Created on: 2000-05-30 +// Created by: Sergey MOZOKHIN +// Copyright (c) 2000-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef XSDRAWSTLVRML_ElemNodesMap_HeaderFile +#define XSDRAWSTLVRML_ElemNodesMap_HeaderFile + +#include +#include +#include + +typedef NCollection_DataMap XSDRAWSTLVRML_ElemNodesMap; +typedef NCollection_DataMap::Iterator XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap; + +#endif diff --git a/src/XSDRAWSTLVRML/FILES b/src/XSDRAWSTLVRML/FILES deleted file mode 100644 index 0541a21c66..0000000000 --- a/src/XSDRAWSTLVRML/FILES +++ /dev/null @@ -1,12 +0,0 @@ -XSDRAWSTLVRML.cxx -XSDRAWSTLVRML.hxx -XSDRAWSTLVRML_CoordsMap.hxx -XSDRAWSTLVRML_DataMapIteratorOfCoordsMap.hxx -XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap.hxx -XSDRAWSTLVRML_DataSource.cxx -XSDRAWSTLVRML_DataSource.hxx -XSDRAWSTLVRML_DataSource3D.cxx -XSDRAWSTLVRML_DataSource3D.hxx -XSDRAWSTLVRML_DrawableMesh.cxx -XSDRAWSTLVRML_DrawableMesh.hxx -XSDRAWSTLVRML_ElemNodesMap.hxx diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx deleted file mode 100644 index 5706ea53f3..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ /dev/null @@ -1,1314 +0,0 @@ -// Created on: 2000-05-30 -// Created by: Sergey MOZOKHIN -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include -#include -#include -//#include -//#include -//#include -#include -#include -#include -#include -//#include -#include -#include -//#include -//#include -#include -#include -//#include -#include -//#include -//#include -//#include -//#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include -//#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _STDIO_H -#include -#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 : createmesh -//purpose : -//======================================================================= -static Standard_Integer createmesh(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use: " << theArgVec[0] << " \n"; - return 0; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if (aContext.IsNull()) - { - theDI << "No active view. Please call 'vinit' first\n"; - return 0; - } - - // Progress indicator - OSD_Path aFile(theArgVec[2]); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(aFile, aProgress->Start()); - - theDI << "Reading OK...\n"; - Handle(XSDRAWSTLVRML_DataSource) aDS = new XSDRAWSTLVRML_DataSource(aSTLMesh); - theDI << "Data source is created successful\n"; - Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh(); - theDI << "MeshVS_Mesh is created successful\n"; - - aMesh->SetDataSource(aDS); - aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True); - - aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW); - - // Hide all nodes by default - Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger(); - const Standard_Integer aLen = aSTLMesh->NbNodes(); - for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) - aNodes->ChangeMap().Add(anIndex); - aMesh->SetHiddenNodes(aNodes); - aMesh->SetSelectableNodes(aNodes); - - VDisplayAISObject(theArgVec[1], aMesh); - aContext->Deactivate(aMesh); - - Draw::Set(theArgVec[1], new XSDRAWSTLVRML_DrawableMesh(aMesh)); - Handle(V3d_View) aView = ViewerTest::CurrentView(); - if (!aView.IsNull()) - aView->FitAll(); - - return 0; -} - -//======================================================================= -//function : create3d -//purpose : -//======================================================================= -static Standard_Integer create3d(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use: " << theArgVec[0] << " \n"; - return 0; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if (aContext.IsNull()) - { - theDI << "No active view. Please call 'vinit' first\n"; - return 0; - } - - Handle(XSDRAWSTLVRML_DataSource3D) aDS = new XSDRAWSTLVRML_DataSource3D(); - theDI << "Data source is created successful\n"; - Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh(); - theDI << "MeshVS_Mesh is created successful\n"; - - aMesh->SetDataSource(aDS); - aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True); - - aMesh->GetDrawer()->SetColor(MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW); - - // Hide all nodes by default - Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger(); - Standard_Integer aLen = aDS->GetAllNodes().Extent(); - for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) - aNodes->ChangeMap().Add(anIndex); - aMesh->SetHiddenNodes(aNodes); - aMesh->SetSelectableNodes(aNodes); - - VDisplayAISObject(theArgVec[1], aMesh); - aContext->Deactivate(aMesh); - - Draw::Set(theArgVec[1], new XSDRAWSTLVRML_DrawableMesh(aMesh)); - Handle(V3d_View) aView = ViewerTest::CurrentView(); - if (!aView.IsNull()) - aView->FitAll(); - - return 0; -} - -//======================================================================= -//function : getMesh -//purpose : -//======================================================================= -Handle(MeshVS_Mesh) getMesh(const char* theName, - Draw_Interpretor& theDI) -{ - Handle(XSDRAWSTLVRML_DrawableMesh) aDrawMesh = - Handle(XSDRAWSTLVRML_DrawableMesh)::DownCast(Draw::Get(theName)); - - if (aDrawMesh.IsNull()) - { - theDI << "There is no such object\n"; - return NULL; - } - else - { - Handle(MeshVS_Mesh) aMesh = aDrawMesh->GetMesh(); - if (aMesh.IsNull()) - { - theDI << "There is invalid mesh\n"; - return NULL; - } - else - return aMesh; - } -} - -//======================================================================= -//function : setcolor -//purpose : -//======================================================================= -static Standard_Integer setcolor(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec, - Standard_Integer theParam) -{ - if (theNbArgs < 5) - theDI << "Wrong number of parameters\n"; - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (!aMesh.IsNull()) - { - Standard_Real aRed = Draw::Atof(theArgVec[2]); - Standard_Real aGreen = Draw::Atof(theArgVec[3]); - Standard_Real aBlue = Draw::Atof(theArgVec[4]); - aMesh->GetDrawer()->SetColor((MeshVS_DrawerAttribute)theParam, - Quantity_Color(aRed, aGreen, aBlue, Quantity_TOC_RGB)); - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - aContext->Redisplay(aMesh, Standard_True); - } - } - return 0; -} - -//======================================================================= -//function : meshcolor -//purpose : -//======================================================================= -static Standard_Integer meshcolor(Draw_Interpretor& theInterp, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_InteriorColor); -} - -//======================================================================= -//function : linecolor -//purpose : -//======================================================================= -static Standard_Integer linecolor(Draw_Interpretor& theInterp, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - return setcolor(theInterp, theNbArgs, theArgVec, MeshVS_DA_EdgeColor); -} - -//======================================================================= -//function : meshmat -//purpose : -//======================================================================= -static Standard_Integer meshmat(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - theDI << "Wrong number of parameters\n"; - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (!aMesh.IsNull()) - { - Standard_Integer aMaterial = Draw::Atoi(theArgVec[2]); - - Graphic3d_MaterialAspect aMatAsp = - (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial; - - if (theNbArgs == 4) - { - Standard_Real aTransparency = Draw::Atof(theArgVec[3]); - aMatAsp.SetTransparency(Standard_ShortReal(aTransparency)); - } - aMesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial, aMatAsp); - aMesh->GetDrawer()->SetMaterial(MeshVS_DA_BackMaterial, aMatAsp); - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - aContext->Redisplay(aMesh, Standard_True); - } - } - return 0; -} - -//======================================================================= -//function : shrink -//purpose : -//======================================================================= -static Standard_Integer shrink(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - theDI << "Wrong number of parameters\n"; - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (!aMesh.IsNull()) - { - Standard_Real aShrinkCoeff = Draw::Atof(theArgVec[2]); - aMesh->GetDrawer()->SetDouble(MeshVS_DA_ShrinkCoeff, aShrinkCoeff); - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - aContext->Redisplay(aMesh, Standard_True); - } - } - return 0; -} - -//======================================================================= -//function : closed -//purpose : -//======================================================================= -static Standard_Integer closed(Draw_Interpretor& theDI, - Standard_Integer theArgc, - const char** theArgv) -{ - if (theArgc < 3) - { - theDI << "Wrong number of parameters.\n"; - } - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgv[1], theDI); - if (!aMesh.IsNull()) - { - Standard_Boolean aFlag = Draw::Atoi(theArgv[2]) != 0; - aMesh->GetDrawer()->SetBoolean(MeshVS_DA_SupressBackFaces, aFlag); - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - if (aContext.IsNull()) - { - theDI << "The context is null\n"; - } - else - { - aContext->Redisplay(aMesh, Standard_True); - } - } - } - return 0; -} - -//======================================================================= -//function : mdisplay -//purpose : -//======================================================================= -static Standard_Integer mdisplay(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - theDI << "Wrong number of parameters\n"; - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (!aMesh.IsNull()) - { - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - { - aContext->Display(aMesh, Standard_True); - } - } - } - return 0; -} - -//======================================================================= -//function : merase -//purpose : -//======================================================================= -static Standard_Integer merase(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - theDI << "Wrong number of parameters\n"; - else - { - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (!aMesh.IsNull()) - { - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - { - aContext->Erase(aMesh, Standard_True); - } - } - else - theDI << "Mesh is null\n"; - } - return 0; -} - -//======================================================================= -//function : hidesel -//purpose : -//======================================================================= -static Standard_Integer hidesel(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use: " << theArgVec[0] << " \n"; - return 0; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (aMesh.IsNull()) - { - theDI << "The mesh is invalid\n"; - return 0; - } - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - { - Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes(); - if (aHiddenNodes.IsNull()) - { - aHiddenNodes = new TColStd_HPackedMapOfInteger(); - } - Handle(TColStd_HPackedMapOfInteger) aHiddenElements = aMesh->GetHiddenElems(); - if (aHiddenElements.IsNull()) - { - aHiddenElements = new TColStd_HPackedMapOfInteger(); - } - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) - { - Handle(MeshVS_MeshEntityOwner) anOwner = - Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner()); - if (!anOwner.IsNull()) - { - if (anOwner->Type() == MeshVS_ET_Node) - { - aHiddenNodes->ChangeMap().Add(anOwner->ID()); - } - else - { - aHiddenElements->ChangeMap().Add(anOwner->ID()); - } - } - } - aContext->ClearSelected(Standard_False); - aMesh->SetHiddenNodes(aHiddenNodes); - aMesh->SetHiddenElems(aHiddenElements); - aContext->Redisplay(aMesh, Standard_True); - } - - return 0; -} - -//======================================================================= -//function : showonly -//purpose : -//======================================================================= -static Standard_Integer showonly(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use: " << theArgVec[0] << " \n"; - return 0; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (aMesh.IsNull()) - { - theDI << "The mesh is invalid\n"; - return 0; - } - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - { - Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = - new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes()); - Handle(TColStd_HPackedMapOfInteger) aHiddenElements = - new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements()); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) - { - Handle(MeshVS_MeshEntityOwner) anOwner = - Handle(MeshVS_MeshEntityOwner)::DownCast(aContext->SelectedOwner()); - if (!anOwner.IsNull()) - { - if (anOwner->Type() == MeshVS_ET_Node) - { - aHiddenNodes->ChangeMap().Remove(anOwner->ID()); - } - else - { - aHiddenElements->ChangeMap().Remove(anOwner->ID()); - } - } - } - aMesh->SetHiddenNodes(aHiddenNodes); - aMesh->SetHiddenElems(aHiddenElements); - aContext->Redisplay(aMesh, Standard_True); - } - - return 0; -} - -//======================================================================= -//function : showonly -//purpose : -//======================================================================= -static Standard_Integer showall(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use: " << theArgVec[0] << " \n"; - return 0; - } - - Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (aMesh.IsNull()) - { - theDI << "The mesh is invalid\n"; - return 0; - } - - if (aContext.IsNull()) - theDI << "The context is null\n"; - else - { - aMesh->SetHiddenNodes(new TColStd_HPackedMapOfInteger()); - aMesh->SetHiddenElems(new TColStd_HPackedMapOfInteger()); - aContext->Redisplay(aMesh, Standard_True); - } - - return 0; -} - -//======================================================================= -//function : meshcolors -//purpose : -//======================================================================= -static Standard_Integer meshcolors(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - try - { - OCC_CATCH_SIGNALS - if (theNbArgs < 4) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use : meshcolors \n"; - theDI << "mode : {elem1|elem2|nodal|nodaltex|none}\n"; - theDI << " elem1 - different color for each element\n"; - theDI << " elem2 - one color for one side\n"; - theDI << " nodal - different color for each node\n"; - theDI << " nodaltex - different color for each node with texture interpolation\n"; - theDI << " none - clear\n"; - theDI << "isreflect : {0|1} \n"; - - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); - if (anIC.IsNull()) - { - theDI << "The context is null\n"; - return 0; - } - if (!aMesh.IsNull()) - { - TCollection_AsciiString aMode = TCollection_AsciiString(theArgVec[2]); - Quantity_Color aColor1(Quantity_NOC_BLUE1); - Quantity_Color aColor2(Quantity_NOC_RED1); - if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none")) - { - Handle(MeshVS_PrsBuilder) aTempBuilder; - Standard_Integer aReflection = Draw::Atoi(theArgVec[3]); - - for (Standard_Integer aCount = 0; aCount < aMesh->GetBuildersCount(); aCount++) - { - aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder"); - if (!aTempBuilder.IsNull()) - aMesh->RemoveBuilderById(aTempBuilder->GetId()); - - aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder"); - if (!aTempBuilder.IsNull()) - aMesh->RemoveBuilderById(aTempBuilder->GetId()); - } - - if (aMode.IsEqual("elem1") || aMode.IsEqual("elem2")) - { - Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder( - aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask); - // Color - const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements(); - TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllElements); - - if (aMode.IsEqual("elem1")) - for (; anIter.More(); anIter.Next()) - { - Quantity_Color aColor((Quantity_NameOfColor)(anIter.Key() % Quantity_NOC_WHITE)); - aBuilder->SetColor1(anIter.Key(), aColor); - } - else - for (; anIter.More(); anIter.Next()) - aBuilder->SetColor2(anIter.Key(), aColor1, aColor2); - - aMesh->AddBuilder(aBuilder, Standard_True); - } - - if (aMode.IsEqual("nodal")) - { - Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( - aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask); - aMesh->AddBuilder(aBuilder, Standard_True); - - // Color - const TColStd_PackedMapOfInteger& anAllNodes = - aMesh->GetDataSource()->GetAllNodes(); - TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes); - for (; anIter.More(); anIter.Next()) - { - Quantity_Color aColor((Quantity_NameOfColor)( - anIter.Key() % Quantity_NOC_WHITE)); - aBuilder->SetColor(anIter.Key(), aColor); - } - aMesh->AddBuilder(aBuilder, Standard_True); - } - - if (aMode.IsEqual("nodaltex")) - { - // assign nodal builder to the mesh - Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder( - aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask); - aMesh->AddBuilder(aBuilder, Standard_True); - aBuilder->UseTexture(Standard_True); - - // prepare color map for texture - Aspect_SequenceOfColor aColorMap; - aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_RED); - aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_YELLOW); - aColorMap.Append((Quantity_NameOfColor)Quantity_NOC_BLUE1); - - // prepare scale map for mesh - it will be assigned to mesh as texture coordinates - // make mesh color interpolated from minimum X coord to maximum X coord - Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource(); - Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ; - - // get bounding box for calculations - aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ); - Standard_Real aDelta = aMaxX - aMinX; - - // assign color scale map values (0..1) to nodes - TColStd_DataMapOfIntegerReal aScaleMap; - TColStd_Array1OfReal aCoords(1, 3); - Standard_Integer aNbNodes; - MeshVS_EntityType aType; - - // iterate nodes - const TColStd_PackedMapOfInteger& anAllNodes = - aMesh->GetDataSource()->GetAllNodes(); - TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes); - for (; anIter.More(); anIter.Next()) - { - //get node coordinates to aCoord variable - aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType); - - Standard_Real aScaleValue; - try - { - OCC_CATCH_SIGNALS - aScaleValue = (aCoords.Value(1) - (Standard_Real)aMinX) / aDelta; - } - catch (Standard_Failure const&) - { - aScaleValue = 0; - } - - aScaleMap.Bind(anIter.Key(), aScaleValue); - } - - //set color map for builder and a color for invalid scale value - aBuilder->SetColorMap(aColorMap); - aBuilder->SetInvalidColor(Quantity_NOC_BLACK); - aBuilder->SetTextureCoords(aScaleMap); - aMesh->AddBuilder(aBuilder, Standard_True); - } - - aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, aReflection != 0); - - anIC->Redisplay(aMesh, Standard_True); - } - else - { - theDI << "Wrong mode name\n"; - return 0; - } - } - } - catch (Standard_Failure const&) - { - theDI << "Error\n"; - } - - return 0; -} - -//======================================================================= -//function : meshvectors -//purpose : -//======================================================================= -static Standard_Integer meshvectors(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use : meshvectors < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n"; - theDI << "Supported mode values:\n"; - theDI << " elem - vector per element\n"; - theDI << " nodal - vector per node\n"; - theDI << " none - clear\n"; - - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); - if (anIC.IsNull()) - { - theDI << "The context is null\n"; - return 0; - } - - TCollection_AsciiString aParam; - TCollection_AsciiString aMode("none"); - Standard_Real aMaxlen(1.0); - Quantity_Color aColor(Quantity_NOC_ORANGE); - Standard_Real anArrowPart(0.1); - Standard_Boolean isSimplePrs(Standard_False); - - for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++) - { - if (!aParam.IsEmpty()) - { - if (aParam == "-mode") - { - aMode = theArgVec[anIdx]; - } - else if (aParam == "-maxlen") - { - aMaxlen = Draw::Atof(theArgVec[anIdx]); - } - else if (aParam == "-color") - { - if (!Quantity_Color::ColorFromName(theArgVec[anIdx], aColor)) - { - theDI << "Syntax error at " << aParam << "\n"; - return 1; - } - } - else if (aParam == "-arrowpart") - { - anArrowPart = Draw::Atof(theArgVec[anIdx]); - } - else if (aParam == "-issimple") - { - isSimplePrs = Draw::Atoi(theArgVec[anIdx]) != 0; - } - aParam.Clear(); - } - else if (theArgVec[anIdx][0] == '-') - { - aParam = theArgVec[anIdx]; - } - } - - if (!aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none")) - { - theDI << "Wrong mode name\n"; - return 0; - } - - Handle(MeshVS_PrsBuilder) aTempBuilder; - - aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder"); - if (!aTempBuilder.IsNull()) - aMesh->RemoveBuilderById(aTempBuilder->GetId()); - - if (!aMode.IsEqual("none")) - { - Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder(aMesh.operator->(), - aMaxlen, - aColor, - MeshVS_DMF_VectorDataPrs, - 0, - -1, - MeshVS_BP_Vector, - isSimplePrs); - - Standard_Boolean anIsElement = aMode.IsEqual("elem"); - const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() : - aMesh->GetDataSource()->GetAllNodes(); - - Standard_Integer aNbNodes; - MeshVS_EntityType aEntType; - - TColStd_Array1OfReal aCoords(1, 3); - aCoords.Init(0.); - TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllIDs); - for (; anIter.More(); anIter.Next()) - { - Standard_Boolean IsValidData = Standard_False; - if (anIsElement) - { - aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType); - if (aEntType == MeshVS_ET_Face) - IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3)); - } - else - IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); - - gp_Vec aNorm; - if (IsValidData) - { - aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); - if (aNorm.Magnitude() < gp::Resolution()) - { - aNorm = gp_Vec(0, 0, 1); //method GetGeom(...) returns coordinates of nodes - } - } - else - { - aNorm = gp_Vec(0, 0, 1); - } - aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized()); - } - - aMesh->AddBuilder(aBuilder, Standard_False); - aMesh->GetDrawer()->SetDouble(MeshVS_DA_VectorArrowPart, anArrowPart); - } - - anIC->Redisplay(aMesh, Standard_True); - - return 0; -} - -//======================================================================= -//function : meshtext -//purpose : -//======================================================================= -static Standard_Integer meshtext(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 2) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use : meshtext \n"; - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - - Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); - if (anIC.IsNull()) - { - theDI << "The context is null\n"; - return 0; - } - - // Prepare triangle labels - MeshVS_DataMapOfIntegerAsciiString aLabels; - Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent(); - for (Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++) - { - aLabels.Bind(anIndex, TCollection_AsciiString(anIndex)); - } - - Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder(aMesh.operator->(), 20., Quantity_NOC_YELLOW); - aTextBuilder->SetTexts(Standard_True, aLabels); - aMesh->AddBuilder(aTextBuilder); - - return 0; -} - -//======================================================================= -//function : meshdeform -//purpose : -//======================================================================= -static Standard_Integer meshdeform(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use : meshdeform < -mode {on|off} > [-scale scalefactor]\n"; - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); - if (anIC.IsNull()) - { - theDI << "The context is null\n"; - return 0; - } - - TCollection_AsciiString aParam; - TCollection_AsciiString aMode("off"); - Standard_Real aScale(1.0); - - for (Standard_Integer anIdx = 2; anIdx < theNbArgs; anIdx++) - { - if (!aParam.IsEmpty()) - { - if (aParam == "-mode") - { - aMode = theArgVec[anIdx]; - } - else if (aParam == "-scale") - { - aScale = Draw::Atof(theArgVec[anIdx]); - } - aParam.Clear(); - } - else if (theArgVec[anIdx][0] == '-') - { - aParam = theArgVec[anIdx]; - } - } - - if (!aMode.IsEqual("on") && !aMode.IsEqual("off")) - { - theDI << "Wrong mode name\n"; - return 0; - } - - Handle(MeshVS_DeformedDataSource) aDefDS = - new MeshVS_DeformedDataSource(aMesh->GetDataSource(), aScale); - - const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes(); - - Standard_Integer aNbNodes; - MeshVS_EntityType aEntType; - - TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllIDs); - for (; anIter.More(); anIter.Next()) - { - TColStd_Array1OfReal aCoords(1, 3); - aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType); - - gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3)); - if (!aNorm.Magnitude()) - aNorm = gp_Vec(0, 0, 1); - aDefDS->SetVector(anIter.Key(), aNorm.Normalized()); - } - - aMesh->SetDataSource(aDefDS); - - anIC->Redisplay(aMesh, Standard_False); - - Handle(V3d_View) aView = ViewerTest::CurrentView(); - if (!aView.IsNull()) - aView->FitAll(); - - return 0; -} - -//======================================================================= -//function : mesh_edge_width -//purpose : -//======================================================================= -static Standard_Integer mesh_edge_width(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - try - { - OCC_CATCH_SIGNALS - if (theNbArgs < 3) - { - theDI << "Wrong number of parameters\n"; - theDI << "Use : mesh_edge_width \n"; - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - - const char* aWidthStr = theArgVec[2]; - if (aWidthStr == 0 || Draw::Atof(aWidthStr) <= 0) - { - theDI << "Width must be real value more than zero\n"; - return 0; - } - - double aWidth = Draw::Atof(aWidthStr); - - Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext(); - if (anIC.IsNull()) - { - theDI << "The context is null\n"; - return 0; - } - - Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer(); - if (aDrawer.IsNull()) - { - theDI << "The drawer is null\n"; - return 0; - } - - aDrawer->SetDouble(MeshVS_DA_EdgeWidth, aWidth); - anIC->Redisplay(aMesh, Standard_True); - } - catch (Standard_Failure const&) - { - theDI << "Error\n"; - } - - return 0; -} - -//======================================================================= -//function : meshinfo -//purpose : -//======================================================================= -static Standard_Integer meshinfo(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs != 2) - { - theDI << "Wrong number of parameters. Use : meshinfo mesh\n"; - return 0; - } - - Handle(MeshVS_Mesh) aMesh = getMesh(theArgVec[1], theDI); - if (aMesh.IsNull()) - { - theDI << "Mesh not found\n"; - return 0; - } - - Handle(XSDRAWSTLVRML_DataSource) stlMeshSource = Handle(XSDRAWSTLVRML_DataSource)::DownCast(aMesh->GetDataSource()); - if (!stlMeshSource.IsNull()) - { - const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes(); - const TColStd_PackedMapOfInteger& tris = stlMeshSource->GetAllElements(); - - theDI << "Nb nodes = " << nodes.Extent() << "\n"; - theDI << "Nb triangles = " << tris.Extent() << "\n"; - } - - return 0; -} - -//======================================================================= -//function : InitCommands -//purpose : -//======================================================================= -void XSDRAWSTLVRML::InitCommands(Draw_Interpretor& theCommands) -{ - const char* g = "XSTEP-STL/VRML"; // Step transfer file commands - //XSDRAW::LoadDraw(theCommands); - - theCommands.Add("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, g); - theCommands.Add("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, g); - theCommands.Add("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, g); - theCommands.Add("meshlinkcolor", "change MeshVS_Mesh line color", __FILE__, linecolor, g); - theCommands.Add("meshmat", "change MeshVS_Mesh material and transparency", __FILE__, meshmat, g); - theCommands.Add("meshshrcoef", "change MeshVS_Mesh shrink coeff", __FILE__, shrink, g); - theCommands.Add("meshclosed", "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g); - theCommands.Add("meshshow", "display MeshVS_Mesh object", __FILE__, mdisplay, g); - theCommands.Add("meshhide", "erase MeshVS_Mesh object", __FILE__, merase, g); - theCommands.Add("meshhidesel", "hide selected entities", __FILE__, hidesel, g); - theCommands.Add("meshshowsel", "show only selected entities", __FILE__, showonly, g); - theCommands.Add("meshshowall", "show all entities", __FILE__, showall, g); - theCommands.Add("meshcolors", "display color presentation", __FILE__, meshcolors, g); - theCommands.Add("meshvectors", "display sample vectors", __FILE__, meshvectors, g); - theCommands.Add("meshtext", "display text labels", __FILE__, meshtext, g); - theCommands.Add("meshdeform", "display deformed mesh", __FILE__, meshdeform, g); - theCommands.Add("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, g); - theCommands.Add("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, g); -} - -//======================================================================= -//function : Factory -//purpose : -//======================================================================= -void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI) -{ - XSDRAWSTLVRML::InitCommands(theDI); -#ifdef OCCT_DEBUG - theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n"; -#endif -} - -// Declare entry point PLUGINFACTORY -DPLUGIN(XSDRAWSTLVRML) diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.hxx deleted file mode 100644 index 4ec0edd030..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.hxx +++ /dev/null @@ -1,39 +0,0 @@ -// Created on: 2000-05-30 -// Created by: Sergey MOZOKHIN -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _XSDRAWSTLVRML_HeaderFile -#define _XSDRAWSTLVRML_HeaderFile - -#include -#include -#include - -#include - -class XSDRAWSTLVRML -{ -public: - - DEFINE_STANDARD_ALLOC - - //! Inits commands for writing to STL and VRML formats - Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands); - - //! Loads all Draw commands of TKXSDRAW. Used for plugin. - Standard_EXPORT static void Factory (Draw_Interpretor& theDI); - -}; - -#endif // _XSDRAWSTLVRML_HeaderFile diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_CoordsMap.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_CoordsMap.hxx deleted file mode 100644 index d177d46ee3..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_CoordsMap.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 2000-05-30 -// Created by: Sergey MOZOKHIN -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef XSDRAWSTLVRML_CoordsMap_HeaderFile -#define XSDRAWSTLVRML_CoordsMap_HeaderFile - -#include -#include -#include - -typedef NCollection_DataMap XSDRAWSTLVRML_CoordsMap; -typedef NCollection_DataMap::Iterator XSDRAWSTLVRML_DataMapIteratorOfCoordsMap; - -#endif diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfCoordsMap.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfCoordsMap.hxx deleted file mode 100644 index 1975d2a4c6..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfCoordsMap.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2015 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef XSDRAWSTLVRML_DataMapIteratorOfCoordsMap_HeaderFile -#define XSDRAWSTLVRML_DataMapIteratorOfCoordsMap_HeaderFile - -#include - -#endif diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap.hxx deleted file mode 100644 index 3649afe9c7..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap.hxx +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2015 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap_HeaderFile -#define XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap_HeaderFile - -#include - -#endif diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.cxx deleted file mode 100644 index f6e95ccbba..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.cxx +++ /dev/null @@ -1,228 +0,0 @@ -// Created on: 2004-06-10 -// Created by: Alexander SOLOVYOV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource,MeshVS_DataSource) - -//================================================================ -// Function : Constructor -// Purpose : -//================================================================ -XSDRAWSTLVRML_DataSource::XSDRAWSTLVRML_DataSource (const Handle(Poly_Triangulation)& aMesh) -{ - myMesh = aMesh; - - if( !myMesh.IsNull() ) - { - const Standard_Integer aNbNodes = myMesh->NbNodes(); - myNodeCoords = new TColStd_HArray2OfReal (1, aNbNodes, 1, 3); - std::cout << "Nodes : " << aNbNodes << std::endl; - - for (Standard_Integer i = 1; i <= aNbNodes; i++) - { - myNodes.Add( i ); - gp_Pnt xyz = myMesh->Node (i); - - myNodeCoords->SetValue(i, 1, xyz.X()); - myNodeCoords->SetValue(i, 2, xyz.Y()); - myNodeCoords->SetValue(i, 3, xyz.Z()); - } - - const Standard_Integer aNbTris = myMesh->NbTriangles(); - myElemNormals = new TColStd_HArray2OfReal(1, aNbTris, 1, 3); - myElemNodes = new TColStd_HArray2OfInteger(1, aNbTris, 1, 3); - - std::cout << "Elements : " << aNbTris << std::endl; - - for (Standard_Integer i = 1; i <= aNbTris; i++) - { - myElements.Add( i ); - - const Poly_Triangle aTri = myMesh->Triangle (i); - - Standard_Integer V[3]; - aTri.Get (V[0], V[1], V[2]); - - const gp_Pnt aP1 = myMesh->Node (V[0]); - const gp_Pnt aP2 = myMesh->Node (V[1]); - const gp_Pnt aP3 = myMesh->Node (V[2]); - - gp_Vec aV1(aP1, aP2); - gp_Vec aV2(aP2, aP3); - - gp_Vec aN = aV1.Crossed(aV2); - if (aN.SquareMagnitude() > Precision::SquareConfusion()) - aN.Normalize(); - else - aN.SetCoord(0.0, 0.0, 0.0); - - for (Standard_Integer j = 0; j < 3; j++) - { - myElemNodes->SetValue(i, j+1, V[j]); - } - - myElemNormals->SetValue (i, 1, aN.X()); - myElemNormals->SetValue (i, 2, aN.Y()); - myElemNormals->SetValue (i, 3, aN.Z()); - } - } - std::cout << "Construction is finished" << std::endl; -} - -//================================================================ -// Function : GetGeom -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource::GetGeom -( const Standard_Integer ID, const Standard_Boolean IsElement, - TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, - MeshVS_EntityType& Type ) const -{ - if( myMesh.IsNull() ) - return Standard_False; - - if( IsElement ) - { - if( ID>=1 && ID<=myElements.Extent() ) - { - Type = MeshVS_ET_Face; - NbNodes = 3; - - for( Standard_Integer i = 1, k = 1; i <= 3; i++ ) - { - Standard_Integer IdxNode = myElemNodes->Value(ID, i); - for(Standard_Integer j = 1; j <= 3; j++, k++ ) - Coords(k) = myNodeCoords->Value(IdxNode, j); - } - - return Standard_True; - } - else - return Standard_False; - } - else - if( ID>=1 && ID<=myNodes.Extent() ) - { - Type = MeshVS_ET_Node; - NbNodes = 1; - - Coords( 1 ) = myNodeCoords->Value(ID, 1); - Coords( 2 ) = myNodeCoords->Value(ID, 2); - Coords( 3 ) = myNodeCoords->Value(ID, 3); - return Standard_True; - } - else - return Standard_False; -} - -//================================================================ -// Function : GetGeomType -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource::GetGeomType -( const Standard_Integer, - const Standard_Boolean IsElement, - MeshVS_EntityType& Type ) const -{ - if( IsElement ) - { - Type = MeshVS_ET_Face; - return Standard_True; - } - else - { - Type = MeshVS_ET_Node; - return Standard_True; - } -} - -//================================================================ -// Function : GetAddr -// Purpose : -//================================================================ -Standard_Address XSDRAWSTLVRML_DataSource::GetAddr -( const Standard_Integer, const Standard_Boolean ) const -{ - return NULL; -} - -//================================================================ -// Function : GetNodesByElement -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource::GetNodesByElement -( const Standard_Integer ID, - TColStd_Array1OfInteger& theNodeIDs, - Standard_Integer& /*theNbNodes*/ ) const -{ - if( myMesh.IsNull() ) - return Standard_False; - - if( ID>=1 && ID<=myElements.Extent() && theNodeIDs.Length() >= 3 ) - { - Standard_Integer aLow = theNodeIDs.Lower(); - theNodeIDs (aLow) = myElemNodes->Value(ID, 1 ); - theNodeIDs (aLow + 1) = myElemNodes->Value(ID, 2 ); - theNodeIDs (aLow + 2) = myElemNodes->Value(ID, 3 ); - return Standard_True; - } - return Standard_False; -} - -//================================================================ -// Function : GetAllNodes -// Purpose : -//================================================================ -const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource::GetAllNodes() const -{ - return myNodes; -} - -//================================================================ -// Function : GetAllElements -// Purpose : -//================================================================ -const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource::GetAllElements() const -{ - return myElements; -} - -//================================================================ -// Function : GetNormal -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource::GetNormal -( const Standard_Integer Id, const Standard_Integer Max, - Standard_Real& nx, Standard_Real& ny,Standard_Real& nz ) const -{ - if( myMesh.IsNull() ) - return Standard_False; - - if( Id>=1 && Id<=myElements.Extent() && Max>=3 ) - { - nx = myElemNormals->Value(Id, 1); - ny = myElemNormals->Value(Id, 2); - nz = myElemNormals->Value(Id, 3); - return Standard_True; - } - else - return Standard_False; -} - diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.hxx deleted file mode 100644 index 830d114361..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource.hxx +++ /dev/null @@ -1,84 +0,0 @@ -// Created on: 2004-06-10 -// Created by: Alexander SOLOVYOV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _XSDRAWSTLVRML_DataSource_HeaderFile -#define _XSDRAWSTLVRML_DataSource_HeaderFile - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class XSDRAWSTLVRML_DataSource; -DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DataSource, MeshVS_DataSource) - -//! The sample DataSource for working with STLMesh_Mesh -class XSDRAWSTLVRML_DataSource : public MeshVS_DataSource -{ -public: - - - //! Constructor - Standard_EXPORT XSDRAWSTLVRML_DataSource(const Handle(Poly_Triangulation)& aMesh); - - //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates. - //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and - //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element. - //! It is recommended to return 1 for node. Type is an element type. - Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer ID, const Standard_Boolean IsElement, TColStd_Array1OfReal& Coords, Standard_Integer& NbNodes, MeshVS_EntityType& Type) const Standard_OVERRIDE; - - //! This method is similar to GetGeom, but returns only element or node type. This method is provided for - //! a fine performance. - Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer ID, const Standard_Boolean IsElement, MeshVS_EntityType& Type) const Standard_OVERRIDE; - - //! This method returns by number an address of any entity which represents element or node data structure. - Standard_EXPORT Standard_Address GetAddr (const Standard_Integer ID, const Standard_Boolean IsElement) const Standard_OVERRIDE; - - //! This method returns information about what node this element consist of. - Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer ID, TColStd_Array1OfInteger& NodeIDs, Standard_Integer& NbNodes) const Standard_OVERRIDE; - - //! This method returns map of all nodes the object consist of. - Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE; - - //! This method returns map of all elements the object consist of. - Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE; - - //! This method calculates normal of face, which is using for correct reflection presentation. - //! There is default method, for advance reflection this method can be redefined. - Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer Id, const Standard_Integer Max, Standard_Real& nx, Standard_Real& ny, Standard_Real& nz) const Standard_OVERRIDE; - - DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource,MeshVS_DataSource) - -protected: - -private: - - Handle(Poly_Triangulation) myMesh; - TColStd_PackedMapOfInteger myNodes; - TColStd_PackedMapOfInteger myElements; - Handle(TColStd_HArray2OfInteger) myElemNodes; - Handle(TColStd_HArray2OfReal) myNodeCoords; - Handle(TColStd_HArray2OfReal) myElemNormals; - -}; - -#endif // _XSDRAWSTLVRML_DataSource_HeaderFile diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.cxx deleted file mode 100644 index bf02c2b969..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.cxx +++ /dev/null @@ -1,385 +0,0 @@ -// Created on: 2014-08-04 -// Created by: Artem NOVIKOV -// Copyright (c) 2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource3D,MeshVS_DataSource) - -//================================================================ -// Function : Constructor -// Purpose : -//================================================================ -XSDRAWSTLVRML_DataSource3D::XSDRAWSTLVRML_DataSource3D() -{ - for (Standard_Integer aNodeID = 1; aNodeID <= 16; aNodeID++) - { - myNodes.Add( aNodeID ); - } - - for (Standard_Integer anElemID = 1; anElemID <= 5; anElemID++) - { - myElements.Add( anElemID ); - } - - myNodeCoords = new TColStd_HArray2OfReal(1, 16, 1, 3); - - myNodeCoords->SetValue( 1, 1, 5 ); - myNodeCoords->SetValue( 1, 2, 5 ); - myNodeCoords->SetValue( 1, 3, 20 ); - - myNodeCoords->SetValue( 2, 1, 0 ); - myNodeCoords->SetValue( 2, 2, 10 ); - myNodeCoords->SetValue( 2, 3, 10 ); - - myNodeCoords->SetValue( 3, 1, 10 ); - myNodeCoords->SetValue( 3, 2, 0 ); - myNodeCoords->SetValue( 3, 3, 10 ); - - myNodeCoords->SetValue( 4, 1, 0 ); - myNodeCoords->SetValue( 4, 2, 0 ); - myNodeCoords->SetValue( 4, 3, 10 ); - - myNodeCoords->SetValue( 5, 1, -10 ); - myNodeCoords->SetValue( 5, 2, 0 ); - myNodeCoords->SetValue( 5, 3, 10 ); - - myNodeCoords->SetValue( 6, 1, -10 ); - myNodeCoords->SetValue( 6, 2, 10 ); - myNodeCoords->SetValue( 6, 3, 10 ); - - myNodeCoords->SetValue( 7, 1, -10 ); - myNodeCoords->SetValue( 7, 2, 10 ); - myNodeCoords->SetValue( 7, 3, 0 ); - - myNodeCoords->SetValue( 8, 1, -10 ); - myNodeCoords->SetValue( 8, 2, 0 ); - myNodeCoords->SetValue( 8, 3, 0 ); - - myNodeCoords->SetValue( 9, 1, 0 ); - myNodeCoords->SetValue( 9, 2, 0 ); - myNodeCoords->SetValue( 9, 3, 0 ); - - myNodeCoords->SetValue( 10, 1, 0 ); - myNodeCoords->SetValue( 10, 2, 10 ); - myNodeCoords->SetValue( 10, 3, 0 ); - - myNodeCoords->SetValue( 11, 1, 0 ); - myNodeCoords->SetValue( 11, 2, -10 ); - myNodeCoords->SetValue( 11, 3, 10 ); - - myNodeCoords->SetValue( 12, 1, 10 ); - myNodeCoords->SetValue( 12, 2, -10 ); - myNodeCoords->SetValue( 12, 3, 10 ); - - myNodeCoords->SetValue( 13, 1, 10 ); - myNodeCoords->SetValue( 13, 2, -10 ); - myNodeCoords->SetValue( 13, 3, 0 ); - - myNodeCoords->SetValue( 14, 1, 0 ); - myNodeCoords->SetValue( 14, 2, -10 ); - myNodeCoords->SetValue( 14, 3, 0 ); - - myNodeCoords->SetValue( 15, 1, 10 ); - myNodeCoords->SetValue( 15, 2, 0 ); - myNodeCoords->SetValue( 15, 3, 0 ); - - myNodeCoords->SetValue( 16, 1, 5 ); - myNodeCoords->SetValue( 16, 2, 5 ); - myNodeCoords->SetValue( 16, 3, -10 ); - - myElemNbNodes = new TColStd_HArray1OfInteger(1, 5); - - myElemNbNodes->SetValue( 1, 4 ); - myElemNbNodes->SetValue( 2, 8 ); - myElemNbNodes->SetValue( 3, 6 ); - myElemNbNodes->SetValue( 4, 8 ); - myElemNbNodes->SetValue( 5, 4 ); - - myElemNodes = new TColStd_HArray2OfInteger(1, 5, 1, 8); - - myElemNodes->SetValue(1, 1, 1); - myElemNodes->SetValue(1, 2, 2); - myElemNodes->SetValue(1, 3, 3); - myElemNodes->SetValue(1, 4, 4); - - myElemNodes->SetValue(2, 1, 2); - myElemNodes->SetValue(2, 2, 4); - myElemNodes->SetValue(2, 3, 5); - myElemNodes->SetValue(2, 4, 6); - myElemNodes->SetValue(2, 5, 7); - myElemNodes->SetValue(2, 6, 8); - myElemNodes->SetValue(2, 7, 9); - myElemNodes->SetValue(2, 8, 10); - - myElemNodes->SetValue(3, 1, 2); - myElemNodes->SetValue(3, 2, 3); - myElemNodes->SetValue(3, 3, 4); - myElemNodes->SetValue(3, 4, 10); - myElemNodes->SetValue(3, 5, 15); - myElemNodes->SetValue(3, 6, 9); - - myElemNodes->SetValue(4, 1, 4); - myElemNodes->SetValue(4, 2, 3); - myElemNodes->SetValue(4, 3, 12); - myElemNodes->SetValue(4, 4, 11); - myElemNodes->SetValue(4, 5, 14); - myElemNodes->SetValue(4, 6, 13); - myElemNodes->SetValue(4, 7, 15); - myElemNodes->SetValue(4, 8, 9); - - myElemNodes->SetValue(5, 1, 16); - myElemNodes->SetValue(5, 2, 15); - myElemNodes->SetValue(5, 3, 10); - myElemNodes->SetValue(5, 4, 9); -} - -//================================================================ -// Function : GetGeom -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetGeom -( const Standard_Integer theID, const Standard_Boolean theIsElement, - TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, - MeshVS_EntityType& theType ) const -{ - if (theIsElement) - { - if (theID >= 1 && theID <= myElements.Extent()) - { - theType = MeshVS_ET_Volume; - theNbNodes = myElemNbNodes->Value(theID); - - for (Standard_Integer aNodeI = 1, aGlobCoordI = 1; aNodeI <= theNbNodes; aNodeI++) - { - Standard_Integer anIdxNode = myElemNodes->Value(theID, aNodeI); - for(Standard_Integer aCoordI = 1; aCoordI <= 3; aCoordI++, aGlobCoordI++ ) - theCoords(aGlobCoordI) = myNodeCoords->Value(anIdxNode, aCoordI); - } - - return Standard_True; - } - else - return Standard_False; - } - else - if (theID >= 1 && theID <= myNodes.Extent()) - { - theType = MeshVS_ET_Node; - theNbNodes = 1; - - theCoords( 1 ) = myNodeCoords->Value(theID, 1); - theCoords( 2 ) = myNodeCoords->Value(theID, 2); - theCoords( 3 ) = myNodeCoords->Value(theID, 3); - return Standard_True; - } - else - return Standard_False; -} - -//================================================================ -// Function : Get3DGeom -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource3D::Get3DGeom -( const Standard_Integer theID, Standard_Integer& theNbNodes, - Handle(MeshVS_HArray1OfSequenceOfInteger)& theData ) const -{ - Handle(MeshVS_HArray1OfSequenceOfInteger) aMeshData; - if (theID == 1 || theID == 5) - { - aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,4); - theNbNodes = 4; - for (Standard_Integer anElemI = 1; anElemI <= 4; anElemI++) - { - aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) % 4 ); - aMeshData->ChangeValue(anElemI).Append( anElemI % 4 ); - aMeshData->ChangeValue(anElemI).Append( (anElemI + 1) % 4 ); - } - theData = aMeshData; - return Standard_True; - } - - if (theID == 2 || theID == 4) - { - aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,6); - theNbNodes = 8; - for (Standard_Integer anElemI = 1, k = 1; anElemI <= 4; anElemI++) - { - aMeshData->ChangeValue(anElemI).Append( (k - 1) % 8 ); - aMeshData->ChangeValue(anElemI).Append( k % 8 ); - aMeshData->ChangeValue(anElemI).Append( (k + 1) % 8 ); - aMeshData->ChangeValue(anElemI).Append( (k + 2) % 8 ); - k+=2; - } - - aMeshData->ChangeValue(5).Append( 0 ); - aMeshData->ChangeValue(5).Append( 3 ); - aMeshData->ChangeValue(5).Append( 4 ); - aMeshData->ChangeValue(5).Append( 7 ); - - aMeshData->ChangeValue(6).Append( 1 ); - aMeshData->ChangeValue(6).Append( 2 ); - aMeshData->ChangeValue(6).Append( 5 ); - aMeshData->ChangeValue(6).Append( 6 ); - - theData = aMeshData; - return Standard_True; - } - - if (theID == 3) - { - aMeshData = new MeshVS_HArray1OfSequenceOfInteger(1,5); - theNbNodes = 6; - for (Standard_Integer anElemI = 1; anElemI <= 2; anElemI++) - { - aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 ); - aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 1 ); - aMeshData->ChangeValue(anElemI).Append( (anElemI - 1) * 3 + 2 ); - } - for (Standard_Integer anElemI = 1; anElemI <= 3; anElemI++) - { - aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 ); - aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 ); - aMeshData->ChangeValue(2 + anElemI).Append( anElemI % 3 + 3 ); - aMeshData->ChangeValue(2 + anElemI).Append( (anElemI - 1) % 3 + 3 ); - } - theData = aMeshData; - return Standard_True; - } - - return Standard_False; -} - -//================================================================ -// Function : GetGeomType -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetGeomType -( const Standard_Integer theID, - const Standard_Boolean theIsElement, - MeshVS_EntityType& theType ) const -{ - if (theIsElement) - { - if (theID >= 1 && theID <= myElements.Extent()) - { - theType = MeshVS_ET_Volume; - return Standard_True; - } - } - else - if (theID >= 1 && theID <= myNodes.Extent()) - { - theType = MeshVS_ET_Node; - return Standard_True; - } - - return Standard_False; -} - -//================================================================ -// Function : GetAddr -// Purpose : -//================================================================ -Standard_Address XSDRAWSTLVRML_DataSource3D::GetAddr -( const Standard_Integer, const Standard_Boolean ) const -{ - return NULL; -} - -//================================================================ -// Function : GetNodesByElement -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetNodesByElement -( const Standard_Integer theID, - TColStd_Array1OfInteger& theNodeIDs, - Standard_Integer& theNbNodes ) const -{ - Standard_Integer aLow; - if (theID == 1 || theID == 5) - { - theNbNodes = 4; - aLow = theNodeIDs.Lower(); - theNodeIDs (aLow) = myElemNodes->Value(theID, 1 ); - theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 ); - theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 ); - theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 ); - return Standard_True; - } - - if (theID == 2 || theID == 4) - { - theNbNodes = 8; - aLow = theNodeIDs.Lower(); - theNodeIDs (aLow) = myElemNodes->Value(theID, 1 ); - theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 ); - theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 ); - theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 ); - theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 ); - theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 ); - theNodeIDs (aLow + 6) = myElemNodes->Value(theID, 7 ); - theNodeIDs (aLow + 7) = myElemNodes->Value(theID, 8 ); - return Standard_True; - } - - if (theID == 3) - { - theNbNodes = 6; - aLow = theNodeIDs.Lower(); - theNodeIDs (aLow) = myElemNodes->Value(theID, 1 ); - theNodeIDs (aLow + 1) = myElemNodes->Value(theID, 2 ); - theNodeIDs (aLow + 2) = myElemNodes->Value(theID, 3 ); - theNodeIDs (aLow + 3) = myElemNodes->Value(theID, 4 ); - theNodeIDs (aLow + 4) = myElemNodes->Value(theID, 5 ); - theNodeIDs (aLow + 5) = myElemNodes->Value(theID, 6 ); - return Standard_True; - } - - return Standard_False; -} - -//================================================================ -// Function : GetAllNodes -// Purpose : -//================================================================ -const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource3D::GetAllNodes() const -{ - return myNodes; -} - -//================================================================ -// Function : GetAllElements -// Purpose : -//================================================================ -const TColStd_PackedMapOfInteger& XSDRAWSTLVRML_DataSource3D::GetAllElements() const -{ - return myElements; -} - -//================================================================ -// Function : GetNormal -// Purpose : -//================================================================ -Standard_Boolean XSDRAWSTLVRML_DataSource3D::GetNormal -( const Standard_Integer /*theID*/, const Standard_Integer /*theMax*/, - Standard_Real& /*theNx*/, Standard_Real& /*theNy*/,Standard_Real& /*theNz*/ ) const -{ - return Standard_False; -} diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.hxx deleted file mode 100644 index ced66f94ef..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DataSource3D.hxx +++ /dev/null @@ -1,89 +0,0 @@ -// Created on: 2014-08-04 -// Created by: Artem NOVIKOV -// Copyright (c) 2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _XSDRAWSTLVRML_DataSource3D_HeaderFile -#define _XSDRAWSTLVRML_DataSource3D_HeaderFile - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class XSDRAWSTLVRML_DataSource3D; -DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DataSource3D, MeshVS_DataSource) - -//! The sample DataSource3D for working with STLMesh_Mesh -class XSDRAWSTLVRML_DataSource3D : public MeshVS_DataSource -{ -public: - - - //! Constructor - Standard_EXPORT XSDRAWSTLVRML_DataSource3D(); - - //! Returns geometry information about node (if IsElement is False) or element (IsElement is True) by coordinates. - //! For element this method must return all its nodes coordinates in the strict order: X, Y, Z and - //! with nodes order is the same as in wire bounding the face or link. NbNodes is number of nodes of element. - //! It is recommended to return 1 for node. Type is an element type. - Standard_EXPORT Standard_Boolean GetGeom (const Standard_Integer theID, const Standard_Boolean theIsElement, TColStd_Array1OfReal& theCoords, Standard_Integer& theNbNodes, MeshVS_EntityType& theType) const Standard_OVERRIDE; - - //! This method returns topology information about 3D-element - //! Returns false if element with ID isn't 3D or because other troubles - Standard_EXPORT virtual Standard_Boolean Get3DGeom (const Standard_Integer theID, Standard_Integer& theNbNodes, Handle(MeshVS_HArray1OfSequenceOfInteger)& theData) const Standard_OVERRIDE; - - //! This method is similar to GetGeom, but returns only element or node type. This method is provided for - //! a fine performance. - Standard_EXPORT Standard_Boolean GetGeomType (const Standard_Integer theID, const Standard_Boolean theIsElement, MeshVS_EntityType& theType) const Standard_OVERRIDE; - - //! This method returns by number an address of any entity which represents element or node data structure. - Standard_EXPORT Standard_Address GetAddr (const Standard_Integer theID, const Standard_Boolean theIsElement) const Standard_OVERRIDE; - - //! This method returns information about what node this element consist of. - Standard_EXPORT virtual Standard_Boolean GetNodesByElement (const Standard_Integer theID, TColStd_Array1OfInteger& theNodeIDs, Standard_Integer& theNbNodes) const Standard_OVERRIDE; - - //! This method returns map of all nodes the object consist of. - Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllNodes() const Standard_OVERRIDE; - - //! This method returns map of all elements the object consist of. - Standard_EXPORT const TColStd_PackedMapOfInteger& GetAllElements() const Standard_OVERRIDE; - - //! This method calculates normal of face, which is using for correct reflection presentation. - //! There is default method, for advance reflection this method can be redefined. - Standard_EXPORT virtual Standard_Boolean GetNormal (const Standard_Integer theID, const Standard_Integer theMax, Standard_Real& theNx, Standard_Real& theNy, Standard_Real& theNz) const Standard_OVERRIDE; - - DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DataSource3D,MeshVS_DataSource) - -protected: - -private: - - TColStd_PackedMapOfInteger myNodes; - TColStd_PackedMapOfInteger myElements; - Handle(TColStd_HArray1OfInteger) myElemNbNodes; - Handle(TColStd_HArray2OfReal) myNodeCoords; - Handle(TColStd_HArray2OfInteger) myElemNodes; - -}; - -#endif // _XSDRAWSTLVRML_DataSource3D_HeaderFile diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.cxx deleted file mode 100644 index 73d8a568a6..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// Created on: 2004-06-11 -// Created by: Alexander SOLOVYOV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(XSDRAWSTLVRML_DrawableMesh,Draw_Drawable3D) - -//================================================================ -// Function : DrawOn -// Purpose : -//================================================================ -XSDRAWSTLVRML_DrawableMesh::XSDRAWSTLVRML_DrawableMesh( const Handle( MeshVS_Mesh )& aMesh ) -{ - myMesh = aMesh; -} - -//================================================================ -// Function : -// Purpose : -//================================================================ -void XSDRAWSTLVRML_DrawableMesh::DrawOn(Draw_Display& /*d*/) const -{ -} - -//================================================================ -// Function : -// Purpose : -//================================================================ -Handle( MeshVS_Mesh ) XSDRAWSTLVRML_DrawableMesh::GetMesh() const -{ - return myMesh; -} diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.hxx deleted file mode 100644 index b87a0590a3..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_DrawableMesh.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Created on: 2004-06-11 -// Created by: Alexander SOLOVYOV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _XSDRAWSTLVRML_DrawableMesh_HeaderFile -#define _XSDRAWSTLVRML_DrawableMesh_HeaderFile - -#include -#include - -#include -class MeshVS_Mesh; -class Draw_Display; - -class XSDRAWSTLVRML_DrawableMesh; -DEFINE_STANDARD_HANDLE(XSDRAWSTLVRML_DrawableMesh, Draw_Drawable3D) - -class XSDRAWSTLVRML_DrawableMesh : public Draw_Drawable3D -{ -public: - - - Standard_EXPORT XSDRAWSTLVRML_DrawableMesh(const Handle(MeshVS_Mesh)& aMesh); - - Standard_EXPORT virtual void DrawOn (Draw_Display& dis) const Standard_OVERRIDE; - - Standard_EXPORT Handle(MeshVS_Mesh) GetMesh() const; - - DEFINE_STANDARD_RTTIEXT(XSDRAWSTLVRML_DrawableMesh,Draw_Drawable3D) - -protected: - -private: - - Handle(MeshVS_Mesh) myMesh; - -}; - -#endif // _XSDRAWSTLVRML_DrawableMesh_HeaderFile diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_ElemNodesMap.hxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML_ElemNodesMap.hxx deleted file mode 100644 index bf225b5849..0000000000 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML_ElemNodesMap.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 2000-05-30 -// Created by: Sergey MOZOKHIN -// Copyright (c) 2000-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef XSDRAWSTLVRML_ElemNodesMap_HeaderFile -#define XSDRAWSTLVRML_ElemNodesMap_HeaderFile - -#include -#include -#include - -typedef NCollection_DataMap XSDRAWSTLVRML_ElemNodesMap; -typedef NCollection_DataMap::Iterator XSDRAWSTLVRML_DataMapIteratorOfElemNodesMap; - -#endif diff --git a/src/XSDRAWVRML/XSDRAWVRML.cxx b/src/XSDRAWVRML/XSDRAWVRML.cxx index 6f4bb9b54c..69260cedb2 100644 --- a/src/XSDRAWVRML/XSDRAWVRML.cxx +++ b/src/XSDRAWVRML/XSDRAWVRML.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -304,8 +306,9 @@ void XSDRAWVRML::Factory(Draw_Interpretor& theDI) } anInitActor = Standard_True; - Standard_CString aGroup = "XDE translation commands"; + DE_Wrapper::GlobalWrapper()->Bind(new Vrml_ConfigurationNode()); + Standard_CString aGroup = "XDE translation commands"; theDI.Add("ReadVrml", "ReadVrml docName filePath [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" "\n\t\t: [-systemCoordSys {Zup|Yup}] [-noCreateDoc] [-fillIncomplete {ON|OFF}]" @@ -324,6 +327,5 @@ void XSDRAWVRML::Factory(Draw_Interpretor& theDI) theDI.Add("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]", __FILE__, writevrml, aGroup); } - // Declare entry point PLUGINFACTORY DPLUGIN(XSDRAWVRML) diff --git a/tests/de_wrapper/begin b/tests/de_wrapper/begin index 23c0924765..bf542f9c5b 100644 --- a/tests/de_wrapper/begin +++ b/tests/de_wrapper/begin @@ -1,5 +1,3 @@ # File: begin -pload XDE -pload OCAF -pload TOPTEST +pload XDEDRAW XSDRAW DEWrapper OCAF TOPTEST diff --git a/tests/de_wrapper/configuration/begin b/tests/de_wrapper/configuration/begin index aa519b2262..f48021b9ae 100644 --- a/tests/de_wrapper/configuration/begin +++ b/tests/de_wrapper/configuration/begin @@ -1,5 +1,7 @@ # File : begin +pload XDE + proc changeconf {value conf} { set res "" foreach iter [split $conf \n] { diff --git a/tests/de_wrapper/gltf/begin b/tests/de_wrapper/gltf/begin index c70f737cda..ebe07a17d0 100644 --- a/tests/de_wrapper/gltf/begin +++ b/tests/de_wrapper/gltf/begin @@ -1,3 +1,5 @@ # File: begin +pload GLTF + set filename [locate_data_file "bug31302_NormalTangentTest.gltf"] diff --git a/tests/de_wrapper/iges/begin b/tests/de_wrapper/iges/begin index b53aeaefab..951aa666f4 100644 --- a/tests/de_wrapper/iges/begin +++ b/tests/de_wrapper/iges/begin @@ -1,4 +1,6 @@ # File: begin +pload IGES + set filename [locate_data_file "bug22869_Spring.igs"] diff --git a/tests/de_wrapper/obj/begin b/tests/de_wrapper/obj/begin index 2f3de9070b..a6388601ba 100644 --- a/tests/de_wrapper/obj/begin +++ b/tests/de_wrapper/obj/begin @@ -1,3 +1,5 @@ # File: begin +pload OBJ + set filename [locate_data_file "P-51 Mustang.obj"] diff --git a/tests/de_wrapper/ply/begin b/tests/de_wrapper/ply/begin index 2f3de9070b..0e888c313b 100644 --- a/tests/de_wrapper/ply/begin +++ b/tests/de_wrapper/ply/begin @@ -1,3 +1,5 @@ # File: begin +pload PLY OBJ + set filename [locate_data_file "P-51 Mustang.obj"] diff --git a/tests/de_wrapper/step/begin b/tests/de_wrapper/step/begin index 293bbce9fe..935d5ac584 100644 --- a/tests/de_wrapper/step/begin +++ b/tests/de_wrapper/step/begin @@ -1,3 +1,5 @@ # File: begin +pload STEP + set filename [locate_data_file "bm2_pe_t4-A.stp"] diff --git a/tests/de_wrapper/stl/begin b/tests/de_wrapper/stl/begin index 5710679506..06619e820f 100644 --- a/tests/de_wrapper/stl/begin +++ b/tests/de_wrapper/stl/begin @@ -1,4 +1,5 @@ # File: begin -pload MODELING +pload MODELING STL + set filename [locate_data_file "model_stl_001.stl"] diff --git a/tests/de_wrapper/vrml/begin b/tests/de_wrapper/vrml/begin index 1a45cc451f..428b22ce30 100644 --- a/tests/de_wrapper/vrml/begin +++ b/tests/de_wrapper/vrml/begin @@ -1,3 +1,5 @@ # File: begin +pload VRML + set filename [locate_data_file "bug29597_vrml2.wrl"] diff --git a/tests/v3d/bugs/bug23407_1 b/tests/v3d/bugs/bug23407_1 index ade491da38..e83fab6c5d 100644 --- a/tests/v3d/bugs/bug23407_1 +++ b/tests/v3d/bugs/bug23407_1 @@ -3,7 +3,7 @@ puts "CR23407: Draw face outlines for XDE objects" puts "============" puts "" -pload XDEDRAW VISUALIZATION +pload XDEDRAW STEP VISUALIZATION XNewDoc Doc1 ReadStep Doc1 [locate_data_file screw.step] diff --git a/tests/vselect/face/G2 b/tests/vselect/face/G2 index 20d68ba069..1681482308 100644 --- a/tests/vselect/face/G2 +++ b/tests/vselect/face/G2 @@ -2,7 +2,7 @@ puts "========" puts "0029356: Modeling Algorithms - GCPnts_TangentialDeflection hangs on specific curve" puts "========" -if {[info commands testreadiges] == ""} {pload XSDRAW} +pload IGES testreadiges [locate_data_file bug29356.igs] a vinit View1 diff --git a/tests/vselect/face/G3 b/tests/vselect/face/G3 index 5f6968f5e6..0bf015c159 100644 --- a/tests/vselect/face/G3 +++ b/tests/vselect/face/G3 @@ -1,6 +1,6 @@ # isolines on infinite prism based on spline edge with poles closed to 1.4e+6 -if {[info commands testreadiges] == ""} {pload XSDRAW} +pload IGES testreadiges [locate_data_file bug29356.igs] a mksurface s a diff --git a/tests/vselect/face/G4 b/tests/vselect/face/G4 index da03c8eb1c..e6e49dd726 100644 --- a/tests/vselect/face/G4 +++ b/tests/vselect/face/G4 @@ -1,6 +1,6 @@ # isolines on finite prism based on spline edge with poles closed to 1.4e+6 -if {[info commands testreadiges] == ""} {pload XSDRAW} +pload IGES testreadiges [locate_data_file bug29356.igs] a mksurface s a