]> OCCT Git - occt.git/commitdiff
0033589: Data Exchange, Step Export - Using thread-safety interface ignore model... CR33589_1
authordpasukhi <dpasukhi@opencascade.com>
Mon, 29 Jan 2024 11:02:23 +0000 (11:02 +0000)
committerichesnok <ichesnok@opencascade.com>
Wed, 14 Feb 2024 16:46:32 +0000 (16:46 +0000)
Fixed issue with MakeHeader.
Fix isn't for review or integration. Only for the internal usage.
Need to adapt into work env.

13 files changed:
src/APIHeaderSection/APIHeaderSection_MakeHeader.cxx
src/STEPCAFControl/STEPCAFControl_ConfigurationNode.cxx
src/STEPCAFControl/STEPCAFControl_Provider.cxx
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPControl/STEPControl_Writer.cxx
src/StepAP214/StepAP214_Protocol.cxx
src/StepAP214/StepAP214_Protocol.hxx
src/StepData/StepData_Protocol.cxx
src/StepData/StepData_Protocol.hxx
src/XSControl/XSControl_TransferReader.cxx
src/XSControl/XSControl_TransferReader.hxx
src/XSControl/XSControl_TransferWriter.cxx
src/XSControl/XSControl_TransferWriter.hxx

index 9f90004ff9488a51b23b85d9d243ac8587dde906..1421261c5d907d032a3469e1ef0456ec76087103 100644 (file)
@@ -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);
index 20b2cffba551e4a2c1819aea97445b7313d0f7c2..926bff40d28b084cfebcfb697dac674e8e1f4678 100644 (file)
@@ -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;
 }
index 2fc66826668c0e8a1678e6a5cecbf3a93daf5ca0..e9b1ab1aba937f2adba6651f97ea7da1f11aa260 100644 (file)
@@ -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;
 }
 
index 9d4a3fc2208dda3e760bd2f06f9f81ee1946711c..8f7ba42fae9f4128e83b27157efeec845d6d35b8 100644 (file)
@@ -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;
index e16cb584c3429481cbf9b09e64f0dec3f87d9d62..fea49477a4fa70423222c3c9168b6fcb1a07cf0f 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <STEPControl_Writer.hxx>
 
+#include <APIHeaderSection_MakeHeader.hxx>
 #include <Interface_InterfaceModel.hxx>
 #include <Interface_Macros.hxx>
 #include <STEPControl_ActorWrite.hxx>
@@ -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());
index 16643aa1784d219b13b18b10dc5fda70eafd417f..e2d528c58bfb808927c60096c338f7c76a72203f 100644 (file)
@@ -27,6 +27,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
 
 #include <HeaderSection_Protocol.hxx>
 
+#include <StepData_StepModel.hxx>
 #include <StepShape_AdvancedBrepShapeRepresentation.hxx>
 #include <StepShape_AdvancedFace.hxx>
 // Removed from CC1-Rev2 to Rev4 : <StepVisual_AnnotationCurveOccurrence.hxx>
@@ -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  : 
index 988c55c8b50b17368fe946a927ba9ffcc4e14eb5..1a6971d6f75b8c4d6200e63eeda68769abb181e8 100644 (file)
@@ -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)
index 330299ccd7d735b892616e8d6ff3f954bfe35df1..3a5bd7859b18de6c869f34b390d969036bddd28e 100644 (file)
@@ -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;
 }
 
index 65f975efefb3e59bd46f1cba0662c28ec1ae75d8..2266673ad64bd2e58913be1134e6e59878140479 100644 (file)
@@ -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
index 4d55b92b6ea15091b5fef2e182edf2fba64ddf5a..10cf9f4187ee188fa752741efc01d762eccbf321 100644 (file)
@@ -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;
index 9cebdeb5d10b53974580376c593b312eab66dee8..642a0e6aa578d2066dc38294fe7f8703041fa1c1 100644 (file)
@@ -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
index ec6871d8f7e809bc1a71ecf00b3bac24e069068e..b8b97d23a48aa23826eae1134d641cc067ec1abf 100644 (file)
@@ -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;
index ba1394e112d1ac7ac2eccdf75abc8bb033f88837..a7f71fb59eec47e112dd322d30ced591a1c28462 100644 (file)
@@ -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