From: Anthony Geay Date: Thu, 2 Apr 2015 06:47:24 +0000 (+0200) Subject: Addition of MEDCouplingPointSet::areAllNodesFetched() method. X-Git-Tag: V7_6_0a1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bd43dc237822bb31af671ffc08773c16c443086;p=tools%2Fmedcoupling.git Addition of MEDCouplingPointSet::areAllNodesFetched() method. --- diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index d0596161b..343076dfd 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1011,7 +1011,7 @@ struct MEDCouplingAccVisit * the format of returned DataArrayInt instance. * * \return a newly allocated DataArrayInt sorted ascendingly of fetched node ids. - * \sa MEDCoupling1SGTUMesh::getNodeIdsInUse + * \sa MEDCoupling1SGTUMesh::getNodeIdsInUse, areAllNodesFetched */ DataArrayInt *MEDCoupling1SGTUMesh::computeFetchedNodeIds() const { @@ -1040,7 +1040,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::computeFetchedNodeIds() const * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. - * \sa MEDCoupling1SGTUMesh::computeFetchedNodeIds + * \sa MEDCoupling1SGTUMesh::computeFetchedNodeIds, areAllNodesFetched */ DataArrayInt *MEDCoupling1SGTUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const { @@ -3046,7 +3046,7 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. - * \sa MEDCoupling1DGTUMesh::computeFetchedNodeIds + * \sa MEDCoupling1DGTUMesh::getNodeIdsInUse, areAllNodesFetched */ DataArrayInt *MEDCoupling1DGTUMesh::computeFetchedNodeIds() const { @@ -3075,7 +3075,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeFetchedNodeIds() const * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. - * \sa MEDCoupling1DGTUMesh::computeFetchedNodeIds + * \sa MEDCoupling1DGTUMesh::computeFetchedNodeIds, areAllNodesFetched */ DataArrayInt *MEDCoupling1DGTUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const { diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 0f6133b76..141154de3 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -1423,6 +1423,20 @@ DataArrayInt *MEDCouplingPointSet::zipConnectivityTraducer(int compType, int sta return ret.retn(); } +/*! + * This const method states if the nodal connectivity of this fetches all nodes in \a this. + * In other words, this method looks is there are no orphan nodes in \a this. + * \sa zipCoordsTraducer, getNodeIdsInUse, computeFetchedNodeIds. + */ +bool MEDCouplingPointSet::areAllNodesFetched() const +{ + checkFullyDefined(); + int nbNodes(getNumberOfNodes()); + std::vector fetchedNodes(nbNodes,false); + computeNodeIdsAlg(fetchedNodes); + return std::find(fetchedNodes.begin(),fetchedNodes.end(),false)==fetchedNodes.end(); +} + /*! * Checks if \a this and \a other meshes are geometrically equivalent, else an * exception is thrown. The meshes are diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 293f5d4fc..08281ec96 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -141,6 +141,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0; MEDCOUPLING_EXPORT virtual DataArrayInt *zipCoordsTraducer(); MEDCOUPLING_EXPORT virtual DataArrayInt *zipConnectivityTraducer(int compType, int startCellId=0); + MEDCOUPLING_EXPORT virtual bool areAllNodesFetched() const; //tools public: MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingPointSet *other, int cellId, double prec) const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 71819a0e2..3a38b65cc 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -1391,7 +1391,7 @@ void MEDCouplingUMesh::simplifyPolyhedra(double eps) * the format of returned DataArrayInt instance. * * \return a newly allocated DataArrayInt sorted ascendingly of fetched node ids. - * \sa MEDCouplingUMesh::getNodeIdsInUse + * \sa MEDCouplingUMesh::getNodeIdsInUse, areAllNodesFetched */ DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const { @@ -1421,7 +1421,7 @@ DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const /*! * \param [in,out] nodeIdsInUse an array of size typically equal to nbOfNodes. - * \sa MEDCouplingUMesh::getNodeIdsInUse + * \sa MEDCouplingUMesh::getNodeIdsInUse, areAllNodesFetched */ void MEDCouplingUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) const { @@ -1579,6 +1579,7 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. + * \sa areAllNodesFetched * * \if ENABLE_EXAMPLES * \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".
diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 61b4057a2..c6bc0d7d0 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -16418,6 +16418,17 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(m2D.getNodalConnectivity().isEqual(DataArrayInt([4,1,2,6,5,4,5,6,10,9]))) self.assertTrue(m2D.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10]))) pass + + def testPointSetAreAllNodesFetched1(self): + m=MEDCouplingCMesh() ; arr=DataArrayDouble(10) ; arr.iota() + m.setCoords(arr,arr) + m=m.buildUnstructured() + self.assertTrue(m.areAllNodesFetched()) + m2=m[[0,2,3,4,5]] + self.assertTrue(not m2.areAllNodesFetched()) + m2.zipCoords() + self.assertTrue(m2.areAllNodesFetched()) + pass pass if __name__ == '__main__': diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 0b365b818..6926805ae 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -1173,6 +1173,7 @@ namespace ParaMEDMEM virtual MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception); virtual DataArrayDouble *getBoundingBoxForBBTree(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception); virtual void renumberNodesWithOffsetInConn(int offset) throw(INTERP_KERNEL::Exception); + virtual bool areAllNodesFetched() const throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception)