From: abn Date: Mon, 18 Feb 2019 09:47:50 +0000 (+0100) Subject: New functionality: computeCellCenterOfMassWithPrecision() X-Git-Tag: V9_3_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=92b31370406fe2c0dc52a9f6a1f70efda8168e78;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 0d2416962..50112f2a8 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -2003,6 +2003,7 @@ namespace MEDCoupling DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const; DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const; void changeOrientationOfCells(); + DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps); int split2DCells(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *subNodesInSeg, const DataArrayInt *subNodesInSegI, const DataArrayInt *midOpt=0, const DataArrayInt *midOptI=0); static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da); static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);