From: abn Date: Mon, 18 Feb 2019 09:47:50 +0000 (+0100) Subject: New functionality: computeCellCenterOfMassWithPrecision() X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=341247cc6bc5833dbe76fb8d0f3f39e4f67086ef;p=tools%2Fmedcoupling.git New functionality: computeCellCenterOfMassWithPrecision() Same job as computeCellCenterOfMass, but sets quadratic precision so that tolerance on arc of circle detection can be finely controlled. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index f3780f4fb..203a75294 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -6419,6 +6419,8 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) * Returns a new DataArrayDouble holding barycenters of all cells. The barycenter is * computed by averaging coordinates of cell nodes, so this method is not a right * choice for degenerated meshes (not well oriented, cells with measure close to zero). + * Beware also that for quadratic meshes, degenerated arc of circles are turned into linear edges for the computation. + * This happens with a default detection precision of eps=1.0e-14. If you need control over this use computeCellCenterOfMassWithPrecision(). * \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a * this->getNumberOfCells() tuples per \a this->getSpaceDimension() * components. The caller is to delete this array using decrRef() as it is @@ -6426,6 +6428,7 @@ MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \sa MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell + * \sa MEDCouplingUMesh::computeCellCenterOfMassWithPrecision */ DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const { @@ -6447,6 +6450,27 @@ DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMass() const return ret.retn(); } + +/*! + * See computeCellCenterOfMass(). + * \param eps a precision for the detection of degenerated arc of circles. + * \return DataArrayDouble * - a new instance of DataArrayDouble, of size \a + * this->getNumberOfCells() tuples per \a this->getSpaceDimension() + * components. The caller is to delete this array using decrRef() as it is + * no more needed. + * \throw If the coordinates array is not set. + * \throw If the nodal connectivity of cells is not defined. + * \sa MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell + * \sa MEDCouplingUMesh::computeCellCenterOfMassWithPrecision + */ +DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMassWithPrecision(double eps) const +{ + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + MCAuto ret = computeCellCenterOfMass(); + return ret.retn(); +} + + /*! * This method computes for each cell in \a this, the location of the iso barycenter of nodes constituting * the cell. Contrary to badly named MEDCouplingUMesh::computeCellCenterOfMass method that returns the center of inertia of the diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 76ee1d148..358d6c8e3 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -234,6 +234,7 @@ namespace MEDCoupling // MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMass() const; + MEDCOUPLING_EXPORT DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps) const; MEDCOUPLING_EXPORT DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const; MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const; MEDCOUPLING_EXPORT DataArrayDouble *computePlaneEquationOf3DFaces() const; diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index b2641c64a..8cd2b6c18 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -364,6 +364,7 @@ using namespace INTERP_KERNEL; %newobject MEDCoupling::MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic; %newobject MEDCoupling::MEDCouplingUMesh::getBoundingBoxForBBTree1DQuadratic; %newobject MEDCoupling::MEDCouplingUMesh::convertDegeneratedCellsAndRemoveFlatOnes; +%newobject MEDCoupling::MEDCouplingUMesh::computeCellCenterOfMassWithPrecision; %newobject MEDCoupling::MEDCouplingUMeshCellByTypeEntry::__iter__; %newobject MEDCoupling::MEDCouplingUMeshCellEntry::__iter__; %newobject MEDCoupling::MEDCoupling1GTUMesh::New; @@ -2001,6 +2002,7 @@ namespace MEDCoupling DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception); void changeOrientationOfCells() throw(INTERP_KERNEL::Exception); int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0) throw(INTERP_KERNEL::Exception); + DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps) const throw(INTERP_KERNEL::Exception); static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception); static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);