+/*!
+ * This method makes the hypothesis that \a this is a Gauss field. This method returns a newly created field on cells with same number of tuples than \a this.
+ * Each Gauss points in \a this is replaced by a polygon or polyhedron cell with associated region following Voronoi algorithm.
+ */
+MCAuto<MEDCouplingFieldDouble> MEDCouplingFieldDouble::voronoize(double eps) const
+{
+ checkConsistencyLight();
+ const MEDCouplingMesh *mesh(getMesh());
+ INTERP_KERNEL::AutoCppPtr<Voronizer> vor;
+ std::size_t meshDim(mesh->getMeshDimension()),spaceDim(mesh->getSpaceDimension());
+ 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;
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::voronoize : only 2D, 3D surf, and 3D are supported for the moment !");
+ return voronoizeGen(vor,eps);
+}
+
+/*!
+ * \sa MEDCouplingUMesh::convertQuadraticCellsToLinear
+ */
+MCAuto<MEDCouplingFieldDouble> MEDCouplingFieldDouble::convertQuadraticCellsToLinear() const
+{
+ checkConsistencyLight();
+ switch(getTypeOfField())
+ {
+ case ON_NODES:
+ {
+ const MEDCouplingMesh *mesh(getMesh());
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !");
+ MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ umesh=umesh->clone(false);
+ umesh->convertQuadraticCellsToLinear();
+ MCAuto<DataArrayIdType> o2n(umesh->zipCoordsTraducer());
+ MCAuto<DataArrayIdType> n2o(o2n->invertArrayO2N2N2O(umesh->getNumberOfNodes()));
+ MCAuto<DataArrayDouble> arr(getArray()->selectByTupleIdSafe(n2o->begin(),n2o->end()));
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_NODES));
+ ret->setArray(arr);
+ ret->setMesh(umesh);
+ ret->copyAllTinyAttrFrom(this);
+ return ret;
+ }
+ case ON_CELLS:
+ {
+ const MEDCouplingMesh *mesh(getMesh());
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !");
+ MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ umesh=umesh->clone(false);
+ umesh->convertQuadraticCellsToLinear();
+ umesh->zipCoords();
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_CELLS));
+ ret->setArray(const_cast<DataArrayDouble *>(getArray()));
+ ret->setMesh(umesh);
+ ret->copyAllTinyAttrFrom(this);
+ return ret;
+ }
+ case ON_GAUSS_PT:
+ {
+ const MEDCouplingMesh *mesh(getMesh());
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !");
+ MCAuto<MEDCouplingUMesh> umesh(mesh->buildUnstructured());
+ std::set<INTERP_KERNEL::NormalizedCellType> gt(umesh->getAllGeoTypes());
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_GAUSS_PT));
+ //
+ const MEDCouplingFieldDiscretization *disc(getDiscretization());
+ const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
+ if(!disc2)
+ throw INTERP_KERNEL::Exception("convertQuadraticCellsToLinear : Not a ON_GAUSS_PT field");
+ std::set<INTERP_KERNEL::NormalizedCellType> gt2(umesh->getAllGeoTypes());
+ std::vector< MCAuto<DataArrayIdType> > cellIdsV;
+ std::vector< MCAuto<MEDCouplingUMesh> > meshesV;
+ std::vector< MEDCouplingGaussLocalization > glV;
+ bool isZipReq(false);
+ for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=gt.begin();it!=gt.end();it++)
+ {
+ const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(*it));
+ MCAuto<DataArrayIdType> cellIds(umesh->giveCellsWithType(*it));
+ cellIdsV.push_back(cellIds);
+ MCAuto<MEDCouplingUMesh> part(umesh->buildPartOfMySelf(cellIds->begin(),cellIds->end()));
+ mcIdType id(disc2->getGaussLocalizationIdOfOneType(*it));
+ const MEDCouplingGaussLocalization& gl(disc2->getGaussLocalization(id));
+ if(!cm.isQuadratic())
+ {
+ glV.push_back(gl);
+ }
+ else
+ {
+ isZipReq=true;
+ part->convertQuadraticCellsToLinear();
+ INTERP_KERNEL::GaussInfo gi(*it,gl.getGaussCoords(),gl.getNumberOfGaussPt(),gl.getRefCoords(),gl.getNumberOfPtsInRefCell());
+ INTERP_KERNEL::GaussInfo gi2(gi.convertToLinear());
+ MEDCouplingGaussLocalization gl2(gi2.getGeoType(),gi2.getRefCoords(),gi2.getGaussCoords(),gl.getWeights());
+ glV.push_back(gl2);
+ }
+ meshesV.push_back(part);
+ }
+ //
+ {
+ std::vector< const MEDCouplingUMesh * > meshesPtr(VecAutoToVecOfCstPt(meshesV));
+ umesh=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshesPtr);
+ std::vector< const DataArrayIdType * > zeCellIds(VecAutoToVecOfCstPt(cellIdsV));
+ MCAuto<DataArrayIdType> zeIds(DataArrayIdType::Aggregate(zeCellIds));
+ umesh->renumberCells(zeIds->begin());
+ umesh->setName(mesh->getName());
+ }
+ //
+ if(isZipReq)
+ umesh->zipCoords();
+ ret->setArray(const_cast<DataArrayDouble *>(getArray()));
+ ret->setMesh(umesh);
+ for(std::vector< MEDCouplingGaussLocalization >::const_iterator it=glV.begin();it!=glV.end();it++)
+ ret->setGaussLocalizationOnType((*it).getType(),(*it).getRefCoords(),(*it).getGaussCoords(),(*it).getWeights());
+ ret->copyAllTinyAttrFrom(this);
+ ret->checkConsistencyLight();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : Only available for fields on nodes and on cells !");
+ }
+}
+
+/*!
+ * This is expected to be a 3 components vector field on nodes (if not an exception will be thrown). \a this is also expected to lie on a MEDCouplingPointSet mesh.
+ * Finally \a this is also expected to be consistent.
+ * In these conditions this method returns a newly created field (to be dealed by the caller).
+ * The returned field will also 3 compo vector field be on nodes lying on the same mesh than \a this.
+ *
+ * For each 3 compo tuple \a tup in \a this the returned tuple is the result of the transformation of \a tup in the new referential. This referential is defined by \a Ur, \a Uteta, \a Uz.
+ * \a Ur is the vector between \a center point and the associated node with \a tuple. \a Uz is \a vect normalized. And Uteta is the cross product of \a Uz with \a Ur.
+ *
+ * \sa DataArrayDouble::fromCartToCylGiven
+ */
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::computeVectorFieldCyl(const double center[3], const double vect[3]) const
+{
+ checkConsistencyLight();
+ const DataArrayDouble *coo(getMesh()->getDirectAccessOfCoordsArrIfInStructure());
+ MEDCouplingTimeDiscretization *td(timeDiscr()->computeVectorFieldCyl(coo,center,vect));
+ td->copyTinyAttrFrom(*timeDiscr());
+ MCAuto<MEDCouplingFieldDouble> ret(new MEDCouplingFieldDouble(getNature(),td,_type->clone()));
+ ret->setMesh(getMesh());
+ ret->setName(getName());
+ return ret.retn();
+}
+