Salome HOME
Voronoi 1D + getCellsContainingPoint is now a virtual abstract method
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 6 Feb 2017 10:20:43 +0000 (11:20 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 6 Feb 2017 10:20:43 +0000 (11:20 +0100)
16 files changed:
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx
src/MEDCoupling/MEDCouplingCurveLinearMesh.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingIMesh.cxx
src/MEDCoupling/MEDCouplingIMesh.hxx
src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingMappedExtrudedMesh.hxx
src/MEDCoupling/MEDCouplingMesh.cxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingVoronoi.cxx
src/MEDCoupling/MEDCouplingVoronoi.hxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py

index e702119f77690e1cbc3046fd3d74a5bb36a94381..7dda1671a544aeb7b8aa1848d581350bb3f5ae01 100644 (file)
@@ -329,10 +329,19 @@ MEDCouplingFieldDouble *MEDCoupling1GTUMesh::getMeasureFieldOnNode(bool isAbs) c
  */
 int MEDCoupling1GTUMesh::getCellContainingPoint(const double *pos, double eps) const
 {
-  MCAuto<MEDCouplingUMesh> m=buildUnstructured();
+  MCAuto<MEDCouplingUMesh> m(buildUnstructured());
   return m->getCellContainingPoint(pos,eps);
 }
 
+/*!
+ * to improve perf !
+ */
+void MEDCoupling1GTUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  MCAuto<MEDCouplingUMesh> m(buildUnstructured());
+  return m->getCellsContainingPoint(pos,eps,elts);
+}
+
 MEDCouplingFieldDouble *MEDCoupling1GTUMesh::buildOrthogonalField() const
 {
   MCAuto<MEDCouplingUMesh> m=buildUnstructured();
index cf44ed6632bf99938a1d518379fb1489c51c6ddd..c17ab296f3cc01ebdcb32bc7c68e3345119bfc69 100644 (file)
@@ -60,6 +60,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
     MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const;
     MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps);
index 0f413d26fb0c541ea1dcc73e679386a3b4790361..f640504926209fefa8031892de5c73d5ee22faf5 100644 (file)
@@ -633,6 +633,12 @@ int MEDCouplingCMesh::getCellContainingPoint(const double *pos, double eps) cons
   return ret;
 }
 
+void MEDCouplingCMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  int ret(getCellContainingPoint(pos,eps));
+  elts.push_back(ret);
+}
+
 void MEDCouplingCMesh::rotate(const double *center, const double *vector, double angle)
 {
   throw INTERP_KERNEL::Exception("No rotation available on CMesh : Traduce it to untructured mesh to apply it !");
index 9b6e50fe1919f747e9f1439c53ff22dbffdc3431..0af6ec29200d53fca57383cf1725aa978c001e27 100644 (file)
@@ -65,6 +65,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
     MEDCOUPLING_EXPORT void translate(const double *vector);
     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
index 17db1d9a0d286a2d71398c78cbb289c07b21d10d..b8e76f68291900eec5609eb17bdaa3b89afff235 100644 (file)
@@ -634,6 +634,12 @@ int MEDCouplingCurveLinearMesh::getCellContainingPoint(const double *pos, double
   }
 }
 
+void MEDCouplingCurveLinearMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  int ret(getCellContainingPoint(pos,eps));
+  elts.push_back(ret);
+}
+
 void MEDCouplingCurveLinearMesh::rotate(const double *center, const double *vector, double angle)
 {
   if(!((DataArrayDouble *)_coords))
index 316e7eaaec63dd8bbfe3b28493925f6ddba42be9..d9884d89c8a689a73f27c183a6b86f07f60e941d 100644 (file)
@@ -66,6 +66,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
     MEDCOUPLING_EXPORT void translate(const double *vector);
     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
index 2b51bd6077425b9807f3c80223a0f3f1c31698b6..4a1d54ba2c601c377a61731573971561ef95f2e9 100644 (file)
@@ -2213,7 +2213,9 @@ MCAuto<MEDCouplingFieldDouble> MEDCouplingFieldDouble::voronoize(double eps) con
   const MEDCouplingMesh *mesh(getMesh());
   INTERP_KERNEL::AutoCppPtr<Voronizer> vor;
   int meshDim(mesh->getMeshDimension()),spaceDim(mesh->getSpaceDimension());
-  if(meshDim==2 && (spaceDim==2 || spaceDim==3))
+  if(meshDim==1 && (spaceDim==1 || spaceDim==2 || spaceDim==3))
+    vor=new Voronizer1D;
+  else if(meshDim==2 && (spaceDim==2 || spaceDim==3))
     vor=new Voronizer2D;
   else if(meshDim==3 && spaceDim==3)
     vor=new Voronizer3D;
index f30feb9d43690af4c50b33bf1389a55230ec8029..329c545842892ff659fd29508d5055ea01738a83 100644 (file)
@@ -1123,6 +1123,12 @@ int MEDCouplingIMesh::getCellContainingPoint(const double *pos, double eps) cons
   return ret;
 }
 
+void MEDCouplingIMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  int ret(getCellContainingPoint(pos,eps));
+  elts.push_back(ret);
+}
+
 void MEDCouplingIMesh::rotate(const double *center, const double *vector, double angle)
 {
   throw INTERP_KERNEL::Exception("No rotation available on IMesh : Traduce it to unstructured mesh to apply it !");
index 78456d339211999888d5d00aa28ea47b84bcf786..362cb980339a5fbc26fc8b7499c267f2fd7d823c 100644 (file)
@@ -80,6 +80,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
     MEDCOUPLING_EXPORT void rotate(const double *center, const double *vector, double angle);
     MEDCOUPLING_EXPORT void translate(const double *vector);
     MEDCOUPLING_EXPORT void scale(const double *point, double factor);
index 463677011ad2763315a745c1c75ea00d21668d42..9456bffcd7730493a9a19bbc37d151243f106e32 100644 (file)
@@ -508,6 +508,11 @@ int MEDCouplingMappedExtrudedMesh::getCellContainingPoint(const double *pos, dou
   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellContainingPoint : not implemented yet !");
 }
 
+void MEDCouplingMappedExtrudedMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellsContainingPoint : not implemented yet !");
+}
+
 MEDCouplingMappedExtrudedMesh::~MEDCouplingMappedExtrudedMesh()
 {
 }
index 421d341c8ac255cfe31f0d2e9554152a39e0f949..807c2f2c1654d7d6507ec466466a34784b8effc8 100644 (file)
@@ -82,6 +82,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
     MEDCOUPLING_EXPORT int getCellContainingPoint(const double *pos, double eps) const;
+    MEDCOUPLING_EXPORT void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
     MEDCOUPLING_EXPORT static int FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
                                                              const int *revNodalPtr, const int *revNodalIndxPtr);
     MEDCOUPLING_EXPORT static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
index 388623f7e059151a020bdc6f23a0c8650243be02..551d4c3f70a255f45abb5f196bf0bc08682f97fe 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "MEDCouplingMesh.hxx"
 #include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMemArray.txx"
 #include "MEDCouplingFieldDouble.hxx"
 #include "MEDCouplingFieldDiscretization.hxx"
 #include "MCAuto.hxx"
@@ -622,27 +622,6 @@ const char *MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NormalizedCel
   return cm.getRepr();
 }
 
-/*!
- * Finds cells in contact with a ball (i.e. a point with precision).
- * \warning This method is suitable if the caller intends to evaluate only one
- *          point, for more points getCellsContainingPoints() is recommended as it is
- *          faster. 
- *  \param [in] pos - array of coordinates of the ball central point.
- *  \param [in] eps - ball radius.
- *  \param [in,out] elts - vector returning ids of the found cells. It is cleared
- *         before inserting ids.
- *
- *  \if ENABLE_EXAMPLES
- *  \ref cpp_mcumesh_getCellsContainingPoint "Here is a C++ example".<br>
- *  \ref  py_mcumesh_getCellsContainingPoint "Here is a Python example".
- *  \endif
- */
-void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
-{
-  int ret=getCellContainingPoint(pos,eps);
-  elts.push_back(ret);
-}
-
 /*!
  * Finds cells in contact with several balls (i.e. points with precision).
  * This method is an extension of getCellContainingPoint() and
@@ -676,14 +655,10 @@ void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints
   const double *work(pos);
   for(int i=0;i<nbOfPoints;i++,work+=spaceDim)
     {
-      int ret=getCellContainingPoint(work,eps);
-      if(ret>=0)
-        {
-          elts->pushBackSilent(ret);
-          eltsIndexPtr[i+1]=eltsIndexPtr[i]+1;
-        }
-      else
-        eltsIndexPtr[i+1]=eltsIndexPtr[i];
+      std::vector<int> ret;
+      getCellsContainingPoint(work,eps,ret);
+      elts->insertAtTheEnd(ret.begin(),ret.end());
+      eltsIndexPtr[i+1]=elts->getNumberOfTuples();
     }
 }
 
index 0e9efe47a2da704e03705d533e7a2711f0b73a47..1f1a79cc4349041dd27e354a407259deca0821e6 100644 (file)
@@ -113,7 +113,7 @@ namespace MEDCoupling
     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
     MEDCOUPLING_EXPORT virtual int getCellContainingPoint(const double *pos, double eps) const = 0;
-    MEDCOUPLING_EXPORT virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
+    MEDCOUPLING_EXPORT virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const = 0;
     MEDCOUPLING_EXPORT virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, MCAuto<DataArrayInt>& elts, MCAuto<DataArrayInt>& eltsIndex) const;
     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
     MEDCOUPLING_EXPORT virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const std::string& func) const;
index be334825bc8d018e3e7f91abe157fb7123bd42bb..7e7efbcfdee1a7452e96a622859172d529b8f191 100644 (file)
@@ -33,6 +33,11 @@ Voronizer::~Voronizer()
 {
 }
 
+int Voronizer1D::getDimension() const
+{
+  return 1;
+}
+
 int Voronizer2D::getDimension() const
 {
   return 2;
@@ -212,6 +217,117 @@ MCAuto<MEDCouplingUMesh> MergeVorCells3D(const std::vector< MCAuto<MEDCouplingUM
   return ret;
 }
 
+MCAuto<MEDCouplingUMesh> MergeVorCells1D(const std::vector< MCAuto<MEDCouplingUMesh> >& vcs, double eps)
+{
+  static const int CONN_SEG2_DFT[2]={0,1};
+  if(vcs.empty())
+    throw INTERP_KERNEL::Exception("MergeVorCells1D : internal error 1 !");
+  if(vcs.size()==1)
+    return vcs[0];
+  if(vcs.size()>2)
+    throw INTERP_KERNEL::Exception("MergeVorCells1D : internal error 2 !");
+  double a0,b0,a1,b1;
+  {
+    const int *connPtr(vcs[0]->getNodalConnectivity()->begin());
+    const double *coordPtr(vcs[0]->getCoords()->begin());
+    a0=coordPtr[connPtr[1]]; b0=coordPtr[connPtr[2]];
+  }
+  {
+    const int *connPtr(vcs[1]->getNodalConnectivity()->begin());
+    const double *coordPtr(vcs[1]->getCoords()->begin());
+    a1=coordPtr[connPtr[1]]; b1=coordPtr[connPtr[2]];
+  }
+  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::New("",1)); ret->allocateCells(); ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,CONN_SEG2_DFT);
+  MCAuto<DataArrayDouble> coo(DataArrayDouble::New()); coo->alloc(2,1); ret->setCoords(coo);
+  if(fabs(b0-a1)<eps)
+    { coo->setIJ(0,0,a0); coo->setIJ(1,0,b1); }
+  else if(fabs(b1-a0)<eps)
+    { coo->setIJ(0,0,b0); coo->setIJ(1,0,a1); }
+  return ret;
+}
+
+MCAuto<MEDCouplingUMesh> MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const
+{
+  static const int CONN_SEG2_DFT[2]={0,1};
+  if(!m || !points)
+    throw INTERP_KERNEL::Exception("Voronoize1D : null pointer !");
+  m->checkConsistencyLight();
+  points->checkAllocated();
+  if(m->getMeshDimension()!=1 || m->getSpaceDimension()!=1 || points->getNumberOfComponents()!=1)
+    throw INTERP_KERNEL::Exception("Voronoize1D : spacedim must be equal to 1 and meshdim also equal to 1 !");
+  if(m->getNumberOfCells()!=1)
+    throw INTERP_KERNEL::Exception("Voronoize1D : mesh is expected to have only one cell !");
+  int nbPts(points->getNumberOfTuples());
+  if(nbPts<1)
+    throw INTERP_KERNEL::Exception("Voronoize1D : at least one point expected !");
+  std::vector<double> bbox(4);
+  m->getBoundingBox(&bbox[0]);
+  std::vector< MCAuto<MEDCouplingUMesh> > l0(1,MCAuto<MEDCouplingUMesh>(m->deepCopy()));
+  const double *pts(points->begin());
+  for(int i=1;i<nbPts;i++)
+    {
+      MCAuto<MEDCouplingUMesh> vorTess;
+      {
+        std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0));
+        vorTess=MEDCouplingUMesh::MergeUMeshes(l0Bis);
+      }
+      {
+        bool dummy;
+        int newNbNodes;
+        MCAuto<DataArrayInt> dummy3(vorTess->mergeNodes(eps,dummy,newNbNodes));
+      }
+      std::vector<int> polygsToIterOn;
+      const double *pt(pts+i);
+      vorTess->getCellsContainingPoint(pt,eps,polygsToIterOn);
+      if(polygsToIterOn.empty())
+        throw INTERP_KERNEL::Exception("Voronoize1D : a point is outside domain !");
+      if(polygsToIterOn.size()>2)
+        throw INTERP_KERNEL::Exception("Voronoize1D : overlap of points !");
+      std::vector< MCAuto<MEDCouplingUMesh> > newVorCells;
+      for(std::vector<int>::const_iterator it=polygsToIterOn.begin();it!=polygsToIterOn.end();it++)
+        {
+          int poly(*it);
+          //
+          double seed(pts[poly]),zept(*pt);
+          double mid((seed+zept)/2.);
+          //
+          MCAuto<MEDCouplingUMesh> tile(l0[poly]);
+          tile->zipCoords();
+          double a,b;
+          {
+            const int *connPtr(tile->getNodalConnectivity()->begin());
+            const double *coordPtr(tile->getCoords()->begin());
+            a=coordPtr[connPtr[1]]; b=coordPtr[connPtr[2]];
+          }
+          double pol0[2],pol1[2];
+          MCAuto<DataArrayDouble> t0(DataArrayDouble::New()); t0->alloc(3,1); t0->setIJ(0,0,zept); t0->setIJ(1,0,mid); t0->setIJ(2,0,seed);
+          t0->applyLin(1.,-a);
+          if(t0->isMonotonic(true,eps))
+            { pol0[0]=a; pol0[1]=mid; pol1[0]=mid; pol1[1]=b; }
+          else
+            { pol1[0]=a; pol1[1]=mid; pol0[0]=mid; pol0[1]=b; }
+          MCAuto<MEDCouplingUMesh> modifiedCell(MEDCouplingUMesh::New("",1)); modifiedCell->allocateCells();
+          MCAuto<DataArrayDouble> coo1(DataArrayDouble::New()); coo1->alloc(2,1); coo1->setIJ(0,0,pol1[0]); coo1->setIJ(1,0,pol1[1]);
+          modifiedCell->setCoords(coo1); modifiedCell->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,CONN_SEG2_DFT);
+          //
+          MCAuto<MEDCouplingUMesh> newVorCell(MEDCouplingUMesh::New("",1)); newVorCell->allocateCells();
+          MCAuto<DataArrayDouble> coo2(DataArrayDouble::New()); coo2->alloc(2,1); coo2->setIJ(0,0,pol0[0]); coo2->setIJ(1,0,pol0[1]);
+          newVorCell->setCoords(coo2); newVorCell->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,CONN_SEG2_DFT);
+          //
+          l0[poly]=modifiedCell;
+          newVorCells.push_back(newVorCell);
+        }
+      l0.push_back(MergeVorCells1D(newVorCells,eps));
+    }
+  std::vector< const MEDCouplingUMesh * > l0Bis(VecAutoToVecOfCstPt(l0));
+  MCAuto<MEDCouplingUMesh> ret(MEDCouplingUMesh::MergeUMeshes(l0Bis));
+  {
+    bool dummy; int dummy2;
+    MCAuto<DataArrayInt> dummy3(ret->mergeNodes(eps,dummy,dummy2));
+  }
+  return ret;
+}
+
 MCAuto<MEDCouplingUMesh> MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const
 {
   if(!m || !points)
index 6047ecd93163cf156efae8d70afc3f42a4980d3f..261c63724e85839b32b4d03abf99b66769a56a35 100644 (file)
@@ -35,6 +35,13 @@ namespace MEDCoupling
     virtual ~Voronizer();
   };
 
+  class Voronizer1D : public Voronizer
+  {
+  public:
+    MCAuto<MEDCouplingUMesh> doIt(const MEDCouplingUMesh *m, const DataArrayDouble *points, double eps) const;
+    int getDimension() const;
+  };
+
   class Voronizer2D : public Voronizer
   {
   public:
index 3f3af10cbb08bf4efe7a2cd7627290fb0646479c..45c3ae72b4c168967cab0bf46fc2116c70e9846f 100644 (file)
@@ -4751,6 +4751,8 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         #####
         fieldOnCell=field.voronoize(1e-12);
         fieldOnCell.checkConsistencyLight()
+        self.assertEqual(fieldOnCell.getMesh().getSpaceDimension(),3)
+        self.assertEqual(fieldOnCell.getMesh().getMeshDimension(),2)
         self.assertEqual(field.getMesh().getSpaceDimension(),fieldOnCell.getMesh().getSpaceDimension())
         self.assertTrue(fieldOnCell.getArray().isEqual(field.getArray(),1e-12))
         meaRef=field.getMesh().getMeasureField(True).getArray()
@@ -4761,6 +4763,39 @@ class MEDCouplingBasicsTest5(unittest.TestCase):
         mea2=mea.sumPerTuple()
         self.assertTrue(mea2.isEqual(meaRef,1e-12))
         pass
+
+    def testVoronoi1D_1(self):
+        tmp=MEDCouplingCMesh("mesh")
+        arr=DataArrayDouble(5) ; arr.iota()
+        tmp.setCoords(arr)
+        tmp=tmp.build1SGTUnstructured()
+        tmp1=tmp.deepCopy()
+        tmp.changeSpaceDimension(2,0.)
+        tmp.getCoords()[:,1]=pi/(len(arr)-1)*tmp.getCoords()[:,0]
+        tmp.getCoords()[:,0]=1.
+        tmp.setCoords(tmp.getCoords().fromPolarToCart())
+        tmp.changeSpaceDimension(3,1.)
+        #
+        field=MEDCouplingFieldDouble(ON_GAUSS_PT)
+        field.setName("MyFieldPG") ; field.setMesh(tmp)
+        field.setGaussLocalizationOnType(NORM_SEG2,[-1.,1.],[-0.9,-0.8,0.2,0.4,0.5,0.9],[0.1,0.1,0.1,0.1,0.1,0.5])
+        arr=DataArrayDouble(field.getNumberOfTuplesExpected()) ; arr.iota() 
+        field.setArray(arr)
+        field.checkConsistencyLight()
+        ####
+        fieldOnCell=field.voronoize(1e-12);
+        fieldOnCell.checkConsistencyLight()
+        self.assertEqual(fieldOnCell.getMesh().getSpaceDimension(),3)
+        self.assertEqual(fieldOnCell.getMesh().getMeshDimension(),1)
+        assert(fieldOnCell.getArray().isEqual(field.getArray(),1e-12))
+        meaRef=field.getMesh().getMeasureField(True).getArray()
+        mea=fieldOnCell.getMesh().getMeasureField(True).getArray()
+        self.assertEqual(field.getDiscretization().getNbOfGaussLocalization(),1)
+        self.assertEqual(field.getDiscretization().getGaussLocalization(0).getNumberOfGaussPt(),6)
+        mea.rearrange(6)
+        mea2=mea.sumPerTuple()
+        self.assertTrue(mea2.isEqual(meaRef,1e-12))
+        pass
     
     pass