From: dpasukhi Date: Mon, 29 Jan 2024 11:02:23 +0000 (+0000) Subject: 0033589: Data Exchange, Step Export - Using thread-safety interface ignore model... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=2344ac47ec08d47d034d64c0e0ed8f7d8e27376b;p=occt.git 0033589: Data Exchange, Step Export - Using thread-safety interface ignore model schema Fixed issue with MakeHeader. Fix isn't for review or integration. Only for the internal usage. Need to adapt into work env. --- diff --git a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx b/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx index 9f90004ff9..1421261c5d 100644 --- a/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx +++ b/src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx @@ -162,7 +162,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)); if (!sch.IsNull()) schid->SetValue (1,sch); } header.AddItem(fs); diff --git a/src/STEPCAFControl/STEPCAFControl_ConfigurationNode.cxx b/src/STEPCAFControl/STEPCAFControl_ConfigurationNode.cxx index 20b2cffba5..926bff40d2 100644 --- a/src/STEPCAFControl/STEPCAFControl_ConfigurationNode.cxx +++ b/src/STEPCAFControl/STEPCAFControl_ConfigurationNode.cxx @@ -151,6 +151,8 @@ bool STEPCAFControl_ConfigurationNode::Load(const Handle(DE_ConfigurationContext theResource->BooleanVal("write.props", InternalParameters.WriteProps, aScope); InternalParameters.WriteModelType = (STEPControl_StepModelType) theResource->IntegerVal("write.model.type", InternalParameters.WriteModelType, aScope); + InternalParameters.WriteNonmanifold = + theResource->IntegerVal("write.nonmanifold", InternalParameters.WriteNonmanifold, aScope); return true; } diff --git a/src/STEPCAFControl/STEPCAFControl_Provider.cxx b/src/STEPCAFControl/STEPCAFControl_Provider.cxx index 2fc6682666..e9b1ab1aba 100644 --- a/src/STEPCAFControl/STEPCAFControl_Provider.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Provider.cxx @@ -74,12 +74,12 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath, aReader.SetLayerMode(aNode->InternalParameters.ReadLayer); aReader.SetPropsMode(aNode->InternalParameters.ReadProps); IFSelect_ReturnStatus aReadStat = IFSelect_RetVoid; - StepData_ConfParameters aParams; - aReadStat = aReader.ReadFile(thePath.ToCString(), aParams); + aReadStat = aReader.ReadFile(thePath.ToCString(), aNode->InternalParameters); if (aReadStat != IFSelect_RetDone) { Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " << thePath << "\t: abandon"; + aNode->InternalParameters.Reset(); return false; } @@ -87,8 +87,10 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath, { Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " << thePath << "\t: Cannot read any relevant data from the STEP file"; + aNode->InternalParameters.Reset(); return false; } + aNode->InternalParameters.Reset(); return true; } @@ -122,13 +124,13 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath, aWriter.SetNameMode(aNode->InternalParameters.WriteName); aWriter.SetLayerMode(aNode->InternalParameters.WriteLayer); aWriter.SetPropsMode(aNode->InternalParameters.WriteProps); - + aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter)); TDF_Label aLabel; - StepData_ConfParameters aParams; - if (!aWriter.Transfer(theDocument, aParams, aMode, 0, theProgress)) + if (!aWriter.Transfer(theDocument, aNode->InternalParameters, aMode, 0, theProgress)) { Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " << thePath << "\t: The document cannot be translated or gives no result"; + aNode->InternalParameters.Reset(); return false; } IFSelect_ReturnStatus aStatus = aWriter.Write(thePath.ToCString()); @@ -138,6 +140,7 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath, { Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " << thePath << "\t: No file written"; + aNode->InternalParameters.Reset(); return false;; } case IFSelect_RetDone: @@ -148,9 +151,11 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath, { Message::SendFail() << "Error in the STEPCAFControl_Provider during writing the file " << thePath << "\t: Error on writing file"; + aNode->InternalParameters.Reset(); return false; } } + aNode->InternalParameters.Reset(); return true; } @@ -199,13 +204,13 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath, STEPControl_Reader aReader; aReader.SetWS(theWS); IFSelect_ReturnStatus aReadstat = IFSelect_RetVoid; - StepData_ConfParameters aParams; - aReadstat = aReader.ReadFile(thePath.ToCString(), aParams); + aReadstat = aReader.ReadFile(thePath.ToCString(), aNode->InternalParameters); Handle(StepData_StepModel) aModel = aReader.StepModel(); if (aReadstat != IFSelect_RetDone) { Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " << thePath << "\t: abandon, no model loaded"; + aNode->InternalParameters.Reset(); return false; } aModel->SetLocalLengthUnit(aNode->GlobalParameters.LengthUnit); @@ -213,9 +218,11 @@ bool STEPCAFControl_Provider::Read(const TCollection_AsciiString& thePath, { Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " << thePath << "\t:Cannot read any relevant data from the STEP file"; + aNode->InternalParameters.Reset(); return false; } theShape = aReader.OneShape(); + aNode->InternalParameters.Reset(); return true; } @@ -242,19 +249,21 @@ bool STEPCAFControl_Provider::Write(const TCollection_AsciiString& thePath, IFSelect_ReturnStatus aWritestat = IFSelect_RetVoid; Handle(StepData_StepModel) aModel = aWriter.Model(); aModel->SetWriteLengthUnit(UnitsMethods::GetLengthUnitScale(aNode->InternalParameters.WriteUnit, UnitsMethods_LengthUnit_Millimeter)); - StepData_ConfParameters aParams; - aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, aParams, true, theProgress); + aWritestat = aWriter.Transfer(theShape, aNode->InternalParameters.WriteModelType, aNode->InternalParameters, true, theProgress); if (aWritestat != IFSelect_RetDone) { Message::SendFail() << "Error in the STEPCAFControl_Provider during reading the file " << thePath << "\t: abandon, no model loaded"; + aNode->InternalParameters.Reset(); return false; } if (aWriter.Write(thePath.ToCString()) != IFSelect_RetDone) { Message::SendFail() << "STEPCAFControl_Provider: Error on writing file"; + aNode->InternalParameters.Reset(); return false; } + aNode->InternalParameters.Reset(); return true; } diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 9d4a3fc220..8f7ba42fae 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -573,6 +573,7 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader, { reader.ClearShapes(); Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(reader.Model()); + myReader.WS()->TransferReader()->SetEncodeRegAngle(aModel->InternalParameters.EncodeRegAngle); StepData_Factors aLocalFactors; prepareUnits(aModel, doc, aLocalFactors); Standard_Integer i; diff --git a/src/STEPControl/STEPControl_Writer.cxx b/src/STEPControl/STEPControl_Writer.cxx index e16cb584c3..fea49477a4 100644 --- a/src/STEPControl/STEPControl_Writer.cxx +++ b/src/STEPControl/STEPControl_Writer.cxx @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -162,7 +163,12 @@ IFSelect_ReturnStatus STEPControl_Writer::Transfer } if (!thesession->Model().IsNull()) { - Handle(StepData_StepModel)::DownCast(thesession->Model())->InternalParameters = theParams; + Handle(StepData_StepModel) aStepModel = Handle(StepData_StepModel)::DownCast(thesession->Model()); + aStepModel->InternalParameters = theParams; + thesession->TransferWriter()->SetNonmanifoldMode(aStepModel->InternalParameters.WriteNonmanifold); + aStepModel->ClearHeader(); + APIHeaderSection_MakeHeader aHeaderApi; + aHeaderApi.Apply(aStepModel); } Handle(STEPControl_ActorWrite) ActWrite = Handle(STEPControl_ActorWrite)::DownCast(WS()->NormAdaptor()->ActorWrite()); diff --git a/src/StepAP214/StepAP214_Protocol.cxx b/src/StepAP214/StepAP214_Protocol.cxx index 16643aa178..e2d528c58b 100644 --- a/src/StepAP214/StepAP214_Protocol.cxx +++ b/src/StepAP214/StepAP214_Protocol.cxx @@ -27,6 +27,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI #include +#include #include #include // Removed from CC1-Rev2 to Rev4 : @@ -1577,6 +1578,38 @@ Handle(Standard_Type)& atype) const } +//======================================================================= +//function : SchemaName +//purpose : +//======================================================================= +Standard_CString StepAP214_Protocol::SchemaName(const Handle(Interface_InterfaceModel)& theModel) const +{ + Handle(StepData_StepModel) aModel = Handle(StepData_StepModel)::DownCast(theModel); + if (aModel.IsNull()) + { + return ""; + } + switch (aModel->InternalParameters.WriteSchema) + { + case StepData_ConfParameters::WriteMode_StepSchema_AP214CD: + return schemaAP214CD; + break; + case StepData_ConfParameters::WriteMode_StepSchema_AP214DIS: + return schemaAP214DIS; + break; + case StepData_ConfParameters::WriteMode_StepSchema_AP203: + return schemaAP203; + break; + case StepData_ConfParameters::WriteMode_StepSchema_AP214IS: + return schemaAP214IS; + break; + case StepData_ConfParameters::WriteMode_StepSchema_AP242DIS: + return schemaAP242DIS; + break; + } + return ""; +} + //======================================================================= //function : SchemaName //purpose : diff --git a/src/StepAP214/StepAP214_Protocol.hxx b/src/StepAP214/StepAP214_Protocol.hxx index 988c55c8b5..1a6971d6f7 100644 --- a/src/StepAP214/StepAP214_Protocol.hxx +++ b/src/StepAP214/StepAP214_Protocol.hxx @@ -42,6 +42,8 @@ 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 Handle(Interface_InterfaceModel)& theModel) const Standard_OVERRIDE; + Standard_EXPORT virtual Standard_CString SchemaName() const Standard_OVERRIDE; //! Returns count of Protocol used as Resources (level one) diff --git a/src/StepData/StepData_Protocol.cxx b/src/StepData/StepData_Protocol.cxx index 330299ccd7..3a5bd7859b 100644 --- a/src/StepData/StepData_Protocol.cxx +++ b/src/StepData/StepData_Protocol.cxx @@ -67,9 +67,14 @@ Standard_Integer StepData_Protocol::TypeNumber return 0; } +Standard_CString StepData_Protocol::SchemaName() const +{ + return thename; +} -Standard_CString StepData_Protocol::SchemaName () const +Standard_CString StepData_Protocol::SchemaName (const Handle(Interface_InterfaceModel)& theModel) const { + (void)theModel; return thename; } diff --git a/src/StepData/StepData_Protocol.hxx b/src/StepData/StepData_Protocol.hxx index 65f975efef..2266673ad6 100644 --- a/src/StepData/StepData_Protocol.hxx +++ b/src/StepData/StepData_Protocol.hxx @@ -67,6 +67,8 @@ public: //! To be redefined by each sub-class //! Here, SchemaName returns "(DEFAULT)" //! was C++ : return const + Standard_EXPORT virtual Standard_CString SchemaName(const Handle(Interface_InterfaceModel)& theModel) const; + Standard_EXPORT virtual Standard_CString SchemaName() const; //! Creates an empty Model for Step Norm diff --git a/src/XSControl/XSControl_TransferReader.cxx b/src/XSControl/XSControl_TransferReader.cxx index 4d55b92b6e..10cf9f4187 100644 --- a/src/XSControl/XSControl_TransferReader.cxx +++ b/src/XSControl/XSControl_TransferReader.cxx @@ -399,7 +399,7 @@ 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 = EncodeRegAngle(); if (tolang <= 0 || sh.IsNull()) return sh; ShapeFix::EncodeRegularity (sh,tolang); return sh; diff --git a/src/XSControl/XSControl_TransferReader.hxx b/src/XSControl/XSControl_TransferReader.hxx index 9cebdeb5d1..642a0e6aa5 100644 --- a/src/XSControl/XSControl_TransferReader.hxx +++ b/src/XSControl/XSControl_TransferReader.hxx @@ -65,6 +65,7 @@ class XSControl_TransferReader : public Standard_Transient //! Creates a TransferReader, empty XSControl_TransferReader() + : myEncodeRegAngle(0.01) {} //! Sets a Controller. It is required to generate the Actor. @@ -113,6 +114,14 @@ class XSControl_TransferReader : public Standard_Transient //! Returns actual value of file name Standard_CString FileName() const { return myFileName.ToCString(); } + + //! Sets value for EncodeRegularityAngle + void SetEncodeRegAngle(const Standard_Real theEncRegAngle) + { myEncodeRegAngle = theEncRegAngle; } + + //! Returns value of EncodeRegularityAngle + Standard_Real EncodeRegAngle() const + { return myEncodeRegAngle; } //! Clears data, according mode : //! -1 all @@ -359,6 +368,7 @@ class XSControl_TransferReader : public Standard_Transient Handle(Transfer_TransientProcess) myTP; TColStd_DataMapOfIntegerTransient myResults; Handle(TopTools_HSequenceOfShape) myShapeResult; + Standard_Real myEncodeRegAngle; }; #endif // _XSControl_TransferReader_HeaderFile diff --git a/src/XSControl/XSControl_TransferWriter.cxx b/src/XSControl/XSControl_TransferWriter.cxx index ec6871d8f7..b8b97d23a4 100644 --- a/src/XSControl/XSControl_TransferWriter.cxx +++ b/src/XSControl/XSControl_TransferWriter.cxx @@ -141,7 +141,7 @@ IFSelect_ReturnStatus XSControl_TransferWriter::TransferWriteShape if (theModel.IsNull()) return IFSelect_RetVoid; TopoDS_Shape aShape = theShape; - Standard_Boolean isNMMode = Interface_Static::IVal("write.step.nonmanifold") != 0; + Standard_Boolean isNMMode = NonmanifoldMode() != 0; if (isNMMode) { ShapeUpgrade_RemoveLocations aRemLoc; diff --git a/src/XSControl/XSControl_TransferWriter.hxx b/src/XSControl/XSControl_TransferWriter.hxx index ba1394e112..a7f71fb59e 100644 --- a/src/XSControl/XSControl_TransferWriter.hxx +++ b/src/XSControl/XSControl_TransferWriter.hxx @@ -46,7 +46,8 @@ class XSControl_TransferWriter : public Standard_Transient //! with an empty FinderProcess (but no controller, etc) XSControl_TransferWriter() : myTransferWriter(new Transfer_FinderProcess), - myTransferMode(0) + myTransferMode(0), + myNonmanifoldMode(0) {} //! Returns the FinderProcess itself @@ -84,6 +85,14 @@ class XSControl_TransferWriter : public Standard_Transient void SetTransferMode (const Standard_Integer theMode) { myTransferMode = theMode; } + //! Returns Nonmanifold Mode + Standard_Integer NonmanifoldMode() const + { return myNonmanifoldMode; } + + //! Changes Nonmanifold Mode + void SetNonmanifoldMode (const Standard_Integer theNonmMode) + { myNonmanifoldMode = theNonmMode; } + //! Prints statistics on current Trace File, according what,mode //! See PrintStatsProcess for details Standard_EXPORT void PrintStats (const Standard_Integer theWhat, const Standard_Integer theMode = 0) const; @@ -134,6 +143,7 @@ class XSControl_TransferWriter : public Standard_Transient Handle(XSControl_Controller) myController; Handle(Transfer_FinderProcess) myTransferWriter; Standard_Integer myTransferMode; + Standard_Integer myNonmanifoldMode; }; #endif // _XSControl_TransferWriter_HeaderFile