From 3a3c0705efc655bbff0053e9ff492e4b04ab559e Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 10 Jul 2014 16:36:41 +0400 Subject: [PATCH] 22612: [CEA 1189] sauv2med should not change faces orientation Suppress fixing orientation of cells --- doc/doxygen/doxfiles/tools.dox | 3 - src/MEDLoader/SauvMedConvertor.cxx | 92 ++++++++++++++-------------- src/MEDLoader/SauvMedConvertor.hxx | 7 +-- src/MEDLoader/SauvReader.cxx | 4 +- src/MEDLoader/SauvReader.hxx | 2 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 2 +- src/MEDLoader/Swig/medutilities.py | 7 +-- 7 files changed, 56 insertions(+), 61 deletions(-) diff --git a/doc/doxygen/doxfiles/tools.dox b/doc/doxygen/doxfiles/tools.dox index 2b16d2ae7..8bcba7cd2 100644 --- a/doc/doxygen/doxfiles/tools.dox +++ b/doc/doxygen/doxfiles/tools.dox @@ -86,9 +86,6 @@ 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 diff --git a/src/MEDLoader/SauvMedConvertor.cxx b/src/MEDLoader/SauvMedConvertor.cxx index a8fb6db55..67e28ed11 100644 --- a/src/MEDLoader/SauvMedConvertor.cxx +++ b/src/MEDLoader/SauvMedConvertor.cxx @@ -2373,14 +2373,12 @@ Group* IntermediateMED::addNewGroup(std::vector* 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(bool fix2DOri) +ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS() { - MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh > mesh = makeMEDFileMesh(fix2DOri); + MEDCouplingAutoRefCountObjectPtr< MEDFileUMesh > mesh = makeMEDFileMesh(); MEDCouplingAutoRefCountObjectPtr< MEDFileFields > fields = makeMEDFileFields(mesh); MEDCouplingAutoRefCountObjectPtr< MEDFileMeshes > meshes = MEDFileMeshes::New(); @@ -2398,7 +2396,7 @@ ParaMEDMEM::MEDFileData* IntermediateMED::convertInMEDFileDS(bool fix2DOri) */ //================================================================================ -ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh(bool fix2DOri) +ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh() { // check if all needed piles are present checkDataAvailability(); @@ -2410,7 +2408,7 @@ ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh(bool fix2DOri) if ( _spaceDim == 2 || _spaceDim == 1 ) orientElements2D(); else if ( _spaceDim == 3 ) - orientElements3D( fix2DOri ); + orientElements3D(); // process groups decreaseHierarchicalDepthOfSubgroups(); @@ -2685,42 +2683,43 @@ void IntermediateMED::orientElements2D() // -------------------------- // orient faces clockwise // -------------------------- - int iQuad = isQuadratic ? 2 : 1; - for ( elemIt = faces->begin(), elemEnd = faces->end(); elemIt != elemEnd; elemIt++ ) - { - // look for index of the most left node - int iLeft = 0, iNode, nbNodes = elemIt->_nodes.size() / iQuad; - double x, minX = nodeCoords( elemIt->_nodes[0] )[0]; - for ( iNode = 1; iNode < nbNodes; ++iNode ) - if (( x = nodeCoords( elemIt->_nodes[ iNode ])[ 0 ]) < minX ) - minX = x, iLeft = iNode; - - // indeces of the nodes neighboring the most left one - int iPrev = ( iLeft - 1 < 0 ) ? nbNodes - 1 : iLeft - 1; - int iNext = ( iLeft + 1 == nbNodes ) ? 0 : iLeft + 1; - // find components of prev-left and left-next vectors - double xP = nodeCoords( elemIt->_nodes[ iPrev ])[ 0 ]; - double yP = nodeCoords( elemIt->_nodes[ iPrev ])[ 1 ]; - double xN = nodeCoords( elemIt->_nodes[ iNext ])[ 0 ]; - double yN = nodeCoords( elemIt->_nodes[ iNext ])[ 1 ]; - double xL = nodeCoords( elemIt->_nodes[ iLeft ])[ 0 ]; - double yL = nodeCoords( elemIt->_nodes[ iLeft ])[ 1 ]; - double xPL = xL - xP, yPL = yL - yP; // components of prev-left vector - double xLN = xN - xL, yLN = yN - yL; // components of left-next vector - // normalise y of the vectors - double modPL = sqrt ( xPL * xPL + yPL * yPL ); - double modLN = sqrt ( xLN * xLN + yLN * yLN ); - if ( modLN > std::numeric_limits::min() && - modPL > std::numeric_limits::min() ) - { - yPL /= modPL; - yLN /= modLN; - // summary direction of neighboring links must be positive - bool clockwise = ( yPL + yLN > 0 ); - if ( !clockwise ) - reverse( *elemIt, swapVec ); - } - } + // COMMENTED for issue 0022612 note 17739 + // int iQuad = isQuadratic ? 2 : 1; + // for ( elemIt = faces->begin(), elemEnd = faces->end(); elemIt != elemEnd; elemIt++ ) + // { + // // look for index of the most left node + // int iLeft = 0, iNode, nbNodes = elemIt->_nodes.size() / iQuad; + // double x, minX = nodeCoords( elemIt->_nodes[0] )[0]; + // for ( iNode = 1; iNode < nbNodes; ++iNode ) + // if (( x = nodeCoords( elemIt->_nodes[ iNode ])[ 0 ]) < minX ) + // minX = x, iLeft = iNode; + + // // indeces of the nodes neighboring the most left one + // int iPrev = ( iLeft - 1 < 0 ) ? nbNodes - 1 : iLeft - 1; + // int iNext = ( iLeft + 1 == nbNodes ) ? 0 : iLeft + 1; + // // find components of prev-left and left-next vectors + // double xP = nodeCoords( elemIt->_nodes[ iPrev ])[ 0 ]; + // double yP = nodeCoords( elemIt->_nodes[ iPrev ])[ 1 ]; + // double xN = nodeCoords( elemIt->_nodes[ iNext ])[ 0 ]; + // double yN = nodeCoords( elemIt->_nodes[ iNext ])[ 1 ]; + // double xL = nodeCoords( elemIt->_nodes[ iLeft ])[ 0 ]; + // double yL = nodeCoords( elemIt->_nodes[ iLeft ])[ 1 ]; + // double xPL = xL - xP, yPL = yL - yP; // components of prev-left vector + // double xLN = xN - xL, yLN = yN - yL; // components of left-next vector + // // normalise y of the vectors + // double modPL = sqrt ( xPL * xPL + yPL * yPL ); + // double modLN = sqrt ( xLN * xLN + yLN * yLN ); + // if ( modLN > std::numeric_limits::min() && + // modPL > std::numeric_limits::min() ) + // { + // yPL /= modPL; + // yLN /= modLN; + // // summary direction of neighboring links must be positive + // bool clockwise = ( yPL + yLN > 0 ); + // if ( !clockwise ) + // reverse( *elemIt, swapVec ); + // } + // } } } @@ -2730,11 +2729,11 @@ void IntermediateMED::orientElements2D() */ //================================================================================ -void IntermediateMED::orientElements3D(bool fix2DOri) +void IntermediateMED::orientElements3D() { // set _reverse flags of faces - if ( fix2DOri ) - orientFaces3D(); + // COMMENTED for issue 0022612 note 17739 + //orientFaces3D(); // ----------------- // fix connectivity @@ -2766,7 +2765,8 @@ void IntermediateMED::orientElements3D(bool fix2DOri) } } - orientVolumes(); + // COMMENTED for issue 0022612 note 17739 + //orientVolumes(); } //================================================================================ diff --git a/src/MEDLoader/SauvMedConvertor.hxx b/src/MEDLoader/SauvMedConvertor.hxx index efd55aa1f..ebaf41919 100644 --- a/src/MEDLoader/SauvMedConvertor.hxx +++ b/src/MEDLoader/SauvMedConvertor.hxx @@ -255,12 +255,11 @@ 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(bool fix2DOri); + ParaMEDMEM::MEDFileData* convertInMEDFileDS(); private: - ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh(bool fix2DOri); + ParaMEDMEM::MEDFileUMesh* makeMEDFileMesh(); ParaMEDMEM::DataArrayDouble * getCoords(); void setConnectivity( ParaMEDMEM::MEDFileUMesh* mesh, ParaMEDMEM::DataArrayDouble* coords ); void setGroups( ParaMEDMEM::MEDFileUMesh* mesh ); @@ -284,7 +283,7 @@ namespace SauvUtilities void eraseUselessGroups(); void detectMixDimGroups(); void orientElements2D(); - void orientElements3D(bool fix2DOri); + void orientElements3D(); void orientFaces3D(); void orientVolumes(); void numberElements(); diff --git a/src/MEDLoader/SauvReader.cxx b/src/MEDLoader/SauvReader.cxx index a943bcf2d..9b0fce3b8 100644 --- a/src/MEDLoader/SauvReader.cxx +++ b/src/MEDLoader/SauvReader.cxx @@ -112,7 +112,7 @@ std::string SauvReader::lineNb() const */ //================================================================================ -ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS(bool fix2DOri) +ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS() { SauvUtilities::IntermediateMED iMed; // intermadiate DS _iMed = &iMed; @@ -146,7 +146,7 @@ ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS(bool fix2DOri) THROW_IK_EXCEPTION("XDR : ENREGISTREMENT DE TYPE " << recordNumber << " not implemented!!!"); } - ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS( fix2DOri ); + ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS(); return medFileData; } diff --git a/src/MEDLoader/SauvReader.hxx b/src/MEDLoader/SauvReader.hxx index 1a07854e6..533ae0ba4 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(bool fix2DOri=false); + MEDLOADER_EXPORT ParaMEDMEM::MEDFileData * loadInMEDFileDS(); MEDLOADER_EXPORT ~SauvReader(); private: diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 5c3c7c811..7a53ab79b 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(bool fix2DOri=false) throw(INTERP_KERNEL::Exception); + MEDFileData * loadInMEDFileDS() 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 06fa149f6..98c06bf19 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( format ) + mfd= sr.loadInMEDFileDS() pass elif driver_in == "MED": mfd = MEDFileData(file_in) @@ -110,10 +110,9 @@ 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): - fix2DOri = ( "--fix2DOri" in argv ) + argv = list(argv) for arg in argv: - if not arg.startswith("--fix"): - convert(arg, "GIBI", "MED", format = fix2DOri) + convert(arg, "GIBI", "MED") pass return -- 2.39.2