From f976062ed906fa586039d64079a831b28c742f27 Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 18 Feb 2019 10:47:50 +0100 Subject: [PATCH] [LAST backport] New functionality: computeCellCenterOfMassWithPrecision() Same job as getBarycenterAndOwner(), but sets quadratic precision so that tolerance on arc of circle detection can be finely controlled. --- src/MEDCoupling/MEDCouplingUMesh.cxx | 22 ++++++++++++++++++++++ src/MEDCoupling/MEDCouplingUMesh.hxx | 1 + src/MEDCoupling_Swig/MEDCouplingCommon.i | 1 + 3 files changed, 24 insertions(+) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 3219c45a2..455b154d6 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7751,6 +7751,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::getBarycenterAndOwner() const { @@ -7772,6 +7773,27 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const return ret.retn(); } + +/*! + * See getBarycenterAndOwner(). + * \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::getBarycenterAndOwner + */ +DataArrayDouble *MEDCouplingUMesh::computeCellCenterOfMassWithPrecision(double eps) const +{ + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + MEDCouplingAutoRefCountObjectPtr ret = getBarycenterAndOwner(); + 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::getBarycenterAndOwner method that returns the center of inertia of the diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index ab2a711f1..14f64814a 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -224,6 +224,7 @@ namespace ParaMEDMEM // MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() 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 dd9019376..615f2e617 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -1818,6 +1818,7 @@ namespace ParaMEDMEM DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception); DataArrayDouble *getBoundingBoxForBBTree1DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception); void changeOrientationOfCells() throw(INTERP_KERNEL::Exception); + DataArrayDouble *computeCellCenterOfMassWithPrecision(double eps) 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); static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception); static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); -- 2.39.2