Salome HOME
Merge branch 'agy/intersect_1D'
authorgeay <anthony.geay@cea.fr>
Fri, 4 Jul 2014 13:08:13 +0000 (15:08 +0200)
committergeay <anthony.geay@cea.fr>
Fri, 4 Jul 2014 13:08:13 +0000 (15:08 +0200)
doc/doxygen/doxfiles/tools.dox
src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx
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 8bcba7cd2b2f4b2d5649eedbd83ef3721cbba12e..2b16d2ae7f030304638e418356d94fe20d8e9f72 100644 (file)
@@ -86,6 +86,9 @@ sauv2med myfile.sauv
 \endcode
 generates a \a med file named \a myfile.sauv.med
 
+An optional argument -\-fix2DOri enables an attempt to orient adjacent 
+faces equally in 3D space.
+
 \section med2sauv med2sauv tool
 
 med2sauv operator is the operator that is inverse of sauv2med. Its
index d4a74a34d02fb9fee83836345e86b7e37724f5c8..7f9b405ff187f83d351f8470227574fe8b0f65b1 100644 (file)
@@ -879,7 +879,7 @@ bool FindInflection(const INTERP_KERNEL::BoxSplittingOptions& bso, const Interna
 
       // Gradient absolute value
       for(std::size_t i=1;i<derivate_second_order.size();i++)
-        gradient_absolute.push_back(fabs(derivate_second_order[i]-derivate_second_order[i-1])) ;
+        gradient_absolute.push_back(abs(derivate_second_order[i]-derivate_second_order[i-1])) ;
       if(derivate_second_order.empty())
         continue;
       for(std::size_t i=1;i<derivate_second_order.size()-1;i++)
index ad4668c12f7bcdde5c333929de3eda18b14bf7e0..a8fb6db55e41d3a29d97ffa8d72c7f047a9b6a9a 100644 (file)
@@ -2373,12 +2373,14 @@ Group* IntermediateMED::addNewGroup(std::vector<SauvUtilities::Group*>* groupsTo
 //================================================================================
 /*!
  * \brief Makes ParaMEDMEM::MEDFileData from self
+ *  \param [in] fix2DOri - to fix or not orientation of faces in 3D space
+ *  \return ParaMEDMEM::MEDFileData* - conversion result
  */
 //================================================================================
 
-ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS()
+ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS(bool fix2DOri)
 {
-  MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh >  mesh   = makeMEDFileMesh();
+  MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh >  mesh   = makeMEDFileMesh(fix2DOri);
   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 fix2DOri)
 {
   // 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( fix2DOri );
 
   // process groups
   decreaseHierarchicalDepthOfSubgroups();
@@ -2728,10 +2730,11 @@ void IntermediateMED::orientElements2D()
  */
 //================================================================================
 
-void IntermediateMED::orientElements3D()
+void IntermediateMED::orientElements3D(bool fix2DOri)
 {
   // set _reverse flags of faces
-  orientFaces3D();
+  if ( fix2DOri )
+    orientFaces3D();
 
   // -----------------
   // fix connectivity
@@ -3238,10 +3241,10 @@ void IntermediateMED::setGroups( ParaMEDMEM::MEDFileUMesh* mesh )
           grp._medGroup = DataArrayInt::New();
           grp._medGroup->setName( grp._name.c_str() );
           grp._medGroup->alloc( cell2order.size(), /*nbOfCompo=*/1 );
-          int * idsPrt = grp._medGroup->getPointer();
+          int * idsPtr = grp._medGroup->getPointer();
           TCellToOrderMap::iterator cell2orderIt, cell2orderEnd = cell2order.end();
           for ( cell2orderIt = cell2order.begin(); cell2orderIt != cell2orderEnd; ++cell2orderIt )
-            *idsPrt++ = (*cell2orderIt).first->_number - 1;
+            *idsPtr++ = (*cell2orderIt).first->_number - 1;
 
           // try to set the mesh name
           if ( !isMeshNameSet &&
@@ -3457,8 +3460,9 @@ void IntermediateMED::setTS( SauvUtilities::DoubleField*  fld,
   // set gauss points
   if ( timeStamp->getTypeOfField() == ParaMEDMEM::ON_GAUSS_PT )
     {
-      TGaussDef gaussDef( support->_cellType, fld->_sub[iSub].nbGauss() );
-      timeStamp->setGaussLocalizationOnType( support->_cellType,
+      TGaussDef gaussDef( fld->_sub[iSub]._support->_cellType,
+                          fld->_sub[iSub].nbGauss() );
+      timeStamp->setGaussLocalizationOnType( fld->_sub[iSub]._support->_cellType,
                                              gaussDef.myRefCoords,
                                              gaussDef.myCoords,
                                              gaussDef.myWeights );
index ebaf41919957960f3aea58a4ada921414a53fd1a..efd55aa1f2a0e4c1f199da650dde7293b12f98b0 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 fix2DOri);
 
   private:
 
-    ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh();
+    ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh(bool fix2DOri);
     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 fix2DOri);
     void orientFaces3D();
     void orientVolumes();
     void numberElements();
index 96281f0ad897dad0d40e954f091b3672745d92f4..a943bcf2d9be379f7c1da4d707c95793ab0b1684 100644 (file)
@@ -112,7 +112,7 @@ std::string SauvReader::lineNb() const
  */
 //================================================================================
 
-ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS()
+ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS(bool fix2DOri)
 {
   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( fix2DOri );
 
   return medFileData;
 }
@@ -384,7 +384,7 @@ void SauvReader::read_PILE_SOUS_MAILLAGE(const int                 nbObjects,
       else
         for (initIntReading(nbElements); more(); next());
 
-      // not a composit group
+      // not a composite group
       if (castemCellType>0 && nbSubGroups==0)
         {
           group._cellType = SauvUtilities::gibi2medGeom(castemCellType);
@@ -638,7 +638,7 @@ void SauvReader::read_PILE_COORDONNEES (const int nbObjects, std::vector<std::st
 
 //================================================================================
 /*!
- * \brief Finds or create a Group equal to a given field support 
+ * \brief Find or create a Group equal to a given field support
  */
 //================================================================================
 
@@ -647,7 +647,7 @@ void SauvReader::setFieldSupport(const vector<SauvUtilities::Group*>& supports,
 {
   SauvUtilities::Group* group = NULL;
   set<SauvUtilities::Group*> sup_set( supports.begin(), supports.end() );
-  if (sup_set.size() == 1 ) // one or equal supports
+  if ( sup_set.size() == 1 ) // one or equal supports
     {
       group = supports[0];
     }
@@ -715,7 +715,7 @@ void SauvReader::setFieldSupport(const vector<SauvUtilities::Group*>& supports,
           // relocate sub-components according to a new order of groups
           if ( isModified )
             {
-              vector< DoubleField::_Sub_data > newSub( field->_sub.size() );
+              vector< DoubleField::_Sub_data > newSub   ( field->_sub.size() );
               vector< vector< double > >       newValues( field->_comp_values.size() );
               size_t iFromSub = 0, iNewSub = 0, iNewComp = 0;
               for ( ; iFromSub < field->_sub.size(); iFromSub += groups.size() )
index 533ae0ba451f801456050f6054fd36b1689a63f2..1a07854e6d89a6dfdbda229e8f51f489582982ec 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 fix2DOri=false);
   MEDLOADER_EXPORT ~SauvReader();
 
  private:
index 7a53ab79b46b65fcb48c4c4d134a0d2df767b793..5c3c7c81150c9ed0e928a1dadbad6074b10befb3 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 fix2DOri=false) throw(INTERP_KERNEL::Exception);
     %extend
     {
       SauvReader(const std::string& fileName) throw(INTERP_KERNEL::Exception)
index 98c06bf197e2fe72ea094655ddf88ec84fa70ed8..06fa149f6ac805740541191c1003eeef64189691 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)
+    fix2DOri = ( "--fix2DOri" in argv )
     for arg in argv:
-        convert(arg, "GIBI", "MED")
+        if not arg.startswith("--fix"):
+            convert(arg, "GIBI", "MED", format = fix2DOri)
         pass
     return