Salome HOME
22612: [CEA 1189] sauv2med should not change faces orientation
authoreap <eap@opencascade.com>
Thu, 26 Jun 2014 10:35:20 +0000 (14:35 +0400)
committereap <eap@opencascade.com>
Thu, 26 Jun 2014 10:35:20 +0000 (14:35 +0400)
  An optional argument --keep2DOri has been added to sauv2med utility that, if provided,
  disables reversing mesh faces in 3D space.

src/MEDLoader/SauvMedConvertor.cxx
src/MEDLoader/SauvMedConvertor.hxx
src/MEDLoader/SauvReader.cxx
src/MEDLoader/SauvReader.hxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/medutilities.py

index 3a6d8451ae2a57d0fed9612435f7a629c290ff9f..4c9caf41ffddc3c90c2edae72a51327b691eddc2 100644 (file)
@@ -2373,12 +2373,14 @@ Group* IntermediateMED::addNewGroup(std::vector<SauvUtilities::Group*>* groupsTo
 //================================================================================
 /*!
  * \brief Makes ParaMEDMEM::MEDFileData from self
+ *  \param [in] keep2DOri - to keep or not orientation of faces in 3D space
+ *  \return ParaMEDMEM::MEDFileData* - conversion result
  */
 //================================================================================
 
-ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS()
+ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS(bool keep2DOri)
 {
-  MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh >  mesh   = makeMEDFileMesh();
+  MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh >  mesh   = makeMEDFileMesh(keep2DOri);
   MEDCouplingAutoRefCountObjectPtr< MEDFileFields > fields = makeMEDFileFields(mesh);
 
   MEDCouplingAutoRefCountObjectPtr< MEDFileMeshes > meshes = MEDFileMeshes::New();
@@ -2396,7 +2398,7 @@ ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS()
  */
 //================================================================================
 
-ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh()
+ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh(bool keep2DOri)
 {
   // check if all needed piles are present
   checkDataAvailability();
@@ -2408,7 +2410,7 @@ ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh()
   if ( _spaceDim == 2 || _spaceDim == 1 )
     orientElements2D();
   else if ( _spaceDim == 3 )
-    orientElements3D();
+    orientElements3D( keep2DOri );
 
   // process groups
   decreaseHierarchicalDepthOfSubgroups();
@@ -2728,10 +2730,11 @@ void IntermediateMED::orientElements2D()
  */
 //================================================================================
 
-void IntermediateMED::orientElements3D()
+void IntermediateMED::orientElements3D(bool keep2DOri)
 {
   // set _reverse flags of faces
-  orientFaces3D();
+  if ( !keep2DOri )
+    orientFaces3D();
 
   // -----------------
   // fix connectivity
index ebaf41919957960f3aea58a4ada921414a53fd1a..7d076876feb713ff4e3224e491541267cd284e1a 100644 (file)
@@ -255,11 +255,12 @@ namespace SauvUtilities
     int getNbCellsOfType( TCellType type ) const { return _cellsByType[type].size(); }
     const Cell* insert(TCellType type, const Cell& ma) { return &( *_cellsByType[type].insert( ma ).first ); }
     Group* addNewGroup(std::vector<SauvUtilities::Group*>* groupsToFix=0);
-    ParaMEDMEM::MEDFileData* convertInMEDFileDS();
+
+    ParaMEDMEM::MEDFileData* convertInMEDFileDS(bool keep2DOri);
 
   private:
 
-    ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh();
+    ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh(bool keep2DOri);
     ParaMEDMEM::DataArrayDouble * getCoords();
     void setConnectivity( ParaMEDMEM::MEDFileUMesh* mesh, ParaMEDMEM::DataArrayDouble* coords );
     void setGroups( ParaMEDMEM::MEDFileUMesh* mesh );
@@ -283,7 +284,7 @@ namespace SauvUtilities
     void eraseUselessGroups();
     void detectMixDimGroups();
     void orientElements2D();
-    void orientElements3D();
+    void orientElements3D(bool keep2DOri);
     void orientFaces3D();
     void orientVolumes();
     void numberElements();
index 9b0fce3b8693f17e86cef8f31260ffeb2db73f52..65b24cca992a3c34af933c669fb67365c5162a33 100644 (file)
@@ -112,7 +112,7 @@ std::string SauvReader::lineNb() const
  */
 //================================================================================
 
-ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS()
+ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS(bool keep2DOri)
 {
   SauvUtilities::IntermediateMED iMed; // intermadiate DS
   _iMed = &iMed;
@@ -146,7 +146,7 @@ ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS()
           THROW_IK_EXCEPTION("XDR : ENREGISTREMENT DE TYPE " << recordNumber << " not implemented!!!");
     }
 
-  ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS();
+  ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS( keep2DOri );
 
   return medFileData;
 }
index 533ae0ba451f801456050f6054fd36b1689a63f2..bc0ae764b444b440a6492c0002bf6118310f4010 100644 (file)
@@ -47,7 +47,7 @@ class SauvReader : public ParaMEDMEM::RefCountObject
 {
  public:
   MEDLOADER_EXPORT static SauvReader* New(const std::string& fileName);
-  MEDLOADER_EXPORT ParaMEDMEM::MEDFileData * loadInMEDFileDS();
+  MEDLOADER_EXPORT ParaMEDMEM::MEDFileData * loadInMEDFileDS(bool keep2DOri=false);
   MEDLOADER_EXPORT ~SauvReader();
 
  private:
index 7a53ab79b46b65fcb48c4c4d134a0d2df767b793..3b44ba2183613c50e738073676d5b31e3d383b92 100644 (file)
@@ -2841,7 +2841,7 @@ namespace ParaMEDMEM
   {
   public:
     static SauvReader* New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
-    MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception);
+    MEDFileData * loadInMEDFileDS(bool keep2DOri=false) throw(INTERP_KERNEL::Exception);
     %extend
     {
       SauvReader(const std::string& fileName) throw(INTERP_KERNEL::Exception)
index 98c06bf197e2fe72ea094655ddf88ec84fa70ed8..c99898e0c4d6de45a300a60ebad6ff14c6efc954 100644 (file)
@@ -49,7 +49,7 @@ def convert(file_in, driver_in, driver_out, format=1, file_out=None):
     #
     if driver_in == "GIBI":
         sr = SauvReader.New(file_in)
-        mfd= sr.loadInMEDFileDS()
+        mfd= sr.loadInMEDFileDS( format )
         pass
     elif driver_in == "MED":
         mfd = MEDFileData(file_in)
@@ -110,9 +110,10 @@ def convert(file_in, driver_in, driver_out, format=1, file_out=None):
         raise NotImplementedError("Driver in %s is unknown"%(driver_in))
 
 def sauv2med(*argv):
-    argv = list(argv)
+    keep2DOri = ( "--keep2DOri" in argv )
     for arg in argv:
-        convert(arg, "GIBI", "MED")
+        if not arg.startswith("--keep"):
+            convert(arg, "GIBI", "MED", format = keep2DOri)
         pass
     return