From 877230bcc677ac3e52f91ccd8624c59c4f9c4621 Mon Sep 17 00:00:00 2001 From: aka Date: Tue, 18 Jul 2017 17:12:23 +0300 Subject: [PATCH] Modification for thread-safety version of the step translator --- .../APIHeaderSection_MakeHeader.cxx | 2 +- src/HeaderSection/HeaderSection_Protocol.cxx | 2 +- src/HeaderSection/HeaderSection_Protocol.hxx | 2 +- src/IFSelect/IFSelect_Functions.cxx | 57 ---- src/IFSelect/IFSelect_WorkSession.cxx | 25 -- src/IFSelect/IFSelect_WorkSession.hxx | 7 - src/Interface/Interface_InterfaceModel.cxx | 21 ++ src/Interface/Interface_InterfaceModel.hxx | 8 +- src/Interface/Interface_Static.cxx | 55 ++-- src/Interface/Interface_Static.hxx | 8 +- src/QABugs/QABugs_11.cxx | 3 +- src/RWHeaderSection/RWHeaderSection.cxx | 6 + .../STEPCAFControl_Controller.cxx | 42 --- .../STEPCAFControl_Controller.hxx | 7 - src/STEPCAFControl/STEPCAFControl_Reader.cxx | 49 ++- src/STEPCAFControl/STEPCAFControl_Reader.hxx | 22 +- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 132 +++++--- src/STEPCAFControl/STEPCAFControl_Writer.hxx | 40 ++- .../STEPConstruct_ContextTool.cxx | 23 +- .../STEPConstruct_ContextTool.hxx | 4 +- src/STEPConstruct/STEPConstruct_Part.cxx | 20 +- src/STEPConstruct/STEPConstruct_Part.hxx | 6 +- src/STEPConstruct/STEPConstruct_Styles.cxx | 12 +- src/STEPConstruct/STEPConstruct_Styles.hxx | 5 +- .../STEPConstruct_UnitContext.cxx | 30 +- .../STEPConstruct_UnitContext.hxx | 4 +- .../STEPConstruct_ValidationProps.cxx | 20 +- src/STEPControl/STEPControl_ActorRead.cxx | 102 +++--- src/STEPControl/STEPControl_ActorRead.hxx | 13 + src/STEPControl/STEPControl_ActorWrite.cxx | 93 +++--- src/STEPControl/STEPControl_ActorWrite.hxx | 25 +- src/STEPControl/STEPControl_Controller.cxx | 189 ++--------- src/STEPControl/STEPControl_Controller.hxx | 10 +- src/STEPControl/STEPControl_Reader.cxx | 56 +++- src/STEPControl/STEPControl_Reader.hxx | 27 +- src/STEPControl/STEPControl_Writer.cxx | 47 ++- src/STEPControl/STEPControl_Writer.hxx | 22 +- src/StepAP214/StepAP214_Protocol.cxx | 27 +- src/StepAP214/StepAP214_Protocol.hxx | 5 +- src/StepData/StepData.cxx | 2 - src/StepData/StepData_DescrProtocol.cxx | 2 +- src/StepData/StepData_DescrProtocol.hxx | 2 +- src/StepData/StepData_FileProtocol.cxx | 2 +- src/StepData/StepData_FileProtocol.hxx | 2 +- src/StepData/StepData_Protocol.cxx | 3 +- src/StepData/StepData_Protocol.hxx | 2 +- src/StepData/StepData_StepModel.cxx | 310 +++++++++++++++++- src/StepData/StepData_StepModel.hxx | 7 +- src/StepData/StepData_StepReaderData.cxx | 2 - src/StepSelect/StepSelect_StepType.cxx | 6 +- src/StepToGeom/StepToGeom.cxx | 3 +- src/StepToTopoDS/StepToTopoDS_Builder.cxx | 19 +- .../StepToTopoDS_TranslateCompositeCurve.cxx | 10 +- ...pToTopoDS_TranslateCurveBoundedSurface.cxx | 6 +- .../StepToTopoDS_TranslateEdgeLoop.cxx | 13 +- .../StepToTopoDS_TranslateFace.cxx | 6 +- .../TopoDSToStep_MakeBrepWithVoids.cxx | 3 +- .../TopoDSToStep_MakeFacetedBrep.cxx | 11 +- ...ToStep_MakeFacetedBrepAndBrepWithVoids.cxx | 3 +- .../TopoDSToStep_MakeGeometricCurveSet.cxx | 5 +- .../TopoDSToStep_MakeManifoldSolidBrep.cxx | 4 +- ...opoDSToStep_MakeShellBasedSurfaceModel.cxx | 19 +- .../TopoDSToStep_MakeStepEdge.cxx | 6 +- .../TopoDSToStep_MakeStepFace.cxx | 19 +- .../TopoDSToStep_MakeStepVertex.cxx | 5 +- src/TopoDSToStep/TopoDSToStep_Tool.cxx | 16 +- src/TopoDSToStep/TopoDSToStep_Tool.hxx | 8 +- src/XDEDRAW/XDEDRAW.cxx | 33 +- src/XDEDRAW/XDEDRAW_Common.cxx | 32 +- src/XSAlgo/XSAlgo_AlgoContainer.cxx | 34 +- src/XSAlgo/XSAlgo_AlgoContainer.hxx | 11 +- src/XSControl/XSControl_Controller.cxx | 50 ++- src/XSControl/XSControl_Controller.hxx | 9 +- src/XSControl/XSControl_Functions.cxx | 1 - src/XSControl/XSControl_Reader.cxx | 20 +- src/XSControl/XSControl_Reader.hxx | 3 + src/XSControl/XSControl_TransferReader.cxx | 11 +- src/XSControl/XSControl_WorkSession.cxx | 1 + src/XSDRAWSTEP/XSDRAWSTEP.cxx | 195 +++++++++-- tests/bugs/xde/bug23597 | 3 +- 80 files changed, 1370 insertions(+), 757 deletions(-) diff --git a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx b/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx index 1ce12440d2..503b30cd67 100644 --- a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx +++ b/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx @@ -163,7 +163,7 @@ void APIHeaderSection_MakeHeader::Apply Handle(StepData_Protocol) stepro = Handle(StepData_Protocol)::DownCast ( model->Protocol()); if (!stepro.IsNull()) sch = new TCollection_HAsciiString - (stepro->SchemaName()); + (stepro->SchemaName(model->GetParam("write.step.schema")->IntegerValue())); if (!sch.IsNull()) schid->SetValue (1,sch); } header.AddItem(fs); diff --git a/src/HeaderSection/HeaderSection_Protocol.cxx b/src/HeaderSection/HeaderSection_Protocol.cxx index c43908ce37..dce01ced17 100644 --- a/src/HeaderSection/HeaderSection_Protocol.cxx +++ b/src/HeaderSection/HeaderSection_Protocol.cxx @@ -35,5 +35,5 @@ Handle(Standard_Type)& atype) const else return 0; } -Standard_CString HeaderSection_Protocol::SchemaName() const +Standard_CString HeaderSection_Protocol::SchemaName(Standard_Integer /*theShematype*/) { return schemaName; } diff --git a/src/HeaderSection/HeaderSection_Protocol.hxx b/src/HeaderSection/HeaderSection_Protocol.hxx index 4ee81ac65d..1adf6a2723 100644 --- a/src/HeaderSection/HeaderSection_Protocol.hxx +++ b/src/HeaderSection/HeaderSection_Protocol.hxx @@ -42,7 +42,7 @@ public: //! Returns a Case Number for each of the HeaderSection Entities Standard_EXPORT virtual Standard_Integer TypeNumber (const Handle(Standard_Type)& atype) const Standard_OVERRIDE; - Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype) Standard_OVERRIDE; diff --git a/src/IFSelect/IFSelect_Functions.cxx b/src/IFSelect/IFSelect_Functions.cxx index 01a2a4bc90..7000cf9892 100644 --- a/src/IFSelect/IFSelect_Functions.cxx +++ b/src/IFSelect/IFSelect_Functions.cxx @@ -877,62 +877,6 @@ static IFSelect_ReturnStatus fun27 return IFSelect_RetVoid; } -static IFSelect_ReturnStatus fun28 - (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); -// **** DefParam **** - Handle(Message_Messenger) sout = Message::DefaultMessenger(); - if (argc < 2) { - Handle(TColStd_HSequenceOfHAsciiString) li = Interface_Static::Items(); - Standard_Integer i,nb = li->Length(); - sout<<" List of parameters : "<Value(i)->ToCString(); - sout<Print(sout); - return IFSelect_RetVoid; - - } else if (arg2[0] == 'i') { -// initialisation : arg1=nompar a2='i' a3=family a4=type [a5=val] - if (argc < 5) { sout<<" name init family type [valinit]"<Arg(4))[0]; - Standard_Boolean ok= (argc==5 ? Interface_Static::Init(arg3,arg1,typ) : - Interface_Static::Init(arg3,arg1,typ,pilot->Arg(5))); - return (ok ? IFSelect_RetDone : IFSelect_RetFail); - - } else if (arg2[0] == 'e') { -// edition : arg1=nompar arg2='e' arg3=option arg4...=parametres option - char comm[100]; - if (argc < 4) { - sout<<" give name and options ! Options (according type), 1 a time\n" - <<" imin ival / imax ival / rmin rval / rmax rval /\n" - <<" enum stnum / enum stnum match / eval e1 e2 e3 ... (maxi 10)\n" - < 4) sout<<"Only the command and ONE more arg are considered"<Arg(3),pilot->Arg(4)); - sout<<"Editing parameter : "<Family(),arg1,'&',comm)) - { sout<<"Editing done"< #include #include -#include #include #include #include @@ -1076,30 +1075,6 @@ Standard_Integer IFSelect_WorkSession::NextIdentForLabel // ################################################################# // .... Parametres (Int et Text) .... -//======================================================================= -//function : -//purpose : -//======================================================================= - -Handle(Standard_Transient) IFSelect_WorkSession::NewParamFromStatic - (const Standard_CString statname, const Standard_CString name) -{ - Handle(Standard_Transient) param; - Handle(Interface_Static) stat = Interface_Static::Static(statname); - if (stat.IsNull()) return param; - if (stat->Type() == Interface_ParamInteger) { - Handle(IFSelect_IntParam) intpar = new IFSelect_IntParam; - intpar->SetStaticName (statname); - param = intpar; - } else { - param = stat->HStringValue(); - } - if (param.IsNull()) return param; - if ( AddNamedItem (name, param) == 0 ) param.Nullify(); - return param; -} - - //======================================================================= //function : //purpose : diff --git a/src/IFSelect/IFSelect_WorkSession.hxx b/src/IFSelect/IFSelect_WorkSession.hxx index bd9748939d..975d94d752 100644 --- a/src/IFSelect/IFSelect_WorkSession.hxx +++ b/src/IFSelect/IFSelect_WorkSession.hxx @@ -407,13 +407,6 @@ public: //! - other values are ignored Standard_EXPORT Standard_Integer NextIdentForLabel (const Standard_CString label, const Standard_Integer id, const Standard_Integer mode = 0) const; - //! Creates a parameter as being bound to a Static - //! If the Static is Integer, this creates an IntParam bound to - //! it by its name. Else this creates a String which is the value - //! of the Static. - //! Returns a null handle if is unknown as a Static - Standard_EXPORT Handle(Standard_Transient) NewParamFromStatic (const Standard_CString statname, const Standard_CString name = ""); - //! Returns an IntParam, given its Ident in the Session //! Null result if is not suitable for an IntParam //! (undefined, or defined for another kind of variable) diff --git a/src/Interface/Interface_InterfaceModel.cxx b/src/Interface/Interface_InterfaceModel.cxx index edfc3c23e8..419941f59e 100644 --- a/src/Interface/Interface_InterfaceModel.cxx +++ b/src/Interface/Interface_InterfaceModel.cxx @@ -1040,3 +1040,24 @@ Handle(TColStd_HSequenceOfHAsciiString) Interface_InterfaceModel::ListTemplates } return list; } + +//======================================================================= +//function : GetParam +//purpose : +//======================================================================= +Handle(Interface_Static) Interface_InterfaceModel::GetParam +(const Standard_CString theParamName) +{ + Handle(Standard_Transient) result; + myParamMap.Find(theParamName, result); + return Handle(Interface_Static)::DownCast(result); +} + +//======================================================================= +//function : AllParameters +//purpose : +//======================================================================= +const NCollection_DataMap& Interface_InterfaceModel::AllParameters() +{ + return myParamMap; +} diff --git a/src/Interface/Interface_InterfaceModel.hxx b/src/Interface/Interface_InterfaceModel.hxx index e290857698..c7aa422801 100644 --- a/src/Interface/Interface_InterfaceModel.hxx +++ b/src/Interface/Interface_InterfaceModel.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include class Interface_Check; class TCollection_HAsciiString; @@ -398,17 +399,20 @@ public: //! Returns the complete list of names attached to template models Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) ListTemplates(); + //! Returns parameter for translation by its name + Standard_EXPORT Handle(Interface_Static) GetParam(const Standard_CString theParamName); + //! Returns all available parameters for translation + Standard_EXPORT const NCollection_DataMap& AllParameters(); DEFINE_STANDARD_RTTIEXT(Interface_InterfaceModel,Standard_Transient) protected: - //! Defines empty InterfaceModel, ready to be filled Standard_EXPORT Interface_InterfaceModel(); - + NCollection_DataMap myParamMap; private: diff --git a/src/Interface/Interface_Static.cxx b/src/Interface/Interface_Static.cxx index bde44bc651..26a89a8ad9 100644 --- a/src/Interface/Interface_Static.cxx +++ b/src/Interface/Interface_Static.cxx @@ -129,8 +129,6 @@ Standard_Boolean Interface_Static::UpdatedStatus () const return theupdate; } - - // ####################################################################### // ######### DICTIONNAIRE DES STATICS (static sur Static) ########## @@ -153,7 +151,6 @@ Standard_Boolean Interface_Static::Init return Standard_True; } - Standard_Boolean Interface_Static::Init (const Standard_CString family, const Standard_CString name, const Standard_Character type, const Standard_CString init) @@ -170,30 +167,7 @@ Standard_Boolean Interface_Static::Init case '&' : { Handle(Interface_Static) unstat = Interface_Static::Static(name); if (unstat.IsNull()) return Standard_False; -// Editions : init donne un petit texte d edition, en 2 termes "cmd var" : -// imin imax rmin rmax unit -// enum ematch eval - Standard_Integer i,iblc = 0; - for (i = 0; init[i] != '\0'; i ++) if (init[i] == ' ') iblc = i+1; -// Reconnaissance du sous-cas et aiguillage - if (init[0] == 'i' && init[2] == 'i') - unstat->SetIntegerLimit (Standard_False,atoi(&init[iblc])); - else if (init[0] == 'i' && init[2] == 'a') - unstat->SetIntegerLimit (Standard_True ,atoi(&init[iblc])); - else if (init[0] == 'r' && init[2] == 'i') - unstat->SetRealLimit (Standard_False,Atof(&init[iblc])); - else if (init[0] == 'r' && init[2] == 'a') - unstat->SetRealLimit (Standard_True ,Atof(&init[iblc])); - else if (init[0] == 'u') - unstat->SetUnitDef (&init[iblc]); - else if (init[0] == 'e' && init[1] == 'm') - unstat->StartEnum (atoi(&init[iblc]),Standard_True); - else if (init[0] == 'e' && init[1] == 'n') - unstat->StartEnum (atoi(&init[iblc]),Standard_False); - else if (init[0] == 'e' && init[1] == 'v') - unstat->AddEnum (&init[iblc]); - else return Standard_False; - return Standard_True; + return Interface_Static::InitValues(unstat, init); } default : return Standard_False; } @@ -205,6 +179,33 @@ Standard_Boolean Interface_Static::Init return Standard_True; } +Standard_Boolean Interface_Static::InitValues(Handle(Interface_Static)& theStatic, const Standard_CString init) +{ + // Editions : init donne un petit texte d edition, en 2 termes "cmd var" : + // imin imax rmin rmax unit + // enum ematch eval + Standard_Integer i, iblc = 0; + for (i = 0; init[i] != '\0'; i++) if (init[i] == ' ') iblc = i + 1; + // Reconnaissance du sous-cas et aiguillage + if (init[0] == 'i' && init[2] == 'i') + theStatic->SetIntegerLimit(Standard_False, atoi(&init[iblc])); + else if (init[0] == 'i' && init[2] == 'a') + theStatic->SetIntegerLimit(Standard_True, atoi(&init[iblc])); + else if (init[0] == 'r' && init[2] == 'i') + theStatic->SetRealLimit(Standard_False, Atof(&init[iblc])); + else if (init[0] == 'r' && init[2] == 'a') + theStatic->SetRealLimit(Standard_True, Atof(&init[iblc])); + else if (init[0] == 'u') + theStatic->SetUnitDef(&init[iblc]); + else if (init[0] == 'e' && init[1] == 'm') + theStatic->StartEnum(atoi(&init[iblc]), Standard_True); + else if (init[0] == 'e' && init[1] == 'n') + theStatic->StartEnum(atoi(&init[iblc]), Standard_False); + else if (init[0] == 'e' && init[1] == 'v') + theStatic->AddEnum(&init[iblc]); + else return Standard_False; + return Standard_True; +} Handle(Interface_Static) Interface_Static::Static (const Standard_CString name) diff --git a/src/Interface/Interface_Static.hxx b/src/Interface/Interface_Static.hxx index 15f1f0403b..8b87ebfe39 100644 --- a/src/Interface/Interface_Static.hxx +++ b/src/Interface/Interface_Static.hxx @@ -130,6 +130,9 @@ public: //! Returns False if does not match this list Standard_EXPORT static Standard_Boolean Init (const Standard_CString family, const Standard_CString name, const Standard_Character type, const Standard_CString init = ""); + //! Edit current with some parameter + Standard_EXPORT static Standard_Boolean InitValues(Handle(Interface_Static)& theStatic, const Standard_CString init); + //! Returns a Static from its name. Null Handle if not present Standard_EXPORT static Handle(Interface_Static) Static (const Standard_CString name); @@ -235,7 +238,7 @@ public: //! Returns False if is not present Standard_EXPORT static Standard_Boolean IsUpdated (const Standard_CString name); - //! Returns a list of names of statics : + //! Returns a list of names of statics: //! = 0 (D) : criter is for family //! = 1 : criter is regexp on names, takes final items //! (ignore wild cards) @@ -250,7 +253,8 @@ public: //! //! This allows for instance to set new values after having loaded //! or reloaded a resource, then to update them as required - Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0, const Standard_CString criter = ""); + Standard_EXPORT static Handle(TColStd_HSequenceOfHAsciiString) Items (const Standard_Integer mode = 0, + const Standard_CString criter = ""); //! Initializes all standard static parameters, which can be used //! by every function. statics specific of a norm or a function diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index ef0c381cb4..3e215861f0 100644 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -2550,7 +2549,7 @@ static Standard_Integer OCC7141 (Draw_Interpretor& di, Standard_Integer argc, co shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main()); shapeTool->AddShape(AddTestStructure(nCount), Standard_True); STEPControl_StepModelType mode = STEPControl_AsIs; - if (!Interface_Static::SetIVal("write.step.assembly",1)) { //assembly mode + if (!writer.GetParam("write.step.assembly")->SetIntegerValue(1)) { //assembly mode di << "Failed to set assembly mode for step data\n\n"; return 0; } diff --git a/src/RWHeaderSection/RWHeaderSection.cxx b/src/RWHeaderSection/RWHeaderSection.cxx index b1d2f27262..d1e0cbc598 100644 --- a/src/RWHeaderSection/RWHeaderSection.cxx +++ b/src/RWHeaderSection/RWHeaderSection.cxx @@ -22,10 +22,16 @@ /// #include static Handle(RWHeaderSection_ReadWriteModule) rwm; static Handle(RWHeaderSection_GeneralModule) rwg; +static int THE_RWHeaderSection_init = 0; void RWHeaderSection::Init() { + if (THE_RWHeaderSection_init) + { + return; + } + THE_RWHeaderSection_init = 1; /// EuclidStandard::Init(); Handle(HeaderSection_Protocol) proto = HeaderSection::Protocol(); StepData::AddHeaderProtocol(proto); diff --git a/src/STEPCAFControl/STEPCAFControl_Controller.cxx b/src/STEPCAFControl/STEPCAFControl_Controller.cxx index 1b5d41463a..b6500bb33b 100644 --- a/src/STEPCAFControl/STEPCAFControl_Controller.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Controller.cxx @@ -13,8 +13,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - -#include #include #include #include @@ -31,43 +29,3 @@ STEPCAFControl_Controller::STEPCAFControl_Controller () Handle(STEPCAFControl_ActorWrite) ActWrite = new STEPCAFControl_ActorWrite; myAdaptorWrite = ActWrite; } - -//======================================================================= -//function : Init -//purpose : -//======================================================================= - -Standard_Boolean STEPCAFControl_Controller::Init () -{ - static Standard_Boolean inic = Standard_False; - if (inic) return Standard_True; - inic = Standard_True; - // self-registering - Handle(STEPCAFControl_Controller) STEPCTL = new STEPCAFControl_Controller; - // do XSAlgo::Init, cause it does not called before. - XSAlgo::Init(); - // do something to avoid warnings... - STEPCTL->AutoRecord(); - - //----------------------------------------------------------- - // Few variables for advanced control of translation process - //----------------------------------------------------------- - - // Indicates whether to write sub-shape names to 'Name' attributes of - // STEP Representation Items - Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", 'e', ""); - Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "enum 0"); - Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "eval Off"); // 0 - Interface_Static::Init ("stepcaf", "write.stepcaf.subshapes.name", '&', "eval On"); // 1 - Interface_Static::SetIVal("write.stepcaf.subshapes.name", 0); // Disabled by default - - // Indicates whether to read sub-shape names from 'Name' attributes of - // STEP Representation Items - Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", 'e', ""); - Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "enum 0"); - Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval Off"); // 0 - Interface_Static::Init ("stepcaf", "read.stepcaf.subshapes.name", '&', "eval On"); // 1 - Interface_Static::SetIVal("read.stepcaf.subshapes.name", 0); // Disabled by default - - return Standard_True; -} diff --git a/src/STEPCAFControl/STEPCAFControl_Controller.hxx b/src/STEPCAFControl/STEPCAFControl_Controller.hxx index bf5e782e6a..3c3e82600e 100644 --- a/src/STEPCAFControl/STEPCAFControl_Controller.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Controller.hxx @@ -38,13 +38,6 @@ public: //! Initializes the use of STEP Norm (the first time) Standard_EXPORT STEPCAFControl_Controller(); - - //! Standard Initialisation. It creates a Controller for STEP-XCAF - //! and records it to various names, available to select it later - //! Returns True when done, False if could not be done - Standard_EXPORT static Standard_Boolean Init(); - - DEFINE_STANDARD_RTTIEXT(STEPCAFControl_Controller,STEPControl_Controller) diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index b1fac42441..592c6ffa1c 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -324,12 +323,12 @@ STEPCAFControl_Reader::STEPCAFControl_Reader (): myNameMode ( Standard_True ), myLayerMode( Standard_True ), myPropsMode( Standard_True ), - mySHUOMode ( Standard_False ), + mySHUOMode ( Standard_False ), myGDTMode ( Standard_True ), myMatMode(Standard_True), myViewMode(Standard_True) { - STEPCAFControl_Controller::Init(); + Init(new XSControl_WorkSession, new STEPCAFControl_Controller); } @@ -338,19 +337,37 @@ STEPCAFControl_Reader::STEPCAFControl_Reader (): //purpose : //======================================================================= -STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& WS, - const Standard_Boolean scratch) : +STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean theScratch) : myColorMode( Standard_True ), myNameMode ( Standard_True ), myLayerMode( Standard_True ), myPropsMode( Standard_True ), - mySHUOMode ( Standard_False ), + mySHUOMode ( Standard_False ), myGDTMode ( Standard_True ), myMatMode(Standard_True), myViewMode(Standard_True) { - STEPCAFControl_Controller::Init(); - Init ( WS, scratch ); + Init (theWS, new STEPCAFControl_Controller, theScratch); +} + +//======================================================================= +//function : STEPCAFControl_Reader +//purpose : +//======================================================================= +STEPCAFControl_Reader::STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch) : + myColorMode(Standard_True), + myNameMode(Standard_True), + myLayerMode(Standard_True), + myPropsMode(Standard_True), + mySHUOMode(Standard_False), + myGDTMode(Standard_True), + myMatMode(Standard_True), + myViewMode(Standard_True) +{ + Init(theWS, theController, theScratch); } @@ -359,11 +376,14 @@ STEPCAFControl_Reader::STEPCAFControl_Reader (const Handle(XSControl_WorkSession //purpose : //======================================================================= -void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& WS, - const Standard_Boolean scratch) +void STEPCAFControl_Reader::Init (const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch) { -// necessary only in Writer, to set good actor: WS->SelectNorm ( "STEP" ); - myReader.SetWS (WS,scratch); + myCAFController = Handle(STEPCAFControl_Controller)::DownCast(theController); + STEPControl_Reader aReader(theWS, theController, theScratch); + myReader = aReader; + myFiles.Clear(); } @@ -825,8 +845,7 @@ Handle(STEPCAFControl_ExternFile) STEPCAFControl_Reader::ReadExternFile (const S // create new WorkSession and Reader Handle(XSControl_WorkSession) newWS = new XSControl_WorkSession; - newWS->SelectNorm ( "STEP" ); - STEPControl_Reader sr ( newWS, Standard_False ); + STEPControl_Reader sr ( newWS, myCAFController, Standard_False ); // start to fill the resulting ExternFile structure Handle(STEPCAFControl_ExternFile) EF = new STEPCAFControl_ExternFile; @@ -4375,7 +4394,7 @@ void STEPCAFControl_Reader::ExpandSubShapes(const Handle(XCAFDoc_ShapeTool)& Sha TColStd_MapOfTransient aRepItems; // Read translation control variables - Standard_Boolean doReadSNames = (Interface_Static::IVal("read.stepcaf.subshapes.name") > 0); + Standard_Boolean doReadSNames = (myReader.Model()->GetParam("read.stepcaf.subshapes.name")->IntegerValue() > 0); if ( !doReadSNames ) return; diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.hxx b/src/STEPCAFControl/STEPCAFControl_Reader.hxx index 548a32c5c5..c72e431815 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -74,12 +75,15 @@ public: //! Creates a reader tool and attaches it to an already existing Session //! Clears the session if it was not yet set for STEP - Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); - - //! Clears the internal data structures and attaches to a new session + Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean theScratch = Standard_True); + + //! Creates a reader tool and attaches it to an already existing Session and controller //! Clears the session if it was not yet set for STEP - Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); - + Standard_EXPORT STEPCAFControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch = Standard_True); + //! Loads a file and returns the read status //! Provided for use like single-file reader Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename); @@ -168,7 +172,12 @@ public: protected: - + + //! Inits a reader with following session and controller + Standard_EXPORT void Init(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch = Standard_True); + //! Translates STEP file already loaded into the reader //! into the document //! If num==0, translates all roots, else only root number num @@ -283,6 +292,7 @@ private: Standard_Boolean myMatMode; Standard_Boolean myViewMode; NCollection_DataMap myGDTMap; + Handle(STEPCAFControl_Controller) myCAFController; }; diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 21133dcdfa..d151d62987 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -278,9 +278,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () : myDGTMode ( Standard_True ), myMatMode ( Standard_True ) { - STEPCAFControl_Controller::Init(); - Handle(XSControl_WorkSession) WS = new XSControl_WorkSession; - Init ( WS ); + Init(new XSControl_WorkSession, new STEPCAFControl_Controller); } @@ -289,29 +287,50 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () : //purpose : //======================================================================= -STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession)& WS, - const Standard_Boolean scratch) +STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean theScratch) : + myColorMode(Standard_True), + myNameMode(Standard_True), + myLayerMode(Standard_True), + myPropsMode(Standard_True), + mySHUOMode(Standard_True), + myDGTMode(Standard_True), + myMatMode(Standard_True) { - STEPCAFControl_Controller::Init(); - Init ( WS, scratch ); - myColorMode = Standard_True; - myNameMode = Standard_True; - myLayerMode = Standard_True; - myPropsMode = Standard_True; - mySHUOMode = Standard_True; + Init(theWS, new STEPCAFControl_Controller, theScratch); } +//======================================================================= +//function : STEPCAFControl_Reader +//purpose : +//======================================================================= +STEPCAFControl_Writer::STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch) : + myColorMode(Standard_True), + myNameMode(Standard_True), + myLayerMode(Standard_True), + myPropsMode(Standard_True), + mySHUOMode(Standard_True), + myDGTMode(Standard_True), + myMatMode(Standard_True) +{ + Init(theWS, theController, theScratch); +} //======================================================================= //function : Init -//purpose : +//purpose : //======================================================================= -void STEPCAFControl_Writer::Init (const Handle(XSControl_WorkSession)& WS, - const Standard_Boolean scratch) +void STEPCAFControl_Writer::Init(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch) { - WS->SelectNorm ( "STEP" ); - myWriter.SetWS (WS,scratch); + myCAFController = Handle(STEPCAFControl_Controller)::DownCast(theController); + STEPControl_Writer aWriter(theWS, theController, theScratch); + myWriter = aWriter; + myFiles.Clear(); myLabEF.Clear(); myLabels.Clear(); @@ -503,10 +522,11 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, if ( labels.Length() <=0 ) return Standard_False; Handle(STEPCAFControl_ActorWrite) Actor = - Handle(STEPCAFControl_ActorWrite)::DownCast ( writer.WS()->NormAdaptor()->ActorWrite() ); + Handle(STEPCAFControl_ActorWrite)::DownCast (writer.WS()->NormAdaptor()->ActorWrite()); // translate free top-level shapes of the DECAF document - Standard_Integer ap = Interface_Static::IVal ("write.step.schema"); + Handle(StepData_StepModel) aModel = writer.Model(); + Standard_Integer ap = aModel->GetParam("write.step.schema")->IntegerValue(); TDF_LabelSequence sublabels; for ( Standard_Integer i=1; i <= labels.Length(); i++ ) { TDF_Label L = labels.Value(i); @@ -574,31 +594,32 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, } else { // translate final solids - TopoDS_Shape Sass = TransferExternFiles ( L, mode, sublabels, multi ); + TopoDS_Shape Sass = TransferExternFiles(L, mode, sublabels, multi); // translate main assembly structure /* if ( ap == 3 ) { // if AP203, switch to AP214 - Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); - Handle(StepData_StepModel) model = - Handle(StepData_StepModel)::DownCast ( writer.WS()->Model() ); - if ( model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ) { - Handle(HeaderSection_FileSchema) fs = - Handle(HeaderSection_FileSchema)::DownCast ( model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ); - Handle(TCollection_HAsciiString) str = fs->SchemaIdentifiersValue ( 1 ); - Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "AUTOMOTIVE_DESIGN" ); - if ( str->Search ( ap214 ) <0 ) { - str->Clear(); - str->AssignCat ( ap214 ); - } - } + myCAFController->GetParam("write.step.schema")->SetCStringValue("AP214DIS"); + Handle(StepData_StepModel) model = + Handle(StepData_StepModel)::DownCast ( writer.WS()->Model() ); + if ( model->HasHeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ) { + Handle(HeaderSection_FileSchema) fs = + Handle(HeaderSection_FileSchema)::DownCast ( model->HeaderEntity(STANDARD_TYPE(HeaderSection_FileSchema)) ); + Handle(TCollection_HAsciiString) str = fs->SchemaIdentifiersValue ( 1 ); + Handle(TCollection_HAsciiString) ap214 = new TCollection_HAsciiString ( "AUTOMOTIVE_DESIGN" ); + if ( str->Search ( ap214 ) <0 ) { + str->Clear(); + str->AssignCat ( ap214 ); + } + } } -*/ - Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); - Interface_Static::SetCVal ("write.step.assembly", "On"); - writer.Transfer ( Sass, STEPControl_AsIs ); - Interface_Static::SetIVal ("write.step.assembly", assemblymode); - Interface_Static::SetIVal ("write.step.schema", ap); +*/ + Handle(Interface_Static) aParameter = aModel->GetParam("write.step.assembly"); + Standard_Integer assemblymode = aParameter->IntegerValue(); + aParameter->SetCStringValue("On"); + writer.Transfer(Sass, STEPControl_AsIs); + aParameter->SetIntegerValue(assemblymode); + aModel->GetParam("write.step.schema")->SetIntegerValue(ap); } } @@ -650,12 +671,12 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, // write validation props // if ( multi && ap ==3 ) { -// Interface_Static::SetCVal ("write.step.schema", "AP214DIS"); +// myCAFController->GetParam("write.step.schema")->SetCStringValue("AP214DIS"); // } if ( GetPropsMode() ) WriteValProps ( writer.WS(), sublabels, multi ); - Interface_Static::SetIVal ("write.step.schema", ap); + aModel->GetParam("write.step.schema")->SetIntegerValue(ap); // refresh graph writer.WS()->ComputeGraph ( Standard_True ); @@ -664,7 +685,7 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer, * Write names for the sub-shapes * ================================ */ - if (Interface_Static::IVal("write.stepcaf.subshapes.name") != 0) + if (aModel->GetParam("write.stepcaf.subshapes.name")->IntegerValue() != 0) { const Handle(XSControl_TransferWriter) &TW = this->ChangeWriter().WS()->TransferWriter(); const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); @@ -753,11 +774,12 @@ TopoDS_Shape STEPCAFControl_Writer::TransferExternFiles (const TDF_Label &L, EF->SetWS ( newWS ); EF->SetName ( name ); EF->SetLabel ( L ); - Standard_Integer assemblymode = Interface_Static::IVal ("write.step.assembly"); - Interface_Static::SetCVal ("write.step.assembly", "Off"); + Handle(Interface_Static) aParameter = sw.Model()->GetParam("write.step.assembly"); + Standard_Integer assemblymode = aParameter->IntegerValue(); + aParameter->SetCStringValue("Off"); const Standard_CString multi = 0; EF->SetTransferStatus ( Transfer ( sw, Lseq, mode, multi, Standard_True ) ); - Interface_Static::SetIVal ("write.step.assembly", assemblymode); + aParameter->SetIntegerValue(assemblymode); myLabEF.Bind ( L, EF ); myFiles.Bind ( name->ToCString(), EF ); @@ -806,7 +828,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteExternRefs (const Handle(XSControl_ const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); STEPConstruct_ExternRefs EFTool ( WS ); - Standard_Integer schema = Interface_Static::IVal("write.step.schema"); + Standard_Integer schema = WS->Model()->GetParam("write.step.schema")->IntegerValue(); for ( Standard_Integer k=1; k <= labels.Length(); k++ ) { TDF_Label lab = labels(k); if ( XCAFDoc_ShapeTool::IsAssembly ( lab ) ) continue; // skip assemblies @@ -1238,9 +1260,9 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work // iterate on subshapes and create STEP styles Handle(StepVisual_StyledItem) override; TopTools_MapOfShape Map; - + MakeSTEPStyles(Styles,S,settings,override,Map,myMapCompMDGPR,DPDCs,ColRGBs,CTool,0,isComponent); - + // create MDGPR and record it in model Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; @@ -1250,7 +1272,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work cerr << "Error: Current Top-Level shape have MDGPR already " << endl; #endif } - Styles.CreateMDGPR ( Context, aMDGPR ); + Styles.CreateMDGPR(Context, aMDGPR, WS->Model()); if (!aMDGPR.IsNull()) myMapCompMDGPR.Bind( aTopSh, aMDGPR ); } @@ -1896,7 +1918,7 @@ static Standard_Boolean createSHUOStyledItem (const XCAFPrs_Style& style, cout << "Warning: " << __FILE__ << ": Create new MDGPR for SHUO instance" << endl; #endif Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation) aMDGPR; - Styles.CreateMDGPR ( Context, aMDGPR ); + Styles.CreateMDGPR ( Context, aMDGPR, WS->Model()); if (!aMDGPR.IsNull()) myMapCompMDGPR.Bind( aTopSh, aMDGPR ); } @@ -4304,3 +4326,13 @@ Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const { return myMatMode; } + +//======================================================================= +//function : GetParam +//purpose : +//======================================================================= +Handle(Interface_Static) STEPCAFControl_Writer::GetParam +(const Standard_CString theParamName) +{ + return myWriter.Model()->GetParam(theParamName); +} diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.hxx b/src/STEPCAFControl/STEPCAFControl_Writer.hxx index 34fcc83485..68682236c9 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -64,15 +65,18 @@ public: //! PropsMode to Standard_True. Standard_EXPORT STEPCAFControl_Writer(); - //! Creates a reader tool and attaches it to an already existing Session + //! Creates a writer tool and attaches it to an already existing Session //! Clears the session if it was not yet set for STEP //! Clears the internal data structures - Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); - - //! Clears the internal data structures and attaches to a new session + Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& WS, + const Standard_Boolean scratch = Standard_True); + + //! Creates a writer tool and attaches it to an already existing Session and controller //! Clears the session if it was not yet set for STEP - Standard_EXPORT void Init (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); - + Standard_EXPORT STEPCAFControl_Writer(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch = Standard_True); + //! Writes all the produced models into file //! In case of multimodel with extern references, //! filename will be a name of root file, all other files @@ -149,18 +153,33 @@ public: Standard_EXPORT void SetMaterialMode (const Standard_Boolean matmode); Standard_EXPORT Standard_Boolean GetMaterialMode() const; + + //! Returns parameter for translation by its name + Standard_EXPORT Handle(Interface_Static) GetParam(const Standard_CString theParamName); protected: + + //! Inits a reader with following session and controller + Standard_EXPORT void Init(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch = Standard_True); + //! Mehod to writing sequence of root assemblies or part of the file specified by use by one label - Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0); + Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, + const STEPControl_StepModelType mode = STEPControl_AsIs, + const Standard_CString multi = 0); //! Transfers labels to a STEP model //! Returns True if translation is OK //! isExternFile setting from TransferExternFiles method - Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr, const TDF_LabelSequence& labels, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0, const Standard_Boolean isExternFile = Standard_False) ; + Standard_EXPORT Standard_Boolean Transfer (STEPControl_Writer& wr, + const TDF_LabelSequence& labels, + const STEPControl_StepModelType mode = STEPControl_AsIs, + const Standard_CString multi = 0, + const Standard_Boolean isExternFile = Standard_False) ; //! Parses assembly structure of label L, writes all the simple //! shapes each to its own file named by name of its label plus @@ -168,7 +187,9 @@ protected: //! Returns shape representing that assembly structure //! in the form of nested empty compounds (and a sequence of //! labels which are newly written nodes of this assembly) - Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, const STEPControl_StepModelType mode, TDF_LabelSequence& Lseq, const Standard_CString prefix = ""); + Standard_EXPORT TopoDS_Shape TransferExternFiles (const TDF_Label& L, + const STEPControl_StepModelType mode, + TDF_LabelSequence& Lseq, const Standard_CString prefix = ""); //! Write external references to STEP Standard_EXPORT Standard_Boolean WriteExternRefs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const; @@ -237,6 +258,7 @@ private: Handle(StepVisual_DraughtingModel) myGDTPresentationDM; Handle(StepVisual_HArray1OfPresentationStyleAssignment) myGDTPrsCurveStyle; Handle(StepRepr_ProductDefinitionShape) myGDTCommonPDS; + Handle(STEPCAFControl_Controller) myCAFController; }; diff --git a/src/STEPConstruct/STEPConstruct_ContextTool.cxx b/src/STEPConstruct/STEPConstruct_ContextTool.cxx index 0b93e40b9e..dd20a3fec6 100644 --- a/src/STEPConstruct/STEPConstruct_ContextTool.cxx +++ b/src/STEPConstruct/STEPConstruct_ContextTool.cxx @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -75,13 +74,14 @@ STEPConstruct_ContextTool::STEPConstruct_ContextTool (const Handle(StepData_Step //purpose : //======================================================================= -void STEPConstruct_ContextTool::SetModel (const Handle(StepData_StepModel)& aStepModel) +void STEPConstruct_ContextTool::SetModel (const Handle(Interface_InterfaceModel)& aStepModel) { + myModel = aStepModel; theAPD.Nullify(); //thePRPC.Nullify(); - Standard_Integer i, nb = aStepModel->NbEntities(); + Standard_Integer i, nb = myModel->NbEntities(); for(i = 1; i<=nb && theAPD.IsNull(); i ++) { - Handle(Standard_Transient) ent = aStepModel->Value(i); + Handle(Standard_Transient) ent = myModel->Value(i); if (ent->IsKind(STANDARD_TYPE(StepBasic_ApplicationProtocolDefinition))) { if (theAPD.IsNull()) theAPD = GetCasted(StepBasic_ApplicationProtocolDefinition, ent); } @@ -111,7 +111,7 @@ void STEPConstruct_ContextTool::AddAPD (const Standard_Boolean enforce) Standard_Boolean noapd = theAPD.IsNull(); if (noapd || enforce) theAPD = new StepBasic_ApplicationProtocolDefinition; - switch (Interface_Static::IVal("write.step.schema")) { //j4 + switch (myModel->GetParam("write.step.schema")->IntegerValue()) { //j4 default: case 1: theAPD->SetApplicationProtocolYear (1997); @@ -147,7 +147,7 @@ void STEPConstruct_ContextTool::AddAPD (const Standard_Boolean enforce) if (theAPD->Application().IsNull()) theAPD->SetApplication (new StepBasic_ApplicationContext); Handle(TCollection_HAsciiString) appl; - switch (Interface_Static::IVal("write.step.schema")) { //j4 + switch (myModel->GetParam("write.step.schema")->IntegerValue()) { //j4 default: case 1: case 2: appl = new TCollection_HAsciiString ( "core data for automotive mechanical design processes" ); @@ -356,7 +356,7 @@ void STEPConstruct_ContextTool::AddPRPC (const Standard_Boolean enforce) Standard_Boolean noprpc = thePRPC.IsNull(); if (noprpc || enforce) { //:i3 abv 1 Sep 98: ProSTEP TR9: generate PRODUCT_TYPE (derived) instead of PRPC - switch (Interface_Static::IVal("write.step.schema")) { //j4 + switch (myModel->GetParam("write.step.schema")->IntegerValue()) { //j4 default: case 1: thePRPC = new StepBasic_ProductType; @@ -567,8 +567,9 @@ void STEPConstruct_ContextTool::SetIndex (const Standard_Integer ind) Handle(TCollection_HAsciiString) STEPConstruct_ContextTool::GetProductName () const { Handle(TCollection_HAsciiString) PdtName; - if (Interface_Static::IsSet("write.step.product.name")) - PdtName = new TCollection_HAsciiString(Interface_Static::CVal("write.step.product.name")); + Handle(Interface_Static) aParam = myModel->GetParam("write.step.product.name"); + if (!aParam.IsNull() && aParam->IsSetValue()) + PdtName = new TCollection_HAsciiString(aParam->CStringValue()); else PdtName = new TCollection_HAsciiString("Product"); for ( Standard_Integer i=1; i <= myLevel.Length(); i++ ) { @@ -596,7 +597,7 @@ Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForPart if ( ! SDRTool.PRPC().IsNull() ) seq->Append ( SDRTool.PRPC() ); // for AP203, add required product management data - if ( Interface_Static::IVal("write.step.schema") == 3 ) { + if (myModel->GetParam("write.step.schema")->IntegerValue() == 3 ) { theAP203.Init ( SDRTool ); seq->Append (theAP203.GetProductCategoryRelationship()); seq->Append (theAP203.GetCreator()); @@ -626,7 +627,7 @@ Handle(TColStd_HSequenceOfTransient) STEPConstruct_ContextTool::GetRootsForAssem seq->Append ( assembly.ItemValue() ); // for AP203, write required product management data - if ( Interface_Static::IVal("write.step.schema") == 3 ) { + if ( myModel->GetParam("write.step.schema")->IntegerValue() == 3 ) { theAP203.Init ( assembly.GetNAUO() ); seq->Append (theAP203.GetSecurity()); seq->Append (theAP203.GetClassificationOfficer()); diff --git a/src/STEPConstruct/STEPConstruct_ContextTool.hxx b/src/STEPConstruct/STEPConstruct_ContextTool.hxx index ed024587ac..ae5b724e06 100644 --- a/src/STEPConstruct/STEPConstruct_ContextTool.hxx +++ b/src/STEPConstruct/STEPConstruct_ContextTool.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -55,7 +56,7 @@ public: //! Initialize ApplicationProtocolDefinition by the first //! entity of that type found in the model - Standard_EXPORT void SetModel (const Handle(StepData_StepModel)& aStepModel); + Standard_EXPORT void SetModel (const Handle(Interface_InterfaceModel)& aStepModel); Standard_EXPORT Handle(StepBasic_ApplicationProtocolDefinition) GetAPD(); @@ -141,6 +142,7 @@ private: Handle(StepBasic_ApplicationProtocolDefinition) theAPD; STEPConstruct_AP203Context theAP203; Handle(StepGeom_Axis2Placement3d) myAxis; + Handle(Interface_InterfaceModel) myModel; }; diff --git a/src/STEPConstruct/STEPConstruct_Part.cxx b/src/STEPConstruct/STEPConstruct_Part.cxx index 18b9ee1a42..40d8140085 100644 --- a/src/STEPConstruct/STEPConstruct_Part.cxx +++ b/src/STEPConstruct/STEPConstruct_Part.cxx @@ -16,7 +16,6 @@ //:j4 gka 16.03.99 S4134 // abv 20.11.99 renamed from StepPDR_SDRtool -#include #include #include #include @@ -59,12 +58,13 @@ STEPConstruct_Part::STEPConstruct_Part() //purpose : //======================================================================= -void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR, - const Handle(TCollection_HAsciiString)& aName, - const Handle(StepBasic_ApplicationContext)& AC) +void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& theShape, + const Handle(TCollection_HAsciiString)& theName, + const Handle(StepBasic_ApplicationContext)& theAppContext, + const Handle(Interface_InterfaceModel)& theModel) { // get current schema - Standard_Integer schema = Interface_Static::IVal("write.step.schema"); + Standard_Integer schema = theModel->GetParam("write.step.schema")->IntegerValue(); // create PC Handle(StepBasic_ProductContext) PC; @@ -82,14 +82,14 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR Handle(TCollection_HAsciiString) PCname = new TCollection_HAsciiString(""); Handle(TCollection_HAsciiString) PCdisciplineType = new TCollection_HAsciiString("mechanical"); - PC->Init(PCname, AC, PCdisciplineType); + PC->Init(PCname, theAppContext, PCdisciplineType); // create product Handle(StepBasic_Product) P = new StepBasic_Product; Handle(StepBasic_HArray1OfProductContext) PCs = new StepBasic_HArray1OfProductContext(1,1); PCs->SetValue(1,PC); Handle(TCollection_HAsciiString) Pdescription = new TCollection_HAsciiString(""); - P->Init(aName, aName, Pdescription, PCs); + P->Init(theName, theName, Pdescription, PCs); // create PDF Handle(StepBasic_ProductDefinitionFormation) PDF; @@ -123,7 +123,7 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR break; } Handle(TCollection_HAsciiString) PDClifeCycleStage = new TCollection_HAsciiString("design"); - PDC->Init(PDCname, AC, PDClifeCycleStage); + PDC->Init(PDCname, theAppContext, PDClifeCycleStage); // create PD Handle(StepBasic_ProductDefinition) PD = new StepBasic_ProductDefinition; @@ -143,11 +143,11 @@ void STEPConstruct_Part::MakeSDR(const Handle(StepShape_ShapeRepresentation)& SR mySDR = new StepShape_ShapeDefinitionRepresentation; StepRepr_RepresentedDefinition RD; RD.SetValue ( PDS ); - mySDR->Init(RD, SR); + mySDR->Init(RD, theShape); // and an associated PRPC Handle(TCollection_HAsciiString) PRPCName; - switch (Interface_Static::IVal("write.step.schema")) { + switch (theModel->GetParam("write.step.schema")->IntegerValue()) { default: case 1: myPRPC = new StepBasic_ProductType; diff --git a/src/STEPConstruct/STEPConstruct_Part.hxx b/src/STEPConstruct/STEPConstruct_Part.hxx index c6aafd1488..d5ae99eaa2 100644 --- a/src/STEPConstruct/STEPConstruct_Part.hxx +++ b/src/STEPConstruct/STEPConstruct_Part.hxx @@ -21,6 +21,7 @@ #include #include +#include #include class StepShape_ShapeDefinitionRepresentation; class StepBasic_ProductRelatedProductCategory; @@ -48,7 +49,10 @@ public: Standard_EXPORT STEPConstruct_Part(); - Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& aShape, const Handle(TCollection_HAsciiString)& aName, const Handle(StepBasic_ApplicationContext)& AC); + Standard_EXPORT void MakeSDR (const Handle(StepShape_ShapeRepresentation)& theShape, + const Handle(TCollection_HAsciiString)& theName, + const Handle(StepBasic_ApplicationContext)& theAppContext, + const Handle(Interface_InterfaceModel)& theModel ); Standard_EXPORT void ReadSDR (const Handle(StepShape_ShapeDefinitionRepresentation)& aShape); diff --git a/src/STEPConstruct/STEPConstruct_Styles.cxx b/src/STEPConstruct/STEPConstruct_Styles.cxx index ad131f96c0..e06fd82f65 100644 --- a/src/STEPConstruct/STEPConstruct_Styles.cxx +++ b/src/STEPConstruct/STEPConstruct_Styles.cxx @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -213,8 +212,9 @@ Handle(StepVisual_StyledItem) STEPConstruct_Styles::AddStyle (const TopoDS_Shape //purpose : //======================================================================= -Standard_Boolean STEPConstruct_Styles::CreateMDGPR (const Handle(StepRepr_RepresentationContext) &Context, - Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& Repr) +Standard_Boolean STEPConstruct_Styles::CreateMDGPR (const Handle(StepRepr_RepresentationContext)& theContext, + Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& theMDGPR, + const Handle(Interface_InterfaceModel) theModel) { if ( myStyles.Extent() <1 ) return Standard_False; @@ -224,15 +224,15 @@ Standard_Boolean STEPConstruct_Styles::CreateMDGPR (const Handle(StepRepr_Repres for ( Standard_Integer i=1; i <= myStyles.Extent(); i++ ) elems->SetValue ( i, Handle(StepRepr_RepresentationItem)::DownCast ( myStyles.FindKey(i) ) ); // create new MDGPR - Repr = new StepVisual_MechanicalDesignGeometricPresentationRepresentation; + theMDGPR = new StepVisual_MechanicalDesignGeometricPresentationRepresentation; Handle(TCollection_HAsciiString) ReprName = new TCollection_HAsciiString ( "" ); - Repr->Init ( ReprName, elems, Context ); + theMDGPR->Init ( ReprName, elems, theContext ); // record Repr in order to have it written to the file // Model()->AddWithRefs ( Repr ); add into the model upper // for AP203, add subschema name - if ( Interface_Static::IVal("write.step.schema") ==3 ) { + if ( theModel->GetParam("write.step.schema")->IntegerValue() == 3 ) { APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) ); Handle(TCollection_HAsciiString) subSchema = new TCollection_HAsciiString ( "SHAPE_APPEARANCE_LAYER_MIM" ); diff --git a/src/STEPConstruct/STEPConstruct_Styles.hxx b/src/STEPConstruct/STEPConstruct_Styles.hxx index 72ef678e88..9c96b9f293 100644 --- a/src/STEPConstruct/STEPConstruct_Styles.hxx +++ b/src/STEPConstruct/STEPConstruct_Styles.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -93,7 +94,9 @@ public: //! Create MDGPR, fill it with all the styles previously defined, //! and add it to the model - Standard_EXPORT Standard_Boolean CreateMDGPR (const Handle(StepRepr_RepresentationContext)& Context, Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& MDGPR); + Standard_EXPORT Standard_Boolean CreateMDGPR (const Handle(StepRepr_RepresentationContext)& theContext, + Handle(StepVisual_MechanicalDesignGeometricPresentationRepresentation)& theMDGPR, + const Handle(Interface_InterfaceModel) theModel); //! Create MDGPR, fill it with all the styles previously defined, //! and add it to the model diff --git a/src/STEPConstruct/STEPConstruct_UnitContext.cxx b/src/STEPConstruct/STEPConstruct_UnitContext.cxx index 1de10cf889..e0fb1e3c6a 100644 --- a/src/STEPConstruct/STEPConstruct_UnitContext.cxx +++ b/src/STEPConstruct/STEPConstruct_UnitContext.cxx @@ -17,7 +17,6 @@ //abv 17.11.99: renamed from StepPDR_MakeUnitAndToleranceContext and merged with STEPControl_Unit //abv 30.02.00: ability to write file in units other than MM -#include #include #include #include @@ -68,7 +67,8 @@ STEPConstruct_UnitContext::STEPConstruct_UnitContext() : done(Standard_False) //purpose : //======================================================================= -void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d) +void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d, + Handle(Interface_InterfaceModel)& theModel) { done = Standard_True; @@ -85,18 +85,18 @@ void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d) Standard_CString uName = 0; Standard_Boolean hasPref = Standard_True; StepBasic_SiPrefix siPref = StepBasic_spMilli; - switch ( Interface_Static::IVal ( "write.step.unit" ) ) { - case 1 : uName = "INCH"; break; - default : - case 2 : break; - case 4 : uName = "FOOT"; break; - case 5 : uName = "MILE"; break; - case 6 : hasPref = Standard_False; break; - case 7 : siPref = StepBasic_spKilo; break; - case 8 : uName = "MIL"; break; - case 9 : siPref = StepBasic_spMicro; break; - case 10 : siPref = StepBasic_spCenti; break; - case 11 : uName = "MICROINCH"; break; + switch (theModel->GetParam("write.step.unit")->IntegerValue()) { + case 1: uName = "INCH"; break; + default: + case 2: break; + case 4: uName = "FOOT"; break; + case 5: uName = "MILE"; break; + case 6: hasPref = Standard_False; break; + case 7: siPref = StepBasic_spKilo; break; + case 8: uName = "MIL"; break; + case 9: siPref = StepBasic_spMicro; break; + case 10: siPref = StepBasic_spCenti; break; + case 11: uName = "MICROINCH"; break; } Handle(StepBasic_SiUnitAndLengthUnit) siUnit = @@ -106,7 +106,7 @@ void STEPConstruct_UnitContext::Init(const Standard_Real Tol3d) if ( uName ) { // for non-metric units, create conversion_based_unit Handle(StepBasic_MeasureValueMember) val = new StepBasic_MeasureValueMember; val->SetName("LENGTH_UNIT"); - val->SetReal ( UnitsMethods::GetLengthFactorValue ( Interface_Static::IVal ( "write.step.unit" ) ) ); + val->SetReal(UnitsMethods::GetLengthFactorValue(theModel->GetParam("write.step.unit")->IntegerValue())); Handle(StepBasic_LengthMeasureWithUnit) measure = new StepBasic_LengthMeasureWithUnit; StepBasic_Unit Unit; diff --git a/src/STEPConstruct/STEPConstruct_UnitContext.hxx b/src/STEPConstruct/STEPConstruct_UnitContext.hxx index 5b53280cd0..67550ed89d 100644 --- a/src/STEPConstruct/STEPConstruct_UnitContext.hxx +++ b/src/STEPConstruct/STEPConstruct_UnitContext.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -47,7 +48,8 @@ public: //! Creates new context (units are MM and radians, //! uncertainty equal to Tol3d) - Standard_EXPORT void Init (const Standard_Real Tol3d); + Standard_EXPORT void Init (const Standard_Real Tol3d, + Handle(Interface_InterfaceModel)& theModel); //! Returns True if Init was called successfully Standard_EXPORT Standard_Boolean IsDone() const; diff --git a/src/STEPConstruct/STEPConstruct_ValidationProps.cxx b/src/STEPConstruct/STEPConstruct_ValidationProps.cxx index 6df3c0ab4e..a3e18f7c7b 100644 --- a/src/STEPConstruct/STEPConstruct_ValidationProps.cxx +++ b/src/STEPConstruct/STEPConstruct_ValidationProps.cxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -343,29 +342,30 @@ Standard_Boolean STEPConstruct_ValidationProps::AddProp (const StepRepr_Characte Handle(TCollection_HAsciiString) PropDefDescr = new TCollection_HAsciiString ( Descr ); Handle(StepRepr_PropertyDefinition) propdef = new StepRepr_PropertyDefinition; propdef->Init ( PropDefName, Standard_True, PropDefDescr, target ); - + Handle(TCollection_HAsciiString) SRName = new TCollection_HAsciiString ( Descr ); Handle(StepRepr_Representation) rep = new StepRepr_Representation; Handle(StepRepr_HArray1OfRepresentationItem) SRItems = new StepRepr_HArray1OfRepresentationItem ( 1, 1 ); SRItems->SetValue ( 1, Prop ); rep->Init ( SRName, SRItems, Context ); - + Handle(StepRepr_PropertyDefinitionRepresentation) PrDR = new StepRepr_PropertyDefinitionRepresentation; StepRepr_RepresentedDefinition RD; RD.SetValue ( propdef ); PrDR->Init ( RD, rep ); - + // record SDR in order to have it written to the file Model()->AddWithRefs ( PrDR ); // for AP203, add subschema name - if ( Interface_Static::IVal("write.step.schema") ==3 ) { - APIHeaderSection_MakeHeader mkHdr ( Handle(StepData_StepModel)::DownCast ( Model() ) ); - Handle(TCollection_HAsciiString) subSchema = - new TCollection_HAsciiString ( "GEOMETRIC_VALIDATION_PROPERTIES_MIM" ); - mkHdr.AddSchemaIdentifier ( subSchema ); + + if (Model()->GetParam("write.step.schema")->IntegerValue() == 3) { + APIHeaderSection_MakeHeader mkHdr(Handle(StepData_StepModel)::DownCast(Model())); + Handle(TCollection_HAsciiString) subSchema = + new TCollection_HAsciiString("GEOMETRIC_VALIDATION_PROPERTIES_MIM"); + mkHdr.AddSchemaIdentifier(subSchema); } - + return Standard_True; } diff --git a/src/STEPControl/STEPControl_ActorRead.cxx b/src/STEPControl/STEPControl_ActorRead.cxx index fd392c95c3..2d98c60c30 100644 --- a/src/STEPControl/STEPControl_ActorRead.cxx +++ b/src/STEPControl/STEPControl_ActorRead.cxx @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -110,7 +109,6 @@ #include #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(STEPControl_ActorRead,Transfer_ActorOfTransientProcess) @@ -199,7 +197,10 @@ namespace { // Purpose : Empty constructor // ============================================================================ -STEPControl_ActorRead::STEPControl_ActorRead() {} +STEPControl_ActorRead::STEPControl_ActorRead() +{ + myXSAlgoContainer = new XSAlgo_AlgoContainer; +} // ============================================================================ // Method : STEPControl_ActorRead::Recognize @@ -215,7 +216,7 @@ Standard_Boolean STEPControl_ActorRead::Recognize if (start->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) return Standard_True; - TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode"); + TCollection_AsciiString aProdMode = myModel->GetParam("read.step.product.mode")->IntegerValue(); if(!aProdMode.IsEqual("ON")) if(start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) return Standard_True; @@ -274,7 +275,7 @@ Handle(Transfer_Binder) STEPControl_ActorRead::Transfer const Handle(Transfer_TransientProcess)& TP) { // [BEGIN] Get version of preprocessor (to detect I-Deas case) (ssv; 23.11.2010) - Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast ( TP->Model() ); + Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(TP->Model()); Interface_EntityIterator anEntIt = aStepModel->Header(); for ( anEntIt.Start(); anEntIt.More(); anEntIt.Next() ) { DeclareAndCast( HeaderSection_FileName, aFileNameEntity, anEntIt.Value() ); @@ -392,16 +393,16 @@ static void getListSDR(const Handle(StepRepr_ShapeAspect)& sa, //purpose : Find all SDRs related to given PDS //======================================================================= -static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, - Handle(TColStd_HSequenceOfTransient)& listSDR, - Handle(TColStd_HSequenceOfTransient)& listNAUO, - Handle(TColStd_HSequenceOfTransient)& listSDRAspect, - const Handle(Transfer_TransientProcess)& TP) +void STEPControl_ActorRead::getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, + Handle(TColStd_HSequenceOfTransient)& listSDR, + Handle(TColStd_HSequenceOfTransient)& listNAUO, + Handle(TColStd_HSequenceOfTransient)& listSDRAspect, + const Handle(Transfer_TransientProcess)& TP) { // Flag indicating preferred shape representation type, to be chosen if // several different representations are attached to the same shape Standard_Integer delta = 100; - Standard_Integer ICS = Interface_Static::IVal("read.step.shape.repr"); + Standard_Integer ICS = myModel->GetParam("read.step.shape.repr")->IntegerValue(); Standard_Integer nbSDR0 = listSDR->Length(); // Iterate by entities referring PDS @@ -501,12 +502,12 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, // Flag indicating whether SDRs associated with the product`s main SDR // by SRRs (which correspond to hybrid model representation in AP203 since 1998) // should be taken into account - Standard_Integer readSRR = Interface_Static::IVal("read.step.shape.relationship"); + Standard_Integer readSRR = myModel->GetParam("read.step.shape.relationship")->IntegerValue(); // Flag indicating whether SDRs associated with the product`s main SDR // by SAs (which correspond to hybrid model representation in AP203 before 1998) // should be taken into account - Standard_Integer readSA = Interface_Static::IVal("read.step.shape.aspect"); + Standard_Integer readSA = myModel->GetParam("read.step.shape.aspect")->IntegerValue(); if ( ! readSA ) listSDRAspect->Clear(); @@ -520,7 +521,7 @@ static void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, // possibly attached directly to intermediate assemblies (1) // Special mode (4) is used to translate shape attached to this product only, // ignoring sub-assemblies if any - Standard_Integer readAssembly = Interface_Static::IVal("read.step.assembly.level"); + Standard_Integer readAssembly = myModel->GetParam("read.step.assembly.level")->IntegerValue(); if ( readAssembly ==3 || ( readAssembly ==2 && listNAUO->Length() >0 ) ) listSDR->Clear(); else if ( readAssembly == 4 ) @@ -751,7 +752,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han return shbinder; isBound = Standard_False; Standard_Integer nb = sr->NbItems(); - // Used in XSAlgo::AlgoContainer()->ProcessShape (ssv; 13.11.2010) + // Used in myXSAlgoContainer->ProcessShape (ssv; 13.11.2010) Standard_Integer nbTPitems = TP->NbMapped(); Handle(Message_Messenger) sout = TP->Messenger(); #ifdef TRANSLOG @@ -771,7 +772,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han Message_ProgressSentry PS ( TP->GetProgress(), "Sub-assembly", 0, nb, 1 ); // [BEGIN] Proceed with non-manifold topology (ssv; 12.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("read.step.nonmanifold") != 0; + Standard_Boolean isNMMode = myModel->GetParam("read.step.nonmanifold")->IntegerValue() != 0; Standard_Boolean isManifold = Standard_True; if ( isNMMode && sr->IsKind(STANDARD_TYPE(StepShape_NonManifoldSurfaceShapeRepresentation)) ) { isManifold = Standard_False; @@ -783,7 +784,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han } // Special processing for I-DEAS STP case (ssv; 15.11.2010) else { - Standard_Integer isIDeasMode = Interface_Static::IVal("read.step.ideas"); + Standard_Integer isIDeasMode = myModel->GetParam("read.step.ideas")->IntegerValue(); if (isNMMode && myNMTool.IsIDEASCase() && isIDeasMode) { isManifold = Standard_False; NM_DETECTED = Standard_True; @@ -829,11 +830,11 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han Handle(Standard_Transient) info; // IMPORTANT: any fixing on non-manifold topology must be done after the shape is transferred from STEP TopoDS_Shape fixedResult = - XSAlgo::AlgoContainer()->ProcessShape( comp, myPrecision, myMaxTol, - "read.step.resource.name", - "read.step.sequence", info, - TP->GetProgress() ); - XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems); + myXSAlgoContainer->ProcessShape( comp, myPrecision, myMaxTol, + "read.step.resource.name", + "read.step.sequence", info, + TP->GetProgress() ); + myXSAlgoContainer->MergeTransferInfo(TP, info, nbTPitems); BRep_Builder brepBuilder; @@ -1173,7 +1174,7 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han TP->AddWarning ( start, "Entity with no unit context; default units taken" ); ResetUnits(); } - else PrepareUnits ( context, TP ); + else PrepareUnits(context, TP); } myShapeBuilder.SetPrecision(myPrecision); myShapeBuilder.SetMaxTol(myMaxTol); @@ -1229,12 +1230,11 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han // Apply ShapeFix (on manifold shapes only. Non-manifold topology is processed separately: ssv; 13.11.2010) if (isManifold) { Handle(Standard_Transient) info; - mappedShape = - XSAlgo::AlgoContainer()->ProcessShape( mappedShape, myPrecision, myMaxTol, - "read.step.resource.name", - "read.step.sequence", info, - TP->GetProgress() ); - XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems); + mappedShape = myXSAlgoContainer->ProcessShape( mappedShape, myPrecision, myMaxTol, + "read.step.resource.name", + "read.step.sequence", info, + TP->GetProgress() ); + myXSAlgoContainer->MergeTransferInfo(TP, info, nbTPitems); } } found = !mappedShape.IsNull(); @@ -1360,15 +1360,15 @@ Handle(TransferBRep_ShapeBinder) STEPControl_ActorRead::TransferEntity(const Han TopoDS_Shape S = sb->Result(); Handle(Standard_Transient) info; - TopoDS_Shape shape = XSAlgo::AlgoContainer()->ProcessShape(S, myPrecision, myMaxTol, - "read.step.resource.name", - "read.step.sequence", info, - TP->GetProgress()); - // TopoDS_Shape shape = XSAlgo::AlgoContainer()->PerformFixShape( S, TP, myPrecision, myMaxTol ); + TopoDS_Shape shape = myXSAlgoContainer->ProcessShape(S, myPrecision, myMaxTol, + "read.step.resource.name", + "read.step.sequence", info, + TP->GetProgress()); + //TopoDS_Shape shape = myXSAlgoContainer->PerformFixShape( S, TP, myPrecision, myMaxTol ); if (shape != S) sb->SetResult(shape); - XSAlgo::AlgoContainer()->MergeTransferInfo(TP, info, nbTPitems); + myXSAlgoContainer->MergeTransferInfo(TP, info, nbTPitems); } @@ -1395,13 +1395,13 @@ Handle(Transfer_Binder) STEPControl_ActorRead::TransferShape(const Handle(Standa const Standard_Boolean isManifold) { if (start.IsNull()) return NullResult(); - XSAlgo::AlgoContainer()->PrepareForTransfer(); + myXSAlgoContainer->PrepareForTransfer(); Handle(Message_Messenger) sout = TP->Messenger(); #ifdef TRANSLOG // POUR MISE AU POINT, a supprimer ensuite if (TP->TraceLevel() > 1) - sout<<" -- Actor : Transfer Ent.n0 "<Model()->Number(start)<<" Type "<DynamicType()->Name()<Number(start)<<" Type "<DynamicType()->Name()<GetParam("read.step.product.mode")->CStringValue(); if(!aProdMode.IsEqual("ON") && start->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) shbinder = OldWay(start,TP); @@ -1531,7 +1531,7 @@ void STEPControl_ActorRead::PrepareUnits(const Handle(StepRepr_Representation)& if (!theGUAC.IsNull()) { stat1 = myUnit.ComputeFactors(theGUAC); - Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode"); + Standard_Integer anglemode = myModel->GetParam("step.angleunit.mode")->IntegerValue(); Standard_Real angleFactor = ( anglemode == 0 ? myUnit.PlaneAngleFactor() : anglemode == 1 ? 1. : M_PI/180. ); UnitsMethods::InitializeFactors(myUnit.LengthFactor(), @@ -1546,15 +1546,15 @@ void STEPControl_ActorRead::PrepareUnits(const Handle(StepRepr_Representation)& } // myPrecision = Precision::Confusion(); - if (Interface_Static::IVal("read.precision.mode") == 1) //:i1 gka S4136 05.04.99 - myPrecision = Interface_Static::RVal("read.precision.val"); + if (myModel->GetParam("read.precision.mode")->IntegerValue() == 1) //:i1 gka S4136 05.04.99 + myPrecision = myModel->GetParam("read.precision.val")->RealValue(); else if (myUnit.HasUncertainty()) myPrecision = myUnit.Uncertainty() * myUnit.LengthFactor(); else { TP->AddWarning(theRepCont,"No Length Uncertainty, value of read.precision.val is taken"); - myPrecision = Interface_Static::RVal("read.precision.val"); + myPrecision = myModel->GetParam("read.precision.val")->RealValue(); } - myMaxTol = Max ( myPrecision, Interface_Static::RVal("read.maxprecision.val") ); + myMaxTol = Max ( myPrecision, myModel->GetParam("read.maxprecision.val")->RealValue() ); // Assign uncertainty #ifdef TRANSLOG if (TP->TraceLevel() > 1) @@ -1567,11 +1567,11 @@ void STEPControl_ActorRead::PrepareUnits(const Handle(StepRepr_Representation)& //purpose : //======================================================================= -void STEPControl_ActorRead::ResetUnits () +void STEPControl_ActorRead::ResetUnits () { UnitsMethods::InitializeFactors ( 1, 1, 1 ); - myPrecision = Interface_Static::RVal("read.precision.val"); - myMaxTol = Max ( myPrecision, Interface_Static::RVal("read.maxprecision.val") ); + myPrecision = myModel->GetParam("read.precision.val")->RealValue(); + myMaxTol = Max ( myPrecision, myModel->GetParam("read.maxprecision.val")->RealValue()); } //======================================================================= @@ -1768,3 +1768,13 @@ void STEPControl_ActorRead::computeIDEASClosings(const TopoDS_Compound& comp, shellClosingsMap.Add(shellA, closingShells); } } + +//======================================================================= +// Method : SetModel +// Purpose : +//======================================================================= +void STEPControl_ActorRead::SetModel(Handle(Interface_InterfaceModel)& theModel) +{ + myModel = theModel; + myXSAlgoContainer->SetModel(theModel); +} diff --git a/src/STEPControl/STEPControl_ActorRead.hxx b/src/STEPControl/STEPControl_ActorRead.hxx index 1ea04b9049..07e082bda7 100644 --- a/src/STEPControl/STEPControl_ActorRead.hxx +++ b/src/STEPControl/STEPControl_ActorRead.hxx @@ -25,8 +25,10 @@ #include #include #include +#include #include #include +#include class StepRepr_Representation; class Standard_Transient; class Transfer_Binder; @@ -75,6 +77,9 @@ public: //! reset units and tolerances context to default //! (mm, radians, read.precision.val, etc.) Standard_EXPORT void ResetUnits(); + + //! Sets step model for translations + Standard_EXPORT void SetModel(Handle(Interface_InterfaceModel)& theModel); //! Computes transformation defined by two axis placements (in MAPPED_ITEM //! or ITEM_DEFINED_TRANSFORMATION) taking into account their @@ -130,10 +135,18 @@ private: Standard_EXPORT void computeIDEASClosings (const TopoDS_Compound& comp, TopTools_IndexedDataMapOfShapeListOfShape& shellClosingMap); + Standard_EXPORT void getSDR(const Handle(StepRepr_ProductDefinitionShape)& PDS, + Handle(TColStd_HSequenceOfTransient)& listSDR, + Handle(TColStd_HSequenceOfTransient)& listNAUO, + Handle(TColStd_HSequenceOfTransient)& listSDRAspect, + const Handle(Transfer_TransientProcess)& TP); + StepToTopoDS_NMTool myNMTool; Standard_Real myPrecision; Standard_Real myMaxTol; Handle(StepRepr_Representation) mySRContext; + Handle(XSAlgo_AlgoContainer) myXSAlgoContainer; + Handle(Interface_InterfaceModel) myModel; }; diff --git a/src/STEPControl/STEPControl_ActorWrite.cxx b/src/STEPControl/STEPControl_ActorWrite.cxx index 268c968ff8..4430547a45 100644 --- a/src/STEPControl/STEPControl_ActorWrite.cxx +++ b/src/STEPControl/STEPControl_ActorWrite.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -104,7 +102,6 @@ #include #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(STEPControl_ActorWrite,Transfer_ActorOfFinderProcess) @@ -230,7 +227,8 @@ static Standard_Boolean IsManifoldShape(const TopoDS_Shape& theShape) { STEPControl_ActorWrite::STEPControl_ActorWrite () : mygroup (0) , mytoler (-1.) { - SetMode(STEPControl_ShellBasedSurfaceModel); + SetMode(STEPControl_ShellBasedSurfaceModel); + myXSAlgoContainer = new XSAlgo_AlgoContainer; } //======================================================================= @@ -344,9 +342,10 @@ STEPControl_StepModelType STEPControl_ActorWrite::Mode () const //purpose : //======================================================================= -void STEPControl_ActorWrite::SetGroupMode (const Standard_Integer mode) -{ - if (mode >= 0) mygroup = mode; +void STEPControl_ActorWrite::SetGroupMode (const Standard_CString theParameter) +{ + Standard_Integer aMode = myModel->GetParam(theParameter)->IntegerValue(); + if (aMode >= 0) mygroup = aMode; } //======================================================================= @@ -448,7 +447,7 @@ Standard_Boolean STEPControl_ActorWrite::Recognize (const Handle(Transfer_Finde Handle(Transfer_Binder) STEPControl_ActorWrite::Transfer (const Handle(Transfer_Finder)& start, const Handle(Transfer_FinderProcess)& FP) { - XSAlgo::AlgoContainer()->PrepareForTransfer(); + myXSAlgoContainer->PrepareForTransfer(); Handle(TransferBRep_ShapeMapper) mapper = Handle(TransferBRep_ShapeMapper)::DownCast(start); @@ -456,20 +455,19 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::Transfer (const Handle(Transfer_ TopoDS_Shape shape = mapper->Value(); // init context - Handle(StepData_StepModel) model = Handle(StepData_StepModel)::DownCast ( FP->Model() ); - if ( ! model.IsNull() ) myContext.SetModel ( model ); //: abv 04.11.00: take APD from model + if ( ! myModel.IsNull() ) myContext.SetModel (myModel); //: abv 04.11.00: take APD from model myContext.AddAPD ( Standard_False ); // update APD myContext.SetLevel ( 1 ); // set assembly level to 1 (to ensure) //:S4136: init UnitsMethods to reset angle unit factors (see TopoDSToStep) - Standard_Real lFactor = UnitsMethods::GetLengthFactorValue ( Interface_Static::IVal ( "write.step.unit" ) ); + Standard_Real lFactor = UnitsMethods::GetLengthFactorValue (myModel->GetParam( "write.step.unit" )->IntegerValue() ); lFactor /= UnitsMethods::GetCasCadeLengthUnit(); - Standard_Integer anglemode = Interface_Static::IVal("step.angleunit.mode"); + Standard_Integer anglemode = myModel->GetParam("step.angleunit.mode")->IntegerValue(); UnitsMethods::InitializeFactors ( lFactor, ( anglemode <= 1 ? 1. : M_PI/180. ), 1. ); // create SDR STEPConstruct_Part SDRTool; - SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application() ); + SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), myModel ); Handle(StepShape_ShapeDefinitionRepresentation) sdr = SDRTool.SDRValue(); // transfer shape @@ -494,23 +492,23 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::Transfer (const Handle(Transfer_ //========================================== -static Standard_Real UsedTolerance (const Standard_Real mytoler, - const TopoDS_Shape& theShape) +Standard_Real STEPControl_ActorWrite::usedTolerance(const Standard_Real theToler, + const TopoDS_Shape& theShape) { // COMPUTING 3D TOLERANCE // Either from Session, or Computed (Least,Average, or Greatest) // Then given to TopoDSToStep_Tool - Standard_Real Tol = mytoler; - Standard_Integer tolmod = Interface_Static::IVal("write.precision.mode"); - if (Tol <= 0 && tolmod == 2) Tol = - Interface_Static::RVal("write.precision.val"); + Standard_Real Tol = theToler; + Standard_Integer tolmod = myModel->GetParam("write.precision.mode")->IntegerValue(); + if (Tol <= 0 && tolmod == 2) + Tol = myModel->GetParam("write.precision.val")->RealValue(); if (Tol <= 0) { ShapeAnalysis_ShapeTolerance stu; - Tol = stu.Tolerance (theShape,tolmod); + Tol = stu.Tolerance(theShape, tolmod); // Par defaut, on prend une tolerance moyenne, on elimine les aberrations - Tol = Interface_MSG::Intervalled (Tol * 1.5); // arrondi a 1 2 5 ... + Tol = Interface_MSG::Intervalled(Tol * 1.5); // arrondi a 1 2 5 ... } if (Tol == 0) Tol = 1.e-07; // minimum ... @@ -528,7 +526,7 @@ Standard_Boolean STEPControl_ActorWrite::IsAssembly (TopoDS_Shape &S) const { if ( ! GroupMode() || S.ShapeType() != TopAbs_COMPOUND ) return Standard_False; // PTV 16.09.2002 OCC725 for storing compound of vertices - if (Interface_Static::IVal("write.step.vertex.mode") == 0) {//bug 23950 + if (myModel->GetParam("write.step.vertex.mode")->IntegerValue() == 0) {//bug 23950 if (S.ShapeType() == TopAbs_COMPOUND ) { Standard_Boolean IsOnlyVertices = Standard_True; TopoDS_Iterator anItr( S ); @@ -587,7 +585,9 @@ static Standard_Boolean transferVertex (const Handle(Transfer_FinderProcess)& FP { Standard_Boolean IsDone = Standard_False; MoniTool_DataMapOfShapeTransient aMap; - TopoDSToStep_Tool aTool(aMap, Standard_True); + TopoDSToStep_Tool aTool(aMap, + Standard_True, + FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_MakeStepVertex aMkVrtx ( TopoDS::Vertex(aShVrtx), aTool, FP ); if (!aMkVrtx.IsDone()) @@ -643,7 +643,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran return TransferCompound(start, SDR0, FP); // [BEGIN] Separate manifold topology from non-manifold in group mode 0 (ssv; 18.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + Standard_Boolean isNMMode = myModel->GetParam("write.step.nonmanifold")->IntegerValue() != 0; Handle(Transfer_Binder) aNMBinder; if (isNMMode && !GroupMode() && theShape.ShapeType() == TopAbs_COMPOUND) { TopoDS_Compound aNMCompound; @@ -736,7 +736,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran sdr = SDR0; else { STEPConstruct_Part SDRTool; - SDRTool.MakeSDR( 0, myContext.GetProductName(), myContext.GetAPD()->Application() ); + SDRTool.MakeSDR( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), myModel ); sdr = SDRTool.SDRValue(); } @@ -763,7 +763,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran Handle(TopTools_HSequenceOfShape) RepItemSeq = new TopTools_HSequenceOfShape(); Standard_Boolean isSeparateVertices = - Interface_Static::IVal("write.step.vertex.mode") == 0;//bug 23950 + myModel->GetParam("write.step.vertex.mode")->IntegerValue() == 0;//bug 23950 // PTV 16.09.2002 OCC725 separate shape from solo vertices. Standard_Boolean isOnlyVertices = Standard_False; if (theShape.ShapeType() == TopAbs_COMPOUND) { @@ -859,7 +859,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran // COMPUTING 3D TOLERANCE // Either from Session, or Computed (Least,Average, or Greatest) // Then given to TopoDSToStep_Tool - Standard_Real Tol = UsedTolerance (mytoler,theShape); + Standard_Real Tol = usedTolerance (mytoler,theShape); // Create a STEP-Entity for each TopoDS_Shape // according to the current StepModelMode @@ -894,13 +894,13 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran // if ( DMT.IsDone() ) aShape = DMT.ModifiedShape ( aShape ); //// aShape = TopoDSToStep::DirectFaces(xShape); Handle(Standard_Transient) info; - Standard_Real maxTol = Interface_Static::RVal("read.maxprecision.val"); + Standard_Real maxTol = myModel->GetParam("read.maxprecision.val")->RealValue(); TopoDS_Shape aShape; - aShape = XSAlgo::AlgoContainer()->ProcessShape(xShape, Tol, maxTol, - "write.step.resource.name", - "write.step.sequence", info, - FP->GetProgress() ); + aShape = myXSAlgoContainer->ProcessShape(xShape, Tol, maxTol, + "write.step.resource.name", + "write.step.sequence", info, + FP->GetProgress() ); if (!isManifold) { mergeInfoForNM(FP, info); } @@ -1098,7 +1098,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran //:abv 24Jan99 CAX-IF TRJ3: Update FinderProcess map to take into account shape processing // UpdateMap ( xShape, CSMT, DMT, FP ); - XSAlgo::AlgoContainer()->MergeTransferInfo(FP, info); + myXSAlgoContainer->MergeTransferInfo(FP, info); } // - Make Shape Representation @@ -1173,7 +1173,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran GetCasted(StepRepr_RepresentationItem, ItemSeq->Value(rep)); items->SetValue(rep,repit); } - Standard_Integer ap = Interface_Static::IVal("write.step.schema"); + Standard_Integer ap = myModel->GetParam("write.step.schema")->IntegerValue(); Transfer_SequenceOfBinder aSeqBindRelation; if(ap == 3 && nbs > 1) { Standard_Integer j = 1; @@ -1201,7 +1201,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran repr1->SetValue(2,items->Value(j)); ShapeRepr1->SetItems(repr1); STEPConstruct_UnitContext mk1; - mk1.Init(Tol); + mk1.Init(Tol, myModel); ShapeRepr1->SetContextOfItems(mk1.Value()); // la tolerance, voir au debut ShapeRepr1->SetName (new TCollection_HAsciiString("")); @@ -1234,7 +1234,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferShape (const Handle(Tran // init representation STEPConstruct_UnitContext mk; - mk.Init(Tol); + mk.Init(Tol, myModel); shapeRep->SetContextOfItems(mk.Value()); // la tolerance, voir au debut shapeRep->SetName (new TCollection_HAsciiString("")); @@ -1278,7 +1278,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferCompound (const Handle(T TopoDS_Shape theShape = mapper->Value(); // Inspect non-manifold topology case (ssv; 10.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + Standard_Boolean isNMMode = myModel->GetParam("write.step.nonmanifold")->IntegerValue() != 0; Standard_Boolean isManifold; if (isNMMode) isManifold = IsManifoldShape(theShape); @@ -1290,7 +1290,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferCompound (const Handle(T // Prepare a collection for non-manifold group of shapes Handle(TopTools_HSequenceOfShape) NonManifoldGroup = new TopTools_HSequenceOfShape(); Standard_Boolean isSeparateVertices = - (Interface_Static::IVal("write.step.vertex.mode") == 0);//bug 23950 + ( myModel->GetParam("write.step.vertex.mode")->IntegerValue() == 0);//bug 23950 // PTV OCC725 17.09.2002 -- begin -- Standard_Integer nbFreeVrtx = 0; TopoDS_Compound aCompOfVrtx; @@ -1379,9 +1379,9 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferCompound (const Handle(T for (Standard_Integer rep = 1; rep <= nsub; rep++) items->SetValue(rep,GetCasted(StepRepr_RepresentationItem, ItemSeq->Value(rep))); shapeRep->SetItems(items); - Standard_Real Tol = UsedTolerance (mytoler,theShape); + Standard_Real Tol = usedTolerance (mytoler,theShape); STEPConstruct_UnitContext mk; - mk.Init(Tol); + mk.Init(Tol, myModel); shapeRep->SetContextOfItems(mk.Value()); // la tolerance, voir au debut shapeRep->SetName (new TCollection_HAsciiString("")); @@ -1433,7 +1433,7 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferSubShape (const Handle( (resbind,STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation),sdr); if ( iasdr ) SDRTool.ReadSDR ( sdr ); else { - SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application() ); + SDRTool.MakeSDR ( 0, myContext.GetProductName(), myContext.GetAPD()->Application(), myModel ); sdr = SDRTool.SDRValue(); } // resultat = GetCasted(StepShape_ShapeRepresentation,sdr->UsedRepresentation()); @@ -1496,3 +1496,14 @@ Handle(Transfer_Binder) STEPControl_ActorWrite::TransferSubShape (const Handle( return resprod; } + +//======================================================================= +// Method : SetModel +// Purpose : +//======================================================================= +void STEPControl_ActorWrite::SetModel(Handle(Interface_InterfaceModel)& theModel) +{ + myModel = theModel; + myXSAlgoContainer->SetModel(theModel); + SetGroupMode("write.step.assembly"); +} diff --git a/src/STEPControl/STEPControl_ActorWrite.hxx b/src/STEPControl/STEPControl_ActorWrite.hxx index afc1869a9e..3e60c69783 100644 --- a/src/STEPControl/STEPControl_ActorWrite.hxx +++ b/src/STEPControl/STEPControl_ActorWrite.hxx @@ -22,11 +22,13 @@ #include #include -#include -#include #include -#include +#include #include +#include +#include +#include +#include class Transfer_Finder; class Transfer_Binder; class Transfer_FinderProcess; @@ -63,7 +65,7 @@ public: Standard_EXPORT STEPControl_StepModelType Mode() const; - Standard_EXPORT void SetGroupMode (const Standard_Integer mode); + Standard_EXPORT void SetGroupMode (const Standard_CString theParameter); Standard_EXPORT Standard_Integer GroupMode() const; @@ -76,6 +78,8 @@ public: //! NOTE: this method can modify shape Standard_EXPORT virtual Standard_Boolean IsAssembly (TopoDS_Shape& S) const; + //! Sets step model for translations + Standard_EXPORT void SetModel(Handle(Interface_InterfaceModel)& theModel); @@ -94,14 +98,23 @@ private: //! Use this method to get the corresponding NMSSR (or //! to create a new one if doesn't exist yet) //! (ssv; 13.11.2010) - Standard_EXPORT Handle(StepShape_NonManifoldSurfaceShapeRepresentation) getNMSSRForGroup (const Handle(TopTools_HSequenceOfShape)& shapeGroup, const Handle(Transfer_FinderProcess)& FP, Standard_Boolean& isNMSSRCreated) const; + Standard_EXPORT Handle(StepShape_NonManifoldSurfaceShapeRepresentation) getNMSSRForGroup (const Handle(TopTools_HSequenceOfShape)& shapeGroup, + const Handle(Transfer_FinderProcess)& FP, + Standard_Boolean& isNMSSRCreated) const; //! bind already written shared faces to STEP entity for non-manifold - Standard_EXPORT void mergeInfoForNM(const Handle(Transfer_FinderProcess)& theFP, const Handle(Standard_Transient) &theInfo) const; + Standard_EXPORT void mergeInfoForNM(const Handle(Transfer_FinderProcess)& theFP, + const Handle(Standard_Transient) &theInfo) const; + + //! + Standard_EXPORT Standard_Real usedTolerance(const Standard_Real mytoler, + const TopoDS_Shape& theShape); Standard_Integer mygroup; Standard_Real mytoler; STEPConstruct_ContextTool myContext; + Handle(XSAlgo_AlgoContainer) myXSAlgoContainer; + Handle(Interface_InterfaceModel) myModel; }; diff --git a/src/STEPControl/STEPControl_Controller.cxx b/src/STEPControl/STEPControl_Controller.cxx index dc3ec175a0..700b0d1aa0 100644 --- a/src/STEPControl/STEPControl_Controller.cxx +++ b/src/STEPControl/STEPControl_Controller.cxx @@ -18,15 +18,16 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include +#include #include #include #include @@ -51,159 +52,17 @@ #include #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(STEPControl_Controller,XSControl_Controller) // Pour NewModel et Write : definition de produit (temporaire ...) -STEPControl_Controller::STEPControl_Controller () -: XSControl_Controller ("STEP", "step") +STEPControl_Controller::STEPControl_Controller() + : XSControl_Controller("STEP", "step") { - static Standard_Boolean init = Standard_False; - if (!init) { - RWHeaderSection::Init(); RWStepAP214::Init(); - - Interface_Static::Init ("step","write.step.product.name",'t',"Open CASCADE STEP translator " OCC_VERSION_STRING); - Interface_Static::Init ("step","write.step.assembly",'e',""); - Interface_Static::Init ("step","write.step.assembly",'&',"enum 0"); - Interface_Static::Init ("step","write.step.assembly",'&',"eval Off"); - Interface_Static::Init ("step","write.step.assembly",'&',"eval On"); - Interface_Static::Init ("step","write.step.assembly",'&',"eval Auto"); - Interface_Static::SetCVal("write.step.assembly","Auto"); - - Interface_Static::Init("step","step.angleunit.mode", 'e',""); - Interface_Static::Init("step","step.angleunit.mode", '&',"enum 0"); - Interface_Static::Init("step","step.angleunit.mode", '&',"eval File"); - Interface_Static::Init("step","step.angleunit.mode", '&',"eval Rad"); - Interface_Static::Init("step","step.angleunit.mode", '&',"eval Deg"); - Interface_Static::SetCVal("step.angleunit.mode","File"); - - Interface_Static::Init("step","write.step.schema", 'e',""); - Interface_Static::Init("step","write.step.schema",'&',"enum 1"); - Interface_Static::Init("step","write.step.schema",'&',"eval AP214CD"); - Interface_Static::Init("step","write.step.schema",'&',"eval AP214DIS"); - Interface_Static::Init("step","write.step.schema",'&',"eval AP203"); - Interface_Static::Init("step","write.step.schema",'&',"eval AP214IS"); - Interface_Static::Init("step","write.step.schema",'&',"eval AP242DIS"); - Interface_Static::SetCVal("write.step.schema","AP214IS"); - - // Type of Product Definition for reading - // Note: the numbers should be consistent with function FindShapeReprType() - // in STEPControl_ActorRead.cxx - Interface_Static::Init("step","read.step.shape.repr",'e',""); - Interface_Static::Init("step","read.step.shape.repr",'&',"enum 1"); - Interface_Static::Init("step","read.step.shape.repr",'&',"eval All"); // 1 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval ABSR"); // 2 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval MSSR"); // 3 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval GBSSR"); // 4 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval FBSR"); // 5 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval EBWSR"); // 6 - Interface_Static::Init("step","read.step.shape.repr",'&',"eval GBWSR"); // 7 - Interface_Static::SetCVal("read.step.shape.repr","All"); - - // Mode for reading shapes attached to main SDR by SRR - // (hybrid model representation in AP203 since 1998) - Interface_Static::Init("step","read.step.shape.relationship",'e',""); - Interface_Static::Init("step","read.step.shape.relationship",'&',"enum 0"); - Interface_Static::Init("step","read.step.shape.relationship",'&',"eval OFF"); - Interface_Static::Init("step","read.step.shape.relationship",'&',"eval ON"); - Interface_Static::SetCVal("read.step.shape.relationship","ON"); - - // Mode for reading shapes attached to Product by ShapeAspect - // (hybrid model representation in AP203 before 1998) - Interface_Static::Init("step","read.step.shape.aspect",'e',""); - Interface_Static::Init("step","read.step.shape.aspect",'&',"enum 0"); - Interface_Static::Init("step","read.step.shape.aspect",'&',"eval OFF"); - Interface_Static::Init("step","read.step.shape.aspect",'&',"eval ON"); - Interface_Static::SetCVal("read.step.shape.aspect","ON"); - - // Mode for reading SDR and ShapeRepr if it is necessary - Interface_Static::Init("step","read.step.product.mode",'e',""); - Interface_Static::Init("step","read.step.product.mode",'&',"enum 0"); - Interface_Static::Init("step","read.step.product.mode",'&',"eval OFF"); - Interface_Static::Init("step","read.step.product.mode",'&',"eval ON"); - Interface_Static::SetCVal("read.step.product.mode","ON"); - - // Order of reading ShapeDefinitionRepresentation in ProductDefinition - Interface_Static::Init("step","read.step.product.context",'e',""); - Interface_Static::Init("step","read.step.product.context",'&',"enum 1"); - Interface_Static::Init("step","read.step.product.context",'&',"eval all"); // 1 - Interface_Static::Init("step","read.step.product.context",'&',"eval design"); // 2 - Interface_Static::Init("step","read.step.product.context",'&',"eval analysis");// 3 - Interface_Static::SetCVal("read.step.product.context","all"); - - // What we try to read in ProductDefinition - Interface_Static::Init("step","read.step.assembly.level",'e',""); - Interface_Static::Init("step","read.step.assembly.level",'&',"enum 1"); - Interface_Static::Init("step","read.step.assembly.level",'&',"eval all"); // 1 - Interface_Static::Init("step","read.step.assembly.level",'&',"eval assembly"); // 2 - Interface_Static::Init("step","read.step.assembly.level",'&',"eval structure");// 3 - Interface_Static::Init("step","read.step.assembly.level",'&',"eval shape"); // 4 - Interface_Static::SetCVal("read.step.assembly.level","all"); - - // unit: supposed to be cascade unit (target unit for reading) - Interface_Static::Init("step","write.step.unit", 'e',""); - Interface_Static::Init("step","write.step.unit",'&',"enum 1"); - Interface_Static::Init("step","write.step.unit",'&',"eval INCH"); // 1 - Interface_Static::Init("step","write.step.unit",'&',"eval MM"); // 2 - Interface_Static::Init("step","write.step.unit",'&',"eval ??"); // 3 - Interface_Static::Init("step","write.step.unit",'&',"eval FT"); // 4 - Interface_Static::Init("step","write.step.unit",'&',"eval MI"); // 5 - Interface_Static::Init("step","write.step.unit",'&',"eval M"); // 6 - Interface_Static::Init("step","write.step.unit",'&',"eval KM"); // 7 - Interface_Static::Init("step","write.step.unit",'&',"eval MIL"); // 8 - Interface_Static::Init("step","write.step.unit",'&',"eval UM"); // 9 - Interface_Static::Init("step","write.step.unit",'&',"eval CM"); //10 - Interface_Static::Init("step","write.step.unit",'&',"eval UIN"); //11 - Interface_Static::SetCVal ("write.step.unit","MM"); - - // Non-manifold topology reading: OFF by default (ssv; 26.11.2010) - Interface_Static::Init ("step","read.step.nonmanifold",'e',""); - Interface_Static::Init ("step","read.step.nonmanifold",'&',"enum 0"); - Interface_Static::Init ("step","read.step.nonmanifold",'&',"eval Off"); - Interface_Static::Init ("step","read.step.nonmanifold",'&',"eval On"); - Interface_Static::SetIVal("read.step.nonmanifold",0); - - // Non-manifold topology writing: OFF by default (ssv; 26.11.2010) - Interface_Static::Init ("step","write.step.nonmanifold",'e',""); - Interface_Static::Init ("step","write.step.nonmanifold",'&',"enum 0"); - Interface_Static::Init ("step","write.step.nonmanifold",'&',"eval Off"); - Interface_Static::Init ("step","write.step.nonmanifold",'&',"eval On"); - Interface_Static::SetIVal("write.step.nonmanifold",0); - - // I-Deas-like STEP processing: OFF by default (ssv; 22.11.2010) - Interface_Static::Init ("step","read.step.ideas",'e',""); - Interface_Static::Init ("step","read.step.ideas",'&',"enum 0"); - Interface_Static::Init ("step","read.step.ideas",'&',"eval Off"); - Interface_Static::Init ("step","read.step.ideas",'&',"eval On"); - Interface_Static::SetIVal("read.step.ideas",0); - - //Parameter to write all free vertices in one SDR (name and style of vertex are lost) (default) - //or each vertex in its own SDR (name and style of vertex are exported). (ika; 21.07.2014) - Interface_Static::Init ("step","write.step.vertex.mode",'e',""); - Interface_Static::Init ("step","write.step.vertex.mode",'&',"enum 0"); - Interface_Static::Init ("step","write.step.vertex.mode",'&',"eval One Compound"); - Interface_Static::Init ("step","write.step.vertex.mode",'&',"eval Single Vertex"); - Interface_Static::SetIVal("write.step.vertex.mode",0); - - // abv 15.11.00: ShapeProcessing - Interface_Static::Init ("XSTEP","write.step.resource.name",'t',"STEP"); - Interface_Static::Init ("XSTEP","read.step.resource.name",'t',"STEP"); - Interface_Static::Init ("XSTEP","write.step.sequence",'t',"ToSTEP"); - Interface_Static::Init ("XSTEP","read.step.sequence",'t',"FromSTEP"); - - // ika 28.07.16: Paremeter to read all top level solids and shells, - // should be used only in case of invalid shape_representation without links to shapes. - Interface_Static::Init("step", "read.step.all.shapes", 'e', ""); - Interface_Static::Init("step", "read.step.all.shapes", '&', "enum 0"); - Interface_Static::Init("step", "read.step.all.shapes", '&', "eval Off"); - Interface_Static::Init("step", "read.step.all.shapes", '&', "eval On"); - Interface_Static::SetIVal("read.step.all.shapes", 0); - - init = Standard_True; - } + RWHeaderSection::Init(); RWStepAP214::Init(); Handle(STEPControl_ActorWrite) ActWrite = new STEPControl_ActorWrite; - ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly")); myAdaptorWrite = ActWrite; Handle(StepSelect_WorkLibrary) swl = new StepSelect_WorkLibrary; @@ -218,7 +77,6 @@ STEPControl_Controller::STEPControl_Controller () SetModeWriteHelp (2,"Shell Based"); SetModeWriteHelp (3,"Manifold Solid"); SetModeWriteHelp (4,"Wireframe"); - TraceStatic ("read.surfacecurve.mode",5); // --- SELECTIONS, SIGNATURES, COMPTEURS, EDITEURS @@ -278,6 +136,9 @@ STEPControl_Controller::STEPControl_Controller () Handle(IFSelect_EditForm) edsdrf = new IFSelect_EditForm (edsdr,Standard_False,Standard_True,"STEP Product Data (SDR)"); AddSessionItem (edsdr,"step-SDR-edit"); AddSessionItem (edsdrf,"step-SDR-data"); + + // initialization of Standard Shape Healing + ShapeExtend::Init(); } Handle(Interface_InterfaceModel) STEPControl_Controller::NewModel () const @@ -294,26 +155,38 @@ IFSelect_ReturnStatus STEPControl_Controller::TransferWriteShape const Standard_Integer modeshape) const { if (modeshape < 0 || modeshape > 4) return IFSelect_RetError; + if (model.IsNull()) return IFSelect_RetError; Handle(STEPControl_ActorWrite) ActWrite = Handle(STEPControl_ActorWrite)::DownCast(myAdaptorWrite); // A PRESENT ON PASSE PAR LE PROFILE - if (!ActWrite.IsNull()) - ActWrite->SetGroupMode (Interface_Static::IVal("write.step.assembly")); + if (!ActWrite.IsNull()) + { + ActWrite->SetGroupMode("write.step.assembly"); + } return XSControl_Controller::TransferWriteShape (shape,FP,model,modeshape); } -Standard_Boolean STEPControl_Controller::Init () +Standard_Boolean STEPControl_Controller::Init(const Handle(XSControl_WorkSession)& theWS) { - static Standard_Boolean inic = Standard_False; - if (!inic) { - Handle(STEPControl_Controller) STEPCTL = new STEPControl_Controller; - STEPCTL->AutoRecord(); // avec les noms donnes a la construction - XSAlgo::Init(); - inic = Standard_True; - } + Handle(Interface_InterfaceModel) aModel = theWS->Model(); + if (aModel.IsNull()) return Standard_False; + + TraceNotStatic(aModel->GetParam("read.surfacecurve.mode"), 5); + TraceNotStatic(aModel->GetParam("read.precision.mode"), 5); + TraceNotStatic(aModel->GetParam("read.precision.val"), 5); + TraceNotStatic(aModel->GetParam("write.precision.mode"), 6); + TraceNotStatic(aModel->GetParam("write.precision.val"), 6); + + DeclareAndCast(STEPControl_ActorRead, aReadActor, myAdaptorRead); + if (!aReadActor.IsNull()) aReadActor->SetModel(aModel); + + DeclareAndCast(STEPControl_ActorWrite, aWriteActor, myAdaptorWrite); + if (!aWriteActor.IsNull()) aWriteActor->SetModel(aModel); + return Standard_True; } + //======================================================================= //function : Customise //purpose : diff --git a/src/STEPControl/STEPControl_Controller.hxx b/src/STEPControl/STEPControl_Controller.hxx index 454a35987f..db27a4a5c6 100644 --- a/src/STEPControl/STEPControl_Controller.hxx +++ b/src/STEPControl/STEPControl_Controller.hxx @@ -59,10 +59,8 @@ public: //! modeshape : 1 Facetted BRep, 2 Shell, 3 Manifold Solid Standard_EXPORT virtual IFSelect_ReturnStatus TransferWriteShape (const TopoDS_Shape& shape, const Handle(Transfer_FinderProcess)& FP, const Handle(Interface_InterfaceModel)& model, const Standard_Integer modetrans = 0) const Standard_OVERRIDE; - //! Standard Initialisation. It creates a Controller for STEP - //! and records it to various names, available to select it later - //! Returns True when done, False if could not be done - Standard_EXPORT static Standard_Boolean Init(); + //! Initialisation of additional parameters taken data from session model + Standard_EXPORT virtual Standard_Boolean Init(const Handle(XSControl_WorkSession)& theWS) Standard_OVERRIDE; @@ -72,13 +70,9 @@ public: protected: - - private: - - }; diff --git a/src/STEPControl/STEPControl_Reader.cxx b/src/STEPControl/STEPControl_Reader.cxx index 4997b1127e..aafef56d23 100644 --- a/src/STEPControl/STEPControl_Reader.cxx +++ b/src/STEPControl/STEPControl_Reader.cxx @@ -14,8 +14,8 @@ #include #include +#include #include -#include #include #include #include @@ -38,8 +38,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -74,8 +74,7 @@ //======================================================================= STEPControl_Reader::STEPControl_Reader () { - STEPControl_Controller::Init(); - SetNorm ("STEP"); + initReader(new XSControl_WorkSession, new STEPControl_Controller); } //======================================================================= @@ -83,12 +82,38 @@ STEPControl_Reader::STEPControl_Reader () //purpose : //======================================================================= -STEPControl_Reader::STEPControl_Reader - (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch) +STEPControl_Reader::STEPControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean scratch) { - STEPControl_Controller::Init(); - SetWS (WS,scratch); - SetNorm ("STEP"); + initReader(theWS, new STEPControl_Controller, scratch); +} + +//======================================================================= +//function : STEPControl_Reader +//purpose : +//======================================================================= + +STEPControl_Reader::STEPControl_Reader (const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch) +{ + initReader(theWS, theController, scratch); +} + +//======================================================================= +//function : initReader +//purpose : +//======================================================================= +void STEPControl_Reader::initReader(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch) +{ + myController = theController; + theWS->SetController(myController); + SetWS(theWS, scratch); + myController->Init(WS()); + + initTransferReader(); } //======================================================================= @@ -122,10 +147,11 @@ Standard_Integer STEPControl_Reader::NbRootsForTransfer() therootsta = Standard_True; //theroots.Clear(); - Standard_Integer nb = Model()->NbEntities(); + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(Model()); + Standard_Integer nb = aModel->NbEntities(); for (Standard_Integer i = 1; i <= nb; i ++) { - Handle(Standard_Transient) ent = Model()->Value(i); - if (Interface_Static::IVal("read.step.all.shapes") == 1) { + Handle(Standard_Transient) ent = aModel->Value(i); + if (aModel->GetParam("read.step.all.shapes")->IntegerValue() == 1) { // Special case to read invalid shape_representation without links to shapes. if (ent->IsKind(STANDARD_TYPE(StepShape_ManifoldSolidBrep))) { Interface_EntityIterator aShareds = WS()->Graph().Sharings(ent); @@ -185,8 +211,8 @@ Standard_Integer STEPControl_Reader::NbRootsForTransfer() } // determinate roots used ProductDefinitionContext if(IsRoot) { - const char *str1 = Interface_Static::CVal("read.step.product.context"); - Standard_Integer ICS = Interface_Static::IVal("read.step.product.context"); + const char *str1 = aModel->GetParam("read.step.product.context")->CStringValue(); + Standard_Integer ICS = aModel->GetParam("read.step.product.context")->IntegerValue(); if(ICS>1) { subs = graph.Shareds(PD); for(subs.Start(); subs.More(); subs.Next()) { @@ -219,7 +245,7 @@ Standard_Integer STEPControl_Reader::NbRootsForTransfer() WS()->TransferReader()->TransientProcess()->RootsForTransfer()->Append(ent); } } - TCollection_AsciiString aProdMode = Interface_Static::CVal("read.step.product.mode"); + TCollection_AsciiString aProdMode = aModel->GetParam("read.step.product.mode")->CStringValue(); if(!aProdMode.IsEqual("ON")) { if(ent->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation))) { Standard_Boolean IsRoot = Standard_True; diff --git a/src/STEPControl/STEPControl_Reader.hxx b/src/STEPControl/STEPControl_Reader.hxx index 52fcfaade1..cf6472dd1f 100644 --- a/src/STEPControl/STEPControl_Reader.hxx +++ b/src/STEPControl/STEPControl_Reader.hxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +39,7 @@ class StepRepr_RepresentationContext; //! As in XSControl_Reader, you specify the list using a selection. //! For the translation of iges files it is possible to use next sequence: //! To change translation parameters -//! class Interface_Static should be used before beginning of +//! class StepData_StepModel should be used before beginning of //! translation (see STEP Parameters and General Parameters) //! Creation of reader - STEPControl_Reader reader; //! To load s file in a model use method reader.ReadFile("filename.stp") @@ -76,10 +77,17 @@ public: //! Creates a reader object with an empty STEP model. Standard_EXPORT STEPControl_Reader(); - + + //! Creates a Reader for STEP from an already existing Session + //! Clears the session if it was not yet set for STEP + Standard_EXPORT STEPControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean scratch = Standard_True); + //! Creates a Reader for STEP from an already existing Session //! Clears the session if it was not yet set for STEP - Standard_EXPORT STEPControl_Reader(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); + Standard_EXPORT STEPControl_Reader(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch = Standard_True); //! Returns the model as a StepModel. //! It can then be consulted (header, product) @@ -97,7 +105,9 @@ public: //! Returns sequence of all unit names for shape representations //! found in file - Standard_EXPORT void FileUnits (TColStd_SequenceOfAsciiString& theUnitLengthNames, TColStd_SequenceOfAsciiString& theUnitAngleNames, TColStd_SequenceOfAsciiString& theUnitSolidAngleNames); + Standard_EXPORT void FileUnits (TColStd_SequenceOfAsciiString& theUnitLengthNames, + TColStd_SequenceOfAsciiString& theUnitAngleNames, + TColStd_SequenceOfAsciiString& theUnitSolidAngleNames); @@ -112,9 +122,16 @@ private: //! Returns units for length , angle and solidangle for shape representations - Standard_EXPORT Standard_Boolean findUnits (const Handle(StepRepr_RepresentationContext)& theReprContext, TColStd_Array1OfAsciiString& theNameUnits, TColStd_Array1OfReal& theFactorUnits); + Standard_EXPORT Standard_Boolean findUnits (const Handle(StepRepr_RepresentationContext)& theReprContext, + TColStd_Array1OfAsciiString& theNameUnits, + TColStd_Array1OfReal& theFactorUnits); + //! + Standard_EXPORT void initReader(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch = Standard_True); + Handle(XSControl_Controller) myController; }; diff --git a/src/STEPControl/STEPControl_Writer.cxx b/src/STEPControl/STEPControl_Writer.cxx index fd6e09a744..d38680ba37 100644 --- a/src/STEPControl/STEPControl_Writer.cxx +++ b/src/STEPControl/STEPControl_Writer.cxx @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -31,28 +30,46 @@ //======================================================================= STEPControl_Writer::STEPControl_Writer () { - STEPControl_Controller::Init(); - SetWS (new XSControl_WorkSession); + initWriter(new XSControl_WorkSession, new STEPControl_Controller); } - //======================================================================= //function : STEPControl_Writer - //purpose : //======================================================================= +STEPControl_Writer::STEPControl_Writer (const Handle(XSControl_WorkSession)& theWS, + const Standard_Boolean theScratch) +{ + initWriter(theWS, new STEPControl_Controller, theScratch); +} -STEPControl_Writer::STEPControl_Writer - (const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch) +//======================================================================= +//function : STEPControl_Writer +//purpose : +//======================================================================= +STEPControl_Writer::STEPControl_Writer(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch) { - STEPControl_Controller::Init(); - SetWS (WS,scratch); + initWriter(theWS, theController, theScratch); } +//======================================================================= +//function : initWriter +//purpose : +//======================================================================= +void STEPControl_Writer::initWriter(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch) +{ + myController = theController; + theWS->SetController(myController); + SetWS(theWS, scratch); + myController->Init(WS()); +} //======================================================================= //function : SetWS - //purpose : //======================================================================= @@ -62,7 +79,9 @@ void STEPControl_Writer::SetWS(const Handle(XSControl_WorkSession)& WS, thesession = WS; thesession->SelectNorm("STEP"); thesession->InitTransferReader(0); - Handle(StepData_StepModel) model = Model (scratch); + Handle(StepData_StepModel) aModel = Model (scratch); + DeclareAndCast(STEPControl_ActorWrite, anActor, myController->ActorWrite()); + if (!anActor.IsNull()) anActor->SetModel(aModel); } @@ -99,8 +118,8 @@ Handle(StepData_StepModel) STEPControl_Writer::Model void STEPControl_Writer::SetTolerance (const Standard_Real Tol) { - DeclareAndCast(STEPControl_ActorWrite,act,WS()->NormAdaptor()->ActorWrite()); - if (!act.IsNull()) act->SetTolerance (Tol); + DeclareAndCast(STEPControl_ActorWrite, anActor, myController->ActorWrite()); + if (!anActor.IsNull()) anActor->SetTolerance (Tol); } @@ -145,7 +164,7 @@ IFSelect_ReturnStatus STEPControl_Writer::Transfer progress->Show(); } - return thesession->TransferWriteShape(sh,compgraph); + return thesession->TransferWriteShape(sh, compgraph); } diff --git a/src/STEPControl/STEPControl_Writer.hxx b/src/STEPControl/STEPControl_Writer.hxx index f60d3b3cf3..4bd0112661 100644 --- a/src/STEPControl/STEPControl_Writer.hxx +++ b/src/STEPControl/STEPControl_Writer.hxx @@ -21,12 +21,13 @@ #include #include +#include #include #include -#include -#include #include #include +#include +#include class XSControl_WorkSession; class StepData_StepModel; class TopoDS_Shape; @@ -48,8 +49,15 @@ public: Standard_EXPORT STEPControl_Writer(); //! Creates a Writer from an already existing Session - //! If is True (D), clears already recorded data - Standard_EXPORT STEPControl_Writer(const Handle(XSControl_WorkSession)& WS, const Standard_Boolean scratch = Standard_True); + //! If is True (D), clears already recorded data + Standard_EXPORT STEPControl_Writer(const Handle(XSControl_WorkSession)& WS, + const Standard_Boolean theScratch = Standard_True); + + //! Creates a Writer for STEP from an already existing Session + //! If is True (D), clears already recorded data + Standard_EXPORT STEPControl_Writer(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean theScratch = Standard_True); //! Sets a length-measure value that //! will be written to uncertainty-measure-with-unit @@ -115,7 +123,10 @@ public: protected: - + //! + Standard_EXPORT void initWriter(const Handle(XSControl_WorkSession)& theWS, + const Handle(XSControl_Controller)& theController, + const Standard_Boolean scratch = Standard_True); @@ -124,6 +135,7 @@ private: Handle(XSControl_WorkSession) thesession; + Handle(XSControl_Controller) myController; }; diff --git a/src/StepAP214/StepAP214_Protocol.cxx b/src/StepAP214/StepAP214_Protocol.cxx index 9d67f7ca2d..0653fcbff0 100644 --- a/src/StepAP214/StepAP214_Protocol.cxx +++ b/src/StepAP214/StepAP214_Protocol.cxx @@ -454,7 +454,6 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI #include #include #include -#include #include #include #include @@ -758,7 +757,8 @@ static Interface_DataMapOfTransientInteger types(800); //purpose : //======================================================================= -StepAP214_Protocol::StepAP214_Protocol () +StepAP214_Protocol::StepAP214_Protocol () : + myShemaName(schemaAP214IS) { if (THE_StepAP214_Protocol_init) { @@ -1481,19 +1481,22 @@ Handle(Standard_Type)& atype) const //purpose : //======================================================================= -Standard_CString StepAP214_Protocol::SchemaName() const -{ - switch (Interface_Static::IVal("write.step.schema")) { //:j4 - default: - case 1 : return schemaAP214CD; break; - case 2 : return schemaAP214DIS; break; - case 3 : return schemaAP203; break; - case 4: return schemaAP214IS; break; - case 5 : return schemaAP242DIS; break; +Standard_CString StepAP214_Protocol::SchemaName(Standard_Integer theShematype) +{ + if (theShematype != 0) + { + switch (theShematype) { //:j4 + default: + case 1: myShemaName = schemaAP214CD; break; + case 2: myShemaName = schemaAP214DIS; break; + case 3: myShemaName = schemaAP203; break; + case 4: myShemaName = schemaAP214IS; break; + case 5: myShemaName = schemaAP242DIS; break; + } } + return myShemaName; } - //======================================================================= //function : NbResources //purpose : diff --git a/src/StepAP214/StepAP214_Protocol.hxx b/src/StepAP214/StepAP214_Protocol.hxx index ab13ff90e8..cb0f01f5ec 100644 --- a/src/StepAP214/StepAP214_Protocol.hxx +++ b/src/StepAP214/StepAP214_Protocol.hxx @@ -43,7 +43,7 @@ public: //! Returns a Case Number for each of the StepAP214 Entities Standard_EXPORT virtual Standard_Integer TypeNumber (const Handle(Standard_Type)& atype) const Standard_OVERRIDE; - Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype = 0) Standard_OVERRIDE; //! Returns count of Protocol used as Resources (level one) Standard_EXPORT virtual Standard_Integer NbResources() const Standard_OVERRIDE; @@ -63,8 +63,7 @@ protected: private: - - + Standard_CString myShemaName; }; diff --git a/src/StepData/StepData.cxx b/src/StepData/StepData.cxx index 79e848c48e..08e87644fb 100644 --- a/src/StepData/StepData.cxx +++ b/src/StepData/StepData.cxx @@ -15,7 +15,6 @@ // svv #2 23.02.00: porting on SIL #include -#include #include #include #include @@ -32,7 +31,6 @@ StaticHandleA(StepData_Protocol,theheader); { // InitHandleVoid(StepData_Protocol,proto); // InitHandleVoid(StepData_DefaultGeneral,stmod); -//:S4136 Interface_Static::Init("step","step.readaccept.void",'i',"1"); // if (proto.IsNull()) proto = new StepData_Protocol; // if (stmod.IsNull()) stmod = new StepData_DefaultGeneral; } diff --git a/src/StepData/StepData_DescrProtocol.cxx b/src/StepData/StepData_DescrProtocol.cxx index b69a82db12..89d0ae36ec 100644 --- a/src/StepData/StepData_DescrProtocol.cxx +++ b/src/StepData/StepData_DescrProtocol.cxx @@ -37,5 +37,5 @@ StepData_DescrProtocol::StepData_DescrProtocol () { } StepData_WriterLib::SetGlobal (rwm,this); } - Standard_CString StepData_DescrProtocol::SchemaName () const + Standard_CString StepData_DescrProtocol::SchemaName (Standard_Integer /*theShematype*/) { return thename.ToCString(); } diff --git a/src/StepData/StepData_DescrProtocol.hxx b/src/StepData/StepData_DescrProtocol.hxx index 6005e09198..f85d60dbd4 100644 --- a/src/StepData/StepData_DescrProtocol.hxx +++ b/src/StepData/StepData_DescrProtocol.hxx @@ -57,7 +57,7 @@ public: //! Returns the Schema Name attached to each class of Protocol //! here, returns the SchemaName set by SetSchemaName //! was C++ : return const - Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype) Standard_OVERRIDE; diff --git a/src/StepData/StepData_FileProtocol.cxx b/src/StepData/StepData_FileProtocol.cxx index 212ac03eee..6078e1e589 100644 --- a/src/StepData/StepData_FileProtocol.cxx +++ b/src/StepData/StepData_FileProtocol.cxx @@ -64,5 +64,5 @@ Standard_Boolean StepData_FileProtocol::GlobalCheck(const Interface_Graph& G, } - Standard_CString StepData_FileProtocol::SchemaName () const + Standard_CString StepData_FileProtocol::SchemaName (Standard_Integer /*theShematype*/) { return thename; } diff --git a/src/StepData/StepData_FileProtocol.hxx b/src/StepData/StepData_FileProtocol.hxx index 5f83066d24..7fe343bad5 100644 --- a/src/StepData/StepData_FileProtocol.hxx +++ b/src/StepData/StepData_FileProtocol.hxx @@ -74,7 +74,7 @@ public: //! To be redefined by each sub-class //! Here, SchemaName returns "" (empty String) //! was C++ : return const - Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype) Standard_OVERRIDE; diff --git a/src/StepData/StepData_Protocol.cxx b/src/StepData/StepData_Protocol.cxx index 614fde78a6..f5ce0382da 100644 --- a/src/StepData/StepData_Protocol.cxx +++ b/src/StepData/StepData_Protocol.cxx @@ -70,12 +70,11 @@ Standard_Integer StepData_Protocol::TypeNumber } -Standard_CString StepData_Protocol::SchemaName () const +Standard_CString StepData_Protocol::SchemaName (Standard_Integer /*theShematype*/) { return thename; } - Handle(Interface_InterfaceModel) StepData_Protocol::NewModel () const { return new StepData_StepModel; diff --git a/src/StepData/StepData_Protocol.hxx b/src/StepData/StepData_Protocol.hxx index c6bba9699c..a0ada9297e 100644 --- a/src/StepData/StepData_Protocol.hxx +++ b/src/StepData/StepData_Protocol.hxx @@ -72,7 +72,7 @@ public: //! To be redefined by each sub-class //! Here, SchemaName returns "(DEFAULT)" //! was C++ : return const - Standard_EXPORT virtual Standard_CString SchemaName() const; + Standard_EXPORT virtual Standard_CString SchemaName(Standard_Integer theShematype = 0); //! Creates an empty Model for Step Norm Standard_EXPORT Handle(Interface_InterfaceModel) NewModel() const Standard_OVERRIDE; diff --git a/src/StepData/StepData_StepModel.cxx b/src/StepData/StepData_StepModel.cxx index 2f7b682fef..9efc9354ba 100644 --- a/src/StepData/StepData_StepModel.cxx +++ b/src/StepData/StepData_StepModel.cxx @@ -34,8 +34,316 @@ IMPLEMENT_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel) // Entete de fichier : liste d entites -StepData_StepModel::StepData_StepModel () { } +StepData_StepModel::StepData_StepModel () +{ + initParameters(); +} +//======================================================================= +//function : initParameters +//purpose : +//======================================================================= +void StepData_StepModel::initParameters() +{ + //for each created item, value from static map should be + //checked, if static map is bound with this parameter than get value from static + Handle(Interface_Static) aStaticItem; + Handle(Interface_Static) anItem = new Interface_Static("step", "write.step.product.name", Interface_ParamText, ""); + myParamMap.Bind("write.step.product.name", anItem); + + anItem = new Interface_Static("step", "write.step.assembly", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + Interface_Static::InitValues(anItem, "eval Auto"); + aStaticItem = Interface_Static::Static("write.step.assembly"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "Auto" : aStaticItem->CStringValue()); + myParamMap.Bind("write.step.assembly", anItem); + + anItem = new Interface_Static("step", "step.angleunit.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval File"); + Interface_Static::InitValues(anItem, "eval Rad"); + Interface_Static::InitValues(anItem, "eval Deg"); + aStaticItem = Interface_Static::Static("step.angleunit.mode"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "File" : aStaticItem->CStringValue()); + myParamMap.Bind("step.angleunit.mode", anItem); + + anItem = new Interface_Static("step", "write.step.schema", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval AP214CD"); + Interface_Static::InitValues(anItem, "eval AP214DIS"); + Interface_Static::InitValues(anItem, "eval AP203"); + Interface_Static::InitValues(anItem, "eval AP214IS"); + Interface_Static::InitValues(anItem, "eval AP242DIS"); + aStaticItem = Interface_Static::Static("write.step.schema"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "AP214IS" : aStaticItem->CStringValue()); + myParamMap.Bind("write.step.schema", anItem); + + // Type of Product Definition for reading + // Note: the numbers should be consistent with function FindShapeReprType() + // in STEPControl_ActorRead.cxx + anItem = new Interface_Static("step", "read.step.shape.repr", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval All"); // 1 + Interface_Static::InitValues(anItem, "eval ABSR"); // 2 + Interface_Static::InitValues(anItem, "eval MSSR"); // 3 + Interface_Static::InitValues(anItem, "eval GBSSR"); // 4 + Interface_Static::InitValues(anItem, "eval FBSR"); // 5 + Interface_Static::InitValues(anItem, "eval EBWSR"); // 6 + Interface_Static::InitValues(anItem, "eval GBWSR"); // 7 + aStaticItem = Interface_Static::Static("read.step.shape.repr"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "All" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.shape.repr", anItem); + + // Mode for reading shapes attached to main SDR by SRR + // (hybrid model representation in AP203 since 1998) + anItem = new Interface_Static("step", "read.step.shape.relationship", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval OFF"); + Interface_Static::InitValues(anItem, "eval ON"); + aStaticItem = Interface_Static::Static("read.step.shape.relationship"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "ON" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.shape.relationship", anItem); + + // Mode for reading shapes attached to Product by ShapeAspect + // (hybrid model representation in AP203 before 1998) + anItem = new Interface_Static("step", "read.step.shape.aspect", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval OFF"); + Interface_Static::InitValues(anItem, "eval ON"); + aStaticItem = Interface_Static::Static("read.step.shape.aspect"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "ON" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.shape.aspect", anItem); + + // Mode for reading SDR and ShapeRepr if it is necessary + anItem = new Interface_Static("step", "read.step.product.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval OFF"); + Interface_Static::InitValues(anItem, "eval ON"); + aStaticItem = Interface_Static::Static("read.step.product.mode"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "ON" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.product.mode", anItem); + + // Order of reading ShapeDefinitionRepresentation in ProductDefinition + anItem = new Interface_Static("step", "read.step.product.context", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval all"); // 1 + Interface_Static::InitValues(anItem, "eval design"); // 2 + Interface_Static::InitValues(anItem, "eval analysis");// 3 + aStaticItem = Interface_Static::Static("read.step.product.context"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "all" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.product.context", anItem); + + // What we try to read in ProductDefinition + anItem = new Interface_Static("step", "read.step.assembly.level", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval all"); // 1 + Interface_Static::InitValues(anItem, "eval assembly"); // 2 + Interface_Static::InitValues(anItem, "eval structure");// 3 + Interface_Static::InitValues(anItem, "eval shape"); // 4 + aStaticItem = Interface_Static::Static("read.step.assembly.level"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "all" : aStaticItem->CStringValue()); + myParamMap.Bind("read.step.assembly.level", anItem); + + // unit: supposed to be cascade unit (target unit for reading) + anItem = new Interface_Static("step", "write.step.unit", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval INCH"); // 1 + Interface_Static::InitValues(anItem, "eval MM"); // 2 + Interface_Static::InitValues(anItem, "eval ??"); // 3 + Interface_Static::InitValues(anItem, "eval FT"); // 4 + Interface_Static::InitValues(anItem, "eval MI"); // 5 + Interface_Static::InitValues(anItem, "eval M"); // 6 + Interface_Static::InitValues(anItem, "eval KM"); // 7 + Interface_Static::InitValues(anItem, "eval MIL"); // 8 + Interface_Static::InitValues(anItem, "eval UM"); // 9 + Interface_Static::InitValues(anItem, "eval CM"); //10 + Interface_Static::InitValues(anItem, "eval UIN"); //11 + aStaticItem = Interface_Static::Static("write.step.unit"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "MM" : aStaticItem->CStringValue()); + myParamMap.Bind("write.step.unit", anItem); + + // Non-manifold topology reading: OFF by default (ssv; 26.11.2010) + anItem = new Interface_Static("step", "read.step.nonmanifold", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + aStaticItem = Interface_Static::Static("read.step.nonmanifold"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.step.nonmanifold", anItem); + + // Non-manifold topology writing: OFF by default (ssv; 26.11.2010) + anItem = new Interface_Static("step", "write.step.nonmanifold", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + aStaticItem = Interface_Static::Static("write.step.nonmanifold"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("write.step.nonmanifold", anItem); + + // I-Deas-like STEP processing: OFF by default (ssv; 22.11.2010) + anItem = new Interface_Static("step", "read.step.ideas", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + aStaticItem = Interface_Static::Static("read.step.ideas"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.step.ideas", anItem); + + //Parameter to write all free vertices in one SDR (name and style of vertex are lost) (default) + //or each vertex in its own SDR (name and style of vertex are exported). (ika; 21.07.2014) + anItem = new Interface_Static("step", "write.step.vertex.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval One Compound"); + Interface_Static::InitValues(anItem, "eval Single Vertex"); + aStaticItem = Interface_Static::Static("write.step.vertex.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("write.step.vertex.mode", anItem); + + // abv 15.11.00: ShapeProcessing + anItem = new Interface_Static("XSTEP", "write.step.resource.name", Interface_ParamText, "STEP"); + myParamMap.Bind("write.step.resource.name", anItem); + anItem = new Interface_Static("XSTEP", "read.step.resource.name", Interface_ParamText, "STEP"); + myParamMap.Bind("read.step.resource.name", anItem); + anItem = new Interface_Static("XSTEP", "write.step.sequence", Interface_ParamText, "ToSTEP"); + myParamMap.Bind("write.step.sequence", anItem); + anItem = new Interface_Static("XSTEP", "read.step.sequence", Interface_ParamText, "FromSTEP"); + myParamMap.Bind("read.step.sequence", anItem); + + // ika 28.07.16: Paremeter to read all top level solids and shells, + // should be used only in case of invalid shape_representation without links to shapes. + anItem = new Interface_Static("step", "read.step.all.shapes", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + aStaticItem = Interface_Static::Static("read.step.all.shapes"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.step.all.shapes", anItem); + + //-------------------------------------------------------------------------------- + //From Base Class + anItem = new Interface_Static("XSTEP", "read.precision.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch 0"); + Interface_Static::InitValues(anItem, "eval File"); + Interface_Static::InitValues(anItem, "eval User"); + anItem->SetIntegerValue(0); + aStaticItem = Interface_Static::Static("read.precision.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.precision.mode", anItem); + + anItem = new Interface_Static("XSTEP", "read.precision.val", Interface_ParamReal, "1.e-03"); + myParamMap.Bind("read.precision.val", anItem); + + anItem = new Interface_Static("XSTEP", "read.maxprecision.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch 0"); + Interface_Static::InitValues(anItem, "eval Preferred"); + Interface_Static::InitValues(anItem, "eval Forced"); + aStaticItem = Interface_Static::Static("read.maxprecision.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.maxprecision.mode", anItem); + + anItem = new Interface_Static("XSTEP", "read.maxprecision.val", Interface_ParamReal, "1."); + myParamMap.Bind("read.maxprecision.val", anItem); + + // encode regularity + // negatif ou nul : ne rien faire. positif : on y va + anItem = new Interface_Static("XSTEP", "read.encoderegularity.angle", Interface_ParamReal, "0.01"); + myParamMap.Bind("read.encoderegularity.angle", anItem); + + // compute surface curves + // 0 : par defaut. 2 : ne garder que le 2D. 3 : ne garder que le 3D + //gka S4054 + anItem = new Interface_Static("XSTEP", "read.surfacecurve.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch -3"); + Interface_Static::InitValues(anItem, "eval 3DUse_Forced"); + Interface_Static::InitValues(anItem, "eval 2DUse_Forced"); + Interface_Static::InitValues(anItem, "eval ?"); + Interface_Static::InitValues(anItem, "eval Default"); + Interface_Static::InitValues(anItem, "eval ?"); + Interface_Static::InitValues(anItem, "eval 2DUse_Preferred"); + Interface_Static::InitValues(anItem, "eval 3DUse_Preferred"); + aStaticItem = Interface_Static::Static("read.surfacecurve.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.surfacecurve.mode", anItem); + + // write precision + anItem = new Interface_Static("XSTEP", "write.precision.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch -1"); + Interface_Static::InitValues(anItem, "eval Min"); + Interface_Static::InitValues(anItem, "eval Average"); + Interface_Static::InitValues(anItem, "eval Max"); + Interface_Static::InitValues(anItem, "eval User"); + aStaticItem = Interface_Static::Static("write.precision.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("write.precision.mode", anItem); + + anItem = new Interface_Static("XSTEP", "write.precision.val", Interface_ParamReal, "1.e-03"); + myParamMap.Bind("write.precision.val", anItem); + + // Write surface curves + // 0: write (defaut), 1: do not write, 2: write except for analytical surfaces + anItem = new Interface_Static("XSTEP", "write.surfacecurve.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + //Interface_Static::InitValues(anItem,"eval NoAnalytic"); + aStaticItem = Interface_Static::Static("write.surfacecurve.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 1 : aStaticItem->IntegerValue()); + myParamMap.Bind("write.surfacecurve.mode", anItem); + //-------------------------------------------------------------------------------- + + //#74 rln 10.03.99 S4135: adding new parameter for handling use of BRepLib::SameParameter + anItem = new Interface_Static("XSTEP", "read.stdsameparameter.mode", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "ematch 0"); + Interface_Static::InitValues(anItem, "eval Off"); + Interface_Static::InitValues(anItem, "eval On"); + aStaticItem = Interface_Static::Static("read.stdsameparameter.mode"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.stdsameparameter.mode", anItem); + + // unit: supposed to be cascade unit (target unit for reading) + anItem = new Interface_Static("XSTEP", "xstep.cascade.unit", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 1"); + Interface_Static::InitValues(anItem, "eval INCH"); // 1 + Interface_Static::InitValues(anItem, "eval MM"); // 2 + Interface_Static::InitValues(anItem, "eval ??"); // 3 + Interface_Static::InitValues(anItem, "eval FT"); // 4 + Interface_Static::InitValues(anItem, "eval MI"); // 5 + Interface_Static::InitValues(anItem, "eval M"); // 6 + Interface_Static::InitValues(anItem, "eval KM"); // 7 + Interface_Static::InitValues(anItem, "eval MIL"); // 8 + Interface_Static::InitValues(anItem, "eval UM"); // 9 + Interface_Static::InitValues(anItem, "eval CM"); //10 + Interface_Static::InitValues(anItem, "eval UIN"); //11 + aStaticItem = Interface_Static::Static("xstep.cascade.unit"); + anItem->SetCStringValue(aStaticItem.IsNull() ? "MM" : aStaticItem->CStringValue()); + myParamMap.Bind("xstep.cascade.unit", anItem); + + //----------------------------------------------------------- + // Few variables for advanced control of translation process + //----------------------------------------------------------- + + // Indicates whether to write sub-shape names to 'Name' attributes of + // STEP Representation Items + anItem = new Interface_Static("stepcaf", "write.stepcaf.subshapes.name", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); // 0 + Interface_Static::InitValues(anItem, "eval On"); // 1 + aStaticItem = Interface_Static::Static("write.stepcaf.subshapes.name"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("write.stepcaf.subshapes.name", anItem); + + // Indicates whether to read sub-shape names from 'Name' attributes of + // STEP Representation Items + anItem = new Interface_Static("stepcaf", "read.stepcaf.subshapes.name", Interface_ParamEnum, ""); + Interface_Static::InitValues(anItem, "enum 0"); + Interface_Static::InitValues(anItem, "eval Off"); // 0 + Interface_Static::InitValues(anItem, "eval On"); // 1 + aStaticItem = Interface_Static::Static("read.stepcaf.subshapes.name"); + anItem->SetIntegerValue(aStaticItem.IsNull() ? 0 : aStaticItem->IntegerValue()); + myParamMap.Bind("read.stepcaf.subshapes.name", anItem); +} Handle(Standard_Transient) StepData_StepModel::Entity (const Standard_Integer num) const diff --git a/src/StepData/StepData_StepModel.hxx b/src/StepData/StepData_StepModel.hxx index 3a54fa7b90..ef1da359db 100644 --- a/src/StepData/StepData_StepModel.hxx +++ b/src/StepData/StepData_StepModel.hxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -49,7 +51,7 @@ public: //! Creates an empty STEP model with an empty header. Standard_EXPORT StepData_StepModel(); - + //! returns entity given its rank. //! Same as InterfaceEntity, but with a shorter name Standard_EXPORT Handle(Standard_Transient) Entity (const Standard_Integer num) const; @@ -106,11 +108,12 @@ public: - DEFINE_STANDARD_RTTIEXT(StepData_StepModel,Interface_InterfaceModel) protected: + //! Initialises all non-static parameters used in translations + Standard_EXPORT void initParameters(); diff --git a/src/StepData/StepData_StepReaderData.cxx b/src/StepData/StepData_StepReaderData.cxx index ad4d755dbe..877ad0f8a1 100644 --- a/src/StepData/StepData_StepReaderData.cxx +++ b/src/StepData/StepData_StepReaderData.cxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -117,7 +116,6 @@ StepData_StepReaderData::StepData_StepReaderData thenbscop = 0; thenbents = 0; thelastn = 0; thenbhead = nbheader; //themults.Init(0); thecheck = new Interface_Check; -//:S4136 acceptvoid = Interface_Static::IVal("step.readaccept.void"); if (initstr) return; //for (Standard_Integer i = 0; i < Maxlst; i ++) { // sprintf(textnum,"$%d",i+1); diff --git a/src/StepSelect/StepSelect_StepType.cxx b/src/StepSelect/StepSelect_StepType.cxx index fd82fee091..416757e5a3 100644 --- a/src/StepSelect/StepSelect_StepType.cxx +++ b/src/StepSelect/StepSelect_StepType.cxx @@ -48,7 +48,7 @@ static TCollection_AsciiString lastvalue; Standard_CString StepSelect_StepType::Value (const Handle(Standard_Transient)& ent, - const Handle(Interface_InterfaceModel)& /*model*/) const + const Handle(Interface_InterfaceModel)& model) const { lastvalue.Clear(); Handle(StepData_ReadWriteModule) module; @@ -56,7 +56,9 @@ static TCollection_AsciiString lastvalue; Standard_Boolean ok = thelib.Select (ent,module,CN); if (!ok) { lastvalue.AssignCat ("..NOT FROM SCHEMA "); - lastvalue.AssignCat (theproto->SchemaName()); + Standard_Integer aval = model->GetParam("write.step.schema").IsNull() ? + 0 : model->GetParam("write.step.schema")->IntegerValue(); + lastvalue.AssignCat (theproto->SchemaName(aval)); lastvalue.AssignCat (".."); } else { Standard_Boolean plex = module->IsComplex(CN); diff --git a/src/StepToGeom/StepToGeom.cxx b/src/StepToGeom/StepToGeom.cxx index 5edea1ad06..6d5c8e219c 100644 --- a/src/StepToGeom/StepToGeom.cxx +++ b/src/StepToGeom/StepToGeom.cxx @@ -1508,7 +1508,8 @@ Handle(Geom_Surface) StepToGeom::MakeSurface (const Handle(StepGeom_Surface)& SS const BRepBuilderAPI_MakeFace aBFace(aBasisSurface, Precision::Confusion()); if (aBFace.IsDone()) { - const TopoDS_Shape aResult = ShapeAlgo::AlgoContainer()->C0ShapeToC1Shape(aBFace.Face(), Abs(anOffset)); + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + const TopoDS_Shape aResult = aContainer->C0ShapeToC1Shape(aBFace.Face(), Abs(anOffset)); if (aResult.ShapeType() == TopAbs_FACE) { aBasisSurface = BRep_Tool::Surface(TopoDS::Face(aResult)); diff --git a/src/StepToTopoDS/StepToTopoDS_Builder.cxx b/src/StepToTopoDS/StepToTopoDS_Builder.cxx index 9de804bcb0..e88ef77e87 100644 --- a/src/StepToTopoDS/StepToTopoDS_Builder.cxx +++ b/src/StepToTopoDS/StepToTopoDS_Builder.cxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -89,10 +88,12 @@ #include #include -static void ResetPreci (const TopoDS_Shape& S, Standard_Real maxtol) +static void ResetPreci (const TopoDS_Shape& S, + Standard_Real maxtol, + const Handle(Interface_InterfaceModel)& theModel) { //:S4136 - Standard_Integer modetol = Interface_Static::IVal("read.maxprecision.mode"); + Standard_Integer modetol = theModel->GetParam("read.maxprecision.mode")->IntegerValue(); if (modetol) { ShapeFix_ShapeTolerance STU; STU.LimitTolerance (S,Precision::Confusion(),maxtol); @@ -228,7 +229,7 @@ void StepToTopoDS_Builder::Init } //:S4136 ShapeFix::SameParameter (S,Standard_False); - ResetPreci (S, MaxTol()); + ResetPreci (S, MaxTol(), TP->Model()); } else { TP->AddWarning(aShell," OuterShell from ManifoldSolidBrep not mapped to TopoDS"); @@ -336,7 +337,7 @@ void StepToTopoDS_Builder::Init } //:S4136 ShapeFix::SameParameter (S,Standard_False); - ResetPreci (S, MaxTol()); + ResetPreci (S, MaxTol(), TP->Model()); } // ============================================================================ @@ -543,8 +544,8 @@ void StepToTopoDS_Builder::Init } //:S4136 ShapeFix::SameParameter (S,Standard_False); - ResetPreci (S, MaxTol()); - ResetPreci (Shl, MaxTol()); //skl + ResetPreci (S, MaxTol(), TP->Model()); + ResetPreci (Shl, MaxTol(), TP->Model()); //skl } // ============================================================================ @@ -604,7 +605,7 @@ void StepToTopoDS_Builder::Init (const Handle(StepShape_EdgeBasedWireframeModel) myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther ); done = ! myResult.IsNull(); - ResetPreci (myResult, MaxTol()); + ResetPreci (myResult, MaxTol(), TP->Model()); } // ============================================================================ @@ -666,7 +667,7 @@ void StepToTopoDS_Builder::Init (const Handle(StepShape_FaceBasedSurfaceModel)& myError = ( myResult.IsNull() ? StepToTopoDS_BuilderDone : StepToTopoDS_BuilderOther ); done = ! myResult.IsNull(); - ResetPreci (myResult, MaxTol()); + ResetPreci (myResult, MaxTol(), TP->Model()); } diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx index 6d578312ce..086c6d3abc 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateCompositeCurve.cxx @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -94,9 +94,9 @@ Standard_Boolean StepToTopoDS_TranslateCompositeCurve::Init (const Handle(StepGe //======================================================================= Standard_Boolean StepToTopoDS_TranslateCompositeCurve::Init (const Handle(StepGeom_CompositeCurve) &CC, - const Handle(Transfer_TransientProcess) &TP, - const Handle(StepGeom_Surface) &S, - const Handle(Geom_Surface) &Surf) + const Handle(Transfer_TransientProcess) &TP, + const Handle(StepGeom_Surface) &S, + const Handle(Geom_Surface) &Surf) { myWire.Nullify(); myInfiniteSegment = Standard_False; @@ -106,7 +106,7 @@ Standard_Boolean StepToTopoDS_TranslateCompositeCurve::Init (const Handle(StepGe Standard_Boolean isClosed = Standard_False; if ( SurfMode ) { - Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode"); + Standard_Integer modepcurve = TP->Model()->GetParam("read.surfacecurve.mode")->IntegerValue(); if ( modepcurve ==-3 ) SurfMode = Standard_False; } diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx index 4dcfc11a97..60a503d089 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateCurveBoundedSurface.cxx @@ -80,8 +80,10 @@ Standard_Boolean StepToTopoDS_TranslateCurveBoundedSurface::Init ( // abv 30.06.00: trj4_k1_geo-tu.stp #108: do as in TranslateFace // pdn to force bsplsurf to be periodic Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(S); - if (!sgbss.IsNull()) { - Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic(Surf); + if (!sgbss.IsNull()) + { + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + Handle(Geom_Surface) periodicSurf = aContainer->ConvertToPeriodic(Surf); if (!periodicSurf.IsNull()) { TP->AddWarning(S, "Surface forced to be periodic"); Surf = periodicSurf; diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx index b2b17747bc..24987fd630 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateEdgeLoop.cxx @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -50,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -170,7 +170,8 @@ static void CheckPCurves (TopoDS_Wire& aWire, const TopoDS_Face& aFace, // advanced check - XSAlgo::AlgoContainer()->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i) ); + Handle(XSAlgo_AlgoContainer) aContainer = new XSAlgo_AlgoContainer; + aContainer->CheckPCurve (myEdge, aFace, preci, sbwd->IsSeam(i) ); } } @@ -221,7 +222,10 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac done = Standard_True; return; } - Standard_Integer modepcurve = Interface_Static::IVal("read.surfacecurve.mode"); + Handle(StepData_StepModel) aModel = + Handle(StepData_StepModel)::DownCast(aTool.TransientProcess()->Model()); + + Standard_Integer modepcurve = aModel->GetParam("read.surfacecurve.mode")->IntegerValue(); // 0,1 : suivre le code, 2 : ne prendre que pcurve, 3 : ne prendre que C3D BRep_Builder B; @@ -663,7 +667,8 @@ void StepToTopoDS_TranslateEdgeLoop::Init(const Handle(StepShape_FaceBound)& Fac if (!aTool.ComputePCurve()) for (TopoDS_Iterator EdgeIt(W);EdgeIt.More();EdgeIt.Next()){ TopoDS_Edge edge = TopoDS::Edge(EdgeIt.Value()); - Handle(ShapeFix_EdgeProjAux) myEdgePro = ShapeAlgo::AlgoContainer()->ToolContainer()->EdgeProjAux(); + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + Handle(ShapeFix_EdgeProjAux) myEdgePro =aContainer->ToolContainer()->EdgeProjAux(); myEdgePro->Init (Face, edge); myEdgePro->Compute(preci); if (myEdgePro->IsFirstDone() && myEdgePro->IsLastDone()) { diff --git a/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx b/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx index 6de7d28d34..5e1d58adb4 100644 --- a/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx +++ b/src/StepToTopoDS/StepToTopoDS_TranslateFace.cxx @@ -183,8 +183,10 @@ void StepToTopoDS_TranslateFace::Init } // pdn to force bsplsurf to be periodic Handle(StepGeom_BSplineSurface) sgbss = Handle(StepGeom_BSplineSurface)::DownCast(StepSurf); - if (!sgbss.IsNull()) { - Handle(Geom_Surface) periodicSurf = ShapeAlgo::AlgoContainer()->ConvertToPeriodic(GeomSurf); + if (!sgbss.IsNull()) + { + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + Handle(Geom_Surface) periodicSurf = aContainer->ConvertToPeriodic(GeomSurf); if (!periodicSurf.IsNull()) { TP->AddWarning(StepSurf, "Surface forced to be periodic"); GeomSurf = periodicSurf; diff --git a/src/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx b/src/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx index 2a3631c04e..411645425b 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeBrepWithVoids.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -76,7 +77,7 @@ TopoDSToStep_MakeBrepWithVoids:: CurrentShell.Reverse(); //:d7 abv 16 Mar 98: try to treat 'open' shells as closed since flag // IsClosed() is often incorrect (taken from MakeManifoldSolid(Solid)) - aTool.Init(aMap, Standard_False); + aTool.Init(aMap, Standard_False, FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); StepB.Init(CurrentShell, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); if (StepB.IsDone()) { diff --git a/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx b/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx index 7c2b382500..05169a6e1c 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrep.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -42,8 +43,9 @@ TopoDSToStep_MakeFacetedBrep:: if (aShell.Closed()) { Handle(StepShape_TopologicalRepresentationItem) aItem; MoniTool_DataMapOfShapeTransient aMap; - - TopoDSToStep_Tool aTool(aMap, Standard_True); + TopoDSToStep_Tool aTool(aMap, + Standard_True, + FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aShell, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); @@ -90,8 +92,9 @@ TopoDSToStep_MakeFacetedBrep:: if (aOuterShell.Closed()) { Handle(StepShape_TopologicalRepresentationItem) aItem; MoniTool_DataMapOfShapeTransient aMap; - - TopoDSToStep_Tool aTool(aMap, Standard_True); + TopoDSToStep_Tool aTool(aMap, + Standard_True, + FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aOuterShell, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx b/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx index 29d859f1bf..030023eeb9 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeFacetedBrepAndBrepWithVoids.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ TopoDSToStep_MakeFacetedBrepAndBrepWithVoids:: TopoDS_Shell CurrentShell = TopoDS::Shell(It.Value()); if (It.Value().Closed()) { - aTool.Init(aMap, Standard_False); + aTool.Init(aMap, Standard_False, FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); StepB.Init(CurrentShell, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeGeometricCurveSet.cxx b/src/TopoDSToStep/TopoDSToStep_MakeGeometricCurveSet.cxx index 4612f7f308..6697015508 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeGeometricCurveSet.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeGeometricCurveSet.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -43,7 +44,9 @@ TopoDSToStep_MakeGeometricCurveSet::TopoDSToStep_MakeGeometricCurveSet( done = Standard_False; Handle(TColStd_HSequenceOfTransient) itemList; MoniTool_DataMapOfShapeTransient aMap; - TopoDSToStep_Tool aTool (aMap, Standard_False); + TopoDSToStep_Tool aTool (aMap, + Standard_False, + FP->Model()->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_WireframeBuilder wirefB (aShape, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx b/src/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx index a7843567d5..0a7fbf3a68 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeManifoldSolidBrep.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -37,7 +38,8 @@ static Handle(StepShape_ManifoldSolidBrep) MakeManifoldSolidBrep (const TopoDS_S Handle(StepShape_ManifoldSolidBrep) theManifoldSolidBrep; MoniTool_DataMapOfShapeTransient aMap; - TopoDSToStep_Tool aTool(aMap, Standard_False); + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + TopoDSToStep_Tool aTool(aMap, Standard_False, aModel->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aShell, aTool, FP); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx b/src/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx index 9c4a20022e..40261b1814 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeShellBasedSurfaceModel.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,10 @@ TopoDSToStep_MakeShellBasedSurfaceModel:: done = Standard_False; MoniTool_DataMapOfShapeTransient aMap; - TopoDSToStep_Tool aTool(aMap, Standard_False); + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + TopoDSToStep_Tool aTool(aMap, + Standard_False, + aModel->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aFace, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); @@ -97,8 +101,11 @@ TopoDSToStep_MakeShellBasedSurfaceModel:: Handle(StepShape_OpenShell) aOpenShell; Handle(StepShape_ClosedShell) aClosedShell; MoniTool_DataMapOfShapeTransient aMap; - - TopoDSToStep_Tool aTool(aMap, Standard_False); + + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + TopoDSToStep_Tool aTool(aMap, + Standard_False, + aModel->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aShell, aTool, FP); //TopoDSToStep::AddResult ( FP, aTool ); @@ -155,7 +162,11 @@ TopoDSToStep_MakeShellBasedSurfaceModel:: if (It.Value().ShapeType() == TopAbs_SHELL) { aShell = TopoDS::Shell(It.Value()); - TopoDSToStep_Tool aTool(aMap, Standard_False); + + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + TopoDSToStep_Tool aTool(aMap, + Standard_False, + aModel->GetParam("write.surfacecurve.mode")->IntegerValue()); TopoDSToStep_Builder StepB(aShell, aTool, FP); TopoDSToStep::AddResult ( FP, aTool ); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx b/src/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx index c8818ecae0..6714c92e84 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeStepEdge.cxx @@ -30,8 +30,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -89,7 +89,9 @@ void TopoDSToStep_MakeStepEdge::Init(const TopoDS_Edge& aEdge, aTool.SetCurrentEdge(aEdge); // [BEGIN] Processing non-manifold topology (ssv; 11.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + Standard_Boolean isNMMode = aModel->GetParam("write.step.nonmanifold")->IntegerValue() != 0; if (isNMMode) { Handle(StepShape_EdgeCurve) anEC; Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aEdge); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx b/src/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx index f669e70c23..0950c57414 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeStepFace.cxx @@ -47,11 +47,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -125,7 +125,8 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& aFace, new TransferBRep_ShapeMapper(aFace); // on ne sait jamais // [BEGIN] Processing non-manifold topology (another approach) (ssv; 10.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + Standard_Boolean isNMMode = aModel->GetParam("write.step.nonmanifold")->IntegerValue() != 0; if (isNMMode) { Handle(StepShape_AdvancedFace) anAF; Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aFace); @@ -222,16 +223,20 @@ void TopoDSToStep_MakeStepFace::Init(const TopoDS_Face& aFace, // create basis curve Standard_Real UF, VF, UL, VL; - ShapeAlgo::AlgoContainer()->GetFaceUVBounds ( aFace, UF, UL, VF, VL ); + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + aContainer->GetFaceUVBounds ( aFace, UF, UL, VF, VL ); gp_Ax2 Ax2 ( pos.XYZ() + X.XYZ() * TS->MajorRadius(), X ^ dir, X ); Handle(Geom_Curve) BasisCurve = new Geom_Circle ( Ax2, TS->MinorRadius() ); // convert basis curve to bspline in order to avoid self-intersecting // surface of revolution (necessary e.g. for CATIA) - if ( VL - VF - 2 * M_PI < -Precision::PConfusion() ) - BasisCurve = ShapeAlgo::AlgoContainer()->ConvertCurveToBSpline (BasisCurve, VF, VL, Precision::Approximation(), - GeomAbs_C1, 100, 9); -// BasisCurve = new Geom_TrimmedCurve ( BasisCurve, VF, VL ); + if (VL - VF - 2 * M_PI < -Precision::PConfusion()) + { + Handle(ShapeAlgo_AlgoContainer) aContainer = new ShapeAlgo_AlgoContainer; + BasisCurve = aContainer->ConvertCurveToBSpline(BasisCurve, VF, VL, Precision::Approximation(), + GeomAbs_C1, 100, 9); + //BasisCurve = new Geom_TrimmedCurve ( BasisCurve, VF, VL ); + } // create surface of revolution gp_Ax1 Axis = Ax3.Axis(); diff --git a/src/TopoDSToStep/TopoDSToStep_MakeStepVertex.cxx b/src/TopoDSToStep/TopoDSToStep_MakeStepVertex.cxx index a7728906c2..3a8db511f9 100644 --- a/src/TopoDSToStep/TopoDSToStep_MakeStepVertex.cxx +++ b/src/TopoDSToStep/TopoDSToStep_MakeStepVertex.cxx @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -62,7 +62,8 @@ void TopoDSToStep_MakeStepVertex::Init(const TopoDS_Vertex& aVertex, aTool.SetCurrentVertex(aVertex); // [BEGIN] Processing non-manifold topology (ssv; 11.11.2010) - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(FP->Model()); + Standard_Boolean isNMMode = aModel->GetParam("write.step.nonmanifold")->IntegerValue() != 0; if (isNMMode) { Handle(StepShape_VertexPoint) aVP; Handle(TransferBRep_ShapeMapper) aSTEPMapper = TransferBRep::ShapeMapper(FP, aVertex); diff --git a/src/TopoDSToStep/TopoDSToStep_Tool.cxx b/src/TopoDSToStep/TopoDSToStep_Tool.cxx index 6408ab9b47..a8a5924035 100644 --- a/src/TopoDSToStep/TopoDSToStep_Tool.cxx +++ b/src/TopoDSToStep/TopoDSToStep_Tool.cxx @@ -16,7 +16,6 @@ #include -#include #include #include #include @@ -31,9 +30,8 @@ //purpose : //======================================================================= TopoDSToStep_Tool::TopoDSToStep_Tool() - :myLowestTol(0.),myReversedSurface (Standard_False) + :myLowestTol(0.),myReversedSurface (Standard_False),myPCurveMode(1) { - myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode"); } //======================================================================= @@ -41,10 +39,12 @@ TopoDSToStep_Tool::TopoDSToStep_Tool() //purpose : //======================================================================= -TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext) +TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, + const Standard_Boolean FacetedContext, + Standard_Integer theCurveMode) :myLowestTol(0.),myReversedSurface(Standard_False) { - Init ( M, FacetedContext ); + Init ( M, FacetedContext, theCurveMode ); } //======================================================================= @@ -52,11 +52,13 @@ TopoDSToStep_Tool::TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, //purpose : //======================================================================= -void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext) +void TopoDSToStep_Tool::Init(const MoniTool_DataMapOfShapeTransient& M, + const Standard_Boolean FacetedContext, + Standard_Integer theCurveMode) { myDataMap = M; myFacetedContext = FacetedContext; - myPCurveMode = Interface_Static::IVal("write.surfacecurve.mode"); + myPCurveMode = theCurveMode; } //======================================================================= diff --git a/src/TopoDSToStep/TopoDSToStep_Tool.hxx b/src/TopoDSToStep/TopoDSToStep_Tool.hxx index 1b8d82a65d..1b9314b903 100644 --- a/src/TopoDSToStep/TopoDSToStep_Tool.hxx +++ b/src/TopoDSToStep/TopoDSToStep_Tool.hxx @@ -50,9 +50,13 @@ public: Standard_EXPORT TopoDSToStep_Tool(); - Standard_EXPORT TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext); + Standard_EXPORT TopoDSToStep_Tool(const MoniTool_DataMapOfShapeTransient& M, + const Standard_Boolean FacetedContext, + Standard_Integer theCurveMode); - Standard_EXPORT void Init (const MoniTool_DataMapOfShapeTransient& M, const Standard_Boolean FacetedContext); + Standard_EXPORT void Init (const MoniTool_DataMapOfShapeTransient& M, + const Standard_Boolean FacetedContext, + Standard_Integer theCurveMode); Standard_EXPORT Standard_Boolean IsBound (const TopoDS_Shape& S); diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index c70cbfb3aa..9865fa7a47 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -1089,6 +1089,31 @@ static Standard_Integer testDoc (Draw_Interpretor&, return 0; } +static void initStatics() +{ + //Be carefull using this method and static map. + //For step files all this parameters initialises in the model. + //They are initialised here to avoid errors during using auxiliary + //functions to work with step files particulary function "param" in IFSelect_Functions.cxx. + //Do NOT USE Interface_Static methods for getting param values while reading step. + //If you need the parameters values use StepData_StepModel::GetParam method + + // Indicates whether to write sub-shape names to 'Name' attributes of + // STEP Representation Items + Interface_Static::Init("stepcaf", "write.stepcaf.subshapes.name", 'e', ""); + Interface_Static::Init("stepcaf", "write.stepcaf.subshapes.name", '&', "enum 0"); + Interface_Static::Init("stepcaf", "write.stepcaf.subshapes.name", '&', "eval Off"); // 0 + Interface_Static::Init("stepcaf", "write.stepcaf.subshapes.name", '&', "eval On"); // 1 + Interface_Static::SetIVal("write.stepcaf.subshapes.name", 0); // Disabled by default + + // Indicates whether to read sub-shape names from 'Name' attributes of + // STEP Representation Items + Interface_Static::Init("stepcaf", "read.stepcaf.subshapes.name", 'e', ""); + Interface_Static::Init("stepcaf", "read.stepcaf.subshapes.name", '&', "enum 0"); + Interface_Static::Init("stepcaf", "read.stepcaf.subshapes.name", '&', "eval Off"); // 0 + Interface_Static::Init("stepcaf", "read.stepcaf.subshapes.name", '&', "eval On"); // 1 + Interface_Static::SetIVal("read.stepcaf.subshapes.name", 0); // Disabled by default +} //======================================================================= //function : Init @@ -1105,7 +1130,13 @@ void XDEDRAW::Init(Draw_Interpretor& di) initactor = Standard_True; // Load static variables for STEPCAF (ssv; 16.08.2012) - STEPCAFControl_Controller::Init(); + static Standard_Boolean inic = Standard_False; + if (!inic) { + initStatics(); + Handle(STEPCAFControl_Controller) STEPCTL = new STEPCAFControl_Controller; + XSDRAW::SetController(STEPCTL); + inic = Standard_True; + } // Initialize XCAF formats Handle(TDocStd_Application) anApp = DDocStd::GetApplication(); diff --git a/src/XDEDRAW/XDEDRAW_Common.cxx b/src/XDEDRAW/XDEDRAW_Common.cxx index 755921d20a..e1b5ca2d3a 100644 --- a/src/XDEDRAW/XDEDRAW_Common.cxx +++ b/src/XDEDRAW/XDEDRAW_Common.cxx @@ -298,11 +298,14 @@ static Standard_Integer ReadStep (Draw_Interpretor& di, Standard_Integer argc, c di << "Use: " << argv[0] << " Doc filename [mode]: read STEP file to a document\n"; return 0; } - - DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); + DeclareAndCast(STEPCAFControl_Controller, ctl, XSDRAW::Controller()); + if (ctl.IsNull()) + { + ctl = new STEPCAFControl_Controller; + XSDRAW::SetController(ctl); + } - STEPCAFControl_Reader reader ( XSDRAW::Session(),Standard_True); + STEPCAFControl_Reader reader ( XSDRAW::Session(), ctl, Standard_True); if (argc == 4) { Standard_Boolean mode = Standard_True; @@ -383,9 +386,14 @@ static Standard_Integer WriteStep (Draw_Interpretor& di, Standard_Integer argc, Standard_CString multifile = 0; Standard_Integer k = 3; - DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); - STEPCAFControl_Writer writer ( XSDRAW::Session(), Standard_True ); + + DeclareAndCast(STEPCAFControl_Controller, ctl, XSDRAW::Controller()); + if (ctl.IsNull()) + { + ctl = new STEPCAFControl_Controller; + XSDRAW::SetController(ctl); + } + STEPCAFControl_Writer writer ( XSDRAW::Session(), ctl, Standard_True ); STEPControl_StepModelType mode = STEPControl_AsIs; if ( argc > k ) { @@ -521,10 +529,14 @@ static Standard_Integer testSTEP(Draw_Interpretor& di, Standard_Integer argc, co return 0; } - DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); + DeclareAndCast(STEPCAFControl_Controller, ctl, XSDRAW::Controller()); + if (ctl.IsNull()) + { + ctl = new STEPCAFControl_Controller; + XSDRAW::SetController(ctl); + } - STEPCAFControl_Reader reader(XSDRAW::Session(), Standard_True); + STEPCAFControl_Reader reader(XSDRAW::Session(), ctl, Standard_True); if (argc == 4) { Standard_Boolean mode = Standard_True; diff --git a/src/XSAlgo/XSAlgo_AlgoContainer.cxx b/src/XSAlgo/XSAlgo_AlgoContainer.cxx index 7094d09aac..89b6243d88 100644 --- a/src/XSAlgo/XSAlgo_AlgoContainer.cxx +++ b/src/XSAlgo/XSAlgo_AlgoContainer.cxx @@ -83,7 +83,7 @@ XSAlgo_AlgoContainer::XSAlgo_AlgoContainer() void XSAlgo_AlgoContainer::PrepareForTransfer() const { - UnitsMethods::SetCasCadeLengthUnit ( Interface_Static::IVal("xstep.cascade.unit") ); + UnitsMethods::SetCasCadeLengthUnit(getParam("xstep.cascade.unit")->IntegerValue()); } //======================================================================= @@ -104,7 +104,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape, Handle(ShapeProcess_ShapeContext) context = Handle(ShapeProcess_ShapeContext)::DownCast(info); if ( context.IsNull() ) { - Standard_CString rscfile = Interface_Static::CVal(prscfile); + Standard_CString rscfile = getParam(prscfile)->CStringValue(); if (!rscfile) rscfile = prscfile; context = new ShapeProcess_ShapeContext(shape, rscfile); @@ -114,7 +114,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape, } info = context; - Standard_CString seq = Interface_Static::CVal ( pseq ); + Standard_CString seq = getParam(pseq)->CStringValue(); if ( ! seq ) seq = pseq; // if resource file is not loaded or does not define .exec.op, @@ -358,7 +358,7 @@ Standard_Boolean XSAlgo_AlgoContainer::CheckPCurve (const TopoDS_Edge& E, B.Range(edge,face,w1,w2); B.SameRange(edge, Standard_False ); //:S4136 - Standard_Integer SPmode = Interface_Static::IVal("read.stdsameparameter.mode"); + Standard_Integer SPmode = getParam("read.stdsameparameter.mode")->IntegerValue(); if ( SPmode ) B.SameParameter (edge, Standard_False ); @@ -567,3 +567,29 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const Handle(Transfer_FinderProcess } } } + +//======================================================================= +// Method : SetModel +// Purpose : +//======================================================================= +void XSAlgo_AlgoContainer::SetModel(Handle(Interface_InterfaceModel)& theModel) +{ + myModel = theModel; +} + +//======================================================================= +// Method : getParam +// Purpose : +//======================================================================= +Handle(Interface_Static) XSAlgo_AlgoContainer::getParam +(const Standard_CString theParamName) const +{ + Handle(Interface_Static) aParam; + if (!myModel.IsNull()) + aParam = myModel->GetParam(theParamName); + + if (aParam.IsNull()) + aParam = Interface_Static::Static(theParamName); + + return aParam; +} diff --git a/src/XSAlgo/XSAlgo_AlgoContainer.hxx b/src/XSAlgo/XSAlgo_AlgoContainer.hxx index f64c90730a..98e400f57f 100644 --- a/src/XSAlgo/XSAlgo_AlgoContainer.hxx +++ b/src/XSAlgo/XSAlgo_AlgoContainer.hxx @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include #include @@ -78,6 +80,9 @@ public: //! from item startTPitem Standard_EXPORT virtual void MergeTransferInfo (const Handle(Transfer_FinderProcess)& FP, const Handle(Standard_Transient)& info) const; + //! Sets the model for translations + Standard_EXPORT void SetModel(Handle(Interface_InterfaceModel)& theModel); + @@ -85,13 +90,17 @@ public: protected: - + //! Returns a parameter for translations. + //! First tries get it from non-static model, + //! if failure get it from static map + Standard_EXPORT Handle(Interface_Static) getParam(const Standard_CString theParamName) const; private: Handle(XSAlgo_ToolContainer) myTC; + Handle(Interface_InterfaceModel) myModel; }; diff --git a/src/XSControl/XSControl_Controller.cxx b/src/XSControl/XSControl_Controller.cxx index e1dc727ba1..b16bce116c 100644 --- a/src/XSControl/XSControl_Controller.cxx +++ b/src/XSControl/XSControl_Controller.cxx @@ -74,15 +74,23 @@ static NCollection_DataMap //purpose : Constructor //======================================================================= -XSControl_Controller::XSControl_Controller (const Standard_CString theLongName, const Standard_CString theShortName) -: myShortName(theShortName), myLongName(theLongName) +XSControl_Controller::XSControl_Controller(const Standard_CString theLongName, const Standard_CString theShortName) + : myShortName(theShortName), myLongName(theLongName) { - // Standard parameters - Interface_Static::Standards(); - TraceStatic ("read.precision.mode" , 5); - TraceStatic ("read.precision.val" , 5); - TraceStatic ("write.precision.mode" , 6); - TraceStatic ("write.precision.val" , 6); + if (!myLongName.IsEqual("STEP") && !myShortName.IsEqual("step")) + { + // Standard parameters + Interface_Static::Standards(); + TraceStatic("read.precision.mode", 5); + TraceStatic("read.precision.val", 5); + TraceStatic("write.precision.mode", 6); + TraceStatic("write.precision.val", 6); + } +} + +Standard_Boolean XSControl_Controller::Init(const Handle(XSControl_WorkSession)& /*theWS*/) +{ + return Standard_True; } //======================================================================= @@ -98,6 +106,18 @@ void XSControl_Controller::TraceStatic (const Standard_CString theName, const St myParamUses.Append(theUse); } +//======================================================================= +//function : TraceNotStatic +//purpose : +//======================================================================= + +void XSControl_Controller::TraceNotStatic(const Handle(Interface_Static)& theParam, const Standard_Integer theUse) +{ + if (theParam.IsNull()) return; + myParams.Append(theParam); + myParamUses.Append(theUse); +} + //======================================================================= //function : SetNames //purpose : @@ -476,9 +496,13 @@ void XSControl_Controller::Customise (Handle(XSControl_WorkSession)& WS) // Here for the specific manufacturers of controllers could create the // Parameters: So wait here - Handle(TColStd_HSequenceOfHAsciiString) listat = Interface_Static::Items(); - Handle(IFSelect_ParamEditor) paramed = IFSelect_ParamEditor::StaticEditor (listat,"All Static Parameters"); - WS->AddNamedItem ("xst-static-params-edit",paramed); - Handle(IFSelect_EditForm) paramform = paramed->Form(Standard_False); - WS->AddNamedItem ("xst-static-params",paramform); + //for step it is not needed + if (!myLongName.IsEqual("STEP") && !myShortName.IsEqual("step")) + { + Handle(TColStd_HSequenceOfHAsciiString) listat = Interface_Static::Items(); + Handle(IFSelect_ParamEditor) paramed = IFSelect_ParamEditor::StaticEditor(listat, "All Static Parameters"); + WS->AddNamedItem("xst-static-params-edit", paramed); + Handle(IFSelect_EditForm) paramform = paramed->Form(Standard_False); + WS->AddNamedItem("xst-static-params", paramform); + } } diff --git a/src/XSControl/XSControl_Controller.hxx b/src/XSControl/XSControl_Controller.hxx index 87b7a4b923..87aaa064d7 100644 --- a/src/XSControl/XSControl_Controller.hxx +++ b/src/XSControl/XSControl_Controller.hxx @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -65,7 +66,10 @@ DEFINE_STANDARD_HANDLE(XSControl_Controller, Standard_Transient) class XSControl_Controller : public Standard_Transient { public: - + + //! Initialisation of additional non-static parameters taken data from session model + Standard_EXPORT virtual Standard_Boolean Init(const Handle(XSControl_WorkSession)& /*theWS*/); + //! Changes names //! if a name is empty, the formerly set one remains //! Remark : Does not call Record or AutoRecord @@ -203,6 +207,9 @@ class XSControl_Controller : public Standard_Transient //! Records the name of a Static to be traced for a given use Standard_EXPORT void TraceStatic (const Standard_CString theName, const Standard_Integer theUse); + //! Records the non Static parameter to be traced for a given use + Standard_EXPORT void TraceNotStatic(const Handle(Interface_Static)& theParam, const Standard_Integer theUse); + TCollection_AsciiString myShortName; TCollection_AsciiString myLongName; Handle(IFSelect_WorkLibrary) myAdaptorLibrary; diff --git a/src/XSControl/XSControl_Functions.cxx b/src/XSControl/XSControl_Functions.cxx index 4b57748481..2f1bcaf04c 100644 --- a/src/XSControl/XSControl_Functions.cxx +++ b/src/XSControl/XSControl_Functions.cxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/src/XSControl/XSControl_Reader.cxx b/src/XSControl/XSControl_Reader.cxx index ea17e5cd61..84ac6998d9 100644 --- a/src/XSControl/XSControl_Reader.cxx +++ b/src/XSControl/XSControl_Reader.cxx @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -78,13 +77,21 @@ Standard_Boolean XSControl_Reader::SetNorm (const Standard_CString norm) { if (thesession.IsNull()) SetWS (new XSControl_WorkSession); Standard_Boolean stat = thesession->SelectNorm (norm); - if (stat) { - thesession->InitTransferReader(0); - thesession->InitTransferReader(4); - } + if (stat) initTransferReader(); return stat; } +//======================================================================= +//function : InitTransferReader +//purpose : +//======================================================================= +void XSControl_Reader::initTransferReader() +{ + if (thesession.IsNull()) return; + thesession->InitTransferReader(0); + thesession->InitTransferReader(4); +} + //======================================================================= //function : SetWS @@ -101,8 +108,7 @@ void XSControl_Reader::SetWS(const Handle(XSControl_WorkSession)& WS, if (thesession->NormAdaptor().IsNull()) return; Handle(Interface_InterfaceModel) model = thesession->Model (); if (scratch || model.IsNull()) model = thesession->NewModel (); - thesession->InitTransferReader(0); - thesession->InitTransferReader(4); + initTransferReader(); } diff --git a/src/XSControl/XSControl_Reader.hxx b/src/XSControl/XSControl_Reader.hxx index ebd3ad079c..0077a05357 100644 --- a/src/XSControl/XSControl_Reader.hxx +++ b/src/XSControl/XSControl_Reader.hxx @@ -251,6 +251,9 @@ protected: //! Returns a sequence of produced shapes Standard_EXPORT TopTools_SequenceOfShape& Shapes(); + //! Sets a Transfer Reader + Standard_EXPORT void initTransferReader(); + Standard_Boolean therootsta; TColStd_SequenceOfTransient theroots; diff --git a/src/XSControl/XSControl_TransferReader.cxx b/src/XSControl/XSControl_TransferReader.cxx index 245ce6fb52..0c0ddc2cb4 100644 --- a/src/XSControl/XSControl_TransferReader.cxx +++ b/src/XSControl/XSControl_TransferReader.cxx @@ -404,7 +404,16 @@ TopoDS_Shape XSControl_TransferReader::ShapeResult TopoDS_Shape sh = xu.BinderShape (mres->Binder()); // Ouh la vilaine verrue - Standard_Real tolang = Interface_Static::RVal("read.encoderegularity.angle"); + Standard_Real tolang; + Handle(Interface_Static) aParam = myModel->GetParam("read.encoderegularity.angle"); + if (aParam.IsNull()) + { + tolang = Interface_Static::RVal("read.encoderegularity.angle"); + } + else + { + tolang = aParam->RealValue(); + } if (tolang <= 0 || sh.IsNull()) return sh; ShapeFix::EncodeRegularity (sh,tolang); return sh; diff --git a/src/XSControl/XSControl_WorkSession.cxx b/src/XSControl/XSControl_WorkSession.cxx index 1f8caedac7..f2f14bb2b9 100644 --- a/src/XSControl/XSControl_WorkSession.cxx +++ b/src/XSControl/XSControl_WorkSession.cxx @@ -105,6 +105,7 @@ Standard_Boolean XSControl_WorkSession::SelectNorm(const Standard_CString normn void XSControl_WorkSession::SetController(const Handle(XSControl_Controller)& ctl) { myController = ctl; + SetModel(myController->NewModel()); SetLibrary ( myController->WorkLibrary() ); SetProtocol ( myController->Protocol() ); diff --git a/src/XSDRAWSTEP/XSDRAWSTEP.cxx b/src/XSDRAWSTEP/XSDRAWSTEP.cxx index 131bd6a129..232a4ae565 100644 --- a/src/XSDRAWSTEP/XSDRAWSTEP.cxx +++ b/src/XSDRAWSTEP/XSDRAWSTEP.cxx @@ -20,10 +20,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -63,6 +63,151 @@ static void cleanpilot () } } +static void initStatics() +{ + //Be carefull using this method and static map. + //For step files all this parameters initialises in the model. + //They are initialised here to avoid errors during using auxiliary + //functions to work with step files particulary function "param" in IFSelect_Functions.cxx. + //Do NOT USE Interface_Static methods for getting param values while reading step. + //If you need the parameters values use StepData_StepModel::GetParam method + Interface_Static::Init("step", "write.step.product.name", 't', "Open CASCADE STEP translator " OCC_VERSION_STRING); + Interface_Static::Init("step", "write.step.assembly", 'e', ""); + Interface_Static::Init("step", "write.step.assembly", '&', "enum 0"); + Interface_Static::Init("step", "write.step.assembly", '&', "eval Off"); + Interface_Static::Init("step", "write.step.assembly", '&', "eval On"); + Interface_Static::Init("step", "write.step.assembly", '&', "eval Auto"); + Interface_Static::SetCVal("write.step.assembly", "Auto"); + + Interface_Static::Init("step", "step.angleunit.mode", 'e', ""); + Interface_Static::Init("step", "step.angleunit.mode", '&', "enum 0"); + Interface_Static::Init("step", "step.angleunit.mode", '&', "eval File"); + Interface_Static::Init("step", "step.angleunit.mode", '&', "eval Rad"); + Interface_Static::Init("step", "step.angleunit.mode", '&', "eval Deg"); + Interface_Static::SetCVal("step.angleunit.mode", "File"); + + Interface_Static::Init("step", "write.step.schema", 'e', ""); + Interface_Static::Init("step", "write.step.schema", '&', "enum 1"); + Interface_Static::Init("step", "write.step.schema", '&', "eval AP214CD"); + Interface_Static::Init("step", "write.step.schema", '&', "eval AP214DIS"); + Interface_Static::Init("step", "write.step.schema", '&', "eval AP203"); + Interface_Static::Init("step", "write.step.schema", '&', "eval AP214IS"); + Interface_Static::Init("step", "write.step.schema", '&', "eval AP242DIS"); + Interface_Static::SetCVal("write.step.schema", "AP214IS"); + + // Type of Product Definition for reading + // Note: the numbers should be consistent with function FindShapeReprType() + // in STEPControl_ActorRead.cxx + Interface_Static::Init("step", "read.step.shape.repr", 'e', ""); + Interface_Static::Init("step", "read.step.shape.repr", '&', "enum 1"); + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval All"); // 1 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval ABSR"); // 2 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval MSSR"); // 3 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval GBSSR"); // 4 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval FBSR"); // 5 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval EBWSR"); // 6 + Interface_Static::Init("step", "read.step.shape.repr", '&', "eval GBWSR"); // 7 + Interface_Static::SetCVal("read.step.shape.repr", "All"); + + // Mode for reading shapes attached to main SDR by SRR + // (hybrid model representation in AP203 since 1998) + Interface_Static::Init("step", "read.step.shape.relationship", 'e', ""); + Interface_Static::Init("step", "read.step.shape.relationship", '&', "enum 0"); + Interface_Static::Init("step", "read.step.shape.relationship", '&', "eval OFF"); + Interface_Static::Init("step", "read.step.shape.relationship", '&', "eval ON"); + Interface_Static::SetCVal("read.step.shape.relationship", "ON"); + + // Mode for reading shapes attached to Product by ShapeAspect + // (hybrid model representation in AP203 before 1998) + Interface_Static::Init("step", "read.step.shape.aspect", 'e', ""); + Interface_Static::Init("step", "read.step.shape.aspect", '&', "enum 0"); + Interface_Static::Init("step", "read.step.shape.aspect", '&', "eval OFF"); + Interface_Static::Init("step", "read.step.shape.aspect", '&', "eval ON"); + Interface_Static::SetCVal("read.step.shape.aspect", "ON"); + + // Mode for reading SDR and ShapeRepr if it is necessary + Interface_Static::Init("step", "read.step.product.mode", 'e', ""); + Interface_Static::Init("step", "read.step.product.mode", '&', "enum 0"); + Interface_Static::Init("step", "read.step.product.mode", '&', "eval OFF"); + Interface_Static::Init("step", "read.step.product.mode", '&', "eval ON"); + Interface_Static::SetCVal("read.step.product.mode", "ON"); + + // Order of reading ShapeDefinitionRepresentation in ProductDefinition + Interface_Static::Init("step", "read.step.product.context", 'e', ""); + Interface_Static::Init("step", "read.step.product.context", '&', "enum 1"); + Interface_Static::Init("step", "read.step.product.context", '&', "eval all"); // 1 + Interface_Static::Init("step", "read.step.product.context", '&', "eval design"); // 2 + Interface_Static::Init("step", "read.step.product.context", '&', "eval analysis");// 3 + Interface_Static::SetCVal("read.step.product.context", "all"); + + // What we try to read in ProductDefinition + Interface_Static::Init("step", "read.step.assembly.level", 'e', ""); + Interface_Static::Init("step", "read.step.assembly.level", '&', "enum 1"); + Interface_Static::Init("step", "read.step.assembly.level", '&', "eval all"); // 1 + Interface_Static::Init("step", "read.step.assembly.level", '&', "eval assembly"); // 2 + Interface_Static::Init("step", "read.step.assembly.level", '&', "eval structure");// 3 + Interface_Static::Init("step", "read.step.assembly.level", '&', "eval shape"); // 4 + Interface_Static::SetCVal("read.step.assembly.level", "all"); + + // unit: supposed to be cascade unit (target unit for reading) + Interface_Static::Init("step", "write.step.unit", 'e', ""); + Interface_Static::Init("step", "write.step.unit", '&', "enum 1"); + Interface_Static::Init("step", "write.step.unit", '&', "eval INCH"); // 1 + Interface_Static::Init("step", "write.step.unit", '&', "eval MM"); // 2 + Interface_Static::Init("step", "write.step.unit", '&', "eval ??"); // 3 + Interface_Static::Init("step", "write.step.unit", '&', "eval FT"); // 4 + Interface_Static::Init("step", "write.step.unit", '&', "eval MI"); // 5 + Interface_Static::Init("step", "write.step.unit", '&', "eval M"); // 6 + Interface_Static::Init("step", "write.step.unit", '&', "eval KM"); // 7 + Interface_Static::Init("step", "write.step.unit", '&', "eval MIL"); // 8 + Interface_Static::Init("step", "write.step.unit", '&', "eval UM"); // 9 + Interface_Static::Init("step", "write.step.unit", '&', "eval CM"); //10 + Interface_Static::Init("step", "write.step.unit", '&', "eval UIN"); //11 + Interface_Static::SetCVal("write.step.unit", "MM"); + + // Non-manifold topology reading: OFF by default (ssv; 26.11.2010) + Interface_Static::Init("step", "read.step.nonmanifold", 'e', ""); + Interface_Static::Init("step", "read.step.nonmanifold", '&', "enum 0"); + Interface_Static::Init("step", "read.step.nonmanifold", '&', "eval Off"); + Interface_Static::Init("step", "read.step.nonmanifold", '&', "eval On"); + Interface_Static::SetIVal("read.step.nonmanifold", 0); + + // Non-manifold topology writing: OFF by default (ssv; 26.11.2010) + Interface_Static::Init("step", "write.step.nonmanifold", 'e', ""); + Interface_Static::Init("step", "write.step.nonmanifold", '&', "enum 0"); + Interface_Static::Init("step", "write.step.nonmanifold", '&', "eval Off"); + Interface_Static::Init("step", "write.step.nonmanifold", '&', "eval On"); + Interface_Static::SetIVal("write.step.nonmanifold", 0); + + // I-Deas-like STEP processing: OFF by default (ssv; 22.11.2010) + Interface_Static::Init("step", "read.step.ideas", 'e', ""); + Interface_Static::Init("step", "read.step.ideas", '&', "enum 0"); + Interface_Static::Init("step", "read.step.ideas", '&', "eval Off"); + Interface_Static::Init("step", "read.step.ideas", '&', "eval On"); + Interface_Static::SetIVal("read.step.ideas", 0); + + //Parameter to write all free vertices in one SDR (name and style of vertex are lost) (default) + //or each vertex in its own SDR (name and style of vertex are exported). (ika; 21.07.2014) + Interface_Static::Init("step", "write.step.vertex.mode", 'e', ""); + Interface_Static::Init("step", "write.step.vertex.mode", '&', "enum 0"); + Interface_Static::Init("step", "write.step.vertex.mode", '&', "eval One Compound"); + Interface_Static::Init("step", "write.step.vertex.mode", '&', "eval Single Vertex"); + Interface_Static::SetIVal("write.step.vertex.mode", 0); + + // abv 15.11.00: ShapeProcessing + Interface_Static::Init("XSTEP", "write.step.resource.name", 't', "STEP"); + Interface_Static::Init("XSTEP", "read.step.resource.name", 't', "STEP"); + Interface_Static::Init("XSTEP", "write.step.sequence", 't', "ToSTEP"); + Interface_Static::Init("XSTEP", "read.step.sequence", 't', "FromSTEP"); + + // ika 28.07.16: Paremeter to read all top level solids and shells, + // should be used only in case of invalid shape_representation without links to shapes. + Interface_Static::Init("step", "read.step.all.shapes", 'e', ""); + Interface_Static::Init("step", "read.step.all.shapes", '&', "enum 0"); + Interface_Static::Init("step", "read.step.all.shapes", '&', "eval Off"); + Interface_Static::Init("step", "read.step.all.shapes", '&', "eval On"); + Interface_Static::SetIVal("read.step.all.shapes", 0); +} //======================================================================= //function : Init @@ -71,13 +216,18 @@ static void cleanpilot () 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")); + static Standard_Boolean inic = Standard_False; + if (!inic) { + initStatics(); + Handle(STEPControl_Controller) aStepCtl = new STEPControl_Controller; + XSDRAW::SetController(aStepCtl); + inic = Standard_True; + } atexit (cleanpilot); } + // ######## COMMANDE stepread : teste le Reader ######### //======================================================================= @@ -93,15 +243,18 @@ static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_ } // On admet le controller AP214 ou une variante DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); - if (ctl.IsNull()) XSDRAW::SetNorm("STEP"); - + if (ctl.IsNull()) + { + ctl = new STEPControl_Controller; + XSDRAW::SetController(ctl); + } // Progress indicator Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); progress->SetScale ( 0, 100, 1 ); progress->Show(); - STEPControl_Reader sr (XSDRAW::Session(),Standard_False); + STEPControl_Reader sr (XSDRAW::Session(), ctl, Standard_False); TCollection_AsciiString fnom,rnom; Standard_Boolean modfic = XSDRAW::FileAndVar (argv[1],argv[2],"STEP",fnom,rnom); @@ -388,14 +541,13 @@ static Standard_Integer steptrans (Draw_Interpretor& di, Standard_Integer argc, static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { -// On admet le controller AP214 ou une variante - DeclareAndCast(STEPControl_Controller,ctl,XSDRAW::Controller()); - if (ctl.IsNull()) { - XSDRAW::SetNorm("STEP"); - //sln 14.01.2002 OCC51: assign new value to ctl in order to avoid exception during using one in the function - ctl = Handle(STEPControl_Controller)::DownCast(XSDRAW::Controller()); + // On admet le controller AP214 ou une variante + DeclareAndCast(STEPControl_Controller, ctl, XSDRAW::Controller()); + if (ctl.IsNull()) + { + ctl = new STEPControl_Controller; + XSDRAW::SetController(ctl); } - if (argc < 3) { di<<"Give mode[1-4] and Shape name + optional file. Mode possible\n"; di<<"f ou 1 : FacettedBRep s ou 2 : ShellBasedSurfaceModel\n" @@ -417,16 +569,15 @@ static Standard_Integer stepwrite (Draw_Interpretor& di, Standard_Integer argc, default : di<<"1st arg = mode, incorrect [give fsmw]\n"; return 1; } - //:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes) - 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); - Handle(Interface_InterfaceModel) stepmodel = sw.Model(); + STEPControl_Writer sw (XSDRAW::Session(), ctl, Standard_False); + Handle(StepData_StepModel) stepmodel = sw.Model(); Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities()); + //:k8 abv 6 Jan 98: using parameter for writing mode (assemblies/shapes) + Handle(STEPControl_ActorWrite) ActWrite = + Handle(STEPControl_ActorWrite)::DownCast(sw.WS()->NormAdaptor()->ActorWrite()); + if (!ActWrite.IsNull()) + ActWrite->SetGroupMode("write.step.assembly"); Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 ); progress->NewScope(90,"Translating"); diff --git a/tests/bugs/xde/bug23597 b/tests/bugs/xde/bug23597 index aef90adef9..25a8960416 100755 --- a/tests/bugs/xde/bug23597 +++ b/tests/bugs/xde/bug23597 @@ -13,10 +13,9 @@ if { [file exists ${filedir}/${TheFileName}.stp] } { puts "Error : There is old ${filedir}/${TheFileName}.stp file" } -xnorm STEP restore [locate_data_file ${TheFileName}.brep] f param write.step.unit FT -newmodel + stepwrite a f ${filedir}/${TheFileName}.stp if { ![file exists ${filedir}/${TheFileName}.stp] } { -- 2.39.5