From 7398df68f6c6cfb0c1ab02203cc1f729d63ad0c8 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 24 Jan 2020 18:04:41 +0100 Subject: [PATCH] Avoid regression on Voronoi cell computation --- src/MEDCoupling/MEDCouplingVoronoi.cxx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/MEDCoupling/MEDCouplingVoronoi.cxx b/src/MEDCoupling/MEDCouplingVoronoi.cxx index 80e1b0e3d..16dbe2e58 100755 --- a/src/MEDCoupling/MEDCouplingVoronoi.cxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.cxx @@ -21,6 +21,7 @@ #include "MEDCouplingVoronoi.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingCMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" #include "MCAuto.txx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" @@ -90,6 +91,11 @@ MCAuto ComputeBigCellFrom(const double pt1[2], const double pt throw INTERP_KERNEL::Exception("ComputeBigCellFrom : expected single element !"); MCAuto ret(sp2->buildPartOfMySelfSlice(ccp[0],ccp[0]+1,1,true)); ret->zipCoords(); + { + MCAuto tmp(ret->getMeasureField(false)); + if(tmp->getArray()->getIJ(0,0)<0) + ret->invertOrientationOfAllCells(); + } return ret; } @@ -424,6 +430,11 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * newVorCell->zipCoords(); MCAuto modifiedCell(a->buildPartOfMySelf(part->begin(),part->end())); modifiedCell->zipCoords(); + { + MCAuto tmp(modifiedCell->getMeasureField(false)); + if(tmp->getArray()->getIJ(0,0)<0) + modifiedCell->invertOrientationOfAllCells(); + } l0[poly]=modifiedCell; // MCAuto ids; @@ -455,7 +466,13 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * } newVorCells.push_back(newVorCell); } - l0.push_back(MergeVorCells(newVorCells,eps)); + MCAuto mergedVorCell(MergeVorCells(newVorCells,eps)); + { + MCAuto tmp(mergedVorCell->getMeasureField(false)); + if(tmp->getArray()->getIJ(0,0)<0) + mergedVorCell->invertOrientationOfAllCells(); + } + l0.push_back(mergedVorCell); } std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0)); MCAuto ret(MEDCouplingUMesh::MergeUMeshes(l0Bis)); -- 2.39.2