\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
// 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++)
//================================================================================
/*!
* \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();
*/
//================================================================================
-ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh()
+ParaMEDMEM::MEDFileUMesh* IntermediateMED::makeMEDFileMesh(bool fix2DOri)
{
// check if all needed piles are present
checkDataAvailability();
if ( _spaceDim == 2 || _spaceDim == 1 )
orientElements2D();
else if ( _spaceDim == 3 )
- orientElements3D();
+ orientElements3D( fix2DOri );
// process groups
decreaseHierarchicalDepthOfSubgroups();
*/
//================================================================================
-void IntermediateMED::orientElements3D()
+void IntermediateMED::orientElements3D(bool fix2DOri)
{
// set _reverse flags of faces
- orientFaces3D();
+ if ( fix2DOri )
+ orientFaces3D();
// -----------------
// fix connectivity
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 &&
// 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 );
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 );
void eraseUselessGroups();
void detectMixDimGroups();
void orientElements2D();
- void orientElements3D();
+ void orientElements3D(bool fix2DOri);
void orientFaces3D();
void orientVolumes();
void numberElements();
*/
//================================================================================
-ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS()
+ParaMEDMEM::MEDFileData * SauvReader::loadInMEDFileDS(bool fix2DOri)
{
SauvUtilities::IntermediateMED iMed; // intermadiate DS
_iMed = &iMed;
THROW_IK_EXCEPTION("XDR : ENREGISTREMENT DE TYPE " << recordNumber << " not implemented!!!");
}
- ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS();
+ ParaMEDMEM::MEDFileData* medFileData = iMed.convertInMEDFileDS( fix2DOri );
return medFileData;
}
else
for (initIntReading(nbElements); more(); next());
- // not a composit group
+ // not a composite group
if (castemCellType>0 && nbSubGroups==0)
{
group._cellType = SauvUtilities::gibi2medGeom(castemCellType);
//================================================================================
/*!
- * \brief Finds or create a Group equal to a given field support
+ * \brief Find or create a Group equal to a given field support
*/
//================================================================================
{
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];
}
// 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() )
{
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:
{
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)
#
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)
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