Salome HOME
Addition of MEDCouplingPointSet::areAllNodesFetched() method. V7_6_0a1
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Apr 2015 06:47:24 +0000 (08:47 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Apr 2015 06:47:24 +0000 (08:47 +0200)
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingCommon.i

index d0596161be89548ca52c3d4abb1691d80402e8ef..343076dfd29a143f7a870ec64d7ac8fb8f1ff001 100644 (file)
@@ -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<double>& 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
 {
index 0f6133b76a0b4d2d84ccbd8e3c71186740253a9f..141154de3551ca92e3482e0a19f352371d063285 100644 (file)
@@ -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<bool> 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
index 293f5d4fc8c761311aa35f8724492107fe760144..08281ec962bf71b9b9407246b130f8aa545f4aff 100644 (file)
@@ -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;
index 71819a0e2c2be882124c95946e41f55b4e3b77a1..3a38b65ccb7a81baaf3bb05dc95fd462a071e4d0 100644 (file)
@@ -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<bool>& 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".<br>
index 61b4057a2984067c2c80d0c2309384e8f31558a6..c6bc0d7d085687dc7978453e9ae27eca387c7171 100644 (file)
@@ -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__':
index 0b365b818b1847fdc8ea1e21cc02aab36485c8cb..6926805aebff562030f0e6c9adf97c161ae4e017 100644 (file)
@@ -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)