From: eap Date: Thu, 26 Jun 2014 10:35:20 +0000 (+0400) Subject: 22612: [CEA 1189] sauv2med should not change faces orientation X-Git-Tag: V7_5_0a1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fmed.git;a=commitdiff_plain;h=5e550e9515cc431f91c7bfb32d22de6f697e82e3 22612: [CEA 1189] sauv2med should not change faces orientation An optional argument --keep2DOri has been added to sauv2med utility that, if provided, disables reversing mesh faces in 3D space. --- diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index 3a6d8451a..4c9caf41f 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -2373,12 +2373,14 @@ Group* IntermediateMED::addNewGroup(std::vector* 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 diff --git a/src/MEDLoader/SauvMedConvertor.hxx b/src/MEDLoader/SauvMedConvertor.hxx index ebaf41919..7d076876f 100644 --- a/src/MEDLoader/SauvMedConvertor.hxx +++ b/src/MEDLoader/SauvMedConvertor.hxx @@ -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* 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(); diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index 9b0fce3b8..65b24cca9 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -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; } diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index 533ae0ba4..bc0ae764b 100644 --- a/src/MEDLoader/SauvReader.hxx +++ b/src/MEDLoader/SauvReader.hxx @@ -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: diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 7a53ab79b..3b44ba218 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -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) diff --git a/src/MEDLoader/Swig/medutilities.py b/src/MEDLoader/Swig/medutilities.py index 98c06bf19..c99898e0c 100644 --- a/src/MEDLoader/Swig/medutilities.py +++ b/src/MEDLoader/Swig/medutilities.py @@ -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