From 6b4fa7a2570bac9ce5d8f27da4c8d0cf3217dc0b Mon Sep 17 00:00:00 2001 From: dpasukhi Date: Sun, 8 Jan 2023 13:54:53 +0000 Subject: [PATCH] // new iteration of updating --- adm/MODULES | 2 +- src/IFSelect/FILES | 2 - src/IFSelect/IFSelect_Functions.cxx | 2550 --------------- src/IFSelect/IFSelect_Functions.hxx | 78 - src/TKXSDRAWBase/CMakeLists.txt | 3 + src/TKXSDRAWBase/EXTERNLIB | 24 + src/TKXSDRAWBase/FILES | 2 + src/TKXSDRAWBase/PACKAGES | 1 + src/TKXSDRAWDEWrapper/CMakeLists.txt | 3 + src/TKXSDRAWDEWrapper/EXTERNLIB | 24 + src/TKXSDRAWDEWrapper/FILES | 2 + src/TKXSDRAWDEWrapper/PACKAGES | 1 + src/TKXSDRAWGLTF/CMakeLists.txt | 3 + src/TKXSDRAWGLTF/EXTERNLIB | 24 + src/TKXSDRAWGLTF/FILES | 2 + src/TKXSDRAWGLTF/PACKAGES | 1 + src/TKXSDRAWIGES/CMakeLists.txt | 3 + src/TKXSDRAWIGES/EXTERNLIB | 24 + src/TKXSDRAWIGES/FILES | 2 + src/TKXSDRAWIGES/PACKAGES | 1 + src/TKXSDRAWOBJ/CMakeLists.txt | 3 + src/TKXSDRAWOBJ/EXTERNLIB | 24 + src/TKXSDRAWOBJ/FILES | 2 + src/TKXSDRAWOBJ/PACKAGES | 1 + src/TKXSDRAWPLY/CMakeLists.txt | 3 + src/TKXSDRAWPLY/EXTERNLIB | 24 + src/TKXSDRAWPLY/FILES | 2 + src/TKXSDRAWPLY/PACKAGES | 1 + src/TKXSDRAWSTEP/CMakeLists.txt | 3 + src/TKXSDRAWSTEP/EXTERNLIB | 24 + src/TKXSDRAWSTEP/FILES | 2 + src/TKXSDRAWSTEP/PACKAGES | 1 + src/TKXSDRAWSTL/CMakeLists.txt | 3 + src/TKXSDRAWSTL/EXTERNLIB | 24 + src/TKXSDRAWSTL/FILES | 2 + src/TKXSDRAWSTL/PACKAGES | 1 + src/TKXSDRAWVRML/CMakeLists.txt | 3 + src/TKXSDRAWVRML/EXTERNLIB | 24 + src/TKXSDRAWVRML/FILES | 2 + src/TKXSDRAWVRML/PACKAGES | 1 + src/XDEDRAW/XDEDRAW_Common.cxx | 911 ------ src/XDEDRAW/XDEDRAW_Common.hxx | 2 - src/XSControl/FILES | 4 - src/XSControl/XSControl_FuncShape.cxx | 834 ----- src/XSControl/XSControl_FuncShape.hxx | 99 - src/XSControl/XSControl_Functions.cxx | 505 --- src/XSDRAW/FILES | 6 +- src/XSDRAW/XSDRAW.hxx | 2 +- src/XSDRAW/XSDRAW_Functions.cxx | 488 ++- src/XSDRAW/XSDRAW_Functions.hxx | 31 +- src/XSDRAW/XSDRAW_FunctionsSession.cxx | 2773 +++++++++++++++++ .../XSDRAW_FunctionsSession.hxx} | 28 +- src/XSDRAW/XSDRAW_FunctionsShape.cxx | 780 +++++ src/XSDRAW/XSDRAW_FunctionsShape.hxx | 39 + src/XSDRAW/XSDRAW_Vars.cxx | 115 - src/XSDRAW/XSDRAW_Vars.hxx | 91 - src/XSDRAWBase/FILES | 2 + src/XSDRAWBase/XSDRAWBase.cxx | 614 ++++ src/XSDRAWBase/XSDRAWBase.hxx | 205 ++ src/XSDRAWDEWrapper/FILES | 2 + src/XSDRAWDEWrapper/XSDRAWDEWrapper.cxx | 433 +++ src/XSDRAWDEWrapper/XSDRAWDEWrapper.hxx | 33 + src/XSDRAWGLTF/FILES | 2 + src/XSDRAWGLTF/XSDRAWGLTF.cxx | 717 +++++ src/XSDRAWGLTF/XSDRAWGLTF.hxx | 33 + src/XSDRAWIGES/XSDRAWIGES.cxx | 891 +++--- src/XSDRAWIGES/XSDRAWIGES.hxx | 43 +- src/XSDRAWOBJ/FILES | 2 + src/XSDRAWOBJ/XSDRAWOBJ.cxx | 522 ++++ src/XSDRAWOBJ/XSDRAWOBJ.hxx | 33 + src/XSDRAWPLY/FILES | 2 + src/XSDRAWPLY/XSDRAWPLY.cxx | 542 ++++ src/XSDRAWPLY/XSDRAWPLY.hxx | 33 + src/XSDRAWSTEP/XSDRAWSTEP.cxx | 782 +++-- src/XSDRAWSTEP/XSDRAWSTEP.hxx | 39 +- src/XSDRAWSTL/FILES | 2 + src/XSDRAWSTL/XSDRAWSTL.cxx | 369 +++ src/XSDRAWSTL/XSDRAWSTL.hxx | 33 + src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx | 1317 -------- src/XSDRAWVRML/FILES | 2 + src/XSDRAWVRML/XSDRAWVRML.cxx | 317 ++ src/XSDRAWVRML/XSDRAWVRML.hxx | 33 + 82 files changed, 9421 insertions(+), 7192 deletions(-) delete mode 100644 src/IFSelect/IFSelect_Functions.cxx delete mode 100644 src/IFSelect/IFSelect_Functions.hxx create mode 100644 src/TKXSDRAWBase/CMakeLists.txt create mode 100644 src/TKXSDRAWBase/EXTERNLIB create mode 100644 src/TKXSDRAWBase/FILES create mode 100644 src/TKXSDRAWBase/PACKAGES create mode 100644 src/TKXSDRAWDEWrapper/CMakeLists.txt create mode 100644 src/TKXSDRAWDEWrapper/EXTERNLIB create mode 100644 src/TKXSDRAWDEWrapper/FILES create mode 100644 src/TKXSDRAWDEWrapper/PACKAGES create mode 100644 src/TKXSDRAWGLTF/CMakeLists.txt create mode 100644 src/TKXSDRAWGLTF/EXTERNLIB create mode 100644 src/TKXSDRAWGLTF/FILES create mode 100644 src/TKXSDRAWGLTF/PACKAGES create mode 100644 src/TKXSDRAWIGES/CMakeLists.txt create mode 100644 src/TKXSDRAWIGES/EXTERNLIB create mode 100644 src/TKXSDRAWIGES/FILES create mode 100644 src/TKXSDRAWIGES/PACKAGES create mode 100644 src/TKXSDRAWOBJ/CMakeLists.txt create mode 100644 src/TKXSDRAWOBJ/EXTERNLIB create mode 100644 src/TKXSDRAWOBJ/FILES create mode 100644 src/TKXSDRAWOBJ/PACKAGES create mode 100644 src/TKXSDRAWPLY/CMakeLists.txt create mode 100644 src/TKXSDRAWPLY/EXTERNLIB create mode 100644 src/TKXSDRAWPLY/FILES create mode 100644 src/TKXSDRAWPLY/PACKAGES create mode 100644 src/TKXSDRAWSTEP/CMakeLists.txt create mode 100644 src/TKXSDRAWSTEP/EXTERNLIB create mode 100644 src/TKXSDRAWSTEP/FILES create mode 100644 src/TKXSDRAWSTEP/PACKAGES create mode 100644 src/TKXSDRAWSTL/CMakeLists.txt create mode 100644 src/TKXSDRAWSTL/EXTERNLIB create mode 100644 src/TKXSDRAWSTL/FILES create mode 100644 src/TKXSDRAWSTL/PACKAGES create mode 100644 src/TKXSDRAWVRML/CMakeLists.txt create mode 100644 src/TKXSDRAWVRML/EXTERNLIB create mode 100644 src/TKXSDRAWVRML/FILES create mode 100644 src/TKXSDRAWVRML/PACKAGES delete mode 100644 src/XSControl/XSControl_FuncShape.cxx delete mode 100644 src/XSControl/XSControl_FuncShape.hxx delete mode 100644 src/XSControl/XSControl_Functions.cxx create mode 100644 src/XSDRAW/XSDRAW_FunctionsSession.cxx rename src/{XSControl/XSControl_Functions.hxx => XSDRAW/XSDRAW_FunctionsSession.hxx} (55%) create mode 100644 src/XSDRAW/XSDRAW_FunctionsShape.cxx create mode 100644 src/XSDRAW/XSDRAW_FunctionsShape.hxx delete mode 100644 src/XSDRAW/XSDRAW_Vars.cxx delete mode 100644 src/XSDRAW/XSDRAW_Vars.hxx create mode 100644 src/XSDRAWBase/FILES create mode 100644 src/XSDRAWBase/XSDRAWBase.cxx create mode 100644 src/XSDRAWBase/XSDRAWBase.hxx create mode 100644 src/XSDRAWDEWrapper/FILES create mode 100644 src/XSDRAWDEWrapper/XSDRAWDEWrapper.cxx create mode 100644 src/XSDRAWDEWrapper/XSDRAWDEWrapper.hxx create mode 100644 src/XSDRAWGLTF/FILES create mode 100644 src/XSDRAWGLTF/XSDRAWGLTF.cxx create mode 100644 src/XSDRAWGLTF/XSDRAWGLTF.hxx create mode 100644 src/XSDRAWOBJ/FILES create mode 100644 src/XSDRAWOBJ/XSDRAWOBJ.cxx create mode 100644 src/XSDRAWOBJ/XSDRAWOBJ.hxx create mode 100644 src/XSDRAWPLY/FILES create mode 100644 src/XSDRAWPLY/XSDRAWPLY.cxx create mode 100644 src/XSDRAWPLY/XSDRAWPLY.hxx create mode 100644 src/XSDRAWSTL/FILES create mode 100644 src/XSDRAWSTL/XSDRAWSTL.cxx create mode 100644 src/XSDRAWSTL/XSDRAWSTL.hxx create mode 100644 src/XSDRAWVRML/FILES create mode 100644 src/XSDRAWVRML/XSDRAWVRML.cxx create mode 100644 src/XSDRAWVRML/XSDRAWVRML.hxx diff --git a/adm/MODULES b/adm/MODULES index f471f8dc8d..e769ea6b35 100644 --- a/adm/MODULES +++ b/adm/MODULES @@ -4,4 +4,4 @@ ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffs Visualization TKService TKV3d TKOpenGl TKOpenGles TKMeshVS TKIVtk TKD3DHost ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml TKStdL TKStd TKTObj TKBinTObj TKXmlTObj TKVCAF DataExchange TKXDE TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF TKRWMesh TKXDECascade TKExpress ExpToCasExe -Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE +Draw TKDraw TKTopTest TKOpenGlTest TKOpenGlesTest TKD3DHostTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE TKXSDRAWBase TKXSDRAWDEWrapper TKXSDRAWGLTF TKXSDRAWIGES TKXSDRAWOBJ TKXSDRAWPLY TKXSDRAWSTEP TKXSDRAWSTL TKXSDRAWVRML diff --git a/src/IFSelect/FILES b/src/IFSelect/FILES index 5cbd79df59..ba23651fe8 100755 --- a/src/IFSelect/FILES +++ b/src/IFSelect/FILES @@ -33,8 +33,6 @@ IFSelect_Editor.cxx IFSelect_Editor.hxx IFSelect_EditValue.hxx IFSelect_FileModifier.gxx -IFSelect_Functions.cxx -IFSelect_Functions.hxx IFSelect_GeneralModifier.cxx IFSelect_GeneralModifier.hxx IFSelect_GraphCounter.cxx diff --git a/src/IFSelect/IFSelect_Functions.cxx b/src/IFSelect/IFSelect_Functions.cxx deleted file mode 100644 index c044591316..0000000000 --- a/src/IFSelect/IFSelect_Functions.cxx +++ /dev/null @@ -1,2550 +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. - -//#58 rln 28.12.98 Versioning - -#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 -// Decomposition of a file name in its parts : prefix, root, suffix -static void SplitFileName - (const Standard_CString filename, - TCollection_AsciiString& prefix, - TCollection_AsciiString& fileroot, - TCollection_AsciiString& suffix) -{ - Standard_Integer nomdeb, nomfin, nomlon; - TCollection_AsciiString resfile (filename); - nomlon = resfile.Length(); - nomdeb = resfile.SearchFromEnd ("/"); - if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT - if (nomdeb < 0) nomdeb = 0; - nomfin = resfile.SearchFromEnd ("."); - if (nomfin < nomdeb) nomfin = nomlon + 1; - - if (nomdeb > 0) prefix = resfile.SubString (1,nomdeb); - fileroot = resfile.SubString(nomdeb+1,nomfin-1); - if (nomfin <= nomlon) suffix = resfile.SubString (nomfin,nomlon); -} - - - -// Functions definit un certain nombre de commandes -// enregistrees dans le Dictionnaire de Activator (par des Act unitaires) -// Les actions elles-memes sont regroupees en fin de fichier - -// Les definitions - -static IFSelect_ReturnStatus funstatus - (const Handle(IFSelect_SessionPilot)& ) -{ -// **** Version & cie **** - //#58 rln - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout<<"Processor Version : "<Session(); -// **** ToggleHandler **** - Standard_Boolean hand = !WS->ErrorHandle(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (hand) sout << " -- Mode Catch Error now Active" <SetErrorHandle(hand); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun3 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** XRead / Load **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Read/Load : give file name !"<Protocol().IsNull()) { sout<<"Protocol not defined"<WorkLibrary().IsNull()) { sout<<"WorkLibrary not defined"<ReadFile (arg1); -// status : 0 OK, 1 erreur lecture, 2 Fail(try/catch), -// -1 fichier non trouve, -2 lecture faite mais resultat vide - switch (status) { - case IFSelect_RetVoid : sout<<"file:"<BeginSentFiles(Standard_True); - return status; -} - -static IFSelect_ReturnStatus fun4 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Write All **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Write All : give file name !"<SendAll (arg1); -} - -static IFSelect_ReturnStatus fun5 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// const Standard_CString arg2 = pilot->Arg(2); -// **** Write Selected **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Write Selected : give file name + givelist !"<CommandPart( 2)); - if (result.IsNull()) { sout<<"No entity selected"<Length()<SetList (result); - return WS->SendSelected (arg1,sp); -} - -static IFSelect_ReturnStatus fun6 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Write Entite(s) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Write Entitie(s) : give file name + n0s entitie(s)!"<Number(pilot->Arg(ia)); - if (id > 0) { - Handle(Standard_Transient) item = WS->StartingEntity(id); - if (sp->Add(item)) sout<<"Added:no."<Arg(ia)< 0) { sout<SendSelected (arg1,sp); -} - -static IFSelect_ReturnStatus fun7 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Entity Label **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give entity number"<HasModel()) { sout<<"No loaded model, abandon"<NumberFromLabel (arg1); - if (nument <= 0 || nument > WS->NbStartingEntities()) - { sout<<"Not a suitable number: "<Label in Model : "; - WS->Model()->PrintLabel(WS->StartingEntity(nument), sout); - sout<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Entity Number **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give label to search"<HasModel()) { sout<<"No loaded model, abandon"<Model(); - Standard_Integer i, cnt = 0; - Standard_Boolean exact = Standard_False; - sout<<" ** Search Entity Number for Label : "<NextNumberForLabel (arg1, 0, exact) ; i != 0; - i = model->NextNumberForLabel (arg1, i, exact)) { - cnt ++; - sout<<" ** Found n0/id:"; - model->Print (model->Value(i), sout); - sout<Session(); - Handle(IFSelect_Signature) signtype = WS->SignType(); - if (signtype.IsNull()) signtype = new IFSelect_SignType; - Handle(IFSelect_SignCounter) counter = - new IFSelect_SignCounter(signtype,Standard_False); - return pilot->ExecuteCounter (counter,1); -} - -static IFSelect_ReturnStatus funcount - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg0 = pilot->Arg(0); - const Standard_CString arg1 = pilot->Arg(1); - Standard_Boolean listmode = (arg0[0] == 'l'); -// **** List Counter **** - - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - sout<<"Designer signature ou compteur, + facultatif selection + facultatif entite"< tout le modele"< cette selection, evaluation normale"< cette selection evaluee sur entite n0 num"<NamedItem(arg1)); - if (counter.IsNull()) { - DeclareAndCast(IFSelect_Signature,signa,WS->NamedItem(arg1)); - if (!signa.IsNull()) counter = new IFSelect_SignCounter(signa,Standard_False,listmode); - } -// Handle(IFSelect_Selection) sel; -// Standard_Integer n3 = 0; if (argc > 3) n3 = WS->NumberFromLabel(arg3); -// if (argc > 2) sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2)); -// if (counter.IsNull() || (argc > 2 && n3 <= 0 && sel.IsNull()) ) { -// sout<<"Nom:"< 2) sout<<" et/ou "<Arg(i),"on")) { onflag = i; break; } - } - - Handle(IFSelect_Selection) sel = WS->GiveSelection(arg1); - DeclareAndCast(IFSelect_SelectDeduct,seld,sel); - if (!seld.IsNull()) { -// Si onflag, faire une SelectSuite - if (onflag > 2) { - Handle(IFSelect_SelectSuite) suite = new IFSelect_SelectSuite; - for (i = 1; i < onflag; i ++) { - sel = WS->GiveSelection(pilot->Arg(i)); - if (!suite->AddInput(sel)) { - sout<<"Incorrect definition for applied selection"<SetApplied (seld); - counter = gc; - } - - if (counter.IsNull()) { - sout<<"Neither Counter nor Signature : "<ExecuteCounter (counter,onflag+1, pcm); -} - -static IFSelect_ReturnStatus funsigntype - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Sign Type **** - Handle(IFSelect_Signature) signtype = WS->SignType(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (signtype.IsNull()) sout<<"signtype actually undefined"<Name (signtype); - Standard_Integer id = WS->ItemIdent (signtype); - sout<Label()< 0) sout<<"signtype : item n0 "<ToCString()<NamedItem(arg1)); - if (signtype.IsNull()) { sout<<"Not a Signature : "<SetSignType(signtype); - return IFSelect_RetDone; - } - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus funsigncase - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Sign Case **** - Handle(IFSelect_Signature) signcase = GetCasted(IFSelect_Signature,WS->NamedItem(arg1)); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (signcase.IsNull()) sout<<"Not a Signature : "<IsIntCase(hasmin,valmin,hasmax,valmax)) { - sout<<"Signature "<CaseList(); - if (caselist.IsNull()) sout<<"Signature "<Length(); - sout<<"Signature "<Value(i); - sout<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Entity Status **** - Standard_Integer i,nb; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - nb = Interface_Category::NbCategories(); - sout<<" Categories defined :"<Number(arg1); - if (num <= 0 || num > WS->NbStartingEntities()) - { sout<<"Not a suitable entity number : "<StartingEntity(num); - WS->PrintEntityStatus (ent, sout); - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun11 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** DumpModel (Data) **** - Standard_Integer niv = 0; -// char arg10 = arg1[0]; -// if (argc < 2) arg10 = '?'; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - switch (arg1[0]) { - case '?' : - sout<<"? for this help, else give a listing mode (first letter suffices) :\n" - <<" general General Statistics\n roots Roots\n" - <<" entities All Entities\n" - <<" listfails CheckList (fails) per entity\n" - <<" messages CheckList (complete) per entity\n" - <<" fails CheckList (fails) per message (counting)\n" - <<" check CheckList (complete) per message (counting)\n" - <<" totalcheck CheckList (complete) per message (listing n0 ents)\n" - <<" FAILS CheckList (fails) per message (listing complete)\n" - <<" TOTALCHECK CheckList (complete) per message (listing complete)"<TraceDumpModel(niv); - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fundumpent - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - Handle(IFSelect_WorkLibrary) WL = WS->WorkLibrary(); - Standard_Integer levdef=0,levmax=10,level; - WL->DumpLevels (levdef,levmax); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2 || (argc == 2 && levmax < 0)) { - sout<<"Give n0 or id of entity"; - if (levmax < 0) sout<<" and dump level"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Standard_Integer num = pilot->Number(arg1); - if (num == 0) return IFSelect_RetError; - level = levdef; - if (argc > 2) level = atoi(arg2); - Handle(Standard_Transient) ent = WS->StartingEntity(num); - if ( ent.IsNull() ) { - sout << "No entity with given id " << arg1 << " (" << num << ") is found in the current model" << std::endl; - } - else { - sout << " -- DUMP Entity n0 " << num << " level " << level << std::endl; - WL->DumpEntity (WS->Model(),WS->Protocol(),ent,sout,level); - - Interface_CheckIterator chl = WS->CheckOne (ent); - if (!chl.IsEmpty(Standard_False)) chl.Print(sout,WS->Model(),Standard_False); - } -// sout << std::flush; - - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus funsign - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<" Give signature name + n0 or id of entity"<NamedItem(arg1)); - if (sign.IsNull()) { sout<<"Not a signature : "<Number(arg2); - Handle(Standard_Transient) ent = WS->StartingEntity (num); - if (num == 0) return IFSelect_RetError; - sout<<"Entity n0 "<SignValue(sign,ent)<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<" Give 2 numeros or labels : dad son"<NumberFromLabel(arg1); - Standard_Integer n2 = WS->NumberFromLabel(arg2); - sout<<"QueryParent for dad:"<QueryParent(WS->StartingEntity(n1),WS->StartingEntity(n2)); - if (qp < 0) sout<Session(); -// **** DumpShare **** - WS->DumpShare(); return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun13 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** ListItems **** - WS->ListItems(pilot->Arg(1)); return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun14 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** NewInt **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 1) { sout<<"Donner la valeur entiere pour IntParam"<= 1) intpar->SetValue(atoi(arg1)); - return pilot->RecordItem (intpar); -} - -static IFSelect_ReturnStatus fun15 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SetInt **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) - { sout<<"Donner 2 arguments : nom Parametre et Valeur"<NamedItem(arg1)); - if (!WS->SetIntValue(par,val)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun16 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** NewText **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 1) { sout<<"Donner la valeur texte pour TextParam"<= 1) textpar->AssignCat(arg1); - return pilot->RecordItem (textpar); -} - -static IFSelect_ReturnStatus fun17 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SetText **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) - { sout<<"Donner 2 arguments : nom Parametre et Valeur"<NamedItem(arg1)); - if (!WS->SetTextValue(par,arg2)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun19 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** DumpSel **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give 1 argument : Selection Name"<DumpSelection (GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun20 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); -// **** EvalSel **** -// **** GiveList **** -// **** GiveShort GivePointed **** -// **** MakeList **** - char mode = pilot->Arg(0)[0]; // givelist/makelist - if (mode == 'g') mode = pilot->Arg(0)[4]; // l list s short p pointed - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<Arg(1); - Handle(Standard_Transient) item = WS->NamedItem (arg1); - pnt = GetCasted(IFSelect_SelectPointed,item); - if (!pnt.IsNull()) { - sout<Clear(); - } else if (!item.IsNull()) { - sout<AddNamedItem (arg1,pnt); - } - } - - Handle(TColStd_HSequenceOfTransient) result = - IFSelect_Functions::GiveList (WS,pilot->CommandPart( (mode == 'm' ? 2 : 1) )); - if (result.IsNull()) return IFSelect_RetError; - Interface_EntityIterator iter (result); - sout<CommandPart( (mode == 'm' ? 2 : 1) )<<" : "; - if (mode == 'l') WS->ListEntities (iter, 0, sout); - else if (mode == 's' || mode == 'm') WS->ListEntities (iter, 2, sout); - else if (mode == 'p') { - sout<StartingNumber (iter.Value()); - sout<SetList (result); - sout<<"List set to a SelectPointed : "<Arg(1)<Session(); - Standard_Integer argc = pilot->NbWords(); -// **** GiveCount **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); - Handle(TColStd_HSequenceOfTransient) result = - IFSelect_Functions::GiveList (WS,pilot->CommandPart(1)); - if (result.IsNull()) return IFSelect_RetError; - sout<CommandPart(1)<<" : List of "<Length()<<" Entities"<Session(); - Standard_Integer argc = pilot->NbWords(); -// **** SelSuite **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give Entity ID, or Selection Name [+ optional other selection or entity]"<EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); - Handle(IFSelect_SelectSuite) selsuite = new IFSelect_SelectSuite; - - for (Standard_Integer i = 1; i < argc; i ++) { - Handle(IFSelect_Selection) sel = WS->GiveSelection(pilot->Arg(i)); - if (!selsuite->AddInput(sel)) { - sout<Arg(i-1)<<" : not a SelectDeduct, no more can be added. Abandon"<SetLabel (pilot->CommandPart(1)); - return pilot->RecordItem (selsuite); -} - - -static IFSelect_ReturnStatus fun21 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** ClearItems **** - WS->ClearItems(); WS->ClearFinalModifiers(); WS->ClearShareOut(Standard_False); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun22 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** ClearData **** - Standard_Integer mode = -1; - if (argc >= 2) { - if (arg1[0] == 'a') mode = 1; - if (arg1[0] == 'g') mode = 2; - if (arg1[0] == 'c') mode = 3; - if (arg1[0] == 'p') mode = 4; - if (arg1[0] == '?') mode = -1; - } - else mode = 0; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (mode <= 0) { - if (mode < 0) sout<<"Give a suitable mode"; - sout<<" Available Modes :\n" - <<" a : all data g : graph+check c : check p : selectpointed"<ClearData (mode); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun24 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); -// **** Item Label **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - TCollection_AsciiString label; - if (argc < 2) { sout<<" Give label to search"<Arg(i)); - if (i < argc-1) label.AssignCat(" "); - } - for (int mode = 0; mode <= 2; mode ++) { - int nbitems = 0; int id; - sout<<"Searching label : "<NextIdentForLabel(label.ToCString(), 0,mode) ; id != 0; - id = WS->NextIdentForLabel(label.ToCString(),id,mode)) { - sout<<" "<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Save (Dump) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner nom du Fichier"<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Restore (Dump) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner nom du Fichier"< 0) sout << "-- Erreur Lecture Fichier "<NbWords(); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - const Standard_CString arg1 = pilot->Arg(1); - Standard_CString arg2 = pilot->Arg(2); - const Standard_CString anEmptyStr = ""; - if (arg2 && strlen(arg2) == 2 && arg2[0] == '"' && arg2[1] == '"') - { - arg2 = anEmptyStr; - } -// **** Param(Value) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2 || (argc == 3 && strcmp (arg1, "-p") == 0)) { - Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items(); - Standard_Integer i,nb = li->Length(), aPatternNb = 0; - size_t aPatternLen = strlen(arg2); - if (argc == 3) - { - for (i = 1; i <= nb; i ++) - { - if (strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) == 0) - { - aPatternNb++; - } - } - } - else - { - aPatternNb = nb; - } - sout << " List of parameters : " << aPatternNb << " items : " << std::endl; - for (i = 1; i <= nb; i ++) { - if (argc == 3 && strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) != 0) - { - continue; - } - sout<Value(i)->String(); - sout<<" : "<Value(i)->ToCString())< 0) { - Standard_Integer use = atoi (arg1); - WS->TraceStatics (use); - } else { - if (argc > 2) sout<<" FORMER STATUS of Static Parameter "< Print (sout); - else sout<<" Value : "<Session(); -// **** SentFiles **** - Handle(TColStd_HSequenceOfHAsciiString) list = WS->SentFiles(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (list.IsNull()) - { sout<<"List of Sent Files not enabled"<Length(); - sout<<" Sent Files : "<Value(i)->ToCString()<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** FilePrefix **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - if (WS->FilePrefix().IsNull()) sout<<"Pas de prefixe defini"<FilePrefix()->ToCString()<SetFilePrefix(arg1); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun31 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** FileExtension **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - if (WS->FileExtension().IsNull()) sout<<"Pas d extension definie"<FileExtension()->ToCString()<SetFileExtension(arg1); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun32 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** FileRoot **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Dispatch et nom de Root"<NamedItem(arg1)); - if (argc < 3) { - if (WS->FileRoot(disp).IsNull()) sout<<"Pas de racine definie pour "<FileRoot(disp)->ToCString()<SetFileRoot(disp,arg2)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun33 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Default File Root **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - if (WS->DefaultFileRoot().IsNull()) sout<<"Pas de racine par defaut definie"<DefaultFileRoot()->ToCString()<SetDefaultFileRoot(arg1); - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun34 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** EvalFile **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (!WS->HasModel()) - { sout<<"Pas de Modele charge, abandon"<EvaluateFile(); - Standard_Integer nbf = WS->NbFiles(); - for (Standard_Integer i = 1; i <= nbf; i ++) { - Handle(Interface_InterfaceModel) mod = WS->FileModel(i); - if (mod.IsNull()) - { sout<<"Modele "<FileName(i); - sout<<"Fichier n0 "<NbEntities()<<" Nom: "; - sout<Session(); -// **** ClearFile **** - WS->ClearFile(); return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun36 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); -// **** Split **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - IFSelect_ReturnStatus stat = IFSelect_RetVoid; - if (argc < 2) sout<<"Split : derniere liste de dispatches definie"<ClearShareOut(Standard_True); - for (Standard_Integer i = 1; i < argc; i ++) { - DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i))); - if (disp.IsNull()) { - sout<<"Pas un dispatch:"<Arg(i)<<", Splitt abandonne"<SetActive(disp,Standard_True); - } - } - if (stat == IFSelect_RetError) return stat; - WS->BeginSentFiles(Standard_True); - if (!WS->SendSplit()) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun37 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Remaining Data **** - char mode = '?'; IFSelect_RemainMode numod = IFSelect_RemainDisplay; - if (argc >= 2) mode = arg1[0]; - if (mode == 'u') numod = IFSelect_RemainUndo; - else if (mode == 'l') numod = IFSelect_RemainDisplay; - else if (mode == 'c') numod = IFSelect_RemainCompute; - else if (mode == 'f') numod = IFSelect_RemainForget; - else { - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc<2) sout<<"Donner un Mode - "; - sout<<"Modes possibles : l list, c compute, u undo, f forget"<SetRemaining(numod)) return IFSelect_RetVoid; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun38 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SetModelContent **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner nom selection et mode (k=keep,r=remove)"<NamedItem(arg1)); - if (sel.IsNull()) - { sout<<"Pas de Selection de Nom : "<SetModelContent(sel,keepmode)) sout<<" Done"<Session(); -// **** ListModif **** - WS->ListFinalModifiers(Standard_True); - WS->ListFinalModifiers(Standard_False); return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun41 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Modifier **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom du Modifier"<NamedItem(arg1)); - if (modif.IsNull()) - { sout<<"Pas de Modifier de Nom : "<Dispatch(); - sout<<"Modifier : "<Label()<ModifierRank(modif); - if (modif->IsKind(STANDARD_TYPE(IFSelect_Modifier))) - sout<< "Model Modifier n0." << rank; - else sout<< "File Modifier n0." << rank; - if (disp.IsNull()) sout<<" Applique a tous les Dispatchs" << std::endl; - else { - sout << " Dispatch : "<Label(); - if (WS->HasName(disp)) sout << " - Nom:"<Name(disp)->ToCString(); - sout<Selection(); - if (!sel.IsNull()) sout<<" Selection : "<< sel->Label(); - if (WS->HasName(sel)) sout<<" - Nom:"<< WS->Name(sel)->ToCString(); - sout<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** ModifSel **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Selection optionnel\n" - <<"Selection pour Mettre une Selection, sinon Annule"<NamedItem(arg1)); - if (modif.IsNull()) - { sout<<"Pas un nom de Modifier : "<NamedItem(arg2)); - if (sel.IsNull()) - { sout<<"Pas un nom de Selection : "<SetItemSelection(modif,sel)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun43 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SetAppliedModifier **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom Modifier; + Nom Dispatch ou Transformer optionnel :\n" - <<" - rien : tous Dispatches\n - Dispatch : ce Dispatch seul\n" - <<" - Transformer : pas un Dispatch mais un Transformer"<NamedItem(arg1)); - if (modif.IsNull()) - { sout<<"Pas un nom de Modifier : "<NamedItem(arg2); - if (item.IsNull()) - { sout<<"Pas un nom connu : "<ShareOut(); - if (!WS->SetAppliedModifier(modif,item)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun44 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** ResetApplied (modifier) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Designer un modifier"<NamedItem(arg1)); - if (modif.IsNull()) - { sout<<"Pas un nom de Modifier : "<ResetAppliedModifier(modif)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun45 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - const Standard_CString arg3 = pilot->Arg(3); -// **** ModifMove **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 4) { sout<<"modifmove MF rang1 rang2, M pour Model F pour File"<ChangeModifierRank(formodel,before,after)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun51 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** DispSel **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner Noms Dispatch et Selection Finale"<NamedItem(arg1)); - if (disp.IsNull()) - { sout<<"Pas un nom de Dispatch : "<NamedItem(arg2)); - if (sel.IsNull()) - { sout<<"Pas un nom de Selection : "<SetItemSelection(disp,sel)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun_dispone - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** DispOne **** - Handle(IFSelect_DispPerOne) disp = new IFSelect_DispPerOne; - return pilot->RecordItem(disp); -} - -static IFSelect_ReturnStatus fun_dispglob - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** DispGlob **** - Handle(IFSelect_DispGlobal) disp = new IFSelect_DispGlobal; - return pilot->RecordItem(disp); -} - -static IFSelect_ReturnStatus fun_dispcount - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** DispCount **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom IntParam pour Count"<NamedItem(arg1)); - if (par.IsNull()) - { sout<<"Pas un nom de IntParam : "<SetCount (par); - return pilot->RecordItem(disp); -} - -static IFSelect_ReturnStatus fun_dispfiles - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** DispFiles **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom IntParam pour NbFiles"<NamedItem(arg1)); - if (par.IsNull()) - { sout<<"Pas un nom de IntParam : "<SetCount (par); - return pilot->RecordItem(disp); -} - - -static IFSelect_ReturnStatus fun_dispsign - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** DispFiles **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom Signature"<NamedItem(arg1)); - if (sig.IsNull()) - { sout<<"Pas un nom de Signature : "<SetSignCounter (new IFSelect_SignCounter(sig)); - return pilot->RecordItem(disp); -} - - -static IFSelect_ReturnStatus fun56 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Dispatch **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom du Dispatch"<NamedItem(arg1)); - if (disp.IsNull()) { sout<<"Pas un dispatch : "<DispatchRank(disp); - sout<<"Dispatch de Nom : "<ItemSelection(disp); - Handle(TCollection_HAsciiString) selname = WS->Name(sel); - if (sel.IsNull()) sout<<"Pas de Selection Finale"<ItemIdent(sel)<ToCString()<HasRootName()) sout<<"-- Racine nom de fichier : " - <RootName()->ToCString()<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Remove **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give Name to Remove !"<RemoveNamedItem(arg1)) return IFSelect_RetFail; - return IFSelect_RetDone; -} - -static IFSelect_ReturnStatus fun58 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** EvalDisp **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"evaldisp mode disp [disp ...] : Mode + Name(s) of Dispatch(es). Mode:\n" - <<" 0 brief 1 +forgotten ents 2 +duplicata 3 1+2"<NamedItem(pilot->Arg(i))); - if (disp.IsNull()) - { sout<<"Not a dispatch:"<Arg(i)<ClearShareOut(Standard_True); - for (i = 2; i < argc; i ++) { - DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(i))); - WS->SetActive(disp,Standard_True); - } -// WS->EvaluateDispatch(disp,mode); - WS->EvaluateComplete(mode); - return IFSelect_RetVoid; -} - - -static IFSelect_ReturnStatus fun_evaladisp - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** EvalADisp [GiveList] **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"evaladisp mode(=0-1-2-3) disp [givelist] : Mode + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch. Mode:\n" - <<" 0 brief 1 +forgotten ents 2 +duplicata 3 1+2"<NamedItem(pilot->Arg(2))); - Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True); - if (disp.IsNull()) - { sout<<"Not a dispatch:"<Arg(2)<FinalSelection(); - Handle(IFSelect_Selection) sel; - if (argc > 3) { - Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; - Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList - (pilot->Session(),pilot->CommandPart(3)); - Standard_Integer nb = (list.IsNull() ? 0 : list->Length()); - if (nb > 0) { sp->AddList (list); sel = sp; } - } - - if (sel.IsNull() && selsav.IsNull()) - { sout<<"No Selection nor GiveList defined"< 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<SetFinalSelection(sel); -// WS->ClearShareOut(Standard_True); -// WS->SetActive(disp,Standard_True); - WS->EvaluateDispatch(disp,mode); - disp->SetFinalSelection(selsav); - - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun_writedisp - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** EvalADisp [GiveList] **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"writedisp filename disp [givelist] : FileName + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch.\n" - <<"FileName : rootname.ext will gives rootname_1.ext etc...\n" - <<" path/rootname.ext gives path/rootname_1.ext etc...\n" - <<"See also : evaladisp"<NamedItem(pilot->Arg(2))); - Handle(IFSelect_Dispatch) disp = IFSelect_Functions::GiveDispatch (WS,pilot->Arg(2),Standard_True); - if (disp.IsNull()) - { sout<<"Not a dispatch:"<Arg(2)<FinalSelection(); - Handle(IFSelect_Selection) sel; - if (argc > 3) { - Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; - Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList - (pilot->Session(),pilot->CommandPart(3)); - Standard_Integer nb = (list.IsNull() ? 0 : list->Length()); - if (nb > 0) { sp->AddList (list); sel = sp; } - } - - if (sel.IsNull() && selsav.IsNull()) - { sout<<"No Selection nor GiveList defined"< 3) sout<<"GiveList is empty, hence computed from the Selection of the Dispatch"<ClearShareOut(Standard_True); - disp->SetFinalSelection(sel); - WS->SetActive(disp,Standard_True); - WS->BeginSentFiles(Standard_True); - - WS->SetFilePrefix (prefix.ToCString()); - WS->SetFileExtension (suffix.ToCString()); - WS->SetFileRoot(disp,rootname.ToCString()); - - Standard_Boolean OK = WS->SendSplit(); - disp->SetFinalSelection(selsav); - return (OK ? IFSelect_RetDone : IFSelect_RetFail); -} - - -static IFSelect_ReturnStatus fun59 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** EvalComplete **** - Standard_Integer mode = 0; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) sout << " -- mode par defaut 0\n"; - else { mode = atoi(arg1); sout << " -- mode : " << mode << std::endl; } - WS->EvaluateComplete(mode); return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun60 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** LastRunCheckList **** - Interface_CheckIterator chlist = WS->LastRunCheckList(); - Handle(IFSelect_CheckCounter) counter = new IFSelect_CheckCounter(0); - counter->Analyse(chlist,WS->Model(),Standard_False); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - counter->PrintCount (sout); - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun61 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** RunTransformer **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom de Transformer"<NamedItem(arg1)); - Standard_Integer effect = WS->RunTransformer(tsf); - switch (effect) { - case -4 : sout<<"Edition sur place, nouveau Protocole, erreur recalcul graphe"< 0) ? IFSelect_RetDone : IFSelect_RetFail); -} - -static IFSelect_ReturnStatus fun62 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** TransformStandard Copy **** - return pilot->RecordItem(WS->NewTransformStandard(Standard_True)); -} - -static IFSelect_ReturnStatus fun63 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** TransformStandard OntheSpot **** - return pilot->RecordItem(WS->NewTransformStandard(Standard_False)); -} - -static IFSelect_ReturnStatus fun6465 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** Run Modifier avec Standard Copy **** -// **** Run Modifier avec OnTheSpot **** - Standard_Boolean runcopy = (pilot->Arg(0)[3] == 'c'); -// soit c est un nom, sinon c est une commande - Handle(IFSelect_Modifier) modif; - if (WS->NameIdent(arg1) > 0) - modif = GetCasted(IFSelect_Modifier,WS->NamedItem(arg1)); - else { - pilot->RemoveWord(0); // c etait la commande run - pilot->Perform(); - modif = GetCasted(IFSelect_Modifier,pilot->RecordedItem()); - } - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (modif.IsNull()) - { sout<<"Pas un nom de Modifier : "< 2) { - list = IFSelect_Functions::GiveList (WS,pilot->CommandPart(2)); - sp = new IFSelect_SelectPointed; - sp->SetList (list); - } - - Standard_Integer effect = 0; - effect = WS->RunModifierSelected (modif,sp,runcopy); -// sout<<"Modifier applique sur TransformStandard #"<ItemIdent(tsf)< 0) ? IFSelect_RetDone : IFSelect_RetFail); -} - -static IFSelect_ReturnStatus fun66 - (const Handle(IFSelect_SessionPilot)& pilot) -{ -// **** (xset) ModifReorder **** - char opt = ' '; - Standard_Integer argc = pilot->NbWords(); - if (argc >= 2) opt = pilot->Word(1).Value(1); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (opt != 'f' && opt != 'l') - { sout<<"Donner option : f -> root-first l -> root-last"<RecordItem(new IFSelect_ModifReorder(opt == 'l')); -} - -static IFSelect_ReturnStatus fun70 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** SelToggle **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom de Selection"<NamedItem(arg1)); - if (!WS->ToggleSelectExtract(sel)) - { sout<<"Pas une SelectExtract : "<IsReversedSelectExtract(sel)) sout<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelInput **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner Noms Selections cible et input"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,sou,WS->NamedItem(arg2)); - if (sel.IsNull() || sou.IsNull()) - { sout<<"Incorrect : "<SetInputSelection(sel,sou)) { - sout<<"Nom incorrect ou Selection "<Session(); -// **** SelModelRoots **** - return pilot->RecordItem (new IFSelect_SelectModelRoots); -} - -static IFSelect_ReturnStatus fun73 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelRange **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc >= 2 && arg1[0] == '?') argc = 1; - if (argc < 2) { - sout<<"Donner la description du SelectRange" - <<" Formes admises :\n : Range de a \n" - <<" tout seul : Range n0 \n from : Range From \n" - <<" until : Range Until "<Word(1).IsEqual("from")) { - if (argc < 3) { sout<<"Forme admise : from "<NamedItem(arg2)); - sel = new IFSelect_SelectRange; - sel->SetFrom (low); -// Range Until - } else if (pilot->Word(1).IsEqual("until")) { - if (argc < 3) { sout<<"Forme admise : until "<NamedItem(arg2)); - sel = new IFSelect_SelectRange; - sel->SetUntil (up); -// Range One (n-th) - } else if (argc < 3) { - low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1)); - sel = new IFSelect_SelectRange; - sel->SetOne (low); -// Range (from-to) - } else { - low = GetCasted(IFSelect_IntParam,WS->NamedItem(arg1)); - up = GetCasted(IFSelect_IntParam,WS->NamedItem(arg2)); - sel = new IFSelect_SelectRange; - sel->SetRange (low,up); - } - return pilot->RecordItem (sel); -} - -static IFSelect_ReturnStatus fun74 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SelRoots **** - return pilot->RecordItem (new IFSelect_SelectRoots); -} - -static IFSelect_ReturnStatus fun75 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SelShared **** - return pilot->RecordItem (new IFSelect_SelectShared); -} - -static IFSelect_ReturnStatus fun76 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelDiff **** - Handle(IFSelect_Selection) sel = new IFSelect_SelectDiff; - if (sel.IsNull()) return IFSelect_RetFail; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) sout<<"Diff sans input : ne pas oublier de les definir (ctlmain, ctlsec)!"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,selsec ,WS->NamedItem(arg2)); - if (argc >= 2) - if (!WS->SetControl(sel,selmain,Standard_True)) - sout<<"Echec ControlMain:"<= 3) - if (!WS->SetControl(sel,selsec,Standard_False)) - sout<<"Echec ControlSecond:"<RecordItem (sel); -} - -static IFSelect_ReturnStatus fun77 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelControlMain **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner Noms de Control et MainInput"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,selmain,WS->NamedItem(arg2)); - if (WS->SetControl(sel,selmain,Standard_True)) return IFSelect_RetDone; - sout<<"Nom incorrect ou Selection "<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelControlSecond **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner Noms de Control et SecondInput"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,seldif,WS->NamedItem(arg2)); - if (WS->SetControl(sel,seldif,Standard_False)) return IFSelect_RetDone; - sout<<"Nom incorrect ou Selection "<Session(); -// **** SelModelAll **** - return pilot->RecordItem (new IFSelect_SelectModelEntities); -} - -static IFSelect_ReturnStatus fun80 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelCombAdd **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner n0 Combine et une Input"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,seladd,WS->NamedItem(arg2)); - if (WS->CombineAdd(sel,seladd)) return IFSelect_RetDone; - sout<<"Nom incorrect ou Selection "<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); -// **** SelCombRem **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Donner n0 Combine et RANG a supprimer"<NamedItem(arg1)); - DeclareAndCast(IFSelect_Selection,inp,WS->NamedItem(arg2)); - if (WS->CombineRemove(sel,inp)) return IFSelect_RetDone; - sout<<"Nom incorrect ou Selection "<Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** SelEntNumber **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner Nom IntParam pour n0 Entite"<NamedItem(arg1)); - Handle(IFSelect_SelectEntityNumber) sel = new IFSelect_SelectEntityNumber; - sel->SetNumber(par); - return pilot->RecordItem (sel); -} - -static IFSelect_ReturnStatus fun83 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SelUnion **** - return pilot->RecordItem (new IFSelect_SelectUnion); -} - -static IFSelect_ReturnStatus fun84 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SelIntersection **** - return pilot->RecordItem (new IFSelect_SelectIntersection); -} - -static IFSelect_ReturnStatus fun85 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** SelTextType Exact **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner le TYPE a selectionner"<RecordItem (new IFSelect_SelectSignature - (new IFSelect_SignType,arg1,Standard_True)); -} - -static IFSelect_ReturnStatus fun86 - (const Handle(IFSelect_SessionPilot)& pilot) -{ -// **** SelErrorEntities **** - return pilot->RecordItem (new IFSelect_SelectErrorEntities); -} - -static IFSelect_ReturnStatus fun87 - (const Handle(IFSelect_SessionPilot)& pilot) -{ -// **** SelUnknownEntities ** - return pilot->RecordItem (new IFSelect_SelectUnknownEntities); -} - -static IFSelect_ReturnStatus fun88 - (const Handle(IFSelect_SessionPilot)& pilot) -{ -// **** SelSharing **** - return pilot->RecordItem (new IFSelect_SelectSharing); -} - -static IFSelect_ReturnStatus fun89 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** SelTextType Contain ** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner le TYPE a selectionner"<RecordItem (new IFSelect_SelectSignature - (new IFSelect_SignType,arg1,Standard_False)); -} - -static IFSelect_ReturnStatus fun90 - (const Handle(IFSelect_SessionPilot)& pilot) -{ -// **** SelPointed **** - Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; - if (pilot->NbWords() > 1) { - Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList - (pilot->Session(),pilot->CommandPart(1)); - if (list.IsNull()) return IFSelect_RetFail; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout<<"SelectPointed : "<Length()<<" entities"<AddList (list); - } - return pilot->RecordItem (sp); -} - -static IFSelect_ReturnStatus fun91 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** SetPointed (edit) / SetList (edit) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - sout<<"Donner NOM SelectPointed + Option(s) :\n" - <<" aucune : liste des entites pointees\n" - <<" 0: Clear +nn ajout entite nn -nn enleve nn /nn toggle nn"<NamedItem(arg1)); - if (sp.IsNull()) { sout<<"Pas une SelectPointed:"<Model(); // pour Print - if (argc == 2) { // listage simple - Standard_Integer nb = sp->NbItems(); - sout<<" SelectPointed : "<Item(i); - Standard_Integer id = WS->StartingNumber(pointed); - if (id == 0) sout <<" (inconnu)"; - else { sout <<" "; model->Print (pointed, sout); } - } - if (nb > 0) sout<Word(ia); - Standard_Integer id = pilot->Number(&(argi.ToCString())[1]); - if (id == 0) { - if (!argi.IsEqual("0")) sout<<"Incorrect,ignore:"<Clear(); } - } else if (argi.Value(1) == '-') { - Handle(Standard_Transient) item = WS->StartingEntity(id); - if (sp->Remove(item)) sout<<"Removed:no."<Print (item, sout); - } else if (argi.Value(1) == '/') { - Handle(Standard_Transient) item = WS->StartingEntity(id); - if (sp->Remove(item)) sout<<"Toggled:n0."<Print (item, sout); - } else if (argi.Value(1) == '+') { - Handle(Standard_Transient) item = WS->StartingEntity(id); - if (sp->Add(item)) sout<<"Added:no."<Print (item, sout); - } else { - sout<<"Ignore:"<Session(); -// **** SelIncorrectEntities **** - WS->ComputeCheck(); - return pilot->RecordItem (new IFSelect_SelectIncorrectEntities); -} - -static IFSelect_ReturnStatus fun93 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SelSignature **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Give name of Signature or Counter, text + option exact(D) else contains"< 3) { if (pilot->Arg(3)[0] == 'c') exact = Standard_False; } - - DeclareAndCast(IFSelect_Signature,sign,WS->NamedItem(arg1)); - DeclareAndCast(IFSelect_SignCounter,cnt,WS->NamedItem(arg1)); - Handle(IFSelect_SelectSignature) sel; - - if (!sign.IsNull()) sel = new IFSelect_SelectSignature (sign,arg2,exact); - else if (!cnt.IsNull()) sel = new IFSelect_SelectSignature (cnt,arg2,exact); - else { sout<RecordItem(sel); -} - -static IFSelect_ReturnStatus fun94 - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** SignCounter **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner nom signature"<NamedItem(arg1)); - if (sign.IsNull()) { sout<RecordItem(cnt); -} - -static IFSelect_ReturnStatus funbselected - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - Handle(IFSelect_WorkSession) WS = pilot->Session(); -// **** NbSelected = GraphCounter **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Donner nom selection (deduction) a appliquer"<GiveSelection(arg1)); - if (applied.IsNull()) { sout<SetApplied (applied); - return pilot->RecordItem(cnt); -} - -// ######################################### -// #### EDITOR - EDITFORM #### -// ######################################### - -static IFSelect_ReturnStatus fun_editlist - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give the name of an EditForm or an Editor"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - -// EditForm - - DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1)); - Handle(IFSelect_Editor) edt; - if (!edf.IsNull()) { - sout<<"Print EditForm "<Editor(); - if (argc < 3) { - -// DEFINITIONS : Editor (direct ou via EditForm) - - if (edt.IsNull()) edt = GetCasted(IFSelect_Editor,WS->NamedItem(arg1)); - if (edt.IsNull()) return IFSelect_RetVoid; - - sout<<"Editor, Label : "<Label()<PrintNames(sout); - sout<PrintDefs (sout); - if (!edf.IsNull()) { - edf->PrintDefs(sout); - sout<PrintValues (sout,what,Standard_False); - } - } - - return IFSelect_RetVoid; -} - -static IFSelect_ReturnStatus fun_editvalue - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 3) { sout<<"Give the name of an EditForm + name of Value [+ newvalue or . to nullify]"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1)); - if (edf.IsNull()) - { sout<<"Not an EditForm : "<NameNumber (arg2); - if (num == 0) sout<<"Unknown Value Name : "<Editor()->IsList(num); - Standard_CString name = edf->Editor()->Name(num,Standard_True); // vrai nom - Handle(TColStd_HSequenceOfHAsciiString) listr; - Handle(TCollection_HAsciiString) str; - sout<<"Value Name : "<IsModified(num) ? "(already edited) : " : " : "); - - if (islist) { - listr = edf->EditedList(num); - if (listr.IsNull()) sout<<"(NULL LIST)"<Length(); - sout<<"(List : "<Value(ilist); - sout<<" ["<ToCString())<EditedValue (num); - sout<<(str.IsNull() ? "(NULL)" : str->ToCString())<Arg(numarg); - if (islist) { - if (argval[0] == '?') { - sout<<"To Edit, options"<ListEditor (num); - if (listed.IsNull()) return IFSelect_RetError; - if (argval[0] == '.') { listr.Nullify(); stated = listed->LoadEdited(listr); } - else if (argval[0] == '+') { - Standard_Integer numadd = 0; - if (argval[1] != '\0') numadd = atoi(argval); - stated = listed->AddValue (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numadd); - } - else if (argval[0] == '-') { - Standard_Integer numrem = atoi(argval); - stated = listed->Remove(numrem); - } - else { - Standard_Integer numset = atoi(argval); - if (numset > 0) stated = listed->AddValue - (new TCollection_HAsciiString(pilot->CommandPart(numarg+1)),numset); - } - if (stated) stated = edf->ModifyList (num,listed,Standard_True); - if (stated) sout<<"List Edition done"<CommandPart(numarg)); - if (edf->Modify (num,str,Standard_True)) { - sout<<"Now set to "<<(str.IsNull() ? "(NULL)" : str->ToCString())<NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give the name of an EditForm [+ name of Value else all]"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1)); - if (edf.IsNull()) - { sout<<"Not an EditForm : "<ClearEdit(); sout<<"All Modifications Cleared"<NameNumber (arg2); - if (num == 0) sout<<"Unknown Value Name : "<IsModified(num)) - { sout<<"Value "<ClearEdit (num); - sout<<"Modification on Value "<NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give the name of an EditForm [+ option keep to re-apply edited values]"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1)); - if (edf.IsNull()) - { sout<<"Not an EditForm : "<Entity(); - Handle(Interface_InterfaceModel) model = edf->Model(); - if (!model.IsNull()) { - if (ent.IsNull()) sout<<"Applying modifications on loaded model"<PrintLabel (ent, sout); - } - } - else sout<<"Applying modifications"<ApplyData (edf->Entity(),edf->Model())) { - sout<<"Modifications could not be applied"< 2 && arg2[0] == 'k') stat = Standard_False; - if (stat) { - edf->ClearEdit(); - sout<<"Edited values are cleared"<NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give the name of an EditForm [+ Entity-Ident]"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - Handle(IFSelect_WorkSession) WS = pilot->Session(); - DeclareAndCast(IFSelect_EditForm,edf,WS->NamedItem(arg1)); - if (edf.IsNull()) - { sout<<"Not an EditForm : "<Number (arg2)); - Standard_Boolean stat = Standard_False; - if (argc < 3) { - sout<<"EditForm "<LoadModel(WS->Model()); - } else if (num <= 0) { - sout<<"Not an entity ident : "<LoadData (WS->StartingEntity(num),WS->Model()); - } - - if (!stat) { - sout<<"Loading not done"< 0) ent = WS->StartingEntity(num); - return ent; -} - - Standard_Integer IFSelect_Functions::GiveEntityNumber - (const Handle(IFSelect_WorkSession)& WS, - const Standard_CString name) -{ - Standard_Integer num = 0; - if (!name || name[0] == '\0') { - char ligne[80]; ligne[0] = '\0'; - std::cin >> ligne; -// std::cin.clear(); std::cin.getline (ligne,79); - if (ligne[0] == '\0') return 0; - num = WS->NumberFromLabel (ligne); - } - else num = WS->NumberFromLabel (name); - return num; -} - - Handle(TColStd_HSequenceOfTransient) IFSelect_Functions::GiveList - (const Handle(IFSelect_WorkSession)& WS, - const Standard_CString first, const Standard_CString second) -{ - return WS->GiveList (first,second); -} - - -// Function which returns an EVALUATED DISPATCH -// (could be added in WorkSession.cdl ...) -// Two modes : returns dispatch as it is, or return with edition -// Dispatch Name can be : an immediate name of already recorded Dispatch -// Or a name of dispatch + a parameter : dispatch-name(param-value) -// According to type of Dispatch : integer , signature name - -Handle(IFSelect_Dispatch) IFSelect_Functions::GiveDispatch - (const Handle(IFSelect_WorkSession)& WS, - const Standard_CString name, const Standard_Boolean mode) -{ - DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(name)); - if (!disp.IsNull()) return disp; // OK as it is given - -// Else, let s try special cases - TCollection_AsciiString nam(name); - Standard_Integer paro = nam.Location(1,'(',1,nam.Length()); - Standard_Integer parf = nam.Location(1,')',1,nam.Length()); - nam.SetValue(paro,'\0'); nam.SetValue(parf,'\0'); - if (paro <= 0 &&parf <= 0) return disp; - disp = GetCasted(IFSelect_Dispatch,WS->NamedItem(nam.ToCString())); - if (disp.IsNull()) return disp; // KO anyway - -// According to the type of dispatch : - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - DeclareAndCast(IFSelect_DispPerCount,dc,disp); - if (!dc.IsNull()) { - Standard_Integer nb = atoi( &(nam.ToCString())[paro]); - if (nb <= 0) { - sout<<" DispPerCount, count is not positive"<SetValue(nb); - dc->SetCount (val); - } - return dc; - } - DeclareAndCast(IFSelect_DispPerFiles,dp,disp); - if (!dp.IsNull()) { - Standard_Integer nb = atoi( &(nam.ToCString())[paro]); - if (nb <= 0) { - sout<<" DispPerFiles, count is not positive"<SetValue(nb); - dp->SetCount (val); - } - return dp; - } - DeclareAndCast(IFSelect_DispPerSignature,ds,disp); - if (!ds.IsNull()) { - DeclareAndCast(IFSelect_Signature,sg,WS->NamedItem( &(nam.ToCString())[paro])); - if (sg.IsNull()) { - sout<<"DispPerSignature "<SetSignCounter (new IFSelect_SignCounter(sg)); - return ds; - } - sout<<"Dispatch : "< Load Model",fun3); - IFSelect_Act::AddFunc("xread","file:string : Read File -> Load Model",fun3); - IFSelect_Act::AddFunc("writeall","file:string : Write all model (no split)",fun4); - IFSelect_Act::AddFunc("writesel","file:string sel:Selection : Write Selected (no split)",fun5); - IFSelect_Act::AddFunc("writeent","file:string n1ent n2ent...:integer : Write Entite(s) (no split)",fun6); - IFSelect_Act::AddFunc("writent", "file:string n1ent n2ent...:integer : Write Entite(s) (no split)",fun6); - IFSelect_Act::AddFunc("elabel","nument:integer : Displays Label Model of an entity",fun7); - IFSelect_Act::AddFunc("enum","label:string : Displays entities n0.s of which Label Model ends by..",fun8); - - IFSelect_Act::AddFunc("listtypes","List nb entities per type. Optional selection name else all model",fun9); - IFSelect_Act::AddFunc("count","Count : counter [selection]",funcount); - IFSelect_Act::AddFunc("listcount","List Counted : counter [selection [nument]]",funcount); - IFSelect_Act::AddFunc("sumcount","Summary Counted : counter [selection [nument]]",funcount); - IFSelect_Act::AddFunc("signtype","Sign Type [newone]",funsigntype); - IFSelect_Act::AddFunc("signcase","signature : displays possible cases",funsigncase); - - IFSelect_Act::AddFunc("estatus","ent/nument : displays status of an entity",fun10); - IFSelect_Act::AddFunc("data","Data (DumpModel); whole help : data tout court",fun11); - IFSelect_Act::AddFunc("entity","give n0 ou id of entity [+ level]",fundumpent); - IFSelect_Act::AddFunc("signature","signature name + n0/ident entity",funsign); - IFSelect_Act::AddFunc("queryparent"," give 2 n0s/labels of entities : dad son",funqp); - - IFSelect_Act::AddFunc("dumpshare","Dump Share (dispatches, IntParams)",fun12); - IFSelect_Act::AddFunc("listitems","List Items [label else all] ->Type,Label[,Name]",fun13); - IFSelect_Act::AddFSet("integer","value:integer : cree un IntParam",fun14); - IFSelect_Act::AddFunc("setint","name:IntParam newValue:integer : Change valeur IntParam",fun15); - IFSelect_Act::AddFSet("text","value:string : cree un TextParam",fun16); - IFSelect_Act::AddFunc("settext","Name:TextParam newValue:string : Change valeur TextParam",fun17); - IFSelect_Act::AddFunc("dumpsel","Dump Selection suivi du Nom de la Selection a dumper",fun19); - IFSelect_Act::AddFunc("evalsel","name:Selection [num/sel] : Evalue une Selection",fun20); - IFSelect_Act::AddFunc("givelist","num/sel [num/sel ...] : Evaluates GiveList",fun20); - IFSelect_Act::AddFunc("giveshort","num/sel [num/sel ...] : GiveList in short form",fun20); - IFSelect_Act::AddFunc("givepointed","num/sel [num/sel ...] : GiveList to fill a SelectPointed",fun20); - IFSelect_Act::AddFunc("makelist","listname [givelist] : Makes a List(SelectPointed) from GiveList",fun20); - IFSelect_Act::AddFunc("givecount","num/sel [num/sel ...] : Counts GiveList",fun20c); - IFSelect_Act::AddFSet("selsuite","sel sel ... : Creates a SelectSuite",funselsuite); - IFSelect_Act::AddFunc("clearitems","Clears all items (selections, dispatches, etc)",fun21); - IFSelect_Act::AddFunc("cleardata","mode:a-g-c-p : Clears all or some data (model, check...)",fun22); - - IFSelect_Act::AddFunc("itemlabel","xxx xxx : liste items having this label",fun24); - IFSelect_Act::AddFunc("xsave","filename:string : sauve items-session",fun25); - IFSelect_Act::AddFunc("xrestore","filename:string : restaure items-session",fun26); - IFSelect_Act::AddFunc("param","[-p Pattern] - displays all parameters or filtered by pattern;\n" - "par_name - displays parameter;\n" - "par_name par_value - changes parameter's value", fun27); - - IFSelect_Act::AddFunc("sentfiles","Lists files sent from last Load",fun29); - IFSelect_Act::AddFunc("fileprefix","prefix:string : definit File Prefix",fun30); - IFSelect_Act::AddFunc("fileext","extent:string : definit File Extension",fun31); - IFSelect_Act::AddFunc("fileroot","disp:Dispatch root:string : definit File Root sur un Dispatch",fun32); - IFSelect_Act::AddFunc("filedef","defroot:string : definit File DefaultRoot",fun33); - IFSelect_Act::AddFunc("evalfile","Evaluation du FileNaming et memorisation",fun34); - IFSelect_Act::AddFunc("clearfile","Efface la liste d'EvalFile",fun35); - IFSelect_Act::AddFunc("xsplit","[disp:Dispatch sinon tout] : Split, la grande affaire !",fun36); - IFSelect_Act::AddFunc("remaining","options... : Remaining Entities, help complet par remaining ?",fun37); - IFSelect_Act::AddFunc("setcontent","sel:Selection mode:k ou r : Restreint contenu du modele",fun38); - - IFSelect_Act::AddFunc("listmodif","List Final Modifiers",fun40); - IFSelect_Act::AddFunc("dumpmodif","modif:Modifier : Affiche le Statut d'un Modifier",fun41); - IFSelect_Act::AddFunc("modifsel","modif:Modifier [sel:Selection] : Change/Annule Selection de Modifier",fun42); - IFSelect_Act::AddFunc("setapplied","modif:Modifier [name:un item sinon sortie fichier] : Applique un Modifier",fun43); - IFSelect_Act::AddFunc("resetapplied","modif:Modifier : Enleve un Modifier de la sortie fichier",fun44); - IFSelect_Act::AddFunc("modifmove","modif:Modifier M(model)/F(file) avant,apres:integer : Deplace un Modifier (sortie fichier)",fun45); - - IFSelect_Act::AddFunc("dispsel","disp:Dispatch sel:Selection -> Selection Finale de Dispatch",fun51); - IFSelect_Act::AddFSet("dispone","cree DispPerOne",fun_dispone); - IFSelect_Act::AddFSet("dispglob","cree DispGlobal",fun_dispglob); - IFSelect_Act::AddFSet("dispcount","count:IntParam : cree DispPerCount",fun_dispcount); - IFSelect_Act::AddFSet("dispfile","files:IntParam : cree DispPerFiles",fun_dispfiles); - IFSelect_Act::AddFSet("dispsign","sign:Signature : cree DispPerSignature",fun_dispsign); - IFSelect_Act::AddFunc("dumpdisp","disp:Dispatch : Affiche le Statut d'un Dispatch",fun56); - - IFSelect_Act::AddFunc("xremove","nom : Remove a Control Item de la Session",fun57); - IFSelect_Act::AddFunc("evaldisp","mode=[0-3] disp:Dispatch : Evaluates one or more Dispatch(es)",fun58); - IFSelect_Act::AddFunc("evaladisp","mode=[0-3] disp:Dispatch [givelist] : Evaluates a Dispatch (on a GiveList)",fun_evaladisp); - IFSelect_Act::AddFunc("writedisp","filepattern disp:Dispatch [givelist] : Writes Entities by Splitting by a Dispatch",fun_writedisp); - IFSelect_Act::AddFunc("evalcomplete","Evaluation Complete de la Repartition",fun59); - - IFSelect_Act::AddFunc("runcheck","affiche LastRunCheckList (write,modif)",fun60); - IFSelect_Act::AddFunc("runtranformer","transf:Transformer : Applique un Transformer",fun61); - IFSelect_Act::AddFSet("copy","cree TransformStandard, option Copy, vide",fun62); - IFSelect_Act::AddFSet("onthespot","cree TransformStandard, option OntheSpot, vide",fun63); - IFSelect_Act::AddFunc("runcopy","modif:ModelModifier [givelist] : Run via TransformStandard option Copy",fun6465); - IFSelect_Act::AddFunc("runonthespot","modif:ModelModifier [givelist] : Run via TransformStandard option OnTheSpot",fun6465); - IFSelect_Act::AddFSet("reorder","[f ou t] reordonne le modele",fun66); - - IFSelect_Act::AddFunc("toggle","sel:Selection genre Extract : Toggle Direct/Reverse",fun70); - IFSelect_Act::AddFunc("input","sel:Selection genre Deduct ou Extract input:Selection : Set Input",fun71); - IFSelect_Act::AddFSet("modelroots","cree SelectModelRoots",fun72); - IFSelect_Act::AddFSet("range","options... : cree SelectRange ...; tout court pour help",fun73); - IFSelect_Act::AddFSet("roots","cree SelectRoots (local roots)",fun74); - IFSelect_Act::AddFSet("shared","cree SelectShared",fun75); - IFSelect_Act::AddFSet("diff","[main:Selection diff:Selection] : cree SelectDiff",fun76); - IFSelect_Act::AddFunc("selmain","sel:Selection genre Control main:Selection : Set Main Input",fun77); - IFSelect_Act::AddFunc("selsecond","sel:Selection genre Control sec:Selection : Set Second Input",fun78); - IFSelect_Act::AddFSet("modelall","cree SelectModelAll",fun79); - IFSelect_Act::AddFunc("seladd","sel:Selection genre Combine input:Selection : Add Selection",fun80); - IFSelect_Act::AddFunc("selrem","sel:Selection genre Combine input:Selection : Remove Selection",fun81); - IFSelect_Act::AddFSet("number","num:IntParam : Cree SelectEntityNumber",fun82); - - IFSelect_Act::AddFSet("union","cree SelectUnion (vide), cf aussi combadd, combrem",fun83); - IFSelect_Act::AddFSet("intersect","cree SelectIntersection (vide), cf aussi combadd, combrem",fun84); - IFSelect_Act::AddFSet("typexact","type:string : cree SelectTextType Exact",fun85); - IFSelect_Act::AddFSet("errors","cree SelectErrorEntities (from file)",fun86); - IFSelect_Act::AddFSet("unknown","cree SelectUnknownEntities",fun87); - IFSelect_Act::AddFSet("sharing","cree SelectSharing",fun88); - IFSelect_Act::AddFSet("typecontain","type:string : cree SelectTextType Contains",fun89); - IFSelect_Act::AddFSet("pointed","cree SelectPointed [num/sel num/sel]",fun90); - IFSelect_Act::AddFunc("setpointed","sel:SelectPointed : edition SelectPointed. tout court pour help",fun91); - IFSelect_Act::AddFunc("setlist","sel:SelectPointed : edition SelectPointed. tout court pour help",fun91); - IFSelect_Act::AddFSet("incorrect","cree SelectIncorrectEntities (computed)",fun92); - - IFSelect_Act::AddFSet("signsel","sign:Signature|cnt:Counter text:string [e(D)|c] : cree SelectSignature",fun93); - IFSelect_Act::AddFSet("signcounter","sign:Signature : cree SignCounter",fun94); - IFSelect_Act::AddFSet("nbselected","applied:Selection : cree GraphCounter(=NbSelected)",funbselected); - - IFSelect_Act::AddFunc("editlist","editor or editform : lists defs + values",fun_editlist); - IFSelect_Act::AddFunc("editvalue","editform paramname [newval or .] : lists-changes a value",fun_editvalue); - IFSelect_Act::AddFunc("editclear","editform [paramname] : clears edition on all or one param",fun_editclear); - IFSelect_Act::AddFunc("editload","editform [entity-id] : loads from model or an entity",fun_editload); - IFSelect_Act::AddFunc("editapply","editform [keep] : applies on loaded data",fun_editapply); -} diff --git a/src/IFSelect/IFSelect_Functions.hxx b/src/IFSelect/IFSelect_Functions.hxx deleted file mode 100644 index 4c9887f562..0000000000 --- a/src/IFSelect/IFSelect_Functions.hxx +++ /dev/null @@ -1,78 +0,0 @@ -// Created on: 1993-07-28 -// Created by: Christian CAILLET -// Copyright (c) 1993-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. - -#ifndef _IFSelect_Functions_HeaderFile -#define _IFSelect_Functions_HeaderFile - -#include -#include -#include - -#include -#include -#include -class Standard_Transient; -class IFSelect_WorkSession; -class IFSelect_Dispatch; - -//! Functions gives access to all the actions which can be -//! commanded with the resources provided by IFSelect : especially -//! WorkSession and various types of Selections and Dispatches -//! -//! It works by adding functions by method Init -class IFSelect_Functions -{ -public: - - DEFINE_STANDARD_ALLOC - - //! Takes the name of an entity, either as argument, - //! or (if is empty) on keyboard, and returns the entity - //! name can be a label or a number (in alphanumeric), - //! it is searched by NumberFromLabel from WorkSession. - //! If doesn't match en entity, a Null Handle is returned - Standard_EXPORT static Handle(Standard_Transient) GiveEntity (const Handle(IFSelect_WorkSession)& WS, const Standard_CString name = ""); - - //! Same as GetEntity, but returns the number in the model of the - //! entity. Returns 0 for null handle - Standard_EXPORT static Standard_Integer GiveEntityNumber (const Handle(IFSelect_WorkSession)& WS, const Standard_CString name = ""); - - //! Computes a List of entities from a WorkSession and two idents, - //! first and second, as follows : - //! if is a Number or Label of an entity : this entity - //! if is the name of a Selection in , and - //! not defined, the standard result of this Selection - //! if is for a Selection and is defined, the - //! standard result of this selection from the list computed - //! with (an entity or a selection) - //! If is erroneous, it is ignored - Standard_EXPORT static Handle(TColStd_HSequenceOfTransient) GiveList (const Handle(IFSelect_WorkSession)& WS, const Standard_CString first = "", const Standard_CString second = ""); - - //! Evaluates and returns a Dispatch, from data of a WorkSession - //! if is False, searches for exact name of Dispatch in WS - //! Else (D), allows a parameter between brackets : - //! ex.: dispatch_name(parameter) - //! The parameter can be: an integer for DispPerCount or DispPerFiles - //! or the name of a Signature for DispPerSignature - //! Returns Null Handle if not found not well evaluated - Standard_EXPORT static Handle(IFSelect_Dispatch) GiveDispatch (const Handle(IFSelect_WorkSession)& WS, const Standard_CString name, const Standard_Boolean mode = Standard_True); - - //! Defines and loads all basic functions (as ActFunc) - Standard_EXPORT static void Init(); - -}; - -#endif // _IFSelect_Functions_HeaderFile diff --git a/src/TKXSDRAWBase/CMakeLists.txt b/src/TKXSDRAWBase/CMakeLists.txt new file mode 100644 index 0000000000..369f35e163 --- /dev/null +++ b/src/TKXSDRAWBase/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWBase) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWBase/EXTERNLIB b/src/TKXSDRAWBase/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWBase/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWBase/FILES b/src/TKXSDRAWBase/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWBase/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWBase/PACKAGES b/src/TKXSDRAWBase/PACKAGES new file mode 100644 index 0000000000..16e955c6b8 --- /dev/null +++ b/src/TKXSDRAWBase/PACKAGES @@ -0,0 +1 @@ +XSDRAWBase diff --git a/src/TKXSDRAWDEWrapper/CMakeLists.txt b/src/TKXSDRAWDEWrapper/CMakeLists.txt new file mode 100644 index 0000000000..4361037707 --- /dev/null +++ b/src/TKXSDRAWDEWrapper/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWDEWrapper) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWDEWrapper/EXTERNLIB b/src/TKXSDRAWDEWrapper/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWDEWrapper/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWDEWrapper/FILES b/src/TKXSDRAWDEWrapper/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWDEWrapper/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWDEWrapper/PACKAGES b/src/TKXSDRAWDEWrapper/PACKAGES new file mode 100644 index 0000000000..c6f027f574 --- /dev/null +++ b/src/TKXSDRAWDEWrapper/PACKAGES @@ -0,0 +1 @@ +XSDRAWDEWrapper diff --git a/src/TKXSDRAWGLTF/CMakeLists.txt b/src/TKXSDRAWGLTF/CMakeLists.txt new file mode 100644 index 0000000000..e372ec36a9 --- /dev/null +++ b/src/TKXSDRAWGLTF/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWGLTF) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWGLTF/EXTERNLIB b/src/TKXSDRAWGLTF/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWGLTF/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWGLTF/FILES b/src/TKXSDRAWGLTF/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWGLTF/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWGLTF/PACKAGES b/src/TKXSDRAWGLTF/PACKAGES new file mode 100644 index 0000000000..2d0b09ae11 --- /dev/null +++ b/src/TKXSDRAWGLTF/PACKAGES @@ -0,0 +1 @@ +XSDRAWGLTF diff --git a/src/TKXSDRAWIGES/CMakeLists.txt b/src/TKXSDRAWIGES/CMakeLists.txt new file mode 100644 index 0000000000..25283fb05b --- /dev/null +++ b/src/TKXSDRAWIGES/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWIGES) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWIGES/EXTERNLIB b/src/TKXSDRAWIGES/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWIGES/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWIGES/FILES b/src/TKXSDRAWIGES/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWIGES/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWIGES/PACKAGES b/src/TKXSDRAWIGES/PACKAGES new file mode 100644 index 0000000000..bf6073a6f6 --- /dev/null +++ b/src/TKXSDRAWIGES/PACKAGES @@ -0,0 +1 @@ +XSDRAWIGES diff --git a/src/TKXSDRAWOBJ/CMakeLists.txt b/src/TKXSDRAWOBJ/CMakeLists.txt new file mode 100644 index 0000000000..39d98fdd11 --- /dev/null +++ b/src/TKXSDRAWOBJ/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWOBJ) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWOBJ/EXTERNLIB b/src/TKXSDRAWOBJ/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWOBJ/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWOBJ/FILES b/src/TKXSDRAWOBJ/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWOBJ/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWOBJ/PACKAGES b/src/TKXSDRAWOBJ/PACKAGES new file mode 100644 index 0000000000..2f48af3a9f --- /dev/null +++ b/src/TKXSDRAWOBJ/PACKAGES @@ -0,0 +1 @@ +XSDRAWOBJ diff --git a/src/TKXSDRAWPLY/CMakeLists.txt b/src/TKXSDRAWPLY/CMakeLists.txt new file mode 100644 index 0000000000..9b20129361 --- /dev/null +++ b/src/TKXSDRAWPLY/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWPLY) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWPLY/EXTERNLIB b/src/TKXSDRAWPLY/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWPLY/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWPLY/FILES b/src/TKXSDRAWPLY/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWPLY/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWPLY/PACKAGES b/src/TKXSDRAWPLY/PACKAGES new file mode 100644 index 0000000000..e62ce608cf --- /dev/null +++ b/src/TKXSDRAWPLY/PACKAGES @@ -0,0 +1 @@ +XSDRAWPLY diff --git a/src/TKXSDRAWSTEP/CMakeLists.txt b/src/TKXSDRAWSTEP/CMakeLists.txt new file mode 100644 index 0000000000..5ecb56ef07 --- /dev/null +++ b/src/TKXSDRAWSTEP/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWSTEP) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWSTEP/EXTERNLIB b/src/TKXSDRAWSTEP/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWSTEP/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWSTEP/FILES b/src/TKXSDRAWSTEP/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWSTEP/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWSTEP/PACKAGES b/src/TKXSDRAWSTEP/PACKAGES new file mode 100644 index 0000000000..33b99297d1 --- /dev/null +++ b/src/TKXSDRAWSTEP/PACKAGES @@ -0,0 +1 @@ +XSDRAWSTEP diff --git a/src/TKXSDRAWSTL/CMakeLists.txt b/src/TKXSDRAWSTL/CMakeLists.txt new file mode 100644 index 0000000000..1a8b908936 --- /dev/null +++ b/src/TKXSDRAWSTL/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWSTL) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWSTL/EXTERNLIB b/src/TKXSDRAWSTL/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWSTL/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWSTL/FILES b/src/TKXSDRAWSTL/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWSTL/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWSTL/PACKAGES b/src/TKXSDRAWSTL/PACKAGES new file mode 100644 index 0000000000..c6c1f752ee --- /dev/null +++ b/src/TKXSDRAWSTL/PACKAGES @@ -0,0 +1 @@ +XSDRAWSTL diff --git a/src/TKXSDRAWVRML/CMakeLists.txt b/src/TKXSDRAWVRML/CMakeLists.txt new file mode 100644 index 0000000000..75fe4d8273 --- /dev/null +++ b/src/TKXSDRAWVRML/CMakeLists.txt @@ -0,0 +1,3 @@ +project(TKXSDRAWVRML) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKXSDRAWVRML/EXTERNLIB b/src/TKXSDRAWVRML/EXTERNLIB new file mode 100644 index 0000000000..1947db4b4f --- /dev/null +++ b/src/TKXSDRAWVRML/EXTERNLIB @@ -0,0 +1,24 @@ +TKBRep +TKV3d +TKMath +TKernel +TKService +TKXSBase +TKMeshVS +TKG3d +TKViewerTest +TKG2d +TKSTEPBase +TKTopAlgo +TKGeomBase +TKGeomAlgo +TKMesh +TKDraw +TKSTEP +TKIGES +TKSTL +TKVRML +TKLCAF +TKDCAF +TKXCAF +TKRWMesh diff --git a/src/TKXSDRAWVRML/FILES b/src/TKXSDRAWVRML/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/src/TKXSDRAWVRML/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/src/TKXSDRAWVRML/PACKAGES b/src/TKXSDRAWVRML/PACKAGES new file mode 100644 index 0000000000..d0fc037807 --- /dev/null +++ b/src/TKXSDRAWVRML/PACKAGES @@ -0,0 +1 @@ +XSDRAWVRML diff --git a/src/XDEDRAW/XDEDRAW_Common.cxx b/src/XDEDRAW/XDEDRAW_Common.cxx index b22973baa3..266d1a6355 100644 --- a/src/XDEDRAW/XDEDRAW_Common.cxx +++ b/src/XDEDRAW/XDEDRAW_Common.cxx @@ -223,348 +223,6 @@ static Standard_Integer FromShape(Draw_Interpretor& theDI, return 0; } -//======================================================================= -//function : ReadIges -//purpose : Read IGES to DECAF document -//======================================================================= -static Standard_Integer ReadIges(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: read IGES file to a document\n"; - return 0; - } - Handle(IGESCAFControl_ConfigurationNode) aNode = - new IGESCAFControl_ConfigurationNode(); - Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible"); - aNode->InternalParameters.ReadOnlyVisible = onlyvisible == 1; - if (theNbArgs == 4) - { - Standard_Boolean aMode = Standard_True; - for (Standard_Integer i = 0; theArgVec[3][i]; i++) - switch (theArgVec[3][i]) - { - case '-': aMode = Standard_False; break; - case '+': aMode = Standard_True; break; - case 'c': aNode->InternalParameters.ReadColor = aMode; break; - case 'n': aNode->InternalParameters.ReadName = aMode; break; - case 'l': aNode->InternalParameters.ReadLayer = aMode; break; - } - } - Handle(TDocStd_Document) aDoc; - if (!DDocStd::GetDocument(theArgVec[1], aDoc, Standard_False)) - { - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - anApp->NewDocument("BinXCAF", aDoc); - TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]); - Handle(DDocStd_DrawDocument) aDrawD = new DDocStd_DrawDocument(aDoc); - Draw::Set(theArgVec[1], aDrawD); - } - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); - Handle(IGESCAFControl_Provider) aProvider = - new IGESCAFControl_Provider(aNode); - aProvider->SetToUpdateStaticParameters(false); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start())) - { - theDI << "Error: Can't read IGES file\n"; - return 1; - } - CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); - Message::SendInfo() << "Document saved with name " << theArgVec[1]; - return 0; -} - -//======================================================================= -//function : WriteIges -//purpose : Write DECAF document to IGES -//======================================================================= -//======================================================================= -static Standard_Integer WriteIges(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: write document to IGES file\n"; - return 0; - } - Handle(IGESCAFControl_ConfigurationNode) aNode = - new IGESCAFControl_ConfigurationNode(); - Handle(TDocStd_Document) aDoc; - DDocStd::GetDocument(theArgVec[1], aDoc); - if (aDoc.IsNull()) - { - theDI << theArgVec[1] << " is not a document\n"; - return 1; - } - if (theNbArgs == 4) - { - Standard_Boolean aMode = Standard_True; - for (Standard_Integer i = 0; theArgVec[3][i]; i++) - switch (theArgVec[3][i]) - { - case '-': aMode = Standard_False; break; - case '+': aMode = Standard_True; break; - case 'c': aNode->InternalParameters.WriteColor = aMode; break; - case 'n': aNode->InternalParameters.WriteName = aMode; break; - case 'l': aNode->InternalParameters.WriteLayer = aMode; break; - } - } - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); - Handle(IGESCAFControl_Provider) aProvider = - new IGESCAFControl_Provider(aNode); - aProvider->SetToUpdateStaticParameters(false); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - const TCollection_AsciiString aPath = theArgVec[2]; - if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start())) - { - theDI << "Error: Can't write IGES file\n"; - return 1; - } - CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS); - return 0; -} - -//======================================================================= -//function : ReadStep -//purpose : Read STEP file to DECAF document -//======================================================================= -static Standard_Integer ReadStep(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - - Standard_CString aDocName = NULL; - TCollection_AsciiString aFilePath, aModeStr; - bool aToTestStream = false; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (anArgCase == "-stream") - { - aToTestStream = true; - } - else if (aDocName == NULL) - { - aDocName = theArgVec[anArgIter]; - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else if (aModeStr.IsEmpty()) - { - aModeStr = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - Handle(STEPCAFControl_ConfigurationNode) aNode = - new STEPCAFControl_ConfigurationNode(); - if (!aModeStr.IsEmpty()) - { - Standard_Boolean aMode = Standard_True; - for (Standard_Integer i = 1; aModeStr.Value(i); ++i) - { - switch (aModeStr.Value(i)) - { - case '-': aMode = Standard_False; break; - case '+': aMode = Standard_True; break; - case 'c': aNode->InternalParameters.WriteColor = aMode; break; - case 'n': aNode->InternalParameters.WriteName = aMode; break; - case 'l': aNode->InternalParameters.WriteLayer = aMode; break; - case 'v': aNode->InternalParameters.WriteProps = aMode; break; - default: - { - theDI << "Syntax error at '" << aModeStr << "'\n"; - return 1; - } - } - } - } - Handle(TDocStd_Document) aDoc; - if (!DDocStd::GetDocument(aDocName, aDoc, Standard_False)) - { - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - anApp->NewDocument("BinXCAF", aDoc); - TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName); - Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); - Draw::Set(aDocName, aDrawDoc); - } - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); - Handle(STEPCAFControl_Provider) aProvider = - new STEPCAFControl_Provider(aNode); - aProvider->SetToUpdateStaticParameters(false); - Standard_Boolean aReadStat = Standard_False; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (aToTestStream) - { - std::ifstream aStream; - OSD_OpenStream(aStream, aFilePath.ToCString(), std::ios::in | std::ios::binary); - TCollection_AsciiString aFolder, aFileNameShort; - OSD_Path::FolderAndFileFromPath(aFilePath, aFolder, aFileNameShort); - aReadStat = - aProvider->Read(aStream, aDoc, aFilePath, aWS, aProgress->Start()); - } - else - { - aReadStat = - aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); - } - if (!aReadStat) - { - theDI << "Cannot read any relevant data from the STEP file\n"; - return 1; - } - Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); - Draw::Set(aDocName, aDrawDoc); - CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); - Message::SendInfo() << "Document saved with name " << aDocName; - return 0; -} - -//======================================================================= -//function : WriteStep -//purpose : Write DECAF document to STEP -//======================================================================= -static Standard_Integer WriteStep(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - Handle(TDocStd_Document) aDoc; - TCollection_AsciiString aDocName, aFilePath; - Handle(STEPCAFControl_ConfigurationNode) aNode = - new STEPCAFControl_ConfigurationNode(); - bool aHasModeArg = false, aToTestStream = false; - TDF_Label aLabel; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (anArgCase == "-stream") - { - aToTestStream = true; - } - else if (aDocName.IsEmpty()) - { - Standard_CString aDocNameStr = theArgVec[anArgIter]; - DDocStd::GetDocument(aDocNameStr, aDoc); - if (aDoc.IsNull()) - { - theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a document\n"; - return 1; - } - aDocName = aDocNameStr; - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else if (!aHasModeArg) - { - aHasModeArg = true; - Standard_Boolean aIsWriteType = Standard_True; - switch (anArgCase.Value(1)) - { - case 'a': - case '0': aNode->InternalParameters.WriteModelType = STEPControl_AsIs; break; - case 'f': - case '1': aNode->InternalParameters.WriteModelType = STEPControl_FacetedBrep; break; - case 's': - case '2': aNode->InternalParameters.WriteModelType = STEPControl_ShellBasedSurfaceModel; break; - case 'm': - case '3': aNode->InternalParameters.WriteModelType = STEPControl_ManifoldSolidBrep; break; - case 'w': - case '4': aNode->InternalParameters.WriteModelType = STEPControl_GeometricCurveSet; break; - default: - { - aIsWriteType = Standard_False; - } - } - Standard_Boolean aWrMode = Standard_True; - Standard_Boolean aIsAttrType = Standard_True; - for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i) - { - switch (anArgCase.Value(i)) - { - case '-': aWrMode = Standard_False; break; - case '+': aWrMode = Standard_True; break; - case 'c': aNode->InternalParameters.WriteColor = aWrMode; break; - case 'n': aNode->InternalParameters.WriteName = aWrMode; break; - case 'l': aNode->InternalParameters.WriteLayer = aWrMode; break; - case 'v': aNode->InternalParameters.WriteProps = aWrMode; break; - default: - { - aIsAttrType = Standard_False; - } - } - } - if (!aIsAttrType && !aIsWriteType) - { - theDI << "Syntax error: mode '" << anArgCase << "' is incorrect mode\n"; - return 1; - } - } - else if (aNode->InternalParameters.WriteMultiPrefix.IsEmpty() - && anArgCase.Search(":") == -1) - { - aNode->InternalParameters.WriteMultiPrefix = theArgVec[anArgIter]; - } - else if (aLabel.IsNull()) - { - aNode->InternalParameters.WriteLabels.Append(theArgVec[anArgIter]); - } - else - { - theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); - Handle(STEPCAFControl_Provider) aProvider = - new STEPCAFControl_Provider(aNode); - aProvider->SetToUpdateStaticParameters(false); - Standard_Boolean aReadStat = Standard_False; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (aToTestStream) - { - std::ofstream aStream; - OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary); - TCollection_AsciiString aFolder, aFileNameShort; - OSD_Path::FolderAndFileFromPath(aFilePath, aFolder, aFileNameShort); - aReadStat = - aProvider->Write(aStream, aDoc, aWS, aProgress->Start()); - } - else - { - aReadStat = - aProvider->Write(aFilePath, aDoc, aWS, aProgress->Start()); - } - if (!aReadStat) - { - theDI << "Cannot write any relevant data to the STEP file\n"; - return 1; - } - CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); - return 0; -} - //======================================================================= //function : Expand //purpose : @@ -692,504 +350,6 @@ static Standard_Integer Extract(Draw_Interpretor& theDI, return 0; } -//======================================================================= -//function : ReadVrml -//purpose : -//======================================================================= -static Standard_Integer ReadVrml(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI.PrintHelp(theArgVec[0]); - return 1; - } - Handle(Vrml_ConfigurationNode) aNode = - new Vrml_ConfigurationNode(); - Handle(TDocStd_Document) aDoc; - Standard_Boolean toUseExistingDoc = Standard_False; - Standard_CString aDocName = NULL; - TCollection_AsciiString aFilePath; - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++) - { - TCollection_AsciiString anArg(theArgVec[anArgIt]); - anArg.LowerCase(); - if (anArgIt + 1 < theNbArgs && anArg == "-fileunit") - { - const TCollection_AsciiString aUnitStr(theArgVec[++anArgIt]); - aNode->InternalParameters.ReadFileUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); - if (aNode->InternalParameters.ReadFileUnit <= 0.0) - { - theDI << "Error: wrong length unit '" << aUnitStr << "'\n"; - return 1; - } - } - else if (anArgIt + 1 < theNbArgs && anArg == "-filecoordsys") - { - if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadFileCoordinateSys)) - { - theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n"; - return 1; - } - } - else if (anArgIt + 1 < theNbArgs && anArg == "-systemcoordsys") - { - if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadSystemCoordinateSys)) - { - theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n"; - return 1; - } - } - else if (anArg == "-fillincomplete") - { - aNode->InternalParameters.ReadFillIncomplete = true; - if (anArgIt + 1 < theNbArgs && - Draw::ParseOnOff(theArgVec[anArgIt + 1], aNode->InternalParameters.ReadFillIncomplete)) - { - ++anArgIt; - } - } - else if (anArg == "-nocreatedoc") - { - toUseExistingDoc = true; - } - else if (aDocName == nullptr) - { - aDocName = theArgVec[anArgIt]; - DDocStd::GetDocument(aDocName, aDoc, Standard_False); - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIt]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIt] << "'\n"; - return 1; - } - } - - if (aFilePath.IsEmpty() || aDocName == nullptr) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - - if (aDoc.IsNull()) - { - if (toUseExistingDoc) - { - theDI << "Error: document with name " << aDocName << " does not exist\n"; - return 1; - } - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - anApp->NewDocument("BinXCAF", aDoc); - } - else if (!toUseExistingDoc) - { - theDI << "Error: document with name " << aDocName << " already exists\n"; - return 1; - } - Handle(Vrml_Provider) aProvider = - new Vrml_Provider(aNode); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start())) - { - theDI << "Error: file reading failed '" << aFilePath << "'\n"; - return 1; - } - TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName); - Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc); - Draw::Set(aDocName, aDD); - CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); - return 0; -} - -//======================================================================= -//function : WriteVrml -//purpose : Write DECAF document to Vrml -//======================================================================= -static Standard_Integer WriteVrml(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Use: " << theArgVec[0] << " Doc filename: write document to Vrml file\n"; - return 0; - } - - Handle(TDocStd_Document) aDoc; - DDocStd::GetDocument(theArgVec[1], aDoc); - if (aDoc.IsNull()) - { - theDI << theArgVec[1] << " is not a document\n"; - return 1; - } - - if (theNbArgs < 3 || theNbArgs > 5) - { - theDI << "wrong number of parameters\n"; - return 0; - } - Handle(Vrml_ConfigurationNode) aNode = - new Vrml_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(Vrml_Provider) aProvider = - new Vrml_Provider(aNode); - - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) - { - theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; - return 1; - } - CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); - return 0; -} - -//======================================================================= -//function : DumpConfiguration -//purpose : -//======================================================================= -static Standard_Integer DumpConfiguration(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper(); - TCollection_AsciiString aPath; - Standard_Boolean aIsRecursive = Standard_True; - Standard_Boolean isHandleFormat = Standard_False; - Standard_Boolean isHandleVendors = Standard_False; - TColStd_ListOfAsciiString aFormats; - TColStd_ListOfAsciiString aVendors; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArg(theArgVec[anArgIter]); - anArg.LowerCase(); - if ((anArg == "-path") && - (anArgIter + 1 < theNbArgs)) - { - ++anArgIter; - aPath = theArgVec[anArgIter]; - } - else if ((anArg == "-recursive") && - (anArgIter + 1 < theNbArgs) && - Draw::ParseOnOff(theArgVec[anArgIter + 1], aIsRecursive)) - { - ++anArgIter; - } - else if (anArg == "-format") - { - isHandleFormat = Standard_True; - isHandleVendors = Standard_False; - } - else if (anArg == "-vendor") - { - isHandleFormat = Standard_False; - isHandleVendors = Standard_True; - } - else if (isHandleFormat) - { - aFormats.Append(theArgVec[anArgIter]); - } - else if (isHandleVendors) - { - aVendors.Append(theArgVec[anArgIter]); - } - else if (!isHandleFormat && !isHandleVendors) - { - theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - Standard_Boolean aStat = Standard_True; - if (!aPath.IsEmpty()) - { - aStat = aConf->Save(aPath, aIsRecursive, aFormats, aVendors); - } - else - { - theDI << aConf->Save(aIsRecursive, aFormats, aVendors) << "\n"; - } - if (!aStat) - { - return 1; - } - return 0; -} - -//======================================================================= -//function : CompareConfiguration -//purpose : -//======================================================================= -static Standard_Integer CompareConfiguration(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs > 5) - { - theDI.PrintHelp(theArgVec[0]); - return 1; - } - Handle(DE_ConfigurationContext) aResourceFirst = new DE_ConfigurationContext(); - if (!aResourceFirst->Load(theArgVec[1])) - { - theDI << "Error: Can't load first configuration\n"; - return 1; - } - Handle(DE_ConfigurationContext) aResourceSecond = new DE_ConfigurationContext(); - if (!aResourceSecond->Load(theArgVec[2])) - { - theDI << "Error: Can't load second configuration\n"; - return 1; - } - const DE_ResourceMap& aResourceMapFirst = aResourceFirst->GetInternalMap(); - const DE_ResourceMap& aResourceMapSecond = aResourceSecond->GetInternalMap(); - Standard_Integer anDiffers = 0; - for (DE_ResourceMap::Iterator anOrigIt(aResourceMapFirst); - anOrigIt.More(); anOrigIt.Next()) - { - const TCollection_AsciiString& anOrigValue = anOrigIt.Value(); - const TCollection_AsciiString& anOrigKey = anOrigIt.Key(); - TCollection_AsciiString aCompValue; - if (!aResourceMapSecond.Find(anOrigKey, aCompValue)) - { - Message::SendWarning() << "Second configuration don't have the next scope : " << anOrigKey; - anDiffers++; - } - if (!aCompValue.IsEqual(anOrigValue)) - { - Message::SendWarning() << "Configurations have differs value with the next scope :" << anOrigKey - << " First value : " << anOrigValue << " Second value : " << aCompValue; - anDiffers++; - } - } - TCollection_AsciiString aMessage; - if (aResourceMapFirst.Extent() != aResourceMapSecond.Extent() || anDiffers > 0) - { - theDI << "Error: Configurations are not same : " << " Differs count : " - << anDiffers << " Count of first's scopes : " << aResourceMapFirst.Extent() - << " Count of second's scopes : " << aResourceMapSecond.Extent() << "\n"; - return 1; - } - return 0; -} - -//======================================================================= -//function : LoadConfiguration -//purpose : -//======================================================================= -static Standard_Integer LoadConfiguration(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs > 4) - { - theDI.PrintHelp(theArgVec[0]); - return 1; - } - Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper(); - TCollection_AsciiString aString = theArgVec[1]; - Standard_Boolean aIsRecursive = Standard_True; - if (theNbArgs == 4) - { - TCollection_AsciiString anArg = theArgVec[2]; - anArg.LowerCase(); - if (!(anArg == "-recursive") || - !Draw::ParseOnOff(theArgVec[3], aIsRecursive)) - { - theDI << "Syntax error at argument '" << theArgVec[3] << "'\n"; - return 1; - } - } - if (!aConf->Load(aString, aIsRecursive)) - { - theDI << "Error: configuration is incorrect\n"; - return 1; - } - return 0; -} - -//======================================================================= -//function : ReadFile -//purpose : -//======================================================================= -static Standard_Integer ReadFile(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs > 6) - { - theDI.PrintHelp(theArgVec[0]); - return 1; - } - TCollection_AsciiString aDocShapeName; - TCollection_AsciiString aFilePath; - Handle(TDocStd_Document) aDoc; - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - TCollection_AsciiString aConfString; - Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readfile"); - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArg(theArgVec[anArgIter]); - anArg.LowerCase(); - if ((anArg == "-conf") && - (anArgIter + 1 < theNbArgs)) - { - ++anArgIter; - aConfString = theArgVec[anArgIter]; - } - else if (aDocShapeName.IsEmpty()) - { - aDocShapeName = theArgVec[anArgIter]; - Standard_CString aNameVar = aDocShapeName.ToCString(); - if (!isNoDoc) - { - DDocStd::GetDocument(aNameVar, aDoc, Standard_False); - } - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - if (aDoc.IsNull() && !isNoDoc) - { - anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); - Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); - TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]); - Draw::Set(theArgVec[1], aDrawDoc); - } - - Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy(); - Standard_Boolean aStat = Standard_True; - if (!aConfString.IsEmpty()) - { - aStat = aConf->Load(aConfString); - } - if (aStat) - { - TopoDS_Shape aShape; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS); - if (isNoDoc && aStat) - { - DBRep::Set(aDocShapeName.ToCString(), aShape); - } - CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); - } - if (!aStat) - { - return 1; - } - return 0; -} - -//======================================================================= -//function : WriteFile -//purpose : -//======================================================================= -static Standard_Integer WriteFile(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs > 6) - { - theDI.PrintHelp(theArgVec[0]); - return 1; - } - TCollection_AsciiString aDocShapeName; - TCollection_AsciiString aFilePath; - Handle(TDocStd_Document) aDoc; - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - TCollection_AsciiString aConfString; - Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "writefile"); - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArg(theArgVec[anArgIter]); - anArg.LowerCase(); - if ((anArg == "-conf") && - (anArgIter + 1 < theNbArgs)) - { - ++anArgIter; - aConfString = theArgVec[anArgIter]; - } - else if (aDocShapeName.IsEmpty()) - { - aDocShapeName = theArgVec[anArgIter]; - Standard_CString aNameVar = aDocShapeName.ToCString(); - if (!isNoDoc) - { - DDocStd::GetDocument(aNameVar, aDoc, Standard_False); - } - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - if (aDoc.IsNull() && !isNoDoc) - { - theDI << "Error: incorrect document\n"; - return 1; - } - Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy(); - Standard_Boolean aStat = Standard_True; - if (!aConfString.IsEmpty()) - { - aStat = aConf->Load(aConfString); - } - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (aStat) - { - if (isNoDoc) - { - TopoDS_Shape aShape = DBRep::Get(aDocShapeName); - if (aShape.IsNull()) - { - theDI << "Error: incorrect shape " << aDocShapeName << "\n"; - return 1; - } - aStat = aConf->Write(aFilePath, aShape, aWS); - } - else - { - aStat = aConf->Write(aFilePath, aDoc, aWS); - } - } - if (!aStat) - { - return 1; - } - CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); - return 0; -} - void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI) { static Standard_Boolean initactor = Standard_False; @@ -1201,25 +361,6 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI) Standard_CString g = "XDE translation commands"; - theDI.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g); - theDI.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g); - theDI.Add("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); - theDI.Add("WriteStep", - "Doc filename [mode=a [multifile_prefix] [label]] [-stream]" - "\n\t\t: Write DECAF document to STEP file" - "\n\t\t: mode can be: a or 0 : AsIs (default)" - "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel" - "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame" - "\n\t\t: multifile_prefix: triggers writing assembly components as separate files," - "\n\t\t: and defines common prefix for their names" - "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly" - "\n\t\t: -stream read using ostream writing interface (testing)", - __FILE__, WriteStep, g); - 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); @@ -1230,56 +371,4 @@ void XDEDRAW_Common::InitCommands(Draw_Interpretor& theDI) 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); - - theDI.Add("ReadVrml", - "ReadVrml docName filePath [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" - "\n\t\t: [-systemCoordSys {Zup|Yup}] [-noCreateDoc] [-fillIncomplete {ON|OFF}]" - "\n\t\t: Read Vrml file into XDE document." - "\n\t\t: -fileCoordSys coordinate system defined by Vrml file; Yup when not specified." - "\n\t\t: -fileUnit length unit of Vrml file content." - "\n\t\t: -systemCoordSys result coordinate system; Zup when not specified." - "\n\t\t: -noCreateDoc read into existing XDE document." - "\n\t\t: -fillIncomplete fill the document with partially retrieved data even if reader has failed with " - "error; true when not specified", - __FILE__, ReadVrml, g); - theDI.Add("WriteVrml", - "WriteVrml Doc filename [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 0 by default]", - __FILE__, WriteVrml, g); - - theDI.Add("DumpConfiguration", - "DumpConfiguration [-path ] [-recursive {on|off}] [-format fmt1 fmt2 ...] [-vendor vend1 vend2 ...]\n" - "\n\t\t: Dump special resource generated from global configuration." - "\n\t\t: '-path' - save resource configuration to the file" - "\n\t\t: '-recursive' - flag to generate a resource from providers. Default is On. Off disables other options" - "\n\t\t: '-format' - flag to generate a resource for choosen formats. If list is empty, generate it for all" - "\n\t\t: '-vendor' - flag to generate a resource for choosen vendors. If list is empty, generate it for all", - __FILE__, DumpConfiguration, g); - theDI.Add("LoadConfiguration", - "LoadConfiguration conf [-recursive {on|off}]\n" - "\n\t\t: 'conf' - path to the resouce file or string value in the special format" - "\n\t\t: '-recursive' - flag to generate a resource for all providers. Default is true" - "\n\t\t: Configure global configuration according special resource", - __FILE__, LoadConfiguration, g); - theDI.Add("CompareConfiguration", - "CompareConfiguration conf1 conf2\n" - "\n\t\t: 'conf1' - path to the first resouce file or string value in the special format" - "\n\t\t: 'conf2' - path to the second resouce file or string value in the special format" - "\n\t\t: Compare two configurations", - __FILE__, CompareConfiguration, g); - theDI.Add("ReadFile", - "ReadFile docName filePath [-conf ]\n" - "\n\t\t: Read CAD file to document with registered format's providers. Use global configuration by default.", - __FILE__, ReadFile, g); - theDI.Add("readfile", - "readfile shapeName filePath [-conf ]\n" - "\n\t\t: Read CAD file to shape with registered format's providers. Use global configuration by default.", - __FILE__, ReadFile, g); - theDI.Add("WriteFile", - "WriteFile docName filePath [-conf ]\n" - "\n\t\t: Write CAD file to document with registered format's providers. Use global configuration by default.", - __FILE__, WriteFile, g); - theDI.Add("writefile", - "writefile shapeName filePath [-conf ]\n" - "\n\t\t: Write CAD file to shape with registered format's providers. Use global configuration by default.", - __FILE__, WriteFile, g); } diff --git a/src/XDEDRAW/XDEDRAW_Common.hxx b/src/XDEDRAW/XDEDRAW_Common.hxx index d945f419ee..2597713404 100644 --- a/src/XDEDRAW/XDEDRAW_Common.hxx +++ b/src/XDEDRAW/XDEDRAW_Common.hxx @@ -21,8 +21,6 @@ #include - - class XDEDRAW_Common { public: diff --git a/src/XSControl/FILES b/src/XSControl/FILES index 034d830ee8..05bc1b3d64 100644 --- a/src/XSControl/FILES +++ b/src/XSControl/FILES @@ -4,10 +4,6 @@ XSControl_ConnectedShapes.cxx XSControl_ConnectedShapes.hxx XSControl_Controller.cxx XSControl_Controller.hxx -XSControl_FuncShape.cxx -XSControl_FuncShape.hxx -XSControl_Functions.cxx -XSControl_Functions.hxx XSControl_Reader.cxx XSControl_Reader.hxx XSControl_SelectForTransfer.cxx diff --git a/src/XSControl/XSControl_FuncShape.cxx b/src/XSControl/XSControl_FuncShape.cxx deleted file mode 100644 index 2c1b347eb5..0000000000 --- a/src/XSControl/XSControl_FuncShape.cxx +++ /dev/null @@ -1,834 +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 -#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 -// ###################################################################### -// #### #### -// #### COMMANDS #### -// #### #### -// ###################################################################### -//======================================================================= -//function : XSControl_tpdraw -//purpose : -//======================================================================= -static IFSelect_ReturnStatus XSControl_tpdraw - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - const Standard_CString arg3 = pilot->Arg(3); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TP.IsNull()) { sout<<"No Transfer Read"<Word(0).Value(3) == 'r'); - - Standard_Integer n1, n2, i, max=0, index=0; - Handle(Interface_InterfaceModel) model = TP->Model(); - if (model.IsNull()) { - if (mode == 0) { - sout<<"Pas de modele, preciser n0 d item de transfert"<NbEntities(); } - if (mode == 1) { sout<<"Item de transfert"; max = TP->NbMapped(); } - if (mode == 2) { sout<<"Racine de transfert"; max = TP->NbRoots(); } - if (tout) { - n1 = 1; n2 = max; - sout<<", listage de 1 a "< max) { - sout<<" - Num="<Value(i); - num = i; - index = TP->MapIndex(ent); - } else if (mode == 1) { - ent = TP->Mapped(i); - if (model.IsNull()) num = 0; - else num = model->Number(ent); - index = i; - } else if (mode == 2) { - ent = TP->Root(i); - if (model.IsNull()) num = 0; - else num = model->Number(ent); - index = TP->MapIndex(ent); - } - - if (index > 0) binder = TP->MapItem (index); - if (binder.IsNull()) index = 0; - if (index == 0) { - if (!tout) sout<<"Entite n0 "<HasResult()) { - if (!tout) sout<<"Entite n0 "<Result(); - nbvar ++; - if (sh.IsNull()) { sout<<" (no Shape recorded)"< 3 && mode > 0) sprintf (nomvar,"%s",arg3); - else if (argc > 2 && mode == 0) sprintf (nomvar,"%s",arg2); - else sprintf (nomvar,"tp_%d",i); - } else { - if (argc > 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar); - else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar); - else sprintf (nomvar,"tp_%d",i); - } - sout<<" -> 1 DRAW Shape: "<SetShape(nomvar,sh); - continue; - } - DeclareAndCast(TransferBRep_ShapeListBinder,slb,binder); - if (!slb.IsNull()) { - Standard_Integer nbs = slb->NbShapes(); - if (tout) sout<<"[ "< "<Shape(j); if (nbvar < 0) nbvar = 0; nbvar ++; - if (sh.IsNull()) { sout<<" (no Shape recorded)"< 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar); - else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar); - else sprintf (nomvar,"tp_%d_%d",i,nbvar); - sout<<" "<SetShape(nomvar,sh); - } - sout<Result(); - if (resu.IsNull()) { - sout<<"Entite n0 "<DynamicType()->Name(); - if (geom.IsNull()) { sout< 3 && mode > 0) sprintf (nomvar,"%s",arg3); - else if (argc > 2 && mode == 0) sprintf (nomvar,"%s",arg2); - else sprintf (nomvar,"tp_%d",i); - } else { - if (argc > 3 && mode > 0) sprintf (nomvar,"%s_%d",arg3,nbvar); - else if (argc > 2 && mode == 0) sprintf (nomvar,"%s_%d",arg2,nbvar); - else sprintf (nomvar,"tp_%d",i); - } - char* nomv = nomvar; - XSControl::Vars(pilot)->Set (nomv,geom); - sout<<" -> DRAW Geom : "<ResultTypeName()<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TP.IsNull()) { sout<<"No Transfer Read"<Session(),pilot->CommandPart(2)); - if (lise.IsNull()) { sout<<"Not a valid entity list : "<CommandPart(2)<Length()<<" Entities, "; - } - if (list.IsNull()) { sout<<"No Shape listed"<Length(); - sout<Value(i)); - XSControl::Vars(pilot)->SetShape (arg1,C); - return IFSelect_RetDone; -} - - - -//======================================================================= -//function : XSControl_traccess -//purpose : -//======================================================================= -static IFSelect_ReturnStatus XSControl_traccess - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - // **** trdraw : TransferReader **** 26 - // **** trsave : TransferReader **** 27 - // **** trcomp (comp -> DRAW) **** 28 - // **** trscomp (comp -> save) **** 29 - Standard_Boolean cascomp = (pilot->Word(0).Location(1,'o',1,5) > 0); - Standard_Boolean cassave = (pilot->Word(0).Location(1,'s',1,5) > 0); - TCollection_AsciiString nomsh, noms; - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TR.IsNull()) { sout<<" manque init"<Model(); - if (mdl.IsNull()) { sout<<" modele absent"< 1 ? IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot),arg1) : 0); - - if (argc > 1) nomsh = arg1; - else nomsh = cascomp ? "TREAD_COMP" : "TREAD_LIST"; - if (cassave) sout<<" save shapes -> current directory"<ShapeResultList(Standard_True); - sout<<" TOUS RESULTATS par ShapeResultList, soit "<Length()<Length(); i <= nb; ++i) - { - noms = nomsh + "_" + i; - if ( (i%1000) == 0) sout<<"("<Value(i).IsNull()) continue; - if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape (noms.ToCString(), list->Value(i)); - else if (!cascomp && cassave) BRepTools::Write (list->Value(i), noms.ToCString()); - else if (cascomp) B.Add (C,list->Value(i)); - } - sout<SetShape (nomsh.ToCString(), C); - else if (cascomp && cassave) BRepTools::Write (C, nomsh.ToCString()); - } else { - if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect:"<ShapeResult(mdl->Value(num)); - if (sh.IsNull()) { sout<<" Pas de resultat pour "< 2) nomsh = arg2; - else nomsh = TCollection_AsciiString ("TREAD_") + num; - if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape (nomsh.ToCString(), sh); - else if (!cascomp && cassave) BRepTools::Write (sh, nomsh.ToCString()); - else sout<<"Option non comprise"< 0) { - TopoDS_Shape varShape; - aLevel--; - TopoDS_Iterator it(sh); - for (; it.More(); it.Next() ) { - varShape = it.Value(); - if ( XSControl_IsEqualSubShape(Shape, varShape, aLevel) ) return Standard_True; - } - } - return Standard_False; -} - -//======================================================================= -//function : XSControl_fromshape -//purpose : -//======================================================================= -static IFSelect_ReturnStatus XSControl_fromshape - (const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** fromshape (tread) **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { - sout<<"Give name of a DRAW Shape"<GetShape(a1); - if (Shape.IsNull()) { - sout<<"Not a DRAW Shape:"<=3 ) - aLevel = atoi(pilot->Arg(2)); - Standard_Boolean silent = Standard_False; - if (aLevel <0 ) { - silent = Standard_True; - aLevel = -aLevel; - } - - // IMPORT - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - if (TR.IsNull()) { } // sout<<"No read transfer (import) recorded"<EntityFromShapeResult (Shape,modrec); - if (ent.IsNull()) { - modrec = -1; - ent = TR->EntityFromShapeResult (Shape,modrec); - } - if (ent.IsNull()) { - modrec = 2; - Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); - if (TP.IsNull()) { - if ( silent ) - sout << "Shape "<NbMapped(); - if ( ! silent ) sout<<"searching in map among "<Mapped(i); - TopoDS_Shape sh = TransferBRep::ShapeResult(TP,ent); - if (sh.IsNull()) { - ent.Nullify(); - continue; - } - if (XSControl_IsEqualSubShape(Shape, sh, aLevel)) break; - modrec = -2; - sh.Location ( L ); - if (XSControl_IsEqualSubShape(S0, sh, aLevel)) break; - ent.Nullify(); - modrec = 2; - } - } - } - if ( ! ent.IsNull() ) { - if ( silent ) sout << "Shape " << arg1 << ": "; - if (modrec <0) sout<<"(moved from origin) "; - //else sout<<"(origin) "; - } - // on affiche - if (ent.IsNull()) { - if ( ! silent ) sout<<" unknown as imported"; - // skl 11.05.2004 - // if Shape is a compound try to make "fromshape" for its subshapes - if(Shape.ShapeType()==TopAbs_COMPOUND) { - sout<EntityFromShapeResult(subsh,submodrec); - if (subent.IsNull()) { - submodrec = -1; - subent = TR->EntityFromShapeResult(subsh,submodrec); - } - if (!subent.IsNull()) { - sout<<" "<Model()->Number(subent); - } - } - } - } - else { - sout<<"imported from entity "; - XSControl::Session(pilot)->Model()->Print (ent, sout); - if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile() << std::endl; - } - if ( ! silent ) sout<TransferWriter()->FinderProcess(); - if (FP.IsNull()) { } - else { - yena = Standard_True; - Handle(Transfer_Finder) fnd = TransferBRep::ShapeMapper (FP,Shape); - Handle(Standard_Transient) ent; - if (!fnd.IsNull()) ent = FP->FindTransient (fnd); - if (!ent.IsNull()) { - sout<<"Shape "<Model()->Print (ent, sout); - if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile(); - sout<Find ( fnd ); - if ( ! bnd.IsNull() ) { - Handle(Transfer_TransientListBinder) TransientListBinder = - //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); //skl - Handle(Transfer_TransientListBinder)::DownCast( bnd ); //skl - if (! TransientListBinder.IsNull() ) { - Standard_Integer i = 1, nb = TransientListBinder->NbTransients(); - if (nb > 0) sout<<"Shape "<Model()->Print( TransientListBinder->Transient(i), sout); - if (i < nb) sout<<", "; - } - if (nb > 0) { - if ( silent ) sout << " in file " << XSControl::Session(pilot)->LoadedFile(); - sout<FindTransient (cfnd); - if ( cent.IsNull() ) continue; - if ( start ) - sout<<"Shape "<Model()->Print(cent,sout); - } - if ( ! start ) sout<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** connected entities (last transfer) **** - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - Handle(Transfer_TransientProcess) TP; - if (!TR.IsNull()) TP = TR->TransientProcess(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TP.IsNull()) { sout<<"no transfer map"<GetShape(a1); - if (Shape.IsNull()) { sout<<"Not a DRAW Shape:"<Length(); - sout<Model(); - sout<<"("; - for (i = 1; i <= nb; i ++) { - if (i > 1) sout<<","; - sout<Number(list->Value(i)); - } - sout<<")"<NbWords(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 4) { - sout<<"Give : filename or . for current model; varname or . to take fileroot\n GiveList, * for all transferrable roots"<Arg(1); - const Standard_CString arg2 = pilot->Arg(2); - const Standard_CString arg3 = pilot->Arg(3); - - // File Name and Variable (root) Name - - TCollection_AsciiString fnom,rnom; - Standard_Boolean modfic = XSControl_FuncShape::FileAndVar - (WS,arg1,arg2,"IMPORT",fnom,rnom); - if (modfic) sout<<" File to read : "<CommandPart (3); - - // Reading file if required - - if (modfic) { - TCollection_AsciiString comload ("xload "); - comload.AssignCat(arg1); - IFSelect_ReturnStatus status = pilot->Execute(comload); - if (status != IFSelect_RetDone) - { sout<<"Abandon import"<GiveList ("xst-transferrable-roots"); - sout<<"All Transferrable Roots : "; - } else { - sout<<"List given by "<GiveList (compart.ToCString()); - } - if (list.IsNull()) { sout<<"No list defined. Abandon"<Length(); - sout<<"Nb entities selected : "<InitTransferReader (0); - const Handle(XSControl_TransferReader) &TR = WS->TransferReader(); - if (TR.IsNull()) { sout<<" init not done or failed"<BeginTransfer(); - - // Transferring - Standard_Integer nbt = TR->TransferList(list); - sout<<"Nb Entities Selected : "<Arg(0)[5] == 'c'); - Standard_Integer nbs = 0; - TopoDS_Shape sh; - TopoDS_Compound C; - BRep_Builder B; - B.MakeCompound (C); - Handle(Interface_InterfaceModel) mdl = TR->Model(); - if (mdl.IsNull()) { sout<<" modele absent"<Value(il); - sh = TR->ShapeResult(ent); - if (sh.IsNull()) continue; - nbs ++; - if (iscomp) B.Add (C,sh); - else { - char nomsh[50]; - sprintf (nomsh,"%s_%d",rnom.ToCString(),nbs); - XSControl::Vars(pilot)->SetShape(nomsh,sh); - } - } - if (nbs == 0) sout<<"No Shape produced"<SetShape(rnom.ToCString(),sh); - } else if (iscomp) { - sout<<"One compound made of "<SetShape(rnom.ToCString(),C); - } else { // several individual shapes - sout<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** twrite **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter(); - if (argc < 2) { sout<<" donner nom de shape draw"<Arg(i); - TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(ai); - if (Shape.IsNull()) { sout<<"pas un nom de shape draw:"<TransferWriteShape (XSControl::Session(pilot)->Model(),Shape); - sout<<" Transfer Write Status = "<Session()->ComputeGraph(); - // Transient ? (Geom) : ignore - return IFSelect_RetDone; -} - -// ###################################################################### -// #### TIMERS #### -// ###################################################################### - - -// ###################################################################### -// #### #### -// #### Initialising Commands #### -// #### #### -// ###################################################################### - -static int THE_XSControl_FuncShape_initactor = 0; - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void XSControl_FuncShape::Init () -{ - if (THE_XSControl_FuncShape_initactor) - { - return; - } - - THE_XSControl_FuncShape_initactor = 1; - - IFSelect_Act::SetGroup("DE: General"); - - IFSelect_Act::AddFunc ("tpdraw","[mode:item or root] num|* [nomvar] Passes an ITEM to Shape Draw (Start or Result)",XSControl_tpdraw); - - IFSelect_Act::AddFunc ("tpcompound","name:cstring [givelist] : -> compound with Shapes Root or from givelist",XSControl_tpcompound); - - IFSelect_Act::AddFunc ("trdraw","results ->DRAW : all; or num [name] : from ent.num -> DRAW [name/tread_num]",XSControl_traccess); - IFSelect_Act::AddFunc ("trsave","results ->files : all; or num [name] : from ent.num -> DRAW [name/tread_num]",XSControl_traccess); - IFSelect_Act::AddFunc ("trcomp","results -> 1 compound -> DRAW + name optional",XSControl_traccess); - IFSelect_Act::AddFunc ("trscomp","results -> 1 compound -> file + name optional",XSControl_traccess); - - IFSelect_Act::AddFunc ("fromshape","shape [level=1]: imported/exported entity (when known)",XSControl_fromshape); - IFSelect_Act::AddFunc ("trconnexent","name of draw shape : entities -> connected shapes (when known)",XSControl_trconnexentities); - - IFSelect_Act::AddFunc ("trimport","filename or . varname givelist -> 1 shape per entity",XSControl_trimport); - IFSelect_Act::AddFunc ("trimpcomp","filename or . varname givelist -> one xcompound",XSControl_trimport); - - IFSelect_Act::AddFunc ("twrite","shape : transfer write for this shape, AFTER newmodel !",XSControl_twrite); - - //skl IFSelect_Act::AddFunc ("checkbrep","shapename or * [+ rootname for expurged and faulties [+ mode f-s]]",XSHAPE_checkbrep); - //skl IFSelect_Act::AddFunc ("dblist","option : clear nb index set n1 data n1 n2",XSHAPE_dblist); -} - -// ###################################################################### -// #### #### -// #### Additional Methods #### -// #### #### -// ###################################################################### - - -//======================================================================= -//function : MoreShapes -//purpose : -//======================================================================= - -Standard_Integer XSControl_FuncShape::MoreShapes - (const Handle(XSControl_WorkSession)& session, - Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name) -{ - // name = un nom -> Draw - // name = "*" -> tous les transferts RACINES du TP - // name = "**" -> tous les transferts du TP : VRAIMENT TOUS - // name = "." -> reperage graphique (not yet impl) - // name = nom(n1-n2) avec n1,n2 entiers : les variables de nom nomn1 a nomn2 - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (list.IsNull()) list = new TopTools_HSequenceOfShape(); - if (name[0] == '*' && (name[1] == '\0' || (name[1] == '*' && name[2] == '\0'))) { - const Handle(Transfer_TransientProcess) &TP = session->TransferReader()->TransientProcess(); - if (TP.IsNull()) { sout<<"last transfer : unknown"<Append (li); - return li->Length(); - } - Standard_Integer i, paro = 0, parf = 0, moins = 0, n1 = 0, n2 = 0; - for (i = 0; name[i] != '\0'; i ++) { - if (name[i] == '(') paro = i; - if (name[i] == '-') moins = i; - if (name[i] == ')') parf = i; - } - if (paro && moins && parf) { - n2 = atoi (&name[moins+1]); - n1 = atoi (&name[paro +1]); if (n1 < 0) n1 += n2; // sinon on a n1-n2 - } - // liste - if (n1 <= n2 && n1 > 0) { - char nom[50], nomsh[60]; Standard_Integer nbsh = 0; - for (i = 0; i < paro; i ++) - { - nom[i]=name[i]; - } - nom[paro] = '\0'; - sout<<"Shapes DRAW named : "<Vars()->GetShape(nomshh); - if (Shape.IsNull()) continue; - list->Append(Shape); - nbsh ++; - } - sout<<" -> taken "<Vars()->GetShape(a1); - if (Shape.IsNull()) { sout<<"not a shape draw:"<Append(Shape); - return 1; -} - - -//======================================================================= -//function : FileAndVar -//purpose : -//======================================================================= - -Standard_Boolean XSControl_FuncShape::FileAndVar - (const Handle(XSControl_WorkSession)& session, - const Standard_CString file, const Standard_CString var, - const Standard_CString def, - TCollection_AsciiString& resfile, TCollection_AsciiString& resvar) -{ - Standard_Boolean iafic = Standard_True; - resfile.Clear(); resvar.Clear(); - if (file) - if ( file[0] == '\0' || - (file[0] == '.' && file[1] == '\0')) iafic = Standard_False; - if (!iafic) resfile.AssignCat (session->LoadedFile()); - else resfile.AssignCat (file); - - if (var && var[0] != '\0' && (var[0] != '.' || var[1] != '\0') ) - resvar.AssignCat (var); - else if (resfile.Length() == 0) resvar.AssignCat (def); - else { - Standard_Integer nomdeb, nomfin; - nomdeb = resfile.SearchFromEnd ("/"); - if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT - if (nomdeb < 0) nomdeb = 0; - nomfin = resfile.SearchFromEnd ("."); - if (nomfin < nomdeb) nomfin = resfile.Length() + 1; - resvar = resfile.SubString(nomdeb+1,nomfin-1); - } - return iafic; -} diff --git a/src/XSControl/XSControl_FuncShape.hxx b/src/XSControl/XSControl_FuncShape.hxx deleted file mode 100644 index fb1fb50e33..0000000000 --- a/src/XSControl/XSControl_FuncShape.hxx +++ /dev/null @@ -1,99 +0,0 @@ -// Created on: 1995-03-16 -// Created by: Christian CAILLET -// Copyright (c) 1995-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. - -#ifndef _XSControl_FuncShape_HeaderFile -#define _XSControl_FuncShape_HeaderFile - -#include -#include -#include - -#include -#include -#include -class XSControl_WorkSession; -class TCollection_AsciiString; - - -//! Defines additional commands for XSControl to : -//! - control of initialisation (xinit, xnorm, newmodel) -//! - analyse of the result of a transfer (recorded in a -//! TransientProcess for Read, FinderProcess for Write) : -//! statistics, various lists (roots,complete,abnormal), what -//! about one specific entity, producing a model with the -//! abnormal result -//! -//! This appendix of XSControl is compiled separately to distinguish -//! basic features from user callable forms -class XSControl_FuncShape -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! Defines and loads all functions which work on shapes for XSControl (as ActFunc) - Standard_EXPORT static void Init(); - - //! Analyses a name as designating Shapes from a Vars or from - //! XSTEP transfer (last Transfer on Reading). can be : - //! "*" : all the root shapes produced by last Transfer (Read) - //! i.e. considers roots of the TransientProcess - //! a name : a name of a variable DRAW - //! - //! Returns the count of designated Shapes. Their list is put in - //! . If is null, it is firstly created. Then it is - //! completed (Append without Clear) by the Shapes found - //! Returns 0 if no Shape could be found - Standard_EXPORT static Standard_Integer MoreShapes (const Handle(XSControl_WorkSession)& session, Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name); - - //! Analyses given file name and variable name, with a default - //! name for variables. Returns resulting file name and variable - //! name plus status "file to read"(True) or "already read"(False) - //! In the latter case, empty resfile means no file available - //! - //! If is null or empty or equates ".", considers Session - //! and returned status is False - //! Else, returns resfile = file and status is True - //! If is neither null nor empty, resvar = var - //! Else, the root part of is considered, if defined - //! Else, is taken - Standard_EXPORT static Standard_Boolean FileAndVar (const Handle(XSControl_WorkSession)& session, const Standard_CString file, const Standard_CString var, const Standard_CString def, TCollection_AsciiString& resfile, TCollection_AsciiString& resvar); - - - - -protected: - - - - - -private: - - - - - -}; - - - - - - - -#endif // _XSControl_FuncShape_HeaderFile diff --git a/src/XSControl/XSControl_Functions.cxx b/src/XSControl/XSControl_Functions.cxx deleted file mode 100644 index a5771e3358..0000000000 --- a/src/XSControl/XSControl_Functions.cxx +++ /dev/null @@ -1,505 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ####################################################################### -// ## ## -// ## ## -// ## FUNCTIONS ## -// ## ## -// ## ## -// ####################################################################### -//======================================================================= -//function : xinit -//======================================================================= -static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** xinit **** - if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ? - IFSelect_RetDone : IFSelect_RetFail); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout<<"Selected Norm:"<SelectedNorm()<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** xnorm **** - Handle(XSControl_WorkSession) WS = XSControl::Session(pilot); - Handle(XSControl_Controller) control = WS->NormAdaptor(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc == 1) - sout<<"Current Norm. xnorm newnorm to change"<Name(Standard_False)<Name(Standard_True)<SetController(control); - sout<<"new norm : "<Name()<NewModel().IsNull()) return IFSelect_RetDone; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout<<"No new Model produced"<Word(0).Value(2) == 'w'); - const Handle(Transfer_FinderProcess) &FP = XSControl::Session(pilot)->TransferWriter()->FinderProcess(); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (modew) { if(!FP.IsNull()) FP->Clear(); else sout<<"No Transfer Write"<Clear(); else sout<<"No Transfer Read"<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - //const Standard_CString arg2 = pilot->Arg(2); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TP.IsNull()) { sout<<"No Transfer Read"< 1) { - char a2 = arg1[1]; if (a2 == '\0') a2 = '!'; - switch (arg1[0]) { - case 'g' : mod1 = 0; break; - case 'c' : mod1 = 4; mod2 = 4; break; - case 'C' : mod1 = 4; mod2 = 2; break; - case 'f' : mod1 = 5; mod2 = 4; break; - case 'F' : mod1 = 5; mod2 = 2; break; - case '*' : mod1 = 2; break; - case '?' : mod1 = 3; break; - default : mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break; - } - if (mod1 < 1 || mod1 > 3) a2 = '!'; - switch (a2) { - case 'n' : mod2 = 0; break; - case 's' : mod2 = 1; break; - case 'b' : mod2 = 2; break; - case 't' : mod2 = 3; break; - case 'r' : mod2 = 4; break; - case 'l' : mod2 = 5; break; - case 'L' : mod2 = 6; break; - case '!' : break; - case '?' : mod1 = -1; break; - default : mod1 = -2; break; - } - } - // A present help eventuel - if (mod1 < -1) sout<<"Unknown Mode"<Model() != pilot->Session()->Model()) sout<<"Model differs from the session"; - Handle(TColStd_HSequenceOfTransient) list = - IFSelect_Functions::GiveList(pilot->Session(),pilot->CommandPart(2)); - XSControl_TransferReader::PrintStatsOnList (TP,list,mod1,mod2); -// TP->PrintStats (1,sout); - } - else sout<<"TransferRead : not defined"<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); - // **** tpent **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TP.IsNull()) { sout<<"No Transfer Read"<Model(); - if (model.IsNull()) return IFSelect_RetFail; - - if (argc < 2) { sout<<"Give ENTITY NUMBER (IN MODEL TransferProcess)"< model->NbEntities()) { sout<<"Number not in [1 - "<NbEntities()<<"]"<Value(num); - Standard_Integer index = TP->MapIndex (ent); - if (index == 0) sout<<"Entity "<PrintTransferStatus (index,Standard_False,sout); - return IFSelect_RetVoid; -} - - -//======================================================================= -//function : tpitem -//======================================================================= -static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); -// **** tpitem/tproot/twitem/twroot **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (argc < 2) { sout<<"Give ITEM NUMBER (in TransferProcess)"<Word(0).Value(3) == 'r') num = -num; - Standard_Boolean modew = Standard_False; - if (pilot->Word(0).Value(2) == 'w') modew = Standard_True; - Handle(Transfer_Binder) binder; - Handle(Transfer_Finder) finder; - Handle(Standard_Transient) ent; - if (!XSControl::Session(pilot)->PrintTransferStatus(num,modew,sout)) - { - sout<<" - Num="<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); -// **** trecord : TransferReader **** - Standard_Boolean tous = (argc == 1); - Standard_Integer num = -1; - const Handle(Interface_InterfaceModel) &mdl = XSControl::Session(pilot)->Model(); - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - Handle(Standard_Transient) ent; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (mdl.IsNull() || TR.IsNull() || TP.IsNull()) - { sout<<" init not done"<NbRoots(); - sout<<" Recording "<Root(i); - if (TR->RecordResult (ent)) sout<<" Root n0."< mdl->NbEntities()) sout<<"incorrect number:"<RecordResult(mdl->Value(num))) sout<<" Entity n0."<NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); -// **** trstat : TransferReader **** - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - if (TR.IsNull()) { sout<<" init not done"<Model(); - if (mdl.IsNull()) { sout<<" No model"<FileName()<PrintStats (sout, 10, 0); - } else { - // stats unitaires - Standard_Integer num = atoi(arg1); - if (num < 1 || num > mdl->NbEntities()) { sout<<" incorrect number:"<Value(num); - if (!TR->IsRecorded(ent)) { sout<<" Entity "<FinalResult(ent); - Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent); - Standard_Integer i, nb = list->Length(); - if (nb > 0) sout<<" Entities implied by Check/Result :"<Print(list->Value(i), sout); } - sout<CheckList(Standard_False); - pilot->Session()->PrintCheckList (sout, chl, Standard_False, IFSelect_EntitiesByItem); - } - return IFSelect_RetVoid; -} - - -//======================================================================= -//function : trbegin -//======================================================================= -static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot) -{ - // **** trbegin : TransferReader **** - Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader(); - Standard_Boolean init = TR.IsNull(); - if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; } - if (init) { - XSControl::Session(pilot)->InitTransferReader (0); - TR = XSControl::Session(pilot)->TransferReader(); - if (TR.IsNull()) { - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - sout<<" init not done or failed"<BeginTransfer(); - return IFSelect_RetDone; -} - - -//======================================================================= -//function : tread -//======================================================================= -static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - //const Standard_CString arg1 = pilot->Arg(1); - // **** tread : TransferReader **** - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - if (TR.IsNull()) { sout<<" init not done"<Model(); - if (mdl.IsNull()) { sout<<" No model"<Session()->NamedItem("xst-model-roots")); - Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots"); - if (sel.IsNull()) { sout<<"Select Roots absent"<Session()->GiveList(sel); - sout<<" Transferring all roots i.e. : "<TransferList(list)<Session(),pilot->CommandPart(1)); - sout<<" Transfer of "<Length()<<" entities"<TransferList(list); - sout<<" Gives "< TProcess **** - const Handle(XSControl_TransferReader) &TR = XSControl::Session(pilot)->TransferReader(); - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (TR.IsNull()) sout<<" No TransferReader"<TransientProcess().IsNull()) sout<<" Transfer Reader without Process"< TReader **** - XSControl::Session(pilot)->InitTransferReader (3); - return IFSelect_RetDone; -} - - -//======================================================================= -//function : twmode -//======================================================================= -static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot) -{ - Standard_Integer argc = pilot->NbWords(); - const Standard_CString arg1 = pilot->Arg(1); - // **** twmode **** - Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter(); - Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor(); - Standard_Integer modemin,modemax; - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (control->ModeWriteBounds (modemin,modemax)) { - sout<<"Write Mode : allowed values "<ModeWriteHelp (modd)< "<SetTransferMode(mod); - if (!control->IsModeWrite (mod)) sout<<"Warning : this new value is not supported"<NbWords(); - //const Standard_CString arg1 = pilot->Arg(1); - //const Standard_CString arg2 = pilot->Arg(2); - const Handle(Transfer_FinderProcess) &FP = XSControl::Session(pilot)->TransferWriter()->FinderProcess(); - // **** twstat **** - // Pour Write - Message_Messenger::StreamBuffer sout = Message::SendInfo(); - if (!FP.IsNull()) { - sout<<"TransferWrite:"; - // XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2); - FP->PrintStats (1,sout); - } - else sout<<"TransferWrite: not defined"<RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader())); -} - - - -static int THE_XSControl_Functions_initactor = 0; - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -void XSControl_Functions::Init () -{ - if (THE_XSControl_Functions_initactor) - { - return; - } - - THE_XSControl_Functions_initactor = 1; - IFSelect_Act::SetGroup("DE: General"); - - IFSelect_Act::AddFunc ("xinit","[norm:string to change norme] reinitialises according to the norm",XSControl_xinit); - IFSelect_Act::AddFunc ("xnorm","displays current norm +norm : changes it",XSControl_xnorm); - - IFSelect_Act::AddFunc ("newmodel","produces a new empty model, for the session",XSControl_newmodel); - - IFSelect_Act::AddFunc ("tpclear","Clears TransferProcess (READ)",XSControl_tpclear); - IFSelect_Act::AddFunc ("twclear","Clears TransferProcess (WRITE)",XSControl_tpclear); - - IFSelect_Act::AddFunc ("tpstat","Statistics on TransferProcess (READ)",XSControl_tpstat); - - IFSelect_Act::AddFunc ("tpent","[num:integer] Statistics on an entity of the model (READ)",XSControl_tpent); - - IFSelect_Act::AddFunc ("tpitem","[num:integer] Statistics on ITEM of transfer (READ)" ,XSControl_tpitem); - IFSelect_Act::AddFunc ("tproot","[num:integer] Statistics on a ROOT of transfert (READ)" ,XSControl_tpitem); - IFSelect_Act::AddFunc ("twitem","[num:integer] Statistics on an ITEM of transfer (WRITE)" ,XSControl_tpitem); - IFSelect_Act::AddFunc ("twroot","[num:integer] Statistics on a ROOT of transfer (WRITE)",XSControl_tpitem); - - IFSelect_Act::AddFunc ("trecord","record : all root results; or num : for entity n0.num",XSControl_trecord); - IFSelect_Act::AddFunc ("trstat","general statistics; or num : stats on entity n0 num",XSControl_trstat); - IFSelect_Act::AddFunc ("trbegin","begin-transfer-reader [init]",XSControl_trbegin); - IFSelect_Act::AddFunc ("tread","transfers all roots, or num|sel|sel num : entity list, by transfer-reader",XSControl_tread); - - IFSelect_Act::AddFunc ("trtp","feeds commands tp... with results from tr...",XSControl_trtp); - IFSelect_Act::AddFunc ("tptr","feeds tr... from tp... (may be incomplete)",XSControl_tptr); - - IFSelect_Act::AddFunc ("twmode","displays mode transfer write, + num changes it",XSControl_twmode); - IFSelect_Act::AddFunc ("twstat","Statistics on TransferProcess (WRITE)",XSControl_twstat); - - IFSelect_Act::AddFSet ("selecttransfer","selection (recognize from transfer actor)",XSControl_settransfert); -} diff --git a/src/XSDRAW/FILES b/src/XSDRAW/FILES index 8d3ba0efb1..5747f7fea3 100755 --- a/src/XSDRAW/FILES +++ b/src/XSDRAW/FILES @@ -2,5 +2,7 @@ XSDRAW.cxx XSDRAW.hxx XSDRAW_Functions.cxx XSDRAW_Functions.hxx -XSDRAW_Vars.cxx -XSDRAW_Vars.hxx +XSDRAW_FunctionsSession.cxx +XSDRAW_FunctionsSession.hxx +XSDRAW_FunctionsShape.cxx +XSDRAW_FunctionsShape.hxx \ No newline at end of file diff --git a/src/XSDRAW/XSDRAW.hxx b/src/XSDRAW/XSDRAW.hxx index 70da6cbb7b..a5e866208f 100644 --- a/src/XSDRAW/XSDRAW.hxx +++ b/src/XSDRAW/XSDRAW.hxx @@ -41,7 +41,7 @@ class TCollection_AsciiString; //! Works with some "static" data : a SessionPilot (used to run) //! with its WorkSession and Model and TransferReader, a //! FinderProcess -class XSDRAW +class XSDRAW { public: diff --git a/src/XSDRAW/XSDRAW_Functions.cxx b/src/XSDRAW/XSDRAW_Functions.cxx index 0f7e96950a..aa2ab3e5bb 100644 --- a/src/XSDRAW/XSDRAW_Functions.cxx +++ b/src/XSDRAW/XSDRAW_Functions.cxx @@ -12,10 +12,492 @@ // commercial license or contractual agreement. -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include -void XSDRAW_Functions::Init () +//======================================================================= +//function : xinit +//======================================================================= +static IFSelect_ReturnStatus XSControl_xinit(const Handle(IFSelect_SessionPilot)& pilot) { - XSControl_FuncShape::Init (); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** xinit **** + if (argc > 1) return (XSControl::Session(pilot)->SelectNorm(arg1) ? + IFSelect_RetDone : IFSelect_RetFail); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "Selected Norm:" << XSControl::Session(pilot)->SelectedNorm() << std::endl; + return IFSelect_RetVoid; +} + +//======================================================================= +//function : xnorm +//======================================================================= +static IFSelect_ReturnStatus XSControl_xnorm(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** xnorm **** + Handle(XSControl_WorkSession) WS = XSControl::Session(pilot); + Handle(XSControl_Controller) control = WS->NormAdaptor(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc == 1) + sout << "Current Norm. xnorm newnorm to change" << std::endl; + else sout << "Current Norm :" << std::endl; + if (control.IsNull()) sout << "no norm currently defined" << std::endl; + else + sout << " Long Name (complete) : " << control->Name(Standard_False) << std::endl + << " Short name (resource) : " << control->Name(Standard_True) << std::endl; + if (argc == 1) return IFSelect_RetVoid; + + control = XSControl_Controller::Recorded(arg1); + if (control.IsNull()) + { + sout << " No norm named : " << arg1 << std::endl; + return IFSelect_RetError; + } + + WS->SetController(control); + sout << "new norm : " << control->Name() << std::endl; + return IFSelect_RetDone; +} + +//======================================================================= +//function : newmodel +//======================================================================= +static IFSelect_ReturnStatus XSControl_newmodel(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** newmodel **** + if (!XSControl::Session(pilot)->NewModel().IsNull()) return IFSelect_RetDone; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "No new Model produced" << std::endl; + return IFSelect_RetFail; +} + +//======================================================================= +//function : tpclear +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpclear(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** tpclear/twclear **** + const Standard_Boolean modew = (pilot->Word(0).Value(2) == 'w'); + const Handle(Transfer_FinderProcess)& FP = XSControl::Session(pilot)->TransferWriter()->FinderProcess(); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (modew) { if (!FP.IsNull()) FP->Clear(); else sout << "No Transfer Write" << std::endl; } + else { if (!TP.IsNull()) TP->Clear(); else sout << "No Transfer Read" << std::endl; } + return IFSelect_RetDone; +} + +//======================================================================= +//function : tpstat +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpstat(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + //const Standard_CString arg2 = pilot->Arg(2); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TP.IsNull()) { sout << "No Transfer Read" << std::endl; return IFSelect_RetError; } + // **** tpstat **** + + Standard_Integer mod1 = -1; + Standard_Integer mod2 = 0; + // g : general c : check (compte) C (liste) f : fails(compte) F (liste) + // resultats racines : n : n0s entites s : status b : binders + // t : compte par type r : compte par resultat l : liste(type-resultat) + // *n *s *b *t *r *l : idem sur tout + // ?n etc.. : idem sur resultats anormaux + // ? tout court pour help + + if (argc > 1) + { + char a2 = arg1[1]; if (a2 == '\0') a2 = '!'; + switch (arg1[0]) + { + case 'g': mod1 = 0; break; + case 'c': mod1 = 4; mod2 = 4; break; + case 'C': mod1 = 4; mod2 = 2; break; + case 'f': mod1 = 5; mod2 = 4; break; + case 'F': mod1 = 5; mod2 = 2; break; + case '*': mod1 = 2; break; + case '?': mod1 = 3; break; + default: mod1 = 1; if (argc > 2) mod1 = 2; a2 = arg1[0]; break; + } + if (mod1 < 1 || mod1 > 3) a2 = '!'; + switch (a2) + { + case 'n': mod2 = 0; break; + case 's': mod2 = 1; break; + case 'b': mod2 = 2; break; + case 't': mod2 = 3; break; + case 'r': mod2 = 4; break; + case 'l': mod2 = 5; break; + case 'L': mod2 = 6; break; + case '!': break; + case '?': mod1 = -1; break; + default: mod1 = -2; break; + } + } + // A present help eventuel + if (mod1 < -1) sout << "Unknown Mode" << std::endl; + if (mod1 < 0) + { + sout << "Modes available :\n" + << "g : general c : checks (count) C (list)\n" + << " f : fails (count) F (list)\n" + << " n : numbers of transferred entities (on TRANSFER ROOTS)\n" + << " s : their status (type entity-result , presence checks)\n" + << " b : detail of binders\n" + << " t : count per entity type r : per type/status result\n" + << " l : count per couple type entity/result\n" + << " L : list per couple type entity/result\n" + << " *n *s *b *t *r *l *L : idem on ALL recorded items\n" + << " ?n ?s ?b ?t ... : idem on abnormal items\n" + << " n select : n applied on a selection idem for s b t r l" << std::endl; + if (mod1 < -1) return IFSelect_RetError; + return IFSelect_RetVoid; + } + + if (!TP.IsNull()) + { + sout << "TransferRead :"; + if (TP->Model() != pilot->Session()->Model()) sout << "Model differs from the session"; + Handle(TColStd_HSequenceOfTransient) list = + IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(2)); + XSControl_TransferReader::PrintStatsOnList(TP, list, mod1, mod2); + // TP->PrintStats (1,sout); + } + else sout << "TransferRead : not defined" << std::endl; + return IFSelect_RetVoid; +} + +//======================================================================= +//function : tpent +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpent(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + // **** tpent **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TP.IsNull()) { sout << "No Transfer Read" << std::endl; return IFSelect_RetError; } + Handle(Interface_InterfaceModel) model = TP->Model(); + if (model.IsNull()) return IFSelect_RetFail; + + if (argc < 2) { sout << "Give ENTITY NUMBER (IN MODEL TransferProcess)" << std::endl; return IFSelect_RetError; } + Standard_Integer num = atoi(arg1); + if (num <= 0 || num > model->NbEntities()) { sout << "Number not in [1 - " << model->NbEntities() << "]" << std::endl; return IFSelect_RetError; } + Handle(Standard_Transient) ent = model->Value(num); + Standard_Integer index = TP->MapIndex(ent); + if (index == 0) sout << "Entity " << num << " not recorded in transfer" << std::endl; + else XSControl::Session(pilot)->PrintTransferStatus(index, Standard_False, sout); + return IFSelect_RetVoid; +} + +//======================================================================= +//function : tpitem +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpitem(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** tpitem/tproot/twitem/twroot **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give ITEM NUMBER (in TransferProcess)" << std::endl; return IFSelect_RetError; } + Standard_Integer num = atoi(arg1); + if (pilot->Word(0).Value(3) == 'r') num = -num; + Standard_Boolean modew = Standard_False; + if (pilot->Word(0).Value(2) == 'w') modew = Standard_True; + Handle(Transfer_Binder) binder; + Handle(Transfer_Finder) finder; + Handle(Standard_Transient) ent; + if (!XSControl::Session(pilot)->PrintTransferStatus(num, modew, sout)) + { + sout << " - Num=" << num << " incorrect" << std::endl; + } + return IFSelect_RetVoid; +} + +//======================================================================= +//function : trecord +//======================================================================= +static IFSelect_ReturnStatus XSControl_trecord(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + // **** trecord : TransferReader **** + Standard_Boolean tous = (argc == 1); + Standard_Integer num = -1; + const Handle(Interface_InterfaceModel)& mdl = XSControl::Session(pilot)->Model(); + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + Handle(Standard_Transient) ent; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (mdl.IsNull() || TR.IsNull() || TP.IsNull()) + { + sout << " init not done" << std::endl; return IFSelect_RetError; + } + if (!tous) num = atoi(arg1); + // Enregistrer les racines + if (tous) + { + Standard_Integer nb = TP->NbRoots(); + sout << " Recording " << nb << " Roots" << std::endl; + for (Standard_Integer i = 1; i <= nb; i++) + { + ent = TP->Root(i); + if (TR->RecordResult(ent)) sout << " Root n0." << i << std::endl; + else sout << " Root n0." << i << " not recorded" << std::endl; + } + } + else + { + if (num < 1 || num > mdl->NbEntities()) sout << "incorrect number:" << num << std::endl; + else if (TR->RecordResult(mdl->Value(num))) sout << " Entity n0." << num << std::endl; + else sout << " Entity n0." << num << " not recorded" << std::endl; + } + return IFSelect_RetDone; +} + +//======================================================================= +//function : trstat +//======================================================================= +static IFSelect_ReturnStatus XSControl_trstat(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + // **** trstat : TransferReader **** + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + if (TR.IsNull()) { sout << " init not done" << std::endl; return IFSelect_RetError; } + Handle(Interface_InterfaceModel) mdl = TR->Model(); + if (mdl.IsNull()) { sout << " No model" << std::endl; return IFSelect_RetError; } + sout << " Statistics : FileName : " << TR->FileName() << std::endl; + if (argc == 1) + { + // stats generales + TR->PrintStats(sout, 10, 0); + } + else + { + // stats unitaires + Standard_Integer num = atoi(arg1); + if (num < 1 || num > mdl->NbEntities()) { sout << " incorrect number:" << arg1 << std::endl; return IFSelect_RetError; } + Handle(Standard_Transient) ent = mdl->Value(num); + if (!TR->IsRecorded(ent)) { sout << " Entity " << num << " not recorded" << std::endl; return IFSelect_RetError; } + Handle(Transfer_ResultFromModel) RM = TR->FinalResult(ent); + Handle(TColStd_HSequenceOfTransient) list = TR->CheckedList(ent); + Standard_Integer i, nb = list->Length(); + if (nb > 0) sout << " Entities implied by Check/Result :" << nb << " i.e.:"; + for (i = 1; i <= nb; i++) { sout << " "; mdl->Print(list->Value(i), sout); } + sout << std::endl; + if (RM.IsNull()) { sout << " no other info" << std::endl; return IFSelect_RetVoid; } + Interface_CheckIterator chl = RM->CheckList(Standard_False); + pilot->Session()->PrintCheckList(sout, chl, Standard_False, IFSelect_EntitiesByItem); + } + return IFSelect_RetVoid; +} + +//======================================================================= +//function : trbegin +//======================================================================= +static IFSelect_ReturnStatus XSControl_trbegin(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** trbegin : TransferReader **** + Handle(XSControl_TransferReader) TR = XSControl::Session(pilot)->TransferReader(); + Standard_Boolean init = TR.IsNull(); + if (pilot->NbWords() > 1) { if (pilot->Arg(1)[0] == 'i') init = Standard_True; } + if (init) + { + XSControl::Session(pilot)->InitTransferReader(0); + TR = XSControl::Session(pilot)->TransferReader(); + if (TR.IsNull()) + { + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << " init not done or failed" << std::endl; + return IFSelect_RetError; + } + } + TR->BeginTransfer(); + return IFSelect_RetDone; +} + +//======================================================================= +//function : tread +//======================================================================= +static IFSelect_ReturnStatus XSControl_tread(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + //const Standard_CString arg1 = pilot->Arg(1); + // **** tread : TransferReader **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + if (TR.IsNull()) { sout << " init not done" << std::endl; return IFSelect_RetError; } + const Handle(Interface_InterfaceModel)& mdl = TR->Model(); + if (mdl.IsNull()) { sout << " No model" << std::endl; return IFSelect_RetError; } + if (argc < 2) + { + // DeclareAndCast(IFSelect_Selection,sel,pilot->Session()->NamedItem("xst-model-roots")); + Handle(Standard_Transient) sel = pilot->Session()->NamedItem("xst-model-roots"); + if (sel.IsNull()) { sout << "Select Roots absent" << std::endl; return IFSelect_RetError; } + Handle(TColStd_HSequenceOfTransient) list = pilot->Session()->GiveList(sel); + sout << " Transferring all roots i.e. : " << TR->TransferList(list) << std::endl; + } + else + { + Handle(TColStd_HSequenceOfTransient) list = + IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(1)); + sout << " Transfer of " << list->Length() << " entities" << std::endl; + Standard_Integer nb = TR->TransferList(list); + sout << " Gives " << nb << " results" << std::endl; + } + return IFSelect_RetDone; +} + +//======================================================================= +//function : trtp +//======================================================================= +static IFSelect_ReturnStatus XSControl_trtp(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** TReader -> TProcess **** + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TR.IsNull()) sout << " No TransferReader" << std::endl; + else if (TR->TransientProcess().IsNull()) sout << " Transfer Reader without Process" << std::endl; + return IFSelect_RetVoid; +} + +//======================================================================= +//function : tptr +//======================================================================= +static IFSelect_ReturnStatus XSControl_tptr(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** TProcess -> TReader **** + XSControl::Session(pilot)->InitTransferReader(3); + return IFSelect_RetDone; +} + +//======================================================================= +//function : twmode +//======================================================================= +static IFSelect_ReturnStatus XSControl_twmode(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** twmode **** + Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter(); + Handle(XSControl_Controller) control = XSControl::Session(pilot)->NormAdaptor(); + Standard_Integer modemin, modemax; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (control->ModeWriteBounds(modemin, modemax)) + { + sout << "Write Mode : allowed values " << modemin << " to " << modemax << std::endl; + for (Standard_Integer modd = modemin; modd <= modemax; modd++) + { + sout << modd << " : " << control->ModeWriteHelp(modd) << std::endl; + } + } + sout << "Write Mode : actual = " << TW->TransferMode() << std::endl; + if (argc <= 1) return IFSelect_RetVoid; + Standard_Integer mod = atoi(arg1); + sout << "New value -> " << arg1 << std::endl; + TW->SetTransferMode(mod); + if (!control->IsModeWrite(mod)) sout << "Warning : this new value is not supported" << std::endl; + return IFSelect_RetDone; +} + +//======================================================================= +//function : twstat +//======================================================================= +static IFSelect_ReturnStatus XSControl_twstat(const Handle(IFSelect_SessionPilot)& pilot) +{ + //Standard_Integer argc = pilot->NbWords(); + //const Standard_CString arg1 = pilot->Arg(1); + //const Standard_CString arg2 = pilot->Arg(2); + const Handle(Transfer_FinderProcess)& FP = XSControl::Session(pilot)->TransferWriter()->FinderProcess(); + // **** twstat **** + // Pour Write + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (!FP.IsNull()) + { + sout << "TransferWrite:"; + // XSControl_TransferWriter::PrintStatsProcess (FP,mod1,mod2); + FP->PrintStats(1, sout); + } + else sout << "TransferWrite: not defined" << std::endl; + return IFSelect_RetVoid; +} + +//======================================================================= +//function : settransfert +//======================================================================= +static IFSelect_ReturnStatus XSControl_settransfert(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** SelectForTransfer **** + return pilot->RecordItem(new XSControl_SelectForTransfer(XSControl::Session(pilot)->TransferReader())); +} + + +//======================================================================= +//function : Init +//purpose : +//======================================================================= +void XSDRAW_Functions::Init() +{ + static int THE_XSDRAW_Functions_initactor = 0; + if (THE_XSDRAW_Functions_initactor) + { + return; + } + + THE_XSDRAW_Functions_initactor = 1; + IFSelect_Act::SetGroup("DE: General"); + + IFSelect_Act::AddFunc("xinit", "[norm:string to change norme] reinitialises according to the norm", XSControl_xinit); + IFSelect_Act::AddFunc("xnorm", "displays current norm +norm : changes it", XSControl_xnorm); + + IFSelect_Act::AddFunc("newmodel", "produces a new empty model, for the session", XSControl_newmodel); + + IFSelect_Act::AddFunc("tpclear", "Clears TransferProcess (READ)", XSControl_tpclear); + IFSelect_Act::AddFunc("twclear", "Clears TransferProcess (WRITE)", XSControl_tpclear); + + IFSelect_Act::AddFunc("tpstat", "Statistics on TransferProcess (READ)", XSControl_tpstat); + + IFSelect_Act::AddFunc("tpent", "[num:integer] Statistics on an entity of the model (READ)", XSControl_tpent); + + IFSelect_Act::AddFunc("tpitem", "[num:integer] Statistics on ITEM of transfer (READ)", XSControl_tpitem); + IFSelect_Act::AddFunc("tproot", "[num:integer] Statistics on a ROOT of transfert (READ)", XSControl_tpitem); + IFSelect_Act::AddFunc("twitem", "[num:integer] Statistics on an ITEM of transfer (WRITE)", XSControl_tpitem); + IFSelect_Act::AddFunc("twroot", "[num:integer] Statistics on a ROOT of transfer (WRITE)", XSControl_tpitem); + + IFSelect_Act::AddFunc("trecord", "record : all root results; or num : for entity n0.num", XSControl_trecord); + IFSelect_Act::AddFunc("trstat", "general statistics; or num : stats on entity n0 num", XSControl_trstat); + IFSelect_Act::AddFunc("trbegin", "begin-transfer-reader [init]", XSControl_trbegin); + IFSelect_Act::AddFunc("tread", "transfers all roots, or num|sel|sel num : entity list, by transfer-reader", XSControl_tread); + + IFSelect_Act::AddFunc("trtp", "feeds commands tp... with results from tr...", XSControl_trtp); + IFSelect_Act::AddFunc("tptr", "feeds tr... from tp... (may be incomplete)", XSControl_tptr); + + IFSelect_Act::AddFunc("twmode", "displays mode transfer write, + num changes it", XSControl_twmode); + IFSelect_Act::AddFunc("twstat", "Statistics on TransferProcess (WRITE)", XSControl_twstat); + + IFSelect_Act::AddFSet("selecttransfer", "selection (recognize from transfer actor)", XSControl_settransfert); } diff --git a/src/XSDRAW/XSDRAW_Functions.hxx b/src/XSDRAW/XSDRAW_Functions.hxx index b2b15c0cab..2be5f026fd 100644 --- a/src/XSDRAW/XSDRAW_Functions.hxx +++ b/src/XSDRAW/XSDRAW_Functions.hxx @@ -1,7 +1,4 @@ -// Created on: 1995-03-16 -// Created by: Christian CAILLET -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -17,21 +14,21 @@ #ifndef _XSDRAW_Functions_HeaderFile #define _XSDRAW_Functions_HeaderFile -//! Defines additional commands for XSDRAW to : -//! - control of initialisation (xinit, xnorm, newmodel) -//! - analyse of the result of a transfer (recorded in a -//! TransientProcess for Read, FinderProcess for Write) : -//! statistics, various lists (roots,complete,abnormal), what -//! about one specific entity, producing a model with the -//! abnormal result +#include +#include +#include + +//! Functions from XSControl gives access to actions which can be +//! commanded with the resources provided by XSControl: especially +//! Controller and Transfer //! -//! This appendix of XSDRAW is compiled separately to distinguish -//! basic features from user callable forms -class XSDRAW_Functions +//! It works by adding functions by method Init +class XSDRAW_Functions { - public: - - //! Defines and loads all basic functions for XSDRAW (as ActFunc) + DEFINE_STANDARD_ALLOC +public: + + //! Defines and loads all functions for XSControl (as ActFunc) Standard_EXPORT static void Init(); }; diff --git a/src/XSDRAW/XSDRAW_FunctionsSession.cxx b/src/XSDRAW/XSDRAW_FunctionsSession.cxx new file mode 100644 index 0000000000..f8f8be28d8 --- /dev/null +++ b/src/XSDRAW/XSDRAW_FunctionsSession.cxx @@ -0,0 +1,2773 @@ +// 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. + +//#58 rln 28.12.98 Versioning + +#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 +// Decomposition of a file name in its parts : prefix, root, suffix +static void SplitFileName +(const Standard_CString filename, + TCollection_AsciiString& prefix, + TCollection_AsciiString& fileroot, + TCollection_AsciiString& suffix) +{ + Standard_Integer nomdeb, nomfin, nomlon; + TCollection_AsciiString resfile(filename); + nomlon = resfile.Length(); + nomdeb = resfile.SearchFromEnd("/"); + if (nomdeb <= 0) nomdeb = resfile.SearchFromEnd("\\"); // pour NT + if (nomdeb < 0) nomdeb = 0; + nomfin = resfile.SearchFromEnd("."); + if (nomfin < nomdeb) nomfin = nomlon + 1; + + if (nomdeb > 0) prefix = resfile.SubString(1, nomdeb); + fileroot = resfile.SubString(nomdeb + 1, nomfin - 1); + if (nomfin <= nomlon) suffix = resfile.SubString(nomfin, nomlon); +} + +Handle(TColStd_HSequenceOfTransient) GiveList +(const Handle(IFSelect_WorkSession)& WS, + const Standard_CString first, const Standard_CString second) +{ + return WS->GiveList(first, second); +} + +// Function which returns an EVALUATED DISPATCH +// (could be added in WorkSession.cdl ...) +// Two modes : returns dispatch as it is, or return with edition +// Dispatch Name can be : an immediate name of already recorded Dispatch +// Or a name of dispatch + a parameter : dispatch-name(param-value) +// According to type of Dispatch : integer , signature name + +Handle(IFSelect_Dispatch) GiveDispatch +(const Handle(IFSelect_WorkSession)& WS, + const Standard_CString name, const Standard_Boolean mode) +{ + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(name)); + if (!disp.IsNull()) return disp; // OK as it is given + +// Else, let s try special cases + TCollection_AsciiString nam(name); + Standard_Integer paro = nam.Location(1, '(', 1, nam.Length()); + Standard_Integer parf = nam.Location(1, ')', 1, nam.Length()); + nam.SetValue(paro, '\0'); nam.SetValue(parf, '\0'); + if (paro <= 0 && parf <= 0) return disp; + disp = GetCasted(IFSelect_Dispatch, WS->NamedItem(nam.ToCString())); + if (disp.IsNull()) return disp; // KO anyway + +// According to the type of dispatch : + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + DeclareAndCast(IFSelect_DispPerCount, dc, disp); + if (!dc.IsNull()) + { + Standard_Integer nb = atoi(&(nam.ToCString())[paro]); + if (nb <= 0) + { + sout << " DispPerCount, count is not positive" << std::endl; + disp.Nullify(); + return disp; + } + if (mode) + { + Handle(IFSelect_IntParam) val = new IFSelect_IntParam; + val->SetValue(nb); + dc->SetCount(val); + } + return dc; + } + DeclareAndCast(IFSelect_DispPerFiles, dp, disp); + if (!dp.IsNull()) + { + Standard_Integer nb = atoi(&(nam.ToCString())[paro]); + if (nb <= 0) + { + sout << " DispPerFiles, count is not positive" << std::endl; + disp.Nullify(); + return disp; + } + if (mode) + { + Handle(IFSelect_IntParam) val = new IFSelect_IntParam; + val->SetValue(nb); + dp->SetCount(val); + } + return dp; + } + DeclareAndCast(IFSelect_DispPerSignature, ds, disp); + if (!ds.IsNull()) + { + DeclareAndCast(IFSelect_Signature, sg, WS->NamedItem(&(nam.ToCString())[paro])); + if (sg.IsNull()) + { + sout << "DispPerSignature " << nam << " , Signature not valid : " << &(nam.ToCString())[paro] << std::endl; + disp.Nullify(); + return disp; + } + if (mode) ds->SetSignCounter(new IFSelect_SignCounter(sg)); + return ds; + } + sout << "Dispatch : " << name << " , Parameter : " << &(nam.ToCString())[paro] << std::endl; + return disp; +} + +// Functions definit un certain nombre de commandes +// enregistrees dans le Dictionnaire de Activator (par des Act unitaires) +// Les actions elles-memes sont regroupees en fin de fichier + +// Les definitions + +static IFSelect_ReturnStatus funstatus +(const Handle(IFSelect_SessionPilot)&) +{ + // **** Version & cie **** + //#58 rln + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "Processor Version : " << XSTEP_PROCESSOR_VERSION << std::endl; + sout << "OL Version : " << XSTEP_SYSTEM_VERSION << std::endl; + sout << "Configuration : " << XSTEP_Config << std::endl; + sout << "UL Names : " << XSTEP_ULNames << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun1 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** ToggleHandler **** + Standard_Boolean hand = !WS->ErrorHandle(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (hand) sout << " -- Mode Catch Error now Active" << std::endl; + else sout << " -- Mode Catch Error now Inactive" << std::endl; + WS->SetErrorHandle(hand); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun3 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** XRead / Load **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Read/Load : give file name !" << std::endl; return IFSelect_RetError; } + if (WS->Protocol().IsNull()) { sout << "Protocol not defined" << std::endl; return IFSelect_RetError; } + if (WS->WorkLibrary().IsNull()) { sout << "WorkLibrary not defined" << std::endl; return IFSelect_RetError; } + + IFSelect_ReturnStatus status = WS->ReadFile(arg1); + // status : 0 OK, 1 erreur lecture, 2 Fail(try/catch), + // -1 fichier non trouve, -2 lecture faite mais resultat vide + switch (status) + { + case IFSelect_RetVoid: sout << "file:" << arg1 << " gives empty result" << std::endl; break; + case IFSelect_RetError: sout << "file:" << arg1 << " could not be opened" << std::endl; break; + case IFSelect_RetDone: sout << "file:" << arg1 << " read" << std::endl; break; + case IFSelect_RetFail: sout << "file:" << arg1 << " : error while reading" << std::endl; break; + case IFSelect_RetStop: sout << "file:" << arg1 << " : EXCEPTION while reading" << std::endl; break; + default: sout << "file:" << arg1 << " could not be read" << std::endl; break; + } + if (status != IFSelect_RetDone) return status; + // sout<<" - clearing list of already written files"<BeginSentFiles(Standard_True); + return status; +} + +static IFSelect_ReturnStatus fun4 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Write All **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Write All : give file name !" << std::endl; return IFSelect_RetError; } + return WS->SendAll(arg1); +} + +static IFSelect_ReturnStatus fun5 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // const Standard_CString arg2 = pilot->Arg(2); + // **** Write Selected **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Write Selected : give file name + givelist !" << std::endl; return IFSelect_RetError; } + Handle(TColStd_HSequenceOfTransient) result = + XSDRAW_FunctionsSession::GiveList(WS, pilot->CommandPart(2)); + if (result.IsNull()) { sout << "No entity selected" << std::endl; return IFSelect_RetError; } + else sout << "Nb Entities selected : " << result->Length() << std::endl; + Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; + sp->SetList(result); + return WS->SendSelected(arg1, sp); +} + +static IFSelect_ReturnStatus fun6 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Write Entite(s) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Write Entitie(s) : give file name + n0s entitie(s)!" << std::endl; return IFSelect_RetError; } + int ko = 0; + Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; + for (Standard_Integer ia = 2; ia < argc; ia++) + { + Standard_Integer id = pilot->Number(pilot->Arg(ia)); + if (id > 0) + { + Handle(Standard_Transient) item = WS->StartingEntity(id); + if (sp->Add(item)) sout << "Added:no." << id << std::endl; + else { sout << " Fail Add n0." << id << std::endl; ko++; } + } + else { sout << "Not an entity number:" << pilot->Arg(ia) << std::endl; ko++; } + } + if (ko > 0) { sout << ko << " bad arguments, abandon" << std::endl; return IFSelect_RetError; } + return WS->SendSelected(arg1, sp); +} + +static IFSelect_ReturnStatus fun7 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Entity Label **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give entity number" << std::endl; return IFSelect_RetError; } + if (!WS->HasModel()) { sout << "No loaded model, abandon" << std::endl; return IFSelect_RetError; } + Standard_Integer nument = WS->NumberFromLabel(arg1); + if (nument <= 0 || nument > WS->NbStartingEntities()) + { + sout << "Not a suitable number: " << arg1 << std::endl; return IFSelect_RetError; + } + sout << "N0." << nument << " ->Label in Model : "; + WS->Model()->PrintLabel(WS->StartingEntity(nument), sout); + sout << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun8 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Entity Number **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give label to search" << std::endl; return IFSelect_RetError; } + if (!WS->HasModel()) { sout << "No loaded model, abandon" << std::endl; return IFSelect_RetError; } + const Handle(Interface_InterfaceModel)& model = WS->Model(); + Standard_Integer i, cnt = 0; + Standard_Boolean exact = Standard_False; + sout << " ** Search Entity Number for Label : " << arg1 << std::endl; + for (i = model->NextNumberForLabel(arg1, 0, exact); i != 0; + i = model->NextNumberForLabel(arg1, i, exact)) + { + cnt++; + sout << " ** Found n0/id:"; + model->Print(model->Value(i), sout); + sout << std::endl; + } + + if (cnt == 0) sout << " ** No Match" << std::endl; + else if (cnt == 1) sout << " ** 1 Match" << std::endl; + else sout << cnt << " Matches" << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun9 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** List Types **** + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Handle(IFSelect_Signature) signtype = WS->SignType(); + if (signtype.IsNull()) signtype = new IFSelect_SignType; + Handle(IFSelect_SignCounter) counter = + new IFSelect_SignCounter(signtype, Standard_False); + return pilot->ExecuteCounter(counter, 1); +} + +static IFSelect_ReturnStatus funcount +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg0 = pilot->Arg(0); + const Standard_CString arg1 = pilot->Arg(1); + Standard_Boolean listmode = (arg0[0] == 'l'); + // **** List Counter **** + + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Designer signature ou compteur, + facultatif selection + facultatif entite" << std::endl; + sout << " signature/compteur seul -> tout le modele" << std::endl + << " sign/compteur + selection -> cette selection, evaluation normale" << std::endl + << " sign/compteur + sel + num -> cette selection evaluee sur entite n0 num" << std::endl; + return IFSelect_RetError; + } + DeclareAndCast(IFSelect_SignCounter, counter, WS->NamedItem(arg1)); + if (counter.IsNull()) + { + DeclareAndCast(IFSelect_Signature, signa, WS->NamedItem(arg1)); + if (!signa.IsNull()) counter = new IFSelect_SignCounter(signa, Standard_False, listmode); + } + // Handle(IFSelect_Selection) sel; + // Standard_Integer n3 = 0; if (argc > 3) n3 = WS->NumberFromLabel(arg3); + // if (argc > 2) sel = GetCasted(IFSelect_Selection,WS->NamedItem(arg2)); + // if (counter.IsNull() || (argc > 2 && n3 <= 0 && sel.IsNull()) ) { + // sout<<"Nom:"< 2) sout<<" et/ou "<Arg(i), "on")) { onflag = i; break; } + } + + Handle(IFSelect_Selection) sel = WS->GiveSelection(arg1); + DeclareAndCast(IFSelect_SelectDeduct, seld, sel); + if (!seld.IsNull()) + { + // Si onflag, faire une SelectSuite + if (onflag > 2) + { + Handle(IFSelect_SelectSuite) suite = new IFSelect_SelectSuite; + for (i = 1; i < onflag; i++) + { + sel = WS->GiveSelection(pilot->Arg(i)); + if (!suite->AddInput(sel)) + { + sout << "Incorrect definition for applied selection" << std::endl; + return IFSelect_RetError; + } + } + seld = suite; + } + + Handle(IFSelect_GraphCounter) gc = new IFSelect_GraphCounter(Standard_False, listmode); + gc->SetApplied(seld); + counter = gc; + } + + if (counter.IsNull()) + { + sout << "Neither Counter nor Signature : " << arg1 << std::endl; + return IFSelect_RetError; + } + + if (onflag == 0) onflag = 1; + IFSelect_PrintCount pcm = IFSelect_ListByItem; + if (arg0[0] == 'c') pcm = IFSelect_CountByItem; + if (arg0[0] == 's') pcm = IFSelect_CountSummary; + return pilot->ExecuteCounter(counter, onflag + 1, pcm); +} + +static IFSelect_ReturnStatus funsigntype +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Sign Type **** + Handle(IFSelect_Signature) signtype = WS->SignType(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (signtype.IsNull()) sout << "signtype actually undefined" << std::endl; + else + { + Handle(TCollection_HAsciiString) str = WS->Name(signtype); + Standard_Integer id = WS->ItemIdent(signtype); + sout << signtype->Label() << std::endl; + if (str.IsNull()) + { + if (id > 0) sout << "signtype : item n0 " << id << std::endl; + } + else + { + sout << "signtype : also named as " << str->ToCString() << std::endl; + } + } + if (argc < 2) sout << "signtype newitem to change, signtype . to clear" << std::endl; + else + { + if (arg1[0] == '.' && arg1[1] == '\0') + { + signtype.Nullify(); + sout << "signtype now cleared" << std::endl; + } + else + { + signtype = GetCasted(IFSelect_Signature, WS->NamedItem(arg1)); + if (signtype.IsNull()) { sout << "Not a Signature : " << arg1 << std::endl; return IFSelect_RetError; } + else sout << "signtype now set to " << arg1 << std::endl; + } + WS->SetSignType(signtype); + return IFSelect_RetDone; + } + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus funsigncase +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Sign Case **** + Handle(IFSelect_Signature) signcase = GetCasted(IFSelect_Signature, WS->NamedItem(arg1)); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (signcase.IsNull()) sout << "Not a Signature : " << arg1 << std::endl; + else + { + Standard_Boolean hasmin, hasmax; Standard_Integer valmin, valmax; + if (signcase->IsIntCase(hasmin, valmin, hasmax, valmax)) + { + sout << "Signature " << arg1 << " : Integer Case"; + if (hasmin) sout << " - Mini:" << valmin; + if (hasmax) sout << " - Maxi:" << valmax; + sout << std::endl; + } + Handle(TColStd_HSequenceOfAsciiString) caselist = signcase->CaseList(); + if (caselist.IsNull()) sout << "Signature " << arg1 << " : no predefined case, see command count " << arg1 << std::endl; + else + { + Standard_Integer i, nb = caselist->Length(); + sout << "Signature " << arg1 << " : " << nb << " basic cases :" << std::endl; + for (i = 1; i <= nb; i++) sout << " " << caselist->Value(i); + sout << std::endl; + } + } + return IFSelect_RetVoid; +} + + +static IFSelect_ReturnStatus fun10 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Entity Status **** + Standard_Integer i, nb; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + nb = Interface_Category::NbCategories(); + sout << " Categories defined :" << nb << " i.e. :\n"; + for (i = 0; i <= nb; i++) + sout << "Cat." << i << " : " << Interface_Category::Name(i) << "\n"; + sout << " On a given entity : give its number" << std::endl; + return IFSelect_RetVoid; + } + Standard_Integer num = pilot->Number(arg1); + if (num <= 0 || num > WS->NbStartingEntities()) + { + sout << "Not a suitable entity number : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(Standard_Transient) ent = WS->StartingEntity(num); + WS->PrintEntityStatus(ent, sout); + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun11 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** DumpModel (Data) **** + Standard_Integer niv = 0; + // char arg10 = arg1[0]; + // if (argc < 2) arg10 = '?'; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + switch (arg1[0]) + { + case '?': + sout << "? for this help, else give a listing mode (first letter suffices) :\n" + << " general General Statistics\n roots Roots\n" + << " entities All Entities\n" + << " listfails CheckList (fails) per entity\n" + << " messages CheckList (complete) per entity\n" + << " fails CheckList (fails) per message (counting)\n" + << " check CheckList (complete) per message (counting)\n" + << " totalcheck CheckList (complete) per message (listing n0 ents)\n" + << " FAILS CheckList (fails) per message (listing complete)\n" + << " TOTALCHECK CheckList (complete) per message (listing complete)" << std::endl; + return IFSelect_RetVoid; + case 'g': niv = 0; break; + case 'r': niv = 1; break; + case 'e': niv = 2; break; + case 'l': niv = 3; break; + case 'm': niv = 4; break; + case 'c': niv = 5; break; + case 't': niv = 6; break; + case 'T': niv = 7; break; + case 'f': niv = 8; break; + case 'F': niv = 10; break; + default: sout << "Unknown Mode . data tout court pour help" << std::endl; return IFSelect_RetError; + } + WS->TraceDumpModel(niv); + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fundumpent +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + Handle(IFSelect_WorkLibrary) WL = WS->WorkLibrary(); + Standard_Integer levdef = 0, levmax = 10, level; + WL->DumpLevels(levdef, levmax); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2 || (argc == 2 && levmax < 0)) + { + sout << "Give n0 or id of entity"; + if (levmax < 0) sout << " and dump level" << std::endl; + else sout << " + optional, dump level in [0 - " << levmax << "] , default = " << levdef << std::endl; + for (level = 0; level <= levmax; level++) + { + Standard_CString help = WL->DumpHelp(level); + if (help[0] != '\0') sout << level << " : " << help << std::endl; + } + return IFSelect_RetError; + } + + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Standard_Integer num = pilot->Number(arg1); + if (num == 0) return IFSelect_RetError; + level = levdef; + if (argc > 2) level = atoi(arg2); + Handle(Standard_Transient) ent = WS->StartingEntity(num); + if (ent.IsNull()) + { + sout << "No entity with given id " << arg1 << " (" << num << ") is found in the current model" << std::endl; + } + else + { + sout << " -- DUMP Entity n0 " << num << " level " << level << std::endl; + WL->DumpEntity(WS->Model(), WS->Protocol(), ent, sout, level); + + Interface_CheckIterator chl = WS->CheckOne(ent); + if (!chl.IsEmpty(Standard_False)) chl.Print(sout, WS->Model(), Standard_False); + } + // sout << std::flush; + + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus funsign +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << " Give signature name + n0 or id of entity" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); + if (sign.IsNull()) { sout << "Not a signature : " << arg1 << std::endl; return IFSelect_RetError; } + Standard_Integer num = pilot->Number(arg2); + Handle(Standard_Transient) ent = WS->StartingEntity(num); + if (num == 0) return IFSelect_RetError; + sout << "Entity n0 " << num << " : " << WS->SignValue(sign, ent) << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus funqp +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << " Give 2 numeros or labels : dad son" << std::endl; return IFSelect_RetError; } + Standard_Integer n1 = WS->NumberFromLabel(arg1); + Standard_Integer n2 = WS->NumberFromLabel(arg2); + sout << "QueryParent for dad:" << arg1 << ":" << n1 << " and son:" << arg2 << ":" << n2 << std::endl; + Standard_Integer qp = WS->QueryParent(WS->StartingEntity(n1), WS->StartingEntity(n2)); + if (qp < 0) sout << arg1 << " is not super-entity of " << arg2 << std::endl; + else if (qp == 0) sout << arg1 << " is same as " << arg2 << std::endl; + else sout << arg1 << " is super-entity of " << arg2 << " , max level found=" << qp << std::endl; + // sout<<" Trouve "<Session(); + // **** DumpShare **** + WS->DumpShare(); return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun13 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** ListItems **** + WS->ListItems(pilot->Arg(1)); return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun14 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** NewInt **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 1) { sout << "Donner la valeur entiere pour IntParam" << std::endl; return IFSelect_RetError; } + Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam; + if (argc >= 1) intpar->SetValue(atoi(arg1)); + return pilot->RecordItem(intpar); +} + +static IFSelect_ReturnStatus fun15 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SetInt **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "Donner 2 arguments : nom Parametre et Valeur" << std::endl; return IFSelect_RetError; + } + Standard_Integer val = atoi(arg2); + DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); + if (!WS->SetIntValue(par, val)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun16 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** NewText **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 1) { sout << "Donner la valeur texte pour TextParam" << std::endl; return IFSelect_RetError; } + Handle(TCollection_HAsciiString) textpar = new TCollection_HAsciiString(); + if (argc >= 1) textpar->AssignCat(arg1); + return pilot->RecordItem(textpar); +} + +static IFSelect_ReturnStatus fun17 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SetText **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "Donner 2 arguments : nom Parametre et Valeur" << std::endl; return IFSelect_RetError; + } + DeclareAndCast(TCollection_HAsciiString, par, WS->NamedItem(arg1)); + if (!WS->SetTextValue(par, arg2)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun19 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** DumpSel **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give 1 argument : Selection Name" << std::endl; return IFSelect_RetError; } + WS->DumpSelection(GetCasted(IFSelect_Selection, WS->NamedItem(arg1))); + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun20 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + // **** EvalSel **** + // **** GiveList **** + // **** GiveShort GivePointed **** + // **** MakeList **** + char mode = pilot->Arg(0)[0]; // givelist/makelist + if (mode == 'g') mode = pilot->Arg(0)[4]; // l list s short p pointed + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << std::endl; return IFSelect_RetError; } + + // MakeList : sur Pointed existante ou a creer + Handle(IFSelect_SelectPointed) pnt; + if (mode == 'm') + { + const Standard_CString arg1 = pilot->Arg(1); + Handle(Standard_Transient) item = WS->NamedItem(arg1); + pnt = GetCasted(IFSelect_SelectPointed, item); + if (!pnt.IsNull()) + { + sout << arg1 << ":Already existing Selection for List, cleared then filled" << std::endl; + pnt->Clear(); + } + else if (!item.IsNull()) + { + sout << arg1 << ":Already existing Item not for a List, command ignored" << std::endl; + return IFSelect_RetFail; + } + else + { + pnt = new IFSelect_SelectPointed; + WS->AddNamedItem(arg1, pnt); + } + } + + Handle(TColStd_HSequenceOfTransient) result = + XSDRAW_FunctionsSession::GiveList(WS, pilot->CommandPart((mode == 'm' ? 2 : 1))); + if (result.IsNull()) return IFSelect_RetError; + Interface_EntityIterator iter(result); + sout << pilot->CommandPart((mode == 'm' ? 2 : 1)) << " : "; + if (mode == 'l') WS->ListEntities(iter, 0, sout); + else if (mode == 's' || mode == 'm') WS->ListEntities(iter, 2, sout); + else if (mode == 'p') + { + sout << iter.NbEntities() << " Entities : "; + for (iter.Start(); iter.More(); iter.Next()) + sout << " +" << WS->StartingNumber(iter.Value()); + sout << std::endl; + } + + if (!pnt.IsNull()) + { + pnt->SetList(result); + sout << "List set to a SelectPointed : " << pilot->Arg(1) << std::endl; + sout << "Later editable by command setlist" << std::endl; + } + + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun20c +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + // **** GiveCount **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << std::endl; return IFSelect_RetError; } + // WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); + Handle(TColStd_HSequenceOfTransient) result = + XSDRAW_FunctionsSession::GiveList(WS, pilot->CommandPart(1)); + if (result.IsNull()) return IFSelect_RetError; + sout << pilot->CommandPart(1) << " : List of " << result->Length() << " Entities" << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus funselsuite +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + // **** SelSuite **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give Entity ID, or Selection Name [+ optional other selection or entity]" << std::endl; return IFSelect_RetError; } + // WS->EvaluateSelection(GetCasted(IFSelect_Selection,WS->NamedItem(arg1))); + Handle(IFSelect_SelectSuite) selsuite = new IFSelect_SelectSuite; + + for (Standard_Integer i = 1; i < argc; i++) + { + Handle(IFSelect_Selection) sel = WS->GiveSelection(pilot->Arg(i)); + if (!selsuite->AddInput(sel)) + { + sout << pilot->Arg(i - 1) << " : not a SelectDeduct, no more can be added. Abandon" << std::endl; + return IFSelect_RetError; + } + } + selsuite->SetLabel(pilot->CommandPart(1)); + return pilot->RecordItem(selsuite); +} + + +static IFSelect_ReturnStatus fun21 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** ClearItems **** + WS->ClearItems(); WS->ClearFinalModifiers(); WS->ClearShareOut(Standard_False); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun22 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** ClearData **** + Standard_Integer mode = -1; + if (argc >= 2) + { + if (arg1[0] == 'a') mode = 1; + if (arg1[0] == 'g') mode = 2; + if (arg1[0] == 'c') mode = 3; + if (arg1[0] == 'p') mode = 4; + if (arg1[0] == '?') mode = -1; + } + else mode = 0; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (mode <= 0) + { + if (mode < 0) sout << "Give a suitable mode"; + sout << " Available Modes :\n" + << " a : all data g : graph+check c : check p : selectpointed" << std::endl; + return (mode < 0 ? IFSelect_RetError : IFSelect_RetVoid); + } + WS->ClearData(mode); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun24 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + // **** Item Label **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + TCollection_AsciiString label; + if (argc < 2) { sout << " Give label to search" << std::endl; return IFSelect_RetError; } + for (int i = 1; i < argc; i++) + { + label.AssignCat(pilot->Arg(i)); + if (i < argc - 1) label.AssignCat(" "); + } + for (int mode = 0; mode <= 2; mode++) + { + int nbitems = 0; int id; + sout << "Searching label : " << label << ". in mode "; + if (mode == 0) sout << " exact" << std::endl; + if (mode == 1) sout << " same head" << std::endl; + if (mode == 2) sout << " search if present" << std::endl; + for (id = WS->NextIdentForLabel(label.ToCString(), 0, mode); id != 0; + id = WS->NextIdentForLabel(label.ToCString(), id, mode)) + { + sout << " " << id; nbitems++; + } + sout << " -- giving " << nbitems << " found" << std::endl; + } + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun25 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Save (Dump) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner nom du Fichier" << std::endl; return IFSelect_RetError; } + IFSelect_SessionFile dumper(WS, arg1); + if (!dumper.IsDone()) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun26 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Restore (Dump) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner nom du Fichier" << std::endl; return IFSelect_RetError; } + IFSelect_SessionFile dumper(WS); + Standard_Integer readstat = dumper.Read(arg1); + if (readstat == 0) return IFSelect_RetDone; + else if (readstat > 0) sout << "-- Erreur Lecture Fichier " << arg1 << std::endl; + else sout << "-- Pas pu ouvrir Fichier " << arg1 << std::endl; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun27 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + const Standard_CString arg1 = pilot->Arg(1); + Standard_CString arg2 = pilot->Arg(2); + const Standard_CString anEmptyStr = ""; + if (arg2 && strlen(arg2) == 2 && arg2[0] == '"' && arg2[1] == '"') + { + arg2 = anEmptyStr; + } + // **** Param(Value) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2 || (argc == 3 && strcmp(arg1, "-p") == 0)) + { + Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items(); + Standard_Integer i, nb = li->Length(), aPatternNb = 0; + size_t aPatternLen = strlen(arg2); + if (argc == 3) + { + for (i = 1; i <= nb; i++) + { + if (strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) == 0) + { + aPatternNb++; + } + } + } + else + { + aPatternNb = nb; + } + sout << " List of parameters : " << aPatternNb << " items : " << std::endl; + for (i = 1; i <= nb; i++) + { + if (argc == 3 && strncmp(li->Value(i)->String().ToCString(), arg2, aPatternLen) != 0) + { + continue; + } + sout << li->Value(i)->String(); + sout << " : " << Interface_Static::CVal(li->Value(i)->ToCString()) << std::endl; + } + return IFSelect_RetVoid; + } + else if (atoi(arg1) > 0) + { + Standard_Integer use = atoi(arg1); + WS->TraceStatics(use); + } + else + { + if (argc > 2) sout << " FORMER STATUS of Static Parameter " << arg1 << std::endl; + else sout << " ACTUAL STATUS of Static Parameter " << arg1 << std::endl; + if (!Interface_Static::IsPresent(arg1)) { sout << " Parameter " << arg1 << " undefined" << std::endl; return IFSelect_RetError; } + if (!Interface_Static::IsSet(arg1)) sout << " Parameter " << arg1 << " not valued" << std::endl; + else if (argc == 2) Interface_Static::Static(arg1)->Print(sout); + else sout << " Value : " << Interface_Static::CVal(arg1) << std::endl; + + if (argc == 2) sout << "To modify, param name_param new_val" << std::endl; + else + { + if (strlen(arg2) != 0) + { + sout << " New demanded value : " << arg2; + } + else + { + sout << " New demanded value : not valued"; + } + if (Interface_Static::SetCVal(arg1, arg2)) + { + sout << " OK" << std::endl; return IFSelect_RetDone; + } + else { sout << " , refused" << std::endl; return IFSelect_RetError; } + } + } + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun29 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SentFiles **** + Handle(TColStd_HSequenceOfHAsciiString) list = WS->SentFiles(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (list.IsNull()) + { + sout << "List of Sent Files not enabled" << std::endl; return IFSelect_RetVoid; + } + Standard_Integer i, nb = list->Length(); + sout << " Sent Files : " << nb << " : " << std::endl; + for (i = 1; i <= nb; i++) + sout << list->Value(i)->ToCString() << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun30 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** FilePrefix **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + if (WS->FilePrefix().IsNull()) sout << "Pas de prefixe defini" << std::endl; + else sout << "Prefixe : " << WS->FilePrefix()->ToCString() << std::endl; + sout << "Pour changer : filepref newprefix" << std::endl; + return IFSelect_RetVoid; + } + WS->SetFilePrefix(arg1); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun31 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** FileExtension **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + if (WS->FileExtension().IsNull()) sout << "Pas d extension definie" << std::endl; + else sout << "Extension : " << WS->FileExtension()->ToCString() << std::endl; + sout << "Pour changer : fileext newext" << std::endl; + return IFSelect_RetVoid; + } + WS->SetFileExtension(arg1); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun32 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** FileRoot **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Dispatch et nom de Root" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); + if (argc < 3) + { + if (WS->FileRoot(disp).IsNull()) sout << "Pas de racine definie pour " << arg1 << std::endl; + else sout << "Racine pour " << arg1 << " : " << WS->FileRoot(disp)->ToCString() << std::endl; + sout << "Pour changer : fileroot nomdisp newroot" << std::endl; + return IFSelect_RetVoid; + } + if (!WS->SetFileRoot(disp, arg2)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun33 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Default File Root **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + if (WS->DefaultFileRoot().IsNull()) sout << "Pas de racine par defaut definie" << std::endl; + else sout << "Racine par defaut : " << WS->DefaultFileRoot()->ToCString() << std::endl; + sout << "Pour changer : filedef newdef" << std::endl; + return IFSelect_RetVoid; + } + WS->SetDefaultFileRoot(arg1); + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun34 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** EvalFile **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (!WS->HasModel()) + { + sout << "Pas de Modele charge, abandon" << std::endl; return IFSelect_RetFail; + } + + sout << "Evaluation avec Memorisation des resultats" << std::endl; + WS->EvaluateFile(); + Standard_Integer nbf = WS->NbFiles(); + for (Standard_Integer i = 1; i <= nbf; i++) + { + Handle(Interface_InterfaceModel) mod = WS->FileModel(i); + if (mod.IsNull()) + { + sout << "Modele " << i << " Model non genere ..." << std::endl; continue; + } + TCollection_AsciiString name = WS->FileName(i); + sout << "Fichier n0 " << i << " Nb Entites : " << mod->NbEntities() << " Nom: "; + sout << name << std::endl; + } + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun35 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** ClearFile **** + WS->ClearFile(); return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun36 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + // **** Split **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + IFSelect_ReturnStatus stat = IFSelect_RetVoid; + if (argc < 2) sout << "Split : derniere liste de dispatches definie" << std::endl; + else + { + WS->ClearShareOut(Standard_True); + for (Standard_Integer i = 1; i < argc; i++) + { + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(pilot->Arg(i))); + if (disp.IsNull()) + { + sout << "Pas un dispatch:" << pilot->Arg(i) << ", Splitt abandonne" << std::endl; + stat = IFSelect_RetError; + } + else WS->SetActive(disp, Standard_True); + } + } + if (stat == IFSelect_RetError) return stat; + WS->BeginSentFiles(Standard_True); + if (!WS->SendSplit()) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun37 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Remaining Data **** + char mode = '?'; IFSelect_RemainMode numod = IFSelect_RemainDisplay; + if (argc >= 2) mode = arg1[0]; + if (mode == 'u') numod = IFSelect_RemainUndo; + else if (mode == 'l') numod = IFSelect_RemainDisplay; + else if (mode == 'c') numod = IFSelect_RemainCompute; + else if (mode == 'f') numod = IFSelect_RemainForget; + else + { + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) sout << "Donner un Mode - "; + sout << "Modes possibles : l list, c compute, u undo, f forget" << std::endl; + if (mode == '?') return IFSelect_RetDone; else return IFSelect_RetError; + } + if (!WS->SetRemaining(numod)) return IFSelect_RetVoid; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun38 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SetModelContent **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner nom selection et mode (k=keep,r=remove)" << std::endl; return IFSelect_RetError; } + Standard_Boolean keepmode; + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + if (sel.IsNull()) + { + sout << "Pas de Selection de Nom : " << arg1 << std::endl; return IFSelect_RetError; + } + if (arg2[0] == 'k') { sout << " -- SetContent keep ..."; keepmode = Standard_True; } + else if (arg2[0] == 'r') { sout << " -- SetContent remove ..."; keepmode = Standard_False; } + else { sout << "Donner nom selection et mode (k=keep,r=remove)" << std::endl; return IFSelect_RetError; } + + if (WS->SetModelContent(sel, keepmode)) sout << " Done" << std::endl; + else sout << " Result empty, ignored" << std::endl; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun40 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** ListModif **** + WS->ListFinalModifiers(Standard_True); + WS->ListFinalModifiers(Standard_False); return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun41 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Modifier **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom du Modifier" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); + if (modif.IsNull()) + { + sout << "Pas de Modifier de Nom : " << arg1 << std::endl; return IFSelect_RetVoid; + } + Handle(IFSelect_IntParam) low, up; + + Handle(IFSelect_Dispatch) disp = modif->Dispatch(); + sout << "Modifier : " << arg1 << " Label : " << modif->Label() << std::endl; + Standard_Integer rank = WS->ModifierRank(modif); + if (modif->IsKind(STANDARD_TYPE(IFSelect_Modifier))) + sout << "Model Modifier n0." << rank; + else sout << "File Modifier n0." << rank; + if (disp.IsNull()) sout << " Applique a tous les Dispatchs" << std::endl; + else + { + sout << " Dispatch : " << disp->Label(); + if (WS->HasName(disp)) sout << " - Nom:" << WS->Name(disp)->ToCString(); + sout << std::endl; + } + + Handle(IFSelect_Selection) sel = modif->Selection(); + if (!sel.IsNull()) sout << " Selection : " << sel->Label(); + if (WS->HasName(sel)) sout << " - Nom:" << WS->Name(sel)->ToCString(); + sout << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun42 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** ModifSel **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Donner Nom Modifier; + Nom Selection optionnel\n" + << "Selection pour Mettre une Selection, sinon Annule" << std::endl; return IFSelect_RetError; + } + DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); + if (modif.IsNull()) + { + sout << "Pas un nom de Modifier : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_Selection) sel; + if (arg2[0] != '\0') + { + sel = GetCasted(IFSelect_Selection, WS->NamedItem(arg2)); + if (sel.IsNull()) + { + sout << "Pas un nom de Selection : " << arg2 << std::endl; return IFSelect_RetError; + } + } + if (!WS->SetItemSelection(modif, sel)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun43 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SetAppliedModifier **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Donner Nom Modifier; + Nom Dispatch ou Transformer optionnel :\n" + << " - rien : tous Dispatches\n - Dispatch : ce Dispatch seul\n" + << " - Transformer : pas un Dispatch mais un Transformer" << std::endl; + return IFSelect_RetError; + } + DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); + if (modif.IsNull()) + { + sout << "Pas un nom de Modifier : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(Standard_Transient) item; + if (arg2[0] != '\0') + { + item = WS->NamedItem(arg2); + if (item.IsNull()) + { + sout << "Pas un nom connu : " << arg2 << std::endl; return IFSelect_RetError; + } + } + else item = WS->ShareOut(); + if (!WS->SetAppliedModifier(modif, item)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun44 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** ResetApplied (modifier) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Designer un modifier" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_GeneralModifier, modif, WS->NamedItem(arg1)); + if (modif.IsNull()) + { + sout << "Pas un nom de Modifier : " << arg1 << std::endl; return IFSelect_RetError; + } + if (!WS->ResetAppliedModifier(modif)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun45 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + const Standard_CString arg3 = pilot->Arg(3); + // **** ModifMove **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 4) { sout << "modifmove MF rang1 rang2, M pour Model F pour File" << std::endl; return IFSelect_RetError; } + Standard_Boolean formodel; + if (arg1[0] == 'm' || arg1[0] == 'M') formodel = Standard_True; + else if (arg1[0] == 'f' || arg1[0] == 'F') formodel = Standard_False; + else { sout << "preciser M pour Model, F pour File" << std::endl; return IFSelect_RetError; } + Standard_Integer before = atoi(arg2); + Standard_Integer after = atoi(arg3); + if (before == 0 || after == 0) { sout << "Donner 2 Entiers Positifs" << std::endl; return IFSelect_RetError; } + if (!WS->ChangeModifierRank(formodel, before, after)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun51 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** DispSel **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner Noms Dispatch et Selection Finale" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); + if (disp.IsNull()) + { + sout << "Pas un nom de Dispatch : " << arg1 << std::endl; return IFSelect_RetError; + } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg2)); + if (sel.IsNull()) + { + sout << "Pas un nom de Selection : " << arg2 << std::endl; return IFSelect_RetError; + } + if (!WS->SetItemSelection(disp, sel)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun_dispone +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** DispOne **** + Handle(IFSelect_DispPerOne) disp = new IFSelect_DispPerOne; + return pilot->RecordItem(disp); +} + +static IFSelect_ReturnStatus fun_dispglob +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** DispGlob **** + Handle(IFSelect_DispGlobal) disp = new IFSelect_DispGlobal; + return pilot->RecordItem(disp); +} + +static IFSelect_ReturnStatus fun_dispcount +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** DispCount **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom IntParam pour Count" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); + if (par.IsNull()) + { + sout << "Pas un nom de IntParam : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_DispPerCount) disp = new IFSelect_DispPerCount; + disp->SetCount(par); + return pilot->RecordItem(disp); +} + +static IFSelect_ReturnStatus fun_dispfiles +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** DispFiles **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom IntParam pour NbFiles" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); + if (par.IsNull()) + { + sout << "Pas un nom de IntParam : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_DispPerFiles) disp = new IFSelect_DispPerFiles; + disp->SetCount(par); + return pilot->RecordItem(disp); +} + + +static IFSelect_ReturnStatus fun_dispsign +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** DispFiles **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom Signature" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Signature, sig, WS->NamedItem(arg1)); + if (sig.IsNull()) + { + sout << "Pas un nom de Signature : " << arg1 << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_DispPerSignature) disp = new IFSelect_DispPerSignature; + disp->SetSignCounter(new IFSelect_SignCounter(sig)); + return pilot->RecordItem(disp); +} + + +static IFSelect_ReturnStatus fun56 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Dispatch **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom du Dispatch" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(arg1)); + if (disp.IsNull()) { sout << "Pas un dispatch : " << arg1 << std::endl; return IFSelect_RetError; } + Standard_Integer num = WS->DispatchRank(disp); + sout << "Dispatch de Nom : " << arg1 << " , en ShareOut, Numero " << num << " : "; + Handle(IFSelect_Selection) sel = WS->ItemSelection(disp); + Handle(TCollection_HAsciiString) selname = WS->Name(sel); + if (sel.IsNull()) sout << "Pas de Selection Finale" << std::endl; + else if (selname.IsNull()) sout << "Selection Finale : #" << WS->ItemIdent(sel) << std::endl; + else sout << "Selection Finale : " << selname->ToCString() << std::endl; + if (disp->HasRootName()) sout << "-- Racine nom de fichier : " + << disp->RootName()->ToCString() << std::endl; + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun57 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Remove **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Give Name to Remove !" << std::endl; return IFSelect_RetError; } + if (!WS->RemoveNamedItem(arg1)) return IFSelect_RetFail; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun58 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** EvalDisp **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "evaldisp mode disp [disp ...] : Mode + Name(s) of Dispatch(es). Mode:\n" + << " 0 brief 1 +forgotten ents 2 +duplicata 3 1+2" << std::endl + << "See also : evaladisp writedisp xsplit" << std::endl; + return IFSelect_RetVoid; + } + Standard_Boolean OK = Standard_True; + Standard_Integer i, mode = atoi(arg1); sout << " Mode " << mode << "\n"; + for (i = 2; i < argc; i++) + { + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(pilot->Arg(i))); + if (disp.IsNull()) + { + sout << "Not a dispatch:" << pilot->Arg(i) << std::endl; OK = Standard_False; + } + } + if (!OK) + { + sout << "Some of the parameters are not correct" << std::endl; + return IFSelect_RetError; + } + + WS->ClearShareOut(Standard_True); + for (i = 2; i < argc; i++) + { + DeclareAndCast(IFSelect_Dispatch, disp, WS->NamedItem(pilot->Arg(i))); + WS->SetActive(disp, Standard_True); + } + // WS->EvaluateDispatch(disp,mode); + WS->EvaluateComplete(mode); + return IFSelect_RetVoid; +} + + +static IFSelect_ReturnStatus fun_evaladisp +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** EvalADisp [GiveList] **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "evaladisp mode(=0-1-2-3) disp [givelist] : Mode + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch. Mode:\n" + << " 0 brief 1 +forgotten ents 2 +duplicata 3 1+2" << std::endl + << "See also : writedisp" << std::endl; + return IFSelect_RetVoid; + } + if (arg1[1] != '\0') { sout << "first parameter : mode, must be a number between 0 and 3" << std::endl; return IFSelect_RetError; } + Standard_Integer mode = atoi(arg1); sout << " Mode " << mode << "\n"; + // DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2))); + Handle(IFSelect_Dispatch) disp = XSDRAW_FunctionsSession::GiveDispatch(WS, pilot->Arg(2), Standard_True); + if (disp.IsNull()) + { + sout << "Not a dispatch:" << pilot->Arg(2) << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_Selection) selsav = disp->FinalSelection(); + Handle(IFSelect_Selection) sel; + if (argc > 3) + { + Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; + Handle(TColStd_HSequenceOfTransient) list = XSDRAW_FunctionsSession::GiveList + (pilot->Session(), pilot->CommandPart(3)); + Standard_Integer nb = (list.IsNull() ? 0 : list->Length()); + if (nb > 0) { sp->AddList(list); sel = sp; } + } + + if (sel.IsNull() && selsav.IsNull()) + { + sout << "No Selection nor GiveList defined" << std::endl; return IFSelect_RetError; + } + if (sel.IsNull() && !selsav.IsNull()) + { + if (argc > 3) sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << std::endl; + sel = selsav; + } + disp->SetFinalSelection(sel); + // WS->ClearShareOut(Standard_True); + // WS->SetActive(disp,Standard_True); + WS->EvaluateDispatch(disp, mode); + disp->SetFinalSelection(selsav); + + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun_writedisp +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** EvalADisp [GiveList] **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "writedisp filename disp [givelist] : FileName + Dispatch [+ GiveList]\n If GiveList not given, computed from Selection of the Dispatch.\n" + << "FileName : rootname.ext will gives rootname_1.ext etc...\n" + << " path/rootname.ext gives path/rootname_1.ext etc...\n" + << "See also : evaladisp" << std::endl; + return IFSelect_RetVoid; + } + TCollection_AsciiString prefix, rootname, suffix; + SplitFileName(arg1, prefix, rootname, suffix); + if (rootname.Length() == 0 || suffix.Length() == 0) + { + sout << "Empty Root Name or Extension" << std::endl; + return IFSelect_RetError; + } + + // DeclareAndCast(IFSelect_Dispatch,disp,WS->NamedItem(pilot->Arg(2))); + Handle(IFSelect_Dispatch) disp = XSDRAW_FunctionsSession::GiveDispatch(WS, pilot->Arg(2), Standard_True); + if (disp.IsNull()) + { + sout << "Not a dispatch:" << pilot->Arg(2) << std::endl; return IFSelect_RetError; + } + Handle(IFSelect_Selection) selsav = disp->FinalSelection(); + Handle(IFSelect_Selection) sel; + if (argc > 3) + { + Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; + Handle(TColStd_HSequenceOfTransient) list = XSDRAW_FunctionsSession::GiveList + (pilot->Session(), pilot->CommandPart(3)); + Standard_Integer nb = (list.IsNull() ? 0 : list->Length()); + if (nb > 0) { sp->AddList(list); sel = sp; } + } + + if (sel.IsNull() && selsav.IsNull()) + { + sout << "No Selection nor GiveList defined" << std::endl; return IFSelect_RetError; + } + if (sel.IsNull() && !selsav.IsNull()) + { + if (argc > 3) sout << "GiveList is empty, hence computed from the Selection of the Dispatch" << std::endl; + sel = selsav; + } + + WS->ClearShareOut(Standard_True); + disp->SetFinalSelection(sel); + WS->SetActive(disp, Standard_True); + WS->BeginSentFiles(Standard_True); + + WS->SetFilePrefix(prefix.ToCString()); + WS->SetFileExtension(suffix.ToCString()); + WS->SetFileRoot(disp, rootname.ToCString()); + + Standard_Boolean OK = WS->SendSplit(); + disp->SetFinalSelection(selsav); + return (OK ? IFSelect_RetDone : IFSelect_RetFail); +} + + +static IFSelect_ReturnStatus fun59 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** EvalComplete **** + Standard_Integer mode = 0; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) sout << " -- mode par defaut 0\n"; + else { mode = atoi(arg1); sout << " -- mode : " << mode << std::endl; } + WS->EvaluateComplete(mode); return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun60 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** LastRunCheckList **** + Interface_CheckIterator chlist = WS->LastRunCheckList(); + Handle(IFSelect_CheckCounter) counter = new IFSelect_CheckCounter(0); + counter->Analyse(chlist, WS->Model(), Standard_False); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + counter->PrintCount(sout); + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun61 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** RunTransformer **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom de Transformer" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Transformer, tsf, WS->NamedItem(arg1)); + Standard_Integer effect = WS->RunTransformer(tsf); + switch (effect) + { + case -4: sout << "Edition sur place, nouveau Protocole, erreur recalcul graphe" << std::endl; break; + case -3: sout << "Erreur, Transformation ignoree" << std::endl; break; + case -2: sout << "Erreur sur edition sur place, risque de corruption (verifier)" << std::endl; break; + case -1: sout << "Erreur sur edition locale, risque de corruption (verifier)" << std::endl; break; + case 0: + if (tsf.IsNull()) sout << "Erreur, pas un Transformer: " << arg1 << std::endl; + else sout << "Execution non faite" << std::endl; + break; + case 1: sout << "Transformation locale (graphe non touche)" << std::endl; break; + case 2: sout << "Edition sur place (graphe recalcule)" << std::endl; break; + case 3: sout << "Modele reconstruit" << std::endl; break; + case 4: sout << "Edition sur place, nouveau Protocole" << std::endl; break; + case 5: sout << "Nouveau Modele avec nouveau Protocole" << std::endl; break; + default: break; + } + return ((effect > 0) ? IFSelect_RetDone : IFSelect_RetFail); +} + +static IFSelect_ReturnStatus fun62 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** TransformStandard Copy **** + return pilot->RecordItem(WS->NewTransformStandard(Standard_True)); +} + +static IFSelect_ReturnStatus fun63 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** TransformStandard OntheSpot **** + return pilot->RecordItem(WS->NewTransformStandard(Standard_False)); +} + +static IFSelect_ReturnStatus fun6465 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** Run Modifier avec Standard Copy **** + // **** Run Modifier avec OnTheSpot **** + Standard_Boolean runcopy = (pilot->Arg(0)[3] == 'c'); + // soit c est un nom, sinon c est une commande + Handle(IFSelect_Modifier) modif; + if (WS->NameIdent(arg1) > 0) + modif = GetCasted(IFSelect_Modifier, WS->NamedItem(arg1)); + else + { + pilot->RemoveWord(0); // c etait la commande run + pilot->Perform(); + modif = GetCasted(IFSelect_Modifier, pilot->RecordedItem()); + } + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (modif.IsNull()) + { + sout << "Pas un nom de Modifier : " << arg1 << std::endl; return IFSelect_RetError; + } + + Handle(TColStd_HSequenceOfTransient) list; + Handle(IFSelect_SelectPointed) sp; + if (argc > 2) + { + list = XSDRAW_FunctionsSession::GiveList(WS, pilot->CommandPart(2)); + sp = new IFSelect_SelectPointed; + sp->SetList(list); + } + + Standard_Integer effect = 0; + effect = WS->RunModifierSelected(modif, sp, runcopy); + // sout<<"Modifier applique sur TransformStandard #"<ItemIdent(tsf)< 0) ? IFSelect_RetDone : IFSelect_RetFail); +} + +static IFSelect_ReturnStatus fun66 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** (xset) ModifReorder **** + char opt = ' '; + Standard_Integer argc = pilot->NbWords(); + if (argc >= 2) opt = pilot->Word(1).Value(1); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (opt != 'f' && opt != 'l') + { + sout << "Donner option : f -> root-first l -> root-last" << std::endl; return IFSelect_RetError; + } + return pilot->RecordItem(new IFSelect_ModifReorder(opt == 'l')); +} + +static IFSelect_ReturnStatus fun70 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** SelToggle **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom de Selection" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + if (!WS->ToggleSelectExtract(sel)) + { + sout << "Pas une SelectExtract : " << arg1 << std::endl; return IFSelect_RetFail; + } + if (WS->IsReversedSelectExtract(sel)) sout << arg1 << " a present Reversed" << std::endl; + else sout << arg1 << " a present Directe" << std::endl; + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun71 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelInput **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner Noms Selections cible et input" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, sou, WS->NamedItem(arg2)); + if (sel.IsNull() || sou.IsNull()) + { + sout << "Incorrect : " << arg1 << "," << arg2 << std::endl; return IFSelect_RetError; + } + if (!WS->SetInputSelection(sel, sou)) + { + sout << "Nom incorrect ou Selection " << arg1 << " ni Extract ni Deduct" << std::endl; + return IFSelect_RetFail; + } + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun72 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelModelRoots **** + return pilot->RecordItem(new IFSelect_SelectModelRoots); +} + +static IFSelect_ReturnStatus fun73 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelRange **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc >= 2 && arg1[0] == '?') argc = 1; + if (argc < 2) + { + sout << "Donner la description du SelectRange" + << " Formes admises :\n : Range de a \n" + << " tout seul : Range n0 \n from : Range From \n" + << " until : Range Until " << std::endl; + return IFSelect_RetVoid; + } + + Handle(IFSelect_IntParam) low, up; + Handle(IFSelect_SelectRange) sel; + // Range From + if (pilot->Word(1).IsEqual("from")) + { + if (argc < 3) { sout << "Forme admise : from " << std::endl; return IFSelect_RetError; } + low = GetCasted(IFSelect_IntParam, WS->NamedItem(arg2)); + sel = new IFSelect_SelectRange; + sel->SetFrom(low); + // Range Until + } + else if (pilot->Word(1).IsEqual("until")) + { + if (argc < 3) { sout << "Forme admise : until " << std::endl; return IFSelect_RetError; } + up = GetCasted(IFSelect_IntParam, WS->NamedItem(arg2)); + sel = new IFSelect_SelectRange; + sel->SetUntil(up); + // Range One (n-th) + } + else if (argc < 3) + { + low = GetCasted(IFSelect_IntParam, WS->NamedItem(arg1)); + sel = new IFSelect_SelectRange; + sel->SetOne(low); + // Range (from-to) + } + else + { + low = GetCasted(IFSelect_IntParam, WS->NamedItem(arg1)); + up = GetCasted(IFSelect_IntParam, WS->NamedItem(arg2)); + sel = new IFSelect_SelectRange; + sel->SetRange(low, up); + } + return pilot->RecordItem(sel); +} + +static IFSelect_ReturnStatus fun74 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelRoots **** + return pilot->RecordItem(new IFSelect_SelectRoots); +} + +static IFSelect_ReturnStatus fun75 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelShared **** + return pilot->RecordItem(new IFSelect_SelectShared); +} + +static IFSelect_ReturnStatus fun76 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelDiff **** + Handle(IFSelect_Selection) sel = new IFSelect_SelectDiff; + if (sel.IsNull()) return IFSelect_RetFail; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) sout << "Diff sans input : ne pas oublier de les definir (ctlmain, ctlsec)!" << std::endl; + DeclareAndCast(IFSelect_Selection, selmain, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, selsec, WS->NamedItem(arg2)); + if (argc >= 2) + if (!WS->SetControl(sel, selmain, Standard_True)) + sout << "Echec ControlMain:" << arg1 << " , a refaire (ctlmain)" << std::endl; + if (argc >= 3) + if (!WS->SetControl(sel, selsec, Standard_False)) + sout << "Echec ControlSecond:" << arg2 << " , a refaire (ctlsec)" << std::endl; + return pilot->RecordItem(sel); +} + +static IFSelect_ReturnStatus fun77 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelControlMain **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner Noms de Control et MainInput" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, selmain, WS->NamedItem(arg2)); + if (WS->SetControl(sel, selmain, Standard_True)) return IFSelect_RetDone; + sout << "Nom incorrect ou Selection " << arg1 << " pas de type Control" << std::endl; + return IFSelect_RetFail; +} + +static IFSelect_ReturnStatus fun78 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelControlSecond **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner Noms de Control et SecondInput" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, seldif, WS->NamedItem(arg2)); + if (WS->SetControl(sel, seldif, Standard_False)) return IFSelect_RetDone; + sout << "Nom incorrect ou Selection " << arg1 << " pas de type Control" << std::endl; + return IFSelect_RetFail; +} + +static IFSelect_ReturnStatus fun79 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelModelAll **** + return pilot->RecordItem(new IFSelect_SelectModelEntities); +} + +static IFSelect_ReturnStatus fun80 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelCombAdd **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner n0 Combine et une Input" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, seladd, WS->NamedItem(arg2)); + if (WS->CombineAdd(sel, seladd)) return IFSelect_RetDone; + sout << "Nom incorrect ou Selection " << arg1 << " pas Combine" << std::endl; + return IFSelect_RetFail; +} + +static IFSelect_ReturnStatus fun81 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** SelCombRem **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Donner n0 Combine et RANG a supprimer" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Selection, sel, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_Selection, inp, WS->NamedItem(arg2)); + if (WS->CombineRemove(sel, inp)) return IFSelect_RetDone; + sout << "Nom incorrect ou Selection " << arg1 << " ni Union ni Intersection" << std::endl; + return IFSelect_RetFail; +} + +static IFSelect_ReturnStatus fun82 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** SelEntNumber **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner Nom IntParam pour n0 Entite" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_IntParam, par, WS->NamedItem(arg1)); + Handle(IFSelect_SelectEntityNumber) sel = new IFSelect_SelectEntityNumber; + sel->SetNumber(par); + return pilot->RecordItem(sel); +} + +static IFSelect_ReturnStatus fun83 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelUnion **** + return pilot->RecordItem(new IFSelect_SelectUnion); +} + +static IFSelect_ReturnStatus fun84 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelIntersection **** + return pilot->RecordItem(new IFSelect_SelectIntersection); +} + +static IFSelect_ReturnStatus fun85 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** SelTextType Exact **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner le TYPE a selectionner" << std::endl; return IFSelect_RetError; } + return pilot->RecordItem(new IFSelect_SelectSignature + (new IFSelect_SignType, arg1, Standard_True)); +} + +static IFSelect_ReturnStatus fun86 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** SelErrorEntities **** + return pilot->RecordItem(new IFSelect_SelectErrorEntities); +} + +static IFSelect_ReturnStatus fun87 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** SelUnknownEntities ** + return pilot->RecordItem(new IFSelect_SelectUnknownEntities); +} + +static IFSelect_ReturnStatus fun88 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** SelSharing **** + return pilot->RecordItem(new IFSelect_SelectSharing); +} + +static IFSelect_ReturnStatus fun89 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** SelTextType Contain ** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner le TYPE a selectionner" << std::endl; return IFSelect_RetError; } + return pilot->RecordItem(new IFSelect_SelectSignature + (new IFSelect_SignType, arg1, Standard_False)); +} + +static IFSelect_ReturnStatus fun90 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // **** SelPointed **** + Handle(IFSelect_SelectPointed) sp = new IFSelect_SelectPointed; + if (pilot->NbWords() > 1) + { + Handle(TColStd_HSequenceOfTransient) list = XSDRAW_FunctionsSession::GiveList + (pilot->Session(), pilot->CommandPart(1)); + if (list.IsNull()) return IFSelect_RetFail; + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + sout << "SelectPointed : " << list->Length() << " entities" << std::endl; + sp->AddList(list); + } + return pilot->RecordItem(sp); +} + +static IFSelect_ReturnStatus fun91 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** SetPointed (edit) / SetList (edit) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Donner NOM SelectPointed + Option(s) :\n" + << " aucune : liste des entites pointees\n" + << " 0: Clear +nn ajout entite nn -nn enleve nn /nn toggle nn" << std::endl; + return IFSelect_RetError; + } + DeclareAndCast(IFSelect_SelectPointed, sp, WS->NamedItem(arg1)); + if (sp.IsNull()) { sout << "Pas une SelectPointed:" << arg1 << std::endl; return IFSelect_RetError; } + const Handle(Interface_InterfaceModel)& model = WS->Model(); // pour Print + if (argc == 2) + { // listage simple + Standard_Integer nb = sp->NbItems(); + sout << " SelectPointed : " << arg1 << " : " << nb << " Items :" << std::endl; + for (Standard_Integer i = 1; i <= nb; i++) + { + Handle(Standard_Transient) pointed = sp->Item(i); + Standard_Integer id = WS->StartingNumber(pointed); + if (id == 0) sout << " (inconnu)"; + else { sout << " "; model->Print(pointed, sout); } + } + if (nb > 0) sout << std::endl; + return IFSelect_RetDone; + } + + for (Standard_Integer ia = 2; ia < argc; ia++) + { + const TCollection_AsciiString argi = pilot->Word(ia); + Standard_Integer id = pilot->Number(&(argi.ToCString())[1]); + if (id == 0) + { + if (!argi.IsEqual("0")) sout << "Incorrect,ignore:" << argi << std::endl; + else { sout << "Clear SelectPointed" << std::endl; sp->Clear(); } + } + else if (argi.Value(1) == '-') + { + Handle(Standard_Transient) item = WS->StartingEntity(id); + if (sp->Remove(item)) sout << "Removed:no." << id; + else sout << " Echec Remove " << id; + sout << ": " << std::endl; + model->Print(item, sout); + } + else if (argi.Value(1) == '/') + { + Handle(Standard_Transient) item = WS->StartingEntity(id); + if (sp->Remove(item)) sout << "Toggled:n0." << id; + else sout << " Echec Toggle " << id; + sout << ": " << std::endl; + model->Print(item, sout); + } + else if (argi.Value(1) == '+') + { + Handle(Standard_Transient) item = WS->StartingEntity(id); + if (sp->Add(item)) sout << "Added:no." << id; + else sout << " Echec Add " << id; + sout << ": " << std::endl; + model->Print(item, sout); + } + else + { + sout << "Ignore:" << argi << " , donner n0 PRECEDE de + ou - ou /" << std::endl; + } + } + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun92 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelIncorrectEntities **** + WS->ComputeCheck(); + return pilot->RecordItem(new IFSelect_SelectIncorrectEntities); +} + +static IFSelect_ReturnStatus fun93 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SelSignature **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) { sout << "Give name of Signature or Counter, text + option exact(D) else contains" << std::endl; return IFSelect_RetError; } + Standard_Boolean exact = Standard_True; + if (argc > 3) { if (pilot->Arg(3)[0] == 'c') exact = Standard_False; } + + DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); + DeclareAndCast(IFSelect_SignCounter, cnt, WS->NamedItem(arg1)); + Handle(IFSelect_SelectSignature) sel; + + if (!sign.IsNull()) sel = new IFSelect_SelectSignature(sign, arg2, exact); + else if (!cnt.IsNull()) sel = new IFSelect_SelectSignature(cnt, arg2, exact); + else { sout << arg1 << ":neither Signature nor Counter" << std::endl; return IFSelect_RetError; } + + return pilot->RecordItem(sel); +} + +static IFSelect_ReturnStatus fun94 +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** SignCounter **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner nom signature" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_Signature, sign, WS->NamedItem(arg1)); + if (sign.IsNull()) { sout << arg1 << ":pas une signature" << std::endl; return IFSelect_RetError; } + Handle(IFSelect_SignCounter) cnt = new IFSelect_SignCounter(sign, Standard_True, Standard_True); + return pilot->RecordItem(cnt); +} + +static IFSelect_ReturnStatus funbselected +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + // **** NbSelected = GraphCounter **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) { sout << "Donner nom selection (deduction) a appliquer" << std::endl; return IFSelect_RetError; } + DeclareAndCast(IFSelect_SelectDeduct, applied, WS->GiveSelection(arg1)); + if (applied.IsNull()) { sout << arg1 << ":pas une SelectDeduct" << std::endl; return IFSelect_RetError; } + Handle(IFSelect_GraphCounter) cnt = new IFSelect_GraphCounter(Standard_True, Standard_True); + cnt->SetApplied(applied); + return pilot->RecordItem(cnt); +} + +// ######################################### +// #### EDITOR - EDITFORM #### +// ######################################### + +static IFSelect_ReturnStatus fun_editlist +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Give the name of an EditForm or an Editor" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + + // EditForm + + DeclareAndCast(IFSelect_EditForm, edf, WS->NamedItem(arg1)); + Handle(IFSelect_Editor) edt; + if (!edf.IsNull()) + { + sout << "Print EditForm " << arg1 << std::endl; + edt = edf->Editor(); + if (argc < 3) + { + + // DEFINITIONS : Editor (direct ou via EditForm) + + if (edt.IsNull()) edt = GetCasted(IFSelect_Editor, WS->NamedItem(arg1)); + if (edt.IsNull()) return IFSelect_RetVoid; + + sout << "Editor, Label : " << edt->Label() << std::endl; + sout << std::endl << " -- Names (short - complete) + Labels of Values" << std::endl; + edt->PrintNames(sout); + sout << std::endl << " -- Definitions --" << std::endl; + edt->PrintDefs(sout); + if (!edf.IsNull()) + { + edf->PrintDefs(sout); + sout << std::endl << "To display values, add an option : o original f final m modified" << std::endl; + } + + return IFSelect_RetVoid; + + } + else + { + char opt = arg2[0]; + Standard_Integer what = 0; + if (opt == 'o') what = -1; + else if (opt == 'f') what = 1; + + edf->PrintValues(sout, what, Standard_False); + } + } + + return IFSelect_RetVoid; +} + +static IFSelect_ReturnStatus fun_editvalue +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 3) + { + sout << "Give the name of an EditForm + name of Value [+ newvalue or . to nullify]" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + DeclareAndCast(IFSelect_EditForm, edf, WS->NamedItem(arg1)); + if (edf.IsNull()) + { + sout << "Not an EditForm : " << arg1 << std::endl; return IFSelect_RetError; + } + Standard_Integer num = edf->NameNumber(arg2); + if (num == 0) sout << "Unknown Value Name : " << arg2 << std::endl; + if (num < 0) sout << "Not Extracted Value Name : " << arg2 << std::endl; + if (num <= 0) return IFSelect_RetError; + + Standard_Boolean islist = edf->Editor()->IsList(num); + Standard_CString name = edf->Editor()->Name(num, Standard_True); // vrai nom + Handle(TColStd_HSequenceOfHAsciiString) listr; + Handle(TCollection_HAsciiString) str; + sout << "Value Name : " << name << (edf->IsModified(num) ? "(already edited) : " : " : "); + + if (islist) + { + listr = edf->EditedList(num); + if (listr.IsNull()) sout << "(NULL LIST)" << std::endl; + else + { + Standard_Integer ilist, nblist = listr->Length(); + sout << "(List : " << nblist << " Items)" << std::endl; + for (ilist = 1; ilist <= nblist; ilist++) + { + str = listr->Value(ilist); + sout << " [" << ilist << "] " << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + } + } + if (argc < 4) sout << "To Edit, options by editval edit-form value-name ?" << std::endl; + } + else + { + str = edf->EditedValue(num); + sout << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + } + if (argc < 4) return IFSelect_RetVoid; + + // Valeur simple ou liste ? + Standard_Integer numarg = 3; + str.Nullify(); + + const Standard_CString argval = pilot->Arg(numarg); + if (islist) + { + if (argval[0] == '?') + { + sout << "To Edit, options" << std::endl << " + val : add value at end (blanks allowed)" + << std::endl << " +nn text : insert val before item nn" << std::endl + << " nn text : replace item nn with a new value" << std::endl + << " -nn : remove item nn" << std::endl << " . : clear the list" << std::endl; + return IFSelect_RetVoid; + } + Standard_Boolean stated = Standard_False; + Handle(IFSelect_ListEditor) listed = edf->ListEditor(num); + if (listed.IsNull()) return IFSelect_RetError; + if (argval[0] == '.') { listr.Nullify(); stated = listed->LoadEdited(listr); } + else if (argval[0] == '+') + { + Standard_Integer numadd = 0; + if (argval[1] != '\0') numadd = atoi(argval); + stated = listed->AddValue(new TCollection_HAsciiString(pilot->CommandPart(numarg + 1)), numadd); + } + else if (argval[0] == '-') + { + Standard_Integer numrem = atoi(argval); + stated = listed->Remove(numrem); + } + else + { + Standard_Integer numset = atoi(argval); + if (numset > 0) stated = listed->AddValue + (new TCollection_HAsciiString(pilot->CommandPart(numarg + 1)), numset); + } + if (stated) stated = edf->ModifyList(num, listed, Standard_True); + if (stated) sout << "List Edition done" << std::endl; + else sout << "List Edition not done, option" << argval << std::endl; + } + else + { + if (argval[0] == '.' && argval[1] == '\0') str.Nullify(); + else str = new TCollection_HAsciiString(pilot->CommandPart(numarg)); + if (edf->Modify(num, str, Standard_True)) + { + sout << "Now set to " << (str.IsNull() ? "(NULL)" : str->ToCString()) << std::endl; + } + else + { + sout << "Modify not done" << std::endl; return IFSelect_RetFail; + } + } + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun_editclear +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Give the name of an EditForm [+ name of Value else all]" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + DeclareAndCast(IFSelect_EditForm, edf, WS->NamedItem(arg1)); + if (edf.IsNull()) + { + sout << "Not an EditForm : " << arg1 << std::endl; return IFSelect_RetError; + } + if (argc < 3) { edf->ClearEdit(); sout << "All Modifications Cleared" << std::endl; } + else + { + Standard_Integer num = edf->NameNumber(arg2); + if (num == 0) sout << "Unknown Value Name : " << arg2 << std::endl; + if (num < 0) sout << "Not Extracted Value Name : " << arg2 << std::endl; + if (num <= 0) return IFSelect_RetError; + if (!edf->IsModified(num)) + { + sout << "Value " << arg2 << " was not modified" << std::endl; return IFSelect_RetVoid; + } + edf->ClearEdit(num); + sout << "Modification on Value " << arg2 << " Cleared" << std::endl; + } + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun_editapply +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Give the name of an EditForm [+ option keep to re-apply edited values]" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + DeclareAndCast(IFSelect_EditForm, edf, WS->NamedItem(arg1)); + if (edf.IsNull()) + { + sout << "Not an EditForm : " << arg1 << std::endl; return IFSelect_RetError; + } + + Handle(Standard_Transient) ent = edf->Entity(); + Handle(Interface_InterfaceModel) model = edf->Model(); + if (!model.IsNull()) + { + if (ent.IsNull()) sout << "Applying modifications on loaded model" << std::endl; + else + { + sout << "Applying modifications on loaded entity : "; + model->PrintLabel(ent, sout); + } + } + else sout << "Applying modifications" << std::endl; + + if (!edf->ApplyData(edf->Entity(), edf->Model())) + { + sout << "Modifications could not be applied" << std::endl; + return IFSelect_RetFail; + } + sout << "Modifications have been applied" << std::endl; + + Standard_Boolean stat = Standard_True; + if (argc > 2 && arg2[0] == 'k') stat = Standard_False; + if (stat) + { + edf->ClearEdit(); + sout << "Edited values are cleared" << std::endl; + } + else sout << "Edited values are kept for another loading/applying" << std::endl; + + return IFSelect_RetDone; +} + +static IFSelect_ReturnStatus fun_editload +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Give the name of an EditForm [+ Entity-Ident]" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + Handle(IFSelect_WorkSession) WS = pilot->Session(); + DeclareAndCast(IFSelect_EditForm, edf, WS->NamedItem(arg1)); + if (edf.IsNull()) + { + sout << "Not an EditForm : " << arg1 << std::endl; return IFSelect_RetError; + } + + Standard_Integer num = (argc < 3 ? 0 : pilot->Number(arg2)); + Standard_Boolean stat = Standard_False; + if (argc < 3) + { + sout << "EditForm " << arg1 << " : Loading Model" << std::endl; + stat = edf->LoadModel(WS->Model()); + } + else if (num <= 0) + { + sout << "Not an entity ident : " << arg2 << std::endl; + return IFSelect_RetError; + } + else + { + sout << "EditForm " << arg1 << " : Loading Entity " << arg2 << std::endl; + stat = edf->LoadData(WS->StartingEntity(num), WS->Model()); + } + + if (!stat) + { + sout << "Loading not done" << std::endl; + return IFSelect_RetFail; + } + sout << "Loading done" << std::endl; + return IFSelect_RetDone; +} + +Handle(Standard_Transient) GiveEntity +(const Handle(IFSelect_WorkSession)& WS, + const Standard_CString name) +{ + Handle(Standard_Transient) ent; // demarre a Null + Standard_Integer num = GiveEntityNumber(WS, name); + if (num > 0) ent = WS->StartingEntity(num); + return ent; +} + +Standard_Integer GiveEntityNumber +(const Handle(IFSelect_WorkSession)& WS, + const Standard_CString name) +{ + Standard_Integer num = 0; + if (!name || name[0] == '\0') + { + char ligne[80]; ligne[0] = '\0'; + std::cin >> ligne; + // std::cin.clear(); std::cin.getline (ligne,79); + if (ligne[0] == '\0') return 0; + num = WS->NumberFromLabel(ligne); + } + else num = WS->NumberFromLabel(name); + return num; +} + +void XSDRAW_FunctionsSession::Init() +{ + static int THE_XSDRAW_FunctionsSession_initactor = 0; + if (THE_XSDRAW_FunctionsSession_initactor) + { + return; + } + + THE_XSDRAW_FunctionsSession_initactor = 1; + IFSelect_Act::SetGroup("DE: General"); + IFSelect_Act::AddFunc("xstatus", "Lists XSTEP Status : Version, System Name ...", funstatus); + IFSelect_Act::AddFunc("handler", "Toggle status catch Handler Error of the session", fun1); + IFSelect_Act::AddFunc("xload", "file:string : Read File -> Load Model", fun3); + IFSelect_Act::AddFunc("xread", "file:string : Read File -> Load Model", fun3); + IFSelect_Act::AddFunc("writeall", "file:string : Write all model (no split)", fun4); + IFSelect_Act::AddFunc("writesel", "file:string sel:Selection : Write Selected (no split)", fun5); + IFSelect_Act::AddFunc("writeent", "file:string n1ent n2ent...:integer : Write Entite(s) (no split)", fun6); + IFSelect_Act::AddFunc("writent", "file:string n1ent n2ent...:integer : Write Entite(s) (no split)", fun6); + IFSelect_Act::AddFunc("elabel", "nument:integer : Displays Label Model of an entity", fun7); + IFSelect_Act::AddFunc("enum", "label:string : Displays entities n0.s of which Label Model ends by..", fun8); + + IFSelect_Act::AddFunc("listtypes", "List nb entities per type. Optional selection name else all model", fun9); + IFSelect_Act::AddFunc("count", "Count : counter [selection]", funcount); + IFSelect_Act::AddFunc("listcount", "List Counted : counter [selection [nument]]", funcount); + IFSelect_Act::AddFunc("sumcount", "Summary Counted : counter [selection [nument]]", funcount); + IFSelect_Act::AddFunc("signtype", "Sign Type [newone]", funsigntype); + IFSelect_Act::AddFunc("signcase", "signature : displays possible cases", funsigncase); + + IFSelect_Act::AddFunc("estatus", "ent/nument : displays status of an entity", fun10); + IFSelect_Act::AddFunc("data", "Data (DumpModel); whole help : data tout court", fun11); + IFSelect_Act::AddFunc("entity", "give n0 ou id of entity [+ level]", fundumpent); + IFSelect_Act::AddFunc("signature", "signature name + n0/ident entity", funsign); + IFSelect_Act::AddFunc("queryparent", " give 2 n0s/labels of entities : dad son", funqp); + + IFSelect_Act::AddFunc("dumpshare", "Dump Share (dispatches, IntParams)", fun12); + IFSelect_Act::AddFunc("listitems", "List Items [label else all] ->Type,Label[,Name]", fun13); + IFSelect_Act::AddFSet("integer", "value:integer : cree un IntParam", fun14); + IFSelect_Act::AddFunc("setint", "name:IntParam newValue:integer : Change valeur IntParam", fun15); + IFSelect_Act::AddFSet("text", "value:string : cree un TextParam", fun16); + IFSelect_Act::AddFunc("settext", "Name:TextParam newValue:string : Change valeur TextParam", fun17); + IFSelect_Act::AddFunc("dumpsel", "Dump Selection suivi du Nom de la Selection a dumper", fun19); + IFSelect_Act::AddFunc("evalsel", "name:Selection [num/sel] : Evalue une Selection", fun20); + IFSelect_Act::AddFunc("givelist", "num/sel [num/sel ...] : Evaluates GiveList", fun20); + IFSelect_Act::AddFunc("giveshort", "num/sel [num/sel ...] : GiveList in short form", fun20); + IFSelect_Act::AddFunc("givepointed", "num/sel [num/sel ...] : GiveList to fill a SelectPointed", fun20); + IFSelect_Act::AddFunc("makelist", "listname [givelist] : Makes a List(SelectPointed) from GiveList", fun20); + IFSelect_Act::AddFunc("givecount", "num/sel [num/sel ...] : Counts GiveList", fun20c); + IFSelect_Act::AddFSet("selsuite", "sel sel ... : Creates a SelectSuite", funselsuite); + IFSelect_Act::AddFunc("clearitems", "Clears all items (selections, dispatches, etc)", fun21); + IFSelect_Act::AddFunc("cleardata", "mode:a-g-c-p : Clears all or some data (model, check...)", fun22); + + IFSelect_Act::AddFunc("itemlabel", "xxx xxx : liste items having this label", fun24); + IFSelect_Act::AddFunc("xsave", "filename:string : sauve items-session", fun25); + IFSelect_Act::AddFunc("xrestore", "filename:string : restaure items-session", fun26); + IFSelect_Act::AddFunc("param", "[-p Pattern] - displays all parameters or filtered by pattern;\n" + "par_name - displays parameter;\n" + "par_name par_value - changes parameter's value", fun27); + + IFSelect_Act::AddFunc("sentfiles", "Lists files sent from last Load", fun29); + IFSelect_Act::AddFunc("fileprefix", "prefix:string : definit File Prefix", fun30); + IFSelect_Act::AddFunc("fileext", "extent:string : definit File Extension", fun31); + IFSelect_Act::AddFunc("fileroot", "disp:Dispatch root:string : definit File Root sur un Dispatch", fun32); + IFSelect_Act::AddFunc("filedef", "defroot:string : definit File DefaultRoot", fun33); + IFSelect_Act::AddFunc("evalfile", "Evaluation du FileNaming et memorisation", fun34); + IFSelect_Act::AddFunc("clearfile", "Efface la liste d'EvalFile", fun35); + IFSelect_Act::AddFunc("xsplit", "[disp:Dispatch sinon tout] : Split, la grande affaire !", fun36); + IFSelect_Act::AddFunc("remaining", "options... : Remaining Entities, help complet par remaining ?", fun37); + IFSelect_Act::AddFunc("setcontent", "sel:Selection mode:k ou r : Restreint contenu du modele", fun38); + + IFSelect_Act::AddFunc("listmodif", "List Final Modifiers", fun40); + IFSelect_Act::AddFunc("dumpmodif", "modif:Modifier : Affiche le Statut d'un Modifier", fun41); + IFSelect_Act::AddFunc("modifsel", "modif:Modifier [sel:Selection] : Change/Annule Selection de Modifier", fun42); + IFSelect_Act::AddFunc("setapplied", "modif:Modifier [name:un item sinon sortie fichier] : Applique un Modifier", fun43); + IFSelect_Act::AddFunc("resetapplied", "modif:Modifier : Enleve un Modifier de la sortie fichier", fun44); + IFSelect_Act::AddFunc("modifmove", "modif:Modifier M(model)/F(file) avant,apres:integer : Deplace un Modifier (sortie fichier)", fun45); + + IFSelect_Act::AddFunc("dispsel", "disp:Dispatch sel:Selection -> Selection Finale de Dispatch", fun51); + IFSelect_Act::AddFSet("dispone", "cree DispPerOne", fun_dispone); + IFSelect_Act::AddFSet("dispglob", "cree DispGlobal", fun_dispglob); + IFSelect_Act::AddFSet("dispcount", "count:IntParam : cree DispPerCount", fun_dispcount); + IFSelect_Act::AddFSet("dispfile", "files:IntParam : cree DispPerFiles", fun_dispfiles); + IFSelect_Act::AddFSet("dispsign", "sign:Signature : cree DispPerSignature", fun_dispsign); + IFSelect_Act::AddFunc("dumpdisp", "disp:Dispatch : Affiche le Statut d'un Dispatch", fun56); + + IFSelect_Act::AddFunc("xremove", "nom : Remove a Control Item de la Session", fun57); + IFSelect_Act::AddFunc("evaldisp", "mode=[0-3] disp:Dispatch : Evaluates one or more Dispatch(es)", fun58); + IFSelect_Act::AddFunc("evaladisp", "mode=[0-3] disp:Dispatch [givelist] : Evaluates a Dispatch (on a GiveList)", fun_evaladisp); + IFSelect_Act::AddFunc("writedisp", "filepattern disp:Dispatch [givelist] : Writes Entities by Splitting by a Dispatch", fun_writedisp); + IFSelect_Act::AddFunc("evalcomplete", "Evaluation Complete de la Repartition", fun59); + + IFSelect_Act::AddFunc("runcheck", "affiche LastRunCheckList (write,modif)", fun60); + IFSelect_Act::AddFunc("runtranformer", "transf:Transformer : Applique un Transformer", fun61); + IFSelect_Act::AddFSet("copy", "cree TransformStandard, option Copy, vide", fun62); + IFSelect_Act::AddFSet("onthespot", "cree TransformStandard, option OntheSpot, vide", fun63); + IFSelect_Act::AddFunc("runcopy", "modif:ModelModifier [givelist] : Run via TransformStandard option Copy", fun6465); + IFSelect_Act::AddFunc("runonthespot", "modif:ModelModifier [givelist] : Run via TransformStandard option OnTheSpot", fun6465); + IFSelect_Act::AddFSet("reorder", "[f ou t] reordonne le modele", fun66); + + IFSelect_Act::AddFunc("toggle", "sel:Selection genre Extract : Toggle Direct/Reverse", fun70); + IFSelect_Act::AddFunc("input", "sel:Selection genre Deduct ou Extract input:Selection : Set Input", fun71); + IFSelect_Act::AddFSet("modelroots", "cree SelectModelRoots", fun72); + IFSelect_Act::AddFSet("range", "options... : cree SelectRange ...; tout court pour help", fun73); + IFSelect_Act::AddFSet("roots", "cree SelectRoots (local roots)", fun74); + IFSelect_Act::AddFSet("shared", "cree SelectShared", fun75); + IFSelect_Act::AddFSet("diff", "[main:Selection diff:Selection] : cree SelectDiff", fun76); + IFSelect_Act::AddFunc("selmain", "sel:Selection genre Control main:Selection : Set Main Input", fun77); + IFSelect_Act::AddFunc("selsecond", "sel:Selection genre Control sec:Selection : Set Second Input", fun78); + IFSelect_Act::AddFSet("modelall", "cree SelectModelAll", fun79); + IFSelect_Act::AddFunc("seladd", "sel:Selection genre Combine input:Selection : Add Selection", fun80); + IFSelect_Act::AddFunc("selrem", "sel:Selection genre Combine input:Selection : Remove Selection", fun81); + IFSelect_Act::AddFSet("number", "num:IntParam : Cree SelectEntityNumber", fun82); + + IFSelect_Act::AddFSet("union", "cree SelectUnion (vide), cf aussi combadd, combrem", fun83); + IFSelect_Act::AddFSet("intersect", "cree SelectIntersection (vide), cf aussi combadd, combrem", fun84); + IFSelect_Act::AddFSet("typexact", "type:string : cree SelectTextType Exact", fun85); + IFSelect_Act::AddFSet("errors", "cree SelectErrorEntities (from file)", fun86); + IFSelect_Act::AddFSet("unknown", "cree SelectUnknownEntities", fun87); + IFSelect_Act::AddFSet("sharing", "cree SelectSharing", fun88); + IFSelect_Act::AddFSet("typecontain", "type:string : cree SelectTextType Contains", fun89); + IFSelect_Act::AddFSet("pointed", "cree SelectPointed [num/sel num/sel]", fun90); + IFSelect_Act::AddFunc("setpointed", "sel:SelectPointed : edition SelectPointed. tout court pour help", fun91); + IFSelect_Act::AddFunc("setlist", "sel:SelectPointed : edition SelectPointed. tout court pour help", fun91); + IFSelect_Act::AddFSet("incorrect", "cree SelectIncorrectEntities (computed)", fun92); + + IFSelect_Act::AddFSet("signsel", "sign:Signature|cnt:Counter text:string [e(D)|c] : cree SelectSignature", fun93); + IFSelect_Act::AddFSet("signcounter", "sign:Signature : cree SignCounter", fun94); + IFSelect_Act::AddFSet("nbselected", "applied:Selection : cree GraphCounter(=NbSelected)", funbselected); + + IFSelect_Act::AddFunc("editlist", "editor or editform : lists defs + values", fun_editlist); + IFSelect_Act::AddFunc("editvalue", "editform paramname [newval or .] : lists-changes a value", fun_editvalue); + IFSelect_Act::AddFunc("editclear", "editform [paramname] : clears edition on all or one param", fun_editclear); + IFSelect_Act::AddFunc("editload", "editform [entity-id] : loads from model or an entity", fun_editload); + IFSelect_Act::AddFunc("editapply", "editform [keep] : applies on loaded data", fun_editapply); +} diff --git a/src/XSControl/XSControl_Functions.hxx b/src/XSDRAW/XSDRAW_FunctionsSession.hxx similarity index 55% rename from src/XSControl/XSControl_Functions.hxx rename to src/XSDRAW/XSDRAW_FunctionsSession.hxx index 3e959430bb..855c945063 100644 --- a/src/XSControl/XSControl_Functions.hxx +++ b/src/XSDRAW/XSDRAW_FunctionsSession.hxx @@ -1,7 +1,4 @@ -// Created on: 1996-03-26 -// Created by: Christian CAILLET -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -14,20 +11,25 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _XSControl_Functions_HeaderFile -#define _XSControl_Functions_HeaderFile +#ifndef _XSDRAW_FunctionsSession_HeaderFile +#define _XSDRAW_FunctionsSession_HeaderFile -//! Functions from XSControl gives access to actions which can be -//! commanded with the resources provided by XSControl: especially -//! Controller and Transfer +#include +#include +#include + +//! Functions gives access to all the actions which can be +//! commanded with the resources provided by IFSelect : especially +//! WorkSession and various types of Selections and Dispatches //! //! It works by adding functions by method Init -class XSControl_Functions +class XSDRAW_FunctionsSession { - public: + DEFINE_STANDARD_ALLOC +public: - //! Defines and loads all functions for XSControl (as ActFunc) + //! Defines and loads all basic functions (as ActFunc) Standard_EXPORT static void Init(); }; -#endif // _XSControl_Functions_HeaderFile +#endif // _XSDRAW_FunctionsSession_HeaderFile diff --git a/src/XSDRAW/XSDRAW_FunctionsShape.cxx b/src/XSDRAW/XSDRAW_FunctionsShape.cxx new file mode 100644 index 0000000000..0e6b8f4267 --- /dev/null +++ b/src/XSDRAW/XSDRAW_FunctionsShape.cxx @@ -0,0 +1,780 @@ +// 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 +#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 + +//======================================================================= +//function : XSControl_tpdraw +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpdraw +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + const Standard_CString arg3 = pilot->Arg(3); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TP.IsNull()) { sout << "No Transfer Read" << std::endl; return IFSelect_RetError; } + // **** tpdraw **** + if (argc < 2) + { + sout << "Donner [mode facultatif : item ou root] , NUMERO , nom DRAW facultatif" << std::endl; + sout << " mode si present : item ou root, sinon n0 d entite modele" << std::endl; + sout << " NUMERO entier : d entite, d item transfert ou de root transfert\n" + << " ou * pour dire tous" << std::endl; + return IFSelect_RetError; + } + Standard_Integer mode = 0, num = 0; + if (arg1[0] == 'i') mode = 1; + else if (arg1[0] == 'r') mode = 2; + Standard_Boolean tout = Standard_False; + if (mode == 0) + { + if (argc < 2) { sout << "Donner au moins un NUMERO ou *" << std::endl; return IFSelect_RetError; } + if (arg1[0] == '*') tout = Standard_True; + else num = IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot), arg1); + } + else + { + if (arg2[0] == '*') tout = Standard_True; + else num = IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot), arg2); + } + + Standard_Integer nbvar = 0; + Handle(Transfer_Binder) binder; + Handle(Standard_Transient) ent; + TopoDS_Shape sh; char nomvar[40]; + // Standard_Boolean moderoot = (pilot->Word(0).Value(3) == 'r'); + + Standard_Integer n1, n2, i, max = 0, index = 0; + Handle(Interface_InterfaceModel) model = TP->Model(); + if (model.IsNull()) + { + if (mode == 0) + { + sout << "Pas de modele, preciser n0 d item de transfert" << std::endl; + return IFSelect_RetError; + } + } + if (mode == 0) { sout << "Entite de modele"; max = model->NbEntities(); } + if (mode == 1) { sout << "Item de transfert"; max = TP->NbMapped(); } + if (mode == 2) { sout << "Racine de transfert"; max = TP->NbRoots(); } + if (tout) + { + n1 = 1; n2 = max; + sout << ", listage de 1 a " << max << std::endl; + } + else if (num <= 0 || num > max) + { + sout << " - Num=" << num << " hors limite (de 1 a " << max << ")" << std::endl; + return IFSelect_RetError; + } + else + { + n1 = n2 = num; nbvar = -1; // nbvar : 1ere shape simple = pas de n0 + sout << ", n0 " << num << std::endl; + } + + for (i = n1; i <= n2; i++) + { + if (mode == 0) + { + ent = model->Value(i); + num = i; + index = TP->MapIndex(ent); + } + else if (mode == 1) + { + ent = TP->Mapped(i); + if (model.IsNull()) num = 0; + else num = model->Number(ent); + index = i; + } + else if (mode == 2) + { + ent = TP->Root(i); + if (model.IsNull()) num = 0; + else num = model->Number(ent); + index = TP->MapIndex(ent); + } + + if (index > 0) binder = TP->MapItem(index); + if (binder.IsNull()) index = 0; + if (index == 0) + { + if (!tout) sout << "Entite n0 " << num << " : non repertoriee" << std::endl; + continue; + } + if (!binder->HasResult()) + { + if (!tout) sout << "Entite n0 " << num << " : pas de resultat" << std::endl; + continue; + } + sh = TransferBRep::ShapeResult(binder); + //DeclareAndCast(TransferBRep_ShapeBinder,shb,binder); + if (!sh.IsNull()) + { + //sh = shb->Result(); + nbvar++; + if (sh.IsNull()) { sout << " (no Shape recorded)" << std::endl; continue; } + if (tout) sout << "[ " << i << " ]:"; + if (num == 0) sout << " pas dans le modele"; + else sout << " ent.n0 " << num; + sout << ", item transfert n0 " << index; + if (nbvar == 0) + { + if (argc > 3 && mode > 0) sprintf(nomvar, "%s", arg3); + else if (argc > 2 && mode == 0) sprintf(nomvar, "%s", arg2); + else sprintf(nomvar, "tp_%d", i); + } + else + { + if (argc > 3 && mode > 0) sprintf(nomvar, "%s_%d", arg3, nbvar); + else if (argc > 2 && mode == 0) sprintf(nomvar, "%s_%d", arg2, nbvar); + else sprintf(nomvar, "tp_%d", i); + } + sout << " -> 1 DRAW Shape: " << nomvar << std::endl; + XSControl::Vars(pilot)->SetShape(nomvar, sh); + continue; + } + DeclareAndCast(TransferBRep_ShapeListBinder, slb, binder); + if (!slb.IsNull()) + { + Standard_Integer nbs = slb->NbShapes(); + if (tout) sout << "[ " << i << " ]:"; + if (num == 0) sout << " pas dans le modele"; + else sout << " ent.n0 " << num; + sout << ", item transfert n0 " << index; + sout << " -> " << nbs << " DRAW Shapes :"; + for (Standard_Integer j = 1; j <= nbs; j++) + { + sh = slb->Shape(j); if (nbvar < 0) nbvar = 0; nbvar++; + if (sh.IsNull()) { sout << " (no Shape recorded)" << std::endl; continue; } + if (argc > 3 && mode > 0) sprintf(nomvar, "%s_%d", arg3, nbvar); + else if (argc > 2 && mode == 0) sprintf(nomvar, "%s_%d", arg2, nbvar); + else sprintf(nomvar, "tp_%d_%d", i, nbvar); + sout << " " << nomvar; + XSControl::Vars(pilot)->SetShape(nomvar, sh); + } + sout << std::endl; + continue; + } + DeclareAndCast(Transfer_SimpleBinderOfTransient, trb, binder); + if (!trb.IsNull()) + { + Handle(Standard_Transient) resu = trb->Result(); + if (resu.IsNull()) + { + sout << "Entite n0 " << num << " : pas de resultat" << std::endl; + continue; + } + DeclareAndCast(Geom_Geometry, geom, resu); + sout << "Entite n0 " << num << " : resultat " << resu->DynamicType()->Name(); + if (geom.IsNull()) { sout << std::endl; continue; } + nbvar++; + if (nbvar == 0) + { + if (argc > 3 && mode > 0) sprintf(nomvar, "%s", arg3); + else if (argc > 2 && mode == 0) sprintf(nomvar, "%s", arg2); + else sprintf(nomvar, "tp_%d", i); + } + else + { + if (argc > 3 && mode > 0) sprintf(nomvar, "%s_%d", arg3, nbvar); + else if (argc > 2 && mode == 0) sprintf(nomvar, "%s_%d", arg2, nbvar); + else sprintf(nomvar, "tp_%d", i); + } + char* nomv = nomvar; + XSControl::Vars(pilot)->Set(nomv, geom); + sout << " -> DRAW Geom : " << nomvar << std::endl; + continue; + } + + if (sh.IsNull() && trb.IsNull()) + if (!tout) sout << "Entite n0 " << num << " : resultat pas une Shape mais " << binder->ResultTypeName() << std::endl; + } + + if (sh.IsNull()) sout << " (No Shape)" << std::endl; + return IFSelect_RetDone; +} + +//======================================================================= +//function : XSControl_tpcompound +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_tpcompound +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TP.IsNull()) { sout << "No Transfer Read" << std::endl; return IFSelect_RetError; } + // **** tpcompound **** + if (argc < 2) { sout << "Give a NAME for the Compound + optional givelist, else roots are taken" << std::endl; return IFSelect_RetError; } + Handle(TopTools_HSequenceOfShape) list; + if (argc == 2) list = TransferBRep::Shapes(TP); + else + { + Handle(TColStd_HSequenceOfTransient) lise = IFSelect_Functions::GiveList(pilot->Session(), pilot->CommandPart(2)); + if (lise.IsNull()) { sout << "Not a valid entity list : " << pilot->CommandPart(2) << std::endl; return IFSelect_RetError; } + list = TransferBRep::Shapes(TP, lise); + sout << lise->Length() << " Entities, "; + } + if (list.IsNull()) { sout << "No Shape listed" << std::endl; return IFSelect_RetError; } + Standard_Integer nb = list->Length(); + sout << nb << " Shape(s) listed" << std::endl; + TopoDS_Compound C; + BRep_Builder B; + B.MakeCompound(C); + for (Standard_Integer i = 1; i <= nb; i++) B.Add(C, list->Value(i)); + XSControl::Vars(pilot)->SetShape(arg1, C); + return IFSelect_RetDone; +} + +//======================================================================= +//function : XSControl_traccess +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_traccess +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + // **** trdraw : TransferReader **** 26 + // **** trsave : TransferReader **** 27 + // **** trcomp (comp -> DRAW) **** 28 + // **** trscomp (comp -> save) **** 29 + Standard_Boolean cascomp = (pilot->Word(0).Location(1, 'o', 1, 5) > 0); + Standard_Boolean cassave = (pilot->Word(0).Location(1, 's', 1, 5) > 0); + TCollection_AsciiString nomsh, noms; + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TR.IsNull()) { sout << " manque init" << std::endl; return IFSelect_RetError; } + const Handle(Interface_InterfaceModel)& mdl = TR->Model(); + if (mdl.IsNull()) { sout << " modele absent" << std::endl; return IFSelect_RetError; } + Standard_Integer num = (argc > 1 ? IFSelect_Functions::GiveEntityNumber(XSControl::Session(pilot), arg1) : 0); + + if (argc > 1) nomsh = arg1; + else nomsh = cascomp ? "TREAD_COMP" : "TREAD_LIST"; + if (cassave) sout << " save shapes -> current directory" << std::endl; + + if (num == 0 || cascomp) + { + TopoDS_Compound C; // pour cas compound + BRep_Builder B; + B.MakeCompound(C); + + const Handle(TopTools_HSequenceOfShape)& list = TR->ShapeResultList(Standard_True); + sout << " TOUS RESULTATS par ShapeResultList, soit " << list->Length() << std::endl; + for (Standard_Integer i = 1, nb = list->Length(); i <= nb; ++i) + { + noms = nomsh + "_" + i; + if ((i % 1000) == 0) sout << "(" << i << ")" << std::endl; + else if ((i % 100) == 0) sout << "*"; + else if ((i % 10) == 0) sout << "0"; + else sout << "."; + if (list->Value(i).IsNull()) continue; + if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape(noms.ToCString(), list->Value(i)); + else if (!cascomp && cassave) BRepTools::Write(list->Value(i), noms.ToCString()); + else if (cascomp) B.Add(C, list->Value(i)); + } + sout << std::endl; + if (cascomp && !cassave) XSControl::Vars(pilot)->SetShape(nomsh.ToCString(), C); + else if (cascomp && cassave) BRepTools::Write(C, nomsh.ToCString()); + } + else + { + if (num < 1 || num > mdl->NbEntities()) { sout << " incorrect:" << arg1 << std::endl; return IFSelect_RetError; } + TopoDS_Shape sh = TR->ShapeResult(mdl->Value(num)); + if (sh.IsNull()) { sout << " Pas de resultat pour " << arg1 << std::endl; return IFSelect_RetError; } + if (argc > 2) nomsh = arg2; + else nomsh = TCollection_AsciiString("TREAD_") + num; + if (!cascomp && !cassave) XSControl::Vars(pilot)->SetShape(nomsh.ToCString(), sh); + else if (!cascomp && cassave) BRepTools::Write(sh, nomsh.ToCString()); + else sout << "Option non comprise" << std::endl; + } + return IFSelect_RetDone; +} + +//======================================================================= +//function : XSControl_IsEqualSubShape +//purpose : +//======================================================================= +// PTV 23.08.2000 Added for checking where are an entity from. +static Standard_Boolean XSControl_IsEqualSubShape(const TopoDS_Shape& Shape, + TopoDS_Shape& sh, Standard_Integer aLevel) +{ + if (sh.IsSame(Shape)) return Standard_True; + if (aLevel > 0) + { + TopoDS_Shape varShape; + aLevel--; + TopoDS_Iterator it(sh); + for (; it.More(); it.Next()) + { + varShape = it.Value(); + if (XSControl_IsEqualSubShape(Shape, varShape, aLevel)) return Standard_True; + } + } + return Standard_False; +} + +//======================================================================= +//function : XSControl_fromshape +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_fromshape +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** fromshape (tread) **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 2) + { + sout << "Give name of a DRAW Shape" << std::endl; + return IFSelect_RetError; + } + const char* a1 = (char*)arg1; + TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(a1); + if (Shape.IsNull()) + { + sout << "Not a DRAW Shape:" << arg1 << std::endl; + return IFSelect_RetError; + } + Standard_Boolean yena = Standard_False; + Standard_Integer aLevel = 1; + if (argc >= 3) + aLevel = atoi(pilot->Arg(2)); + Standard_Boolean silent = Standard_False; + if (aLevel < 0) + { + silent = Standard_True; + aLevel = -aLevel; + } + + // IMPORT + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + if (TR.IsNull()) {} // sout<<"No read transfer (import) recorded"<EntityFromShapeResult(Shape, modrec); + if (ent.IsNull()) + { + modrec = -1; + ent = TR->EntityFromShapeResult(Shape, modrec); + } + if (ent.IsNull()) + { + modrec = 2; + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + if (TP.IsNull()) + { + if (silent) + sout << "Shape " << arg1 << " : "; + sout << "no map" << std::endl; + } + else + { + TopoDS_Shape S0 = Shape; + TopLoc_Location L; + S0.Location(L); + Standard_Integer i, nb = TP->NbMapped(); + if (!silent) sout << "searching in map among " << nb << " ..."; + for (i = 1; i <= nb; i++) + { + ent = TP->Mapped(i); + TopoDS_Shape sh = TransferBRep::ShapeResult(TP, ent); + if (sh.IsNull()) + { + ent.Nullify(); + continue; + } + if (XSControl_IsEqualSubShape(Shape, sh, aLevel)) break; + modrec = -2; + sh.Location(L); + if (XSControl_IsEqualSubShape(S0, sh, aLevel)) break; + ent.Nullify(); + modrec = 2; + } + } + } + if (!ent.IsNull()) + { + if (silent) sout << "Shape " << arg1 << ": "; + if (modrec < 0) sout << "(moved from origin) "; + //else sout<<"(origin) "; + } + // on affiche + if (ent.IsNull()) + { + if (!silent) sout << " unknown as imported"; + // skl 11.05.2004 + // if Shape is a compound try to make "fromshape" for its subshapes + if (Shape.ShapeType() == TopAbs_COMPOUND) + { + sout << std::endl << "Subshapes imported from entities:"; + TopoDS_Iterator Iter(Shape); + for (; Iter.More(); Iter.Next()) + { + TopoDS_Shape subsh = Iter.Value(); + Standard_Integer submodrec = 1; + Handle(Standard_Transient) subent = TR->EntityFromShapeResult(subsh, submodrec); + if (subent.IsNull()) + { + submodrec = -1; + subent = TR->EntityFromShapeResult(subsh, submodrec); + } + if (!subent.IsNull()) + { + sout << " " << XSControl::Session(pilot)->Model()->Number(subent); + } + } + } + } + else + { + sout << "imported from entity "; + XSControl::Session(pilot)->Model()->Print(ent, sout); + if (silent) sout << " in file " << XSControl::Session(pilot)->LoadedFile() << std::endl; + } + if (!silent) sout << std::endl; + } + + // ET EN EXPORT ? + const Handle(Transfer_FinderProcess)& FP = XSControl::Session(pilot)->TransferWriter()->FinderProcess(); + if (FP.IsNull()) {} + else + { + yena = Standard_True; + Handle(Transfer_Finder) fnd = TransferBRep::ShapeMapper(FP, Shape); + Handle(Standard_Transient) ent; + if (!fnd.IsNull()) ent = FP->FindTransient(fnd); + if (!ent.IsNull()) + { + sout << "Shape " << arg1 << ": exported to entity "; + XSControl::Session(pilot)->Model()->Print(ent, sout); + if (silent) sout << " in file " << XSControl::Session(pilot)->LoadedFile(); + sout << std::endl; + } + // abv 31.08.00: treat case of split shape (several results) + // it is supposed that results are of the same type and lie in one-level comp + else + { + Handle(Transfer_Binder) bnd = FP->Find(fnd); + if (!bnd.IsNull()) + { + Handle(Transfer_TransientListBinder) TransientListBinder = + //Handle(Transfer_TransientListBinder)::DownCast( bnd->Next(Standard_True) ); //skl + Handle(Transfer_TransientListBinder)::DownCast(bnd); //skl + if (!TransientListBinder.IsNull()) + { + Standard_Integer i = 1, nb = TransientListBinder->NbTransients(); + if (nb > 0) sout << "Shape " << arg1 << ": exported to entities "; + for (; i <= nb; i++) + { + XSControl::Session(pilot)->Model()->Print(TransientListBinder->Transient(i), sout); + if (i < nb) sout << ", "; + } + if (nb > 0) + { + if (silent) sout << " in file " << XSControl::Session(pilot)->LoadedFile(); + sout << std::endl; + } + } + /* else { + TopoDS_Shape comp = TransferBRep::ShapeResult(bnd); + if ( ! comp.IsNull() && comp.ShapeType() < Shape.ShapeType() ) { + Standard_Boolean start = Standard_True; + for ( TopoDS_Iterator it(comp); it.More(); it.Next() ) { + Handle(Transfer_Finder) cfnd = TransferBRep::ShapeMapper (FP,it.Value()); + if ( cfnd.IsNull() ) continue; + Handle(Standard_Transient) cent = FP->FindTransient (cfnd); + if ( cent.IsNull() ) continue; + if ( start ) + sout<<"Shape "<Model()->Print(cent,sout); + } + if ( ! start ) sout<NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** connected entities (last transfer) **** + const Handle(XSControl_TransferReader)& TR = XSControl::Session(pilot)->TransferReader(); + Handle(Transfer_TransientProcess) TP; + if (!TR.IsNull()) TP = TR->TransientProcess(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (TP.IsNull()) { sout << "no transfer map" << std::endl; return IFSelect_RetVoid; } + if (argc < 2) + { + sout << "Give name of a DRAW Shape + optional shape type v-e-w-f(D)-s" << std::endl; + return IFSelect_RetError; + } + const char* a1 = (const char*)arg1; + TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(a1); + if (Shape.IsNull()) { sout << "Not a DRAW Shape:" << arg1 << std::endl; return IFSelect_RetError; } + sout << "Shape " << arg1 << " : "; + + Handle(TColStd_HSequenceOfTransient) list = + XSControl_ConnectedShapes::AdjacentEntities(Shape, TP, TopAbs_FACE); + Standard_Integer i, nb = list->Length(); + sout << nb << " Entities produced Connected Shapes :" << std::endl; + const Handle(Interface_InterfaceModel)& model = XSControl::Session(pilot)->Model(); + sout << "("; + for (i = 1; i <= nb; i++) + { + if (i > 1) sout << ","; + sout << model->Number(list->Value(i)); + } + sout << ")" << std::endl; + return IFSelect_RetDone; +} + +//======================================================================= +//function : XSControl_trimport +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_trimport +(const Handle(IFSelect_SessionPilot)& pilot) +{ + // FileName ou . (pour courant) VarName GiveList (obligatoire) + // GiveList : * pour xst-transferrable-roots + Handle(XSControl_WorkSession) WS = XSControl::Session(pilot); + + Standard_Integer argc = pilot->NbWords(); + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + if (argc < 4) + { + sout << "Give : filename or . for current model; varname or . to take fileroot\n GiveList, * for all transferrable roots" << std::endl; + return IFSelect_RetError; + } + const Standard_CString arg1 = pilot->Arg(1); + const Standard_CString arg2 = pilot->Arg(2); + const Standard_CString arg3 = pilot->Arg(3); + + // File Name and Variable (root) Name + + TCollection_AsciiString fnom, rnom; + Standard_Boolean modfic = XSDRAW_FunctionsShape::FileAndVar + (WS, arg1, arg2, "IMPORT", fnom, rnom); + if (modfic) sout << " File to read : " << fnom << std::endl; + else sout << " Model taken from the session : " << fnom << std::endl; + sout << " -- Names of variables BREP-DRAW prefixed by : " << rnom << std::endl; + + // keep the current command, because sub-commands will be called + TCollection_AsciiString compart = pilot->CommandPart(3); + + // Reading file if required + + if (modfic) + { + TCollection_AsciiString comload("xload "); + comload.AssignCat(arg1); + IFSelect_ReturnStatus status = pilot->Execute(comload); + if (status != IFSelect_RetDone) + { + sout << "Abandon import" << std::endl; return status; + } + } + else + { + sout << "Currently Loaded Model" << std::endl; + } + + // Selecting Entities + + Handle(TColStd_HSequenceOfTransient) list; + if (arg3[0] == '*' && arg3[1] == '\0') + { + list = WS->GiveList("xst-transferrable-roots"); + sout << "All Transferrable Roots : "; + } + else + { + sout << "List given by " << compart.ToCString() << " : "; + list = WS->GiveList(compart.ToCString()); + } + if (list.IsNull()) { sout << "No list defined. Abandon" << std::endl; return IFSelect_RetError; } + Standard_Integer nbl = list->Length(); + sout << "Nb entities selected : " << nbl << std::endl; + + // Starting Transfer + + WS->InitTransferReader(0); + const Handle(XSControl_TransferReader)& TR = WS->TransferReader(); + if (TR.IsNull()) { sout << " init not done or failed" << std::endl; return IFSelect_RetError; } + + TR->BeginTransfer(); + + // Transferring + Standard_Integer nbt = TR->TransferList(list); + sout << "Nb Entities Selected : " << nbl << " have given " << nbt << " results" << std::endl; + + // Filling VARS. one compound (trimpcomp) or one shape per ent (trimport) + Standard_Boolean iscomp = (pilot->Arg(0)[5] == 'c'); + Standard_Integer nbs = 0; + TopoDS_Shape sh; + TopoDS_Compound C; + BRep_Builder B; + B.MakeCompound(C); + Handle(Interface_InterfaceModel) mdl = TR->Model(); + if (mdl.IsNull()) { sout << " modele absent" << std::endl; return IFSelect_RetError; } + for (Standard_Integer il = 1; il <= nbl; il++) + { + Handle(Standard_Transient) ent = list->Value(il); + sh = TR->ShapeResult(ent); + if (sh.IsNull()) continue; + nbs++; + if (iscomp) B.Add(C, sh); + else + { + char nomsh[50]; + sprintf(nomsh, "%s_%d", rnom.ToCString(), nbs); + XSControl::Vars(pilot)->SetShape(nomsh, sh); + } + } + if (nbs == 0) sout << "No Shape produced" << std::endl; + else if (nbs == 1) + { + sout << "One Shape produced, named " << rnom.ToCString() << std::endl; + XSControl::Vars(pilot)->SetShape(rnom.ToCString(), sh); + } + else if (iscomp) + { + sout << "One compound made of " << nbs << " Shapes, named " << rnom.ToCString() << std::endl; + XSControl::Vars(pilot)->SetShape(rnom.ToCString(), C); + } + else + { // several individual shapes + sout << nbs << " Shapes, named " << rnom.ToCString() << "_1 to " << rnom.ToCString() << "_" << nbs << std::endl; + } + + return IFSelect_RetDone; +} + +//======================================================================= +//function : XSControl_twrite +//purpose : +//======================================================================= +static IFSelect_ReturnStatus XSControl_twrite +(const Handle(IFSelect_SessionPilot)& pilot) +{ + Standard_Integer argc = pilot->NbWords(); + const Standard_CString arg1 = pilot->Arg(1); + // **** twrite **** + Message_Messenger::StreamBuffer sout = Message::SendInfo(); + Handle(XSControl_TransferWriter) TW = XSControl::Session(pilot)->TransferWriter(); + if (argc < 2) { sout << " donner nom de shape draw" << std::endl; return IFSelect_RetError; } + sout << "Attention, on alimente le modele courant ..." << std::endl; + + // Shape + for (Standard_Integer i = 1; i < argc; i++) + { + const char* ai = (const char*)pilot->Arg(i); + TopoDS_Shape Shape = XSControl::Vars(pilot)->GetShape(ai); + if (Shape.IsNull()) { sout << "pas un nom de shape draw:" << arg1 << std::endl; continue; } + sout << "Pour Shape : " << ai; + Standard_Integer stat = TW->TransferWriteShape(XSControl::Session(pilot)->Model(), Shape); + sout << " Transfer Write Status = " << stat << std::endl; + } + pilot->Session()->ComputeGraph(); + // Transient ? (Geom) : ignore + return IFSelect_RetDone; +} + + +//======================================================================= +//function : Init +//purpose : +//======================================================================= +void XSDRAW_FunctionsShape::Init() +{ + static int THE_XSDRAW_FunctionsShape_initactor = 0; + if (THE_XSDRAW_FunctionsShape_initactor) + { + return; + } + + THE_XSDRAW_FunctionsShape_initactor = 1; + + IFSelect_Act::SetGroup("DE: General"); + IFSelect_Act::AddFunc("tpdraw", "[mode:item or root] num|* [nomvar] Passes an ITEM to Shape Draw (Start or Result)", XSControl_tpdraw); + IFSelect_Act::AddFunc("tpcompound", "name:cstring [givelist] : -> compound with Shapes Root or from givelist", XSControl_tpcompound); + IFSelect_Act::AddFunc("trdraw", "results ->DRAW : all; or num [name] : from ent.num -> DRAW [name/tread_num]", XSControl_traccess); + IFSelect_Act::AddFunc("trsave", "results ->files : all; or num [name] : from ent.num -> DRAW [name/tread_num]", XSControl_traccess); + IFSelect_Act::AddFunc("trcomp", "results -> 1 compound -> DRAW + name optional", XSControl_traccess); + IFSelect_Act::AddFunc("trscomp", "results -> 1 compound -> file + name optional", XSControl_traccess); + IFSelect_Act::AddFunc("fromshape", "shape [level=1]: imported/exported entity (when known)", XSControl_fromshape); + IFSelect_Act::AddFunc("trconnexent", "name of draw shape : entities -> connected shapes (when known)", XSControl_trconnexentities); + IFSelect_Act::AddFunc("trimport", "filename or . varname givelist -> 1 shape per entity", XSControl_trimport); + IFSelect_Act::AddFunc("trimpcomp", "filename or . varname givelist -> one xcompound", XSControl_trimport); + IFSelect_Act::AddFunc("twrite", "shape : transfer write for this shape, AFTER newmodel !", XSControl_twrite); +} diff --git a/src/XSDRAW/XSDRAW_FunctionsShape.hxx b/src/XSDRAW/XSDRAW_FunctionsShape.hxx new file mode 100644 index 0000000000..fb27c6a383 --- /dev/null +++ b/src/XSDRAW/XSDRAW_FunctionsShape.hxx @@ -0,0 +1,39 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAW_FunctionsShape_HeaderFile +#define _XSDRAW_FunctionsShape_HeaderFile + +#include +#include +#include + +//! Defines additional commands for XSControl to : +//! - control of initialisation (xinit, xnorm, newmodel) +//! - analyse of the result of a transfer (recorded in a +//! TransientProcess for Read, FinderProcess for Write) : +//! statistics, various lists (roots,complete,abnormal), what +//! about one specific entity, producing a model with the +//! abnormal result +//! +//! This appendix of XSControl is compiled separately to distinguish +//! basic features from user callable forms +class XSDRAW_FunctionsShape +{ + DEFINE_STANDARD_ALLOC +public: + //! Defines and loads all functions which work on shapes for XSControl (as ActFunc) + Standard_EXPORT static void Init(); +}; + +#endif // _XSDRAW_FunctionsShape_HeaderFile diff --git a/src/XSDRAW/XSDRAW_Vars.cxx b/src/XSDRAW/XSDRAW_Vars.cxx deleted file mode 100644 index ebe95e22ac..0000000000 --- a/src/XSDRAW/XSDRAW_Vars.cxx +++ /dev/null @@ -1,115 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -IMPLEMENT_STANDARD_RTTIEXT(XSDRAW_Vars,XSControl_Vars) - -XSDRAW_Vars::XSDRAW_Vars () { } - -void XSDRAW_Vars::Set - (const Standard_CString name, - const Handle(Standard_Transient)& val) -{ - //char* nam = name; -// selon type - DeclareAndCast(Geom_Geometry,geom,val); - if (!geom.IsNull()) { - DrawTrSurf::Set(name,geom); - return; - } - DeclareAndCast(Geom2d_Curve,g2d,val); - if (!g2d.IsNull()) { - DrawTrSurf::Set(name,geom); - return; - } -// ?? -} - -/* -Handle(Standard_Transient) XSDRAW_Vars::Get (const Standard_CString name) const -{ - Handle(Standard_Transient) val; - if (!thevars->GetItem (name,val)) val.Nullify(); - return val; -} -*/ - - -Handle(Geom_Geometry) XSDRAW_Vars::GetGeom (Standard_CString& name) const -{ //char* nam = name; - return DrawTrSurf::Get(name); -} - -Handle(Geom2d_Curve) XSDRAW_Vars::GetCurve2d (Standard_CString& name) const -{ //char* nam = name; - return DrawTrSurf::GetCurve2d(name); -} - -Handle(Geom_Curve) XSDRAW_Vars::GetCurve (Standard_CString& name) const -{ //char* nam = name; - return DrawTrSurf::GetCurve(name); -} - -Handle(Geom_Surface) XSDRAW_Vars::GetSurface (Standard_CString& name) const -{ //char* nam = name; - return DrawTrSurf::GetSurface(name); -} - - -void XSDRAW_Vars::SetPoint (const Standard_CString name, const gp_Pnt& val) -{ - //char* nam = name; - DrawTrSurf::Set (name, val); -} - -Standard_Boolean XSDRAW_Vars::GetPoint (Standard_CString& name, gp_Pnt& pnt) const -{ //char* nam = name; - return DrawTrSurf::GetPoint (name,pnt); } - - -void XSDRAW_Vars::SetPoint2d (const Standard_CString name, const gp_Pnt2d& val) -{ - //char* nam = name; - DrawTrSurf::Set (name, val); -} - -Standard_Boolean XSDRAW_Vars::GetPoint2d (Standard_CString& name, gp_Pnt2d& pnt) const -{ - //char* nam = name; - return DrawTrSurf::GetPoint2d (name,pnt); } - - -void XSDRAW_Vars::SetShape (const Standard_CString name, const TopoDS_Shape& val) -{ - DBRep::Set (name, val); -} - -TopoDS_Shape XSDRAW_Vars::GetShape (Standard_CString& name) const -{ - //char* nam = name; - return DBRep::Get (name); -} diff --git a/src/XSDRAW/XSDRAW_Vars.hxx b/src/XSDRAW/XSDRAW_Vars.hxx deleted file mode 100644 index 3edc215633..0000000000 --- a/src/XSDRAW/XSDRAW_Vars.hxx +++ /dev/null @@ -1,91 +0,0 @@ -// Created on: 1998-07-22 -// Created by: Christian CAILLET -// 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. - -#ifndef _XSDRAW_Vars_HeaderFile -#define _XSDRAW_Vars_HeaderFile - -#include -#include - -#include -class Standard_Transient; -class Geom_Geometry; -class Geom2d_Curve; -class Geom_Curve; -class Geom_Surface; -class gp_Pnt; -class gp_Pnt2d; -class TopoDS_Shape; - - -class XSDRAW_Vars; -DEFINE_STANDARD_HANDLE(XSDRAW_Vars, XSControl_Vars) - -//! Vars for DRAW session (i.e. DBRep and DrawTrSurf) -class XSDRAW_Vars : public XSControl_Vars -{ - -public: - - - Standard_EXPORT XSDRAW_Vars(); - - Standard_EXPORT virtual void Set (const Standard_CString name, const Handle(Standard_Transient)& val) Standard_OVERRIDE; - - Standard_EXPORT virtual Handle(Geom_Geometry) GetGeom (Standard_CString& name) const Standard_OVERRIDE; - - Standard_EXPORT virtual Handle(Geom2d_Curve) GetCurve2d (Standard_CString& name) const Standard_OVERRIDE; - - Standard_EXPORT virtual Handle(Geom_Curve) GetCurve (Standard_CString& name) const Standard_OVERRIDE; - - Standard_EXPORT virtual Handle(Geom_Surface) GetSurface (Standard_CString& name) const Standard_OVERRIDE; - - Standard_EXPORT virtual void SetPoint (const Standard_CString name, const gp_Pnt& val) Standard_OVERRIDE; - - Standard_EXPORT virtual void SetPoint2d (const Standard_CString name, const gp_Pnt2d& val) Standard_OVERRIDE; - - Standard_EXPORT virtual Standard_Boolean GetPoint (Standard_CString& name, gp_Pnt& pnt) const Standard_OVERRIDE; - - Standard_EXPORT virtual Standard_Boolean GetPoint2d (Standard_CString& name, gp_Pnt2d& pnt) const Standard_OVERRIDE; - - Standard_EXPORT virtual void SetShape (const Standard_CString name, const TopoDS_Shape& val) Standard_OVERRIDE; - - Standard_EXPORT virtual TopoDS_Shape GetShape (Standard_CString& name) const Standard_OVERRIDE; - - - - - DEFINE_STANDARD_RTTIEXT(XSDRAW_Vars,XSControl_Vars) - -protected: - - - - -private: - - - - -}; - - - - - - - -#endif // _XSDRAW_Vars_HeaderFile diff --git a/src/XSDRAWBase/FILES b/src/XSDRAWBase/FILES new file mode 100644 index 0000000000..38340b5f01 --- /dev/null +++ b/src/XSDRAWBase/FILES @@ -0,0 +1,2 @@ +XSDRAWBase.cxx +XSDRAWBase.hxx diff --git a/src/XSDRAWBase/XSDRAWBase.cxx b/src/XSDRAWBase/XSDRAWBase.cxx new file mode 100644 index 0000000000..bc4840e85d --- /dev/null +++ b/src/XSDRAWBase/XSDRAWBase.cxx @@ -0,0 +1,614 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#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 +// Pour le transfert (write) +// Pour NewModel et Write : definition de produit (temporaire ...) +// steptrans +extern "C" { +static void cleanpilot () +{ + XSDRAW::Session()->ClearData(1); +} +} + + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void XSDRAWSTEP::Init () +{ + Handle(StepSelect_Activator) stepact = new StepSelect_Activator; + if (STEPControl_Controller::Init()) // XSDRAW::SetNorm("STEP AP-214"); trop tot + XSDRAW::SetController(XSControl_Controller::Recorded("STEP")); + + atexit (cleanpilot); +} + +// ######## COMMANDE stepread : teste le Reader ######### + +//======================================================================= +//function : stepread +//purpose : +//======================================================================= + +static Standard_Integer stepread (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 3) { + di << "Use: stepread [file] [f or r (type of model full or reduced)]\n"; + return 1; + } + // On admet le controller AP214 ou une variante + DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); + if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); + + + // Progress indicator + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); + Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100); + + STEPControl_Reader sr (XSDRAW::Session(),Standard_False); + TCollection_AsciiString fnom,rnom; + Standard_Boolean modfic = XSDRAW::FileAndVar + (argv[1],argv[2],"STEP",fnom,rnom); + if (modfic) di<<" File STEP to read : "<Show(aPSRoot); + + Standard_Boolean fromtcl = Standard_False; + Standard_Boolean aFullMode = Standard_False; + Standard_Integer k = 3; + if(argc > k ) + { + if(argv[k][0] == 'f' || argv[3][0] == 'F') + { + aFullMode = Standard_True; + k++; + } + else if(argv[k][0] == 'r' || argv[3][0] == 'R') + { + aFullMode = Standard_False; + k++; + } + else + fromtcl = Standard_True; + + } + if(!fromtcl) + fromtcl = argc > k; + if(aFullMode) + std::cout<<"Full model for translation with additional info will be used \n"<SetModeStat(aFullMode); + + + if (modfic) readstat = sr.ReadFile (fnom.ToCString()); + else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone; + + aPSRoot.Next(20); // On average loading takes 20% + if (aPSRoot.UserBreak()) + return 1; + + if (readstat != IFSelect_RetDone) { + if (modfic) di<<"Could not read file "<PrepareForTransfer(); // update unit info + sr.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit()); + + // nom = "." -> fichier deja lu + Standard_Integer i, num, nbs, modepri = 1; + if (fromtcl) modepri = 4; + while (modepri) { + num = sr.NbRootsForTransfer(); + if (!fromtcl) { + di<<"NbRootsForTransfer="<Print (sr.RootForTransfer(i), aTmpStream); + di << aTmpStream.str().c_str(); + di<<" Type:"<DynamicType()->Name()<<"\n"; + } + + std::cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<>modepri; + } + + if (modepri == 0) { di<<"End Reading STEP\n"; return 0; } + if (modepri <= 2) { + num = 1; + if (modepri == 2) { + std::cout<<"Root N0 : "<>num; + } + aPSRoot.SetName("Translation"); + progress->Show(aPSRoot); + + if (!sr.TransferRoot (num, aPSRoot.Next(80))) + di<<"Transfer root n0 "< DRAW Shape: "< DRAW Shape: "<Append(sr.RootForTransfer(j)); + } + else { + di<<"List given by "< k+1) di<<" "< (k+1) ? argv[k+1] : 0 ) ); + } + if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots\n"; continue; } + } else { + std::cout<<"Name of Selection :"<Length(); + di<<"Nb entities selected : "<Show(aPSRoot); + + Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl); + for (ill = 1; ill <= nbl && aPS.More(); ill++) { + num = sr.Model()->Number(list->Value(ill)); + if (num == 0) continue; + if (!sr.TransferOne(num, aPS.Next())) + di<<"Transfer entity n0 "< DRAW Shape: "< 4) + { + di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n"; + di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n"; + di << " Option -stream forces usage of API accepting stream\n"; + return 1; + } + + Standard_Boolean useStream = (argc > 3 && ! strcasecmp (argv[3], "-stream")); + + STEPControl_Reader Reader; + Standard_CString filename = argv[1]; + IFSelect_ReturnStatus readstat; + if (useStream) + { + std::ifstream aStream; + OSD_OpenStream (aStream, filename, std::ios::in | std::ios::binary); + TCollection_AsciiString aFolder, aFileNameShort; + OSD_Path::FolderAndFileFromPath (filename, aFolder, aFileNameShort); + readstat = Reader.ReadStream (aFileNameShort.ToCString(), aStream); + } + else + { + readstat = Reader.ReadFile(filename); + } + di<<"Status from reading STEP file "<PrepareForTransfer(); // update unit info + Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit()); + Reader.TransferRoots(); + TopoDS_Shape shape = Reader.OneShape(); + DBRep::Set(argv[2],shape); + di<<"Count of shapes produced : "< 4) n2 = XSDRAW::GetEntityNumber(argv[4]); + if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast + (XSDRAW::Entity(n1)); + if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast + (XSDRAW::Entity(n2)); + StepToTopoDS_MakeTransformed mktrans; + if (mktrans.Compute (ax1,ax2)) { + TopLoc_Location loc (mktrans.Transformation()); + shape.Move (loc); +// mktrans.Transform (shape); + DBRep::Set (argv[2],shape); + di<<"Transformed Shape as "<ActorWrite() ); + if ( ! ActWrite.IsNull() ) + ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly")); + + TopoDS_Shape shape = DBRep::Get(argv[2]); + STEPControl_Writer sw (XSDRAW::Session(),Standard_False); + Handle(Interface_InterfaceModel) stepmodel = sw.Model(); + Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); + + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); + Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100); + progress->Show(aPSRoot); + + Standard_Integer stat = sw.Transfer (shape, mode, Standard_True, aPSRoot.Next(90)); + if (stat == IFSelect_RetDone) + { + di << "Translation: OK\n"; + } + else + { + di << "Error: translation failed, status = " << stat << "\n"; + } + + if (aPSRoot.UserBreak()) + return 1; + aPSRoot.SetName("Writing"); + progress->Show(aPSRoot); + +// Que s est-il passe + stepmodel = sw.Model(); + Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); + if (nbavant > 0) di<<"Beware : Model not empty before transferring\n"; + if (nbapres <= nbavant) di<<"Beware : No data produced by this transfer\n"; + if (nbapres == 0) { di<<"No data to write\n"; return 0; } + + if (argc <= 3) { + di<<" Now, to write a file, command : writeall filename\n"; + return 0; + } + + const char *nomfic = argv[3]; + stat = sw.Write(nomfic); + switch (stat) { + case IFSelect_RetVoid : di<<"Error: No file written\n"; break; + case IFSelect_RetDone : di<<"File "<Session(); + const Interface_Graph& graph = WS->Graph(); + + Handle(TColStd_HSequenceOfTransient) roots = WS->GiveList("xst-transferrable-roots", ""); + STEPSelections_Counter cnt; + + for (Standard_Integer i =1 ; i <= roots->Length(); i++) { + cnt.Count(graph,roots->Value(i)); + } + + di<< "Instances of Faces \t: "<Session(); + const Interface_Graph& graph = WS->Graph(); + + STEPSelections_AssemblyExplorer exp(graph); + exp.Dump(std::cout); + return 0; +} + +static Standard_Integer stepfileunits (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + + if( argc < 2) + { + di << "Error: Invalid number of parameters. Should be: getfileunits name_file\n"; + return 1; + } + STEPControl_Reader aStepReader; + + IFSelect_ReturnStatus readstat = IFSelect_RetVoid; + readstat = aStepReader.ReadFile (argv[1]); + + if (readstat != IFSelect_RetDone) { + + di<<"No model loaded\n"; + return 1; + } + + TColStd_SequenceOfAsciiString anUnitLengthNames; + TColStd_SequenceOfAsciiString anUnitAngleNames; + TColStd_SequenceOfAsciiString anUnitSolidAngleNames; + aStepReader.FileUnits( anUnitLengthNames,anUnitAngleNames,anUnitSolidAngleNames); + + Standard_Integer i =1; + di<<"=====================================================\n"; + di<<"LENGTH Unit\n"; + for( ; i <= anUnitLengthNames.Length() ; i++) + di< +#include + +#include +#include +#include + +class IFSelect_SessionPilot; +class XSControl_WorkSession; +class XSControl_Controller; +class Interface_Protocol; +class Interface_InterfaceModel; +class Standard_Transient; +class Transfer_TransientProcess; +class Transfer_FinderProcess; +class XSControl_TransferReader; +class TCollection_AsciiString; + +//! Basic package to work functions of X-STEP (IFSelect & Co) +//! under control of DRAW +//! +//! Works with some "static" data : a SessionPilot (used to run) +//! with its WorkSession and Model and TransferReader, a +//! FinderProcess +class XSDRAWBase +{ + DEFINE_STANDARD_ALLOC +public: + + //! Takes variables to/from the DRAW session + //! Implements ProgressIndicator for DRAW + //! Changes the name under which a command of xstep is known by + //! Draw. This allows to avoid collisions + //! To be called before LoadDraw or any other xstep initialisation + Standard_EXPORT static void ChangeCommand(const Standard_CString oldname, const Standard_CString newname); + + //! Removes a command from the interpretation list of Draw + //! To be called before LoadDraw or any other xstep initialisation + Standard_EXPORT static void RemoveCommand(const Standard_CString oldname); + + //! Defines the basic context to work with a X-STEP Session : + //! it performs the basic inits, also records the Controller + //! If the Controller is not yet set, it must be set after + //! (call to SetController) + //! LoadSession is called by LoadDraw + //! Returns True the first time, False if already called + Standard_EXPORT static Standard_Boolean LoadSession(); + + //! Defines the context for using a X-STEP Session under DRAW + //! Once the various INITs have been done, a call to LoadDraw + //! records the defined commands for the X-STEP SessionPilot, + //! into the DRAW interpretation list. + //! "Set" commands are accessed under command xset + //! SDS>xset name command ... + //! Other commands can be accessed directly or under command xstep + //! SDS>command ... and SDS>xstep command ... are equivalent + //! + //! Only the command xinit is accessed directly only : + //! SDS>xinit (from the already defined Controller) + //! SDS>xinit iges (first defines the Controller as for "iges") + //! + //! It also records the function to be called by DRAW (not + //! declared because specific). + //! And it defines the context variables, i.e. a WorkSession, then + //! it calls SetController with the currently defined Controller + //! Remark : at least, the standard commands are recorded + //! + //! See also Controller : it is part of the Context, but it must + //! be precised separately + Standard_EXPORT static void LoadDraw(Draw_Interpretor& theCommands); + + //! Allows to execute a xstep-draw command from C++ program + //! Fixed form : Execute("command args..."); + //! Form with a variable text part : add %s for the variable : + //! Execute ("command args %s args..",var) [var is a CString] + //! Returns the same value as returned by call from DRAW + Standard_EXPORT static Standard_Integer Execute(const Standard_CString command, const Standard_CString var = ""); + + //! Returns the SessionPilot (can be used for direct call) + Standard_EXPORT static Handle(IFSelect_SessionPilot) Pilot(); + + //! Returns the WorkSession defined in AddDraw (through Pilot) + //! It is from XSControl, it brings functionalities for Transfers + Standard_EXPORT static Handle(XSControl_WorkSession) Session(); + + //! Defines a Controller for the command "xinit" and applies it + //! (i.e. calls its method Customise) + Standard_EXPORT static void SetController(const Handle(XSControl_Controller)& control); + + //! Returns the Controller, a Null Handle if not yet defined + Standard_EXPORT static Handle(XSControl_Controller) Controller(); + + //! Sets a norm by its name (controller recorded as ) + //! Returns True if done, False if this norm is unknown + Standard_EXPORT static Standard_Boolean SetNorm(const Standard_CString normname); + + //! Returns the actually defined Protocol + Standard_EXPORT static Handle(Interface_Protocol) Protocol(); + + //! Returns the Model of the Session (it is Session()->Model() ) + Standard_EXPORT static Handle(Interface_InterfaceModel) Model(); + + //! Sets a Model in session (it is Session()->SetModel(model) ) + //! If is defined, SetLoadedFile is also done + Standard_EXPORT static void SetModel(const Handle(Interface_InterfaceModel)& model, const Standard_CString file = ""); + + //! Produces a new model (from the Controller), can be Null + //! Does not set it in the session + Standard_EXPORT static Handle(Interface_InterfaceModel) NewModel(); + + //! Returns the entity n0 of the Model of the Session + //! (it is StartingEntity) + //! Null Handle if is not suitable + Standard_EXPORT static Handle(Standard_Transient) Entity(const Standard_Integer num); + + //! Returns the number of an entity in the Model (StartingNumber) + //! 0 if unknown in the model, or null + Standard_EXPORT static Standard_Integer Number(const Handle(Standard_Transient)& ent); + + //! Sets a TransferProcess in order to analyse it (see Activator) + //! It can be either a FinderProcess or a TransientProcess, in + //! that case a new TransferReader is created on it + Standard_EXPORT static void SetTransferProcess(const Handle(Standard_Transient)& TP); + + //! Returns the TransferProcess : TransientProcess detained by + //! the TransferReader + Standard_EXPORT static Handle(Transfer_TransientProcess) TransientProcess(); + + //! Returns the FinderProcess, detained by the TransferWriter + Standard_EXPORT static Handle(Transfer_FinderProcess) FinderProcess(); + + //! Initialises a TransferReader, according to mode : + //! 0 nullifies it, 1 clears it (not nullify) + //! 2 sets it with TransientProcess & Model + //! 3 idem plus roots of TransientProcess + //! Remark : called with 0 at least at each SetModel/NewModel + Standard_EXPORT static void InitTransferReader(const Standard_Integer mode); + + //! Returns the current TransferReader, can be null + //! It detains the TransientProcess + Standard_EXPORT static Handle(XSControl_TransferReader) TransferReader(); + + //! Takes the name of an entity, either as argument, or (if + //! is empty) on keyboard, and returns the entity + //! name can be a label or a number (in alphanumeric), it is + //! searched by NumberFromLabel from WorkSession. + //! If doesn't match en entity, a Null Handle is returned + Standard_EXPORT static Handle(Standard_Transient) GetEntity(const Standard_CString name = ""); + + //! Same as GetEntity, but returns the number in the model of the + //! entity. Returns 0 for null handle + Standard_EXPORT static Standard_Integer GetEntityNumber(const Standard_CString name = ""); + + //! Evaluates and returns a list of entity, from : + //! keyboard if and are empty, see below + //! first if second is empty : can be a number/label of an entity + //! or the name of a selection to be evaluated (standard) + //! first : name of a selection, evaluated from a list defined by + //! second + //! In case of failure, returns a Null Handle + Standard_EXPORT static Handle(TColStd_HSequenceOfTransient) GetList(const Standard_CString first = "", const Standard_CString second = ""); + + //! Analyses given file name and variable name, with a default + //! name for variables. Returns resulting file name and variable + //! name plus status "file to read"(True) or "already read"(False) + //! In the latter case, empty resfile means no file available + //! + //! If is null or empty or equates ".", considers Session + //! and returned status is False + //! Else, returns resfile = file and status is True + //! If is neither null nor empty, resvar = var + //! Else, the root part of is considered, if defined + //! Else, is taken + Standard_EXPORT static Standard_Boolean FileAndVar(const Standard_CString file, const Standard_CString var, const Standard_CString def, TCollection_AsciiString& resfile, TCollection_AsciiString& resvar); + + //! Analyses a name as designating Shapes from DRAW variables or + //! XSTEP transfer (last Transfer on Reading). can be : + //! "*" : all the root shapes produced by last Transfer (Read) + //! i.e. considers roots of the TransientProcess + //! a name : a name of a variable DRAW + //! + //! Returns the count of designated Shapes. Their list is put in + //! . If is null, it is firstly created. Then it is + //! completed (Append without Clear) by the Shapes found + //! Returns 0 if no Shape could be found + Standard_EXPORT static Standard_Integer MoreShapes(Handle(TopTools_HSequenceOfShape)& list, const Standard_CString name); +}; + +#endif // _XSDRAWBase_HeaderFile diff --git a/src/XSDRAWDEWrapper/FILES b/src/XSDRAWDEWrapper/FILES new file mode 100644 index 0000000000..6fe0441e17 --- /dev/null +++ b/src/XSDRAWDEWrapper/FILES @@ -0,0 +1,2 @@ +XSDRAWDEWrapper.cxx +XSDRAWDEWrapper.hxx diff --git a/src/XSDRAWDEWrapper/XSDRAWDEWrapper.cxx b/src/XSDRAWDEWrapper/XSDRAWDEWrapper.cxx new file mode 100644 index 0000000000..ef8729b15e --- /dev/null +++ b/src/XSDRAWDEWrapper/XSDRAWDEWrapper.cxx @@ -0,0 +1,433 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#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 + +//======================================================================= +//function : DumpConfiguration +//purpose : +//======================================================================= +static Standard_Integer DumpConfiguration(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper(); + TCollection_AsciiString aPath; + Standard_Boolean aIsRecursive = Standard_True; + Standard_Boolean isHandleFormat = Standard_False; + Standard_Boolean isHandleVendors = Standard_False; + TColStd_ListOfAsciiString aFormats; + TColStd_ListOfAsciiString aVendors; + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArg(theArgVec[anArgIter]); + anArg.LowerCase(); + if ((anArg == "-path") && + (anArgIter + 1 < theNbArgs)) + { + ++anArgIter; + aPath = theArgVec[anArgIter]; + } + else if ((anArg == "-recursive") && + (anArgIter + 1 < theNbArgs) && + Draw::ParseOnOff(theArgVec[anArgIter + 1], aIsRecursive)) + { + ++anArgIter; + } + else if (anArg == "-format") + { + isHandleFormat = Standard_True; + isHandleVendors = Standard_False; + } + else if (anArg == "-vendor") + { + isHandleFormat = Standard_False; + isHandleVendors = Standard_True; + } + else if (isHandleFormat) + { + aFormats.Append(theArgVec[anArgIter]); + } + else if (isHandleVendors) + { + aVendors.Append(theArgVec[anArgIter]); + } + else if (!isHandleFormat && !isHandleVendors) + { + theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + Standard_Boolean aStat = Standard_True; + if (!aPath.IsEmpty()) + { + aStat = aConf->Save(aPath, aIsRecursive, aFormats, aVendors); + } + else + { + theDI << aConf->Save(aIsRecursive, aFormats, aVendors) << "\n"; + } + if (!aStat) + { + return 1; + } + return 0; +} + +//======================================================================= +//function : CompareConfiguration +//purpose : +//======================================================================= +static Standard_Integer CompareConfiguration(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs > 5) + { + theDI.PrintHelp(theArgVec[0]); + return 1; + } + Handle(DE_ConfigurationContext) aResourceFirst = new DE_ConfigurationContext(); + if (!aResourceFirst->Load(theArgVec[1])) + { + theDI << "Error: Can't load first configuration\n"; + return 1; + } + Handle(DE_ConfigurationContext) aResourceSecond = new DE_ConfigurationContext(); + if (!aResourceSecond->Load(theArgVec[2])) + { + theDI << "Error: Can't load second configuration\n"; + return 1; + } + const DE_ResourceMap& aResourceMapFirst = aResourceFirst->GetInternalMap(); + const DE_ResourceMap& aResourceMapSecond = aResourceSecond->GetInternalMap(); + Standard_Integer anDiffers = 0; + for (DE_ResourceMap::Iterator anOrigIt(aResourceMapFirst); + anOrigIt.More(); anOrigIt.Next()) + { + const TCollection_AsciiString& anOrigValue = anOrigIt.Value(); + const TCollection_AsciiString& anOrigKey = anOrigIt.Key(); + TCollection_AsciiString aCompValue; + if (!aResourceMapSecond.Find(anOrigKey, aCompValue)) + { + Message::SendWarning() << "Second configuration don't have the next scope : " << anOrigKey; + anDiffers++; + } + if (!aCompValue.IsEqual(anOrigValue)) + { + Message::SendWarning() << "Configurations have differs value with the next scope :" << anOrigKey + << " First value : " << anOrigValue << " Second value : " << aCompValue; + anDiffers++; + } + } + TCollection_AsciiString aMessage; + if (aResourceMapFirst.Extent() != aResourceMapSecond.Extent() || anDiffers > 0) + { + theDI << "Error: Configurations are not same : " << " Differs count : " + << anDiffers << " Count of first's scopes : " << aResourceMapFirst.Extent() + << " Count of second's scopes : " << aResourceMapSecond.Extent() << "\n"; + return 1; + } + return 0; +} + +//======================================================================= +//function : LoadConfiguration +//purpose : +//======================================================================= +static Standard_Integer LoadConfiguration(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs > 4) + { + theDI.PrintHelp(theArgVec[0]); + return 1; + } + Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper(); + TCollection_AsciiString aString = theArgVec[1]; + Standard_Boolean aIsRecursive = Standard_True; + if (theNbArgs == 4) + { + TCollection_AsciiString anArg = theArgVec[2]; + anArg.LowerCase(); + if (!(anArg == "-recursive") || + !Draw::ParseOnOff(theArgVec[3], aIsRecursive)) + { + theDI << "Syntax error at argument '" << theArgVec[3] << "'\n"; + return 1; + } + } + if (!aConf->Load(aString, aIsRecursive)) + { + theDI << "Error: configuration is incorrect\n"; + return 1; + } + return 0; +} + +//======================================================================= +//function : ReadFile +//purpose : +//======================================================================= +static Standard_Integer ReadFile(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs > 6) + { + theDI.PrintHelp(theArgVec[0]); + return 1; + } + TCollection_AsciiString aDocShapeName; + TCollection_AsciiString aFilePath; + Handle(TDocStd_Document) aDoc; + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + TCollection_AsciiString aConfString; + Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readfile"); + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArg(theArgVec[anArgIter]); + anArg.LowerCase(); + if ((anArg == "-conf") && + (anArgIter + 1 < theNbArgs)) + { + ++anArgIter; + aConfString = theArgVec[anArgIter]; + } + else if (aDocShapeName.IsEmpty()) + { + aDocShapeName = theArgVec[anArgIter]; + Standard_CString aNameVar = aDocShapeName.ToCString(); + if (!isNoDoc) + { + DDocStd::GetDocument(aNameVar, aDoc, Standard_False); + } + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + if (aDoc.IsNull() && !isNoDoc) + { + anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); + TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]); + Draw::Set(theArgVec[1], aDrawDoc); + } + + Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy(); + Standard_Boolean aStat = Standard_True; + if (!aConfString.IsEmpty()) + { + aStat = aConf->Load(aConfString); + } + if (aStat) + { + TopoDS_Shape aShape; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + aStat = isNoDoc ? aConf->Read(aFilePath, aShape, aWS) : aConf->Read(aFilePath, aDoc, aWS); + if (isNoDoc && aStat) + { + DBRep::Set(aDocShapeName.ToCString(), aShape); + } + CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); + } + if (!aStat) + { + return 1; + } + return 0; +} + +//======================================================================= +//function : WriteFile +//purpose : +//======================================================================= +static Standard_Integer WriteFile(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs > 6) + { + theDI.PrintHelp(theArgVec[0]); + return 1; + } + TCollection_AsciiString aDocShapeName; + TCollection_AsciiString aFilePath; + Handle(TDocStd_Document) aDoc; + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + TCollection_AsciiString aConfString; + Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "writefile"); + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArg(theArgVec[anArgIter]); + anArg.LowerCase(); + if ((anArg == "-conf") && + (anArgIter + 1 < theNbArgs)) + { + ++anArgIter; + aConfString = theArgVec[anArgIter]; + } + else if (aDocShapeName.IsEmpty()) + { + aDocShapeName = theArgVec[anArgIter]; + Standard_CString aNameVar = aDocShapeName.ToCString(); + if (!isNoDoc) + { + DDocStd::GetDocument(aNameVar, aDoc, Standard_False); + } + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at argument '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aDocShapeName.IsEmpty() || aFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + if (aDoc.IsNull() && !isNoDoc) + { + theDI << "Error: incorrect document\n"; + return 1; + } + Handle(DE_Wrapper) aConf = DE_Wrapper::GlobalWrapper()->Copy(); + Standard_Boolean aStat = Standard_True; + if (!aConfString.IsEmpty()) + { + aStat = aConf->Load(aConfString); + } + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (aStat) + { + if (isNoDoc) + { + TopoDS_Shape aShape = DBRep::Get(aDocShapeName); + if (aShape.IsNull()) + { + theDI << "Error: incorrect shape " << aDocShapeName << "\n"; + return 1; + } + aStat = aConf->Write(aFilePath, aShape, aWS); + } + else + { + aStat = aConf->Write(aFilePath, aDoc, aWS); + } + } + if (!aStat) + { + return 1; + } + CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); + return 0; +} + +void XSDRAWDEWrapper::InitCommands(Draw_Interpretor& theDI) +{ + static Standard_Boolean initactor = Standard_False; + if (initactor) + { + return; + } + initactor = Standard_True; + + Standard_CString g = "XDE translation commands"; + theDI.Add("DumpConfiguration", + "DumpConfiguration [-path ] [-recursive {on|off}] [-format fmt1 fmt2 ...] [-vendor vend1 vend2 ...]\n" + "\n\t\t: Dump special resource generated from global configuration." + "\n\t\t: '-path' - save resource configuration to the file" + "\n\t\t: '-recursive' - flag to generate a resource from providers. Default is On. Off disables other options" + "\n\t\t: '-format' - flag to generate a resource for choosen formats. If list is empty, generate it for all" + "\n\t\t: '-vendor' - flag to generate a resource for choosen vendors. If list is empty, generate it for all", + __FILE__, DumpConfiguration, g); + theDI.Add("LoadConfiguration", + "LoadConfiguration conf [-recursive {on|off}]\n" + "\n\t\t: 'conf' - path to the resouce file or string value in the special format" + "\n\t\t: '-recursive' - flag to generate a resource for all providers. Default is true" + "\n\t\t: Configure global configuration according special resource", + __FILE__, LoadConfiguration, g); + theDI.Add("CompareConfiguration", + "CompareConfiguration conf1 conf2\n" + "\n\t\t: 'conf1' - path to the first resouce file or string value in the special format" + "\n\t\t: 'conf2' - path to the second resouce file or string value in the special format" + "\n\t\t: Compare two configurations", + __FILE__, CompareConfiguration, g); + theDI.Add("ReadFile", + "ReadFile docName filePath [-conf ]\n" + "\n\t\t: Read CAD file to document with registered format's providers. Use global configuration by default.", + __FILE__, ReadFile, g); + theDI.Add("readfile", + "readfile shapeName filePath [-conf ]\n" + "\n\t\t: Read CAD file to shape with registered format's providers. Use global configuration by default.", + __FILE__, ReadFile, g); + theDI.Add("WriteFile", + "WriteFile docName filePath [-conf ]\n" + "\n\t\t: Write CAD file to document with registered format's providers. Use global configuration by default.", + __FILE__, WriteFile, g); + theDI.Add("writefile", + "writefile shapeName filePath [-conf ]\n" + "\n\t\t: Write CAD file to shape with registered format's providers. Use global configuration by default.", + __FILE__, WriteFile, g); +} diff --git a/src/XSDRAWDEWrapper/XSDRAWDEWrapper.hxx b/src/XSDRAWDEWrapper/XSDRAWDEWrapper.hxx new file mode 100644 index 0000000000..397c108986 --- /dev/null +++ b/src/XSDRAWDEWrapper/XSDRAWDEWrapper.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWDEWrapper_HeaderFile +#define _XSDRAWDEWrapper_HeaderFile + +#include +#include + +#include + +class XSDRAWDEWrapper +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWDEWrapper_HeaderFile diff --git a/src/XSDRAWGLTF/FILES b/src/XSDRAWGLTF/FILES new file mode 100644 index 0000000000..28bb8b0397 --- /dev/null +++ b/src/XSDRAWGLTF/FILES @@ -0,0 +1,2 @@ +XSDRAWGLTF.cxx +XSDRAWGLTF.hxx diff --git a/src/XSDRAWGLTF/XSDRAWGLTF.cxx b/src/XSDRAWGLTF/XSDRAWGLTF.cxx new file mode 100644 index 0000000000..7ac66a5af5 --- /dev/null +++ b/src/XSDRAWGLTF/XSDRAWGLTF.cxx @@ -0,0 +1,717 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#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 : ReadGltf +//purpose : Reads glTF file +//============================================================================= +static Standard_Integer ReadGltf(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + TCollection_AsciiString aDestName, aFilePath; + Handle(RWGltf_ConfigurationNode) aNode = + new RWGltf_ConfigurationNode(); + Standard_Boolean toUseExistingDoc = Standard_False; + //Standard_Boolean toListExternalFiles = Standard_False; + //Standard_Boolean isParallel = Standard_False; + //Standard_Boolean isDoublePrec = Standard_False; + //Standard_Boolean toSkipLateDataLoading = Standard_False; + //Standard_Boolean toKeepLateData = Standard_True; + //Standard_Boolean toPrintDebugInfo = Standard_False; + //Standard_Boolean toLoadAllScenes = Standard_False; + //Standard_Boolean toPrintAssetInfo = Standard_False; + Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf"); + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArgCase(theArgVec[anArgIter]); + anArgCase.LowerCase(); + if (!isNoDoc + && (anArgCase == "-nocreate" + || anArgCase == "-nocreatedoc")) + { + toUseExistingDoc = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-parallel") + { + aNode->InternalParameters.ReadParallel = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-doubleprec" + || anArgCase == "-doubleprecision" + || anArgCase == "-singleprec" + || anArgCase == "-singleprecision") + { + aNode->InternalParameters.ReadSinglePrecision = + !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + if (anArgCase.StartsWith("-single")) + { + aNode->InternalParameters.ReadSinglePrecision = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + } + else if (anArgCase == "-skiplateloading") + { + aNode->InternalParameters.ReadSkipLateDataLoading = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-keeplate") + { + aNode->InternalParameters.ReadKeepLateData = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-allscenes") + { + aNode->InternalParameters.ReadLoadAllScenes = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-toprintinfo" + || anArgCase == "-toprintdebuginfo") + { + aNode->InternalParameters.ReadPrintDebugMessages = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + //else if (anArgCase == "-listexternalfiles" + // || anArgCase == "-listexternals" + // || anArgCase == "-listexternal" + // || anArgCase == "-external" + // || anArgCase == "-externalfiles") + //{ + // toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); + //} + //else if (anArgCase == "-assetinfo" + // || anArgCase == "-metadata") + //{ + // toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); + //} + else if (aDestName.IsEmpty()) + { + aDestName = theArgVec[anArgIter]; + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + //if (aFilePath.IsEmpty() && !aDestName.IsEmpty()) + //{ + // if (toListExternalFiles || toPrintAssetInfo) + // { + // std::swap (aFilePath, aDestName); + // } + //} + if (aFilePath.IsEmpty() || aDestName.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(TDocStd_Document) aDoc; + if (!aDestName.IsEmpty() + && !isNoDoc) + { + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + Standard_CString aNameVar = aDestName.ToCString(); + DDocStd::GetDocument(aNameVar, aDoc, Standard_False); + if (aDoc.IsNull()) + { + if (toUseExistingDoc) + { + theDI << "Error: document with name " << aDestName << " does not exist\n"; + return 1; + } + anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); + } + else if (!toUseExistingDoc) + { + theDI << "Error: document with name " << aDestName << " already exists\n"; + return 1; + } + } + + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(RWGltf_Provider) aProvider = + new RWGltf_Provider(aNode); + Standard_Boolean aReadStat = Standard_False; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (isNoDoc) + { + TopoDS_Shape aResShape; + aReadStat = aProvider->Read(aFilePath, aResShape, aWS, aProgress->Start()); + if (aReadStat) + { + DBRep::Set(aDestName.ToCString(), aResShape); + } + } + else + { + aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); + if (aReadStat) + { + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); + TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName); + Draw::Set(aDestName.ToCString(), aDrawDoc); + } + } + if (!aReadStat) + { + theDI << "Cannot read any relevant data from the GLTF file\n"; + return 1; + } + //bool isFirstLine = true; + //if (toPrintAssetInfo) + //{ + // for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter (aReader.Metadata()); aKeyIter.More(); aKeyIter.Next()) + // { + // if (!isFirstLine) + // { + // theDI << "\n"; + // } + // isFirstLine = false; + // theDI << aKeyIter.Key() << ": " << aKeyIter.Value(); + // } + //} + //if (toListExternalFiles) + //{ + // if (!isFirstLine) + // { + // theDI << "\n"; + // } + // for (NCollection_IndexedMap::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next()) + // { + // theDI << "\"" << aFileIter.Value() << "\" "; + // } + //} + + return 0; +} + +//============================================================================= +//function : WriteGltf +//purpose : Writes glTF file +//============================================================================= +static Standard_Integer WriteGltf(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + TCollection_AsciiString aGltfFilePath; + Handle(TDocStd_Document) aDoc; + TopoDS_Shape aShape; + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + Handle(RWGltf_ConfigurationNode) aNode = + new RWGltf_ConfigurationNode(); + //TColStd_IndexedDataMapOfStringString aFileInfo; + //RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact; + //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup; + //bool toForceUVExport = false, toEmbedTexturesInGlb = true; + //bool toMergeFaces = false, toSplitIndices16 = false; + //bool isParallel = false; + //RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; + //RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product; + //RWGltf_DracoParameters aDracoParameters; + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArgCase(theArgVec[anArgIter]); + anArgCase.LowerCase(); + if (anArgCase == "-comments" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; + } + else if (anArgCase == "-author" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; + } + else if (anArgCase == "-forceuvexport" + || anArgCase == "-forceuv") + { + aNode->InternalParameters.WriteForcedUVExport = true; + if (anArgIter + 1 < theNbArgs + && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteForcedUVExport)) + { + ++anArgIter; + } + } + else if (anArgCase == "-mergefaces") + { + aNode->InternalParameters.WriteMergeFaces = true; + if (anArgIter + 1 < theNbArgs + && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteMergeFaces)) + { + ++anArgIter; + } + } + else if (anArgCase == "-splitindices16" + || anArgCase == "-splitindexes16" + || anArgCase == "-splitindices" + || anArgCase == "-splitindexes" + || anArgCase == "-splitind") + { + aNode->InternalParameters.WriteSplitIndices16 = true; + if (anArgIter + 1 < theNbArgs + && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteSplitIndices16)) + { + ++anArgIter; + } + } + else if (anArgIter + 1 < theNbArgs + && (anArgCase == "-systemcoordinatesystem" + || anArgCase == "-systemcoordsystem" + || anArgCase == "-systemcoordsys" + || anArgCase == "-syscoordsys")) + { + if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) + { + theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + else if (anArgCase == "-trsfformat" + && anArgIter + 1 < theNbArgs) + { + TCollection_AsciiString aTrsfStr(theArgVec[++anArgIter]); + aTrsfStr.LowerCase(); + if (aTrsfStr == "compact") + { + aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; + } + else if (aTrsfStr == "mat4") + { + aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Mat4; + } + else if (aTrsfStr == "trs") + { + aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_TRS; + } + else + { + theDI << "Syntax error at '" << anArgCase << "'\n"; + return 1; + } + } + else if (anArgCase == "-nodenameformat" + || anArgCase == "-nodename") + { + ++anArgIter; + if (anArgIter >= theNbArgs + || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteNodeNameFormat)) + { + theDI << "Syntax error at '" << anArgCase << "'\n"; + return 1; + } + } + else if (anArgCase == "-meshnameformat" + || anArgCase == "-meshname") + { + ++anArgIter; + if (anArgIter >= theNbArgs + || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteMeshNameFormat)) + { + theDI << "Syntax error at '" << anArgCase << "'\n"; + return 1; + } + } + else if (aDoc.IsNull()) + { + Standard_CString aNameVar = theArgVec[anArgIter]; + DDocStd::GetDocument(aNameVar, aDoc, false); + if (aDoc.IsNull()) + { + aShape = DBRep::Get(aNameVar); + if (aShape.IsNull()) + { + theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n"; + return 1; + } + aNode->InternalParameters.WriteNodeNameFormat = RWMesh_NameFormat_Product; + } + } + else if (aGltfFilePath.IsEmpty()) + { + aGltfFilePath = theArgVec[anArgIter]; + } + else if (anArgCase == "-texturesSeparate") + { + aNode->InternalParameters.WriteEmbedTexturesInGlb = false; + } + else if (anArgCase == "-draco") + { + aNode->InternalParameters.WriteDracoParameters.DracoCompression = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-compressionlevel" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.CompressionLevel)) + { + ++anArgIter; + } + else if (anArgCase == "-quantizepositionbits" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.QuantizePositionBits)) + { + ++anArgIter; + } + else if (anArgCase == "-quantizenormalbits" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.QuantizeNormalBits)) + { + ++anArgIter; + } + else if (anArgCase == "-quantizetexcoordbits" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.QuantizeTexcoordBits)) + { + ++anArgIter; + } + else if (anArgCase == "-quantizecolorbits" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.QuantizeColorBits)) + { + ++anArgIter; + } + else if (anArgCase == "-quantizegenericbits" && (anArgIter + 1) < theNbArgs + && Draw::ParseInteger(theArgVec[anArgIter + 1], + aNode->InternalParameters.WriteDracoParameters.QuantizeGenericBits)) + { + ++anArgIter; + } + else if (anArgCase == "-unifiedquantization") + { + aNode->InternalParameters.WriteDracoParameters.UnifiedQuantization = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArgCase == "-parallel") + { + aNode->InternalParameters.WriteParallel = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aGltfFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + + TCollection_AsciiString anExt = aGltfFilePath; + anExt.LowerCase(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(RWGltf_Provider) aProvider = + new RWGltf_Provider(aNode); + Standard_Boolean aWriteStat = Standard_False; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aDoc.IsNull()) + { + aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start()); + } + else if (!aShape.IsNull()) + { + aWriteStat = aProvider->Write(aGltfFilePath, aShape, aWS, aProgress->Start()); + } + if (!aWriteStat) + { + theDI << "Cannot write any relevant data to the GLTF file\n"; + return 1; + } + return 0; +} + +//======================================================================= +//function : InitCommands +//purpose : +//======================================================================= +void XSDRAWGLTF::InitCommands(Draw_Interpretor& theCommands) +{ + const char* g = "XSTEP-STL/VRML"; // Step transfer file commands + //XSDRAW::LoadDraw(theCommands); + + theCommands.Add("ReadGltf", + "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]" + "\n\t\t: Read glTF file into XDE document." + "\n\t\t: -listExternalFiles do not read mesh and only list external files" + "\n\t\t: -noCreateDoc read into existing XDE document" + "\n\t\t: -doublePrecision store triangulation with double or single floating point" + "\n\t\t: precision (single by default)" + "\n\t\t: -skipLateLoading data loading is skipped and can be performed later" + "\n\t\t: (false by default)" + "\n\t\t: -keepLate data is loaded into itself with preservation of information" + "\n\t\t: about deferred storage to load/unload this data later." + "\n\t\t: -allScenes load all scenes defined in the document instead of default one (false by default)" + "\n\t\t: -toPrintDebugInfo print additional debug information during data reading" + "\n\t\t: -assetInfo print asset information", + __FILE__, ReadGltf, g); + theCommands.Add("readgltf", + "readgltf shape file" + "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.", + __FILE__, ReadGltf, g); + theCommands.Add("WriteGltf", + "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact" + "\n\t\t: [-systemCoordSys {Zup|Yup}]=Zup" + "\n\t\t: [-comments Text] [-author Name]" + "\n\t\t: [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0" + "\n\t\t: [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd" + "\n\t\t: [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product" + "\n\t\t: [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10" + "\n\t\t: [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12" + "\n\t\t: [-unifiedQuantization]=0 [-parallel]=0" + "\n\t\t: Write XDE document into glTF file." + "\n\t\t: -trsfFormat preferred transformation format" + "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified" + "\n\t\t: -mergeFaces merge Faces within the same Mesh" + "\n\t\t: -splitIndices16 split Faces to keep 16-bit indices when -mergeFaces is enabled" + "\n\t\t: -forceUVExport always export UV coordinates" + "\n\t\t: -texturesSeparate write textures to separate files" + "\n\t\t: -nodeNameFormat name format for Nodes" + "\n\t\t: -meshNameFormat name format for Meshes" + "\n\t\t: -draco use Draco compression 3D geometric meshes" + "\n\t\t: -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order" + "\n\t\t: -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)" + "\n\t\t: -quantizeNormalBits quantization bits for normal attribute when using Draco compression (by default 10)" + "\n\t\t: -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)" + "\n\t\t: -quantizeColorBits quantization bits for color attribute when using Draco compression (by default 8)" + "\n\t\t: -quantizeGenericBits quantization bits for skinning attribute (joint indices and joint weights)" + "\n and custom attributes when using Draco compression (by default 12)" + "\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false" + "\n\t\t: -parallel use multithreading for Draco compression", + __FILE__, WriteGltf, g); + theCommands.Add("writegltf", + "writegltf shape file", + __FILE__, WriteGltf, g); +} + +//======================================================================= +//function : Factory +//purpose : +//======================================================================= +void XSDRAWGLTF::Factory(Draw_Interpretor& theDI) +{ + XSDRAWIGES::InitSelect(); + XSDRAWIGES::InitToBRep(theDI); + XSDRAWIGES::InitFromBRep(theDI); + XSDRAWSTEP::InitCommands(theDI); + XSDRAWGLTF::InitCommands(theDI); + XSDRAW::LoadDraw(theDI); +#ifdef OCCT_DEBUG + theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n"; +#endif +} diff --git a/src/XSDRAWGLTF/XSDRAWGLTF.hxx b/src/XSDRAWGLTF/XSDRAWGLTF.hxx new file mode 100644 index 0000000000..4d3dd258b7 --- /dev/null +++ b/src/XSDRAWGLTF/XSDRAWGLTF.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWGLTF_HeaderFile +#define _XSDRAWGLTF_HeaderFile + +#include +#include + +#include + +class XSDRAWGLTF +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWGLTF_HeaderFile diff --git a/src/XSDRAWIGES/XSDRAWIGES.cxx b/src/XSDRAWIGES/XSDRAWIGES.cxx index 6e29a6ecb3..a01e4c4e10 100644 --- a/src/XSDRAWIGES/XSDRAWIGES.cxx +++ b/src/XSDRAWIGES/XSDRAWIGES.cxx @@ -1,4 +1,4 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -11,9 +11,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -//gka 06.01.99 S3767 new function TPSTAT (first version) -//pdn 11.01.99 putting "return" statement for compilation on NT - #include #include #include @@ -44,64 +41,100 @@ #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 -namespace { +namespace +{ //======================================================================= //function : WriteShape //purpose : Creates a file Shape_'number' //======================================================================= -void WriteShape(const TopoDS_Shape& shape, const Standard_Integer number) -{ - char fname[110]; - sprintf(fname, "Shape_%d",number); - std::ofstream f(fname,std::ios::out | std::ios::binary); - std::cout << "Output file name : " << fname << std::endl; - f << "DBRep_DrawableShape\n"; - - BRepTools::Write(shape, f); - f.close(); -} + void WriteShape(const TopoDS_Shape& shape, const Standard_Integer number) + { + char fname[110]; + sprintf(fname, "Shape_%d", number); + std::ofstream f(fname, std::ios::out | std::ios::binary); + std::cout << "Output file name : " << fname << std::endl; + f << "DBRep_DrawableShape\n"; + + BRepTools::Write(shape, f); + f.close(); + } -TCollection_AsciiString XSDRAW_CommandPart + TCollection_AsciiString XSDRAW_CommandPart (Standard_Integer argc, const char** argv, const Standard_Integer argf) -{ - TCollection_AsciiString res; - for (Standard_Integer i = argf; i < argc; i ++) { - if (i > argf) res.AssignCat(" "); - res.AssignCat (argv[i]); + { + TCollection_AsciiString res; + for (Standard_Integer i = argf; i < argc; i++) + { + if (i > argf) res.AssignCat(" "); + res.AssignCat(argv[i]); + } + return res; } - return res; -} } //-------------------------------------------------------------- // Function : igesbrep //-------------------------------------------------------------- -static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +static Standard_Integer igesbrep(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - DeclareAndCast(IGESControl_Controller,ctl,XSDRAW::Controller()); + DeclareAndCast(IGESControl_Controller, ctl, XSDRAW::Controller()); if (ctl.IsNull()) XSDRAW::SetNorm("IGES"); // Progress indicator - Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); - Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100); - - IGESControl_Reader Reader (XSDRAW::Session(),Standard_False); + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); + Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100); + + IGESControl_Reader Reader(XSDRAW::Session(), Standard_False); Standard_Boolean aFullMode = Standard_True; Reader.WS()->SetModeStat(aFullMode); if (ctl.IsNull()) - ctl=Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller()); + ctl = Handle(IGESControl_Controller)::DownCast(XSDRAW::Controller()); - TCollection_AsciiString fnom,rnom; + TCollection_AsciiString fnom, rnom; Standard_Boolean modfic = XSDRAW::FileAndVar - (argv[1],argv[2],"IGESBREP",fnom,rnom); - if (modfic) di<<" File IGES to read : "<Show(aPSRoot); - if (modfic) readstat = Reader.ReadFile (fnom.ToCString()); + if (modfic) readstat = Reader.ReadFile(fnom.ToCString()); else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone; aPSRoot.Next(20); // On average loading takes 20% if (aPSRoot.UserBreak()) return 1; - if (readstat != IFSelect_RetDone) { - if (modfic) di<<"Could not read file "< 3); Standard_Integer modepri = 1, nent, nbs; if (fromtcl) modepri = 4; - while (modepri) { + while (modepri) + { //Roots for transfer are defined before setting mode ALL or OnlyVisible - gka //mode OnlyVisible does not work. // nent = Reader.NbRootsForTransfer(); - if (!fromtcl) { - std::cout<<"Mode (0 End, 1 Visible Roots, 2 All Roots, 3 Only One Entity, 4 Selection) :"<>str; - modepri = Draw::Atoi(str); + + // amv 26.09.2003 : this is used to avoid error of enter's simbol + char str[80]; + std::cin >> str; + modepri = Draw::Atoi(str); } - if (modepri == 0) { //fin + if (modepri == 0) + { //fin di << "Bye and good luck! \n"; break; - } + } - else if (modepri <= 2) { // 1 : Visible Roots, 2 : All Roots + else if (modepri <= 2) + { // 1 : Visible Roots, 2 : All Roots di << "All Geometry Transfer\n"; - di<<"spline_continuity (read) : "<TransferReader()->Context().Clear(); - XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess()); + XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); aPSRoot.SetName("Translation"); progress->Show(aPSRoot); - - if (modepri == 1) Reader.SetReadVisible (Standard_True); + + if (modepri == 1) Reader.SetReadVisible(Standard_True); Reader.TransferRoots(aPSRoot.Next(80)); - + if (aPSRoot.UserBreak()) return 1; // result in only one shape for all the roots // or in one shape for one root. - di<<"Count of shapes produced : "< 1) { - std::cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << std::flush; + if (Reader.NbShapes() > 1) + { + std::cout << " pass(0) one shape for all (1)\n or one shape per root (2)\n + WriteBRep (one for all : 3) (one per root : 4) : " << std::flush; answer = -1; //amv 26.09.2003 - char str_a[80]; - std::cin >> str_a; - answer = Draw::Atoi(str_a); + char str_a[80]; + std::cin >> str_a; + answer = Draw::Atoi(str_a); } - if ( answer == 0) continue; - if ( answer == 1 || answer == 3) { - TopoDS_Shape shape = Reader.OneShape(); - // save the shape - if (shape.IsNull()) { di<<"No Shape produced\n"; continue; } - char fname[110]; - Sprintf(fname, "%s", rnom.ToCString()); - di << "Saving shape in variable Draw : " << fname << "\n"; - if (answer == 3) WriteShape (shape,1); - try { - OCC_CATCH_SIGNALS - DBRep::Set(fname,shape); - } - catch(Standard_Failure const& anException) { - di << "** Exception : "; - di << anException.GetMessageString(); - di<<" ** Skip\n"; - di << "Saving shape in variable Draw : " << fname << "\n"; - WriteShape (shape,1); - } + if (answer == 0) continue; + if (answer == 1 || answer == 3) + { + TopoDS_Shape shape = Reader.OneShape(); + // save the shape + if (shape.IsNull()) { di << "No Shape produced\n"; continue; } + char fname[110]; + Sprintf(fname, "%s", rnom.ToCString()); + di << "Saving shape in variable Draw : " << fname << "\n"; + if (answer == 3) WriteShape(shape, 1); + try + { + OCC_CATCH_SIGNALS + DBRep::Set(fname, shape); + } + catch (Standard_Failure const& anException) + { + di << "** Exception : "; + di << anException.GetMessageString(); + di << " ** Skip\n"; + di << "Saving shape in variable Draw : " << fname << "\n"; + WriteShape(shape, 1); + } } - - else if (answer == 2 || answer == 4) { - Standard_Integer numshape = Reader.NbShapes(); - for (Standard_Integer inum = 1; inum <= numshape; inum++) { - // save all the shapes - TopoDS_Shape shape = Reader.Shape(inum); - if (shape.IsNull()) { di<<"No Shape produced\n"; continue; } - char fname[110]; - Sprintf(fname, "%s_%d", rnom.ToCString(),inum); - di << "Saving shape in variable Draw : " << fname << "\n"; - if (answer == 4) WriteShape (shape,inum); - try { - OCC_CATCH_SIGNALS - DBRep::Set(fname,shape); - } - catch(Standard_Failure const& anException) { - di << "** Exception : "; - di << anException.GetMessageString(); - di<<" ** Skip\n"; - } - } + + else if (answer == 2 || answer == 4) + { + Standard_Integer numshape = Reader.NbShapes(); + for (Standard_Integer inum = 1; inum <= numshape; inum++) + { + // save all the shapes + TopoDS_Shape shape = Reader.Shape(inum); + if (shape.IsNull()) { di << "No Shape produced\n"; continue; } + char fname[110]; + Sprintf(fname, "%s_%d", rnom.ToCString(), inum); + di << "Saving shape in variable Draw : " << fname << "\n"; + if (answer == 4) WriteShape(shape, inum); + try + { + OCC_CATCH_SIGNALS + DBRep::Set(fname, shape); + } + catch (Standard_Failure const& anException) + { + di << "** Exception : "; + di << anException.GetMessageString(); + di << " ** Skip\n"; + } + } } else return 0; } - else if (modepri == 3) { // One Entity - std::cout << "Only One Entity"< DRAW Shape: "< DRAW Shape: " << shname << "\n"; + di << "Now, " << nbs << " Shapes produced\n"; + TopoDS_Shape sh = Reader.Shape(nbs); + DBRep::Set(shname, sh); } } - else if (modepri == 4) { // Selection + else if (modepri == 4) + { // Selection Standard_Integer answer = 1; Handle(TColStd_HSequenceOfTransient) list; -// Selection, nommee ou via tcl. tcl : raccourcis admis -// * donne iges-visible + xst-transferrable-roots -// *r donne xst-model-roots (TOUTES racines) + // Selection, nommee ou via tcl. tcl : raccourcis admis + // * donne iges-visible + xst-transferrable-roots + // *r donne xst-model-roots (TOUTES racines) - if( fromtcl && argv[3][0]=='*' && argv[3][1]=='\0' ) { + if (fromtcl && argv[3][0] == '*' && argv[3][1] == '\0') + { di << "All Geometry Transfer\n"; - di<<"spline_continuity (read) : "<TransferReader()->Context().Clear(); - XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess()); + XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); aPSRoot.SetName("Translation"); progress->Show(aPSRoot); - - Reader.SetReadVisible (Standard_True); + + Reader.SetReadVisible(Standard_True); Reader.TransferRoots(aPSRoot.Next(80)); - + if (aPSRoot.UserBreak()) return 1; @@ -275,95 +325,108 @@ static Standard_Integer igesbrep (Draw_Interpretor& di, Standard_Integer argc, c char fname[110]; Sprintf(fname, "%s", rnom.ToCString()); di << "Saving shape in variable Draw : " << fname << "\n"; - try { + try + { OCC_CATCH_SIGNALS - DBRep::Set(fname,shape); + DBRep::Set(fname, shape); } - catch(Standard_Failure const& anException) { + catch (Standard_Failure const& anException) + { di << "** Exception : "; - di << anException.GetMessageString(); - di<<" ** Skip\n"; + di << anException.GetMessageString(); + di << " ** Skip\n"; di << "Saving shape in variable Draw : " << fname << "\n"; - WriteShape (shape,1); - } + WriteShape(shape, 1); + } return 0; } - - if(fromtcl) { - modepri = 0; // d office, une seule passe - if (argv[3][0] == '*' && argv[3][1] == 'r' && argv[3][2] == '\0') { - di<<"All Roots : "; - list = XSDRAW::GetList ("xst-model-roots"); - } - else { - TCollection_AsciiString compart = XSDRAW_CommandPart (argc,argv,3); - di<<"List given by "<Length(); - di<<"Nb entities selected : "<>str_answer; - answer = Draw::Atoi(str_answer); - } - if (answer <= 0 || answer > 3) continue; - if (answer == 3) { - for (Standard_Integer ill = 1; ill <= nbl; ill ++) { - Handle(Standard_Transient) ent = list->Value(ill); - di<<" ";// model->Print(ent,di); - } - di<<"\n"; - } - if (answer == 1 || answer == 2) { - Standard_Integer nbt = 0; - Handle(XSControl_WorkSession) thesession = Reader.WS(); - - XSDRAW::SetTransferProcess (thesession->TransferReader()->TransientProcess()); + char str_answer[80]; + std::cin >> str_answer; + answer = Draw::Atoi(str_answer); + } + if (answer <= 0 || answer > 3) continue; + if (answer == 3) + { + for (Standard_Integer ill = 1; ill <= nbl; ill++) + { + Handle(Standard_Transient) ent = list->Value(ill); + di << " ";// model->Print(ent,di); + } + di << "\n"; + } + if (answer == 1 || answer == 2) + { + Standard_Integer nbt = 0; + Handle(XSControl_WorkSession) thesession = Reader.WS(); + + XSDRAW::SetTransferProcess(thesession->TransferReader()->TransientProcess()); aPSRoot.SetName("Translation"); progress->Show(aPSRoot); Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl); for (Standard_Integer ill = 1; ill <= nbl && aPS.More(); ill++) { - nent = Reader.Model()->Number(list->Value(ill)); - if (nent == 0) continue; - if (!Reader.TransferOne(nent, aPS.Next())) - di<<"Transfer entity n0 "< DRAW Shape: "<Number(list->Value(ill)); + if (nent == 0) continue; + if (!Reader.TransferOne(nent, aPS.Next())) + di << "Transfer entity n0 " << nent << " : no result\n"; + else + { + nbs = Reader.NbShapes(); + char shname[30]; Sprintf(shname, "%s_%d", rnom.ToCString(), nbs); + di << "Transfer entity n0 " << nent << " OK -> DRAW Shape: " << shname << "\n"; + di << "Now, " << nbs << " Shapes produced\n"; + TopoDS_Shape sh = Reader.Shape(nbs); + DBRep::Set(shname, sh); nbt++; - } - } + } + } if (aPSRoot.UserBreak()) return 1; - di<<"Nb Shapes successfully produced : "<AddWithRefs(ent, protocol): ecriture de l`entite et eventuellement // . de sa matrice de transformation // . de ses sous-elements - IGESControl_Writer ICW (Interface_Static::CVal("write.iges.unit"), - Interface_Static::IVal("write.iges.brep.mode")); - di<<"unit (write) : "<) : brepiges shape [+shape][ +shape] nomfic -// c a d tant qu il y a des + on ajoute ce qui suit + // Mode d emploi (K4B ->) : brepiges shape [+shape][ +shape] nomfic + // c a d tant qu il y a des + on ajoute ce qui suit const char* nomfic = NULL; Standard_Integer npris = 0; - Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); - Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100); + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); + Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100); progress->Show(aPSRoot); Message_ProgressScope aPS(aPSRoot.Next(90), NULL, n); - for ( Standard_Integer i = 1; i < n && aPS.More(); i++) { + for (Standard_Integer i = 1; i < n && aPS.More(); i++) + { const char* nomvar = a[i]; if (a[i][0] == '+') nomvar = &(a[i])[1]; - else if (i > 1) { nomfic = a[i]; break; } + else if (i > 1) { nomfic = a[i]; break; } TopoDS_Shape Shape = DBRep::Get(nomvar); - if (ICW.AddShape (Shape, aPS.Next())) npris ++; - else if (ICW.AddGeom (DrawTrSurf::GetCurve (nomvar)) ) npris ++; - else if (ICW.AddGeom (DrawTrSurf::GetSurface (nomvar)) ) npris ++; + if (ICW.AddShape(Shape, aPS.Next())) npris++; + else if (ICW.AddGeom(DrawTrSurf::GetCurve(nomvar))) npris++; + else if (ICW.AddGeom(DrawTrSurf::GetSurface(nomvar))) npris++; } ICW.ComputeModel(); XSDRAW::SetModel(ICW.Model()); - XSDRAW::SetTransferProcess (ICW.TransferProcess()); - + XSDRAW::SetTransferProcess(ICW.TransferProcess()); + if (aPSRoot.UserBreak()) return 1; aPSRoot.SetName("Writing"); progress->Show(aPSRoot); - di<NbEntities()<<" Entities\n"; + di << npris << " Shapes written, giving " << XSDRAW::Model()->NbEntities() << " Entities\n"; - if ( ! nomfic ) // delayed write + if (!nomfic) // delayed write { - di<<" Now, to write a file, command : writeall filename\n"; + di << " Now, to write a file, command : writeall filename\n"; return 0; } // write file - if (! ICW.Write(nomfic)) di<<" Error: could not write file " << nomfic; - else di<<" File " << nomfic << " written"; + if (!ICW.Write(nomfic)) di << " Error: could not write file " << nomfic; + else di << " File " << nomfic << " written"; return 0; } @@ -466,28 +531,30 @@ static Standard_Integer brepiges (Draw_Interpretor& di, Standard_Integer n, cons // //-------------------------------------------------------------- -static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, const char** a) +static Standard_Integer testwrite(Draw_Interpretor& di, Standard_Integer n, const char** a) { - if (n != 3) - { - di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n"; - di << " Usage : " << a[0] <<" file_name shape_name\n"; - return 1; - } + if (n != 3) + { + di << "ERROR in " << a[0] << "Wrong Number of Arguments.\n"; + di << " Usage : " << a[0] << " file_name shape_name\n"; + return 1; + } IGESControl_Writer Writer; Standard_CString filename = a[1]; - TopoDS_Shape shape = DBRep::Get(a[2]); + TopoDS_Shape shape = DBRep::Get(a[2]); Standard_Boolean ok = Writer.AddShape(shape); - if(!ok){ - di<<"Shape not add\n"; + if (!ok) + { + di << "Shape not add\n"; return 1; } - - if(!(Writer.Write(filename))){ - di<<"Error on writing file\n"; + + if (!(Writer.Write(filename))) + { + di << "Error on writing file\n"; return 1; } - di<<"File Is Written\n"; + di << "File Is Written\n"; return 0; } //-------------------------------------------------------------- @@ -496,15 +563,15 @@ static Standard_Integer testwrite (Draw_Interpretor& di, Standard_Integer n, con //-------------------------------------------------------------- -static Standard_Integer igesparam (Draw_Interpretor& di, Standard_Integer , const char** ) +static Standard_Integer igesparam(Draw_Interpretor& di, Standard_Integer, const char**) { -// liste des parametres - di<<"List of parameters which control IGES :\n"; - di<<" unit : write.iges.unit\n mode write : write.iges.brep.mode\n spline_continuity (read) : read.iges.bspline.continuity\nSee definition by defparam, read/edit value by param\n"; - di<<"unit (write) : "<NbWords(); + // Standard_Integer narg = pilot->NbWords(); Standard_Integer narg = n; - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); TColStd_Array1OfAsciiString strarg(1, 3); TColStd_Array1OfAsciiString typarg(1, 3); - strarg.SetValue(1,"xst-type(CurveOnSurface)"); - strarg.SetValue(2,"xst-type(Boundary)"); - strarg.SetValue(3,"xst-type(Loop)"); - typarg.SetValue(1,"IGESGeom_TrimmedSurface"); - typarg.SetValue(2,"IGESGeom_BoundedSurface"); - typarg.SetValue(3,"IGESSolid_Face"); - if (TP.IsNull()) { di<<"No Transfer Read\n"; return 1; } - Standard_Integer nbFaces = 0, totFaces = 0 ; - Handle(IFSelect_WorkSession) WS = pilot->Session(); - Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult(); - Standard_Integer k=0; - if(narg > 1) { -// TCollection_AsciiString Arg = pilot->Word(1); + strarg.SetValue(1, "xst-type(CurveOnSurface)"); + strarg.SetValue(2, "xst-type(Boundary)"); + strarg.SetValue(3, "xst-type(Loop)"); + typarg.SetValue(1, "IGESGeom_TrimmedSurface"); + typarg.SetValue(2, "IGESGeom_BoundedSurface"); + typarg.SetValue(3, "IGESSolid_Face"); + if (TP.IsNull()) { di << "No Transfer Read\n"; return 1; } + Standard_Integer nbFaces = 0, totFaces = 0; + Handle(IFSelect_WorkSession) WS = pilot->Session(); + Transfer_IteratorOfProcessForTransient itrp = TP->AbnormalResult(); + Standard_Integer k = 0; + if (narg > 1) + { + // TCollection_AsciiString Arg = pilot->Word(1); TCollection_AsciiString Arg(a[1]); - for(k=1 ; k<=3;k++ ) { - if(typarg.Value(k).Location(Arg,1,typarg.Value(k).Length()) != 0) break; + for (k = 1; k <= 3; k++) + { + if (typarg.Value(k).Location(Arg, 1, typarg.Value(k).Length()) != 0) break; } - } - if( k == 4) {di<< "Invalid argument\n"; return 0; } - for(Standard_Integer j = 1 ; j <= 3; j++) { + } + if (k == 4) { di << "Invalid argument\n"; return 0; } + for (Standard_Integer j = 1; j <= 3; j++) + { TColStd_MapOfTransient aMap; - if(narg == 1) k=j; - Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(),strarg.Value(k).ToCString()); - if (!list.IsNull()) itrp.Filter (list); - else { + if (narg == 1) k = j; + Handle(TColStd_HSequenceOfTransient) list = IFSelect_Functions::GiveList(pilot->Session(), strarg.Value(k).ToCString()); + if (!list.IsNull()) itrp.Filter(list); + else + { di << "No untrimmed faces\n"; return 0; } - for (itrp.Start(); itrp.More(); itrp.Next()) { + for (itrp.Start(); itrp.More(); itrp.Next()) + { Handle(Standard_Transient) ent = itrp.Starting(); - Handle(TColStd_HSequenceOfTransient) super = WS->Sharings (ent); - if (!super.IsNull()) { - Standard_Integer nb = super->Length(); - if (nb > 0) { - for (Standard_Integer i = 1; i <= nb; i++) - if (super->Value(i)->IsKind (typarg.Value(k).ToCString())) { - if(aMap.Add(super->Value(i))) nbFaces++; - } - } + Handle(TColStd_HSequenceOfTransient) super = WS->Sharings(ent); + if (!super.IsNull()) + { + Standard_Integer nb = super->Length(); + if (nb > 0) + { + for (Standard_Integer i = 1; i <= nb; i++) + if (super->Value(i)->IsKind(typarg.Value(k).ToCString())) + { + if (aMap.Add(super->Value(i))) nbFaces++; + } + } } } - if(nbFaces != 0) { - if( j == 1 ) di << "Number of untrimmed faces: \n"; - switch(k){ - case 1: - di << "Trimmed Surface: \n"; break; - case 2: - di << "Bounded Surface: \n"; break; - case 3: - di << "Face: \n"; break; + if (nbFaces != 0) + { + if (j == 1) di << "Number of untrimmed faces: \n"; + switch (k) + { + case 1: + di << "Trimmed Surface: \n"; break; + case 2: + di << "Bounded Surface: \n"; break; + case 3: + di << "Face: \n"; break; } TColStd_MapIteratorOfMapOfTransient itmap; Standard_SStream aTmpStream; - for(itmap.Initialize(aMap); itmap.More(); itmap.Next()) { - XSDRAW::Model()->Print (itmap.Key(), aTmpStream); + for (itmap.Initialize(aMap); itmap.More(); itmap.Next()) + { + XSDRAW::Model()->Print(itmap.Key(), aTmpStream); aTmpStream << " "; } di << aTmpStream.str().c_str(); di << "\n"; - di << "\nNumber:"<< nbFaces << "\n"; + di << "\nNumber:" << nbFaces << "\n"; totFaces += nbFaces; } - if(narg > 1) break; + if (narg > 1) break; nbFaces = 0; } - - if(totFaces == 0) di << "No untrimmed faces\n"; + + if (totFaces == 0) di << "No untrimmed faces\n"; else di << "Total number :" << totFaces << "\n"; return 0; } @@ -600,37 +678,40 @@ static Standard_Integer XSDRAWIGES_tplosttrim (Draw_Interpretor& di, Standard_In // Function : TPSTAT // //-------------------------------------------------------------- -static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer n, const char** a) +static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di, Standard_Integer n, const char** a) { Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot(); Standard_Integer argc = n;//= pilot->NbWords(); const Standard_CString arg1 = a[1];//pilot->Arg(1); - const Handle(Transfer_TransientProcess) &TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); + const Handle(Transfer_TransientProcess)& TP = XSControl::Session(pilot)->TransferReader()->TransientProcess(); IGESControl_Reader read; //(XSControl::Session(pilot),Standard_False); // **** tpent **** Handle(Interface_InterfaceModel) model = TP->Model(); - if (model.IsNull()) {di<<"No Transfer Read\n"; return -1;} + if (model.IsNull()) { di << "No Transfer Read\n"; return -1; } Handle(XSControl_WorkSession) thesession = read.WS(); thesession->SetMapReader(TP); Standard_Integer mod1 = 0; - if (argc > 1) { + if (argc > 1) + { char a2 = arg1[1]; if (a2 == '\0') a2 = '!'; - switch (arg1[0]) { - case 'g' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_GeneralInfo);break; - case 'c' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_CountByItem); break; - case 'C' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ListByItem); break; - case 'r' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_ResultCount);break; - case 's' : read.PrintTransferInfo(IFSelect_FailAndWarn,IFSelect_Mapping);break; - case '?' : mod1 = -1; break; - default : mod1 = -2; break; + switch (arg1[0]) + { + case 'g': read.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_GeneralInfo); break; + case 'c': read.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_CountByItem); break; + case 'C': read.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_ListByItem); break; + case 'r': read.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_ResultCount); break; + case 's': read.PrintTransferInfo(IFSelect_FailAndWarn, IFSelect_Mapping); break; + case '?': mod1 = -1; break; + default: mod1 = -2; break; } } - if (mod1 < -1) di<<"Unknown Mode\n"; - if (mod1 < 0) { - di<<"Modes available :\n" - <<"g : general c : checks (count) C (list)\n" - <<"r : number of CasCade resulting shapes\n" - <<"s : mapping between IGES entities and CasCade shapes\n"; + if (mod1 < -1) di << "Unknown Mode\n"; + if (mod1 < 0) + { + di << "Modes available :\n" + << "g : general c : checks (count) C (list)\n" + << "r : number of CasCade resulting shapes\n" + << "s : mapping between IGES entities and CasCade shapes\n"; if (mod1 < -1) return -1; return 0; } @@ -639,8 +720,9 @@ static Standard_Integer XSDRAWIGES_TPSTAT(Draw_Interpretor& di,Standard_Integer static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const char** a) { - if(argc < 3) { - di<<"etest igesfile shape\n"; + if (argc < 3) + { + di << "etest igesfile shape\n"; return 0; } IGESControl_Reader aReader; @@ -648,15 +730,15 @@ static Standard_Integer etest(Draw_Interpretor& di, Standard_Integer argc, const aReader.SetReadVisible(Standard_True); aReader.TransferRoots(); TopoDS_Shape shape = aReader.OneShape(); - DBRep::Set(a[2],shape); + DBRep::Set(a[2], shape); return 0; } extern "C" { -static void cleanpilot () -{ - XSDRAW::Session()->ClearData(1); -} + static void cleanpilot() + { + XSDRAW::Session()->ClearData(1); + } } @@ -665,14 +747,121 @@ static void cleanpilot () // //-------------------------------------------------------------- -void XSDRAWIGES::InitSelect () +void XSDRAWIGES::InitSelect() { Handle(IGESSelect_Activator) igesact = new IGESSelect_Activator; IGESControl_Controller::Init(); -// XSDRAW::SetNorm ("IGES"); trop tot - XSDRAW::SetController (XSControl_Controller::Recorded("iges")); - - atexit (cleanpilot); + // XSDRAW::SetNorm ("IGES"); trop tot + XSDRAW::SetController(XSControl_Controller::Recorded("iges")); + + atexit(cleanpilot); +} + +//======================================================================= +//function : ReadIges +//purpose : Read IGES to DECAF document +//======================================================================= +static Standard_Integer ReadIges(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: read IGES file to a document\n"; + return 0; + } + Handle(IGESCAFControl_ConfigurationNode) aNode = + new IGESCAFControl_ConfigurationNode(); + Standard_Integer onlyvisible = Interface_Static::IVal("read.iges.onlyvisible"); + aNode->InternalParameters.ReadOnlyVisible = onlyvisible == 1; + if (theNbArgs == 4) + { + Standard_Boolean aMode = Standard_True; + for (Standard_Integer i = 0; theArgVec[3][i]; i++) + switch (theArgVec[3][i]) + { + case '-': aMode = Standard_False; break; + case '+': aMode = Standard_True; break; + case 'c': aNode->InternalParameters.ReadColor = aMode; break; + case 'n': aNode->InternalParameters.ReadName = aMode; break; + case 'l': aNode->InternalParameters.ReadLayer = aMode; break; + } + } + Handle(TDocStd_Document) aDoc; + if (!DDocStd::GetDocument(theArgVec[1], aDoc, Standard_False)) + { + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + anApp->NewDocument("BinXCAF", aDoc); + TDataStd_Name::Set(aDoc->GetData()->Root(), theArgVec[1]); + Handle(DDocStd_DrawDocument) aDrawD = new DDocStd_DrawDocument(aDoc); + Draw::Set(theArgVec[1], aDrawD); + } + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); + Handle(IGESCAFControl_Provider) aProvider = + new IGESCAFControl_Provider(aNode); + aProvider->SetToUpdateStaticParameters(false); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Read(theArgVec[2], aDoc, aWS, aProgress->Start())) + { + theDI << "Error: Can't read IGES file\n"; + return 1; + } + CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); + Message::SendInfo() << "Document saved with name " << theArgVec[1]; + return 0; +} + +//======================================================================= +//function : WriteIges +//purpose : Write DECAF document to IGES +//======================================================================= +//======================================================================= +static Standard_Integer WriteIges(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Use: " << theArgVec[0] << " Doc filename [mode]: write document to IGES file\n"; + return 0; + } + Handle(IGESCAFControl_ConfigurationNode) aNode = + new IGESCAFControl_ConfigurationNode(); + Handle(TDocStd_Document) aDoc; + DDocStd::GetDocument(theArgVec[1], aDoc); + if (aDoc.IsNull()) + { + theDI << theArgVec[1] << " is not a document\n"; + return 1; + } + if (theNbArgs == 4) + { + Standard_Boolean aMode = Standard_True; + for (Standard_Integer i = 0; theArgVec[3][i]; i++) + switch (theArgVec[3][i]) + { + case '-': aMode = Standard_False; break; + case '+': aMode = Standard_True; break; + case 'c': aNode->InternalParameters.WriteColor = aMode; break; + case 'n': aNode->InternalParameters.WriteName = aMode; break; + case 'l': aNode->InternalParameters.WriteLayer = aMode; break; + } + } + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); + Handle(IGESCAFControl_Provider) aProvider = + new IGESCAFControl_Provider(aNode); + aProvider->SetToUpdateStaticParameters(false); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + const TCollection_AsciiString aPath = theArgVec[2]; + if (!aProvider->Write(aPath, aDoc, aWS, aProgress->Start())) + { + theDI << "Error: Can't write IGES file\n"; + return 1; + } + CollectActiveWorkSessions(aWS, aPath, THE_PREVIOUS_WORK_SESSIONS); + return 0; } @@ -681,17 +870,19 @@ void XSDRAWIGES::InitSelect () //purpose : //======================================================================= -void XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands) +void XSDRAWIGES::InitToBRep(Draw_Interpretor& theCommands) { const char* g = "DE: IGES"; - theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g); - theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g); - theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g); - theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g); - theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g); - theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g); - theCommands.Add("etest", "test of eviewer", __FILE__, etest, g); - + theCommands.Add("igesbrep", "igesbrep [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g); + theCommands.Add("testreadiges", "testreadiges [file else already loaded model] [name DRAW]", __FILE__, testread, g); + theCommands.Add("igesread", "igesread [file else already loaded model] [name DRAW]", __FILE__, igesbrep, g); + theCommands.Add("igesparam", "igesparam ->list, + name ->one param, + name val->change", __FILE__, igesparam, g); + theCommands.Add("TPSTAT", " ", __FILE__, XSDRAWIGES_TPSTAT, g); + theCommands.Add("tplosttrim", "number of untrimmed faces during last transfer", __FILE__, XSDRAWIGES_tplosttrim, g); + theCommands.Add("etest", "test of eviewer", __FILE__, etest, g); + + theCommands.Add("ReadIges", "Doc filename: Read IGES file to DECAF document", __FILE__, ReadIges, g); + theCommands.Add("WriteIges", "Doc filename: Write DECAF document to IGES file", __FILE__, WriteIges, g); } @@ -700,9 +891,9 @@ void XSDRAWIGES::InitToBRep (Draw_Interpretor& theCommands) //purpose : //======================================================================= -void XSDRAWIGES::InitFromBRep (Draw_Interpretor& theCommands) +void XSDRAWIGES::InitFromBRep(Draw_Interpretor& theCommands) { const char* g = "DE: IGES"; - theCommands.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g); - theCommands.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g); + theCommands.Add("brepiges", "brepiges sh1 [+sh2 [+sh3 ..]] filename.igs", __FILE__, brepiges, g); + theCommands.Add("testwriteiges", "testwriteiges filename.igs shape", __FILE__, testwrite, g); } diff --git a/src/XSDRAWIGES/XSDRAWIGES.hxx b/src/XSDRAWIGES/XSDRAWIGES.hxx index e78351cdd1..55fb43153c 100644 --- a/src/XSDRAWIGES/XSDRAWIGES.hxx +++ b/src/XSDRAWIGES/XSDRAWIGES.hxx @@ -1,7 +1,4 @@ -// Created on: 1995-03-15 -// Created by: Christian CAILLET -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -22,45 +19,15 @@ #include - -//! XSDRAW for IGES : commands IGESSelect, Controller, transfer class XSDRAWIGES { -public: - DEFINE_STANDARD_ALLOC +public: - - //! Inits IGESSelect commands, for DRAW - Standard_EXPORT static void InitSelect(); - - //! Inits IGESToBRep for DRAW - Standard_EXPORT static void InitToBRep (Draw_Interpretor& theCommands); - - //! Inits BRepToIGES for DRAW - Standard_EXPORT static void InitFromBRep (Draw_Interpretor& theCommands); - - - - -protected: - - - - - -private: - - - - + Standard_EXPORT static void Init(); + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); }; - - - - - - #endif // _XSDRAWIGES_HeaderFile diff --git a/src/XSDRAWOBJ/FILES b/src/XSDRAWOBJ/FILES new file mode 100644 index 0000000000..9659ffd3c3 --- /dev/null +++ b/src/XSDRAWOBJ/FILES @@ -0,0 +1,2 @@ +XSDRAWOBJ.cxx +XSDRAWOBJ.hxx diff --git a/src/XSDRAWOBJ/XSDRAWOBJ.cxx b/src/XSDRAWOBJ/XSDRAWOBJ.cxx new file mode 100644 index 0000000000..ef7d7ce3a9 --- /dev/null +++ b/src/XSDRAWOBJ/XSDRAWOBJ.cxx @@ -0,0 +1,522 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#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 : ReadObj +//purpose : Reads OBJ file +//============================================================================= +static Standard_Integer ReadObj(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + TCollection_AsciiString aDestName, aFilePath; + Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + Standard_Boolean toUseExistingDoc = Standard_False; + //Standard_Real aFileUnitFactor = -1.0; + //RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup; + //Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False; + Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj"); + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArgCase(theArgVec[anArgIter]); + anArgCase.LowerCase(); + if (anArgIter + 1 < theNbArgs + && (anArgCase == "-unit" + || anArgCase == "-units" + || anArgCase == "-fileunit" + || anArgCase == "-fileunits")) + { + const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]); + aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); + if (aNode->InternalParameters.FileLengthUnit <= 0.0) + { + theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n"; + return 1; + } + } + else if (anArgIter + 1 < theNbArgs + && (anArgCase == "-filecoordinatesystem" + || anArgCase == "-filecoordsystem" + || anArgCase == "-filecoordsys")) + { + if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS)) + { + theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + else if (anArgIter + 1 < theNbArgs + && (anArgCase == "-resultcoordinatesystem" + || anArgCase == "-resultcoordsystem" + || anArgCase == "-resultcoordsys" + || anArgCase == "-rescoordsys")) + { + if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) + { + theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + else if (anArgCase == "-singleprecision" + || anArgCase == "-singleprec") + { + aNode->InternalParameters.ReadSinglePrecision = Standard_True; + if (anArgIter + 1 < theNbArgs + && Draw::ParseOnOff(theArgVec[anArgIter + 1], + aNode->InternalParameters.ReadSinglePrecision)) + { + ++anArgIter; + } + } + else if (isNoDoc + && (anArgCase == "-singleface" + || anArgCase == "-singletriangulation")) + { + aNode->InternalParameters.ReadCreateShapes = Standard_True; + } + else if (!isNoDoc + && (anArgCase == "-nocreate" + || anArgCase == "-nocreatedoc")) + { + toUseExistingDoc = Standard_True; + if (anArgIter + 1 < theNbArgs + && Draw::ParseOnOff(theArgVec[anArgIter + 1], toUseExistingDoc)) + { + ++anArgIter; + } + } + //else if (anArgCase == "-listexternalfiles" + // || anArgCase == "-listexternals" + // || anArgCase == "-listexternal" + // || anArgCase == "-external" + // || anArgCase == "-externalfiles") + //{ + // toListExternalFiles = Standard_True; + //} + else if (aDestName.IsEmpty()) + { + aDestName = theArgVec[anArgIter]; + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + Handle(TDocStd_Document) aDoc; + if (!isNoDoc) + { + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + Standard_CString aNameVar = aDestName.ToCString(); + DDocStd::GetDocument(aNameVar, aDoc, Standard_False); + if (aDoc.IsNull()) + { + if (toUseExistingDoc) + { + theDI << "Error: document with name " << aDestName << " does not exist\n"; + return 1; + } + anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); + } + else if (!toUseExistingDoc) + { + theDI << "Error: document with name " << aDestName << " already exists\n"; + return 1; + } + } + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + Standard_Boolean aReadStat = Standard_False; + if (isNoDoc) + { + TopoDS_Shape aShape; + aReadStat = aProvider->Read(aFilePath, aShape, aWS, aProgress->Start()); + if (aReadStat) + { + DBRep::Set(aDestName.ToCString(), aShape); + } + } + else + { + aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); + if (aReadStat) + { + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); + TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName); + Draw::Set(aDestName.ToCString(), aDrawDoc); + } + } + if (!aReadStat) + { + theDI << "Cannot read any relevant data from the Obj file\n"; + return 1; + } + return 0; +} + +//============================================================================= +//function : WriteObj +//purpose : Writes OBJ file +//============================================================================= +static Standard_Integer WriteObj(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + TCollection_AsciiString anObjFilePath; + Handle(TDocStd_Document) aDoc; + Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + //TColStd_IndexedDataMapOfStringString aFileInfo; + //Standard_Real aFileUnitFactor = -1.0; + //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup; + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArgCase(theArgVec[anArgIter]); + anArgCase.LowerCase(); + if (anArgIter + 1 < theNbArgs + && (anArgCase == "-unit" + || anArgCase == "-units" + || anArgCase == "-fileunit" + || anArgCase == "-fileunits")) + { + const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]); + aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); + if (aNode->InternalParameters.FileLengthUnit <= 0.0) + { + theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n"; + return 1; + } + } + else if (anArgIter + 1 < theNbArgs + && (anArgCase == "-filecoordinatesystem" + || anArgCase == "-filecoordsystem" + || anArgCase == "-filecoordsys")) + { + if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS)) + { + theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + else if (anArgIter + 1 < theNbArgs + && (anArgCase == "-systemcoordinatesystem" + || anArgCase == "-systemcoordsystem" + || anArgCase == "-systemcoordsys" + || anArgCase == "-syscoordsys")) + { + if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) + { + theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + else if (anArgCase == "-comments" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; + } + else if (anArgCase == "-author" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; + } + else if (aDoc.IsNull()) + { + Standard_CString aNameVar = theArgVec[anArgIter]; + DDocStd::GetDocument(aNameVar, aDoc, false); + if (aDoc.IsNull()) + { + TopoDS_Shape aShape = DBRep::Get(aNameVar); + if (aShape.IsNull()) + { + theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n"; + return 1; + } + anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); + Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); + aShapeTool->AddShape(aShape); + } + } + else if (anObjFilePath.IsEmpty()) + { + anObjFilePath = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (anObjFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) + { + theDI << "Error: Mesh writing has been failed.\n"; + } + return 0; +} + +//======================================================================= +//function : InitCommands +//purpose : +//======================================================================= +void XSDRAWOBJ::InitCommands(Draw_Interpretor& theCommands) +{ + const char* g = "XSTEP-STL/VRML"; // Step transfer file commands + theCommands.Add("ReadObj", + "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" + "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" + "\n\t\t: [-listExternalFiles] [-noCreateDoc]" + "\n\t\t: Read OBJ file into XDE document." + "\n\t\t: -fileUnit length unit of OBJ file content;" + "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified." + "\n\t\t: -resultCoordSys result coordinate system; Zup when not specified." + "\n\t\t: -singlePrecision truncate vertex data to single precision during read; FALSE by default." + "\n\t\t: -listExternalFiles do not read mesh and only list external files." + "\n\t\t: -noCreateDoc read into existing XDE document.", + __FILE__, ReadObj, g); + theCommands.Add("readobj", + "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" + "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" + "\n\t\t: [-singleFace]" + "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document." + "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.", + __FILE__, ReadObj, g); + theCommands.Add("WriteObj", + "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" + "\n\t\t: [-systemCoordSys {Zup|Yup}]" + "\n\t\t: [-comments Text] [-author Name]" + "\n\t\t: Write XDE document into OBJ file." + "\n\t\t: -fileUnit length unit of OBJ file content;" + "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified." + "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.", + __FILE__, WriteObj, g); + theCommands.Add("writeobj", + "writeobj shape file", + __FILE__, WriteObj, g); +} diff --git a/src/XSDRAWOBJ/XSDRAWOBJ.hxx b/src/XSDRAWOBJ/XSDRAWOBJ.hxx new file mode 100644 index 0000000000..897bcdaf4d --- /dev/null +++ b/src/XSDRAWOBJ/XSDRAWOBJ.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWOBJ_HeaderFile +#define _XSDRAWOBJ_HeaderFile + +#include +#include + +#include + +class XSDRAWOBJ +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWOBJ_HeaderFile diff --git a/src/XSDRAWPLY/FILES b/src/XSDRAWPLY/FILES new file mode 100644 index 0000000000..3501638378 --- /dev/null +++ b/src/XSDRAWPLY/FILES @@ -0,0 +1,2 @@ +XSDRAWPLY.cxx +XSDRAWPLY.hxx diff --git a/src/XSDRAWPLY/XSDRAWPLY.cxx b/src/XSDRAWPLY/XSDRAWPLY.cxx new file mode 100644 index 0000000000..10f8bdaf49 --- /dev/null +++ b/src/XSDRAWPLY/XSDRAWPLY.cxx @@ -0,0 +1,542 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#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 : writeply +//purpose : write PLY file +//======================================================================= +static Standard_Integer WritePly(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + Handle(TDocStd_Document) aDoc; + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + TCollection_AsciiString aShapeName, aFileName; + Handle(RWPly_ConfigurationNode) aNode = new RWPly_ConfigurationNode(); + Standard_Real aDist = 0.0; + Standard_Real aDens = Precision::Infinite(); + Standard_Real aTol = Precision::Confusion(); + //bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false; + //TColStd_IndexedDataMapOfStringString aFileInfo; + bool isPntSet = false, isDensityPoints = false; + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArg(theArgVec[anArgIter]); + anArg.LowerCase(); + if (anArg == "-normal") + { + aNode->InternalParameters.WriteNormals = + Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArg == "-nonormal") + { + aNode->InternalParameters.WriteNormals = + !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArg == "-color" + || anArg == "-nocolor" + || anArg == "-colors" + || anArg == "-nocolors") + { + aNode->InternalParameters.WriteColors = + Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArg == "-uv" + || anArg == "-nouv") + { + aNode->InternalParameters.WriteTexCoords = + Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); + } + else if (anArg == "-partid") + { + aNode->InternalParameters.WritePartId = + Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); + aNode->InternalParameters.WriteFaceId = + aNode->InternalParameters.WriteFaceId && + !aNode->InternalParameters.WritePartId; + } + else if (anArg == "-surfid" + || anArg == "-surfaceid" + || anArg == "-faceid") + { + aNode->InternalParameters.WriteFaceId = + Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); + aNode->InternalParameters.WritePartId = + aNode->InternalParameters.WritePartId && + !aNode->InternalParameters.WriteFaceId; + } + else if (anArg == "-pntset" + || anArg == "-pntcloud" + || anArg == "-pointset" + || anArg == "-pointcloud" + || anArg == "-cloud" + || anArg == "-points") + { + isPntSet = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); + } + else if ((anArg == "-dist" + || anArg == "-distance") + && anArgIter + 1 < theNbArgs + && Draw::ParseReal(theArgVec[anArgIter + 1], aDist)) + { + ++anArgIter; + isPntSet = true; + if (aDist < 0.0) + { + theDI << "Syntax error: -distance value should be >= 0.0\n"; + return 1; + } + aDist = Max(aDist, Precision::Confusion()); + } + else if ((anArg == "-dens" + || anArg == "-density") + && anArgIter + 1 < theNbArgs + && Draw::ParseReal(theArgVec[anArgIter + 1], aDens)) + { + ++anArgIter; + isDensityPoints = Standard_True; + isPntSet = true; + if (aDens <= 0.0) + { + theDI << "Syntax error: -density value should be > 0.0\n"; + return 1; + } + } + else if ((anArg == "-tol" + || anArg == "-tolerance") + && anArgIter + 1 < theNbArgs + && Draw::ParseReal(theArgVec[anArgIter + 1], aTol)) + { + ++anArgIter; + isPntSet = true; + if (aTol < Precision::Confusion()) + { + theDI << "Syntax error: -tol value should be >= " + << Precision::Confusion() << "\n"; + return 1; + } + } + else if (anArg == "-comments" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; + } + else if (anArg == "-author" + && anArgIter + 1 < theNbArgs) + { + aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; + } + else if (aDoc.IsNull()) + { + if (aShapeName.IsEmpty()) + { + aShapeName = theArgVec[anArgIter]; + } + + Standard_CString aNameVar = theArgVec[anArgIter]; + DDocStd::GetDocument(aNameVar, aDoc, false); + if (aDoc.IsNull()) + { + TopoDS_Shape aShape = DBRep::Get(aNameVar); + if (!aShape.IsNull()) + { + anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); + Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); + aShapeTool->AddShape(aShape); + } + } + } + else if (aFileName.IsEmpty()) + { + aFileName = theArgVec[anArgIter]; + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aDoc.IsNull() + && !aShapeName.IsEmpty()) + { + theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document\n"; + return 1; + } + else if (aDoc.IsNull() + || aFileName.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + + if (isPntSet) + { + TDF_LabelSequence aRootLabels; + Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); + aShapeTool->GetFreeShapes(aRootLabels); + if (aRootLabels.IsEmpty()) + { + theDI << "Error: empty document\n"; + return 1; + } + class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext + { + public: + PointCloudPlyWriter(Standard_Real theTol) + : BRepLib_PointCloudShape(TopoDS_Shape(), theTol) + {} + + void AddFaceColor(const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor) + { + myFaceColor.Bind(theFace, theColor); + } + + protected: + virtual void addPoint(const gp_Pnt& thePoint, + const gp_Vec& theNorm, + const gp_Pnt2d& theUV, + const TopoDS_Shape& theFace) + { + Graphic3d_Vec4ub aColor; + myFaceColor.Find(theFace, aColor); + RWPly_PlyWriterContext::WriteVertex(thePoint, + Graphic3d_Vec3((float)theNorm.X(), (float)theNorm.Y(), (float)theNorm.Z()), + Graphic3d_Vec2((float)theUV.X(), (float)theUV.Y()), + aColor); + } + + private: + NCollection_DataMap myFaceColor; + }; + + PointCloudPlyWriter aPlyCtx(aTol); + aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals); + aPlyCtx.SetColors(aNode->InternalParameters.WriteColors); + aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords); + + TopoDS_Compound aComp; + BRep_Builder().MakeCompound(aComp); + for (XCAFPrs_DocumentExplorer aDocExplorer(aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes); + aDocExplorer.More(); aDocExplorer.Next()) + { + const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current(); + for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next()) + { + BRep_Builder().Add(aComp, aFaceIter.Face()); + Graphic3d_Vec4ub aColorVec(255); + if (aFaceIter.HasFaceColor()) + { + Graphic3d_Vec4 aColorF = aFaceIter.FaceColor(); + aColorVec.SetValues((unsigned char)int(aColorF.r() * 255.0f), + (unsigned char)int(aColorF.g() * 255.0f), + (unsigned char)int(aColorF.b() * 255.0f), + (unsigned char)int(aColorF.a() * 255.0f)); + } + aPlyCtx.AddFaceColor(aFaceIter.Face(), aColorVec); + } + } + aPlyCtx.SetShape(aComp); + + Standard_Integer aNbPoints = isDensityPoints + ? aPlyCtx.NbPointsByDensity(aDens) + : aPlyCtx.NbPointsByTriangulation(); + if (aNbPoints <= 0) + { + theDI << "Error: unable to generate points\n"; + return 1; + } + + if (!aPlyCtx.Open(aFileName) + || !aPlyCtx.WriteHeader(aNbPoints, 0, TColStd_IndexedDataMapOfStringString())) + { + theDI << "Error: unable to create file '" << aFileName << "'\n"; + return 1; + } + + Standard_Boolean isDone = isDensityPoints + ? aPlyCtx.GeneratePointsByDensity(aDens) + : aPlyCtx.GeneratePointsByTriangulation(); + if (!isDone) + { + theDI << "Error: Point cloud was not generated in file '" << aFileName << "'\n"; + return 1; + } + else if (!aPlyCtx.Close()) + { + theDI << "Error: Point cloud file '" << aFileName << "' was not written\n"; + return 1; + } + else + { + theDI << aNbPoints << "\n"; + } + } + else + { + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(RWPly_Provider) aProvider = new RWPly_Provider(aNode); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) + { + theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; + return 1; + } + } + 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("WritePly", R"( +WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0 + [-pointCloud {0|1}]=0 [-distance Value]=0.0 [-density Value] [-tolerance Value] +Write document or triangulated shape into PLY file. + -normals write per-vertex normals + -colors write per-vertex colors + -uv write per-vertex UV coordinates + -partId write per-element part index (alternative to -faceId) + -faceId write per-element face index (alternative to -partId) + +Generate point cloud out of the shape and write it into PLY file. + -pointCloud write point cloud instead without triangulation indices + -distance sets distance from shape into the range [0, Value]; + -density sets density of points to generate randomly on surface; + -tolerance sets tolerance; default value is Precision::Confusion(); +)", __FILE__, WritePly, g); + theCommands.Add("writeply", + "writeply shape file", + __FILE__, WritePly, g); +} + +//======================================================================= +//function : Factory +//purpose : +//======================================================================= +void XSDRAWPLY::Factory(Draw_Interpretor& theDI) +{ + XSDRAWIGES::InitSelect(); + XSDRAWIGES::InitToBRep(theDI); + XSDRAWIGES::InitFromBRep(theDI); + XSDRAWSTLVRML::InitCommands(theDI); + XSDRAW::LoadDraw(theDI); +#ifdef OCCT_DEBUG + theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n"; +#endif +} diff --git a/src/XSDRAWPLY/XSDRAWPLY.hxx b/src/XSDRAWPLY/XSDRAWPLY.hxx new file mode 100644 index 0000000000..385b605560 --- /dev/null +++ b/src/XSDRAWPLY/XSDRAWPLY.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWPLY_HeaderFile +#define _XSDRAWPLY_HeaderFile + +#include +#include + +#include + +class XSDRAWPLY +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWPLY_HeaderFile diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index 7ceff7987b..b9a6e0203a 100644 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -1,4 +1,4 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -11,8 +11,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -//:k8 abv 6 Jan 98: using parameter "step.group" for writing assemblies/shapes - #include #include #include @@ -45,31 +43,83 @@ #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 // Pour le transfert (write) // Pour NewModel et Write : definition de produit (temporaire ...) // steptrans extern "C" { -static void cleanpilot () -{ - XSDRAW::Session()->ClearData(1); -} + static void cleanpilot() + { + XSDRAW::Session()->ClearData(1); + } } +//======================================================================= +//function : GetLengthUnit +//purpose : Gets length unit value from static interface and document in M +//======================================================================= +static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = nullptr) +{ + if (!theDoc.IsNull()) + { + Standard_Real aUnit = 1.; + if (XCAFDoc_DocumentTool::GetLengthUnit(theDoc, aUnit, + UnitsMethods_LengthUnit_Millimeter)) + { + return aUnit; + } + } + XSAlgo::AlgoContainer()->PrepareForTransfer(); + return UnitsMethods::GetCasCadeLengthUnit(); +} //======================================================================= //function : Init //purpose : //======================================================================= -void XSDRAWSTEP::Init () +void XSDRAWSTEP::Init() { Handle(StepSelect_Activator) stepact = new StepSelect_Activator; if (STEPControl_Controller::Init()) // XSDRAW::SetNorm("STEP AP-214"); trop tot XSDRAW::SetController(XSControl_Controller::Recorded("STEP")); - - atexit (cleanpilot); + + atexit(cleanpilot); } // ######## COMMANDE stepread : teste le Reader ######### @@ -79,28 +129,29 @@ void XSDRAWSTEP::Init () //purpose : //======================================================================= -static Standard_Integer stepread (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +static Standard_Integer stepread(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if (argc < 3) { + if (argc < 3) + { di << "Use: stepread [file] [f or r (type of model full or reduced)]\n"; return 1; } // On admet le controller AP214 ou une variante - DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); + DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); // Progress indicator - Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); - Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100); + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); + Message_ProgressScope aPSRoot(progress->Start(), "Reading", 100); - STEPControl_Reader sr (XSDRAW::Session(),Standard_False); - TCollection_AsciiString fnom,rnom; + STEPControl_Reader sr(XSDRAW::Session(), Standard_False); + TCollection_AsciiString fnom, rnom; Standard_Boolean modfic = XSDRAW::FileAndVar - (argv[1],argv[2],"STEP",fnom,rnom); - if (modfic) di<<" File STEP to read : "< k ) + if (argc > k) { - if(argv[k][0] == 'f' || argv[3][0] == 'F') + if (argv[k][0] == 'f' || argv[3][0] == 'F') { aFullMode = Standard_True; k++; } - else if(argv[k][0] == 'r' || argv[3][0] == 'R') + else if (argv[k][0] == 'r' || argv[3][0] == 'R') { aFullMode = Standard_False; k++; } else fromtcl = Standard_True; - + } - if(!fromtcl) + if (!fromtcl) fromtcl = argc > k; - if(aFullMode) - std::cout<<"Full model for translation with additional info will be used \n"<SetModeStat(aFullMode); - if (modfic) readstat = sr.ReadFile (fnom.ToCString()); + if (modfic) readstat = sr.ReadFile(fnom.ToCString()); else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone; aPSRoot.Next(20); // On average loading takes 20% if (aPSRoot.UserBreak()) return 1; - if (readstat != IFSelect_RetDone) { - if (modfic) di<<"Could not read file "< fichier deja lu Standard_Integer i, num, nbs, modepri = 1; if (fromtcl) modepri = 4; - while (modepri) { + while (modepri) + { num = sr.NbRootsForTransfer(); - if (!fromtcl) { - di<<"NbRootsForTransfer="<Print (sr.RootForTransfer(i), aTmpStream); + sr.Model()->Print(sr.RootForTransfer(i), aTmpStream); di << aTmpStream.str().c_str(); - di<<" Type:"<DynamicType()->Name()<<"\n"; + di << " Type:" << sr.RootForTransfer(i)->DynamicType()->Name() << "\n"; } - std::cout<<"Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : "<>modepri; + std::cout << "Mode (0 End, 1 root n0 1, 2 one root/n0, 3 one entity/n0, 4 Selection) : " << std::flush; + std::cin >> modepri; } - if (modepri == 0) { di<<"End Reading STEP\n"; return 0; } - if (modepri <= 2) { + if (modepri == 0) { di << "End Reading STEP\n"; return 0; } + if (modepri <= 2) + { num = 1; - if (modepri == 2) { - std::cout<<"Root N0 : "<>num; + if (modepri == 2) + { + std::cout << "Root N0 : " << std::flush; std::cin >> num; } aPSRoot.SetName("Translation"); progress->Show(aPSRoot); - if (!sr.TransferRoot (num, aPSRoot.Next(80))) - di<<"Transfer root n0 "< DRAW Shape: "< DRAW Shape: " << shname << "\n"; + di << "Now, " << nbs << " Shapes produced\n"; TopoDS_Shape sh = sr.Shape(nbs); - DBRep::Set (shname,sh); + DBRep::Set(shname, sh); } if (aPSRoot.UserBreak()) return 1; } - else if (modepri == 3) { - std::cout<<"Entity : "< DRAW Shape: "< DRAW Shape: " << shname << "\n"; + di << "Now, " << nbs << " Shapes produced\n"; TopoDS_Shape sh = sr.Shape(nbs); - DBRep::Set (shname,sh); + DBRep::Set(shname, sh); } } - else if (modepri == 4) { + else if (modepri == 4) + { // char snm[100]; Standard_Integer answer = 1; Handle(TColStd_HSequenceOfTransient) list; // Selection, nommee ou via tcl. tcl : raccourcis admis // * donne xst-transferrable-roots - if (fromtcl) { + if (fromtcl) + { modepri = 0; // d ioffice une seule passe - if (argv[k][0] == '*' && argv[k][1] == '\0') { - di<<"Transferrable Roots : "; + if (argv[k][0] == '*' && argv[k][1] == '\0') + { + di << "Transferrable Roots : "; list = XSDRAW::GetList("xst-transferrable-roots"); //list = new TColStd_HSequenceOfTransient; //for(Standard_Integer j=1; j<=num; j++) // list->Append(sr.RootForTransfer(j)); } - else { - di<<"List given by "< k+1) di<<" "< (k+1) ? argv[k+1] : 0 ) ); + else + { + di << "List given by " << argv[k]; + if (argc > k + 1) di << " " << argv[k + 1]; + di << " : "; + list = XSDRAW::GetList(argv[k], (argc > (k + 1) ? argv[k + 1] : 0)); } - if (list.IsNull()) { di<<"No list defined. Give a selection name or * for all transferrable roots\n"; continue; } - } else { - std::cout<<"Name of Selection :"<Length(); - di<<"Nb entities selected : "<Show(aPSRoot); Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl); - for (ill = 1; ill <= nbl && aPS.More(); ill++) { + for (ill = 1; ill <= nbl && aPS.More(); ill++) + { num = sr.Model()->Number(list->Value(ill)); if (num == 0) continue; if (!sr.TransferOne(num, aPS.Next())) - di<<"Transfer entity n0 "< DRAW Shape: "< DRAW Shape: " << shname << "\n"; + di << "Now, " << nbs << " Shapes produced\n"; TopoDS_Shape sh = sr.Shape(nbs); - DBRep::Set (shname,sh); + DBRep::Set(shname, sh); } } if (aPSRoot.UserBreak()) return 1; } - else di<<"Unknown mode n0 "< 4) + if (argc < 3 || argc > 4) { di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n"; di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n"; @@ -277,7 +345,7 @@ static Standard_Integer testreadstep (Draw_Interpretor& di, Standard_Integer arg return 1; } - Standard_Boolean useStream = (argc > 3 && ! strcasecmp (argv[3], "-stream")); + Standard_Boolean useStream = (argc > 3 && !strcasecmp(argv[3], "-stream")); STEPControl_Reader Reader; Standard_CString filename = argv[1]; @@ -285,61 +353,66 @@ static Standard_Integer testreadstep (Draw_Interpretor& di, Standard_Integer arg if (useStream) { std::ifstream aStream; - OSD_OpenStream (aStream, filename, std::ios::in | std::ios::binary); + OSD_OpenStream(aStream, filename, std::ios::in | std::ios::binary); TCollection_AsciiString aFolder, aFileNameShort; - OSD_Path::FolderAndFileFromPath (filename, aFolder, aFileNameShort); - readstat = Reader.ReadStream (aFileNameShort.ToCString(), aStream); + OSD_Path::FolderAndFileFromPath(filename, aFolder, aFileNameShort); + readstat = Reader.ReadStream(aFileNameShort.ToCString(), aStream); } else { readstat = Reader.ReadFile(filename); } - di<<"Status from reading STEP file "<PrepareForTransfer(); // update unit info Reader.SetSystemLengthUnit(UnitsMethods::GetCasCadeLengthUnit()); Reader.TransferRoots(); TopoDS_Shape shape = Reader.OneShape(); - DBRep::Set(argv[2],shape); - di<<"Count of shapes produced : "< 4) n2 = XSDRAW::GetEntityNumber(argv[4]); if (n1 > 0) ax1 = Handle(StepGeom_Axis2Placement3d)::DownCast - (XSDRAW::Entity(n1)); + (XSDRAW::Entity(n1)); if (n2 > 0) ax2 = Handle(StepGeom_Axis2Placement3d)::DownCast - (XSDRAW::Entity(n2)); + (XSDRAW::Entity(n2)); StepToTopoDS_MakeTransformed mktrans; - if (mktrans.Compute (ax1,ax2)) { - TopLoc_Location loc (mktrans.Transformation()); - shape.Move (loc); -// mktrans.Transform (shape); - DBRep::Set (argv[2],shape); - di<<"Transformed Shape as "<ActorWrite() ); - if ( ! ActWrite.IsNull() ) - ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly")); + Handle(STEPControl_ActorWrite) ActWrite = + Handle(STEPControl_ActorWrite)::DownCast(ctl->ActorWrite()); + if (!ActWrite.IsNull()) + ActWrite->SetGroupMode(Interface_Static::IVal("write.step.assembly")); TopoDS_Shape shape = DBRep::Get(argv[2]); - STEPControl_Writer sw (XSDRAW::Session(),Standard_False); + STEPControl_Writer sw(XSDRAW::Session(), Standard_False); Handle(Interface_InterfaceModel) stepmodel = sw.Model(); Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); - Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); - Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100); + Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator(di, 1); + Message_ProgressScope aPSRoot(progress->Start(), "Translating", 100); progress->Show(aPSRoot); - Standard_Integer stat = sw.Transfer (shape, mode, Standard_True, aPSRoot.Next(90)); + Standard_Integer stat = sw.Transfer(shape, mode, Standard_True, aPSRoot.Next(90)); if (stat == IFSelect_RetDone) { di << "Translation: OK\n"; - } - else + } + else { di << "Error: translation failed, status = " << stat << "\n"; } @@ -411,25 +488,27 @@ static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, aPSRoot.SetName("Writing"); progress->Show(aPSRoot); -// Que s est-il passe + // Que s est-il passe stepmodel = sw.Model(); Standard_Integer nbapres = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); - if (nbavant > 0) di<<"Beware : Model not empty before transferring\n"; - if (nbapres <= nbavant) di<<"Beware : No data produced by this transfer\n"; - if (nbapres == 0) { di<<"No data to write\n"; return 0; } + if (nbavant > 0) di << "Beware : Model not empty before transferring\n"; + if (nbapres <= nbavant) di << "Beware : No data produced by this transfer\n"; + if (nbapres == 0) { di << "No data to write\n"; return 0; } - if (argc <= 3) { - di<<" Now, to write a file, command : writeall filename\n"; + if (argc <= 3) + { + di << " Now, to write a file, command : writeall filename\n"; return 0; } - const char *nomfic = argv[3]; + const char* nomfic = argv[3]; stat = sw.Write(nomfic); - switch (stat) { - case IFSelect_RetVoid : di<<"Error: No file written\n"; break; - case IFSelect_RetDone : di<<"File "<Session(); - const Interface_Graph& graph = WS->Graph(); - + const Interface_Graph& graph = WS->Graph(); + Handle(TColStd_HSequenceOfTransient) roots = WS->GiveList("xst-transferrable-roots", ""); STEPSelections_Counter cnt; - - for (Standard_Integer i =1 ; i <= roots->Length(); i++) { - cnt.Count(graph,roots->Value(i)); - } - - di<< "Instances of Faces \t: "<Length(); i++) + { + cnt.Count(graph, roots->Value(i)); + } + + di << "Instances of Faces \t: " << cnt.NbInstancesOfFaces() << "\n"; + di << "Instances of Shells\t: " << cnt.NbInstancesOfShells() << "\n"; + di << "Instances of Solids\t: " << cnt.NbInstancesOfSolids() << "\n"; + di << "Instances of Wires in GS\t: " << cnt.NbInstancesOfWires() << "\n"; + di << "Instances of Edges in GS\t: " << cnt.NbInstancesOfEdges() << "\n"; + + di << "Source Faces \t: " << cnt.NbSourceFaces() << "\n"; + di << "Source Shells\t: " << cnt.NbSourceShells() << "\n"; + di << "Source Solids\t: " << cnt.NbSourceSolids() << "\n"; + di << "Source Wires in GS\t: " << cnt.NbSourceWires() << "\n"; + di << "Source Edges in GS\t: " << cnt.NbSourceEdges() << "\n"; + return 1; } static Standard_Integer dumpassembly - (Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char** /*argv*/) +(Draw_Interpretor& /*di*/, Standard_Integer /*argc*/, const char** /*argv*/) { Handle(IFSelect_SessionPilot) pilot = XSDRAW::Pilot(); Handle(IFSelect_WorkSession) WS = pilot->Session(); const Interface_Graph& graph = WS->Graph(); - + STEPSelections_AssemblyExplorer exp(graph); exp.Dump(std::cout); return 0; } -static Standard_Integer stepfileunits (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +static Standard_Integer stepfileunits(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if( argc < 2) + if (argc < 2) { di << "Error: Invalid number of parameters. Should be: getfileunits name_file\n"; return 1; } STEPControl_Reader aStepReader; - + IFSelect_ReturnStatus readstat = IFSelect_RetVoid; - readstat = aStepReader.ReadFile (argv[1]); - - if (readstat != IFSelect_RetDone) { - - di<<"No model loaded\n"; + readstat = aStepReader.ReadFile(argv[1]); + + if (readstat != IFSelect_RetDone) + { + + di << "No model loaded\n"; return 1; } TColStd_SequenceOfAsciiString anUnitLengthNames; TColStd_SequenceOfAsciiString anUnitAngleNames; TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aStepReader.FileUnits( anUnitLengthNames,anUnitAngleNames,anUnitSolidAngleNames); - - Standard_Integer i =1; - di<<"=====================================================\n"; - di<<"LENGTH Unit\n"; - for( ; i <= anUnitLengthNames.Length() ; i++) - di<InternalParameters.WriteColor = aMode; break; + case 'n': aNode->InternalParameters.WriteName = aMode; break; + case 'l': aNode->InternalParameters.WriteLayer = aMode; break; + case 'v': aNode->InternalParameters.WriteProps = aMode; break; + default: + { + theDI << "Syntax error at '" << aModeStr << "'\n"; + return 1; + } + } + } + } + Handle(TDocStd_Document) aDoc; + if (!DDocStd::GetDocument(aDocName, aDoc, Standard_False)) + { + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + anApp->NewDocument("BinXCAF", aDoc); + TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName); + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); + Draw::Set(aDocName, aDrawDoc); + } + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); + Handle(STEPCAFControl_Provider) aProvider = + new STEPCAFControl_Provider(aNode); + aProvider->SetToUpdateStaticParameters(false); + Standard_Boolean aReadStat = Standard_False; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (aToTestStream) + { + std::ifstream aStream; + OSD_OpenStream(aStream, aFilePath.ToCString(), std::ios::in | std::ios::binary); + TCollection_AsciiString aFolder, aFileNameShort; + OSD_Path::FolderAndFileFromPath(aFilePath, aFolder, aFileNameShort); + aReadStat = + aProvider->Read(aStream, aDoc, aFilePath, aWS, aProgress->Start()); + } + else + { + aReadStat = + aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); + } + if (!aReadStat) + { + theDI << "Cannot read any relevant data from the STEP file\n"; + return 1; + } + Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); + Draw::Set(aDocName, aDrawDoc); + CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); + Message::SendInfo() << "Document saved with name " << aDocName; + return 0; +} + +//======================================================================= +//function : WriteStep +//purpose : Write DECAF document to STEP +//======================================================================= +static Standard_Integer WriteStep(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + Handle(TDocStd_Document) aDoc; + TCollection_AsciiString aDocName, aFilePath; + Handle(STEPCAFControl_ConfigurationNode) aNode = + new STEPCAFControl_ConfigurationNode(); + bool aHasModeArg = false, aToTestStream = false; + TDF_Label aLabel; + for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) + { + TCollection_AsciiString anArgCase(theArgVec[anArgIter]); + anArgCase.LowerCase(); + if (anArgCase == "-stream") + { + aToTestStream = true; + } + else if (aDocName.IsEmpty()) + { + Standard_CString aDocNameStr = theArgVec[anArgIter]; + DDocStd::GetDocument(aDocNameStr, aDoc); + if (aDoc.IsNull()) + { + theDI << "Syntax error: '" << theArgVec[anArgIter] << "' is not a document\n"; + return 1; + } + aDocName = aDocNameStr; + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIter]; + } + else if (!aHasModeArg) + { + aHasModeArg = true; + Standard_Boolean aIsWriteType = Standard_True; + switch (anArgCase.Value(1)) + { + case 'a': + case '0': aNode->InternalParameters.WriteModelType = STEPControl_AsIs; break; + case 'f': + case '1': aNode->InternalParameters.WriteModelType = STEPControl_FacetedBrep; break; + case 's': + case '2': aNode->InternalParameters.WriteModelType = STEPControl_ShellBasedSurfaceModel; break; + case 'm': + case '3': aNode->InternalParameters.WriteModelType = STEPControl_ManifoldSolidBrep; break; + case 'w': + case '4': aNode->InternalParameters.WriteModelType = STEPControl_GeometricCurveSet; break; + default: + { + aIsWriteType = Standard_False; + } + } + Standard_Boolean aWrMode = Standard_True; + Standard_Boolean aIsAttrType = Standard_True; + for (Standard_Integer i = 1; i <= anArgCase.Length(); ++i) + { + switch (anArgCase.Value(i)) + { + case '-': aWrMode = Standard_False; break; + case '+': aWrMode = Standard_True; break; + case 'c': aNode->InternalParameters.WriteColor = aWrMode; break; + case 'n': aNode->InternalParameters.WriteName = aWrMode; break; + case 'l': aNode->InternalParameters.WriteLayer = aWrMode; break; + case 'v': aNode->InternalParameters.WriteProps = aWrMode; break; + default: + { + aIsAttrType = Standard_False; + } + } + } + if (!aIsAttrType && !aIsWriteType) + { + theDI << "Syntax error: mode '" << anArgCase << "' is incorrect mode\n"; + return 1; + } + } + else if (aNode->InternalParameters.WriteMultiPrefix.IsEmpty() + && anArgCase.Search(":") == -1) + { + aNode->InternalParameters.WriteMultiPrefix = theArgVec[anArgIter]; + } + else if (aLabel.IsNull()) + { + aNode->InternalParameters.WriteLabels.Append(theArgVec[anArgIter]); + } + else + { + theDI << "Syntax error: unknown argument '" << theArgVec[anArgIter] << "'\n"; + return 1; + } + } + if (aFilePath.IsEmpty()) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); + Handle(STEPCAFControl_Provider) aProvider = + new STEPCAFControl_Provider(aNode); + aProvider->SetToUpdateStaticParameters(false); + Standard_Boolean aReadStat = Standard_False; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (aToTestStream) + { + std::ofstream aStream; + OSD_OpenStream(aStream, aFilePath, std::ios::out | std::ios::binary); + TCollection_AsciiString aFolder, aFileNameShort; + OSD_Path::FolderAndFileFromPath(aFilePath, aFolder, aFileNameShort); + aReadStat = + aProvider->Write(aStream, aDoc, aWS, aProgress->Start()); + } + else + { + aReadStat = + aProvider->Write(aFilePath, aDoc, aWS, aProgress->Start()); + } + if (!aReadStat) + { + theDI << "Cannot write any relevant data to the STEP file\n"; + return 1; + } + CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); + return 0; +} + +void XSDRAWSTEP::InitCommands(Draw_Interpretor& theCommands) { const char* g = "DE: STEP"; // Step transfer file commands XSDRAWSTEP::Init(); XSDRAW::LoadDraw(theCommands); - theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); + theCommands.Add("stepwrite", "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g); theCommands.Add("testwritestep", "testwritestep filename.stp shape [-stream]", - __FILE__, testwrite, g); - theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g); - theCommands.Add("testreadstep", "testreadstep file shape [-stream]",__FILE__, testreadstep, g); - theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g); - theCommands.Add("countexpected","TEST", __FILE__, countexpected, g); - theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g); - theCommands.Add("stepfileunits" , "stepfileunits name_file", __FILE__, stepfileunits, g); + __FILE__, testwrite, g); + theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]", __FILE__, stepread, g); + theCommands.Add("testreadstep", "testreadstep file shape [-stream]", __FILE__, testreadstep, g); + theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g); + theCommands.Add("countexpected", "TEST", __FILE__, countexpected, g); + theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g); + theCommands.Add("stepfileunits", "stepfileunits name_file", __FILE__, stepfileunits, g); + theCommands.Add("ReadStep", + "Doc filename [mode] [-stream]" + "\n\t\t: Read STEP file to a document." + "\n\t\t: -stream read using istream reading interface (testing)", + __FILE__, ReadStep, g); + theCommands.Add("WriteStep", + "Doc filename [mode=a [multifile_prefix] [label]] [-stream]" + "\n\t\t: Write DECAF document to STEP file" + "\n\t\t: mode can be: a or 0 : AsIs (default)" + "\n\t\t: f or 1 : FacettedBRep s or 2 : ShellBasedSurfaceModel" + "\n\t\t: m or 3 : ManifoldSolidBrep w or 4 : GeometricCurveSet/WireFrame" + "\n\t\t: multifile_prefix: triggers writing assembly components as separate files," + "\n\t\t: and defines common prefix for their names" + "\n\t\t: label tag of the sub-assembly label to save only that sub-assembly" + "\n\t\t: -stream read using ostream writing interface (testing)", + __FILE__, WriteStep, g); } diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.hxx b/src/XSDRAWSTEP/XSDRAWSTEP.hxx index 9c2673ba25..c979e3fb0b 100644 --- a/src/XSDRAWSTEP/XSDRAWSTEP.hxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.hxx @@ -1,7 +1,4 @@ -// Created on: 1996-01-12 -// Created by: Christian CAILLET -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS +// Copyright (c) 2023 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -22,41 +19,15 @@ #include - -//! XSDRAW for STEP AP214 and AP203 -class XSDRAWSTEP +class XSDRAWSTEP { -public: - DEFINE_STANDARD_ALLOC +public: - Standard_EXPORT static void Init(); - - //! Inits commands to access product data and to write shapes - Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands); - - - - -protected: - - - - - -private: - - - - + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); }; - - - - - - #endif // _XSDRAWSTEP_HeaderFile diff --git a/src/XSDRAWSTL/FILES b/src/XSDRAWSTL/FILES new file mode 100644 index 0000000000..b8b27c62b0 --- /dev/null +++ b/src/XSDRAWSTL/FILES @@ -0,0 +1,2 @@ +XSDRAWSTL.cxx +XSDRAWSTL.hxx diff --git a/src/XSDRAWSTL/XSDRAWSTL.cxx b/src/XSDRAWSTL/XSDRAWSTL.cxx new file mode 100644 index 0000000000..6745cea079 --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL.cxx @@ -0,0 +1,369 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#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 : writestl +//purpose : +//============================================================================= +static Standard_Integer writestl(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3 || theNbArgs > 4) + { + theDI << "Use: " << theArgVec[0] + << " shape file [ascii/binary (0/1) : 1 by default]\n"; + } + else + { + TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); + Standard_Boolean isASCIIMode = Standard_False; + if (theNbArgs == 4) + { + isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0); + } + Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); + aNode->InternalParameters.WriteAscii = isASCIIMode; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); + if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) + { + theDI << "Error: Mesh writing has been failed.\n"; + } + } + return 0; +} + +//============================================================================= +//function : readstl +//purpose : Reads stl file +//============================================================================= +static Standard_Integer readstl(Draw_Interpretor& theDI, + Standard_Integer theArgc, + const char** theArgv) +{ + TCollection_AsciiString aShapeName, aFilePath; + Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + //bool toCreateCompOfTris = false; + //bool anIsMulti = false; + //double aMergeAngle = M_PI / 2.0; + for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter) + { + TCollection_AsciiString anArg(theArgv[anArgIter]); + anArg.LowerCase(); + if (aShapeName.IsEmpty()) + { + aShapeName = theArgv[anArgIter]; + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgv[anArgIter]; + } + else if (anArg == "-brep") + { + Standard_Boolean toCreateCompOfTris = Standard_True; + if (anArgIter + 1 < theArgc + && Draw::ParseOnOff(theArgv[anArgIter + 1], toCreateCompOfTris)) + { + ++anArgIter; + } + if (!toCreateCompOfTris) + { + aNode->InternalParameters.ReadShapeType = + RWStl_ConfigurationNode::ReadMode_ShapeType_CompShape; + } + } + else if (anArg == "-multi") + { + Standard_Boolean anIsMulti = Standard_True; + if (anArgIter + 1 < theArgc + && Draw::ParseOnOff(theArgv[anArgIter + 1], anIsMulti)) + { + ++anArgIter; + } + if (anIsMulti) + { + aNode->InternalParameters.ReadShapeType = + RWStl_ConfigurationNode::ReadMode_ShapeType_MultiMesh; + } + } + else if (anArg == "-mergeangle" + || anArg == "-smoothangle" + || anArg == "-nomergeangle" + || anArg == "-nosmoothangle") + { + if (anArg.StartsWith("-no")) + { + aNode->InternalParameters.ReadMergeAngle = M_PI / 2.0; + } + else + { + aNode->InternalParameters.ReadMergeAngle = M_PI / 4.0; + if (anArgIter + 1 < theArgc + && Draw::ParseReal(theArgv[anArgIter + 1], aNode->InternalParameters.ReadMergeAngle)) + { + if (aNode->InternalParameters.ReadMergeAngle < 0.0 || + aNode->InternalParameters.ReadMergeAngle > 90.0) + { + theDI << "Syntax error: angle should be within [0,90] range"; + return 1; + } + ++anArgIter; + } + } + } + else + { + theDI << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n"; + return 1; + } + } + if (aFilePath.IsEmpty()) + { + theDI << "Syntax error: not enough arguments\n"; + return 1; + } + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); + TopoDS_Shape aShape; + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start())) + { + theDI << "Cannot read any relevant data from the STL file\n"; + return 1; + } + DBRep::Set(aShapeName.ToCString(), aShape); + return 0; +} + +//======================================================================= +//function : InitCommands +//purpose : +//======================================================================= +void XSDRAWSTL::InitCommands(Draw_Interpretor& theCommands) +{ + const char* g = "XSTEP-STL/VRML"; // Step transfer file commands + //XSDRAW::LoadDraw(theCommands); + + theCommands.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, g); + theCommands.Add("readstl", + "readstl shape file [-brep] [-mergeAngle Angle] [-multi]" + "\n\t\t: Reads STL file and creates a new shape with specified name." + "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces." + "\n\t\t: Single triangulation-only Face is created otherwise (default)." + "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default." + "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.", + __FILE__, readstl, g); + +} + diff --git a/src/XSDRAWSTL/XSDRAWSTL.hxx b/src/XSDRAWSTL/XSDRAWSTL.hxx new file mode 100644 index 0000000000..494e75806d --- /dev/null +++ b/src/XSDRAWSTL/XSDRAWSTL.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWSTL_HeaderFile +#define _XSDRAWSTL_HeaderFile + +#include +#include + +#include + +class XSDRAWSTL +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWSTL_HeaderFile diff --git a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx index 828b5eadc1..c8667d6d8b 100644 --- a/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx +++ b/src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx @@ -213,924 +213,6 @@ static Standard_Real GetLengthUnit(const Handle(TDocStd_Document)& theDoc = null return UnitsMethods::GetCasCadeLengthUnit(); } -//============================================================================= -//function : ReadGltf -//purpose : Reads glTF file -//============================================================================= -static Standard_Integer ReadGltf(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - TCollection_AsciiString aDestName, aFilePath; - Handle(RWGltf_ConfigurationNode) aNode = - new RWGltf_ConfigurationNode(); - Standard_Boolean toUseExistingDoc = Standard_False; - //Standard_Boolean toListExternalFiles = Standard_False; - //Standard_Boolean isParallel = Standard_False; - //Standard_Boolean isDoublePrec = Standard_False; - //Standard_Boolean toSkipLateDataLoading = Standard_False; - //Standard_Boolean toKeepLateData = Standard_True; - //Standard_Boolean toPrintDebugInfo = Standard_False; - //Standard_Boolean toLoadAllScenes = Standard_False; - //Standard_Boolean toPrintAssetInfo = Standard_False; - Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readgltf"); - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (!isNoDoc - && (anArgCase == "-nocreate" - || anArgCase == "-nocreatedoc")) - { - toUseExistingDoc = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-parallel") - { - aNode->InternalParameters.ReadParallel = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-doubleprec" - || anArgCase == "-doubleprecision" - || anArgCase == "-singleprec" - || anArgCase == "-singleprecision") - { - aNode->InternalParameters.ReadSinglePrecision = - !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - if (anArgCase.StartsWith("-single")) - { - aNode->InternalParameters.ReadSinglePrecision = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - } - else if (anArgCase == "-skiplateloading") - { - aNode->InternalParameters.ReadSkipLateDataLoading = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-keeplate") - { - aNode->InternalParameters.ReadKeepLateData = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-allscenes") - { - aNode->InternalParameters.ReadLoadAllScenes = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-toprintinfo" - || anArgCase == "-toprintdebuginfo") - { - aNode->InternalParameters.ReadPrintDebugMessages = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - //else if (anArgCase == "-listexternalfiles" - // || anArgCase == "-listexternals" - // || anArgCase == "-listexternal" - // || anArgCase == "-external" - // || anArgCase == "-externalfiles") - //{ - // toListExternalFiles = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); - //} - //else if (anArgCase == "-assetinfo" - // || anArgCase == "-metadata") - //{ - // toPrintAssetInfo = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); - //} - else if (aDestName.IsEmpty()) - { - aDestName = theArgVec[anArgIter]; - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - //if (aFilePath.IsEmpty() && !aDestName.IsEmpty()) - //{ - // if (toListExternalFiles || toPrintAssetInfo) - // { - // std::swap (aFilePath, aDestName); - // } - //} - if (aFilePath.IsEmpty() || aDestName.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(TDocStd_Document) aDoc; - if (!aDestName.IsEmpty() - && !isNoDoc) - { - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - Standard_CString aNameVar = aDestName.ToCString(); - DDocStd::GetDocument(aNameVar, aDoc, Standard_False); - if (aDoc.IsNull()) - { - if (toUseExistingDoc) - { - theDI << "Error: document with name " << aDestName << " does not exist\n"; - return 1; - } - anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); - } - else if (!toUseExistingDoc) - { - theDI << "Error: document with name " << aDestName << " already exists\n"; - return 1; - } - } - - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(RWGltf_Provider) aProvider = - new RWGltf_Provider(aNode); - Standard_Boolean aReadStat = Standard_False; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (isNoDoc) - { - TopoDS_Shape aResShape; - aReadStat = aProvider->Read(aFilePath, aResShape, aWS, aProgress->Start()); - if (aReadStat) - { - DBRep::Set(aDestName.ToCString(), aResShape); - } - } - else - { - aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); - if (aReadStat) - { - Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); - TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName); - Draw::Set(aDestName.ToCString(), aDrawDoc); - } - } - if (!aReadStat) - { - theDI << "Cannot read any relevant data from the GLTF file\n"; - return 1; - } - //bool isFirstLine = true; - //if (toPrintAssetInfo) - //{ - // for (TColStd_IndexedDataMapOfStringString::Iterator aKeyIter (aReader.Metadata()); aKeyIter.More(); aKeyIter.Next()) - // { - // if (!isFirstLine) - // { - // theDI << "\n"; - // } - // isFirstLine = false; - // theDI << aKeyIter.Key() << ": " << aKeyIter.Value(); - // } - //} - //if (toListExternalFiles) - //{ - // if (!isFirstLine) - // { - // theDI << "\n"; - // } - // for (NCollection_IndexedMap::Iterator aFileIter (aReader.ExternalFiles()); aFileIter.More(); aFileIter.Next()) - // { - // theDI << "\"" << aFileIter.Value() << "\" "; - // } - //} - - return 0; -} - -//============================================================================= -//function : WriteGltf -//purpose : Writes glTF file -//============================================================================= -static Standard_Integer WriteGltf(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - TCollection_AsciiString aGltfFilePath; - Handle(TDocStd_Document) aDoc; - TopoDS_Shape aShape; - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - Handle(RWGltf_ConfigurationNode) aNode = - new RWGltf_ConfigurationNode(); - //TColStd_IndexedDataMapOfStringString aFileInfo; - //RWGltf_WriterTrsfFormat aTrsfFormat = RWGltf_WriterTrsfFormat_Compact; - //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup; - //bool toForceUVExport = false, toEmbedTexturesInGlb = true; - //bool toMergeFaces = false, toSplitIndices16 = false; - //bool isParallel = false; - //RWMesh_NameFormat aNodeNameFormat = RWMesh_NameFormat_InstanceOrProduct; - //RWMesh_NameFormat aMeshNameFormat = RWMesh_NameFormat_Product; - //RWGltf_DracoParameters aDracoParameters; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (anArgCase == "-comments" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; - } - else if (anArgCase == "-author" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; - } - else if (anArgCase == "-forceuvexport" - || anArgCase == "-forceuv") - { - aNode->InternalParameters.WriteForcedUVExport = true; - if (anArgIter + 1 < theNbArgs - && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteForcedUVExport)) - { - ++anArgIter; - } - } - else if (anArgCase == "-mergefaces") - { - aNode->InternalParameters.WriteMergeFaces = true; - if (anArgIter + 1 < theNbArgs - && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteMergeFaces)) - { - ++anArgIter; - } - } - else if (anArgCase == "-splitindices16" - || anArgCase == "-splitindexes16" - || anArgCase == "-splitindices" - || anArgCase == "-splitindexes" - || anArgCase == "-splitind") - { - aNode->InternalParameters.WriteSplitIndices16 = true; - if (anArgIter + 1 < theNbArgs - && Draw::ParseOnOff(theArgVec[anArgIter + 1], aNode->InternalParameters.WriteSplitIndices16)) - { - ++anArgIter; - } - } - else if (anArgIter + 1 < theNbArgs - && (anArgCase == "-systemcoordinatesystem" - || anArgCase == "-systemcoordsystem" - || anArgCase == "-systemcoordsys" - || anArgCase == "-syscoordsys")) - { - if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) - { - theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - else if (anArgCase == "-trsfformat" - && anArgIter + 1 < theNbArgs) - { - TCollection_AsciiString aTrsfStr(theArgVec[++anArgIter]); - aTrsfStr.LowerCase(); - if (aTrsfStr == "compact") - { - aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Compact; - } - else if (aTrsfStr == "mat4") - { - aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_Mat4; - } - else if (aTrsfStr == "trs") - { - aNode->InternalParameters.WriteTrsfFormat = RWGltf_WriterTrsfFormat_TRS; - } - else - { - theDI << "Syntax error at '" << anArgCase << "'\n"; - return 1; - } - } - else if (anArgCase == "-nodenameformat" - || anArgCase == "-nodename") - { - ++anArgIter; - if (anArgIter >= theNbArgs - || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteNodeNameFormat)) - { - theDI << "Syntax error at '" << anArgCase << "'\n"; - return 1; - } - } - else if (anArgCase == "-meshnameformat" - || anArgCase == "-meshname") - { - ++anArgIter; - if (anArgIter >= theNbArgs - || !parseNameFormat(theArgVec[anArgIter], aNode->InternalParameters.WriteMeshNameFormat)) - { - theDI << "Syntax error at '" << anArgCase << "'\n"; - return 1; - } - } - else if (aDoc.IsNull()) - { - Standard_CString aNameVar = theArgVec[anArgIter]; - DDocStd::GetDocument(aNameVar, aDoc, false); - if (aDoc.IsNull()) - { - aShape = DBRep::Get(aNameVar); - if (aShape.IsNull()) - { - theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n"; - return 1; - } - aNode->InternalParameters.WriteNodeNameFormat = RWMesh_NameFormat_Product; - } - } - else if (aGltfFilePath.IsEmpty()) - { - aGltfFilePath = theArgVec[anArgIter]; - } - else if (anArgCase == "-texturesSeparate") - { - aNode->InternalParameters.WriteEmbedTexturesInGlb = false; - } - else if (anArgCase == "-draco") - { - aNode->InternalParameters.WriteDracoParameters.DracoCompression = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-compressionlevel" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.CompressionLevel)) - { - ++anArgIter; - } - else if (anArgCase == "-quantizepositionbits" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.QuantizePositionBits)) - { - ++anArgIter; - } - else if (anArgCase == "-quantizenormalbits" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.QuantizeNormalBits)) - { - ++anArgIter; - } - else if (anArgCase == "-quantizetexcoordbits" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.QuantizeTexcoordBits)) - { - ++anArgIter; - } - else if (anArgCase == "-quantizecolorbits" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.QuantizeColorBits)) - { - ++anArgIter; - } - else if (anArgCase == "-quantizegenericbits" && (anArgIter + 1) < theNbArgs - && Draw::ParseInteger(theArgVec[anArgIter + 1], - aNode->InternalParameters.WriteDracoParameters.QuantizeGenericBits)) - { - ++anArgIter; - } - else if (anArgCase == "-unifiedquantization") - { - aNode->InternalParameters.WriteDracoParameters.UnifiedQuantization = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArgCase == "-parallel") - { - aNode->InternalParameters.WriteParallel = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aGltfFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - - TCollection_AsciiString anExt = aGltfFilePath; - anExt.LowerCase(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - Handle(RWGltf_Provider) aProvider = - new RWGltf_Provider(aNode); - Standard_Boolean aWriteStat = Standard_False; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aDoc.IsNull()) - { - aWriteStat = aProvider->Write(aGltfFilePath, aDoc, aWS, aProgress->Start()); - } - else if (!aShape.IsNull()) - { - aWriteStat = aProvider->Write(aGltfFilePath, aShape, aWS, aProgress->Start()); - } - if (!aWriteStat) - { - theDI << "Cannot write any relevant data to the GLTF file\n"; - return 1; - } - return 0; -} - -//============================================================================= -//function : writestl -//purpose : -//============================================================================= -static Standard_Integer writestl(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3 || theNbArgs > 4) - { - theDI << "Use: " << theArgVec[0] - << " shape file [ascii/binary (0/1) : 1 by default]\n"; - } - else - { - TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); - Standard_Boolean isASCIIMode = Standard_False; - if (theNbArgs == 4) - { - isASCIIMode = (Draw::Atoi(theArgVec[3]) == 0); - } - Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); - aNode->InternalParameters.WriteAscii = isASCIIMode; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI); - if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) - { - theDI << "Error: Mesh writing has been failed.\n"; - } - } - return 0; -} - -//============================================================================= -//function : readstl -//purpose : Reads stl file -//============================================================================= -static Standard_Integer readstl(Draw_Interpretor& theDI, - Standard_Integer theArgc, - const char** theArgv) -{ - TCollection_AsciiString aShapeName, aFilePath; - Handle(RWStl_ConfigurationNode) aNode = new RWStl_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - //bool toCreateCompOfTris = false; - //bool anIsMulti = false; - //double aMergeAngle = M_PI / 2.0; - for (Standard_Integer anArgIter = 1; anArgIter < theArgc; ++anArgIter) - { - TCollection_AsciiString anArg(theArgv[anArgIter]); - anArg.LowerCase(); - if (aShapeName.IsEmpty()) - { - aShapeName = theArgv[anArgIter]; - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgv[anArgIter]; - } - else if (anArg == "-brep") - { - Standard_Boolean toCreateCompOfTris = Standard_True; - if (anArgIter + 1 < theArgc - && Draw::ParseOnOff(theArgv[anArgIter + 1], toCreateCompOfTris)) - { - ++anArgIter; - } - if (!toCreateCompOfTris) - { - aNode->InternalParameters.ReadShapeType = - RWStl_ConfigurationNode::ReadMode_ShapeType_CompShape; - } - } - else if (anArg == "-multi") - { - Standard_Boolean anIsMulti = Standard_True; - if (anArgIter + 1 < theArgc - && Draw::ParseOnOff(theArgv[anArgIter + 1], anIsMulti)) - { - ++anArgIter; - } - if (anIsMulti) - { - aNode->InternalParameters.ReadShapeType = - RWStl_ConfigurationNode::ReadMode_ShapeType_MultiMesh; - } - } - else if (anArg == "-mergeangle" - || anArg == "-smoothangle" - || anArg == "-nomergeangle" - || anArg == "-nosmoothangle") - { - if (anArg.StartsWith("-no")) - { - aNode->InternalParameters.ReadMergeAngle = M_PI / 2.0; - } - else - { - aNode->InternalParameters.ReadMergeAngle = M_PI / 4.0; - if (anArgIter + 1 < theArgc - && Draw::ParseReal(theArgv[anArgIter + 1], aNode->InternalParameters.ReadMergeAngle)) - { - if (aNode->InternalParameters.ReadMergeAngle < 0.0 || - aNode->InternalParameters.ReadMergeAngle > 90.0) - { - theDI << "Syntax error: angle should be within [0,90] range"; - return 1; - } - ++anArgIter; - } - } - } - else - { - theDI << "Syntax error: unknown argument '" << theArgv[anArgIter] << "'\n"; - return 1; - } - } - if (aFilePath.IsEmpty()) - { - theDI << "Syntax error: not enough arguments\n"; - return 1; - } - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); - TopoDS_Shape aShape; - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Read(aFilePath, aShape, aWS, aProgress->Start())) - { - theDI << "Cannot read any relevant data from the STL file\n"; - return 1; - } - DBRep::Set(aShapeName.ToCString(), aShape); - return 0; -} - -//============================================================================= -//function : ReadObj -//purpose : Reads OBJ file -//============================================================================= -static Standard_Integer ReadObj(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - TCollection_AsciiString aDestName, aFilePath; - Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - Standard_Boolean toUseExistingDoc = Standard_False; - //Standard_Real aFileUnitFactor = -1.0; - //RWMesh_CoordinateSystem aResultCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup; - //Standard_Boolean toListExternalFiles = Standard_False, isSingleFace = Standard_False, isSinglePrecision = Standard_False; - Standard_Boolean isNoDoc = (TCollection_AsciiString(theArgVec[0]) == "readobj"); - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (anArgIter + 1 < theNbArgs - && (anArgCase == "-unit" - || anArgCase == "-units" - || anArgCase == "-fileunit" - || anArgCase == "-fileunits")) - { - const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]); - aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); - if (aNode->InternalParameters.FileLengthUnit <= 0.0) - { - theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n"; - return 1; - } - } - else if (anArgIter + 1 < theNbArgs - && (anArgCase == "-filecoordinatesystem" - || anArgCase == "-filecoordsystem" - || anArgCase == "-filecoordsys")) - { - if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS)) - { - theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - else if (anArgIter + 1 < theNbArgs - && (anArgCase == "-resultcoordinatesystem" - || anArgCase == "-resultcoordsystem" - || anArgCase == "-resultcoordsys" - || anArgCase == "-rescoordsys")) - { - if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) - { - theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - else if (anArgCase == "-singleprecision" - || anArgCase == "-singleprec") - { - aNode->InternalParameters.ReadSinglePrecision = Standard_True; - if (anArgIter + 1 < theNbArgs - && Draw::ParseOnOff(theArgVec[anArgIter + 1], - aNode->InternalParameters.ReadSinglePrecision)) - { - ++anArgIter; - } - } - else if (isNoDoc - && (anArgCase == "-singleface" - || anArgCase == "-singletriangulation")) - { - aNode->InternalParameters.ReadCreateShapes = Standard_True; - } - else if (!isNoDoc - && (anArgCase == "-nocreate" - || anArgCase == "-nocreatedoc")) - { - toUseExistingDoc = Standard_True; - if (anArgIter + 1 < theNbArgs - && Draw::ParseOnOff(theArgVec[anArgIter + 1], toUseExistingDoc)) - { - ++anArgIter; - } - } - //else if (anArgCase == "-listexternalfiles" - // || anArgCase == "-listexternals" - // || anArgCase == "-listexternal" - // || anArgCase == "-external" - // || anArgCase == "-externalfiles") - //{ - // toListExternalFiles = Standard_True; - //} - else if (aDestName.IsEmpty()) - { - aDestName = theArgVec[anArgIter]; - } - else if (aFilePath.IsEmpty()) - { - aFilePath = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - Handle(TDocStd_Document) aDoc; - if (!isNoDoc) - { - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - Standard_CString aNameVar = aDestName.ToCString(); - DDocStd::GetDocument(aNameVar, aDoc, Standard_False); - if (aDoc.IsNull()) - { - if (toUseExistingDoc) - { - theDI << "Error: document with name " << aDestName << " does not exist\n"; - return 1; - } - anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); - } - else if (!toUseExistingDoc) - { - theDI << "Error: document with name " << aDestName << " already exists\n"; - return 1; - } - } - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - Standard_Boolean aReadStat = Standard_False; - if (isNoDoc) - { - TopoDS_Shape aShape; - aReadStat = aProvider->Read(aFilePath, aShape, aWS, aProgress->Start()); - if (aReadStat) - { - DBRep::Set(aDestName.ToCString(), aShape); - } - } - else - { - aReadStat = aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start()); - if (aReadStat) - { - Handle(DDocStd_DrawDocument) aDrawDoc = new DDocStd_DrawDocument(aDoc); - TDataStd_Name::Set(aDoc->GetData()->Root(), aDestName); - Draw::Set(aDestName.ToCString(), aDrawDoc); - } - } - if (!aReadStat) - { - theDI << "Cannot read any relevant data from the Obj file\n"; - return 1; - } - return 0; -} - -//============================================================================= -//function : WriteObj -//purpose : Writes OBJ file -//============================================================================= -static Standard_Integer WriteObj(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - TCollection_AsciiString anObjFilePath; - Handle(TDocStd_Document) aDoc; - Handle(RWObj_ConfigurationNode) aNode = new RWObj_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - //TColStd_IndexedDataMapOfStringString aFileInfo; - //Standard_Real aFileUnitFactor = -1.0; - //RWMesh_CoordinateSystem aSystemCoordSys = RWMesh_CoordinateSystem_Zup, aFileCoordSys = RWMesh_CoordinateSystem_Yup; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArgCase(theArgVec[anArgIter]); - anArgCase.LowerCase(); - if (anArgIter + 1 < theNbArgs - && (anArgCase == "-unit" - || anArgCase == "-units" - || anArgCase == "-fileunit" - || anArgCase == "-fileunits")) - { - const TCollection_AsciiString aUnitStr(theArgVec[++anArgIter]); - aNode->InternalParameters.FileLengthUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); - if (aNode->InternalParameters.FileLengthUnit <= 0.0) - { - theDI << "Syntax error: wrong length unit '" << aUnitStr << "'\n"; - return 1; - } - } - else if (anArgIter + 1 < theNbArgs - && (anArgCase == "-filecoordinatesystem" - || anArgCase == "-filecoordsystem" - || anArgCase == "-filecoordsys")) - { - if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.FileCS)) - { - theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - else if (anArgIter + 1 < theNbArgs - && (anArgCase == "-systemcoordinatesystem" - || anArgCase == "-systemcoordsystem" - || anArgCase == "-systemcoordsys" - || anArgCase == "-syscoordsys")) - { - if (!parseCoordinateSystem(theArgVec[++anArgIter], aNode->InternalParameters.SystemCS)) - { - theDI << "Syntax error: unknown coordinate system '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - else if (anArgCase == "-comments" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; - } - else if (anArgCase == "-author" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; - } - else if (aDoc.IsNull()) - { - Standard_CString aNameVar = theArgVec[anArgIter]; - DDocStd::GetDocument(aNameVar, aDoc, false); - if (aDoc.IsNull()) - { - TopoDS_Shape aShape = DBRep::Get(aNameVar); - if (aShape.IsNull()) - { - theDI << "Syntax error: '" << aNameVar << "' is not a shape nor document\n"; - return 1; - } - anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); - Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); - aShapeTool->AddShape(aShape); - } - } - else if (anObjFilePath.IsEmpty()) - { - anObjFilePath = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (anObjFilePath.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(RWStl_Provider) aProvider = new RWStl_Provider(aNode); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) - { - theDI << "Error: Mesh writing has been failed.\n"; - } - return 0; -} - -//============================================================================= -//function : writevrml -//purpose : -//============================================================================= -static Standard_Integer writevrml(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3 || theNbArgs > 5) - { - theDI << "wrong number of parameters\n"; - return 0; - } - TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); - // Get the optional parameters - Standard_Integer aVersion = 2; - Standard_Integer aType = 1; - if (theNbArgs >= 4) - { - aVersion = Draw::Atoi(theArgVec[3]); - if (theNbArgs == 5) - aType = Draw::Atoi(theArgVec[4]); - } - // Bound parameters - aVersion = Max(1, aVersion); - aVersion = Min(2, aVersion); - aType = Max(0, aType); - aType = Min(2, aType); - Handle(Vrml_ConfigurationNode) aNode = - new Vrml_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - Handle(Vrml_Provider) aProvider = - new Vrml_Provider(aNode); - aNode->InternalParameters.WriterVersion = - (Vrml_ConfigurationNode::WriteMode_WriterVersion)aVersion; - aNode->InternalParameters.WriteRepresentationType = - (Vrml_ConfigurationNode::WriteMode_RepresentationType)aType; - - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) - { - theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; - return 1; - } - - return 0; -} - -//======================================================================= -//function : loadvrml -//purpose : -//======================================================================= -static Standard_Integer loadvrml(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - if (theNbArgs < 3) - { - theDI << "Error: wrong number of parameters" << "\n"; - return 1; - } - Handle(Vrml_ConfigurationNode) aNode = - new Vrml_ConfigurationNode(); - aNode->GlobalParameters.LengthUnit = GetLengthUnit(); - Handle(Vrml_Provider) aProvider = - new Vrml_Provider(aNode); - TopoDS_Shape aShape; - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Read(theArgVec[2], aShape, aWS, aProgress->Start())) - { - theDI << "Error: file reading failed '" << theArgVec[2] << "'\n"; - return 1; - } - DBRep::Set(theArgVec[1], aShape); - return 0; -} - //======================================================================= //function : createmesh //purpose : @@ -2189,291 +1271,6 @@ static Standard_Integer meshinfo(Draw_Interpretor& theDI, return 0; } -//======================================================================= -//function : writeply -//purpose : write PLY file -//======================================================================= -static Standard_Integer WritePly(Draw_Interpretor& theDI, - Standard_Integer theNbArgs, - const char** theArgVec) -{ - Handle(TDocStd_Document) aDoc; - Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); - TCollection_AsciiString aShapeName, aFileName; - Handle(RWPly_ConfigurationNode) aNode = new RWPly_ConfigurationNode(); - Standard_Real aDist = 0.0; - Standard_Real aDens = Precision::Infinite(); - Standard_Real aTol = Precision::Confusion(); - //bool hasColors = true, hasNormals = true, hasTexCoords = false, hasPartId = true, hasFaceId = false; - //TColStd_IndexedDataMapOfStringString aFileInfo; - bool isPntSet = false, isDensityPoints = false; - for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) - { - TCollection_AsciiString anArg(theArgVec[anArgIter]); - anArg.LowerCase(); - if (anArg == "-normal") - { - aNode->InternalParameters.WriteNormals = - Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArg == "-nonormal") - { - aNode->InternalParameters.WriteNormals = - !Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArg == "-color" - || anArg == "-nocolor" - || anArg == "-colors" - || anArg == "-nocolors") - { - aNode->InternalParameters.WriteColors = - Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArg == "-uv" - || anArg == "-nouv") - { - aNode->InternalParameters.WriteTexCoords = - Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); - } - else if (anArg == "-partid") - { - aNode->InternalParameters.WritePartId = - Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); - aNode->InternalParameters.WriteFaceId = - aNode->InternalParameters.WriteFaceId && - !aNode->InternalParameters.WritePartId; - } - else if (anArg == "-surfid" - || anArg == "-surfaceid" - || anArg == "-faceid") - { - aNode->InternalParameters.WriteFaceId = - Draw::ParseOnOffNoIterator(theNbArgs, theArgVec, anArgIter); - aNode->InternalParameters.WritePartId = - aNode->InternalParameters.WritePartId && - !aNode->InternalParameters.WriteFaceId; - } - else if (anArg == "-pntset" - || anArg == "-pntcloud" - || anArg == "-pointset" - || anArg == "-pointcloud" - || anArg == "-cloud" - || anArg == "-points") - { - isPntSet = Draw::ParseOnOffIterator(theNbArgs, theArgVec, anArgIter); - } - else if ((anArg == "-dist" - || anArg == "-distance") - && anArgIter + 1 < theNbArgs - && Draw::ParseReal(theArgVec[anArgIter + 1], aDist)) - { - ++anArgIter; - isPntSet = true; - if (aDist < 0.0) - { - theDI << "Syntax error: -distance value should be >= 0.0\n"; - return 1; - } - aDist = Max(aDist, Precision::Confusion()); - } - else if ((anArg == "-dens" - || anArg == "-density") - && anArgIter + 1 < theNbArgs - && Draw::ParseReal(theArgVec[anArgIter + 1], aDens)) - { - ++anArgIter; - isDensityPoints = Standard_True; - isPntSet = true; - if (aDens <= 0.0) - { - theDI << "Syntax error: -density value should be > 0.0\n"; - return 1; - } - } - else if ((anArg == "-tol" - || anArg == "-tolerance") - && anArgIter + 1 < theNbArgs - && Draw::ParseReal(theArgVec[anArgIter + 1], aTol)) - { - ++anArgIter; - isPntSet = true; - if (aTol < Precision::Confusion()) - { - theDI << "Syntax error: -tol value should be >= " - << Precision::Confusion() << "\n"; - return 1; - } - } - else if (anArg == "-comments" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteComment = theArgVec[++anArgIter]; - } - else if (anArg == "-author" - && anArgIter + 1 < theNbArgs) - { - aNode->InternalParameters.WriteAuthor = theArgVec[++anArgIter]; - } - else if (aDoc.IsNull()) - { - if (aShapeName.IsEmpty()) - { - aShapeName = theArgVec[anArgIter]; - } - - Standard_CString aNameVar = theArgVec[anArgIter]; - DDocStd::GetDocument(aNameVar, aDoc, false); - if (aDoc.IsNull()) - { - TopoDS_Shape aShape = DBRep::Get(aNameVar); - if (!aShape.IsNull()) - { - anApp->NewDocument(TCollection_ExtendedString("BinXCAF"), aDoc); - Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); - aShapeTool->AddShape(aShape); - } - } - } - else if (aFileName.IsEmpty()) - { - aFileName = theArgVec[anArgIter]; - } - else - { - theDI << "Syntax error at '" << theArgVec[anArgIter] << "'\n"; - return 1; - } - } - if (aDoc.IsNull() - && !aShapeName.IsEmpty()) - { - theDI << "Syntax error: '" << aShapeName << "' is not a shape nor document\n"; - return 1; - } - else if (aDoc.IsNull() - || aFileName.IsEmpty()) - { - theDI << "Syntax error: wrong number of arguments\n"; - return 1; - } - aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); - - if (isPntSet) - { - TDF_LabelSequence aRootLabels; - Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main()); - aShapeTool->GetFreeShapes(aRootLabels); - if (aRootLabels.IsEmpty()) - { - theDI << "Error: empty document\n"; - return 1; - } - class PointCloudPlyWriter : public BRepLib_PointCloudShape, public RWPly_PlyWriterContext - { - public: - PointCloudPlyWriter(Standard_Real theTol) - : BRepLib_PointCloudShape(TopoDS_Shape(), theTol) - {} - - void AddFaceColor(const TopoDS_Shape& theFace, const Graphic3d_Vec4ub& theColor) - { - myFaceColor.Bind(theFace, theColor); - } - - protected: - virtual void addPoint(const gp_Pnt& thePoint, - const gp_Vec& theNorm, - const gp_Pnt2d& theUV, - const TopoDS_Shape& theFace) - { - Graphic3d_Vec4ub aColor; - myFaceColor.Find(theFace, aColor); - RWPly_PlyWriterContext::WriteVertex(thePoint, - Graphic3d_Vec3((float)theNorm.X(), (float)theNorm.Y(), (float)theNorm.Z()), - Graphic3d_Vec2((float)theUV.X(), (float)theUV.Y()), - aColor); - } - - private: - NCollection_DataMap myFaceColor; - }; - - PointCloudPlyWriter aPlyCtx(aTol); - aPlyCtx.SetNormals(aNode->InternalParameters.WriteNormals); - aPlyCtx.SetColors(aNode->InternalParameters.WriteColors); - aPlyCtx.SetTexCoords(aNode->InternalParameters.WriteTexCoords); - - TopoDS_Compound aComp; - BRep_Builder().MakeCompound(aComp); - for (XCAFPrs_DocumentExplorer aDocExplorer(aDoc, aRootLabels, XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes); - aDocExplorer.More(); aDocExplorer.Next()) - { - const XCAFPrs_DocumentNode& aDocNode = aDocExplorer.Current(); - for (RWMesh_FaceIterator aFaceIter(aDocNode.RefLabel, aDocNode.Location, true, aDocNode.Style); aFaceIter.More(); aFaceIter.Next()) - { - BRep_Builder().Add(aComp, aFaceIter.Face()); - Graphic3d_Vec4ub aColorVec(255); - if (aFaceIter.HasFaceColor()) - { - Graphic3d_Vec4 aColorF = aFaceIter.FaceColor(); - aColorVec.SetValues((unsigned char)int(aColorF.r() * 255.0f), - (unsigned char)int(aColorF.g() * 255.0f), - (unsigned char)int(aColorF.b() * 255.0f), - (unsigned char)int(aColorF.a() * 255.0f)); - } - aPlyCtx.AddFaceColor(aFaceIter.Face(), aColorVec); - } - } - aPlyCtx.SetShape(aComp); - - Standard_Integer aNbPoints = isDensityPoints - ? aPlyCtx.NbPointsByDensity(aDens) - : aPlyCtx.NbPointsByTriangulation(); - if (aNbPoints <= 0) - { - theDI << "Error: unable to generate points\n"; - return 1; - } - - if (!aPlyCtx.Open(aFileName) - || !aPlyCtx.WriteHeader(aNbPoints, 0, TColStd_IndexedDataMapOfStringString())) - { - theDI << "Error: unable to create file '" << aFileName << "'\n"; - return 1; - } - - Standard_Boolean isDone = isDensityPoints - ? aPlyCtx.GeneratePointsByDensity(aDens) - : aPlyCtx.GeneratePointsByTriangulation(); - if (!isDone) - { - theDI << "Error: Point cloud was not generated in file '" << aFileName << "'\n"; - return 1; - } - else if (!aPlyCtx.Close()) - { - theDI << "Error: Point cloud file '" << aFileName << "' was not written\n"; - return 1; - } - else - { - theDI << aNbPoints << "\n"; - } - } - else - { - Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); - Handle(RWPly_Provider) aProvider = new RWPly_Provider(aNode); - Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); - if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) - { - theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; - return 1; - } - } - return 0; -} - //======================================================================= //function : InitCommands //purpose : @@ -2483,101 +1280,6 @@ void XSDRAWSTLVRML::InitCommands(Draw_Interpretor& theCommands) const char* g = "XSTEP-STL/VRML"; // Step transfer file commands //XSDRAW::LoadDraw(theCommands); - theCommands.Add("ReadGltf", - "ReadGltf Doc file [-parallel {on|off}] [-listExternalFiles] [-noCreateDoc] [-doublePrecision {on|off}] [-assetInfo]" - "\n\t\t: Read glTF file into XDE document." - "\n\t\t: -listExternalFiles do not read mesh and only list external files" - "\n\t\t: -noCreateDoc read into existing XDE document" - "\n\t\t: -doublePrecision store triangulation with double or single floating point" - "\n\t\t: precision (single by default)" - "\n\t\t: -skipLateLoading data loading is skipped and can be performed later" - "\n\t\t: (false by default)" - "\n\t\t: -keepLate data is loaded into itself with preservation of information" - "\n\t\t: about deferred storage to load/unload this data later." - "\n\t\t: -allScenes load all scenes defined in the document instead of default one (false by default)" - "\n\t\t: -toPrintDebugInfo print additional debug information during data reading" - "\n\t\t: -assetInfo print asset information", - __FILE__, ReadGltf, g); - theCommands.Add("readgltf", - "readgltf shape file" - "\n\t\t: Same as ReadGltf but reads glTF file into a shape instead of a document.", - __FILE__, ReadGltf, g); - theCommands.Add("WriteGltf", - "WriteGltf Doc file [-trsfFormat {compact|TRS|mat4}]=compact" - "\n\t\t: [-systemCoordSys {Zup|Yup}]=Zup" - "\n\t\t: [-comments Text] [-author Name]" - "\n\t\t: [-forceUVExport]=0 [-texturesSeparate]=0 [-mergeFaces]=0 [-splitIndices16]=0" - "\n\t\t: [-nodeNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=instOrProd" - "\n\t\t: [-meshNameFormat {empty|product|instance|instOrProd|prodOrInst|prodAndInst|verbose}]=product" - "\n\t\t: [-draco]=0 [-compressionLevel {0-10}]=7 [-quantizePositionBits Value]=14 [-quantizeNormalBits Value]=10" - "\n\t\t: [-quantizeTexcoordBits Value]=12 [-quantizeColorBits Value]=8 [-quantizeGenericBits Value]=12" - "\n\t\t: [-unifiedQuantization]=0 [-parallel]=0" - "\n\t\t: Write XDE document into glTF file." - "\n\t\t: -trsfFormat preferred transformation format" - "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified" - "\n\t\t: -mergeFaces merge Faces within the same Mesh" - "\n\t\t: -splitIndices16 split Faces to keep 16-bit indices when -mergeFaces is enabled" - "\n\t\t: -forceUVExport always export UV coordinates" - "\n\t\t: -texturesSeparate write textures to separate files" - "\n\t\t: -nodeNameFormat name format for Nodes" - "\n\t\t: -meshNameFormat name format for Meshes" - "\n\t\t: -draco use Draco compression 3D geometric meshes" - "\n\t\t: -compressionLevel draco compression level [0-10] (by default 7), a value of 0 will apply sequential encoding and preserve face order" - "\n\t\t: -quantizePositionBits quantization bits for position attribute when using Draco compression (by default 14)" - "\n\t\t: -quantizeNormalBits quantization bits for normal attribute when using Draco compression (by default 10)" - "\n\t\t: -quantizeTexcoordBits quantization bits for texture coordinate attribute when using Draco compression (by default 12)" - "\n\t\t: -quantizeColorBits quantization bits for color attribute when using Draco compression (by default 8)" - "\n\t\t: -quantizeGenericBits quantization bits for skinning attribute (joint indices and joint weights)" - "\n and custom attributes when using Draco compression (by default 12)" - "\n\t\t: -unifiedQuantization quantization is applied on each primitive separately if this option is false" - "\n\t\t: -parallel use multithreading for Draco compression", - __FILE__, WriteGltf, g); - theCommands.Add("writegltf", - "writegltf shape file", - __FILE__, WriteGltf, g); - theCommands.Add("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]", __FILE__, writevrml, g); - theCommands.Add("writestl", "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]", __FILE__, writestl, g); - theCommands.Add("readstl", - "readstl shape file [-brep] [-mergeAngle Angle] [-multi]" - "\n\t\t: Reads STL file and creates a new shape with specified name." - "\n\t\t: When -brep is specified, creates a Compound of per-triangle Faces." - "\n\t\t: Single triangulation-only Face is created otherwise (default)." - "\n\t\t: -mergeAngle specifies maximum angle in degrees between triangles to merge equal nodes; disabled by default." - "\n\t\t: -multi creates a face per solid in multi-domain files; ignored when -brep is set.", - __FILE__, readstl, g); - theCommands.Add("loadvrml", "shape file", __FILE__, loadvrml, g); - theCommands.Add("ReadObj", - "ReadObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" - "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" - "\n\t\t: [-listExternalFiles] [-noCreateDoc]" - "\n\t\t: Read OBJ file into XDE document." - "\n\t\t: -fileUnit length unit of OBJ file content;" - "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified." - "\n\t\t: -resultCoordSys result coordinate system; Zup when not specified." - "\n\t\t: -singlePrecision truncate vertex data to single precision during read; FALSE by default." - "\n\t\t: -listExternalFiles do not read mesh and only list external files." - "\n\t\t: -noCreateDoc read into existing XDE document.", - __FILE__, ReadObj, g); - theCommands.Add("readobj", - "readobj shape file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" - "\n\t\t: [-resultCoordSys {Zup|Yup}] [-singlePrecision]" - "\n\t\t: [-singleFace]" - "\n\t\t: Same as ReadObj but reads OBJ file into a shape instead of a document." - "\n\t\t: -singleFace merge OBJ content into a single triangulation Face.", - __FILE__, ReadObj, g); - theCommands.Add("WriteObj", - "WriteObj Doc file [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" - "\n\t\t: [-systemCoordSys {Zup|Yup}]" - "\n\t\t: [-comments Text] [-author Name]" - "\n\t\t: Write XDE document into OBJ file." - "\n\t\t: -fileUnit length unit of OBJ file content;" - "\n\t\t: -fileCoordSys coordinate system defined by OBJ file; Yup when not specified." - "\n\t\t: -systemCoordSys system coordinate system; Zup when not specified.", - __FILE__, WriteObj, g); - theCommands.Add("writeobj", - "writeobj shape file", - __FILE__, WriteObj, g); - theCommands.Add("meshfromstl", "creates MeshVS_Mesh from STL file", __FILE__, createmesh, g); theCommands.Add("mesh3delem", "creates 3d element mesh to test", __FILE__, create3d, g); theCommands.Add("meshshadcolor", "change MeshVS_Mesh shading color", __FILE__, meshcolor, g); @@ -2596,25 +1298,6 @@ void XSDRAWSTLVRML::InitCommands(Draw_Interpretor& theCommands) theCommands.Add("meshdeform", "display deformed mesh", __FILE__, meshdeform, g); theCommands.Add("mesh_edge_width", "set width of edges", __FILE__, mesh_edge_width, g); theCommands.Add("meshinfo", "displays the number of nodes and triangles", __FILE__, meshinfo, g); - theCommands.Add("WritePly", R"( -WritePly Doc file [-normals {0|1}]=1 [-colors {0|1}]=1 [-uv {0|1}]=0 [-partId {0|1}]=1 [-faceId {0|1}]=0 - [-pointCloud {0|1}]=0 [-distance Value]=0.0 [-density Value] [-tolerance Value] -Write document or triangulated shape into PLY file. - -normals write per-vertex normals - -colors write per-vertex colors - -uv write per-vertex UV coordinates - -partId write per-element part index (alternative to -faceId) - -faceId write per-element face index (alternative to -partId) - -Generate point cloud out of the shape and write it into PLY file. - -pointCloud write point cloud instead without triangulation indices - -distance sets distance from shape into the range [0, Value]; - -density sets density of points to generate randomly on surface; - -tolerance sets tolerance; default value is Precision::Confusion(); -)", __FILE__, WritePly, g); - theCommands.Add("writeply", - "writeply shape file", - __FILE__, WritePly, g); } //======================================================================= diff --git a/src/XSDRAWVRML/FILES b/src/XSDRAWVRML/FILES new file mode 100644 index 0000000000..e2a81aa604 --- /dev/null +++ b/src/XSDRAWVRML/FILES @@ -0,0 +1,2 @@ +XSDRAWVRML.cxx +XSDRAWVRML.hxx diff --git a/src/XSDRAWVRML/XSDRAWVRML.cxx b/src/XSDRAWVRML/XSDRAWVRML.cxx new file mode 100644 index 0000000000..6a0bc75ff5 --- /dev/null +++ b/src/XSDRAWVRML/XSDRAWVRML.cxx @@ -0,0 +1,317 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#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 + +//======================================================================= +//function : ReadVrml +//purpose : +//======================================================================= +static Standard_Integer ReadVrml(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI.PrintHelp(theArgVec[0]); + return 1; + } + Handle(Vrml_ConfigurationNode) aNode = + new Vrml_ConfigurationNode(); + Handle(TDocStd_Document) aDoc; + Standard_Boolean toUseExistingDoc = Standard_False; + Standard_CString aDocName = NULL; + TCollection_AsciiString aFilePath; + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + for (Standard_Integer anArgIt = 1; anArgIt < theNbArgs; anArgIt++) + { + TCollection_AsciiString anArg(theArgVec[anArgIt]); + anArg.LowerCase(); + if (anArgIt + 1 < theNbArgs && anArg == "-fileunit") + { + const TCollection_AsciiString aUnitStr(theArgVec[++anArgIt]); + aNode->InternalParameters.ReadFileUnit = UnitsAPI::AnyToSI(1.0, aUnitStr.ToCString()); + if (aNode->InternalParameters.ReadFileUnit <= 0.0) + { + theDI << "Error: wrong length unit '" << aUnitStr << "'\n"; + return 1; + } + } + else if (anArgIt + 1 < theNbArgs && anArg == "-filecoordsys") + { + if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadFileCoordinateSys)) + { + theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n"; + return 1; + } + } + else if (anArgIt + 1 < theNbArgs && anArg == "-systemcoordsys") + { + if (!parseCoordinateSystem(theArgVec[++anArgIt], aNode->InternalParameters.ReadSystemCoordinateSys)) + { + theDI << "Error: unknown coordinate system '" << theArgVec[anArgIt] << "'\n"; + return 1; + } + } + else if (anArg == "-fillincomplete") + { + aNode->InternalParameters.ReadFillIncomplete = true; + if (anArgIt + 1 < theNbArgs && + Draw::ParseOnOff(theArgVec[anArgIt + 1], aNode->InternalParameters.ReadFillIncomplete)) + { + ++anArgIt; + } + } + else if (anArg == "-nocreatedoc") + { + toUseExistingDoc = true; + } + else if (aDocName == nullptr) + { + aDocName = theArgVec[anArgIt]; + DDocStd::GetDocument(aDocName, aDoc, Standard_False); + } + else if (aFilePath.IsEmpty()) + { + aFilePath = theArgVec[anArgIt]; + } + else + { + theDI << "Syntax error at '" << theArgVec[anArgIt] << "'\n"; + return 1; + } + } + + if (aFilePath.IsEmpty() || aDocName == nullptr) + { + theDI << "Syntax error: wrong number of arguments\n"; + return 1; + } + + if (aDoc.IsNull()) + { + if (toUseExistingDoc) + { + theDI << "Error: document with name " << aDocName << " does not exist\n"; + return 1; + } + Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); + anApp->NewDocument("BinXCAF", aDoc); + } + else if (!toUseExistingDoc) + { + theDI << "Error: document with name " << aDocName << " already exists\n"; + return 1; + } + Handle(Vrml_Provider) aProvider = + new Vrml_Provider(aNode); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Read(aFilePath, aDoc, aWS, aProgress->Start())) + { + theDI << "Error: file reading failed '" << aFilePath << "'\n"; + return 1; + } + TDataStd_Name::Set(aDoc->GetData()->Root(), aDocName); + Handle(DDocStd_DrawDocument) aDD = new DDocStd_DrawDocument(aDoc); + Draw::Set(aDocName, aDD); + CollectActiveWorkSessions(aWS, aFilePath, THE_PREVIOUS_WORK_SESSIONS); + return 0; +} + +//======================================================================= +//function : WriteVrml +//purpose : Write DECAF document to Vrml +//======================================================================= +static Standard_Integer WriteVrml(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Use: " << theArgVec[0] << " Doc filename: write document to Vrml file\n"; + return 0; + } + + Handle(TDocStd_Document) aDoc; + DDocStd::GetDocument(theArgVec[1], aDoc); + if (aDoc.IsNull()) + { + theDI << theArgVec[1] << " is not a document\n"; + return 1; + } + + if (theNbArgs < 3 || theNbArgs > 5) + { + theDI << "wrong number of parameters\n"; + return 0; + } + Handle(Vrml_ConfigurationNode) aNode = + new Vrml_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(aDoc); + Handle(Vrml_Provider) aProvider = + new Vrml_Provider(aNode); + + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Write(theArgVec[2], aDoc, aWS, aProgress->Start())) + { + theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; + return 1; + } + CollectActiveWorkSessions(aWS, theArgVec[2], THE_PREVIOUS_WORK_SESSIONS); + return 0; +} + + +//======================================================================= +//function : loadvrml +//purpose : +//======================================================================= +static Standard_Integer loadvrml(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDI << "Error: wrong number of parameters" << "\n"; + return 1; + } + Handle(Vrml_ConfigurationNode) aNode = + new Vrml_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + Handle(Vrml_Provider) aProvider = + new Vrml_Provider(aNode); + TopoDS_Shape aShape; + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + if (!aProvider->Read(theArgVec[2], aShape, aWS, aProgress->Start())) + { + theDI << "Error: file reading failed '" << theArgVec[2] << "'\n"; + return 1; + } + DBRep::Set(theArgVec[1], aShape); + return 0; +} + +//============================================================================= +//function : writevrml +//purpose : +//============================================================================= +static Standard_Integer writevrml(Draw_Interpretor& theDI, + Standard_Integer theNbArgs, + const char** theArgVec) +{ + if (theNbArgs < 3 || theNbArgs > 5) + { + theDI << "wrong number of parameters\n"; + return 0; + } + TopoDS_Shape aShape = DBRep::Get(theArgVec[1]); + // Get the optional parameters + Standard_Integer aVersion = 2; + Standard_Integer aType = 1; + if (theNbArgs >= 4) + { + aVersion = Draw::Atoi(theArgVec[3]); + if (theNbArgs == 5) + aType = Draw::Atoi(theArgVec[4]); + } + // Bound parameters + aVersion = Max(1, aVersion); + aVersion = Min(2, aVersion); + aType = Max(0, aType); + aType = Min(2, aType); + Handle(Vrml_ConfigurationNode) aNode = + new Vrml_ConfigurationNode(); + aNode->GlobalParameters.LengthUnit = GetLengthUnit(); + Handle(Vrml_Provider) aProvider = + new Vrml_Provider(aNode); + aNode->InternalParameters.WriterVersion = + (Vrml_ConfigurationNode::WriteMode_WriterVersion)aVersion; + aNode->InternalParameters.WriteRepresentationType = + (Vrml_ConfigurationNode::WriteMode_RepresentationType)aType; + + Handle(XSControl_WorkSession) aWS = XSDRAW::Session(); + Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(theDI, 1); + if (!aProvider->Write(theArgVec[2], aShape, aWS, aProgress->Start())) + { + theDI << "Error: file writing failed '" << theArgVec[2] << "'\n"; + return 1; + } + return 0; +} + +void XSDRAWVRML::InitCommands(Draw_Interpretor& theDI) +{ + static Standard_Boolean initactor = Standard_False; + if (initactor) + { + return; + } + initactor = Standard_True; + + Standard_CString g = "XDE translation commands"; + + theDI.Add("ReadVrml", + "ReadVrml docName filePath [-fileCoordSys {Zup|Yup}] [-fileUnit Unit]" + "\n\t\t: [-systemCoordSys {Zup|Yup}] [-noCreateDoc] [-fillIncomplete {ON|OFF}]" + "\n\t\t: Read Vrml file into XDE document." + "\n\t\t: -fileCoordSys coordinate system defined by Vrml file; Yup when not specified." + "\n\t\t: -fileUnit length unit of Vrml file content." + "\n\t\t: -systemCoordSys result coordinate system; Zup when not specified." + "\n\t\t: -noCreateDoc read into existing XDE document." + "\n\t\t: -fillIncomplete fill the document with partially retrieved data even if reader has failed with " + "error; true when not specified", + __FILE__, ReadVrml, g); + theDI.Add("WriteVrml", + "WriteVrml Doc filename [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 0 by default]", + __FILE__, WriteVrml, g); + theDI.Add("loadvrml", "shape file", __FILE__, loadvrml, g); + 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, g); +} diff --git a/src/XSDRAWVRML/XSDRAWVRML.hxx b/src/XSDRAWVRML/XSDRAWVRML.hxx new file mode 100644 index 0000000000..8a289dbb78 --- /dev/null +++ b/src/XSDRAWVRML/XSDRAWVRML.hxx @@ -0,0 +1,33 @@ +// Copyright (c) 2023 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _XSDRAWVRML_HeaderFile +#define _XSDRAWVRML_HeaderFile + +#include +#include + +#include + +class XSDRAWVRML +{ + DEFINE_STANDARD_ALLOC +public: + + Standard_EXPORT static void Init(); + + //! Loads all Draw commands of XSDRAWSTL. Used for plugin. + Standard_EXPORT static void Factory(Draw_Interpretor& theDI); +}; + +#endif // _XSDRAWVRML_HeaderFile -- 2.39.5